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

[Solved] Item Stacking

Status
Not open for further replies.
Level 4
Joined
Dec 12, 2012
Messages
96
I'm creating a trigger that increases an item's charges whenever heroes pick/acquire item of the same type. My trigger works, it adds charges but it doesn't remove the other item. And when I add ITEM - REMOVE, it just removes both items. How do I fix this?


  • Increase item charges
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Millenium Coin
    • Actions
      • Set MCoin1 = (Item carried by (Triggering unit) of type Millenium Coin)
      • Item - Set charges remaining in MCoin1 to ((Charges remaining in MCoin1) + 1)
 

TKF

TKF

Level 19
Joined
Nov 29, 2006
Messages
1,267
Ok I've looked in the editor. This is how I did the item stacking in Naval Battle.

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Charges remaining in (Item being manipulated)) Not equal to 0
    • Then - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-class of (Item being manipulated)) Equal to Purchasable
        • Then - Actions
          • 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-type of (Item carried by (Triggering unit) in slot (Integer A))) Equal to (Item-type of (Item being manipulated))
                  • (Item carried by (Triggering unit) in slot (Integer A)) Not equal to (Item being manipulated)
                • Then - Actions
                  • Item - Set charges remaining in (Item carried by (Triggering unit) in slot (Integer A)) to ((Charges remaining in (Item carried by (Triggering unit) in slot (Integer A))) + (Charges remaining in (Item being manipulated)))
                  • Item - Remove (Item being manipulated)
                • Else - Actions
        • Else - Actions
    • Else - Actions
I don't remember why I put those conditions, maybe to only remove items with charges only.

You can set it to specific item if you want.
 
Level 6
Joined
Dec 6, 2009
Messages
168
  • Player 1 Human
    • Events
      • Map initialization
    • Conditions
      • (Player 1 (Red) slot status) Equal to Is playing
    • Actions
      • Unit - Create 1 Adventurer for Player 1 (Red) at (Center of Human Player 1 <gen>) facing Default building facing degrees
      • Set Player1_Villager = (Last created unit)
      • Custom script: call InitEquipment(udg_Player1_Villager)
      • Hero - Create Health Stone and give it to Player1_Villager
      • Player Group - Make (All allies of Player 1 (Red)) treat (All allies of Player 1 (Red)) as an Ally with shared vision
  • Split
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
    • Actions
      • Custom script: set udg_order = GetIssuedOrderId()
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • order Greater than or equal to 852002
          • order Less than or equal to 852007
          • (Target item of issued order) Equal to (Item carried by (Ordered unit) in slot (order - 852001))
          • (Charges remaining in (Target item of issued order)) Greater than 1
        • Then - Actions
          • Item - Set charges remaining in (Target item of issued order) to ((Charges remaining in (Target item of issued order)) - 1)
          • Set L = (Position of (Ordered unit))
          • Item - Create (Item-type of (Target item of issued order)) at L
          • Custom script: call RemoveLocation(udg_L)
          • Item - Set charges remaining in (Last created item) to 1
        • Else - Actions
This works 100% and you can split the items aswell!
 
Level 4
Joined
Dec 12, 2012
Messages
96
  • Player 1 Human
    • Events
      • Map initialization
    • Conditions
      • (Player 1 (Red) slot status) Equal to Is playing
    • Actions
      • Unit - Create 1 Adventurer for Player 1 (Red) at (Center of Human Player 1 <gen>) facing Default building facing degrees
      • Set Player1_Villager = (Last created unit)
      • Custom script: call InitEquipment(udg_Player1_Villager)
      • Hero - Create Health Stone and give it to Player1_Villager
      • Player Group - Make (All allies of Player 1 (Red)) treat (All allies of Player 1 (Red)) as an Ally with shared vision
  • Split
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
    • Actions
      • Custom script: set udg_order = GetIssuedOrderId()
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • order Greater than or equal to 852002
          • order Less than or equal to 852007
          • (Target item of issued order) Equal to (Item carried by (Ordered unit) in slot (order - 852001))
          • (Charges remaining in (Target item of issued order)) Greater than 1
        • Then - Actions
          • Item - Set charges remaining in (Target item of issued order) to ((Charges remaining in (Target item of issued order)) - 1)
          • Set L = (Position of (Ordered unit))
          • Item - Create (Item-type of (Target item of issued order)) at L
          • Custom script: call RemoveLocation(udg_L)
          • Item - Set charges remaining in (Last created item) to 1
        • Else - Actions
This works 100% and you can split the items aswell!

I'm already using the Easy Item Stack but this seems simpler. Thanks +rep :)
 
Status
Not open for further replies.
Top