设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1566|回复: 2
打印 上一主题 下一主题

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

[复制链接]

Lv1.梦旅人

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

开拓者

跳转到指定楼层
1
发表于 2015-2-1 21:04:43 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

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

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


RUBY 代码复制
  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.  
  37. class Window_Selectable
  38.   def cursor_x
  39.     cursor_width = self.width / @column_max - 32
  40.     x = @index % @column_max * (cursor_width + 32) + self.x + 16
  41.     return x
  42.   end
  43.   def cursor_y
  44.     y = @index / @column_max * 32 - self.oy + self.y + 16
  45.     return y
  46.   end
  47. end
  48.  
  49.  
  50. class Window_Dump < Window_Base
  51.   def initialize
  52.     super(0, 0, 176, 96)
  53.     self.contents = Bitmap.new(width - 32, height - 32)
  54.     self.x = 320 - width / 2
  55.     self.y = 240 - height / 2
  56.     self.z = 200
  57.     self.active = false
  58.     self.visible = false
  59.     @number = 1
  60.   end
  61.   def set(max)
  62.     @max = max
  63.     @number = 1
  64.     refresh
  65.   end
  66.   def number
  67.     return @number
  68.   end
  69.   def refresh
  70.     self.contents.clear
  71.     self.contents.font.color = system_color
  72.     self.contents.draw_text(0, 0, 144, 32, "输入丢弃个数")
  73.     self.contents.font.color = normal_color
  74.     self.contents.draw_text(72, 32, 32, 32, "×")
  75.     self.contents.draw_text(104, 32, 24, 32, @number.to_s, 2)
  76.     self.cursor_rect.set(100, 32, 32, 32)
  77.   end
  78.   def update
  79.     super
  80.     if self.active
  81.       # 光标右 (+1)
  82.       if Input.repeat?(Input::RIGHT) and @number < @max
  83.         $game_system.se_play($data_system.cursor_se)
  84.         @number += 1
  85.         refresh
  86.       end
  87.       # 光标左 (-1)
  88.       if Input.repeat?(Input::LEFT) and @number > 1
  89.         $game_system.se_play($data_system.cursor_se)
  90.         @number -= 1
  91.         refresh
  92.       end
  93.       # 光标上 (+10)
  94.       if Input.repeat?(Input::UP) and @number < @max
  95.         $game_system.se_play($data_system.cursor_se)
  96.         @number = [@number + 10, @max].min
  97.         refresh
  98.       end
  99.       # 光标下 (-10)
  100.       if Input.repeat?(Input::DOWN) and @number > 1
  101.         $game_system.se_play($data_system.cursor_se)
  102.         @number = [@number - 10, 1].max
  103.         refresh
  104.       end
  105.     end
  106.   end
  107. end
  108.  
  109.  
  110. class Scene_Item
  111.   alias rb_main main
  112.   def main
  113.     @dump_window = Window_Dump.new
  114.     @command_window = Window_ItemCommand.new(108, ["使用", "丢弃"])
  115.     rb_main
  116.     @dump_window.dispose
  117.     @command_window.dispose
  118.   end
  119.   def update
  120.     @command_window.calling_window = @item_window
  121.     @dump_window.update
  122.     @command_window.update
  123.     @help_window.update
  124.     @item_window.update
  125.     @target_window.update
  126.     if @item_window.active
  127.       update_item
  128.       return
  129.     end
  130.     if @target_window.active
  131.       update_target
  132.       return
  133.     end
  134.     if @command_window.active
  135.       update_command
  136.       return
  137.     end
  138.     if @dump_window.active
  139.       update_dump
  140.       return
  141.     end
  142.   end
  143.   def update_item
  144.     if Input.trigger?(Input::B)
  145.       $game_system.se_play($data_system.cancel_se)
  146.       $scene = Scene_Menu.new(0)
  147.       return
  148.     end
  149.     if Input.trigger?(Input::C)
  150.       @item = @item_window.item
  151.       if @item.nil?
  152.         $game_system.se_play($data_system.buzzer_se)
  153.         return
  154.       end
  155.       $game_system.se_play($data_system.decision_se)
  156.       @command_window.item = @item
  157.       @command_window.adjust_position
  158.       @command_window.index = 0
  159.       @command_window.active = true
  160.       @command_window.visible = true
  161.       @item_window.active = false
  162.       return
  163.     end
  164.   end
  165.   def update_command
  166.     if Input.trigger?(Input::B)
  167.       $game_system.se_play($data_system.cancel_se)
  168.       @command_window.visible = false
  169.       @command_window.active = false
  170.       @item_window.active = true
  171.       return
  172.     end
  173.     if Input.trigger?(Input::C)
  174.       case @command_window.index
  175.       when 0
  176.         unless @item.is_a?(RPG::Item) && $game_party.item_can_use?(@item.id)
  177.           $game_system.se_play($data_system.buzzer_se)
  178.           return
  179.         end
  180.         $game_system.se_play($data_system.decision_se)
  181.         if @item.scope >= 3
  182.           @command_window.active = false
  183.           @command_window.visible = false
  184.           @target_window.x = (@item_window.index + 1) % 2 * 304
  185.           @target_window.visible = true
  186.           @target_window.active = true
  187.           if @item.scope == 4 || @item.scope == 6
  188.             @target_window.index = -1
  189.           else
  190.             @target_window.index = 0
  191.           end
  192.         else
  193.           if @item.common_event_id > 0
  194.             $game_temp.common_event_id = @item.common_event_id
  195.             $game_system.se_play(@item.menu_se)
  196.             if @item.consumable
  197.               $game_party.lose_item(@item.id, 1)
  198.               @item_window.draw_item(@item_window.index)
  199.             end
  200.             $scene = Scene_Map.new
  201.             return
  202.           end
  203.         end
  204.       when 1
  205.         case @item
  206.         when RPG::Item
  207.           number = $game_party.item_number(@item.id)
  208.         when RPG::Weapon
  209.           number = $game_party.weapon_number(@item.id)
  210.         when RPG::Armor
  211.           number = $game_party.weapon_number(@item.id)
  212.         end
  213.         $game_system.se_play($data_system.decision_se)
  214.         @dump_window.set(number)
  215.         @dump_window.visible = true
  216.         @dump_window.active = true
  217.         @command_window.visible = false
  218.         @command_window.active = false
  219.       end
  220.     end
  221.     return
  222.   end
  223.   def update_dump
  224.     if Input.trigger?(Input::B)
  225.       $game_system.se_play($data_system.cancel_se)
  226.       @dump_window.visible = false
  227.       @dump_window.active = false
  228.       @command_window.active = true
  229.       @command_window.visible = true
  230.       return
  231.     end
  232.     if Input.trigger?(Input::C)
  233.       $game_system.se_play($data_system.shop_se)
  234.       number = @dump_window.number
  235.       case @item
  236.       when RPG::Item
  237.         $game_party.lose_item(@item.id, number)
  238.       when RPG::Weapon
  239.         $game_party.lose_weapon(@item.id, number)
  240.       when RPG::Armor
  241.         $game_party.lose_armor(@item.id, number)
  242.       end
  243.       @dump_window.visible = false
  244.       @dump_window.active = false
  245.       @item_window.active = true
  246.       @item_window.refresh
  247.       return
  248.     end
  249.   end
  250. end

Lv4.逐梦者 (版主)

梦石
0
星屑
9532
在线时间
5073 小时
注册时间
2013-6-21
帖子
3580

开拓者贵宾剧作品鉴家

2
发表于 2015-2-1 21:55:45 | 只看该作者
看起来应该是我写的那个脚本。因此改自己写的东西格外顺手
简单改了一下,没有测试。用法是将不可丢弃的物品/武器/防具ID写在最前面注释那里。
例如,ID为1号,3号的物品不可丢弃,就改成:NOT_FOR_DUMP_ITEMS = [1,3]
RUBY 代码复制
  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.  
  61. class Window_Selectable
  62.   def cursor_x
  63.     cursor_width = self.width / @column_max - 32
  64.     x = @index % @column_max * (cursor_width + 32) + self.x + 16
  65.     return x
  66.   end
  67.   def cursor_y
  68.     y = @index / @column_max * 32 - self.oy + self.y + 16
  69.     return y
  70.   end
  71. end
  72.  
  73.  
  74. class Window_Dump < Window_Base
  75.   def initialize
  76.     super(0, 0, 176, 96)
  77.     self.contents = Bitmap.new(width - 32, height - 32)
  78.     self.x = 320 - width / 2
  79.     self.y = 240 - height / 2
  80.     self.z = 200
  81.     self.active = false
  82.     self.visible = false
  83.     @number = 1
  84.   end
  85.   def set(max)
  86.     @max = max
  87.     @number = 1
  88.     refresh
  89.   end
  90.   def number
  91.     return @number
  92.   end
  93.   def refresh
  94.     self.contents.clear
  95.     self.contents.font.color = system_color
  96.     self.contents.draw_text(0, 0, 144, 32, "输入丢弃个数")
  97.     self.contents.font.color = normal_color
  98.     self.contents.draw_text(72, 32, 32, 32, "×")
  99.     self.contents.draw_text(104, 32, 24, 32, @number.to_s, 2)
  100.     self.cursor_rect.set(100, 32, 32, 32)
  101.   end
  102.   def update
  103.     super
  104.     if self.active
  105.       # 光标右 (+1)
  106.       if Input.repeat?(Input::RIGHT) and @number < @max
  107.         $game_system.se_play($data_system.cursor_se)
  108.         @number += 1
  109.         refresh
  110.       end
  111.       # 光标左 (-1)
  112.       if Input.repeat?(Input::LEFT) and @number > 1
  113.         $game_system.se_play($data_system.cursor_se)
  114.         @number -= 1
  115.         refresh
  116.       end
  117.       # 光标上 (+10)
  118.       if Input.repeat?(Input::UP) and @number < @max
  119.         $game_system.se_play($data_system.cursor_se)
  120.         @number = [@number + 10, @max].min
  121.         refresh
  122.       end
  123.       # 光标下 (-10)
  124.       if Input.repeat?(Input::DOWN) and @number > 1
  125.         $game_system.se_play($data_system.cursor_se)
  126.         @number = [@number - 10, 1].max
  127.         refresh
  128.       end
  129.     end
  130.   end
  131. end
  132.  
  133.  
  134. class Scene_Item
  135.   include RB_ItemDump
  136.   alias rb_main main
  137.   def main
  138.     @dump_window = Window_Dump.new
  139.     @command_window = Window_ItemCommand.new(108, ["使用", "丢弃"])
  140.     rb_main
  141.     @dump_window.dispose
  142.     @command_window.dispose
  143.   end
  144.   def update
  145.     @command_window.calling_window = @item_window
  146.     @dump_window.update
  147.     @command_window.update
  148.     @help_window.update
  149.     @item_window.update
  150.     @target_window.update
  151.     if @item_window.active
  152.       update_item
  153.       return
  154.     end
  155.     if @target_window.active
  156.       update_target
  157.       return
  158.     end
  159.     if @command_window.active
  160.       update_command
  161.       return
  162.     end
  163.     if @dump_window.active
  164.       update_dump
  165.       return
  166.     end
  167.   end
  168.   def update_item
  169.     if Input.trigger?(Input::B)
  170.       $game_system.se_play($data_system.cancel_se)
  171.       $scene = Scene_Menu.new(0)
  172.       return
  173.     end
  174.     if Input.trigger?(Input::C)
  175.       @item = @item_window.item
  176.       if @item.nil?
  177.         $game_system.se_play($data_system.buzzer_se)
  178.         return
  179.       end
  180.       $game_system.se_play($data_system.decision_se)
  181.       @command_window.item = @item
  182.       @command_window.adjust_position
  183.       @command_window.index = 0
  184.       @command_window.active = true
  185.       @command_window.visible = true
  186.       @item_window.active = false
  187.       return
  188.     end
  189.   end
  190.   def update_command
  191.     if Input.trigger?(Input::B)
  192.       $game_system.se_play($data_system.cancel_se)
  193.       @command_window.visible = false
  194.       @command_window.active = false
  195.       @item_window.active = true
  196.       return
  197.     end
  198.     if Input.trigger?(Input::C)
  199.       case @command_window.index
  200.       when 0
  201.         unless @item.is_a?(RPG::Item) && $game_party.item_can_use?(@item.id)
  202.           $game_system.se_play($data_system.buzzer_se)
  203.           return
  204.         end
  205.         $game_system.se_play($data_system.decision_se)
  206.         if @item.scope >= 3
  207.           @command_window.active = false
  208.           @command_window.visible = false
  209.           @target_window.x = (@item_window.index + 1) % 2 * 304
  210.           @target_window.visible = true
  211.           @target_window.active = true
  212.           if @item.scope == 4 || @item.scope == 6
  213.             @target_window.index = -1
  214.           else
  215.             @target_window.index = 0
  216.           end
  217.         else
  218.           if @item.common_event_id > 0
  219.             $game_temp.common_event_id = @item.common_event_id
  220.             $game_system.se_play(@item.menu_se)
  221.             if @item.consumable
  222.               $game_party.lose_item(@item.id, 1)
  223.               @item_window.draw_item(@item_window.index)
  224.             end
  225.             $scene = Scene_Map.new
  226.             return
  227.           end
  228.         end
  229.       when 1
  230.         if not_for_dump?(@item)
  231.           $game_system.se_play($data_system.buzzer_se)
  232.           return
  233.         end
  234.         case @item
  235.         when RPG::Item
  236.           number = $game_party.item_number(@item.id)
  237.         when RPG::Weapon
  238.           number = $game_party.weapon_number(@item.id)
  239.         when RPG::Armor
  240.           number = $game_party.weapon_number(@item.id)
  241.         end
  242.         $game_system.se_play($data_system.decision_se)
  243.         @dump_window.set(number)
  244.         @dump_window.visible = true
  245.         @dump_window.active = true
  246.         @command_window.visible = false
  247.         @command_window.active = false
  248.       end
  249.     end
  250.     return
  251.   end
  252.   def update_dump
  253.     if Input.trigger?(Input::B)
  254.       $game_system.se_play($data_system.cancel_se)
  255.       @dump_window.visible = false
  256.       @dump_window.active = false
  257.       @command_window.active = true
  258.       @command_window.visible = true
  259.       return
  260.     end
  261.     if Input.trigger?(Input::C)
  262.       $game_system.se_play($data_system.shop_se)
  263.       number = @dump_window.number
  264.       case @item
  265.       when RPG::Item
  266.         $game_party.lose_item(@item.id, number)
  267.       when RPG::Weapon
  268.         $game_party.lose_weapon(@item.id, number)
  269.       when RPG::Armor
  270.         $game_party.lose_armor(@item.id, number)
  271.       end
  272.       @dump_window.visible = false
  273.       @dump_window.active = false
  274.       @item_window.active = true
  275.       @item_window.refresh
  276.       return
  277.     end
  278.   end
  279. end

点评

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

使用道具 举报

Lv1.梦旅人

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

开拓者

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

谢谢!大大
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-9-22 17:35

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表