Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- #
- # Price Changer (1.0)
- # 18/02/2012
- # By Pacman
- # This script allows you to change the price of items mid-game.
- # To do this, use the script call:
- # change_price(sym, id, [price])
- # Where sym is :item, :weapon or :armor (depending on what you're chaning the
- # price of), id is the database ID of the item, weapon or armor you're changing,
- # and price is the new price (integer). If you exclude the price argument, it
- # defaults to the original price of the item. Examples:
- # change_price(:item, 4, 20) - Will change the price of the fourth item in the
- # database to 20.
- # change_price(:weapon, 2, 50) - Will change the price of the second weapon
- # in the database to 50.
- # change_price(:armor, 3) - Will change the price of the third armor in the
- # database to the original price.
- # You can also use :i, :w or :a as sym.
- #
- #===============================================================================
- #==============================================================================
- # ■ Game_System
- #------------------------------------------------------------------------------
- # システム周りのデータを扱うクラスです。セーブやメニューの禁止状態などを保存
- # します。このクラスのインスタンスは $game_system で参照されます。
- #==============================================================================
- class Game_System
- #--------------------------------------------------------------------------
- # Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :new_price
- #--------------------------------------------------------------------------
- # * Get new prices
- #--------------------------------------------------------------------------
- def new_price
- if @new_price.nil?
- @new_price = {}
- @new_price[:item] = []
- @new_price[:weapon] = []
- @new_price[:armor] = []
- end
- @new_price
- end
- end
- #==============================================================================
- # ■ Game_Interpreter
- #------------------------------------------------------------------------------
- # イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
- # Game_Troop クラス、Game_Event クラスの内部で使用されます。
- #==============================================================================
- class Game_Interpreter
- #--------------------------------------------------------------------------
- # * Adjust the price of items
- # sym : type of item to alter
- # id : id of the item to alter
- # price : new price of the item (defaults to original)
- #--------------------------------------------------------------------------
- def change_price(sym, id, price = nil)
- if sym == :item || sym == :i # Items
- price ||= $data_items[id].orig_price
- $game_system.new_price[:item][id] = price
- elsif sym == :weapon || sym == :w # Weapons
- price ||= $data_weapons[id].orig_price
- $game_system.new_price[:weapon][id] = price
- elsif sym == :armor || sym == :a # Armours
- price ||= $data_armors[id].orig_price
- $game_system.new_price[:armor][id] = price
- end
- end
- end
- #==============================================================================
- # *** RPG
- #------------------------------------------------------------------------------
- # Module that holds data classes for all things in the game.
- #==============================================================================
- module RPG
- #--------------------------------------------------------------------------
- # ** Classes Item, Weapon, Armor
- #--------------------------------------------------------------------------
- [["Item", "items"], ["Weapon", "weapons"], ["Armor", "armor"]].each { |klass|
- # Create new methods
- prcchg = %Q(class #{klass[0]}; def orig_price; @price; end
- def price; return $game_system.new_price[:#{klass[1]}][@id].nil? ? @price :
- $game_system.new_price[:#{klass[1]}][@id]; end; end)
- eval(prcchg)
- }
- end
- $imported ||= {}
- $imported[:pac_price_changer]
- #===============================================================================
- #
- # END OF SCRIPT
- #
- #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement