RPG~NOOB!!!
Member
My Max Items Script Version: 1.0
By: Jarviar also know on some rpgmaker sites as RPG~NOOB!!!
Introduction
This is a nice little script that let's you select the max number of each item. It comes with two parts the first is the main code and the second is plugins for the default shop screen.
Features
Screenshots
Will try to post one if requested. But all it would be is the inventory screen or the shop screen.
Demo
---
Script
Here's the script. The first script is the main one the second is an extension for the default shop window if you want to use the extension past in the bottom of the first script..
[rgss]#--------------------------------------------------------------------------------
# Simple Max Items/Weapons/Armor Script
# By Jarviar also known as RPG~NOOB!!!
#--------------------------------------------------------------------------------
# n = number value
# i_id = Item ID
# w_id = Weapon ID
# a_id = Armor ID
#
# Maximums_Items = n
# The default max number of items allowed in the players inventory at once.
# Maximums_Weapon = n
# The default max number of weapons allowed in the players inventory at once.
# Maximums_Armor = n
# The default max number of armor allowed in the players inventory at once.
#
# Item_Max[i_id] = n
# The max amount of the specified item allowed in the players inventory at once.
# Weapon_Max[w_id] = n
# The max amount of the specified weapon allowed in the players inventory at once.
# Armor_Max[a_id] = n
# The max amount of the specified armor allowed in the players inventory at once.
#
#--------------------------------------------------------------------------------
# MAIN SCRIPT \|/ ---------------------------------------------------------------
module MyMaxItems_Config
Item_Max = {}
Weapon_Max = {}
Armor_Max = {}
# Modify this part \|/
Maximums_Items = 10
Maximums_Weapon = 5
Maximums_Armor = 5
# Add specific max's below this line.
# Modify this part /|\
end
class Game_Party
include MyMaxItems_Config
def gain_item(item_id, n)
if item_id > 0
if Item_Max.include?(item_id) and Item_Max[item_id] != nil
@items[item_id] = [[item_number(item_id) + n, 0].max, Item_Max[item_id]].min
else
@items[item_id] = [[item_number(item_id) + n, 0].max, Maximums_Items].min
end
end
end
def gain_weapon(weapon_id, n)
if weapon_id > 0
if Weapon_Max.include?(weapon_id) and Weapon_Max[weapon_id] != nil
@weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, Weapon_Max[weapon_id]].min
else
@weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, Maximums_Weapon].min
end
end
end
def gain_armor(armor_id, n)
if armor_id > 0
if Armor_Max.include?(armor_id) and Armor_Max[armor_id] != nil
@armors[armor_id] = [[armor_number(armor_id) + n, 0].max, Armor_Max[armor_id]].min
else
@armors[armor_id] = [[armor_number(armor_id) + n, 0].max, Maximums_Armor].min
end
end
end
end
# MAIN SCRIPT /|\ ---------------------------------------------------------------
[/rgss]
[rgss]# SHOP EXTENSION \|/ ------------------------------------------------------------
class Scene_Shop
include MyMaxItems_Config
def update_buy
# Set status window item
@status_window.item = @buy_window.item
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Change windows to initial mode
@command_window.active = true
@dummy_window.visible = true
@buy_window.active = false
@buy_window.visible = false
@status_window.visible = false
@status_window.item = nil
# Erase help text
@help_window.set_text("")
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Get item
@item = @buy_window.item
# If item is invalid, or price is higher than money possessed
if @item == nil or @item.price > $game_party.gold
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Get items in possession count
case @item
when RPG::Item
number = $game_party.item_number(@item.id)
if Item_Max.include?(@item.id) and Item_Max[@item.id] != nil
max_number = Item_Max[@item.id]
else
max_number = Maximums_Items
end
when RPG::Weapon
number = $game_party.weapon_number(@item.id)
if Weapon_Max.include?(@item.id) and Weapon_Max[@item.id] != nil
max_number = Weapon_Max[@item.id]
else
max_number = Maximums_Weapon
end
when RPG::Armor
number = $game_party.armor_number(@item.id)
if Armor_Max.include?(@item.id) and Armor_Max[@item.id] != nil
max_number = Armor_Max[@item.id]
else
max_number = Maximums_Armor
end
end
if number == max_number
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
max = @item.price == 0 ? max_number : $game_party.gold / @item.price
max = [max, max_number - number].min
@buy_window.active = false
@buy_window.visible = false
@number_window.set(@item, max, @item.price)
@number_window.active = true
@number_window.visible = true
end
end
end
class Window_ShopBuy < Window_Selectable
include MyMaxItems_Config
def draw_item(index)
item = @data[index]
# Get items in possession
case item
when RPG::Item
number = $game_party.item_number(item.id)
if Item_Max.include?(item.id) and Item_Max[item.id] != nil
max_number = Item_Max[item.id]
else
max_number = Maximums_Items
end
when RPG::Weapon
number = $game_party.weapon_number(item.id)
if Weapon_Max.include?(item.id) and Weapon_Max[item.id] != nil
max_number = Weapon_Max[item.id]
else
max_number = Maximums_Weapon
end
when RPG::Armor
number = $game_party.armor_number(item.id)
if Armor_Max.include?(item.id) and Armor_Max[item.id] != nil
max_number = Armor_Max[item.id]
else
max_number = Maximums_Armor
end
end
# If price is less than money in possession, and amount in possession is
# not 99, then set to normal text color. Otherwise set to disabled color
if item.price <= $game_party.gold and number < max_number
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4
y = index * 32
rect = Rect.new(x, y, self.width - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 88, 32, item.price.to_s, 2)
end
end
class Window_ShopStatus < Window_Base
include MyMaxItems_Config
def refresh
self.contents.clear
if @item == nil
return
end
case @item
when RPG::Item
number = $game_party.item_number(@item.id)
if Item_Max.include?(@item.id) and Item_Max[@item.id] != nil
max_number = Item_Max[@item.id]
else
max_number = Maximums_Items
end
when RPG::Weapon
number = $game_party.weapon_number(@item.id)
if Weapon_Max.include?(@item.id) and Weapon_Max[@item.id] != nil
max_number = Weapon_Max[@item.id]
else
max_number = Maximums_Weapon
end
when RPG::Armor
number = $game_party.armor_number(@item.id)
if Armor_Max.include?(@item.id) and Armor_Max[@item.id] != nil
max_number = Armor_Max[@item.id]
else
max_number = Maximums_Armor
end
end
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 66.7, 32, "Owned:")
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 150, 32, number.to_s + '/' + max_number.to_s, 2)
if @item.is_a?(RPG::Item)
return
end
# Equipment adding information
for i in 0...$game_party.actors.size
# Get actor
actor = $game_party.actors
# If equippable, then set to normal text color. If not, set to
# invalid text color.
if actor.equippable?(@item)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
# Draw actor's name
self.contents.draw_text(4, 64 + 64 * i, 120, 32, actor.name)
# Get current equipment
if @item.is_a?(RPG::Weapon)
item1 = $data_weapons[actor.weapon_id]
elsif @item.kind == 0
item1 = $data_armors[actor.armor1_id]
elsif @item.kind == 1
item1 = $data_armors[actor.armor2_id]
elsif @item.kind == 2
item1 = $data_armors[actor.armor3_id]
else
item1 = $data_armors[actor.armor4_id]
end
# If equippable
if actor.equippable?(@item)
# If weapon
if @item.is_a?(RPG::Weapon)
atk1 = item1 != nil ? item1.atk : 0
atk2 = @item != nil ? @item.atk : 0
change = atk2 - atk1
end
# If armor
if @item.is_a?(RPG::Armor)
pdef1 = item1 != nil ? item1.pdef : 0
mdef1 = item1 != nil ? item1.mdef : 0
pdef2 = @item != nil ? @item.pdef : 0
mdef2 = @item != nil ? @item.mdef : 0
change = pdef2 - pdef1 + mdef2 - mdef1
end
# Draw parameter change values
self.contents.draw_text(124, 64 + 64 * i, 112, 32,
sprintf("%+d", change), 2)
end
# Draw item
if item1 != nil
x = 4
y = 64 + 64 * i + 32
bitmap = RPG::Cache.icon(item1.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item1.name)
end
end
end
end
# SHOP EXTENSION /|\ ------------------------------------------------------------
[/rgss]
Instructions
1. Place script above main.
2. If you don't want the shop extension delete from the line with # SHOP EXTENSION \|/ to the end of the script.
3. Read comments and customize.
FAQ
---
Compatibility
Works with or without SDK!
The main code works with about everything but the shop extension WILL mess up custom shop systems. If your using a custom shop system then dont use the second script..
Credits and Thanks
Me/Jarviar for making.
Author's Notes
Sorry if this topic is kinda cluttered this is the first script I've uploaded. And I've noticed that in rpgmaker if you have a weapon in hand and dont have enough slots for it in your inventory then it just disappears.
Terms and Conditions
Remember to give some credit to me. Other than that enjoy.
By: Jarviar also know on some rpgmaker sites as RPG~NOOB!!!
Introduction
This is a nice little script that let's you select the max number of each item. It comes with two parts the first is the main code and the second is plugins for the default shop screen.
Features
- Customize the default max for items with Maximums_Items = n
- Customize the default max for weapons with Maximums_Weapon = n
- Customize the default max for armor with Maximums_Armor = n
- Set the max number for a specific item with Item_Max[id] = n
- Set the max number for a specific weapon with Weapon_Max[id] = n
- Set the max number for specific armor with Armor_Max[id] = n
- If your using my shop extension it'll change the 'number in possession #' to 'Owned: #/Max'
Screenshots
Will try to post one if requested. But all it would be is the inventory screen or the shop screen.
Demo
---
Script
Here's the script. The first script is the main one the second is an extension for the default shop window if you want to use the extension past in the bottom of the first script..
[rgss]#--------------------------------------------------------------------------------
# Simple Max Items/Weapons/Armor Script
# By Jarviar also known as RPG~NOOB!!!
#--------------------------------------------------------------------------------
# n = number value
# i_id = Item ID
# w_id = Weapon ID
# a_id = Armor ID
#
# Maximums_Items = n
# The default max number of items allowed in the players inventory at once.
# Maximums_Weapon = n
# The default max number of weapons allowed in the players inventory at once.
# Maximums_Armor = n
# The default max number of armor allowed in the players inventory at once.
#
# Item_Max[i_id] = n
# The max amount of the specified item allowed in the players inventory at once.
# Weapon_Max[w_id] = n
# The max amount of the specified weapon allowed in the players inventory at once.
# Armor_Max[a_id] = n
# The max amount of the specified armor allowed in the players inventory at once.
#
#--------------------------------------------------------------------------------
# MAIN SCRIPT \|/ ---------------------------------------------------------------
module MyMaxItems_Config
Item_Max = {}
Weapon_Max = {}
Armor_Max = {}
# Modify this part \|/
Maximums_Items = 10
Maximums_Weapon = 5
Maximums_Armor = 5
# Add specific max's below this line.
# Modify this part /|\
end
class Game_Party
include MyMaxItems_Config
def gain_item(item_id, n)
if item_id > 0
if Item_Max.include?(item_id) and Item_Max[item_id] != nil
@items[item_id] = [[item_number(item_id) + n, 0].max, Item_Max[item_id]].min
else
@items[item_id] = [[item_number(item_id) + n, 0].max, Maximums_Items].min
end
end
end
def gain_weapon(weapon_id, n)
if weapon_id > 0
if Weapon_Max.include?(weapon_id) and Weapon_Max[weapon_id] != nil
@weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, Weapon_Max[weapon_id]].min
else
@weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, Maximums_Weapon].min
end
end
end
def gain_armor(armor_id, n)
if armor_id > 0
if Armor_Max.include?(armor_id) and Armor_Max[armor_id] != nil
@armors[armor_id] = [[armor_number(armor_id) + n, 0].max, Armor_Max[armor_id]].min
else
@armors[armor_id] = [[armor_number(armor_id) + n, 0].max, Maximums_Armor].min
end
end
end
end
# MAIN SCRIPT /|\ ---------------------------------------------------------------
[/rgss]
[rgss]# SHOP EXTENSION \|/ ------------------------------------------------------------
class Scene_Shop
include MyMaxItems_Config
def update_buy
# Set status window item
@status_window.item = @buy_window.item
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Change windows to initial mode
@command_window.active = true
@dummy_window.visible = true
@buy_window.active = false
@buy_window.visible = false
@status_window.visible = false
@status_window.item = nil
# Erase help text
@help_window.set_text("")
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Get item
@item = @buy_window.item
# If item is invalid, or price is higher than money possessed
if @item == nil or @item.price > $game_party.gold
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Get items in possession count
case @item
when RPG::Item
number = $game_party.item_number(@item.id)
if Item_Max.include?(@item.id) and Item_Max[@item.id] != nil
max_number = Item_Max[@item.id]
else
max_number = Maximums_Items
end
when RPG::Weapon
number = $game_party.weapon_number(@item.id)
if Weapon_Max.include?(@item.id) and Weapon_Max[@item.id] != nil
max_number = Weapon_Max[@item.id]
else
max_number = Maximums_Weapon
end
when RPG::Armor
number = $game_party.armor_number(@item.id)
if Armor_Max.include?(@item.id) and Armor_Max[@item.id] != nil
max_number = Armor_Max[@item.id]
else
max_number = Maximums_Armor
end
end
if number == max_number
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
max = @item.price == 0 ? max_number : $game_party.gold / @item.price
max = [max, max_number - number].min
@buy_window.active = false
@buy_window.visible = false
@number_window.set(@item, max, @item.price)
@number_window.active = true
@number_window.visible = true
end
end
end
class Window_ShopBuy < Window_Selectable
include MyMaxItems_Config
def draw_item(index)
item = @data[index]
# Get items in possession
case item
when RPG::Item
number = $game_party.item_number(item.id)
if Item_Max.include?(item.id) and Item_Max[item.id] != nil
max_number = Item_Max[item.id]
else
max_number = Maximums_Items
end
when RPG::Weapon
number = $game_party.weapon_number(item.id)
if Weapon_Max.include?(item.id) and Weapon_Max[item.id] != nil
max_number = Weapon_Max[item.id]
else
max_number = Maximums_Weapon
end
when RPG::Armor
number = $game_party.armor_number(item.id)
if Armor_Max.include?(item.id) and Armor_Max[item.id] != nil
max_number = Armor_Max[item.id]
else
max_number = Maximums_Armor
end
end
# If price is less than money in possession, and amount in possession is
# not 99, then set to normal text color. Otherwise set to disabled color
if item.price <= $game_party.gold and number < max_number
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4
y = index * 32
rect = Rect.new(x, y, self.width - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 88, 32, item.price.to_s, 2)
end
end
class Window_ShopStatus < Window_Base
include MyMaxItems_Config
def refresh
self.contents.clear
if @item == nil
return
end
case @item
when RPG::Item
number = $game_party.item_number(@item.id)
if Item_Max.include?(@item.id) and Item_Max[@item.id] != nil
max_number = Item_Max[@item.id]
else
max_number = Maximums_Items
end
when RPG::Weapon
number = $game_party.weapon_number(@item.id)
if Weapon_Max.include?(@item.id) and Weapon_Max[@item.id] != nil
max_number = Weapon_Max[@item.id]
else
max_number = Maximums_Weapon
end
when RPG::Armor
number = $game_party.armor_number(@item.id)
if Armor_Max.include?(@item.id) and Armor_Max[@item.id] != nil
max_number = Armor_Max[@item.id]
else
max_number = Maximums_Armor
end
end
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 66.7, 32, "Owned:")
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 150, 32, number.to_s + '/' + max_number.to_s, 2)
if @item.is_a?(RPG::Item)
return
end
# Equipment adding information
for i in 0...$game_party.actors.size
# Get actor
actor = $game_party.actors
# If equippable, then set to normal text color. If not, set to
# invalid text color.
if actor.equippable?(@item)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
# Draw actor's name
self.contents.draw_text(4, 64 + 64 * i, 120, 32, actor.name)
# Get current equipment
if @item.is_a?(RPG::Weapon)
item1 = $data_weapons[actor.weapon_id]
elsif @item.kind == 0
item1 = $data_armors[actor.armor1_id]
elsif @item.kind == 1
item1 = $data_armors[actor.armor2_id]
elsif @item.kind == 2
item1 = $data_armors[actor.armor3_id]
else
item1 = $data_armors[actor.armor4_id]
end
# If equippable
if actor.equippable?(@item)
# If weapon
if @item.is_a?(RPG::Weapon)
atk1 = item1 != nil ? item1.atk : 0
atk2 = @item != nil ? @item.atk : 0
change = atk2 - atk1
end
# If armor
if @item.is_a?(RPG::Armor)
pdef1 = item1 != nil ? item1.pdef : 0
mdef1 = item1 != nil ? item1.mdef : 0
pdef2 = @item != nil ? @item.pdef : 0
mdef2 = @item != nil ? @item.mdef : 0
change = pdef2 - pdef1 + mdef2 - mdef1
end
# Draw parameter change values
self.contents.draw_text(124, 64 + 64 * i, 112, 32,
sprintf("%+d", change), 2)
end
# Draw item
if item1 != nil
x = 4
y = 64 + 64 * i + 32
bitmap = RPG::Cache.icon(item1.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item1.name)
end
end
end
end
# SHOP EXTENSION /|\ ------------------------------------------------------------
[/rgss]
Instructions
1. Place script above main.
2. If you don't want the shop extension delete from the line with # SHOP EXTENSION \|/ to the end of the script.
3. Read comments and customize.
FAQ
---
Compatibility
Works with or without SDK!
The main code works with about everything but the shop extension WILL mess up custom shop systems. If your using a custom shop system then dont use the second script..
Credits and Thanks
Me/Jarviar for making.
Author's Notes
Sorry if this topic is kinda cluttered this is the first script I've uploaded. And I've noticed that in rpgmaker if you have a weapon in hand and dont have enough slots for it in your inventory then it just disappears.
Terms and Conditions
Remember to give some credit to me. Other than that enjoy.