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

How to detect in which inventory slot is item?

Status
Not open for further replies.
Level 12
Joined
Mar 26, 2005
Messages
790
When hero uses an item, I need to replace it with another item in the same inventory slot

like

E:unit cast an ability X
C:abilit is ITEM_X
A:remove item ITEM_X from hero
create item ITEM_Z for hero
issue hero to place ITEM_Z to inventory slot x (x=inventory slot, where the item_x originally was)

but the last line is not as an option in gui.
 
Level 26
Joined
Mar 19, 2008
Messages
3,140
This should help you:
  • item replace
    • Events
      • Unit - A unit Starts effect of ability
    • Conditions
      • (Ability being cast) Equal to Item change
    • Actions
      • Set ItemX = (Target item of ability being cast)
      • Set ItemZ = Mask of Death
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item carried by (Triggering unit) in slot (Integer A)) Equal to ItemX
            • Then - Actions
              • Set i = (Integer A)
            • Else - Actions
      • Hero - Drop the item from slot i of (Triggering unit)
      • Item - Remove (Last dropped item)
      • Hero - Create ItemZ and give it to (Triggering unit)
      • Unit - Order (Triggering unit) to move (Last created item) to inventory slot i
 
Level 26
Joined
Mar 19, 2008
Messages
3,140
Unfortunately, I was checking that native by myself some time ago and it doesn't work, and even causes bugs sometimes.
Searched for explanation, found few interesting posts (like here and here). It is said to better leave the native alone, and work with dummy items or other tricks.

Sad, I thought that if given function is created, it should be bug-less and there should be proper purpose for it's creation.
 
Status
Not open for further replies.
Top