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

Project1

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

[已经过期] 1.03B CP及时战斗与武器随机属性脚本整合问题!

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
2 小时
注册时间
2009-4-6
帖子
43
跳转到指定楼层
1
发表于 2009-7-24 22:21:06 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 迦月 于 2009-7-26 15:27 编辑

[code]#=============================================================================
#★Zhong RMVX 半即时战斗系统 1.03b版★
#-----------------------------------------------------------------------------
#★Scene_CP核心部分参考自 : 神思  《战斗真位移》战斗系统
#★作者: Zhong_zw
#★联系方式: 66rpg.com论坛短信 或 [email protected]
#★游戏中如若引用本脚本,请保留以上信息,并作相关说明.
#☆如若转载本脚本请联系本人☆
#=============================================================================
#=============================================================================
#☆1.01版修正问题:
#1、物品、特技窗口选择我方人物时,头像重叠
#2、连续伤害及自动回复效果无效。
#☆1.02版修正问题:
#1、减少刷新次数,提高速度
#2、修正被打击时有可能退到cp槽外
#☆1.02a版修正问题:
#1、复活问题.
#2、头像刷新问题.
#☆1.03版更新内容:
#1、地图名称与战斗背景的对应关系可在哈希表中设置
#2、如无相应战斗背景直接采用默认战斗背景
#3、角色CP图缺失时,用角色相应行走图代替
#☆1.03a版更新内容:
#1、物品经验得失窗口有时图标显示错误的问题
#★注:旧版本的只要把脚本中“class Window_egi<Window_Base”这个类完整的覆盖原来就行了。
#☆1.03b版更新内容:
#1、图标战斗指令窗口刷新的问题
#2、修正战斗事件响应的部分功能
#=============================================================================
#☆使用方法说明☆
#☆使用方法基本与我之前发的朴素横版战斗相同
#☆动画设置:
#1、武器、特技、物品的施展动画直接在其备注填入动画id即可。如果为空即不显示施展动画。
#2、敌人普通攻击动画,在其备注里填写格式如下:
#  a1=XX #施展动画id
#  a2=XX #对方动画id
#如果为空即使用默认普通动画(画面震动).
#☆战斗图设置:
#3、角色战斗图的的命名方式是角色id后面加上_z,如1_z.存放在Battlers文件夹。
#4、默认待机图为两帧,只要在Battlers文件夹里放一个“战斗图名+待“的文件,就会自动循环播放
#这两个战斗图,如1_b待,没有则没待机动作。
#☆战斗背景设置:
#5、在Graphics目录下新建Battlebacks文件夹。
#6、战斗时先搜索文件夹内是否有与角色所在区域同名的战斗图,如果没有则搜索文件夹里是否
#存在与地图同名的图片。
#7、简而言之,你须储存与你地图同名的战斗背景在Battlebacks,如果想在同一幅地图实现不同地域
#战斗背景不同,就在Battlebacks文件夹里储存与这个地域同名的战斗背景.至少保证战斗的地图
#都有一幅该地图同名的战斗背景,不然战斗时会提示找不到地图.(可参考《拉尔夫战记》或朴素横版的范例)
#☆CP条设置:
#8、CP条:在system文件夹里储存一个命名为"cp条"的图片,默认长度为327,如果需要可在Scene_CP类里调整相
#关参数.
#9、角色cp图命名方式是"角色id+_cp",如:1_cp,角色活跃cp图命名方式是"角色id+_a_cp",如1_a_cp,
#敌人cp图命名方式是"敌人名 + _敌人cp",如史莱姆_敌人cp,敌人活跃cp图是"敌人名+_a_cp".
#亦可在system文件夹里储存名为"敌人cp"的图片,作为敌人的统一cp图,活跃图名为"a_敌人cp",默认如果找不到敌人相关cp图就直接
#用这张图片.
#☆选择光标设置
#10、在system文件夹里储存名为"光标"的图片作为选择光标.
#11、B_B_CONFIG = true 时地图与战斗背景的命名关系写在BATTLE_BACK 这个数组里,
#B_B_CONFIG = false时,和战斗背景和以前的命名方式相同。
#12、战斗背景文件缺失时,用回默认战斗背景。
#★队伍战斗事件的设置说明★:
#13、除“回合”和“回合结束”条件外,其他事件条件设置与默认系统相同。
#14、关于角色回合的定义:角色回合是指每个角色各自独有一个回合属性,角色CP值每满一次就增加一个回合,角色间的回合相互独立。
#15、关于角色回合条件设置,参照工程目录下的“说明图片”文件夹的图片1、2,3对各个框进行设置,实现两种回合条件的设置
#    步骤如下:
#     一、一般回合条件设置,即当角色回合等于或大于小于某个数值时就在回合开始前或后执行
#         事件。
#       1. 参看“说明图片”文件夹中的图1对各个框的定义。
#       2. 在事件条件设置窗口中勾上“回合结束”,即打开回合条件设置开关。
#       3. 勾上“回合数”,在“回合关系参数”框里输入“回合关系参数”。★注:旁边的那个框值为0
#       回合关系参数取值:
#            0 为当 "角色回合"等于"回合参数"值时,回合开始前执行。
#            1 为当 "角色回合"大于"回合参数"值时,回合开始前执行。
#            2 为当 "角色回合"小于"回合参数"值时,回合开始前执行。
#            3 为当 "角色回合"等于"回合参数"值时,回合进行后执行。
#            4 为当 "角色回合"大于"回合参数"值时,回合进行后执行。
#            5 为当 "角色回合"小于"回合参数"值时,回合进行后执行。
#        
#       4.选择“回合对象”,勾上相应的"敌角色"或"角色",选择相应对象。
#       5.在“回合参数”框上填入相关数值。

#     二、循环回合条件设置,即当角色回合等于某个回合后执行事件,以后每隔N个回合在执行一次。
#         1. 参看“说明图片”文件夹中的图2对各个框的定义。
#         2.设置事件执行时机,即回合执行前或后。
#           对“事件执行时机参数”进行设置,取值如下:
#             0 为回合执行前。
#             1 为回合执行后。
#         3.设置"间隔参数",即当达到一定回合数后,每隔N个回合再执行事件的间隔。
#         4.设置相应“回合对象”
#         5.设置“回合参数”
#         6.如图3设置,把“间隔”设为回合。
#16、附赠角色显示动画函数:
#     $game_troop.interpreter.add_aa(动画对象,动画id)
#     "动画对象"取值:角色id或-1,-1时即全体动画
#      在事件的"脚本"中调用就可以了!
#
#           
#=============================================================================
#=============================================================================
#★战斗背景设置及其他功能开关
#=============================================================================
BATTLE_BACK = {"汪洋"=>"草地","树林"=>"山岛森林"} #地图名称与战斗背景对应关系,命名方式:地图名或区域=>战斗背景名
B_B_CONFIG = true #是否启用地图名称与战斗背景对应关系功能
#"汪洋"=>"草地1",


#================================================
#★战斗者类
#================================================
class Game_Battler
   attr_accessor :cp
   attr_accessor :cp_total
   #================================================
   attr_accessor :Battler_turn #角色单独的回合数
   attr_accessor :turn_start  #角色回合状态 0:回合结束或非角色回合 1:角色回合 3:角色回合准备
   #================================================
   attr_accessor :cp_turn #角色能不行动时,计算角色实际cp爆满次数,用以代替回合,计算状态解除时机
   #=======================================
  attr_accessor :animation2_id   
  attr_accessor :act_status
  attr_accessor :damage
  attr_accessor :damage_pop
  attr_accessor :slip_damage
  attr_accessor :auto_damage
  #=========================================
   
   alias oldinitialize  initialize
   def initialize
     @cp = 0
     @cp_total = false
     @cp_turn = 0
     @damage = nil
     @damage_pop = false
     @act_status = 0
     @slip_damage = 0
     @auto_damage = 0
     @Battler_turn = 0
     @turn_start = 0
     oldinitialize
   end
  def maxcp
    return 100
  end  
  #--------------------------------------------------------------------------
  # ● 应用连续伤害效果
  #--------------------------------------------------------------------------
  def slip_damage_effect
    if slip_damage? and @hp > 0
      @hp_damage = apply_variance(maxhp / 10, 10)
      @hp_damage = @hp - 1 if @hp_damage >= @hp
      @slip_damage = @hp_damage
      self.hp -= @hp_damage
    end
  end

end #class   
#===============================================
#★角色队伍类
#===============================================
class Game_Party < Game_Unit
attr_accessor :actor_battler
alias oldinitialize initialize
def initialize
  oldinitialize
  @actor_battler = []
end
end #class  
#================================================
#★敌人队伍类
#================================================
class Game_Troop < Game_Unit
  attr_accessor :enemy_battler
alias  oldinitialize initialize
def initialize
   oldinitialize
   @enemy_battler = []
end  
  #--------------------------------------------------------------------------
  # ● 判断是否符合战斗事件 (页) 条件
  #     page : 战斗事件页
  #--------------------------------------------------------------------------
  def conditions_met?(page)
    c = page.condition
    if not c.turn_ending and not c.turn_valid and not c.enemy_valid and
       not c.actor_valid and not c.switch_valid
      return false      # 未设置条件…不执行
    end
    if @event_flags

Lv1.梦旅人

梦石
0
星屑
50
在线时间
2 小时
注册时间
2009-4-6
帖子
43
2
 楼主| 发表于 2009-7-26 15:28:28 | 只看该作者
#=============================================================================
#★Zhong RMVX 半即时战斗系统 1.03b版★
#-----------------------------------------------------------------------------
#★Scene_CP核心部分参考自 : 神思  《战斗真位移》战斗系统
#★作者: Zhong_zw
#★联系方式: 66rpg.com论坛短信 或 [email protected]
#★游戏中如若引用本脚本,请保留以上信息,并作相关说明.
#☆如若转载本脚本请联系本人☆
#=============================================================================
#=============================================================================
#☆1.01版修正问题:
#1、物品、特技窗口选择我方人物时,头像重叠
#2、连续伤害及自动回复效果无效。
#☆1.02版修正问题:
#1、减少刷新次数,提高速度
#2、修正被打击时有可能退到cp槽外
#☆1.02a版修正问题:
#1、复活问题.
#2、头像刷新问题.
#☆1.03版更新内容:
#1、地图名称与战斗背景的对应关系可在哈希表中设置
#2、如无相应战斗背景直接采用默认战斗背景
#3、角色CP图缺失时,用角色相应行走图代替
#☆1.03a版更新内容:
#1、物品经验得失窗口有时图标显示错误的问题
#★注:旧版本的只要把脚本中“class Window_egi<Window_Base”这个类完整的覆盖原来就行了。
#☆1.03b版更新内容:
#1、图标战斗指令窗口刷新的问题
#2、修正战斗事件响应的部分功能
#=============================================================================
#☆使用方法说明☆
#☆使用方法基本与我之前发的朴素横版战斗相同
#☆动画设置:
#1、武器、特技、物品的施展动画直接在其备注填入动画id即可。如果为空即不显示施展动画。
#2、敌人普通攻击动画,在其备注里填写格式如下:
#  a1=XX #施展动画id
#  a2=XX #对方动画id
#如果为空即使用默认普通动画(画面震动).
#☆战斗图设置:
#3、角色战斗图的的命名方式是角色id后面加上_z,如1_z.存放在Battlers文件夹。
#4、默认待机图为两帧,只要在Battlers文件夹里放一个“战斗图名+待“的文件,就会自动循环播放
#这两个战斗图,如1_b待,没有则没待机动作。
#☆战斗背景设置:
#5、在Graphics目录下新建Battlebacks文件夹。
#6、战斗时先搜索文件夹内是否有与角色所在区域同名的战斗图,如果没有则搜索文件夹里是否
#存在与地图同名的图片。
#7、简而言之,你须储存与你地图同名的战斗背景在Battlebacks,如果想在同一幅地图实现不同地域
#战斗背景不同,就在Battlebacks文件夹里储存与这个地域同名的战斗背景.至少保证战斗的地图
#都有一幅该地图同名的战斗背景,不然战斗时会提示找不到地图.(可参考《拉尔夫战记》或朴素横版的范例)
#☆CP条设置:
#8、CP条:在system文件夹里储存一个命名为"cp条"的图片,默认长度为327,如果需要可在Scene_CP类里调整相
#关参数.
#9、角色cp图命名方式是"角色id+_cp",如:1_cp,角色活跃cp图命名方式是"角色id+_a_cp",如1_a_cp,
#敌人cp图命名方式是"敌人名 + _敌人cp",如史莱姆_敌人cp,敌人活跃cp图是"敌人名+_a_cp".
#亦可在system文件夹里储存名为"敌人cp"的图片,作为敌人的统一cp图,活跃图名为"a_敌人cp",默认如果找不到敌人相关cp图就直接
#用这张图片.
#☆选择光标设置
#10、在system文件夹里储存名为"光标"的图片作为选择光标.
#11、B_B_CONFIG = true 时地图与战斗背景的命名关系写在BATTLE_BACK 这个数组里,
#B_B_CONFIG = false时,和战斗背景和以前的命名方式相同。
#12、战斗背景文件缺失时,用回默认战斗背景。
#★队伍战斗事件的设置说明★:
#13、除“回合”和“回合结束”条件外,其他事件条件设置与默认系统相同。
#14、关于角色回合的定义:角色回合是指每个角色各自独有一个回合属性,角色CP值每满一次就增加一个回合,角色间的回合相互独立。
#15、关于角色回合条件设置,参照工程目录下的“说明图片”文件夹的图片1、2,3对各个框进行设置,实现两种回合条件的设置
#    步骤如下:
#     一、一般回合条件设置,即当角色回合等于或大于小于某个数值时就在回合开始前或后执行
#         事件。
#       1. 参看“说明图片”文件夹中的图1对各个框的定义。
#       2. 在事件条件设置窗口中勾上“回合结束”,即打开回合条件设置开关。
#       3. 勾上“回合数”,在“回合关系参数”框里输入“回合关系参数”。★注:旁边的那个框值为0
#       回合关系参数取值:
#            0 为当 "角色回合"等于"回合参数"值时,回合开始前执行。
#            1 为当 "角色回合"大于"回合参数"值时,回合开始前执行。
#            2 为当 "角色回合"小于"回合参数"值时,回合开始前执行。
#            3 为当 "角色回合"等于"回合参数"值时,回合进行后执行。
#            4 为当 "角色回合"大于"回合参数"值时,回合进行后执行。
#            5 为当 "角色回合"小于"回合参数"值时,回合进行后执行。
#        
#       4.选择“回合对象”,勾上相应的"敌角色"或"角色",选择相应对象。
#       5.在“回合参数”框上填入相关数值。

#     二、循环回合条件设置,即当角色回合等于某个回合后执行事件,以后每隔N个回合在执行一次。
#         1. 参看“说明图片”文件夹中的图2对各个框的定义。
#         2.设置事件执行时机,即回合执行前或后。
#           对“事件执行时机参数”进行设置,取值如下:
#             0 为回合执行前。
#             1 为回合执行后。
#         3.设置"间隔参数",即当达到一定回合数后,每隔N个回合再执行事件的间隔。
#         4.设置相应“回合对象”
#         5.设置“回合参数”
#         6.如图3设置,把“间隔”设为回合。
#16、附赠角色显示动画函数:
#     $game_troop.interpreter.add_aa(动画对象,动画id)
#     "动画对象"取值:角色id或-1,-1时即全体动画
#      在事件的"脚本"中调用就可以了!
#
#           
#=============================================================================
#=============================================================================
#★战斗背景设置及其他功能开关
#=============================================================================
BATTLE_BACK = {"汪洋"=>"草地","树林"=>"山岛森林"} #地图名称与战斗背景对应关系,命名方式:地图名或区域=>战斗背景名
B_B_CONFIG = true #是否启用地图名称与战斗背景对应关系功能
#"汪洋"=>"草地1",


#================================================
#★战斗者类
#================================================
class Game_Battler
   attr_accessor :cp
   attr_accessor :cp_total
   #================================================
   attr_accessor :Battler_turn #角色单独的回合数
   attr_accessor :turn_start  #角色回合状态 0:回合结束或非角色回合 1:角色回合 3:角色回合准备
   #================================================
   attr_accessor :cp_turn #角色能不行动时,计算角色实际cp爆满次数,用以代替回合,计算状态解除时机
   #=======================================
  attr_accessor :animation2_id   
  attr_accessor :act_status
  attr_accessor :damage
  attr_accessor :damage_pop
  attr_accessor :slip_damage
  attr_accessor :auto_damage
  #=========================================
   
   alias oldinitialize  initialize
   def initialize
     @cp = 0
     @cp_total = false
     @cp_turn = 0
     @damage = nil
     @damage_pop = false
     @act_status = 0
     @slip_damage = 0
     @auto_damage = 0
     @Battler_turn = 0
     @turn_start = 0
     oldinitialize
   end
  def maxcp
    return 100
  end  
  #--------------------------------------------------------------------------
  # ● 应用连续伤害效果
  #--------------------------------------------------------------------------
  def slip_damage_effect
    if slip_damage? and @hp > 0
      @hp_damage = apply_variance(maxhp / 10, 10)
      @hp_damage = @hp - 1 if @hp_damage >= @hp
      @slip_damage = @hp_damage
      self.hp -= @hp_damage
    end
  end

end #class   
#===============================================
#★角色队伍类
#===============================================
class Game_Party < Game_Unit
attr_accessor :actor_battler
alias oldinitialize initialize
def initialize
  oldinitialize
  @actor_battler = []
end
end #class  
#================================================
#★敌人队伍类
#================================================
class Game_Troop < Game_Unit
  attr_accessor :enemy_battler
alias  oldinitialize initialize
def initialize
   oldinitialize
   @enemy_battler = []
end  
  #--------------------------------------------------------------------------
  # ● 判断是否符合战斗事件 (页) 条件
  #     page : 战斗事件页
  #--------------------------------------------------------------------------
  def conditions_met?(page)
    c = page.condition
    if not c.turn_ending and not c.turn_valid and not c.enemy_valid and
       not c.actor_valid and not c.switch_valid
      return false      # 未设置条件…不执行
    end
    if @event_flags
      return false      # 已执行
    end

    if c.enemy_valid    # 敌方角色
      enemy = $game_troop.members[c.enemy_index]
      return false if enemy == nil
      if c.turn_ending == false  #
        return false if enemy.hp * 100.0 / enemy.maxhp > c.enemy_hp
      elsif c.turn_ending and not c.turn_valid  
        return false if enemy.Battler_turn != c.enemy_hp  or enemy.cp != 100
      elsif c.turn_ending and  c.turn_valid
        a = c.turn_a
        b = c.turn_b
       if b>0
        return false if (a==0 and ( c.enemy_hp < 1 or enemy.Battler_turn < c.enemy_hp or enemy.Battler_turn % b != c.enemy_hp % b or enemy.cp != 100 or enemy.turn_start != 1))
        return false if (a==1 and ( c.enemy_hp < 1 or enemy.Battler_turn < c.enemy_hp or enemy.Battler_turn % b != c.enemy_hp % b or enemy.cp != 100 or enemy.turn_start != 0))
       else
         if a == 0 #回合开始时 等于
          return false if ( enemy.Battler_turn != c.enemy_hp or enemy.cp != 100 or enemy.turn_start != 1)
         
          elsif a == 1 # #回合开始时 回合数大于
           return false if (enemy.Battler_turn <= c.enemy_hp or enemy.cp != 100 or enemy.turn_start != 1)
          elsif a == 2 #回合开始时 回合数小于
           return false if (enemy.Battler_turn >= c.enemy_hp or enemy.cp != 100 or enemy.turn_start != 1)
          elsif a == 3 #回合结束时 回合数等于
           return false if (enemy.Battler_turn != c.enemy_hp or enemy.cp != 100 or enemy.turn_start != 0)
          elsif a == 4 #回合结束时 回合数大于
           return false if (enemy.Battler_turn <= c.enemy_hp or enemy.cp != 100 or enemy.turn_start != 0)
          elsif a == 5 # 回合结束时 回合数小于
           return false if (enemy.Battler_turn >= c.enemy_hp or enemy.cp != 100 or enemy.turn_start != 0)
         end
       end
      end
    end
    if c.actor_valid    # 角色
      actor = $game_actors[c.actor_id]
      return false if actor == nil
      if c.turn_ending == false  #
        return false if actor.hp * 100.0 / actor.maxhp > c.actor_hp
      elsif c.turn_ending and not c.turn_valid  
        return false if actor.Battler_turn != c.actor_hp  or actor.cp != 100
      elsif c.turn_ending and  c.turn_valid
        a = c.turn_a
        b = c.turn_b
       if b > 0
        return false if (a== 0  and ( c.actor_hp < 1 or actor.Battler_turn < c.actor_hp or actor.Battler_turn % b != c.actor_hp % b or actor.cp != 100 or actor.turn_start != 1))
        return false if (a== 1  and ( c.actor_hp < 1 or actor.Battler_turn < c.actor_hp or actor.Battler_turn % b != c.actor_hp % b or actor.cp != 100 or actor.turn_start != 0))
       else
        if a == 0 # 等于
          return false if (actor.Battler_turn != c.actor_hp or actor.cp != 100 or actor.turn_start != 1)
         
        elsif a == 1 #回合开始时 回合数大于
          return false if (actor.Battler_turn <= c.actor_hp or actor.cp != 100 or actor.turn_start != 1)
        elsif a == 2 #回合开始时 回合数小于
          return false if (actor.Battler_turn >= c.actor_hp or actor.cp != 100 or actor.turn_start != 1)
        elsif a == 3 #回合结束时 回合数等于
          return false if (actor.Battler_turn != c.actor_hp or actor.cp != 100   or actor.turn_start != 0)
        elsif a == 4 #回合结束时 回合数大于
          return false if (actor.Battler_turn <= c.actor_hp or actor.cp != 100   or actor.turn_start != 0)
        elsif a == 5 #回合结束时 回合数小于
           return false if (actor.Battler_turn >= c.actor_hp or actor.cp != 100   or actor.turn_start != 0)
        end  
       end
      end  
        
    end
    if c.switch_valid   # 开关
      return false if $game_switches[c.switch_id] == false
    end
    return true         # 符合条件
  end
  #--------------------------------------------------------------------------
  # ● 增加回合
  #--------------------------------------------------------------------------
  def increase_turn
    for page in troop.pages
      if page.span == 1
        @event_flags= false
      end
    end
    #@turn_count += 1
  end

end#class
#================================================
#★cp条处理类
#================================================

class Scene_CP
    attr_accessor :stop
    attr_accessor :in_battler
    attr_accessor :cp_battler
    BATTLE_SPEED = 0.8
    def initialize
      @stop = false
      @all_agi = 0
      @v =  Viewport.new(0, 0, 544, 90)
      @count = 0
      @cpline = Sprite.new(@v)
      @cpline.bitmap = Bitmap.new(544,416)
      bitmap = Bitmap.new("Graphics/system/cp条")
      @cpline.bitmap.blt(105,8,bitmap,bitmap.rect)
      @cp_battler = {}
      @walk_count = 0
      for battler in $game_party.members + $game_troop.members
        @all_agi += battler.agi
        @cp_battler[battler] = Sprite_cpbattler.new
        if battler.is_a?(Game_Actor)
          name = battler.id.to_s + "_cp"
          if FileTest.exist?("Graphics/system/#{name}.jpg") or FileTest.exist?("Graphics/system/#{name}.png") or FileTest.exist?("Graphics/system/#{name}.bmp")
              bitmap = Bitmap.new("Graphics/system/#{name}")
              rect = bitmap.rect
              @cp_battler[battler].bitmap = bitmap
          else
              
               
               bitmap = Bitmap.new("Graphics/Characters/#{battler.character_name}")
                sign = battler.character_name[/^[\!\$]./]
                if sign != nil and sign.include?('$')
                  cw = bitmap.width / 3
                  ch = bitmap.height / 4
                  
                else
                  cw = bitmap.width / 12
                  ch = bitmap.height / 8
                  
                end
                 n = battler.character_index
                 rect = Rect.new((n%4*3+1)*cw, (n/4*4+2)*ch, cw, ch)
               
                 @cp_battler[battler].bitmap = Bitmap.new(cw,ch)
          end
         
         
          @cp_battler[battler].bitmap.blt(0, 0,bitmap,rect)
        else
          name = battler.original_name + "_敌人cp"
          if FileTest.exist?("Graphics/system/#{name}.jpg") or FileTest.exist?("Graphics/system/#{name}.png") or FileTest.exist?("Graphics/system/#{name}.bmp")
             @cp_battler[battler].bitmap = Bitmap.new("Graphics/system/#{name}")
          else
             @cp_battler[battler].bitmap = Bitmap.new("Graphics/system/敌人cp")
          end
             @cp_battler[battler].bitmap.blt(80,60, @cp_battler[battler].bitmap,  @cp_battler[battler].bitmap.rect)
        end  
        @cp_battler[battler].z = 101
        @cp_battler[battler].visible = false
        
      end
    end   
   
    #===========================================
   
   
   
   
    #===========================================
   
   
    def update
      
      return if @stop
      
      
      for battler in $game_party.members + $game_troop.members
        if (@cp_battler[battler].disposed? or @cp_battler[battler].opacity == 0) and battler.dead?
          @cp_battler.delete(@cp_battler[battler])
          next
        end  
        if battler.dead?
         if  @cp_battler.include?(battler)
              @cp_battler[battler].collapse = true
          end   
          battler.cp = 0
          next
        end  
       next if @cp_battler[battler].disposed?   
       battler.cp = [[battler.cp + BATTLE_SPEED*10*battler.agi / @all_agi,0].max,battler.maxcp].min if battler.movable?
       battler.cp_turn = [[battler.cp_turn+BATTLE_SPEED*10*battler.agi / @all_agi, 0].max,battler.maxcp].min
       if battler.cp == battler.maxcp
         #============================
         #☆设置战斗者处于回合准备状态
         #============================
           battler.turn_start = 3
         #============================  
         if battler.is_a?(Game_Actor)
              name = battler.id.to_s + "_a_cp"
              if FileTest.exist?("Graphics/system/#{name}.jpg") or FileTest.exist?("Graphics/system/#{name}.png") or FileTest.exist?("Graphics/system/#{name}.bmp")
               bitmap = Bitmap.new("Graphics/system/#{name}")
               rect = bitmap.rect
               @cp_battler[battler].bitmap = bitmap
              else
               
                bitmap = Bitmap.new("Graphics/Characters/#{battler.character_name}")
                sign = battler.character_name[/^[\!\$]./]
                if sign != nil and sign.include?('$')
                  cw = bitmap.width / 3
                  ch = bitmap.height / 4
                else
                  cw = bitmap.width / 12
                  ch = bitmap.height / 8
                end
                 n = battler.character_index
                 
                 rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
               
                 @cp_battler[battler].bitmap = Bitmap.new(cw,ch)
                 
              end
              
              @cp_battler[battler].bitmap.blt(0,0,bitmap,rect)
            
          else
            name = battler.original_name + "_a_cp"
            if FileTest.exist?("Graphics/system/#{name}.jpg") or FileTest.exist?("Graphics/system/#{name}.png") or FileTest.exist?("Graphics/system/#{name}.bmp")
            @cp_battler[battler].bitmap = Bitmap.new("Graphics/system/#{name}")
            else
            @cp_battler[battler].bitmap = Bitmap.new("Graphics/system/a_敌人cp")
            end
            @cp_battler[battler].bitmap.blt(80,60,  @cp_battler[battler].bitmap,  @cp_battler[battler].bitmap.rect)
          end  
            @cp_battler[battler].z = 101
            battler.cp_total = true
     
      elsif battler.cp_total == true
          if battler.is_a?(Game_Actor)
             name = battler.id.to_s + "_cp"
             if FileTest.exist?("Graphics/system/#{name}.jpg") or FileTest.exist?("Graphics/system/#{name}.png") or FileTest.exist?("Graphics/system/#{name}.bmp")
              bitmap = Bitmap.new("Graphics/system/#{name}")
              rect = bitmap.rect
              @cp_battler[battler].bitmap = bitmap
             else
              
                bitmap =  Bitmap.new("Graphics/Characters/#{battler.character_name}")
                sign = battler.character_name[/^[\!\$]./]
                if sign != nil and sign.include?('$')
                  cw = bitmap.width / 3
                  ch = bitmap.height / 4
                else
                  cw = bitmap.width / 12
                  ch = bitmap.height / 8
                end
                 n = battler.character_index
                 rect = Rect.new((n%4*3+1)*cw, (n/4*4+2)*ch, cw, ch)
                 
                 @cp_battler[battler].bitmap = Bitmap.new(cw,ch)
                 
                 
              end
            
              @cp_battler[battler].bitmap.blt(0,0,bitmap,rect)
            
            
          elsif  
             name = battler.original_name + "_敌人cp"
             if FileTest.exist?("Graphics/system/#{name}.jpg") or FileTest.exist?("Graphics/system/#{name}.png") or FileTest.exist?("Graphics/system/#{name}.bmp")
                 @cp_battler[battler].bitmap = Bitmap.new("Graphics/system/#{name}")
               
             else
                 @cp_battler[battler].bitmap = Bitmap.new("Graphics/system/敌人cp")
               
             end
               
               @cp_battler[battler].bitmap.blt(80,60, @cp_battler[battler].bitmap, @cp_battler[battler].bitmap.rect)
            end
            battler.cp_total = false
            @cp_battler[battler].z = 105
            
      end
      
      @cp_battler[battler].visible = true if @cp_battler[battler].visible == false
      @cp_battler[battler].opacity = 255
      @cp_battler[battler].y = 30
      @cp_battler[battler].x = 95+300*battler.cp/battler.maxcp
      if battler.cp_turn == battler.maxcp
        battler.remove_states_auto unless battler.movable?
        battler.slip_damage_effect
        battler.do_auto_recovery if battler.is_a?(Game_Actor)
        battler.damage_pop = true if battler.slip_damage != 0 or battler.auto_damage != 0
        battler.cp_turn = 0
      end  
      if battler.cp == battler.maxcp
         if battler.is_a?(Game_Actor)
           $game_party.actor_battler.push(battler)
         else
           battler.make_action
           $game_troop.enemy_battler.push(battler)
           battler.make_action
          end   
      else
        next
      end  
      
      
      
   end     
end

  def dispose
    for j in 0..25
    @cpline.opacity -= 10
    for i in @cp_battler.values
      unless i.disposed?
      i.opacity -= 10
      end
    end  
     Graphics.update
    end  
    @v.dispose
    @cpline.dispose
    for i in @cp_battler.values
      i.dispose unless i.disposed?
    end
  end  
end
  
  
  
  
  
  
  
  
  class Sprite_cpbattler < Sprite
    attr_accessor :collapse
   
    def initialize (viewport = nil)
      super (viewport)
     
      @effect_duration = 0        
      @collapse = false
    end
    def update
       super
  
     if self.collapse == true and self.opacity != 0
      @effect_type = 5
      @effect_duration = 48
      self.color.set(255, 128, 128, 128)
      for i in 0..48
      self.opacity = 256 - (48 - @effect_duration) * 6
      if self.opacity == 0
   
      break
      end  
      Graphics.update
      @effect_duration -= 1
      end
     
      self.collapse = false
      self.color.set(255,255,255,5)
     end
     
    end
   
  def dispose
     if self.bitmap != nil
      self.bitmap.dispose
     end
   
    super
  end
      
end  

#==========================================================================
#
#==========================================================================
class Scene_Battle < Scene_Base
  
  #--------------------------------------------------------------------------
  # ● 開始処理
  #--------------------------------------------------------------------------
  def start
    super
    #======================
    @select_input = true
    #======================
    $game_temp.in_battle = true
    #=============================================
    unless  $BTEST
      @battleback = nil
      for area in  $data_areas.values
        
        if $game_player.in_area?(area)
           
            name = area.name
            unless B_B_CONFIG
             @battleback = Cache.battleback("#{name}")if FileTest.exist?("Graphics/Battlebacks/#{name}.jpg") or FileTest.exist?("Graphics/Battlebacks/#{name}.jpg") or FileTest.exist?("Graphics/Battlebacks/#{name}.bmp")
               break
            else
              if BATTLE_BACK[name] != nil
                @battleback = Cache.battleback("#{BATTLE_BACK[name]}")if FileTest.exist?("Graphics/Battlebacks/#{BATTLE_BACK[name]}.jpg") or FileTest.exist?("Graphics/Battlebacks/#{BATTLE_BACK[name]}.jpg") or FileTest.exist?("Graphics/Battlebacks/#{BATTLE_BACK[name]}.bmp")
              end
              break  
               
               
           end
         end
      end     
        if @battleback == nil
            name = $game_map.name
            unless B_B_CONFIG
              
              @battleback = Cache.battleback("#{name}")if FileTest.exist?("Graphics/Battlebacks/#{name}.jpg") or FileTest.exist?("Graphics/Battlebacks/#{name}.jpg") or FileTest.exist?("Graphics/Battlebacks/#{name}.bmp")
            else
              if BATTLE_BACK[name] != nil
                 @battleback = Cache.battleback("#{BATTLE_BACK[name]}")
              else
                 @battleback = nil
              end
            end   
        end      
      $game_temp.background_bitmap  = @battleback if @battleback != nil
    end
   #==================================================
    @spriteset = Spriteset_Battle.new
    @message_window = Window_BattleMessage.new
    @message_window.visible = false
    @action_battlers = []
    @cp_battle = Scene_CP.new
    @cp_battle.stop = false
    create_info_viewport
   
   
    @select_icon = Sprite.new
    @select_icon.z = 148
    @select_icon.bitmap = Bitmap.new("Graphics/system/光标")
    @select_icon.opacity = 240
    @select_icon.visible = false
    @c_c = 0
   
   
  end
  
  #==============================================================
  #★ 定义光标刷新
  #==============================================================
   
  def select_icon_update(s_sw = false)
    if s_sw == false
      @select_icon.visible = false
    else
      @select_icon.visible = true
      @select_icon.x = $game_troop.members[@target_enemy_window.enemy.index].screen_x
      @select_icon.y = $game_troop.members[@target_enemy_window.enemy.index].screen_y - 30
      
      if @c_c%2 == 0
      @select_icon.opacity += 30
      else
      @select_icon.opacity -= 30  
      end
    end  
   
  end   
  
  
  #=================================================
  #★主刷新部分
  #=================================================
  
  
  def update
    super
   
    @c_c += 1
  
    update_basic(true)
    update_info_viewport               
      return if judge_win_loss            
      update_scene_change
      if @target_enemy_window != nil
        update_target_enemy_selection     
      elsif @target_actor_window != nil
        update_target_actor_selection     
      elsif @skill_window != nil
        update_skill_selection            
      elsif @item_window != nil
        update_item_selection            
      
      elsif @actor_command_window.active
        update_actor_command_selection   
      #=================================
      elsif @cp_battle.stop ==  false
        active_battler_update
      #=================================  
         
      end
      
    #end
  
      
  end
  #--------------------------------------------------------------------------
  # ● 战斗事件处理
  #--------------------------------------------------------------------------
  def process_battle_event
    #============================
    if $game_message.texts != nil
     @message_window.visible = true
    end
    #=============================
    loop do
      return if judge_win_loss
      return if $game_temp.next_scene != nil
      $game_troop.interpreter.update
      $game_troop.setup_battle_event
     # wait_for_message
      process_action if $game_troop.forcing_battler != nil
      #======================================
      unless $game_troop.interpreter.running?
         if $game_message.texts != nil
          @message_window.clear
          @message_window.visible = false
        end
         return
      end  
      #=======================================
      update_basic
    end
   
  end
  
  
  #================================================
  #★战斗初始化
  #===============================================
  
  def start_party_command_selection
    if $game_temp.in_battle
      @status_window.refresh
      @status_window.index = @actor_index = -1
      @active_battler = nil
     
     @actor_command_window.active = false
      $game_party.clear_actions
   
    for i in 0..$game_party.members.size-1
      if $game_party.members.act_status != -1
        $game_party.members.act_status = -1
      end  
    end
   
      if $game_troop.surprise or not $game_party.inputable?
        start_main
      end
    end
  end
  
  #=============================================
  #★角色回合的处理函数
  #=============================================
  
  
  def next_actor
   
    for i in 0..$game_party.members.size-1
      if $game_party.members.act_status != -1
        $game_party.members.act_status = -1
      end  
    end
  
    @info_viewport.visible = true
    @status_window.refresh
    @now_face = -1
    @actor_command_window.index = 0
    @actor_command_window.update
    @status_window.update
  
    loop do
   
      if @actor_index == @actor_battler.size - 1
      
        start_main
        return
        
      end   
      @actor_index += 1
      index = 0
      for battler in $game_party.members
        if battler == @actor_battler[@actor_index]
          break
        else
          index += 1
        end
      end  
      @status_window.index = index
     
       if @active_battler != nil and @active_battler != @actor_battler[@actor_index] and @active_battler.is_a?(Game_Actor)
        @active_battler.act_status = -1
      end
      
      @active_battler = @actor_battler[@actor_index]
     
     
      @active_battler.act_status = 1
      #=================================
      #★角色回合事件处理
      #================================
      @active_battler.Battler_turn += 1
      @active_battler.turn_start = 1
      $game_troop.increase_turn
      process_battle_event
      if @active_battler.auto_battle
        @active_battler.make_action
        next
      end
      break if @active_battler.inputable?
    end
    start_actor_command_selection
  end
  
  #===================================================
  #★激活角色指令窗口
  #===================================================
  
  def start_actor_command_selection
    @actor_command_window.setup(@active_battler)
    @actor_command_window.active = true
    @actor_command_window.index = 0
  end
  
  #==============================================
  #★指令窗口刷新
  #==============================================
   def update_actor_command_selection
   
    if Input.trigger?(Input::C)
      case @actor_command_window.index
      when 0  # 攻击
        Sound.play_decision
        @active_battler.action.set_attack
        start_target_enemy_selection
      when 1  # 特技
        Sound.play_decision
        start_skill_selection
      when 2  # 防御
        Sound.play_decision
        @active_battler.action.set_guard
        next_actor
        #@active_battler.cp = 0
      when 3  # 物品
        Sound.play_decision
        start_item_selection
      
      when 4 #逃跑
        if $game_troop.can_escape == false
          Sound.play_buzzer
          return
        end
        Sound.play_decision
        process_escape
    end
    end
  end
  
  #====================================
  #★选择敌人
  #====================================
  def start_target_enemy_selection
     if @skill_window != nil
      @skill_window.visible = false
    end
    if @item_window != nil
      @item_window.visible = false
    end  
    @target_enemy_window = Window_TargetEnemy.new
    @target_enemy_window.opacity = 0
    @target_enemy_window.contents_opacity = 0
    #@target_enemy_window.y = @info_viewport.rect.y
    #@info_viewport.rect.x += @target_enemy_window.width
    #@info_viewport.ox += @target_enemy_window.width
    @actor_command_window.active = false
  
    select_icon_update(true)
  end
  #===========================================================
  #★结束敌人选择
  #===========================================================
   def end_target_enemy_selection
    #@info_viewport.rect.x -= @target_enemy_window.width
    #@info_viewport.ox -= @target_enemy_window.width
    @target_enemy_window.dispose
    @target_enemy_window = nil
   
    select_icon_update
   
    if @actor_command_window.index == 0
      @actor_command_window.active = true
    end
  end  
  #=======================================================
  #★敌人选择刷新
  #=======================================================
  def update_target_enemy_selection
   @target_enemy_window.update
   
    select_icon_update(true)

    if Input.trigger?(Input::B)
      Sound.play_cancel
      if @skill_window != nil
        @skill_window.visible = true
      end
      if @item_window != nil
        @item_window.visible = true
      end  
      end_target_enemy_selection
    elsif Input.trigger?(Input::C)
      Sound.play_decision
      @active_battler.action.target_index = @target_enemy_window.enemy.index
      end_target_enemy_selection
      end_skill_selection
      end_item_selection
      next_actor
     # @active_battler.cp = 0
    end
  end
  
  #======================================================
  #★己方选择
  #======================================================
  def start_target_actor_selection
    @target_actor_window = Window_BattleStatus.new
    @target_actor_window.index = 0
    @target_actor_window.active = true
    @target_actor_window.y = @info_viewport.rect.y
    @target_actor_window.draw_actorface($game_party.members[@target_actor_window.index])
    @info_viewport.rect.x += @target_actor_window.width
    @info_viewport.ox += @target_actor_window.width
    @actor_command_window.active = false
    #=====================
    #☆减少刷新次数
    #=====================
    @last_index = -1
  end
  #==================================================
  #★己方选择结束处理
  #==================================================
  def end_target_actor_selection
    @info_viewport.rect.x -= @target_actor_window.width
    @info_viewport.ox -= @target_actor_window.width
    @target_actor_window.dispose
    @target_actor_window = nil
    #=====================
    #☆减少刷新次数
    #=====================
    @last_index = -1
  end
  #===================================================
  #★己方选择刷新
  #===================================================
  def update_target_actor_selection
    if @last_index != @target_actor_window.index
     @target_actor_window.refresh
     @target_actor_window.draw_actorface($game_party.members[@target_actor_window.index])
     @last_index = @target_actor_window.index
    end
    @target_actor_window.update
    if Input.trigger?(Input::B)
      Sound.play_cancel
      end_target_actor_selection
    elsif Input.trigger?(Input::C)
      Sound.play_decision
      @active_battler.action.target_index = @target_actor_window.index
     
      end_target_actor_selection
      end_skill_selection
      end_item_selection
      next_actor
     # @active_battler.cp = 0
    end
  end
  #============================================
  #★特技使用决定  处理
  #===========================================
  
  
  def determine_skill
    @active_battler.action.set_skill(@skill.id)
    @skill_window.active = false
    if @skill.need_selection?
      if @skill.for_opponent?
        start_target_enemy_selection
      else
        start_target_actor_selection
      end
    else
      end_skill_selection
      next_actor
     # @active_battler.cp = 0
    end
  end
  #=========================================
  #★物品使用决定  处理
  #=========================================
  
  
  def determine_item
    @active_battler.action.set_item(@item.id)
    @item_window.active = false
    if @item.need_selection?
      if @item.for_opponent?
        start_target_enemy_selection
      else
        start_target_actor_selection
      end
    else
      end_item_selection
      next_actor
     #  @active_battler.cp = 0
    end
  end
  
  #===============================================
  #★各窗口视口生成
  #===============================================
   def create_info_viewport
    @info_viewport = Viewport.new(0, 288, 544, 256)
    @info_viewport.z = 100
    @status_window = Window_BattleStatus.new
    @actor_command_window = Window_ActorCommand.new
    @status_window.viewport = @info_viewport
    @actor_command_window.viewport = @info_viewport
    @status_window.x = 0
    @actor_command_window.x = 416
    @status_window.y = 128
    @actor_command_window.y = 128
    @info_viewport.visible = false
    #========================
    #☆减少头像刷新用
    #========================
    @now_face = -1
   
  end
  #================================================
  #★视口释放
  #================================================
  def dispose_info_viewport
    @status_window.dispose
    @actor_command_window.dispose
    @info_viewport.dispose
    #========================
    #☆减少头像刷新用
    #========================
    @now_face = -1
    if @window_egi != nil
     @window_egi.dispose
    end
  end
  #======================================================
  #★视口刷新
  #======================================================
  
  
  def update_info_viewport
   
    @actor_command_window.update
   
  
    if @active_battler != nil and @active_battler.is_a?(Game_Actor) and @active_battler.id != @now_face
      @status_window.draw_actorface(@active_battler)
      @now_face = @active_battler.id
    end  
   
   
    @status_window.update
   
   
   
    if @actor_command_window.active and   @actor_command_window.y > 0
     @actor_command_window.y -= 8
     @status_window.y -= 8
   
   
    end

  end
  
  #================================================
  #★战斗开始 处理
  #================================================
  
  def process_battle_start
   
   
    if $game_troop.preemptive
     
      for battler in $game_party.members
         battler.cp = battler.maxcp
       end  
       $game_troop.preemptive = false
    elsif $game_troop.surprise
      
      for battler in $game_troop.members
        battler.cp = battler.maxcp
      end
      $game_troop.surprise = false
    end
   
    make_escape_ratio
    process_battle_event
   
    #===========================================
    @status_window.refresh
    @status_window.index = @actor_index = -1
   
    #=====================
    @cp_battle.stop = false
    #=====================
  
  end
  #=========================================
  #★战斗结束cp条释放处理
  #=========================================
  def dispose_cp_battle
      #=============================
      @cp_battle.dispose
      #=============================
      for battler in $game_party.members + $game_troop.members
        battler.cp = 0
        #=========================
        battler.Battler_turn = 0
        battler.turn_start = 0
        #=========================
      end  
  
  end
  
  #==========================================
  #★逃走处理
  #==========================================
  def process_escape
    @message_window.visible = false
    @info_viewport.visible = false
   
    if $game_troop.preemptive
      success = true
    else
      success = (rand(100) < @escape_ratio)
    end
    Sound.play_escape
    if success
      #=============================
      @cp_battle.dispose
      #=============================
      for battler in $game_party.members
        battler.cp = 0
        #=========================
        battler.Battler_turn = 0
        battler.turn_start = 0
        #=========================
      end  
     
      battle_end(1)
    else
      @escape_ratio += 10
     
      #@active_battler.cp = 0
      @active_battler.action.clear
      next_actor   
    end
  end
  #========================================
  #★胜利处理
  #========================================
  def process_victory
    @message_window.visible = false
    @info_viewport.visible = false
  
    RPG::BGM.stop
    $game_system.battle_end_me.play
    for battler in $game_troop.members
      if battler.dead?
         if  @cp_battle.cp_battler.include?(battler)
              @cp_battle.cp_battler[battler].collapse = true
              
              next
          end  
       end     
    end
     @cp_battle.cp_battler.each{|key,value|
      if value.disposed?
        @cp_battler.delete(key)
        next
      end
      value.update}
    #=============================
    @cp_battle.dispose
    #=============================
   for battler in $game_party.members
      #=========================
      battler.Battler_turn = 0
      battler.turn_start = 0
      #=========================
     battler.cp = 0
   end
    unless $BTEST
      $game_temp.map_bgm.play
      $game_temp.map_bgs.play
    end
    display_exp_and_gold
    display_drop_items
    display_level_up
    battle_end(0)
  end
   
  #=================================
  #★失败处理
  #=================================
  def process_defeat
    @message_window.visible = false
    @cp_battle.dispose
    for battler in $game_party.members + $game_troop.members
      #=========================
      battler.Battler_turn = 0
      battler.turn_start = 0
      #=========================
      battler.cp = 0
    end
    @info_viewport.visible = false
   
    battle_end(2)
   
  end
  #=====================================
  # ★ 执行画面转换
  #=====================================
  def update_scene_change
    case $game_temp.next_scene
    when "map"
      dispose_cp_battle
      call_map
    when "gameover"
      dispose_cp_battle
      call_gameover
    when "title"
      dispose_cp_battle
      call_title
    else
      $game_temp.next_scene = nil
    end
  end
  #=============================================================================
  #★CP战斗的主要刷新★
  #=============================================================================
  
   def active_battler_update
   
    #===================================
    @actor_battler = []
    @enemy_battler = []
    $game_party.actor_battler = []
    $game_troop.enemy_battler = []
    #===================================
    @cp_battle.update
    @actor_battler = $game_party.actor_battler
    @enemy_battler = $game_troop.enemy_battler
    #for battler in $game_party.members + $game_troop.members
      
    #end
    if @actor_battler.size != 0
      @cp_battle.stop = true
#~       @active_battler.Battler_turn += 1
#~       @active_battler.turn_start = 1
#~       $game_troop.increase_turn
#~       process_battle_event
      next_actor
      Audio.se_play("Audio/SE/Jump2",100,100)
    elsif @enemy_battler.size != 0  
   
    #================
    @cp_battle.stop = true
    start_main
    #================
   
   
     
   end
  
end

#=============================================================
#=============================================================
  #====================================================
  #★战斗主处理
  #====================================================
   def start_main
   
    for i in 0..$game_party.members.size-1
      if $game_party.members.act_status != 0
        $game_party.members.act_status = 0
      end  
    end
   
   
   
    if @info_viewport.visible
    @info_viewport.visible = false
    @status_window.y = 128
    @actor_command_window.y = 128
    end
    @actor_command_window.index = 0
    @actor_command_window.update
    @actor_command_window.active = false
   
    @status_window.index = @actor_index = -1
    @active_battler = nil
  
    make_action_orders
    wait(20)
   #=============================
  
   while @action_battlers.size != 0 and judge_win_loss == false
        process_action
        #process_battle_event
   end
   @cp_battle.stop = false
   #=============================
   
end
#=====================================
#★行动顺序生成
#=====================================


def make_action_orders
    @action_battlers = []
   
    unless $game_troop.surprise
      @action_battlers += @actor_battler if @actor_battler.size != 0
    end
   
   
    unless $game_troop.preemptive
      @action_battlers += @enemy_battler if @enemy_battler.size != 0
    end
    for battler in @action_battlers
      
      battler.action.make_speed
    end
    @action_battlers.sort! do |a,b|
      b.action.speed - a.action.speed
    end
  end
#====================================
#★战斗行动处理
#====================================
def process_action
   
    return if judge_win_loss
    return if $game_temp.next_scene != nil
    set_next_active_battler
   
    return if @active_battler == nil
    return if @active_battler.dead?
   
    @active_battler.white_flash = true
   
    unless @active_battler.is_a?(Game_Actor)
      @active_battler.Battler_turn += 1
      @active_battler.turn_start = 1
      $game_troop.increase_turn
      process_battle_event
    end  
   
    unless @active_battler.action.forcing
      @active_battler.action.prepare
    end
    if @active_battler.action.valid?
      execute_action
    end
   
    unless @active_battler.action.forcing
     
      remove_states_auto
      display_current_state
    end
    @active_battler.white_flash = false
    @active_battler.turn_start = 0
    process_battle_event
    @active_battler.cp = 0
  end

  #=================================
  #★攻击行动 执行
  #=================================
  def execute_action_attack
   
    targets = @active_battler.action.make_targets
    display_attack_animation(targets)
    wait(20)
    for target in targets
      target.attack_effect(@active_battler)
      display_action_effects(target)
    end
    #=====================
    #@active_battler.cp = 0
    #=====================
   end
  #===============================
  #★防御行动   执行
  #===============================
   
   
   def execute_action_guard
   
    wait(45)
    #=====================
    #@active_battler.cp = 0
    #=====================
  end
   #===============================
   #★逃走  执行
   #===============================
  
  def execute_action_escape
   
    @active_battler.escape
    Sound.play_escape
    wait(45)
    #=====================
    #@active_battler.cp = 0
    #=====================
  end
  #====================================
  #★待机  执行
  #====================================
  def execute_action_wait
   
    wait(45)
    #=====================
    #@active_battler.cp = 0
    #=====================
  end
  
  #============================
  #★特技   执行
  #============================
  def execute_action_skill
    skill = @active_battler.action.skill
   
    targets = @active_battler.action.make_targets
   
   
    user = @active_battler.action.skill_user
    if skill.animation2_id != 0
      display_animation(user,skill.animation2_id)
    end  
    display_animation(targets, skill.animation_id)
   
    wait_for_animation
   
    @active_battler.mp -= @active_battler.calc_mp_cost(skill)
    $game_temp.common_event_id = skill.common_event_id
    for target in targets
      target.skill_effect(@active_battler, skill)
      display_action_effects(target, skill)
    end
    #=====================
    #@active_battler.cp = 0
    #=====================
  end
  
  #==============================
  #★物品行动 执行
  #==============================
  
  def execute_action_item
    item = @active_battler.action.item
   
   
    user = @active_battler.action.skill_user
    if item.animation2_id != 0
      display_animation(user,item.animation2_id)
    end  
   
   
    targets = @active_battler.action.make_targets
    display_animation(targets, item.animation_id)
   
    wait_for_animation
   
    $game_party.consume_item(item)
    $game_temp.common_event_id = item.common_event_id
    for target in targets
      target.item_effect(@active_battler, item)
      display_action_effects(target, item)
    end
    #=====================
   # @active_battler.cp = 0
    #=====================
  end
  #===========================
  #★行动动画显示
  #animation_id :-1 为普通攻击
  #===========================
  def display_animation(targets, animation_id)
    if animation_id < 0
      display_attack_animation(targets)
    else
      display_normal_animation(targets, animation_id)
    end
    wait(20)
   
  end
  #====================================
  #★普通攻击的动画显示
  #====================================
  def display_attack_animation(targets)

    if @active_battler.is_a?(Game_Enemy)
        user = @active_battler.action.skill_user
      if @select_input == true
        a1 = 0
        a2 = 0
        eval(@active_battler.note)
        display_normal_animation(user,a1)if   a1 != 0
        display_normal_animation(targets,a2)if  a2 !=0
        Sound.play_enemy_attack if   a1 == 0 and a2 == 0
        wait(15, true) if  a1 == 0 and  a2 == 0
      elsif @active_battler.animation1_id != 0 or @active_battler.animation2_id != 0
            display_normal_animation(user,@active_battler.animation1_id)if @active_battler.animation1_id != 0
            display_normal_animation(targets,@active_battler.animation2_id)if @active_battler.animation2_id != 0
            Sound.play_enemy_attack if  @active_battler.animation1_id == 0 and @active_battler.animation2_id == 0
            wait(15, true) if  @active_battler.animation1_id == 0 and @active_battler.animation2_id == 0
       end     
   
   
   else
      aid1 = @active_battler.atk_animation_id
      aid2 = @active_battler.atk_animation_id2
     
      user = @active_battler.action.skill_user
      if @active_battler.act_animation_id != 0
        display_normal_animation(user,@active_battler.act_animation_id)
      end  
     
   
      
      display_normal_animation(targets, aid1, false)
      display_normal_animation(targets, aid2, true)
    end
    wait_for_animation
  end
  
  #========================================
  #★显示行动结果
  #========================================
   def display_action_effects(target, obj = nil)
    unless target.skipped
     
      wait(5)
      #=======================
      target.damage_pop = true
      #=======================
      display_critical(target, obj)
      display_damage(target, obj)
      display_state_changes(target, obj)
   
    end
  end
  
  #======================================
  #★显示HP伤害
  #======================================
  
  
  def display_hp_damage(target, obj = nil)
     
    if target.hp_damage == 0               
      return if obj != nil and obj.damage_to_mp
      return if obj != nil and obj.base_damage == 0
      
    elsif target.absorbed                   # 吸収
     
       #=====================================
      @active_battler.damage_pop = true
      @active_battler.damage = target.hp_damage
     
      target.cp -= target.hp_damage/100
      target.cp = [target.cp,0].max
      @cp_battle.cp_battler[target].x = [95+300*target.cp/target.maxcp,95].max
     if target.dead?
         @cp_battle.cp_battler[target].collapse = true
         target.cp = 0
         @cp_battle.cp_battler[target].update
      end
      
      
   
      #=====================================
    elsif target.hp_damage > 0            
     
      if target.actor?
      
        Sound.play_actor_damage
        $game_troop.screen.start_shake(5, 5, 10)
      else
      
        Sound.play_enemy_damage
        target.blink = true
      end
      #=====================================
      
      target.cp -= target.hp_damage/100
      target.cp = [target.cp,0].max
      @cp_battle.cp_battler[target].x = [95 + 300*target.cp/target.maxcp,95].max
      
      if target.dead?
         @cp_battle.cp_battler[target].collapse = true
         target.cp = 0
         @cp_battle.cp_battler[target].update
      end
      
     
      #wait(10)
      #=====================================
    else                                    
     
      Sound.play_recovery
    end
   
  end
  #--------------------------------------------------------------------------
  # ● MP 伤害表示
  #--------------------------------------------------------------------------
  def display_mp_damage(target, obj = nil)
    return if target.dead?
    return if target.mp_damage == 0
   
    if target.absorbed                      # 吸收
      
      #=====================================
      @active_battler.damage_pop = true
      @active_battler.damage = - target.mp_damage
     
      
      target.cp -= target.mp_damage/100
      target.cp = [target.cp,0].max
      @cp_battle.cp_battler[target].x = [95+300*target.cp/target.maxcp,95].max
      
      #=====================================
    elsif target.mp_damage > 0              
   
     #=====================================
      target.cp -= target.mp_damage/100
      target.cp = [target.cp,0].max
      @cp_battle.cp_battler[target].x = [95+300*target.cp/target.maxcp,95].max
      
      #=====================================
    else                                    
   
      Sound.play_recovery
    end
   
  end
  #=======================================
  #★重定义对话窗口刷新
  #=======================================
  def wait_for_message
   #wait(45)
  end
  
  #================================================
  #★经验金钱获得物品提示窗口(原方法重定义)
  #================================================
  def display_exp_and_gold
    exp=$game_troop.exp_total
    gold=$game_troop.gold_total
    $game_party.gain_gold(gold)
    drop_items = $game_troop.make_drop_items
    @window_egi = Window_egi.new(exp,gold,drop_items)
    @window_egi.openness=0
    wait(15)
    loop do
      if @window_egi.openness <= 255
       @window_egi.openness+=48
      end
      if Input.trigger?(Input::C) or Input.trigger?(Input::B)
        break
      end
      Graphics.update
      Input.update
      
      
    end
   
    loop do
      @window_egi.openness -= 48 if @window_egi.openness >= 0
      Graphics.update
      if @window_egi.openness <= 0
        break
      end  
    end #loop
   
  end

  alias oldstart_skill_selection  start_skill_selection
  def start_skill_selection
    oldstart_skill_selection
    @skill_window.z = 3000
    @skill_window.help_window.z = 3000
   
  end  
  alias oldstart_item_selection  start_item_selection
  def start_item_selection
    oldstart_item_selection
    @item_window.z=3000
    @item_window.help_window.z = 3000
  end  
  

  
end #class


#=====================================================
#★战斗状态窗口类
#=====================================================


class Window_BattleStatus < Window_Selectable
  
  
  def draw_item(index)
    rect = item_rect(index)
    rect.x += 4
    rect.width -= 8
    self.contents.clear_rect(rect)
    self.contents.font.color = normal_color
    actor = $game_party.members[index]
    draw_actor_name(actor, 96, rect.y)
    draw_actor_state(actor, 114+48, rect.y, 48)
    draw_actor_hp(actor, 174, rect.y, 120)
    draw_actor_mp(actor, 310, rect.y, 70)
  end
  #=======================================================================
  #★定义角色头像的描绘
  #=======================================================================
   def draw_actorface(actor)
      
    draw_face(actor.face_name, actor.face_index, 5, 5, size = 80)
  end
  #=========================================================================
  
  def update_cursor
     super
     self.cursor_rect.width = self.width - 120
     self.cursor_rect.x = 90
     
  end  
  #========================================================================
end #class

#=================================================
#★战斗图处理的类
#=================================================

class Sprite_Battler < Sprite_Base
  
#=================================
#★刷新
#=================================
def update
    super
    if @battler == nil
      self.bitmap = nil
    else
      @use_sprite = @battler.use_sprite?
      if @use_sprite
        self.x = @battler.screen_x
        self.y = @battler.screen_y
        self.z = @battler.screen_z
        update_battler_bitmap
        if @battler.act_status == 1
         if self.opacity <280
           self.opacity += 20
        end
      elsif @battler.act_status == -1
         if self.opacity > 125
           self.opacity -= 20
         end  
      elsif  (@battler.dead? or   @battler.hidden) and @battler.collapse == false
      
      else
        self.opacity = 255
      end  
      end
      
      setup_new_effect
      update_effect
     
    end
  end  
#===============================
#
#===============================
  def update_battler_bitmap
    if @battler.battler_name != @battler_name or
       @battler.battler_hue != @battler_hue
      @battler_name = @battler.battler_name
      @battler_hue = @battler.battler_hue
      self.bitmap = Cache.battler(@battler_name, @battler_hue)
      @width = bitmap.width
      @height = bitmap.height
      self.ox = @width / 2
      self.oy = @height
      if (@battler.dead? or @battler.hidden) and @battler.collapse == false
        
      end
    end
    if @battler.is_a?(Game_Actor)
      count = 40
    else
      count = 44
    end  
   
   
    if Graphics.frame_count%count <= 19
      self.bitmap = Cache.battler(@battler_name,@battler_hue)
      @width = bitmap.width
      @height = bitmap.height
      self.ox = @width / 2
      self.oy = @height
    else
      b_name = @battler_name + "待"
       if FileTest.exist?("Graphics/Battlers/#{b_name}.png") or FileTest.exist?("Graphics/Battlers/#{b_name}.jpg")  or  FileTest.exist?("Graphics/Battlers/#{b_name}.bmp")
         self.bitmap = Cache.battler(b_name,@battler_hue)
         @width = bitmap.width
         @height = bitmap.height
         self.ox = @width/2
         self.oy = @height
       end
    end      
      
   
  end
  
#==================================
#
#==================================
def setup_new_effect
    if @battler.white_flash
      @effect_type = WHITEN
      @effect_duration = 16
      @battler.white_flash = false
    end
   
    if @battler.blink
      @effect_type = BLINK
      @effect_duration = 20
      @battler.blink = false
    end
    if not @battler_visible and @battler.exist?
      @effect_type = APPEAR
      @effect_duration = 16
      @battler_visible = true
    end
    if @battler.damage_pop and not (@battler.collapse or @battler.hidden)
      if @battler.damage != nil
        s_1 = @battler.damage > 0 ? 0 : 1
        @battler.damage = @battler.damage > 0 ? [email protected] : @battler.damage
      end  
      
      damage(@battler.damage,@battler.critical,s_1) if @battler.damage != 0 and @battler.damage != nil
      damage(@battler.hp_damage,@battler.critical,0) if @battler.hp_damage != 0
      damage(@battler.mp_damage,@battler.critical,1) if @battler.mp_damage != 0
      damage("失误",@battler.critical) if @battler.missed
      damage("MISS",@battler.critical) if @battler.evaded
      damage(@battler.slip_damage - @battler.auto_damage,@battler.critical) if @battler.slip_damage != 0 or @battler.auto_damage != 0
      @battler.slip_damage = 0
      @battler.auto_damage = 0
      @battler.damage = nil
      @battler.damage_pop = false
    end
    if @battler_visible and @battler.hidden
      @effect_type = DISAPPEAR
      @effect_duration = 32
      @battler_visible = false
    end
    if @battler.collapse and self.opacity != 0
      @effect_type = COLLAPSE
      @effect_duration = 48
      @battler.collapse = false
      @battler_visible = false
    end
    if @battler.animation_id != 0 and @battler.collapse == false
      self.opacity = 255
      animation = $data_animations[@battler.animation_id]
      mirror = @battler.animation_mirror
      start_animation(animation, mirror)
      @battler.animation_id = 0
    end
   
      
  end
#=========================================
#
#=========================================
  
  

  
  
end #class  








#=================================================
#★处理战斗行动的类
#=================================================
class Game_BattleAction

  def skill_user
    targets = []
    targets.push(battler)
     
     return targets.compact
   end
  

  
   
end#class  
#=======================================================
#★处理敌人的类
#
#=======================================================

class Game_Enemy < Game_Battler
def note
    return $data_enemies[@enemy_id].note
end  

  
end#class
#======================================================
#★角色处理类
#======================================================
class Game_Actor < Game_Battler

  def setup(actor_id)
    actor = $data_actors[actor_id]
    @actor_id = actor_id
    @name = actor.name
    #--------------------------------------------
    #★添加战斗图名称,以便战斗中获取战斗图
    #--------------------------------------------
    @battler_name = actor_id.to_s + "_z"
    @battler_hue = 0
    @flash = false
    @character_name = actor.character_name
    @character_index = actor.character_index
    @face_name = actor.face_name
    @face_index = actor.face_index
    @class_id = actor.class_id
    @weapon_id = actor.weapon_id
    @armor1_id = actor.armor1_id
    @armor2_id = actor.armor2_id
    @armor3_id = actor.armor3_id
    @armor4_id = actor.armor4_id
    @level = actor.initial_level
    @exp_list = Array.new(101)
    make_exp_list
    @exp = @exp_list[@level]
    @skills = []
    for i in self.class.learnings
      learn_skill(i.skill_id) if i.level <= @level
    end
    clear_extra_values
    recover_all
  end
  
  #--------------------------------------------------------------------------
  # ● 执行自动回复 (回合结束时调用)
  #--------------------------------------------------------------------------
  def do_auto_recovery
    if auto_hp_recover and not dead?
      self.hp += maxhp / 20
      @auto_damage = maxhp / 20
    end
  end
  #==========================================================================
  #★ 定义武器的行动方动画id,默认为第一武器的id
  #==========================================================================
  
  def act_animation_id
    return weapons[0] == nil ? 0 : weapons[0].animation2_id
  end  
  
  #==========================================================================
  #==========================================================================
  #==========================================================================
  #★定义角色战斗图 X 坐标
  #==========================================================================
  def screen_x
   if self.index != nil
    case index
     when 0
      return 460
     when 1
      return 440
     when 2
      return 420
     when 3
      return 400
    end  
  else
   return 0
  end
end
  #========================================================================
  #★定义角色战斗图 Y 坐标
  #========================================================================
  def screen_y
    if self.index != nil
      case index
       when 0
         return 245
       when 1
         return 215
       when 2
         return 185
       when 3
         return 155
       end
    else   
   
    return 230
   end
  end  
  
  #========================================================================
  #★定义角色战斗图 Z 坐标
  #========================================================================   
  def screen_z
     if self.index != nil
      return 4 - self.index
    else
      return 0
    end
  end
  
  

  
  def use_sprite?
    return true
  end
  
end#class




#==========================================================
#★模块定义
#==========================================================
  module RPG
  class BaseItem
    def animation2_id
      return @note != nil ? @note.to_i : 0
    end
  end  
   class Enemy
     def animation1_id
       animation1_id = @note.split(/,/)[0]
       return animation1_id != nil ? animation1_id.to_i : 0
     end
     def animation2_id
       animation2_id = @note.split(/,/)[1]
       return animation2_id != nil ? animation2_id.to_i : 0
     end
    end
   
  end
  
  
#======================================================
#★精灵类主模块_伤害部分的添加
#======================================================
class Sprite_Base < Sprite
  def initialize(viewport = nil)
    super(viewport)
    @use_sprite = true         
    @animation_duration = 0     
    #=============
    @_damage_duration = 0
    #=============
  end
alias oldupdate update
  def update
    oldupdate
    #================
    damge_update
    #================

  end

alias olddispose dispose
   def dispose
     olddispose
     
    #===============
    dispose_damage
    #===============
   end
  
#==========================================================================
#★定义伤害处理
#==========================================================================

   def damage(value, critical,type = 0)
      dispose_damage
      if value.is_a?(Numeric)
        damage_string = value.abs.to_s
      else
        damage_string = value.to_s
      end
      bitmap = Bitmap.new(160, 48)
      bitmap.font.name = "黑体"
      bitmap.font.size = 25
      bitmap.font.color.set(0, 0, 0)
      bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
      bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
      bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
      bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
      if value.is_a?(Numeric) and value < 0
        case type
         when 0
           bitmap.font.color.set(176, 255, 144)
         when 1
           bitmap.font.color.set(0,100,255)
         end  
      else
        case type
        when 0
        bitmap.font.color.set(255, 255, 255)
        when 1
          bitmap.font.color.set(200,0,185)
        end  
      end
      
      bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
      if critical and type == 0
        bitmap.font.size = 18
        bitmap.font.color.set(0, 0, 0)
        bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
        bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
        bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
        bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
        bitmap.font.color.set(255, 255, 255)
        bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
      end
      @_damage_sprite = ::Sprite.new(self.viewport)
      @_damage_sprite.bitmap = bitmap
      @_damage_sprite.ox = 80
      @_damage_sprite.oy = 20
      @_damage_sprite.x = self.x
      @_damage_sprite.y = self.y - self.oy / 2
      @_damage_sprite.z = 3000
      @_damage_duration = 40
    end
   
    #===================================================
    #
    #===================================================
    def dispose_damage
      if @_damage_sprite != nil
        @_damage_sprite.bitmap.dispose
        @_damage_sprite.dispose
        @_damage_sprite = nil
        @_damage_duration = 0
      end
    end
    #=============================================
    #
    #=============================================
    def damge_update
       if @_damage_duration > 0
        @_damage_duration -= 1
        case @_damage_duration
        when 38..39
          @_damage_sprite.y -= 4
        when 36..37
          @_damage_sprite.y -= 2
        when 34..35
          @_damage_sprite.y += 2
        when 28..33
          @_damage_sprite.y += 4
        end
        @_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32
        if @_damage_duration == 0
          dispose_damage
        end
      end
   end
  
  

end#class
#=======================================================
#★战斗经验、金钱、物品提示窗口
#=======================================================
class Window_egi<Window_Base
#====================================
#●初始化
#====================================
def initialize(exp, gold,item)
   
   
    @exp=exp
    @gold=gold
    @item=item
    @item_name = {}
    n=0
    m=0
   
    if @item != nil
     for itn in @item
      
      if @item_name[itn.name]==nil
         @item_name[itn.name]=[0,""]
         @item_name[itn.name][1]=itn.icon_index
         m+=1
      end
      @item_name[itn.name][0] += 1
    end
    end
    if @gold>0
      m+=1
    end  
    super(200,100, 160,32*m+112 )
    self.opacity = 150
   
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
def refresh
    self.contents.clear
    self.contents.font.size=19
    if @exp > 0
     self.contents.font.color = Color.new(255,255,0,255)
     self.contents.draw_text(6,8,64,32,"获得经验:")
     self.contents.font.color = Color.new(255,255,255,255)
     self.contents.draw_text(80,8,32,32,sprintf("%4s",@exp))
   
   elsif @exp == 0
     self.contents.font.color = Color.new(255,0,0,0)
     self.contents.draw_text(6,8,32,32,"没有获得经验!")
     
   end
   if @gold>0
     self.contents.font.color = Color.new(255,255,0,255)
     self.contents.draw_text(6,40,64,32,"获得金钱:")
     self.contents.font.color = Color.new(255,255,255,255)
     self.contents.draw_text(80,40,32,32,sprintf("%4s",@gold)+Vocab::gold)
   end  
   if @item_name.size != 0
   self.contents.font.size = 20
   self.contents.font.color = Color.new(255,255,0)
   self.contents.draw_text(25,72,64,32,"获得物品")
   i=0

    i=0
    self.contents.font.size = 18
    self.contents.font.color = Color.new(255,255,255,255)
    for itn in @item_name
     draw_icon(itn[1][1] ,6 ,106+i*32 , true)
     self.contents.draw_text(30,106+i*32,64,32,itn[0] + " × "+ itn[1][0].to_s)
   
     i+=1
    end
      
     
  end
  
   
   
end
   
   
end#class  

module Cache
  def self.battleback(filename)
     load_bitmap("Graphics/Battlebacks/", filename)
   end   
end   
  
#=====================================================
#添加战斗背景的相关定义
#=====================================================
class Game_Map
  attr_accessor :name   
    def setup(map_id)
    @map_id = map_id
    @map = load_data(sprintf("Data/Map%03d.rvdata", @map_id))
    @mapinfo = load_data("Data/MapInfos.rvdata")
    #============================
    @name = @mapinfo[@map_id].name
    #============================
    @display_x = 0
    @display_y = 0
    @passages = $data_system.passages
    referesh_vehicles
    setup_events
    setup_scroll
    setup_parallax
    @need_refresh = false
   end #class
  
  
   def area(old_name,new_name)
  
    for area in  $data_areas.values
      if area.name == old_name and area.map_id == @map_id
        area.name == new_name
      end
    end
  end  
end #class

class Spriteset_Battle

  def create_battleback
    name = $game_map.name
    source = $game_temp.background_bitmap
    bitmap = Bitmap.new(640, 480)
    if BATTLE_BACK[name] != nil
     
     bitmap.blt(0,0,source,source.rect)
     @battleback_sprite = Sprite.new(@viewport1)
     @battleback_sprite.bitmap = bitmap
     @battleback_sprite.ox = 272
     @battleback_sprite.oy = 208
     @battleback_sprite.x = 260
     @battleback_sprite.y = 208
    else
   
     bitmap.stretch_blt(bitmap.rect, source, source.rect)
     bitmap.radial_blur(90, 12)
     @battleback_sprite = Sprite.new(@viewport1)
     @battleback_sprite.bitmap = bitmap
     @battleback_sprite.ox = 320
     @battleback_sprite.oy = 240
     @battleback_sprite.x = 272
     @battleback_sprite.y = 176
     @battleback_sprite.wave_amp = 8
     @battleback_sprite.wave_length = 240
     @battleback_sprite.wave_speed = 120
    end
     
  end
  alias oldcreate_battlefloor create_battlefloor
  def create_battlefloor
   oldcreate_battlefloor
   @battlefloor_sprite.opacity = 0
  end
end#class

#==============================================================================
# ■ Game_Interpreter
#------------------------------------------------------------------------------
#  执行事件命令的解释器。本类在 Game_Map 类、Game_Troop 类、
# Game_Event 类的内部使用。
#==============================================================================

class Game_Interpreter
   #===========================================================================
   #☆角色显示动画方法
   #○range:动画影响范围,-1全体或相应角色id
   #●anim_id:动画id
   #===========================================================================
   def add_aa(range,anim_id)
     iterate_battler(1,range) do |battler|
      next unless battler.exist?
      battler.animation_id = anim_id
    end
     
   end #def
   
  
end #class
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
2 小时
注册时间
2009-4-6
帖子
43
3
 楼主| 发表于 2009-7-26 15:29:09 | 只看该作者
#==============================================================================
# 复杂装备系统之随机属性(征求bug版) by 沉影不器
#------------------------------------------------------------------------------
# 说明: 让装备类似暗黑那样附加随机属性,目前有17种属性元素可供组合,允许按
#       能力百分比加成.
#
#       附加属性的名称允许多个(按能力从小大到排列),用英文逗号隔开,自动按
#       附加能力大小选择词缀
#
#       极品爆率不影响物品掉落机率,而是指掉落的物品带附加属性的机率
#
# 获得随机属性装备的方法:
#       事件脚本中输入 get_weapon(母版武器id, 数量, 附加属性1, 附加属性2...)
#       或者直接指定附加属性数 get_weapon(母版武器id, 数量, 附加属性数)
#       将随机生成指定附加属性数的装备
#       获得防具方法是 get_armor() 参数含义同上
#
# 获得普通装备的方法:
#       事件脚本中输入 get_weapon(母版武器id, 数量)
#       获得防具方法是 get_armor() 参数含义同上
#==============================================================================
# 参数设定
#==============================================================================
module Game_Equip
  ## 最大附加属性数
  GiftMax = 4
  ## 附加属性影响价格基数
  GiftPrice = 10
  ## 极品爆率最低值和最高值(0到100)
  Equip_Chance = [5, 75]  
  
  ## 附加属性各参数:
  ##     name    添加到装备前的修饰词
  ##     max     该属性最大值
  ##     weight  权重(最大值的权重,用于计算价值,用于计算颜色也行)
  ##     percent 是否按百分比计算
  Gift = Struct.new(:name, :max, :weight, :percent)
  Gifts = [
     # 攻击
     Gift.new("锐利,伤害,霸道", 50, 25, false),
     Gift.new("残忍,残酷,凶残", 50, 40, true),
     # 防御
     Gift.new("厚重,守卫,守护", 50, 10, false),
     Gift.new("结实,防卫,防护", 50, 20, true),
     # 精神
     Gift.new("光荣", 50, 15, false),
     Gift.new("祝福", 50, 25, true),
     # 敏捷
     Gift.new("敏捷", 50, 20, false),
     Gift.new("灵巧", 50, 30, true),
     # hp
     Gift.new("落英", 80, 20, false),
     Gift.new("武士", 15, 20, true),
     # mp
     Gift.new("神灵", 80, 15, false),
     Gift.new("圣者", 15, 15, true),
     # 命中
     Gift.new("精确", 10, 10,false),
     # 闪避
     Gift.new("幻影", 10, 10, false),
     # 暴击
     Gift.new("暴击", 10, 10, false),
     # 经验
     Gift.new("贪婪", 20, 10, true),
     # 极品爆率  ###(待定)
     Gift.new("幸运", 50, 10, false)
  ]
end


#==============================================================================
# ■ Game_Equip 自定义装备模块
#==============================================================================
module Game_Equip
  #--------------------------------------------------------------------------
  # ● 物品(装备)重生
  #    item:  物品
  #    *gift: 附加属性(留空表示无属性,数字表示指定数量随机属性)
  #--------------------------------------------------------------------------
  def self.reini(item, *gift)
    return if item.nil?
    result = item.clone
    gifts = *gift
    gifts.flatten! if gifts.is_a? Array
    ## 附加属性为空或指定为(0)时,直接返回母版
    return self.result(result) if gifts.nil? or gifts == 0
    ## 指定附加属性数量时
    if gifts.is_a? Integer
      ## 控制数量
      num = [gifts, GiftMax].min
      gifts = []
      ## 随机生成指定数量的附加属性
      rd = different_rand(Gifts.size-1, num)
      rd.each{|n| gifts.push Game_Gift.new(n)}
    end
    gifts = [gifts].flatten
    return self.result(result) if gifts.empty?
    ## 处理数据
    result.gifts = gifts
    name = ""
    price = 0
    for gift in gifts
      name  += gift.name
      price += gift.weight * GiftPrice
    end
    ## 设定名称
    result.name =  name + '的' + result.name
    ## 设定价格
    result.price += price.round
    ## 设定颜色
    result.text_color = gifts.size
    return self.result(result)
  end
  #--------------------------------------------------------------------------
  # ● 返回结果
  #    item: 物品
  #--------------------------------------------------------------------------
  def self.result(item)
    case item
    when RPG::Item
      
    when RPG::Weapon
      item.base_id = item.id
      item.id = $data_weapons.size
      $data_weapons << item
    when RPG::Armor
      item.base_id = item.id
      item.id = $data_armors.size
      $data_armors << item
    end
    return item
  end
  #--------------------------------------------------------------------------
  # ● 物品(装备)重生
  #    item_id: 物品id
  #    type:    类型
  #    *gift:   附加属性(留空表示无属性,数字表示指定数量随机属性)
  #--------------------------------------------------------------------------
  def self.reini_id(item_id, type, *gift)
    ## 排除装备id为零的情况
    return 0 if item_id == 0
    case type
    when 0
      item = $base_weapons[item_id]
    when 1
      item = $base_armors[item_id]
    end
    return self.reini(item, *gift).id
  end
end

#==============================================================================
# ■ Game_Gift 装备附加能力
#==============================================================================
class Game_Gift
  include Game_Equip
  #--------------------------------------------------------------------------
  # ● 读取口
  #--------------------------------------------------------------------------
  attr_reader   :type
  attr_reader   :value
  attr_reader   :name
  #--------------------------------------------------------------------------
  # ● 初始化
  #--------------------------------------------------------------------------
  def initialize(type = nil, value = nil)
    get_type(type)
    get_value(value)
    get_name
  end
  #--------------------------------------------------------------------------
  # ● 获取属性
  #--------------------------------------------------------------------------
  def get_type(type)
    unless type.nil? or type > Gifts.size or type < 0
      @type = type
    else
      @type = rand(Gifts.size - 1)
    end
  end
  #--------------------------------------------------------------------------
  # ● 获取品质值
  #--------------------------------------------------------------------------
  def get_value(value)
    unless value.nil? or value.abs > max
      @value = value
    else
      @value = linear_rand(max) + 1
    end
  end
  #--------------------------------------------------------------------------
  # ● 获取名称
  #--------------------------------------------------------------------------
  def get_name
    names = Gifts[@type].name.split(/,/)
    n = (@value.abs-1)/(max.to_f/names.size)
    @name = names[n.truncate]
  end
  #--------------------------------------------------------------------------
  # ● 获取最大值
  #--------------------------------------------------------------------------
  def max
    return Gifts[@type].max
  end
  #--------------------------------------------------------------------------
  # ● 获取权重
  #--------------------------------------------------------------------------
  def weight
    return @value > 0 ? @value / max.to_f * Gifts[@type].weight : 0
  end
  #--------------------------------------------------------------------------
  # ● 获取是否百分比
  #--------------------------------------------------------------------------
  def percent
    return Gifts[@type].percent
  end
  
  #--------------------------------------------------------------------------
  # ● 攻击力
  #--------------------------------------------------------------------------
  def atk(actor_id)
    # 无角色信息时返回
    return 0 unless actor_id
    # 数据类型不符时返回
    return 0 if @type != 0 and @type != 1
    if percent
      return $game_actors[actor_id].self_atk * @value / 100
    else
      return @value
    end
  end
  #--------------------------------------------------------------------------
  # ● 防御力
  #--------------------------------------------------------------------------
  def def(actor_id)
    # 无角色信息时返回
    return 0 unless actor_id
    # 数据类型不符时返回
    return 0 if @type != 2 and @type != 3
    if percent
      return $game_actors[actor_id].self_def * @value / 100
    else
      return @value
    end
  end
  #--------------------------------------------------------------------------
  # ● 精神
  #--------------------------------------------------------------------------
  def spi(actor_id)
    # 无角色信息时返回
    return 0 unless actor_id
    # 数据类型不符时返回
    return 0 if @type != 4 and @type != 5
    if percent
      return $game_actors[actor_id].self_spi * @value / 100
    else
      return @value
    end
  end
  #--------------------------------------------------------------------------
  # ● 敏捷
  #--------------------------------------------------------------------------
  def agi(actor_id)
    # 无角色信息时返回
    return 0 unless actor_id
    # 数据类型不符时返回
    return 0 if @type != 6 and @type != 7
    if percent
      return $game_actors[actor_id].self_agi * @value / 100
    else
      return @value
    end
  end
  #--------------------------------------------------------------------------
  # ● hp
  #--------------------------------------------------------------------------
  def hp(actor_id)
    # 无角色信息时返回
    return 0 unless actor_id
    # 数据类型不符时返回
    return 0 if @type != 8 and @type != 9
    if percent
      return $game_actors[actor_id].self_maxhp * @value / 100
    else
      return @value
    end
  end
  #--------------------------------------------------------------------------
  # ● mp
  #--------------------------------------------------------------------------
  def mp(actor_id)
    # 无角色信息时返回
    return 0 unless actor_id
    # 数据类型不符时返回
    return 0 if @type != 10 and @type != 11
    if percent
      return $game_actors[actor_id].self_maxmp * @value / 100
    else
      return @value
    end
  end
  #--------------------------------------------------------------------------
  # ● 命中
  #--------------------------------------------------------------------------
  def hit
    # 数据类型不符时返回
    return 0 if @type != 12
    return @value
  end
  #--------------------------------------------------------------------------
  # ● 闪避
  #--------------------------------------------------------------------------
  def eva
    # 数据类型不符时返回
    return 0 if @type != 13
    return @value
  end
  #--------------------------------------------------------------------------
  # ● 暴击
  #--------------------------------------------------------------------------
  def cri
    # 数据类型不符时返回
    return 0 if @type != 14
    return @value
  end
  #--------------------------------------------------------------------------
  # ● 经验(百分比)
  #--------------------------------------------------------------------------
  def exp
    # 数据类型不符时返回
    return 0 if @type != 15
    return @value
  end
  #--------------------------------------------------------------------------
  # ● 高级装备暴率(百分比)
  #--------------------------------------------------------------------------
  def equip_chance
    # 数据类型不符时返回
    return 0 if @type != 16
    return @value
  end
end
#==============================================================================
# ■ RPG::BaseItem
#==============================================================================
module RPG
  class BaseItem
    ## 颜色
    attr_accessor :text_color
  end
end
#==============================================================================
# ■ RPG::Weapon
#==============================================================================
module RPG
  class Weapon < BaseItem
    #------------------------------------------------------------------------
    # 附加属性
    #------------------------------------------------------------------------
    attr_accessor :base_id
    attr_accessor :actor_id
    attr_accessor :gifts
    #------------------------------------------------------------------------
    # 攻击力(合)
    #------------------------------------------------------------------------
    def atk
      n = @atk
      @gifts = [] if @gifts.nil?
      for g in @gifts.compact do n += g.atk(actor_id) end
      return n
    end
    #------------------------------------------------------------------------
    # 防御力(合)
    #------------------------------------------------------------------------
    def def
      n = @def
      @gifts = [] if @gifts.nil?
      for g in @gifts.compact do n += g.def(actor_id) end
      return n
    end
    #------------------------------------------------------------------------
    # 魔力(合)
    #------------------------------------------------------------------------
    def spi
      n = @spi
      @gifts = [] if @gifts.nil?
      for g in @gifts.compact do n += g.spi(actor_id) end
      return n
    end
    #------------------------------------------------------------------------
    # 敏捷(合)
    #------------------------------------------------------------------------
    def agi
      n = @agi
      @gifts = [] if @gifts.nil?
      for g in @gifts.compact do n += g.agi(actor_id) end
      return n
    end
    #------------------------------------------------------------------------
    # 最大hp(合)
    #------------------------------------------------------------------------
    def maxhp
      n = 0
      @gifts = [] if @gifts.nil?
      for g in @gifts.compact do n += g.maxhp(actor_id) end
      return n
    end
    #------------------------------------------------------------------------
    # 最大mp(合)
    #------------------------------------------------------------------------
    def maxmp
      n = 0
      @gifts = [] if @gifts.nil?
      for g in @gifts.compact do n += g.maxmp(actor_id) end
      return n
    end
    #------------------------------------------------------------------------
    # 命中率(合)
    #------------------------------------------------------------------------
    def hit
      n = @hit
      @gifts = [] if @gifts.nil?
      for g in @gifts.compact do n += g.hit end
      return n
    end
    #------------------------------------------------------------------------
    # 闪避率(合)
    #------------------------------------------------------------------------
    def eva
      n = 0
      @gifts = [] if @gifts.nil?
      for g in @gifts.compact do n += g.eva end
      return n
    end
    #------------------------------------------------------------------------
    # 暴击率(合)
    #------------------------------------------------------------------------
    def cri
      n = 0
      @gifts = [] if @gifts.nil?
      for g in @gifts.compact do n += g.cri end
      return n
    end
    #--------------------------------------------------------------------------
    # ● 经验(百分比)
    #--------------------------------------------------------------------------
    def exp
      n = 0
      @gifts = [] if @gifts.nil?
      for g in @gifts.compact do n += g.exp end
      return n
    end
    #--------------------------------------------------------------------------
    # ● 高级装备暴率(百分比)
    #--------------------------------------------------------------------------
    def equip_chance
      n = 0
      @gifts = [] if @gifts.nil?
      for g in @gifts.compact do n += g.equip_chance end
      return n
    end
  end
end
#==============================================================================
# ■ RPG::Armor
#==============================================================================
module RPG
  class Armor < BaseItem
    #------------------------------------------------------------------------
    # 附加属性
    #------------------------------------------------------------------------
    attr_accessor :base_id
    attr_accessor :actor_id
    attr_accessor :gifts
    #------------------------------------------------------------------------
    # 攻击力(合)
    #------------------------------------------------------------------------
    def atk
      n = @atk
      @gifts = [] if @gifts.nil?
      for g in @gifts.compact do n += g.atk(actor_id) end
      return n
    end
    #------------------------------------------------------------------------
    # 防御力(合)
    #------------------------------------------------------------------------
    def def
      n = @def
      @gifts = [] if @gifts.nil?
      for g in @gifts.compact do n += g.def(actor_id) end
      return n
    end
    #------------------------------------------------------------------------
    # 魔力(合)
    #------------------------------------------------------------------------
    def spi
      n = @spi
      @gifts = [] if @gifts.nil?
      for g in @gifts.compact do n += g.spi(actor_id) end
      return n
    end
    #------------------------------------------------------------------------
    # 敏捷(合)
    #------------------------------------------------------------------------
    def agi
      n = @agi
      @gifts = [] if @gifts.nil?
      for g in @gifts.compact do n += g.agi(actor_id) end
      return n
    end
    #------------------------------------------------------------------------
    # 最大hp(合)
    #------------------------------------------------------------------------
    def maxhp
      n = 0
      @gifts = [] if @gifts.nil?
      for g in @gifts.compact do n += g.maxhp(actor_id) end
      return n
    end
    #------------------------------------------------------------------------
    # 最大mp(合)
    #------------------------------------------------------------------------
    def maxmp
      n = 0
      @gifts = [] if @gifts.nil?
      for g in @gifts.compact do n += g.maxmp(actor_id) end
      return n
    end
    #------------------------------------------------------------------------
    # 命中率(合)
    #------------------------------------------------------------------------
    def hit
      n = 0
      @gifts = [] if @gifts.nil?
      for g in @gifts.compact do n += g.hit end
      return n
    end
    #------------------------------------------------------------------------
    # 闪避率(合)
    #------------------------------------------------------------------------
    def eva
      n = @eva
      @gifts = [] if @gifts.nil?
      for g in @gifts.compact do n += g.eva end
      return n
    end
    #------------------------------------------------------------------------
    # 暴击率(合)
    #------------------------------------------------------------------------
    def cri
      n = 0
      @gifts = [] if @gifts.nil?
      for g in @gifts.compact do n += g.cri end
      return n
    end
    #--------------------------------------------------------------------------
    # ● 经验(百分比)
    #--------------------------------------------------------------------------
    def exp
      n = 0
      @gifts = [] if @gifts.nil?
      for g in @gifts.compact do n += g.exp end
      return n
    end
    #--------------------------------------------------------------------------
    # ● 高级装备暴率(百分比)
    #--------------------------------------------------------------------------
    def equip_chance
      n = 0
      @gifts = [] if @gifts.nil?
      for g in @gifts.compact do n += g.equip_chance end
      return n
    end
  end
end
#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # ● 获取自身 MaxHP
  #--------------------------------------------------------------------------
  def self_maxhp
    return actor.parameters[0, @level]
  end
  #--------------------------------------------------------------------------
  # ● 获取自身 MaxMP
  #--------------------------------------------------------------------------
  def self_maxmp
    return actor.parameters[1, @level]
  end
  #--------------------------------------------------------------------------
  # ● 获取自身攻击力
  #--------------------------------------------------------------------------
  def self_atk
    return actor.parameters[2, @level]
  end
  #--------------------------------------------------------------------------
  # ● 获取自身防御力
  #--------------------------------------------------------------------------
  def self_def
    return actor.parameters[3, @level]
  end
  #--------------------------------------------------------------------------
  # ● 获取自身精神力
  #--------------------------------------------------------------------------
  def self_spi
    return actor.parameters[4, @level]
  end
  #--------------------------------------------------------------------------
  # ● 获取自身敏捷性
  #--------------------------------------------------------------------------
  def self_agi
    return actor.parameters[5, @level]
  end
  #--------------------------------------------------------------------------
  # ● 获取命中率
  #--------------------------------------------------------------------------
  def hit
    n = 95
    for e in equips.compact do n += e.hit end
    return n
  end
  #--------------------------------------------------------------------------
  # ● 获取回避率
  #--------------------------------------------------------------------------
  def eva
    n = 5
    for e in equips.compact do n += e.eva end
    return n
  end
  #--------------------------------------------------------------------------
  # ● 获取会心一击概率
  #--------------------------------------------------------------------------
  def cri
    n = 4
    n += 4 if actor.critical_bonus
    for e in equips.compact do n += e.cri end
    return n
  end
  #--------------------------------------------------------------------------
  # ● 获取更多经验值
  #--------------------------------------------------------------------------
  def exp_added
    exp = 100
    for equip in equips.compact
      exp += equip.exp
    end
    return exp
  end
  #--------------------------------------------------------------------------
  # ● 获取高级物品暴率
  #--------------------------------------------------------------------------
  def equip_chance
    equip_chance = 0
    for equip in equips.compact
      equip_chance += equip.equip_chance
    end
    return equip_chance
  end
  #--------------------------------------------------------------------------
  # ● 获得经验值 (考虑到附加经验值)
  #     exp  : 经验值增加量
  #     show : 显示升级标志
  #--------------------------------------------------------------------------
  def gain_exp(exp, show)
    change_exp(@exp + exp * exp_added, show)
  end
end
#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #     actor_id : 角色 ID
  #--------------------------------------------------------------------------
  def initialize(actor_id)
    super()
    setup(actor_id)
    @last_skill_id = 0
  end
  #--------------------------------------------------------------------------
  # ● 设置
  #     actor_id : 角色 ID
  #--------------------------------------------------------------------------
  def setup(actor_id)
    actor = $data_actors[actor_id]
    @actor_id = actor_id
    @name = actor.name
    @character_name = actor.character_name
    @character_index = actor.character_index
    @face_name = actor.face_name
    @face_index = actor.face_index
    @class_id = actor.class_id
    @weapon_id = actor.weapon_id
    @armor1_id = actor.armor1_id
    @armor2_id = actor.armor2_id
    @armor3_id = actor.armor3_id
    @armor4_id = actor.armor4_id
    @level = actor.initial_level
    @exp_list = Array.new(101)
    make_exp_list
    @exp = @exp_list[@level]
    @skills = []
    for i in self.class.learnings
      learn_skill(i.skill_id) if i.level <= @level
    end
    clear_extra_values
    recover_all
    ## 生成新装备id
    reset_equip_id
  end
  #--------------------------------------------------------------------------
  # ● 装备重设
  #--------------------------------------------------------------------------
  def reset_equip_id
    @weapon_id = Game_Equip.reini_id(@weapon_id, 0)
    @armor1_id = Game_Equip.reini_id(@armor1_id, two_hands_legal? ? 0 : 1)
    @armor2_id = Game_Equip.reini_id(@armor2_id, 1)
    @armor3_id = Game_Equip.reini_id(@armor3_id, 1)
    @armor4_id = Game_Equip.reini_id(@armor4_id, 1)
  end
  #--------------------------------------------------------------------------
  # ● 判断是否可以装备
  #     item : 物品
  #     base : 是否读取母版数据
  #--------------------------------------------------------------------------
  def equippable?(item, base = true)
    id = base ? item.base_id : item.id
    if item.is_a?(RPG::Weapon)
      return self.class.weapon_set.include?(id)
    elsif item.is_a?(RPG::Armor)
      return false if two_swords_style and item.kind == 0
      return self.class.armor_set.include?(id)
    end
    return false
  end
  #--------------------------------------------------------------------------
  # ● 更改装备 (指定对象)
  #     equip_type : 装备部位 (0..4)
  #     item       : 武器 or 防具 (nil 为解除装备)
  #     test       : 测试标志 (战斗测试、以及装备画面的临时装备)
  #--------------------------------------------------------------------------
  def change_equip(equip_type, item, test = false)
    last_item = equips[equip_type]
    unless test
      return if $game_party.item_number(item) == 0 if item != nil
      $game_party.gain_item(last_item, 1)
      $game_party.lose_item(item, 1)
      last_item.actor_id = nil unless last_item.nil?
    end
    item_id = item == nil ? 0 : item.id
    case equip_type
    when 0  # 武器
      @weapon_id = item_id
      unless two_hands_legal?             # 违反双手拿取的情况下
        change_equip(1, nil, test)        # 解除反手的装备
      end
    when 1  # 盾
      @armor1_id = item_id
      unless two_hands_legal?             # 违反双手拿取的情况下
        change_equip(0, nil, test)        # 解除反手的装备
      end
    when 2  # 头
      @armor2_id = item_id
    when 3  # 身体
      @armor3_id = item_id
    when 4  # 装饰品
      @armor4_id = item_id
    end
    item.actor_id = self.id unless item.nil?
  end
end
#==============================================================================
# ■ Game_Party
#==============================================================================
class Game_Party < Game_Unit
  #--------------------------------------------------------------------------
  # ● 判断持有的物品
  #     item          : 物品
  #     include_equip : 包括装备品
  #--------------------------------------------------------------------------
  def has_item_by_base_id?(item, include_equip = false)
    for i in items
      return true if i.base_id == item.id
    end
    if include_equip
      for actor in members
        for e in actor.equips
          return true if e.base_id == item.id
        end
      end
    end
    return false
  end
  #--------------------------------------------------------------------------
  # ● 获得物品
  #     item          : 物品
  #     n             : 个数
  #--------------------------------------------------------------------------
  def gain_reini(item, n, include_equip = false, *gift)
    if n < 0
      lose_item(item, -n, include_equip = false)
    else
      case item
      when RPG::Item
        number = item_number(item)
        @items[item.id] = [[number + n, 0].max, 99].min
      when RPG::Weapon
        for i in 0...n
          w = Game_Equip.reini(item, *gift)
          @weapons[w.id] = 1
        end
      when RPG::Armor
        for i in 0...n
          a = Game_Equip.reini(item, *gift)
          @armors[a.id] = 1
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 减少物品 (减少)
  #     item          : 物品
  #     n             : 个数
  #     include_equip : 包括装备品
  #--------------------------------------------------------------------------
  def lose_reini(item, n, include_equip = false)
    number = item_number(item)
    case item
    when RPG::Item
      @items[item.id] = [[number - n, 0].max, 99].min
    when RPG::Weapon
      @weapons[item.id] = [[number - n, 0].max, 99].min
    when RPG::Armor
      @armors[item.id] = [[number - n, 0].max, 99].min
    end
    n -= number
    if include_equip and n > 0
      for actor in members
        while n > 0 and actor.equips.include?(item)
          actor.discard_equip(item)
          n -= 1
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 获得物品
  #     item_id       : 物品id
  #     type          : 类型(0物品, 1武器, 2防具)
  #     n             : 个数
  #--------------------------------------------------------------------------
  def gain_reini_byid(item_id, type, n, include_equip = false, *gift)
    case type
    when 0
      item = $data_items[item_id]
    when 1
      item = $base_weapons[item_id]
    when 2
      item = $base_armors[item_id]
    end
    gain_reini(item, n, include_equip, *gift)
  end
  #--------------------------------------------------------------------------
  # ● 极品爆率
  #--------------------------------------------------------------------------
  def equip_chance
    chance = Game_Equip::Equip_Chance[0]
    members.each {|actor| chance += actor.equip_chance}
    return chance
  end
end
#==============================================================================
# ■ Game_Troop
#==============================================================================
class Game_Troop < Game_Unit
  #--------------------------------------------------------------------------
  # ● 敌人角色名称后的文字表
  #--------------------------------------------------------------------------
  LETTER_TABLE = [ 'A','B','C','D','E','F','G','H','I','J',
                   'K','L','M','N','O','P','Q','R','S','T',
                   'U','V','W','X','Y','Z']
  #--------------------------------------------------------------------------
  # ● 生成掉落物品队列
  #--------------------------------------------------------------------------
  def make_drop_items
    drop_items = []
    for enemy in dead_members
      for di in [enemy.drop_item1, enemy.drop_item2]
        next if di.kind == 0
        next if rand(di.denominator) != 0
        if di.kind == 1
          drop_items.push($data_items[di.item_id])
        elsif di.kind == 2
          item = reini_chance($base_weapons[di.weapon_id], $game_party.equip_chance)
          drop_items.push(item)
        elsif di.kind == 3
          item = reini_chance($base_armors[di.weapon_id], $game_party.equip_chance)
          drop_items.push(item)
        end
      end
    end
    return drop_items
  end
  #--------------------------------------------------------------------------
  # ● 处理极品爆率
  #--------------------------------------------------------------------------
  def reini_chance(item, chance)
    @item = item
    @chance = [chance/100.0, Game_Equip::Equip_Chance[1]/100.0].min
    @gifts = []
    loop do
      if rand(0) < @chance and @gifts.size < Game_Equip::GiftMax
        @gifts << Game_Gift.new
        @chance /= 2
      else
        return Game_Equip.reini(@item, @gifts)
      end
    end
  end
end
#==============================================================================
# ■ Game_Interpreter
#==============================================================================
class Game_Interpreter
  #--------------------------------------------------------------------------
  # ● 计算操作的值
  #     operation    : 操作 (0:增加 1:减少)
  #     operand_type : 运算域类型 (0:常量 1:变量)
  #     operand      : 运算域 (数值为变量 ID)
  #--------------------------------------------------------------------------
  def operate_value(operation, operand_type, operand)
    if operand_type == 0
      value = operand
    else
      value = $game_variables[operand]
    end
    if operation == 1
      value = -value
    end
    return value
  end
  #--------------------------------------------------------------------------
  # ● 条件分歧
  #--------------------------------------------------------------------------
  def command_111
    result = false
    case @params[0]
    when 0  # 开关
      result = ($game_switches[@params[1]] == (@params[2] == 0))
    when 1  # 变量
      value1 = $game_variables[@params[1]]
      if @params[2] == 0
        value2 = @params[3]
      else
        value2 = $game_variables[@params[3]]
      end
      case @params[4]
      when 0  # 相等
        result = (value1 == value2)
      when 1  # 大于等于
        result = (value1 >= value2)
      when 2  # 小于等于
        result = (value1 <= value2)
      when 3  # 大于
        result = (value1 > value2)
      when 4  # 小于
        result = (value1 < value2)
      when 5  # 不等于
        result = (value1 != value2)
      end
    when 2  # 自我开关
      if @original_event_id > 0
        key = [@map_id, @original_event_id, @params[1]]
        if @params[2] == 0
          result = ($game_self_switches[key] == true)
        else
          result = ($game_self_switches[key] != true)
        end
      end
    when 3  # 计时器
      if $game_system.timer_working
        sec = $game_system.timer / Graphics.frame_rate
        if @params[2] == 0
          result = (sec >= @params[1])
        else
          result = (sec <= @params[1])
        end
      end
    when 4  # 角色
      actor = $game_actors[@params[1]]
      if actor != nil
        case @params[2]
        when 0  # 是同伴
          result = ($game_party.members.include?(actor))
        when 1  # 姓名
          result = (actor.name == @params[3])
        when 2  # 特技
          result = (actor.skill_learn?($data_skills[@params[3]]))
        when 3  # 武器
          ## 判断是否符合母版id
          actor.weapons.each do |weapon|
            if weapon.base_id == @params[3]
              result = true
              break
            end
          end
        when 4  # 防具
          ## 判断是否符合母版id
          actor.armors.each do |armor|
            if armor.base_id == @params[3]
              result = true
              break
            end
          end
        when 5  # 状态
          result = (actor.state?(@params[3]))
        end
      end
    when 5  # 敌方角色
      enemy = $game_troop.members[@params[1]]
      if enemy != nil
        case @params[2]
        when 0  # 出现
          result = (enemy.exist?)
        when 1  # 状态
          result = (enemy.state?(@params[3]))
        end
      end
    when 6  # 角色
      character = get_character(@params[1])
      if character != nil
        result = (character.direction == @params[2])
      end
    when 7  # 金钱
      if @params[2] == 0
        result = ($game_party.gold >= @params[1])
      else
        result = ($game_party.gold <= @params[1])
      end
    when 8  # 物品
      result = $game_party.has_item?($data_items[@params[1]])
    when 9  # 武器
      result = $game_party.has_item_by_base_id?($base_weapons[@params[1]], @params[2])
    when 10  # 防具
      result = $game_party.has_item_by_base_id?($base_armors[@params[1]], @params[2])
    when 11  # 按钮
      result = Input.press?(@params[1])
    when 12  # 脚本
      result = eval(@params[1])
    when 13  # 交通工具
      result = ($game_player.vehicle_type == @params[1])
    end
    @branch[@indent] = result     # 将判断结果放置在缓存中
    if @branch[@indent] == true
      @branch.delete(@indent)
      return true
    end
    return command_skip
  end
  
  
  #--------------------------------------------------------------------------
  # ● 计算装备操作的值
  #     operand_type : 运算域类型 (0:常量 1:变量)
  #     operand      : 运算域 (数值为变量 ID)
  #--------------------------------------------------------------------------
  def opera_equip_value(operation, operand_type, operand)
    if operand_type == 0
      value = operand
    else
      value = $game_variables[operand]
    end
    return value
  end
  #--------------------------------------------------------------------------
  # ● 增减武器
  #--------------------------------------------------------------------------
  def command_127
    value = operate_value(@params[1], @params[2], @params[3])
    if @params[1] == 0
      $game_party.gain_reini($base_weapons[@params[0]], value.abs, @params[4])
    else
      $game_party.lose_reini($base_weapons[@params[0]], value.abs, @params[4])
    end
    return true
  end
  #--------------------------------------------------------------------------
  # ● 增减防具
  #--------------------------------------------------------------------------
  def command_128
    value = operate_value(@params[1], @params[2], @params[3])
    if @params[1] == 0
      $game_party.gain_reini($base_armors[@params[0]], value.abs, @params[4])
    else
      $game_party.lose_reini($base_armors[@params[0]], value.abs, @params[4])
    end
    return true
  end
  #--------------------------------------------------------------------------
  # ● 更改装备
  #--------------------------------------------------------------------------
  def command_319
    actor = $game_actors[@params[0]]
    if actor != nil
      actor.change_equip_by_id(@params[1], @params[2])
    end
    return true
  end
  #--------------------------------------------------------------------------
  # ● 增减武器
  #--------------------------------------------------------------------------
  def get_weapon(id, n, *gift)
    $game_party.gain_reini($base_weapons[id], n, false, *gift)
  end
  #--------------------------------------------------------------------------
  # ● 增减防具
  #--------------------------------------------------------------------------
  def get_armor(id, n, *gift)
    $game_party.gain_reini($base_armors[id], n, false, *gift)
  end
end
#==============================================================================
# ■ Window_Base
#==============================================================================
class Window_Base < Window
  def draw_item_name(item, x, y, enabled = true)
    if item != nil
      draw_icon(item.icon_index, x, y, enabled)
      self.contents.font.color = text_color(item.text_color.to_i)
      self.contents.font.color.alpha = enabled ? 255 : 128
      self.contents.draw_text(x + 24, y, 172, WLH, item.name)
    end
  end
end
#==============================================================================
# ■ Window_ShopBuy
#==============================================================================
class Window_ShopBuy < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    @data = []
    for goods_item in @shop_goods
      case goods_item[0]
      when 0
        item = $base_items[goods_item[1]]
      when 1
        item = $base_weapons[goods_item[1]]
      when 2
        item = $base_armors[goods_item[1]]
      end
      if item != nil
        @data.push(item)
      end
    end
    @item_max = @data.size
    create_contents
    for i in 0...@item_max
      draw_item(i)
    end
  end
end
#==============================================================================
# ■ Window_ShopStatus
#==============================================================================
class Window_ShopStatus < Window_Base
  #--------------------------------------------------------------------------
  # ● 描绘角色现在装备的能力值变化
  #     actor : 角色
  #     x     : 描画目标 X 坐标
  #     y     : 描画目标 Y 坐标
  #--------------------------------------------------------------------------
  def draw_actor_parameter_change(actor, x, y)
    return if @item.is_a?(RPG::Item)
    enabled = actor.equippable?(@item, false)
    self.contents.font.color = normal_color
    self.contents.font.color.alpha = enabled ? 255 : 128
    self.contents.draw_text(x, y, 200, WLH, actor.name)
    if @item.is_a?(RPG::Weapon)
      item1 = weaker_weapon(actor)
    elsif actor.two_swords_style and @item.kind == 0
      item1 = nil
    else
      item1 = actor.equips[1 + @item.kind]
    end
    if enabled
      if @item.is_a?(RPG::Weapon)
        atk1 = item1 == nil ? 0 : item1.atk
        atk2 = @item == nil ? 0 : @item.atk
        change = atk2 - atk1
      else
        def1 = item1 == nil ? 0 : item1.def
        def2 = @item == nil ? 0 : @item.def
        change = def2 - def1
      end
      self.contents.draw_text(x, y, 200, WLH, sprintf("%+d", change), 2)
    end
    draw_item_name(item1, x, y + WLH, enabled)
  end
end
#==============================================================================
# ■ Scene_File
#==============================================================================
class Scene_File < Scene_Base
  #--------------------------------------------------------------------------
  # ● 写入存档数据
  #     file : 写入文件用对象 (已经打开)
  #--------------------------------------------------------------------------
  def write_save_data(file)
    characters = []
    for actor in $game_party.members
      characters.push([actor.character_name, actor.character_index])
    end
    $game_system.save_count += 1
    $game_system.version_id = $data_system.version_id
    @last_bgm = RPG::BGM::last
    @last_bgs = RPG::BGS::last
    Marshal.dump(characters,           file)
    Marshal.dump(Graphics.frame_count, file)
    Marshal.dump(@last_bgm,            file)
    Marshal.dump(@last_bgs,            file)
    Marshal.dump($game_system,         file)
    Marshal.dump($game_message,        file)
    Marshal.dump($game_switches,       file)
    Marshal.dump($game_variables,      file)
    Marshal.dump($game_self_switches,  file)
    Marshal.dump($game_actors,         file)
    Marshal.dump($game_party,          file)
    Marshal.dump($game_troop,          file)
    Marshal.dump($game_map,            file)
    Marshal.dump($game_player,         file)
    Marshal.dump($data_weapons,        file)
    Marshal.dump($data_armors,         file)
  end
  #--------------------------------------------------------------------------
  # ● 读取存档数据
  #     file : 读取文件用对象 (已经打开)
  #--------------------------------------------------------------------------
  def read_save_data(file)
    characters           = Marshal.load(file)
    Graphics.frame_count = Marshal.load(file)
    @last_bgm            = Marshal.load(file)
    @last_bgs            = Marshal.load(file)
    $game_system         = Marshal.load(file)
    $game_message        = Marshal.load(file)
    $game_switches       = Marshal.load(file)
    $game_variables      = Marshal.load(file)
    $game_self_switches  = Marshal.load(file)
    $game_actors         = Marshal.load(file)
    $game_party          = Marshal.load(file)
    $game_troop          = Marshal.load(file)
    $game_map            = Marshal.load(file)
    $game_player         = Marshal.load(file)
    $data_weapons        = Marshal.load(file)
    $data_armors         = Marshal.load(file)
    if $game_system.version_id != $data_system.version_id
      $game_map.setup($game_map.map_id)
      $game_player.center($game_player.x, $game_player.y)
    end
  end
end
#==============================================================================
# ■ Scene_Shop
#==============================================================================
class Scene_Shop < Scene_Base
  #--------------------------------------------------------------------------
  # ● 确定输入个数
  #--------------------------------------------------------------------------
  def decide_number_input
    Sound.play_shop
    @number_window.active = false
    @number_window.visible = false
    case @command_window.index
    when 0  # 购买
      $game_party.lose_gold(@number_window.number * @item.price)
      $game_party.gain_reini(@item, @number_window.number)
      @gold_window.refresh
      @buy_window.refresh
      @status_window.refresh
      @buy_window.active = true
      @buy_window.visible = true
    when 1  # 卖出
      $game_party.gain_gold(@number_window.number * (@item.price / 2))
      $game_party.lose_reini_item(@item, @number_window.number)
      @gold_window.refresh
      @sell_window.refresh
      @status_window.refresh
      @sell_window.active = true
      @sell_window.visible = true
      @status_window.visible = false
    end
  end
end
#==============================================================================
# ■ Scene_Title
#==============================================================================
class Scene_Title < Scene_Base
  #--------------------------------------------------------------------------
  # ● 载入数据库
  #--------------------------------------------------------------------------
  def load_database
    $data_actors        = load_data("Data/Actors.rvdata")
    $data_classes       = load_data("Data/Classes.rvdata")
    $data_skills        = load_data("Data/Skills.rvdata")
    $data_items         = load_data("Data/Items.rvdata")
    $base_weapons       = load_data("Data/Weapons.rvdata")
    $base_armors        = load_data("Data/Armors.rvdata")
    $data_enemies       = load_data("Data/Enemies.rvdata")
    $data_troops        = load_data("Data/Troops.rvdata")
    $data_states        = load_data("Data/States.rvdata")
    $data_animations    = load_data("Data/Animations.rvdata")
    $data_common_events = load_data("Data/CommonEvents.rvdata")
    $data_system        = load_data("Data/System.rvdata")
    $data_areas         = load_data("Data/Areas.rvdata")
    $data_weapons       = [nil]
    $data_armors        = [nil]
  end
  #--------------------------------------------------------------------------
  # ● 载入战斗测试用的数据库
  #--------------------------------------------------------------------------
  def load_bt_database
    $data_actors        = load_data("Data/BT_Actors.rvdata")
    $data_classes       = load_data("Data/BT_Classes.rvdata")
    $data_skills        = load_data("Data/BT_Skills.rvdata")
    $data_items         = load_data("Data/BT_Items.rvdata")
    $data_weapons       = load_data("Data/BT_Weapons.rvdata")
    $data_armors        = load_data("Data/BT_Armors.rvdata")
    $data_enemies       = load_data("Data/BT_Enemies.rvdata")
    $data_troops        = load_data("Data/BT_Troops.rvdata")
    $data_states        = load_data("Data/BT_States.rvdata")
    $data_animations    = load_data("Data/BT_Animations.rvdata")
    $data_common_events = load_data("Data/BT_CommonEvents.rvdata")
    $data_system        = load_data("Data/BT_System.rvdata")
    $base_weapons       = $data_weapons
    $base_armors        = $data_armors
  end
end
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
2 小时
注册时间
2009-4-6
帖子
43
4
 楼主| 发表于 2009-7-27 11:43:14 | 只看该作者
怎么没人能帮我看看嘛?
  我想是不是Z轴描述出了问题啊?  高人  看看拜托~~
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
8 小时
注册时间
2009-1-19
帖子
591
5
发表于 2009-7-27 14:21:51 | 只看该作者
应该是脚本冲突....LZ把那么一大堆脚本搬出来肯定没人看,没人理你的...........................
劝你还是2选1吧........................
梦想世界在我脑中~~
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
2 小时
注册时间
2009-4-6
帖子
43
6
 楼主| 发表于 2009-7-27 16:21:10 | 只看该作者
冲突的位置大体知道在什么位置,现在就是不知道怎么改··我把它改成了纵版CP了···
我汗··
回复 支持 反对

使用道具 举报

Lv1.梦旅人

仙剑奇侠

梦石
0
星屑
50
在线时间
33 小时
注册时间
2008-4-2
帖子
622
7
发表于 2009-7-30 00:36:24 | 只看该作者
哇~好大堆的脚本...
LZ你可以点【插入代码】的...
伱这么厉害的脚本估计没多少个人会帮伱看....

回复 支持 反对

使用道具 举报

Lv2.观梦者 (管理员)

八云紫的式神

梦石
0
星屑
554
在线时间
1243 小时
注册时间
2008-1-1
帖子
4282

烫烫烫

8
发表于 2009-8-2 08:21:14 | 只看该作者
哇~好大堆的脚本...
LZ你可以点【插入代码】的...
伱这么厉害的脚本估计没多少个人会帮伱看....
小闵 发表于 2009-7-30 00:36

因为好像论坛有点bug……代码过长的话code标签就会显示不出

LZ……你还是2选1吧,或者悬赏整合
rm for linux(wine)制作中,期待夏娜SAMA能实现到webrm上
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
2 小时
注册时间
2009-4-6
帖子
43
9
 楼主| 发表于 2009-8-18 16:56:01 | 只看该作者
诶··真是痛苦啊     现在苦读F1    争取自己解决吧··
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-12 20:09

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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