• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Switching Attack Index

Not open for further replies.
Hi, I was wondering if anyone could help me out with a skill I'm trying to give an unit. Basically, this unit has a skill which is an activate/deactivate type (e.g. Immolation) and when the skill activates, the unit switches to attack index 1 which is ranges, and when the skill deactivate, the unit switches back to attack index 2, a melee attack.

I've tried doing it with triggers but there doesn't seem to be any GUI triggers for that. If anyone has a solution (other than making 2 versions of the unit and having the skill actually swap between the two a la Bear Form etc - I'd prefer to avoid that) that would be awesome. I suppose it might be feasible in JASS, but I can't code for the life of me. But if you have lines of custom scripts that might work, please help, I'm not totally hopeless :p

Also, I don't think Orb effects would work because as far as I know they can only enable and not disable an attack index, which I need to happen. Enable 1, disable 2; disable 1, enable 2.

And finally, are there any autocasts abilities that enable a unit to use an unused attack index?
You can always use Spell Book and any Item Attack bonus (lightning for example).

Add item ability into spell book and add spell book to hero as unit ability. Hide it with disable ability trigger for your player!
You can also create levels to allow turning this on or off, or simple adding or removing ability...

Here test:
Paladin: you won't be able to attack enemy unit's until you pick up item!
Mountain King: can attack enemy units right away, because he already have ability (you can see +6 damage left only so you can see difference)


  • test map.w3x
    16.5 KB · Views: 52
Hmm, interesting. So what I can do is have my unit with a default of no attack index enabled, then have 2 orb effects that each enable one of the two indexes. +rep to you -Kobas- :)

EDIT: Okay, so in theory, it should work, but we all know the editor doesn't really care for logic. So... my unit has her default melee attack, but when she makes the switch to ranged... nothing happens. I have 2 spellbook spell (each contains one index enabler ability), both which I have disabled at game start. Unit has no attacks enabled by default but also starts with a spellbook spell which contains index 2 enabler (melee attack). When she activates immolation, spellbook 2 is supposed to be removed and replaced with spellbook 1 (ranged). Nada.

EDIT 2: Still no fix, but spellbooks aren't necessary since the index enablers don't have icons or tooltips etc. Can just add them directly. Just a thought.

EDIT 3: Tried with items. Didn't work. Seems the index enablers enable index 2 regardless of which number you tell it to enable. Seems Bear Form it is then :(
Last edited:
  • This will work
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Thunder Clap
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • a Equal to False
        • Then - Actions
          • Unit - Remove Spell Book unit from Mountain King 0007 <gen>
          • Set a = True
          • Game - Display to (All players) for 3.00 seconds the text: Melee Attack
        • Else - Actions
          • Unit - Add Spell Book unit to Mountain King 0007 <gen>
          • Set a = False
          • Game - Display to (All players) for 3.00 seconds the text: Ranged Attack
Add this into test map and try it will work :D
Hero use same ability to activate and deactivate range attack!

Oh add this into initialization trigger ↓
  • Untitled Trigger 001
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Player - Disable Spell Book unit for Player 1 (Red)
      • Set a = False
a = false if units have ability
a = true if they don't have ability already
Level 37
Mar 6, 2006
You can also cast silence on the unit to disable the main attack and then add item to enable attack 2. Then you attack ground units with ranged attack also.

However you won't see the attack type and damage when silenced, and you see a buff icon.


@Kobas, why not check the sb level and not use a boolean. That would make it MUI. Also can you make it attack ground units with ranged attack?
Well bonus item attacks enable or disable attack index (1 or 2 or both)
Also can you make it attack ground units with ranged attack?
You need to edit unit settings do do that

why not check the sb level and not use a boolean. That would make it MUI
Dunno this looked as easiest solution
Not open for further replies.