lunariafantasia/Scripts/_.60.rb
2024-01-12 03:12:38 -06:00

142 lines
No EOL
5.5 KiB
Ruby
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#==============================================================================
# ■ Game_Temp
#------------------------------------------------------------------------------
#  セーブデータに含まれない、一時的なデータを扱うクラスです。このクラスのイン
# スタンスは $game_temp で参照されます。
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :shop_rate # ショップの販売レート
attr_reader :add_shop_item # 追加販売物の配列
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias shop_rate_initialize initialize
def initialize
shop_rate_initialize
rate_reset
add_shop_item_reset
end
#--------------------------------------------------------------------------
# ○
#--------------------------------------------------------------------------
def rate_reset
@shop_rate = 100
end
#--------------------------------------------------------------------------
# ○
#--------------------------------------------------------------------------
def add_shop_item_reset
@add_shop_item = []
end
#--------------------------------------------------------------------------
# ○ 追加販売アイテム設定
# type => アイテムカテゴリ 0 道具, 1 武器, 2 防具, id => アイテムID,
# price => 値段(0でデフォ値), index => 差し込み位置(0で先頭、-1で最後尾)
#--------------------------------------------------------------------------
def add_shop_item_set(type, id, price, index)
@add_shop_item.push([type, id, price > 0 ? 1 : 0, price, index])
end
end
#==============================================================================
# ■ Window_ShopBuy
#------------------------------------------------------------------------------
#  ショップ画面で、購入できる商品の一覧を表示するウィンドウです。
#==============================================================================
class Window_ShopBuy < Window_Selectable
#--------------------------------------------------------------------------
# ● 商品の値段を取得
#--------------------------------------------------------------------------
alias rate_price price
def price(item)
if rate_price(item) == 0
rate_price(item)
else
[rate_price(item) * $game_temp.shop_rate / 100, 1].max
end
end
end
#==============================================================================
# ■ Scene_Shop
#------------------------------------------------------------------------------
#  ショップ画面の処理を行うクラスです。
#==============================================================================
class Scene_Shop < Scene_MenuBase
#--------------------------------------------------------------------------
# ● 準備
#--------------------------------------------------------------------------
alias prepare_add prepare
def prepare(goods, purchase_only)
prepare_add(goods, purchase_only)
$game_temp.add_shop_item.each do |ary|
num = ary.pop
@goods.insert(num, ary)
end
end
#--------------------------------------------------------------------------
# ● 終了処理 ショップを閉じるとレートをリセット
#--------------------------------------------------------------------------
def terminate
super
$game_temp.rate_reset
$game_temp.add_shop_item_reset
$game_temp.shop_name = ""
end
#--------------------------------------------------------------------------
# ● 売値の取得 ※再定義
#--------------------------------------------------------------------------
def selling_price
@item.price / @item.sell_rate
end
end
class RPG::EquipItem < RPG::BaseItem
def sell_rate
@sell_rate ||= sell_rate_set
end
def sell_rate_set
return $1.to_i if self.note =~ /\<売却率:(\d+)\>/
return 2
end
end
class RPG::Item < RPG::UsableItem
def sell_rate
@sell_rate ||= sell_rate_set
end
def sell_rate_set
return $1.to_i if self.note =~ /\<売却率:(\d+)\>/
return 2
end
end
#==============================================================================
# ■ Game_Interpreter
#------------------------------------------------------------------------------
#  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
# Game_Troop クラス、Game_Event クラスの内部で使用されます。
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# ○ ショップレート変更
#--------------------------------------------------------------------------
def shop_rate(rate)
$game_temp.shop_rate = rate
end
#--------------------------------------------------------------------------
# ○ ショップアイテム追加
#--------------------------------------------------------------------------
def add_shop_item(type, id, price, index = 0)
$game_temp.add_shop_item_set(type, id, price, index)
end
end