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

[Trigger] Autoclosing spellbook abilities when they cast

Status
Not open for further replies.
Level 14
Joined
Aug 30, 2004
Messages
909
My heroes have a spellbook Hero ability that lets them cast multiple spells. When they cast these spells, I want to automatically close the book so they can see their regular spells and move, patrol, stop, hold position, and so on.

Originally I did this:

  • Spell Book Fix
    • Events
      • Unit - A unit owned by Player 7 (Green) Begins channeling an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Borean's Grace tranquility
          • (Ability being cast) Equal to Consume Fires
          • (Ability being cast) Equal to Consume Fire 2
          • (Ability being cast) Equal to Crushing Wave channel
          • (Ability being cast) Equal to Earthen Sanctuary Inferno (Neutral Hostile)
          • (Ability being cast) Equal to Earthen Sanctuary Inferno (Neutral Hostile) 2
          • (Ability being cast) Equal to Quake impale
          • (Ability being cast) Equal to Fire Shield
          • (Ability being cast) Equal to Fire Shield 2
          • (Ability being cast) Equal to Gail of Wind rocket effect = 1
          • (Ability being cast) Equal to Hurricane
          • (Ability being cast) Equal to Kiss of the Witch fan of knives
          • (Ability being cast) Equal to Lightning Rune
          • (Ability being cast) Equal to Lamune's Dazzling Scouts
          • (Ability being cast) Equal to Magnetic Rock (Neutral Hostile)
          • (Ability being cast) Equal to Magnetic Rock (Neutral Hostile) 2
          • (Ability being cast) Equal to Mists of Obscurement (aqua)
          • (Ability being cast) Equal to Pyroclasm acid bomb 1
          • (Ability being cast) Equal to Pyroclasm acid bomb 2
          • (Ability being cast) Equal to Pyromantic Siege (Neutral Hostile 2)
          • (Ability being cast) Equal to Sandstorm
          • (Ability being cast) Equal to Sandstorm (snow)
          • (Ability being cast) Equal to Smoke Screen channel
          • (Ability being cast) Equal to Spirit Link Mirin Meld
          • (Ability being cast) Equal to Touch of the Witch Roar(Morph)
          • (Ability being cast) Equal to Twister Gate (Neutral Hostile)
          • (Ability being cast) Equal to Water Barrier (more powerful)
    • Actions
      • Game - Force Player 7 (Green) to press Escape/Cancel
It worked surprisingly well, except if the player cast one of those spells at a great distance and then selected another unit, at which point the trigger would make them press ESC causing other problems.

I recalled that there is an order you can give to a unit to make them open a spellbook. I used it in my Battle for Tatooine map. Does anyone know if there is a custom order I can give to CLOSE a spellbook? I'm looking for something like this:

  • Custom script: call IssueImmediateOrderById (udg_triggeringUnit, 852608)
 
I think the easiest fix would be to enumerate the units selected by the player. If the casting unit is not selected, then don't press Esc. That can still lead to some unwanted situations if the player has multiple units selected, though. You can check if the unit is the only one selected, but that will make it so the spellbook isn't closed even if it the highlighted unit in the player's selection.

Another possible solution would be: Detect the order of the ability, instead of when the unit starts casting it. This way, even if the unit casts the ability far away, Esc is instantly pressed. Though I'm not sure this can work with abilities based off of item abilities.
 
Level 14
Joined
Aug 30, 2004
Messages
909
I can try that second one; but I would have thought this was possible with just an order. There is a "Cancel" button there... and if there's an order to open a spellbook, why not one to close it?

There is another problem with the ESC key as well which is that it doesn't work if the player is holding down ALT to see unit life bars.

I tried adding and removing the spellbook ability, but that seems to cancel the spell before it takes place; and it removes cooldowns.
 
I tried catching an order event for opening/closing a spellbook, but it doesn't return anything.

  • Untitled Trigger 001
    • Events
      • Unit - A unit Is issued an order with no target
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order targeting an object
    • Conditions
    • Actions
      • Game - Display to (All players) the text: (String((Issued order)))
      • Custom script: call BJDebugMsg(I2S(GetIssuedOrderId()))
So I'm not sure how people figured out that custom order to open a spellbook, but it seems like it requires more extensive testing (maybe brute force?).

I can't think of an alternative to pressing Esc right now, I know that unselecting and then selecting the unit again won't work.
 
Level 14
Joined
Aug 30, 2004
Messages
909
That's funny; I literally just wrote out that trigger you pasted and was about to test for the order myself.

On older post suggested this for cancelling a building, but it hasn't worked yet:

  • Custom script: call IssueImmediateOrderById (udg_triggeringUnit, 851976)
I could just leave it so the player has to manually press ESC to get back to their main spells, but it is annoying. The ESC trigger (particularly with your detect whether the unit is selected trigger) might still be the best unless anyone else has an idea.
 
Indeed, I just tested Tasyen's idea and it worked like a charm. You won't even have to change the events and conditions for your original trigger, just add an empty spell book then remove it.

This will still make it so the spell book remains open when a unit is ordered to cast a spell out of range, but then you just have to change the event and conditions to apply to orders instead, if you don't want that behavior.
 
Status
Not open for further replies.
Top