• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Wait Several Seconds to Fire the Trigger once more

Status
Not open for further replies.
Level 4
Joined
Sep 15, 2013
Messages
53
So I have a system that will play a special effect once a unit was killed..
How do i do it in jass so that it if an event will happen again it wont trigger the action but will trigger again after several seconds? Also I want it so that multiple units can do this. Thanks!
 
I interpret you question as: Give an action an unit specific cooldown.
One could start a timer when the action runs, save it onto the unit using "unit indexer" or hash (unit indexer is proably better).
Inser a filter, blocking any executions as long the remaining time of the killer's cooldown is bigger then 0.
JASS:
TriggerRegisterPlayerUnitEvent takes trigger whichTrigger, player whichPlayer, playerunitevent whichPlayerUnitEvent, boolexpr filter
inside this filter one can with GetFilterUnit() access the killing unit, if the filter returns false the trigger will not evalute nor execute.

There is also the option to use unit specific dynamic Triggers which you execute/evalute on an event, but for kill events this might proably not be worth it. This unit specific dynamic Tiggers have the advantage that always only the current relevant code is executed which takes away the need of filters.

On execution start a timer for the unit, when the trigger reprocs and the timer is still running do not do the action instead start a timer executing an alternative version after a delay (one would need to attach data to the timer killer killed etc).
Edit: For simply displaying a special effect you could also just use a wait + locals instead of a timer.

JASS:
native TimerStart takes timer whichTimer, real timeout, boolean periodic, code handlerFunc returns nothing
 
Last edited:
Level 4
Joined
Sep 15, 2013
Messages
53
  • Untitled Trigger 001
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Killing unit) Equal to Tiny 0001 <gen>
        • Then - Actions
          • Special Effect - Create a special effect attached to the overhead of (Killing unit) using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
          • Special Effect - Destroy (Last created special effect)
          • Trigger - Turn off (This trigger)
          • Wait 6.00 game-time seconds
          • Trigger - Turn on (This trigger)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Killing unit) Equal to Monkey King 0004 <gen>
        • Then - Actions
          • Special Effect - Create a special effect attached to the overhead of (Killing unit) using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
          • Special Effect - Destroy (Last created special effect)
          • Trigger - Turn off (This trigger)
          • Wait 6.00 game-time seconds
          • Trigger - Turn on (This trigger)
        • Else - Actions
It should look like this. But i want so that it can be used by every killing unit? Any suggetions?
 
Last edited:
Dat is GUI.
Jass is that written code.
And you want a Cooldown, my first apporach was right :).

Get Unit Indexer (if you haven't yet), on Index create a Timer for that Unit, on DeIndex destroy it.
When an unit kills start its kill timer for the wanted amount of time, if it kills but the killCooldown still is running reject the actions.
Could look Like this:
  • Index
    • Events
      • Game - UnitIndexEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • Custom script: set udg_KillCooldown[udg_UDex] = CreateTimer()
  • DeIndex
    • Events
      • Game - UnitIndexEvent becomes Equal to 2.00
    • Conditions
    • Actions
      • Custom script: call DestroyTimer( udg_KillCooldown[udg_UDex])
  • Kill
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Remaining time for KillCooldown[(Custom value of (Killing unit))]) Less than or equal to 0.00
    • Actions
      • Special Effect - Create a special effect attached to the overhead of (Killing unit) using Abilities\Spells\Undead\OrbOfDeath\OrbOfDeathMissile.mdl
      • Special Effect - Destroy (Last created special effect)
      • Countdown Timer - Start KillCooldown[(Custom value of (Killing unit))] as a One-shot timer that will expire in 6.00 seconds
Edit: If the displayed effect or cooldown should differ you could inser new variables, either on UDex to be unit specific or map UnitType <-> data.
 
Last edited:
Status
Not open for further replies.
Top