IMP1

"haystack".scan(/needle/)
Veteran
Joined
Mar 6, 2014
Messages
70
Reaction score
45
First Language
English
Primarily Uses
RMVXA
Storage Boxes 1.12
by IMP1

Link to Script

Description:
Storage boxes allows you to set up containers (barrels, chests, banks, whatever you want) that can hold items. You can specifiy a limit for how many items a container can hold, and a name for a container. This script also includes a scene whereby you can move items between a container and the party. You can specify an item to be unstorable in its notebox, and set it so all key items are unstorable.

Screenshot(s):
8ZmsPWj.png

(Forgive the funky windowscreen)

Instructions:
Copy the script from the link and paste it into a new script in your project, above Main Process, and below Materials

Credit:
IMP1

Add-ons:
vFoggy has written some scripts to better allow gold withdrawals from boxes, as requested by tomkomaster, here.
Roninator2 has written an edit to set the sizes of the boxes to use game variables, as requested by
Lionheart123. That edit can be found here. I think this was previously doable by using the manual setup, but I guess this is easier for some people.

Previously, saving and loading a game would introduce a bug where the more than one of the same item would sometimes be split across different slots in a box. This is fixed in v1.12, but changes the way boxes work in a probably-not-backwards-compatible way. So for anyone wanting backwards, compatibility, Roninator2 has kinda provided a hotfix, which I hear works, so I'm linking in under Add-ons above. But this version is also deprecated, so for any new projects, use the latest version.

I'm almost completely inactive on these forums. I do get emails about new posts, so I'm happy to reply, but I don't use RMVXAce any more, so don't expect any major additions to this by me.
 
Last edited:

cygnus flamel

Veteran
Veteran
Joined
Feb 9, 2014
Messages
46
Reaction score
17
First Language
spanish
Primarily Uses
Nice script! this one with Theo´s limited inventory makes a good combo i can imagine something like skyrim
 

Kuro Neko

Veteran
Veteran
Joined
Sep 26, 2013
Messages
173
Reaction score
15
First Language
English
Primarily Uses
[IMG]http://i1147.photobucket.com/albums/o560/zabakapro/Untitled_zpsbc26c85b.jpg[/IMG]

Am i using it wrong or something? 'cause no matter how i tried, the storage scene won't appear with this event.

P/s: I'm testing it with a new project so there's no way it's a problem of compability.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
38,438
Reaction score
10,869
First Language
German
Primarily Uses
RMMV
Have you configured the box 4 in the script?


Because in default, only boxes 0, 1 and 2 are pre-defined - you cannot open a box that does not exist.
 

Kuro Neko

Veteran
Veteran
Joined
Sep 26, 2013
Messages
173
Reaction score
15
First Language
English
Primarily Uses
Have you configured the box 4 in the script?

Because in default, only boxes 0, 1 and 2 are pre-defined - you cannot open a box that does not exist.
tried it with 0, 1 and 2, too. In the default, of course. I just want to test it if it work. But somehow, it's not. It's not like the game crash or something, nothing happended, like an empty event. Just to make sure, that script call i've input is right, not wrong in something, right?
 

IMP1

"haystack".scan(/needle/)
Veteran
Joined
Mar 6, 2014
Messages
70
Reaction score
45
First Language
English
Primarily Uses
RMVXA
That might have been was me getting confused with VX.

Instead of

$scene = Scene_ItemStorage.new(4)
, you need the following:

SceneManager.call(Scene_ItemStorage)
SceneManager.scene.prepare(4)
Sorry. I've updated the script with the correct instruction.
 
Last edited by a moderator:

Dymdez

Newbie-in-Chief
Veteran
Joined
Feb 4, 2014
Messages
752
Reaction score
156
First Language
English
Primarily Uses
Hello, on line 288, where it scripts cancelling out of the transfer screen, is it possible to place a sound effect to signify "closing" the drawer? How would we add a sound effect here? I think it would greatly improve the script, in a most simple fashion! Thanks!

EDIT: Figured it out, on line 276 you can edit the sound that plays, awesome! Just replace the line that is there with the following:

RPG::SE.new("SE Name", volume, pitch).play
 
Last edited by a moderator:

IMP1

"haystack".scan(/needle/)
Veteran
Joined
Mar 6, 2014
Messages
70
Reaction score
45
First Language
English
Primarily Uses
RMVXA
So Dymdez has suggested the idea of having the possibilty of items being stolen from certain boxes with different probabilities. I thought this sounded like a cool idea, but I'm unsure how to work the logistics of this.


I was thinking that maybe the duration between visits to a box would increase the likelihood of items being stolen. But I'm not sure how to display that to the user.


Perhaps the time in seconds until the likelihood reaches 1?


Or the probability that an item is stolen every second (which would be performed multiple times to increase the chance with longer periods)?


Or a probability function with time as the independant variable?


Any suggestions from anyone?


Ideas


* Sounds on opening and closing of boxes (different boxes can have different sounds).


* Items being stolen at random (different boxes and different items can have different probabilities).
 
Last edited by a moderator:

Dymdez

Newbie-in-Chief
Veteran
Joined
Feb 4, 2014
Messages
752
Reaction score
156
First Language
English
Primarily Uses
So Dymdez has suggested the idea of having the possibilty of items being stolen from certain boxes with different probabilities. I thought this sounded like a cool idea, but I'm unsure how to work the logistics of this.

I was thinking that maybe the duration between visits to a box would increase the likelihood of items being stolen. But I'm not sure how to display that to the user.

Perhaps the time in seconds until the likelihood reaches 1?

Or the probability that an item is stolen every second (which would be performed multiple times to increase the chance with longer periods)?

Or a probability function with time as the independant variable?

Any suggestions from anyone?
IMP! Hey! Awesome you took my suggestion!! I don't mean to hijack my own idea, but could I clarify how I envisioned this?

Basically, you can add an attribute to each box, lets call it "Security Level." Security level could be either 1, 2, or 3.

The lower the security level, the more likely an item placed in a box (note, placed in by player, not there to begin with) would be "stolen" (stolen here just means deleted). The higher the security level, the less likely an item to be "stolen." The idea here is purely for flavor, we don't want someone to deposit their inventory in some random crate and come back days later and everything is there; it will help with immersion to make it so people have to go to secured places to have their items secure (like a bank, or player house). And furthermore, we could imagine building entire quests off of having a player's bank account robbed by an NPC, or something similarly awesome!

Also, I'll add that with the inventory limiting script by Theo, it really works because players will want to store items!
 
Last edited by a moderator:

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,206
Reaction score
874
First Language
Hungarian
Primarily Uses
RMVXA
The check for the item stolen should be executed only at the opening of the storage box.


The security level sounds like a good idea.


You could make a variable which will store the gameplay time of the last visit. Update this variable when the player leaves the storage box scene.


Make another variable for the current gameplay time. Update this only when the player opens the storage box scene.


After updating the second variable, here comes the fun part, the formula.


You can use a basic rand(x)+1 command multiplied by the security level minus the difference between the first and the second variable in minutes.


If the end result returns 0, the item is stolen, if not, it is not.


To twist it even further, you can add in another variable to the formula. This time, make a "steal likehood" variable for each item, which the developer could set up for each item individually.


Afterall, nobody would choose to steal a stinky rag over stealing a shiny golden bar, right?


You can then subtract this new variable too from the end result, so if the item got a high chance of being stolen, it will most probably be stolen after some time, while a rusty old sword would still be there. You can also use this variable to determine which item is stolen from the storage.


Just a few ideas of mine. :)


Whatever you do, do not make any real-time checks. It is not necessary and would bring down the FPS.


Check for stolen items only when the player opens a storage box.
 

Dymdez

Newbie-in-Chief
Veteran
Joined
Feb 4, 2014
Messages
752
Reaction score
156
First Language
English
Primarily Uses
Wow, Sixth, excellent post! Would it be possible to make the "steal likelihood" a function of the items value in gold?
 

IMP1

"haystack".scan(/needle/)
Veteran
Joined
Mar 6, 2014
Messages
70
Reaction score
45
First Language
English
Primarily Uses
RMVXA
The check for the item stolen should be executed only at the opening of the storage box.
Yeah, definitely. This is what I had in mind.
Sixth said:
You could make a variable which will store the gameplay time of the last visit. Update this variable when the player leaves the storage box scene.
I also already have this :p Are you reading my mind?

Each box holds the value it was last accessed (not including script calls changing a box's contents - although you can "touch" a box, which will update its last accessed time), and this is compared to when a box is opened, when the calculations are done.



Sixth said:
To twist it even further, you can add in another variable to the formula. This time, make a "steal likehood" variable for each item, which the developer could set up for each item individually.

Afterall, nobody would choose to steal a stinky rag over stealing a shiny golden bar, right?

You can then subtract this new variable too from the end result, so if the item got a high chance of being stolen, it will most probably be stolen after some time, while a rusty old sword would still be there. You can also use this variable to determine which item is stolen from the storage.
Would it be possible to make the "steal likelihood" a function of the items value in gold?
It could have a default formula for an item's liklihood, which can then be overridden with a notebox tag.
Sixth said:
You can use a basic rand(x)+1 command multiplied by the security level minus the difference between the first and the second variable in minutes.

If the end result returns 0, the item is stolen, if not, it is not.
So formula would be something like:
# t = time elapsed
# k = item's likelihood (or default based off value)
# p = probability that item is stolen
p = 1 + 1 / (-1 - t)
# This is setting p as a function of the time elapsed, between 0 and 1
# See http://www.wolframalpha.com/input/?i=y+=+1/(-1-x)+%2B+1
# Multiplying this by k means items with higher likelihoods are more likely to be stolen
p = k * (1 + 1/(-1 - t))
# Wolfram alpha says this is the equivilent to the following, which is a prettier/simpler equation.
p = k * t / (t + 1)Of course, any scripter (or brave non-scripter) could edit the method that returns the probabilty to suit their needs/wants.
I still have one more question. Should I just iterate through each item in the box and perform the calculation for each one, or should there be some way of determining the amount of items to check?

Also, how to incorporate the box itself (some boxes are more secure than others)? Maybe just also multiply by a box coefficient? So it'd be like:

Code:
p = b * k * t / (t + 1) # b = box, k = item, t = time
 
Last edited:

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,206
Reaction score
874
First Language
Hungarian
Primarily Uses
RMVXA
That math made me dizzy. :D

# x = module constant, the developer can set this up himself in the settings# t = time elapsed in minutes# bs = box's security level# n = module constant, number of max items stolen (- 1 in the settings if we use the default rand method)# stolen_items = method to determine which item will be stolenprob = (rand(x)+1 * bs) - tif prob <= 0 num = rand(n)+1 num.times do stolen_items endendI would do something like this.In the 'stolen_items' method I would define which item is stolen. That would be the item with the highest steal likehood rate.

The security level of the boxes can be a simple number, and could be setup for each storage, just like any other setting.

I don't see any random factor in your formula. But maybe I am missing something.

Random factor is crucial so that the player never knows if it will be stolen in the next 20 minutes or won't be stolen even within the next few days. Same with the amount of items stolen. One can never know how many item will be missing on the next visit.

And do not forget to put a check in it, so that the steal can not happen if the player didn't leave the area far enough from the box. Either make a check to see if the player transferred a map or not, or make a range check, and once the player leaves the range, the time counting can start.

It would be weird to get an item stolen when the player stands next to the box.

There might be easier methods to do this, and surely can be done with other formulas too.

I am just giving ideas. :)
 
Last edited by a moderator:

Dymdez

Newbie-in-Chief
Veteran
Joined
Feb 4, 2014
Messages
752
Reaction score
156
First Language
English
Primarily Uses
Another idea - add weapons/armors?

Another idea - start cursor in the box inventory not player inventory, makes way more sense that way

Another idea - transfer item sound effect [deposit sound effect/ withdraw sound effect]
 
Last edited by a moderator:

Diretooth

Lv. 25 Werewolf
Veteran
Joined
Mar 10, 2013
Messages
1,235
Reaction score
449
First Language
English
Primarily Uses
RMMV
IF I can understand how this works fully, I can use this as an alternative, or maybe even a supplement, to chests, rather than have the typical scattered chest thing.
 

Dymdez

Newbie-in-Chief
Veteran
Joined
Feb 4, 2014
Messages
752
Reaction score
156
First Language
English
Primarily Uses
IF I can understand how this works fully, I can use this as an alternative, or maybe even a supplement, to chests, rather than have the typical scattered chest thing.
Currently only a supplement because it only deals with item transfers, not weapons or armor.

This is incorrect, replace the first instance of "items" with either "weapons" or "armors" and it will work just fine.

IMP1 I found two bugs. Check out this screenie!

rW1r4Wm.png


I put 25 arrows in the "box" but it comes up as "0" and allows me to take infinite (well past my inventory limit, see Theo's limited inventory for details there). Here is the exact language i used "item = $data_items[9]

$game_boxes.add_item(item, 25, 10, :all)"

Edit: Alright, so this is only kinda a bug. I just think that 25 arrows should still count as 1 item, looks messy if it doesnt. The problem is that I wasn't using ":force." Also, maybe there should be a "take all" option if there is more than 5 of an item.

Also, the "help display text" at the top did not refresh after I took the shortbow out of the box, it remained displaying the shortbows display text, "its circular shape helps give it strength"
 
Last edited by a moderator:

IMP1

"haystack".scan(/needle/)
Veteran
Joined
Mar 6, 2014
Messages
70
Reaction score
45
First Language
English
Primarily Uses
RMVXA
Another idea - add weapons/armors?
This was already in it, but I've added how to do this in the instructions. Thanks for pointing that out :)
Another idea - start cursor in the box inventory not player inventory, makes way more sense that way
This was also in it, and is also in the instructions now (I thought it was before, but whatever).
Another idea - transfer item sound effect (deposit sound effect/ withdraw sound effect)
This is a good idea. Also you said about sounds for opening and closing the scene. Should this depend on what kind of box it is?
IF I can understand how this works fully, I can use this as an alternative, or maybe even a supplement, to chests, rather than have the typical scattered chest thing.
That's right! I'd use it to replace chests, but that's because I like games with 'permanant' storage. You could definitley mix and match the two. Hope you enjoy it, and let me know if there are any issues or improvements you can think of.
[...]Edit: Alright, so this is only kinda a bug. I just think that 25 arrows should still count as 1 item, looks messy if it doesnt. The problem is that I wasn't using ":force." Also, maybe there should be a "take all" option if there is more than 5 of an item.


Also, the "help display text" at the top did not refresh after I took the shortbow out of the box, it remained displaying the shortbows display text, "its circular shape helps give it strength"
So there was a bug that added 0 of an item if there was no room. This is now fixed and I've updated the link in the OP.
I wonder how much of the other bugs were because of this, so after getting the new version, which of the problems you listed still happen?
 
Last edited by a moderator:

IMP1

"haystack".scan(/needle/)
Veteran
Joined
Mar 6, 2014
Messages
70
Reaction score
45
First Language
English
Primarily Uses
RMVXA
Storage Boxes Addon: Item Sizes v1.4
by IMP1

Link to Addon
This addon currently works with Theo's Limited Inventory script, but can be extended to work with others - I don't really know what's out there in terms of equivilants. It uses the item size value from Theo's script instead of just having them all set to 1 as is the default behavious in Storage Boxes.

EDIT: It now uses the player's inventory limit to stop taking items beyond that limit, and displays the item count of the inventory.*
 
Last edited:

Dymdez

Newbie-in-Chief
Veteran
Joined
Feb 4, 2014
Messages
752
Reaction score
156
First Language
English
Primarily Uses
Ok, I'll give it a test. Any thought to making a notetag for items that will always count their inventory space as "1," like for arrows?

You ask "

Dymdez, on 02 Nov 2014 - 01:03 AM, said:

Another idea - transfer item sound effect (deposit sound effect/ withdraw sound effect)
This is a good idea. Also you said about sounds for opening and closing the scene. Should this depend on what kind of box it is?"

Well, I figure the best way to handle this is just to add more functions in the box creation area so, something like this..

{
        name: "Drawer", # ID = 1 [left drawer right]
        size: 5,

        closeSE: "name of the sound effect that plays when cancelling input"

        openSE: "same as above except when opening"

},

Currently, there's no way to have more than 1 different closing sound effect, which you would have to manually place in the update section on line 300 or so i think. (replace sound.play with the script call for a specific SE)

Also, for specific transfer sound effects, you could add a notetag to a weapon that would indicate if it was there, don't play the default sound effect, but rather the indicated one -- >     "<transferSE "name of sound effect">"

Lastly, the refresh "bug" still remains. It's not really a bug, it's just yet to be coded. If there is more than 1 item in a box and you remove the first item, the cursor will automatically move to the second item, but the item description text above will not change until you move a cursor.
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,206
Reaction score
874
First Language
Hungarian
Primarily Uses
RMVXA
You forgot the most important part for making a compatibility patch for Theo's Inv Limit script.

The restriction of taking items when the player's inventory lacks space.

I made a little snippet for it.

It also replaces the info shown on the player's info box (where it shows only "Bag" by default.

It now shows the players inventory info.

And made the help window's height change-able. 1 line is just not sufficient for many games.

Also added a compatibility patch for Galv's New Item Indicator script too. This part won't trigger if someone doesn't use that script, so there should be no issue with it.

Here is the snippet:

module IMP1_Storage_Boxes # Lines to show for the help window. HELP_WINDOW_LINES = 2end#==============================================================================# Scene_ItemStorage#==============================================================================class Scene_ItemStorage < Scene_MenuBase #-------------------------------------------------------------------------- # Creates windows. - !!UPDATED!! #-------------------------------------------------------------------------- alias sixth_theo_invpatch122 create_windows def create_windows if $imported[:Theo_LimInventory] @old_inv = $game_party.total_inv_size @bag_window = Window_ItemStorageLeft.new @box_window = Window_ItemStorageRight.new(@box_id) @help_window = Window_Help.new(IMP1_Storage_Boxes::HELP_WINDOW_LINES) @bag_title = Window_BoxTitle.new(0, IMP1_Storage_Boxes::pARTY_NAME,nil,@old_inv) @box_title = Window_BoxTitle.new((Graphics.width/2), IMP1_Storage_Boxes::BOXES[@box_id][:name], @box_id,@old_inv) @box_window.help_window = @help_window @bag_window.help_window = @help_window @bag_window.help_window.back_opacity = 200 @taking = false if $game_boxes.full?(@box_id) if @taking @box_window.activate.select_last @bag_window.deactivate.select_last else @bag_window.activate.select_last @box_window.deactivate.select_last end else sixth_theo_invpatch122 end end #-------------------------------------------------------------------------- # Move item from one side to the other. - !!UPDATED!! #-------------------------------------------------------------------------- alias sixth_galv_indi122 move_item def move_item if $imported[:Theo_LimInventory] if @box_window.active item = @box_window.item if @box_window.index < 0 or item.nil? || $game_party.inv_maxed? || $game_party.total_inv_size + item.inv_size > $game_party.inv_max Sound.play_buzzer else Sound.play_ok @old_inv = $game_party.total_inv_size $game_boxes.remove_item(item, 1, @box_id) $game_party.gain_item(item, 1) end else item = @bag_window.item if @bag_window.index < 0 or item.nil? Sound.play_buzzer elsif !$game_boxes.space?(@box_id) or !@bag_window.enable?(item) Sound.play_buzzer else Sound.play_ok @old_inv = $game_party.total_inv_size $game_party.lose_item(item, 1) $game_boxes.add_item(item, 1, @box_id) end end else sixth_galv_indi122 end refresh_new if $imported["Galv_New_Item_Indicator"] end #-------------------------------------------------------------------------- # Refreshes new indicator. - !!NEW!! #-------------------------------------------------------------------------- def refresh_new @item_window.refresh if @item_window @box_window.refresh if @box_window @bag_window.refresh if @bag_window endend#==============================================================================# Window_Item_StorageLeft - !!UPDATED!!#==============================================================================class Window_ItemStorageLeft < Window_ItemList #-------------------------------------------------------------------------- # Edited to make there only one column, to change the positioning and make # it inactive by default. #-------------------------------------------------------------------------- def initialize y = line_height*IMP1_Storage_Boxes::HELP_WINDOW_LINES+24+fitting_height(1) super(0, y, Graphics.width/2, Graphics.height-y) refresh endend#==============================================================================# Window_ItemStorageRight - !!UPDATED!!#==============================================================================class Window_ItemStorageRight < Window_ItemList #-------------------------------------------------------------------------- # Edited to make there only one column, to change the positioning and make # it inactive by default. #-------------------------------------------------------------------------- def initialize(box_id) @box_id = box_id y = line_height*IMP1_Storage_Boxes::HELP_WINDOW_LINES+24+fitting_height(1) super(Graphics.width/2, y, Graphics.width/2, Graphics.height-y) refresh endend#==============================================================================# Window_BoxTitle - !!UPDATED!!#==============================================================================class Window_BoxTitle < Window_Base #-------------------------------------------------------------------------- # Initialization. - !!UPDATED!! #-------------------------------------------------------------------------- def initialize(x, t, box = nil, old_inv=nil) super(x, line_height*IMP1_Storage_Boxes::HELP_WINDOW_LINES + 24, Graphics.width/2, fitting_height(1)) @box = box @t = t @old_inv = old_inv refresh #draw_contents end #-------------------------------------------------------------------------- # Frame update. - !!UPDATED!! #-------------------------------------------------------------------------- def update super if !@box.nil? a = $game_boxes.how_full(@box, true) != @text b = $game_boxes.how_full(@box, false) != @text if a and b self.contents.clear refresh end elsif @old_inv != $game_party.total_inv_size && $imported[:Theo_LimInventory] refresh @old_inv = $game_party.total_inv_size end end #-------------------------------------------------------------------------- # Draws the contents. - !!UPDATED!! #-------------------------------------------------------------------------- def refresh #draw_contents(dull = false) contents.clear if not @box.nil? and IMP1_Storage_Boxes::BOXES[@box][:size] != 0 @text = $game_boxes.how_full(@box, true) draw_text(0, 0, (Graphics.width/2)-32, line_height, @text, 2) elsif not @box.nil? @text = $game_boxes.how_full(@box, false) draw_text(0, 0, (Graphics.width/2)-32, line_height, @text, 2) elsif @box.nil? && $imported[:Theo_LimInventory] x = contents.width/3 draw_inv_info(0,0,contents.width) else self.contents.draw_text(0, 0, (Graphics.width/2)-32, line_height, @t) end end end# Window_BoxTitle
With your just released addon and with this little snippet, Theo's script is fully compatible with yours. :)

What I couldn't manage to fix is the refreshing of the help window. Even if I put in '@help_window.refresh', it won't refresh itself. -.-

I am talking about the bug what Dymdez already reported.
 

Latest Threads

Latest Profile Posts

Rave Heart Overhaul Edition is now available! :elwink:

It was fun while it lasted, but guess it's time to say goodbye to my antidepresants. My body is immune to their good effects and only bad effects would remain.
Character in the game lore: An individual with exceptional skills.
Players: Slip through the cliff and die.

Forum statistics

Threads
131,588
Messages
1,221,289
Members
173,285
Latest member
tnt3927
Top