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

[Trigger] Moving Items To And From Regions

Status
Not open for further replies.
Level 6
Joined
Apr 1, 2009
Messages
201
I created a trigger for my inventory system and am having trouble with the conditions. My inventory system is where you get items from killing units and those items are placed in a player specific region, known as there inventory. The inventory is broken up into 2 regions, one is your regular inventory and the other half is your safe inventory in a sense. The reason for two regions is so you can sell items in one region and keep the ones you want in another when they build up. Each player has 2 inventory regions. What I'm trying to do is make a trigger where items can be moved to and from one of the regions only by the player that owns the inventory. Right now I'm making the trigger to send items to the inventory, then I will build off of that to take items out of the inventory. I think the problem is with the conditions. I'm trying to figure out how to make items that are dropped move into the inventory. The conditions are the item has to be yours, not in another players inventory, and not in the region you are trying to move it to. The problem is items can be moved from any players inventory and any not owned item on the ground.


  • Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Player Group - Pick every player in (All allies of Player 9 (Gray)) and do (Actions)
        • Loop - Actions
          • Visibility - Create an initially Enabled visibility modifier for (Picked player) emitting Visibility across Inventory Region <gen>
      • -------- Player and Player's Inventory --------
      • Set PlayerGroupOne[1] = Player 1 (Red)
      • Set PlayerInventory[1] = Player 1 Inventory <gen>
      • Set PlayerGroupOne[2] = Player 2 (Blue)
      • Set PlayerInventory[2] = Player 2 Inventory <gen>
      • Set PlayerGroupOne[3] = Player 3 (Teal)
      • Set PlayerInventory[3] = Player 3 Inventory <gen>
      • Set PlayerGroupOne[4] = Player 4 (Purple)
      • Set PlayerInventory[4] = Player 4 Inventory <gen>
      • Set PlayerGroupOne[5] = Player 5 (Yellow)
      • Set PlayerInventory[5] = Player 5 Inventory <gen>
      • Set PlayerGroupOne[6] = Player 6 (Orange)
      • Set PlayerInventory[6] = Player 6 Inventory <gen>
      • Set PlayerGroupOne[7] = Player 7 (Green)
      • Set PlayerInventory[7] = Player 7 Inventory <gen>
      • Set PlayerGroupOne[8] = Player 8 (Pink)
      • Set PlayerInventory[8] = Player 8 Inventory <gen>
      • -------- Player and Player's Safe Inventory --------
      • Set PlayerGroupTwo[1] = Player 1 (Red)
      • Set PlayerSafeInventory[1] = Player 1 Safe Inventory <gen>
      • Set PlayerGroupTwo[2] = Player 2 (Blue)
      • Set PlayerSafeInventory[2] = Player 2 Safe Inventory <gen>
      • Set PlayerGroupTwo[3] = Player 3 (Teal)
      • Set PlayerSafeInventory[3] = Player 3 Safe Inventory <gen>
      • Set PlayerGroupTwo[4] = Player 4 (Purple)
      • Set PlayerSafeInventory[4] = Player 4 Safe Inventory <gen>
      • Set PlayerGroupTwo[5] = Player 5 (Yellow)
      • Set PlayerSafeInventory[5] = Player 5 Safe Eventory <gen>
      • Set PlayerGroupTwo[6] = Player 6 (Orange)
      • Set PlayerSafeInventory[6] = Player 6 Safe Inventory <gen>
      • Set PlayerGroupTwo[7] = Player 7 (Green)
      • Set PlayerSafeInventory[7] = Player 7 Safe Inventory <gen>
      • Set PlayerGroupTwo[8] = Player 8 (Pink)
      • Set PlayerSafeInventory[8] = Player 8 Safe Inventory <gen>
  • Move To Inventory
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Move To Inventory [Y]
    • Actions
      • Set DisplayForce = (Player group((Triggering player)))
      • Set MoveItemCaster = (Owner of (Triggering unit))
      • For each (Integer MoveToInvenInt) from 1 to 8, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CustomValueIO Equal to 0
              • MoveItemCaster Equal to PlayerGroupOne[MoveToInvenInt]
              • MoveItemCaster Equal to PlayerGroupTwo[MoveToInvenInt]
              • Or - Any (Conditions) are true
                • Conditions
                  • ((Target item of ability being cast) is in PlayerInventory[MoveToInvenInt]) Equal to False
                  • ((Target item of ability being cast) is in PlayerSafeInventory[MoveToInvenInt]) Equal to True
            • Then - Actions
              • Set PlayerInventoryRegion = (Center of PlayerInventory[MoveToInvenInt])
              • Item - Move (Target item of ability being cast) to PlayerInventoryRegion
              • Custom script: call RemoveLocation(udg_PlayerInventoryRegion)
            • Else - Actions
              • Game - Display to DisplayForce the text: Invalid Item
              • Custom script: call DestroyForce(udg_DisplayForce)
              • Skip remaining actions
 
Last edited:
Level 3
Joined
Nov 16, 2011
Messages
54
  • CustomValueIO Equal to 0
What is this function? Where are you setting it, to what is it referring, for what is used?
 
Level 17
Joined
Jun 17, 2010
Messages
2,275
Your global variable works at an instance of all 8 players at one time, so no matter what it will work for every player. You dont even need Integer function because you are using the Unit Casts Ability so you can just use the triggering unit/player function. The Global Variable 1-8 is why it doesnt work.

  • Move To Inventory
  • Events
    • Unit - A unit Begins casting an ability
  • Conditions
    • (Ability being cast) Equal to Move To Inventory [Y]
  • Actions
    • Set DisplayForce = (Player group((Triggering player)))
    • Set MoveItemCaster = (Owner of (Triggering unit))
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • CustomValueIO Equal to 0
        • MoveItemCaster Equal to PlayerGroupOne[(Player number of (MoveItemCaster))]
        • MoveItemCaster Equal to PlayerGroupTwo[(Player number of (MoveItemCaster))]
        • Or - Any (Conditions) are true
          • Conditions
            • ((Target item of ability being cast) is in PlayerInventory[(Player number of (MoveItemCaster))]) Equal to False
            • ((Target item of ability being cast) is in PlayerSafeInventory[(Player number of (MoveItemCaster))]) Equal to True
      • Then - Actions
        • Set PlayerInventoryRegion = (Center of PlayerInventory[(Player number of (MoveItemCaster))])
        • Item - Move (Target item of ability being cast) to PlayerInventoryRegion
        • Custom script: call RemoveLocation(udg_PlayerInventoryRegion)
      • Else - Actions
        • Game - Display to DisplayForce the text: Invalid Item
        • Custom script: call DestroyForce(udg_DisplayForce)
        • Skip remaining actions
 
Level 6
Joined
Apr 1, 2009
Messages
201
Could you draw it? I couldnt really get it with that wall of text at the top ^^

  • Item Ownership
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • Set ItemVariableIO = (Item being manipulated)
      • Set CustomValueIO = (Custom value of ItemVariableIO)
      • Set PlayerNumberIO = (Player number of (Triggering player))
      • Set ForcePlayerGroupIO = (Player group((Triggering player)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CustomValueIO Equal to 0
        • Then - Actions
          • Item - Set the custom value of ItemVariableIO to PlayerNumberIO
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CustomValueIO Not equal to PlayerNumberIO
            • Then - Actions
              • Hero - Drop ItemVariableIO from (Triggering unit)
              • Game - Display to ForcePlayerGroupIO the text: This item does not ...
              • Custom script: call DestroyForce(udg_ForcePlayerGroupIO)
            • Else - Actions
Your global variable works at an instance of all 8 players at one time, so no matter what it will work for every player. You dont even need Integer function because you are using the Unit Casts Ability so you can just use the triggering unit/player function. The Global Variable 1-8 is why it doesnt work.

Ahhhh so that's why it wasn't working. Thank you but I ran into a problem when I changed the trigger and I'm thinking of a way to fix it now but am having no luck. The player can't move an item they own to there inventory becuase it's set as the item can only be moved if it's not owned. I tried adding to the or conditions if it belongs to the player he can move it, but no luck :/ The trigger posted above is the item ownership trigger.
 
Level 6
Joined
Apr 1, 2009
Messages
201
LIke This?

  • Move To Inventory
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Move To Inventory [Y]
    • Actions
      • Set DisplayForce = (Player group((Triggering player)))
      • Set MoveItemCaster = (Owner of (Triggering unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CustomValueIO Equal to 0
          • MoveItemCaster Equal to PlayerGroupOne[(Player number of MoveItemCaster)]
          • MoveItemCaster Equal to PlayerGroupTwo[(Player number of MoveItemCaster)]
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CustomValueIO Equal to PlayerNumberIO
              • ((Target item of ability being cast) is in PlayerInventory[(Player number of MoveItemCaster)]) Equal to False
              • ((Target item of ability being cast) is in PlayerSafeInventory[(Player number of MoveItemCaster)]) Equal to True
            • Then - Actions
              • Set PlayerInventoryRegion = (Center of PlayerInventory[(Player number of MoveItemCaster)])
              • Item - Move (Target item of ability being cast) to PlayerInventoryRegion
              • Custom script: call RemoveLocation(udg_PlayerInventoryRegion)
            • Else - Actions
              • Game - Display to DisplayForce the text: Invalid Item
              • Custom script: call DestroyForce(udg_DisplayForce)
        • Else - Actions
          • Game - Display to DisplayForce the text: Invalid Item
          • Custom script: call DestroyForce(udg_DisplayForce)
 
Level 17
Joined
Jun 17, 2010
Messages
2,275
  • Move To Inventory
  • Events
    • Unit - A unit Begins casting an ability
  • Conditions
    • (Ability being cast) Equal to Move To Inventory [Y]
  • Actions
    • Set DisplayForce = (Player group((Triggering player)))
    • Set MoveItemCaster = (Owner of (Triggering unit))
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • CustomValueIO Equal to 0
        • MoveItemCaster Equal to PlayerGroupOne[(Player number of (MoveItemCaster))]
        • MoveItemCaster Equal to PlayerGroupTwo[(Player number of (MoveItemCaster))]
        • Or - Any (Conditions) are true
          • Conditions
            • ((Target item of ability being cast) is in PlayerInventory[(Player number of (MoveItemCaster))]) Equal to False
            • ((Target item of ability being cast) is in PlayerSafeInventory[(Player number of (MoveItemCaster))]) Equal to True
      • Then - Actions
        • Set PlayerInventoryRegion = (Center of PlayerInventory[(Player number of (MoveItemCaster))])
        • Item - Move (Target item of ability being cast) to PlayerInventoryRegion
        • Custom script: call RemoveLocation(udg_PlayerInventoryRegion)
      • Else - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • ((A condition that states the item is owned by the Player))
            • ((The item is in group one))
          • Then - Actions
            • ((Set Variable))
            • Item - Move (Target item of ability being cast) to ((Group 2))
            • ((Fix leak))
          • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • ((A condition that states the item is owned by the Player))
                • ((The item is in group two))
              • Then - Actions
                • ((Set Variable))
                • Item - Move (Target item of ability being cast) to ((Group 1))
                • ((Fix leak))
              • Else - Actions
                • Game - Display to DisplayForce the text: Invalid Item
                • Custom script: call DestroyForce(udg_DisplayForce)
                • Skip remaining actions
 
Level 6
Joined
Apr 1, 2009
Messages
201
Hmmm I think I made things confusing but

  • ((Set Variable))
  • Item - Move (Target item of ability being cast) to ((Group 2))
  • ((Fix leak))
  • ((Set Variable))
  • Item - Move (Target item of ability being cast) to ((Group 1))
  • ((Fix leak))
I wanted the item to go to here no matter what the condition

  • Set PlayerInventoryRegion = (Center of PlayerInventory[(Player number of (MoveItemCaster))])
Player group 1 is for my set variables of the player and the region they own. Thats where I want the items to go. Player group 2 is the second part of the inventory and is where my set variables are for the player and second part of there inventory known as the safe region. If an item is in the safe region it can be moved to the player group 1 region.
 
Status
Not open for further replies.
Top