I've got a map with a black mask for a two player co-op small squad tactical. Effectively the second player has been sent to rescue the first player's squad and complete their objectives.
Key Points:
-I'd like the players to NOT start with allied vision so they have to find each other.
-I'd like to trigger it so that when they're within each other's sight radius (or a short distance 3, whatever works) it then grants them permanent allied vision
-The Human players are 1 and 2
I've tried a few implementations trying to get it to function and I can't get the trigger to fire. I'm not super experienced with the Galaxy Editor and maybe I'm just dumb but this is what I came up with at current:
Events -
Unit - Any Unit Enters a distance of 3.0 from (Unit(Any Unit))
Local Variables -
Conditions -
(Owner of (Triggering Unit)) == 2
Actions -
Unit Group - Pick each unit in (Any units in (Region((Position of Triggering unit)), 3.0)) owned by player 1 matching Excluded: Missle, Dead, Hidden, with at most Any Amount) and do (Actions)
Actions -
General - If (Conditions then do (Actions) else do (Actions)
If
(Owner of (Picked unit)) == 1
Then
Player - Make all players in (Active Players) treat each other as Ally with Shared Vision
Trigger - Turn (Current Trigger) Off
Else
The Event will not fire when you convert a Preset into an Unit as third Parameter (tested it out).
Let's see, if there's an other event, that would work...
Edit:
Found nothing that would do the job, but you can use a hardcore (baaad) Variant:
Use a periodic Timer Event, that checks if Any Unit of Player 1 is in Range of Any Unit of Player 2...
Not pretty, but functional.
Yeah I just tested it out and the previous version with a little more robust checking and its not functioning, oh well I guess. Maybe the timer even could work tho, something better than nothing! Thanks everyone!
Would having the players neutral with each other and then setting them to allied when in range do that same job?
If so i'm sure you can use the same sort of script that changes a neutral shop into your own shop, to trigger allying of players. Maybe have a point/region or building that will do the trick? Just some ideas if you can't make the unit thing work.
Alternativly, maybe a targeted ability if all else fails, it would bypass the need for a check and make the players have something more to do than just find each other. It's not perfect but it should workas a last ditch effort.
Alternativly, maybe a targeted ability if all else fails, it would bypass the need for a check and make the players have something more to do than just find each other. It's not perfect but it should workas a last ditch effort.
The problem with setting them to neutral or anything like that isn't that their ally settings are hard to manipulate I just can't get a trigger to fire when ANY random infantry unit comes in range of ANY other infantry unit controlled by the other player. Setting up a unit with an useable ability might work but it seems kind of odd for cooperative play.
I could set it up to be specific units easily but that creates other problems all its own. XD
This may seem alittle silly, but it's another method that will work.
Unit Acquires Target
void TriggerAddEventUnitAcquiredTarget(unit u)
This event fires when a unit acquires a target. Use "Acquired Target" to get the target that was acquired. Use "Triggering Player" to get the owner of the unit that acquired a target. Use "Triggering Unit" to get the unit that acquired a target.
So as soon as two units come into contact they will target to attack each other, if you run an interupt script that automatically causes them to ally the second they target each other to attack, that should stop them from actually attacking. It's a viable if some what round the houses method.
Okay been looking at some of the commands, you could try a more inclsuive conditional statement to check for the entering unit script, something like(probably not owrded correctly):
If Unit - Unit (Owner of Unit == (Get Player Ally == True)) enters within 3.0 of Unit
Something like that... Don't have the editor on this PC so i'm flying blind so to speak. But a conditional statement that will check if an allied players unit has entered the area of any of your units. since it only checks for an allied state and not a number it simplifies it to a single condition.
Although I kind of like the idea to make them enemies and use acquiring targets could be a touch dangerous too, I'll have to try out the second method tho although I'm not quite sure how to build it it looks possible. I'll have to test it out when I'm more awake tho. XD Thanks! I know I've spent a good chunk of my time racking my brain before coming here <.<
Melee Initialization = Action - Player - Make player 1 and player 2 treat each other as Enemy
New Element = Event - Unit - Any Unit aquires a target
Conditions - (Owner of (Triggering Unit)) == 1
And
Conditions
(Owner of (Aquired Target)) == 2
Actions - Player - Make player 1 and player 2 treat each other as Ally With Shared Vision
New Element 2 = Event - Unit - Any Unit aquires a target
Conditions - (Owner of (Triggering Unit)) == 2
And
Conditions
(Owner of (Aquired Target)) == 1
Actions - Player - Make player 1 and player 2 treat each other as Ally With Shared Vision
It works, as far as I can tell when I tested it, I tried putting in an Or condition instead of having 2 Elements, but that seemed to break it.
Set Variable - Commando[1] = (Put the first unit that you want to meet here, if you're creating it via triggers put this after the action creating the unit and set it to last created unit)
Set Variable - Commando[2] = (Second meeting unit)
Player - Make (Owner of (Commando[1])) and (Owner of (Commando[2])) treat each other as Ally with shared vision disabled
Events -
Unit - Commando[1] Enters a distance of 3.0 from Commando[2]
Unit - Commando[2] Enters a distance of 3.0 from Commando[1]
Local Variables -
Conditions -
Actions -
Player - Make (Owner of (Commando[1])) and (Owner of (Commando[2])) treat each other as Ally with shared vision
Your trigger revamped.
This was made for two players
I think you'll find the problem here is the units that are supposed to meet are NOT preset, nor are they stationary. They could be any two randomly moving units on the map owned by either player. The way I've set mine up, when any of unit from one side or the other comes into contact one will try to attack the other, but as soon as they auto target to attack, it forces an allience with shared viewing.
(Put the first unit that you want to meet here, if you're creating it via triggers put this after the action creating the unit and set it to last created unit)
Just do that ^
But i see you've solved your problem, so nevermind.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I've got a map with a black mask for a two player co-op small squad tactical. Effectively the second player has been sent to rescue the first player's squad and complete their objectives.
Key Points:
-I'd like the players to NOT start with allied vision so they have to find each other.
-I'd like to trigger it so that when they're within each other's sight radius (or a short distance 3, whatever works) it then grants them permanent allied vision
-The Human players are 1 and 2
I've tried a few implementations trying to get it to function and I can't get the trigger to fire. I'm not super experienced with the Galaxy Editor and maybe I'm just dumb but this is what I came up with at current:
Events -
Unit - Any Unit Enters a distance of 3.0 from (Unit(Any Unit))
Local Variables -
Conditions -
(Owner of (Triggering Unit)) == 2
Actions -
Unit Group - Pick each unit in (Any units in (Region((Position of Triggering unit)), 3.0)) owned by player 1 matching Excluded: Missle, Dead, Hidden, with at most Any Amount) and do (Actions)
Actions -
General - If (Conditions then do (Actions) else do (Actions)
If
(Owner of (Picked unit)) == 1
Then
Player - Make all players in (Active Players) treat each other as Ally with Shared Vision
Trigger - Turn (Current Trigger) Off
Else
melee initialization = make player 1 and player 2 treat each other as allies (WITHOUT shared vision).
trigger 1- Any Unit Enters a distance of 3.0 from (Unit(Any Unit))
condition- or if owner of entering unit == 1 if owner of entering unit== 2
loc var- playerX
events-
if owner of entering unit == 2 set var playerX to 1
if owner of entering unit == 1 set var playerX to 2
if (number of units within 3 range of entering unit owned by (playerX) >= 1 then- make p1 and p2 treat each other as allies WITH shared vision
@zeldarules28: Go
Thanks I'll test it out now! I should have mentioned I did have allied vision turned off at initialization already too but checking if this works! brb
I'm curious, how do i get "Entering Unit" ??
The Event will not fire when you convert a Preset into an Unit as third Parameter (tested it out). Let's see, if there's an other event, that would work...
Edit:
Found nothing that would do the job, but you can use a hardcore (baaad) Variant:
Use a periodic Timer Event, that checks if Any Unit of Player 1 is in Range of Any Unit of Player 2...
Not pretty, but functional.
@Thenarden: Go
Yeah I just tested it out and the previous version with a little more robust checking and its not functioning, oh well I guess. Maybe the timer even could work tho, something better than nothing! Thanks everyone!
@Skoite: Go
I believe Triggering Unit works.
Would having the players neutral with each other and then setting them to allied when in range do that same job?
If so i'm sure you can use the same sort of script that changes a neutral shop into your own shop, to trigger allying of players. Maybe have a point/region or building that will do the trick? Just some ideas if you can't make the unit thing work.
Alternativly, maybe a targeted ability if all else fails, it would bypass the need for a check and make the players have something more to do than just find each other. It's not perfect but it should workas a last ditch effort.
A Selection event would do the same...
@PurpleFantum: Go
The problem with setting them to neutral or anything like that isn't that their ally settings are hard to manipulate I just can't get a trigger to fire when ANY random infantry unit comes in range of ANY other infantry unit controlled by the other player. Setting up a unit with an useable ability might work but it seems kind of odd for cooperative play.
I could set it up to be specific units easily but that creates other problems all its own. XD
This may seem alittle silly, but it's another method that will work.
Unit Acquires Target
void TriggerAddEventUnitAcquiredTarget(unit u)
This event fires when a unit acquires a target. Use "Acquired Target" to get the target that was acquired. Use "Triggering Player" to get the owner of the unit that acquired a target. Use "Triggering Unit" to get the unit that acquired a target.
So as soon as two units come into contact they will target to attack each other, if you run an interupt script that automatically causes them to ally the second they target each other to attack, that should stop them from actually attacking. It's a viable if some what round the houses method.
@PurpleFantum: Go
Okay been looking at some of the commands, you could try a more inclsuive conditional statement to check for the entering unit script, something like(probably not owrded correctly):
If Unit - Unit (Owner of Unit == (Get Player Ally == True)) enters within 3.0 of Unit
Something like that... Don't have the editor on this PC so i'm flying blind so to speak. But a conditional statement that will check if an allied players unit has entered the area of any of your units. since it only checks for an allied state and not a number it simplifies it to a single condition.
@PurpleFantum: Go
Although I kind of like the idea to make them enemies and use acquiring targets could be a touch dangerous too, I'll have to try out the second method tho although I'm not quite sure how to build it it looks possible. I'll have to test it out when I'm more awake tho. XD Thanks! I know I've spent a good chunk of my time racking my brain before coming here <.<
Melee Initialization = Action - Player - Make player 1 and player 2 treat each other as Enemy
New Element = Event - Unit - Any Unit aquires a target
Conditions - (Owner of (Triggering Unit)) == 1
And
Conditions
(Owner of (Aquired Target)) == 2
Actions - Player - Make player 1 and player 2 treat each other as Ally With Shared Vision
New Element 2 = Event - Unit - Any Unit aquires a target
Conditions - (Owner of (Triggering Unit)) == 2
And
Conditions
(Owner of (Aquired Target)) == 1
Actions - Player - Make player 1 and player 2 treat each other as Ally With Shared Vision
It works, as far as I can tell when I tested it, I tried putting in an Or condition instead of having 2 Elements, but that seemed to break it.
Events - Game time is 0.00
Actions -
Set Variable - Commando[1] = (Put the first unit that you want to meet here, if you're creating it via triggers put this after the action creating the unit and set it to last created unit)
Set Variable - Commando[2] = (Second meeting unit)
Player - Make (Owner of (Commando[1])) and (Owner of (Commando[2])) treat each other as Ally with shared vision disabled
Events - Unit - Commando[1] Enters a distance of 3.0 from Commando[2] Unit - Commando[2] Enters a distance of 3.0 from Commando[1]
Local Variables -
Conditions -
Actions -
Player - Make (Owner of (Commando[1])) and (Owner of (Commando[2])) treat each other as Ally with shared vision
Your trigger revamped. This was made for two players
@obliviron: Go
I think you'll find the problem here is the units that are supposed to meet are NOT preset, nor are they stationary. They could be any two randomly moving units on the map owned by either player. The way I've set mine up, when any of unit from one side or the other comes into contact one will try to attack the other, but as soon as they auto target to attack, it forces an allience with shared viewing.
(Put the first unit that you want to meet here, if you're creating it via triggers put this after the action creating the unit and set it to last created unit) Just do that ^
But i see you've solved your problem, so nevermind.