Project1

标题: 求一个调整卖价的商店 [打印本页]

作者: qknight    时间: 2014-3-20 12:15
标题: 求一个调整卖价的商店
本帖最后由 qknight 于 2014-3-20 17:42 编辑

系统默认商店只能调整买价但不能调整卖价呢,求如何也能自由调整卖价使得玩家只有在指定的商店出售物品才能卖出高价……求个这样的脚本,毕竟买卖东西多了用分歧条件就太麻烦了
作者: 喵呜喵5    时间: 2014-3-20 13:16
  1. =begin
  2. ===============================================================================
  3.   高价回收物品的商店 By喵呜喵5
  4. ===============================================================================

  5. 【说明】

  6.   指定的开关打开时,事件指令中的商店处理会进入特定的物品回收商店
  7.   
  8.   在物品回收商店中无法购买物品,只能贩卖物品
  9.   
  10.   物品的售价则为商店处理中设置的物品价格(而非数据库中设置的价格)
  11.   
  12. =end
  13. $m5script = {} if $m5script.nil?
  14. $m5script["M5SellShop"] = true
  15. module M5SellShop
  16. #==============================================================================
  17. # 设定部分
  18. #==============================================================================
  19.   
  20.   SWI = 1
  21.   
  22.   #这里设置一个开关ID,当开关打开时使用商店处理将进入物品回收商店
  23.   
  24.   LIMIT = true    # true / false
  25.   
  26.   #设置为false时,在物品回收商店也能以正常价格(原价除2)贩卖没有设置价格的物品
  27.   
  28. #==============================================================================
  29. # 设定结束
  30. #==============================================================================
  31. #==============================================================================
  32. # 脚本部分
  33. #==============================================================================
  34. end
  35. class Game_Interpreter
  36.   alias m5_20140320_command_302 command_302
  37.   def command_302
  38.     if !$game_switches[M5SellShop::SWI]
  39.       m5_20140320_command_302
  40.     else
  41.       return if $game_party.in_battle
  42.       goods = [@params]
  43.       while next_event_code == 605
  44.         [url=home.php?mod=space&uid=370741]@Index[/url] += 1
  45.         goods.push(@list[@index].parameters)
  46.       end
  47.       SceneManager.call(Scene_M5SellShop)
  48.       SceneManager.scene.prepare(goods, @params[4])
  49.       Fiber.yield
  50.     end   
  51.   end
  52. end
  53. class Window_M5SellShopCommand < Window_ShopCommand
  54.   def col_max
  55.     return 2
  56.   end
  57.   def make_command_list   
  58.     add_command(Vocab::ShopSell,   :sell)
  59.     add_command(Vocab::ShopCancel, :cancel)
  60.   end  
  61. end
  62. class Window_M5SellShop < Window_ShopSell
  63.   def initialize(x, y, width, height,shop_goods)
  64.     super(x, y, width, height)
  65.     @shop_goods = shop_goods
  66.   end
  67.   def make_item_list
  68.     @data = []
  69.     @price = {}
  70.     @shop_goods.each do |goods|
  71.       case goods[0]
  72.       when 0;  item = $data_items[goods[1]]
  73.       when 1;  item = $data_weapons[goods[1]]
  74.       when 2;  item = $data_armors[goods[1]]
  75.       end
  76.       if item
  77.         @data.push(item)
  78.         @price[item] = goods[2] == 0 ? item.price : goods[3]
  79.       end
  80.     end
  81.     @data = @data.select {|item| include?(item) }
  82.     @data.push(nil) if include?(nil)
  83.   end
  84. end
  85. class Scene_M5SellShop < Scene_Shop
  86.   def prepare(goods, purchase_only)
  87.     super(goods, false)
  88.   end
  89.   def create_command_window
  90.     @command_window = Window_M5SellShopCommand.new(@gold_window.x, @purchase_only)
  91.     @command_window.viewport = @viewport
  92.     @command_window.y = @help_window.height   
  93.     @command_window.set_handler(:sell,   method(:command_sell))
  94.     @command_window.set_handler(:cancel, method(:return_scene))
  95.   end
  96.   def create_sell_window
  97.     wy = @category_window.y + @category_window.height
  98.     wh = Graphics.height - wy
  99.     if M5SellShop::LIMIT
  100.       @sell_window = Window_M5SellShop.new(0, wy, Graphics.width, wh, @goods)
  101.     else
  102.       @sell_window = Window_ShopSell.new(0, wy, Graphics.width, wh)
  103.     end
  104.     @sell_window.viewport = @viewport
  105.     @sell_window.help_window = @help_window
  106.     @sell_window.hide
  107.     @sell_window.set_handler(:ok,     method(:on_sell_ok))
  108.     @sell_window.set_handler(:cancel, method(:on_sell_cancel))
  109.     @category_window.item_window = @sell_window
  110.   end
  111.   def selling_price
  112.     return buying_price if buying_price   
  113.     super
  114.   end
  115. end
复制代码

作者: qknight    时间: 2014-3-20 17:38
本帖最后由 qknight 于 2014-3-20 17:42 编辑
喵呜喵5 发表于 2014-3-20 13:16


已经没问题了,感谢老师的指点




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1