Staredit Network > Forums > SC2 Assistance > Topic: Starting a Timer
Starting a Timer
Aug 16 2010, 7:44 pm
By: JACofNoIdea  

Aug 16 2010, 7:44 pm JACofNoIdea Post #1



I'm trying to make a 1 minute timer that activates when any unit walks within a certain distance of a point. I'm not sure what I'm doing wrong in the trigger menu. I have it set up like this:

Events
... Unit - Any Unit Enters within 1.0 of <point>
Local Variables
Conditions
... (Owner of (Triggering Unit)) == 1
Actions
... Timer - Start (New Timer) as a One Shot timer that will expire in 60.0 Game Time seconds
... Timer - Create a timer window for (Last started timer), with the title "blah", using Remaining time (initially hidden)
... Timer - Set timer for (Last created timer window) to (Last started timer)
... Timer - Show (Last created timer window) for (All players)

The timer will initially be visible on game load unless I have that condition in there. I don't think it should be needed and I think it makes the trigger locked out to other players. When a unit does activate the trigger, a new timer window appears, but the time is at 0. Oh, and as a note (it probably is apparent from the above text) I don't really know what I'm doing. Just started messing around with the map editor. Help is much appreciated!

Thanks

Post has been edited 1 time(s), last time on Aug 16 2010, 8:01 pm by JACofNoIdea.



None.

Aug 16 2010, 8:19 pm shmeeps Post #2



The time error may have to do with excessive use of "Last Created...". When it comes to things like these that are persistent (IE, will still exist after the trigger finishes), you should always use variables.

On the left panel, right click and create a new variable called TimerVariable (Hotkey is Ctrl+B), and change it's type (Via the drop down box in the main screen) from "Integer" to "Timer". Make a second one called TimerWindowVariable, and change it's type from "Integer" to "Timer Window". These will store the timer's value and it's window, respectively.

Now, change your trigger to something like this:

Code
   Events
       Unit - Any Unit Enters within 1.0 of Point
   Local Variables
   Conditions
   Actions
       Timer - Start TimerVariable as a One Shot timer that will expire in 60.0 Game Time seconds
       Timer - Create a timer window for TimerVariable, with the title "Blah!", using Remaining time (initially Visible)
       Variable - Set TimerWindowVariable = (Last created timer window)
       Timer - Show TimerWindowVariable for (All players)


Make sure you specify a point as well. A null point (one that isn't specified or doesn't exist), will not ever make the trigger run.

Let us know how that works.



None.

Aug 16 2010, 8:40 pm JACofNoIdea Post #3



Thanks for the help, but there is one small issue >_<.

A new timer shows up, counting down from 1 minute, when a unit enters the set points range. So that works.

The issue is a timer is visible initially, counting down from 1 minute, without any activation, upon game load. When a unit enters the trigger, a new timer is added on (so 2 are running).

Ultimately, I'm using the timer so that if a unit enters a point, a timer will show up counting down 1 minute. If the unit leaves the point range, the timer will disappear and reset. If someone then re-enters the point, the timer will start up again from 1 minute (king of the hill type situation). I'll also have to figure out how to have only 1 active at a time (say, for example, if you have 2 units enter the point or 2 different players on the point). Then I have to add in a bunch of other things when the timer hits zero, but that will be an issue for another day lol.

Will the current setup allow for it to be reused later on or is that only for a 1 time use?



None.

Aug 16 2010, 8:45 pm shmeeps Post #4



The trigger I gave you can be re-used or set to be run only once. Right now though, it won't work either way significantly well. But it can be modified very easily either way.

Let me make sure I understand before I try to give you an answer. You have one timer that runs on start up for one minute, and then is removed? And you want to have a second timer that can run along side of it, or do you wish for these to be combined into one timer, where it just resets any time as needed?

Or is that timer just opening unexpectedly at the beginning of the map?



None.

Aug 16 2010, 8:49 pm JACofNoIdea Post #5



It's just opening unexpedtedly at game load. I only want the timer to show up when a unit enters the designated point.

Also, I made some small clarifications to the last post, idk which version you read before a refresh or w/e. Might want to reread that.



None.

Aug 16 2010, 9:04 pm shmeeps Post #6



Okay, then something like this should work, which must be expanded to two triggers. You must also create a new variable called UnitGroupVariable, of type Unit Group:

Code
TimerStart
   Events
       Unit - Any Unit Enters within 1.0 of Point
   Local Variables
   Conditions
   Actions
       Unit Group - Add (Triggering unit) to UnitGroupVariable
       Timer - Start TimerVariable as a One Shot timer that will expire in 60.0 Game Time seconds
       Timer - Create a timer window for TimerVariable, with the title "Blah!", using Remaining time (initially Visible)
       Variable - Set TimerWindowVariable = (Last created timer window)
       Timer - Show TimerWindowVariable for (All players)
       Trigger - Turn (Current trigger) Off
       Trigger - Turn TimerStop On


Code
TimerStop
   Events
       Unit - Any Unit Leaves within 1.0 of Point
   Local Variables
   Conditions
   Actions
       Unit Group - Remove (Triggering unit) from UnitGroupVariable
       General - If (Conditions) then do (Actions) else do (Actions)
           If
               (Number of Living units in (Units in UnitGroupVariable within (Playable map area), with at most Any Amount)) == 0
           Then
               Timer - Hide TimerWindowVariable for (All players)
               Timer - Destroy TimerWindowVariable
               Timer - Pause TimerVariable
               Trigger - Turn (Current trigger) Off
               Trigger - Turn TimerStart On
           Else


This will make it so that if a unit enters the point, it will start the timer, and disable the trigger (to stop the timer from starting again, hopefully.), and enable the trigger that allows the timer to turn off. If a unit then leaves the point, it will count the number of units in the group, and if there are none, it will reset the timer and hide it. Give me a few minutes and I can upload a demonstration map.

Attachments:
King Of The Hill.SC2Map
Hits: 2 Size: 26.23kb

Post has been edited 2 time(s), last time on Aug 16 2010, 9:31 pm by shmeeps.



None.

Aug 16 2010, 9:19 pm JACofNoIdea Post #7



Thank you for the help!

It works on your map, but doesn't seem to on mine. For me, the timer is still loading right from the start. I just copy pasted the code for timerstart and stop (making sure all variables and whatnot applied to mine). I'm going to look for any differences or areas that might make mine not work. It might actually just be because I have a beacon there. I'll try removing that too

Post has been edited 2 time(s), last time on Aug 16 2010, 9:30 pm by JACofNoIdea.



None.

Aug 16 2010, 9:31 pm shmeeps Post #8



Yeah, a beacon will count as a unit. If you can't figure it out just let us know, if nothing else you can post your map and we can take a look to see if we notice anything. I also updated my posted map just a bit, to make it a bit less prone to error. It should work either way though.



None.

Aug 16 2010, 9:32 pm JACofNoIdea Post #9



Yeah, it was the beacon lol. I was thinking "unit" applied to, well, units...not objects too. Thank you, it works now :D



None.

Aug 16 2010, 9:35 pm shmeeps Post #10



Yeah, it a little silly, but beacons, and a few other objects are flagged as units, I guess they need it to be that way to run correctly.

Also make sure to copy over the "Remove on Death" Trigger. A unit that is killed wont be automatically removed from the unit group, and can still be counted in calculations in some circumstances. It will also help make the map run a little smoother, as the unit group will stay relatively constant in size, instead of just growing.



None.

Aug 16 2010, 9:41 pm JACofNoIdea Post #11



Added that on (missed it before). Thanks.



None.

Aug 17 2010, 2:27 am deathfromace Post #12



Seems he got his answer and so I don't make a new thread I will post my timer problem here.

Quote
paralyze
Events
Unit - Any Unit takes Non-Fatal Ranged damage (from Hydralisk - Needle Spines (Damage) effects)
Local Variables
Conditions
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Zealot [240.50, 209.50] has paralyze) == false
Then
Unit - Add 1 paralyze to Zealot [240.50, 209.50] from player 15
Unit - Set paralyze duration to 3 on unit Zealot [240.50, 209.50]
Else
Trigger - Pause the action queue
Timer - Start timervar as a Repeating timer that will expire in 8.0 Game Time seconds
Trigger - Unpause the action queue

I attempted to use the timevar suggestion that I read above. All I want to happen is if the target is already paralyzed it does nothing waits for the time then does it again. But with this all it does it keep paralyzing every 3 seconds.



None.

Aug 17 2010, 4:01 am shmeeps Post #13



Are you trying to make it so it can only paralyze once every 8 seconds? Try this instead:

Code
paralyze
Events
   Unit - Any Unit takes Non-Fatal Ranged damage (from Hydralisk - Needle Spines (Damage) effects)
Local Variables
Conditions
Actions
   General - If (Conditions) then do (Actions) else do (Actions)
       If
           (Zealot [240.50, 209.50] has paralyze) == false
       Then
           Unit - Add 1 paralyze to Zealot [240.50, 209.50] from player 15
           Unit - Set paralyze duration to 3 on unit Zealot [240.50, 209.50]
       Else
           Timer - Start timervar as a One-Shot timer that will expire in 8.0 Game Time seconds
           Trigger - Stop all instances of (Current trigger)
           Trigger - Turn (Current trigger) Off


and the second trigger:

Code
paralyze timer
Events
       Timer - timervar expires
Local Variables
Conditions
Actions
       Trigger - Turn paralyze On




None.

Aug 17 2010, 5:47 am deathfromace Post #14



That works, thank you once again.



None.

Aug 17 2010, 5:49 am shmeeps Post #15



Not a problem, let us know if you need anything else.



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[07:46 am]
RIVE -- :wob:
[2024-4-22. : 6:48 pm]
Ultraviolet -- :wob:
[2024-4-21. : 1:32 pm]
Oh_Man -- I will
[2024-4-20. : 11:29 pm]
Zoan -- Oh_Man
Oh_Man shouted: yeah i'm tryin to go through all the greatest hits and get the runs up on youtube so my senile ass can appreciate them more readily
You should do my Delirus map too; it's a little cocky to say but I still think it's actually just a good game lol
[2024-4-20. : 8:20 pm]
Ultraviolet -- Goons were functioning like stalkers, I think a valk was made into a banshee, all sorts of cool shit
[2024-4-20. : 8:20 pm]
Ultraviolet -- Oh wait, no I saw something else. It was more melee style, and guys were doing warpgate shit and morphing lings into banelings (Infested terran graphics)
[2024-4-20. : 8:18 pm]
Ultraviolet -- Oh_Man
Oh_Man shouted: lol SC2 in SC1: https://youtu.be/pChWu_eRQZI
oh ya I saw that when Armo posted it on Discord, pretty crazy
[2024-4-20. : 8:09 pm]
Vrael -- thats less than half of what I thought I'd need, better figure out how to open SCMDraft on windows 11
[2024-4-20. : 8:09 pm]
Vrael -- woo baby talk about a time crunch
[2024-4-20. : 8:08 pm]
Vrael -- Oh_Man
Oh_Man shouted: yeah i'm tryin to go through all the greatest hits and get the runs up on youtube so my senile ass can appreciate them more readily
so that gives me approximately 27 more years to finish tenebrous before you get to it?
Please log in to shout.


Members Online: C(a)HeK, Dem0n, No-Name-Needed-II, Tableguy