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

[General] Stop a unit from casting an ability

Status
Not open for further replies.
Level 3
Joined
Oct 25, 2017
Messages
43
Hello,

I have a morph ability based on Bear Form that requires an item in order to work. All is fine and dandy but I cannot get the unit to not cast the ability when the item is not present in the inventory - the trigger detects that there is no item, displays the correct message but the ability is still cast.

  • Switch Test
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Switch Attack (Alliance)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • ((Triggering unit) has an item of type itmBows[0]) Equal to False
              • ((Triggering unit) has an item of type itmBows[1]) Equal to False
              • ((Triggering unit) has an item of type itmBows[2]) Equal to False
              • ((Triggering unit) has an item of type itmCrossbows[0]) Equal to False
        • Then - Actions
          • Unit - Pause (Triggering unit)
          • Unit - Order (Triggering unit) to Stop
          • Unit - Unpause (Triggering unit)
          • Game - Display to (Player group((Owner of (Triggering unit)))) the text: You need a ranged w...
          • -------- To stop the spell from switching without the requirements --------
        • Else - Actions

I tried 4-5 variations of this trigger and nothing seems to work.

Any help would be much apreciated.

Cheers
 
Level 11
Joined
Nov 23, 2013
Messages
665
Use a dummy spell.
Your dummy spell must be a spell that does nothing. Give it to your unit. Your normal Switch Attack ability must be hidden (you can do so by setting the position to 0 / -11 - hold shift when changing -11 so WE can accept negative value). Give it to your unit as well.
And then something like that:
  • Switch
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal Switch Attack (dummy)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Casting unit) has an item of type [Your Item] Equal FALSE
        • Then - Actions
          • Game - Display to (Player group((Owner of (Casting unit)))) for 30.00 seconds the text: You need a ranged weapon
        • Else - Actions
          • Unit - Order (Casting unit) to Night Elf - Bear Form
 
Level 3
Joined
Oct 25, 2017
Messages
43
Use a dummy spell.
Your dummy spell must be a spell that does nothing. Give it to your unit. Your normal Switch Attack ability must be hidden (you can do so by setting the position to 0 / -11 - hold shift when changing -11 so WE can accept negative value). Give it to your unit as well.
And then something like that:
  • Switch
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal Switch Attack (dummy)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Casting unit) has an item of type [Your Item] Equal FALSE
        • Then - Actions
          • Game - Display to (Player group((Owner of (Casting unit)))) for 30.00 seconds the text: You need a ranged weapon
        • Else - Actions
          • Unit - Order (Casting unit) to Night Elf - Bear Form

I hoped it wouldn't have come to that to not clog up the map. But I'll try when I get home.

Thanks!
 
Level 3
Joined
Oct 25, 2017
Messages
43
Could you post demo for easyness? I'm sure it can work without a dummy ability, too.
I've made a system exactly like the one on my map with the same effect.

As you can see, if you have the Bow in your inventory then the ability works fine - switch from melee to ranged - but if you don't have the bow in your inventory then the ability switches icons but the unit does not morph.
 

Attachments

  • Range to Melee.w3x
    17.2 KB · Views: 23
Status
Not open for further replies.
Top