=begin
===============================================================================
变量商店 By喵呜喵5
===============================================================================
【说明】
可以使用变量在商店进行购物
首先先在事件中使用脚本命令输入:shop_set(变量的ID,"变量的单位"),例如:
shop_set(1,"节操")
接着使用事件中的商店处理时,购买物品不会消耗金钱而是消耗对应的变量
使用命令shop_set可以恢复原来使用金钱购物的商店
=end
$m5script = {} if $m5script.nil?
$m5script["M5VARShop"] = true
module M5VARShop
#==============================================================================
# 设定部分
#==============================================================================
PRICE = false #true
#设置为true的情况下,变量商店物品的出售价格为【数据库中】物品售价的一半
#设置为false的情况下, 变量商店物品的出售价格为【该商店】物品售价的一半
VAR = 1
#这里设置一个没有使用到的变量的ID,游戏中请不要修改这个ID的变量数值
#==============================================================================
# 设定结束
#==============================================================================
end
class Game_Interpreter
def shop_set(gold=0,unit="")
gold = 0 if gold == M5VARShop::VAR
$game_variables[M5VARShop::VAR]=[gold,unit]
end
end
class Window_Gold_New < Window_Gold
def initialize(gold,unit)
@gold,@unit = gold,unit
super()
end
def value
@gold == 0 ? super : $game_variables[@gold]
end
def currency_unit
(@gold == 0 || @unit == "") ? super : @unit
end
end
class Scene_Shop
def create_gold_window
$game_variables[M5VARShop::VAR] = [0,""] if \
!$game_variables[M5VARShop::VAR].is_a?(Array)
@gold_window = Window_Gold_New.new($game_variables[M5VARShop::VAR][0],$game_variables[M5VARShop::VAR][1])
@gold_window.viewport = @viewport
@gold_window.x = Graphics.width - @gold_window.width
@gold_window.y = @help_window.height
end
alias m5_20140318_do_buy do_buy
def do_buy(number)
if $game_variables[M5VARShop::VAR][0] == 0
m5_20140318_do_buy(number)
else
$game_variables[$game_variables[M5VARShop::VAR][0]] -= number * buying_price
$game_party.gain_item(@item, number)
end
end
alias m5_20140318_do_sell do_sell
def do_sell(number)
if $game_variables[M5VARShop::VAR][0] == 0
m5_20140318_do_sell(number)
else
$game_variables[$game_variables[M5VARShop::VAR][0]] += number * selling_price
$game_party.lose_item(@item, number)
end
end
alias m5_20140318_selling_price selling_price
def selling_price
return m5_20140318_selling_price if M5VARShop::PRICE || $game_variables[M5VARShop::VAR][0] == 0
buying_price / 2
end
end