Try this...
#===============================================================================
# ** RPG::Item
#===============================================================================
class RPG::Item
#-----------------------------------------------------------------------------
# * Alias Listings
#-----------------------------------------------------------------------------
alias_method :changeprices_rpgitm_price, :price
#-----------------------------------------------------------------------------
# * Price
#-----------------------------------------------------------------------------
def price
if $game_system.is_a?(Game_System) && $game_system.item_price.has_key?(id)
return $game_system.item_price[id]
end
changeprices_rpgitm_price
end
end
#===============================================================================
# ** RPG::Armor
#===============================================================================
class RPG::Armor
#-----------------------------------------------------------------------------
# * Alias Listings
#-----------------------------------------------------------------------------
alias_method :changeprices_rpgarm_price, :price
#-----------------------------------------------------------------------------
# * Price
#-----------------------------------------------------------------------------
def price
if $game_system.is_a?(Game_System) && $game_system.armor_price.has_key?(id)
return $game_system.armor_price[id]
end
changeprices_rpgarm_price
end
end
#===============================================================================
# ** RPG::Weapon
#===============================================================================
class RPG::Weapon
#-----------------------------------------------------------------------------
# * Alias Listings
#-----------------------------------------------------------------------------
alias_method :changeprices_rpgwpn_price, :price
#-----------------------------------------------------------------------------
# * Price
#-----------------------------------------------------------------------------
def price
if $game_system.is_a?(Game_System) && $game_system.weapon_price.has_key?(id)
return $game_system.weapon_price[id]
end
changeprices_rpgwpn_price
end
end
#===============================================================================
# ** Game_System
#===============================================================================
class Game_System
#-----------------------------------------------------------------------------
# * Public Instance Variables
#-----------------------------------------------------------------------------
attr_reader :item_price
attr_reader :armor_price
attr_reader :weapon_price
#-----------------------------------------------------------------------------
# * Alias Listings
#-----------------------------------------------------------------------------
alias_method :changeprices_gmsystem_initialize, :initialize
def initialize
changeprices_gmsystem_initialize
@item_price = Hash.new
@armor_price = Hash.new
@weapon_price = Hash.new
end
#-----------------------------------------------------------------------------
# * Reset Item Prices
#-----------------------------------------------------------------------------
def reset_item_prices(arr = nil)
unless arr.is_a?(Array)
arr = Array.new
$data_items.each {|item| next if item.nil? ; arr << item.id}
end
arr.each {|i| @item_price.delete(i)}
end
#-----------------------------------------------------------------------------
# * Reset Armor Prices
#-----------------------------------------------------------------------------
def reset_armor_prices(arr = nil)
unless arr.is_a?(Array)
arr = Array.new
$data_armors.each {|armor| next if armor.nil? ; arr << armor.id}
end
arr.each {|i| @armor_price.delete(i)}
end
#-----------------------------------------------------------------------------
# * Reset Weapon Prices
#-----------------------------------------------------------------------------
def reset_weapon_prices(arr = nil)
unless arr.is_a?(Array)
arr = Array.new
$data_weapons.each {|weapon| next if weapon.nil? ; arr << weapon.id}
end
arr.each {|i| @weapon_price.delete(i)}
end
end
Using a simple call script, I tested it so it works fine, it aliases the
price method of RPG Item, Armor and Weapon and is saved through $game_system. You can also reset your prices too. I've made a couple call scripts to test the system, here's how you do it.
To change prices of things...
gs = $game_system
gs.item_price[1] = 420
gs.armor_price[1] = 420
gs.weapon_price[1] = 420
To reset prices to default (whats defined in database), do...
gs = $game_system
gs.reset_item_prices
gs.reset_armor_prices
gs.reset_weapon_prices
Note, when resetting prices to items or other, you can use an array of numbers (ie, [1, 2, 3, 9, 11]) to reset
only those items to their default prices specified in the database, same for armors and weapons. If you don't specify an array, it'll automatically clear ALL custom prices set in game back to the default database prices.
This will corrupt saved games (which means just don't try to load any old save files), meaning these prices will be saved and loaded from your save file.
Enjoy :thumb: