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

Refill bottle

Status
Not open for further replies.
Level 6
Joined
Jun 20, 2012
Messages
195
So I'm working on a map and it has this item Enchanted Vial, when the item is used, it will be replaced by an Empty Vial and will be placed on the same slot in the inventory. I want the Empty Vial to be replaced by Enchanted Vial whenever the hero is near a fountain. I've been working on this for days now still no progress. can someone show me how to do this.


*Note: The Enchanted Vial should be placed the same in the slot as the Empty Vial in the Inventory.
 
I'm having problems searching for a function that places units around the inventory. However you could use this. Remember to only have one item, make it charged and unperishable.
  • Refill
    • Events
      • Unit - A unit comes within 800.00 of Archer 0001 <gen>
    • Conditions
    • Actions
      • Item - Set charges remaining in (Item carried by (Triggering unit) of type Echanted Vial) to 1
 
I'm having problems searching for a function that places units around the inventory.

However, I did not check the JASS list.
JASS:
call UnitAddItemToSlotById(unit whichUnit, integer itemid, integer itemSlot)

Item ID is the.. Item ID. Press Ctrl D in Object Editor to find an item's ID.
JASS:
call UnitRemoveItemFromSlot(unit whichUnit, integer itemSlot)
 
Last edited:
Level 6
Joined
Jun 20, 2012
Messages
195
  • call UnitAddItemToSlotById(udg_TempUnit, 'crys', 5)
is this correct? however can I use a variable for the itemID? is ther a custom script to take an item's ID?

like get itemID of item in slot 1 ..something like that maybe.
 
I didn't know that you'd need that because you would probably know the ItemId via Ctrl D in Object Editor.

Also remember to do it in this order:
set udg_TempInteger =
JASS:
InventoryItemTypeSlot
JASS:
function InventoryItemTypeSlot takes integer itemid, unit u returns integer
    local integer a = -1
    local integer b = 0
    loop
        set a = a + 1
        exitwhen a == 6
        if GetItemTypeId(GetItemInSlot(u, a)) == i then
            set b = a
            set a = 6
        endif
    endloop
    return b
endfunction

Then check if the variable is greater than 0. Afterwards;
call UnitRemoveItemFromSlot(udg_TempUnit, udg_TempInteger)

Then:
call UnitAddItemToSlotById(udg_TempUnit, itemid, udg_TempInteger)
 
Level 6
Joined
Jun 20, 2012
Messages
195
Not necessarily it's just additional information for me, coz what if I have many items that changes when used? let's say first click it becomes this, then next click it becomes that..do I need to make a trigger for each? but anyways thanks very much.. +REP to you and I'll be sure to include you in the credits when I finish this map ..:)
 
Status
Not open for further replies.
Top