查看: 2033|回复: 2

[已经解决] 求大神修改物品丢弃脚本

[复制链接]
梦石
0
星屑
65
在线时间
232 小时
注册时间
2014-8-1
回帖
131

开拓者

发表于 2015-2-1 21:04:43 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 RyanBern 于 2015-2-1 21:14 编辑

那位大神帮我修改修改这个物品丢弃!比如一个非常重要的东西丢弃了整个游戏都进行不下去之类的事情!怎么办,所以我想大神们帮我添加一个无法丢弃的项目


  1. class Window_ItemCommand < Window_Command
  2.   attr_accessor :calling_window
  3.   def initialize(width, commands)
  4.     super(width, commands)
  5.     @item = nil
  6.     @calling_window = nil
  7.     self.z = 120
  8.     self.active = false
  9.     self.visible = false
  10.   end
  11.   def item=(item)
  12.     @item = item
  13.     refresh
  14.   end
  15.   def refresh
  16.     self.contents.clear
  17.     (0...@item_max).each do |i|
  18.       draw_item(i, normal_color)
  19.     end
  20.     unless @item.is_a?(RPG::Item) && $game_party.item_can_use?(@item.id)
  21.       disable_item(0)
  22.     end
  23.   end
  24.   def adjust_position
  25.     if @calling_window.nil?
  26.       return
  27.     end
  28.     if @calling_window.cursor_y + 32 + self.height < 480
  29.       self.y = @calling_window.cursor_y + 32
  30.     else
  31.       self.y = @calling_window.cursor_y - self.height
  32.     end
  33.     self.x = @calling_window.cursor_x
  34.   end
  35. end

  36. class Window_Selectable
  37.   def cursor_x
  38.     cursor_width = self.width / @column_max - 32
  39.     x = @index % @column_max * (cursor_width + 32) + self.x + 16
  40.     return x
  41.   end
  42.   def cursor_y
  43.     y = @index / @column_max * 32 - self.oy + self.y + 16
  44.     return y
  45.   end
  46. end


  47. class Window_Dump < Window_Base
  48.   def initialize
  49.     super(0, 0, 176, 96)
  50.     self.contents = Bitmap.new(width - 32, height - 32)
  51.     self.x = 320 - width / 2
  52.     self.y = 240 - height / 2
  53.     self.z = 200
  54.     self.active = false
  55.     self.visible = false
  56.     @number = 1
  57.   end
  58.   def set(max)
  59.     @max = max
  60.     @number = 1
  61.     refresh
  62.   end
  63.   def number
  64.     return @number
  65.   end
  66.   def refresh
  67.     self.contents.clear
  68.     self.contents.font.color = system_color
  69.     self.contents.draw_text(0, 0, 144, 32, "输入丢弃个数")
  70.     self.contents.font.color = normal_color
  71.     self.contents.draw_text(72, 32, 32, 32, "×")
  72.     self.contents.draw_text(104, 32, 24, 32, @number.to_s, 2)
  73.     self.cursor_rect.set(100, 32, 32, 32)
  74.   end
  75.   def update
  76.     super
  77.     if self.active
  78.       # 光标右 (+1)
  79.       if Input.repeat?(Input::RIGHT) and @number < @max
  80.         $game_system.se_play($data_system.cursor_se)
  81.         @number += 1
  82.         refresh
  83.       end
  84.       # 光标左 (-1)
  85.       if Input.repeat?(Input::LEFT) and @number > 1
  86.         $game_system.se_play($data_system.cursor_se)
  87.         @number -= 1
  88.         refresh
  89.       end
  90.       # 光标上 (+10)
  91.       if Input.repeat?(Input::UP) and @number < @max
  92.         $game_system.se_play($data_system.cursor_se)
  93.         @number = [@number + 10, @max].min
  94.         refresh
  95.       end
  96.       # 光标下 (-10)
  97.       if Input.repeat?(Input::DOWN) and @number > 1
  98.         $game_system.se_play($data_system.cursor_se)
  99.         @number = [@number - 10, 1].max
  100.         refresh
  101.       end
  102.     end
  103.   end
  104. end


  105. class Scene_Item
  106.   alias rb_main main
  107.   def main
  108.     @dump_window = Window_Dump.new
  109.     @command_window = Window_ItemCommand.new(108, ["使用", "丢弃"])
  110.     rb_main
  111.     @dump_window.dispose
  112.     @command_window.dispose
  113.   end
  114.   def update
  115.     @command_window.calling_window = @item_window
  116.     @dump_window.update
  117.     @command_window.update
  118.     @help_window.update
  119.     @item_window.update
  120.     @target_window.update
  121.     if @item_window.active
  122.       update_item
  123.       return
  124.     end
  125.     if @target_window.active
  126.       update_target
  127.       return
  128.     end
  129.     if @command_window.active
  130.       update_command
  131.       return
  132.     end
  133.     if @dump_window.active
  134.       update_dump
  135.       return
  136.     end
  137.   end
  138.   def update_item
  139.     if Input.trigger?(Input::B)
  140.       $game_system.se_play($data_system.cancel_se)
  141.       $scene = Scene_Menu.new(0)
  142.       return
  143.     end
  144.     if Input.trigger?(Input::C)
  145.       @item = @item_window.item
  146.       if @item.nil?
  147.         $game_system.se_play($data_system.buzzer_se)
  148.         return
  149.       end
  150.       $game_system.se_play($data_system.decision_se)
  151.       @command_window.item = @item
  152.       @command_window.adjust_position
  153.       @command_window.index = 0
  154.       @command_window.active = true
  155.       @command_window.visible = true
  156.       @item_window.active = false
  157.       return
  158.     end
  159.   end
  160.   def update_command
  161.     if Input.trigger?(Input::B)
  162.       $game_system.se_play($data_system.cancel_se)
  163.       @command_window.visible = false
  164.       @command_window.active = false
  165.       @item_window.active = true
  166.       return
  167.     end
  168.     if Input.trigger?(Input::C)
  169.       case @command_window.index
  170.       when 0
  171.         unless @item.is_a?(RPG::Item) && $game_party.item_can_use?(@item.id)
  172.           $game_system.se_play($data_system.buzzer_se)
  173.           return
  174.         end
  175.         $game_system.se_play($data_system.decision_se)
  176.         if @item.scope >= 3
  177.           @command_window.active = false
  178.           @command_window.visible = false
  179.           @target_window.x = (@item_window.index + 1) % 2 * 304
  180.           @target_window.visible = true
  181.           @target_window.active = true
  182.           if @item.scope == 4 || @item.scope == 6
  183.             @target_window.index = -1
  184.           else
  185.             @target_window.index = 0
  186.           end
  187.         else
  188.           if @item.common_event_id > 0
  189.             $game_temp.common_event_id = @item.common_event_id
  190.             $game_system.se_play(@item.menu_se)
  191.             if @item.consumable
  192.               $game_party.lose_item(@item.id, 1)
  193.               @item_window.draw_item(@item_window.index)
  194.             end
  195.             $scene = Scene_Map.new
  196.             return
  197.           end
  198.         end
  199.       when 1
  200.         case @item
  201.         when RPG::Item
  202.           number = $game_party.item_number(@item.id)
  203.         when RPG::Weapon
  204.           number = $game_party.weapon_number(@item.id)
  205.         when RPG::Armor
  206.           number = $game_party.weapon_number(@item.id)
  207.         end
  208.         $game_system.se_play($data_system.decision_se)
  209.         @dump_window.set(number)
  210.         @dump_window.visible = true
  211.         @dump_window.active = true
  212.         @command_window.visible = false
  213.         @command_window.active = false
  214.       end
  215.     end
  216.     return
  217.   end
  218.   def update_dump
  219.     if Input.trigger?(Input::B)
  220.       $game_system.se_play($data_system.cancel_se)
  221.       @dump_window.visible = false
  222.       @dump_window.active = false
  223.       @command_window.active = true
  224.       @command_window.visible = true
  225.       return
  226.     end
  227.     if Input.trigger?(Input::C)
  228.       $game_system.se_play($data_system.shop_se)
  229.       number = @dump_window.number
  230.       case @item
  231.       when RPG::Item
  232.         $game_party.lose_item(@item.id, number)
  233.       when RPG::Weapon
  234.         $game_party.lose_weapon(@item.id, number)
  235.       when RPG::Armor
  236.         $game_party.lose_armor(@item.id, number)
  237.       end
  238.       @dump_window.visible = false
  239.       @dump_window.active = false
  240.       @item_window.active = true
  241.       @item_window.refresh
  242.       return
  243.     end
  244.   end
  245. end
复制代码
梦石
0
星屑
9557
在线时间
5074 小时
注册时间
2013-6-21
回帖
3459

开拓者贵宾剧作品鉴家

发表于 2015-2-1 21:55:45 | 显示全部楼层
看起来应该是我写的那个脚本。因此改自己写的东西格外顺手
简单改了一下,没有测试。用法是将不可丢弃的物品/武器/防具ID写在最前面注释那里。
例如,ID为1号,3号的物品不可丢弃,就改成:NOT_FOR_DUMP_ITEMS = [1,3]

  1. module RB_ItemDump
  2.   # 不可丢弃的物品ID
  3.   NOT_FOR_DUMP_ITEMS = []
  4.   # 不可丢弃的武器ID
  5.   NOT_FOR_DUMP_WEAPONS = []
  6.   # 不可丢弃的防具ID
  7.   NOT_FOR_DUMP_ARMORS = []
  8.   def not_for_dump?(item)
  9.     case item
  10.     when RPG::Item
  11.       return NOT_FOR_DUMP_ITEMS.include?(item.id)
  12.     when RPG::Weapon
  13.       return NOT_FOR_DUMP_WEAPONS.include?(item.id)
  14.     when RPG::Armor
  15.       return NOT_FOR_DUMP_ARMORS.include?(item.id)
  16.     else
  17.       return true
  18.     end
  19.   end
  20. end
  21. class Window_ItemCommand < Window_Command
  22.   include RB_ItemDump
  23.   attr_accessor :calling_window
  24.   def initialize(width, commands)
  25.     super(width, commands)
  26.     @item = nil
  27.     @calling_window = nil
  28.     self.z = 120
  29.     self.active = false
  30.     self.visible = false
  31.   end
  32.   def item=(item)
  33.     @item = item
  34.     refresh
  35.   end
  36.   def refresh
  37.     self.contents.clear
  38.     (0...@item_max).each do |i|
  39.       draw_item(i, normal_color)
  40.     end
  41.     unless @item.is_a?(RPG::Item) && $game_party.item_can_use?(@item.id)
  42.       disable_item(0)
  43.     end
  44.     if not_for_dump?(@item)
  45.       disable_item(1)
  46.     end
  47.   end
  48.   def adjust_position
  49.     if @calling_window.nil?
  50.       return
  51.     end
  52.     if @calling_window.cursor_y + 32 + self.height < 480
  53.       self.y = @calling_window.cursor_y + 32
  54.     else
  55.       self.y = @calling_window.cursor_y - self.height
  56.     end
  57.     self.x = @calling_window.cursor_x
  58.   end
  59. end

  60. class Window_Selectable
  61.   def cursor_x
  62.     cursor_width = self.width / @column_max - 32
  63.     x = @index % @column_max * (cursor_width + 32) + self.x + 16
  64.     return x
  65.   end
  66.   def cursor_y
  67.     y = @index / @column_max * 32 - self.oy + self.y + 16
  68.     return y
  69.   end
  70. end


  71. class Window_Dump < Window_Base
  72.   def initialize
  73.     super(0, 0, 176, 96)
  74.     self.contents = Bitmap.new(width - 32, height - 32)
  75.     self.x = 320 - width / 2
  76.     self.y = 240 - height / 2
  77.     self.z = 200
  78.     self.active = false
  79.     self.visible = false
  80.     @number = 1
  81.   end
  82.   def set(max)
  83.     @max = max
  84.     @number = 1
  85.     refresh
  86.   end
  87.   def number
  88.     return @number
  89.   end
  90.   def refresh
  91.     self.contents.clear
  92.     self.contents.font.color = system_color
  93.     self.contents.draw_text(0, 0, 144, 32, "输入丢弃个数")
  94.     self.contents.font.color = normal_color
  95.     self.contents.draw_text(72, 32, 32, 32, "×")
  96.     self.contents.draw_text(104, 32, 24, 32, @number.to_s, 2)
  97.     self.cursor_rect.set(100, 32, 32, 32)
  98.   end
  99.   def update
  100.     super
  101.     if self.active
  102.       # 光标右 (+1)
  103.       if Input.repeat?(Input::RIGHT) and @number < @max
  104.         $game_system.se_play($data_system.cursor_se)
  105.         @number += 1
  106.         refresh
  107.       end
  108.       # 光标左 (-1)
  109.       if Input.repeat?(Input::LEFT) and @number > 1
  110.         $game_system.se_play($data_system.cursor_se)
  111.         @number -= 1
  112.         refresh
  113.       end
  114.       # 光标上 (+10)
  115.       if Input.repeat?(Input::UP) and @number < @max
  116.         $game_system.se_play($data_system.cursor_se)
  117.         @number = [@number + 10, @max].min
  118.         refresh
  119.       end
  120.       # 光标下 (-10)
  121.       if Input.repeat?(Input::DOWN) and @number > 1
  122.         $game_system.se_play($data_system.cursor_se)
  123.         @number = [@number - 10, 1].max
  124.         refresh
  125.       end
  126.     end
  127.   end
  128. end


  129. class Scene_Item
  130.   include RB_ItemDump
  131.   alias rb_main main
  132.   def main
  133.     @dump_window = Window_Dump.new
  134.     @command_window = Window_ItemCommand.new(108, ["使用", "丢弃"])
  135.     rb_main
  136.     @dump_window.dispose
  137.     @command_window.dispose
  138.   end
  139.   def update
  140.     @command_window.calling_window = @item_window
  141.     @dump_window.update
  142.     @command_window.update
  143.     @help_window.update
  144.     @item_window.update
  145.     @target_window.update
  146.     if @item_window.active
  147.       update_item
  148.       return
  149.     end
  150.     if @target_window.active
  151.       update_target
  152.       return
  153.     end
  154.     if @command_window.active
  155.       update_command
  156.       return
  157.     end
  158.     if @dump_window.active
  159.       update_dump
  160.       return
  161.     end
  162.   end
  163.   def update_item
  164.     if Input.trigger?(Input::B)
  165.       $game_system.se_play($data_system.cancel_se)
  166.       $scene = Scene_Menu.new(0)
  167.       return
  168.     end
  169.     if Input.trigger?(Input::C)
  170.       @item = @item_window.item
  171.       if @item.nil?
  172.         $game_system.se_play($data_system.buzzer_se)
  173.         return
  174.       end
  175.       $game_system.se_play($data_system.decision_se)
  176.       @command_window.item = @item
  177.       @command_window.adjust_position
  178.       @command_window.index = 0
  179.       @command_window.active = true
  180.       @command_window.visible = true
  181.       @item_window.active = false
  182.       return
  183.     end
  184.   end
  185.   def update_command
  186.     if Input.trigger?(Input::B)
  187.       $game_system.se_play($data_system.cancel_se)
  188.       @command_window.visible = false
  189.       @command_window.active = false
  190.       @item_window.active = true
  191.       return
  192.     end
  193.     if Input.trigger?(Input::C)
  194.       case @command_window.index
  195.       when 0
  196.         unless @item.is_a?(RPG::Item) && $game_party.item_can_use?(@item.id)
  197.           $game_system.se_play($data_system.buzzer_se)
  198.           return
  199.         end
  200.         $game_system.se_play($data_system.decision_se)
  201.         if @item.scope >= 3
  202.           @command_window.active = false
  203.           @command_window.visible = false
  204.           @target_window.x = (@item_window.index + 1) % 2 * 304
  205.           @target_window.visible = true
  206.           @target_window.active = true
  207.           if @item.scope == 4 || @item.scope == 6
  208.             @target_window.index = -1
  209.           else
  210.             @target_window.index = 0
  211.           end
  212.         else
  213.           if @item.common_event_id > 0
  214.             $game_temp.common_event_id = @item.common_event_id
  215.             $game_system.se_play(@item.menu_se)
  216.             if @item.consumable
  217.               $game_party.lose_item(@item.id, 1)
  218.               @item_window.draw_item(@item_window.index)
  219.             end
  220.             $scene = Scene_Map.new
  221.             return
  222.           end
  223.         end
  224.       when 1
  225.         if not_for_dump?(@item)
  226.           $game_system.se_play($data_system.buzzer_se)
  227.           return
  228.         end
  229.         case @item
  230.         when RPG::Item
  231.           number = $game_party.item_number(@item.id)
  232.         when RPG::Weapon
  233.           number = $game_party.weapon_number(@item.id)
  234.         when RPG::Armor
  235.           number = $game_party.weapon_number(@item.id)
  236.         end
  237.         $game_system.se_play($data_system.decision_se)
  238.         @dump_window.set(number)
  239.         @dump_window.visible = true
  240.         @dump_window.active = true
  241.         @command_window.visible = false
  242.         @command_window.active = false
  243.       end
  244.     end
  245.     return
  246.   end
  247.   def update_dump
  248.     if Input.trigger?(Input::B)
  249.       $game_system.se_play($data_system.cancel_se)
  250.       @dump_window.visible = false
  251.       @dump_window.active = false
  252.       @command_window.active = true
  253.       @command_window.visible = true
  254.       return
  255.     end
  256.     if Input.trigger?(Input::C)
  257.       $game_system.se_play($data_system.shop_se)
  258.       number = @dump_window.number
  259.       case @item
  260.       when RPG::Item
  261.         $game_party.lose_item(@item.id, number)
  262.       when RPG::Weapon
  263.         $game_party.lose_weapon(@item.id, number)
  264.       when RPG::Armor
  265.         $game_party.lose_armor(@item.id, number)
  266.       end
  267.       @dump_window.visible = false
  268.       @dump_window.active = false
  269.       @item_window.active = true
  270.       @item_window.refresh
  271.       return
  272.     end
  273.   end
  274. end
复制代码

点评

好神奇啊!谢谢大大帮我修改  发表于 2015-2-2 21:04
回复

使用道具 举报

梦石
0
星屑
65
在线时间
232 小时
注册时间
2014-8-1
回帖
131

开拓者

 楼主| 发表于 2015-2-2 20:37:54 | 显示全部楼层
RyanBern 发表于 2015-2-1 21:55
看起来应该是我写的那个脚本。因此改自己写的东西格外顺手
简单改了一下,没有测试。用法是将不可丢 ...

谢谢!大大
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部