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

Item gives ability

Status
Not open for further replies.
Level 1
Joined
Jul 6, 2021
Messages
2
hi,

Is it possible to through the object editor to make an item give a hero an ability? Say, if the hero pics up orb of fire, he/she gets a Firebolt ability?


Thanks, Hultmanable
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,875
Edit: The Spell Book ability allows for this. The mysteries of the Spellbook

That being said, it can also be done through triggers. Note that this will act differently from a Spell Book which could be a good thing or a bad thing depending on what you want:

  • Events:
  • Unit - A unit Acquires an item
  • Conditions:
  • (Item-type of (Item being manipulated)) Equal to Orb of Fire
  • Actions:
  • Unit - Add Firebolt to (Triggering unit)

  • Events:
  • Unit - A unit Loses an item
  • Conditions:
  • (Item-type of (Item being manipulated)) Equal to Orb of Fire
  • Actions:
  • Unit - Remove Firebolt from (Triggering unit)

Now the problem here is that if you pick up 2 Orbs of Fire, and then drop 1 of them, you'll lose the Firebolt ability despite still having an extra Orb equipped. To fix this you need to count how many Orbs of Fire the unit has and use this number to determine what should happen:
  • Lose Orb of Fire
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Orb of Fire
    • Actions
      • Set VariableSet ItemCount = 0
      • For each (Integer InvSlot) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item carried by (Triggering unit) in slot InvSlot)) Equal to Orb of Fire
            • Then - Actions
              • Set VariableSet ItemCount = (ItemCount + 1)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ItemCount Less than or equal to 1
        • Then - Actions
          • Unit - Remove Firebolt from (Triggering unit)
        • Else - Actions
The math might seem weird here since it removes Firebolt when you have Less than or equal to 1 Orb, but that's because the Orb that you lost (dropped/sold/traded) is still considered in your Inventory when this Event goes off. That's why we have to account for it in our counting.
 

Attachments

  • Acquire Lose Item Ability.w3m
    17.4 KB · Views: 11
Last edited:
Status
Not open for further replies.
Top