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

[Solved] Unit Movement Cancels Spell Damage

Status
Not open for further replies.
Level 5
Joined
Jan 19, 2018
Messages
126
Hello Hive,
I created a Trigger spell based on Storm Bolt, everything is working properly except for 1 thing. If the caster moves before the bolt hits the target, it does no damage. Is there a way to fix this? Here is my spell trigger...
  • Arcane Blast
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Arcane Blast
    • Actions
      • -------- Special Effect Based on Level --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Integer((Real((Level of (Ability being cast) for (Casting unit)))))) Greater than or equal to 2
        • Then - Actions
          • Special Effect - Create a special effect attached to the weapon of (Casting unit) using Abilities\Spells\NightElf\Blink\BlinkTarget.mdl
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Integer((Real((Level of (Ability being cast) for (Casting unit)))))) Equal to 3
        • Then - Actions
          • Special Effect - Create a special effect attached to the origin of (Casting unit) using ArcaneExplosion.mdx
        • Else - Actions
      • -------- Wait Ingame to Compensate for Missile Travel (Waiting TIme = Distance Between Units/Missile Speed) --------
      • Wait ((Distance between (Position of (Casting unit)) and (Position of (Target unit of ability being cast))) / 1500.00) game-time seconds
      • -------- Damage Target Unit (Damage = (Ability Level x 150) + (Hero Intelligence x Ability Level)) --------
      • Unit - Cause (Casting unit) to damage (Target unit of ability being cast), dealing ((150.00 x (Real((Level of (Ability being cast) for (Casting unit))))) + ((Real((Intelligence of (Casting unit) (Include bonuses)))) x (Real((Level of (Ability being cast) for (Casting unit)))))) damage of attack type Spells and damage type Magic
I tried changing the Event to "Starts the effect of an ability" but the problem still occurs.
Thanks in advance.
 
Level 11
Joined
Nov 23, 2013
Messages
665
I'm not an expert, but I'd say it's probably caused by the wait action. During the wait duration, if any other unit casts something, Target unit of ability being cast, Ability being cast and Casting unit will refer to another unit.
You need to store Casting unit etc in variables (using arrays to make it MUI, it's better)
 
Level 5
Joined
Jan 19, 2018
Messages
126
I'm not an expert, but I'd say it's probably caused by the wait action. During the wait duration, if any other unit casts something, Target unit of ability being cast, Ability being cast and Casting unit will refer to another unit.
You need to store Casting unit etc in variables (using arrays to make it MUI, it's better)
You were right about needing to the target unit as a variable, it works now! New Trigger:
  • Arcane Blast
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Arcane Blast
    • Actions
      • -------- StoreTarget Unit --------
      • Set ArcaneBlastTarget = (Target unit of ability being cast)
      • -------- Special Effect Based on Level --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Integer((Real((Level of (Ability being cast) for (Casting unit)))))) Greater than or equal to 2
        • Then - Actions
          • Special Effect - Create a special effect attached to the weapon of (Casting unit) using Abilities\Spells\NightElf\Blink\BlinkTarget.mdl
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Integer((Real((Level of (Ability being cast) for (Casting unit)))))) Equal to 3
        • Then - Actions
          • Special Effect - Create a special effect attached to the origin of (Casting unit) using ArcaneExplosion.mdx
        • Else - Actions
      • -------- Wait Ingame to Compensate for Missile Travel (Waiting TIme = Distance Between Units/Missile Speed) --------
      • Wait ((Distance between (Position of (Casting unit)) and (Position of (Target unit of ability being cast))) / 1500.00) game-time seconds
      • -------- Damage Target Unit (Damage = (Ability Level x 150) + (Hero Intelligence x Ability Level)) --------
      • Unit - Cause (Casting unit) to damage ArcaneBlastTarget, dealing ((150.00 x (Real((Level of (Ability being cast) for (Casting unit))))) + ((Real((Intelligence of (Casting unit) (Include bonuses)))) x (Real((Level of (Ability being cast) for (Casting unit)))))) damage of attack type Spells and damage type Magic
Thanks a bunch!
 
Level 5
Joined
Jan 19, 2018
Messages
126
I don't think this is related, but why are you converting the level of the ability to a Real just to convert it back to an Integer?
Oh you're right I wasn't paying attention to that!
I Guess because I was converting the Hero stat reals I unconsciously starting converting the Hero ability levels by mistake.
Good eye!
 
Level 11
Joined
Nov 23, 2013
Messages
665
You're very welcome!
Also, if more than one unit is able to cast this spell, you'd better make it MUI so it doesn't flaw when several unit cast it within a short interval. If you need it, you may want to look at this tutorial :csmile:
Good luck with your project!
 
Status
Not open for further replies.
Top