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

Ability cancels casting if move command is issued

Status
Not open for further replies.
Level 2
Joined
Sep 13, 2021
Messages
9
As the title says I have a placeholder ability called mend pet that causes one unit to rejuvenate another. The ability is based on Berserk so that it's instant cast. However, if I use the ability and immediately issue a move command the ability gets canceled. How would I fix this?

  • Mend Pet
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Mend Pet
    • Actions
      • Unit - Add Rejuvenation to (Casting unit)
      • Player - Enable Rejuvenation for (Owner of (Triggering unit))
      • Unit - Order (Triggering unit) to Night Elf Druid Of The Claw - Rejuvenation (Random unit from (Units owned by (Owner of (Triggering unit)) of type Misha (Level 1)))
      • Player - Disable Rejuvenation for (Owner of (Triggering unit))
 
Level 21
Joined
Dec 4, 2007
Messages
1,473
You probably want to use a different event: Unit - Starts the effect of an ability

But more importantly:

Why don't you let a different unit cast Rejuvenation on your prefered target?
Your Rejuvenation spell gets cancelled, because it ONLY fires after winding up (animation), thus no order must interfere (even though berserk is instant).
 
Level 2
Joined
Sep 13, 2021
Messages
9
Because I still want the casting unit to stop and do the casting animation for rejuvenation. I'm fairly new to this, is creating a different unit to do this the cleanest way? If so how do I go about it?
 

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,456
Some examples of Dummy units + spells:
See my 1st post here for an attached map that contains a Dummy unit you can use. See my 2nd post here for making a Dummy cast a spell on multiple targets (so you can turn a single target spell into a multi-target spell):

The idea is simple, you create an unselectable unit (Dummy) that has no model (optional), add your desired ability to it, and have it cast that ability on your desired target. Then you remove the Dummy a moment later as it's no longer needed.

You do need to make sure that both your Dummy and it's ability are setup correctly otherwise you'll run into issues. But that's easy as well, base the Dummy unit off of the Locust unit, set it's Attacks Enabled to None, Movement Type to None, and Speed Base to 0. Then edit the ability that you want the Dummy to cast so that it has enough Cast Range (999999), 0 Mana Cost, no Requirements, and double check the Targets Allowed field.
 
Last edited:
Level 2
Joined
Sep 13, 2021
Messages
9
@Uncle I used your first post to create the trigger. It works but it's acting the same way where if I issue an order immediately after casting, the animation gets cancelled (the ability still gets casted) obviously because of the dummy. So how do I prevent the caster from doing anything until the animation is fully completed.

My trigger:

  • Mend Pet Ability Copy
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mend Pet
    • Actions
      • Unit - Move (Triggering unit) instantly to (Position of (Triggering unit)), facing (Position of MishaUnits[(Player number of (Triggering player))])
      • Animation - Play (Triggering unit)'s spell animation
      • Unit - Create 1 Dummy for (Triggering player) at (Position of (Triggering unit)) facing (Facing of MishaUnits[(Player number of (Triggering player))]) degrees
      • Unit - Add a 0.50 second Generic expiration timer to (Last created unit)
      • Unit - Add Rejuvenation to (Last created unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Mend Pet for (Triggering unit)) Equal to 1
        • Then - Actions
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Mend Pet for (Triggering unit)) Equal to 2
            • Then - Actions
              • Unit - Set level of Rejuvenation for (Last created unit) to 2
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Mend Pet for (Triggering unit)) Equal to 3
                • Then - Actions
                  • Unit - Set level of Rejuvenation for (Last created unit) to 3
                • Else - Actions
      • Sound - Play RexxarBase_Misha_Heel05 <gen>
      • Unit - Order (Last created unit) to Night Elf Druid Of The Claw - Rejuvenation MishaUnits[(Player number of (Triggering player))]

Also would this sound be played for triggering player only? That's what is desired.
 
Last edited:

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,456
The ability gets canceled because you're moving the casting unit which issues a Stop order. You can either add a 0.00 second Wait and move the Triggering unit afterwards or use Custom script: SetUnitX / SetUnitY to move the unit based on x/y coordinates which doesn't issue a Stop order. If you use the Wait then make sure that you use: Player number of Owner of (Triggering unit) instead of (Triggering player).

Example of SetUnitX/Y: [Spell] - Problem with SetUnitX and Y

But why can't you use the animation provided by the Mend Pet ability in the Object Editor?

Anyway, the Play Animation action can be interrupted by any order so it's not really reliable. There's a Custom script for that which forces the animation to be played called SetUnitAnimationByIndex:
  • Custom script: call SetUnitAnimationByIndex(whichUnit, whichAnimation)
whichAnimation takes an Integer value so what you'd do is plug in some number from 0-X, X being the total number of animations the unit has - 1. You'll have to test these numbers out but from my experience the Spell animation is usually at least 4.

Important disclaimer: I'm not 100% sure if this works the way I think it does, it may get interrupted as well. That being said, I do know that if the unit is Stunned/Paused that this function can force the unit to play an animation in that disabled state. However, sometimes you need to apply a frame delay (0 second Wait) in order for this to work. Warcraft 3 is a pain, sometimes things don't work unless you delay them.

The only catch is that once the animation finishes the unit needs to have it's Animation reset otherwise it will just stand there frozen. Pretty much any order should reset the animation but you can also do it with the Reset animation action.

Alternatively, you could use the Channel ability to force the unit to cast the spell over X seconds. When using this ability set Disable Other Abilities to False and Follow Through Time to however long you want the unit to have to cast. Also, make sure in Options that the ability is Visible.

For the trigger, I'm pretty sure that you can still use the Starts effect Event in order to detect a successful cast of Channel (completed the entire Follow Through Time), but if not you may need to use a different Event like Finishes casting.
 
Last edited:
Level 2
Joined
Sep 13, 2021
Messages
9
I think you misunderstood me, the animation cancels only if I order the triggering unit to move somewhere with my mouse. If it is standing still it works as intended even with the moving that I'm doing in the trigger.

But why can't you use the animation provided by the Mend Pet ability in the Object Editor?
I'm using berserk as the base ability, and AFAIK adding art animation to it does nothing...

I tried and ran into the same issue:

  • Custom script: call SetUnitAnimationByIndex (GetTriggerUnit(),5)

Behavior:
1. Use ability
2. Command unit to move IMMEDIATELY after using ability
3. Animation gets canceled (the problem) - Ability still gets casted as expected

Expected behavior:
1. Use ability
2. Unit becomes unresponsive and casts the spell only (example Stomp by Tauren cheiftan) and does animation for it
3. Unit becomes responsive again

Hope I'm making sense :gg:
 

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,456
Can you use a different base ability then? Sounds like your expected behavior is the same exact behavior that most non-instant abilities use.
 
Last edited:
Level 2
Joined
Sep 13, 2021
Messages
9
I used War stomp instead and it waits for the animation now! Only problem is now it does the animation first and then faces Misha (The target). I would want it to instantly face Misha, do the animation and then the dummy casts heal on Misha. I think the spell art animation is performed before any action in the trigger and for some reason the instantly face X unit action doesn't work "Instantly" it takes at least 0.5 seconds. :xxd:
 
Status
Not open for further replies.
Top