HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Capture + Hold region for # sec?

08-18-2010, 08:58 PM#1
galinth
I am trying to make a trigger that... when you have a unit enter a region, and stay within that region for "#" seconds (countdown timer), "A" actions occur when timer expires. If that unit leaves the region, the countdown timer is reset / wiped.

I am making a "neutral building" in the middle of the map that is capturable by 2 players against each other. I am mostly confused about the "timer only ticks when unit STAYS in the region" part. Can someone please show me a simple setup (GUI)? Please help!
08-18-2010, 10:51 PM#2
DioD
post your own code (did you try it self?)
08-20-2010, 12:21 AM#3
galinth
right now i am using 2 triggers to attempt to do it, but i can't find out how to.. stop+reset timer if the unit capturing leaves the region.


* Here is trigger #1 with the timer*

Trigger:
Capture Ground
Collapse Events
Unit - A unit enters Capture Spot <gen>
Collapse Conditions
(Owner of (Triggering unit)) Equal to Player 1 (Red)
Collapse Actions
Collapse Player Group - Pick every player in Player Group - Player 1 (Red) and do (Actions)
Collapse Loop - Actions
Countdown Timer - Start CAPtimer as a One-shot timer that will expire in 10.00 seconds
Countdown Timer - Create a timer window for CAPtimer with title "Capturing"
Trigger - Turn off (This trigger)


* Here is trigger #2 with results*

Trigger:
Capture Spawn
Collapse Events
Time - CAPtimer expires
Conditions
Collapse Actions
Collapse Player Group - Pick every player in Player Group - Player 1 (Red) and do (Actions)
Collapse Loop - Actions
Countdown Timer - Destroy (Last created timer window)
Unit - Create 1 Watch Tower for Player 1 (Red) at (Center of Tower Spawn <gen>) facing Default building facing degrees
08-20-2010, 02:53 PM#4
0zyx0
There's an event that fires when a unit leaves a region. Make a trigger that is fired by that, and pause CAPtimer when that happens. Don't bother destroying it. It works fine to just start the timer again from a paused state (it will be just as if you've never used the timer before).
08-20-2010, 10:16 PM#5
galinth
Quote:
Originally Posted by 0zyx0
There's an event that fires when a unit leaves a region. Make a trigger that is fired by that, and pause CAPtimer when that happens. Don't bother destroying it. It works fine to just start the timer again from a paused state (it will be just as if you've never used the timer before).


oooooh ok, yeah i saw pause, but i didn't know that it works as a reset also, ill try it out now. ty
08-20-2010, 10:56 PM#6
galinth
Cool this basic trigger did the trick, thanks again for the help! (figured id post it just in case for other nubs like myself)

Trigger:
Timer Wipe
Collapse Events
Unit - A unit leaves Capture Spot <gen>
Collapse Conditions
(Owner of (Triggering unit)) Equal to Player 1 (Red)
Collapse Actions
Countdown Timer - Pause CAPtimer
Countdown Timer - Destroy (Last created timer window)
08-21-2010, 01:13 AM#7
Anitarf
It won't work correctly if a player can control multiple units. In that case, you would need a unit group to keep track of all the units in the region and only pause the timer once the last of them leaves.

You'd probably also want to keep track of capturing units dying and remove them from the group in those cases as well.

Furthermore, a unit from the other team entering the arena should also pause the timer.
08-22-2010, 08:57 PM#8
galinth
Quote:
Originally Posted by Anitarf
It won't work correctly if a player can control multiple units. In that case, you would need a unit group to keep track of all the units in the region and only pause the timer once the last of them leaves.

You'd probably also want to keep track of capturing units dying and remove them from the group in those cases as well.

Furthermore, a unit from the other team entering the arena should also pause the timer.


Ah I see what you are saying, actually I made the region smallest possible (literally only 1 unit can fit on it) and the 2 teams vying for it have no air units. I set up a sequence of switches that turn on / off triggers for each side, with their own timers, depending on who occupies the captured area