• 🏆 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!

[Spell] how to get around using a wait with this spell

Status
Not open for further replies.
Level 15
Joined
Jul 9, 2008
Messages
1,552
ok so i have a basic spell that will move the unit to the target and will gain bonus attack speed bonus for a short period of time

  • Rift Strike
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Rift Strike
    • Actions
      • Wait 0.20 seconds
      • Set Caster_loc = (Position of (Casting unit))
      • Set Target_loc = ((Position of (Target unit of ability being cast)) offset by -50.00 towards (Angle from Caster_loc to (Position of (Target unit of ability being cast))) degrees)
      • Special Effect - Create a special effect at Caster_loc using Abilities\Spells\Orc\FeralSpirit\feralspirittarget.mdl
      • Special Effect - Destroy (Last created special effect)
      • Special Effect - Create a special effect at Target_loc using Abilities\Spells\Orc\FeralSpirit\feralspirittarget.mdl
      • Special Effect - Destroy (Last created special effect)
      • Unit - Move (Triggering unit) instantly to Target_loc, facing Caster_loc
      • Unit - Order (Casting unit) to Attack (Target unit of ability being cast)
      • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at Target_loc facing (Facing of (Triggering unit)) degrees
      • Unit - Add rift to (Last created unit)
      • Unit - Order (Last created unit) to Orc Shaman - Bloodlust (Casting unit)
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Custom script: call RemoveLocation(udg_Caster_loc)
      • Custom script: call RemoveLocation(udg_Target_loc)
the problem is i know ill have issues with the wait there if 2 units cast the spell at the same time or with in the 0.2 seconds even tho its highly unlikely to happen id rather resolve the problem.
although if i remove the wait the spell doesn't go on cool down witch is pree much the only reason its there
 
Level 22
Joined
Aug 27, 2013
Messages
3,973
Something like this:
  • Rift Strike
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Rift Strike
    • Actions
      • Custom script: local location udg_Loc1
      • Custom script: local location udg_Loc2
      • Custom script: local location udg_Loc3
      • Custom script: local unit udg_Target = GetSpellTargetUnit()
      • Wait 0.20 seconds
      • Set Loc1 = (Position of (Triggering unit))
      • Set Loc2 = (Position of Target)
      • Set Loc3 = (Loc2 offset by -50.00 towards (Angle from Loc1 to Loc2) degrees)
      • Special Effect - Create a special effect at Loc1 using Abilities\Spells\Orc\FeralSpirit\feralspirittarget.mdl
      • Special Effect - Destroy (Last created special effect)
      • Special Effect - Create a special effect at Loc2 using Abilities\Spells\Orc\FeralSpirit\feralspirittarget.mdl
      • Special Effect - Destroy (Last created special effect)
      • Unit - Move (Triggering unit) instantly to Loc2, facing (Angle from Loc1 to Loc2) degrees
      • Unit - Order (Triggering unit) to Attack Target
      • Unit - Create 1 Footman for (Triggering player) at Loc2 facing Default building facing degrees
      • Unit - Add Rift to (Last created unit)
      • Unit - Order (Last created unit) to Orc Shaman - Bloodlust (Triggering unit)
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Custom script: call RemoveLocation(udg_Loc1)
      • Custom script: call RemoveLocation(udg_Loc2)
      • Custom script: call RemoveLocation(udg_Loc3)
      • Custom script: set udg_Loc1 = null
      • Custom script: set udg_Loc2 = null
      • Custom script: set udg_Loc3 = null
      • Custom script: set udg_Target = null
Here is the Tutorial which explains about local variables.
 
Level 15
Joined
Jul 9, 2008
Messages
1,552
alright thanks mate and thanks for the link as well

small question is this line leaking a point? i seen uv done it differently in your trigger
  • Set Target_loc = ((Position of (Target unit of ability being cast)) offset by -50.00 towards (Angle from Caster_loc to (Position of (Target unit of ability being cast))) degrees)
 
Level 4
Joined
Sep 13, 2014
Messages
106
I'm pretty sure that the
  • Set Loc1 = (Position of (Triggering unit))
  • Set Loc2 = (Position of Target)
  • Set Loc3 = (Loc2 offset by -50.00 towards (Angle from Loc1 to Loc2) degrees)
should be before the wait. Also, it is weird how @Rheiko it uses "udg_" in front of the variable name. It is unorthodox. I don't know whether there is anything preventing you from declaring variables already declared in a greater scope, or for declaring undefined globals, but it is certainly interesting.
 
Level 22
Joined
Aug 27, 2013
Messages
3,973
Firstly, that might be correct. I'm not really used to local variables.
Secondly, this:
If you choose the global and have
the local variable with the same name, it will allow you to use the local for the action instead.

Though my application seems wrong, so i would be glad if you instead fixed it for me.

Edit:
it should be probably something like this
  • Custom script: local location udg_Loc1 = Location( GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()))
 
Last edited:
I'm pretty sure that the
  • Set Loc1 = (Position of (Triggering unit))
  • Set Loc2 = (Position of Target)
  • Set Loc3 = (Loc2 offset by -50.00 towards (Angle from Loc1 to Loc2) degrees)
should be before the wait. Also, it is weird how @Rheiko it uses "udg_" in front of the variable name. It is unorthodox. I don't know whether there is anything preventing you from declaring variables already declared in a greater scope, or for declaring undefined globals, but it is certainly interesting.

It can be before or after. It depends on whether you want the points from when the spell is cast or the points 0.20 seconds later. But his trigger should work fine as it is, since (Triggering unit) and "Target" are local. He could even remove the first 3 lines and it'd work, since Loc1, Loc2, and Loc3 don't need to be local.

As for the variable shadowing, nothing prevents us from declaring variables already declared in the global scope. You can't have two variables with the same name in the same scope, but you can have one named "udg_Target" in the global scope and one named "udg_Target" in the local scope. It is useful for situations like this where you want to use GUI but want to benefit from locals. :)
 
Level 4
Joined
Sep 13, 2014
Messages
106
Oh, I assumed it was actually being used as a variable, and the whole point was that it stored what happened before the 0.2 seconds. Maybe I didn't read thoroughly enough, it is rather being used to prevent leaks.
 
Level 8
Joined
Apr 8, 2009
Messages
499
I had the same problem with one of my spells, causing it not to go on cooldown.
Fixed it the same way--- except that I noticed that if you put the wait on 0 seconds it'll have the same effect as when it's put on 0.2 seconds.
Wouldn't that also solve the chance of multiple units casting within 0.2 units?
 
Level 8
Joined
Jan 28, 2016
Messages
486
Is it at all possible to use this event instead of the wait?
  • Rift Strike
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Rift Strike
    • Actions
      • -------- Add actions here --------
 
Status
Not open for further replies.
Top