This only applies to the first one, other DQs (and by extension, other games that borrow heavily from DQ) have all items instanced.
VXAce Problem with Limited Inventory...
RGSS3 Script RequestsI updated the patch as it had a small display bug with item counting, I also restored the removal of instance items counting which was overwritten by one of Hime's actor inventory scripts.
Finally, there was a missing feature in Hime's script as buying items would store them inside the leader's inventory, now it is inside the buyer's inventory.
If, however, you don't have specificities to these items and just want them to be displayed multiple times in your inventory.
Then I really don't think you should instantiate them. You can use this script instead (put this below my patch if you use it, it should be a standalone) which will take an item with multiple occurrences and split it to simulate instance items.
Here is my script load order:
Note that with the exception of my patch, the 3 script I provided in this thread should not require this load order and should only require their 'parent' script (for the addons) to work properly.
I don't plan on providing more scripts and my support to these scripts (except the main patch) is not to be expected.
Finally, there was a missing feature in Hime's script as buying items would store them inside the leader's inventory, now it is inside the buyer's inventory.
Ruby:
#==============================================================================
# Actor Inventory, Limited Inventory and Instance Items compatibility patch
#------------------------------------------------------------------------------
# Author: Timtrack
# date: 31/05/2025
# Requires: TheoAllen - Limited Inventory && Hime's Actor Inventory
# Supports Hime's Instance Items
#==============================================================================
# Note: tested with the following script order:
# Limited Inventory
# Instance Items*
# Core - Inventory
# Core - Inventory - Instance Items patch*
# Actor Inventory
# Actor Inventory - Instance Items*
# Actor Inventory Scenes
# This patch
#
# * Use the scripts with the symbol if you use Hime's instance items
#==============================================================================
$imported = {} if $imported.nil?
$imported["TIM_ACTOR_LIMIT_INSTANCE_INVENTORY_Patch"] = true
module TimPatch
#set to true for TheoAllen's script to slow paarty members if at least one
#actor inventory is full, else all inventories must be full to slow the party
INVENTORY_SLOWED_ANY = false
#set to true for extra items to be given to other actors inventories when
#current actor inventory is full (item is discarded if no inventory can handle it)
DISTRIBUTE_EXTRA_ITEMS = true
end #TimPatch
#==============================================================================
# Game_Inventory
#==============================================================================
class Game_Inventory
attr_accessor :force_gain
end #Game_Inventory
#==============================================================================
# Game_ActorInventory
#==============================================================================
class Game_ActorInventory < Game_Inventory
#-----------------------------------------------------------------------------
# alias method: max_item_number -> handles the weight
#-----------------------------------------------------------------------------
alias timpatch_liminv_max_item max_item_number
def max_item_number(item)
return 9999999 if @force_gain #don't ask for weight in force gain mode
$BTEST ? timpatch_liminv_max_item(item) : @actor.inv_max_item(item) + item_number(item)
end
if $imported["TH_InstanceItems"]
#-----------------------------------------------------------------------------
# alias method: add_instance_item -> will forbid new insstances to be given if inventory is full
#-----------------------------------------------------------------------------
alias timpatch_liminv_add_instance_item add_instance_item
def add_instance_item(item)
if actor.inv_max_item(item) <= 0 && !@force_gain
$game_party.distribute_instance_item(item) if TimPatch::DISTRIBUTE_EXTRA_ITEMS
else
timpatch_liminv_add_instance_item(item)
end
end
else #compatibility if no instance item script is used
def instance_enabled?(item); false; end
end#$imported["TH_InstanceItems"]
if TimPatch::DISTRIBUTE_EXTRA_ITEMS
#-----------------------------------------------------------------------------
# alias method: gain_item
#-----------------------------------------------------------------------------
alias timpatch_instance_gain_item gain_item
def gain_item(item, amount, include_equip = false)
return timpatch_instance_gain_item(item, amount, include_equip) if @force_gain || instance_enabled?(item) || amount <= 0
#case where item is not instanciable and amount is > 0
place = @actor.inv_max_item(item)
return timpatch_instance_gain_item(item, amount, include_equip) if place >= amount
#if not enough space for items, we disstribute the rest to the party members:
r = timpatch_instance_gain_item(item, place, include_equip)
$game_party.distribute_extra_items(item, amount-place)
return r #just a failsafe if gain_item had a return value
end
end #TimPatch::DISTRIBUTE_EXTRA_ITEMS
end #Game_ActorInventory
#==============================================================================
# Game_Actor -> all new methods here were pasted from Game_Party in Limited Inventory
#==============================================================================
class Game_Actor < Game_Battler
def inv_maxed?
inv_max <= total_inv_size
end
#this one contains the actor inventory AND their equipment
def total_inv_size
result = all_items.inject(0) {|total,item| total + (item_number(item) * item.inv_size)}
result += equip_size
result
end
def inv_max_item(item)
return 9999999 if item.nil? || item.inv_size == 0
free_slot / item.inv_size
end
def free_slot
inv_max - total_inv_size
end
alias theo_liminv_item_max? item_max?
def item_max?(item)
$BTEST ? theo_liminv_item_max?(item) : inv_max_item(item) <= 0
end
def near_maxed?
free_slot.to_f / inv_max <= Theo::LimInv::NearMaxed_Percent/100.0
end
def item_size(item)
return 0 unless item
item.inv_size * item_number(item)
end
#-----------------------------------------------------------------------------
# alias method: max_item_number
#-----------------------------------------------------------------------------
alias timpatch_liminv_max_item max_item_number
def max_item_number(item)
return 9999999 if Theo::LimInv::ForceGain
$BTEST ? timpatch_liminv_max_item(item) : inv_max_item(item) + item_number(item)
end
#-----------------------------------------------------------------------------
# alias method: gain_item
#-----------------------------------------------------------------------------
alias timpatch_liminv_gain_item gain_item
def gain_item(*args)
if Theo::LimInv::ForceGain
force_gain_item(*args)
else
timpatch_liminv_gain_item(*args)
end
end
if $imported["TH_InstanceItems"]
#-----------------------------------------------------------------------------
# new method: add_instance_item
#-----------------------------------------------------------------------------
def add_instance_item(item)
@inventory.add_instance_item(item)
end
end #$imported["TH_InstanceItems"]
#-----------------------------------------------------------------------------
# new method: force_gain_item
#-----------------------------------------------------------------------------
def force_gain_item(*args)
@inventory.force_gain = true
timpatch_liminv_gain_item(*args)
@inventory.force_gain = false
end
end #Game_Actor
#==============================================================================
# Game_Party -> inventory is the sum of all inventories, note that inv_max is already defined that way
#==============================================================================
class Game_Party < Game_Unit
#-----------------------------------------------------------------------------
# overwrite method: total_inv_size
#-----------------------------------------------------------------------------
def total_inv_size
members.inject(0) {|r,a| r+a.total_inv_size}
end
#-----------------------------------------------------------------------------
# overwrite method: force_gain_item (NOTE: inventory size or checking of party is not implemented!)
#-----------------------------------------------------------------------------
def force_gain_item(item, amount, include_equip = false)
return @inventory.gain_item(item, include_equip) if $imported["TIM-AI-addon-SharedItems"] && TIM::ActorInventoryAddon.shared_inventory?(item)
leader.force_gain_item(item, amount, include_equip)
end
#-----------------------------------------------------------------------------
# new method: distribute_extra_items -> called when an invenotry is full and
# others are not, only if DISTRIBUTE_EXTRA_ITEMS is true (handles multiple instance items)
#-----------------------------------------------------------------------------
def distribute_extra_items(item, amount)
candidates = members.select{|a| a.inv_max_item(item) >= 1}
for a in candidates
to_add = [0,[a.inv_max_item(item), amount].min].max
a.gain_item(item, to_add)
amount -= to_add
return if amount <= 0
end
end
if $imported["TH_InstanceItems"]
#-----------------------------------------------------------------------------
# new method: distribute_instance_item -> called when an invenotry is full and
# others are not, only if DISTRIBUTE_EXTRA_ITEMS is true (handles instance items)
#-----------------------------------------------------------------------------
def distribute_instance_item(item)
candidate = members.find{|a| a.inv_max_item(item) >= 1}
candidate.add_instance_item(item) if candidate #do nothing if no candidate was found
end
end #$imported["TH_InstanceItems"]
end #Game_Party
#==============================================================================
# Game_Player -> slow down features from single actors (only if option INVENTORY_SLOWED_ANY is true!)
#==============================================================================
if TimPatch::INVENTORY_SLOWED_ANY
class Game_Player
#-----------------------------------------------------------------------------
# alias method: dash?
#-----------------------------------------------------------------------------
alias timpatch_liminv_dash? dash?
def dash?
return false if Theo::LimInv::Full_DisableDash && $game_party.members.any?{|a| a.inv_maxed?}
return timpatch_liminv_dash?
end
#-----------------------------------------------------------------------------
# overwrite method: move_penalty
#-----------------------------------------------------------------------------
def move_penalty
Theo::LimInv::Full_SlowDown && $game_party.members.any?{|a| a.inv_maxed?} ? 1 : 0
end
end #Game_Player
end #TimPatch::INVENTORY_SLOWED_ANY
#==============================================================================
# Window_Base
#==============================================================================
class Window_Base < Window
#-----------------------------------------------------------------------------
# alias method: draw_inv_slot
#-----------------------------------------------------------------------------
alias actor_inv_patch_draw_inv_slot draw_inv_slot
def draw_inv_slot(x,y,width = contents.width,align = 2)
return actor_inv_patch_draw_inv_slot(x,y,width,align) unless SceneManager.scene_is?(Scene_Item) || SceneManager.scene_is?(Scene_Shop) || SceneManager.scene_is?(Scene_Battle)
#added
actor = SceneManager.scene_is?(Scene_Battle) ? BattleManager.actor : SceneManager.scene.actor
#replaced $game_party with actor:
txt = sprintf("%d/%d", actor.total_inv_size, actor.inv_max)
color = Theo::LimInv::NearMaxed_Color
if actor.near_maxed?
change_color(text_color(color))
else
change_color(normal_color)
end
draw_text(x,y,width,line_height,txt,align)
change_color(normal_color)
end
#-----------------------------------------------------------------------------
# overwrite method: draw_item_size
#-----------------------------------------------------------------------------
def draw_item_size(item,x,y,total = true,width = contents.width)
rect = Rect.new(x,y,width,line_height)
change_color(system_color)
draw_text(rect,Theo::LimInv::InvSizeVocab)
change_color(normal_color)
#modified here:
number = get_item_size(item,total)
draw_text(rect,number,2)
end
#-----------------------------------------------------------------------------
# new method: get_item_size
#-----------------------------------------------------------------------------
def get_item_size(item,total = true)
if Theo::LimInv::DrawTotal_Size && total
actor = SceneManager.scene_is?(Scene_Battle) ? BattleManager.actor : SceneManager.scene.actor
actor.item_size(item)
else
item.nil? ? 0 : item.inv_size
end
end
end #Window_Base
#==============================================================================
# Window_DiscardAmount
#==============================================================================
class Window_DiscardAmount < Window_Base
#-----------------------------------------------------------------------------
# overwrite method: lose_item
#-----------------------------------------------------------------------------
def lose_item
#replaced
#$game_party.lose_item(@item,@amount)
#with:
actor = SceneManager.scene.actor
actor.lose_item(@item,@amount)
#---
@itemlist.redraw_current_item
@freeslot.refresh
if actor.item_number(@item) == 0
Sound.play_ok
@itemlist.activate.refresh
@itemlist.update_help
@cmn_window.close.deactivate
close
else
close_window
end
end
end #Window_DiscardAmount
if $imported["TH_InstanceItems"]
#==============================================================================
# Window_ItemList
#==============================================================================
class Window_ItemList < Window_Selectable
#-----------------------------------------------------------------------------
# alias method: draw_item_number
#-----------------------------------------------------------------------------
alias timpatch_ai_li_draw_item_number draw_item_number
def draw_item_number(rect, item)
timpatch_ai_li_draw_item_number(rect,item) if item.is_template?
end
end #Window_ItemList
end #$imported["TH_InstanceItems"]
#==============================================================================
# Window_ShopNumber
#==============================================================================
class Window_ShopNumber < Window_Selectable
#-----------------------------------------------------------------------------
# overwrite method: draw_itemsize
#-----------------------------------------------------------------------------
def draw_itemsize
actor = SceneManager.scene_is?(Scene_Shop) ? SceneManager.scene.actor : $game_party.leader
item_size = @number * @item.inv_size
total_size = actor.total_inv_size +
(@mode == :buy ? item_size : -item_size)
txt = sprintf("%d/%d",total_size,actor.inv_max)
ypos = item_y + line_height * ($imported["YEA-ShopOptions"] ? 5 : 4)
rect = Rect.new(4,ypos,contents.width-8,line_height)
change_color(system_color)
draw_text(rect,Theo::LimInv::InvSlotVocab)
change_color(normal_color)
draw_text(rect,txt,2)
end
end #Window_ShopNumber
#==============================================================================
# Scene_Item
#==============================================================================
class Scene_Item < Scene_ItemBase
attr_reader :actor
#-----------------------------------------------------------------------------
# overwrite method: on_item_ok
#-----------------------------------------------------------------------------
def on_item_ok
@actor.last_item.object = item
@use_command.set_item(item)
@use_command.open
@use_command.activate
@use_command.select(0)
end
#-----------------------------------------------------------------------------
# alias method: on_actor_change
#-----------------------------------------------------------------------------
alias timpatch_ai_li_on_actor_change on_actor_change
def on_actor_change
timpatch_ai_li_on_actor_change
@freeslot.refresh
end
end #Scene_Item
#==============================================================================
# Scene_Shop
#==============================================================================
class Scene_Shop < Scene_MenuBase
attr_reader :actor
#-----------------------------------------------------------------------------
# overwrite method: do_buy
#-----------------------------------------------------------------------------
def do_buy(number)
puts @actor.id
$game_party.lose_gold(number * buying_price)
@actor.gain_item(@item, number)
end
end #Scene_Shop
I just want to be sure, when you say instantiated, does that mean that each item has specific values? Like you could have 2 potions (with the same id in the database) but with different effects? (one could heal for 50 hps and the other for 53 hps for instance?) If that is the case, then yes you must instantiate them but I won't provide a multi-sell feature as it goes against instance items script purpose (code-wise the two items are different, so how could I determine if they should be sold together or not?).
If, however, you don't have specificities to these items and just want them to be displayed multiple times in your inventory.
Then I really don't think you should instantiate them. You can use this script instead (put this below my patch if you use it, it should be a standalone) which will take an item with multiple occurrences and split it to simulate instance items.
Ruby:
#==============================================================================
# Single item display
#------------------------------------------------------------------------------
# Author: Timtrack
# date: 01/06/2025
#
# Items with multiple occurences are split into multiple entries in the item
# windows. They are still considered one item in the database.
#==============================================================================
# Installation: put this below scripts adding new inventory features, otherwise plug and play
# Works with Hime's Instance items, Actor inventory and Theo Allen's Limited Inventory
#==============================================================================
$imported = {} if $imported.nil?
$imported["TIM_SingleItems"] = true
module TIM
module SingleItem
DISPLAY_SINGLE_NUMBER = false #to not display anything if the item is not stackable
module REGEXP
SINGLE_EXCEPTION = /<stacked>/i #if you don't want the item to be splited, does not work with instance items as they are single items
end #REGEXP
#--------------------------------------------------------------------------
# new method: stack_item?
#--------------------------------------------------------------------------
def self.stack_item?(obj)
if $imported["TH_InstanceItems"] && InstanceManager.instance_enabled?(obj)
false
else
obj.stackable
end
end
end #SingleItem
end #TIM
#============================================================================
# DataManager
#============================================================================
module DataManager
#--------------------------------------------------------------------------
# alias method: load_database
#--------------------------------------------------------------------------
class <<self; alias load_database_single_items load_database; end
def self.load_database
load_database_single_items
load_notetags_single_items
end
#--------------------------------------------------------------------------
# new method: load_notetags_single_items
#--------------------------------------------------------------------------
def self.load_notetags_single_items
groups = [$data_items,$data_armors,$data_weapons]
for group in groups
for obj in group
next if obj.nil?
obj.load_notetags_single_items
end
end
end
end # DataManager
#============================================================================
# RPG::BaseItem
#============================================================================
class RPG::BaseItem
attr_reader :stackable
#--------------------------------------------------------------------------
# common cache: load_notetags_single_items
#--------------------------------------------------------------------------
def load_notetags_single_items
@stackable = false
#---
self.note.split(/[\r\n]+/).each { |line|
case line
#---
when TIM::SingleItem::REGEXP::SINGLE_EXCEPTION
@stackable = true
end
#---
} # self.note.split
#---
end
end # RPG::BaseItem
#==============================================================================
# Window_ItemList
#==============================================================================
class Window_ItemList < Window_Selectable
#-----------------------------------------------------------------------------
# alias method: make_item_list
#-----------------------------------------------------------------------------
alias single_item_make_item_list make_item_list
def make_item_list
single_item_make_item_list
@data = @data.inject([]){|l,i| l + (i && !TIM::SingleItem.stack_item?(i) ? [i]*original_item_number(i) : [i])}
end
#-----------------------------------------------------------------------------
# new method: original_item_number
#-----------------------------------------------------------------------------
def original_item_number(item)
if $imported["TH_ActorInventory"] && !($imported["TIM-AI-addon-SharedItems"] && TIM::ActorInventoryAddon.shared_inventory?(item))
@actor.item_number(item)
else
$game_party.item_number(item)
end
end
#-----------------------------------------------------------------------------
# overwrite method: draw_item_number
#-----------------------------------------------------------------------------
def draw_item_number(rect, item)
return unless TIM::SingleItem::DISPLAY_SINGLE_NUMBER || TIM::SingleItem.stack_item?(item)
draw_text(rect, sprintf(":%2d", TIM::SingleItem.stack_item?(item) ? original_item_number(item) : 1), 2)
end
end #Window_ItemList
#==============================================================================
# Compatibility patch with TheoAllen's limited inventory
#==============================================================================
if $imported[:Theo_LimInventory]
#==============================================================================
# Window_Base
#==============================================================================
class Window_Base < Window
#-----------------------------------------------------------------------------
# new method: original_item_number
#-----------------------------------------------------------------------------
def original_item_number(item)
if $imported["TIM_ACTOR_LIMIT_INSTANCE_INVENTORY_Patch"]
SceneManager.scene.actor.item_number(item)
else
$game_party.item_number(item)
end
end
unless $imported["TIM_ACTOR_LIMIT_INSTANCE_INVENTORY_Patch"]
#-----------------------------------------------------------------------------
# overwrite method: draw_item_size (already overwritten by one of my patch)
#-----------------------------------------------------------------------------
def draw_item_size(item,x,y,total = true,width = contents.width)
rect = Rect.new(x,y,width,line_height)
change_color(system_color)
draw_text(rect,Theo::LimInv::InvSizeVocab)
change_color(normal_color)
#modified here:
number = get_item_size(item,total)
draw_text(rect,number,2)
end
#-----------------------------------------------------------------------------
# new method: get_item_size (already defined by one of my patch)
#-----------------------------------------------------------------------------
def get_item_size(item,total = true)
if Theo::LimInv::DrawTotal_Size && total
$game_party.item_size(item)
else
item.nil? ? 0 : item.inv_size
end
end
end #$imported["TIM_ACTOR_LIMIT_INSTANCE_INVENTORY_Patch"]
#-----------------------------------------------------------------------------
# alias method: get_item_size
#-----------------------------------------------------------------------------
alias single_items_get_item_size get_item_size
def get_item_size(item,total = true)
r = single_items_get_item_size(item,total)
r /= original_item_number(item) unless total
return r
end
end #Window_Base
#==============================================================================
# Window_DiscardAmount
#==============================================================================
class Window_DiscardAmount < Window_Base
#-----------------------------------------------------------------------------
# alias method: lose_item
#-----------------------------------------------------------------------------
alias single_item_lose_item lose_item
def lose_item
b = @amount > 0 && !TIM::SingleItem.stack_item?(@item) && @amount < original_item_number(@item)
single_item_lose_item
if b
Sound.play_ok
@itemlist.activate.refresh
@itemlist.update_help
@cmn_window.close.deactivate
close
end
end
end #Window_DiscardAmount
end #$imported[:Theo_LimInventory]
It was not easier, but I wrote something for this too:
Ruby:
#==============================================================================
# Hime's Actor Inventory addon - shared items
#------------------------------------------------------------------------------
# Author: Timtrack
# date: 01/06/2025
# Requires: Hime's Actor Inventory and Actor Inventory Scenes
#==============================================================================
# Installation: put this below Hime's scripts
#==============================================================================
$imported = {} if $imported.nil?
$imported["TIM-AI-addon-SharedItems"] = true
module TIM
module ActorInventoryAddon
SHARED_KEY_ITEMS = true
module REGEXP
SHARED = /<shared_inventory>/i
end #REGEXP
def self.shared_inventory?(item)
return false unless item
return true if item.shared_inventory
return true if SHARED_KEY_ITEMS && item.is_a?(RPG::Item) && item.key_item?
false
end
end #ActorInventory
end #TIM
#============================================================================
# DataManager
#============================================================================
module DataManager
#--------------------------------------------------------------------------
# alias method: load_database
#--------------------------------------------------------------------------
class <<self; alias load_database_shared_items load_database; end
def self.load_database
load_database_shared_items
load_notetags_shared_items
end
#--------------------------------------------------------------------------
# new method: load_notetags_shared_items
#--------------------------------------------------------------------------
def self.load_notetags_shared_items
groups = [$data_items,$data_armors,$data_weapons]
for group in groups
for obj in group
next if obj.nil?
obj.load_notetags_shared_items
end
end
end
end # DataManager
#============================================================================
# RPG::BaseItem
#============================================================================
class RPG::BaseItem
attr_reader :shared_inventory
#--------------------------------------------------------------------------
# common cache: load_notetags_shared_items
#--------------------------------------------------------------------------
def load_notetags_shared_items
@shared_inventory = false
#---
self.note.split(/[\r\n]+/).each { |line|
case line
#---
when TIM::ActorInventoryAddon::REGEXP::SHARED
@shared_inventory = true
end
#---
} # self.note.split
#---
end
end # RPG::BaseItem
#==============================================================================
# Window_ItemList
#==============================================================================
class Window_ItemList < Window_Selectable
#-----------------------------------------------------------------------------
# alias method: make_item_list
#-----------------------------------------------------------------------------
alias shared_item_make_item_list make_item_list
def make_item_list
shared_item_make_item_list
@data = $game_party.all_items.select {|item| include?(item) } + @data
end
end #Window_ItemList
#==============================================================================
# Game_Actor
#==============================================================================
class Game_Actor
#--------------------------------------------------------------------------
# alias method: gain_item
#--------------------------------------------------------------------------
alias shared_gain_item gain_item
def gain_item(item, amount, include_equip = false)
return shared_gain_item(item, amount, include_equip) unless TIM::ActorInventoryAddon.shared_inventory?(item)
$game_party.gain_item(item, amount, include_equip)
end
alias shared_item_number item_number
def item_number(item)
return shared_item_number(item) unless TIM::ActorInventoryAddon.shared_inventory?(item)
$game_party.item_number(item)
end
alias shared_has_item? has_item?
def has_item?(item)
return shared_has_item?(item) unless TIM::ActorInventoryAddon.shared_inventory?(item)
$game_party.has_item?(item)
end
end #Game_Actor
#============================================================================
# Game_Party
#============================================================================
class Game_Party < Game_Unit
#--------------------------------------------------------------------------
# alias method: has_item?
#--------------------------------------------------------------------------
alias shared_has_item? has_item?
def has_item?(item, include_equip = false)
return shared_has_item?(item, include_equip) unless TIM::ActorInventoryAddon.shared_inventory?(item)
@inventory.has_item?(item, include_equip)
end
#--------------------------------------------------------------------------
# alias method: item_number
#--------------------------------------------------------------------------
alias shared_item_number item_number
def item_number(item)
return shared_item_number(item) unless TIM::ActorInventoryAddon.shared_inventory?(item)
@inventory.item_number(item)
end
#--------------------------------------------------------------------------
# alias method: gain_item
#--------------------------------------------------------------------------
alias shared_gain_item gain_item
def gain_item(item, amount, include_equip = false)
return shared_gain_item(item, amount, include_equip) unless TIM::ActorInventoryAddon.shared_inventory?(item)
@inventory.gain_item(item, amount, include_equip)
end
end #Game_Party
Here is my script load order:
Note that with the exception of my patch, the 3 script I provided in this thread should not require this load order and should only require their 'parent' script (for the addons) to work properly.
I don't plan on providing more scripts and my support to these scripts (except the main patch) is not to be expected.
Well this script works exactly like I want to, so yea, I really didn't need to instantiate them it seems lol.
In fact, everything is working the way I want to 😀 Aside from some HUD related stuff that's out of the scope of this topic.
Fair enough honestly, you've provided quite a lot of useful stuff, so I don't think I have anything to complain.
So yea, thanks 😀
Oh wait... so yea I do know you said support for these scripts is not to be expected, but I suppose I should make it known that the Single item display script is glitched. This is one of my character's inventories:
I only have 8 and yet, when I go to buy one more item, the game adds one more when counting my inventory space.
I also noticed that sometimes when I buy a single item, it doesn't appear anywhere in the inventory.
The issue with the inventory counter also causes things like this to happen:
This is how my scripts are ordered if that's any relevant. (The # is because I'm using another script to disable it)
You have to buy any amount of items first:
Now try getting another but don't go through it.
Now everytime you try getting an item it will appear as if you have more than you actually have (even though in this case you have only bought 3 potions.)
Now try getting another but don't go through it.
Now everytime you try getting an item it will appear as if you have more than you actually have (even though in this case you have only bought 3 potions.)
I don't encounter this issue, I forgot to say that the Single Item display must be put under my patch if you use my patch (try to follow my load order from my previous post when possible),
If the issue persists, can you tell me which parameters you have? (notetags in your items and whether the instance item script instantiate items)
Also make sure you have the latest version of my patch in your project otherwise the other scripts might not work as intended with it.
EDIT: also make sure you have unmodified versions of Hime's and TheoAllen's scripts (except for their parameters)
You can find them on Hime's page, as for TheoAllen, there is a github page with version 1.4c which is the one I used.
If the issue persists, can you tell me which parameters you have? (notetags in your items and whether the instance item script instantiate items)
Also make sure you have the latest version of my patch in your project otherwise the other scripts might not work as intended with it.
EDIT: also make sure you have unmodified versions of Hime's and TheoAllen's scripts (except for their parameters)
You can find them on Hime's page, as for TheoAllen, there is a github page with version 1.4c which is the one I used.
Hold on, I think the issue I mentioned was just me getting confused by numbers, things do work as they should mostly, but the actual issue is something else entirely, sometimes the inventory counter is just plain wrong and I can't really replicate it, like in this case:
Even though the character's inventory is like this:
I tried fiddling around the script order and disabling some but I haven't noticed any difference
Don't try to fiddle with the load order I provided, I wrote them with a specific order in mind so it is supposed to work if you put Hime's and TheoAllen script like you did, then:
-shared addon (optional)
-compatibility patch
-exception addon (optional)
-single item display (optional)
I found out that my patch did not put the correct discarding limits in inventories (always picking the leader's inventory instead) it should be fixed in this version:
I still do not encounter your bug, are you sure you don't have other scripts messing around or scripts that were modified?
Here is my script file that you can put on a blank project to test the shop and other features.
-shared addon (optional)
-compatibility patch
-exception addon (optional)
-single item display (optional)
I found out that my patch did not put the correct discarding limits in inventories (always picking the leader's inventory instead) it should be fixed in this version:
Ruby:
#==============================================================================
# Actor Inventory, Limited Inventory and Instance Items compatibility patch
#------------------------------------------------------------------------------
# Author: Timtrack
# date: 01/06/2025
# Requires: TheoAllen - Limited Inventory && Hime's Actor Inventory
# Supports Hime's Instance Items
#==============================================================================
# Note: tested with the following script order:
# Limited Inventory
# Instance Items*
# Core - Inventory
# Core - Inventory - Instance Items patch*
# Actor Inventory
# Actor Inventory - Instance Items*
# Actor Inventory Scenes
# This patch
#
# * Use the scripts with the symbol if you use Hime's instance items
#==============================================================================
$imported = {} if $imported.nil?
$imported["TIM_ACTOR_LIMIT_INSTANCE_INVENTORY_Patch"] = true
module TimPatch
#set to true for TheoAllen's script to slow paarty members if at least one
#actor inventory is full, else all inventories must be full to slow the party
INVENTORY_SLOWED_ANY = false
#set to true for extra items to be given to other actors inventories when
#current actor inventory is full (item is discarded if no inventory can handle it)
DISTRIBUTE_EXTRA_ITEMS = true
end #TimPatch
#==============================================================================
# Game_Inventory
#==============================================================================
class Game_Inventory
attr_accessor :force_gain
end #Game_Inventory
#==============================================================================
# Game_ActorInventory
#==============================================================================
class Game_ActorInventory < Game_Inventory
#-----------------------------------------------------------------------------
# alias method: max_item_number -> handles the weight
#-----------------------------------------------------------------------------
alias timpatch_liminv_max_item max_item_number
def max_item_number(item)
return 9999999 if @force_gain #don't ask for weight in force gain mode
$BTEST ? timpatch_liminv_max_item(item) : @actor.inv_max_item(item) + item_number(item)
end
if $imported["TH_InstanceItems"]
#-----------------------------------------------------------------------------
# alias method: add_instance_item -> will forbid new insstances to be given if inventory is full
#-----------------------------------------------------------------------------
alias timpatch_liminv_add_instance_item add_instance_item
def add_instance_item(item)
if actor.inv_max_item(item) <= 0 && !@force_gain
$game_party.distribute_instance_item(item) if TimPatch::DISTRIBUTE_EXTRA_ITEMS
else
timpatch_liminv_add_instance_item(item)
end
end
else #compatibility if no instance item script is used
def instance_enabled?(item); false; end
end#$imported["TH_InstanceItems"]
if TimPatch::DISTRIBUTE_EXTRA_ITEMS
#-----------------------------------------------------------------------------
# alias method: gain_item
#-----------------------------------------------------------------------------
alias timpatch_instance_gain_item gain_item
def gain_item(item, amount, include_equip = false)
return timpatch_instance_gain_item(item, amount, include_equip) if @force_gain || instance_enabled?(item) || amount <= 0
#case where item is not instanciable and amount is > 0
place = @actor.inv_max_item(item)
return timpatch_instance_gain_item(item, amount, include_equip) if place >= amount
#if not enough space for items, we disstribute the rest to the party members:
r = timpatch_instance_gain_item(item, place, include_equip)
$game_party.distribute_extra_items(item, amount-place)
return r #just a failsafe if gain_item had a return value
end
end #TimPatch::DISTRIBUTE_EXTRA_ITEMS
end #Game_ActorInventory
#==============================================================================
# Game_Actor -> all new methods here were pasted from Game_Party in Limited Inventory
#==============================================================================
class Game_Actor < Game_Battler
def inv_maxed?
inv_max <= total_inv_size
end
#this one contains the actor inventory AND their equipment
def total_inv_size
result = all_items.inject(0) {|total,item| total + (item_number(item) * item.inv_size)}
result += equip_size
result
end
def inv_max_item(item)
return 9999999 if item.nil? || item.inv_size == 0
free_slot / item.inv_size
end
def free_slot
inv_max - total_inv_size
end
alias theo_liminv_item_max? item_max?
def item_max?(item)
$BTEST ? theo_liminv_item_max?(item) : inv_max_item(item) <= 0
end
def near_maxed?
free_slot.to_f / inv_max <= Theo::LimInv::NearMaxed_Percent/100.0
end
def item_size(item)
return 0 unless item
item.inv_size * item_number(item)
end
#-----------------------------------------------------------------------------
# alias method: max_item_number
#-----------------------------------------------------------------------------
alias timpatch_liminv_max_item max_item_number
def max_item_number(item)
return 9999999 if Theo::LimInv::ForceGain
$BTEST ? timpatch_liminv_max_item(item) : inv_max_item(item) + item_number(item)
end
#-----------------------------------------------------------------------------
# alias method: gain_item
#-----------------------------------------------------------------------------
alias timpatch_liminv_gain_item gain_item
def gain_item(*args)
if Theo::LimInv::ForceGain
force_gain_item(*args)
else
timpatch_liminv_gain_item(*args)
end
end
if $imported["TH_InstanceItems"]
#-----------------------------------------------------------------------------
# new method: add_instance_item
#-----------------------------------------------------------------------------
def add_instance_item(item)
@inventory.add_instance_item(item)
end
end #$imported["TH_InstanceItems"]
#-----------------------------------------------------------------------------
# new method: force_gain_item
#-----------------------------------------------------------------------------
def force_gain_item(*args)
@inventory.force_gain = true
timpatch_liminv_gain_item(*args)
@inventory.force_gain = false
end
end #Game_Actor
#==============================================================================
# Game_Party -> inventory is the sum of all inventories, note that inv_max is already defined that way
#==============================================================================
class Game_Party < Game_Unit
#-----------------------------------------------------------------------------
# overwrite method: total_inv_size
#-----------------------------------------------------------------------------
def total_inv_size
members.inject(0) {|r,a| r+a.total_inv_size}
end
#-----------------------------------------------------------------------------
# overwrite method: force_gain_item (NOTE: inventory size or checking of party is not implemented!)
#-----------------------------------------------------------------------------
def force_gain_item(item, amount, include_equip = false)
return @inventory.gain_item(item, include_equip) if $imported["TIM-AI-addon-SharedItems"] && TIM::ActorInventoryAddon.shared_inventory?(item)
leader.force_gain_item(item, amount, include_equip)
end
#-----------------------------------------------------------------------------
# new method: distribute_extra_items -> called when an invenotry is full and
# others are not, only if DISTRIBUTE_EXTRA_ITEMS is true (handles multiple instance items)
#-----------------------------------------------------------------------------
def distribute_extra_items(item, amount)
candidates = members.select{|a| a.inv_max_item(item) >= 1}
for a in candidates
to_add = [0,[a.inv_max_item(item), amount].min].max
a.gain_item(item, to_add)
amount -= to_add
return if amount <= 0
end
end
if $imported["TH_InstanceItems"]
#-----------------------------------------------------------------------------
# new method: distribute_instance_item -> called when an invenotry is full and
# others are not, only if DISTRIBUTE_EXTRA_ITEMS is true (handles instance items)
#-----------------------------------------------------------------------------
def distribute_instance_item(item)
candidate = members.find{|a| a.inv_max_item(item) >= 1}
candidate.add_instance_item(item) if candidate #do nothing if no candidate was found
end
end #$imported["TH_InstanceItems"]
end #Game_Party
#==============================================================================
# Game_Player -> slow down features from single actors (only if option INVENTORY_SLOWED_ANY is true!)
#==============================================================================
if TimPatch::INVENTORY_SLOWED_ANY
class Game_Player
#-----------------------------------------------------------------------------
# alias method: dash?
#-----------------------------------------------------------------------------
alias timpatch_liminv_dash? dash?
def dash?
return false if Theo::LimInv::Full_DisableDash && $game_party.members.any?{|a| a.inv_maxed?}
return timpatch_liminv_dash?
end
#-----------------------------------------------------------------------------
# overwrite method: move_penalty
#-----------------------------------------------------------------------------
def move_penalty
Theo::LimInv::Full_SlowDown && $game_party.members.any?{|a| a.inv_maxed?} ? 1 : 0
end
end #Game_Player
end #TimPatch::INVENTORY_SLOWED_ANY
#==============================================================================
# Window_Base
#==============================================================================
class Window_Base < Window
#-----------------------------------------------------------------------------
# alias method: draw_inv_slot
#-----------------------------------------------------------------------------
alias actor_inv_patch_draw_inv_slot draw_inv_slot
def draw_inv_slot(x,y,width = contents.width,align = 2)
return actor_inv_patch_draw_inv_slot(x,y,width,align) unless SceneManager.scene_is?(Scene_Item) || SceneManager.scene_is?(Scene_Shop) || SceneManager.scene_is?(Scene_Battle)
#added
actor = SceneManager.scene_is?(Scene_Battle) ? BattleManager.actor : SceneManager.scene.actor
#replaced $game_party with actor:
txt = sprintf("%d/%d", actor.total_inv_size, actor.inv_max)
color = Theo::LimInv::NearMaxed_Color
if actor.near_maxed?
change_color(text_color(color))
else
change_color(normal_color)
end
draw_text(x,y,width,line_height,txt,align)
change_color(normal_color)
end
#-----------------------------------------------------------------------------
# overwrite method: draw_item_size
#-----------------------------------------------------------------------------
def draw_item_size(item,x,y,total = true,width = contents.width)
rect = Rect.new(x,y,width,line_height)
change_color(system_color)
draw_text(rect,Theo::LimInv::InvSizeVocab)
change_color(normal_color)
#modified here:
number = get_item_size(item,total)
draw_text(rect,number,2)
end
#-----------------------------------------------------------------------------
# new method: get_item_size
#-----------------------------------------------------------------------------
def get_item_size(item,total = true)
if Theo::LimInv::DrawTotal_Size && total
actor = SceneManager.scene_is?(Scene_Battle) ? BattleManager.actor : SceneManager.scene.actor
actor.item_size(item)
else
item.nil? ? 0 : item.inv_size
end
end
end #Window_Base
#==============================================================================
# Window_DiscardAmount
#==============================================================================
class Window_DiscardAmount < Window_Base
#-----------------------------------------------------------------------------
# overwrite method: refresh
#-----------------------------------------------------------------------------
def refresh
contents.clear
return unless @item
draw_item_name(@item,0,0,true,contents.width)
actor = SceneManager.scene.actor
txt = sprintf("%d/%d",@amount, actor.item_number(@item))
draw_text(0,0,contents.width,line_height,txt,2)
end
#-----------------------------------------------------------------------------
# overwrite method: lose_item
#-----------------------------------------------------------------------------
def lose_item
#replaced
#$game_party.lose_item(@item,@amount)
#with:
actor = SceneManager.scene.actor
actor.lose_item(@item,@amount)
#---
@itemlist.redraw_current_item
@freeslot.refresh
if actor.item_number(@item) == 0
Sound.play_ok
@itemlist.activate.refresh
@itemlist.update_help
@cmn_window.close.deactivate
close
else
close_window
end
end
#-----------------------------------------------------------------------------
# overwrite method: change_amount
#-----------------------------------------------------------------------------
def change_amount(num)
actor = SceneManager.scene.actor
@amount = [[@amount+num,0].max,actor.item_number(@item)].min
Sound.play_cursor
refresh
end
end #Window_DiscardAmount
if $imported["TH_InstanceItems"]
#==============================================================================
# Window_ItemList
#==============================================================================
class Window_ItemList < Window_Selectable
#-----------------------------------------------------------------------------
# alias method: draw_item_number
#-----------------------------------------------------------------------------
alias timpatch_ai_li_draw_item_number draw_item_number
def draw_item_number(rect, item)
timpatch_ai_li_draw_item_number(rect,item) if item.is_template?
end
end #Window_ItemList
end #$imported["TH_InstanceItems"]
#==============================================================================
# Window_ShopNumber
#==============================================================================
class Window_ShopNumber < Window_Selectable
#-----------------------------------------------------------------------------
# overwrite method: draw_itemsize
#-----------------------------------------------------------------------------
def draw_itemsize
actor = SceneManager.scene_is?(Scene_Shop) ? SceneManager.scene.actor : $game_party.leader
item_size = @number * @item.inv_size
total_size = actor.total_inv_size +
(@mode == :buy ? item_size : -item_size)
txt = sprintf("%d/%d",total_size,actor.inv_max)
ypos = item_y + line_height * ($imported["YEA-ShopOptions"] ? 5 : 4)
rect = Rect.new(4,ypos,contents.width-8,line_height)
change_color(system_color)
draw_text(rect,Theo::LimInv::InvSlotVocab)
change_color(normal_color)
draw_text(rect,txt,2)
end
end #Window_ShopNumber
#==============================================================================
# Scene_Item
#==============================================================================
class Scene_Item < Scene_ItemBase
attr_reader :actor
#-----------------------------------------------------------------------------
# overwrite method: on_item_ok
#-----------------------------------------------------------------------------
def on_item_ok
@actor.last_item.object = item
@use_command.set_item(item)
@use_command.open
@use_command.activate
@use_command.select(0)
end
#-----------------------------------------------------------------------------
# alias method: on_actor_change
#-----------------------------------------------------------------------------
alias timpatch_ai_li_on_actor_change on_actor_change
def on_actor_change
timpatch_ai_li_on_actor_change
@freeslot.refresh
end
end #Scene_Item
#==============================================================================
# Scene_Shop
#==============================================================================
class Scene_Shop < Scene_MenuBase
attr_reader :actor
#-----------------------------------------------------------------------------
# overwrite method: do_buy
#-----------------------------------------------------------------------------
def do_buy(number)
puts @actor.id
$game_party.lose_gold(number * buying_price)
@actor.gain_item(@item, number)
end
end #Scene_Shop
I still do not encounter your bug, are you sure you don't have other scripts messing around or scripts that were modified?
Here is my script file that you can put on a blank project to test the shop and other features.
Okay now there's nothing going wrong, so I suppose it's fixed.
If I find any other glitch I will post here so that anyone can go and fix it, but as of now, I think mostly things work the way I want them.
UPDATE: Nevermind, I still randomly get the game thinking my inventory has 13 items out of 12, everything else works fine. I only get this glitch when I madly buy items and occasionally see my inventory
If I find any other glitch I will post here so that anyone can go and fix it, but as of now, I think mostly things work the way I want them.
UPDATE: Nevermind, I still randomly get the game thinking my inventory has 13 items out of 12, everything else works fine. I only get this glitch when I madly buy items and occasionally see my inventory
I also managed to replicate this using just the scripts you sent in a new project
I managed to replicate the bug.
It is actually a bug from the Scene_Shop modifications in Hime's Actor Inventory Scenes.
What happens is that the scene takes as an actor the last actor selected in the menu. However, Hime's script overwrite the actor to fix them as the leader instead but does not update the right menus.
Meaning that if you select another actor (say actor 2) than the leader in your menu and then pick the shop, it will say that it buys stuff for actor 2 but instead does so for the leader (while stating, since actor 2's inventory is not full, that it can buy stuff). What you see as full inventory is probably your leader's inventory then.
Note that if you switch actor in the shop afterwards, the problem disappears.
Anyway, I updated my patch to fix this:
Alternatively, you can comment line 240 of Actor Scenes to get something like this:
It is actually a bug from the Scene_Shop modifications in Hime's Actor Inventory Scenes.
What happens is that the scene takes as an actor the last actor selected in the menu. However, Hime's script overwrite the actor to fix them as the leader instead but does not update the right menus.
Meaning that if you select another actor (say actor 2) than the leader in your menu and then pick the shop, it will say that it buys stuff for actor 2 but instead does so for the leader (while stating, since actor 2's inventory is not full, that it can buy stuff). What you see as full inventory is probably your leader's inventory then.
Note that if you switch actor in the shop afterwards, the problem disappears.
Anyway, I updated my patch to fix this:
Ruby:
#==============================================================================
# Actor Inventory, Limited Inventory and Instance Items compatibility patch
#------------------------------------------------------------------------------
# Author: Timtrack
# date: 01/06/2025
# Requires: TheoAllen - Limited Inventory && Hime's Actor Inventory
# Supports Hime's Instance Items
#==============================================================================
# Note: tested with the following script order:
# Limited Inventory
# Instance Items*
# Core - Inventory
# Core - Inventory - Instance Items patch*
# Actor Inventory
# Actor Inventory - Instance Items*
# Actor Inventory Scenes
# This patch
#
# * Use the scripts with the symbol if you use Hime's instance items
#==============================================================================
$imported = {} if $imported.nil?
$imported["TIM_ACTOR_LIMIT_INSTANCE_INVENTORY_Patch"] = true
module TimPatch
#set to true for TheoAllen's script to slow paarty members if at least one
#actor inventory is full, else all inventories must be full to slow the party
INVENTORY_SLOWED_ANY = false
#set to true for extra items to be given to other actors inventories when
#current actor inventory is full (item is discarded if no inventory can handle it)
DISTRIBUTE_EXTRA_ITEMS = true
end #TimPatch
#==============================================================================
# Game_Inventory
#==============================================================================
class Game_Inventory
attr_accessor :force_gain
end #Game_Inventory
#==============================================================================
# Game_ActorInventory
#==============================================================================
class Game_ActorInventory < Game_Inventory
#-----------------------------------------------------------------------------
# alias method: max_item_number -> handles the weight
#-----------------------------------------------------------------------------
alias timpatch_liminv_max_item max_item_number
def max_item_number(item)
return 9999999 if @force_gain #don't ask for weight in force gain mode
$BTEST ? timpatch_liminv_max_item(item) : @actor.inv_max_item(item) + item_number(item)
end
if $imported["TH_InstanceItems"]
#-----------------------------------------------------------------------------
# alias method: add_instance_item -> will forbid new insstances to be given if inventory is full
#-----------------------------------------------------------------------------
alias timpatch_liminv_add_instance_item add_instance_item
def add_instance_item(item)
if actor.inv_max_item(item) <= 0 && !@force_gain
$game_party.distribute_instance_item(item) if TimPatch::DISTRIBUTE_EXTRA_ITEMS
else
timpatch_liminv_add_instance_item(item)
end
end
else #compatibility if no instance item script is used
def instance_enabled?(item); false; end
end#$imported["TH_InstanceItems"]
if TimPatch::DISTRIBUTE_EXTRA_ITEMS
#-----------------------------------------------------------------------------
# alias method: gain_item
#-----------------------------------------------------------------------------
alias timpatch_instance_gain_item gain_item
def gain_item(item, amount, include_equip = false)
return timpatch_instance_gain_item(item, amount, include_equip) if @force_gain || instance_enabled?(item) || amount <= 0
#case where item is not instanciable and amount is > 0
place = @actor.inv_max_item(item)
return timpatch_instance_gain_item(item, amount, include_equip) if place >= amount
#if not enough space for items, we disstribute the rest to the party members:
r = timpatch_instance_gain_item(item, place, include_equip)
$game_party.distribute_extra_items(item, amount-place)
return r #just a failsafe if gain_item had a return value
end
end #TimPatch::DISTRIBUTE_EXTRA_ITEMS
end #Game_ActorInventory
#==============================================================================
# Game_Actor -> all new methods here were pasted from Game_Party in Limited Inventory
#==============================================================================
class Game_Actor < Game_Battler
def inv_maxed?
inv_max <= total_inv_size
end
#this one contains the actor inventory AND their equipment
def total_inv_size
result = all_items.inject(0) {|total,item| total + (item_number(item) * item.inv_size)}
result += equip_size
result
end
def inv_max_item(item)
return 9999999 if item.nil? || item.inv_size == 0
free_slot / item.inv_size
end
def free_slot
inv_max - total_inv_size
end
alias theo_liminv_item_max? item_max?
def item_max?(item)
$BTEST ? theo_liminv_item_max?(item) : inv_max_item(item) <= 0
end
def near_maxed?
free_slot.to_f / inv_max <= Theo::LimInv::NearMaxed_Percent/100.0
end
def item_size(item)
return 0 unless item
item.inv_size * item_number(item)
end
#-----------------------------------------------------------------------------
# alias method: max_item_number
#-----------------------------------------------------------------------------
alias timpatch_liminv_max_item max_item_number
def max_item_number(item)
return 9999999 if Theo::LimInv::ForceGain
$BTEST ? timpatch_liminv_max_item(item) : inv_max_item(item) + item_number(item)
end
#-----------------------------------------------------------------------------
# alias method: gain_item
#-----------------------------------------------------------------------------
alias timpatch_liminv_gain_item gain_item
def gain_item(*args)
if Theo::LimInv::ForceGain
force_gain_item(*args)
else
timpatch_liminv_gain_item(*args)
end
end
if $imported["TH_InstanceItems"]
#-----------------------------------------------------------------------------
# new method: add_instance_item
#-----------------------------------------------------------------------------
def add_instance_item(item)
@inventory.add_instance_item(item)
end
end #$imported["TH_InstanceItems"]
#-----------------------------------------------------------------------------
# new method: force_gain_item
#-----------------------------------------------------------------------------
def force_gain_item(*args)
@inventory.force_gain = true
timpatch_liminv_gain_item(*args)
@inventory.force_gain = false
end
end #Game_Actor
#==============================================================================
# Game_Party -> inventory is the sum of all inventories, note that inv_max is already defined that way
#==============================================================================
class Game_Party < Game_Unit
#-----------------------------------------------------------------------------
# overwrite method: total_inv_size
#-----------------------------------------------------------------------------
def total_inv_size
members.inject(0) {|r,a| r+a.total_inv_size}
end
#-----------------------------------------------------------------------------
# overwrite method: force_gain_item (NOTE: inventory size or checking of party is not implemented!)
#-----------------------------------------------------------------------------
def force_gain_item(item, amount, include_equip = false)
return @inventory.gain_item(item, include_equip) if $imported["TIM-AI-addon-SharedItems"] && TIM::ActorInventoryAddon.shared_inventory?(item)
leader.force_gain_item(item, amount, include_equip)
end
#-----------------------------------------------------------------------------
# new method: distribute_extra_items -> called when an invenotry is full and
# others are not, only if DISTRIBUTE_EXTRA_ITEMS is true (handles multiple instance items)
#-----------------------------------------------------------------------------
def distribute_extra_items(item, amount)
candidates = members.select{|a| a.inv_max_item(item) >= 1}
for a in candidates
to_add = [0,[a.inv_max_item(item), amount].min].max
a.gain_item(item, to_add)
amount -= to_add
return if amount <= 0
end
end
if $imported["TH_InstanceItems"]
#-----------------------------------------------------------------------------
# new method: distribute_instance_item -> called when an invenotry is full and
# others are not, only if DISTRIBUTE_EXTRA_ITEMS is true (handles instance items)
#-----------------------------------------------------------------------------
def distribute_instance_item(item)
candidate = members.find{|a| a.inv_max_item(item) >= 1}
candidate.add_instance_item(item) if candidate #do nothing if no candidate was found
end
end #$imported["TH_InstanceItems"]
end #Game_Party
#==============================================================================
# Game_Player -> slow down features from single actors (only if option INVENTORY_SLOWED_ANY is true!)
#==============================================================================
if TimPatch::INVENTORY_SLOWED_ANY
class Game_Player
#-----------------------------------------------------------------------------
# alias method: dash?
#-----------------------------------------------------------------------------
alias timpatch_liminv_dash? dash?
def dash?
return false if Theo::LimInv::Full_DisableDash && $game_party.members.any?{|a| a.inv_maxed?}
return timpatch_liminv_dash?
end
#-----------------------------------------------------------------------------
# overwrite method: move_penalty
#-----------------------------------------------------------------------------
def move_penalty
Theo::LimInv::Full_SlowDown && $game_party.members.any?{|a| a.inv_maxed?} ? 1 : 0
end
end #Game_Player
end #TimPatch::INVENTORY_SLOWED_ANY
#==============================================================================
# Window_Base
#==============================================================================
class Window_Base < Window
#-----------------------------------------------------------------------------
# alias method: draw_inv_slot
#-----------------------------------------------------------------------------
alias actor_inv_patch_draw_inv_slot draw_inv_slot
def draw_inv_slot(x,y,width = contents.width,align = 2)
return actor_inv_patch_draw_inv_slot(x,y,width,align) unless SceneManager.scene_is?(Scene_Item) || SceneManager.scene_is?(Scene_Shop) || SceneManager.scene_is?(Scene_Battle)
#added
actor = SceneManager.scene_is?(Scene_Battle) ? BattleManager.actor : SceneManager.scene.actor
#replaced $game_party with actor:
txt = sprintf("%d/%d", actor.total_inv_size, actor.inv_max)
color = Theo::LimInv::NearMaxed_Color
if actor.near_maxed?
change_color(text_color(color))
else
change_color(normal_color)
end
draw_text(x,y,width,line_height,txt,align)
change_color(normal_color)
end
#-----------------------------------------------------------------------------
# overwrite method: draw_item_size
#-----------------------------------------------------------------------------
def draw_item_size(item,x,y,total = true,width = contents.width)
rect = Rect.new(x,y,width,line_height)
change_color(system_color)
draw_text(rect,Theo::LimInv::InvSizeVocab)
change_color(normal_color)
#modified here:
number = get_item_size(item,total)
draw_text(rect,number,2)
end
#-----------------------------------------------------------------------------
# new method: get_item_size
#-----------------------------------------------------------------------------
def get_item_size(item,total = true)
if Theo::LimInv::DrawTotal_Size && total
actor = SceneManager.scene_is?(Scene_Battle) ? BattleManager.actor : SceneManager.scene.actor
actor.item_size(item)
else
item.nil? ? 0 : item.inv_size
end
end
end #Window_Base
#==============================================================================
# Window_DiscardAmount
#==============================================================================
class Window_DiscardAmount < Window_Base
#-----------------------------------------------------------------------------
# overwrite method: refresh
#-----------------------------------------------------------------------------
def refresh
contents.clear
return unless @item
draw_item_name(@item,0,0,true,contents.width)
actor = SceneManager.scene.actor
txt = sprintf("%d/%d",@amount, actor.item_number(@item))
draw_text(0,0,contents.width,line_height,txt,2)
end
#-----------------------------------------------------------------------------
# overwrite method: lose_item
#-----------------------------------------------------------------------------
def lose_item
#replaced
#$game_party.lose_item(@item,@amount)
#with:
actor = SceneManager.scene.actor
actor.lose_item(@item,@amount)
#---
@itemlist.redraw_current_item
@freeslot.refresh
if actor.item_number(@item) == 0
Sound.play_ok
@itemlist.activate.refresh
@itemlist.update_help
@cmn_window.close.deactivate
close
else
close_window
end
end
#-----------------------------------------------------------------------------
# overwrite method: change_amount
#-----------------------------------------------------------------------------
def change_amount(num)
actor = SceneManager.scene.actor
@amount = [[@amount+num,0].max,actor.item_number(@item)].min
Sound.play_cursor
refresh
end
end #Window_DiscardAmount
if $imported["TH_InstanceItems"]
#==============================================================================
# Window_ItemList
#==============================================================================
class Window_ItemList < Window_Selectable
#-----------------------------------------------------------------------------
# alias method: draw_item_number
#-----------------------------------------------------------------------------
alias timpatch_ai_li_draw_item_number draw_item_number
def draw_item_number(rect, item)
timpatch_ai_li_draw_item_number(rect,item) if item.is_template?
end
end #Window_ItemList
end #$imported["TH_InstanceItems"]
#==============================================================================
# Window_ShopNumber
#==============================================================================
class Window_ShopNumber < Window_Selectable
#-----------------------------------------------------------------------------
# overwrite method: draw_itemsize
#-----------------------------------------------------------------------------
def draw_itemsize
actor = SceneManager.scene_is?(Scene_Shop) ? SceneManager.scene.actor : $game_party.leader
item_size = @number * @item.inv_size
total_size = actor.total_inv_size +
(@mode == :buy ? item_size : -item_size)
txt = sprintf("%d/%d",total_size,actor.inv_max)
ypos = item_y + line_height * ($imported["YEA-ShopOptions"] ? 5 : 4)
rect = Rect.new(4,ypos,contents.width-8,line_height)
change_color(system_color)
draw_text(rect,Theo::LimInv::InvSlotVocab)
change_color(normal_color)
draw_text(rect,txt,2)
end
end #Window_ShopNumber
#==============================================================================
# Scene_Item
#==============================================================================
class Scene_Item < Scene_ItemBase
attr_reader :actor
#-----------------------------------------------------------------------------
# overwrite method: on_item_ok
#-----------------------------------------------------------------------------
def on_item_ok
@actor.last_item.object = item
@use_command.set_item(item)
@use_command.open
@use_command.activate
@use_command.select(0)
end
#-----------------------------------------------------------------------------
# alias method: on_actor_change
#-----------------------------------------------------------------------------
alias timpatch_ai_li_on_actor_change on_actor_change
def on_actor_change
timpatch_ai_li_on_actor_change
@freeslot.refresh
end
end #Scene_Item
#==============================================================================
# Scene_Shop
#==============================================================================
class Scene_Shop < Scene_MenuBase
attr_reader :actor
if $imported["TH_ActorTradeScene"]
#-----------------------------------------------------------------------------
# overwrite method: start -> bugfix to Hime's script
#-----------------------------------------------------------------------------
def start
@actor = $game_party.leader #just a security measure, it is actually not required thanks to Scene_MenuBase
th_actor_inventory_start
end
end
#-----------------------------------------------------------------------------
# overwrite method: do_buy
#-----------------------------------------------------------------------------
def do_buy(number)
puts @actor.id
$game_party.lose_gold(number * buying_price)
@actor.gain_item(@item, number)
end
end #Scene_Shop
Alternatively, you can comment line 240 of Actor Scenes to get something like this:
Ruby:
class Scene_Shop < Scene_MenuBase
def start
th_actor_inventory_start
#@actor = $game_party.leader
end
end
Okay now I'm facing no issues, I think all is done, but just in case, I will still stay vigilant for any bug and post it here. Either way you've helped a lot so thanks again 🙂
So, funny thing I found for anyone else that tries using these scripts
This time I decided to equip items but I got an error:

I solved it by going to Actor Inventory" and removing the "include_equip" thingy:
Okay finally an actual issue.
Not really a bug but we ended up forgetting to make weapons and armors discardable, so if an unlucky player is at a dungeon and ends up with an inventory more or less like this...
He's screwed and will only be able to get rid of them by going back to a town and sell them.
So, funny thing I found for anyone else that tries using these scripts
This time I decided to equip items but I got an error:

I solved it by going to Actor Inventory" and removing the "include_equip" thingy:
Okay finally an actual issue.
Not really a bug but we ended up forgetting to make weapons and armors discardable, so if an unlucky player is at a dungeon and ends up with an inventory more or less like this...
He's screwed and will only be able to get rid of them by going back to a town and sell them.
The bug comes from my script shared items, I forgot to put the second parameter.
You should discard your changes to Actor Inventory script, this was not a bug from this script and your 'fix' might break things like event calls checking for items in party.
Here is a an updated version of the script:
Ruby:
#==============================================================================
# Hime's Actor Inventory addon - shared items
#------------------------------------------------------------------------------
# Author: Timtrack
# date: 02/06/2025
# Requires: Hime's Actor Inventory and Actor Inventory Scenes
#==============================================================================
# Installation: put this below Hime's scripts
#==============================================================================
$imported = {} if $imported.nil?
$imported["TIM-AI-addon-SharedItems"] = true
module TIM
module ActorInventoryAddon
SHARED_KEY_ITEMS = true
module REGEXP
SHARED = /<shared_inventory>/i
end #REGEXP
def self.shared_inventory?(item)
return false unless item
return true if item.shared_inventory
return true if SHARED_KEY_ITEMS && item.is_a?(RPG::Item) && item.key_item?
false
end
end #ActorInventory
end #TIM
#============================================================================
# DataManager
#============================================================================
module DataManager
#--------------------------------------------------------------------------
# alias method: load_database
#--------------------------------------------------------------------------
class <<self; alias load_database_shared_items load_database; end
def self.load_database
load_database_shared_items
load_notetags_shared_items
end
#--------------------------------------------------------------------------
# new method: load_notetags_shared_items
#--------------------------------------------------------------------------
def self.load_notetags_shared_items
groups = [$data_items,$data_armors,$data_weapons]
for group in groups
for obj in group
next if obj.nil?
obj.load_notetags_shared_items
end
end
end
end # DataManager
#============================================================================
# RPG::BaseItem
#============================================================================
class RPG::BaseItem
attr_reader :shared_inventory
#--------------------------------------------------------------------------
# common cache: load_notetags_shared_items
#--------------------------------------------------------------------------
def load_notetags_shared_items
@shared_inventory = false
#---
self.note.split(/[\r\n]+/).each { |line|
case line
#---
when TIM::ActorInventoryAddon::REGEXP::SHARED
@shared_inventory = true
end
#---
} # self.note.split
#---
end
end # RPG::BaseItem
#==============================================================================
# Window_ItemList
#==============================================================================
class Window_ItemList < Window_Selectable
#-----------------------------------------------------------------------------
# alias method: make_item_list
#-----------------------------------------------------------------------------
alias shared_item_make_item_list make_item_list
def make_item_list
shared_item_make_item_list
@data = $game_party.all_items.select {|item| include?(item) } + @data
end
end #Window_ItemList
#==============================================================================
# Game_Actor
#==============================================================================
class Game_Actor
#--------------------------------------------------------------------------
# alias method: gain_item
#--------------------------------------------------------------------------
alias shared_gain_item gain_item
def gain_item(item, amount, include_equip = false)
return shared_gain_item(item, amount, include_equip) unless TIM::ActorInventoryAddon.shared_inventory?(item)
$game_party.gain_item(item, amount, include_equip)
end
alias shared_item_number item_number
def item_number(item)
return shared_item_number(item) unless TIM::ActorInventoryAddon.shared_inventory?(item)
$game_party.item_number(item)
end
alias shared_has_item? has_item?
def has_item?(item, include_equip = false)
return shared_has_item?(item, include_equip) unless TIM::ActorInventoryAddon.shared_inventory?(item)
$game_party.has_item?(item, include_equip)
end
end #Game_Actor
#============================================================================
# Game_Party
#============================================================================
class Game_Party < Game_Unit
#--------------------------------------------------------------------------
# alias method: has_item?
#--------------------------------------------------------------------------
alias shared_has_item? has_item?
def has_item?(item, include_equip = false)
return shared_has_item?(item, include_equip) unless TIM::ActorInventoryAddon.shared_inventory?(item)
@inventory.has_item?(item, include_equip)
end
#--------------------------------------------------------------------------
# alias method: item_number
#--------------------------------------------------------------------------
alias shared_item_number item_number
def item_number(item)
return shared_item_number(item) unless TIM::ActorInventoryAddon.shared_inventory?(item)
@inventory.item_number(item)
end
#--------------------------------------------------------------------------
# alias method: gain_item
#--------------------------------------------------------------------------
alias shared_gain_item gain_item
def gain_item(item, amount, include_equip = false)
return shared_gain_item(item, amount, include_equip) unless TIM::ActorInventoryAddon.shared_inventory?(item)
@inventory.gain_item(item, amount, include_equip)
end
end #Game_Party
Well it is a 'bug' since I forgot to patch this! Here is a new version of the patch ~
Ruby:
#==============================================================================
# Actor Inventory, Limited Inventory and Instance Items compatibility patch
#------------------------------------------------------------------------------
# Author: Timtrack
# date: 02/06/2025
# Requires: TheoAllen - Limited Inventory and Hime's Actor Inventory
# Supports Hime's Instance Items
#==============================================================================
# Note: tested with the following script order:
# Limited Inventory
# Instance Items*
# Core - Inventory
# Core - Inventory - Instance Items patch*
# Actor Inventory
# Actor Inventory - Instance Items*
# Actor Inventory Scenes
# This patch
#
# * Use the scripts with the symbol if you use Hime's instance items
#==============================================================================
$imported = {} if $imported.nil?
$imported["TIM_ACTOR_LIMIT_INSTANCE_INVENTORY_Patch"] = true
module TimPatch
#set to true for TheoAllen's script to slow paarty members if at least one
#actor inventory is full, else all inventories must be full to slow the party
INVENTORY_SLOWED_ANY = false
#set to true for extra items to be given to other actors inventories when
#current actor inventory is full (item is discarded if no inventory can handle it)
DISTRIBUTE_EXTRA_ITEMS = true
#if an item is non discardable and non usable in the menu:
#disable the item from the menu if this option is true
#if the option is false, you can still select the item with only the option to cancel
#your action
DISABLE_NON_USABLE_AND_DISCARDABLE_ITEMS = false
#-----------------------------------------------------------------------------
# new method: discardable? -> meant to overwrite TheoAllen's discardable
# method that was hidden in a window object (code is exactly the same)
#-----------------------------------------------------------------------------
def self.discardable?(item)
return false if item.nil?
!(item.is_a?(RPG::Item) && item.key_item?)
end
end #TimPatch
#==============================================================================
# Game_Inventory
#==============================================================================
class Game_Inventory
attr_accessor :force_gain
end #Game_Inventory
#==============================================================================
# Game_ActorInventory
#==============================================================================
class Game_ActorInventory < Game_Inventory
#-----------------------------------------------------------------------------
# alias method: max_item_number -> handles the weight
#-----------------------------------------------------------------------------
alias timpatch_liminv_max_item max_item_number
def max_item_number(item)
return 9999999 if @force_gain #don't ask for weight in force gain mode
$BTEST ? timpatch_liminv_max_item(item) : @actor.inv_max_item(item) + item_number(item)
end
if $imported["TH_InstanceItems"]
#-----------------------------------------------------------------------------
# alias method: add_instance_item -> will forbid new insstances to be given if inventory is full
#-----------------------------------------------------------------------------
alias timpatch_liminv_add_instance_item add_instance_item
def add_instance_item(item)
if actor.inv_max_item(item) <= 0 && !@force_gain
$game_party.distribute_instance_item(item) if TimPatch::DISTRIBUTE_EXTRA_ITEMS
else
timpatch_liminv_add_instance_item(item)
end
end
else #compatibility if no instance item script is used
def instance_enabled?(item); false; end
end#$imported["TH_InstanceItems"]
if TimPatch::DISTRIBUTE_EXTRA_ITEMS
#-----------------------------------------------------------------------------
# alias method: gain_item
#-----------------------------------------------------------------------------
alias timpatch_instance_gain_item gain_item
def gain_item(item, amount, include_equip = false)
return timpatch_instance_gain_item(item, amount, include_equip) if @force_gain || instance_enabled?(item) || amount <= 0
#case where item is not instanciable and amount is > 0
place = @actor.inv_max_item(item)
return timpatch_instance_gain_item(item, amount, include_equip) if place >= amount
#if not enough space for items, we disstribute the rest to the party members:
r = timpatch_instance_gain_item(item, place, include_equip)
$game_party.distribute_extra_items(item, amount-place)
return r #just a failsafe if gain_item had a return value
end
end #TimPatch::DISTRIBUTE_EXTRA_ITEMS
end #Game_ActorInventory
#==============================================================================
# Game_Actor -> all new methods here were pasted from Game_Party in Limited Inventory
#==============================================================================
class Game_Actor < Game_Battler
def inv_maxed?
inv_max <= total_inv_size
end
#this one contains the actor inventory AND their equipment
def total_inv_size
result = all_items.inject(0) {|total,item| total + (item_number(item) * item.inv_size)}
result += equip_size
result
end
def inv_max_item(item)
return 9999999 if item.nil? || item.inv_size == 0
free_slot / item.inv_size
end
def free_slot
inv_max - total_inv_size
end
alias theo_liminv_item_max? item_max?
def item_max?(item)
$BTEST ? theo_liminv_item_max?(item) : inv_max_item(item) <= 0
end
def near_maxed?
free_slot.to_f / inv_max <= Theo::LimInv::NearMaxed_Percent/100.0
end
def item_size(item)
return 0 unless item
item.inv_size * item_number(item)
end
#-----------------------------------------------------------------------------
# alias method: max_item_number
#-----------------------------------------------------------------------------
alias timpatch_liminv_max_item max_item_number
def max_item_number(item)
return 9999999 if Theo::LimInv::ForceGain
$BTEST ? timpatch_liminv_max_item(item) : inv_max_item(item) + item_number(item)
end
#-----------------------------------------------------------------------------
# alias method: gain_item
#-----------------------------------------------------------------------------
alias timpatch_liminv_gain_item gain_item
def gain_item(*args)
if Theo::LimInv::ForceGain
force_gain_item(*args)
else
timpatch_liminv_gain_item(*args)
end
end
if $imported["TH_InstanceItems"]
#-----------------------------------------------------------------------------
# new method: add_instance_item
#-----------------------------------------------------------------------------
def add_instance_item(item)
@inventory.add_instance_item(item)
end
end #$imported["TH_InstanceItems"]
#-----------------------------------------------------------------------------
# new method: force_gain_item
#-----------------------------------------------------------------------------
def force_gain_item(*args)
@inventory.force_gain = true
timpatch_liminv_gain_item(*args)
@inventory.force_gain = false
end
end #Game_Actor
#==============================================================================
# Game_Party -> inventory is the sum of all inventories, note that inv_max is already defined that way
#==============================================================================
class Game_Party < Game_Unit
#-----------------------------------------------------------------------------
# overwrite method: total_inv_size
#-----------------------------------------------------------------------------
def total_inv_size
members.inject(0) {|r,a| r+a.total_inv_size}
end
#-----------------------------------------------------------------------------
# overwrite method: force_gain_item (NOTE: inventory size or checking of party is not implemented!)
#-----------------------------------------------------------------------------
def force_gain_item(item, amount, include_equip = false)
return @inventory.gain_item(item, include_equip) if $imported["TIM-AI-addon-SharedItems"] && TIM::ActorInventoryAddon.shared_inventory?(item)
leader.force_gain_item(item, amount, include_equip)
end
#-----------------------------------------------------------------------------
# new method: distribute_extra_items -> called when an invenotry is full and
# others are not, only if DISTRIBUTE_EXTRA_ITEMS is true (handles multiple instance items)
#-----------------------------------------------------------------------------
def distribute_extra_items(item, amount)
candidates = members.select{|a| a.inv_max_item(item) >= 1}
for a in candidates
to_add = [0,[a.inv_max_item(item), amount].min].max
a.gain_item(item, to_add)
amount -= to_add
return if amount <= 0
end
end
if $imported["TH_InstanceItems"]
#-----------------------------------------------------------------------------
# new method: distribute_instance_item -> called when an invenotry is full and
# others are not, only if DISTRIBUTE_EXTRA_ITEMS is true (handles instance items)
#-----------------------------------------------------------------------------
def distribute_instance_item(item)
candidate = members.find{|a| a.inv_max_item(item) >= 1}
candidate.add_instance_item(item) if candidate #do nothing if no candidate was found
end
end #$imported["TH_InstanceItems"]
end #Game_Party
#==============================================================================
# Game_Player -> slow down features from single actors (only if option INVENTORY_SLOWED_ANY is true!)
#==============================================================================
if TimPatch::INVENTORY_SLOWED_ANY
class Game_Player
#-----------------------------------------------------------------------------
# alias method: dash?
#-----------------------------------------------------------------------------
alias timpatch_liminv_dash? dash?
def dash?
return false if Theo::LimInv::Full_DisableDash && $game_party.members.any?{|a| a.inv_maxed?}
return timpatch_liminv_dash?
end
#-----------------------------------------------------------------------------
# overwrite method: move_penalty
#-----------------------------------------------------------------------------
def move_penalty
Theo::LimInv::Full_SlowDown && $game_party.members.any?{|a| a.inv_maxed?} ? 1 : 0
end
end #Game_Player
end #TimPatch::INVENTORY_SLOWED_ANY
#==============================================================================
# Window_Base
#==============================================================================
class Window_Base < Window
#-----------------------------------------------------------------------------
# alias method: draw_inv_slot
#-----------------------------------------------------------------------------
alias actor_inv_patch_draw_inv_slot draw_inv_slot
def draw_inv_slot(x,y,width = contents.width,align = 2)
return actor_inv_patch_draw_inv_slot(x,y,width,align) unless SceneManager.scene_is?(Scene_Item) || SceneManager.scene_is?(Scene_Shop) || SceneManager.scene_is?(Scene_Battle)
#added
actor = SceneManager.scene_is?(Scene_Battle) ? BattleManager.actor : SceneManager.scene.actor
#replaced $game_party with actor:
txt = sprintf("%d/%d", actor.total_inv_size, actor.inv_max)
color = Theo::LimInv::NearMaxed_Color
if actor.near_maxed?
change_color(text_color(color))
else
change_color(normal_color)
end
draw_text(x,y,width,line_height,txt,align)
change_color(normal_color)
end
#-----------------------------------------------------------------------------
# overwrite method: draw_item_size
#-----------------------------------------------------------------------------
def draw_item_size(item,x,y,total = true,width = contents.width)
rect = Rect.new(x,y,width,line_height)
change_color(system_color)
draw_text(rect,Theo::LimInv::InvSizeVocab)
change_color(normal_color)
#modified here:
number = get_item_size(item,total)
draw_text(rect,number,2)
end
#-----------------------------------------------------------------------------
# new method: get_item_size
#-----------------------------------------------------------------------------
def get_item_size(item,total = true)
if Theo::LimInv::DrawTotal_Size && total
actor = SceneManager.scene_is?(Scene_Battle) ? BattleManager.actor : SceneManager.scene.actor
actor.item_size(item)
else
item.nil? ? 0 : item.inv_size
end
end
end #Window_Base
#==============================================================================
# Window_DiscardAmount
#==============================================================================
class Window_DiscardAmount < Window_Base
#-----------------------------------------------------------------------------
# overwrite method: refresh
#-----------------------------------------------------------------------------
def refresh
contents.clear
return unless @item
draw_item_name(@item,0,0,true,contents.width)
actor = SceneManager.scene.actor
txt = sprintf("%d/%d",@amount, actor.item_number(@item))
draw_text(0,0,contents.width,line_height,txt,2)
end
#-----------------------------------------------------------------------------
# overwrite method: lose_item
#-----------------------------------------------------------------------------
def lose_item
#replaced
#$game_party.lose_item(@item,@amount)
#with:
actor = SceneManager.scene.actor
actor.lose_item(@item,@amount)
#---
@itemlist.redraw_current_item
@freeslot.refresh
if actor.item_number(@item) == 0
Sound.play_ok
@itemlist.activate.refresh
@itemlist.update_help
@cmn_window.close.deactivate
close
else
close_window
end
end
#-----------------------------------------------------------------------------
# overwrite method: change_amount
#-----------------------------------------------------------------------------
def change_amount(num)
actor = SceneManager.scene.actor
@amount = [[@amount+num,0].max,actor.item_number(@item)].min
Sound.play_cursor
refresh
end
end #Window_DiscardAmount
#==============================================================================
# Window_ItemUseCommand
#==============================================================================
class Window_ItemUseCommand < Window_Command
#-----------------------------------------------------------------------------
# overwrite method: discardable? -> define the method outside of the window obj
#-----------------------------------------------------------------------------
def discardable?(item)
TimPatch.discardable?(item)
end
end #Window_ItemUseCommand
if $imported["TH_InstanceItems"]
#==============================================================================
# Window_ItemList
#==============================================================================
class Window_ItemList < Window_Selectable
#-----------------------------------------------------------------------------
# alias method: draw_item_number
#-----------------------------------------------------------------------------
alias timpatch_ai_li_draw_item_number draw_item_number
def draw_item_number(rect, item)
timpatch_ai_li_draw_item_number(rect,item) if item.is_template?
end
#-----------------------------------------------------------------------------
# overwrite method: enable? -> restores TheoAllen's Limited Inventory behavior
#-----------------------------------------------------------------------------
alias timpatch_ai_li_enable? enable?
def enable?(item)
return item unless TimPatch::DISABLE_NON_USABLE_AND_DISCARDABLE_ITEMS
item && (timpatch_ai_li_enable?(item) || discardable?(item))
end
#-----------------------------------------------------------------------------
# new method: discardable?
#-----------------------------------------------------------------------------
def discardable?(item)
SceneManager.scene_is?(Scene_Item) && TimPatch.discardable?(item)
end
end #Window_ItemList
end #$imported["TH_InstanceItems"]
#==============================================================================
# Window_ShopNumber
#==============================================================================
class Window_ShopNumber < Window_Selectable
#-----------------------------------------------------------------------------
# overwrite method: draw_itemsize
#-----------------------------------------------------------------------------
def draw_itemsize
actor = SceneManager.scene_is?(Scene_Shop) ? SceneManager.scene.actor : $game_party.leader
item_size = @number * @item.inv_size
total_size = actor.total_inv_size +
(@mode == :buy ? item_size : -item_size)
txt = sprintf("%d/%d",total_size,actor.inv_max)
ypos = item_y + line_height * ($imported["YEA-ShopOptions"] ? 5 : 4)
rect = Rect.new(4,ypos,contents.width-8,line_height)
change_color(system_color)
draw_text(rect,Theo::LimInv::InvSlotVocab)
change_color(normal_color)
draw_text(rect,txt,2)
end
end #Window_ShopNumber
#==============================================================================
# Scene_Item
#==============================================================================
class Scene_Item < Scene_ItemBase
attr_reader :actor
#-----------------------------------------------------------------------------
# overwrite method: on_item_ok
#-----------------------------------------------------------------------------
def on_item_ok
#@actor.last_item.object = item
@use_command.set_item(item)
@use_command.open
@use_command.activate
@use_command.select(0)
end
#-----------------------------------------------------------------------------
# alias method: use_command_ok
#-----------------------------------------------------------------------------
alias timpatch_ai_li_use_command_ok use_command_ok
def use_command_ok
@actor.last_item.object = item
timpatch_ai_li_use_command_ok
end
#-----------------------------------------------------------------------------
# alias method: on_actor_change
#-----------------------------------------------------------------------------
alias timpatch_ai_li_on_actor_change on_actor_change
def on_actor_change
timpatch_ai_li_on_actor_change
@freeslot.refresh
end
end #Scene_Item
#==============================================================================
# Scene_Shop
#==============================================================================
class Scene_Shop < Scene_MenuBase
attr_reader :actor
if $imported["TH_ActorTradeScene"]
#-----------------------------------------------------------------------------
# overwrite method: start -> bugfix to Hime's script
#-----------------------------------------------------------------------------
def start
@actor = $game_party.leader
th_actor_inventory_start
end
end
#-----------------------------------------------------------------------------
# overwrite method: do_buy
#-----------------------------------------------------------------------------
def do_buy(number)
$game_party.lose_gold(number * buying_price)
@actor.gain_item(@item, number)
end
end #Scene_Shop
Also, please refrain from posting multiple messages in a row in such a short time, you can edit your previous posts for this. You can find the forum rules here.
Okay did all of that and I can discard weapons! (And sorry for that multiple message thingy D: )
And speaking of bugs, oddly enough, I can't sell multiple items now. Similarly, I cannot discard multiple items.
And speaking of bugs, oddly enough, I can't sell multiple items now. Similarly, I cannot discard multiple items.
It does seem to work fine on my side. Are you sure you are not using the instance items script here?
Take a save where your items cannot be sold or discarded together, then deactivate my script 'single item display' and reload the save to see if your items were instantiated or not.
Take a save where your items cannot be sold or discarded together, then deactivate my script 'single item display' and reload the save to see if your items were instantiated or not.
Finally back! And yes I was using Instance Items, but disabling made me go back to not being able to discard weapons or armor...
That was because I did not put my modification under the right conditions in the patch ahah.
Here is yet another version. The discarding part should work even without instance items.
EDIT: There was once again a small bug (if you weren't using Actor Trade Scene then my patch would not fix the shop bug from Hime, I updated the patch above.
If you still encounter your discarding bug and it is not due to to instance items, then could you provide a demo or equivalent for me to test it?
Here is yet another version. The discarding part should work even without instance items.
Ruby:
#==============================================================================
# Actor Inventory, Limited Inventory and Instance Items compatibility patch
#------------------------------------------------------------------------------
# Author: Timtrack
# date: 02/06/2025
# Requires: TheoAllen - Limited Inventory and Hime's Actor Inventory
# Supports Hime's Instance Items
#==============================================================================
# Note: tested with the following script order:
# Limited Inventory
# Instance Items*
# Core - Inventory
# Core - Inventory - Instance Items patch*
# Actor Inventory
# Actor Inventory - Instance Items*
# Actor Inventory Scenes
# This patch
#
# * Use the scripts with the symbol if you use Hime's instance items
#==============================================================================
$imported = {} if $imported.nil?
$imported["TIM_ACTOR_LIMIT_INSTANCE_INVENTORY_Patch"] = true
module TimPatch
#set to true for TheoAllen's script to slow paarty members if at least one
#actor inventory is full, else all inventories must be full to slow the party
INVENTORY_SLOWED_ANY = false
#set to true for extra items to be given to other actors inventories when
#current actor inventory is full (item is discarded if no inventory can handle it)
DISTRIBUTE_EXTRA_ITEMS = true
#if an item is non discardable and non usable in the menu:
#disable the item from the menu if this option is true
#if the option is false, you can still select the item with only the option to cancel
#your action
DISABLE_NON_USABLE_AND_DISCARDABLE_ITEMS = false
#-----------------------------------------------------------------------------
# new method: discardable? -> meant to overwrite TheoAllen's discardable
# method that was hidden in a window object (code is exactly the same)
#-----------------------------------------------------------------------------
def self.discardable?(item)
return false if item.nil?
!(item.is_a?(RPG::Item) && item.key_item?)
end
end #TimPatch
#==============================================================================
# Game_Inventory
#==============================================================================
class Game_Inventory
attr_accessor :force_gain
end #Game_Inventory
#==============================================================================
# Game_ActorInventory
#==============================================================================
class Game_ActorInventory < Game_Inventory
#-----------------------------------------------------------------------------
# alias method: max_item_number -> handles the weight
#-----------------------------------------------------------------------------
alias timpatch_liminv_max_item max_item_number
def max_item_number(item)
return 9999999 if @force_gain #don't ask for weight in force gain mode
$BTEST ? timpatch_liminv_max_item(item) : @actor.inv_max_item(item) + item_number(item)
end
if $imported["TH_InstanceItems"]
#-----------------------------------------------------------------------------
# alias method: add_instance_item -> will forbid new insstances to be given if inventory is full
#-----------------------------------------------------------------------------
alias timpatch_liminv_add_instance_item add_instance_item
def add_instance_item(item)
if actor.inv_max_item(item) <= 0 && !@force_gain
$game_party.distribute_instance_item(item) if TimPatch::DISTRIBUTE_EXTRA_ITEMS
else
timpatch_liminv_add_instance_item(item)
end
end
else #compatibility if no instance item script is used
def instance_enabled?(item); false; end
end#$imported["TH_InstanceItems"]
if TimPatch::DISTRIBUTE_EXTRA_ITEMS
#-----------------------------------------------------------------------------
# alias method: gain_item
#-----------------------------------------------------------------------------
alias timpatch_instance_gain_item gain_item
def gain_item(item, amount, include_equip = false)
return timpatch_instance_gain_item(item, amount, include_equip) if @force_gain || instance_enabled?(item) || amount <= 0
#case where item is not instanciable and amount is > 0
place = @actor.inv_max_item(item)
return timpatch_instance_gain_item(item, amount, include_equip) if place >= amount
#if not enough space for items, we disstribute the rest to the party members:
r = timpatch_instance_gain_item(item, place, include_equip)
$game_party.distribute_extra_items(item, amount-place)
return r #just a failsafe if gain_item had a return value
end
end #TimPatch::DISTRIBUTE_EXTRA_ITEMS
end #Game_ActorInventory
#==============================================================================
# Game_Actor -> all new methods here were pasted from Game_Party in Limited Inventory
#==============================================================================
class Game_Actor < Game_Battler
def inv_maxed?
inv_max <= total_inv_size
end
#this one contains the actor inventory AND their equipment
def total_inv_size
result = all_items.inject(0) {|total,item| total + (item_number(item) * item.inv_size)}
result += equip_size
result
end
def inv_max_item(item)
return 9999999 if item.nil? || item.inv_size == 0
free_slot / item.inv_size
end
def free_slot
inv_max - total_inv_size
end
alias theo_liminv_item_max? item_max?
def item_max?(item)
$BTEST ? theo_liminv_item_max?(item) : inv_max_item(item) <= 0
end
def near_maxed?
free_slot.to_f / inv_max <= Theo::LimInv::NearMaxed_Percent/100.0
end
def item_size(item)
return 0 unless item
item.inv_size * item_number(item)
end
#-----------------------------------------------------------------------------
# alias method: max_item_number
#-----------------------------------------------------------------------------
alias timpatch_liminv_max_item max_item_number
def max_item_number(item)
return 9999999 if Theo::LimInv::ForceGain
$BTEST ? timpatch_liminv_max_item(item) : inv_max_item(item) + item_number(item)
end
#-----------------------------------------------------------------------------
# alias method: gain_item
#-----------------------------------------------------------------------------
alias timpatch_liminv_gain_item gain_item
def gain_item(*args)
if Theo::LimInv::ForceGain
force_gain_item(*args)
else
timpatch_liminv_gain_item(*args)
end
end
if $imported["TH_InstanceItems"]
#-----------------------------------------------------------------------------
# new method: add_instance_item
#-----------------------------------------------------------------------------
def add_instance_item(item)
@inventory.add_instance_item(item)
end
end #$imported["TH_InstanceItems"]
#-----------------------------------------------------------------------------
# new method: force_gain_item
#-----------------------------------------------------------------------------
def force_gain_item(*args)
@inventory.force_gain = true
timpatch_liminv_gain_item(*args)
@inventory.force_gain = false
end
end #Game_Actor
#==============================================================================
# Game_Party -> inventory is the sum of all inventories, note that inv_max is already defined that way
#==============================================================================
class Game_Party < Game_Unit
#-----------------------------------------------------------------------------
# overwrite method: total_inv_size
#-----------------------------------------------------------------------------
def total_inv_size
members.inject(0) {|r,a| r+a.total_inv_size}
end
#-----------------------------------------------------------------------------
# overwrite method: force_gain_item (NOTE: inventory size or checking of party is not implemented!)
#-----------------------------------------------------------------------------
def force_gain_item(item, amount, include_equip = false)
return @inventory.gain_item(item, include_equip) if $imported["TIM-AI-addon-SharedItems"] && TIM::ActorInventoryAddon.shared_inventory?(item)
leader.force_gain_item(item, amount, include_equip)
end
#-----------------------------------------------------------------------------
# new method: distribute_extra_items -> called when an invenotry is full and
# others are not, only if DISTRIBUTE_EXTRA_ITEMS is true (handles multiple instance items)
#-----------------------------------------------------------------------------
def distribute_extra_items(item, amount)
candidates = members.select{|a| a.inv_max_item(item) >= 1}
for a in candidates
to_add = [0,[a.inv_max_item(item), amount].min].max
a.gain_item(item, to_add)
amount -= to_add
return if amount <= 0
end
end
if $imported["TH_InstanceItems"]
#-----------------------------------------------------------------------------
# new method: distribute_instance_item -> called when an invenotry is full and
# others are not, only if DISTRIBUTE_EXTRA_ITEMS is true (handles instance items)
#-----------------------------------------------------------------------------
def distribute_instance_item(item)
candidate = members.find{|a| a.inv_max_item(item) >= 1}
candidate.add_instance_item(item) if candidate #do nothing if no candidate was found
end
end #$imported["TH_InstanceItems"]
end #Game_Party
#==============================================================================
# Game_Player -> slow down features from single actors (only if option INVENTORY_SLOWED_ANY is true!)
#==============================================================================
if TimPatch::INVENTORY_SLOWED_ANY
class Game_Player
#-----------------------------------------------------------------------------
# alias method: dash?
#-----------------------------------------------------------------------------
alias timpatch_liminv_dash? dash?
def dash?
return false if Theo::LimInv::Full_DisableDash && $game_party.members.any?{|a| a.inv_maxed?}
return timpatch_liminv_dash?
end
#-----------------------------------------------------------------------------
# overwrite method: move_penalty
#-----------------------------------------------------------------------------
def move_penalty
Theo::LimInv::Full_SlowDown && $game_party.members.any?{|a| a.inv_maxed?} ? 1 : 0
end
end #Game_Player
end #TimPatch::INVENTORY_SLOWED_ANY
#==============================================================================
# Window_Base
#==============================================================================
class Window_Base < Window
#-----------------------------------------------------------------------------
# alias method: draw_inv_slot
#-----------------------------------------------------------------------------
alias actor_inv_patch_draw_inv_slot draw_inv_slot
def draw_inv_slot(x,y,width = contents.width,align = 2)
return actor_inv_patch_draw_inv_slot(x,y,width,align) unless SceneManager.scene_is?(Scene_Item) || SceneManager.scene_is?(Scene_Shop) || SceneManager.scene_is?(Scene_Battle)
#added
actor = SceneManager.scene_is?(Scene_Battle) ? BattleManager.actor : SceneManager.scene.actor
#replaced $game_party with actor:
txt = sprintf("%d/%d", actor.total_inv_size, actor.inv_max)
color = Theo::LimInv::NearMaxed_Color
if actor.near_maxed?
change_color(text_color(color))
else
change_color(normal_color)
end
draw_text(x,y,width,line_height,txt,align)
change_color(normal_color)
end
#-----------------------------------------------------------------------------
# overwrite method: draw_item_size
#-----------------------------------------------------------------------------
def draw_item_size(item,x,y,total = true,width = contents.width)
rect = Rect.new(x,y,width,line_height)
change_color(system_color)
draw_text(rect,Theo::LimInv::InvSizeVocab)
change_color(normal_color)
#modified here:
number = get_item_size(item,total)
draw_text(rect,number,2)
end
#-----------------------------------------------------------------------------
# new method: get_item_size
#-----------------------------------------------------------------------------
def get_item_size(item,total = true)
if Theo::LimInv::DrawTotal_Size && total
actor = SceneManager.scene_is?(Scene_Battle) ? BattleManager.actor : SceneManager.scene.actor
actor.item_size(item)
else
item.nil? ? 0 : item.inv_size
end
end
end #Window_Base
#==============================================================================
# Window_DiscardAmount
#==============================================================================
class Window_DiscardAmount < Window_Base
#-----------------------------------------------------------------------------
# overwrite method: refresh
#-----------------------------------------------------------------------------
def refresh
contents.clear
return unless @item
draw_item_name(@item,0,0,true,contents.width)
actor = SceneManager.scene.actor
txt = sprintf("%d/%d",@amount, actor.item_number(@item))
draw_text(0,0,contents.width,line_height,txt,2)
end
#-----------------------------------------------------------------------------
# overwrite method: lose_item
#-----------------------------------------------------------------------------
def lose_item
#replaced
#$game_party.lose_item(@item,@amount)
#with:
actor = SceneManager.scene.actor
actor.lose_item(@item,@amount)
#---
@itemlist.redraw_current_item
@freeslot.refresh
if actor.item_number(@item) == 0
Sound.play_ok
@itemlist.activate.refresh
@itemlist.update_help
@cmn_window.close.deactivate
close
else
close_window
end
end
#-----------------------------------------------------------------------------
# overwrite method: change_amount
#-----------------------------------------------------------------------------
def change_amount(num)
actor = SceneManager.scene.actor
@amount = [[@amount+num,0].max,actor.item_number(@item)].min
Sound.play_cursor
refresh
end
end #Window_DiscardAmount
#==============================================================================
# Window_ItemUseCommand
#==============================================================================
class Window_ItemUseCommand < Window_Command
#-----------------------------------------------------------------------------
# overwrite method: discardable? -> define the method outside of the window obj
#-----------------------------------------------------------------------------
def discardable?(item)
TimPatch.discardable?(item)
end
end #Window_ItemUseCommand
#==============================================================================
# Window_ItemList
#==============================================================================
class Window_ItemList < Window_Selectable
if $imported["TH_InstanceItems"]
#-----------------------------------------------------------------------------
# alias method: draw_item_number
#-----------------------------------------------------------------------------
alias timpatch_ai_li_draw_item_number draw_item_number
def draw_item_number(rect, item)
timpatch_ai_li_draw_item_number(rect,item) if item.is_template?
end
end #$imported["TH_InstanceItems"]
#-----------------------------------------------------------------------------
# overwrite method: enable? -> restores TheoAllen's Limited Inventory behavior
#-----------------------------------------------------------------------------
alias timpatch_ai_li_enable? enable?
def enable?(item)
puts "enable " + item.to_s
return false unless item
return true unless TimPatch::DISABLE_NON_USABLE_AND_DISCARDABLE_ITEMS
item && (timpatch_ai_li_enable?(item) || discardable?(item))
end
#-----------------------------------------------------------------------------
# new method: discardable?
#-----------------------------------------------------------------------------
def discardable?(item)
SceneManager.scene_is?(Scene_Item) && TimPatch.discardable?(item)
end
end #Window_ItemList
#==============================================================================
# Window_ShopNumber
#==============================================================================
class Window_ShopNumber < Window_Selectable
#-----------------------------------------------------------------------------
# overwrite method: draw_itemsize
#-----------------------------------------------------------------------------
def draw_itemsize
actor = SceneManager.scene_is?(Scene_Shop) ? SceneManager.scene.actor : $game_party.leader
item_size = @number * @item.inv_size
total_size = actor.total_inv_size +
(@mode == :buy ? item_size : -item_size)
txt = sprintf("%d/%d",total_size,actor.inv_max)
ypos = item_y + line_height * ($imported["YEA-ShopOptions"] ? 5 : 4)
rect = Rect.new(4,ypos,contents.width-8,line_height)
change_color(system_color)
draw_text(rect,Theo::LimInv::InvSlotVocab)
change_color(normal_color)
draw_text(rect,txt,2)
end
end #Window_ShopNumber
#==============================================================================
# Scene_Item
#==============================================================================
class Scene_Item < Scene_ItemBase
attr_reader :actor
#-----------------------------------------------------------------------------
# overwrite method: on_item_ok
#-----------------------------------------------------------------------------
def on_item_ok
#@actor.last_item.object = item
@use_command.set_item(item)
@use_command.open
@use_command.activate
@use_command.select(0)
end
#-----------------------------------------------------------------------------
# alias method: use_command_ok
#-----------------------------------------------------------------------------
alias timpatch_ai_li_use_command_ok use_command_ok
def use_command_ok
@actor.last_item.object = item
timpatch_ai_li_use_command_ok
end
#-----------------------------------------------------------------------------
# alias method: on_actor_change
#-----------------------------------------------------------------------------
alias timpatch_ai_li_on_actor_change on_actor_change
def on_actor_change
timpatch_ai_li_on_actor_change
@freeslot.refresh
end
end #Scene_Item
#==============================================================================
# Scene_Shop
#==============================================================================
class Scene_Shop < Scene_MenuBase
attr_reader :actor
if $imported["TH_ActorInventoryScenes"]
#-----------------------------------------------------------------------------
# overwrite method: start -> bugfix to Hime's script
#-----------------------------------------------------------------------------
def start
@actor = $game_party.leader
th_actor_inventory_start
end
end
#-----------------------------------------------------------------------------
# overwrite method: do_buy
#-----------------------------------------------------------------------------
def do_buy(number)
$game_party.lose_gold(number * buying_price)
@actor.gain_item(@item, number)
end
end #Scene_Shop
I meant to disable my Single item display addon to check if your items were instantiated.
If your items were instantiated with Hime's script, then selling or discarding them one by one is the expected behavior.
EDIT: There was once again a small bug (if you weren't using Actor Trade Scene then my patch would not fix the shop bug from Hime, I updated the patch above.
If you still encounter your discarding bug and it is not due to to instance items, then could you provide a demo or equivalent for me to test it?
In one way or another I'm no longer having issues for now! Will come back when I inevitably come back to another (unless it, y'know, doesn't.)
Actually, Timtrack is it possible to make certain items or weapons impossible to discard? I ask this because I'm thought of making a weapon a Key Item (it's plot relevant as you may imagine) but I can still discard it, and that would not be good for the game's story... (or the player for that matter)
Actually, Timtrack is it possible to make certain items or weapons impossible to discard? I ask this because I'm thought of making a weapon a Key Item (it's plot relevant as you may imagine) but I can still discard it, and that would not be good for the game's story... (or the player for that matter)
Put this below my patch and put <non_discardable> in the notetags of the items you wish to forbid from being discardable.
If you want something more specific, you should modify
If you have other scripts requests (aside from bugs in the scripts I provided), please create a new topic for this.
If you want something more specific, you should modify
self.discardable?(item) method.If you have other scripts requests (aside from bugs in the scripts I provided), please create a new topic for this.
Ruby:
#==============================================================================
# Limited Inventory addon - Discardability Exception
#------------------------------------------------------------------------------
# Author: Timtrack
# date: 02/06/2025
# Requires: TheoAllen - Limited Inventory
# Supports: Hime's Actor Inventory and my compatibility patch
#==============================================================================
# How to use:
# All items (weapons and armors too) are discardable except key items and
# items with <non_discardable> in their notetags
# You can modify method self.discardable? for more specificities
#==============================================================================
# Installation: put it below TheoAllen's script and my compatibility patch with
# Actor Invenrtory if you use it
#==============================================================================
$imported = {} if $imported.nil?
$imported["TIM_DiscardItemExceptions"] = true
module TIM
module REGEXP
DISCARDABILITY_EXCEPTION = /<non_discardable>/i
end #REGEXP
end #TIM
#============================================================================
# TimPatch
#============================================================================
module TimPatch
#-----------------------------------------------------------------------------
# overwrite method: discardable?
#-----------------------------------------------------------------------------
def self.discardable?(item)
return false if item.nil?
return false if item.is_a?(RPG::Item) && item.key_item?
return item.discardable?
end
end #TimPatch
#============================================================================
# DataManager
#============================================================================
module DataManager
#--------------------------------------------------------------------------
# alias method: load_database
#--------------------------------------------------------------------------
class <<self; alias load_database_discard_exceptions load_database; end
def self.load_database
load_database_discard_exceptions
load_notetags_discard_exceptions
end
#--------------------------------------------------------------------------
# new method: load_notetags_instance_exceptions
#--------------------------------------------------------------------------
def self.load_notetags_discard_exceptions
groups = [$data_items,$data_armors,$data_weapons]
for group in groups
for obj in group
next if obj.nil?
obj.load_notetags_discard_exceptions
end
end
end
end # DataManager
#============================================================================
# RPG::BaseItem
#============================================================================
class RPG::BaseItem
#--------------------------------------------------------------------------
# common cache: load_notetags_discard_exceptions
#--------------------------------------------------------------------------
def load_notetags_discard_exceptions
@discardable = true
#---
self.note.split(/[\r\n]+/).each { |line|
case line
#---
when TIM::REGEXP::DISCARDABILITY_EXCEPTION
@discardable = false
end
#---
} # self.note.split
#---
end
#--------------------------------------------------------------------------
# new method: discardable?
#--------------------------------------------------------------------------
def discardable?
@discardable
end
end # RPG::BaseItem
unless $imported["TIM_ACTOR_LIMIT_INSTANCE_INVENTORY_Patch"]
#==============================================================================
# Window_ItemUseCommand
#==============================================================================
class Window_ItemUseCommand < Window_Command
#-----------------------------------------------------------------------------
# overwrite method: discardable? -> define the method outside of the window obj
#-----------------------------------------------------------------------------
def discardable?(item)
TimPatch.discardable?(item)
end
end #Window_ItemUseCommand
end #$imported["TIM_ACTOR_LIMIT_INSTANCE_INVENTORY_Patch"]
Original thread: https://forums.rpgmakerweb.com/threads/problem-with-limited-inventory.177973/