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

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 64
Joined
Aug 10, 2018
Messages
6,583
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: 5
Last edited:
Status
Not open for further replies.
Top