=begin =============================================================================== 变量商店 By喵呜喵5 =============================================================================== 【说明】 可以使用变量在商店进行购物 首先先在事件中使用脚本命令输入 m5_20160528_shop(变量的ID,"变量的名称") 例如:m5_20160528_shop(1,"节操") 若事件指令中下一条指令为商店处理,则进入商店时购买物品消耗的是对应的变量 =end $m5script ||= {}; $m5script[:M5VS20160528] = 20160528 module M5VS20160528 #============================================================================== # 设定部分 #============================================================================== EQUAL = false # 设置为 true 时,变量商店物品的出售价格为【数据库中】物品售价的一半 # 设置为 false 时,变量商店物品的出售价格为【该商店】物品售价的一半 # (一般来说,个人建议将变量商店请设置为只允许购买) #============================================================================== # 设定结束 #============================================================================== def self.init; set(0, nil); end def self.gold; @data[0]; end def self.unit; @data[1]; end def self.set(gold, unit); @data = [gold, unit]; end def self.work(&block) origin_gold = $game_party.gold $game_party.m5_20160528_set_gold($game_variables[gold]) if unit block.call return unless unit $game_variables[gold] = $game_party.gold $game_party.m5_20160528_set_gold(origin_gold) end end M5VS20160528.init class Game_Interpreter def m5_20160528_shop(gold, unit) return unless next_event_code == 302 M5VS20160528.set(gold, unit) @index += 1 execute_command M5VS20160528.init end end class Window_Gold alias m5_20160528_value value def value M5VS20160528.unit ? $game_variables[M5VS20160528.gold] : m5_20160528_value end alias m5_20160528_unit currency_unit def currency_unit; M5VS20160528.unit || m5_20160528_unit; end end class Game_Party; def m5_20160528_set_gold(gold); @gold = gold; end; end class Scene_Shop alias m5_20140318_do_buy do_buy def do_buy(number); M5VS20160528.work{ m5_20140318_do_buy(number) }; end alias m5_20140318_do_sell do_sell def do_sell(number); M5VS20160528.work{ m5_20140318_do_sell(number) }; end alias m5_20140318_selling_price selling_price def selling_price return m5_20140318_selling_price unless M5VS20160528.unit return m5_20140318_selling_price if M5VS20160528::EQUAL p = buying_price || 0 p / 2 end end
=begin =============================================================================== 高价回收物品的商店 By喵呜喵5 =============================================================================== 【说明】 指定的开关打开时,事件指令中的商店处理会进入特定的物品回收商店 在物品回收商店中无法购买物品,只能贩卖物品 物品的售价则为商店处理中设置的物品价格(而非数据库中设置的价格) =end $m5script ||= {} $m5script[:M5SS20151022] = 20151022 module M5SS20151022 #============================================================================== # 设定部分 #============================================================================== SWI = 1 #这里设置一个开关ID,当开关打开时使用商店处理将进入物品回收商店 SHOW1 = true # true / false #设置为true时,在物品回收商店也能以正常价格(原价除2)贩卖没有设置价格的物品 SHOW2 = false # true / false #设置为true时,在物品回收商店中也会显示玩家不拥有但有设置价格的物品 #============================================================================== # 设定结束 #============================================================================== class Sell < Window_ShopSell attr_writer :shop_goods def initialize *args super *args @shop_goods = [] end def make_item_list @data = [] @price = {} @shop_goods.each do |goods| item = ( case goods[0] when 0 then $data_items when 1 then $data_weapons when 2 then $data_armors end )[ goods[1] ] if item next unless include?(item) @data << item @price[item] = goods[2] == 0 ? item.price : goods[3] end end if SHOW1 @data += $game_party.all_items.select {|item| include?(item)} @data.uniq! end @data = @data.select{|item| $game_party.has_item?(item)} unless SHOW2 @data.push(nil) if include?(nil) end def enable?(item) item && (@price[item] ? @price[item] > 0 : item.price > 0) && $game_party.has_item?(item) end end class Command < Window_ShopCommand def col_max; @list.size; end def make_command_list super @list.delete_if { |command| command[:symbol] == :buy } end end Scene_Clone = Scene_Shop.clone class Scene_Clone Window_ShopCommand = M5SS20151022::Command Window_ShopSell = M5SS20151022::Sell end class Scene < Scene_Clone def create_sell_window super @sell_window.shop_goods = @goods end def selling_price; buying_price || super; end end end # module M5SS20151022 class Game_Interpreter alias m5_20140320_command_302 command_302 def command_302 temp_scene = Scene_Shop if $game_switches[M5SS20151022::SWI] Object.const_set(:Scene_Shop, M5SS20151022::Scene) ( @params = @params.clone )[4] = false end m5_20140320_command_302 Object.const_set(:Scene_Shop, temp_scene) end end
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |