RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[XP] Inventory limit + non-stacked items.

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 68
RMRK Junior
Hello!

I'm working with RPG Maker XP and I have two requests:

Normally XP updates quantities of an item you already have. Rather I want identical items to take up their own space instead of stacking.

Inventory Example:
Iron Sword     Iron Sword
Potion           Potion
Potion

I'd also like an inventory cap with a switch or something to trigger an event when you reach your cap.

Cap Example:
You can only care 14 items. When you attempt to add an item a switch triggers instead.

The only compatibility issue I see is this multi-inventory script.
Spoiler for:
#==============================================================================
# ** Night_Runner's Multiple inventories Script
#------------------------------------------------------------------------------
# Designed for RPG Maker XP
# Date created: 15/Nov/09
# Version: 1.0
# Designed for: keyonne
#           @> http://www.rpgrevolution.com/forums/index.php?showtopic=30908
#
# DESCRIPTION:
#  Below is a line, INVENTORY_VARIABLE = 1, this means that when the
#   in-game variable is equal to 0, the game has a inventory associated with
#   0 . Similarly, if it equal to 1, it has a new inventory, which has its own
#   items/weapons/armors, completely seperate to when the in-game variable is
#   set to 0
#  Please note: If your variable is a negative, it will take the positive
#   version of the inventory, so if you set the value to inventory -5
#   (through the in game variable), it will look at inventory +5
#    (from the in game variable).
#==============================================================================

INVENTORY_VARIABLE = 41



#==============================================================================
#  Please note, editing beyond here may result in learning
#                   You have been warned.
#==============================================================================

class Game_System
  attr_accessor :max_items
  alias add_max_items initialize
  def initialize
    #===========================================================================
    # BEGIN CONFIG
    @max_items = 14 # Change this to the max items you want the party to carry
    # END CONFIG
    #===========================================================================
    add_max_items
  end
end

#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  Mass butchering happens below
#==============================================================================

class Game_Party
  alias minventories_initialize initialize
  def initialize
    minventories_initialize
    # Create amount in possession hash for items, weapons, and armor
    @items = []
    @weapons = []
    @armors = []
    nr_initialize_inventory
  end
  #--------------------------------------------------------------------------
  # * Battle Test Party Setup
  #--------------------------------------------------------------------------
  def setup_battle_test_members
    # Initialize invenotry is newly created
    nr_initialize_inventory
    @actors = []
    for battler in $data_system.test_battlers
      actor = $game_actors[battler.actor_id]
      actor.level = battler.level
      gain_weapon(battler.weapon_id, 1)
      gain_armor(battler.armor1_id, 1)
      gain_armor(battler.armor2_id, 1)
      gain_armor(battler.armor3_id, 1)
      gain_armor(battler.armor4_id, 1)
      actor.equip(0, battler.weapon_id)
      actor.equip(1, battler.armor1_id)
      actor.equip(2, battler.armor2_id)
      actor.equip(3, battler.armor3_id)
      actor.equip(4, battler.armor4_id)
      actor.recover_all
      @actors.push(actor)
    end
    @items[@game_variable] = {}
    for i in 1...$data_items.size
      if $data_items.name != ""
        occasion = $data_items.occasion
        if occasion == 0 or occasion == 1
          @items[@game_variable] = 99
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Get Number of Items Possessed
  #     item_id : item ID
  #--------------------------------------------------------------------------
  def item_number(item_id)
    # Initialize invenotry is newly created
    nr_initialize_inventory
    # If quantity data is in the hash, use it. If not, return 0
    a = @items[@game_variable]
    return a.include?(item_id) ? a[item_id] : 0
  end
  #--------------------------------------------------------------------------
  # * Get Number of Weapons Possessed
  #     weapon_id : weapon ID
  #--------------------------------------------------------------------------
  def weapon_number(weapon_id)
    # Initialize invenotry is newly created
    nr_initialize_inventory
    # If quantity data is in the hash, use it. If not, return 0
    a = @weapons[@game_variable]
    return a.include?(weapon_id) ? a[weapon_id] : 0
  end
  #--------------------------------------------------------------------------
  # * Get Amount of Armor Possessed
  #     armor_id : armor ID
  #--------------------------------------------------------------------------
  def armor_number(armor_id)
    # Initialize invenotry is newly created
    nr_initialize_inventory
    # If quantity data is in the hash, use it. If not, return 0
    a = @armors[@game_variable]
    return a.include?(armor_id) ? a[armor_id] : 0
  end
  #--------------------------------------------------------------------------
  # * Gain Items (or lose)
  #     item_id : item ID
  #     n       : quantity
  #--------------------------------------------------------------------------
  def gain_item(item_id, n)
    # Initialize invenotry is newly created
    nr_initialize_inventory
    # Update quantity data in the hash.
    if item_id > 0
      item = [[item_number(item_id) + n, 0].max, 1].min
      @items[@game_variable][item_id] = item
    end
  end
  #--------------------------------------------------------------------------
  # * Gain Weapons (or lose)
  #     weapon_id : weapon ID
  #     n         : quantity
  #--------------------------------------------------------------------------
  def gain_weapon(weapon_id, n)
    # Initialize invenotry is newly created
    nr_initialize_inventory
    # Update quantity data in the hash.
    if weapon_id > 0
      weapon = [[weapon_number(weapon_id) + n, 0].max, 1].min
      @weapons[@game_variable][weapon_id] = weapon
    end
  end
  #--------------------------------------------------------------------------
  # * Gain Armor (or lose)
  #     armor_id : armor ID
  #     n        : quantity
  #--------------------------------------------------------------------------
  def gain_armor(armor_id, n)
    # Initialize invenotry is newly created
    nr_initialize_inventory
    # Update quantity data in the hash.
    if armor_id > 0
      armor = [[armor_number(armor_id) + n, 0].max, 1].min
      @armors[@game_variable][armor_id] = armor
    end
  end
  #--------------------------------------------------------------------------
  # * Initialize Inventory
  #     Search through, if the variable has changed to something that hasn't
  #     been used before, initialize the sets of items/weapons/armors
  #--------------------------------------------------------------------------
  def nr_initialize_inventory
    @game_variable = $game_variables[INVENTORY_VARIABLE].abs
    if @items[@game_variable] == nil
      @items[@game_variable] = {}
    end
    if @weapons[@game_variable] == nil
      @weapons[@game_variable] = {}
    end
    if @armors[@game_variable] == nil
      @armors[@game_variable] = {}
    end
  end
end