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

Project1

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

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

[复制链接]

Lv4.逐梦者

梦石
0
星屑
12157
在线时间
4435 小时
注册时间
2014-4-11
帖子
5955

开拓者

跳转到指定楼层
1
发表于 2014-12-6 21:54:32 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

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

RUBY 代码复制
  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行
我把上面那一段复制进去也没效果。
RUBY 代码复制
  1. #==============================================================================
  2. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  3. # ■ 使用方法写在发布页
  4. #==============================================================================
  5. =begin
  6.  
  7. 部分可能在制作中用到的核心算法:
  8.  
  9. 角色(Game_Actor):
  10. 属性:max_size,最大负重,可在游戏更改。如$game_actors[1].max_size += 1
  11. 属性:items,物品列表,只可读取,不可修改。如$a = $game_actors[1].items[0]
  12. 函数:judge_equip,判断一下是否装备正确。如果不正确就把装备设置为空
  13. 函数:gain_item(item_id, kind=1, n=true),给某角色增减物品。
  14.       item_id : 物品 ID;n: true是增加,false是减少;kind:种类,1是物品,2是武器,3是防具
  15. 函数:item_amount,返回现有负重物品数量
  16. 函数:have_item?(item),判断是否拥有某物
  17. 函数:item_full?,判断背包是不是满了
  18.  
  19.  
  20. 队伍(Game_Party):
  21. 属性:max_amount,最大背包中物品数量
  22. 属性:now_amount,背包中现有物品数量
  23. 函数:item_full?,判断背包是否放满
  24. 函数:refresh_item_amount,重新刷新背包中现有物品数量,发生意外的时候用
  25.  
  26. =end
  27. #==============================================================================
  28. # ■ Game_Actor
  29. #------------------------------------------------------------------------------
  30. #  处理角色的类。本类在 Game_Actors 类 ($game_actors)
  31. # 的内部使用、Game_Party 类请参考 ($game_party) 。
  32. #==============================================================================
  33. class Game_Actor < Game_Battler
  34.   attr_accessor :max_size
  35.   attr_reader   :items
  36.   #--------------------------------------------------------------------------
  37.   # ● 设置
  38.   #     actor_id : 角色 ID
  39.   #--------------------------------------------------------------------------
  40.   alias final_items_setup setup
  41.   def setup(actor_id)
  42.     final_items_setup(actor_id)   
  43.     #--角色自带的物品建立
  44.     @max_size = 8
  45.     @items = []        
  46.     if @weapon_id >0
  47.       @items.push($data_weapons[@weapon_id])
  48.     end
  49.     if @armor1_id >0
  50.       @items.push($data_armors[@armor1_id])
  51.     end
  52.     if @armor2_id >0
  53.       @items.push($data_armors[@armor2_id])
  54.     end
  55.     if @armor3_id >0
  56.       @items.push($data_armors[@armor3_id])
  57.     end
  58.     if @armor4_id >0
  59.       @items.push($data_armors[@armor4_id])
  60.     end
  61.   end
  62.   #--------------------------------------------------------------------------
  63.   # ● 测试装备是否正确,如果不正确就设置为空
  64.   #--------------------------------------------------------------------------
  65.   def judge_equip
  66.     if @armor1_id>0
  67.       unless @items.include?($data_armors[@armor1_id])
  68.         @armor1_id = 0
  69.       end
  70.     end
  71.     if @armor2_id>0
  72.       unless @items.include?($data_armors[@armor2_id])
  73.         @armor2_id = 0
  74.       end
  75.     end
  76.     if @armor3_id>0
  77.       unless @items.include?($data_armors[@armor3_id])
  78.         @armor3_id = 0
  79.       end
  80.     end
  81.     if @armor4_id>0
  82.       unless @items.include?($data_armors[@armor4_id])
  83.         @armor4_id = 0
  84.       end
  85.     end
  86.     if @weapon_id>0
  87.       unless @items.include?($data_weapons[@weapon_id])
  88.         @weapon_id = 0
  89.       end
  90.     end
  91.   end
  92.   #--------------------------------------------------------------------------
  93.   # ● 增加物品 (减少)
  94.   #     item_id : 物品 ID
  95.   #     n       : true是增加,false是减少
  96.   #     kind    : 种类,1是物品,2是武器,3是防具
  97.   #--------------------------------------------------------------------------
  98.   def gain_item(item_id, kind=1, n=true)
  99.     return if item_full?
  100.     if kind == 1
  101.       if item_id > 0 and n==true
  102.         @items.push($data_items[item_id])
  103.       elsif item_id >0 and n==false
  104.         @items.delete($data_items[item_id])
  105.       end
  106.     end
  107.     if kind == 2
  108.       if item_id > 0 and n==true
  109.         @items.push($data_weapons[item_id])
  110.       elsif item_id > 0 and n==false
  111.         @items.push($data_weapons[item_id])
  112.       end
  113.     end
  114.     if kind == 3
  115.       if item_id > 0 and n==true
  116.         @items.push($data_armors[item_id])
  117.       elsif item_id > 0 and n==true
  118.         @items.push($data_armors[item_id])
  119.       end
  120.     end
  121.   end
  122.   #--------------------------------------------------------------------------
  123.   # ● 返回物品数量
  124.   #--------------------------------------------------------------------------  
  125.   def item_amount
  126.     return @items.size
  127.   end
  128.   #--------------------------------------------------------------------------
  129.   # ● 判断是否拥有物品
  130.   #--------------------------------------------------------------------------  
  131.   def have_item?(item)
  132.     return @items.include?(item)
  133.   end
  134.   #--------------------------------------------------------------------------
  135.   # ● 判断是否物品满了
  136.   #--------------------------------------------------------------------------  
  137.   def item_full?
  138.     return true if @items.size>=@max_size
  139.     return false
  140.   end
  141.   #--------------------------------------------------------------------------
  142.   # ● 变更装备
  143.   #     equip_type : 装备类型
  144.   #     id    : 武器 or 防具 ID  (0 为解除装备)
  145.   #--------------------------------------------------------------------------
  146.   def equip(equip_type, id)
  147.     case equip_type
  148.     when 0  # 武器
  149.       if id >= 0
  150.         @weapon_id = id
  151.       end
  152.     when 1  # 盾
  153.       if id >= 0
  154.         update_auto_state($data_armors[@armor1_id], $data_armors[id])
  155.         @armor1_id = id
  156.       end
  157.     when 2  # 头
  158.       if id >= 0
  159.         update_auto_state($data_armors[@armor2_id], $data_armors[id])
  160.         @armor2_id = id
  161.       end
  162.     when 3  # 身体
  163.       if id >= 0
  164.         update_auto_state($data_armors[@armor3_id], $data_armors[id])
  165.         @armor3_id = id
  166.       end
  167.     when 4  # 装饰品
  168.       if id >= 0
  169.         update_auto_state($data_armors[@armor4_id], $data_armors[id])
  170.         @armor4_id = id
  171.       end
  172.     end
  173.   end  
  174. end
  175.  
  176. #==============================================================================
  177. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  178. # ■ 使用方法写在发布页
  179. #==============================================================================
  180. # ■ Game_Party
  181. #------------------------------------------------------------------------------
  182. #  处理同伴的类。包含金钱以及物品的信息。本类的实例
  183. # 请参考 $game_party。
  184. #==============================================================================
  185.  
  186. class Game_Party
  187.   #--------------------------------------------------------------------------
  188.   # ● 定义实例变量
  189.   #--------------------------------------------------------------------------
  190.   attr_accessor :max_amount
  191.   attr_reader   :now_amount
  192.   #--------------------------------------------------------------------------
  193.   # ● 初始化对像
  194.   #--------------------------------------------------------------------------
  195.   alias final_item_initialize initialize
  196.   def initialize
  197.     final_item_initialize
  198.     @max_amount = 15
  199.     @now_amount = 0
  200.   end
  201.   #--------------------------------------------------------------------------
  202.   #--------------------------------------------------------------------------
  203.   def item_full?
  204.     return true if @now_amount>=@max_amount
  205.     return false
  206.   end
  207.   def refresh_item_amount
  208.     @now_amount = 0
  209.     for i in 1...$data_items.size
  210.       if $game_party.item_number(i) > 0
  211.         @now_amount += $game_party.item_number(i)
  212.       end
  213.     end
  214.     for i in 1...$data_weapons.size
  215.       if $game_party.weapon_number(i) > 0
  216.         @now_amount += $game_party.weapon_number(i)
  217.       end
  218.     end
  219.     for i in 1...$data_armors.size
  220.       if $game_party.armor_number(i) > 0
  221.         @now_amount += $game_party.armor_number(i)
  222.       end
  223.     end
  224.   end
  225.   #--------------------------------------------------------------------------
  226.   # ● 增加物品 (减少)
  227.   #     item_id : 物品 ID
  228.   #     n       : 个数
  229.   #--------------------------------------------------------------------------
  230.   def gain_item(item_id, n)
  231.     # 更新 hash 的个数数据
  232.     if item_id > 0
  233.       @items[item_id] = [[item_number(item_id) + n, 0].max, @max_amount].min
  234.       refresh_item_amount
  235.     end
  236.   end
  237.   #--------------------------------------------------------------------------
  238.   # ● 增加武器 (减少)
  239.   #     weapon_id : 武器 ID
  240.   #     n         : 个数
  241.   #--------------------------------------------------------------------------
  242.   def gain_weapon(weapon_id, n)
  243.     # 更新 hash 的个数数据
  244.     if weapon_id > 0
  245.       @weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, @max_amount].min
  246.       refresh_item_amount
  247.     end
  248.   end
  249.   #--------------------------------------------------------------------------
  250.   # ● 增加防具 (减少)
  251.   #     armor_id : 防具 ID
  252.   #     n        : 个数
  253.   #--------------------------------------------------------------------------
  254.   def gain_armor(armor_id, n)
  255.     # 更新 hash 的个数数据
  256.     if armor_id > 0
  257.       @armors[armor_id] = [[armor_number(armor_id) + n, 0].max, @max_amount].min
  258.       refresh_item_amount
  259.     end
  260.   end  
  261.   #--------------------------------------------------------------------------
  262.   # ● 判断物品可以使用
  263.   #     item_id : 物品 ID
  264.   #--------------------------------------------------------------------------
  265.   def item_can_use?(item_id)
  266.     # 物品个数为 0 的情况
  267.     #if item_number(item_id) == 0
  268.       # 不能使用
  269.       #return false
  270.     #end
  271.     # 获取可以使用的时候
  272.     occasion = $data_items[item_id].occasion
  273.     # 战斗的情况
  274.     if $game_temp.in_battle
  275.       # 可以使用时为 0 (平时) 或者是 1 (战斗时) 可以使用
  276.       return (occasion == 0 or occasion == 1)
  277.     end
  278.     # 可以使用时为 0 (平时) 或者是 2 (菜单时) 可以使用
  279.     return (occasion == 0 or occasion == 2)
  280.   end  
  281. end
  282.  
  283. #==============================================================================
  284. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  285. # ■ 使用方法写在发布页
  286. #==============================================================================
  287. # ■ Window_Command
  288. #------------------------------------------------------------------------------
  289. #  一般的命令选择行窗口。
  290. #==============================================================================
  291.  
  292. class Window_Command < Window_Selectable
  293.   #--------------------------------------------------------------------------
  294.   # ● 项目有效化
  295.   #     index : 项目编号
  296.   #--------------------------------------------------------------------------  
  297.   def enable_item(index)
  298.     draw_item(index, normal_color)
  299.   end
  300. end
  301.  
  302. #==============================================================================
  303. # ■ Window_Item
  304. #------------------------------------------------------------------------------
  305. #  物品画面、战斗画面、显示浏览物品的窗口。
  306. #==============================================================================
  307.  
  308. class Window_Item < Window_Selectable
  309.   #--------------------------------------------------------------------------
  310.   # ● 初始化对像
  311.   #--------------------------------------------------------------------------
  312.   def initialize(actor=nil)
  313.     @actor=actor
  314.     super(0, 64, 640, 416)
  315.     @column_max = 1
  316.     refresh
  317.     self.index = 0
  318.     # 战斗中的情况下将窗口移至中央并将其半透明化
  319.     if $game_temp.in_battle
  320.       self.y = 64
  321.       self.height = 256
  322.       self.back_opacity = 160
  323.     end
  324.   end
  325.   #--------------------------------------------------------------------------
  326.   # ● 获取物品
  327.   #--------------------------------------------------------------------------
  328.   def item
  329.     return @data[self.index]
  330.   end
  331.   #--------------------------------------------------------------------------
  332.   # ● 刷新
  333.   #--------------------------------------------------------------------------
  334.   def refresh
  335.     if self.contents != nil
  336.       self.contents.dispose
  337.       self.contents = nil
  338.     end
  339.     @data = []
  340.     # 添加报务
  341.  
  342.     if @actor==nil   
  343.       for i in 1...$data_items.size
  344.         if $game_party.item_number(i) > 0
  345.           for pushtimes in 0...$game_party.item_number(i)
  346.             @data.push($data_items[i])
  347.           end
  348.         end
  349.       end
  350.       for i in 1...$data_weapons.size
  351.         if $game_party.weapon_number(i) > 0
  352.           for pushtimes in 0...$game_party.weapon_number(i)
  353.             @data.push($data_weapons[i])
  354.           end
  355.         end
  356.       end
  357.       for i in 1...$data_armors.size
  358.         if $game_party.armor_number(i) > 0
  359.           for pushtimes in 0...$game_party.armor_number(i)
  360.             @data.push($data_armors[i])
  361.           end
  362.         end
  363.       end
  364.     else
  365.       for i in [email]0...@actor.items.size[/email]
  366.         if @actor.items[i].is_a?(RPG::Item)
  367.           @data.push(@actor.items[i])
  368.         else         
  369.           if @actor.items[i].is_a?(RPG::Weapon) or @actor.items[i].is_a?(RPG::Armor)
  370.             if @actor.items[i].name==$data_items[@actor.items[i].id].name
  371.               @data.push($data_items[@actor.items[i].id])
  372.               next
  373.             else
  374.               @data.push(@actor.items[i])
  375.               next
  376.             end
  377.           end
  378.         end
  379.       end
  380.     end
  381.     # 如果项目数不是 0 就生成位图、重新描绘全部项目
  382.     @item_max = @data.size
  383.     if @item_max > 0
  384.       self.contents = Bitmap.new(width - 32, row_max * 32)
  385.       self.contents.font.size = 20
  386.       for i in 0...@item_max
  387.         draw_item(i)
  388.       end
  389.     end
  390.   end
  391.   #--------------------------------------------------------------------------
  392.   # ● 描绘项目
  393.   #     index : 项目编号
  394.   #--------------------------------------------------------------------------
  395.   def draw_item(index)
  396.     if @actor==nil
  397.       item = @data[index]
  398.       x = 4
  399.       y = index * 32
  400.       rect = Rect.new(x, y, self.width - 32, 32)
  401.       self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  402.       bitmap = RPG::Cache.icon(item.icon_name)
  403.       opacity = self.contents.font.color == normal_color ? 255 : 128
  404.       self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  405.       self.contents.font.size = 20
  406.       self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  407.       self.contents.font.size = 14
  408.       self.contents.draw_text(x + 150, y, 400, 42, ":"+"    ★队伍目前物品数:"+$game_party.now_amount.to_s+" / "+$game_party.max_amount.to_s, 0)
  409.     else
  410.       item = @data[index]
  411.       #if item.is_a?(RPG::Item) and
  412.         #$game_party.item_can_use?(item.id)
  413.         #self.contents.font.color = normal_color
  414.       #else
  415.         #self.contents.font.color = disabled_color
  416.       #end
  417.       x = 4
  418.       y = index * 32
  419.       rect = Rect.new(x, y, self.width - 32, 32)
  420.       self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  421.       bitmap = RPG::Cache.icon(item.icon_name)
  422.       opacity = self.contents.font.color == normal_color ? 255 : 128
  423.       self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  424.       self.contents.font.size = 20
  425.       self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  426.       self.contents.font.size = 14
  427.       self.contents.draw_text(x + 150, y, 400, 42, ":"+"    物品数量:"+@actor.item_amount.to_s+"    最大负重:"+@actor.max_size.to_s, 0)
  428.     end
  429.   end
  430.   #--------------------------------------------------------------------------
  431.   # ● 刷新帮助文本
  432.   #--------------------------------------------------------------------------
  433.   def update_help
  434.     @help_window.set_text(item)
  435.     @help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max)
  436.     #@help_window.contents.font.size = 18
  437.     #if @actor==nil
  438.     #  @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 )
  439.     #else
  440.     #  @help_window.set_text(@actor.name+"    物品数量:"[email protected]_amount.to_s+"    最大负重:"[email protected]_size.to_s)
  441.     #end
  442.   end
  443.   def dispose
  444.     super
  445.     @actor.judge_equip if @actor != nil
  446.   end
  447. end
  448.  
  449. #==============================================================================
  450. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  451. # ■ 使用方法写在发布页
  452. #============================================================================
  453. # ■ Window_EquipItem
  454. #------------------------------------------------------------------------------
  455. #  装备画面、显示浏览变更装备的候补物品的窗口。
  456. #==============================================================================
  457.  
  458. class Window_EquipItem < Window_Selectable
  459.   #--------------------------------------------------------------------------
  460.   # ● 刷新
  461.   #--------------------------------------------------------------------------
  462.   def refresh
  463.     if self.contents != nil
  464.       self.contents.dispose
  465.       self.contents = nil
  466.     end
  467.     @data = []
  468.  
  469.     # 添加可以装备的武器
  470.     if @equip_type == 0
  471.       weapon_set = $data_classes[@actor.class_id].weapon_set
  472.       for item in @actor.items
  473.         if item.is_a?(RPG::Weapon) and weapon_set.include?(item.id)
  474.           @data.push(item)
  475.         end
  476.       end
  477.     end
  478.     # 添加可以装备的防具
  479.     if @equip_type != 0
  480.       armor_set = $data_classes[@actor.class_id].armor_set
  481.       for item in @actor.items
  482.         if item.is_a?(RPG::Armor) and armor_set.include?(item.id)
  483.           if item.kind == @equip_type-1
  484.             @data.push(item)
  485.           end
  486.         end
  487.       end
  488.     end
  489.     # 添加空白
  490.     @data.push(nil)
  491.     # 生成位图、描绘全部项目
  492.     @item_max = @data.size
  493.     self.contents = Bitmap.new(width - 32, row_max * 32)
  494.     for i in 0...@item_max-1
  495.       draw_item(i)
  496.     end
  497.   end
  498.   #--------------------------------------------------------------------------
  499.   # ● 项目的描绘
  500.   #     index : 项目符号
  501.   #--------------------------------------------------------------------------
  502.   def draw_item(index)
  503.     item = @data[index]
  504.     x = 4 + index % 2 * (288 + 32)
  505.     y = index / 2 * 32
  506.     bitmap = RPG::Cache.icon(item.icon_name)
  507.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
  508.     self.contents.font.color = normal_color
  509.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  510.   end
  511. end
  512.  
  513. #==============================================================================
  514. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  515. # ■ 使用方法写在发布页
  516. #==============================================================================
  517. # ■ Window_ShopStatus_New
  518. #------------------------------------------------------------------------------
  519. #  商店画面、显示物品所持数与角色装备的窗口。
  520. #==============================================================================
  521.  
  522. class Window_ShopStatus_New < Window_Selectable
  523.   #--------------------------------------------------------------------------
  524.   # ● 初始化对像
  525.   #--------------------------------------------------------------------------
  526.   def initialize
  527.     super(368, 128, 272, 352)
  528.     self.contents = Bitmap.new(width - 32, height - 32)
  529.     self.contents.font.size = 18
  530.     @item = nil
  531.     @item_max = $game_party.actors.size + 1
  532.     refresh
  533.   end
  534.   #--------------------------------------------------------------------------
  535.   # ● 刷新
  536.   #--------------------------------------------------------------------------
  537.   def refresh
  538.     self.contents.clear
  539.  
  540.     if @item == nil
  541.       return
  542.     end
  543.     case @item
  544.     when RPG::Item
  545.       number = $game_party.item_number(@item.id)
  546.     when RPG::Weapon
  547.       number = $game_party.weapon_number(@item.id)
  548.     when RPG::Armor
  549.       number = $game_party.armor_number(@item.id)
  550.     end
  551.     self.contents.font.color = system_color
  552.     self.contents.draw_text(4, 0, 200, 32, "队伍中本物品数:")
  553.     self.contents.font.color = normal_color
  554.     self.contents.draw_text(204, 0, 32, 32, number.to_s, 2)
  555.     self.contents.font.color = system_color
  556.     self.contents.draw_text(4, 32, 200, 32, "队伍目前物品数:")
  557.     self.contents.font.color = normal_color
  558.     self.contents.draw_text(164, 32, 72, 32, $game_party.now_amount.to_s+" / "+$game_party.max_amount.to_s, 2)
  559.     #if @item.is_a?(RPG::Item)
  560.       #return
  561.     #end
  562.     # 添加装备品信息
  563.     for i in 0...$game_party.actors.size
  564.       actor = $game_party.actors[i]
  565.       self.contents.font.color = Color.new(255,255,0)
  566.       self.contents.draw_text(116, 64 + 64 * i, 132, 32, "负重: ")
  567.       self.contents.font.color = normal_color
  568.       self.contents.draw_text(164, 64 + 64 * i, 72, 32, actor.item_amount.to_s+" / "+actor.max_size.to_s,2)
  569.       # 获取当前的装备品
  570.       unless @item == nil or @item.is_a?(RPG::Item)
  571.         if @item.is_a?(RPG::Weapon)
  572.           item1 = $data_weapons[actor.weapon_id]
  573.         elsif @item.kind == 0
  574.           item1 = $data_armors[actor.armor1_id]
  575.         elsif @item.kind == 1
  576.           item1 = $data_armors[actor.armor2_id]
  577.         elsif @item.kind == 2
  578.           item1 = $data_armors[actor.armor3_id]
  579.         else
  580.           item1 = $data_armors[actor.armor4_id]
  581.         end
  582.         # 可以装备为普通文字颜色、不能装备设置为无效文字颜色
  583.         if actor.equippable?(@item)
  584.           self.contents.font.color = normal_color
  585.         else
  586.           self.contents.font.color = disabled_color
  587.         end        
  588.         # 描绘角色名字
  589.         self.contents.draw_text(4, 64 + 64 * i, 120, 32, actor.name)
  590.         # 可以装备的情况
  591.         if actor.equippable?(@item)
  592.           # 武器的情况
  593.           if @item.is_a?(RPG::Weapon)
  594.             atk1 = item1 != nil ? item1.atk : 0
  595.             atk2 = @item != nil ? @item.atk : 0
  596.             change = atk2 - atk1
  597.           end
  598.           # 防具的情况
  599.           if @item.is_a?(RPG::Armor)
  600.             pdef1 = item1 != nil ? item1.pdef : 0
  601.             mdef1 = item1 != nil ? item1.mdef : 0
  602.             pdef2 = @item != nil ? @item.pdef : 0
  603.             mdef2 = @item != nil ? @item.mdef : 0
  604.             change = pdef2 - pdef1 + mdef2 - mdef1
  605.           end
  606.           # 描绘能力值变化
  607.           self.contents.draw_text(124, 96 + 64 * i, 112, 32,
  608.             sprintf("%+d", change), 2)
  609.         end
  610.         # 描绘物品
  611.         if item1 != nil
  612.           x = 4
  613.           y = 64 + 64 * i + 32
  614.           bitmap = RPG::Cache.icon(item1.icon_name)
  615.           opacity = self.contents.font.color == normal_color ? 255 : 128
  616.           self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  617.           self.contents.draw_text(x + 28, y, 212, 32, item1.name)
  618.         end
  619.       else
  620.         self.contents.font.color = normal_color
  621.         # 描绘角色名字
  622.         self.contents.draw_text(4, 64 + 64 * i, 120, 32, actor.name)
  623.       end
  624.     end
  625.   end
  626.   #--------------------------------------------------------------------------
  627.   # ● 设置物品
  628.   #     item : 新的物品
  629.   #--------------------------------------------------------------------------
  630.   def item=(item)
  631.     if @item != item
  632.       @item = item
  633.       refresh
  634.     end
  635.   end
  636.   #--------------------------------------------------------------------------
  637.   # ● 刷新光标矩形
  638.   #--------------------------------------------------------------------------
  639.   def update_cursor_rect
  640.     if @index < 0
  641.       self.cursor_rect.empty
  642.     else
  643.       self.cursor_rect.set(0, @index * 64, self.width - 32, 64)
  644.     end
  645.   end
  646. end
  647.  
  648. #==============================================================================
  649. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  650. # ■ 使用方法写在发布页
  651. #==============================================================================
  652. # ■ Scene_Menu
  653. #------------------------------------------------------------------------------
  654. #  处理菜单画面的类。
  655. #==============================================================================
  656.  
  657. class Scene_Menu
  658.   #--------------------------------------------------------------------------
  659.   # ● 初始化对像
  660.   #     menu_index : 命令光标的初期位置
  661.   #--------------------------------------------------------------------------
  662.   def initialize(menu_index = 0)
  663.     @menu_index = menu_index
  664.   end
  665.   #--------------------------------------------------------------------------
  666.   # ● 主处理
  667.   #--------------------------------------------------------------------------
  668.   def main
  669.         @menu_com = Sprite.new
  670.     @menu_com.bitmap = RPG::Cache.picture("自己做背景.png")  
  671.  
  672.     # 生成命令窗口
  673.     s1 = $data_system.words.item
  674.     s2 = $data_system.words.skill
  675.     s3 = $data_system.words.equip
  676.     s4 = "状态"
  677.     s5 = "存档"
  678.     s6 = "结束游戏"
  679.     @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
  680.     @command_window.index = @menu_index
  681.     @item_command_window = Window_Command.new(160,["队伍物品","个人物品"])
  682.     @item_command_window.x = 120
  683.     @item_command_window.visible = false
  684.     @item_command_window.active = false
  685.     @item_command_window.z = 999
  686.     # 同伴人数为 0 的情况下
  687.     if $game_party.actors.size == 0
  688.       # 物品、特技、装备、状态无效化
  689.       @command_window.disable_item(0)
  690.       @command_window.disable_item(1)
  691.       @command_window.disable_item(2)
  692.       @command_window.disable_item(3)
  693.     end
  694.     # 禁止存档的情况下
  695.     if $game_system.save_disabled
  696.       # 存档无效
  697.       @command_window.disable_item(4)
  698.     end
  699.     # 生成游戏时间窗口
  700.     @playtime_window = Window_PlayTime.new
  701.     @playtime_window.x = 0
  702.     @playtime_window.y = 224
  703.     # 生成步数窗口
  704.     @steps_window = Window_Steps.new
  705.     @steps_window.x = 0
  706.     @steps_window.y = 320
  707.     # 生成金钱窗口
  708.     @gold_window = Window_Gold.new
  709.     @gold_window.x = 0
  710.     @gold_window.y = 416
  711.     # 生成状态窗口
  712.     @status_window = Window_MenuStatus.new
  713.     @status_window.x = 160
  714.     @status_window.y = 0
  715.     # 执行过渡
  716.     Graphics.transition
  717.     # 主循环
  718.     loop do
  719.       # 刷新游戏画面
  720.       Graphics.update
  721.       # 刷新输入信息
  722.       Input.update
  723.       # 刷新画面
  724.       update
  725.       # 如果切换画面就中断循环
  726.       if $scene != self
  727.         break
  728.       end
  729.     end
  730.     # 准备过渡
  731.     Graphics.freeze
  732.     # 释放窗口
  733.         @menu_com.bitmap.dispose if @menu_com.bitmap  
  734.     @menu_com.dispose
  735.  
  736.     @command_window.dispose
  737.     @playtime_window.dispose
  738.     @steps_window.dispose
  739.     @gold_window.dispose
  740.     @status_window.dispose
  741.     @item_command_window.dispose
  742.   end
  743.   #--------------------------------------------------------------------------
  744.   # ● 刷新画面
  745.   #--------------------------------------------------------------------------
  746.   def update
  747.     # 刷新窗口
  748.     @command_window.update
  749.     @playtime_window.update
  750.     @steps_window.update
  751.     @gold_window.update
  752.     @status_window.update
  753.     @item_command_window.update
  754.     # 命令窗口被激活的情况下: 调用 update_command
  755.     if @command_window.active
  756.       update_command
  757.       return
  758.     end
  759.     # 状态窗口被激活的情况下: 调用 update_status
  760.     if @status_window.active
  761.       update_status
  762.       return
  763.     end
  764.     if @item_command_window.active
  765.       update_item_command
  766.       return
  767.     end
  768.   end
  769.   def update_item_command
  770.     if Input.trigger?(Input::B)
  771.       $game_system.se_play($data_system.cancel_se)
  772.       @item_command_window.active = false
  773.       @item_command_window.visible = false
  774.       @command_window.active = true
  775.     end
  776.     if Input.trigger?(Input::C)
  777.       case @item_command_window.index
  778.       when 0
  779.         $game_system.se_play($data_system.decision_se)
  780.         $scene = Scene_Item.new
  781.       when 1
  782.         # 演奏确定 SE
  783.         $game_system.se_play($data_system.decision_se)
  784.         # 激活状态窗口
  785.         @item_command_window.active = false
  786.         @item_command_window.visible = false
  787.         @status_window.active = true
  788.         @status_window.index = 0
  789.       end
  790.     end
  791.   end
  792.   #--------------------------------------------------------------------------
  793.   # ● 刷新画面 (命令窗口被激活的情况下)
  794.   #--------------------------------------------------------------------------
  795.   def update_command
  796.     # 按下 B 键的情况下
  797.     if Input.trigger?(Input::B)
  798.       # 演奏取消 SE
  799.       $game_system.se_play($data_system.cancel_se)
  800.       # 切换的地图画面
  801.       $scene = Scene_Map.new
  802.       return
  803.     end
  804.     # 按下 C 键的情况下
  805.     if Input.trigger?(Input::C)
  806.       # 同伴人数为 0、存档、游戏结束以外的场合
  807.       if $game_party.actors.size == 0 and @command_window.index < 4
  808.         # 演奏冻结 SE
  809.         $game_system.se_play($data_system.buzzer_se)
  810.         return
  811.       end
  812.       # 命令窗口的光标位置分支
  813.       case @command_window.index
  814.       when 0  # 物品
  815.         # 演奏确定 SE
  816.         $game_system.se_play($data_system.decision_se)
  817.         # 激活状态窗口
  818.         @command_window.active = false
  819.         @item_command_window.active = true
  820.         @item_command_window.index = 0
  821.         @item_command_window.visible = true
  822.       when 1  # 特技
  823.         # 演奏确定 SE
  824.         $game_system.se_play($data_system.decision_se)
  825.         # 激活状态窗口
  826.         @command_window.active = false
  827.         @status_window.active = true
  828.         @status_window.index = 0
  829.       when 2  # 装备
  830.         # 演奏确定 SE
  831.         $game_system.se_play($data_system.decision_se)
  832.         # 激活状态窗口
  833.         @command_window.active = false
  834.         @status_window.active = true
  835.         @status_window.index = 0
  836.       when 3  # 状态
  837.         # 演奏确定 SE
  838.         $game_system.se_play($data_system.decision_se)
  839.         # 激活状态窗口
  840.         @command_window.active = false
  841.         @status_window.active = true
  842.         @status_window.index = 0
  843.       when 4  # 存档
  844.         # 禁止存档的情况下
  845.         if $game_system.save_disabled
  846.           # 演奏冻结 SE
  847.           $game_system.se_play($data_system.buzzer_se)
  848.           return
  849.         end
  850.         # 演奏确定 SE
  851.         $game_system.se_play($data_system.decision_se)
  852.         # 切换到存档画面
  853.         $scene = Scene_Save.new
  854.       when 5  # 游戏结束
  855.         # 演奏确定 SE
  856.         $game_system.se_play($data_system.decision_se)
  857.         # 切换到游戏结束画面
  858.         $scene = Scene_End.new
  859.       end
  860.       return
  861.     end
  862.   end
  863.   #--------------------------------------------------------------------------
  864.   # ● 刷新画面 (状态窗口被激活的情况下)
  865.   #--------------------------------------------------------------------------
  866.   def update_status
  867.     # 按下 B 键的情况下
  868.     if Input.trigger?(Input::B)
  869.       # 演奏取消 SE
  870.       $game_system.se_play($data_system.cancel_se)
  871.       # 激活命令窗口
  872.       @command_window.active = true
  873.       @status_window.active = false
  874.       @status_window.index = -1
  875.       return
  876.     end
  877.     # 按下 C 键的情况下
  878.     if Input.trigger?(Input::C)
  879.       # 命令窗口的光标位置分支
  880.       case @command_window.index
  881.       when 0  # 物品        
  882.         $game_system.se_play($data_system.decision_se)
  883.         $scene = Scene_Item.new($game_party.actors[@status_window.index])
  884.       when 1  # 特技
  885.         # 本角色的行动限制在 2 以上的情况下
  886.         if $game_party.actors[@status_window.index].restriction >= 2
  887.           # 演奏冻结 SE
  888.           $game_system.se_play($data_system.buzzer_se)
  889.           return
  890.         end
  891.         # 演奏确定 SE
  892.         $game_system.se_play($data_system.decision_se)
  893.         # 切换到特技画面
  894.         $scene = Scene_Skill.new(@status_window.index)
  895.       when 2  # 装备
  896.         # 演奏确定 SE
  897.         $game_system.se_play($data_system.decision_se)
  898.         # 切换的装备画面
  899.         $scene = Scene_Equip.new(@status_window.index)
  900.       when 3  # 状态
  901.         # 演奏确定 SE
  902.         $game_system.se_play($data_system.decision_se)
  903.         # 切换到状态画面
  904.         $scene = Scene_Status.new(@status_window.index)
  905.       end
  906.       return
  907.     end
  908.   end
  909. end
  910.  
  911. #==============================================================================
  912. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  913. # ■ 使用方法写在发布页
  914. #==============================================================================
  915. # ■ Scene_Item
  916. #------------------------------------------------------------------------------
  917. #  处理物品画面的类。
  918. #==============================================================================
  919.  
  920. class Scene_Item
  921.  
  922.   #★——添加定义
  923.   def initialize(actor = nil)
  924.     @actor = actor
  925.   end
  926.  
  927.   #--------------------------------------------------------------------------
  928.   # ● 主处理
  929.   #--------------------------------------------------------------------------
  930.   def main
  931.         @menu_com = Sprite.new
  932.     @menu_com.bitmap = RPG::Cache.picture("技能窗口.png")  
  933.  
  934.     # 生成帮助窗口、物品窗口
  935.     @help_window = Window_Help.new
  936.     @item_window = Window_Item.new(@actor)
  937.     # 关联帮助窗口
  938.     @item_window.help_window = @help_window
  939.     # 生成目标窗口 (设置为不可见・不活动)
  940.     @target_window = Window_Target.new
  941.     @target_window.visible = false
  942.     @target_window.active = false
  943.     if @actor==nil
  944.       @command_window = Window_Command.new(160,["使用物品","交给他人","丢弃物品"])
  945.     else
  946.       @command_window = Window_Command.new(160,["使用物品","转交他人","丢弃物品","放回队伍"])
  947.     end
  948.     @command_window.x = 240
  949.     @command_window.y = 180
  950.     @command_window.visible = false
  951.     @command_window.active = false
  952.     @command_window.z = 999
  953.     @target_window.z = 10000
  954.     # 执行过度
  955.     Graphics.transition
  956.     # 主循环
  957.     loop do
  958.       # 刷新游戏画面
  959.       Graphics.update
  960.       # 刷新输入信息
  961.       Input.update
  962.       # 刷新画面
  963.       update
  964.       # 如果画面切换就中断循环
  965.       if $scene != self
  966.         break
  967.       end
  968.     end
  969.     # 装备过渡
  970.     Graphics.freeze
  971.     # 释放窗口
  972.         @menu_com.bitmap.dispose if @menu_com.bitmap  
  973.     @menu_com.dispose
  974.  
  975.     @help_window.dispose
  976.     @item_window.dispose
  977.     @target_window.dispose
  978.     @command_window.dispose
  979.   end
  980.   #--------------------------------------------------------------------------
  981.   # ● 刷新画面
  982.   #--------------------------------------------------------------------------
  983.   def update
  984.     # 刷新窗口
  985.     @help_window.update
  986.     @item_window.update
  987.     @target_window.update
  988.     @command_window.update
  989.     # 物品窗口被激活的情况下: 调用 update_item
  990.     if @item_window.active
  991.       update_item
  992.       return
  993.     end
  994.     # 目标窗口被激活的情况下: 调用 update_target
  995.     if @target_window.active
  996.       update_target
  997.       return
  998.     end
  999.     if @command_window.active
  1000.       update_command
  1001.       return
  1002.     end
  1003.   end
  1004.   #--------------------------------------------------------------------------
  1005.   # ● 刷新画面
  1006.   #--------------------------------------------------------------------------
  1007.   def update_command
  1008.     # 按下 B 键的情况下
  1009.     if Input.trigger?(Input::B)
  1010.       # 演奏取消 SE
  1011.       $game_system.se_play($data_system.cancel_se)
  1012.       # 切换到菜单画面
  1013.       @command_window.visible = false
  1014.       @command_window.active = false
  1015.       @item_window.active = true
  1016.       return
  1017.     end
  1018.     # 按下 C 键的情况下
  1019.     if Input.trigger?(Input::C)
  1020.       case @command_window.index
  1021.       when 0
  1022.         # 获取物品窗口当前选中的物品数据
  1023.         @item = @item_window.item
  1024.         # 不使用物品的情况下
  1025.         if @actor == nil
  1026.           $game_system.se_play($data_system.buzzer_se)
  1027.           return
  1028.         end
  1029.         unless @item.is_a?(RPG::Item)
  1030.           # 演奏冻结 SE
  1031.           $game_system.se_play($data_system.buzzer_se)
  1032.           return
  1033.         end
  1034.         # 不能使用的情况下
  1035.         unless $game_party.item_can_use?(@item.id)
  1036.           # 演奏冻结 SE
  1037.           $game_system.se_play($data_system.buzzer_se)
  1038.           return
  1039.         end
  1040.         # 演奏确定 SE
  1041.         $game_system.se_play($data_system.decision_se)
  1042.         # 效果范围是我方的情况下
  1043.         if @item.scope >= 3
  1044.           # 激活目标窗口
  1045.           @command_window.active = false
  1046.           @target_window.x = (@item_window.index + 1) % 2 * 304
  1047.           @target_window.visible = true
  1048.           @target_window.active = true
  1049.           # 设置效果范围 (单体/全体) 的对应光标位置
  1050.           if @item.scope == 4 || @item.scope == 6
  1051.             @target_window.index = -1
  1052.           else
  1053.             @target_window.index = 0
  1054.           end
  1055.         # 效果在我方以外的情况下
  1056.         else
  1057.           # 公共事件 ID 有效的情况下
  1058.           if @item.common_event_id > 0
  1059.             # 预约调用公共事件
  1060.             $game_temp.common_event_id = @item.common_event_id
  1061.             # 演奏物品使用时的 SE
  1062.             $game_system.se_play(@item.menu_se)
  1063.             # 消耗品的情况下
  1064.             if @item.consumable
  1065.               # 使用的物品数减 1
  1066.               if @actor==nil
  1067.                 $game_party.lose_item(@item.id, 1)
  1068.               else
  1069.                 @actor.items.delete_at(@item_window.index)
  1070.               end
  1071.               # 再描绘物品窗口的项目
  1072.               @item_window.draw_item(@item_window.index)
  1073.             end
  1074.             # 切换到地图画面
  1075.             $scene = Scene_Map.new
  1076.             return
  1077.           end
  1078.         end
  1079.         return
  1080.       when 1
  1081.         $game_system.se_play($data_system.decision_se)
  1082.         @command_window.active = false
  1083.         @target_window.visible = true
  1084.         @target_window.index = 0
  1085.         @target_window.active = true
  1086.       when 2
  1087.         $game_system.se_play($data_system.load_se)
  1088.         if @actor != nil
  1089.           @actor.items.delete_at(@item_window.index)
  1090.           @actor.judge_equip
  1091.         else
  1092.           if @item_window.item.is_a?(RPG::Item)
  1093.             $game_party.gain_item(@item_window.item.id,-1)
  1094.           end
  1095.           if @item_window.item.is_a?(RPG::Weapon)
  1096.             $game_party.gain_weapon(@item_window.item.id,-1)
  1097.           end
  1098.           if @item_window.item.is_a?(RPG::Armor)
  1099.             $game_party.gain_armor(@item_window.item.id,-1)
  1100.           end
  1101.         end
  1102.         # 切换到菜单画面
  1103.         @command_window.visible = false
  1104.         @command_window.active = false
  1105.         @item_window.refresh
  1106.         @item_window.active = true
  1107.       when 3
  1108.         if $game_party.item_full?
  1109.           $game_system.se_play($data_system.cancel_se)
  1110.           return
  1111.         end
  1112.         $game_system.se_play($data_system.decision_se)
  1113.         if @item_window.item.is_a?(RPG::Item)
  1114.           $game_party.gain_item(@item_window.item.id,1)
  1115.         end
  1116.         if @item_window.item.is_a?(RPG::Weapon)
  1117.           $game_party.gain_weapon(@item_window.item.id,1)
  1118.         end
  1119.         if @item_window.item.is_a?(RPG::Armor)
  1120.           $game_party.gain_armor(@item_window.item.id,1)
  1121.         end
  1122.         @actor.items.delete_at(@item_window.index)
  1123.         # 切换到菜单画面
  1124.         @command_window.visible = false
  1125.         @command_window.active = false
  1126.         @item_window.refresh
  1127.         @item_window.active = true
  1128.       end
  1129.     end
  1130.   end  
  1131.   #--------------------------------------------------------------------------
  1132.   # ● 刷新画面 (物品窗口被激活的情况下)
  1133.   #--------------------------------------------------------------------------
  1134.   def update_item
  1135.     # 按下 B 键的情况下
  1136.     if Input.trigger?(Input::B)
  1137.       # 演奏取消 SE
  1138.       $game_system.se_play($data_system.cancel_se)
  1139.       # 切换到菜单画面
  1140.       $scene = Scene_Menu.new(0)
  1141.       return
  1142.     end
  1143.     # 按下 C 键的情况下
  1144.     if Input.trigger?(Input::C)
  1145.       # 获取物品窗口当前选中的物品数据
  1146.       @item = @item_window.item
  1147.       $game_system.se_play($data_system.decision_se)
  1148.       if @item.is_a?(RPG::Item) and $game_party.item_can_use?(@item.id) and @actor != nil
  1149.         @command_window.enable_item(0)
  1150.       else
  1151.         @command_window.disable_item(0)
  1152.       end
  1153.       @command_window.index = 0
  1154.       @command_window.visible = true
  1155.       @command_window.active = true
  1156.       @item_window.active = false
  1157.       return
  1158.     end
  1159.     # 按下 R 键的情况下
  1160.     if Input.trigger?(Input::R)
  1161.       $game_system.se_play($data_system.cursor_se)
  1162.       actor_index = 0
  1163.       for i in 0...$game_party.actors.size
  1164.         if @actor==$game_party.actors[i]
  1165.           actor_index = i
  1166.           break
  1167.         end
  1168.       end
  1169.       actor_index += 1
  1170.       actor_index %= $game_party.actors.size
  1171.       # 切换到别的特技画面
  1172.       $scene = Scene_Item.new($game_party.actors[actor_index])
  1173.       return
  1174.     end
  1175.     # 按下 L 键的情况下
  1176.     if Input.trigger?(Input::L)
  1177.       # 演奏光标 SE
  1178.       $game_system.se_play($data_system.cursor_se)      
  1179.       actor_index = 0
  1180.       for i in 0...$game_party.actors.size
  1181.         if @actor==$game_party.actors[i]
  1182.           actor_index = i
  1183.           break
  1184.         end
  1185.       end
  1186.       actor_index -= 1
  1187.       actor_index %= $game_party.actors.size
  1188.       # 切换到别的特技画面
  1189.       $scene = Scene_Item.new($game_party.actors[actor_index])
  1190.       return
  1191.     end
  1192.   end
  1193.   #--------------------------------------------------------------------------
  1194.   # ● 刷新画面 (目标窗口被激活的情况下)
  1195.   #--------------------------------------------------------------------------
  1196.   def update_target
  1197.     # 按下 B 键的情况下
  1198.     if Input.trigger?(Input::B)
  1199.       # 演奏取消 SE
  1200.       $game_system.se_play($data_system.cancel_se)
  1201.       # 由于物品用完而不能使用的场合
  1202.       unless $game_party.item_can_use?(@item.id)
  1203.         # 再次生成物品窗口的内容
  1204.         @item_window.refresh
  1205.       end
  1206.       # 删除目标窗口
  1207.       @command_window.active = true
  1208.       @target_window.visible = false
  1209.       @target_window.active = false
  1210.       return
  1211.     end
  1212.     # 按下 C 键的情况下
  1213.     if Input.trigger?(Input::C)
  1214.       if @command_window.index==0
  1215.         # 目标是全体的情况下
  1216.         if @target_window.index == -1
  1217.           # 对同伴全体应用物品使用效果
  1218.           used = false
  1219.           for i in $game_party.actors
  1220.             used |= i.item_effect(@item)
  1221.           end
  1222.         end
  1223.         # 目标是单体的情况下
  1224.         if @target_window.index >= 0
  1225.           # 对目标角色应用物品的使用效果
  1226.           target = $game_party.actors[@target_window.index]
  1227.           used = target.item_effect(@item)
  1228.         end
  1229.         # 使用物品的情况下
  1230.         if used
  1231.           # 演奏物品使用时的 SE
  1232.           $game_system.se_play(@item.menu_se)
  1233.           # 消耗品的情况下
  1234.           if @item.consumable
  1235.  
  1236.             if @actor == nil
  1237.               # 使用的物品数减 1
  1238.               $game_party.lose_item(@item.id, 1)
  1239.             else
  1240.               @actor.items.delete_at(@item_window.index)
  1241.             end
  1242.  
  1243.             # 再描绘物品窗口的项目
  1244.             @item_window.draw_item(@item_window.index)
  1245.           end
  1246.           # 再生成目标窗口的内容
  1247.           @target_window.refresh
  1248.           # 全灭的情况下
  1249.           if $game_party.all_dead?
  1250.             # 切换到游戏结束画面
  1251.             $scene = Scene_Gameover.new
  1252.             return
  1253.           end
  1254.           # 公共事件 ID 有效的情况下
  1255.           if @item.common_event_id > 0
  1256.             # 预约调用公共事件
  1257.             $game_temp.common_event_id = @item.common_event_id
  1258.             # 切换到地图画面
  1259.             $scene = Scene_Map.new
  1260.             return
  1261.           end
  1262.           @item_window.refresh
  1263.           @item_window.index -= 1 if @item_window.index >0
  1264.         end
  1265.         # 无法使用物品的情况下
  1266.         unless used
  1267.           # 演奏冻结 SE
  1268.           $game_system.se_play($data_system.buzzer_se)
  1269.         end
  1270.         return
  1271.       end
  1272.       if @command_window.index==1
  1273.         if $game_party.actors[@target_window.index].item_full?
  1274.           $game_system.se_play($data_system.buzzer_se)
  1275.           return
  1276.         end
  1277.         if @actor != nil
  1278.           @actor.items.delete_at(@item_window.index)
  1279.         else
  1280.           if @item_window.item.is_a?(RPG::Item)
  1281.             $game_party.lose_item(@item_window.item.id, 1)
  1282.           elsif @item_window.item.is_a?(RPG::Weapon)
  1283.             $game_party.lose_weapon(@item_window.item.id, 1)
  1284.           elsif @item_window.item.is_a?(RPG::Armor)
  1285.             $game_party.lose_armor(@item_window.item.id, 1)
  1286.           end
  1287.         end
  1288.         $game_system.se_play($data_system.decision_se)
  1289.         $game_party.actors[@target_window.index].items.push(@item_window.item)
  1290.         @item_window.refresh
  1291.         @item_window.index -= 1 if @item_window.index>0
  1292.         @item_window.active = true
  1293.         @command_window.visible = false
  1294.         @command_window.active = false
  1295.         @command_window.index = 0
  1296.         @target_window.visible = false
  1297.         @target_window.active = false
  1298.       end
  1299.     end
  1300.   end
  1301. end
  1302.  
  1303. #==============================================================================
  1304. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  1305. # ■ 使用方法写在发布页
  1306. #==============================================================================
  1307. # ■ Scene_Battle (分割定义 3)
  1308. #------------------------------------------------------------------------------
  1309. #  处理战斗画面的类。
  1310. #==============================================================================
  1311.  
  1312. class Scene_Battle
  1313.   #--------------------------------------------------------------------------
  1314.   # ● 开始选择物品
  1315.   #--------------------------------------------------------------------------
  1316.   def start_item_select
  1317.     # 无效化角色指令窗口
  1318.     @actor_command_window.active = false
  1319.     @actor_command_window.visible = false
  1320.     # 生成物品窗口
  1321.     @item_window = Window_Item.new($game_party.actors[@actor_index])
  1322.     # 关联帮助窗口
  1323.     #@item_window.help_window = @help_window
  1324.     @item_window.help_window =  Window_Help.new#★★★★★★★★★★★★
  1325.     # 无效化角色指令窗口
  1326.     @actor_command_window.active = false
  1327.     @actor_command_window.visible = false
  1328.   end
  1329.   #--------------------------------------------------------------------------
  1330.   # ● 刷新画面 (角色命令回合 : 选择物品)
  1331.   #--------------------------------------------------------------------------
  1332.   def update_phase3_item_select
  1333.     # 设置物品窗口为可视状态
  1334.     @item_window.visible = true
  1335.     # 刷新物品窗口
  1336.     @item_window.update
  1337.     # 按下 B 键的情况下
  1338.     if Input.trigger?(Input::B)
  1339.       # 演奏取消 SE
  1340.       $game_system.se_play($data_system.cancel_se)
  1341.       # 选择物品结束
  1342.       end_item_select
  1343.       return
  1344.     end
  1345.     # 按下 C 键的情况下
  1346.     if Input.trigger?(Input::C)
  1347.       # 获取物品窗口现在选择的物品资料
  1348.       @item = @item_window.item
  1349.       unless @item.is_a?(RPG::Item)
  1350.         # 演奏冻结 SE
  1351.         $game_system.se_play($data_system.buzzer_se)
  1352.         return
  1353.       end
  1354.       # 无法使用的情况下
  1355.       unless $game_party.item_can_use?(@item.id)
  1356.         # 演奏冻结 SE
  1357.         $game_system.se_play($data_system.buzzer_se)
  1358.         return
  1359.       end
  1360.       # 演奏确定 SE
  1361.       $game_system.se_play($data_system.decision_se)
  1362.  
  1363.       # 设置行动
  1364.       @active_battler.current_action.item_id = @item.id
  1365.       # 设置物品窗口为不可见状态
  1366.       @item_window.visible = false
  1367.           # 效果范围是敌单体的情况下
  1368.       if @item.scope == 1
  1369.         # 开始选择敌人
  1370.         start_enemy_select
  1371.       # 效果范围是我方单体的情况下
  1372.       elsif @item.scope == 3 or @item.scope == 5
  1373.         # 开始选择角色
  1374.         start_actor_select
  1375.       # 效果范围不是单体的情况下
  1376.       else
  1377.         # 物品选择结束
  1378.         end_item_select
  1379.         # 转到下一位角色的指令输入
  1380.         phase3_next_actor
  1381.       end
  1382.       return
  1383.     end
  1384.   end
  1385. end
  1386.  
  1387. #==============================================================================
  1388. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  1389. # ■ 使用方法写在发布页
  1390. #==============================================================================
  1391. # ■ Scene_Shop
  1392. #------------------------------------------------------------------------------
  1393. #  处理商店画面的类。
  1394. #==============================================================================
  1395.  
  1396. class Scene_Shop
  1397.   #--------------------------------------------------------------------------
  1398.   # ● 主处理
  1399.   #--------------------------------------------------------------------------
  1400.   def main
  1401.  
  1402.     @type = 0   
  1403.  
  1404.     # 生成帮助窗口
  1405.     #@help_window = Window_Help.new
  1406.     @help_window = Window_Help.new#★★★★★★★★★★★★★★★★
  1407.     # 生成指令窗口
  1408.     @command_window = Window_ShopCommand.new
  1409.     # 生成金钱窗口
  1410.     @gold_window = Window_Gold.new
  1411.     @gold_window.x = 480
  1412.     @gold_window.y = 64
  1413.     # 生成时间窗口
  1414.     @dummy_window = Window_Base.new(0, 128, 640, 352)
  1415.     # 生成购买窗口
  1416.     @buy_window = Window_ShopBuy.new($game_temp.shop_goods)
  1417.     @buy_window.active = false
  1418.     @buy_window.visible = false
  1419.     @buy_window.help_window = @help_window
  1420.     # 生成卖出窗口
  1421.     @sell_window = Window_ShopSell.new
  1422.     @sell_window.active = false
  1423.     @sell_window.visible = false
  1424.     @sell_window.help_window = @help_window
  1425.     # 生成状态窗口
  1426.     @status_window = Window_ShopStatus_New.new
  1427.     @status_window.visible = false
  1428.     @status_window.index = -1
  1429.     # 执行过渡
  1430.     Graphics.transition
  1431.     # 主循环
  1432.     loop do
  1433.       # 刷新游戏画面
  1434.       Graphics.update
  1435.       # 刷新输入信息
  1436.       Input.update
  1437.       # 刷新画面
  1438.       update
  1439.       # 如果画面切换的话就中断循环
  1440.       if $scene != self
  1441.         break
  1442.       end
  1443.     end
  1444.     # 准备过渡
  1445.     Graphics.freeze
  1446.     # 释放窗口
  1447.     @help_window.dispose
  1448.     @command_window.dispose
  1449.     @gold_window.dispose
  1450.     @dummy_window.dispose
  1451.     @buy_window.dispose
  1452.     @sell_window.dispose
  1453.     @status_window.dispose
  1454.   end
  1455.   #--------------------------------------------------------------------------
  1456.   # ● 刷新画面
  1457.   #--------------------------------------------------------------------------
  1458.   def update
  1459.     # 刷新窗口
  1460.     @help_window.update
  1461.     @command_window.update
  1462.     @gold_window.update
  1463.     @dummy_window.update
  1464.     @buy_window.update
  1465.     @sell_window.update
  1466.     @status_window.update
  1467.     # 指令窗口激活的情况下: 调用 update_command
  1468.     if @command_window.active
  1469.       @help_window.visible=false
  1470.       update_command
  1471.       return
  1472.     end
  1473.     # 购买窗口激活的情况下: 调用 update_buy
  1474.     if @buy_window.active
  1475. # 修改開始
  1476.       @help_window.visible=true#★★★★★★★★★★★★★★★★
  1477.       if @buy_window.item==nil#★★★★★★★★★★★★★★★★
  1478.         @help_window.visible=false#★★★★★★★★★★★★★★★★
  1479.       end #★★★★★★★★★★★★★★★★     
  1480.       update_buy
  1481.       return
  1482.     end
  1483.     # 卖出窗口激活的情况下: 调用 update_sell
  1484.     if @sell_window.active
  1485. # 修改開始
  1486.       @help_window.visible=true#★★★★★★★★★★★★★★★★
  1487.       if @sell_window.item==nil#★★★★★★★★★★★★★★★★
  1488.         @help_window.visible=false#★★★★★★★★★★★★★★★★
  1489.       end #★★★★★★★★★★★★★★★★
  1490. # 修改終了
  1491.       update_sell
  1492.       return
  1493.     end
  1494.     if @type==1
  1495. # 修改開始
  1496.       @help_window.visible=true#★★★★★★★★★★★★★★★★
  1497.       if @sell_window.item==nil#★★★★★★★★★★★★★★★★
  1498.         @help_window.visible=false#★★★★★★★★★★★★★★★★
  1499.       end #★★★★★★★★★★★★★★★★
  1500. # 修改終了
  1501.       update_st1
  1502.       return
  1503.     end
  1504.   end
  1505.  
  1506.   def update_st1
  1507.     if Input.trigger?(Input::B)
  1508.       $game_system.se_play($data_system.cancel_se)
  1509.       @buy_window.active = true
  1510.       @type = 0
  1511.       @status_window.index = -1
  1512.       @status_window.active = false
  1513.       return
  1514.     end
  1515.     if Input.trigger?(Input::C)
  1516.       if @status_window.index == 0        
  1517.         if $game_party.item_full?
  1518.           $game_system.se_play($data_system.cancel_se)
  1519.           return
  1520.         end        
  1521.         # 演奏商店 SE
  1522.         $game_system.se_play($data_system.shop_se)
  1523.         $game_party.lose_gold(@item.price)
  1524.         case @item
  1525.         when RPG::Item
  1526.           $game_party.gain_item(@item.id, 1)
  1527.         when RPG::Weapon
  1528.           $game_party.gain_weapon(@item.id, 1)
  1529.         when RPG::Armor
  1530.           $game_party.gain_armor(@item.id, 1)
  1531.         end
  1532.         # 刷新各窗口
  1533.         @gold_window.refresh
  1534.         @buy_window.refresh
  1535.         @status_window.refresh
  1536.         # 窗口状态转向购买模式
  1537.         @buy_window.active = true
  1538.         @buy_window.visible = true
  1539.         @status_window.active = false
  1540.         @status_window.index = -1
  1541.         @type = 0
  1542.       else
  1543.         if $game_party.actors[@status_window.index-1].item_full?
  1544.           $game_system.se_play($data_system.cancel_se)
  1545.           return
  1546.         end        
  1547.         # 演奏商店 SE
  1548.         $game_system.se_play($data_system.shop_se)
  1549.         $game_party.lose_gold(@item.price)
  1550.         case @item
  1551.         when RPG::Item
  1552.           $game_party.actors[@status_window.index-1].gain_item(@item.id, 1)
  1553.         when RPG::Weapon
  1554.           $game_party.actors[@status_window.index-1].gain_item(@item.id, 2)
  1555.         when RPG::Armor
  1556.           $game_party.actors[@status_window.index-1].gain_item(@item.id, 3)
  1557.         end
  1558.         # 刷新各窗口
  1559.         @gold_window.refresh
  1560.         @buy_window.refresh
  1561.         @status_window.refresh
  1562.         # 窗口状态转向购买模式
  1563.         @buy_window.active = true
  1564.         @status_window.active = false
  1565.         @type = 0
  1566.         @status_window.index = -1
  1567.       end
  1568.     end
  1569.   end
  1570.   #--------------------------------------------------------------------------
  1571.   # ● 刷新画面 (指令窗口激活的情况下)
  1572.   #--------------------------------------------------------------------------
  1573.   def update_command
  1574.     # 按下 B 键的情况下
  1575.     if Input.trigger?(Input::B)
  1576.       # 演奏取消 SE
  1577.       $game_system.se_play($data_system.cancel_se)
  1578.       # 切换到地图画面
  1579.       $scene = Scene_Map.new
  1580.       return
  1581.     end
  1582.     # 按下 C 键的情况下
  1583.     if Input.trigger?(Input::C)
  1584.       # 命令窗口光标位置分支
  1585.       case @command_window.index
  1586.       when 0  # 购买
  1587.         # 演奏确定 SE
  1588.         $game_system.se_play($data_system.decision_se)
  1589.         # 窗口状态转向购买模式
  1590.         @command_window.active = false
  1591.         @dummy_window.visible = false
  1592.         @buy_window.active = true
  1593.         @buy_window.visible = true
  1594.         @buy_window.refresh
  1595.         @status_window.visible = true
  1596.       when 1  # 卖出
  1597.         # 演奏确定 SE
  1598.         $game_system.se_play($data_system.decision_se)
  1599.         # 窗口状态转向卖出模式
  1600.         @command_window.active = false
  1601.         @dummy_window.visible = false
  1602.         @sell_window.active = true
  1603.         @sell_window.visible = true
  1604.         @sell_window.refresh
  1605.       when 2  # 取消
  1606.         # 演奏确定 SE
  1607.         $game_system.se_play($data_system.decision_se)
  1608.         # 切换到地图画面
  1609.         $scene = Scene_Map.new
  1610.       end
  1611.       return
  1612.     end
  1613.   end
  1614.   #--------------------------------------------------------------------------
  1615.   # ● 刷新画面 (购买窗口激活的情况下)
  1616.   #--------------------------------------------------------------------------
  1617.   def update_buy
  1618.     # 设置状态窗口的物品
  1619.     @status_window.item = @buy_window.item
  1620.     # 按下 B 键的情况下
  1621.     if Input.trigger?(Input::B)
  1622.       # 演奏取消 SE
  1623.       $game_system.se_play($data_system.cancel_se)
  1624.       # 窗口状态转向初期模式
  1625.       @command_window.active = true
  1626.       @dummy_window.visible = true
  1627.       @buy_window.active = false
  1628.       @buy_window.visible = false
  1629.       @status_window.visible = false
  1630.       @status_window.item = nil
  1631.       # 删除帮助文本
  1632.       @help_window.set_text("")
  1633.       return
  1634.     end
  1635.     # 按下 C 键的情况下
  1636.     if Input.trigger?(Input::C)
  1637.       # 获取物品
  1638.       @item = @buy_window.item
  1639.       # 物品无效的情况下、或者价格在所持金以上的情况下
  1640.       if @item == nil or @item.price > $game_party.gold
  1641.         # 演奏冻结 SE
  1642.         $game_system.se_play($data_system.buzzer_se)
  1643.         return
  1644.       end
  1645.       # 获取物品所持数
  1646.       #case @item
  1647.       #when RPG::Item
  1648.         #number = $game_party.item_number(@item.id)
  1649.       #when RPG::Weapon
  1650.         #number = $game_party.weapon_number(@item.id)
  1651.       #when RPG::Armor
  1652.         #number = $game_party.armor_number(@item.id)
  1653.       #end
  1654.       # 如果已经拥有了 99 个情况下
  1655.       #if number == 99
  1656.         # 演奏冻结 SE
  1657.         #$game_system.se_play($data_system.buzzer_se)
  1658.         #return
  1659.       #end
  1660.       # 演奏确定 SE
  1661.       $game_system.se_play($data_system.decision_se)
  1662.       # 计算可以最多购买的数量
  1663.       #max = @item.price == 0 ? 99 : $game_party.gold / @item.price
  1664.       #max = [max, 99 - number].min
  1665.       # 窗口状态转向数值输入模式
  1666.       #@buy_window.active = false
  1667.       #@buy_window.visible = false
  1668.       #@number_window.set(@item, max, @item.price)
  1669.       #@number_window.active = true
  1670.       #@number_window.visible = true
  1671.       @buy_window.active = false
  1672.       @status_window.index = 0
  1673.       @type = 1
  1674.       @status_window.active = true
  1675.     end
  1676.   end
  1677.   #--------------------------------------------------------------------------
  1678.   # ● 画面更新 (卖出窗口激活的情况下)
  1679.   #--------------------------------------------------------------------------
  1680.   def update_sell
  1681.     # 按下 B 键的情况下
  1682.     if Input.trigger?(Input::B)
  1683.       # 演奏取消 SE
  1684.       $game_system.se_play($data_system.cancel_se)
  1685.       # 窗口状态转向初期模式
  1686.       @command_window.active = true
  1687.       @dummy_window.visible = true
  1688.       @sell_window.active = false
  1689.       @sell_window.visible = false
  1690.       @status_window.item = nil
  1691.       # 删除帮助文本
  1692.       @help_window.set_text("")
  1693.       return
  1694.     end
  1695.     # 按下 C 键的情况下
  1696.     if Input.trigger?(Input::C)
  1697.       # 获取物品
  1698.       @item = @sell_window.item
  1699.       # 设置状态窗口的物品
  1700.       @status_window.item = @item
  1701.       # 物品无效的情况下、或者价格为 0 (不能卖出) 的情况下
  1702.       if @item == nil or @item.price == 0
  1703.         # 演奏冻结 SE
  1704.         $game_system.se_play($data_system.buzzer_se)
  1705.         return
  1706.       end
  1707.       # 演奏确定 SE
  1708.       $game_system.se_play($data_system.decision_se)      
  1709.       # 卖出处理
  1710.       $game_party.gain_gold(@item.price / 2)
  1711.       case @item
  1712.       when RPG::Item
  1713.         $game_party.lose_item(@item.id, 1)
  1714.       when RPG::Weapon
  1715.         $game_party.lose_weapon(@item.id, 1)
  1716.       when RPG::Armor
  1717.         $game_party.lose_armor(@item.id, 1)
  1718.       end
  1719.       # 刷新各窗口
  1720.       @gold_window.refresh
  1721.       @sell_window.refresh
  1722.       @status_window.refresh
  1723.     end
  1724.   end
  1725. end

Lv4.逐梦者

梦石
0
星屑
12157
在线时间
4435 小时
注册时间
2014-4-11
帖子
5955

开拓者

2
 楼主| 发表于 2014-12-10 21:14:20 | 只看该作者
我自己已经解决
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-20 17:36

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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