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

[General] Backpack System Problem

Status
Not open for further replies.
So I made a bag system. You have two bags - main and second. The problem here is that When both bags are full and I try to switch from the second to the main nothing happens except that the ability is switched.

To explain the trigger easier:
I create two bags for each player in the initialization.
When you switch to the second bag the items from your hero go to the first bag and the items from the second bag go to your hero
when switch to main bag the items from your hero go to the second bag and the items from the main bag go to the hero.

  • Hero Backpack
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Use Main Backpack
        • Then - Actions
          • Set B_P_N = (Player number of (Owner of (Triggering unit)))
          • Hero - Give (Item carried by Hero[B_P_N] in slot 1) to Backpack_Secondary[B_P_N]
          • Hero - Give (Item carried by Hero[B_P_N] in slot 2) to Backpack_Secondary[B_P_N]
          • Hero - Give (Item carried by Hero[B_P_N] in slot 3) to Backpack_Secondary[B_P_N]
          • Hero - Give (Item carried by Hero[B_P_N] in slot 4) to Backpack_Secondary[B_P_N]
          • Hero - Give (Item carried by Hero[B_P_N] in slot 5) to Backpack_Secondary[B_P_N]
          • Hero - Give (Item carried by Hero[B_P_N] in slot 6) to Backpack_Secondary[B_P_N]
          • -------- ----------------------- --------
          • Hero - Give (Item carried by Backpack_Main[B_P_N] in slot 1) to Hero[B_P_N]
          • Hero - Give (Item carried by Backpack_Main[B_P_N] in slot 2) to Hero[B_P_N]
          • Hero - Give (Item carried by Backpack_Main[B_P_N] in slot 3) to Hero[B_P_N]
          • Hero - Give (Item carried by Backpack_Main[B_P_N] in slot 4) to Hero[B_P_N]
          • Hero - Give (Item carried by Backpack_Main[B_P_N] in slot 5) to Hero[B_P_N]
          • Hero - Give (Item carried by Backpack_Main[B_P_N] in slot 6) to Hero[B_P_N]
          • -------- ----------------------- --------
          • Unit - Remove Use Main Backpack from (Triggering unit)
          • Unit - Add Use Second Backpack to (Triggering unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Use Second Backpack
        • Then - Actions
          • Set B_P_N = (Player number of (Owner of (Triggering unit)))
          • Hero - Give (Item carried by Hero[B_P_N] in slot 1) to Backpack_Main[B_P_N]
          • Hero - Give (Item carried by Hero[B_P_N] in slot 2) to Backpack_Main[B_P_N]
          • Hero - Give (Item carried by Hero[B_P_N] in slot 3) to Backpack_Main[B_P_N]
          • Hero - Give (Item carried by Hero[B_P_N] in slot 4) to Backpack_Main[B_P_N]
          • Hero - Give (Item carried by Hero[B_P_N] in slot 5) to Backpack_Main[B_P_N]
          • Hero - Give (Item carried by Hero[B_P_N] in slot 6) to Backpack_Main[B_P_N]
          • -------- ----------------------- --------
          • Hero - Give (Item carried by Backpack_Secondary[B_P_N] in slot 1) to Hero[B_P_N]
          • Hero - Give (Item carried by Backpack_Secondary[B_P_N] in slot 2) to Hero[B_P_N]
          • Hero - Give (Item carried by Backpack_Secondary[B_P_N] in slot 3) to Hero[B_P_N]
          • Hero - Give (Item carried by Backpack_Secondary[B_P_N] in slot 4) to Hero[B_P_N]
          • Hero - Give (Item carried by Backpack_Secondary[B_P_N] in slot 5) to Hero[B_P_N]
          • Hero - Give (Item carried by Backpack_Secondary[B_P_N] in slot 6) to Hero[B_P_N]
          • -------- ----------------------- --------
          • Unit - Remove Use Second Backpack from (Triggering unit)
          • Unit - Add Use Main Backpack to (Triggering unit)
        • Else - Actions
 
Last edited:
Level 4
Joined
Dec 24, 2010
Messages
67
Sorry, I'm bad at explaining so I just edited your system.
It works now. It might look little too advance, but it's not, trust me. I put comments there for brief explanations anyway.

I made it leakless and MUI. Just download the map below.

  • BackpackSecond
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Use Second Backpack
    • Actions
      • -------- We first set the variable of a temporary unit we will use, which is the caster. --------
      • Set TempUnit = (Triggering unit)
      • -------- --------
      • -------- --------
      • -------- This is how we get the unique id of a unit. Every unit has one. Kinda like a human DNA. --------
      • Custom script: set udg_TempHandle = GetHandleId( udg_TempUnit )
      • -------- --------
      • For each (Integer TempInteger) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set TempPoint = (Random point in Region 000 <gen>)
          • Set TempItem = (Item carried by TempUnit in slot TempInteger)
          • -------- --------
          • -------- If slot not empty, drop and move the item. --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TempItem Not equal to No item
            • Then - Actions
              • Item - Move TempItem to TempPoint
            • Else - Actions
              • -------- --------
              • -------- We use the dummy item NO_ITEM because the standard NoItem is buggy! Blame blizzard. --------
              • Set TempItem = NO_ITEM
          • -------- --------
          • -------- Below, we save the item in a Hashtable, using the casting unit's unique id (every unit has unique id for them) --------
          • Hashtable - Save Handle OfTempItem as (TempInteger - 1) of TempHandle in BackpackTable
          • -------- --------
          • -------- Now, we load the items we saved in the Main backpack. --------
          • Set TempItem = (Load (TempInteger + 5) of TempHandle in BackpackTable)
          • -------- --------
          • -------- If Second backpack slot is not empty, give the item to unit. --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TempItem Not equal to NO_ITEM
            • Then - Actions
              • Hero - Give TempItem to TempUnit
              • Unit - Order TempUnit to move TempItem to inventory slot TempInteger
            • Else - Actions
          • -------- --------
          • -------- This is how to remove location leaks. But don't mind this for now. Just copy and paste it for the time being. --------
          • Custom script: call RemoveLocation ( udg_TempPoint )
      • -------- --------
      • -------- --------
      • -------- You know these stuff already --------
      • Unit - Remove Use Second Backpack from TempUnit
      • Unit - Add Use Main Backpack to TempUnit
      • -------- --------
      • -------- You don't have to memorize all this if you don't understand, Trust me, I learned these things automatically by copying and pasting over time. --------

Edit:
 

Attachments

  • YourAlternativeBackpackXYZzz.w3x
    26.6 KB · Views: 50
Last edited:
Status
Not open for further replies.
Top