查看: 1579|回复: 1

[已经解决] 这个脚本使用后战斗时使用物品不消耗了,不知道怎么改

[复制链接]
梦石
0
星屑
12161
在线时间
4435 小时
注册时间
2014-4-11
回帖
5616

开拓者

发表于 2014-12-6 21:54:32 | 显示全部楼层 |阅读模式

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

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

×
菜单界面使用是可以消耗的。
我看了下菜单界面,里面有带这样的脚本的。

  1.             # 消耗品的情况下
  2.             if @item.consumable
  3.               # 使用的物品数减 1
  4.               if @actor==nil
  5.                 $game_party.lose_item(@item.id, 1)
  6.               else
  7.                 @actor.items.delete_at(@item_window.index)
  8.               end
复制代码


这个背包系统的战斗处理部分是不带这样的脚本内容的。
第1362行
我把上面那一段复制进去也没效果。
  1. #==============================================================================
  2. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  3. # ■ 使用方法写在发布页
  4. #==============================================================================
  5. =begin

  6. 部分可能在制作中用到的核心算法:

  7. 角色(Game_Actor):
  8. 属性:max_size,最大负重,可在游戏更改。如$game_actors[1].max_size += 1
  9. 属性:items,物品列表,只可读取,不可修改。如$a = $game_actors[1].items[0]
  10. 函数:judge_equip,判断一下是否装备正确。如果不正确就把装备设置为空
  11. 函数:gain_item(item_id, kind=1, n=true),给某角色增减物品。
  12.       item_id : 物品 ID;n: true是增加,false是减少;kind:种类,1是物品,2是武器,3是防具
  13. 函数:item_amount,返回现有负重物品数量
  14. 函数:have_item?(item),判断是否拥有某物
  15. 函数:item_full?,判断背包是不是满了


  16. 队伍(Game_Party):
  17. 属性:max_amount,最大背包中物品数量
  18. 属性:now_amount,背包中现有物品数量
  19. 函数:item_full?,判断背包是否放满
  20. 函数:refresh_item_amount,重新刷新背包中现有物品数量,发生意外的时候用

  21. =end
  22. #==============================================================================
  23. # ■ Game_Actor
  24. #------------------------------------------------------------------------------
  25. #  处理角色的类。本类在 Game_Actors 类 ($game_actors)
  26. # 的内部使用、Game_Party 类请参考 ($game_party) 。
  27. #==============================================================================
  28. class Game_Actor < Game_Battler
  29.   attr_accessor :max_size
  30.   attr_reader   :items
  31.   #--------------------------------------------------------------------------
  32.   # ● 设置
  33.   #     actor_id : 角色 ID
  34.   #--------------------------------------------------------------------------
  35.   alias final_items_setup setup
  36.   def setup(actor_id)
  37.     final_items_setup(actor_id)   
  38.     #--角色自带的物品建立
  39.     @max_size = 8
  40.     @items = []        
  41.     if @weapon_id >0
  42.       @items.push($data_weapons[@weapon_id])
  43.     end
  44.     if @armor1_id >0
  45.       @items.push($data_armors[@armor1_id])
  46.     end
  47.     if @armor2_id >0
  48.       @items.push($data_armors[@armor2_id])
  49.     end
  50.     if @armor3_id >0
  51.       @items.push($data_armors[@armor3_id])
  52.     end
  53.     if @armor4_id >0
  54.       @items.push($data_armors[@armor4_id])
  55.     end
  56.   end
  57.   #--------------------------------------------------------------------------
  58.   # ● 测试装备是否正确,如果不正确就设置为空
  59.   #--------------------------------------------------------------------------
  60.   def judge_equip
  61.     if @armor1_id>0
  62.       unless @items.include?($data_armors[@armor1_id])
  63.         @armor1_id = 0
  64.       end
  65.     end
  66.     if @armor2_id>0
  67.       unless @items.include?($data_armors[@armor2_id])
  68.         @armor2_id = 0
  69.       end
  70.     end
  71.     if @armor3_id>0
  72.       unless @items.include?($data_armors[@armor3_id])
  73.         @armor3_id = 0
  74.       end
  75.     end
  76.     if @armor4_id>0
  77.       unless @items.include?($data_armors[@armor4_id])
  78.         @armor4_id = 0
  79.       end
  80.     end
  81.     if @weapon_id>0
  82.       unless @items.include?($data_weapons[@weapon_id])
  83.         @weapon_id = 0
  84.       end
  85.     end
  86.   end
  87.   #--------------------------------------------------------------------------
  88.   # ● 增加物品 (减少)
  89.   #     item_id : 物品 ID
  90.   #     n       : true是增加,false是减少
  91.   #     kind    : 种类,1是物品,2是武器,3是防具
  92.   #--------------------------------------------------------------------------
  93.   def gain_item(item_id, kind=1, n=true)
  94.     return if item_full?
  95.     if kind == 1
  96.       if item_id > 0 and n==true
  97.         @items.push($data_items[item_id])
  98.       elsif item_id >0 and n==false
  99.         @items.delete($data_items[item_id])
  100.       end
  101.     end
  102.     if kind == 2
  103.       if item_id > 0 and n==true
  104.         @items.push($data_weapons[item_id])
  105.       elsif item_id > 0 and n==false
  106.         @items.push($data_weapons[item_id])
  107.       end
  108.     end
  109.     if kind == 3
  110.       if item_id > 0 and n==true
  111.         @items.push($data_armors[item_id])
  112.       elsif item_id > 0 and n==true
  113.         @items.push($data_armors[item_id])
  114.       end
  115.     end
  116.   end
  117.   #--------------------------------------------------------------------------
  118.   # ● 返回物品数量
  119.   #--------------------------------------------------------------------------  
  120.   def item_amount
  121.     return @items.size
  122.   end
  123.   #--------------------------------------------------------------------------
  124.   # ● 判断是否拥有物品
  125.   #--------------------------------------------------------------------------  
  126.   def have_item?(item)
  127.     return @items.include?(item)
  128.   end
  129.   #--------------------------------------------------------------------------
  130.   # ● 判断是否物品满了
  131.   #--------------------------------------------------------------------------  
  132.   def item_full?
  133.     return true if @items.size>=@max_size
  134.     return false
  135.   end
  136.   #--------------------------------------------------------------------------
  137.   # ● 变更装备
  138.   #     equip_type : 装备类型
  139.   #     id    : 武器 or 防具 ID  (0 为解除装备)
  140.   #--------------------------------------------------------------------------
  141.   def equip(equip_type, id)
  142.     case equip_type
  143.     when 0  # 武器
  144.       if id >= 0
  145.         @weapon_id = id
  146.       end
  147.     when 1  # 盾
  148.       if id >= 0
  149.         update_auto_state($data_armors[@armor1_id], $data_armors[id])
  150.         @armor1_id = id
  151.       end
  152.     when 2  # 头
  153.       if id >= 0
  154.         update_auto_state($data_armors[@armor2_id], $data_armors[id])
  155.         @armor2_id = id
  156.       end
  157.     when 3  # 身体
  158.       if id >= 0
  159.         update_auto_state($data_armors[@armor3_id], $data_armors[id])
  160.         @armor3_id = id
  161.       end
  162.     when 4  # 装饰品
  163.       if id >= 0
  164.         update_auto_state($data_armors[@armor4_id], $data_armors[id])
  165.         @armor4_id = id
  166.       end
  167.     end
  168.   end  
  169. end

  170. #==============================================================================
  171. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  172. # ■ 使用方法写在发布页
  173. #==============================================================================
  174. # ■ Game_Party
  175. #------------------------------------------------------------------------------
  176. #  处理同伴的类。包含金钱以及物品的信息。本类的实例
  177. # 请参考 $game_party。
  178. #==============================================================================

  179. class Game_Party
  180.   #--------------------------------------------------------------------------
  181.   # ● 定义实例变量
  182.   #--------------------------------------------------------------------------
  183.   attr_accessor :max_amount
  184.   attr_reader   :now_amount
  185.   #--------------------------------------------------------------------------
  186.   # ● 初始化对像
  187.   #--------------------------------------------------------------------------
  188.   alias final_item_initialize initialize
  189.   def initialize
  190.     final_item_initialize
  191.     @max_amount = 15
  192.     @now_amount = 0
  193.   end
  194.   #--------------------------------------------------------------------------
  195.   #--------------------------------------------------------------------------
  196.   def item_full?
  197.     return true if @now_amount>=@max_amount
  198.     return false
  199.   end
  200.   def refresh_item_amount
  201.     @now_amount = 0
  202.     for i in 1...$data_items.size
  203.       if $game_party.item_number(i) > 0
  204.         @now_amount += $game_party.item_number(i)
  205.       end
  206.     end
  207.     for i in 1...$data_weapons.size
  208.       if $game_party.weapon_number(i) > 0
  209.         @now_amount += $game_party.weapon_number(i)
  210.       end
  211.     end
  212.     for i in 1...$data_armors.size
  213.       if $game_party.armor_number(i) > 0
  214.         @now_amount += $game_party.armor_number(i)
  215.       end
  216.     end
  217.   end
  218.   #--------------------------------------------------------------------------
  219.   # ● 增加物品 (减少)
  220.   #     item_id : 物品 ID
  221.   #     n       : 个数
  222.   #--------------------------------------------------------------------------
  223.   def gain_item(item_id, n)
  224.     # 更新 hash 的个数数据
  225.     if item_id > 0
  226.       @items[item_id] = [[item_number(item_id) + n, 0].max, @max_amount].min
  227.       refresh_item_amount
  228.     end
  229.   end
  230.   #--------------------------------------------------------------------------
  231.   # ● 增加武器 (减少)
  232.   #     weapon_id : 武器 ID
  233.   #     n         : 个数
  234.   #--------------------------------------------------------------------------
  235.   def gain_weapon(weapon_id, n)
  236.     # 更新 hash 的个数数据
  237.     if weapon_id > 0
  238.       @weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, @max_amount].min
  239.       refresh_item_amount
  240.     end
  241.   end
  242.   #--------------------------------------------------------------------------
  243.   # ● 增加防具 (减少)
  244.   #     armor_id : 防具 ID
  245.   #     n        : 个数
  246.   #--------------------------------------------------------------------------
  247.   def gain_armor(armor_id, n)
  248.     # 更新 hash 的个数数据
  249.     if armor_id > 0
  250.       @armors[armor_id] = [[armor_number(armor_id) + n, 0].max, @max_amount].min
  251.       refresh_item_amount
  252.     end
  253.   end  
  254.   #--------------------------------------------------------------------------
  255.   # ● 判断物品可以使用
  256.   #     item_id : 物品 ID
  257.   #--------------------------------------------------------------------------
  258.   def item_can_use?(item_id)
  259.     # 物品个数为 0 的情况
  260.     #if item_number(item_id) == 0
  261.       # 不能使用
  262.       #return false
  263.     #end
  264.     # 获取可以使用的时候
  265.     occasion = $data_items[item_id].occasion
  266.     # 战斗的情况
  267.     if $game_temp.in_battle
  268.       # 可以使用时为 0 (平时) 或者是 1 (战斗时) 可以使用
  269.       return (occasion == 0 or occasion == 1)
  270.     end
  271.     # 可以使用时为 0 (平时) 或者是 2 (菜单时) 可以使用
  272.     return (occasion == 0 or occasion == 2)
  273.   end  
  274. end

  275. #==============================================================================
  276. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  277. # ■ 使用方法写在发布页
  278. #==============================================================================
  279. # ■ Window_Command
  280. #------------------------------------------------------------------------------
  281. #  一般的命令选择行窗口。
  282. #==============================================================================

  283. class Window_Command < Window_Selectable
  284.   #--------------------------------------------------------------------------
  285.   # ● 项目有效化
  286.   #     index : 项目编号
  287.   #--------------------------------------------------------------------------  
  288.   def enable_item(index)
  289.     draw_item(index, normal_color)
  290.   end
  291. end

  292. #==============================================================================
  293. # ■ Window_Item
  294. #------------------------------------------------------------------------------
  295. #  物品画面、战斗画面、显示浏览物品的窗口。
  296. #==============================================================================

  297. class Window_Item < Window_Selectable
  298.   #--------------------------------------------------------------------------
  299.   # ● 初始化对像
  300.   #--------------------------------------------------------------------------
  301.   def initialize(actor=nil)
  302.     @actor=actor
  303.     super(0, 64, 640, 416)
  304.     @column_max = 1
  305.     refresh
  306.     self.index = 0
  307.     # 战斗中的情况下将窗口移至中央并将其半透明化
  308.     if $game_temp.in_battle
  309.       self.y = 64
  310.       self.height = 256
  311.       self.back_opacity = 160
  312.     end
  313.   end
  314.   #--------------------------------------------------------------------------
  315.   # ● 获取物品
  316.   #--------------------------------------------------------------------------
  317.   def item
  318.     return @data[self.index]
  319.   end
  320.   #--------------------------------------------------------------------------
  321.   # ● 刷新
  322.   #--------------------------------------------------------------------------
  323.   def refresh
  324.     if self.contents != nil
  325.       self.contents.dispose
  326.       self.contents = nil
  327.     end
  328.     @data = []
  329.     # 添加报务

  330.     if @actor==nil   
  331.       for i in 1...$data_items.size
  332.         if $game_party.item_number(i) > 0
  333.           for pushtimes in 0...$game_party.item_number(i)
  334.             @data.push($data_items[i])
  335.           end
  336.         end
  337.       end
  338.       for i in 1...$data_weapons.size
  339.         if $game_party.weapon_number(i) > 0
  340.           for pushtimes in 0...$game_party.weapon_number(i)
  341.             @data.push($data_weapons[i])
  342.           end
  343.         end
  344.       end
  345.       for i in 1...$data_armors.size
  346.         if $game_party.armor_number(i) > 0
  347.           for pushtimes in 0...$game_party.armor_number(i)
  348.             @data.push($data_armors[i])
  349.           end
  350.         end
  351.       end
  352.     else
  353.       for i in [email]0...@actor.items.size[/email]
  354.         if @actor.items[i].is_a?(RPG::Item)
  355.           @data.push(@actor.items[i])
  356.         else         
  357.           if @actor.items[i].is_a?(RPG::Weapon) or @actor.items[i].is_a?(RPG::Armor)
  358.             if @actor.items[i].name==$data_items[@actor.items[i].id].name
  359.               @data.push($data_items[@actor.items[i].id])
  360.               next
  361.             else
  362.               @data.push(@actor.items[i])
  363.               next
  364.             end
  365.           end
  366.         end
  367.       end
  368.     end
  369.     # 如果项目数不是 0 就生成位图、重新描绘全部项目
  370.     @item_max = @data.size
  371.     if @item_max > 0
  372.       self.contents = Bitmap.new(width - 32, row_max * 32)
  373.       self.contents.font.size = 20
  374.       for i in 0...@item_max
  375.         draw_item(i)
  376.       end
  377.     end
  378.   end
  379.   #--------------------------------------------------------------------------
  380.   # ● 描绘项目
  381.   #     index : 项目编号
  382.   #--------------------------------------------------------------------------
  383.   def draw_item(index)
  384.     if @actor==nil
  385.       item = @data[index]
  386.       x = 4
  387.       y = index * 32
  388.       rect = Rect.new(x, y, self.width - 32, 32)
  389.       self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  390.       bitmap = RPG::Cache.icon(item.icon_name)
  391.       opacity = self.contents.font.color == normal_color ? 255 : 128
  392.       self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  393.       self.contents.font.size = 20
  394.       self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  395.       self.contents.font.size = 14
  396.       self.contents.draw_text(x + 150, y, 400, 42, ":"+"    ★队伍目前物品数:"+$game_party.now_amount.to_s+" / "+$game_party.max_amount.to_s, 0)
  397.     else
  398.       item = @data[index]
  399.       #if item.is_a?(RPG::Item) and
  400.         #$game_party.item_can_use?(item.id)
  401.         #self.contents.font.color = normal_color
  402.       #else
  403.         #self.contents.font.color = disabled_color
  404.       #end
  405.       x = 4
  406.       y = index * 32
  407.       rect = Rect.new(x, y, self.width - 32, 32)
  408.       self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  409.       bitmap = RPG::Cache.icon(item.icon_name)
  410.       opacity = self.contents.font.color == normal_color ? 255 : 128
  411.       self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  412.       self.contents.font.size = 20
  413.       self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  414.       self.contents.font.size = 14
  415.       self.contents.draw_text(x + 150, y, 400, 42, ":"+"    物品数量:"+@actor.item_amount.to_s+"    最大负重:"+@actor.max_size.to_s, 0)
  416.     end
  417.   end
  418.   #--------------------------------------------------------------------------
  419.   # ● 刷新帮助文本
  420.   #--------------------------------------------------------------------------
  421.   def update_help
  422.     @help_window.set_text(item)
  423.     @help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max)
  424.     #@help_window.contents.font.size = 18
  425.     #if @actor==nil
  426.     #  @help_window.set_text(self.item == nil ? ""+"    ★队伍目前物品数:"+$game_party.now_amount.to_s+" / "+$game_party.max_amount.to_s : self.item.description+"    ★队伍目前物品数:"+$game_party.now_amount.to_s+" / "+$game_party.max_amount.to_s )
  427.     #else
  428.     #  @help_window.set_text(@actor.name+"    物品数量:"+@actor.item_amount.to_s+"    最大负重:"+@actor.max_size.to_s)
  429.     #end
  430.   end
  431.   def dispose
  432.     super
  433.     @actor.judge_equip if @actor != nil
  434.   end
  435. end

  436. #==============================================================================
  437. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  438. # ■ 使用方法写在发布页
  439. #============================================================================
  440. # ■ Window_EquipItem
  441. #------------------------------------------------------------------------------
  442. #  装备画面、显示浏览变更装备的候补物品的窗口。
  443. #==============================================================================

  444. class Window_EquipItem < Window_Selectable
  445.   #--------------------------------------------------------------------------
  446.   # ● 刷新
  447.   #--------------------------------------------------------------------------
  448.   def refresh
  449.     if self.contents != nil
  450.       self.contents.dispose
  451.       self.contents = nil
  452.     end
  453.     @data = []

  454.     # 添加可以装备的武器
  455.     if @equip_type == 0
  456.       weapon_set = $data_classes[@actor.class_id].weapon_set
  457.       for item in @actor.items
  458.         if item.is_a?(RPG::Weapon) and weapon_set.include?(item.id)
  459.           @data.push(item)
  460.         end
  461.       end
  462.     end
  463.     # 添加可以装备的防具
  464.     if @equip_type != 0
  465.       armor_set = $data_classes[@actor.class_id].armor_set
  466.       for item in @actor.items
  467.         if item.is_a?(RPG::Armor) and armor_set.include?(item.id)
  468.           if item.kind == @equip_type-1
  469.             @data.push(item)
  470.           end
  471.         end
  472.       end
  473.     end
  474.     # 添加空白
  475.     @data.push(nil)
  476.     # 生成位图、描绘全部项目
  477.     @item_max = @data.size
  478.     self.contents = Bitmap.new(width - 32, row_max * 32)
  479.     for i in 0...@item_max-1
  480.       draw_item(i)
  481.     end
  482.   end
  483.   #--------------------------------------------------------------------------
  484.   # ● 项目的描绘
  485.   #     index : 项目符号
  486.   #--------------------------------------------------------------------------
  487.   def draw_item(index)
  488.     item = @data[index]
  489.     x = 4 + index % 2 * (288 + 32)
  490.     y = index / 2 * 32
  491.     bitmap = RPG::Cache.icon(item.icon_name)
  492.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
  493.     self.contents.font.color = normal_color
  494.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  495.   end
  496. end

  497. #==============================================================================
  498. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  499. # ■ 使用方法写在发布页
  500. #==============================================================================
  501. # ■ Window_ShopStatus_New
  502. #------------------------------------------------------------------------------
  503. #  商店画面、显示物品所持数与角色装备的窗口。
  504. #==============================================================================

  505. class Window_ShopStatus_New < Window_Selectable
  506.   #--------------------------------------------------------------------------
  507.   # ● 初始化对像
  508.   #--------------------------------------------------------------------------
  509.   def initialize
  510.     super(368, 128, 272, 352)
  511.     self.contents = Bitmap.new(width - 32, height - 32)
  512.     self.contents.font.size = 18
  513.     @item = nil
  514.     @item_max = $game_party.actors.size + 1
  515.     refresh
  516.   end
  517.   #--------------------------------------------------------------------------
  518.   # ● 刷新
  519.   #--------------------------------------------------------------------------
  520.   def refresh
  521.     self.contents.clear

  522.     if @item == nil
  523.       return
  524.     end
  525.     case @item
  526.     when RPG::Item
  527.       number = $game_party.item_number(@item.id)
  528.     when RPG::Weapon
  529.       number = $game_party.weapon_number(@item.id)
  530.     when RPG::Armor
  531.       number = $game_party.armor_number(@item.id)
  532.     end
  533.     self.contents.font.color = system_color
  534.     self.contents.draw_text(4, 0, 200, 32, "队伍中本物品数:")
  535.     self.contents.font.color = normal_color
  536.     self.contents.draw_text(204, 0, 32, 32, number.to_s, 2)
  537.     self.contents.font.color = system_color
  538.     self.contents.draw_text(4, 32, 200, 32, "队伍目前物品数:")
  539.     self.contents.font.color = normal_color
  540.     self.contents.draw_text(164, 32, 72, 32, $game_party.now_amount.to_s+" / "+$game_party.max_amount.to_s, 2)
  541.     #if @item.is_a?(RPG::Item)
  542.       #return
  543.     #end
  544.     # 添加装备品信息
  545.     for i in 0...$game_party.actors.size
  546.       actor = $game_party.actors[i]
  547.       self.contents.font.color = Color.new(255,255,0)
  548.       self.contents.draw_text(116, 64 + 64 * i, 132, 32, "负重: ")
  549.       self.contents.font.color = normal_color
  550.       self.contents.draw_text(164, 64 + 64 * i, 72, 32, actor.item_amount.to_s+" / "+actor.max_size.to_s,2)
  551.       # 获取当前的装备品
  552.       unless @item == nil or @item.is_a?(RPG::Item)
  553.         if @item.is_a?(RPG::Weapon)
  554.           item1 = $data_weapons[actor.weapon_id]
  555.         elsif @item.kind == 0
  556.           item1 = $data_armors[actor.armor1_id]
  557.         elsif @item.kind == 1
  558.           item1 = $data_armors[actor.armor2_id]
  559.         elsif @item.kind == 2
  560.           item1 = $data_armors[actor.armor3_id]
  561.         else
  562.           item1 = $data_armors[actor.armor4_id]
  563.         end
  564.         # 可以装备为普通文字颜色、不能装备设置为无效文字颜色
  565.         if actor.equippable?(@item)
  566.           self.contents.font.color = normal_color
  567.         else
  568.           self.contents.font.color = disabled_color
  569.         end        
  570.         # 描绘角色名字
  571.         self.contents.draw_text(4, 64 + 64 * i, 120, 32, actor.name)
  572.         # 可以装备的情况
  573.         if actor.equippable?(@item)
  574.           # 武器的情况
  575.           if @item.is_a?(RPG::Weapon)
  576.             atk1 = item1 != nil ? item1.atk : 0
  577.             atk2 = @item != nil ? @item.atk : 0
  578.             change = atk2 - atk1
  579.           end
  580.           # 防具的情况
  581.           if @item.is_a?(RPG::Armor)
  582.             pdef1 = item1 != nil ? item1.pdef : 0
  583.             mdef1 = item1 != nil ? item1.mdef : 0
  584.             pdef2 = @item != nil ? @item.pdef : 0
  585.             mdef2 = @item != nil ? @item.mdef : 0
  586.             change = pdef2 - pdef1 + mdef2 - mdef1
  587.           end
  588.           # 描绘能力值变化
  589.           self.contents.draw_text(124, 96 + 64 * i, 112, 32,
  590.             sprintf("%+d", change), 2)
  591.         end
  592.         # 描绘物品
  593.         if item1 != nil
  594.           x = 4
  595.           y = 64 + 64 * i + 32
  596.           bitmap = RPG::Cache.icon(item1.icon_name)
  597.           opacity = self.contents.font.color == normal_color ? 255 : 128
  598.           self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  599.           self.contents.draw_text(x + 28, y, 212, 32, item1.name)
  600.         end
  601.       else
  602.         self.contents.font.color = normal_color
  603.         # 描绘角色名字
  604.         self.contents.draw_text(4, 64 + 64 * i, 120, 32, actor.name)
  605.       end
  606.     end
  607.   end
  608.   #--------------------------------------------------------------------------
  609.   # ● 设置物品
  610.   #     item : 新的物品
  611.   #--------------------------------------------------------------------------
  612.   def item=(item)
  613.     if @item != item
  614.       @item = item
  615.       refresh
  616.     end
  617.   end
  618.   #--------------------------------------------------------------------------
  619.   # ● 刷新光标矩形
  620.   #--------------------------------------------------------------------------
  621.   def update_cursor_rect
  622.     if @index < 0
  623.       self.cursor_rect.empty
  624.     else
  625.       self.cursor_rect.set(0, @index * 64, self.width - 32, 64)
  626.     end
  627.   end
  628. end

  629. #==============================================================================
  630. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  631. # ■ 使用方法写在发布页
  632. #==============================================================================
  633. # ■ Scene_Menu
  634. #------------------------------------------------------------------------------
  635. #  处理菜单画面的类。
  636. #==============================================================================

  637. class Scene_Menu
  638.   #--------------------------------------------------------------------------
  639.   # ● 初始化对像
  640.   #     menu_index : 命令光标的初期位置
  641.   #--------------------------------------------------------------------------
  642.   def initialize(menu_index = 0)
  643.     @menu_index = menu_index
  644.   end
  645.   #--------------------------------------------------------------------------
  646.   # ● 主处理
  647.   #--------------------------------------------------------------------------
  648.   def main
  649.         @menu_com = Sprite.new
  650.     @menu_com.bitmap = RPG::Cache.picture("自己做背景.png")  

  651.     # 生成命令窗口
  652.     s1 = $data_system.words.item
  653.     s2 = $data_system.words.skill
  654.     s3 = $data_system.words.equip
  655.     s4 = "状态"
  656.     s5 = "存档"
  657.     s6 = "结束游戏"
  658.     @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
  659.     @command_window.index = @menu_index
  660.     @item_command_window = Window_Command.new(160,["队伍物品","个人物品"])
  661.     @item_command_window.x = 120
  662.     @item_command_window.visible = false
  663.     @item_command_window.active = false
  664.     @item_command_window.z = 999
  665.     # 同伴人数为 0 的情况下
  666.     if $game_party.actors.size == 0
  667.       # 物品、特技、装备、状态无效化
  668.       @command_window.disable_item(0)
  669.       @command_window.disable_item(1)
  670.       @command_window.disable_item(2)
  671.       @command_window.disable_item(3)
  672.     end
  673.     # 禁止存档的情况下
  674.     if $game_system.save_disabled
  675.       # 存档无效
  676.       @command_window.disable_item(4)
  677.     end
  678.     # 生成游戏时间窗口
  679.     @playtime_window = Window_PlayTime.new
  680.     @playtime_window.x = 0
  681.     @playtime_window.y = 224
  682.     # 生成步数窗口
  683.     @steps_window = Window_Steps.new
  684.     @steps_window.x = 0
  685.     @steps_window.y = 320
  686.     # 生成金钱窗口
  687.     @gold_window = Window_Gold.new
  688.     @gold_window.x = 0
  689.     @gold_window.y = 416
  690.     # 生成状态窗口
  691.     @status_window = Window_MenuStatus.new
  692.     @status_window.x = 160
  693.     @status_window.y = 0
  694.     # 执行过渡
  695.     Graphics.transition
  696.     # 主循环
  697.     loop do
  698.       # 刷新游戏画面
  699.       Graphics.update
  700.       # 刷新输入信息
  701.       Input.update
  702.       # 刷新画面
  703.       update
  704.       # 如果切换画面就中断循环
  705.       if $scene != self
  706.         break
  707.       end
  708.     end
  709.     # 准备过渡
  710.     Graphics.freeze
  711.     # 释放窗口
  712.         @menu_com.bitmap.dispose if @menu_com.bitmap  
  713.     @menu_com.dispose

  714.     @command_window.dispose
  715.     @playtime_window.dispose
  716.     @steps_window.dispose
  717.     @gold_window.dispose
  718.     @status_window.dispose
  719.     @item_command_window.dispose
  720.   end
  721.   #--------------------------------------------------------------------------
  722.   # ● 刷新画面
  723.   #--------------------------------------------------------------------------
  724.   def update
  725.     # 刷新窗口
  726.     @command_window.update
  727.     @playtime_window.update
  728.     @steps_window.update
  729.     @gold_window.update
  730.     @status_window.update
  731.     @item_command_window.update
  732.     # 命令窗口被激活的情况下: 调用 update_command
  733.     if @command_window.active
  734.       update_command
  735.       return
  736.     end
  737.     # 状态窗口被激活的情况下: 调用 update_status
  738.     if @status_window.active
  739.       update_status
  740.       return
  741.     end
  742.     if @item_command_window.active
  743.       update_item_command
  744.       return
  745.     end
  746.   end
  747.   def update_item_command
  748.     if Input.trigger?(Input::B)
  749.       $game_system.se_play($data_system.cancel_se)
  750.       @item_command_window.active = false
  751.       @item_command_window.visible = false
  752.       @command_window.active = true
  753.     end
  754.     if Input.trigger?(Input::C)
  755.       case @item_command_window.index
  756.       when 0
  757.         $game_system.se_play($data_system.decision_se)
  758.         $scene = Scene_Item.new
  759.       when 1
  760.         # 演奏确定 SE
  761.         $game_system.se_play($data_system.decision_se)
  762.         # 激活状态窗口
  763.         @item_command_window.active = false
  764.         @item_command_window.visible = false
  765.         @status_window.active = true
  766.         @status_window.index = 0
  767.       end
  768.     end
  769.   end
  770.   #--------------------------------------------------------------------------
  771.   # ● 刷新画面 (命令窗口被激活的情况下)
  772.   #--------------------------------------------------------------------------
  773.   def update_command
  774.     # 按下 B 键的情况下
  775.     if Input.trigger?(Input::B)
  776.       # 演奏取消 SE
  777.       $game_system.se_play($data_system.cancel_se)
  778.       # 切换的地图画面
  779.       $scene = Scene_Map.new
  780.       return
  781.     end
  782.     # 按下 C 键的情况下
  783.     if Input.trigger?(Input::C)
  784.       # 同伴人数为 0、存档、游戏结束以外的场合
  785.       if $game_party.actors.size == 0 and @command_window.index < 4
  786.         # 演奏冻结 SE
  787.         $game_system.se_play($data_system.buzzer_se)
  788.         return
  789.       end
  790.       # 命令窗口的光标位置分支
  791.       case @command_window.index
  792.       when 0  # 物品
  793.         # 演奏确定 SE
  794.         $game_system.se_play($data_system.decision_se)
  795.         # 激活状态窗口
  796.         @command_window.active = false
  797.         @item_command_window.active = true
  798.         @item_command_window.index = 0
  799.         @item_command_window.visible = true
  800.       when 1  # 特技
  801.         # 演奏确定 SE
  802.         $game_system.se_play($data_system.decision_se)
  803.         # 激活状态窗口
  804.         @command_window.active = false
  805.         @status_window.active = true
  806.         @status_window.index = 0
  807.       when 2  # 装备
  808.         # 演奏确定 SE
  809.         $game_system.se_play($data_system.decision_se)
  810.         # 激活状态窗口
  811.         @command_window.active = false
  812.         @status_window.active = true
  813.         @status_window.index = 0
  814.       when 3  # 状态
  815.         # 演奏确定 SE
  816.         $game_system.se_play($data_system.decision_se)
  817.         # 激活状态窗口
  818.         @command_window.active = false
  819.         @status_window.active = true
  820.         @status_window.index = 0
  821.       when 4  # 存档
  822.         # 禁止存档的情况下
  823.         if $game_system.save_disabled
  824.           # 演奏冻结 SE
  825.           $game_system.se_play($data_system.buzzer_se)
  826.           return
  827.         end
  828.         # 演奏确定 SE
  829.         $game_system.se_play($data_system.decision_se)
  830.         # 切换到存档画面
  831.         $scene = Scene_Save.new
  832.       when 5  # 游戏结束
  833.         # 演奏确定 SE
  834.         $game_system.se_play($data_system.decision_se)
  835.         # 切换到游戏结束画面
  836.         $scene = Scene_End.new
  837.       end
  838.       return
  839.     end
  840.   end
  841.   #--------------------------------------------------------------------------
  842.   # ● 刷新画面 (状态窗口被激活的情况下)
  843.   #--------------------------------------------------------------------------
  844.   def update_status
  845.     # 按下 B 键的情况下
  846.     if Input.trigger?(Input::B)
  847.       # 演奏取消 SE
  848.       $game_system.se_play($data_system.cancel_se)
  849.       # 激活命令窗口
  850.       @command_window.active = true
  851.       @status_window.active = false
  852.       @status_window.index = -1
  853.       return
  854.     end
  855.     # 按下 C 键的情况下
  856.     if Input.trigger?(Input::C)
  857.       # 命令窗口的光标位置分支
  858.       case @command_window.index
  859.       when 0  # 物品        
  860.         $game_system.se_play($data_system.decision_se)
  861.         $scene = Scene_Item.new($game_party.actors[@status_window.index])
  862.       when 1  # 特技
  863.         # 本角色的行动限制在 2 以上的情况下
  864.         if $game_party.actors[@status_window.index].restriction >= 2
  865.           # 演奏冻结 SE
  866.           $game_system.se_play($data_system.buzzer_se)
  867.           return
  868.         end
  869.         # 演奏确定 SE
  870.         $game_system.se_play($data_system.decision_se)
  871.         # 切换到特技画面
  872.         $scene = Scene_Skill.new(@status_window.index)
  873.       when 2  # 装备
  874.         # 演奏确定 SE
  875.         $game_system.se_play($data_system.decision_se)
  876.         # 切换的装备画面
  877.         $scene = Scene_Equip.new(@status_window.index)
  878.       when 3  # 状态
  879.         # 演奏确定 SE
  880.         $game_system.se_play($data_system.decision_se)
  881.         # 切换到状态画面
  882.         $scene = Scene_Status.new(@status_window.index)
  883.       end
  884.       return
  885.     end
  886.   end
  887. end

  888. #==============================================================================
  889. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  890. # ■ 使用方法写在发布页
  891. #==============================================================================
  892. # ■ Scene_Item
  893. #------------------------------------------------------------------------------
  894. #  处理物品画面的类。
  895. #==============================================================================

  896. class Scene_Item

  897.   #★——添加定义
  898.   def initialize(actor = nil)
  899.     @actor = actor
  900.   end

  901.   #--------------------------------------------------------------------------
  902.   # ● 主处理
  903.   #--------------------------------------------------------------------------
  904.   def main
  905.         @menu_com = Sprite.new
  906.     @menu_com.bitmap = RPG::Cache.picture("技能窗口.png")  

  907.     # 生成帮助窗口、物品窗口
  908.     @help_window = Window_Help.new
  909.     @item_window = Window_Item.new(@actor)
  910.     # 关联帮助窗口
  911.     @item_window.help_window = @help_window
  912.     # 生成目标窗口 (设置为不可见・不活动)
  913.     @target_window = Window_Target.new
  914.     @target_window.visible = false
  915.     @target_window.active = false
  916.     if @actor==nil
  917.       @command_window = Window_Command.new(160,["使用物品","交给他人","丢弃物品"])
  918.     else
  919.       @command_window = Window_Command.new(160,["使用物品","转交他人","丢弃物品","放回队伍"])
  920.     end
  921.     @command_window.x = 240
  922.     @command_window.y = 180
  923.     @command_window.visible = false
  924.     @command_window.active = false
  925.     @command_window.z = 999
  926.     @target_window.z = 10000
  927.     # 执行过度
  928.     Graphics.transition
  929.     # 主循环
  930.     loop do
  931.       # 刷新游戏画面
  932.       Graphics.update
  933.       # 刷新输入信息
  934.       Input.update
  935.       # 刷新画面
  936.       update
  937.       # 如果画面切换就中断循环
  938.       if $scene != self
  939.         break
  940.       end
  941.     end
  942.     # 装备过渡
  943.     Graphics.freeze
  944.     # 释放窗口
  945.         @menu_com.bitmap.dispose if @menu_com.bitmap  
  946.     @menu_com.dispose

  947.     @help_window.dispose
  948.     @item_window.dispose
  949.     @target_window.dispose
  950.     @command_window.dispose
  951.   end
  952.   #--------------------------------------------------------------------------
  953.   # ● 刷新画面
  954.   #--------------------------------------------------------------------------
  955.   def update
  956.     # 刷新窗口
  957.     @help_window.update
  958.     @item_window.update
  959.     @target_window.update
  960.     @command_window.update
  961.     # 物品窗口被激活的情况下: 调用 update_item
  962.     if @item_window.active
  963.       update_item
  964.       return
  965.     end
  966.     # 目标窗口被激活的情况下: 调用 update_target
  967.     if @target_window.active
  968.       update_target
  969.       return
  970.     end
  971.     if @command_window.active
  972.       update_command
  973.       return
  974.     end
  975.   end
  976.   #--------------------------------------------------------------------------
  977.   # ● 刷新画面
  978.   #--------------------------------------------------------------------------
  979.   def update_command
  980.     # 按下 B 键的情况下
  981.     if Input.trigger?(Input::B)
  982.       # 演奏取消 SE
  983.       $game_system.se_play($data_system.cancel_se)
  984.       # 切换到菜单画面
  985.       @command_window.visible = false
  986.       @command_window.active = false
  987.       @item_window.active = true
  988.       return
  989.     end
  990.     # 按下 C 键的情况下
  991.     if Input.trigger?(Input::C)
  992.       case @command_window.index
  993.       when 0
  994.         # 获取物品窗口当前选中的物品数据
  995.         @item = @item_window.item
  996.         # 不使用物品的情况下
  997.         if @actor == nil
  998.           $game_system.se_play($data_system.buzzer_se)
  999.           return
  1000.         end
  1001.         unless @item.is_a?(RPG::Item)
  1002.           # 演奏冻结 SE
  1003.           $game_system.se_play($data_system.buzzer_se)
  1004.           return
  1005.         end
  1006.         # 不能使用的情况下
  1007.         unless $game_party.item_can_use?(@item.id)
  1008.           # 演奏冻结 SE
  1009.           $game_system.se_play($data_system.buzzer_se)
  1010.           return
  1011.         end
  1012.         # 演奏确定 SE
  1013.         $game_system.se_play($data_system.decision_se)
  1014.         # 效果范围是我方的情况下
  1015.         if @item.scope >= 3
  1016.           # 激活目标窗口
  1017.           @command_window.active = false
  1018.           @target_window.x = (@item_window.index + 1) % 2 * 304
  1019.           @target_window.visible = true
  1020.           @target_window.active = true
  1021.           # 设置效果范围 (单体/全体) 的对应光标位置
  1022.           if @item.scope == 4 || @item.scope == 6
  1023.             @target_window.index = -1
  1024.           else
  1025.             @target_window.index = 0
  1026.           end
  1027.         # 效果在我方以外的情况下
  1028.         else
  1029.           # 公共事件 ID 有效的情况下
  1030.           if @item.common_event_id > 0
  1031.             # 预约调用公共事件
  1032.             $game_temp.common_event_id = @item.common_event_id
  1033.             # 演奏物品使用时的 SE
  1034.             $game_system.se_play(@item.menu_se)
  1035.             # 消耗品的情况下
  1036.             if @item.consumable
  1037.               # 使用的物品数减 1
  1038.               if @actor==nil
  1039.                 $game_party.lose_item(@item.id, 1)
  1040.               else
  1041.                 @actor.items.delete_at(@item_window.index)
  1042.               end
  1043.               # 再描绘物品窗口的项目
  1044.               @item_window.draw_item(@item_window.index)
  1045.             end
  1046.             # 切换到地图画面
  1047.             $scene = Scene_Map.new
  1048.             return
  1049.           end
  1050.         end
  1051.         return
  1052.       when 1
  1053.         $game_system.se_play($data_system.decision_se)
  1054.         @command_window.active = false
  1055.         @target_window.visible = true
  1056.         @target_window.index = 0
  1057.         @target_window.active = true
  1058.       when 2
  1059.         $game_system.se_play($data_system.load_se)
  1060.         if @actor != nil
  1061.           @actor.items.delete_at(@item_window.index)
  1062.           @actor.judge_equip
  1063.         else
  1064.           if @item_window.item.is_a?(RPG::Item)
  1065.             $game_party.gain_item(@item_window.item.id,-1)
  1066.           end
  1067.           if @item_window.item.is_a?(RPG::Weapon)
  1068.             $game_party.gain_weapon(@item_window.item.id,-1)
  1069.           end
  1070.           if @item_window.item.is_a?(RPG::Armor)
  1071.             $game_party.gain_armor(@item_window.item.id,-1)
  1072.           end
  1073.         end
  1074.         # 切换到菜单画面
  1075.         @command_window.visible = false
  1076.         @command_window.active = false
  1077.         @item_window.refresh
  1078.         @item_window.active = true
  1079.       when 3
  1080.         if $game_party.item_full?
  1081.           $game_system.se_play($data_system.cancel_se)
  1082.           return
  1083.         end
  1084.         $game_system.se_play($data_system.decision_se)
  1085.         if @item_window.item.is_a?(RPG::Item)
  1086.           $game_party.gain_item(@item_window.item.id,1)
  1087.         end
  1088.         if @item_window.item.is_a?(RPG::Weapon)
  1089.           $game_party.gain_weapon(@item_window.item.id,1)
  1090.         end
  1091.         if @item_window.item.is_a?(RPG::Armor)
  1092.           $game_party.gain_armor(@item_window.item.id,1)
  1093.         end
  1094.         @actor.items.delete_at(@item_window.index)
  1095.         # 切换到菜单画面
  1096.         @command_window.visible = false
  1097.         @command_window.active = false
  1098.         @item_window.refresh
  1099.         @item_window.active = true
  1100.       end
  1101.     end
  1102.   end  
  1103.   #--------------------------------------------------------------------------
  1104.   # ● 刷新画面 (物品窗口被激活的情况下)
  1105.   #--------------------------------------------------------------------------
  1106.   def update_item
  1107.     # 按下 B 键的情况下
  1108.     if Input.trigger?(Input::B)
  1109.       # 演奏取消 SE
  1110.       $game_system.se_play($data_system.cancel_se)
  1111.       # 切换到菜单画面
  1112.       $scene = Scene_Menu.new(0)
  1113.       return
  1114.     end
  1115.     # 按下 C 键的情况下
  1116.     if Input.trigger?(Input::C)
  1117.       # 获取物品窗口当前选中的物品数据
  1118.       @item = @item_window.item
  1119.       $game_system.se_play($data_system.decision_se)
  1120.       if @item.is_a?(RPG::Item) and $game_party.item_can_use?(@item.id) and @actor != nil
  1121.         @command_window.enable_item(0)
  1122.       else
  1123.         @command_window.disable_item(0)
  1124.       end
  1125.       @command_window.index = 0
  1126.       @command_window.visible = true
  1127.       @command_window.active = true
  1128.       @item_window.active = false
  1129.       return
  1130.     end
  1131.     # 按下 R 键的情况下
  1132.     if Input.trigger?(Input::R)
  1133.       $game_system.se_play($data_system.cursor_se)
  1134.       actor_index = 0
  1135.       for i in 0...$game_party.actors.size
  1136.         if @actor==$game_party.actors[i]
  1137.           actor_index = i
  1138.           break
  1139.         end
  1140.       end
  1141.       actor_index += 1
  1142.       actor_index %= $game_party.actors.size
  1143.       # 切换到别的特技画面
  1144.       $scene = Scene_Item.new($game_party.actors[actor_index])
  1145.       return
  1146.     end
  1147.     # 按下 L 键的情况下
  1148.     if Input.trigger?(Input::L)
  1149.       # 演奏光标 SE
  1150.       $game_system.se_play($data_system.cursor_se)      
  1151.       actor_index = 0
  1152.       for i in 0...$game_party.actors.size
  1153.         if @actor==$game_party.actors[i]
  1154.           actor_index = i
  1155.           break
  1156.         end
  1157.       end
  1158.       actor_index -= 1
  1159.       actor_index %= $game_party.actors.size
  1160.       # 切换到别的特技画面
  1161.       $scene = Scene_Item.new($game_party.actors[actor_index])
  1162.       return
  1163.     end
  1164.   end
  1165.   #--------------------------------------------------------------------------
  1166.   # ● 刷新画面 (目标窗口被激活的情况下)
  1167.   #--------------------------------------------------------------------------
  1168.   def update_target
  1169.     # 按下 B 键的情况下
  1170.     if Input.trigger?(Input::B)
  1171.       # 演奏取消 SE
  1172.       $game_system.se_play($data_system.cancel_se)
  1173.       # 由于物品用完而不能使用的场合
  1174.       unless $game_party.item_can_use?(@item.id)
  1175.         # 再次生成物品窗口的内容
  1176.         @item_window.refresh
  1177.       end
  1178.       # 删除目标窗口
  1179.       @command_window.active = true
  1180.       @target_window.visible = false
  1181.       @target_window.active = false
  1182.       return
  1183.     end
  1184.     # 按下 C 键的情况下
  1185.     if Input.trigger?(Input::C)
  1186.       if @command_window.index==0
  1187.         # 目标是全体的情况下
  1188.         if @target_window.index == -1
  1189.           # 对同伴全体应用物品使用效果
  1190.           used = false
  1191.           for i in $game_party.actors
  1192.             used |= i.item_effect(@item)
  1193.           end
  1194.         end
  1195.         # 目标是单体的情况下
  1196.         if @target_window.index >= 0
  1197.           # 对目标角色应用物品的使用效果
  1198.           target = $game_party.actors[@target_window.index]
  1199.           used = target.item_effect(@item)
  1200.         end
  1201.         # 使用物品的情况下
  1202.         if used
  1203.           # 演奏物品使用时的 SE
  1204.           $game_system.se_play(@item.menu_se)
  1205.           # 消耗品的情况下
  1206.           if @item.consumable

  1207.             if @actor == nil
  1208.               # 使用的物品数减 1
  1209.               $game_party.lose_item(@item.id, 1)
  1210.             else
  1211.               @actor.items.delete_at(@item_window.index)
  1212.             end

  1213.             # 再描绘物品窗口的项目
  1214.             @item_window.draw_item(@item_window.index)
  1215.           end
  1216.           # 再生成目标窗口的内容
  1217.           @target_window.refresh
  1218.           # 全灭的情况下
  1219.           if $game_party.all_dead?
  1220.             # 切换到游戏结束画面
  1221.             $scene = Scene_Gameover.new
  1222.             return
  1223.           end
  1224.           # 公共事件 ID 有效的情况下
  1225.           if @item.common_event_id > 0
  1226.             # 预约调用公共事件
  1227.             $game_temp.common_event_id = @item.common_event_id
  1228.             # 切换到地图画面
  1229.             $scene = Scene_Map.new
  1230.             return
  1231.           end
  1232.           @item_window.refresh
  1233.           @item_window.index -= 1 if @item_window.index >0
  1234.         end
  1235.         # 无法使用物品的情况下
  1236.         unless used
  1237.           # 演奏冻结 SE
  1238.           $game_system.se_play($data_system.buzzer_se)
  1239.         end
  1240.         return
  1241.       end
  1242.       if @command_window.index==1
  1243.         if $game_party.actors[@target_window.index].item_full?
  1244.           $game_system.se_play($data_system.buzzer_se)
  1245.           return
  1246.         end
  1247.         if @actor != nil
  1248.           @actor.items.delete_at(@item_window.index)
  1249.         else
  1250.           if @item_window.item.is_a?(RPG::Item)
  1251.             $game_party.lose_item(@item_window.item.id, 1)
  1252.           elsif @item_window.item.is_a?(RPG::Weapon)
  1253.             $game_party.lose_weapon(@item_window.item.id, 1)
  1254.           elsif @item_window.item.is_a?(RPG::Armor)
  1255.             $game_party.lose_armor(@item_window.item.id, 1)
  1256.           end
  1257.         end
  1258.         $game_system.se_play($data_system.decision_se)
  1259.         $game_party.actors[@target_window.index].items.push(@item_window.item)
  1260.         @item_window.refresh
  1261.         @item_window.index -= 1 if @item_window.index>0
  1262.         @item_window.active = true
  1263.         @command_window.visible = false
  1264.         @command_window.active = false
  1265.         @command_window.index = 0
  1266.         @target_window.visible = false
  1267.         @target_window.active = false
  1268.       end
  1269.     end
  1270.   end
  1271. end

  1272. #==============================================================================
  1273. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  1274. # ■ 使用方法写在发布页
  1275. #==============================================================================
  1276. # ■ Scene_Battle (分割定义 3)
  1277. #------------------------------------------------------------------------------
  1278. #  处理战斗画面的类。
  1279. #==============================================================================

  1280. class Scene_Battle
  1281.   #--------------------------------------------------------------------------
  1282.   # ● 开始选择物品
  1283.   #--------------------------------------------------------------------------
  1284.   def start_item_select
  1285.     # 无效化角色指令窗口
  1286.     @actor_command_window.active = false
  1287.     @actor_command_window.visible = false
  1288.     # 生成物品窗口
  1289.     @item_window = Window_Item.new($game_party.actors[@actor_index])
  1290.     # 关联帮助窗口
  1291.     #@item_window.help_window = @help_window
  1292.     @item_window.help_window =  Window_Help.new#★★★★★★★★★★★★
  1293.     # 无效化角色指令窗口
  1294.     @actor_command_window.active = false
  1295.     @actor_command_window.visible = false
  1296.   end
  1297.   #--------------------------------------------------------------------------
  1298.   # ● 刷新画面 (角色命令回合 : 选择物品)
  1299.   #--------------------------------------------------------------------------
  1300.   def update_phase3_item_select
  1301.     # 设置物品窗口为可视状态
  1302.     @item_window.visible = true
  1303.     # 刷新物品窗口
  1304.     @item_window.update
  1305.     # 按下 B 键的情况下
  1306.     if Input.trigger?(Input::B)
  1307.       # 演奏取消 SE
  1308.       $game_system.se_play($data_system.cancel_se)
  1309.       # 选择物品结束
  1310.       end_item_select
  1311.       return
  1312.     end
  1313.     # 按下 C 键的情况下
  1314.     if Input.trigger?(Input::C)
  1315.       # 获取物品窗口现在选择的物品资料
  1316.       @item = @item_window.item
  1317.       unless @item.is_a?(RPG::Item)
  1318.         # 演奏冻结 SE
  1319.         $game_system.se_play($data_system.buzzer_se)
  1320.         return
  1321.       end
  1322.       # 无法使用的情况下
  1323.       unless $game_party.item_can_use?(@item.id)
  1324.         # 演奏冻结 SE
  1325.         $game_system.se_play($data_system.buzzer_se)
  1326.         return
  1327.       end
  1328.       # 演奏确定 SE
  1329.       $game_system.se_play($data_system.decision_se)

  1330.       # 设置行动
  1331.       @active_battler.current_action.item_id = @item.id
  1332.       # 设置物品窗口为不可见状态
  1333.       @item_window.visible = false
  1334.           # 效果范围是敌单体的情况下
  1335.       if @item.scope == 1
  1336.         # 开始选择敌人
  1337.         start_enemy_select
  1338.       # 效果范围是我方单体的情况下
  1339.       elsif @item.scope == 3 or @item.scope == 5
  1340.         # 开始选择角色
  1341.         start_actor_select
  1342.       # 效果范围不是单体的情况下
  1343.       else
  1344.         # 物品选择结束
  1345.         end_item_select
  1346.         # 转到下一位角色的指令输入
  1347.         phase3_next_actor
  1348.       end
  1349.       return
  1350.     end
  1351.   end
  1352. end

  1353. #==============================================================================
  1354. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  1355. # ■ 使用方法写在发布页
  1356. #==============================================================================
  1357. # ■ Scene_Shop
  1358. #------------------------------------------------------------------------------
  1359. #  处理商店画面的类。
  1360. #==============================================================================

  1361. class Scene_Shop
  1362.   #--------------------------------------------------------------------------
  1363.   # ● 主处理
  1364.   #--------------------------------------------------------------------------
  1365.   def main

  1366.     @type = 0   

  1367.     # 生成帮助窗口
  1368.     #@help_window = Window_Help.new
  1369.     @help_window = Window_Help.new#★★★★★★★★★★★★★★★★
  1370.     # 生成指令窗口
  1371.     @command_window = Window_ShopCommand.new
  1372.     # 生成金钱窗口
  1373.     @gold_window = Window_Gold.new
  1374.     @gold_window.x = 480
  1375.     @gold_window.y = 64
  1376.     # 生成时间窗口
  1377.     @dummy_window = Window_Base.new(0, 128, 640, 352)
  1378.     # 生成购买窗口
  1379.     @buy_window = Window_ShopBuy.new($game_temp.shop_goods)
  1380.     @buy_window.active = false
  1381.     @buy_window.visible = false
  1382.     @buy_window.help_window = @help_window
  1383.     # 生成卖出窗口
  1384.     @sell_window = Window_ShopSell.new
  1385.     @sell_window.active = false
  1386.     @sell_window.visible = false
  1387.     @sell_window.help_window = @help_window
  1388.     # 生成状态窗口
  1389.     @status_window = Window_ShopStatus_New.new
  1390.     @status_window.visible = false
  1391.     @status_window.index = -1
  1392.     # 执行过渡
  1393.     Graphics.transition
  1394.     # 主循环
  1395.     loop do
  1396.       # 刷新游戏画面
  1397.       Graphics.update
  1398.       # 刷新输入信息
  1399.       Input.update
  1400.       # 刷新画面
  1401.       update
  1402.       # 如果画面切换的话就中断循环
  1403.       if $scene != self
  1404.         break
  1405.       end
  1406.     end
  1407.     # 准备过渡
  1408.     Graphics.freeze
  1409.     # 释放窗口
  1410.     @help_window.dispose
  1411.     @command_window.dispose
  1412.     @gold_window.dispose
  1413.     @dummy_window.dispose
  1414.     @buy_window.dispose
  1415.     @sell_window.dispose
  1416.     @status_window.dispose
  1417.   end
  1418.   #--------------------------------------------------------------------------
  1419.   # ● 刷新画面
  1420.   #--------------------------------------------------------------------------
  1421.   def update
  1422.     # 刷新窗口
  1423.     @help_window.update
  1424.     @command_window.update
  1425.     @gold_window.update
  1426.     @dummy_window.update
  1427.     @buy_window.update
  1428.     @sell_window.update
  1429.     @status_window.update
  1430.     # 指令窗口激活的情况下: 调用 update_command
  1431.     if @command_window.active
  1432.       @help_window.visible=false
  1433.       update_command
  1434.       return
  1435.     end
  1436.     # 购买窗口激活的情况下: 调用 update_buy
  1437.     if @buy_window.active
  1438. # 修改開始
  1439.       @help_window.visible=true#★★★★★★★★★★★★★★★★
  1440.       if @buy_window.item==nil#★★★★★★★★★★★★★★★★
  1441.         @help_window.visible=false#★★★★★★★★★★★★★★★★
  1442.       end #★★★★★★★★★★★★★★★★     
  1443.       update_buy
  1444.       return
  1445.     end
  1446.     # 卖出窗口激活的情况下: 调用 update_sell
  1447.     if @sell_window.active
  1448. # 修改開始
  1449.       @help_window.visible=true#★★★★★★★★★★★★★★★★
  1450.       if @sell_window.item==nil#★★★★★★★★★★★★★★★★
  1451.         @help_window.visible=false#★★★★★★★★★★★★★★★★
  1452.       end #★★★★★★★★★★★★★★★★
  1453. # 修改終了
  1454.       update_sell
  1455.       return
  1456.     end
  1457.     if @type==1
  1458. # 修改開始
  1459.       @help_window.visible=true#★★★★★★★★★★★★★★★★
  1460.       if @sell_window.item==nil#★★★★★★★★★★★★★★★★
  1461.         @help_window.visible=false#★★★★★★★★★★★★★★★★
  1462.       end #★★★★★★★★★★★★★★★★
  1463. # 修改終了
  1464.       update_st1
  1465.       return
  1466.     end
  1467.   end

  1468.   def update_st1
  1469.     if Input.trigger?(Input::B)
  1470.       $game_system.se_play($data_system.cancel_se)
  1471.       @buy_window.active = true
  1472.       @type = 0
  1473.       @status_window.index = -1
  1474.       @status_window.active = false
  1475.       return
  1476.     end
  1477.     if Input.trigger?(Input::C)
  1478.       if @status_window.index == 0        
  1479.         if $game_party.item_full?
  1480.           $game_system.se_play($data_system.cancel_se)
  1481.           return
  1482.         end        
  1483.         # 演奏商店 SE
  1484.         $game_system.se_play($data_system.shop_se)
  1485.         $game_party.lose_gold(@item.price)
  1486.         case @item
  1487.         when RPG::Item
  1488.           $game_party.gain_item(@item.id, 1)
  1489.         when RPG::Weapon
  1490.           $game_party.gain_weapon(@item.id, 1)
  1491.         when RPG::Armor
  1492.           $game_party.gain_armor(@item.id, 1)
  1493.         end
  1494.         # 刷新各窗口
  1495.         @gold_window.refresh
  1496.         @buy_window.refresh
  1497.         @status_window.refresh
  1498.         # 窗口状态转向购买模式
  1499.         @buy_window.active = true
  1500.         @buy_window.visible = true
  1501.         @status_window.active = false
  1502.         @status_window.index = -1
  1503.         @type = 0
  1504.       else
  1505.         if $game_party.actors[@status_window.index-1].item_full?
  1506.           $game_system.se_play($data_system.cancel_se)
  1507.           return
  1508.         end        
  1509.         # 演奏商店 SE
  1510.         $game_system.se_play($data_system.shop_se)
  1511.         $game_party.lose_gold(@item.price)
  1512.         case @item
  1513.         when RPG::Item
  1514.           $game_party.actors[@status_window.index-1].gain_item(@item.id, 1)
  1515.         when RPG::Weapon
  1516.           $game_party.actors[@status_window.index-1].gain_item(@item.id, 2)
  1517.         when RPG::Armor
  1518.           $game_party.actors[@status_window.index-1].gain_item(@item.id, 3)
  1519.         end
  1520.         # 刷新各窗口
  1521.         @gold_window.refresh
  1522.         @buy_window.refresh
  1523.         @status_window.refresh
  1524.         # 窗口状态转向购买模式
  1525.         @buy_window.active = true
  1526.         @status_window.active = false
  1527.         @type = 0
  1528.         @status_window.index = -1
  1529.       end
  1530.     end
  1531.   end
  1532.   #--------------------------------------------------------------------------
  1533.   # ● 刷新画面 (指令窗口激活的情况下)
  1534.   #--------------------------------------------------------------------------
  1535.   def update_command
  1536.     # 按下 B 键的情况下
  1537.     if Input.trigger?(Input::B)
  1538.       # 演奏取消 SE
  1539.       $game_system.se_play($data_system.cancel_se)
  1540.       # 切换到地图画面
  1541.       $scene = Scene_Map.new
  1542.       return
  1543.     end
  1544.     # 按下 C 键的情况下
  1545.     if Input.trigger?(Input::C)
  1546.       # 命令窗口光标位置分支
  1547.       case @command_window.index
  1548.       when 0  # 购买
  1549.         # 演奏确定 SE
  1550.         $game_system.se_play($data_system.decision_se)
  1551.         # 窗口状态转向购买模式
  1552.         @command_window.active = false
  1553.         @dummy_window.visible = false
  1554.         @buy_window.active = true
  1555.         @buy_window.visible = true
  1556.         @buy_window.refresh
  1557.         @status_window.visible = true
  1558.       when 1  # 卖出
  1559.         # 演奏确定 SE
  1560.         $game_system.se_play($data_system.decision_se)
  1561.         # 窗口状态转向卖出模式
  1562.         @command_window.active = false
  1563.         @dummy_window.visible = false
  1564.         @sell_window.active = true
  1565.         @sell_window.visible = true
  1566.         @sell_window.refresh
  1567.       when 2  # 取消
  1568.         # 演奏确定 SE
  1569.         $game_system.se_play($data_system.decision_se)
  1570.         # 切换到地图画面
  1571.         $scene = Scene_Map.new
  1572.       end
  1573.       return
  1574.     end
  1575.   end
  1576.   #--------------------------------------------------------------------------
  1577.   # ● 刷新画面 (购买窗口激活的情况下)
  1578.   #--------------------------------------------------------------------------
  1579.   def update_buy
  1580.     # 设置状态窗口的物品
  1581.     @status_window.item = @buy_window.item
  1582.     # 按下 B 键的情况下
  1583.     if Input.trigger?(Input::B)
  1584.       # 演奏取消 SE
  1585.       $game_system.se_play($data_system.cancel_se)
  1586.       # 窗口状态转向初期模式
  1587.       @command_window.active = true
  1588.       @dummy_window.visible = true
  1589.       @buy_window.active = false
  1590.       @buy_window.visible = false
  1591.       @status_window.visible = false
  1592.       @status_window.item = nil
  1593.       # 删除帮助文本
  1594.       @help_window.set_text("")
  1595.       return
  1596.     end
  1597.     # 按下 C 键的情况下
  1598.     if Input.trigger?(Input::C)
  1599.       # 获取物品
  1600.       @item = @buy_window.item
  1601.       # 物品无效的情况下、或者价格在所持金以上的情况下
  1602.       if @item == nil or @item.price > $game_party.gold
  1603.         # 演奏冻结 SE
  1604.         $game_system.se_play($data_system.buzzer_se)
  1605.         return
  1606.       end
  1607.       # 获取物品所持数
  1608.       #case @item
  1609.       #when RPG::Item
  1610.         #number = $game_party.item_number(@item.id)
  1611.       #when RPG::Weapon
  1612.         #number = $game_party.weapon_number(@item.id)
  1613.       #when RPG::Armor
  1614.         #number = $game_party.armor_number(@item.id)
  1615.       #end
  1616.       # 如果已经拥有了 99 个情况下
  1617.       #if number == 99
  1618.         # 演奏冻结 SE
  1619.         #$game_system.se_play($data_system.buzzer_se)
  1620.         #return
  1621.       #end
  1622.       # 演奏确定 SE
  1623.       $game_system.se_play($data_system.decision_se)
  1624.       # 计算可以最多购买的数量
  1625.       #max = @item.price == 0 ? 99 : $game_party.gold / @item.price
  1626.       #max = [max, 99 - number].min
  1627.       # 窗口状态转向数值输入模式
  1628.       #@buy_window.active = false
  1629.       #@buy_window.visible = false
  1630.       #@number_window.set(@item, max, @item.price)
  1631.       #@number_window.active = true
  1632.       #@number_window.visible = true
  1633.       @buy_window.active = false
  1634.       @status_window.index = 0
  1635.       @type = 1
  1636.       @status_window.active = true
  1637.     end
  1638.   end
  1639.   #--------------------------------------------------------------------------
  1640.   # ● 画面更新 (卖出窗口激活的情况下)
  1641.   #--------------------------------------------------------------------------
  1642.   def update_sell
  1643.     # 按下 B 键的情况下
  1644.     if Input.trigger?(Input::B)
  1645.       # 演奏取消 SE
  1646.       $game_system.se_play($data_system.cancel_se)
  1647.       # 窗口状态转向初期模式
  1648.       @command_window.active = true
  1649.       @dummy_window.visible = true
  1650.       @sell_window.active = false
  1651.       @sell_window.visible = false
  1652.       @status_window.item = nil
  1653.       # 删除帮助文本
  1654.       @help_window.set_text("")
  1655.       return
  1656.     end
  1657.     # 按下 C 键的情况下
  1658.     if Input.trigger?(Input::C)
  1659.       # 获取物品
  1660.       @item = @sell_window.item
  1661.       # 设置状态窗口的物品
  1662.       @status_window.item = @item
  1663.       # 物品无效的情况下、或者价格为 0 (不能卖出) 的情况下
  1664.       if @item == nil or @item.price == 0
  1665.         # 演奏冻结 SE
  1666.         $game_system.se_play($data_system.buzzer_se)
  1667.         return
  1668.       end
  1669.       # 演奏确定 SE
  1670.       $game_system.se_play($data_system.decision_se)      
  1671.       # 卖出处理
  1672.       $game_party.gain_gold(@item.price / 2)
  1673.       case @item
  1674.       when RPG::Item
  1675.         $game_party.lose_item(@item.id, 1)
  1676.       when RPG::Weapon
  1677.         $game_party.lose_weapon(@item.id, 1)
  1678.       when RPG::Armor
  1679.         $game_party.lose_armor(@item.id, 1)
  1680.       end
  1681.       # 刷新各窗口
  1682.       @gold_window.refresh
  1683.       @sell_window.refresh
  1684.       @status_window.refresh
  1685.     end
  1686.   end
  1687. end
复制代码
梦石
0
星屑
12161
在线时间
4435 小时
注册时间
2014-4-11
回帖
5616

开拓者

 楼主| 发表于 2014-12-10 21:14:20 | 显示全部楼层
我自己已经解决
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部