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

Need help making a portable stash system.

Status
Not open for further replies.
Level 6
Joined
Dec 9, 2014
Messages
176
I need a way to cure the problem of only having 6 inventory slots in my RPG. While I would love to use some of the extravagant and awesome bag systems, I don't know how well they would work with the current systems I have for stacking and equipment, and I don't know Jass which a lot of them use.

So I was thinking about using an ability that instantly moves heroes over from a spot on the map the player will never see and changes their ownership from neutral passive to the player. Give the heroes the model of a closed chest and make it so they can't move or fight and are invulnerable. When the ability is used, a temporary region is created around your hero, if you leave this region the "chests" will change owner to say, neutral passive and will be instantly moved to the area of the map the player doesn't see and the region will be removed. The ability's level ca be upgraded every 10 levels, adding another chest to the stash and thereby increasing the stash size. This is a singleplayer map so I think this should work. I just need to know where I should start lol.
 
Level 6
Joined
Dec 9, 2014
Messages
176
No no, lol. The chests will be invulnerable so they don't get destroyed and you lose your stash lol. When the hero leaves the region the chests are teleported back to their area and changed ownership to neutral passive and the region is removed. Ability has little to no cooldown so you can reference it like an inventory any time you want.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
I see.

I want to point out that moving around X existing chests is a rather.. bad.. solution. The best option would be to store the items each chest carry into a variable and then put those items in a chest that you spawn each time the ability is cast.

This shouldn't be too much of an issue if you know hashtables.
 
Level 6
Joined
Dec 9, 2014
Messages
176
Well, I took my best shot at it and I can't seem to figure out what I did wrong. I don't know hashtables so I have to work with what I know. The system involves a lot of moving and needs a remove for the temporary region created around the player when they use the ability. From what I can tell, everything looks sound, but the ability wont even show up in the hero's ability slots. I'm gonna attach the map and hopefully someone can figure out what I did wrong. The Ability is simply called "Open Backpack" and the triggers are in the category "Stash System".
 

Attachments

  • WoE - MC 0.3.w3x
    11 MB · Views: 73

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
I will create a demo map for you. I will do it before I go to sleep sometime but you might need to wait between 20 mins and 4 hours depending on my motivation x)

Edit:
Ok the request turned out to be a real bitch. I think I had to use 3 methods before finding a working one.
  • init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set CS_hash = (Last created hashtable)
      • Set CS_number = 2
      • Set CS_dummy = Box Dummy
      • Set CS_range = 400.00
      • Game - Display to (All players) the text: press esc to summon...
  • summon chests
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Custom script: local integer i
      • Set CS_unit = Paladin 0000 <gen>
      • Set CS_loc = (Position of CS_unit)
      • Custom script: set i = GetHandleId(udg_CS_unit)
      • For each (Integer A) from 1 to CS_number, do (Actions)
        • Loop - Actions
          • Unit - Create 1 CS_dummy for (Owner of CS_unit) at CS_loc facing Default building facing degrees
          • Set CS_active_chests[(Integer A)] = (Last created unit)
          • Custom script: call SaveUnitHandle(udg_CS_hash, i, bj_forLoopAIndex, udg_CS_active_chests[bj_forLoopAIndex])
          • For each (Integer B) from 1 to 6, do (Actions)
            • Loop - Actions
              • Custom script: set udg_CS_item[ bj_forLoopBIndex] = LoadInteger(udg_CS_hash, i, bj_forLoopAIndex * 10 + bj_forLoopBIndex)
              • Hero - Create CS_item[(Integer B)] and give it to CS_active_chests[(Integer A)]
      • Custom script: call SaveLocationHandle(udg_CS_hash, i, udg_CS_number + 1, udg_CS_loc)
      • Unit Group - Add CS_unit to CS_group
  • remove chest
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in CS_group and do (Actions)
        • Loop - Actions
          • Custom script: local integer i = GetHandleId(GetEnumUnit())
          • Custom script: set udg_CS_loc = LoadLocationHandle(udg_CS_hash, i, udg_CS_number + 1)
          • Set CS_loc2 = (Position of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between CS_loc and CS_loc2) Greater than or equal to CS_range
            • Then - Actions
              • For each (Integer A) from 1 to CS_number, do (Actions)
                • Loop - Actions
                  • Custom script: set udg_CS_active_chests[bj_forLoopAIndex] = LoadUnitHandle(udg_CS_hash, i, bj_forLoopAIndex)
                  • For each (Integer B) from 1 to 6, do (Actions)
                    • Loop - Actions
                      • Set CS_item[(Integer B)] = (Item-type of (Item carried by CS_active_chests[(Integer A)] in slot (Integer B)))
                      • Custom script: call SaveInteger(udg_CS_hash, i, bj_forLoopAIndex * 10 + bj_forLoopBIndex, udg_CS_item[bj_forLoopBIndex])
                      • Item - Remove (Item carried by CS_active_chests[(Integer A)] in slot (Integer B))
                  • Unit - Add a 0.01 second Generic expiration timer to CS_active_chests[(Integer A)]
              • Unit Group - Remove (Picked unit) from CS_group
            • Else - Actions
Note: There are location leaks but I am too afraid to remove them since removing a saved handle will fuck up the system. I think you can remove "CS_loc2" without issues but you should never remove "CS_loc" if you want the system to work.
 

Attachments

  • Flex Inv System.w3x
    18.3 KB · Views: 65
Level 6
Joined
Dec 9, 2014
Messages
176
I will create a demo map for you. I will do it before I go to sleep sometime but you might need to wait between 20 mins and 4 hours depending on my motivation x)

Edit:
Ok the request turned out to be a real bitch. I think I had to use 3 methods before finding a working one.
  • init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set CS_hash = (Last created hashtable)
      • Set CS_number = 2
      • Set CS_dummy = Box Dummy
      • Set CS_range = 400.00
      • Game - Display to (All players) the text: press esc to summon...
  • summon chests
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Custom script: local integer i
      • Set CS_unit = Paladin 0000 <gen>
      • Set CS_loc = (Position of CS_unit)
      • Custom script: set i = GetHandleId(udg_CS_unit)
      • For each (Integer A) from 1 to CS_number, do (Actions)
        • Loop - Actions
          • Unit - Create 1 CS_dummy for (Owner of CS_unit) at CS_loc facing Default building facing degrees
          • Set CS_active_chests[(Integer A)] = (Last created unit)
          • Custom script: call SaveUnitHandle(udg_CS_hash, i, bj_forLoopAIndex, udg_CS_active_chests[bj_forLoopAIndex])
          • For each (Integer B) from 1 to 6, do (Actions)
            • Loop - Actions
              • Custom script: set udg_CS_item[ bj_forLoopBIndex] = LoadInteger(udg_CS_hash, i, bj_forLoopAIndex * 10 + bj_forLoopBIndex)
              • Hero - Create CS_item[(Integer B)] and give it to CS_active_chests[(Integer A)]
      • Custom script: call SaveLocationHandle(udg_CS_hash, i, udg_CS_number + 1, udg_CS_loc)
      • Unit Group - Add CS_unit to CS_group
  • remove chest
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in CS_group and do (Actions)
        • Loop - Actions
          • Custom script: local integer i = GetHandleId(GetEnumUnit())
          • Custom script: set udg_CS_loc = LoadLocationHandle(udg_CS_hash, i, udg_CS_number + 1)
          • Set CS_loc2 = (Position of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between CS_loc and CS_loc2) Greater than or equal to CS_range
            • Then - Actions
              • For each (Integer A) from 1 to CS_number, do (Actions)
                • Loop - Actions
                  • Custom script: set udg_CS_active_chests[bj_forLoopAIndex] = LoadUnitHandle(udg_CS_hash, i, bj_forLoopAIndex)
                  • For each (Integer B) from 1 to 6, do (Actions)
                    • Loop - Actions
                      • Set CS_item[(Integer B)] = (Item-type of (Item carried by CS_active_chests[(Integer A)] in slot (Integer B)))
                      • Custom script: call SaveInteger(udg_CS_hash, i, bj_forLoopAIndex * 10 + bj_forLoopBIndex, udg_CS_item[bj_forLoopBIndex])
                      • Item - Remove (Item carried by CS_active_chests[(Integer A)] in slot (Integer B))
                  • Unit - Add a 0.01 second Generic expiration timer to CS_active_chests[(Integer A)]
              • Unit Group - Remove (Picked unit) from CS_group
            • Else - Actions
Note: There are location leaks but I am too afraid to remove them since removing a saved handle will fuck up the system. I think you can remove "CS_loc2" without issues but you should never remove "CS_loc" if you want the system to work.

Thanks! I'll try this tomorrow and see how it fits.
 
Status
Not open for further replies.
Top