• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] JASS scirpt that cancels an ability

Status
Not open for further replies.
Level 3
Joined
Jun 9, 2009
Messages
38
I need the JASS script to cancel a currently casting ability.

I have this, that only works for training and upgrades I believe.

call IssueImmediateOrderById( udg_<variable>, 0x000d0008 )
 
Level 3
Joined
Jun 9, 2009
Messages
38
In the Trigger:

  • Refine Materials
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Unit-type of (Casting unit)) Equal to Refinery
      • (Ability being cast) Equal to Refine
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Casting unit)) Current lumber) Greater than or equal to 100
          • (Mana of (Casting unit)) Greater than or equal to 10.00
        • Then - Actions
          • Unit - Set mana of (Casting unit) to ((Mana of (Casting unit)) - 10.00)
          • Player - Set (Owner of (Casting unit)) Current gold to (((Owner of (Casting unit)) Current gold) + 90)
          • Player - Set (Owner of (Casting unit)) Current lumber to (((Owner of (Casting unit)) Current lumber) - 100)
        • Else - Actions
          • Unit - Order (Triggering unit) to Stop
Stop doesn't do anything. The spell keeps casting.
 
Level 3
Joined
Jun 9, 2009
Messages
38
What parts of it do I have to change. I've never dabbled in JASS/Custom Scripts except for that script I used above.
 
Level 3
Joined
Jun 9, 2009
Messages
38
I see what's happening. It doesn't cancel it in the middle of the cast. It waits till the end spell when it's going to cast and then cancels it. Wastes time, but I guess it works.
 
Level 3
Joined
Jun 9, 2009
Messages
38
Did more testing, if I take that cancel string out the same thing happens. It just casts the ability and does nothing else since it's going through the Else commands.
 
Level 3
Joined
Jun 9, 2009
Messages
38
Thanks for the help guys, but none of them worked. I'm probably doing something wrong.

It works fine without the stop command anyways. It's a looping command that won't hinder the next time it goes through even if it casts without any results.
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
  • Custom script: call SetUnitPosition(GetTriggerUnit(), GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()))
It works. Dont whine it does not, it does. It is the same as Cokemonkey11 said, only without leaks,,
 
Level 3
Joined
Jun 9, 2009
Messages
38
  • Custom script: call SetUnitPosition(GetTriggerUnit(), GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()))
It works. Dont whine it does not, it does. It is the same as Cokemonkey11 said, only without leaks,,

Thanks for the help guys, but none of them worked. I'm probably doing something wrong.

Wow, I wasn't under the impression thanking people and saying I probably did something wrong is whining.
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
Im just telling you it works, and that you should probably try again then,,
But you are right that i could have been a little nicer to you,, My apolagies for that.
Just copy the exact line i wrote there and put it in a custom script,,
Here is the line again:
call SetUnitPosition(GetTriggerUnit(), GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()))

Try again and see if it works,,
 
Level 3
Joined
Jun 9, 2009
Messages
38
  • Refine Materials
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Unit-type of (Casting unit)) Equal to Refinery
      • (Ability being cast) Equal to Refine
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Casting unit)) Current lumber) Greater than or equal to 100
          • (Mana of (Casting unit)) Greater than or equal to 10.00
        • Then - Actions
          • Unit - Set mana of (Casting unit) to ((Mana of (Casting unit)) - 10.00)
          • Player - Set (Owner of (Casting unit)) Current gold to (((Owner of (Casting unit)) Current gold) + 90)
          • Player - Set (Owner of (Casting unit)) Current lumber to (((Owner of (Casting unit)) Current lumber) - 100)
        • Else - Actions
          • Custom script: call SetUnitPosition(GetTriggerUnit(), GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()))
I honestly have no idea why this doesn't work. One of the reasons why I'm gonna switch over to JASS. Hopefully soon when I can work on the code with my dad.

EDIT: To clarify, the building just sits there casting the ability
 
Last edited:
Level 13
Joined
Nov 22, 2006
Messages
1,260
  • Refine Materials
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Refinery
      • (Ability being cast) Equal to Refine
    • Actions
      • Set Caster = (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of Caster) Current lumber) Greater than or equal to 100
          • (Mana of Caster) Greater than or equal to 10.00
        • Then - Actions
          • Unit - Set mana of Caster to ((Mana of Caster) - 10.00)
          • Player - Set (Owner of Caster) Current gold to (((Owner of Caster) Current gold) + 90)
          • Player - Set (Owner of Caster) Current lumber to (((Owner of Caster) Current lumber) - 100)
        • Else - Actions
          • Countdown Timer - Start Timer as a One-shot timer that will expire in 0.00 seconds
  • Stop
    • Events
      • Time - Timer expires
    • Conditions
    • Actions
      • Unit - Order Caster to Stop
That should work. Ordering unit on another order event doesn't work directly, so you have to either put a wait or use a timer like I did now.

Btw, I use "triggering unit" since it's a little faster than "casting unit", but I guess it's just the matter of style.
 
Status
Not open for further replies.
Top