[XP]Items Limit

Started by Ronivan, March 02, 2015, 09:53:10 am

Previous topic - Next topic

Ronivan

Hello everyone!
This the MOG Item Limit V1.7

Description
This is a script that limits the number of items which you can carry with you, just like series Tales. Instead of 99 items, you can determine the number of items you can carry of a specific item, changing or adding new
lines in the script Items Limit, like this: A => B  (A= Item ID in the Database, B = amount limit). You can add as many lines as you wish, just follow the same pattern as it is in the script.
Also the script has specific sections for items, weapons, armors and money.

How to use
There are two scripts, must be placed one bellow the other, just like the order I have posted here. Put them in the order above Main. Edit the items limit in the first script.

Credits
All credits go to Moghunter for making the script.


Scripts
(place them in the same order I have posted here, and above main)

1º Items Limit
#_______________________________________________________________________________
# MOG Item Limit V1.7
#_______________________________________________________________________________
# By Moghunter
# http://www.atelier-rgss.com
#_______________________________________________________________________________
# Portuguese:
# Permite definir o limite maximo para cada item, armas
# ou armaduras.
#
# English:
# Set the maximum limit for each item, weapons
# Or armor.
#_______________________________________________________________________________
module MOG
#-------------------------------------------------------------------------------
# Definição do limite padrão.
# Items Limit Definition
#-------------------------------------------------------------------------------
DEFAULT_LIMIT = 99
#-------------------------------------------------------------------------------
# A => B
#
# A = ID do item, armadura ou arma (ID of the item, weapon or armor).
# B = Quantidade de itens maximo (amount of maximum items).
#
#-------------------------------------------------------------------------------
#Definição do limite maximo de Itens.
#Definition of Item maximum limit.
#-------------------------------------------------------------------------------
ITEM_LIMIT = {
1=>20, #Vera Nut
2=>20, #Vera Tonic
3=>20, #Vera Potion
4=>10, #Vera Medicine
5=>20, #Mana Seeds
6=>20, #Mana Tonic
7=>20, #Mana Potion
8=>10, #Mana Spirit
9=>7,  #Vera Elixir
10=>7,  #Mana Elixir
11=>10, #Yggdrasil Seed
12=>10, #Yggdrasil Berry
13=>5,  #Elixir Vitae
14=>1,  #--------------
15=>30, #Antidote Pills
16=>30, #Eye Drops
17=>30, #Clear Mint
18=>30, #Ammonia
19=>30, #Soft
20=>30, #Holy Water
21=>30, #Winter Booze
22=>30, #Stardust Herb
23=>15, #Panacea

}
#-------------------------------------------------------------------------------
#Definição do limite maximo de armas.
#Definition of weapons maximum limit.
#-------------------------------------------------------------------------------
WEAPON_LIMIT = {
1=>9, #Bronze Sword
2=>6, #Iron Sword
3=>3, #Steel Sword
4=>1, #Mythril Sword
5=>9, #Bronze Spear
6=>6, #Iron Spear
7=>3, #Steel Spear
8=>1 #Mythril Spear
}
#-------------------------------------------------------------------------------
#Definição do limite maximo de armaduras.
#Definition of armors maximum limit.
#-------------------------------------------------------------------------------
ARMOR_LIMIT = {
1=>20, #Bronze Shield
2=>15, #Iron Shield
5=>20, #Bronze Helm
13=>10 #Bronze Armor
}
#-------------------------------------------------------------------------------
#Definição do limite maximo de dinheiro
#Definition of maximum money limit.
#-------------------------------------------------------------------------------
GOLD_LIMIT = 1000000000
#-------------------------------------------------------------------------------
end
$mogscript = {} if $mogscript == nil
$mogscript["Item_Limit"] = true
##############
# Game_Party #
##############
class Game_Party
alias mog45_gain_item gain_item
def gain_item(item_id, n)
if item_id > 0
item_limit = MOG::ITEM_LIMIT[item_id]
if item_limit != nil
@items[item_id] = [[item_number(item_id) + n, 0].max, item_limit].min
else
@items[item_id] = [[item_number(item_id) + n, 0].max, MOG::DEFAULT_LIMIT].min
end
end
return
mog45_gain_item(item_id, n)
end
alias mog45_gain_weapon gain_weapon
def gain_weapon(weapon_id, n)
if weapon_id > 0
weapon_limit = MOG::WEAPON_LIMIT[weapon_id]
if weapon_limit !=nil
@weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, weapon_limit].min
else
@weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, MOG::DEFAULT_LIMIT].min
end
end
return
mog45_gain_weapon(weapon_id, n)
end
alias mog45_gain_armor gain_armor
def gain_armor(armor_id, n)
if armor_id > 0
armor_limit = MOG::ARMOR_LIMIT[armor_id]
if armor_limit != nil
@armors[armor_id] = [[armor_number(armor_id) + n, 0].max, armor_limit].min
else
@armors[armor_id] = [[armor_number(armor_id) + n, 0].max, MOG::DEFAULT_LIMIT].min
end
end
return
mog45_gain_armor
end
def gain_gold(n)
@gold = [[@gold + n, 0].max, MOG::GOLD_LIMIT].min
end
end
##############
# Scene_Shop #
##############
class Scene_Shop
alias mog45_update update
def update
if @sell_window.active == true
$sell = true
else
$sell = false
end
mog45_update
end
alias mog45_update_buy update_buy
def update_buy
if Input.trigger?(Input::C)
@item = @buy_window.item
case @item
when RPG::Item
number = $game_party.item_number(@item.id)
item_limit = MOG::ITEM_LIMIT[@item.id]
if item_limit != nil
if number >= item_limit
$game_system.se_play($data_system.buzzer_se)
return
end
else
if number == MOG::DEFAULT_LIMIT
$game_system.se_play($data_system.buzzer_se)
return
end
end
when RPG::Weapon
number = $game_party.weapon_number(@item.id)
weapon_limit = MOG::WEAPON_LIMIT[@item.id]
if weapon_limit != nil
if number >= weapon_limit
$game_system.se_play($data_system.buzzer_se)
return
end
else
if number == MOG::DEFAULT_LIMIT
$game_system.se_play($data_system.buzzer_se)
return
end
end
when RPG::Armor
number = $game_party.armor_number(@item.id)
armor_limit = MOG::ARMOR_LIMIT[@item.id]
if armor_limit != nil
if number >= armor_limit
$game_system.se_play($data_system.buzzer_se)
return
end
else
if number == MOG::DEFAULT_LIMIT
$game_system.se_play($data_system.buzzer_se)
return
end
end
end
end
mog45_update_buy
end
end
#####################
# Window_ShopNumber #
#####################
class Window_ShopNumber < Window_Base
alias mog45_set set
def set(item, max, price)
@item = item
case @item
when RPG::Item
number = $game_party.item_number(@item.id)
item_limit = MOG::ITEM_LIMIT[@item.id]
if item_limit!= nil
if $sell == true
valor = item_limit - number
@max = item_limit - valor
else
@max = item_limit - number
end
else
if $sell == true
valor = MOG::DEFAULT_LIMIT - number
@max = MOG::DEFAULT_LIMIT - valor
else
@max = MOG::DEFAULT_LIMIT - number
end
end
when RPG::Weapon
number = $game_party.weapon_number(@item.id)
weapon_limit = MOG::WEAPON_LIMIT[@item.id]
if weapon_limit!= nil
if $sell == true
valor = weapon_limit - number
@max = weapon_limit - valor
else
@max = weapon_limit - number
end
else
if $sell == true
valor = MOG::DEFAULT_LIMIT - number
@max = MOG::DEFAULT_LIMIT - valor
else
@max = MOG::DEFAULT_LIMIT - number
end
end
when RPG::Armor
number = $game_party.armor_number(@item.id)
armor_limit = MOG::ARMOR_LIMIT[@item.id]
if armor_limit!= nil
if $sell == true
valor = armor_limit - number
@max = armor_limit - valor
else
@max = armor_limit - number
end
else
if $sell == true
valor = MOG::DEFAULT_LIMIT - number
@max = MOG::DEFAULT_LIMIT - valor
else
@max = MOG::DEFAULT_LIMIT - number
end
end
end
@price = price
@number = 1
refresh
return
mog45_set set(item, max, price)
end
end
###############
# Window_Item #
###############
class Window_Item < Window_Selectable
def draw_item(index)
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
item_number = MOG::ITEM_LIMIT[item.id]
when RPG::Weapon
number = $game_party.weapon_number(item.id)
item_number = MOG::WEAPON_LIMIT[item.id]
when RPG::Armor
number = $game_party.armor_number(item.id)
item_number = MOG::ARMOR_LIMIT[item.id]
end
if item.is_a?(RPG::Item) and
$game_party.item_can_use?(item.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 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)
if item_number != nil
self.contents.draw_text(x + 220, y, 60, 32, number.to_s + " / " + item_number.to_s, 2)
else
max_limit = MOG::DEFAULT_LIMIT
self.contents.draw_text(x + 220, y, 60, 32, number.to_s + " / " + max_limit.to_s, 2)
end
end
end



2º Items Limit EX
##################
# Window_Item_Ex #
##################
class Window_Item_Ex < Window_Selectable
def draw_item(index)
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
item_number = MOG::ITEM_LIMIT[item.id]
end
if item.is_a?(RPG::Item) and
$game_party.item_can_use?(item.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 1 * (288 + 32)
y = index / 1 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.font.name = "Georgia"
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, 190, 32, item.name, 0)
if item_number != nil
self.contents.draw_text(x + 195, y, 60, 32, number.to_s + " / " + item_number.to_s, 2)
else
max_limit = MOG::DEFAULT_LIMIT
self.contents.draw_text(x + 195, y, 60, 32, number.to_s + " / " + max_limit.to_s, 2)
end
end
end
#################
# Window_Weapon #
#################
class Window_Weapon < Window_Selectable
def draw_item(index)
item = @data[index]
case item
when RPG::Weapon
number = $game_party.weapon_number(item.id)
item_number = MOG::WEAPON_LIMIT[item.id]
end
if item.is_a?(RPG::Item) and
$game_party.item_can_use?(item.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 1 * (288 + 32)
y = index / 1 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.font.name = "Georgia"
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, 190, 32, item.name, 0)
if item_number != nil
self.contents.draw_text(x + 195, y, 60, 32, number.to_s + " / " + item_number.to_s, 2)
else
max_limit = MOG::DEFAULT_LIMIT
self.contents.draw_text(x + 195, y, 60, 32, number.to_s + " / " + max_limit.to_s, 2)
end
end
end
################
# Window_Armor #
################
class Window_Armor < Window_Selectable
def draw_item(index)
item = @data[index]
case item
when RPG::Armor
number = $game_party.armor_number(item.id)
item_number = MOG::ARMOR_LIMIT[item.id]
end
if item.is_a?(RPG::Item) and
$game_party.item_can_use?(item.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 1 * (288 + 32)
y = index / 1 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.font.name = "Georgia"
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, 190, 32, item.name, 0)
if item_number != nil
self.contents.draw_text(x + 195, y, 60, 32, number.to_s + " / " + item_number.to_s, 2)
else
max_limit = MOG::DEFAULT_LIMIT
self.contents.draw_text(x + 195, y, 60, 32, number.to_s + " / " + max_limit.to_s, 2)
end
end
end
#####################
# Window_ShopStatus #
#####################
class Window_ShopStatus < Window_Base
alias mog45_refresh refresh
def refresh
if $mogscript["menu_shop"] == true
mog45_refresh
return false
end
self.contents.clear
if @item == nil
return
end
case @item
when RPG::Item
number = $game_party.item_number(@item.id)
item_max = MOG::ITEM_LIMIT[@item.id]
when RPG::Weapon
number = $game_party.weapon_number(@item.id)
item_max = MOG::WEAPON_LIMIT[@item.id]
when RPG::Armor
number = $game_party.armor_number(@item.id)
item_max = MOG::ARMOR_LIMIT[@item.id]
end
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 200, 32, "Stock")
self.contents.font.color = normal_color
if item_max != nil
self.contents.draw_text(155, 0, 80, 32, number.to_s + " / " + item_max.to_s, 2)
else
max_limit = MOG::DEFAULT_LIMIT
self.contents.draw_text(155, 0, 80, 32, number.to_s + " / " + max_limit.to_s, 2)
end
if @item.is_a?(RPG::Item)
return
end
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
if actor.equippable?(@item)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
self.contents.draw_text(4, 64 + 64 * i, 120, 32, actor.name)
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 actor.equippable?(@item)
if @item.is_a?(RPG::Weapon)
atk1 = item1 != nil ? item1.atk : 0
atk2 = @item != nil ? @item.atk : 0
change = atk2 - atk1
end
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
self.contents.draw_text(124, 64 + 64 * i, 112, 32,
sprintf("%+d", change), 2)
end
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
return true
mog45_refresh
end
end
###################
# Window_ShopSell #
###################
class Window_ShopSell < Window_Selectable
def initialize
if $mogscript["menu_shop"] == true
super(-10, 180, 305, 225)
self.opacity = 0
@column_max = 1
refresh
self.index = 0
else
super(0, 128, 640, 352)
@column_max = 2
refresh
self.index = 0
end
end
def draw_item(index)
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
item_number = MOG::ITEM_LIMIT[item.id]
when RPG::Weapon
number = $game_party.weapon_number(item.id)
item_number = MOG::WEAPON_LIMIT[item.id]
when RPG::Armor
number = $game_party.armor_number(item.id)
item_number = MOG::ARMOR_LIMIT[item.id]
end
if item.price > 0
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
if $mogscript["menu_shop"] == nil
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 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)
if item_number != nil
self.contents.draw_text(x + 220, y, 60, 32, number.to_s + " / " + item_number.to_s, 2)
else
max_limit = MOG::DEFAULT_LIMIT
self.contents.draw_text(x + 220, y, 60, 32, number.to_s + " / " + max_limit.to_s, 2)
end
else
self.contents.font.name = "Georgia"
x = 4 + index % 1 * (288 + 32)
y = index / 1 * 32
rect = Rect.new(x, y, self.width / @column_max - 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, 150, 32, item.name, 0)
self.contents.font.color = Color.new(50,250,150,255)
prc = item.price / 2
self.contents.draw_text(x + 180, y, 80, 32, "+G " + prc.to_s, 2)
end
end
end




I hope it may be usefull for you guys! Punch me if I have done something wrong.

KK20

March 02, 2015, 02:50:08 pm #1 Last Edit: March 02, 2015, 02:51:26 pm by KK20
First of all, this: http://forum.chaos-project.com/index.php/topic,17.0.html

Secondly, I know we have some of Moghunter's scripts in the database, but do we really need to keep adding more of them when anyone can just go to http://www.atelier-rgss.com https://atelierrgss.wordpress.com ?

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Ronivan

March 02, 2015, 06:33:52 pm #2 Last Edit: March 02, 2015, 07:10:44 pm by Ronivan
You are right, and of course I thought yes about what you said, if someone where after such script, they would do a search and find it quite easly. But also I thought about the idea of posting a script like this, like some kind of sharing an idea. Someone here may see this post and make use of the script even if it was not supposed to be in their project in the first place. There are lots of usefull scripts that people don't know or don't think of a possibility for their games. I'm sorry that this post may be a burden.

ForeverZer0

It's not a burden, but it won't make it to the database until the script template is applied.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.