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

[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,266
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