• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Fixing/Adding CoolDown to a ability

Status
Not open for further replies.
Level 8
Joined
Apr 8, 2009
Messages
499
I triggered a sort of "blink strike" spell, and have problems with the Cooldown on the ability.

basic ability used is "Finger of Death (Archimonde)", used as "Flash"

For some reason, when i cast this spell it doesn't get any Cooldown time. although it should have a Cooldown of 30.
can anyone help me on this?
Also, i'm not sure if i made it leakless correctly so if anyone could check.....

+rep to anyone who helps.


  • Flash I
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Flash [Tier 1]
    • Actions
      • Wait 0.00 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Casting unit) has buff Stealth ) Equal to True
        • Then - Actions
          • Set Temp_Flash_Loc[(Player number of (Owner of (Triggering unit)))] = (Position of (Target unit of ability being cast))
          • Set CasterLoc[(Player number of (Owner of (Triggering unit)))] = (Position of (Casting unit))
          • Set Temp_Flash_Tar[(Player number of (Owner of (Casting unit)))] = (Target unit of ability being cast)
          • Special Effect - Create a special effect at CasterLoc[(Player number of (Owner of (Triggering unit)))] using Abilities\Spells\Orc\MirrorImage\MirrorImageCaster.mdl
          • Special Effect - Destroy (Last created special effect)
          • Custom script: call RemoveLocation(udg_CasterLoc)
          • Unit - Move (Triggering unit) instantly to Temp_Flash_Loc[(Player number of (Owner of (Triggering unit)))], facing (Position of Temp_Flash_Tar[(Player number of (Owner of (Casting unit)))])
          • Set CasterLoc[(Player number of (Owner of (Triggering unit)))] = (Position of (Casting unit))
          • Special Effect - Create a special effect at CasterLoc[(Player number of (Owner of (Triggering unit)))] using Abilities\Spells\Orc\MirrorImage\MirrorImageCaster.mdl
          • Special Effect - Destroy (Last created special effect)
          • Custom script: call RemoveLocation(udg_CasterLoc)
          • Unit - Remove Stealth from (Casting unit)
          • Unit - Set (Casting unit) movement speed to (Default movement speed of (Casting unit))
          • Unit - Order (Casting unit) to Night Elf Demon Hunter - Deactivate Immolation
          • Unit - Cause (Casting unit) to damage Temp_Flash_Tar[(Player number of (Owner of (Casting unit)))], dealing ((Real((Level of Flash [Tier 1] for (Casting unit)))) x 50.00) damage of attack type Spells and damage type Normal
          • Unit - Create 1 Flash_Stun I dummy [Tier 1] for (Owner of (Casting unit)) at (Position of Temp_Flash_Tar[(Player number of (Owner of (Casting unit)))]) facing Default building facing degrees
          • Unit - Add a 0.50 second Generic expiration timer to (Last created unit)
          • Unit - Order (Last created unit) to Human Mountain King - Storm Bolt Temp_Flash_Tar[(Player number of (Owner of (Casting unit)))]
        • Else - Actions
          • Set Temp_Flash_Loc[(Player number of (Owner of (Triggering unit)))] = (Position of (Target unit of ability being cast))
          • Set Temp_Flash_Tar[(Player number of (Owner of (Casting unit)))] = (Target unit of ability being cast)
          • Set CasterLoc[(Player number of (Owner of (Triggering unit)))] = (Position of (Casting unit))
          • Special Effect - Create a special effect at CasterLoc[(Player number of (Owner of (Triggering unit)))] using Abilities\Spells\Orc\MirrorImage\MirrorImageCaster.mdl
          • Special Effect - Destroy (Last created special effect)
          • Custom script: call RemoveLocation(udg_CasterLoc)
          • Unit - Move (Triggering unit) instantly to Temp_Flash_Loc[(Player number of (Owner of (Triggering unit)))], facing (Position of Temp_Flash_Tar[(Player number of (Owner of (Casting unit)))])
          • Set CasterLoc[(Player number of (Owner of (Triggering unit)))] = (Position of (Casting unit))
          • Special Effect - Create a special effect at (Position of (Triggering unit)) using Abilities\Spells\Orc\MirrorImage\MirrorImageCaster.mdl
          • Special Effect - Destroy (Last created special effect)
          • Custom script: call RemoveLocation(udg_CasterLoc)
          • Unit - Cause (Casting unit) to damage Temp_Flash_Tar[(Player number of (Owner of (Casting unit)))], dealing ((Real((Level of Flash [Tier 1] for (Casting unit)))) x 10.00) damage of attack type Spells and damage type Normal
 
Last edited:
Level 19
Joined
Feb 4, 2009
Messages
1,313
how do i fix that?

make the event "unit starts effect of ability"
there also is another bug with "unit begins casting"
you can order the unit to cast and stop immediactly
so you will get the spell effect but no cooldown
because "move unit" makes the unit stop you can see this bug but it can also be abused manually
 
Level 8
Joined
Apr 8, 2009
Messages
499
make the event "unit starts effect of ability"
there also is another bug with "unit begins casting"
you can order the unit to cast and stop immediactly
so you will get the spell effect but no cooldown
because "move unit" makes the unit stop you can see this bug but it can also be abused manually

tried this before, didn't work then.
Tried again just now, spell still works, but no Cooldown is given to the cast ability.

Try making blink require a unit target

tried that once before, doesn't work at all, even if you set a unit as targetable with regular blink, you can stil only cast it on terrain.
.... or maybe i missed up big time. but i'm pretty sure i haven't.
 
The event "starts the effect" is the best for making triggered spells : it fires just after the cast point but before the casting time (there's no event that fires right after the casting time). The usual chronology of a spell is something like this :

1) The unit begins to cast*
2) Wait for unit's casting point
3) Mana is used
4) The unit starts the effect (trigger)*
5) Wait for spell's casting time
6) The unit starts the effect (spell)
7) Cooldown is started
8) Wait for unit's casting backswing
9) The unit ends the ability*

EDIT : After doing more tests, I conclued that I can't see any "usual" chronology. This is the chronology of Finger Of Death but each ability has its own chronology and I can't take out one which is shared by a lot of abilities.
The * shows when trigger events are. When you move you unit (or when you order him to stop), you just stop the execution of the spell. There can be several effects depending on how you stop the execution of the spell (eg. if you pause/unpause the unit while he starts the effect, it causes bug). Channeling spells and some immediate spells (like Blink or Divine shield) are slightly differents.

So, all that to say that you have 2 choices :
- You can wait 0.00 seconds after the unit starts the effect (but "Target unit of ability being cast" can bug after a wait),
- You use the jass functions "SetUnitX/Y" which don't order your unit to stop.
JASS:
call SetUnitX(GetTriggerUnit(),GetUnitX(GetSpellTargetUnit())-75*CosBJ(GetUnitFacing(GetTriggerUnit())))
call SetUnitY(GetTriggerUnit(),GetUnitY(GetSpellTargetUnit())-75*SinBJ(GetUnitFacing(GetTriggerUnit())))

Sorry big post but I made some tests and I wanted to write it down ^^. Also, I have not the english WE but I figure my events' translation are understandable.
 
Last edited:
Level 8
Joined
Apr 8, 2009
Messages
499
The event "starts the effect" is the best for making triggered spells : it fires just after the cast point but before the casting time (there's no event that fires right after the casting time). The usual chronology of a spell is something like this :

1) The unit begins to cast*
2) Wait for unit's casting point
3) Mana is used
4) The unit starts the effect (trigger)*
5) Wait for spell's casting time
6) The unit starts the effect (spell)
7) Cooldown is started
8) Wait for unit's casting backswing
9) The unit ends the ability*

The * shows when trigger events are. When you move you unit (or when you order him to stop), you just stop the execution of the spell. There can be several effects depending on how you stop the execution of the spell (eg. if you pause/unpause the unit while he starts the effect, it causes bug). Channeling spells and some immediate spells (like Blink or Divine shield) are slightly differents.

So, all that to say that you have 2 choices :
- You can wait 0.00 seconds after the unit starts the effect (but "Target unit of ability being cast" can bug after a wait),
- You use the jass functions "SetUnitX/Y" which don't order your unit to stop.
JASS:
call SetUnitX(GetTriggerUnit(),GetUnitX(GetSpellTargetUnit())-75*CosBJ(GetUnitFacing(GetTriggerUnit())))
call SetUnitY(GetTriggerUnit(),GetUnitY(GetSpellTargetUnit())-75*SinBJ(GetUnitFacing(GetTriggerUnit())))

Sorry big post but I made some tests and I wanted to write it down ^^. Also, I have not the english WE but I figure my events' translation are understandable.

gonna see if it works, i've never used Jass before so i dont really know hot to implant that..... should i enter it as custom script?

------------------------------
EDIT:
Put:

  • Wait 0.00 seconds
before the effects, works like you said it would. +rep.

now a last chance for ppl to get rep, help me make this leak-less? ^__^
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Test map attached
If you have any question regarding the test map, feel free to ask me =D

LEAKS
You didn't clean Special Effects leak
Put this action RIGHT AFTER YOU CREATE a Special Effect:
  • Special Effect - Destroy (Last created special effect)
Point leak
You must set Caster Location first:
  • Set CasterLoc = (Position of (Triggering unit))
Then use it in here:
  • Special Effect - Create a special effect at CasterLoc using Abilities\Spells\Orc\MirrorImage\MirrorImageCaster.mdl
Then destroy it by using this action:
  • Custom script: call RemoveLocation(udg_CasterLoc)
Unit leak
After you use this action:
  • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
You must clean the unit by using this:
  • Unit - Add a 0.50 second Generic expiration timer to (Last created unit)
 

Attachments

  • Blink Strike Cooldown.w3x
    13 KB · Views: 54
Level 8
Joined
Apr 8, 2009
Messages
499
GetX/Y has no leaks. Only points leak.

  • Set Temp_Flash_Loc[(Player number of (Owner of (Triggering unit)))] = (Position of (Target unit of ability being cast))
thats a point right?

Test map attached
If you have any question regarding the test map, feel free to ask me =D

LEAKS
You didn't clean Special Effects leak
Put this action RIGHT AFTER YOU CREATE a Special Effect:
  • Special Effect - Destroy (Last created special effect)
Point leak
You must set Caster Location first:
  • Set CasterLoc = (Position of (Triggering unit))
Then use it in here:
  • Special Effect - Create a special effect at CasterLoc using Abilities\Spells\Orc\MirrorImage\MirrorImageCaster.mdl
Then destroy it by using this action:
  • Custom script: call RemoveLocation(udg_CasterLoc)
Unit leak
After you use this action:
  • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
You must clean the unit by using this:
  • Unit - Add a 0.50 second Generic expiration timer to (Last created unit)

ah, i see ^__^. it all makes sense now... no really it does ;D

imma fix these points then, ty for all your help guys ^_^



--------
EDIT:
--------

Updated my triggers in my first post,
apart from that i THINK leaks have been solved BUT i can't open my map through world editor now o.o; it works fine when i open it normally in wc3 though....
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
You can't open my test map in WE ?
How strange..
I guess I just copy and paste my trigger eh?
Here it is:
  • Start
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Blink Strike
    • Actions
      • Set Caster = (Triggering unit)
      • Set Target = (Target unit of ability being cast)
      • Set TargetLoc = (Position of Target)
      • Trigger - Turn on Blink Cooldown <gen>
  • Blink Cooldown (Initially Off)
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit - Move Caster instantly to (TargetLoc offset by 10.00 towards ((Facing of Target) + 180.00) degrees), facing TargetLoc
      • Custom script: call RemoveLocation(udg_TargetLoc)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((This trigger) is on) Equal to True
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
You see that in the second trigger, I used Periodic Event, that's okay, just try it and it works fine
If you have any question, feel free to ask
 
Level 8
Joined
Apr 8, 2009
Messages
499
You can't open my test map in WE ?
How strange..
I guess I just copy and paste my trigger eh?
Here it is:
  • Start
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Blink Strike
    • Actions
      • Set Caster = (Triggering unit)
      • Set Target = (Target unit of ability being cast)
      • Set TargetLoc = (Position of Target)
      • Trigger - Turn on Blink Cooldown <gen>
  • Blink Cooldown (Initially Off)
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit - Move Caster instantly to (TargetLoc offset by 10.00 towards ((Facing of Target) + 180.00) degrees), facing TargetLoc
      • Custom script: call RemoveLocation(udg_TargetLoc)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((This trigger) is on) Equal to True
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
You see that in the second trigger, I used Periodic Event, that's okay, just try it and it works fine
If you have any question, feel free to ask

not what i ment xD, didn't open your map, just followed the triggers you posted in your 1st comment.

its about my map (with your triggers needed to avoid leaks).
i can open it both in WE and in wc3, when i want to test the map in WE it won't work, but when i open the map in wc3 it'll work.
thats whats confuzing me at the moment o.o;.

i updated the triggers above so check them out ^_^
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
What, why ?
Does it shut down the game or instant crash ?

EDIT:
How does you want the spell to work ?
A blink strike ability and... ?
Tell me the SFX and other important thing that I need to know
I'll try to create the spell myself and post it to you
 
Level 8
Joined
Apr 8, 2009
Messages
499
What, why ?
Does it shut down the game or instant crash ?

whenever i go to local area --> create a game --> my map.
it auto returns to local area connection menu.

also, my spell already works, its the leaks i'm working on now. check the triggers in the first post.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Try remove the latest solution that I suggested to you (the leak cleaning and all) then try to host it back
If the game still can't be hosted, then there's something wrong with the map, not the solution I gave you
Cause', leak cleaning doesn't have to do with "can't host map" problem
 
Level 8
Joined
Apr 8, 2009
Messages
499
removed the:
  • Custom script: call RemoveLocation(udg_CasterLoc)
parts and its hostable, readded them and its not hostable. explain please?
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
If you use an array-type variable, the leak cleaning method is different
Say, you got Point-type variable and array it with Integer type variable
You need to clean it like this:
  • Custom script: call RemoveLocation(udg_PointVariable[udg_IntegerVariable])
 
Level 8
Joined
Apr 8, 2009
Messages
499
If you use an array-type variable, the leak cleaning method is different
Say, you got Point-type variable and array it with Integer type variable
You need to clean it like this:
  • Custom script: call RemoveLocation(udg_PointVariable[udg_IntegerVariable])


awesome, will try it out soon ^_^.
 
Level 5
Joined
Nov 7, 2005
Messages
78
Test map attached
If you have any question regarding the test map, feel free to ask me =D

LEAKS
You didn't clean Special Effects leak
Put this action RIGHT AFTER YOU CREATE a Special Effect:
  • Special Effect - Destroy (Last created special effect)
Point leak
You must set Caster Location first:
  • Set CasterLoc = (Position of (Triggering unit))
Then use it in here:
  • Special Effect - Create a special effect at CasterLoc using Abilities\Spells\Orc\MirrorImage\MirrorImageCaster.mdl
Then destroy it by using this action:
  • Custom script: call RemoveLocation(udg_CasterLoc)
Unit leak
After you use this action:
  • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
You must clean the unit by using this:
  • Unit - Add a 0.50 second Generic expiration timer to (Last created unit)

Haven't looked at the map, but at least one leak was missed.

Location leak:
  • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
You need to store (Center of (Playable map area)) in a location variable, use that variable in the above line, then remove the location. The following would also work (as a complete replacement for the line):
Code:
call CreateUnit( Player(0), 'hfoo', GetRectCenterX(bj_mapInitialPlayableArea), GetRectCenterY(bj_mapInitialPlayableArea), bj_UNIT_FACING )
 
Level 5
Joined
Nov 7, 2005
Messages
78
And I was making sure the point leak was apparent too. If you did not mean to point out every leak (again, I have not looked at the map), but rather intended to point out one of each type, then I am guilty of missing the point.
 
Level 8
Joined
Apr 8, 2009
Messages
499
mkay, defskull i input that line you mentioned like this:


----EDIT----

i saw a failure LOL. brb gonna test again.
 
Level 8
Joined
Apr 8, 2009
Messages
499
He meant udg_IntegerVariable as a generic example, in your specific case you want:
JASS:
call RemoveLocation(udg_CasterLoc[GetPlayerId(GetOwningPlayer(GetTriggerUnit())) + 1])

mkay. lets try that out then o.o

also, just post it in GUI triggers, less confusing for me ^__^

-----EDIT----

works perfectly. +rep for all of you people ^_^
 
Status
Not open for further replies.
Top