One way would be to apply each unit a specific behavior on entering the region, removing it when the unit leaves. The behavior triggers an effect after some time which could then be used as an event for the trigger.
This would also allow you to display the time left on each unit.
There is no specific event exactly what your looking for. You will need to just use a regular unit enters event and then run a while loop that then counts how long the unit is in th region that leads mostly like to an if then.
Enter Region
Events
Unit - Any Unit Enters Selected Region
Local Variables
Conditions
(Owner of (Triggering unit)) != Region Owner
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
( Region Win Timer is paused) == True
Then
Timer - Unpause Region Win Timer
Else
General - If (Conditions) then do (Actions) else do (Actions)
If
(Number of Living units in (Any units in Selected Region owned by player (Owner of (Triggering unit)) matching Excluded: Missile, Dead, Hidden, with at most Any Amount)) > (Number of Living units in (Any units in Selected Region owned by player Region Owner matching Excluded: Missile, Dead, Hidden, with at most Any Amount))
Then
Variable - Set Region Owner = (Owner of (Triggering unit))
Timer - Restart Region Win Timer
Else
Variable : Region Win Timer = (New timer) <Timer>
Variable : Selected Region = 0 <Integer>
just going to point out for mine he can cause thing to happen at different amounts of time the unit has stayed in the region, by simply adding more if then statements.
It seems that using a custom value for each unit would be the simplest approach. Just run a loop that picks each unit in the region and increments its custom value by 1 per loop.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
What's a good way to do this? I want an action to trigger if a unit stays in a region for a specified amount of time without leaving
<Click Here> To See My Epic Single Player Campaign (LifeForceCampaign.com)
One way would be to apply each unit a specific behavior on entering the region, removing it when the unit leaves. The behavior triggers an effect after some time which could then be used as an event for the trigger.
This would also allow you to display the time left on each unit.
@Sanktoras: Go
Pretty good idea. I would prefer a trigger-only solution but I will fall back on this if I can't figure anything else out. Thanks.
<Click Here> To See My Epic Single Player Campaign (LifeForceCampaign.com)
There is no specific event exactly what your looking for. You will need to just use a regular unit enters event and then run a while loop that then counts how long the unit is in th region that leads mostly like to an if then.
local var: x = 0 <integer>
event: unit enters region
action: while
condition: unit is in region
action:
if x > 60
then: do something
else: do nothing
modify x +1
wait 1 gametime second
Still alive and kicking, just busy.
My guide to the trigger editor (still a work in progress)
Enter Region
Events
Unit - Any Unit Enters Selected Region
Local Variables
Conditions
(Owner of (Triggering unit)) != Region Owner
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
( Region Win Timer is paused) == True
Then
Timer - Unpause Region Win Timer
Else
General - If (Conditions) then do (Actions) else do (Actions)
If
(Number of Living units in (Any units in Selected Region owned by player (Owner of (Triggering unit)) matching Excluded: Missile, Dead, Hidden, with at most Any Amount)) > (Number of Living units in (Any units in Selected Region owned by player Region Owner matching Excluded: Missile, Dead, Hidden, with at most Any Amount))
Then
Variable - Set Region Owner = (Owner of (Triggering unit))
Timer - Restart Region Win Timer
Else
Variable : Region Win Timer = (New timer) <Timer>
Variable : Selected Region = 0 <Integer>
An example used from our map. This should help you with your question though. This is how we did it.
@iMisu: Go
Rad. Thanks a lot.
<Click Here> To See My Epic Single Player Campaign (LifeForceCampaign.com)
Example map on next post
using timers will work but making it work dynamically with any and all units it takes a little finesse.
Misu's example is half way there but it is using global timer variables.
@Bilxor: Go
Heres the example .... its about as good as it gets....for pure trigger and not galaxy script
just going to point out for mine he can cause thing to happen at different amounts of time the unit has stayed in the region, by simply adding more if then statements.
Still alive and kicking, just busy.
My guide to the trigger editor (still a work in progress)
It seems that using a custom value for each unit would be the simplest approach. Just run a loop that picks each unit in the region and increments its custom value by 1 per loop.