查看: 1962|回复: 6

[已经解决] 使用后知后觉的1.7横版战斗系统遇到的bug,求教

[复制链接]
梦石
0
星屑
50
在线时间
40 小时
注册时间
2011-7-23
回帖
46
发表于 2017-1-3 21:50:20 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 RaidenInfinity 于 2017-1-3 22:47 编辑

本人使用后知后觉的1.7横版战斗系统做一个游戏,其中代码

  1. module Hzhj
  2. module HorizontalBattleSystem
  3. # 取得参战角色的最大数.如果要改大.需要在下面的坐标设置里增加对应的条目
  4. MaxBattleMembers = 8

  5. ActorsBattlePosition = {}
  6. # 设置角色战斗图形的坐标
  7. # 等号左边的[]号里面的1 2 3 4 表示角色在队伍里的位置
  8. # 等号右边的[]号里面的两个数字分别表示 X坐标 Y坐标
  9. # 每次进入战斗的时候都会以这里设置的信息作为初始化位置.
  10. # 如果你把上面的 MaxBattleMembers 改大了.比如改成了 5.
  11. # 那么你需要在下面新增一行代码设置队伍中第5位置的坐标.
  12. # 就像这样 ActorsBattlePosition[5] = [X坐标, Y坐标]
  13. 但是存在bug,即使将MaxBattleMembers值改为8,5-8号队员会参加战斗,但无任何图形显示
复制代码

点评

用一下代碼框!  发表于 2017-1-3 22:35
梦石
0
星屑
50
在线时间
40 小时
注册时间
2011-7-23
回帖
46
 楼主| 发表于 2017-1-3 21:51:29 | 显示全部楼层
本帖最后由 RaidenInfinity 于 2017-1-3 22:44 编辑

  1. module Hzhj
  2.   module HorizontalBattleSystem
  3.     # 取得参战角色的最大数.如果要改大.需要在下面的坐标设置里增加对应的条目
  4.     #(存在bug,即使将MaxBattleMembers值改为8,5-8号队员会参加战斗,但无任何图形显示)
  5.      MaxBattleMembers = 8
  6.    
  7.     ActorsBattlePosition = {}
  8.     # 设置角色战斗图形的坐标
  9.     # 等号左边的[]号里面的1 2 3 4 表示角色在队伍里的位置
  10.     # 等号右边的[]号里面的两个数字分别表示 X坐标 Y坐标
  11.     # 每次进入战斗的时候都会以这里设置的信息作为初始化位置.
  12.     # 如果你把上面的 MaxBattleMembers 改大了.比如改成了 5.
  13.     # 那么你需要在下面新增一行代码设置队伍中第5位置的坐标.
  14.     # 就像这样 ActorsBattlePosition[5] = [X坐标, Y坐标]
  15.     ActorsBattlePosition[1] = [600, 400]
  16.     ActorsBattlePosition[2] = [600, 300]
  17.     ActorsBattlePosition[3] = [500, 400]
  18.         ActorsBattlePosition[4] = [500, 300]
  19.     ActorsBattlePosition[5] = [300, 200]
  20.     ActorsBattlePosition[6] = [550, 300]
  21.     ActorsBattlePosition[7] = [400, 400]
  22.     ActorsBattlePosition[8] = [400, 300]
复制代码
  
我改了以上代码,然后游戏测试正常,只是5-8号角色无法显示动画及本身!!!像隐形人,能够殴打敌人,,,但是看不见!什么鬼。。求教指点
回复

使用道具 举报

梦石
0
星屑
50
在线时间
40 小时
注册时间
2011-7-23
回帖
46
 楼主| 发表于 2017-1-3 21:51:53 | 显示全部楼层
本帖最后由 RaidenInfinity 于 2017-1-3 22:45 编辑

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

  16. module Hzhj
  17.   module HorizontalBattleSystem
  18.     # 取得参战角色的最大数.如果要改大.需要在下面的坐标设置里增加对应的条目
  19.     #(存在bug,即使将MaxBattleMembers值改为8,5-8号队员会参加战斗,但无任何图形显示)
  20.      MaxBattleMembers = 8
  21.    
  22.     ActorsBattlePosition = {}
  23.     # 设置角色战斗图形的坐标
  24.     # 等号左边的[]号里面的1 2 3 4 表示角色在队伍里的位置
  25.     # 等号右边的[]号里面的两个数字分别表示 X坐标 Y坐标
  26.     # 每次进入战斗的时候都会以这里设置的信息作为初始化位置.
  27.     # 如果你把上面的 MaxBattleMembers 改大了.比如改成了 5.
  28.     # 那么你需要在下面新增一行代码设置队伍中第5位置的坐标.
  29.     # 就像这样 ActorsBattlePosition[5] = [X坐标, Y坐标]
  30.     ActorsBattlePosition[1] = [600, 400]
  31.     ActorsBattlePosition[2] = [600, 300]
  32.     ActorsBattlePosition[3] = [500, 400]
  33.         ActorsBattlePosition[4] = [500, 300]
  34.     ActorsBattlePosition[5] = [300, 200]
  35.     ActorsBattlePosition[6] = [550, 300]
  36.     ActorsBattlePosition[7] = [400, 400]
  37.     ActorsBattlePosition[8] = [400, 300]
  38.    

  39.    
  40.     # 设置伤害值图形的色相 取值范围 0~360
  41.     DamageBitmapHue = 0
  42.     # 伤害值分段显示的标志SE文件名
  43.     DamageSectionDisplaySEName = "DamageSection"
  44.    
  45.     # 动画 Z 坐标值默认变化量
  46.     DefaultAniAddZ = 768
  47.    
  48.     # 状态动画 Z 坐标值默认变化量
  49.     DefaultLoopAniAddZ = 20
  50.    
  51.     # 战斗中角色的面向
  52.     ActorDirection = 4
  53.    
  54.     # 真位移的帧数
  55.     RealMoveDuration = 20
  56.     # 真位移移动前会计算目标点.会获取攻防双方战斗图大小来进行计算.
  57.     # 下面2个是对战斗图 width height 进行修正.
  58.     # 为正则扩大 为负则缩小.单位 像素.
  59.     # 一般来说不必修改.只有像梦幻群侠传那种战斗图四边有很多透明区域时才修正.
  60.     RealMoveBmpAddW = 0
  61.     RealMoveBmpAddH = 0
  62.    
  63.     # 使用技能、物品的过程默认使用RMVA模式
  64.     # 在该模式下.本脚本提供的很多功能受限无法使用.
  65.     DefaultUseRmvaMode = false
  66.    
  67.     # 默认显示敌人的HP条、MP条、TP条
  68.     DefaultDisplayEnemyBar = true
  69.    
  70.     # 一张战斗图中有几个样式(帧、格)
  71.     DynamicPatternMax = 4
  72.     # 一张战斗图中的一个样式持续多少帧
  73.     OnePatternDuration = 15
  74.    
  75.     # 角色使用战斗死亡图形
  76.     UseActorDeadGraphic = true
  77.     # 敌人使用战斗死亡图形
  78.     UseEnemyDeadGraphic = true
  79.    
  80.     # 使用挨打图形
  81.     UseBeatenGraphic = true
  82.     # 挨打图形维持帧数
  83.     BeatenGraphicDuration = 30
  84.    
  85.     # 是否使用角色防御图 只有同时使用了挨打图.此项才有效.
  86.     UseActorGuardGraphic = true
  87.     # 是否使用敌人防御图 只有同时使用了挨打图.此项才有效.
  88.     UseEnemyGuardGraphic = false
  89.    
  90.     # 角色是否使用挨打SE
  91.     UseActorWBSE = true
  92.     # 敌人是否使用挨打SE
  93.     UseEnemyWBSE = true
  94.     # 角色是否使用防御SE
  95.     UseActorGDSE = true
  96.     # 敌人是否使用防御SE
  97.     UseEnemyGDSE = false
  98.   end
  99. end

  100. class RPG::Actor < RPG::BaseItem
  101.   def battler_name
  102.     return @battler_name unless @battler_name.nil?
  103.     if /@btname\[(.+?)\]/ =~ @note
  104.       return (@battler_name = $1.clone)
  105.     else
  106.       return (@battler_name = "#{@name}_#{@nickname}")
  107.     end
  108.   end
  109.   def battler_hue
  110.     return @battler_hue unless @battler_hue.nil?
  111.     if /@bthue\[([0-9]+?)\]/ =~ @note
  112.       return (@battler_hue = $1.to_i.abs)
  113.     else
  114.       return (@battler_hue = 0)
  115.     end
  116.   end
  117.   attr_writer :battler_name
  118.   attr_writer :battler_hue
  119. end
  120. #==============================================================================
  121. # ■ Game_Actor
  122. #==============================================================================
  123. class Game_Actor < Game_Battler
  124.   #--------------------------------------------------------------------------
  125.   # ● 属性(新增定义)
  126.   #--------------------------------------------------------------------------
  127.   attr_writer   :battler_name             # 战斗图形文件名
  128.   attr_writer   :battler_hue              # 战斗图形色相
  129.   #--------------------------------------------------------------------------
  130.   # ● 设置(追加定义)
  131.   #--------------------------------------------------------------------------
  132.   alias hzhj_old_setup_for_add_actor_battle_graphic setup
  133.   def setup(actor_id)
  134.     hzhj_old_setup_for_add_actor_battle_graphic(actor_id)
  135.     @battler_name = actor.battler_name
  136.     @battler_hue = actor.battler_hue
  137.   end
  138.   #--------------------------------------------------------------------------
  139.   # ● 是否使用活动块(重定义)
  140.   #--------------------------------------------------------------------------
  141.   def use_sprite?
  142.     return true
  143.   end
  144.   #--------------------------------------------------------------------------
  145.   # ● 取得战斗画面 X 坐标(新增定义)
  146.   #--------------------------------------------------------------------------
  147.   def screen_x
  148.     return ActorsBattlePosition[index + 1][0]
  149.   end
  150.   #--------------------------------------------------------------------------
  151.   # ● 取得战斗画面 Y 坐标(新增定义)
  152.   #--------------------------------------------------------------------------
  153.   def screen_y
  154.     return ActorsBattlePosition[index + 1][1]
  155.   end
  156.   #--------------------------------------------------------------------------
  157.   # ● 取得战斗画面 Z 坐标(新增定义)
  158.   #--------------------------------------------------------------------------
  159.   def screen_z
  160.     return real_screen_y + 100
  161.   end
  162. end
  163. #==============================================================================
  164. # ■ Game_Enemy
  165. #==============================================================================
  166. class Game_Enemy < Game_Battler
  167.   #--------------------------------------------------------------------------
  168.   # ● 属性(新增定义)
  169.   #--------------------------------------------------------------------------
  170.   attr_writer   :battler_name             # 战斗图形文件名
  171.   attr_writer   :battler_hue              # 战斗图形色相
  172.   #--------------------------------------------------------------------------
  173.   # ● 取得战斗画面 Z 坐标(重定义)
  174.   #--------------------------------------------------------------------------
  175.   def screen_z
  176.     return real_screen_y + 100
  177.   end
  178. end
  179. #==============================================================================
  180. # ■ Game_Party
  181. #==============================================================================
  182. class Game_Party < Game_Unit
  183.   include Hzhj::HorizontalBattleSystem
  184.   #--------------------------------------------------------------------------
  185.   # ● 取得参战角色的最大数(重定义),貌似存在bug,可以8人上场,但并不被显示

  186.   #--------------------------------------------------------------------------
  187.   def max_battle_members
  188.    return MaxBattleMembers
  189.   end
  190. end

  191. class RPG::Animation
  192.   def wait_subject_duration
  193.     return @wait_subject_duration unless @wait_subject_duration.nil?
  194.     if /@w\[(\-??\d+?)\]/ =~ @name
  195.       @wait_subject_duration = $1.to_i
  196.     else
  197.       @wait_subject_duration = 0
  198.     end
  199.     return @wait_subject_duration
  200.   end
  201.   attr_writer :wait_subject_duration
  202. end
  203. class RPG::UsableItem < RPG::BaseItem
  204.   include Hzhj::HorizontalBattleSystem
  205.   def animation1_id
  206.     return @animation1_id unless @animation1_id.nil?
  207.     if /@a1id\[(\d+?)\]/i =~ @note
  208.       return (@animation1_id = $1.to_i)
  209.     else
  210.       return (@animation1_id = 0)
  211.     end
  212.   end
  213.   def wljn
  214.     return @wljn unless @wljn.nil?
  215.     if /@wljn/i =~ @note
  216.       return (@wljn = true)
  217.     else
  218.       return (@wljn = false)
  219.   end
  220.   end
  221.   def rmva_mode
  222.     return @rmva_mode unless @rmva_mode.nil?
  223.     if /@rmva/i =~ @note
  224.       return (@rmva_mode = !DefaultUseRmvaMode)
  225.     else
  226.       return (@rmva_mode = DefaultUseRmvaMode)
  227.     end
  228.   end
  229.   attr_writer :animation1_id
  230.   attr_writer :wljn
  231.   attr_writer :rmva_mode
  232. end
  233. class RPG::Weapon < RPG::EquipItem
  234.   def animation1_id
  235.    return @animation1_id unless @animation1_id.nil?
  236.     if /@a1id\[(\d+?)\]/ =~ @note
  237.       return (@animation1_id = $1.to_i)
  238.    else
  239.       return (@animation1_id = 0)
  240.     end
  241.   end
  242.   attr_writer :animation1_id
  243. end
  244. class RPG::Enemy < RPG::BaseItem
  245.   def animation1_id
  246.     return @animation1_id unless @animation1_id.nil?
  247.     if /@a1id\[(\d+?)\]/ =~ @note
  248.       return (@animation1_id = $1.to_i)
  249.     else
  250.       return (@animation1_id = 0)
  251.    end
  252.   end
  253.   def animation2_id
  254.     return @animation2_id unless @animation2_id.nil?
  255.     if /@a2id\[(\d+?)\]/ =~ @note
  256.       return (@animation2_id = $1.to_i)
  257.     else
  258.       return (@animation2_id = 0)
  259.     end
  260.   end
  261.   def animation3_id  
  262.     return @animation3_id unless @animation3_id.nil?
  263.     if /@a3id\[(\d+?)\]/ =~ @note
  264.       return (@animation3_id = $1.to_i)
  265.     else
  266.       return (@animation3_id = 0)
  267.     end
  268.   end
  269.   attr_writer :animation1_id
  270.   attr_writer :animation2_id
  271.   attr_writer :animation3_id
  272. end
  273. #==============================================================================
  274. # ■ Game_Actor
  275. #==============================================================================
  276. class Game_Actor < Game_Battler
  277.   #--------------------------------------------------------------------------
  278.   # ● 取得普通攻击的行动方动画 ID (新增定义)
  279.   #--------------------------------------------------------------------------
  280.   def animation1_id
  281.     if dual_wield?
  282.       return weapons[0].animation1_id if weapons[0]
  283.       return weapons[1] ? weapons[1].animation1_id : 0
  284.     else
  285.       return weapons[0] ? weapons[0].animation1_id : 0
  286.     end
  287.   end
  288. end
  289. #==============================================================================
  290. # ■ Game_Enemy
  291. #==============================================================================
  292. class Game_Enemy < Game_Battler
  293.   #--------------------------------------------------------------------------
  294.   # ● 取得普通攻击的行动方动画 ID (新增定义)
  295.   #--------------------------------------------------------------------------
  296.   def animation1_id
  297.     return enemy.animation1_id
  298.   end
  299.   #--------------------------------------------------------------------------
  300.   # ● 取得普通攻击的动画 ID (新增定义)
  301.   #--------------------------------------------------------------------------
  302.   def atk_animation_id1
  303.     return enemy.animation2_id
  304.   end
  305.   #--------------------------------------------------------------------------
  306.   # ● 取得普通攻击的动画 ID (二刀流:武器2)(新增定义)
  307.   #--------------------------------------------------------------------------
  308.   def atk_animation_id2
  309.     return enemy.animation3_id
  310.   end
  311. end
  312. #==============================================================================
  313. # ■ Scene_Battle
  314. #==============================================================================
  315. class Scene_Battle < Scene_Base
  316.   include Hzhj::HorizontalBattleSystem
  317.   #--------------------------------------------------------------------------
  318.   # ● 使用技能/物品(重定义)
  319.   #--------------------------------------------------------------------------
  320.   def use_item
  321.     item = @subject.current_action.item
  322.     @log_window.display_use_item(@subject, item)
  323.     @subject.use_item(item)
  324.     refresh_status
  325.     targets = @subject.current_action.make_targets.compact
  326.     show_animation(targets, item.animation_id)
  327.   end
  328.   #--------------------------------------------------------------------------
  329.   # ● 显示动画(重定义)
  330.   #--------------------------------------------------------------------------
  331.   def show_animation(targets, animation_id)
  332.     item = @subject.current_action.item
  333.     if item.rmva_mode
  334.       show_rmva_animation(targets, animation_id, item)
  335.     else
  336.       show_hzhj_animation(targets, animation_id, item)
  337.     end
  338.   end
  339.   #--------------------------------------------------------------------------
  340.   # ● RMVA模式显示动画(新增定义)
  341.   #--------------------------------------------------------------------------
  342.   def show_rmva_animation(targets, animation_id, item)
  343.     @subject.damage_section_displayed = false
  344.     @subject.not_damage_section = true
  345.     targets.each do |target|
  346.       target.damage_section_displayed = false
  347.       target.not_damage_section = true
  348.     end
  349.     if animation_id < 0
  350.       show_attack_animation(targets)
  351.     else
  352.       show_rmva_usable_animation(targets, animation_id, item)
  353.     end
  354.   end
  355.   #--------------------------------------------------------------------------
  356.   # ● HZHJ模式显示动画(新增定义)
  357.   #--------------------------------------------------------------------------
  358.   def show_hzhj_animation(targets, animation_id, item)
  359.     if animation_id < 0
  360.       show_hzhj_attack_animation(targets, item)
  361.     else
  362.       if item.wljn
  363.         show_wljn_skill_animation(targets, animation_id, item)
  364.       else
  365.         show_magic_skill_animation(targets, animation_id, item)
  366.       end
  367.     end
  368.   end
  369.   #--------------------------------------------------------------------------
  370.   # ● HZHJ模式显示攻击动画(重定义)
  371.   #--------------------------------------------------------------------------
  372.   def show_hzhj_attack_animation(targets, item)
  373.     ary = []
  374.     need_move = false
  375.     animation1 = $data_animations[@subject.animation1_id]
  376.     need_move = animation1.need_move if animation1
  377.     come_back = true
  378.     targets.each_with_index do |target, i|
  379.       ary[0] = target
  380.       item.repeats.times do
  381.         next if target.dead? && item.damage.type == 1
  382.         next if @subject.dead?
  383.         next if !@subject.current_action
  384.         if need_move && come_back
  385.           come_back = false
  386.           @subject.setup_move_info(target, RealMoveDuration, animation1.move_se)
  387.           wait_for_move
  388.         end
  389.         damage_target = hzhj_apply_item_effects(target, item)
  390.         show_subject_animation(@subject.animation1_id)
  391.         show_normal_animation(ary, @subject.atk_animation_id1, false)
  392.         show_normal_animation(ary, @subject.atk_animation_id2, true)
  393.         @log_window.wait
  394.         wait_for_animation
  395.         hzhj_invoke_item(target, item, damage_target)
  396.       end
  397.       if need_move
  398.         if target != targets[i+1] or target.dead?
  399.           come_back = true
  400.           @subject.come_back_self_position(RealMoveDuration)
  401.           wait_for_move
  402.         else
  403.           come_back = false
  404.         end
  405.       end
  406.     end
  407.   end
  408.   #--------------------------------------------------------------------------
  409.   # ● HZHJ模式显示物理技能类动画(新增定义)
  410.   #--------------------------------------------------------------------------
  411.   def show_wljn_skill_animation(targets, animation_id, item)
  412.     ary = []
  413.     need_move = false
  414.     animation1 = $data_animations[item.animation1_id]
  415.     need_move = animation1.need_move if animation1
  416.     come_back = true
  417.     targets.each_with_index do |target, i|
  418.       ary[0] = target
  419.       item.repeats.times do
  420.         next if target.dead? && item.damage.type == 1
  421.         next if @subject.dead?
  422.         next if !@subject.current_action
  423.         if need_move && come_back
  424.           come_back = false
  425.           @subject.setup_move_info(target, RealMoveDuration, animation1.move_se)
  426.           wait_for_move
  427.         end
  428.         damage_target = hzhj_apply_item_effects(target, item)
  429.         show_subject_animation(item.animation1_id)
  430.         show_normal_animation(ary, animation_id, false)
  431.         @log_window.wait
  432.         wait_for_animation
  433.         hzhj_invoke_item(target, item, damage_target)
  434.       end
  435.       if need_move
  436.         if target != targets[i+1] or target.dead?
  437.           come_back = true
  438.           @subject.come_back_self_position(RealMoveDuration)
  439.           wait_for_move
  440.         else
  441.           come_back = false
  442.         end
  443.       end
  444.     end
  445.   end
  446.   #--------------------------------------------------------------------------
  447.   # ● HZHJ模式显示魔法技能类动画(新增定义)
  448.   #--------------------------------------------------------------------------
  449.   def show_magic_skill_animation(targets, animation_id, item)
  450.     ary = []
  451.     damage_targets = {}
  452.     item.repeats.times do
  453.       next if @subject.dead?
  454.       next if !@subject.current_action
  455.       ary.clear
  456.       damage_targets.clear
  457.       targets.each do |target|
  458.         next if target.dead? && item.damage.type == 1
  459.         ary << target
  460.         damage_targets[target] = hzhj_apply_item_effects(target, item)
  461.       end
  462.       next if ary.empty?
  463.       show_subject_animation(item.animation1_id)
  464.       show_normal_animation(ary, animation_id)
  465.       @log_window.wait
  466.       wait_for_animation
  467.       ary.each do |target|
  468.         hzhj_invoke_item(target, item, damage_targets[target])
  469.       end
  470.       if [9, 10].include?(item.scope)
  471.         ary.each do |target|
  472.           if target.alive?
  473.             target.come_back_self_position(RealMoveDuration)
  474.           end
  475.         end
  476.         wait_for_move
  477.       end
  478.     end
  479.   end
  480.   #--------------------------------------------------------------------------
  481.   # ● RMVA模式显示攻击动画(重定义)
  482.   #--------------------------------------------------------------------------
  483.   def show_attack_animation(targets)
  484.     item = @subject.current_action.item
  485.     show_subject_animation(@subject.animation1_id)
  486.     show_normal_animation(targets, @subject.atk_animation_id1, false)
  487.     show_normal_animation(targets, @subject.atk_animation_id2, true)
  488.     @log_window.wait
  489.     wait_for_animation
  490.     targets.each {|target| item.repeats.times { invoke_item(target, item) } }
  491.   end
  492.   #--------------------------------------------------------------------------
  493.   # ● RMVA模式显示技能、物品动画 (新增定义)
  494.   #--------------------------------------------------------------------------
  495.   def show_rmva_usable_animation(targets, animation_id, item)
  496.     show_subject_animation(item.animation1_id)
  497.     show_normal_animation(targets, animation_id)
  498.     @log_window.wait
  499.     wait_for_animation
  500.     targets.each {|target| item.repeats.times { invoke_item(target, item) } }
  501.     if [9, 10].include?(item.scope)
  502.       targets.each do |target|
  503.         if target.alive?
  504.           target.come_back_self_position(RealMoveDuration)
  505.         end
  506.       end
  507.       wait_for_move
  508.     end
  509.   end
  510.   #--------------------------------------------------------------------------
  511.   # ● 显示行动方动画(新增定义)
  512.   #--------------------------------------------------------------------------
  513.   def show_subject_animation(animation_id, subject = @subject, mirror = false)
  514.     animation = $data_animations[animation_id]
  515.     if animation
  516.       subject.animation_id = animation_id
  517.       subject.animation_mirror = mirror
  518.       if animation.wait_subject_duration < 0
  519.         wait_for_animation
  520.       elsif animation.wait_subject_duration > 0
  521.         animation.wait_subject_duration.times{update_for_wait}
  522.       end
  523.     end
  524.   end
  525. end

  526. class RPG::Animation
  527.   include Hzhj::HorizontalBattleSystem
  528.   def ani_z_correction
  529.     return @ani_z_correction unless @ani_z_correction.nil?
  530.     if /@az\[(\-??\d+?)\]/ =~ @name
  531.       return (@ani_z_correction = $1.to_i)
  532.     else
  533.       return (@ani_z_correction = DefaultAniAddZ)
  534.     end
  535.   end
  536.   def loop_z_correction
  537.     return @loop_z_correction unless @loop_z_correction.nil?
  538.     if /@lz\[(\-??\d+?)\]/ =~ @name
  539.       return (@loop_z_correction = $1.to_i)
  540.     else
  541.       return (@loop_z_correction = DefaultLoopAniAddZ)
  542.     end
  543.   end
  544.   attr_writer :ani_z_correction
  545.   attr_writer :loop_z_correction
  546. end
  547. class RPG::State < RPG::BaseItem
  548.   def animation_id
  549.     return @animation_id unless @animation_id.nil?
  550.     if /@aid\[(\d+?)\]/ =~ @note
  551.       return (@animation_id = $1.to_i)
  552.     else
  553.       return (@animation_id = 0)
  554.     end
  555.   end
  556.   attr_writer :animation_id
  557. end
  558. #==============================================================================
  559. # ■ Game_BattlerBase
  560. #==============================================================================
  561. class Game_BattlerBase
  562.   #--------------------------------------------------------------------------
  563.   # ● 实例变量(新增定义)
  564.   #--------------------------------------------------------------------------
  565.   attr_reader   :hzhj_add_state_id
  566.   attr_reader   :hzhj_remove_state_id
  567.   attr_accessor :need_update_state_animation
  568.   #--------------------------------------------------------------------------
  569.   # ● 初始化(追加定义)
  570.   #--------------------------------------------------------------------------
  571.   alias hzhj_old_init_for_state_ani_game_battler_base initialize
  572.   def initialize
  573.     @hzhj_add_state_id = []
  574.     @hzhj_remove_state_id = []
  575.     @need_update_state_animation = false
  576.     @states = []
  577.     @state_turns = {}
  578.     @state_steps = {}
  579.     hzhj_old_init_for_state_ani_game_battler_base
  580.   end
  581.   #--------------------------------------------------------------------------
  582.   # ● 清除状态信息(追加定义)
  583.   #--------------------------------------------------------------------------
  584.   alias hzhj_old_clear_states_for_state_ani_game_battler_base clear_states
  585.   def clear_states
  586.     old_states = @states.clone
  587.     hzhj_old_clear_states_for_state_ani_game_battler_base
  588.     bingji = old_states | @states
  589.     return if bingji.empty?
  590.     set_add_state_id(bingji & @states)
  591.     set_remove_state_id(bingji & old_states)
  592.   end
  593.   #--------------------------------------------------------------------------
  594.   # ● 消除状态(追加定义)
  595.   #--------------------------------------------------------------------------
  596.   alias hzhj_old_erase_state_for_state_ani_game_battler_base erase_state
  597.   def erase_state(state_id)
  598.     old_states = @states.clone
  599.     hzhj_old_erase_state_for_state_ani_game_battler_base(state_id)
  600.     bingji = old_states | @states
  601.     return if bingji.empty?
  602.     set_add_state_id(bingji & @states)
  603.     set_remove_state_id(bingji & old_states)
  604.   end
  605.   #--------------------------------------------------------------------------
  606.   # ● 设置增加的状态(新增定义)
  607.   #--------------------------------------------------------------------------
  608.   def set_add_state_id(zjdzt)
  609.     for i in zjdzt
  610.       if $data_states[i].animation_id > 0
  611.         if not @hzhj_add_state_id.include?(i)
  612.           @hzhj_add_state_id.push(i)
  613.         end
  614.       end
  615.     end
  616.   end
  617.   #--------------------------------------------------------------------------
  618.   # ● 设置解除的状态(新增定义)
  619.   #--------------------------------------------------------------------------
  620.   def set_remove_state_id(jsdzt)
  621.     for i in jsdzt
  622.       if $data_states[i].animation_id > 0
  623.         if not @hzhj_remove_state_id.include?(i)
  624.           ani_id = $data_states[i].animation_id
  625.           not_end_loop_animation = false
  626.           for state in self.states
  627.             if state.animation_id == ani_id
  628.               not_end_loop_animation = true
  629.               break
  630.             end
  631.           end
  632.           unless not_end_loop_animation
  633.             @hzhj_remove_state_id.push(i)
  634.           end
  635.         end
  636.       end
  637.     end
  638.   end
  639. end
  640. #==============================================================================
  641. # ■ Game_Battler
  642. #==============================================================================
  643. class Game_Battler < Game_BattlerBase
  644.   #--------------------------------------------------------------------------
  645.   # ● 附加新的状态(追加定义)
  646.   #--------------------------------------------------------------------------
  647.   alias hzhj_old_add_new_state_for_state_ani_game_battler add_new_state
  648.   def add_new_state(state_id)
  649.     old_states = @states.clone
  650.     hzhj_old_add_new_state_for_state_ani_game_battler(state_id)
  651.     bingji = old_states | @states
  652.     return if bingji.empty?
  653.     set_add_state_id(bingji & @states)
  654.     set_remove_state_id(bingji & old_states)
  655.   end
  656. end
  657. #==============================================================================
  658. # ■ Sprite_Base
  659. #==============================================================================
  660. class Sprite_Base < Sprite
  661.   #--------------------------------------------------------------------------
  662.   # ● 初始化(追加定义)
  663.   #--------------------------------------------------------------------------
  664.   alias hzhj_old_init_for_state_ani_spr_base initialize
  665.   def initialize(*args)
  666.     hzhj_old_init_for_state_ani_spr_base(*args)
  667.     @hzhj_loop_animations = []
  668.     @hzhj_loop_durations = {}
  669.     @hzhj_loop_sprites = {}
  670.     @hzhj_loop_bitmap1s = {}
  671.     @hzhj_loop_bitmap2s = {}
  672.     @hzhj_loop_ani_oxs = {}
  673.     @hzhj_loop_ani_oys = {}
  674.     @flash_nil_duration = 0
  675.   end
  676.   #--------------------------------------------------------------------------
  677.   # ● 释放(追加定义)
  678.   #--------------------------------------------------------------------------
  679.   alias hzhj_old_dispose_for_state_ani_spr_base dispose
  680.   def dispose
  681.     dispose_loop_animation
  682.     hzhj_old_dispose_for_state_ani_spr_base
  683.   end
  684.   #--------------------------------------------------------------------------
  685.   # ● 设定动画的活动块(追加定义)
  686.   #--------------------------------------------------------------------------
  687.   alias hzhj_old_ani_set_spr_for_state_ani_spr_base animation_set_sprites
  688.   def animation_set_sprites(*args)
  689.     hzhj_old_ani_set_spr_for_state_ani_spr_base(*args)
  690.     @ani_sprites.each{|sprite|sprite.z += @animation.ani_z_correction}
  691.   end
  692.   #--------------------------------------------------------------------------
  693.   # ● 判断是否有循环动画(新增定义)
  694.   #--------------------------------------------------------------------------
  695.   def loop_animation?
  696.     return (not @hzhj_loop_animations.empty?)
  697.   end
  698.   #--------------------------------------------------------------------------
  699.   # ● 开始播放循环动画(新增定义)
  700.   #--------------------------------------------------------------------------
  701.   def start_loop_animation(animation)
  702.     return if @hzhj_loop_animations.include?(animation)
  703.     if animation.nil?
  704.       dispose_loop_animation
  705.       return
  706.     end
  707.     set_animation_rate
  708.     @hzhj_loop_animations.push(animation)
  709.     init_loop_animation_duration(animation)
  710.     load_loop_animation_bitmap(animation)
  711.     make_loop_animation_sprites(animation)
  712.     set_loop_animation_origin(animation)
  713.   end
  714.   #--------------------------------------------------------------------------
  715.   # ● 初始化循环动画播放位置(新增定义)
  716.   #--------------------------------------------------------------------------
  717.   def init_loop_animation_duration(animation)
  718.     @hzhj_loop_durations[animation] = animation.frame_max * @ani_rate + 1
  719.   end
  720.   #--------------------------------------------------------------------------
  721.   # ● 读取循环动画图像(新增定义)
  722.   #--------------------------------------------------------------------------
  723.   def load_loop_animation_bitmap(animation)
  724.     animation1_name = animation.animation1_name
  725.     animation1_hue = animation.animation1_hue
  726.     animation2_name = animation.animation2_name
  727.     animation2_hue = animation.animation2_hue
  728.     bitmap1 = Cache.animation(animation1_name, animation1_hue)
  729.     bitmap2 = Cache.animation(animation2_name, animation2_hue)
  730.     if @@_reference_count.include?(bitmap1)
  731.       @@_reference_count[bitmap1] += 1
  732.     else
  733.       @@_reference_count[bitmap1] = 1
  734.     end
  735.     if @@_reference_count.include?(bitmap2)
  736.       @@_reference_count[bitmap2] += 1
  737.     else
  738.       @@_reference_count[bitmap2] = 1
  739.     end
  740.     @hzhj_loop_bitmap1s[animation] = bitmap1
  741.     @hzhj_loop_bitmap2s[animation] = bitmap2
  742.     Graphics.frame_reset
  743.   end
  744.   #--------------------------------------------------------------------------
  745.   # ● 生成循环动画活动块(新增定义)
  746.   #--------------------------------------------------------------------------
  747.   def make_loop_animation_sprites(animation)
  748.     sprites = []
  749.     if @use_sprite
  750.       16.times do
  751.         sprite = ::Sprite.new(viewport)
  752.         sprite.visible = false
  753.         sprites.push(sprite)
  754.       end
  755.     end
  756.     @hzhj_loop_sprites[animation] = sprites
  757.   end
  758.   #--------------------------------------------------------------------------
  759.   # ● 设定循环动画的原点(新增定义)
  760.   #--------------------------------------------------------------------------
  761.   def set_loop_animation_origin(animation)
  762.     if animation.position == 3
  763.       if viewport == nil
  764.         ani_ox = Graphics.width / 2
  765.         ani_oy = Graphics.height / 2
  766.       else
  767.         ani_ox = viewport.rect.width / 2
  768.         ani_oy = viewport.rect.height / 2
  769.       end
  770.     else
  771.       ani_ox = x - ox + width / 2
  772.       ani_oy = y - oy + height / 2
  773.       if animation.position == 0
  774.         ani_oy -= height / 2
  775.       elsif animation.position == 2
  776.         ani_oy += height / 2
  777.       end
  778.     end
  779.     @hzhj_loop_ani_oxs[animation] = ani_ox
  780.     @hzhj_loop_ani_oys[animation] = ani_oy
  781.   end
  782.   #--------------------------------------------------------------------------
  783.   # ● 释放所有循环动画(新增定义)
  784.   #--------------------------------------------------------------------------
  785.   def dispose_loop_animation
  786.     return unless loop_animation?
  787.     for animation in @hzhj_loop_animations.clone
  788.       end_loop_animation(animation)
  789.     end
  790.     @hzhj_loop_durations.clear
  791.     @hzhj_loop_sprites.clear
  792.     @hzhj_loop_bitmap1s.clear
  793.     @hzhj_loop_bitmap2s.clear
  794.     @hzhj_loop_ani_oxs.clear
  795.     @hzhj_loop_ani_oys.clear
  796.     @hzhj_loop_animations.clear
  797.   end
  798.   #--------------------------------------------------------------------------
  799.   # ● 结束某个循环动画(新增定义)
  800.   #--------------------------------------------------------------------------
  801.   def end_loop_animation(animation)
  802.     return if not @hzhj_loop_animations.include?(animation)
  803.     bitmap1 = @hzhj_loop_bitmap1s[animation]
  804.     @@_reference_count[bitmap1] -= 1
  805.     if @@_reference_count[bitmap1] == 0
  806.       @@_reference_count.delete(bitmap1)
  807.       bitmap1.dispose
  808.     end
  809.     bitmap2 = @hzhj_loop_bitmap2s[animation]
  810.     @@_reference_count[bitmap2] -= 1
  811.     if @@_reference_count[bitmap2] == 0
  812.       @@_reference_count.delete(bitmap2)
  813.       bitmap2.dispose
  814.     end
  815.     sprites = @hzhj_loop_sprites[animation]
  816.     for sprite in sprites
  817.       sprite.dispose
  818.     end
  819.     @hzhj_loop_durations.delete(animation)
  820.     @hzhj_loop_sprites.delete(animation)
  821.     @hzhj_loop_bitmap1s.delete(animation)
  822.     @hzhj_loop_bitmap2s.delete(animation)
  823.     @hzhj_loop_ani_oxs.delete(animation)
  824.     @hzhj_loop_ani_oys.delete(animation)
  825.     @hzhj_loop_animations.delete(animation)
  826.   end
  827.   #--------------------------------------------------------------------------
  828.   # ● 刷新(追加定义)
  829.   #--------------------------------------------------------------------------
  830.   alias hzhj_old_update_for_state_ani_spr_base update
  831.   def update
  832.     hzhj_old_update_for_state_ani_spr_base
  833.     update_loop_animation
  834.   end
  835.   #--------------------------------------------------------------------------
  836.   # ● 刷新循环动画(新增定义)
  837.   #--------------------------------------------------------------------------
  838.   def update_loop_animation
  839.     @flash_nil_duration -= 1 if @flash_nil_duration > 0
  840.     return unless loop_animation?
  841.     for animation in @hzhj_loop_animations
  842.       @hzhj_loop_durations[animation] -= 1
  843.       duration = @hzhj_loop_durations[animation]
  844.       if duration % @ani_rate == 0
  845.         if duration > 0
  846.           set_loop_animation_origin(animation)
  847.           frame_index = animation.frame_max
  848.           frame_index -= (duration + @ani_rate - 1) / @ani_rate
  849.           args = []
  850.           args[0] = @hzhj_loop_sprites[animation]
  851.           args[1] = @hzhj_loop_bitmap1s[animation]
  852.           args[2] = @hzhj_loop_bitmap2s[animation]
  853.           args[3] = @hzhj_loop_ani_oxs[animation]
  854.           args[4] = @hzhj_loop_ani_oys[animation]
  855.           args[5] = animation.loop_z_correction
  856.           args[6] = ((not flash_nil? or animation.to_screen?) and visible)
  857.           loop_animation_set_sprites(animation.frames[frame_index], args)
  858.           animation.timings.each do |timing|
  859.             loop_animation_process_timing(timing) if timing.frame == frame_index
  860.           end
  861.         else
  862.           init_loop_animation_duration(animation)
  863.           redo
  864.         end
  865.       end
  866.     end
  867.   end
  868.   #--------------------------------------------------------------------------
  869.   # ● 设定循环动画的活动块(新增定义)
  870.   #--------------------------------------------------------------------------
  871.   def loop_animation_set_sprites(frame, args)
  872.     sprites = args[0]
  873.     bitmap1 = args[1]
  874.     bitmap2 = args[2]
  875.     ani_ox = args[3]
  876.     ani_oy = args[4]
  877.     loop_z_correction = args[5]
  878.     state_visible = args[6]
  879.     cell_data = frame.cell_data
  880.     sprites.each_with_index do |sprite, i|
  881.       next unless sprite
  882.       pattern = cell_data[i, 0]
  883.       if !pattern || pattern < 0
  884.         sprite.visible = false
  885.         next
  886.       end
  887.       sprite.bitmap = pattern < 100 ? bitmap1 : bitmap2
  888.       sprite.visible = state_visible
  889.       sprite.src_rect.set(pattern % 5 * 192,
  890.         pattern % 100 / 5 * 192, 192, 192)
  891.       sprite.x = ani_ox + cell_data[i, 1]
  892.       sprite.y = ani_oy + cell_data[i, 2]
  893.       sprite.angle = cell_data[i, 4]
  894.       sprite.mirror = (cell_data[i, 5] == 1)
  895.       if loop_z_correction > 9999
  896.         sprite.z = loop_z_correction % 10000 + i
  897.       elsif loop_z_correction < -9999
  898.         sprite.z = loop_z_correction % -10000 + i
  899.       else
  900.         sprite.z = self.z + loop_z_correction + i
  901.       end
  902.       sprite.ox = 96
  903.       sprite.oy = 96
  904.       sprite.zoom_x = cell_data[i, 3] / 100.0
  905.       sprite.zoom_y = cell_data[i, 3] / 100.0
  906.       sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  907.       sprite.blend_type = cell_data[i, 7]
  908.     end
  909.   end
  910.   #--------------------------------------------------------------------------
  911.   # ● 循环动画SE 和闪烁时机的处理(新增定义)
  912.   #--------------------------------------------------------------------------
  913.   def loop_animation_process_timing(timing)
  914.     timing.se.play
  915.     case timing.flash_scope
  916.     when 1
  917.       self.flash(timing.flash_color, timing.flash_duration * @ani_rate)
  918.     when 2
  919.       if viewport
  920.         viewport.flash(timing.flash_color, timing.flash_duration * @ani_rate)
  921.       end
  922.     when 3
  923.       self.flash(nil, timing.flash_duration * @ani_rate)
  924.     end
  925.   end
  926.   #--------------------------------------------------------------------------
  927.   # ● 设置闪烁(追加定义)
  928.   #--------------------------------------------------------------------------
  929.   alias hzhj_old_flash_for_state_ani_spr_base flash
  930.   def flash(*args)
  931.     if args[0].nil?
  932.       @flash_nil_duration = args[1]
  933.     else
  934.       @flash_nil_duration = 0
  935.     end
  936.     hzhj_old_flash_for_state_ani_spr_base(*args)
  937.   end
  938.   #--------------------------------------------------------------------------
  939.   # ● 判断是否正处于【隐藏目标】(新增定义)
  940.   #--------------------------------------------------------------------------
  941.   def flash_nil?
  942.     return (@flash_nil_duration > 0)
  943.   end
  944. end
  945. #==============================================================================
  946. # ■ Sprite_Battler
  947. #==============================================================================
  948. class Sprite_Battler < Sprite_Base
  949.   #--------------------------------------------------------------------------
  950.   # ● 初始化(追加定义)
  951.   #--------------------------------------------------------------------------
  952.   alias hzhj_old_init_for_state_ani_spr_battler initialize
  953.   def initialize(*args)
  954.     hzhj_old_init_for_state_ani_spr_battler(*args)
  955.     init_battler_add_state_id
  956.   end
  957.   #--------------------------------------------------------------------------
  958.   # ● 初始化战斗者要播放状态动画的状态(新增定义)
  959.   #--------------------------------------------------------------------------
  960.   def init_battler_add_state_id
  961.     if @battler.nil?
  962.       dispose_loop_animation
  963.     else
  964.       @battler.hzhj_add_state_id.clear
  965.       @battler.hzhj_remove_state_id.clear
  966.       @battler.need_update_state_animation = true
  967.       for state in @battler.states
  968.         next if state.nil?
  969.         next if $data_animations[state.animation_id].nil?
  970.         @battler.hzhj_add_state_id.push(state.id)
  971.       end
  972.     end
  973.   end
  974.   #--------------------------------------------------------------------------
  975.   # ● 设置战斗者(追加定义)
  976.   #--------------------------------------------------------------------------
  977.   alias hzhj_old_battlerdy_for_state_ani_spr_battler battler=
  978.   def battler=(value)
  979.     old_battler = @battler
  980.     hzhj_old_battlerdy_for_state_ani_spr_battler(value)
  981.     if old_battler != @battler
  982.       init_battler_add_state_id
  983.     end
  984.   end
  985.   #--------------------------------------------------------------------------
  986.   # ● 刷新(追加定义)
  987.   #--------------------------------------------------------------------------
  988.   alias hzhj_old_update_for_state_ani_spr_battler update
  989.   def update
  990.     hzhj_old_update_for_state_ani_spr_battler
  991.     if @battler
  992.       if @battler.need_update_state_animation
  993.         @battler.need_update_state_animation = false
  994.         if not @battler.hzhj_add_state_id.empty?
  995.           for i in @battler.hzhj_add_state_id
  996.             if @battler.state?(i)
  997.               ani_id = $data_states[i].animation_id
  998.               animation = $data_animations[ani_id]
  999.               start_loop_animation(animation) if not animation.nil?
  1000.             end
  1001.           end
  1002.           @battler.hzhj_add_state_id.clear
  1003.         end
  1004.         if not @battler.hzhj_remove_state_id.empty?
  1005.           for i in @battler.hzhj_remove_state_id
  1006.             if not @battler.state?(i)
  1007.               ani_id = $data_states[i].animation_id
  1008.               animation = $data_animations[ani_id]
  1009.               end_loop_animation(animation) if not animation.nil?
  1010.             end
  1011.           end
  1012.           @battler.hzhj_remove_state_id.clear
  1013.         end
  1014.       end
  1015.     end
  1016.   end
  1017. end
  1018. #==============================================================================
  1019. # ■ Window_BattleLog
  1020. #==============================================================================
  1021. class Window_BattleLog < Window_Selectable
  1022.   #--------------------------------------------------------------------------
  1023.   # ● 显示状态附加/解除(追加定义)
  1024.   #--------------------------------------------------------------------------
  1025.   alias hzhj_old_display_status_for_state_ani_wnd_btlog display_changed_states
  1026.   def display_changed_states(target)
  1027.     target.need_update_state_animation = true
  1028.     hzhj_old_display_status_for_state_ani_wnd_btlog(target)
  1029.   end
  1030. end

  1031. #==============================================================================
  1032. # ■ Sprite_Damage (新增类)
  1033. #==============================================================================
  1034. class Sprite_Damage < Sprite
  1035.   include Hzhj::HorizontalBattleSystem
  1036.   #--------------------------------------------------------------------------
  1037.   # ● 获取/生成伤害值源图
  1038.   #--------------------------------------------------------------------------
  1039.   @@obmp = nil
  1040.   def self.obmp
  1041.     if @@obmp.nil? or @@obmp.disposed?
  1042.       @@obmp = Bitmap.new(180, 256)
  1043.       @@obmp.font.bold = true
  1044.       @@obmp.font.shadow = false
  1045.       @@obmp.font.outline = true
  1046.       @@obmp.font.out_color = Color.new(255, 255, 255, 255)
  1047.       @@obmp.font.size = 32
  1048.       colors = []
  1049.       colors.push(Color.new(255,   0,   0, 255))
  1050.       colors.push(Color.new(255, 128, 128, 255))
  1051.       colors.push(Color.new(  0,   0, 255, 255))
  1052.       colors.push(Color.new(128, 128, 255, 255))
  1053.       colors.push(Color.new(  0, 255,   0, 255))
  1054.       colors.push(Color.new(128, 255, 128, 255))
  1055.       colors.each_with_index do |color, hi|
  1056.         @@obmp.font.color = color
  1057.         for wi in 0..9
  1058.           @@obmp.draw_text(wi * 18, hi * 32, 18, 32, "#{wi}", 1)
  1059.         end
  1060.       end
  1061.       @@obmp.font.size = 20
  1062.       @@obmp.font.italic = true
  1063.       @@obmp.font.out_color = Color.new(0, 0, 0, 255)
  1064.       @@obmp.font.color = Color.new(255, 255, 255, 255)
  1065.       @@obmp.draw_text( 0, 192, 90, 32, "Critical", 1)
  1066.       @@obmp.draw_text(90, 192, 90, 32, "Miss", 1)
  1067.       @@obmp.draw_text( 0, 224, 90, 32, "Evasion", 1)
  1068.       @@obmp.hue_change(DamageBitmapHue)
  1069.     end
  1070.     return @@obmp
  1071.   end
  1072.   #--------------------------------------------------------------------------
  1073.   # ● 初始化
  1074.   #--------------------------------------------------------------------------
  1075.   def initialize(viewport, args)
  1076.     super(viewport)
  1077.     @type = args[0]
  1078.     @value = args[1]
  1079.     @critical = args[2]
  1080.     self.x = args[4]
  1081.     self.y = args[5]
  1082.     self.z = args[6] + Graphics.height * 5
  1083.     make_move(args[3])
  1084.     refresh
  1085.   end
  1086.   #--------------------------------------------------------------------------
  1087.   # ● 生成移动数据
  1088.   #--------------------------------------------------------------------------
  1089.   def make_move(battler_obj_class)
  1090.     @move = []
  1091.     case battler_obj_class
  1092.     when :actor
  1093.       make_move_actor
  1094.     when :enemy
  1095.       make_move_enemy
  1096.     else
  1097.       make_move_default
  1098.     end
  1099.   end
  1100.   #--------------------------------------------------------------------------
  1101.   # ● 生成移动数据 默认
  1102.   #--------------------------------------------------------------------------
  1103.   def make_move_default
  1104.     45.times do |n|
  1105.       if n % 3 == 0
  1106.         ady = n < 21 ? -6 : -1
  1107.         opa = n < 21 ? 255 : 255-(n-21)*6
  1108.         @move.push([0, ady, opa])
  1109.       else
  1110.         @move.push([0, 0, -1])
  1111.       end
  1112.     end
  1113.   end
  1114.   #--------------------------------------------------------------------------
  1115.   # ● 生成移动数据 角色
  1116.   #--------------------------------------------------------------------------
  1117.   def make_move_actor
  1118.     make_move_default
  1119.   end
  1120.   #--------------------------------------------------------------------------
  1121.   # ● 生成移动数据 敌人
  1122.   #--------------------------------------------------------------------------
  1123.   def make_move_enemy
  1124.     make_move_default
  1125.   end
  1126.   #--------------------------------------------------------------------------
  1127.   # ● 描绘
  1128.   #--------------------------------------------------------------------------
  1129.   def refresh
  1130.     if not self.bitmap.nil?
  1131.       self.bitmap.dispose
  1132.       self.bitmap = nil
  1133.     end
  1134.     begin
  1135.       @obmp = Cache.animation("damage", DamageBitmapHue)
  1136.     rescue Errno::ENOENT
  1137.       @obmp = Sprite_Damage.obmp
  1138.     end
  1139.     @numw = @obmp.width / 10
  1140.     @numh = @obmp.height / 8
  1141.     @strw = @obmp.width / 2
  1142.     case @value
  1143.     when Numeric
  1144.       blt_obmp_numeric
  1145.     when Symbol
  1146.       blt_obmp_text
  1147.     end
  1148.   end
  1149.   #--------------------------------------------------------------------------
  1150.   # ● 通过源图描绘数字
  1151.   #--------------------------------------------------------------------------
  1152.   def blt_obmp_numeric
  1153.     nums = @value.to_i.abs.to_s.split("")
  1154.     nbmpw = nums.size * @numw
  1155.     bmph = @numh
  1156.     cbmpw = 0
  1157.     crect = nil
  1158.     dy = 0
  1159.     if @critical
  1160.       cbmpw = @strw
  1161.       bmph *= 2
  1162.       crect = Rect.new(0, @numh * 6, @strw, @numh)
  1163.       dy = @numh
  1164.     end
  1165.     self.bitmap = Bitmap.new([nbmpw, cbmpw, 32].max, [bmph, 32].max)
  1166.     self.ox = bitmap.width / 2
  1167.     self.oy = bmph /2
  1168.     bitmap.blt((bitmap.width - cbmpw) / 2, 0, @obmp, crect) if crect
  1169.     dx = (bitmap.width - nbmpw) / 2
  1170.     ry = 0
  1171.     case @type
  1172.     when :hp
  1173.       ry = @value >= 0 ? 0 : @numh
  1174.     when :mp
  1175.       ry = @value >= 0 ? @numh * 2 : @numh * 3
  1176.     when :tp
  1177.       ry = @value >= 0 ? @numh * 4 : @numh * 5
  1178.     else
  1179.       return
  1180.     end
  1181.     rect = Rect.new(0, ry, @numw, @numh)
  1182.     nums.each_with_index do |str, i|
  1183.       rect.x = str.to_i * @numw
  1184.       bitmap.blt(dx, dy, @obmp, rect)
  1185.       dx += @numw
  1186.     end
  1187.   end
  1188.   #--------------------------------------------------------------------------
  1189.   # ● 通过源图描绘文字
  1190.   #--------------------------------------------------------------------------
  1191.   def blt_obmp_text
  1192.     self.bitmap = Bitmap.new([@strw, 32].max, [@numh, 32].max)
  1193.     self.ox = @strw / 2
  1194.     self.oy = @numh / 2
  1195.     rx = ry = 0
  1196.     case @type
  1197.     when :miss
  1198.       rx = @strw
  1199.       ry = @numh * 6
  1200.     when :eva
  1201.       ry = @numh * 7
  1202.     else
  1203.       return
  1204.     end
  1205.     rect = Rect.new(rx, ry, @strw, @numh)
  1206.     bitmap.blt(0, 0, @obmp, rect)
  1207.   end
  1208.   #--------------------------------------------------------------------------
  1209.   # ● 释放
  1210.   #--------------------------------------------------------------------------
  1211.   def dispose
  1212.     bitmap.dispose if bitmap
  1213.     super
  1214.   end
  1215.   #--------------------------------------------------------------------------
  1216.   # ● 移动中判定
  1217.   #--------------------------------------------------------------------------
  1218.   def moving?
  1219.     return (not @move.empty?)
  1220.   end
  1221.   #--------------------------------------------------------------------------
  1222.   # ● 刷新
  1223.   #--------------------------------------------------------------------------
  1224.   def update
  1225.     super
  1226.     if moving?
  1227.       ary = @move.shift
  1228.       self.x += ary[0]
  1229.       self.y += ary[1]
  1230.       self.opacity = ary[2] if ary[2] >= 0
  1231.     end
  1232.   end
  1233. end
  1234. #==============================================================================
  1235. # ■ Game_BattlerBase
  1236. #==============================================================================
  1237. class Game_BattlerBase
  1238.   #--------------------------------------------------------------------------
  1239.   # ● 实例变量(新增定义)
  1240.   #--------------------------------------------------------------------------
  1241.   attr_accessor :hzhj_damage
  1242.   #--------------------------------------------------------------------------
  1243.   # ● 初始化(追加定义)
  1244.   #--------------------------------------------------------------------------
  1245.   alias hzhj_old_init_for_display_damage_game_battler_base initialize
  1246.   def initialize
  1247.     @hzhj_damage = []
  1248.     hzhj_old_init_for_display_damage_game_battler_base
  1249.   end
  1250. end
  1251. #==============================================================================
  1252. # ■ Sprite_Base
  1253. #==============================================================================
  1254. class Sprite_Base < Sprite
  1255.   #--------------------------------------------------------------------------
  1256.   # ● 初始化(追加定义)
  1257.   #--------------------------------------------------------------------------
  1258.   alias hzhj_old_init_for_display_damage_spr_base initialize
  1259.   def initialize(*args)
  1260.     hzhj_old_init_for_display_damage_spr_base(*args)
  1261.     @hzhj_damage_sprites = []
  1262.   end
  1263.   #--------------------------------------------------------------------------
  1264.   # ● 释放(追加定义)
  1265.   #--------------------------------------------------------------------------
  1266.   alias hzhj_old_dispose_for_display_damage_spr_base dispose
  1267.   def dispose
  1268.     hzhj_old_dispose_for_display_damage_spr_base
  1269.     dispose_damage
  1270.   end
  1271.   #--------------------------------------------------------------------------
  1272.   # ● 判断是否有伤害在显示(新增定义)
  1273.   #--------------------------------------------------------------------------
  1274.   def damage?
  1275.     return (not @hzhj_damage_sprites.empty?)
  1276.   end
  1277.   #--------------------------------------------------------------------------
  1278.   # ● 开始显示伤害(新增定义)
  1279.   #--------------------------------------------------------------------------
  1280.   def start_damage(args)
  1281.     args[4] = x - ox + width / 2
  1282.     args[5] = y - oy + height / 2
  1283.     args[6] = z
  1284.     @hzhj_damage_sprites.push(Sprite_Damage.new(viewport, args))
  1285.   end
  1286.   #--------------------------------------------------------------------------
  1287.   # ● 释放所有伤害显示(新增定义)
  1288.   #--------------------------------------------------------------------------
  1289.   def dispose_damage
  1290.     return unless damage?
  1291.     @hzhj_damage_sprites.each{|sprite|sprite.dispose}
  1292.     @hzhj_damage_sprites.clear
  1293.   end
  1294.   #--------------------------------------------------------------------------
  1295.   # ● 刷新(追加定义)
  1296.   #--------------------------------------------------------------------------
  1297.   alias hzhj_old_update_for_display_damage_spr_base update
  1298.   def update
  1299.     hzhj_old_update_for_display_damage_spr_base
  1300.     update_damage
  1301.   end
  1302.   #--------------------------------------------------------------------------
  1303.   # ● 刷新显示伤害(新增定义)
  1304.   #--------------------------------------------------------------------------
  1305.   def update_damage
  1306.     return unless damage?
  1307.     @hzhj_damage_sprites.each_with_index do |sprite, i|
  1308.       if sprite.moving?
  1309.         sprite.update
  1310.       else
  1311.         sprite.dispose
  1312.         @hzhj_damage_sprites[i] = nil
  1313.       end
  1314.     end
  1315.     @hzhj_damage_sprites.delete(nil)
  1316.   end
  1317. end
  1318. #==============================================================================
  1319. # ■ Sprite_Battler
  1320. #==============================================================================
  1321. class Sprite_Battler < Sprite_Base
  1322.   #--------------------------------------------------------------------------
  1323.   # ● 刷新(追加定义)
  1324.   #--------------------------------------------------------------------------
  1325.   alias hzhj_old_update_for_display_damage_spr_battler update
  1326.   def update
  1327.     hzhj_old_update_for_display_damage_spr_battler
  1328.     if @battler
  1329.       if not @battler.hzhj_damage.empty?
  1330.         unless @battler.damage_section_displayed
  1331.           args = @battler.hzhj_damage.clone
  1332.           args[3] = @battler.actor? ? :actor : (@battler.enemy? ? :enemy : nil)
  1333.           start_damage(args)
  1334.         end
  1335.         @battler.hzhj_damage.clear
  1336.       end
  1337.     end
  1338.   end
  1339. end
  1340. #==============================================================================
  1341. # ■ Window_BattleLog
  1342. #==============================================================================
  1343. class Window_BattleLog < Window_Selectable
  1344.   #--------------------------------------------------------------------------
  1345.   # ● 显示 MISS (追加定义)
  1346.   #--------------------------------------------------------------------------
  1347.   alias hzhj_old_display_miss_for_display_damage_wnd_btlog display_miss
  1348.   def display_miss(target, item)
  1349.     target.hzhj_damage = [:miss, :miss, false]
  1350.     hzhj_old_display_miss_for_display_damage_wnd_btlog(target, item)
  1351.   end
  1352.   #--------------------------------------------------------------------------
  1353.   # ● 显示回避 (追加定义)
  1354.   #--------------------------------------------------------------------------
  1355.   alias hzhj_old_display_evasion_for_display_damage_wnd_btlog display_evasion
  1356.   def display_evasion(target, item)
  1357.     target.hzhj_damage = [:eva, :evasion, false]
  1358.     hzhj_old_display_evasion_for_display_damage_wnd_btlog(target, item)
  1359.   end
  1360.   #--------------------------------------------------------------------------
  1361.   # ● 显示 HP 伤害 (追加定义)
  1362.   #--------------------------------------------------------------------------
  1363.   alias hzhj_old_display_hp_damage_for_display_damage_wnd_btlog display_hp_damage
  1364.   def display_hp_damage(target, item)
  1365.     return if target.result.hp_damage == 0 && item && !item.damage.to_hp?
  1366.     value = target.result.hp_damage
  1367.     critical = target.result.critical
  1368.     target.hzhj_damage = [:hp, value, critical]
  1369.     hzhj_old_display_hp_damage_for_display_damage_wnd_btlog(target, item)
  1370.   end
  1371.   #--------------------------------------------------------------------------
  1372.   # ● 显示 MP 伤害 (追加定义)
  1373.   #--------------------------------------------------------------------------
  1374.   alias hzhj_old_display_mp_damage_for_display_damage_wnd_btlog display_mp_damage
  1375.   def display_mp_damage(target, item)
  1376.     return if target.dead? || target.result.mp_damage == 0
  1377.     value = target.result.mp_damage
  1378.     critical = target.result.critical
  1379.     target.hzhj_damage = [:mp, value, critical]
  1380.     hzhj_old_display_mp_damage_for_display_damage_wnd_btlog(target, item)
  1381.   end
  1382.   #--------------------------------------------------------------------------
  1383.   # ● 显示 TP 伤害 (追加定义)
  1384.   #--------------------------------------------------------------------------
  1385.   alias hzhj_old_display_tp_damage_for_display_damage_wnd_btlog display_tp_damage
  1386.   def display_tp_damage(target, item)
  1387.     return if target.dead? || target.result.tp_damage == 0
  1388.     value = target.result.tp_damage
  1389.     critical = target.result.critical
  1390.     target.hzhj_damage = [:tp, value, critical]
  1391.     hzhj_old_display_tp_damage_for_display_damage_wnd_btlog(target, item)
  1392.   end
  1393. end

  1394. class RPG::Animation
  1395.   def need_move
  1396.     return @need_move unless @need_move.nil?
  1397.     if /@[Rr][Mm]/ =~ @name
  1398.       return (@need_move = true)
  1399.     else
  1400.       return (@need_move = false)
  1401.     end
  1402.   end
  1403.   def move_se
  1404.     return @move_se unless @move_se.nil?
  1405.     @move_se = RPG::SE.new
  1406.     if /@[Ss][Ee]\[(.+?)\]/ =~ @name
  1407.       @move_se.name = $1.clone
  1408.     end
  1409.     return @move_se
  1410.   end
  1411.   attr_writer :need_move
  1412.   attr_writer :move_se
  1413. end
  1414. #==============================================================================
  1415. # ■ Game_Battler
  1416. #==============================================================================
  1417. class Game_Battler < Game_BattlerBase
  1418.   include Hzhj::HorizontalBattleSystem
  1419.   #--------------------------------------------------------------------------
  1420.   # ● 属性
  1421.   #--------------------------------------------------------------------------
  1422.   attr_accessor :add_x                    # X 坐标变化量
  1423.   attr_accessor :add_y                    # Y 坐标变化量
  1424.   attr_accessor :move_speed_x             # 战斗图 X 移动速度
  1425.   attr_accessor :move_speed_y             # 战斗图 Y 移动速度
  1426.   #--------------------------------------------------------------------------
  1427.   # ● 初始化(追加定义)
  1428.   #--------------------------------------------------------------------------
  1429.   alias hzhj_old_init_for_real_move_game_battler initialize
  1430.   def initialize
  1431.     @add_x = 0
  1432.     @add_y = 0
  1433.     @move_speed_x = 0
  1434.     @move_speed_y = 0
  1435.     hzhj_old_init_for_real_move_game_battler
  1436.   end
  1437.   #--------------------------------------------------------------------------
  1438.   # ● 真实 X 坐标(新增定义)
  1439.   #--------------------------------------------------------------------------
  1440.   def real_screen_x
  1441.     return screen_x + add_x
  1442.   end
  1443.   #--------------------------------------------------------------------------
  1444.   # ● 真实 Y 坐标(新增定义)
  1445.   #--------------------------------------------------------------------------
  1446.   def real_screen_y
  1447.     return screen_y + add_y
  1448.   end
  1449.   #--------------------------------------------------------------------------
  1450.   # ● 返回自己的战斗位置(新增定义)
  1451.   #--------------------------------------------------------------------------
  1452.   def come_back_self_position(duration)
  1453.     return if dead?
  1454.     tx = screen_x
  1455.     ty = screen_y
  1456.     addx = tx - real_screen_x
  1457.     addy = ty - real_screen_y
  1458.     return if addx == 0 && addy == 0
  1459.     @add_x = 0
  1460.     @add_y = 0
  1461.     @move_speed_x = [(addx.abs / duration.to_f).ceil, 1].max
  1462.     @move_speed_y = [(addy.abs / duration.to_f).ceil, 1].max
  1463.   end
  1464.   #--------------------------------------------------------------------------
  1465.   # ● 设置移动信息(新增定义)
  1466.   #--------------------------------------------------------------------------
  1467.   def setup_move_info(target_battler, duration, move_se)
  1468.     return if dead?
  1469.     tbmp = Cache.battler(target_battler.battler_name, target_battler.battler_hue)
  1470.     sbmp = Cache.battler(@battler_name, @battler_hue)
  1471.     tbw = tbmp.width / DynamicPatternMax + RealMoveBmpAddW
  1472.     sbw = sbmp.width / DynamicPatternMax + RealMoveBmpAddW
  1473.     tbh = tbmp.height + RealMoveBmpAddH
  1474.     sbh = sbmp.height + RealMoveBmpAddH
  1475.     d = actor? ? ActorDirection : 10 - ActorDirection
  1476.     tx = target_battler.real_screen_x
  1477.     ty = target_battler.real_screen_y
  1478.     case d
  1479.     when 1
  1480.       tx = tx + tbw / 2 + sbw / 2
  1481.       ty = ty - sbh / 2
  1482.     when 2
  1483.       ty = ty - sbh / 2
  1484.     when 3
  1485.       tx = tx - tbw / 2 - sbw / 2
  1486.       ty = ty - sbh / 2
  1487.     when 4
  1488.       tx = tx + tbw / 2 + sbw / 2
  1489.     when 6
  1490.       tx = tx - tbw / 2 - sbw / 2
  1491.     when 7
  1492.       tx = tx + tbw / 2 + sbw / 2
  1493.       ty = ty + sbh / 2
  1494.     when 8
  1495.       ty = ty + sbh / 2
  1496.     when 9
  1497.       tx = tx - tbw / 2 - sbw / 2
  1498.       ty = ty + sbh / 2
  1499.     end
  1500.     addx = tx - real_screen_x
  1501.     addy = ty - real_screen_y
  1502.     return if addx == 0 && addy == 0
  1503.     @add_x = tx - screen_x if addx != 0
  1504.     @add_y = ty - screen_y if addy != 0
  1505.     @move_speed_x = [(addx.abs / duration.to_f).ceil, 1].max
  1506.     @move_speed_y = [(addy.abs / duration.to_f).ceil, 1].max
  1507.     move_se.play
  1508.   end
  1509. end
  1510. #==============================================================================
  1511. # ■ Sprite_Battler
  1512. #==============================================================================
  1513. class Sprite_Battler < Sprite_Base
  1514.   #--------------------------------------------------------------------------
  1515.   # ● 初始化(追加定义)
  1516.   #--------------------------------------------------------------------------
  1517.   alias hzhj_old_init_for_real_move_spr_battler initialize
  1518.   def initialize(viewport, battler = nil)
  1519.     hzhj_old_init_for_real_move_spr_battler(viewport, battler)
  1520.     init_position(@battler) if @battler
  1521.   end
  1522.   #--------------------------------------------------------------------------
  1523.   # ● 设置战斗者(追加定义)
  1524.   #--------------------------------------------------------------------------
  1525.   alias hzhj_old_set_battler_for_real_move_spr_battler battler=
  1526.   def battler=(value)
  1527.     if @battler != value && value
  1528.       init_position(value)
  1529.     end
  1530.     hzhj_old_set_battler_for_real_move_spr_battler(value)
  1531.   end
  1532.   #--------------------------------------------------------------------------
  1533.   # ● 初始化位置(新增定义)
  1534.   #--------------------------------------------------------------------------
  1535.   def init_position(battler)
  1536.     battler.add_x = 0
  1537.     battler.add_y = 0
  1538.     self.x = battler.real_screen_x
  1539.     self.y = battler.real_screen_y
  1540.     self.z = battler.screen_z
  1541.   end
  1542.   #--------------------------------------------------------------------------
  1543.   # ● 移动中判定(新增定义)
  1544.   #--------------------------------------------------------------------------
  1545.   def moving?
  1546.     return false unless @battler
  1547.     (x != @battler.real_screen_x or y != @battler.real_screen_y) && @battler
  1548.   end
  1549.   #--------------------------------------------------------------------------
  1550.   # ● 位置的更新(重定义)
  1551.   #--------------------------------------------------------------------------
  1552.   def update_position
  1553.     if !@battler.dead?
  1554.       if x < @battler.real_screen_x
  1555.         self.x = [x + @battler.move_speed_x, @battler.real_screen_x].min
  1556.       elsif x > @battler.real_screen_x
  1557.         self.x = [x - @battler.move_speed_x, @battler.real_screen_x].max
  1558.       end
  1559.       if y < @battler.real_screen_y
  1560.         self.y = [y + @battler.move_speed_y, @battler.real_screen_y].min
  1561.       elsif y > @battler.real_screen_y
  1562.         self.y = [y - @battler.move_speed_y, @battler.real_screen_y].max
  1563.       end
  1564.       self.z = y + 100
  1565.     end
  1566.   end
  1567. end
  1568. #==============================================================================
  1569. # ■ Spriteset_Battle
  1570. #==============================================================================
  1571. class Spriteset_Battle
  1572.   #--------------------------------------------------------------------------
  1573.   # ● 判定是否移动中(新增定义)
  1574.   #--------------------------------------------------------------------------
  1575.   def moving?
  1576.     battler_sprites.any? {|sprite| sprite.moving? }
  1577.   end
  1578. end
  1579. #==============================================================================
  1580. # ■ Scene_Battle
  1581. #==============================================================================
  1582. class Scene_Battle < Scene_Base
  1583.   #--------------------------------------------------------------------------
  1584.   # ● 等待战斗图移动的结束(新增定义)
  1585.   #--------------------------------------------------------------------------
  1586.   def wait_for_move
  1587.     update_for_wait
  1588.     update_for_wait while @spriteset.moving?
  1589.   end
  1590. end

  1591. class RPG::Troop
  1592.   include Hzhj::HorizontalBattleSystem
  1593.   def display_enemy_bar
  1594.     return @display_enemy_bar unless @display_enemy_bar.nil?
  1595.     if /@ebar/i =~ @name
  1596.       return (@display_enemy_bar = !DefaultDisplayEnemyBar)
  1597.     else
  1598.       return (@display_enemy_bar = DefaultDisplayEnemyBar)
  1599.     end
  1600.   end
  1601.   attr_writer :display_enemy_bar
  1602. end
  1603. #==============================================================================
  1604. # ■ Game_Troop
  1605. #==============================================================================
  1606. class Game_Troop < Game_Unit
  1607.   attr_accessor :display_enemy_bar      # 是否显示敌人HP条、MP条、TP条
  1608.   #--------------------------------------------------------------------------
  1609.   # ● 设置
  1610.   #--------------------------------------------------------------------------
  1611.   alias hzhj_old_setup_for_display_enemy_bar_game_troop setup
  1612.   def setup(troop_id)
  1613.     hzhj_old_setup_for_display_enemy_bar_game_troop(troop_id)
  1614.     @display_enemy_bar = troop.display_enemy_bar
  1615.   end
  1616. end
  1617. #==============================================================================
  1618. # ■ Window_BattleEnemy
  1619. #==============================================================================
  1620. class Window_BattleEnemy < Window_Selectable
  1621.   #--------------------------------------------------------------------------
  1622.   # ● 取得列数
  1623.   #--------------------------------------------------------------------------
  1624.   def col_max
  1625.     if $game_troop.display_enemy_bar
  1626.       return 1
  1627.     else
  1628.       return 2
  1629.     end
  1630.   end
  1631.   #--------------------------------------------------------------------------
  1632.   # ● 刷新
  1633.   #--------------------------------------------------------------------------
  1634.   def refresh
  1635.     create_contents
  1636.     super
  1637.   end
  1638.   #--------------------------------------------------------------------------
  1639.   # ● 描画项目
  1640.   #--------------------------------------------------------------------------
  1641.   def draw_item(index)
  1642.     if $game_troop.display_enemy_bar
  1643.       enemy = $game_troop.alive_members[index]
  1644.       draw_basic_area(basic_area_rect(index), enemy)
  1645.       draw_gauge_area(gauge_area_rect(index), enemy)
  1646.     else
  1647.       change_color(normal_color)
  1648.       name = $game_troop.alive_members[index].name
  1649.       draw_text(item_rect_for_text(index), name)
  1650.     end
  1651.   end
  1652.   #--------------------------------------------------------------------------
  1653.   # ● 取得基本区域的矩形
  1654.   #--------------------------------------------------------------------------
  1655.   def basic_area_rect(index)
  1656.     rect = item_rect_for_text(index)
  1657.     rect.width -= gauge_area_width + 10
  1658.     rect
  1659.   end
  1660.   #--------------------------------------------------------------------------
  1661.   # ● 取得值槽区域的矩形
  1662.   #--------------------------------------------------------------------------
  1663.   def gauge_area_rect(index)
  1664.     rect = item_rect_for_text(index)
  1665.     rect.x += rect.width - gauge_area_width
  1666.     rect.width = gauge_area_width
  1667.     rect
  1668.   end
  1669.   #--------------------------------------------------------------------------
  1670.   # ● 取得值槽区域的宽度
  1671.   #--------------------------------------------------------------------------
  1672.   def gauge_area_width
  1673.     return 220
  1674.   end
  1675.   #--------------------------------------------------------------------------
  1676.   # ● 描画基本区域
  1677.   #--------------------------------------------------------------------------
  1678.   def draw_basic_area(rect, actor)
  1679.     draw_actor_name(actor, rect.x + 0, rect.y, 100)
  1680.     draw_actor_icons(actor, rect.x + 104, rect.y, rect.width - 104)
  1681.   end
  1682.   #--------------------------------------------------------------------------
  1683.   # ● 描画值槽区域
  1684.   #--------------------------------------------------------------------------
  1685.   def draw_gauge_area(rect, actor)
  1686.     if $data_system.opt_display_tp
  1687.       draw_gauge_area_with_tp(rect, actor)
  1688.     else
  1689.       draw_gauge_area_without_tp(rect, actor)
  1690.     end
  1691.   end
  1692.   #--------------------------------------------------------------------------
  1693.   # ● 描画值槽区域(包括 TP 值)
  1694.   #--------------------------------------------------------------------------
  1695.   def draw_gauge_area_with_tp(rect, actor)
  1696.     draw_actor_hp(actor, rect.x + 0, rect.y, 72)
  1697.     draw_actor_mp(actor, rect.x + 82, rect.y, 64)
  1698.     draw_actor_tp(actor, rect.x + 156, rect.y, 64)
  1699.   end
  1700.   #--------------------------------------------------------------------------
  1701.   # ● 描画值槽区域(不包括 TP 值)
  1702.   #--------------------------------------------------------------------------
  1703.   def draw_gauge_area_without_tp(rect, actor)
  1704.     draw_actor_hp(actor, rect.x + 0, rect.y, 134)
  1705.     draw_actor_mp(actor, rect.x + 144,  rect.y, 76)
  1706.   end
  1707. end

  1708. #==============================================================================
  1709. # ■ Sprite_Battler
  1710. #==============================================================================
  1711. class Sprite_Battler < Sprite_Base
  1712.   include Hzhj::HorizontalBattleSystem
  1713.   #--------------------------------------------------------------------------
  1714.   # ● 初始化(追加定义)
  1715.   #--------------------------------------------------------------------------
  1716.   alias hzhj_old_init_for_dynamic_spr_battler initialize
  1717.   def initialize(viewport, battler = nil)
  1718.     hzhj_old_init_for_dynamic_spr_battler(viewport, battler)
  1719.     @dynamic_duration = 0
  1720.     @dynamic_duration_max = DynamicPatternMax * OnePatternDuration
  1721.   end
  1722.   #--------------------------------------------------------------------------
  1723.   # ● 源位图(Source Bitmap)的更新(重定义)
  1724.   #--------------------------------------------------------------------------
  1725.   def update_bitmap
  1726.     new_bitmap = Cache.battler(@battler.battler_name, @battler.battler_hue)
  1727.     if bitmap != new_bitmap
  1728.       self.bitmap = new_bitmap
  1729.       init_visibility
  1730.       @dynamic_duration = 0
  1731.       @sx = 0
  1732.       @sw = bitmap.width / DynamicPatternMax
  1733.       @sh = bitmap.height
  1734.       self.ox = @sw / 2
  1735.       self.oy = @sh
  1736.       src_rect.set(@sx, 0, @sw, @sh)
  1737.     end
  1738.   end
  1739.   #--------------------------------------------------------------------------
  1740.   # ● 原点的更新(重定义)
  1741.   #--------------------------------------------------------------------------
  1742.   def update_origin
  1743.     if bitmap
  1744.       @dynamic_duration += 1
  1745.       @dynamic_duration %= @dynamic_duration_max
  1746.       @sx = @dynamic_duration / OnePatternDuration * @sw
  1747.       src_rect.set(@sx, 0, @sw, @sh)
  1748.     end
  1749.   end
  1750.   #--------------------------------------------------------------------------
  1751.   # ● 返回普通设定(追加定义)
  1752.   #--------------------------------------------------------------------------
  1753.   alias hzhj_old_revert_to_normal_for_dynamic_spr_battler revert_to_normal
  1754.   def revert_to_normal
  1755.     hzhj_old_revert_to_normal_for_dynamic_spr_battler
  1756.     self.ox = @sw / 2 if bitmap
  1757.   end
  1758.   #--------------------------------------------------------------------------
  1759.   # ● BOSS 战败(崩坏)效果的更新(追加定义)
  1760.   #--------------------------------------------------------------------------
  1761.   alias hzhj_old_update_boss_col_for_dynamic_spr_battler update_boss_collapse
  1762.   def update_boss_collapse
  1763.     hzhj_old_update_boss_col_for_dynamic_spr_battler
  1764.     self.ox = @sw / 2 + @effect_duration % 2 * 4 - 2
  1765.   end
  1766. end

  1767. #==============================================================================
  1768. # ■ Game_Battler
  1769. #==============================================================================
  1770. class Game_Battler < Game_BattlerBase
  1771.   def set_normal_battler_name
  1772.     @battler_name = @battler_name.split(/★/)[0]
  1773.   end
  1774.   def set_beaten_battler_name
  1775.     if guard?
  1776.       if (UseActorGuardGraphic && actor?) or
  1777.          (UseEnemyGuardGraphic && enemy?)
  1778.         set_guard_battler_name
  1779.         return
  1780.       end
  1781.     end
  1782.     @battler_name = @battler_name.split(/★/)[0] + "★1"
  1783.     if UseActorWBSE && actor?
  1784.       Audio.se_play("Audio/SE/AWBSE_#{id}", 100, 100)
  1785.     elsif UseEnemyWBSE && enemy?
  1786.       Audio.se_play("Audio/SE/EWBSE_#{enemy_id}", 100, 100)
  1787.     end
  1788.   end
  1789.   def set_dead_battler_name
  1790.     @battler_name = @battler_name.split(/★/)[0] + "★2"
  1791.   end
  1792.   def set_guard_battler_name
  1793.     @battler_name = @battler_name.split(/★/)[0] + "★3"
  1794.     if UseActorGDSE && actor?
  1795.       Audio.se_play("Audio/SE/AGDSE_#{id}", 100, 100)
  1796.     elsif UseEnemyGDSE && enemy?
  1797.       Audio.se_play("Audio/SE/EGDSE_#{enemy_id}", 100, 100)
  1798.     end
  1799.   end
  1800. end
  1801. #==============================================================================
  1802. # ■ Sprite_Battler
  1803. #==============================================================================
  1804. class Sprite_Battler < Sprite_Base
  1805.   #--------------------------------------------------------------------------
  1806.   # ● 初始化(追加定义)
  1807.   #--------------------------------------------------------------------------
  1808.   alias hzhj_old_init_for_dead_spr_battler initialize
  1809.   def initialize(viewport, battler = nil)
  1810.     hzhj_old_init_for_dead_spr_battler(viewport, battler)
  1811.     @dead_graphic_used = false
  1812.     if @battler
  1813.       @battler.set_normal_battler_name
  1814.       if @battler.dead?
  1815.         if (UseActorDeadGraphic && @battler.actor?) or
  1816.            (UseEnemyDeadGraphic && @battler.enemy?)
  1817.           @battler.set_dead_battler_name
  1818.           @dead_graphic_used = true
  1819.         end
  1820.       end
  1821.     end
  1822.     @beaten_duration = -1
  1823.   end
  1824.   #--------------------------------------------------------------------------
  1825.   # ● 设置战斗者(追加定义)
  1826.   #--------------------------------------------------------------------------
  1827.   alias hzhj_old_set_battler_for_dead_spr_battler battler=
  1828.   def battler=(value)
  1829.     if @battler != value
  1830.       @dead_graphic_used = false
  1831.       if value
  1832.         value.set_normal_battler_name
  1833.         if value.dead?
  1834.           if (UseActorDeadGraphic && value.actor?) or
  1835.              (UseEnemyDeadGraphic && value.enemy?)
  1836.             value.set_dead_battler_name
  1837.             @dead_graphic_used = true
  1838.           end
  1839.         end
  1840.       end
  1841.       @beaten_duration = -1
  1842.     end
  1843.     hzhj_old_set_battler_for_dead_spr_battler(value)
  1844.   end
  1845.   #--------------------------------------------------------------------------
  1846.   # ● 源位图(Source Bitmap)的更新(重定义)
  1847.   #--------------------------------------------------------------------------
  1848.   alias hzhj_old_update_bitmap_for_was_beaten_spr_battler update_bitmap
  1849.   def update_bitmap
  1850.     if @beaten_duration > 0
  1851.       @beaten_duration -= 1
  1852.     elsif @beaten_duration == 0
  1853.       @beaten_duration = -1
  1854.       set_bitmap(:normal)
  1855.     end
  1856.     hzhj_old_update_bitmap_for_was_beaten_spr_battler
  1857.   end
  1858.   #--------------------------------------------------------------------------
  1859.   # ● 初始化可视状态(追加定义)
  1860.   #--------------------------------------------------------------------------
  1861.   alias hzhj_old_visibility_for_dead_spr_battler init_visibility
  1862.   def init_visibility
  1863.     hzhj_old_visibility_for_dead_spr_battler
  1864.     if @battler.dead?
  1865.       if (UseActorDeadGraphic && @battler.actor?) or
  1866.          (UseEnemyDeadGraphic && @battler.enemy?)
  1867.         self.opacity = 255
  1868.       end
  1869.     end
  1870.   end
  1871.   #--------------------------------------------------------------------------
  1872.   # ● 效果开始(追加定义)
  1873.   #--------------------------------------------------------------------------
  1874.   alias hzhj_old_start_effect_for_dead_spr_battler start_effect
  1875.   def start_effect(effect_type)
  1876.     if effect_type == :appear
  1877.       if @dead_graphic_used
  1878.         set_bitmap(:normal)
  1879.         @effect_type = nil
  1880.         @effect_duration = 0
  1881.         @dead_graphic_used = false
  1882.         @battler_visible = true
  1883.         return
  1884.       end
  1885.     elsif effect_type == :collapse or
  1886.           effect_type == :boss_collapse or
  1887.           effect_type == :instant_collapse
  1888.       if @beaten_duration >= 0
  1889.         @beaten_duration = -1
  1890.         set_bitmap(:normal)
  1891.       end
  1892.       if (UseActorDeadGraphic && @battler.actor?) or
  1893.          (UseEnemyDeadGraphic && @battler.enemy?)
  1894.         set_bitmap(:dead)
  1895.         @effect_type = nil
  1896.         @effect_duration = 0
  1897.         @dead_graphic_used = true
  1898.         @battler_visible = false
  1899.         return
  1900.       end
  1901.     end
  1902.     hzhj_old_start_effect_for_dead_spr_battler(effect_type)
  1903.   end
  1904.   #--------------------------------------------------------------------------
  1905.   # ● 设置新的位图(新增定义)
  1906.   #--------------------------------------------------------------------------
  1907.   def set_bitmap(sym)
  1908.     case sym
  1909.     when :normal
  1910.       @battler.set_normal_battler_name
  1911.     when :was_beaten
  1912.       @battler.set_beaten_battler_name
  1913.     when :dead
  1914.       @battler.set_dead_battler_name
  1915.     else
  1916.       return
  1917.     end
  1918.     new_bitmap = Cache.battler(@battler.battler_name, @battler.battler_hue)
  1919.     if bitmap != new_bitmap
  1920.       self.bitmap = new_bitmap
  1921.       @dynamic_duration = 0
  1922.       @sx = 0
  1923.       @sw = bitmap.width / DynamicPatternMax
  1924.       @sh = bitmap.height
  1925.       self.ox = @sw / 2
  1926.       self.oy = @sh
  1927.       src_rect.set(@sx, 0, @sw, @sh)
  1928.     end
  1929.     update_origin
  1930.     update_position
  1931.   end
  1932. end

  1933. #==============================================================================
  1934. # ■ Scene_Battle
  1935. #==============================================================================
  1936. class Scene_Battle < Scene_Base
  1937.   #--------------------------------------------------------------------------
  1938.   # ● 发动技能/物品(新增定义)
  1939.   #--------------------------------------------------------------------------
  1940.   def hzhj_invoke_item(target, item, damage_target)
  1941.     refresh_status
  1942.     @log_window.display_action_results(damage_target, item)
  1943.     @subject.damage_section_displayed = false
  1944.     @subject.last_target_index = target.index
  1945.     return if target.dead?
  1946.     if rand < target.item_cnt(@subject, item)
  1947.       hzhj_invoke_counter_attack(target, item)
  1948.     elsif rand < target.item_mrf(@subject, item)
  1949.       hzhj_invoke_magic_reflection(target, item)
  1950.     end
  1951.   end
  1952.   #--------------------------------------------------------------------------
  1953.   # ● 发动物理反击(新增定义)
  1954.   #--------------------------------------------------------------------------
  1955.   def hzhj_invoke_counter_attack(target, item)
  1956.     @log_window.display_counter(target, item)
  1957.     attack_skill = $data_skills[target.attack_skill_id]
  1958.     @subject.item_apply(target, attack_skill)
  1959.     need_move = false
  1960.     animation1 = $data_animations[target.animation1_id]
  1961.     need_move = animation1.need_move if animation1
  1962.     ary = [@subject]
  1963.     if need_move
  1964.       target.setup_move_info(@subject, RealMoveDuration, animation1.move_se)
  1965.       wait_for_move
  1966.     end
  1967.     @subject.damage_section_displayed = false
  1968.     @subject.not_damage_section = false
  1969.     show_subject_animation(target.animation1_id, target)
  1970.     show_normal_animation(ary, target.atk_animation_id1, false)
  1971.     show_normal_animation(ary, target.atk_animation_id2, true)
  1972.     @log_window.wait
  1973.     wait_for_animation
  1974.     if need_move && target.alive?
  1975.       target.come_back_self_position(RealMoveDuration)
  1976.       wait_for_move
  1977.     end
  1978.     refresh_status
  1979.     @log_window.display_action_results(@subject, attack_skill)
  1980.   end
  1981.   #--------------------------------------------------------------------------
  1982.   # ● 发动魔法反射(新增定义)
  1983.   #--------------------------------------------------------------------------
  1984.   def hzhj_invoke_magic_reflection(target, item)
  1985.     @subject.damage_section_displayed = false
  1986.     @subject.not_damage_section = false
  1987.     @log_window.display_reflection(target, item)
  1988.     @subject.item_apply(@subject, item)
  1989.     refresh_status
  1990.     @log_window.display_action_results(@subject, item)
  1991.   end
  1992. end

  1993. #==============================================================================
  1994. # ■ Game_Battler
  1995. #==============================================================================
  1996. class Game_Battler < Game_BattlerBase
  1997.   attr_accessor :damage_section_displayed
  1998.   attr_accessor :not_damage_section
  1999. end
  2000. #==============================================================================
  2001. # ■ Game_Actor
  2002. #==============================================================================
  2003. class Game_Actor < Game_Battler
  2004.   #--------------------------------------------------------------------------
  2005.   # ● 执行伤害效果
  2006.   #--------------------------------------------------------------------------
  2007.   alias hzhj_old_per_damage_for_damage_section_game_actor perform_damage_effect
  2008.   def perform_damage_effect
  2009.     unless damage_section_displayed
  2010.       hzhj_old_per_damage_for_damage_section_game_actor
  2011.     end
  2012.   end
  2013. end
  2014. #==============================================================================
  2015. # ■ Game_Enemy
  2016. #==============================================================================
  2017. class Game_Enemy < Game_Battler
  2018.   #--------------------------------------------------------------------------
  2019.   # ● 执行伤害效果
  2020.   #--------------------------------------------------------------------------
  2021.   alias hzhj_old_per_damage_for_damage_section_game_enemy perform_damage_effect
  2022.   def perform_damage_effect
  2023.     unless damage_section_displayed
  2024.       hzhj_old_per_damage_for_damage_section_game_enemy
  2025.     end
  2026.   end
  2027. end
  2028. #==============================================================================
  2029. # ■ Sprite_Battler
  2030. #==============================================================================
  2031. class Sprite_Battler < Sprite_Base
  2032.   #--------------------------------------------------------------------------
  2033.   # ● SE 和闪烁时机的处理
  2034.   #--------------------------------------------------------------------------
  2035.   def animation_process_timing(timing)
  2036.     if timing.se.name == DamageSectionDisplaySEName
  2037.       hp_value = @battler.result.hp_damage
  2038.       mp_value = @battler.result.mp_damage
  2039.       tp_value = @battler.result.tp_damage
  2040.       value = args = nil
  2041.       was_beaten = false
  2042.       if hp_value != 0 && !@battler.not_damage_section
  2043.         was_beaten = true if hp_value > 0
  2044.         value = hp_value * timing.flash_color.red.to_i / 100
  2045.         critical = @battler.result.critical
  2046.         args = [:hp, value, critical]
  2047.       elsif mp_value != 0 && !@battler.not_damage_section
  2048.         was_beaten = true if mp_value > 0
  2049.         value = mp_value * timing.flash_color.red.to_i / 100
  2050.         critical = @battler.result.critical
  2051.         args = [:mp, value, critical]
  2052.       elsif tp_value != 0 && !@battler.not_damage_section
  2053.         was_beaten = true if tp_value > 0
  2054.         value = tp_value * timing.flash_color.red.to_i / 100
  2055.         critical = @battler.result.critical
  2056.         args = [:tp, value, critical]
  2057.       end
  2058.       if value && args
  2059.         args[3] = @battler.actor? ? :actor : (@battler.enemy? ? :enemy : nil)
  2060.         @battler.damage_section_displayed = true
  2061.         start_damage(args)
  2062.         if UseBeatenGraphic && was_beaten
  2063.           set_bitmap(:was_beaten)
  2064.           @beaten_duration = BeatenGraphicDuration
  2065.         end
  2066.       end
  2067.       return
  2068.     end
  2069.     super(timing)
  2070.   end
  2071. end
  2072. #==============================================================================
  2073. # ■ Scene_Battle
  2074. #==============================================================================
  2075. class Scene_Battle < Scene_Base
  2076.   #--------------------------------------------------------------------------
  2077.   # ● 应用技能/物品效果(新增定义)
  2078.   #--------------------------------------------------------------------------
  2079.   def hzhj_apply_item_effects(target, item)
  2080.     target.damage_section_displayed = false
  2081.     target.not_damage_section = false
  2082.     target = apply_substitute(target, item)
  2083.     target.damage_section_displayed = false
  2084.     target.not_damage_section = false
  2085.     target.item_apply(@subject, item)
  2086.     return target
  2087.   end
  2088. end
  2089. #==============================================================================
  2090. # ■ 此脚本来自 [url]www.66rpg.com[/url]
  2091. #================================================
复制代码
回复

使用道具 举报

梦石
0
星屑
9973
在线时间
1649 小时
注册时间
2012-6-6
回帖
306
发表于 2017-1-9 22:43:19 | 显示全部楼层
2@3Z`352J4C9J8LFJPNJD}V.png


看见没有,把4改成8就OK了

评分

参与人数 1星屑 +150 收起 理由
RaidenInfinity + 150 认可答案,不过直接改默认脚本不太好.

查看全部评分

回复

使用道具 举报

梦石
0
星屑
50
在线时间
40 小时
注册时间
2011-7-23
回帖
46
 楼主| 发表于 2017-1-9 22:57:52 | 显示全部楼层
感谢 ,我马上试一下
回复

使用道具 举报

梦石
0
星屑
50
在线时间
40 小时
注册时间
2011-7-23
回帖
46
 楼主| 发表于 2017-1-9 23:01:25 | 显示全部楼层
大神 ,膜拜你,太棒了。。另外请教 一下,我想引入前锋、中军、阵型的概念,该用哪个插件呢?
比如敌人必须先打我的前排人员,打死了,然后才能殴打我的后排人员。。请教下@流浪杰哥
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部