VXAce Problem with Limited Inventory...

(I'm sorry if I make posts with this frequency, but I keep coming across errors.)

I have a problem with a user related to some scripts that we are both testing.

The Limited Inventory from TheoAllen, and some scripts from Hime.
1748407154932.png

Basically what happens is that, even though the items have a huge size, the game does not count them as additional weight, so it seems that the script is broken.
1748407350803.png

Also as an additional detail, there are no options to use or discard items.

Me and the user did some tests and we discovered that the Actor Inventory Script is responsible for the game not detecting the space in the inventory, after disabling it to corroborate that.

Unfortunately, we have not been able to find out who is responsible for the above mentioned options not being displayed.

As there are already several scripts, I will leave here my scripts.rvdata2, there are all the scripts related to this problem.
Hello!

The Limited Inventory from TheoAllen, and some scripts from Hime.
1748407154932.png
I am not familiar with Hime's scripts, are you saying that all the scripts related to inventory are the ones you've pictured here?

Also as an additional detail, there are no options to use or discard items.
Are you saying that you cannot use an item by pressing the ok button? For discarding, which script can do this? Is it TheoAllen's script?


Your issue is hard to reproduce because you provide the script data but it doesn't work on a blank project: it requires map 18, so I replaced it with map 1 in script "Splash Screen Map" but it's not possible to load the main menu, as there is a bitmap error (missing file).

Can you provide both the scripts (or remove unecessary ones) and the required resources (or change the resources such that it only uses RTP), that way, it would be easier to test and find your issues, otherwise we must parse all script files and it is harder to help you.

I suggest you follow these guidelines when possible (mostly for demo providing part).
Hello!


I am not familiar with Hime's scripts, are you saying that all the scripts related to inventory are the ones you've pictured here?


Are you saying that you cannot use an item by pressing the ok button? For discarding, which script can do this? Is it TheoAllen's script?


Your issue is hard to reproduce because you provide the script data but it doesn't work on a blank project: it requires map 18, so I replaced it with map 1 in script "Splash Screen Map" but it's not possible to load the main menu, as there is a bitmap error (missing file).

Can you provide both the scripts (or remove unecessary ones) and the required resources (or change the resources such that it only uses RTP), that way, it would be easier to test and find your issues, otherwise we must parse all script files and it is harder to help you.

I suggest you follow these guidelines when possible (mostly for demo providing part).
Hello! sorry for the late reply.

You could say yes, since (as far as I remember) they are the only scripts that affect the inventory, but so far Me and the user don't know what other compatibility flaws there might be.

With the options, I mean that they are supposed to appear as shown in this screenshot of the script

In any case, you can try to delete the other unnecessary scripts, as they do not affect the inventory scripts.

If you need the links to the scripts (even if there are about 6), I will try to put the links here.
Okay so without the 3 actor inventory scripts, everything seems to work fine.
Note that the script "Actor Inventory - Instance Items patch" should be put below "Actor Inventory".

My guess is that you need a patch between the actor inventory script and the limited inventory one, maybe someone has one?

Otherwise, I made a small one, it should handle discarding items and the inventory size is displayed correctly, note that I did not test it under battle or with a full inventory. What would be the behavior if one of your actor inventory is full?
Also, TheoAllen's script has some slowing down feature when inventory is full, I'm pretty sure this patch won't provide it, do you want it to happen, if so, under which conditions?

Ruby:
#==============================================================================
# Actor Inventory and Limited Inventory compatibility pacth
#------------------------------------------------------------------------------
# Author: Timtrack
# date: 28/05/2025
# Requires: TheoAllen - Limited Inventory && Hime's Actor Inventory Scenes
#==============================================================================
# Note: tested with the following script order:
# Limited Inventory
# Instance Items
# Core - Inventory
# Core - Inventory - Instance Items patch
# Limited Inventory - Instance Items patch
# Actor Inventory
# Actor Inventory - Instance Items
# Actor Inventory Scenes
# This patch
#==============================================================================
# This patch handles discarding actor inventory's items and having their inventory size displayed
#==============================================================================

#==============================================================================
# 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 $game_party.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

#==============================================================================
# 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)
    actor = SceneManager.scene.actor #added
    #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
end #Window_Base

#==============================================================================
# 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
end #Scene_Item

#==============================================================================
# Game_Actor -> all new methods that 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 = inventory_items.inject(0) {|total,item| total + (item_number(item) * item.inv_size)}
    result += equip_size
    result
  end
 
  alias theo_liminv_max_item max_item_number
  def max_item_number(item)
    $BTEST ? theo_liminv_max_item(item) : inv_max_item(item) + item_number(item)
  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_maxed?
  end
 
  def near_maxed?
    free_slot.to_f / inv_max <= Theo::LimInv::NearMaxed_Percent/100.0
  end
end #Game_Actor

Please tell me if you find any issue or want any specific feature.
Okay so without the 3 actor inventory scripts, everything seems to work fine.
Note that the script "Actor Inventory - Instance Items patch" should be put below "Actor Inventory".

My guess is that you need a patch between the actor inventory script and the limited inventory one, maybe someone has one?

Otherwise, I made a small one, it should handle discarding items and the inventory size is displayed correctly, note that I did not test it under battle or with a full inventory. What would be the behavior if one of your actor inventory is full?
Also, TheoAllen's script has some slowing down feature when inventory is full, I'm pretty sure this patch won't provide it, do you want it to happen, if so, under which conditions?

Ruby:
#==============================================================================
# Actor Inventory and Limited Inventory compatibility pacth
#------------------------------------------------------------------------------
# Author: Timtrack
# date: 28/05/2025
# Requires: TheoAllen - Limited Inventory && Hime's Actor Inventory Scenes
#==============================================================================
# Note: tested with the following script order:
# Limited Inventory
# Instance Items
# Core - Inventory
# Core - Inventory - Instance Items patch
# Limited Inventory - Instance Items patch
# Actor Inventory
# Actor Inventory - Instance Items
# Actor Inventory Scenes
# This patch
#==============================================================================
# This patch handles discarding actor inventory's items and having their inventory size displayed
#==============================================================================

#==============================================================================
# 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 $game_party.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

#==============================================================================
# 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)
    actor = SceneManager.scene.actor #added
    #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
end #Window_Base

#==============================================================================
# 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
end #Scene_Item

#==============================================================================
# Game_Actor -> all new methods that 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 = inventory_items.inject(0) {|total,item| total + (item_number(item) * item.inv_size)}
    result += equip_size
    result
  end
 
  alias theo_liminv_max_item max_item_number
  def max_item_number(item)
    $BTEST ? theo_liminv_max_item(item) : inv_max_item(item) + item_number(item)
  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_maxed?
  end
 
  def near_maxed?
    free_slot.to_f / inv_max <= Theo::LimInv::NearMaxed_Percent/100.0
  end
end #Game_Actor

Please tell me if you find any issue or want any specific feature.
Sorry if I didn't respond, I was in class.

Trying it, now although the counter in the inventory works, and the options work correctly, I have found some problems.

-The first and the least serious and I believe that even this is optional, is that the counter window of the main menu, is not updated, unlike the inventory window.

This is the least of it for me, I can just remove that window that I feel is filler, and that's it.

-The other and the main one, is that, even if the inventory counter increases with each item obtained, the problem comes in that even being in the limit or exceeding, there is no effect.

The counter keeps going up even if you have exceeded the space limit, even if you have the option activated to prevent it from going up when the limit is reached.

Even if I have that option deactivated so that it continues to increase, the penalties for this as the decrease of speed and the one of no longer being able to use the dash do not work.

In the battles as you mention, there is no change at all, the items go to the inventory with or without full inventory.
Okay, I have a few questions for you to see how I should patch the rest:
- Is your game with only one actor at a time or multiple in the same party? If multiple then it will be more complicated to handle the rest but it is doable.
- By default the counter in the menu is the party inventory counter, since the party inventory does not exist with the actor inventory script, what do you want to be displayed? The leader counter or the sum of all party members counter?
- If you try to add an item to the party leader's inventory but it is full, do you want the item to follow Theo Allen's original script? (I don't know the behavior of the script but I can just apply it) Or some special interaction with the other members inventories? (Like actor 1 is full but 2 is available so let's give it to 2 instead?)
- Same problem for dash or move speed: if one party member is almost full, does it slow the player even if all others are not full?

I will investigate the battle part regardless.
Okay, I have a few questions for you to see how I should patch the rest:
- Is your game with only one actor at a time or multiple in the same party? If multiple then it will be more complicated to handle the rest but it is doable.
- By default the counter in the menu is the party inventory counter, since the party inventory does not exist with the actor inventory script, what do you want to be displayed? The leader counter or the sum of all party members counter?
- If you try to add an item to the party leader's inventory but it is full, do you want the item to follow Theo Allen's original script? (I don't know the behavior of the script but I can just apply it) Or some special interaction with the other members inventories? (Like actor 1 is full but 2 is available so let's give it to 2 instead?)
- Same problem for dash or move speed: if one party member is almost full, does it slow the player even if all others are not full?

I will investigate the battle part regardless.
- My project as such is of multiple actors/protagonists, who join together as the story goes on.

-I think the sum of the whole group would be the most ideal, if only the leader's is shown it could be a bit weird, I don't know, but ok.

-I would love that special function you mention of giving it to the other member of the group that follows him, I feel it would be great.

-I would honestly love for the delay to affect the whole group, that is, if an actor has his inventory full, the team would be delayed as well.
Here is a second version of the patch, it should handle the max item part.
Note that shops will be limited by the party leader's inventory.
Please tell me if there is anything else you need or any bug.

I think the sum of the whole group would be the most ideal
Okay, I display that then.

I would love that special function you mention of giving it to the other member of the group that follows him
If you set option DISTRIUTE_EXTRA_ITEMS to true in my patch, then items that are too heavy for the leader will be distributed among other members. (note that in battle, members will only be the battling actors)
If the option is false, extra items will not be added.

I would honestly love for the delay to affect the whole group
Done, if you set option INVENTORY_SLOWED_ANY to true in my patch, then as long as one inventory is full, the party will be slowed down. Else, the party inventory (which is the sum of the member's inventories) is used to say if the party is slowed down.

Also note that you should disable ForceGain in TheoAllen's script if you want extra items to be discarded, otherwise the inventory will outweight the available size.

Ruby:
#==============================================================================
# Actor Inventory and Limited Inventory compatibility patch
#------------------------------------------------------------------------------
# Author: Timtrack
# date: 29/05/2025
# Requires: TheoAllen - Limited Inventory, Hime's Instance Items and Hime's Actor Inventory
#==============================================================================
# Note: tested with the following script order:
# Limited Inventory
# Instance Items
# Core - Inventory
# Core - Inventory - Instance Items patch
# (Limited Inventory - Instance Items patch) this patch can be discarded because both my patch and actor inventory script overwrite gain_itenm and force_gain_item in Game_Party
# Actor Inventory
# Actor Inventory - Instance Items
# Actor Inventory Scenes
# This patch
#==============================================================================
# This patch handles discarding actor inventory's items
#==============================================================================

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)
  DISTRIUTE_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
 
  #-----------------------------------------------------------------------------
  # 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::DISTRIUTE_EXTRA_ITEMS
    else
      timpatch_liminv_add_instance_item(item)
    end
  end
 
  if TimPatch::DISTRIUTE_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::DISTRIUTE_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_maxed?
  end
 
  def near_maxed?
    free_slot.to_f / inv_max <= Theo::LimInv::NearMaxed_Percent/100.0
  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
 
  #-----------------------------------------------------------------------------
  # new method: add_instance_item
  #-----------------------------------------------------------------------------
  def add_instance_item(item)
    @inventory.add_instance_item(item)
  end
 
  #-----------------------------------------------------------------------------
  # 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
  #-----------------------------------------------------------------------------
  def force_gain_item(*args)
    leader.force_gain_item(*args)
  end
 
  #-----------------------------------------------------------------------------
  # new method: distribute_extra_items -> called when an invenotry is full and
  # others are not, only if DISTRIUTE_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
 
  #-----------------------------------------------------------------------------
  # new method: distribute_instance_item -> called when an invenotry is full and
  # others are not, only if DISTRIUTE_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 #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_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 $game_party.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

#==============================================================================
# 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
end #Window_Base

#==============================================================================
# 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
end #Scene_Item

#==============================================================================
# Scene_Shop
#==============================================================================
class Scene_Shop < Scene_MenuBase
  attr_reader :actor
end #Scene_Item
Here is a second version of the patch, it should handle the max item part.
Note that shops will be limited by the party leader's inventory.
Please tell me if there is anything else you need or any bug.


Okay, I display that then.


If you set option DISTRIUTE_EXTRA_ITEMS to true in my patch, then items that are too heavy for the leader will be distributed among other members. (note that in battle, members will only be the battling actors)
If the option is false, extra items will not be added.


Done, if you set option INVENTORY_SLOWED_ANY to true in my patch, then as long as one inventory is full, the party will be slowed down. Else, the party inventory (which is the sum of the member's inventories) is used to say if the party is slowed down.

Also note that you should disable ForceGain in TheoAllen's script if you want extra items to be discarded, otherwise the inventory will outweight the available size.

Ruby:
#==============================================================================
# Actor Inventory and Limited Inventory compatibility patch
#------------------------------------------------------------------------------
# Author: Timtrack
# date: 29/05/2025
# Requires: TheoAllen - Limited Inventory, Hime's Instance Items and Hime's Actor Inventory
#==============================================================================
# Note: tested with the following script order:
# Limited Inventory
# Instance Items
# Core - Inventory
# Core - Inventory - Instance Items patch
# (Limited Inventory - Instance Items patch) this patch can be discarded because both my patch and actor inventory script overwrite gain_itenm and force_gain_item in Game_Party
# Actor Inventory
# Actor Inventory - Instance Items
# Actor Inventory Scenes
# This patch
#==============================================================================
# This patch handles discarding actor inventory's items
#==============================================================================

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)
  DISTRIUTE_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
 
  #-----------------------------------------------------------------------------
  # 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::DISTRIUTE_EXTRA_ITEMS
    else
      timpatch_liminv_add_instance_item(item)
    end
  end
 
  if TimPatch::DISTRIUTE_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::DISTRIUTE_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_maxed?
  end
 
  def near_maxed?
    free_slot.to_f / inv_max <= Theo::LimInv::NearMaxed_Percent/100.0
  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
 
  #-----------------------------------------------------------------------------
  # new method: add_instance_item
  #-----------------------------------------------------------------------------
  def add_instance_item(item)
    @inventory.add_instance_item(item)
  end
 
  #-----------------------------------------------------------------------------
  # 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
  #-----------------------------------------------------------------------------
  def force_gain_item(*args)
    leader.force_gain_item(*args)
  end
 
  #-----------------------------------------------------------------------------
  # new method: distribute_extra_items -> called when an invenotry is full and
  # others are not, only if DISTRIUTE_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
 
  #-----------------------------------------------------------------------------
  # new method: distribute_instance_item -> called when an invenotry is full and
  # others are not, only if DISTRIUTE_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 #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_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 $game_party.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

#==============================================================================
# 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
end #Window_Base

#==============================================================================
# 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
end #Scene_Item

#==============================================================================
# Scene_Shop
#==============================================================================
class Scene_Shop < Scene_MenuBase
  attr_reader :actor
end #Scene_Item
Ok, finally testing it, the script is pretty close to finally be very functional🙂, just need to fix and cover some details so there are no more complications.

------------------------------------------------
I will start with the stores, and is that the other user that I mentioned at the beginning found some problems.

If in the instance item script the Enable_Items option is activated, at the moment of selling, the items will be sold one by one, which the user finds uncomfortable.

Another detail of the stores is that, the counter mixes the space of the members in the menu, in the stores the same thing happens, the bad thing of this is that it causes that the leader character can continue buying, and the items go to the other members, although you can only buy one item at a time, which is something annoying (What I would recommend here would be that only the leader buys items for him, and that only his inventory space is shown, so that the player alternates of character).

And the last thing, and this only happens to the other user, is that the inventory of items counts the key items as part of all members.
This is because the user uses a script that changes the item menu (I just found this out).

I clarify that this only happens to the user, I do not have any problem with that bcs I use the base scene.
1748557271824.png

(user screenshot)
------------------------------------------------
And the last thing that would be an addition, is that in battles after obtaining items, if it is detected that the leader has a full inventory, a dialog will appear indicating that he can not carry more items and asks him to discard one or to abandon the item obtained.

Something like this would be intuitive to tell the truth.

This happens with the chests, where if you have the item limit and forcegain disabled, the item is not earned and disappears, with the chest remaining open, but I think it could be fixed by configuring the event or with some script call, but well.

That's all I've been able to notice.
For now, I want to thank you a lot for your help with this.😍
You're welcome ~

If in the instance item script the Enable_Items option is activated, at the moment of selling, the items will be sold one by one, which the user finds uncomfortable.
This is a feature from the original instance item script. If the user wants to sell multiple items a time, then I would question why would they use instance items for them? I could try to change this buuut, if you modify these items one by one with other scripts (some could add features, others could change the price I guess), then how could the script choose the correct items to sell?
I personally don't think this is a good idea to sell multiple instance items at a time. I would suggest, if it is only for display purpose to show items one by one, to use another script to split the display instead of instance items whose purpose is more to modify the instance items afterwards.

Another detail of the stores is that, the counter mixes the space of the members in the menu, in the stores the same thing happens, the bad thing of this is that it causes that the leader character can continue buying, and the items go to the other members, although you can only buy one item at a time, which is something annoying (What I would recommend here would be that only the leader buys items for him, and that only his inventory space is shown, so that the player alternates of character).
Okay, I will change this to only handle the leader's inventory when buying or selling stuff.

And the last thing, and this only happens to the other user, is that the inventory of items counts the key items as part of all members.
This is because the user uses a script that changes the item menu (I just found this out).
I will need a link to the original script for this. I can only help if I know what is the script and where it comes from :')



The ask for discard part would be more complicated as it requires a new scene for this and more details, I am unsure I will be able to provide it and it would be more of an addon than a patch. At the very least, I will ask you for more informations.

First of all, if the extra items are distributed among other members, do you prefer:
- to first ask the leader to discard, then put the rest on the other members
- put the rest on the other members then, if no space is available for other items, to ask to discard parts? If so, only ask the leader to discard or have access to the full party here?

Regardless of the distributed part, if you get 3 potions, should I ask you to discard items for 1 potion, then the next one and so on? Or would it be only one question and then I add the items I can and don't add the rest?

And the last thing that would be an addition, is that in battles after obtaining items, if it is detected that the leader has a full inventory, a dialog will appear indicating that he can not carry more items and asks him to discard one or to abandon the item obtained.
Same here, do we ask for each item to discard your inventory? This could take a long time for the player.

This happens with the chests, where if you have the item limit and forcegain disabled, the item is not earned and disappears, with the chest remaining open, but I think it could be fixed by configuring the event or with some script call, but well.
Maybe this script to have chest inventories by TheoAllen could be useful? (I don't know how it works and I am fairly sure it won't be compatible with Hime's scripts but it could be patched probably?)



Design-wise, maybe it is better to use the force items part whenever you don't want to lose the item. And for other cases, use event script calls (which are definitely available) to check if there is enough space and then add the item only if the space is available and maybe say "You don't have enough space" otherwise.

I could also add a small popup window when trying to add an item while inventory is full (at end of battle or when opening chests) and saying "Inventory is full, item BLA is lost" or something like this? It is at the very least easier on my part.
You're welcome ~


This is a feature from the original instance item script. If the user wants to sell multiple items a time, then I would question why would they use instance items for them? I could try to change this buuut, if you modify these items one by one with other scripts (some could add features, others could change the price I guess), then how could the script choose the correct items to sell?
I personally don't think this is a good idea to sell multiple instance items at a time. I would suggest, if it is only for display purpose to show items one by one, to use another script to split the display instead of instance items whose purpose is more to modify the instance items afterwards.


Okay, I will change this to only handle the leader's inventory when buying or selling stuff.


I will need a link to the original script for this. I can only help if I know what is the script and where it comes from :')



The ask for discard part would be more complicated as it requires a new scene for this and more details, I am unsure I will be able to provide it and it would be more of an addon than a patch. At the very least, I will ask you for more informations.

First of all, if the extra items are distributed among other members, do you prefer:
- to first ask the leader to discard, then put the rest on the other members
- put the rest on the other members then, if no space is available for other items, to ask to discard parts? If so, only ask the leader to discard or have access to the full party here?

Regardless of the distributed part, if you get 3 potions, should I ask you to discard items for 1 potion, then the next one and so on? Or would it be only one question and then I add the items I can and don't add the rest?


Same here, do we ask for each item to discard your inventory? This could take a long time for the player.


Maybe this script to have chest inventories by TheoAllen could be useful? (I don't know how it works and I am fairly sure it won't be compatible with Hime's scripts but it could be patched probably?)



Design-wise, maybe it is better to use the force items part whenever you don't want to lose the item. And for other cases, use event script calls (which are definitely available) to check if there is enough space and then add the item only if the space is available and maybe say "You don't have enough space" otherwise.

I could also add a small popup window when trying to add an item while inventory is full (at end of battle or when opening chests) and saying "Inventory is full, item BLA is lost" or something like this? It is at the very least easier on my part.
- Personally I think the same, I think it would be more practical for the user to use the items in a normal way instead of having each one separately, I think that would alleviate this.
(I just discussed it with the user, he told me that he didn't intend to edit the instance items script, so that would be something he shouldn't worry about, so well, I guess that's out of the details, Although this is only to be able to sell copies of items (e.g. potions) more conveniently.)

- This is the script (The user version, on line 133, has only :item and :key_item.)

-------------------------------------------------------------------------------------
- Seeing that it requires a new scene, I think the most practical would be the second, because well, I think that would be more intuitive, and in that case, allow access to the entire group, although I do not know if you can make the window of each inventory is separate (I mean that in the scene, you are taken first to the inventory of the leader, and by moving more to the left or right, the inventory is changed to the inventory of another actor), I do not know how complicated that could be, but well, it's up to you how to do it.

Personally I think that just one question would be enough, I feel that if it were for each object it would be annoying.

- I didn't know that script you mention until now, I'll take a look to see how it is.

Yes, I think that would be fine, although there is the option to ask if you want to discard or abandon the item obtained in battle as it happens in Earthbound, but well, I don't know how complex this is.
perhaps it work work to write an addon script to the instance items so that with a note tag you can block if an item will be created as an instance item or not. then such things as potions would act like the default and not generate a new item every time.
And the last thing, and this only happens to the other user, is that the inventory of items counts the key items as part of all members.
This is because the user uses a script that changes the item menu (I just found this out).
I tried the script and I did not find any issue for key items display or weight in the menu, battle or shop. I just took the script and put it above the limited inventory script. I also tried to leave only categories :item and :key_item, no issue on my side.

I think it would be more practical for the user to use the items in a normal way instead of having each one separately, I think that would alleviate this.
In the instance item script, you can set line 204 Enable_Items to false to disable instances for items (you have a similar option for weapons and armors). Unless you want specific items to be instanciable and others non-instanciable, this could be useful. Otherwise me or another user can provide an addon like @Roninator2 suggests to disable instance for some items in their notetags.

(What I would recommend here would be that only the leader buys items for him, and that only his inventory space is shown, so that the player alternates of character)
I fixed this in this new version of the patch (I also removed the dependency to Hime's instance items even if it is still supported)

Spoiler: Code
Ruby:
#==============================================================================
# Actor Inventory, Limited Inventory and Instance Items compatibility patch
#------------------------------------------------------------------------------
# Author: Timtrack
# date: 30/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
#==============================================================================

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
 
  #-----------------------------------------------------------------------------
  # 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
  #-----------------------------------------------------------------------------
  def force_gain_item(*args)
    leader.force_gain_item(*args)
  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_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 $game_party.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

#==============================================================================
# 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
end #Window_Base

#==============================================================================
# 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
end #Scene_Item

#==============================================================================
# Scene_Shop
#==============================================================================
class Scene_Shop < Scene_MenuBase
  attr_reader :actor
end #Scene_Shop

- Seeing that it requires a new scene, I think the most practical would be the second, because well, I think that would be more intuitive, and in that case, allow access to the entire group, although I do not know if you can make the window of each inventory is separate (I mean that in the scene, you are taken first to the inventory of the leader, and by moving more to the left or right, the inventory is changed to the inventory of another actor), I do not know how complicated that could be, but well, it's up to you how to do it.

Personally I think that just one question would be enough, I feel that if it were for each object it would be annoying.

- I didn't know that script you mention until now, I'll take a look to see how it is.

Yes, I think that would be fine, although there is the option to ask if you want to discard or abandon the item obtained in battle as it happens in Earthbound, but well, I don't know how complex this is.

Well I don't know how Earthbound item system works. My reference is more like Fire Emblem when it comes to ask to replace items with a new one, but in this system, all items weight the same, so discarding one item is enough to add another one.

Sadly, I cannot guarantee that I will provide this ask to make space addon, I would be happier if someone else could take care of it.
I tried the script and I did not find any issue for key items display or weight in the menu, battle or shop. I just took the script and put it above the limited inventory script. I also tried to leave only categories :item and :key_item, no issue on my side.


In the instance item script, you can set line 204 Enable_Items to false to disable instances for items (you have a similar option for weapons and armors). Unless you want specific items to be instanciable and others non-instanciable, this could be useful. Otherwise me or another user can provide an addon like @Roninator2 suggests to disable instance for some items in their notetags.


I fixed this in this new version of the patch (I also removed the dependency to Hime's instance items even if it is still supported)

Spoiler: Code
Ruby:
#==============================================================================
# Actor Inventory, Limited Inventory and Instance Items compatibility patch
#------------------------------------------------------------------------------
# Author: Timtrack
# date: 30/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
#==============================================================================
# This patch handles discarding actor inventory's items
#==============================================================================

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:ISTRIBUTE_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:ISTRIBUTE_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:ISTRIBUTE_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
 
  #-----------------------------------------------------------------------------
  # 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
  #-----------------------------------------------------------------------------
  def force_gain_item(*args)
    leader.force_gain_item(*args)
  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_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 $game_party.item_number([USER=16865]@ItEm[/USER]) == 0
      Sound.play_ok
      @itemlist.activate.refresh
      @itemlist.update_help
      @cmn_window.close.deactivate
      close
    else
      close_window
    end
  end
end #Window_DiscardAmount

#==============================================================================
# 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
end #Window_Base

#==============================================================================
# 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 = [USER=39170]@Number[/USER] * @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
end #Scene_Item

#==============================================================================
# Scene_Shop
#==============================================================================
class Scene_Shop < Scene_MenuBase
  attr_reader :actor
end #Scene_Shop



Well I don't know how Earthbound item system works. My reference is more like Fire Emblem when it comes to ask to replace items with a new one, but in this system, all items weight the same, so discarding one item is enough to add another one.

Sadly, I cannot guarantee that I will provide this ask to make space addon, I would be happier if someone else could take care of it.
I understand, I have no complaints with that system anyway, so it's fine.

Anyway, thank you very much for helping with this patch, I really appreciate your help, thank you very much!

1748636264760.png

Uh, ok, I was about to send the message, but testing the script I get an error as soon as it starts.
Sorry, it seems there were some characters errors when I pasted the script here. I updated the previous post with the correct syntax.
Sorry, it seems there were some characters errors when I pasted the script here. I updated the previous post with the correct syntax.
Don't worry, it works fine now.
I tried the script and I did not find any issue for key items display or weight in the menu, battle or shop. I just took the script and put it above the limited inventory script. I also tried to leave only categories :item and :key_item, no issue on my side.
Heya, I'm the other user OmegaSC mentions here, just to clarify: what I meant is that the counts key items as part of the inventory as seen in this picture (which I don't want):
1748641666717.png

As you can see, I have no items, yet the game counts the one key item I have (it's on the key item section obviously).
1748642608519.png

Alongside that, Key Items are also individual, other characters don't share that Key Item! I have. What I want is something like Mother 3 where Key Items are separate from character's inventories in general.
1748642379914.png

Also a minor glitch I found, if I use Page Up and Page Down to scroll down/up my character's inventory, the Inventory number is not updated.
1748642304696.png
Also a minor glitch I found, if I use Page Up and Page Down to scroll down/up my character's inventory, the Inventory number is not updated.

I updated the script, it should fix this bug.

Spoiler: Code
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
 
  #-----------------------------------------------------------------------------
  # 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
  #-----------------------------------------------------------------------------
  def force_gain_item(*args)
    leader.force_gain_item(*args)
  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_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 $game_party.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

#==============================================================================
# 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
end #Window_Base

#==============================================================================
# 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
end #Scene_Shop


perhaps it work work to write an addon script to the instance items so that with a note tag you can block if an item will be created as an instance item or not. then such things as potions would act like the default and not generate a new item every time.
Here is an addon I coded, it allows you to set some items/weapons/armors as non-instanciable if you put in their notetags:
<no_instance>
You can put this script below my patch.
It seems to work fine with some items instanciable and others non-instanciable, I haven't tested it with equipments, especially if you try to remove them by event calls from actors.

Note that if you don't use any instance items (but let's say weapons and armors), you should disable Enable_Items in Hime's instance items script, it would be much cleaner.
Also, if you use instance items only for display purpose (ie no other scripts is used to change them), then I strongly suggest you use another script to simply change the item/weapons/armors display.

Ruby:
#==============================================================================
# Hime's Instance Items addon - exceptions
#------------------------------------------------------------------------------
# Author: Timtrack
# date: 31/05/2025
# Requires: Hime's Instance Items
# Should be compatible with Hime's Core - Inventory, Actor Inventory and
# TheoAllen's Limited Inventory
#==============================================================================
# Installation: put this below all the cited scripts, if you use my patch
# for them, put this script below the patch.
#==============================================================================

$imported = {} if $imported.nil?
$imported["TIM_InstanceItemsExceptions"] = true

module TIM
  module REGEXP
    INSTANCE_EXCEPTION = /<no_instance>/i
  end #REGEXP
end #TIM

#============================================================================
# InstanceManager
#============================================================================
module InstanceManager
  #--------------------------------------------------------------------------
  # alias method: instance_enabled?
  #--------------------------------------------------------------------------
  class <<self; alias exception_instance_enabled? instance_enabled?; end
  def self.instance_enabled?(obj)
    exception_instance_enabled?(obj) && obj.instanciable?
  end
end #InstanceManager


#============================================================================
# DataManager
#============================================================================
module DataManager
  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  class <<self; alias load_database_instance_exceptions load_database; end
  def self.load_database
    load_database_instance_exceptions
    load_notetags_instance_exceptions
  end

  #--------------------------------------------------------------------------
  # new method: load_notetags_instance_exceptions
  #--------------------------------------------------------------------------
  def self.load_notetags_instance_exceptions
    groups = [$data_items,$data_armors,$data_weapons]
    for group in groups
      for obj in group
        next if obj.nil?
        obj.load_notetags_instance_exceptions
      end
    end
  end
end # DataManager

#============================================================================
# RPG::BaseItem
#============================================================================
class RPG::BaseItem
  #--------------------------------------------------------------------------
  # common cache: load_notetags_height
  #--------------------------------------------------------------------------
  def load_notetags_instance_exceptions
    @instanciable = true
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when TIM::REGEXP::INSTANCE_EXCEPTION
        @instanciable = false
      end
      #---
    } # self.note.split
    #---
  end
 
  #--------------------------------------------------------------------------
  # new method: instanciable?
  #--------------------------------------------------------------------------
  def instanciable?
    @instanciable
  end
end # RPG::BaseItem

if $imported[:TH_CoreInventory_InstanceItemPatch]
  #============================================================================
  # Game_Inventory
  #============================================================================
  class Game_Inventory
    #-----------------------------------------------------------------------------
    # alias method: weapons -> concatenate instance and non-instances
    #-----------------------------------------------------------------------------
    alias tim_iex_weapons weapons
    def weapons
      TH::Instance_Items::Enable_Weapons ? @weapon_list + th_instance_items_weapons.select{|w| !instance_enabled?(w)} : tim_iex_weapons
    end
    
    #-----------------------------------------------------------------------------
    # alias method: items -> concatenate instance and non-instances
    #-----------------------------------------------------------------------------
    alias tim_iex_items items
    def items
      TH::Instance_Items::Enable_Items ? @item_list + th_instance_items_items.select{|i| !instance_enabled?(i)} : tim_iex_items
    end

    #-----------------------------------------------------------------------------
    # alias method: armors -> concatenate instance and non-instances
    #-----------------------------------------------------------------------------
    alias tim_iex_armors armors
    def armors
      TH::Instance_Items::Enable_Armors ? @armor_list + th_instance_items_armors.select{|a| !instance_enabled?(a)} : tim_iex_armors
    end
  end #Game_Inventory
else #!$imported[:TH_CoreInventory_InstanceItemPatch]
  #============================================================================
  # Game_Party
  #============================================================================
  class Game_Party < Game_Unit
    #-----------------------------------------------------------------------------
    # alias method: weapons -> concatenate instance and non-instances
    #-----------------------------------------------------------------------------
    alias tim_iex_weapons weapons
    def weapons
      TH::Instance_Items::Enable_Weapons ? @weapon_list + th_instance_items_weapons.select{|w| !instance_enabled?(w)} : tim_iex_weapons
    end
    
    #-----------------------------------------------------------------------------
    # alias method: items -> concatenate instance and non-instances
    #-----------------------------------------------------------------------------
    alias tim_iex_items items
    def items
      TH::Instance_Items::Enable_Items ? @item_list + th_instance_items_items.select{|i| !instance_enabled?(i)} : tim_iex_items
    end

    #-----------------------------------------------------------------------------
    # alias method: armors -> concatenate instance and non-instances
    #-----------------------------------------------------------------------------
    alias tim_iex_armors armors
    def armors
      TH::Instance_Items::Enable_Armors ? @armor_list + th_instance_items_armors.select{|a| !instance_enabled?(a)} : tim_iex_armors
    end
  end
end #$imported[:TH_CoreInventory_InstanceItemPatch]


As you can see, I have no items, yet the game counts the one key item I have (it's on the key item section obviously).
Since key items are items, this behaviour is expected, you can use the addon I provide to merge them in a single item. For their weight, you can put
<inv size: 0>
In the item's notetag if you don't want them to weight anything.
What I want is something like Mother 3 where Key Items are separate from character's inventories in general.
That would be more complicated, you would need another inventory (maybe the party inventory?) to store the items. Then it would mean that when items are fetched, we would take both the actor's and the party's inventories, same when trying to remove the item. It is not impossible but there are many possible bugs. I don't think that I will provide such script, if anyone wants to try this please do.
Ight, now everything is fixed (for now)
ack said:
Note that if you don't use any instance items (but let's say weapons and armors), you should disable Enable_Items in Hime's instance items script, it would be much cleaner.
Also, if you use instance items only for display purpose (ie no other scripts is used to change them), then I strongly suggest you use another script to simply change the item/weapons/armors display.
I don't wanna disable instances for items since it would be against the whole point of the system I want (Dragon Quest/Earthbound-like inventories)
I might start being a little redundant now, but just in case I was unclear what I want is that if I have for example 5 potions, 3 antidotes and 1 ether I am able to sell all the 5 potions quickly without affecting every other item, (since they're all instanced) this is only to make it more coherent with the player being able to buy more than one item at once.
That would be more complicated, you would need another inventory (maybe the party inventory?) to store the items. Then it would mean that when items are fetched, we would take both the actor's and the party's inventories, same when trying to remove the item. It is not impossible but there are many possible bugs. I don't think that I will provide such script, if anyone wants to try this please do.
Isn't it possible (and perhaps easier) to just make an inventory made specifically for storing Key Items? For that matter, Key Items are not intended to be removable (especially since they're not meant to take up inventory space).
I don't wanna disable instances for items since it would be against the whole point of the system I want (Dragon Quest/Earthbound-like inventories)
Forgive me for not understanding, but Dragon Quest I (or Dragon Warrior) has medical herbs as an item not an instance item. with a limit to how much you can carry. If this mechanic has changed in different versions of dragon quest then that may be true.

Original thread: https://forums.rpgmakerweb.com/threads/problem-with-limited-inventory.177973/