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

Triggered spell and problem with turning collision back on

Status
Not open for further replies.
Level 7
Joined
Sep 9, 2007
Messages
253
The ability which triggers this is based off drain life channelled ability.


Can anyone tell me why the target unit seems to have 0 collision after this spell is cast on him. Collision is successfully turned back on for the caster but doesn't work for the target. Apart from this the spell works well.

  • Soul Tether
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Soul Tether (quil)
    • Actions
      • Wait 2.00 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) has buff Drain Life (Caster)) Equal to True
        • Then - Actions
          • Set aaTempPoint = (Position of (Target unit of ability being cast))
          • Set aaTempPoint2 = (Position of (Triggering unit))
          • Unit - Turn collision for (Triggering unit) Off
          • Unit - Turn collision for (Target unit of ability being cast) Off
          • Unit - Move (Target unit of ability being cast) instantly to aaTempPoint2, facing aaTempPoint
          • Unit - Move (Triggering unit) instantly to aaTempPoint, facing aaTempPoint2
          • Unit - Turn collision for (Triggering unit) On
          • Unit - Turn collision for (Target unit of ability being cast) On
          • Special Effect - Create a special effect at aaTempPoint using Abilities\Spells\Orc\MirrorImage\MirrorImageDeathCaster.mdl
          • Special Effect - Destroy (Last created special effect)
          • Special Effect - Create a special effect at aaTempPoint2 using Abilities\Spells\Orc\MirrorImage\MirrorImageDeathCaster.mdl
          • Special Effect - Destroy (Last created special effect)
          • Custom script: call RemoveLocation(udg_aaTempPoint)
          • Custom script: call RemoveLocation(udg_aaTempPoint2)
        • Else - Actions
 
Level 30
Joined
Nov 29, 2012
Messages
6,637
It worked? Well, there are times Triggering unit can be overrided (don't know the exact term) by a new unit so storing them would do the trick and also, as what most do for efficiency, anything used twice should be stored into a variable.
 
Globals variables like in gui may be overwritten during these 2 seconds. So you can't be sure you operate with the correct unit after the wait. Locals would do it.

Note:
Using TriggeringUnit and DyingUnit wont be overwritten, even after waits. They can be treaten like local variables.

In your case I'm sure "Target unit of ability being cast" is what doesnt work after the wait.

These things you simply can check with displaying messages. For example display name of triggering unit and name of Target unit of ability being cast after the wait, and then you see that one of them is null. ;)
 
Level 7
Joined
Sep 9, 2007
Messages
253
I don't save the units into variables until after the wait, shouldn't that make it OK?

  • Soul Tether
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Soul Tether (quil)
    • Actions
      • Wait 2.00 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) has buff Drain Life (Caster)) Equal to True
        • Then - Actions
          • Set aaTempUnit = (Target unit of ability being cast)
          • Set aaTriggeringUnit = (Triggering unit)
          • Set aaTempPoint = (Position of aaTempUnit)
          • Set aaTempPoint2 = (Position of aaTriggeringUnit)
          • Unit - Turn collision for aaTriggeringUnit Off
          • Unit - Turn collision for aaTempUnit Off
          • Unit - Move aaTempUnit instantly to aaTempPoint2, facing aaTempPoint
          • Unit - Move aaTriggeringUnit instantly to aaTempPoint, facing aaTempPoint2
          • Unit - Turn collision for aaTriggeringUnit On
          • Unit - Turn collision for aaTempUnit On
          • Special Effect - Create a special effect at aaTempPoint using Abilities\Spells\Orc\MirrorImage\MirrorImageDeathCaster.mdl
          • Special Effect - Destroy (Last created special effect)
          • Special Effect - Create a special effect at aaTempPoint2 using Abilities\Spells\Orc\MirrorImage\MirrorImageDeathCaster.mdl
          • Special Effect - Destroy (Last created special effect)
          • Custom script: call RemoveLocation(udg_aaTempPoint)
          • Custom script: call RemoveLocation(udg_aaTempPoint2)
        • Else - Actions
Target unit of ability being cast is working for the other actions but just not turning collision on. eg. the point is being saved at position of target unit because the casting unit gets moved to that point correctly. The Target unit also correctly moves to the point where the casting unit was and it is also correctly getting it's unit collision turned off. It seems odd that it works for 3 actions out of the 4.

Thanks for helping me fix this.
 
Status
Not open for further replies.
Top