• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

Trigger unit

Status
Not open for further replies.
Level 2
Joined
Sep 1, 2005
Messages
9
I have a trigger that creates a unit for my warlock from WoW that makes it create a Doomguard. How do i put a timer on how long the doomguard lasts?
 
Level 2
Joined
Mar 5, 2006
Messages
16
in the same trigger make an action that starts a timer using a global timer variable. Also create a global unit variable and then replace the action that creates the doomguard with a set variable and set the unit variable to create unit doomguard, so that you can refer to that doomguard later.

Then create another trigger with the event that the timer you started when you created doom guard expires, and have the action as unit - destroy or something like that and for which unit choose your global unit variable which is holding your doomguard. Then when the timer expires the doomguard dissappears. Or you could use unit - kill, and maybe even throw in a special effect at unit position using your unit variable, just for fun.

i think there is a better way to do this with local variables using JASS. Using local variables would allow you to have any amount of doomguards and doomguard timers running at the same time. But im not sure how to do that. Try searching local variable linking in the forums under JASS.
 
Level 6
Joined
Feb 18, 2005
Messages
263
there are several ways to do this.

1. Expiration timer
if you simply want the doomguard to die if the time expires, then i would recomend adding an expiration timer with the time you want to it.
You can't get the remaining time, but sa long as you don't want that, everything is fine and btw it's nearly the fastest possible way.

2. Timer
Another way would be to start a timer, that expires after thje time you want it.
You'd need to start the timer when you spawn the doomguard and you need a trigger like
event - timer expires
action - kill doomguard
this way you can get the remaining time, but the amount of doomguards you can have is limited by the number of timers you use. you can reuse a timer but can't use it more than once at a time.
So if you only want one doomguard an want to do some special things if he grows 'older' this would be one of the, if not the, best way.

wait trigger
alternativley to creating a timer you could simply tell your trigger to wait some time and then continue.
the mayor disadvantage of this method is, that unless it's custom code, the function will be canceld if it's event triggers while the function has not finished.
I do not recoment this method outside custom script and inside it it's no nice, but sometimes a very effectiv (but slow) way to do timed things


hope this helps you

- Raszul[/b]
 
Status
Not open for further replies.
Top