• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Magical Bottle

Status
Not open for further replies.
Level 11
Joined
Jan 23, 2015
Messages
788
I'm not that dumb but I just can't think of anything right now - like making a magical bottle item that gets empty when used and can be refilled again, similar with DotA's bottle.
I've already tried creating triggers on my own, but there's always something wrong, so I'm saying there's gotta be someone who already made a bottle and will help me a bit? :)
 
Level 11
Joined
Jan 23, 2015
Messages
788
I don't mind but my PC is not available right now
But I know I made two triggers - one for emptying the bottle and one for filling it. I just change the item by dropping it, destroying it and giving the hero an empty/full bottle(I know it's not the best way, that's why I'm asking). The problem is when I use the bottle it doesn't get empty..
 

EdgeOfChaos

E

EdgeOfChaos

When a unit uses an item:
If (item = full bottle)
Remove item
Give hero 2/3 bottle
ElseIf (item = 2/3 bottle)
Remove item
Give hero 1/3 bottle
ElseIf (item = 1/3 bottle)
Remove item
Give hero empty bottle.

Every 0.5 seconds of the game:
Select every unit in region FillRegion matching condition: unit has item of empty bottle, 1/3, or 2/3 bottle:
Remove item carried by hero of type empty bottle etc...
Give hero item (full bottle)

This should work. Tell me if it doesn't and I'll help out with world editor (this is only psuedocode)
 
Level 22
Joined
Feb 6, 2014
Messages
2,466
When a unit uses an item:
If (item = full bottle)
Remove item
Give hero 2/3 bottle
ElseIf (item = 2/3 bottle)
Remove item
Give hero 1/3 bottle
ElseIf (item = 1/3 bottle)
Remove item
Give hero empty bottle.

Every 0.5 seconds of the game:
Select every unit in region FillRegion matching condition: unit has item of empty bottle, 1/3, or 2/3 bottle:
Remove item carried by hero of type empty bottle etc...
Give hero item (full bottle)

This should work. Tell me if it doesn't and I'll help out with world editor (this is only psuedocode)

This is basically it. The only downside to that is the Bottle may changed to a new slot if it happens to have a free slot above.
 
Level 22
Joined
Feb 6, 2014
Messages
2,466
That's why I said it's not the best way, i think I need to store the slot of the full bottle before i change it for an empty one, when i change it i'll use the stored slot. But I can't see if it's actually possible..

Here take a look at the actual Magic Bottle script from my map.
JASS:
function MagicBottleActivated takes nothing returns nothing
    local integer i = 0
    local unit u = GetTriggerUnit()
    local item bottle = GetManipulatedItem()
    
    loop
        exitwhen i > 5
        if (UnitItemInSlot(u, i) == bottle) then
            if (GetItemTypeId(bottle) == 'I01L') then //  3/3
                call RemoveItem(bottle)
                call UnitAddItemById(u, 'I01M')
            elseif (GetItemTypeId(bottle) == 'I02R') then //  3/3 shared
                call RemoveItem(bottle)
                call UnitAddItemById(u, 'I02Q')
            elseif (GetItemTypeId(bottle) == 'I01M') then //  2/3 
                call RemoveItem(bottle)
                call UnitAddItemById(u, 'I01K')
            elseif (GetItemTypeId(bottle) == 'I02Q') then //  2/3 shared
                call RemoveItem(bottle)
                call UnitAddItemById(u, 'I02P')
            elseif (GetItemTypeId(bottle) == 'I01K') then //  1/3
                call RemoveItem(bottle)
                call UnitAddItemById(u, 'I01J')
                call SetItemUserData(UnitItemInSlot(u, i), iN)
            elseif (GetItemTypeId(bottle) == 'I02P') then //  1/3 shared
                call RemoveItem(bottle)
                call UnitAddItemById(u, 'I02N')
            endif
            set i = 5
            
        elseif (UnitItemInSlot(u, i) == null) then
            call UnitAddItemById(u, 'I01H')
        endif
        
        set i= i + 1
    endloop
    
        //Remove Space Takers Dummy item
        set i = 0
        loop
            exitwhen i > 5
            if (GetItemTypeId(UnitItemInSlot(u, i)) == 'I01H') then
                call RemoveItem(UnitItemInSlot(u, i))
            endif
            set i = i + 1
        endloop
    
    set u = null
    set bottle = null
    
endfunction

where 'I01H' is a dummy item whose purpose is to take up space in inventory slot.

Note: in my code, there exists two types of bottle (Normal Bottle and Shared Bottle).
 
Last edited:
Level 22
Joined
Feb 6, 2014
Messages
2,466
Just GUI, I'm gonna make a 1/1 bottle or maybe 2/2 don't know for sure..

  • Bottle Used
    • Events
      • Unit - A unit Uses an item
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Item-type of (Item being manipulated)) Equal to Bottle 1/3
          • (Item-type of (Item being manipulated)) Equal to Bottle 2/3
          • (Item-type of (Item being manipulated)) Equal to Bottle 3/3
    • Actions
      • Set yourUnit = (Triggering unit)
      • Set bottleItem = (Item being manipulated)
      • Set index = 1
      • Custom script: loop
      • Custom script: exitwhen udg_index > 6
      • Set tempItemType = (Item-type of (Item carried by yourUnit in slot index))
      • -------- If the item in slot (index) is equal to the used bottle --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • tempItemType Equal to (Item-type of bottleItem)
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • tempItemType Equal to Bottle 3/3
            • Then - Actions
              • Item - Remove bottleItem
              • Hero - Create Bottle 2/3 and give it to yourUnit
              • Custom script: exitwhen true
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • tempItemType Equal to Bottle 2/3
                • Then - Actions
                  • Item - Remove bottleItem
                  • Hero - Create Bottle 1/3 and give it to yourUnit
                  • Custom script: exitwhen true
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • tempItemType Equal to Bottle 1/3
                    • Then - Actions
                      • Item - Remove bottleItem
                      • Hero - Create Empty Bottle and give it to yourUnit
                      • Custom script: exitwhen true
                    • Else - Actions
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • tempItemType Equal to (Item-type of No item)
            • Then - Actions
              • -------- Slot taker --------
              • Hero - Create Claws of Attack +15 and give it to yourUnit
            • Else - Actions
      • Set index = (index + 1)
      • Custom script: endloop
      • Set index = 1
      • Custom script: loop
      • Custom script: exitwhen udg_index > 6
      • Set tempItemType = (Item-type of (Item carried by yourUnit in slot index))
      • -------- If equal to Slot Taker --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • tempItemType Equal to Claws of Attack +15
        • Then - Actions
          • Item - Remove (Item carried by yourUnit in slot index)
        • Else - Actions
      • Set index = (index + 1)
      • Custom script: endloop
EDIT: Btw, I used claws of attack +15 as an item that takes slot then removed it afterwards. If you have that in your map, I suggest creating a new item whose sole purpose is to serves as a slot taker.
 

Attachments

  • Bote.w3x
    17.5 KB · Views: 74
Status
Not open for further replies.
Top