Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Maximum 20 items per item...

Alright. I need a script that limits the "number of units in one item".
Example: normally, a player can hold up to 99 potions. I want to reduce the 99 to 20. This should also be the limit with weapons, armors and so on.
Can anyone help with this?
 
Code:
class Game_Party
  # limit_type = { item_id => limit, ... }
  Item_Limits = {}
  Weapon_Limits = {}
  Armor_Limits = {}
  alias seph_itemlimits_gameprty_gainitem gain_item
  alias seph_itemlimits_gameprty_gainweapon gain_weapon
  alias seph_itemlimits_gameprty_gainarmor gain_armor
  def gain_item(item_id, n)
    seph_itemlimits_gameprty_gainitem(item_id, n)
    if Item_Limits.has_key?(item_id)
      @items[item_id] = [@items[item_id], 0].max, Item_Limits[item_id]].min
    end
  end
  def gain_weapon(item_id, n)
    seph_itemlimits_gameprty_gainweapon(item_id, n)
    if Weapon_Limits.has_key?(item_id)
      @weapons[item_id] = [@weapons[item_id], 0].max, Weapon_Limits[item_id]].min
    end
  end
  def gain_armor(item_id, n)
    seph_itemlimits_gameprty_gainarmor(item_id, n)
    if Armor_Limits.has_key?(item_id)
      @armors[item_id] = [@armors[item_id], 0].max, Armor_Limits[item_id]].min
    end
  end
end

You can use that. All you have to do is modify the Constants in there. There still remains the max of 99, but you can also make maxes for all the items seperatly.

If you want to change something, let me know.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top