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

Moving Items in Inventory

Status
Not open for further replies.
Level 7
Joined
Jun 8, 2010
Messages
283
Currently I have a system that needs items to be moved around in the inventory.
If a unit uses an item in an inventory it will automatically be moved to the Unit's Slot 1 inventory.
If the unit uses an item and already has an item in the Slot 1 inventory, the item being used will switch places with the Slot 1 item.

Example:
So if I have a gun in Slot 2 and I click on it to equip it, it will automatically be moved to Slot 1. If I have a knife in Slot 1 but I want to equip an Axe in Slot 4. The Axe will be moved to Slot 1 and the Knife will be moved to Slot 4.

Reward: +Rep
 
Level 7
Joined
Jun 8, 2010
Messages
283
But how would I do it so that it will move the item to the next available item slot?
For example if 2 is not empty, then it will check slot , then 4 and so on.

Itd be helpful if you post the triggers for each case I mentioned in the first post. It would be easier for me to implement and modify it to my needs.

Anyways I already know the trigger, I just dont know how to check in a loop whether a inventory slot is empty, and if its occupied the loop will check the next slot.
  • Item - Move (Last created item) to (Center of (Playable map area))
  • [/trigger
 
Last edited:
Level 7
Joined
Jun 8, 2010
Messages
283
Note: Sorry for double posting but theres been several changes to the trigger thatll need a bump since Ive discussed with several different people.

Well, I got it working now with the below trigger however when I use an item in Slot 1 and theres an Item in Slot 2, the item in Slot 2 is kicked into Slot 3 and Slot 3 is kicked into slot 4 and so on.

Can anyone explain why?

EDIT: To describe the behavior of the items, they "jump" around when using items that are adjacent to one another.

  • chaos m16a4
    • Events
      • Unit - A unit Uses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to M16-A4 Assault Rifle
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Hero manipulating item)) Equal to TUCU Marine (M16A4)
        • Then - Actions
          • For each (Integer A) from 2 to 6, do (Actions)
            • Loop - Actions
              • Unit - Order (Hero manipulating item) to move (Item carried by (Hero manipulating item) in slot 1) to inventory slot (Integer A)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Hero manipulating item) has (Item carried by (Hero manipulating item) in slot 1)) Equal to False
            • Then - Actions
              • Unit - Order (Hero manipulating item) to move (Item being manipulated) to inventory slot 1
              • -------- sets item used to slot 1 --------
            • Else - Actions
          • Item - Set charges remaining in (Item being manipulated) to ((Charges remaining in (Item being manipulated)) + 1)
          • Unit - Add Chaos (Melee) to (Hero manipulating item)
          • Special Effect - Destroy flashlight_fx[(Player number of (Owner of (Hero manipulating item)))]
          • Special Effect - Create a special effect attached to the overhead of (Casting unit) using war3mapImported\LIght_Flashlight_22.MDX
          • Set flashlight_fx[(Player number of (Owner of (Casting unit)))] = (Last created special effect)
        • Else - Actions
          • For each (Integer A) from 2 to 6, do (Actions)
            • Loop - Actions
              • Unit - Order (Hero manipulating item) to move (Item carried by (Hero manipulating item) in slot 1) to inventory slot (Integer A)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Hero manipulating item) has (Item carried by (Hero manipulating item) in slot 1)) Equal to False
            • Then - Actions
              • Unit - Order (Hero manipulating item) to move (Item being manipulated) to inventory slot 1
              • -------- ^^^ Automatically set item to nearest availible slot --------
            • Else - Actions
          • Item - Set charges remaining in (Item being manipulated) to ((Charges remaining in (Item being manipulated)) + 1)
          • Unit - Add Chaos (m16a4) to (Hero manipulating item)
          • Special Effect - Destroy flashlight_fx[(Player number of (Owner of (Hero manipulating item)))]
          • Special Effect - Create a special effect attached to the overhead of (Casting unit) using war3mapImported\LIght_Flashlight_22.MDX
          • Set flashlight_fx[(Player number of (Owner of (Casting unit)))] = (Last created special effect)
 
Last edited:
Level 13
Joined
Mar 4, 2009
Messages
1,156
to set to nearest slot just drop the item and give it a gain (try just giveing it too)
Hero - drop item
Hero - give item

and use (Triggering Unit) for everything taht you can,also use (Triggering Player) because it is same as (Onwer of(Unit(Triggerng Unit)))
 
Status
Not open for further replies.
Top