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

Project1

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

[已经过期] 这个脚本战斗中添加第五个角色会不现实角色图,求解

[复制链接]

Lv1.梦旅人

梦石
0
星屑
114
在线时间
53 小时
注册时间
2013-6-29
帖子
19
跳转到指定楼层
1
发表于 2016-7-9 12:28:23 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
论坛里下的这脚本,在组满四个人之后进战斗,唤出第五个人时,角色图片不现实,但是角色存在并且可以攻击之类的

下面脚本我也改了限制了,VA里面的战斗人数限制也改了,第五人的位置也设置了,但是就是不出图片(前四个都正常也能中途召唤,但是第五人往后全部都不显示角色图片了),技能释放攻击都正常



#==============================================================================
# ■ 此脚本来自 www.66rpg.com
#------------------------------------------------------------------------------
#   名称:横版战斗模板
#   作者:后知后觉([email protected])
#   版本:v1.7  2012-02-09
#   使用协议:在保留此脚本相关信息的情况下
#             可任意使用、修改及修改后发布.
#             如是修改后发布.请在作者标注那里加上 某某某改 等信息
#             感谢你来这里谈谈你对这个工程的看法或报告BUG.
#               http://rpg.blue/thread-216673-1-1.html
#   使用说明:
#       请来发布帖查看:
#           http://rpg.blue/thread-216673-1-1.html
#==============================================================================

module Hzhj
  module HorizontalBattleSystem
    # 取得参战角色的最大数.如果要改大.需要在下面的坐标设置里增加对应的条目
    MaxBattleMembers = 5
   
    ActorsBattlePosition = {}
    # 设置角色战斗图形的坐标
    # 等号左边的[]号里面的1 2 3 4 表示角色在队伍里的位置
    # 等号右边的[]号里面的两个数字分别表示 X坐标 Y坐标
    # 每次进入战斗的时候都会以这里设置的信息作为初始化位置.
    # 如果你把上面的 MaxBattleMembers 改大了.比如改成了 5.
    # 那么你需要在下面新增一行代码设置队伍中第5位置的坐标.
    # 就像这样 ActorsBattlePosition[5] = [X坐标, Y坐标]
    ActorsBattlePosition[1] = [132, 520]
    ActorsBattlePosition[2] = [264, 520]
    ActorsBattlePosition[3] = [396, 520]
    ActorsBattlePosition[4] = [528, 520]
    ActorsBattlePosition[5] = [660, 520]
   
    # 设置伤害值图形的色相 取值范围 0~360
    DamageBitmapHue = 0
    # 伤害值分段显示的标志SE文件名
    DamageSectionDisplaySEName = false
   
    # 动画 Z 坐标值默认变化量
    DefaultAniAddZ = false
   
    # 状态动画 Z 坐标值默认变化量
    DefaultLoopAniAddZ = false
   
    # 战斗中角色的面向
    ActorDirection = 5
   
    # 真位移的帧数
    RealMoveDuration = false
    # 真位移移动前会计算目标点.会获取攻防双方战斗图大小来进行计算.
    # 下面2个是对战斗图 width height 进行修正.
    # 为正则扩大 为负则缩小.单位 像素.
    # 一般来说不必修改.只有像梦幻群侠传那种战斗图四边有很多透明区域时才修正.
    RealMoveBmpAddW = 0
    RealMoveBmpAddH = 0
   
    # 使用技能、物品的过程默认使用RMVA模式
    # 在该模式下.本脚本提供的很多功能受限无法使用.
    DefaultUseRmvaMode = false
   
    # 默认显示敌人的HP条、MP条、TP条
    DefaultDisplayEnemyBar = true
   
    # 一张战斗图中有几个样式(帧、格)
    DynamicPatternMax = 1
    # 一张战斗图中的一个样式持续多少帧
    OnePatternDuration = 1
   
    # 角色使用战斗死亡图形
    UseActorDeadGraphic = true
    # 敌人使用战斗死亡图形
    UseEnemyDeadGraphic = true
   
    # 使用挨打图形
    UseBeatenGraphic = false
    # 挨打图形维持帧数
    BeatenGraphicDuration = 30
   
    # 是否使用角色防御图 只有同时使用了挨打图.此项才有效.
    UseActorGuardGraphic = false
    # 是否使用敌人防御图 只有同时使用了挨打图.此项才有效.
    UseEnemyGuardGraphic = false
   
    # 角色是否使用挨打SE
    UseActorWBSE = false
    # 敌人是否使用挨打SE
    UseEnemyWBSE = false
    # 角色是否使用防御SE
    UseActorGDSE = false
    # 敌人是否使用防御SE
    UseEnemyGDSE = false
  end
end

class RPG::Actor < RPG::BaseItem
  def battler_name
    return @battler_name unless @battler_name.nil?
    if /@btname\[(.+?)\]/ =~ @note
      return (@battler_name = $1.clone)
    else
      return (@battler_name = "#{@name}_#{@nickname}")
    end
  end
  def battler_hue
    return @battler_hue unless @battler_hue.nil?
    if /@bthue\[([0-9]+?)\]/ =~ @note
      return (@battler_hue = $1.to_i.abs)
    else
      return (@battler_hue = 0)
    end
  end
  attr_writer :battler_name
  attr_writer :battler_hue
end
#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # ● 属性(新增定义)
  #--------------------------------------------------------------------------
  attr_writer   :battler_name             # 战斗图形文件名
  attr_writer   :battler_hue              # 战斗图形色相
  #--------------------------------------------------------------------------
  # ● 设置(追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_setup_for_add_actor_battle_graphic setup
  def setup(actor_id)
    hzhj_old_setup_for_add_actor_battle_graphic(actor_id)
    @battler_name = actor.battler_name
    @battler_hue = actor.battler_hue
  end
  #--------------------------------------------------------------------------
  # ● 是否使用活动块(重定义)
  #--------------------------------------------------------------------------
  def use_sprite?
    return true
  end
  #--------------------------------------------------------------------------
  # ● 取得战斗画面 X 坐标(新增定义)
  #--------------------------------------------------------------------------
  def screen_x
    return ActorsBattlePosition[index + 1][0]
  end
  #--------------------------------------------------------------------------
  # ● 取得战斗画面 Y 坐标(新增定义)
  #--------------------------------------------------------------------------
  def screen_y
    return ActorsBattlePosition[index + 1][1]
  end
  #--------------------------------------------------------------------------
  # ● 取得战斗画面 Z 坐标(新增定义)
  #--------------------------------------------------------------------------
  def screen_z
    return real_screen_y + 100
  end
end
#==============================================================================
# ■ Game_Enemy
#==============================================================================
class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # ● 属性(新增定义)
  #--------------------------------------------------------------------------
  attr_writer   :battler_name             # 战斗图形文件名
  attr_writer   :battler_hue              # 战斗图形色相
  #--------------------------------------------------------------------------
  # ● 取得战斗画面 Z 坐标(重定义)
  #--------------------------------------------------------------------------
  def screen_z
    return real_screen_y + 100
  end
end
#==============================================================================
# ■ Game_Party
#==============================================================================
class Game_Party < Game_Unit
  include Hzhj::HorizontalBattleSystem
  #--------------------------------------------------------------------------
  # ● 取得参战角色的最大数(重定义)
  #--------------------------------------------------------------------------
  def max_battle_members
    return MaxBattleMembers
  end
end

class RPG::Animation
  def wait_subject_duration
    return @wait_subject_duration unless @wait_subject_duration.nil?
    if /@w\[(\-??\d+?)\]/ =~ @name
      @wait_subject_duration = $1.to_i
    else
      @wait_subject_duration = 0
    end
    return @wait_subject_duration
  end
  attr_writer :wait_subject_duration
end
class RPG::UsableItem < RPG::BaseItem
  include Hzhj::HorizontalBattleSystem
  def animation1_id
    return @animation1_id unless @animation1_id.nil?
    if /@a1id\[(\d+?)\]/i =~ @note
      return (@animation1_id = $1.to_i)
    else
      return (@animation1_id = 0)
    end
  end
  def wljn
    return @wljn unless @wljn.nil?
    if /@wljn/i =~ @note
      return (@wljn = true)
    else
      return (@wljn = false)
    end
  end
  def rmva_mode
    return @rmva_mode unless @rmva_mode.nil?
    if /@rmva/i =~ @note
      return (@rmva_mode = !DefaultUseRmvaMode)
    else
      return (@rmva_mode = DefaultUseRmvaMode)
    end
  end
  attr_writer :animation1_id
  attr_writer :wljn
  attr_writer :rmva_mode
end
class RPG::Weapon < RPG::EquipItem
  def animation1_id
    return @animation1_id unless @animation1_id.nil?
    if /@a1id\[(\d+?)\]/ =~ @note
      return (@animation1_id = $1.to_i)
    else
      return (@animation1_id = 0)
    end
  end
  attr_writer :animation1_id
end
class RPG::Enemy < RPG::BaseItem
  def animation1_id
    return @animation1_id unless @animation1_id.nil?
    if /@a1id\[(\d+?)\]/ =~ @note
      return (@animation1_id = $1.to_i)
    else
      return (@animation1_id = 0)
    end
  end
  def animation2_id
    return @animation2_id unless @animation2_id.nil?
    if /@a2id\[(\d+?)\]/ =~ @note
      return (@animation2_id = $1.to_i)
    else
      return (@animation2_id = 0)
    end
  end
  def animation3_id
    return @animation3_id unless @animation3_id.nil?
    if /@a3id\[(\d+?)\]/ =~ @note
      return (@animation3_id = $1.to_i)
    else
      return (@animation3_id = 0)
    end
  end
  attr_writer :animation1_id
  attr_writer :animation2_id
  attr_writer :animation3_id
end
#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # ● 取得普通攻击的行动方动画 ID (新增定义)
  #--------------------------------------------------------------------------
  def animation1_id
    if dual_wield?
      return weapons[0].animation1_id if weapons[0]
      return weapons[1] ? weapons[1].animation1_id : 0
    else
      return weapons[0] ? weapons[0].animation1_id : 0
    end
  end
end
#==============================================================================
# ■ Game_Enemy
#==============================================================================
class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # ● 取得普通攻击的行动方动画 ID (新增定义)
  #--------------------------------------------------------------------------
  def animation1_id
    return enemy.animation1_id
  end
  #--------------------------------------------------------------------------
  # ● 取得普通攻击的动画 ID (新增定义)
  #--------------------------------------------------------------------------
  def atk_animation_id1
    return enemy.animation2_id
  end
  #--------------------------------------------------------------------------
  # ● 取得普通攻击的动画 ID (二刀流:武器2)(新增定义)
  #--------------------------------------------------------------------------
  def atk_animation_id2
    return enemy.animation3_id
  end
end
#==============================================================================
# ■ Scene_Battle
#==============================================================================
class Scene_Battle < Scene_Base
  include Hzhj::HorizontalBattleSystem
  #--------------------------------------------------------------------------
  # ● 使用技能/物品(重定义)
  #--------------------------------------------------------------------------
  def use_item
    item = @subject.current_action.item
    @log_window.display_use_item(@subject, item)
    @subject.use_item(item)
    refresh_status
    targets = @subject.current_action.make_targets.compact
    show_animation(targets, item.animation_id)
  end
  #--------------------------------------------------------------------------
  # ● 显示动画(重定义)
  #--------------------------------------------------------------------------
  def show_animation(targets, animation_id)
    item = @subject.current_action.item
    if item.rmva_mode
      show_rmva_animation(targets, animation_id, item)
    else
      show_hzhj_animation(targets, animation_id, item)
    end
  end
  #--------------------------------------------------------------------------
  # ● RMVA模式显示动画(新增定义)
  #--------------------------------------------------------------------------
  def show_rmva_animation(targets, animation_id, item)
    @subject.damage_section_displayed = false
    @subject.not_damage_section = true
    targets.each do |target|
      target.damage_section_displayed = false
      target.not_damage_section = true
    end
    if animation_id < 0
      show_attack_animation(targets)
    else
      show_rmva_usable_animation(targets, animation_id, item)
    end
  end
  #--------------------------------------------------------------------------
  # ● HZHJ模式显示动画(新增定义)
  #--------------------------------------------------------------------------
  def show_hzhj_animation(targets, animation_id, item)
    if animation_id < 0
      show_hzhj_attack_animation(targets, item)
    else
      if item.wljn
        show_wljn_skill_animation(targets, animation_id, item)
      else
        show_magic_skill_animation(targets, animation_id, item)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● HZHJ模式显示攻击动画(重定义)
  #--------------------------------------------------------------------------
  def show_hzhj_attack_animation(targets, item)
    ary = []
    need_move = false
    animation1 = $data_animations[@subject.animation1_id]
    need_move = animation1.need_move if animation1
    come_back = true
    targets.each_with_index do |target, i|
      ary[0] = target
      item.repeats.times do
        next if target.dead? && item.damage.type == 1
        next if @subject.dead?
        next if [email protected]_action
        if need_move && come_back
          come_back = false
          @subject.setup_move_info(target, RealMoveDuration, animation1.move_se)
          wait_for_move
        end
        damage_target = hzhj_apply_item_effects(target, item)
        show_subject_animation(@subject.animation1_id)
        show_normal_animation(ary, @subject.atk_animation_id1, false)
        show_normal_animation(ary, @subject.atk_animation_id2, true)
        @log_window.wait
        wait_for_animation
        hzhj_invoke_item(target, item, damage_target)
      end
      if need_move
        if target != targets[i+1] or target.dead?
          come_back = true
          @subject.come_back_self_position(RealMoveDuration)
          wait_for_move
        else
          come_back = false
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● HZHJ模式显示物理技能类动画(新增定义)
  #--------------------------------------------------------------------------
  def show_wljn_skill_animation(targets, animation_id, item)
    ary = []
    need_move = false
    animation1 = $data_animations[item.animation1_id]
    need_move = animation1.need_move if animation1
    come_back = true
    targets.each_with_index do |target, i|
      ary[0] = target
      item.repeats.times do
        next if target.dead? && item.damage.type == 1
        next if @subject.dead?
        next if [email protected]_action
        if need_move && come_back
          come_back = false
          @subject.setup_move_info(target, RealMoveDuration, animation1.move_se)
          wait_for_move
        end
        damage_target = hzhj_apply_item_effects(target, item)
        show_subject_animation(item.animation1_id)
        show_normal_animation(ary, animation_id, false)
        @log_window.wait
        wait_for_animation
        hzhj_invoke_item(target, item, damage_target)
      end
      if need_move
        if target != targets[i+1] or target.dead?
          come_back = true
          @subject.come_back_self_position(RealMoveDuration)
          wait_for_move
        else
          come_back = false
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● HZHJ模式显示魔法技能类动画(新增定义)
  #--------------------------------------------------------------------------
  def show_magic_skill_animation(targets, animation_id, item)
    ary = []
    damage_targets = {}
    item.repeats.times do
      next if @subject.dead?
      next if [email protected]_action
      ary.clear
      damage_targets.clear
      targets.each do |target|
        next if target.dead? && item.damage.type == 1
        ary << target
        damage_targets[target] = hzhj_apply_item_effects(target, item)
      end
      next if ary.empty?
      show_subject_animation(item.animation1_id)
      show_normal_animation(ary, animation_id)
      @log_window.wait
      wait_for_animation
      ary.each do |target|
        hzhj_invoke_item(target, item, damage_targets[target])
      end
      if [9, 10].include?(item.scope)
        ary.each do |target|
          if target.alive?
            target.come_back_self_position(RealMoveDuration)
          end
        end
        wait_for_move
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● RMVA模式显示攻击动画(重定义)
  #--------------------------------------------------------------------------
  def show_attack_animation(targets)
    item = @subject.current_action.item
    show_subject_animation(@subject.animation1_id)
    show_normal_animation(targets, @subject.atk_animation_id1, false)
    show_normal_animation(targets, @subject.atk_animation_id2, true)
    @log_window.wait
    wait_for_animation
    targets.each {|target| item.repeats.times { invoke_item(target, item) } }
  end
  #--------------------------------------------------------------------------
  # ● RMVA模式显示技能、物品动画 (新增定义)
  #--------------------------------------------------------------------------
  def show_rmva_usable_animation(targets, animation_id, item)
    show_subject_animation(item.animation1_id)
    show_normal_animation(targets, animation_id)
    @log_window.wait
    wait_for_animation
    targets.each {|target| item.repeats.times { invoke_item(target, item) } }
    if [9, 10].include?(item.scope)
      targets.each do |target|
        if target.alive?
          target.come_back_self_position(RealMoveDuration)
        end
      end
      wait_for_move
    end
  end
  #--------------------------------------------------------------------------
  # ● 显示行动方动画(新增定义)
  #--------------------------------------------------------------------------
  def show_subject_animation(animation_id, subject = @subject, mirror = false)
    animation = $data_animations[animation_id]
    if animation
      subject.animation_id = animation_id
      subject.animation_mirror = mirror
      if animation.wait_subject_duration < 0
        wait_for_animation
      elsif animation.wait_subject_duration > 0
        animation.wait_subject_duration.times{update_for_wait}
      end
    end
  end
end

class RPG::Animation
  include Hzhj::HorizontalBattleSystem
  def ani_z_correction
    return @ani_z_correction unless @ani_z_correction.nil?
    if /@az\[(\-??\d+?)\]/ =~ @name
      return (@ani_z_correction = $1.to_i)
    else
      return (@ani_z_correction = DefaultAniAddZ)
    end
  end
  def loop_z_correction
    return @loop_z_correction unless @loop_z_correction.nil?
    if /@lz\[(\-??\d+?)\]/ =~ @name
      return (@loop_z_correction = $1.to_i)
    else
      return (@loop_z_correction = DefaultLoopAniAddZ)
    end
  end
  attr_writer :ani_z_correction
  attr_writer :loop_z_correction
end
class RPG::State < RPG::BaseItem
  def animation_id
    return @animation_id unless @animation_id.nil?
    if /@aid\[(\d+?)\]/ =~ @note
      return (@animation_id = $1.to_i)
    else
      return (@animation_id = 0)
    end
  end
  attr_writer :animation_id
end
#==============================================================================
# ■ Game_BattlerBase
#==============================================================================
class Game_BattlerBase
  #--------------------------------------------------------------------------
  # ● 实例变量(新增定义)
  #--------------------------------------------------------------------------
  attr_reader   :hzhj_add_state_id
  attr_reader   :hzhj_remove_state_id
  attr_accessor :need_update_state_animation
  #--------------------------------------------------------------------------
  # ● 初始化(追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_init_for_state_ani_game_battler_base initialize
  def initialize
    @hzhj_add_state_id = []
    @hzhj_remove_state_id = []
    @need_update_state_animation = false
    @states = []
    @state_turns = {}
    @state_steps = {}
    hzhj_old_init_for_state_ani_game_battler_base
  end
  #--------------------------------------------------------------------------
  # ● 清除状态信息(追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_clear_states_for_state_ani_game_battler_base clear_states
  def clear_states
    old_states = @states.clone
    hzhj_old_clear_states_for_state_ani_game_battler_base
    bingji = old_states | @states
    return if bingji.empty?
    set_add_state_id(bingji & @states)
    set_remove_state_id(bingji & old_states)
  end
  #--------------------------------------------------------------------------
  # ● 消除状态(追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_erase_state_for_state_ani_game_battler_base erase_state
  def erase_state(state_id)
    old_states = @states.clone
    hzhj_old_erase_state_for_state_ani_game_battler_base(state_id)
    bingji = old_states | @states
    return if bingji.empty?
    set_add_state_id(bingji & @states)
    set_remove_state_id(bingji & old_states)
  end
  #--------------------------------------------------------------------------
  # ● 设置增加的状态(新增定义)
  #--------------------------------------------------------------------------
  def set_add_state_id(zjdzt)
    for i in zjdzt
      if $data_states.animation_id > 0
        if not @hzhj_add_state_id.include?(i)
          @hzhj_add_state_id.push(i)
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 设置解除的状态(新增定义)
  #--------------------------------------------------------------------------
  def set_remove_state_id(jsdzt)
    for i in jsdzt
      if $data_states.animation_id > 0
        if not @hzhj_remove_state_id.include?(i)
          ani_id = $data_states.animation_id
          not_end_loop_animation = false
          for state in self.states
            if state.animation_id == ani_id
              not_end_loop_animation = true
              break
            end
          end
          unless not_end_loop_animation
            @hzhj_remove_state_id.push(i)
          end
        end
      end
    end
  end
end
#==============================================================================
# ■ Game_Battler
#==============================================================================
class Game_Battler < Game_BattlerBase
  #--------------------------------------------------------------------------
  # ● 附加新的状态(追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_add_new_state_for_state_ani_game_battler add_new_state
  def add_new_state(state_id)
    old_states = @states.clone
    hzhj_old_add_new_state_for_state_ani_game_battler(state_id)
    bingji = old_states | @states
    return if bingji.empty?
    set_add_state_id(bingji & @states)
    set_remove_state_id(bingji & old_states)
  end
end
#==============================================================================
# ■ Sprite_Base
#==============================================================================
class Sprite_Base < Sprite
  #--------------------------------------------------------------------------
  # ● 初始化(追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_init_for_state_ani_spr_base initialize
  def initialize(*args)
    hzhj_old_init_for_state_ani_spr_base(*args)
    @hzhj_loop_animations = []
    @hzhj_loop_durations = {}
    @hzhj_loop_sprites = {}
    @hzhj_loop_bitmap1s = {}
    @hzhj_loop_bitmap2s = {}
    @hzhj_loop_ani_oxs = {}
    @hzhj_loop_ani_oys = {}
    @flash_nil_duration = 0
  end
  #--------------------------------------------------------------------------
  # ● 释放(追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_dispose_for_state_ani_spr_base dispose
  def dispose
    dispose_loop_animation
    hzhj_old_dispose_for_state_ani_spr_base
  end
  #--------------------------------------------------------------------------
  # ● 设定动画的活动块(追加定义)
  #--------------------------------------------------------------------------
#~   alias hzhj_old_ani_set_spr_for_state_ani_spr_base animation_set_sprites
#~   def animation_set_sprites(*args)
#~     hzhj_old_ani_set_spr_for_state_ani_spr_base(*args)
#~     @ani_sprites.each{|sprite|sprite.z += @animation.ani_z_correction}
#~   end
  #--------------------------------------------------------------------------
  # ● 判断是否有循环动画(新增定义)
  #--------------------------------------------------------------------------
  def loop_animation?
    return (not @hzhj_loop_animations.empty?)
  end
  #--------------------------------------------------------------------------
  # ● 开始播放循环动画(新增定义)
  #--------------------------------------------------------------------------
  def start_loop_animation(animation)
    return if @hzhj_loop_animations.include?(animation)
    if animation.nil?
      dispose_loop_animation
      return
    end
    set_animation_rate
    @hzhj_loop_animations.push(animation)
    init_loop_animation_duration(animation)
    load_loop_animation_bitmap(animation)
    make_loop_animation_sprites(animation)
    set_loop_animation_origin(animation)
  end
  #--------------------------------------------------------------------------
  # ● 初始化循环动画播放位置(新增定义)
  #--------------------------------------------------------------------------
  def init_loop_animation_duration(animation)
    @hzhj_loop_durations[animation] = animation.frame_max * @ani_rate + 1
  end
  #--------------------------------------------------------------------------
  # ● 读取循环动画图像(新增定义)
  #--------------------------------------------------------------------------
  def load_loop_animation_bitmap(animation)
    animation1_name = animation.animation1_name
    animation1_hue = animation.animation1_hue
    animation2_name = animation.animation2_name
    animation2_hue = animation.animation2_hue
    bitmap1 = Cache.animation(animation1_name, animation1_hue)
    bitmap2 = Cache.animation(animation2_name, animation2_hue)
    if @@_reference_count.include?(bitmap1)
      @@_reference_count[bitmap1] += 1
    else
      @@_reference_count[bitmap1] = 1
    end
    if @@_reference_count.include?(bitmap2)
      @@_reference_count[bitmap2] += 1
    else
      @@_reference_count[bitmap2] = 1
    end
    @hzhj_loop_bitmap1s[animation] = bitmap1
    @hzhj_loop_bitmap2s[animation] = bitmap2
    Graphics.frame_reset
  end
  #--------------------------------------------------------------------------
  # ● 生成循环动画活动块(新增定义)
  #--------------------------------------------------------------------------
  def make_loop_animation_sprites(animation)
    sprites = []
    if @use_sprite
      16.times do
        sprite = ::Sprite.new(viewport)
        sprite.visible = false
        sprites.push(sprite)
      end
    end
    @hzhj_loop_sprites[animation] = sprites
  end
  #--------------------------------------------------------------------------
  # ● 设定循环动画的原点(新增定义)
  #--------------------------------------------------------------------------
  def set_loop_animation_origin(animation)
    if animation.position == 3
      if viewport == nil
        ani_ox = Graphics.width / 2
        ani_oy = Graphics.height / 2
      else
        ani_ox = viewport.rect.width / 2
        ani_oy = viewport.rect.height / 2
      end
    else
      ani_ox = x - ox + width / 2
      ani_oy = y - oy + height / 2
      if animation.position == 0
        ani_oy -= height / 2
      elsif animation.position == 2
        ani_oy += height / 2
      end
    end
    @hzhj_loop_ani_oxs[animation] = ani_ox
    @hzhj_loop_ani_oys[animation] = ani_oy
  end
  #--------------------------------------------------------------------------
  # ● 释放所有循环动画(新增定义)
  #--------------------------------------------------------------------------
  def dispose_loop_animation
    return unless loop_animation?
    for animation in @hzhj_loop_animations.clone
      end_loop_animation(animation)
    end
    @hzhj_loop_durations.clear
    @hzhj_loop_sprites.clear
    @hzhj_loop_bitmap1s.clear
    @hzhj_loop_bitmap2s.clear
    @hzhj_loop_ani_oxs.clear
    @hzhj_loop_ani_oys.clear
    @hzhj_loop_animations.clear
  end
  #--------------------------------------------------------------------------
  # ● 结束某个循环动画(新增定义)
  #--------------------------------------------------------------------------
  def end_loop_animation(animation)
    return if not @hzhj_loop_animations.include?(animation)
    bitmap1 = @hzhj_loop_bitmap1s[animation]
    @@_reference_count[bitmap1] -= 1
    if @@_reference_count[bitmap1] == 0
      @@_reference_count.delete(bitmap1)
      bitmap1.dispose
    end
    bitmap2 = @hzhj_loop_bitmap2s[animation]
    @@_reference_count[bitmap2] -= 1
    if @@_reference_count[bitmap2] == 0
      @@_reference_count.delete(bitmap2)
      bitmap2.dispose
    end
    sprites = @hzhj_loop_sprites[animation]
    for sprite in sprites
      sprite.dispose
    end
    @hzhj_loop_durations.delete(animation)
    @hzhj_loop_sprites.delete(animation)
    @hzhj_loop_bitmap1s.delete(animation)
    @hzhj_loop_bitmap2s.delete(animation)
    @hzhj_loop_ani_oxs.delete(animation)
    @hzhj_loop_ani_oys.delete(animation)
    @hzhj_loop_animations.delete(animation)
  end
  #--------------------------------------------------------------------------
  # ● 刷新(追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_update_for_state_ani_spr_base update
  def update
    hzhj_old_update_for_state_ani_spr_base
    update_loop_animation
  end
  #--------------------------------------------------------------------------
  # ● 刷新循环动画(新增定义)
  #--------------------------------------------------------------------------
  def update_loop_animation
    @flash_nil_duration -= 1 if @flash_nil_duration > 0
    return unless loop_animation?
    for animation in @hzhj_loop_animations
      @hzhj_loop_durations[animation] -= 1
      duration = @hzhj_loop_durations[animation]
      if duration % @ani_rate == 0
        if duration > 0
          set_loop_animation_origin(animation)
          frame_index = animation.frame_max
          frame_index -= (duration + @ani_rate - 1) / @ani_rate
          args = []
          args[0] = @hzhj_loop_sprites[animation]
          args[1] = @hzhj_loop_bitmap1s[animation]
          args[2] = @hzhj_loop_bitmap2s[animation]
          args[3] = @hzhj_loop_ani_oxs[animation]
          args[4] = @hzhj_loop_ani_oys[animation]
          args[5] = animation.loop_z_correction
          args[6] = ((not flash_nil? or animation.to_screen?) and visible)
          loop_animation_set_sprites(animation.frames[frame_index], args)
          animation.timings.each do |timing|
            loop_animation_process_timing(timing) if timing.frame == frame_index
          end
        else
          init_loop_animation_duration(animation)
          redo
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 设定循环动画的活动块(新增定义)
  #--------------------------------------------------------------------------
  def loop_animation_set_sprites(frame, args)
    sprites = args[0]
    bitmap1 = args[1]
    bitmap2 = args[2]
    ani_ox = args[3]
    ani_oy = args[4]
    loop_z_correction = args[5]
    state_visible = args[6]
    cell_data = frame.cell_data
    sprites.each_with_index do |sprite, i|
      next unless sprite
      pattern = cell_data[i, 0]
      if !pattern || pattern < 0
        sprite.visible = false
        next
      end
      sprite.bitmap = pattern < 100 ? bitmap1 : bitmap2
      sprite.visible = state_visible
      sprite.src_rect.set(pattern % 5 * 192,
        pattern % 100 / 5 * 192, 192, 192)
      sprite.x = ani_ox + cell_data[i, 1]
      sprite.y = ani_oy + cell_data[i, 2]
      sprite.angle = cell_data[i, 4]
      sprite.mirror = (cell_data[i, 5] == 1)
      if loop_z_correction > 9999
        sprite.z = loop_z_correction % 10000 + i
      elsif loop_z_correction < -9999
        sprite.z = loop_z_correction % -10000 + i
      else
        sprite.z = self.z + loop_z_correction + i
      end
      sprite.ox = 96
      sprite.oy = 96
      sprite.zoom_x = cell_data[i, 3] / 100.0
      sprite.zoom_y = cell_data[i, 3] / 100.0
      sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
      sprite.blend_type = cell_data[i, 7]
    end
  end
  #--------------------------------------------------------------------------
  # ● 循环动画SE 和闪烁时机的处理(新增定义)
  #--------------------------------------------------------------------------
  def loop_animation_process_timing(timing)
    timing.se.play
    case timing.flash_scope
    when 1
      self.flash(timing.flash_color, timing.flash_duration * @ani_rate)
    when 2
      if viewport
        viewport.flash(timing.flash_color, timing.flash_duration * @ani_rate)
      end
    when 3
      self.flash(nil, timing.flash_duration * @ani_rate)
    end
  end
  #--------------------------------------------------------------------------
  # ● 设置闪烁(追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_flash_for_state_ani_spr_base flash
  def flash(*args)
    if args[0].nil?
      @flash_nil_duration = args[1]
    else
      @flash_nil_duration = 0
    end
    hzhj_old_flash_for_state_ani_spr_base(*args)
  end
  #--------------------------------------------------------------------------
  # ● 判断是否正处于【隐藏目标】(新增定义)
  #--------------------------------------------------------------------------
  def flash_nil?
    return (@flash_nil_duration > 0)
  end
end
#==============================================================================
# ■ Sprite_Battler
#==============================================================================
class Sprite_Battler < Sprite_Base
  #--------------------------------------------------------------------------
  # ● 初始化(追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_init_for_state_ani_spr_battler initialize
  def initialize(*args)
    hzhj_old_init_for_state_ani_spr_battler(*args)
    init_battler_add_state_id
  end
  #--------------------------------------------------------------------------
  # ● 初始化战斗者要播放状态动画的状态(新增定义)
  #--------------------------------------------------------------------------
  def init_battler_add_state_id
    if @battler.nil?
      dispose_loop_animation
    else
      @battler.hzhj_add_state_id.clear
      @battler.hzhj_remove_state_id.clear
      @battler.need_update_state_animation = true
      for state in @battler.states
        next if state.nil?
        next if $data_animations[state.animation_id].nil?
        @battler.hzhj_add_state_id.push(state.id)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 设置战斗者(追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_battlerdy_for_state_ani_spr_battler battler=
  def battler=(value)
    old_battler = @battler
    hzhj_old_battlerdy_for_state_ani_spr_battler(value)
    if old_battler != @battler
      init_battler_add_state_id
    end
  end
  #--------------------------------------------------------------------------
  # ● 刷新(追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_update_for_state_ani_spr_battler update
  def update
    hzhj_old_update_for_state_ani_spr_battler
    if @battler
      if @battler.need_update_state_animation
        @battler.need_update_state_animation = false
        if not @battler.hzhj_add_state_id.empty?
          for i in @battler.hzhj_add_state_id
            if @battler.state?(i)
              ani_id = $data_states.animation_id
              animation = $data_animations[ani_id]
              start_loop_animation(animation) if not animation.nil?
            end
          end
          @battler.hzhj_add_state_id.clear
        end
        if not @battler.hzhj_remove_state_id.empty?
          for i in @battler.hzhj_remove_state_id
            if not @battler.state?(i)
              ani_id = $data_states.animation_id
              animation = $data_animations[ani_id]
              end_loop_animation(animation) if not animation.nil?
            end
          end
          @battler.hzhj_remove_state_id.clear
        end
      end
    end
  end
end
#==============================================================================
# ■ Window_BattleLog
#==============================================================================
class Window_BattleLog < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 显示状态附加/解除(追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_display_status_for_state_ani_wnd_btlog display_changed_states
  def display_changed_states(target)
    target.need_update_state_animation = true
    hzhj_old_display_status_for_state_ani_wnd_btlog(target)
  end
end

#==============================================================================
# ■ Sprite_Damage (新增类)
#==============================================================================
class Sprite_Damage < Sprite
  include Hzhj::HorizontalBattleSystem
  #--------------------------------------------------------------------------
  # ● 获取/生成伤害值源图
  #--------------------------------------------------------------------------
  @@obmp = nil
  def self.obmp
    if @@obmp.nil? or @@obmp.disposed?
      @@obmp = Bitmap.new(180, 256)
      @@obmp.font.bold = true
      @@obmp.font.shadow = false
      @@obmp.font.outline = true
      @@obmp.font.out_color = Color.new(255, 255, 255, 255)
      @@obmp.font.size = 32
      colors = []
      colors.push(Color.new(255,   0,   0, 255))
      colors.push(Color.new(255, 128, 128, 255))
      colors.push(Color.new(  0,   0, 255, 255))
      colors.push(Color.new(128, 128, 255, 255))
      colors.push(Color.new(  0, 255,   0, 255))
      colors.push(Color.new(128, 255, 128, 255))
      colors.each_with_index do |color, hi|
        @@obmp.font.color = color
        for wi in 0..9
          @@obmp.draw_text(wi * 18, hi * 32, 18, 32, "#{wi}", 1)
        end
      end
      @@obmp.font.size = 20
      @@obmp.font.italic = true
      @@obmp.font.out_color = Color.new(0, 0, 0, 255)
      @@obmp.font.color = Color.new(255, 255, 255, 255)
      @@obmp.draw_text( 0, 192, 90, 32, "Critical", 1)
      @@obmp.draw_text(90, 192, 90, 32, "Miss", 1)
      @@obmp.draw_text( 0, 224, 90, 32, "Evasion", 1)
      @@obmp.hue_change(DamageBitmapHue)
    end
    return @@obmp
  end
  #--------------------------------------------------------------------------
  # ● 初始化
  #--------------------------------------------------------------------------
  def initialize(viewport, args)
    super(viewport)
    @type = args[0]
    @value = args[1]
    @critical = args[2]
    self.x = args[4]
    self.y = args[5]
    self.z = args[6] + Graphics.height * 5
    make_move(args[3])
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 生成移动数据
  #--------------------------------------------------------------------------
  def make_move(battler_obj_class)
    @move = []
    case battler_obj_class
    when :actor
      make_move_actor
    when :enemy
      make_move_enemy
    else
      make_move_default
    end
  end
  #--------------------------------------------------------------------------
  # ● 生成移动数据 默认
  #--------------------------------------------------------------------------
  def make_move_default
    45.times do |n|
      if n % 3 == 0
        ady = n < 21 ? -6 : -1
        opa = n < 21 ? 255 : 255-(n-21)*6
        @move.push([0, ady, opa])
      else
        @move.push([0, 0, -1])
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 生成移动数据 角色
  #--------------------------------------------------------------------------
  def make_move_actor
    make_move_default
  end
  #--------------------------------------------------------------------------
  # ● 生成移动数据 敌人
  #--------------------------------------------------------------------------
  def make_move_enemy
    make_move_default
  end
  #--------------------------------------------------------------------------
  # ● 描绘
  #--------------------------------------------------------------------------
  def refresh
    if not self.bitmap.nil?
      self.bitmap.dispose
      self.bitmap = nil
    end
    begin
      @obmp = Cache.animation("damage", DamageBitmapHue)
    rescue Errno::ENOENT
      @obmp = Sprite_Damage.obmp
    end
    @numw = @obmp.width / 10
    @numh = @obmp.height / 8
    @strw = @obmp.width / 2
    case @value
    when Numeric
      blt_obmp_numeric
    when Symbol
      blt_obmp_text
    end
  end
  #--------------------------------------------------------------------------
  # ● 通过源图描绘数字
  #--------------------------------------------------------------------------
  def blt_obmp_numeric
    nums = @value.to_i.abs.to_s.split("")
    nbmpw = nums.size * @numw
    bmph = @numh
    cbmpw = 0
    crect = nil
    dy = 0
    if @critical
      cbmpw = @strw
      bmph *= 2
      crect = Rect.new(0, @numh * 6, @strw, @numh)
      dy = @numh
    end
    self.bitmap = Bitmap.new([nbmpw, cbmpw, 32].max, [bmph, 32].max)
    self.ox = bitmap.width / 2
    self.oy = bmph /2
    bitmap.blt((bitmap.width - cbmpw) / 2, 0, @obmp, crect) if crect
    dx = (bitmap.width - nbmpw) / 2
    ry = 0
    case @type
    when :hp
      ry = @value >= 0 ? 0 : @numh
    when :mp
      ry = @value >= 0 ? @numh * 2 : @numh * 3
    when :tp
      ry = @value >= 0 ? @numh * 4 : @numh * 5
    else
      return
    end
    rect = Rect.new(0, ry, @numw, @numh)
    nums.each_with_index do |str, i|
      rect.x = str.to_i * @numw
      bitmap.blt(dx, dy, @obmp, rect)
      dx += @numw
    end
  end
  #--------------------------------------------------------------------------
  # ● 通过源图描绘文字
  #--------------------------------------------------------------------------
  def blt_obmp_text
    self.bitmap = Bitmap.new([@strw, 32].max, [@numh, 32].max)
    self.ox = @strw / 2
    self.oy = @numh / 2
    rx = ry = 0
    case @type
    when :miss
      rx = @strw
      ry = @numh * 6
    when :eva
      ry = @numh * 7
    else
      return
    end
    rect = Rect.new(rx, ry, @strw, @numh)
    bitmap.blt(0, 0, @obmp, rect)
  end
  #--------------------------------------------------------------------------
  # ● 释放
  #--------------------------------------------------------------------------
  def dispose
    bitmap.dispose if bitmap
    super
  end
  #--------------------------------------------------------------------------
  # ● 移动中判定
  #--------------------------------------------------------------------------
  def moving?
    return (not @move.empty?)
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def update
    super
    if moving?
      ary = @move.shift
      self.x += ary[0]
      self.y += ary[1]
      self.opacity = ary[2] if ary[2] >= 0
    end
  end
end
#==============================================================================
# ■ Game_BattlerBase
#==============================================================================
class Game_BattlerBase
  #--------------------------------------------------------------------------
  # ● 实例变量(新增定义)
  #--------------------------------------------------------------------------
  attr_accessor :hzhj_damage
  #--------------------------------------------------------------------------
  # ● 初始化(追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_init_for_display_damage_game_battler_base initialize
  def initialize
    @hzhj_damage = []
    hzhj_old_init_for_display_damage_game_battler_base
  end
end
#==============================================================================
# ■ Sprite_Base
#==============================================================================
class Sprite_Base < Sprite
  #--------------------------------------------------------------------------
  # ● 初始化(追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_init_for_display_damage_spr_base initialize
  def initialize(*args)
    hzhj_old_init_for_display_damage_spr_base(*args)
    @hzhj_damage_sprites = []
  end
  #--------------------------------------------------------------------------
  # ● 释放(追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_dispose_for_display_damage_spr_base dispose
  def dispose
    hzhj_old_dispose_for_display_damage_spr_base
    dispose_damage
  end
  #--------------------------------------------------------------------------
  # ● 判断是否有伤害在显示(新增定义)
  #--------------------------------------------------------------------------
  def damage?
    return (not @hzhj_damage_sprites.empty?)
  end
  #--------------------------------------------------------------------------
  # ● 开始显示伤害(新增定义)
  #--------------------------------------------------------------------------
  def start_damage(args)
    args[4] = x - ox + width / 2
    args[5] = y - oy + height / 2
    args[6] = z
    @hzhj_damage_sprites.push(Sprite_Damage.new(viewport, args))
  end
  #--------------------------------------------------------------------------
  # ● 释放所有伤害显示(新增定义)
  #--------------------------------------------------------------------------
  def dispose_damage
    return unless damage?
    @hzhj_damage_sprites.each{|sprite|sprite.dispose}
    @hzhj_damage_sprites.clear
  end
  #--------------------------------------------------------------------------
  # ● 刷新(追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_update_for_display_damage_spr_base update
  def update
    hzhj_old_update_for_display_damage_spr_base
    update_damage
  end
  #--------------------------------------------------------------------------
  # ● 刷新显示伤害(新增定义)
  #--------------------------------------------------------------------------
  def update_damage
    return unless damage?
    @hzhj_damage_sprites.each_with_index do |sprite, i|
      if sprite.moving?
        sprite.update
      else
        sprite.dispose
        @hzhj_damage_sprites = nil
      end
    end
    @hzhj_damage_sprites.delete(nil)
  end
end
#==============================================================================
# ■ Sprite_Battler
#==============================================================================
class Sprite_Battler < Sprite_Base
  #--------------------------------------------------------------------------
  # ● 刷新(追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_update_for_display_damage_spr_battler update
  def update
    hzhj_old_update_for_display_damage_spr_battler
    if @battler
      if not @battler.hzhj_damage.empty?
        unless @battler.damage_section_displayed
          args = @battler.hzhj_damage.clone
          args[3] = @battler.actor? ? :actor : (@battler.enemy? ? :enemy : nil)
          start_damage(args)
        end
        @battler.hzhj_damage.clear
      end
    end
  end
end
#==============================================================================
# ■ Window_BattleLog
#==============================================================================
class Window_BattleLog < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 显示 MISS (追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_display_miss_for_display_damage_wnd_btlog display_miss
  def display_miss(target, item)
    target.hzhj_damage = [:miss, :miss, false]
    hzhj_old_display_miss_for_display_damage_wnd_btlog(target, item)
  end
  #--------------------------------------------------------------------------
  # ● 显示回避 (追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_display_evasion_for_display_damage_wnd_btlog display_evasion
  def display_evasion(target, item)
    target.hzhj_damage = [:eva, :evasion, false]
    hzhj_old_display_evasion_for_display_damage_wnd_btlog(target, item)
  end
  #--------------------------------------------------------------------------
  # ● 显示 HP 伤害 (追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_display_hp_damage_for_display_damage_wnd_btlog display_hp_damage
  def display_hp_damage(target, item)
    return if target.result.hp_damage == 0 && item && !item.damage.to_hp?
    value = target.result.hp_damage
    critical = target.result.critical
    target.hzhj_damage = [:hp, value, critical]
    hzhj_old_display_hp_damage_for_display_damage_wnd_btlog(target, item)
  end
  #--------------------------------------------------------------------------
  # ● 显示 MP 伤害 (追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_display_mp_damage_for_display_damage_wnd_btlog display_mp_damage
  def display_mp_damage(target, item)
    return if target.dead? || target.result.mp_damage == 0
    value = target.result.mp_damage
    critical = target.result.critical
    target.hzhj_damage = [:mp, value, critical]
    hzhj_old_display_mp_damage_for_display_damage_wnd_btlog(target, item)
  end
  #--------------------------------------------------------------------------
  # ● 显示 TP 伤害 (追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_display_tp_damage_for_display_damage_wnd_btlog display_tp_damage
  def display_tp_damage(target, item)
    return if target.dead? || target.result.tp_damage == 0
    value = target.result.tp_damage
    critical = target.result.critical
    target.hzhj_damage = [:tp, value, critical]
    hzhj_old_display_tp_damage_for_display_damage_wnd_btlog(target, item)
  end
end

class RPG::Animation
  def need_move
    return @need_move unless @need_move.nil?
    if /@[Rr][Mm]/ =~ @name
      return (@need_move = true)
    else
      return (@need_move = false)
    end
  end
  def move_se
    return @move_se unless @move_se.nil?
    @move_se = RPG::SE.new
    if /@[Ss][Ee]\[(.+?)\]/ =~ @name
      @move_se.name = $1.clone
    end
    return @move_se
  end
  attr_writer :need_move
  attr_writer :move_se
end
#==============================================================================
# ■ Game_Battler
#==============================================================================
class Game_Battler < Game_BattlerBase
  include Hzhj::HorizontalBattleSystem
  #--------------------------------------------------------------------------
  # ● 属性
  #--------------------------------------------------------------------------
  attr_accessor :add_x                    # X 坐标变化量
  attr_accessor :add_y                    # Y 坐标变化量
  attr_accessor :move_speed_x             # 战斗图 X 移动速度
  attr_accessor :move_speed_y             # 战斗图 Y 移动速度
  #--------------------------------------------------------------------------
  # ● 初始化(追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_init_for_real_move_game_battler initialize
  def initialize
    @add_x = 0
    @add_y = 0
    @move_speed_x = 0
    @move_speed_y = 0
    hzhj_old_init_for_real_move_game_battler
  end
  #--------------------------------------------------------------------------
  # ● 真实 X 坐标(新增定义)
  #--------------------------------------------------------------------------
  def real_screen_x
    return screen_x + add_x
  end
  #--------------------------------------------------------------------------
  # ● 真实 Y 坐标(新增定义)
  #--------------------------------------------------------------------------
  def real_screen_y
    return screen_y + add_y
  end
  #--------------------------------------------------------------------------
  # ● 返回自己的战斗位置(新增定义)
  #--------------------------------------------------------------------------
  def come_back_self_position(duration)
    return if dead?
    tx = screen_x
    ty = screen_y
    addx = tx - real_screen_x
    addy = ty - real_screen_y
    return if addx == 0 && addy == 0
    @add_x = 0
    @add_y = 0
    @move_speed_x = [(addx.abs / duration.to_f).ceil, 1].max
    @move_speed_y = [(addy.abs / duration.to_f).ceil, 1].max
  end
  #--------------------------------------------------------------------------
  # ● 设置移动信息(新增定义)
  #--------------------------------------------------------------------------
  def setup_move_info(target_battler, duration, move_se)
    return if dead?
    tbmp = Cache.battler(target_battler.battler_name, target_battler.battler_hue)
    sbmp = Cache.battler(@battler_name, @battler_hue)
    tbw = tbmp.width / DynamicPatternMax + RealMoveBmpAddW
    sbw = sbmp.width / DynamicPatternMax + RealMoveBmpAddW
    tbh = tbmp.height + RealMoveBmpAddH
    sbh = sbmp.height + RealMoveBmpAddH
    d = actor? ? ActorDirection : 10 - ActorDirection
    tx = target_battler.real_screen_x
    ty = target_battler.real_screen_y
    case d
    when 1
      tx = tx + tbw / 2 + sbw / 2
      ty = ty - sbh / 2
    when 2
      ty = ty - sbh / 2
    when 3
      tx = tx - tbw / 2 - sbw / 2
      ty = ty - sbh / 2
    when 4
      tx = tx + tbw / 2 + sbw / 2
    when 6
      tx = tx - tbw / 2 - sbw / 2
    when 7
      tx = tx + tbw / 2 + sbw / 2
      ty = ty + sbh / 2
    when 8
      ty = ty + sbh / 2
    when 9
      tx = tx - tbw / 2 - sbw / 2
      ty = ty + sbh / 2
    end
    addx = tx - real_screen_x
    addy = ty - real_screen_y
    return if addx == 0 && addy == 0
    @add_x = tx - screen_x if addx != 0
    @add_y = ty - screen_y if addy != 0
    @move_speed_x = [(addx.abs / duration.to_f).ceil, 1].max
    @move_speed_y = [(addy.abs / duration.to_f).ceil, 1].max
    move_se.play
  end
end
#==============================================================================
# ■ Sprite_Battler
#==============================================================================
class Sprite_Battler < Sprite_Base
  #--------------------------------------------------------------------------
  # ● 初始化(追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_init_for_real_move_spr_battler initialize
  def initialize(viewport, battler = nil)
    hzhj_old_init_for_real_move_spr_battler(viewport, battler)
    init_position(@battler) if @battler
  end
  #--------------------------------------------------------------------------
  # ● 设置战斗者(追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_set_battler_for_real_move_spr_battler battler=
  def battler=(value)
    if @battler != value && value
      init_position(value)
    end
    hzhj_old_set_battler_for_real_move_spr_battler(value)
  end
  #--------------------------------------------------------------------------
  # ● 初始化位置(新增定义)
  #--------------------------------------------------------------------------
  def init_position(battler)
    battler.add_x = 0
    battler.add_y = 0
    self.x = battler.real_screen_x
    self.y = battler.real_screen_y
    self.z = battler.screen_z
  end
  #--------------------------------------------------------------------------
  # ● 移动中判定(新增定义)
  #--------------------------------------------------------------------------
  def moving?
    return false unless @battler
    (x != @battler.real_screen_x or y != @battler.real_screen_y) && @battler
  end
  #--------------------------------------------------------------------------
  # ● 位置的更新(重定义)
  #--------------------------------------------------------------------------
  def update_position
    if [email protected]?
      if x < @battler.real_screen_x
        self.x = [x + @battler.move_speed_x, @battler.real_screen_x].min
      elsif x > @battler.real_screen_x
        self.x = [x - @battler.move_speed_x, @battler.real_screen_x].max
      end
      if y < @battler.real_screen_y
        self.y = [y + @battler.move_speed_y, @battler.real_screen_y].min
      elsif y > @battler.real_screen_y
        self.y = [y - @battler.move_speed_y, @battler.real_screen_y].max
      end
      self.z = y + 100
    end
  end
end
#==============================================================================
# ■ Spriteset_Battle
#==============================================================================
class Spriteset_Battle
  #--------------------------------------------------------------------------
  # ● 判定是否移动中(新增定义)
  #--------------------------------------------------------------------------
  def moving?
    battler_sprites.any? {|sprite| sprite.moving? }
  end
end
#==============================================================================
# ■ Scene_Battle
#==============================================================================
class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # ● 等待战斗图移动的结束(新增定义)
  #--------------------------------------------------------------------------
  def wait_for_move
    update_for_wait
    update_for_wait while @spriteset.moving?
  end
end

class RPG::Troop
  include Hzhj::HorizontalBattleSystem
  def display_enemy_bar
    return @display_enemy_bar unless @display_enemy_bar.nil?
    if /@ebar/i =~ @name
      return (@display_enemy_bar = !DefaultDisplayEnemyBar)
    else
      return (@display_enemy_bar = DefaultDisplayEnemyBar)
    end
  end
  attr_writer :display_enemy_bar
end
#==============================================================================
# ■ Game_Troop
#==============================================================================
class Game_Troop < Game_Unit
  attr_accessor :display_enemy_bar      # 是否显示敌人HP条、MP条、TP条
  #--------------------------------------------------------------------------
  # ● 设置
  #--------------------------------------------------------------------------
  alias hzhj_old_setup_for_display_enemy_bar_game_troop setup
  def setup(troop_id)
    hzhj_old_setup_for_display_enemy_bar_game_troop(troop_id)
    @display_enemy_bar = troop.display_enemy_bar
  end
end
#==============================================================================
# ■ Window_BattleEnemy
#==============================================================================
class Window_BattleEnemy < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 取得列数
  #--------------------------------------------------------------------------
  def col_max
    if $game_troop.display_enemy_bar
      return 1
    else
      return 2
    end
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    create_contents
    super
  end
  #--------------------------------------------------------------------------
  # ● 描画项目
  #--------------------------------------------------------------------------
  def draw_item(index)
    if $game_troop.display_enemy_bar
      enemy = $game_troop.alive_members[index]
      draw_basic_area(basic_area_rect(index), enemy)
      draw_gauge_area(gauge_area_rect(index), enemy)
    else
      change_color(normal_color)
      name = $game_troop.alive_members[index].name
      draw_text(item_rect_for_text(index), name)
    end
  end
  #--------------------------------------------------------------------------
  # ● 取得基本区域的矩形
  #--------------------------------------------------------------------------
  def basic_area_rect(index)
    rect = item_rect_for_text(index)
    rect.width -= gauge_area_width + 10
    rect
  end
  #--------------------------------------------------------------------------
  # ● 取得值槽区域的矩形
  #--------------------------------------------------------------------------
  def gauge_area_rect(index)
    rect = item_rect_for_text(index)
    rect.x += rect.width - gauge_area_width
    rect.width = gauge_area_width
    rect
  end
  #--------------------------------------------------------------------------
  # ● 取得值槽区域的宽度
  #--------------------------------------------------------------------------
  def gauge_area_width
    return 220
  end
  #--------------------------------------------------------------------------
  # ● 描画基本区域
  #--------------------------------------------------------------------------
  def draw_basic_area(rect, actor)
    draw_actor_name(actor, rect.x + 0, rect.y, 100)
    draw_actor_icons(actor, rect.x + 104, rect.y, rect.width - 104)
  end
  #--------------------------------------------------------------------------
  # ● 描画值槽区域
  #--------------------------------------------------------------------------
  def draw_gauge_area(rect, actor)
    if $data_system.opt_display_tp
      draw_gauge_area_with_tp(rect, actor)
    else
      draw_gauge_area_without_tp(rect, actor)
    end
  end
  #--------------------------------------------------------------------------
  # ● 描画值槽区域(包括 TP 值)
  #--------------------------------------------------------------------------
  def draw_gauge_area_with_tp(rect, actor)
    draw_actor_hp(actor, rect.x + 0, rect.y, 72)
    draw_actor_mp(actor, rect.x + 82, rect.y, 64)
    draw_actor_tp(actor, rect.x + 156, rect.y, 64)
  end
  #--------------------------------------------------------------------------
  # ● 描画值槽区域(不包括 TP 值)
  #--------------------------------------------------------------------------
  def draw_gauge_area_without_tp(rect, actor)
    draw_actor_hp(actor, rect.x + 0, rect.y, 134)
    draw_actor_mp(actor, rect.x + 144,  rect.y, 76)
  end
end

#==============================================================================
# ■ Sprite_Battler
#==============================================================================
class Sprite_Battler < Sprite_Base
  include Hzhj::HorizontalBattleSystem
  #--------------------------------------------------------------------------
  # ● 初始化(追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_init_for_dynamic_spr_battler initialize
  def initialize(viewport, battler = nil)
    hzhj_old_init_for_dynamic_spr_battler(viewport, battler)
    @dynamic_duration = 0
    @dynamic_duration_max = DynamicPatternMax * OnePatternDuration
  end
  #--------------------------------------------------------------------------
  # ● 源位图(Source Bitmap)的更新(重定义)
  #--------------------------------------------------------------------------
  def update_bitmap
    new_bitmap = Cache.battler(@battler.battler_name, @battler.battler_hue)
    if bitmap != new_bitmap
      self.bitmap = new_bitmap
      init_visibility
      @dynamic_duration = 0
      @sx = 0
      @sw = bitmap.width / DynamicPatternMax
      @sh = bitmap.height
      self.ox = @sw / 2
      self.oy = @sh
      src_rect.set(@sx, 0, @sw, @sh)
    end
  end
  #--------------------------------------------------------------------------
  # ● 原点的更新(重定义)
  #--------------------------------------------------------------------------
  def update_origin
    if bitmap
      @dynamic_duration += 1
      @dynamic_duration %= @dynamic_duration_max
      @sx = @dynamic_duration / OnePatternDuration * @sw
      src_rect.set(@sx, 0, @sw, @sh)
    end
  end
  #--------------------------------------------------------------------------
  # ● 返回普通设定(追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_revert_to_normal_for_dynamic_spr_battler revert_to_normal
  def revert_to_normal
    hzhj_old_revert_to_normal_for_dynamic_spr_battler
    self.ox = @sw / 2 if bitmap
  end
  #--------------------------------------------------------------------------
  # ● BOSS 战败(崩坏)效果的更新(追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_update_boss_col_for_dynamic_spr_battler update_boss_collapse
  def update_boss_collapse
    hzhj_old_update_boss_col_for_dynamic_spr_battler
    self.ox = @sw / 2 + @effect_duration % 2 * 4 - 2
  end
end

#==============================================================================
# ■ Game_Battler
#==============================================================================
class Game_Battler < Game_BattlerBase
  def set_normal_battler_name
    @battler_name = @battler_name.split(/★/)[0]
  end
  def set_beaten_battler_name
    if guard?
      if (UseActorGuardGraphic && actor?) or
         (UseEnemyGuardGraphic && enemy?)
        set_guard_battler_name
        return
      end
    end
    @battler_name = @battler_name.split(/★/)[0] + "★1"
    if UseActorWBSE && actor?
      Audio.se_play("Audio/SE/AWBSE_#{id}", 100, 100)
    elsif UseEnemyWBSE && enemy?
      Audio.se_play("Audio/SE/EWBSE_#{enemy_id}", 100, 100)
    end
  end
  def set_dead_battler_name
    @battler_name = @battler_name.split(/★/)[0] + "★2"
  end
  def set_guard_battler_name
    @battler_name = @battler_name.split(/★/)[0] + "★3"
    if UseActorGDSE && actor?
      Audio.se_play("Audio/SE/AGDSE_#{id}", 100, 100)
    elsif UseEnemyGDSE && enemy?
      Audio.se_play("Audio/SE/EGDSE_#{enemy_id}", 100, 100)
    end
  end
end
#==============================================================================
# ■ Sprite_Battler
#==============================================================================
class Sprite_Battler < Sprite_Base
  #--------------------------------------------------------------------------
  # ● 初始化(追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_init_for_dead_spr_battler initialize
  def initialize(viewport, battler = nil)
    hzhj_old_init_for_dead_spr_battler(viewport, battler)
    @dead_graphic_used = false
    if @battler
      @battler.set_normal_battler_name
      if @battler.dead?
        if (UseActorDeadGraphic && @battler.actor?) or
           (UseEnemyDeadGraphic && @battler.enemy?)
          @battler.set_dead_battler_name
          @dead_graphic_used = true
        end
      end
    end
    @beaten_duration = -1
  end
  #--------------------------------------------------------------------------
  # ● 设置战斗者(追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_set_battler_for_dead_spr_battler battler=
  def battler=(value)
    if @battler != value
      @dead_graphic_used = false
      if value
        value.set_normal_battler_name
        if value.dead?
          if (UseActorDeadGraphic && value.actor?) or
             (UseEnemyDeadGraphic && value.enemy?)
            value.set_dead_battler_name
            @dead_graphic_used = true
          end
        end
      end
      @beaten_duration = -1
    end
    hzhj_old_set_battler_for_dead_spr_battler(value)
  end
  #--------------------------------------------------------------------------
  # ● 源位图(Source Bitmap)的更新(重定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_update_bitmap_for_was_beaten_spr_battler update_bitmap
  def update_bitmap
    if @beaten_duration > 0
      @beaten_duration -= 1
    elsif @beaten_duration == 0
      @beaten_duration = -1
      set_bitmap(:normal)
    end
    hzhj_old_update_bitmap_for_was_beaten_spr_battler
  end
  #--------------------------------------------------------------------------
  # ● 初始化可视状态(追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_visibility_for_dead_spr_battler init_visibility
  def init_visibility
    hzhj_old_visibility_for_dead_spr_battler
    if @battler.dead?
      if (UseActorDeadGraphic && @battler.actor?) or
         (UseEnemyDeadGraphic && @battler.enemy?)
        self.opacity = 255
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 效果开始(追加定义)
  #--------------------------------------------------------------------------
  alias hzhj_old_start_effect_for_dead_spr_battler start_effect
  def start_effect(effect_type)
    if effect_type == :appear
      if @dead_graphic_used
        set_bitmap(:normal)
        @effect_type = nil
        @effect_duration = 0
        @dead_graphic_used = false
        @battler_visible = true
        return
      end
    elsif effect_type == :collapse or
          effect_type == :boss_collapse or
          effect_type == :instant_collapse
      if @beaten_duration >= 0
        @beaten_duration = -1
        set_bitmap(:normal)
      end
      if (UseActorDeadGraphic && @battler.actor?) or
         (UseEnemyDeadGraphic && @battler.enemy?)
        set_bitmap(:dead)
        @effect_type = nil
        @effect_duration = 0
        @dead_graphic_used = true
        @battler_visible = false
        return
      end
    end
    hzhj_old_start_effect_for_dead_spr_battler(effect_type)
  end
  #--------------------------------------------------------------------------
  # ● 设置新的位图(新增定义)
  #--------------------------------------------------------------------------
  def set_bitmap(sym)
    case sym
    when :normal
      @battler.set_normal_battler_name
    when :was_beaten
      @battler.set_beaten_battler_name
    when :dead
      @battler.set_dead_battler_name
    else
      return
    end
    new_bitmap = Cache.battler(@battler.battler_name, @battler.battler_hue)
    if bitmap != new_bitmap
      self.bitmap = new_bitmap
      @dynamic_duration = 0
      @sx = 0
      @sw = bitmap.width / DynamicPatternMax
      @sh = bitmap.height
      self.ox = @sw / 2
      self.oy = @sh
      src_rect.set(@sx, 0, @sw, @sh)
    end
    update_origin
    update_position
  end
end

#==============================================================================
# ■ Scene_Battle
#==============================================================================
class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # ● 发动技能/物品(新增定义)
  #--------------------------------------------------------------------------
  def hzhj_invoke_item(target, item, damage_target)
    refresh_status
    @log_window.display_action_results(damage_target, item)
    @subject.damage_section_displayed = false
    @subject.last_target_index = target.index
    return if target.dead?
    if rand < target.item_cnt(@subject, item)
      hzhj_invoke_counter_attack(target, item)
    elsif rand < target.item_mrf(@subject, item)
      hzhj_invoke_magic_reflection(target, item)
    end
  end
  #--------------------------------------------------------------------------
  # ● 发动物理反击(新增定义)
  #--------------------------------------------------------------------------
  def hzhj_invoke_counter_attack(target, item)
    @log_window.display_counter(target, item)
    attack_skill = $data_skills[target.attack_skill_id]
    @subject.item_apply(target, attack_skill)
    need_move = false
    animation1 = $data_animations[target.animation1_id]
    need_move = animation1.need_move if animation1
    ary = [@subject]
    if need_move
      target.setup_move_info(@subject, RealMoveDuration, animation1.move_se)
      wait_for_move
    end
    @subject.damage_section_displayed = false
    @subject.not_damage_section = false
    show_subject_animation(target.animation1_id, target)
    show_normal_animation(ary, target.atk_animation_id1, false)
    show_normal_animation(ary, target.atk_animation_id2, true)
    @log_window.wait
    wait_for_animation
    if need_move && target.alive?
      target.come_back_self_position(RealMoveDuration)
      wait_for_move
    end
    refresh_status
    @log_window.display_action_results(@subject, attack_skill)
  end
  #--------------------------------------------------------------------------
  # ● 发动魔法反射(新增定义)
  #--------------------------------------------------------------------------
  def hzhj_invoke_magic_reflection(target, item)
    @subject.damage_section_displayed = false
    @subject.not_damage_section = false
    @log_window.display_reflection(target, item)
    @subject.item_apply(@subject, item)
    refresh_status
    @log_window.display_action_results(@subject, item)
  end
end

#==============================================================================
# ■ Game_Battler
#==============================================================================
class Game_Battler < Game_BattlerBase
  attr_accessor :damage_section_displayed
  attr_accessor :not_damage_section
end
#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # ● 执行伤害效果
  #--------------------------------------------------------------------------
  alias hzhj_old_per_damage_for_damage_section_game_actor perform_damage_effect
  def perform_damage_effect
    unless damage_section_displayed
      hzhj_old_per_damage_for_damage_section_game_actor
    end
  end
end
#==============================================================================
# ■ Game_Enemy
#==============================================================================
class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # ● 执行伤害效果
  #--------------------------------------------------------------------------
  alias hzhj_old_per_damage_for_damage_section_game_enemy perform_damage_effect
  def perform_damage_effect
    unless damage_section_displayed
      hzhj_old_per_damage_for_damage_section_game_enemy
    end
  end
end
#==============================================================================
# ■ Sprite_Battler
#==============================================================================
class Sprite_Battler < Sprite_Base
  #--------------------------------------------------------------------------
  # ● SE 和闪烁时机的处理
  #--------------------------------------------------------------------------
  def animation_process_timing(timing)
    if timing.se.name == DamageSectionDisplaySEName
      hp_value = @battler.result.hp_damage
      mp_value = @battler.result.mp_damage
      tp_value = @battler.result.tp_damage
      value = args = nil
      was_beaten = false
      if hp_value != 0 && [email protected]_damage_section
        was_beaten = true if hp_value > 0
        value = hp_value * timing.flash_color.red.to_i / 100
        critical = @battler.result.critical
        args = [:hp, value, critical]
      elsif mp_value != 0 && [email protected]_damage_section
        was_beaten = true if mp_value > 0
        value = mp_value * timing.flash_color.red.to_i / 100
        critical = @battler.result.critical
        args = [:mp, value, critical]
      elsif tp_value != 0 && [email protected]_damage_section
        was_beaten = true if tp_value > 0
        value = tp_value * timing.flash_color.red.to_i / 100
        critical = @battler.result.critical
        args = [:tp, value, critical]
      end
      if value && args
        args[3] = @battler.actor? ? :actor : (@battler.enemy? ? :enemy : nil)
        @battler.damage_section_displayed = true
        start_damage(args)
        if UseBeatenGraphic && was_beaten
          set_bitmap(:was_beaten)
          @beaten_duration = BeatenGraphicDuration
        end
      end
      return
    end
    super(timing)
  end
end
#==============================================================================
# ■ Scene_Battle
#==============================================================================
class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # ● 应用技能/物品效果(新增定义)
  #--------------------------------------------------------------------------
  def hzhj_apply_item_effects(target, item)
    target.damage_section_displayed = false
    target.not_damage_section = false
    target = apply_substitute(target, item)
    target.damage_section_displayed = false
    target.not_damage_section = false
    target.item_apply(@subject, item)
    return target
  end
end
#==============================================================================
# ■ 此脚本来自 www.66rpg.com
#==============================================================================
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-11-16 15:00

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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