#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# â–ˆ Change Item Prices
# Credits: bukai aka spk
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ID = ID of the Item. Either Weapon, Armor or Item.
# PRICE = New Price
# TYPE
# 0 = Item
# 1 = Weapon
# 2 = Armor
#
#
# Available methods,
# Callscript:
# $cost.new_price(ID, PRICE, TYPE) # set new price for an item
# $cost.add_price(ID, PRICE, TYPE) # increase the price by X
# $cost.sub_price(ID, PRICE, TYPE) # decrease the price by X
#
#=======================================================================
class PriceChange
attr_accessor :id
attr_accessor :price
attr_accessor :type
def initialize
@id = id
@price = price
@type = type
end
def new_price(id, price, type)
case type
when 0
$data_items[id].price = price
when 1
$data_weapons[id].price = price
when 2
$data_armors[id].price = price
else
p "INVALID INPUT"
end
end
def add_price(id, price, type)
case type
when 0
$data_items[id].price += price
when 1
$data_weapons[id].price += price
when 2
$data_armors[id].price += price
else
p "INVALID INPUT"
end
end
def sub_price(id, price, type)
case type
when 0
$data_items[id].price -= price
when 1
$data_weapons[id].price -= price
when 2
$data_armors[id].price -= price
else
p "INVALID INPUT"
end
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Call Class
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Scene_Title
alias bukai_main main
def main
$cost = PriceChange.new
bukai_main
end
end
class Scene_Save < Scene_File
def write_save_data(file)
# Make character data for drawing save file
characters = []
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
characters.push([actor.character_name, actor.character_hue])
end
# Write character data for drawing save file
Marshal.dump(characters, file)
# Wrire frame count for measuring play time
Marshal.dump(Graphics.frame_count, file)
# Increase save count by 1
$game_system.save_count += 1
# Save magic number
# (A random value will be written each time saving with editor)
$game_system.magic_number = $data_system.magic_number
# Write each type of game object
Marshal.dump($game_system, file)
Marshal.dump($game_switches, file)
Marshal.dump($game_variables, file)
Marshal.dump($game_self_switches, file)
Marshal.dump($game_screen, file)
Marshal.dump($game_actors, file)
Marshal.dump($game_party, file)
Marshal.dump($game_troop, file)
Marshal.dump($game_map, file)
Marshal.dump($game_player, file)
Marshal.dump($cost, file)
Marshal.dump($data_items, file)
Marshal.dump($data_weapons, file)
Marshal.dump($data_armors, file)
end
end
class Scene_Load < Scene_File
#--------------------------------------------------------------------------
# * Read Save Data
# file : file object for reading (opened)
#--------------------------------------------------------------------------
def read_save_data(file)
# Read character data for drawing save file
characters = Marshal.load(file)
# Read frame count for measuring play time
Graphics.frame_count = Marshal.load(file)
# Read each type of game object
$game_system = Marshal.load(file)
$game_switches = Marshal.load(file)
$game_variables = Marshal.load(file)
$game_self_switches = Marshal.load(file)
$game_screen = Marshal.load(file)
$game_actors = Marshal.load(file)
$game_party = Marshal.load(file)
$game_troop = Marshal.load(file)
$game_map = Marshal.load(file)
$game_player = Marshal.load(file)
$cost = Marshal.load(file)
$data_items = Marshal.load(file)
$data_weapons = Marshal.load(file)
$data_armors = Marshal.load(file)
# If magic number is different from when saving
# (if editing was added with editor)
if $game_system.magic_number != $data_system.magic_number
# Load map
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
end
# Refresh party members
$game_party.refresh
end
end