• 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.

Urgent unit item (damage/melee/ranged)

Status
Not open for further replies.
Level 9
Joined
Sep 20, 2015
Messages
385
It is possible but with some workaround.

I don't kow if you played the campaign but there is Rexxar that has melee range but can attack air units. Also the Alchemist in melee has the same set up. Other units do it too.

In unit editor, you can choose two attacks.

You can set the two attacks fields enabled to have 2 different attacks.
Set the two attacks disabled by default in object editor.

I don't know if it's still the same but you can enable and disable attacks for a unit. I don't know if there is a new way to do it via trigger or code, but you can enable/enable attacks with drunken haze ability or silence ability.
You can also use orbs based items abilities to enable one attack.


Obivously the method you choose will affect the triggers.

ORBS.
The orb should be the easiest one because you don't have to code abilities.

ABILITIES.
For abilities you can have 2 drunken haze abilities, one disable attack-1 the other attack-2.
Both abilities will have only one level, and if you press Shift+enter while a field is selected, you can put negative values in the object editor. So set the position XY to (0, -11). This way the icon will be invisible on the grid.

When the unit picks up an item do a item check and then add the disableAttack1 ability or disableattack2.
Obviously the ability will be removed if the item is dropped.


So if the unit does not have weapon items it has both attacks disabled, when he picks up an item, based on what type of item is you can enable the melee or the ranged attack.

This is an example trigger for the item pick up.

  • Untitled Trigger 001
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to Melee Weapon
        • Then - Actions
        • Choose one method here
        • Else - Actions

I don't know how it will work if both attacks are enabled but one attack enabled at time should work.
 
Status
Not open for further replies.
Top