Project1

标题: 如何在商店添加要出售全部的物品、武器、防具? [打印本页]

作者: jiangjie81    时间: 2013-3-3 15:34
标题: 如何在商店添加要出售全部的物品、武器、防具?
本帖最后由 jiangjie81 于 2013-3-10 18:44 编辑

求教各位大大,如何使用脚本代码,在商店里 直接添加要出售全部的物品、武器、防具?

一个一个的设定,实在是悲催!

=========
参见4楼的办法。有效。
作者: yangjunyin2002    时间: 2013-3-3 15:43
目前,我只有获得全部物品的代码
  1. for i in 0...$data_items.size
  2. $game_party.gain_item($data_items[i],50)
  3. end
  4. for i in 0...$data_weapons.size
  5. $game_party.gain_item($data_weapons[i],50)
  6. end
  7. for i in 0...$data_armors.size
  8. $game_party.gain_item($data_armors[i],50)
  9. end
复制代码
那个50可以改。就是所有物品、武器、防具给你的数量。
作者: vince3725    时间: 2013-3-3 20:47
  1. # ————————————————————————————————————
  2. # 本脚本来自www.66rpg.com,转载请保留此信息
  3. # ————————————————————————————————————
  4. #==============================================================================
  5. # ■ Scene_Warehouse
  6. #------------------------------------------------------------------------------
  7. #  商店画面  : 窗口管理
  8. #==============================================================================

  9. class Scene_Warehouse < Scene_MenuBase
  10.   #--------------------------------------------------------------------------
  11.   # ● 开始处理 :生成窗口
  12.   #--------------------------------------------------------------------------
  13.   def start
  14.     super
  15.     create_help_window
  16.     create_command_window
  17.     create_item_window
  18.     create_number_window
  19.   end
  20.   #--------------------------------------------------------------------------
  21.   # ● 生成指令窗口
  22.   #--------------------------------------------------------------------------
  23.   def create_command_window
  24.     @command_window = Window_WarehouseCommand.new(Graphics.width, @purchase_only)
  25.     @command_window.viewport = @viewport
  26.     @command_window.y = @help_window.height
  27.     @command_window.set_handler(:save,    method(:command_save))
  28.     @command_window.set_handler(:get,     method(:command_get))
  29.     @command_window.set_handler(:cancel,  method(:return_scene))
  30.   end
  31.   #--------------------------------------------------------------------------
  32.   # ● 生成物品窗口
  33.   #--------------------------------------------------------------------------
  34.   def create_item_window
  35.     y      = @command_window.y + @command_window.height
  36.     height = Graphics.height - @command_window.y - @command_window.height
  37.     width  = @help_window.width
  38.     @item_window = Window_WarehouseItem.new(0, y, width, height)
  39.    
  40.     @item_window.viewport = @viewport
  41.     @item_window.help_window = @help_window
  42.     @item_window.set_action(0)
  43.    
  44.     @item_window.set_handler(:ok,     method(:on_ok))
  45.     @item_window.set_handler(:cancel, method(:on_cancel))
  46.   end
  47.   #--------------------------------------------------------------------------
  48.   # ● 生成输入窗口
  49.   #--------------------------------------------------------------------------
  50.   def create_number_window
  51.     @number_window = Window_WarehouseNumber.new((Graphics.width - 304)/2,(Graphics.height - 72)/2,72)
  52.     @number_window.viewport = @viewport
  53.     @number_window.hide
  54.     @number_window.set_handler(:ok,     method(:on_num_ok))
  55.     @number_window.set_handler(:cancel, method(:on_num_cancel))
  56.   end

  57. #==============================================================================
  58. # ■仓库画面  : 主指令管理
  59. #==============================================================================

  60.   #--------------------------------------------------------------------------
  61.   # ● 主界面 :存入
  62.   #--------------------------------------------------------------------------
  63.   def command_save
  64.     @item_window.set_action(1)
  65.     @command_window.deactivate    # 冻结指令窗口
  66.     @item_window.activate         # 激活物品窗口
  67.     @item_window.index = 0
  68.     @item_window.refresh
  69.     @item_window.update_help
  70.   end
  71.   #--------------------------------------------------------------------------
  72.   # ● 主界面 :取出
  73.   #--------------------------------------------------------------------------
  74.   def command_get
  75.     @item_window.set_action(2)
  76.     @command_window.deactivate    # 冻结指令窗口
  77.     @item_window.activate         # 激活物品窗口
  78.     @item_window.index = 0
  79.     @item_window.refresh
  80.     @item_window.update_help
  81.   end
  82.   
  83. #==============================================================================
  84. # ■仓库画面  : 指令管理
  85. #==============================================================================
  86.   
  87.   #--------------------------------------------------------------------------
  88.   # ● 命令 :确定
  89.   #--------------------------------------------------------------------------
  90.   def on_ok
  91.     item = @item_window.get_item_now
  92.     if @item_window.enable?(item) || @item_window.action == 1
  93.       case @item_window.action
  94.         when 1
  95.           @number_window.save_item
  96.           @number_window.set(item,$game_party.item_number(item))
  97.         when 2
  98.           @number_window.save_item(false)
  99.           i = $game_party.max_item_number(item) - $game_party.item_number(item)
  100.           if i < $game_party.ware_num(item)
  101.             @number_window.set(item, i)
  102.           else
  103.             @number_window.set(item,$game_party.ware_num(item))
  104.           end
  105.       end
  106.       @item_window.deactivate
  107.       @number_window.show
  108.       @number_window.activate
  109.     else
  110.       Sound.play_buzzer
  111.       @help_window.set_text("背包内装不下了~")
  112.       @item_window.activate
  113.     end
  114.   end
  115.   #--------------------------------------------------------------------------
  116.   # ● 命令 :取消
  117.   #--------------------------------------------------------------------------
  118.   def on_cancel
  119.     @item_window.deactivate
  120.     @item_window.set_action(0)
  121.     @item_window.index = -1
  122.     @item_window.contents.clear
  123.     @command_window.activate
  124.     @help_window.clear
  125.   end
  126.   
  127. #==============================================================================
  128. # ■仓库画面  : 数值输入指令管理
  129. #==============================================================================

  130.   #--------------------------------------------------------------------------
  131.   # ● 命令 :存入确定
  132.   #--------------------------------------------------------------------------
  133.   def on_num_ok
  134.     @number_window.hide
  135.     @number_window.deactivate
  136.     case @number_window.action
  137.       when true
  138.         $game_party.ware_add(@number_window.get_item, @number_window.get_num)
  139.         $game_party.lose_item(@number_window.get_item, @number_window.get_num)
  140.       when false
  141.         $game_party.ware_del(@number_window.get_item, @number_window.get_num)
  142.         $game_party.gain_item(@number_window.get_item, @number_window.get_num)
  143.     end
  144.     # 更新画面
  145.       @item_window.refresh
  146.     if @number_window.get_num == @number_window.get_max && @item_window.index != 0
  147.       @item_window.index -= 1
  148.     end
  149.    
  150.     if @item_window.get_data == []
  151.       @command_window.activate
  152.       @item_window.deactivate
  153.       @item_window.index = -1
  154.       @help_window.clear
  155.     else
  156.       @item_window.activate
  157.     end
  158.     @command_window.refresh
  159.     @number_window.refresh
  160.   end
  161.   #--------------------------------------------------------------------------
  162.   # ● 命令 :存入取消
  163.   #--------------------------------------------------------------------------
  164.   def on_num_cancel
  165.     @number_window.refresh
  166.     @number_window.hide
  167.     @number_window.deactivate
  168.     @item_window.activate
  169.   end
  170. # 定义结束
  171. end
复制代码
  1. #encoding:utf-8
  2. # ————————————————————————————————————
  3. # 本脚本来自www.66rpg.com,转载请保留此信息
  4. # ————————————————————————————————————
  5. #==============================================================================
  6. # ■ Window_WarehouseNumber
  7. #------------------------------------------------------------------------------
  8. #  商店画面中,输入“物品买入/卖出数量”的窗口。
  9. #==============================================================================

  10. class Window_WarehouseNumber < Window_Selectable
  11.   #--------------------------------------------------------------------------
  12.   # ● 初始化对象
  13.   #--------------------------------------------------------------------------
  14.   def initialize(x, y, height)
  15.     super(x, y, window_width, height)
  16.     @item = nil
  17.     [url=home.php?mod=space&uid=25307]@Max[/url] = 1
  18.     [url=home.php?mod=space&uid=27178]@Number[/url] = 1
  19.   end
  20.   #--------------------------------------------------------------------------
  21.   # ● 获取窗口的宽度
  22.   #--------------------------------------------------------------------------
  23.   def window_width
  24.     return 304
  25.   end
  26.   #--------------------------------------------------------------------------
  27.   # ● 设置物品、最大值
  28.   #--------------------------------------------------------------------------
  29.   def set(item, max)
  30.     @item = item
  31.     @max = max
  32.     @number = 1
  33.     refresh
  34.   end
  35.   #--------------------------------------------------------------------------
  36.   # ● 设置状态
  37.   #--------------------------------------------------------------------------
  38.   def save_item(action = true)
  39.     @action = action
  40.   end
  41.   #--------------------------------------------------------------------------
  42.   # ● 取得状态
  43.   #--------------------------------------------------------------------------
  44.   def action
  45.     return @action
  46.   end
  47.   #--------------------------------------------------------------------------
  48.   # ● 获得数值
  49.   #--------------------------------------------------------------------------
  50.   def get_num
  51.     return @number
  52.   end
  53.   #--------------------------------------------------------------------------
  54.   # ● 获得物品
  55.   #--------------------------------------------------------------------------
  56.   def get_item
  57.     return @item
  58.   end
  59.   #--------------------------------------------------------------------------
  60.   # ● 获得最大值
  61.   #--------------------------------------------------------------------------
  62.   def get_max
  63.     return @max
  64.   end
  65.   #--------------------------------------------------------------------------
  66.   # ● 刷新
  67.   #--------------------------------------------------------------------------
  68.   def refresh
  69.     contents.clear
  70.     draw_item_name(@item, 0, item_y)
  71.     draw_number
  72.   end
  73.   #--------------------------------------------------------------------------
  74.   # ● 绘制数量
  75.   #--------------------------------------------------------------------------
  76.   def draw_number
  77.     change_color(normal_color)
  78.     draw_text(cursor_x - 28, item_y, 22, line_height, "×")
  79.     draw_text(cursor_x, item_y, cursor_width - 4, line_height, @number, 2)
  80.   end
  81.   #--------------------------------------------------------------------------
  82.   # ● 显示物品名称行的 Y 坐标
  83.   #--------------------------------------------------------------------------
  84.   def item_y
  85.     return 8
  86.   end
  87.   #--------------------------------------------------------------------------
  88.   # ● 获取光标的宽度
  89.   #--------------------------------------------------------------------------
  90.   def cursor_width
  91.     figures * 10 + 12
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # ● 获取光标的 X 坐标
  95.   #--------------------------------------------------------------------------
  96.   def cursor_x
  97.     contents_width - cursor_width - 4
  98.   end
  99.   #--------------------------------------------------------------------------
  100.   # ● 获取数量显示的最大列数
  101.   #--------------------------------------------------------------------------
  102.   def figures
  103.     return 2
  104.   end
  105.   #--------------------------------------------------------------------------
  106.   # ● 更新画面
  107.   #--------------------------------------------------------------------------
  108.   def update
  109.     super
  110.     if active
  111.       last_number = @number
  112.       update_number
  113.       if @number != last_number
  114.         Sound.play_cursor
  115.         refresh
  116.       end
  117.     end
  118.   end
  119.   #--------------------------------------------------------------------------
  120.   # ● 更新数量
  121.   #--------------------------------------------------------------------------
  122.   def update_number
  123.     change_number(1)   if Input.repeat?(:RIGHT)
  124.     change_number(-1)  if Input.repeat?(:LEFT)
  125.     change_number(10)  if Input.repeat?(:UP)
  126.     change_number(-10) if Input.repeat?(:DOWN)
  127.   end
  128.   #--------------------------------------------------------------------------
  129.   # ● 更改数量
  130.   #--------------------------------------------------------------------------
  131.   def change_number(amount)
  132.     @number = [[@number + amount, @max].min, 1].max
  133.   end
  134.   #--------------------------------------------------------------------------
  135.   # ● 更新光标
  136.   #--------------------------------------------------------------------------
  137.   def update_cursor
  138.     cursor_rect.set(cursor_x, item_y, cursor_width, line_height)
  139.   end
  140. end
复制代码

作者: Sion    时间: 2013-3-4 19:55
本帖最后由 Sion 于 2013-3-4 20:03 编辑
  1. goods = []
  2. $data_items.compact.each {|item| goods.push([0, item.id, 0])}
  3. $data_weapons.compact.each {|weapon| goods.push([1, weapon.id, 0])}
  4. $data_armors.compact.each {|armor| goods.push([2, armor.id, 0])}
  5. SceneManager.call(Scene_Shop)
  6. SceneManager.scene.prepare(goods, false)#设为true禁止出售
复制代码
这个代码可以插入到事件的脚本中使用,插入默认的脚本框中因为代码太长会自动换行,导致运行的时候报错。你可能需要改一改脚本输入框;或者把它写成一个方法来调用。
作者: jiangjie81    时间: 2013-3-6 11:46
用VA新工程测试了一下,真的没有药品出售。
作者: 紫苍焰    时间: 2013-3-6 16:43
本帖最后由 紫苍焰 于 2013-3-6 16:46 编辑

……
嗯,确认无解。




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