• 🏆 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!
  • ✅ HD Level Design Contest #1 POLL is now OPEN! Check out the stunning visuals of the final entries. 🔗Click here to cast your vote!

[Solved] Another broken position-swap spell...

Status
Not open for further replies.
Level 2
Joined
Jun 20, 2011
Messages
19
While creating a seemingly simple spell for my map, I ran into a peculiar problem I wasn't expecting.
The spell is meant to be a simple positional switch, nether swap -style, but with different gfx and additional effects. Thinkin I'd cough something that simple in about five minutes, I did this:
  • Shift
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Shift
    • Actions
      • Set TempLoc = (Position of (Casting unit))
      • Set TempLoc2 = (Position of (Target unit of ability being cast))
      • Lightning - Create a Healing Wave - Primary lightning effect from source TempLoc to target TempLoc2
      • Set ShiftBeam = (Last created lightning effect)
      • Special Effect - Create a special effect at TempLoc using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
      • Special Effect - Create a special effect at TempLoc2 using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
      • Unit - Turn collision for (Casting unit) Off
      • Unit - Turn collision for (Target unit of ability being cast) Off
      • Unit - Move (Casting unit) instantly to TempLoc2
      • Unit - Move (Target unit of ability being cast) instantly to TempLoc
      • Unit - Turn collision for (Casting unit) On
      • Unit - Turn collision for (Target unit of ability being cast) On
      • Custom script: call RemoveLocation( udg_TempLoc )
      • Custom script: call RemoveLocation( udg_TempLoc2 )
      • Wait 0.60 seconds
      • Lightning - Destroy ShiftBeam
Seems like it should work, right? The gfx does what it's supposed to do, the hero gets moved....but the targeted enemy stays bolted to the floor and won't budge, even after the 20th something test cast.

Could someone smarter than me point out what I'm doing wrong?

Thanks in advance.
 
Level 4
Joined
Jun 23, 2011
Messages
70
Reading now.

The first two things I would try would be this: Lock the target unit to a variable (i.e., 'TargetUnit'), and drop the remlocs to below the wait call. The computer is either not remembering the targeted unit or not registering it in the first place. If neither of those works, I'll build it myself and solve.
 
Level 2
Joined
Jun 20, 2011
Messages
19
Interesting. I did what you suggested and the thing works now.
Good enough for me, but it might be handy to know what was causing it to avoid a potential repetition.

Anyway, thanks a bunch.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
When moving a unit instantly, it is ordered to stop. Therefore the cooldown and mana cost won't trigger.

The wait makes the spell not MUI, and it can bug if it is cast again before the wait is over.

Either order a dummy unit to cast a dummy lightning ability or

  • Shift
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Shift
    • Actions
      • Custom Script: local lightning ShiftBeam
      • Set TempLoc = (Position of (Casting unit))
      • Set TempLoc2 = (Position of (Target unit of ability being cast))
      • Lightning - Create a Healing Wave - Primary lightning effect from source TempLoc to target TempLoc2
      • Set ShiftBeam = (Last created lightning effect)
      • Special Effect - Create a special effect at TempLoc using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
      • Special Effect - Create a special effect at TempLoc2 using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
      • Unit - Turn collision for (Casting unit) Off
      • Unit - Turn collision for (Target unit of ability being cast) Off
      • Unit - Move (Casting unit) instantly to TempLoc2
      • Unit - Move (Target unit of ability being cast) instantly to TempLoc
      • Unit - Turn collision for (Casting unit) On
      • Unit - Turn collision for (Target unit of ability being cast) On
      • Custom script: call RemoveLocation( udg_TempLoc )
      • Custom script: call RemoveLocation( udg_TempLoc2 )
      • Wait 0.60 seconds
      • Lightning - Destroy ShiftBeam
      • Custom script: set ShiftBeam = null
 
Level 2
Joined
Jun 20, 2011
Messages
19
I found another thread about a similar spell not setting off it's cooldown correctly, and used the fix suggested there: adding a 0.00 Wait just before moving anything. This works for me.
In my map, the spell does not need to be MUI, as there is only one hero that can cast it, and only one player can have this hero at a time. Furthermore, the spell has a (now fixed) cooldown of 20 seconds at all levels, meaning the lightning has plenty of time to disappear before a second cast is ever possible.

Thanks for your concern though. Now, if only I could find a way to change the prefix in the thread title to "solved"...
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
I think you should know that waits are inaccurate. Wait always adds 0,1-0,2 seconds to the value you use in single player, possibly more in multiplayer. Therefore a 0,00 second wait turns into 0,1 - 0,2 second wait. That won't change the functionality of that trigger, but is good to know.

Now, if only I could find a way to change the prefix in the thread title to "solved"...

Done ;)
 
Status
Not open for further replies.
Top