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

Project1

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

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

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
40 小时
注册时间
2011-7-23
帖子
55
跳转到指定楼层
1
发表于 2017-1-3 21:50:20 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

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

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

点评

用一下代碼框!  发表于 2017-1-3 22:35

Lv1.梦旅人

梦石
0
星屑
50
在线时间
40 小时
注册时间
2011-7-23
帖子
55
2
 楼主| 发表于 2017-1-3 21:51:29 | 只看该作者
本帖最后由 RaidenInfinity 于 2017-1-3 22:44 编辑

RUBY 代码复制
  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号角色无法显示动画及本身!!!像隐形人,能够殴打敌人,,,但是看不见!什么鬼。。求教指点
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
40 小时
注册时间
2011-7-23
帖子
55
3
 楼主| 发表于 2017-1-3 21:51:53 | 只看该作者
本帖最后由 RaidenInfinity 于 2017-1-3 22:45 编辑

RUBY 代码复制
  1. ==============================================================================
  2. # ■ 此脚本来自 [url]www.66rpg.com[/url]
  3. #------------------------------------------------------------------------------
  4. #   名称:横版战斗模板
  5. #   作者:后知后觉([email][email protected][/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.  
  17. module Hzhj
  18.   module HorizontalBattleSystem
  19.     # 取得参战角色的最大数.如果要改大.需要在下面的坐标设置里增加对应的条目
  20.     #(存在bug,即使将MaxBattleMembers值改为8,5-8号队员会参加战斗,但无任何图形显示)
  21.      MaxBattleMembers = 8
  22.  
  23.     ActorsBattlePosition = {}
  24.     # 设置角色战斗图形的坐标
  25.     # 等号左边的[]号里面的1 2 3 4 表示角色在队伍里的位置
  26.     # 等号右边的[]号里面的两个数字分别表示 X坐标 Y坐标
  27.     # 每次进入战斗的时候都会以这里设置的信息作为初始化位置.
  28.     # 如果你把上面的 MaxBattleMembers 改大了.比如改成了 5.
  29.     # 那么你需要在下面新增一行代码设置队伍中第5位置的坐标.
  30.     # 就像这样 ActorsBattlePosition[5] = [X坐标, Y坐标]
  31.     ActorsBattlePosition[1] = [600, 400]
  32.     ActorsBattlePosition[2] = [600, 300]
  33.     ActorsBattlePosition[3] = [500, 400]
  34.         ActorsBattlePosition[4] = [500, 300]
  35.     ActorsBattlePosition[5] = [300, 200]
  36.     ActorsBattlePosition[6] = [550, 300]
  37.     ActorsBattlePosition[7] = [400, 400]
  38.     ActorsBattlePosition[8] = [400, 300]
  39.  
  40.  
  41.  
  42.     # 设置伤害值图形的色相 取值范围 0~360
  43.     DamageBitmapHue = 0
  44.     # 伤害值分段显示的标志SE文件名
  45.     DamageSectionDisplaySEName = "DamageSection"
  46.  
  47.     # 动画 Z 坐标值默认变化量
  48.     DefaultAniAddZ = 768
  49.  
  50.     # 状态动画 Z 坐标值默认变化量
  51.     DefaultLoopAniAddZ = 20
  52.  
  53.     # 战斗中角色的面向
  54.     ActorDirection = 4
  55.  
  56.     # 真位移的帧数
  57.     RealMoveDuration = 20
  58.     # 真位移移动前会计算目标点.会获取攻防双方战斗图大小来进行计算.
  59.     # 下面2个是对战斗图 width height 进行修正.
  60.     # 为正则扩大 为负则缩小.单位 像素.
  61.     # 一般来说不必修改.只有像梦幻群侠传那种战斗图四边有很多透明区域时才修正.
  62.     RealMoveBmpAddW = 0
  63.     RealMoveBmpAddH = 0
  64.  
  65.     # 使用技能、物品的过程默认使用RMVA模式
  66.     # 在该模式下.本脚本提供的很多功能受限无法使用.
  67.     DefaultUseRmvaMode = false
  68.  
  69.     # 默认显示敌人的HP条、MP条、TP条
  70.     DefaultDisplayEnemyBar = true
  71.  
  72.     # 一张战斗图中有几个样式(帧、格)
  73.     DynamicPatternMax = 4
  74.     # 一张战斗图中的一个样式持续多少帧
  75.     OnePatternDuration = 15
  76.  
  77.     # 角色使用战斗死亡图形
  78.     UseActorDeadGraphic = true
  79.     # 敌人使用战斗死亡图形
  80.     UseEnemyDeadGraphic = true
  81.  
  82.     # 使用挨打图形
  83.     UseBeatenGraphic = true
  84.     # 挨打图形维持帧数
  85.     BeatenGraphicDuration = 30
  86.  
  87.     # 是否使用角色防御图 只有同时使用了挨打图.此项才有效.
  88.     UseActorGuardGraphic = true
  89.     # 是否使用敌人防御图 只有同时使用了挨打图.此项才有效.
  90.     UseEnemyGuardGraphic = false
  91.  
  92.     # 角色是否使用挨打SE
  93.     UseActorWBSE = true
  94.     # 敌人是否使用挨打SE
  95.     UseEnemyWBSE = true
  96.     # 角色是否使用防御SE
  97.     UseActorGDSE = true
  98.     # 敌人是否使用防御SE
  99.     UseEnemyGDSE = false
  100.   end
  101. end
  102.  
  103. class RPG::Actor < RPG::BaseItem
  104.   def battler_name
  105.     return @battler_name unless @battler_name.nil?
  106.     if /@btname\[(.+?)\]/ =~ @note
  107.       return (@battler_name = $1.clone)
  108.     else
  109.       return (@battler_name = "#{@name}_#{@nickname}")
  110.     end
  111.   end
  112.   def battler_hue
  113.     return @battler_hue unless @battler_hue.nil?
  114.     if /@bthue\[([0-9]+?)\]/ =~ @note
  115.       return (@battler_hue = $1.to_i.abs)
  116.     else
  117.       return (@battler_hue = 0)
  118.     end
  119.   end
  120.   attr_writer :battler_name
  121.   attr_writer :battler_hue
  122. end
  123. #==============================================================================
  124. # ■ Game_Actor
  125. #==============================================================================
  126. class Game_Actor < Game_Battler
  127.   #--------------------------------------------------------------------------
  128.   # ● 属性(新增定义)
  129.   #--------------------------------------------------------------------------
  130.   attr_writer   :battler_name             # 战斗图形文件名
  131.   attr_writer   :battler_hue              # 战斗图形色相
  132.   #--------------------------------------------------------------------------
  133.   # ● 设置(追加定义)
  134.   #--------------------------------------------------------------------------
  135.   alias hzhj_old_setup_for_add_actor_battle_graphic setup
  136.   def setup(actor_id)
  137.     hzhj_old_setup_for_add_actor_battle_graphic(actor_id)
  138.     @battler_name = actor.battler_name
  139.     @battler_hue = actor.battler_hue
  140.   end
  141.   #--------------------------------------------------------------------------
  142.   # ● 是否使用活动块(重定义)
  143.   #--------------------------------------------------------------------------
  144.   def use_sprite?
  145.     return true
  146.   end
  147.   #--------------------------------------------------------------------------
  148.   # ● 取得战斗画面 X 坐标(新增定义)
  149.   #--------------------------------------------------------------------------
  150.   def screen_x
  151.     return ActorsBattlePosition[index + 1][0]
  152.   end
  153.   #--------------------------------------------------------------------------
  154.   # ● 取得战斗画面 Y 坐标(新增定义)
  155.   #--------------------------------------------------------------------------
  156.   def screen_y
  157.     return ActorsBattlePosition[index + 1][1]
  158.   end
  159.   #--------------------------------------------------------------------------
  160.   # ● 取得战斗画面 Z 坐标(新增定义)
  161.   #--------------------------------------------------------------------------
  162.   def screen_z
  163.     return real_screen_y + 100
  164.   end
  165. end
  166. #==============================================================================
  167. # ■ Game_Enemy
  168. #==============================================================================
  169. class Game_Enemy < Game_Battler
  170.   #--------------------------------------------------------------------------
  171.   # ● 属性(新增定义)
  172.   #--------------------------------------------------------------------------
  173.   attr_writer   :battler_name             # 战斗图形文件名
  174.   attr_writer   :battler_hue              # 战斗图形色相
  175.   #--------------------------------------------------------------------------
  176.   # ● 取得战斗画面 Z 坐标(重定义)
  177.   #--------------------------------------------------------------------------
  178.   def screen_z
  179.     return real_screen_y + 100
  180.   end
  181. end
  182. #==============================================================================
  183. # ■ Game_Party
  184. #==============================================================================
  185. class Game_Party < Game_Unit
  186.   include Hzhj::HorizontalBattleSystem
  187.   #--------------------------------------------------------------------------
  188.   # ● 取得参战角色的最大数(重定义),貌似存在bug,可以8人上场,但并不被显示
  189.  
  190.   #--------------------------------------------------------------------------
  191.   def max_battle_members
  192.    return MaxBattleMembers
  193.   end
  194. end
  195.  
  196. class RPG::Animation
  197.   def wait_subject_duration
  198.     return @wait_subject_duration unless @wait_subject_duration.nil?
  199.     if /@w\[(\-??\d+?)\]/ =~ @name
  200.       @wait_subject_duration = $1.to_i
  201.     else
  202.       @wait_subject_duration = 0
  203.     end
  204.     return @wait_subject_duration
  205.   end
  206.   attr_writer :wait_subject_duration
  207. end
  208. class RPG::UsableItem < RPG::BaseItem
  209.   include Hzhj::HorizontalBattleSystem
  210.   def animation1_id
  211.     return @animation1_id unless @animation1_id.nil?
  212.     if /@a1id\[(\d+?)\]/i =~ @note
  213.       return (@animation1_id = $1.to_i)
  214.     else
  215.       return (@animation1_id = 0)
  216.     end
  217.   end
  218.   def wljn
  219.     return @wljn unless @wljn.nil?
  220.     if /@wljn/i =~ @note
  221.       return (@wljn = true)
  222.     else
  223.       return (@wljn = false)
  224.   end
  225.   end
  226.   def rmva_mode
  227.     return @rmva_mode unless @rmva_mode.nil?
  228.     if /@rmva/i =~ @note
  229.       return (@rmva_mode = !DefaultUseRmvaMode)
  230.     else
  231.       return (@rmva_mode = DefaultUseRmvaMode)
  232.     end
  233.   end
  234.   attr_writer :animation1_id
  235.   attr_writer :wljn
  236.   attr_writer :rmva_mode
  237. end
  238. class RPG::Weapon < RPG::EquipItem
  239.   def animation1_id
  240.    return @animation1_id unless @animation1_id.nil?
  241.     if /@a1id\[(\d+?)\]/ =~ @note
  242.       return (@animation1_id = $1.to_i)
  243.    else
  244.       return (@animation1_id = 0)
  245.     end
  246.   end
  247.   attr_writer :animation1_id
  248. end
  249. class RPG::Enemy < RPG::BaseItem
  250.   def animation1_id
  251.     return @animation1_id unless @animation1_id.nil?
  252.     if /@a1id\[(\d+?)\]/ =~ @note
  253.       return (@animation1_id = $1.to_i)
  254.     else
  255.       return (@animation1_id = 0)
  256.    end
  257.   end
  258.   def animation2_id
  259.     return @animation2_id unless @animation2_id.nil?
  260.     if /@a2id\[(\d+?)\]/ =~ @note
  261.       return (@animation2_id = $1.to_i)
  262.     else
  263.       return (@animation2_id = 0)
  264.     end
  265.   end
  266.   def animation3_id  
  267.     return @animation3_id unless @animation3_id.nil?
  268.     if /@a3id\[(\d+?)\]/ =~ @note
  269.       return (@animation3_id = $1.to_i)
  270.     else
  271.       return (@animation3_id = 0)
  272.     end
  273.   end
  274.   attr_writer :animation1_id
  275.   attr_writer :animation2_id
  276.   attr_writer :animation3_id
  277. end
  278. #==============================================================================
  279. # ■ Game_Actor
  280. #==============================================================================
  281. class Game_Actor < Game_Battler
  282.   #--------------------------------------------------------------------------
  283.   # ● 取得普通攻击的行动方动画 ID (新增定义)
  284.   #--------------------------------------------------------------------------
  285.   def animation1_id
  286.     if dual_wield?
  287.       return weapons[0].animation1_id if weapons[0]
  288.       return weapons[1] ? weapons[1].animation1_id : 0
  289.     else
  290.       return weapons[0] ? weapons[0].animation1_id : 0
  291.     end
  292.   end
  293. end
  294. #==============================================================================
  295. # ■ Game_Enemy
  296. #==============================================================================
  297. class Game_Enemy < Game_Battler
  298.   #--------------------------------------------------------------------------
  299.   # ● 取得普通攻击的行动方动画 ID (新增定义)
  300.   #--------------------------------------------------------------------------
  301.   def animation1_id
  302.     return enemy.animation1_id
  303.   end
  304.   #--------------------------------------------------------------------------
  305.   # ● 取得普通攻击的动画 ID (新增定义)
  306.   #--------------------------------------------------------------------------
  307.   def atk_animation_id1
  308.     return enemy.animation2_id
  309.   end
  310.   #--------------------------------------------------------------------------
  311.   # ● 取得普通攻击的动画 ID (二刀流:武器2)(新增定义)
  312.   #--------------------------------------------------------------------------
  313.   def atk_animation_id2
  314.     return enemy.animation3_id
  315.   end
  316. end
  317. #==============================================================================
  318. # ■ Scene_Battle
  319. #==============================================================================
  320. class Scene_Battle < Scene_Base
  321.   include Hzhj::HorizontalBattleSystem
  322.   #--------------------------------------------------------------------------
  323.   # ● 使用技能/物品(重定义)
  324.   #--------------------------------------------------------------------------
  325.   def use_item
  326.     item = @subject.current_action.item
  327.     @log_window.display_use_item(@subject, item)
  328.     @subject.use_item(item)
  329.     refresh_status
  330.     targets = @subject.current_action.make_targets.compact
  331.     show_animation(targets, item.animation_id)
  332.   end
  333.   #--------------------------------------------------------------------------
  334.   # ● 显示动画(重定义)
  335.   #--------------------------------------------------------------------------
  336.   def show_animation(targets, animation_id)
  337.     item = @subject.current_action.item
  338.     if item.rmva_mode
  339.       show_rmva_animation(targets, animation_id, item)
  340.     else
  341.       show_hzhj_animation(targets, animation_id, item)
  342.     end
  343.   end
  344.   #--------------------------------------------------------------------------
  345.   # ● RMVA模式显示动画(新增定义)
  346.   #--------------------------------------------------------------------------
  347.   def show_rmva_animation(targets, animation_id, item)
  348.     @subject.damage_section_displayed = false
  349.     @subject.not_damage_section = true
  350.     targets.each do |target|
  351.       target.damage_section_displayed = false
  352.       target.not_damage_section = true
  353.     end
  354.     if animation_id < 0
  355.       show_attack_animation(targets)
  356.     else
  357.       show_rmva_usable_animation(targets, animation_id, item)
  358.     end
  359.   end
  360.   #--------------------------------------------------------------------------
  361.   # ● HZHJ模式显示动画(新增定义)
  362.   #--------------------------------------------------------------------------
  363.   def show_hzhj_animation(targets, animation_id, item)
  364.     if animation_id < 0
  365.       show_hzhj_attack_animation(targets, item)
  366.     else
  367.       if item.wljn
  368.         show_wljn_skill_animation(targets, animation_id, item)
  369.       else
  370.         show_magic_skill_animation(targets, animation_id, item)
  371.       end
  372.     end
  373.   end
  374.   #--------------------------------------------------------------------------
  375.   # ● HZHJ模式显示攻击动画(重定义)
  376.   #--------------------------------------------------------------------------
  377.   def show_hzhj_attack_animation(targets, item)
  378.     ary = []
  379.     need_move = false
  380.     animation1 = $data_animations[@subject.animation1_id]
  381.     need_move = animation1.need_move if animation1
  382.     come_back = true
  383.     targets.each_with_index do |target, i|
  384.       ary[0] = target
  385.       item.repeats.times do
  386.         next if target.dead? && item.damage.type == 1
  387.         next if @subject.dead?
  388.         next if !@subject.current_action
  389.         if need_move && come_back
  390.           come_back = false
  391.           @subject.setup_move_info(target, RealMoveDuration, animation1.move_se)
  392.           wait_for_move
  393.         end
  394.         damage_target = hzhj_apply_item_effects(target, item)
  395.         show_subject_animation(@subject.animation1_id)
  396.         show_normal_animation(ary, @subject.atk_animation_id1, false)
  397.         show_normal_animation(ary, @subject.atk_animation_id2, true)
  398.         @log_window.wait
  399.         wait_for_animation
  400.         hzhj_invoke_item(target, item, damage_target)
  401.       end
  402.       if need_move
  403.         if target != targets[i+1] or target.dead?
  404.           come_back = true
  405.           @subject.come_back_self_position(RealMoveDuration)
  406.           wait_for_move
  407.         else
  408.           come_back = false
  409.         end
  410.       end
  411.     end
  412.   end
  413.   #--------------------------------------------------------------------------
  414.   # ● HZHJ模式显示物理技能类动画(新增定义)
  415.   #--------------------------------------------------------------------------
  416.   def show_wljn_skill_animation(targets, animation_id, item)
  417.     ary = []
  418.     need_move = false
  419.     animation1 = $data_animations[item.animation1_id]
  420.     need_move = animation1.need_move if animation1
  421.     come_back = true
  422.     targets.each_with_index do |target, i|
  423.       ary[0] = target
  424.       item.repeats.times do
  425.         next if target.dead? && item.damage.type == 1
  426.         next if @subject.dead?
  427.         next if !@subject.current_action
  428.         if need_move && come_back
  429.           come_back = false
  430.           @subject.setup_move_info(target, RealMoveDuration, animation1.move_se)
  431.           wait_for_move
  432.         end
  433.         damage_target = hzhj_apply_item_effects(target, item)
  434.         show_subject_animation(item.animation1_id)
  435.         show_normal_animation(ary, animation_id, false)
  436.         @log_window.wait
  437.         wait_for_animation
  438.         hzhj_invoke_item(target, item, damage_target)
  439.       end
  440.       if need_move
  441.         if target != targets[i+1] or target.dead?
  442.           come_back = true
  443.           @subject.come_back_self_position(RealMoveDuration)
  444.           wait_for_move
  445.         else
  446.           come_back = false
  447.         end
  448.       end
  449.     end
  450.   end
  451.   #--------------------------------------------------------------------------
  452.   # ● HZHJ模式显示魔法技能类动画(新增定义)
  453.   #--------------------------------------------------------------------------
  454.   def show_magic_skill_animation(targets, animation_id, item)
  455.     ary = []
  456.     damage_targets = {}
  457.     item.repeats.times do
  458.       next if @subject.dead?
  459.       next if !@subject.current_action
  460.       ary.clear
  461.       damage_targets.clear
  462.       targets.each do |target|
  463.         next if target.dead? && item.damage.type == 1
  464.         ary << target
  465.         damage_targets[target] = hzhj_apply_item_effects(target, item)
  466.       end
  467.       next if ary.empty?
  468.       show_subject_animation(item.animation1_id)
  469.       show_normal_animation(ary, animation_id)
  470.       @log_window.wait
  471.       wait_for_animation
  472.       ary.each do |target|
  473.         hzhj_invoke_item(target, item, damage_targets[target])
  474.       end
  475.       if [9, 10].include?(item.scope)
  476.         ary.each do |target|
  477.           if target.alive?
  478.             target.come_back_self_position(RealMoveDuration)
  479.           end
  480.         end
  481.         wait_for_move
  482.       end
  483.     end
  484.   end
  485.   #--------------------------------------------------------------------------
  486.   # ● RMVA模式显示攻击动画(重定义)
  487.   #--------------------------------------------------------------------------
  488.   def show_attack_animation(targets)
  489.     item = @subject.current_action.item
  490.     show_subject_animation(@subject.animation1_id)
  491.     show_normal_animation(targets, @subject.atk_animation_id1, false)
  492.     show_normal_animation(targets, @subject.atk_animation_id2, true)
  493.     @log_window.wait
  494.     wait_for_animation
  495.     targets.each {|target| item.repeats.times { invoke_item(target, item) } }
  496.   end
  497.   #--------------------------------------------------------------------------
  498.   # ● RMVA模式显示技能、物品动画 (新增定义)
  499.   #--------------------------------------------------------------------------
  500.   def show_rmva_usable_animation(targets, animation_id, item)
  501.     show_subject_animation(item.animation1_id)
  502.     show_normal_animation(targets, animation_id)
  503.     @log_window.wait
  504.     wait_for_animation
  505.     targets.each {|target| item.repeats.times { invoke_item(target, item) } }
  506.     if [9, 10].include?(item.scope)
  507.       targets.each do |target|
  508.         if target.alive?
  509.           target.come_back_self_position(RealMoveDuration)
  510.         end
  511.       end
  512.       wait_for_move
  513.     end
  514.   end
  515.   #--------------------------------------------------------------------------
  516.   # ● 显示行动方动画(新增定义)
  517.   #--------------------------------------------------------------------------
  518.   def show_subject_animation(animation_id, subject = @subject, mirror = false)
  519.     animation = $data_animations[animation_id]
  520.     if animation
  521.       subject.animation_id = animation_id
  522.       subject.animation_mirror = mirror
  523.       if animation.wait_subject_duration < 0
  524.         wait_for_animation
  525.       elsif animation.wait_subject_duration > 0
  526.         animation.wait_subject_duration.times{update_for_wait}
  527.       end
  528.     end
  529.   end
  530. end
  531.  
  532. class RPG::Animation
  533.   include Hzhj::HorizontalBattleSystem
  534.   def ani_z_correction
  535.     return @ani_z_correction unless @ani_z_correction.nil?
  536.     if /@az\[(\-??\d+?)\]/ =~ @name
  537.       return (@ani_z_correction = $1.to_i)
  538.     else
  539.       return (@ani_z_correction = DefaultAniAddZ)
  540.     end
  541.   end
  542.   def loop_z_correction
  543.     return @loop_z_correction unless @loop_z_correction.nil?
  544.     if /@lz\[(\-??\d+?)\]/ =~ @name
  545.       return (@loop_z_correction = $1.to_i)
  546.     else
  547.       return (@loop_z_correction = DefaultLoopAniAddZ)
  548.     end
  549.   end
  550.   attr_writer :ani_z_correction
  551.   attr_writer :loop_z_correction
  552. end
  553. class RPG::State < RPG::BaseItem
  554.   def animation_id
  555.     return @animation_id unless @animation_id.nil?
  556.     if /@aid\[(\d+?)\]/ =~ @note
  557.       return (@animation_id = $1.to_i)
  558.     else
  559.       return (@animation_id = 0)
  560.     end
  561.   end
  562.   attr_writer :animation_id
  563. end
  564. #==============================================================================
  565. # ■ Game_BattlerBase
  566. #==============================================================================
  567. class Game_BattlerBase
  568.   #--------------------------------------------------------------------------
  569.   # ● 实例变量(新增定义)
  570.   #--------------------------------------------------------------------------
  571.   attr_reader   :hzhj_add_state_id
  572.   attr_reader   :hzhj_remove_state_id
  573.   attr_accessor :need_update_state_animation
  574.   #--------------------------------------------------------------------------
  575.   # ● 初始化(追加定义)
  576.   #--------------------------------------------------------------------------
  577.   alias hzhj_old_init_for_state_ani_game_battler_base initialize
  578.   def initialize
  579.     @hzhj_add_state_id = []
  580.     @hzhj_remove_state_id = []
  581.     @need_update_state_animation = false
  582.     @states = []
  583.     @state_turns = {}
  584.     @state_steps = {}
  585.     hzhj_old_init_for_state_ani_game_battler_base
  586.   end
  587.   #--------------------------------------------------------------------------
  588.   # ● 清除状态信息(追加定义)
  589.   #--------------------------------------------------------------------------
  590.   alias hzhj_old_clear_states_for_state_ani_game_battler_base clear_states
  591.   def clear_states
  592.     old_states = @states.clone
  593.     hzhj_old_clear_states_for_state_ani_game_battler_base
  594.     bingji = old_states | @states
  595.     return if bingji.empty?
  596.     set_add_state_id(bingji & @states)
  597.     set_remove_state_id(bingji & old_states)
  598.   end
  599.   #--------------------------------------------------------------------------
  600.   # ● 消除状态(追加定义)
  601.   #--------------------------------------------------------------------------
  602.   alias hzhj_old_erase_state_for_state_ani_game_battler_base erase_state
  603.   def erase_state(state_id)
  604.     old_states = @states.clone
  605.     hzhj_old_erase_state_for_state_ani_game_battler_base(state_id)
  606.     bingji = old_states | @states
  607.     return if bingji.empty?
  608.     set_add_state_id(bingji & @states)
  609.     set_remove_state_id(bingji & old_states)
  610.   end
  611.   #--------------------------------------------------------------------------
  612.   # ● 设置增加的状态(新增定义)
  613.   #--------------------------------------------------------------------------
  614.   def set_add_state_id(zjdzt)
  615.     for i in zjdzt
  616.       if $data_states[i].animation_id > 0
  617.         if not @hzhj_add_state_id.include?(i)
  618.           @hzhj_add_state_id.push(i)
  619.         end
  620.       end
  621.     end
  622.   end
  623.   #--------------------------------------------------------------------------
  624.   # ● 设置解除的状态(新增定义)
  625.   #--------------------------------------------------------------------------
  626.   def set_remove_state_id(jsdzt)
  627.     for i in jsdzt
  628.       if $data_states[i].animation_id > 0
  629.         if not @hzhj_remove_state_id.include?(i)
  630.           ani_id = $data_states[i].animation_id
  631.           not_end_loop_animation = false
  632.           for state in self.states
  633.             if state.animation_id == ani_id
  634.               not_end_loop_animation = true
  635.               break
  636.             end
  637.           end
  638.           unless not_end_loop_animation
  639.             @hzhj_remove_state_id.push(i)
  640.           end
  641.         end
  642.       end
  643.     end
  644.   end
  645. end
  646. #==============================================================================
  647. # ■ Game_Battler
  648. #==============================================================================
  649. class Game_Battler < Game_BattlerBase
  650.   #--------------------------------------------------------------------------
  651.   # ● 附加新的状态(追加定义)
  652.   #--------------------------------------------------------------------------
  653.   alias hzhj_old_add_new_state_for_state_ani_game_battler add_new_state
  654.   def add_new_state(state_id)
  655.     old_states = @states.clone
  656.     hzhj_old_add_new_state_for_state_ani_game_battler(state_id)
  657.     bingji = old_states | @states
  658.     return if bingji.empty?
  659.     set_add_state_id(bingji & @states)
  660.     set_remove_state_id(bingji & old_states)
  661.   end
  662. end
  663. #==============================================================================
  664. # ■ Sprite_Base
  665. #==============================================================================
  666. class Sprite_Base < Sprite
  667.   #--------------------------------------------------------------------------
  668.   # ● 初始化(追加定义)
  669.   #--------------------------------------------------------------------------
  670.   alias hzhj_old_init_for_state_ani_spr_base initialize
  671.   def initialize(*args)
  672.     hzhj_old_init_for_state_ani_spr_base(*args)
  673.     @hzhj_loop_animations = []
  674.     @hzhj_loop_durations = {}
  675.     @hzhj_loop_sprites = {}
  676.     @hzhj_loop_bitmap1s = {}
  677.     @hzhj_loop_bitmap2s = {}
  678.     @hzhj_loop_ani_oxs = {}
  679.     @hzhj_loop_ani_oys = {}
  680.     @flash_nil_duration = 0
  681.   end
  682.   #--------------------------------------------------------------------------
  683.   # ● 释放(追加定义)
  684.   #--------------------------------------------------------------------------
  685.   alias hzhj_old_dispose_for_state_ani_spr_base dispose
  686.   def dispose
  687.     dispose_loop_animation
  688.     hzhj_old_dispose_for_state_ani_spr_base
  689.   end
  690.   #--------------------------------------------------------------------------
  691.   # ● 设定动画的活动块(追加定义)
  692.   #--------------------------------------------------------------------------
  693.   alias hzhj_old_ani_set_spr_for_state_ani_spr_base animation_set_sprites
  694.   def animation_set_sprites(*args)
  695.     hzhj_old_ani_set_spr_for_state_ani_spr_base(*args)
  696.     @ani_sprites.each{|sprite|sprite.z += @animation.ani_z_correction}
  697.   end
  698.   #--------------------------------------------------------------------------
  699.   # ● 判断是否有循环动画(新增定义)
  700.   #--------------------------------------------------------------------------
  701.   def loop_animation?
  702.     return (not @hzhj_loop_animations.empty?)
  703.   end
  704.   #--------------------------------------------------------------------------
  705.   # ● 开始播放循环动画(新增定义)
  706.   #--------------------------------------------------------------------------
  707.   def start_loop_animation(animation)
  708.     return if @hzhj_loop_animations.include?(animation)
  709.     if animation.nil?
  710.       dispose_loop_animation
  711.       return
  712.     end
  713.     set_animation_rate
  714.     @hzhj_loop_animations.push(animation)
  715.     init_loop_animation_duration(animation)
  716.     load_loop_animation_bitmap(animation)
  717.     make_loop_animation_sprites(animation)
  718.     set_loop_animation_origin(animation)
  719.   end
  720.   #--------------------------------------------------------------------------
  721.   # ● 初始化循环动画播放位置(新增定义)
  722.   #--------------------------------------------------------------------------
  723.   def init_loop_animation_duration(animation)
  724.     @hzhj_loop_durations[animation] = animation.frame_max * @ani_rate + 1
  725.   end
  726.   #--------------------------------------------------------------------------
  727.   # ● 读取循环动画图像(新增定义)
  728.   #--------------------------------------------------------------------------
  729.   def load_loop_animation_bitmap(animation)
  730.     animation1_name = animation.animation1_name
  731.     animation1_hue = animation.animation1_hue
  732.     animation2_name = animation.animation2_name
  733.     animation2_hue = animation.animation2_hue
  734.     bitmap1 = Cache.animation(animation1_name, animation1_hue)
  735.     bitmap2 = Cache.animation(animation2_name, animation2_hue)
  736.     if @@_reference_count.include?(bitmap1)
  737.       @@_reference_count[bitmap1] += 1
  738.     else
  739.       @@_reference_count[bitmap1] = 1
  740.     end
  741.     if @@_reference_count.include?(bitmap2)
  742.       @@_reference_count[bitmap2] += 1
  743.     else
  744.       @@_reference_count[bitmap2] = 1
  745.     end
  746.     @hzhj_loop_bitmap1s[animation] = bitmap1
  747.     @hzhj_loop_bitmap2s[animation] = bitmap2
  748.     Graphics.frame_reset
  749.   end
  750.   #--------------------------------------------------------------------------
  751.   # ● 生成循环动画活动块(新增定义)
  752.   #--------------------------------------------------------------------------
  753.   def make_loop_animation_sprites(animation)
  754.     sprites = []
  755.     if @use_sprite
  756.       16.times do
  757.         sprite = ::Sprite.new(viewport)
  758.         sprite.visible = false
  759.         sprites.push(sprite)
  760.       end
  761.     end
  762.     @hzhj_loop_sprites[animation] = sprites
  763.   end
  764.   #--------------------------------------------------------------------------
  765.   # ● 设定循环动画的原点(新增定义)
  766.   #--------------------------------------------------------------------------
  767.   def set_loop_animation_origin(animation)
  768.     if animation.position == 3
  769.       if viewport == nil
  770.         ani_ox = Graphics.width / 2
  771.         ani_oy = Graphics.height / 2
  772.       else
  773.         ani_ox = viewport.rect.width / 2
  774.         ani_oy = viewport.rect.height / 2
  775.       end
  776.     else
  777.       ani_ox = x - ox + width / 2
  778.       ani_oy = y - oy + height / 2
  779.       if animation.position == 0
  780.         ani_oy -= height / 2
  781.       elsif animation.position == 2
  782.         ani_oy += height / 2
  783.       end
  784.     end
  785.     @hzhj_loop_ani_oxs[animation] = ani_ox
  786.     @hzhj_loop_ani_oys[animation] = ani_oy
  787.   end
  788.   #--------------------------------------------------------------------------
  789.   # ● 释放所有循环动画(新增定义)
  790.   #--------------------------------------------------------------------------
  791.   def dispose_loop_animation
  792.     return unless loop_animation?
  793.     for animation in @hzhj_loop_animations.clone
  794.       end_loop_animation(animation)
  795.     end
  796.     @hzhj_loop_durations.clear
  797.     @hzhj_loop_sprites.clear
  798.     @hzhj_loop_bitmap1s.clear
  799.     @hzhj_loop_bitmap2s.clear
  800.     @hzhj_loop_ani_oxs.clear
  801.     @hzhj_loop_ani_oys.clear
  802.     @hzhj_loop_animations.clear
  803.   end
  804.   #--------------------------------------------------------------------------
  805.   # ● 结束某个循环动画(新增定义)
  806.   #--------------------------------------------------------------------------
  807.   def end_loop_animation(animation)
  808.     return if not @hzhj_loop_animations.include?(animation)
  809.     bitmap1 = @hzhj_loop_bitmap1s[animation]
  810.     @@_reference_count[bitmap1] -= 1
  811.     if @@_reference_count[bitmap1] == 0
  812.       @@_reference_count.delete(bitmap1)
  813.       bitmap1.dispose
  814.     end
  815.     bitmap2 = @hzhj_loop_bitmap2s[animation]
  816.     @@_reference_count[bitmap2] -= 1
  817.     if @@_reference_count[bitmap2] == 0
  818.       @@_reference_count.delete(bitmap2)
  819.       bitmap2.dispose
  820.     end
  821.     sprites = @hzhj_loop_sprites[animation]
  822.     for sprite in sprites
  823.       sprite.dispose
  824.     end
  825.     @hzhj_loop_durations.delete(animation)
  826.     @hzhj_loop_sprites.delete(animation)
  827.     @hzhj_loop_bitmap1s.delete(animation)
  828.     @hzhj_loop_bitmap2s.delete(animation)
  829.     @hzhj_loop_ani_oxs.delete(animation)
  830.     @hzhj_loop_ani_oys.delete(animation)
  831.     @hzhj_loop_animations.delete(animation)
  832.   end
  833.   #--------------------------------------------------------------------------
  834.   # ● 刷新(追加定义)
  835.   #--------------------------------------------------------------------------
  836.   alias hzhj_old_update_for_state_ani_spr_base update
  837.   def update
  838.     hzhj_old_update_for_state_ani_spr_base
  839.     update_loop_animation
  840.   end
  841.   #--------------------------------------------------------------------------
  842.   # ● 刷新循环动画(新增定义)
  843.   #--------------------------------------------------------------------------
  844.   def update_loop_animation
  845.     @flash_nil_duration -= 1 if @flash_nil_duration > 0
  846.     return unless loop_animation?
  847.     for animation in @hzhj_loop_animations
  848.       @hzhj_loop_durations[animation] -= 1
  849.       duration = @hzhj_loop_durations[animation]
  850.       if duration % @ani_rate == 0
  851.         if duration > 0
  852.           set_loop_animation_origin(animation)
  853.           frame_index = animation.frame_max
  854.           frame_index -= (duration + @ani_rate - 1) / @ani_rate
  855.           args = []
  856.           args[0] = @hzhj_loop_sprites[animation]
  857.           args[1] = @hzhj_loop_bitmap1s[animation]
  858.           args[2] = @hzhj_loop_bitmap2s[animation]
  859.           args[3] = @hzhj_loop_ani_oxs[animation]
  860.           args[4] = @hzhj_loop_ani_oys[animation]
  861.           args[5] = animation.loop_z_correction
  862.           args[6] = ((not flash_nil? or animation.to_screen?) and visible)
  863.           loop_animation_set_sprites(animation.frames[frame_index], args)
  864.           animation.timings.each do |timing|
  865.             loop_animation_process_timing(timing) if timing.frame == frame_index
  866.           end
  867.         else
  868.           init_loop_animation_duration(animation)
  869.           redo
  870.         end
  871.       end
  872.     end
  873.   end
  874.   #--------------------------------------------------------------------------
  875.   # ● 设定循环动画的活动块(新增定义)
  876.   #--------------------------------------------------------------------------
  877.   def loop_animation_set_sprites(frame, args)
  878.     sprites = args[0]
  879.     bitmap1 = args[1]
  880.     bitmap2 = args[2]
  881.     ani_ox = args[3]
  882.     ani_oy = args[4]
  883.     loop_z_correction = args[5]
  884.     state_visible = args[6]
  885.     cell_data = frame.cell_data
  886.     sprites.each_with_index do |sprite, i|
  887.       next unless sprite
  888.       pattern = cell_data[i, 0]
  889.       if !pattern || pattern < 0
  890.         sprite.visible = false
  891.         next
  892.       end
  893.       sprite.bitmap = pattern < 100 ? bitmap1 : bitmap2
  894.       sprite.visible = state_visible
  895.       sprite.src_rect.set(pattern % 5 * 192,
  896.         pattern % 100 / 5 * 192, 192, 192)
  897.       sprite.x = ani_ox + cell_data[i, 1]
  898.       sprite.y = ani_oy + cell_data[i, 2]
  899.       sprite.angle = cell_data[i, 4]
  900.       sprite.mirror = (cell_data[i, 5] == 1)
  901.       if loop_z_correction > 9999
  902.         sprite.z = loop_z_correction % 10000 + i
  903.       elsif loop_z_correction < -9999
  904.         sprite.z = loop_z_correction % -10000 + i
  905.       else
  906.         sprite.z = self.z + loop_z_correction + i
  907.       end
  908.       sprite.ox = 96
  909.       sprite.oy = 96
  910.       sprite.zoom_x = cell_data[i, 3] / 100.0
  911.       sprite.zoom_y = cell_data[i, 3] / 100.0
  912.       sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  913.       sprite.blend_type = cell_data[i, 7]
  914.     end
  915.   end
  916.   #--------------------------------------------------------------------------
  917.   # ● 循环动画SE 和闪烁时机的处理(新增定义)
  918.   #--------------------------------------------------------------------------
  919.   def loop_animation_process_timing(timing)
  920.     timing.se.play
  921.     case timing.flash_scope
  922.     when 1
  923.       self.flash(timing.flash_color, timing.flash_duration * @ani_rate)
  924.     when 2
  925.       if viewport
  926.         viewport.flash(timing.flash_color, timing.flash_duration * @ani_rate)
  927.       end
  928.     when 3
  929.       self.flash(nil, timing.flash_duration * @ani_rate)
  930.     end
  931.   end
  932.   #--------------------------------------------------------------------------
  933.   # ● 设置闪烁(追加定义)
  934.   #--------------------------------------------------------------------------
  935.   alias hzhj_old_flash_for_state_ani_spr_base flash
  936.   def flash(*args)
  937.     if args[0].nil?
  938.       @flash_nil_duration = args[1]
  939.     else
  940.       @flash_nil_duration = 0
  941.     end
  942.     hzhj_old_flash_for_state_ani_spr_base(*args)
  943.   end
  944.   #--------------------------------------------------------------------------
  945.   # ● 判断是否正处于【隐藏目标】(新增定义)
  946.   #--------------------------------------------------------------------------
  947.   def flash_nil?
  948.     return (@flash_nil_duration > 0)
  949.   end
  950. end
  951. #==============================================================================
  952. # ■ Sprite_Battler
  953. #==============================================================================
  954. class Sprite_Battler < Sprite_Base
  955.   #--------------------------------------------------------------------------
  956.   # ● 初始化(追加定义)
  957.   #--------------------------------------------------------------------------
  958.   alias hzhj_old_init_for_state_ani_spr_battler initialize
  959.   def initialize(*args)
  960.     hzhj_old_init_for_state_ani_spr_battler(*args)
  961.     init_battler_add_state_id
  962.   end
  963.   #--------------------------------------------------------------------------
  964.   # ● 初始化战斗者要播放状态动画的状态(新增定义)
  965.   #--------------------------------------------------------------------------
  966.   def init_battler_add_state_id
  967.     if @battler.nil?
  968.       dispose_loop_animation
  969.     else
  970.       @battler.hzhj_add_state_id.clear
  971.       @battler.hzhj_remove_state_id.clear
  972.       @battler.need_update_state_animation = true
  973.       for state in @battler.states
  974.         next if state.nil?
  975.         next if $data_animations[state.animation_id].nil?
  976.         @battler.hzhj_add_state_id.push(state.id)
  977.       end
  978.     end
  979.   end
  980.   #--------------------------------------------------------------------------
  981.   # ● 设置战斗者(追加定义)
  982.   #--------------------------------------------------------------------------
  983.   alias hzhj_old_battlerdy_for_state_ani_spr_battler battler=
  984.   def battler=(value)
  985.     old_battler = @battler
  986.     hzhj_old_battlerdy_for_state_ani_spr_battler(value)
  987.     if old_battler != @battler
  988.       init_battler_add_state_id
  989.     end
  990.   end
  991.   #--------------------------------------------------------------------------
  992.   # ● 刷新(追加定义)
  993.   #--------------------------------------------------------------------------
  994.   alias hzhj_old_update_for_state_ani_spr_battler update
  995.   def update
  996.     hzhj_old_update_for_state_ani_spr_battler
  997.     if @battler
  998.       if @battler.need_update_state_animation
  999.         @battler.need_update_state_animation = false
  1000.         if not @battler.hzhj_add_state_id.empty?
  1001.           for i in @battler.hzhj_add_state_id
  1002.             if @battler.state?(i)
  1003.               ani_id = $data_states[i].animation_id
  1004.               animation = $data_animations[ani_id]
  1005.               start_loop_animation(animation) if not animation.nil?
  1006.             end
  1007.           end
  1008.           @battler.hzhj_add_state_id.clear
  1009.         end
  1010.         if not @battler.hzhj_remove_state_id.empty?
  1011.           for i in @battler.hzhj_remove_state_id
  1012.             if not @battler.state?(i)
  1013.               ani_id = $data_states[i].animation_id
  1014.               animation = $data_animations[ani_id]
  1015.               end_loop_animation(animation) if not animation.nil?
  1016.             end
  1017.           end
  1018.           @battler.hzhj_remove_state_id.clear
  1019.         end
  1020.       end
  1021.     end
  1022.   end
  1023. end
  1024. #==============================================================================
  1025. # ■ Window_BattleLog
  1026. #==============================================================================
  1027. class Window_BattleLog < Window_Selectable
  1028.   #--------------------------------------------------------------------------
  1029.   # ● 显示状态附加/解除(追加定义)
  1030.   #--------------------------------------------------------------------------
  1031.   alias hzhj_old_display_status_for_state_ani_wnd_btlog display_changed_states
  1032.   def display_changed_states(target)
  1033.     target.need_update_state_animation = true
  1034.     hzhj_old_display_status_for_state_ani_wnd_btlog(target)
  1035.   end
  1036. end
  1037.  
  1038. #==============================================================================
  1039. # ■ Sprite_Damage (新增类)
  1040. #==============================================================================
  1041. class Sprite_Damage < Sprite
  1042.   include Hzhj::HorizontalBattleSystem
  1043.   #--------------------------------------------------------------------------
  1044.   # ● 获取/生成伤害值源图
  1045.   #--------------------------------------------------------------------------
  1046.   @@obmp = nil
  1047.   def self.obmp
  1048.     if @@obmp.nil? or @@obmp.disposed?
  1049.       @@obmp = Bitmap.new(180, 256)
  1050.       @@obmp.font.bold = true
  1051.       @@obmp.font.shadow = false
  1052.       @@obmp.font.outline = true
  1053.       @@obmp.font.out_color = Color.new(255, 255, 255, 255)
  1054.       @@obmp.font.size = 32
  1055.       colors = []
  1056.       colors.push(Color.new(255,   0,   0, 255))
  1057.       colors.push(Color.new(255, 128, 128, 255))
  1058.       colors.push(Color.new(  0,   0, 255, 255))
  1059.       colors.push(Color.new(128, 128, 255, 255))
  1060.       colors.push(Color.new(  0, 255,   0, 255))
  1061.       colors.push(Color.new(128, 255, 128, 255))
  1062.       colors.each_with_index do |color, hi|
  1063.         @@obmp.font.color = color
  1064.         for wi in 0..9
  1065.           @@obmp.draw_text(wi * 18, hi * 32, 18, 32, "#{wi}", 1)
  1066.         end
  1067.       end
  1068.       @@obmp.font.size = 20
  1069.       @@obmp.font.italic = true
  1070.       @@obmp.font.out_color = Color.new(0, 0, 0, 255)
  1071.       @@obmp.font.color = Color.new(255, 255, 255, 255)
  1072.       @@obmp.draw_text( 0, 192, 90, 32, "Critical", 1)
  1073.       @@obmp.draw_text(90, 192, 90, 32, "Miss", 1)
  1074.       @@obmp.draw_text( 0, 224, 90, 32, "Evasion", 1)
  1075.       @@obmp.hue_change(DamageBitmapHue)
  1076.     end
  1077.     return @@obmp
  1078.   end
  1079.   #--------------------------------------------------------------------------
  1080.   # ● 初始化
  1081.   #--------------------------------------------------------------------------
  1082.   def initialize(viewport, args)
  1083.     super(viewport)
  1084.     @type = args[0]
  1085.     @value = args[1]
  1086.     @critical = args[2]
  1087.     self.x = args[4]
  1088.     self.y = args[5]
  1089.     self.z = args[6] + Graphics.height * 5
  1090.     make_move(args[3])
  1091.     refresh
  1092.   end
  1093.   #--------------------------------------------------------------------------
  1094.   # ● 生成移动数据
  1095.   #--------------------------------------------------------------------------
  1096.   def make_move(battler_obj_class)
  1097.     @move = []
  1098.     case battler_obj_class
  1099.     when :actor
  1100.       make_move_actor
  1101.     when :enemy
  1102.       make_move_enemy
  1103.     else
  1104.       make_move_default
  1105.     end
  1106.   end
  1107.   #--------------------------------------------------------------------------
  1108.   # ● 生成移动数据 默认
  1109.   #--------------------------------------------------------------------------
  1110.   def make_move_default
  1111.     45.times do |n|
  1112.       if n % 3 == 0
  1113.         ady = n < 21 ? -6 : -1
  1114.         opa = n < 21 ? 255 : 255-(n-21)*6
  1115.         @move.push([0, ady, opa])
  1116.       else
  1117.         @move.push([0, 0, -1])
  1118.       end
  1119.     end
  1120.   end
  1121.   #--------------------------------------------------------------------------
  1122.   # ● 生成移动数据 角色
  1123.   #--------------------------------------------------------------------------
  1124.   def make_move_actor
  1125.     make_move_default
  1126.   end
  1127.   #--------------------------------------------------------------------------
  1128.   # ● 生成移动数据 敌人
  1129.   #--------------------------------------------------------------------------
  1130.   def make_move_enemy
  1131.     make_move_default
  1132.   end
  1133.   #--------------------------------------------------------------------------
  1134.   # ● 描绘
  1135.   #--------------------------------------------------------------------------
  1136.   def refresh
  1137.     if not self.bitmap.nil?
  1138.       self.bitmap.dispose
  1139.       self.bitmap = nil
  1140.     end
  1141.     begin
  1142.       @obmp = Cache.animation("damage", DamageBitmapHue)
  1143.     rescue Errno::ENOENT
  1144.       @obmp = Sprite_Damage.obmp
  1145.     end
  1146.     @numw = @obmp.width / 10
  1147.     @numh = @obmp.height / 8
  1148.     @strw = @obmp.width / 2
  1149.     case @value
  1150.     when Numeric
  1151.       blt_obmp_numeric
  1152.     when Symbol
  1153.       blt_obmp_text
  1154.     end
  1155.   end
  1156.   #--------------------------------------------------------------------------
  1157.   # ● 通过源图描绘数字
  1158.   #--------------------------------------------------------------------------
  1159.   def blt_obmp_numeric
  1160.     nums = @value.to_i.abs.to_s.split("")
  1161.     nbmpw = nums.size * @numw
  1162.     bmph = @numh
  1163.     cbmpw = 0
  1164.     crect = nil
  1165.     dy = 0
  1166.     if @critical
  1167.       cbmpw = @strw
  1168.       bmph *= 2
  1169.       crect = Rect.new(0, @numh * 6, @strw, @numh)
  1170.       dy = @numh
  1171.     end
  1172.     self.bitmap = Bitmap.new([nbmpw, cbmpw, 32].max, [bmph, 32].max)
  1173.     self.ox = bitmap.width / 2
  1174.     self.oy = bmph /2
  1175.     bitmap.blt((bitmap.width - cbmpw) / 2, 0, @obmp, crect) if crect
  1176.     dx = (bitmap.width - nbmpw) / 2
  1177.     ry = 0
  1178.     case @type
  1179.     when :hp
  1180.       ry = @value >= 0 ? 0 : @numh
  1181.     when :mp
  1182.       ry = @value >= 0 ? @numh * 2 : @numh * 3
  1183.     when :tp
  1184.       ry = @value >= 0 ? @numh * 4 : @numh * 5
  1185.     else
  1186.       return
  1187.     end
  1188.     rect = Rect.new(0, ry, @numw, @numh)
  1189.     nums.each_with_index do |str, i|
  1190.       rect.x = str.to_i * @numw
  1191.       bitmap.blt(dx, dy, @obmp, rect)
  1192.       dx += @numw
  1193.     end
  1194.   end
  1195.   #--------------------------------------------------------------------------
  1196.   # ● 通过源图描绘文字
  1197.   #--------------------------------------------------------------------------
  1198.   def blt_obmp_text
  1199.     self.bitmap = Bitmap.new([@strw, 32].max, [@numh, 32].max)
  1200.     self.ox = @strw / 2
  1201.     self.oy = @numh / 2
  1202.     rx = ry = 0
  1203.     case @type
  1204.     when :miss
  1205.       rx = @strw
  1206.       ry = @numh * 6
  1207.     when :eva
  1208.       ry = @numh * 7
  1209.     else
  1210.       return
  1211.     end
  1212.     rect = Rect.new(rx, ry, @strw, @numh)
  1213.     bitmap.blt(0, 0, @obmp, rect)
  1214.   end
  1215.   #--------------------------------------------------------------------------
  1216.   # ● 释放
  1217.   #--------------------------------------------------------------------------
  1218.   def dispose
  1219.     bitmap.dispose if bitmap
  1220.     super
  1221.   end
  1222.   #--------------------------------------------------------------------------
  1223.   # ● 移动中判定
  1224.   #--------------------------------------------------------------------------
  1225.   def moving?
  1226.     return (not @move.empty?)
  1227.   end
  1228.   #--------------------------------------------------------------------------
  1229.   # ● 刷新
  1230.   #--------------------------------------------------------------------------
  1231.   def update
  1232.     super
  1233.     if moving?
  1234.       ary = @move.shift
  1235.       self.x += ary[0]
  1236.       self.y += ary[1]
  1237.       self.opacity = ary[2] if ary[2] >= 0
  1238.     end
  1239.   end
  1240. end
  1241. #==============================================================================
  1242. # ■ Game_BattlerBase
  1243. #==============================================================================
  1244. class Game_BattlerBase
  1245.   #--------------------------------------------------------------------------
  1246.   # ● 实例变量(新增定义)
  1247.   #--------------------------------------------------------------------------
  1248.   attr_accessor :hzhj_damage
  1249.   #--------------------------------------------------------------------------
  1250.   # ● 初始化(追加定义)
  1251.   #--------------------------------------------------------------------------
  1252.   alias hzhj_old_init_for_display_damage_game_battler_base initialize
  1253.   def initialize
  1254.     @hzhj_damage = []
  1255.     hzhj_old_init_for_display_damage_game_battler_base
  1256.   end
  1257. end
  1258. #==============================================================================
  1259. # ■ Sprite_Base
  1260. #==============================================================================
  1261. class Sprite_Base < Sprite
  1262.   #--------------------------------------------------------------------------
  1263.   # ● 初始化(追加定义)
  1264.   #--------------------------------------------------------------------------
  1265.   alias hzhj_old_init_for_display_damage_spr_base initialize
  1266.   def initialize(*args)
  1267.     hzhj_old_init_for_display_damage_spr_base(*args)
  1268.     @hzhj_damage_sprites = []
  1269.   end
  1270.   #--------------------------------------------------------------------------
  1271.   # ● 释放(追加定义)
  1272.   #--------------------------------------------------------------------------
  1273.   alias hzhj_old_dispose_for_display_damage_spr_base dispose
  1274.   def dispose
  1275.     hzhj_old_dispose_for_display_damage_spr_base
  1276.     dispose_damage
  1277.   end
  1278.   #--------------------------------------------------------------------------
  1279.   # ● 判断是否有伤害在显示(新增定义)
  1280.   #--------------------------------------------------------------------------
  1281.   def damage?
  1282.     return (not @hzhj_damage_sprites.empty?)
  1283.   end
  1284.   #--------------------------------------------------------------------------
  1285.   # ● 开始显示伤害(新增定义)
  1286.   #--------------------------------------------------------------------------
  1287.   def start_damage(args)
  1288.     args[4] = x - ox + width / 2
  1289.     args[5] = y - oy + height / 2
  1290.     args[6] = z
  1291.     @hzhj_damage_sprites.push(Sprite_Damage.new(viewport, args))
  1292.   end
  1293.   #--------------------------------------------------------------------------
  1294.   # ● 释放所有伤害显示(新增定义)
  1295.   #--------------------------------------------------------------------------
  1296.   def dispose_damage
  1297.     return unless damage?
  1298.     @hzhj_damage_sprites.each{|sprite|sprite.dispose}
  1299.     @hzhj_damage_sprites.clear
  1300.   end
  1301.   #--------------------------------------------------------------------------
  1302.   # ● 刷新(追加定义)
  1303.   #--------------------------------------------------------------------------
  1304.   alias hzhj_old_update_for_display_damage_spr_base update
  1305.   def update
  1306.     hzhj_old_update_for_display_damage_spr_base
  1307.     update_damage
  1308.   end
  1309.   #--------------------------------------------------------------------------
  1310.   # ● 刷新显示伤害(新增定义)
  1311.   #--------------------------------------------------------------------------
  1312.   def update_damage
  1313.     return unless damage?
  1314.     @hzhj_damage_sprites.each_with_index do |sprite, i|
  1315.       if sprite.moving?
  1316.         sprite.update
  1317.       else
  1318.         sprite.dispose
  1319.         @hzhj_damage_sprites[i] = nil
  1320.       end
  1321.     end
  1322.     @hzhj_damage_sprites.delete(nil)
  1323.   end
  1324. end
  1325. #==============================================================================
  1326. # ■ Sprite_Battler
  1327. #==============================================================================
  1328. class Sprite_Battler < Sprite_Base
  1329.   #--------------------------------------------------------------------------
  1330.   # ● 刷新(追加定义)
  1331.   #--------------------------------------------------------------------------
  1332.   alias hzhj_old_update_for_display_damage_spr_battler update
  1333.   def update
  1334.     hzhj_old_update_for_display_damage_spr_battler
  1335.     if @battler
  1336.       if not @battler.hzhj_damage.empty?
  1337.         unless @battler.damage_section_displayed
  1338.           args = @battler.hzhj_damage.clone
  1339.           args[3] = @battler.actor? ? :actor : (@battler.enemy? ? :enemy : nil)
  1340.           start_damage(args)
  1341.         end
  1342.         @battler.hzhj_damage.clear
  1343.       end
  1344.     end
  1345.   end
  1346. end
  1347. #==============================================================================
  1348. # ■ Window_BattleLog
  1349. #==============================================================================
  1350. class Window_BattleLog < Window_Selectable
  1351.   #--------------------------------------------------------------------------
  1352.   # ● 显示 MISS (追加定义)
  1353.   #--------------------------------------------------------------------------
  1354.   alias hzhj_old_display_miss_for_display_damage_wnd_btlog display_miss
  1355.   def display_miss(target, item)
  1356.     target.hzhj_damage = [:miss, :miss, false]
  1357.     hzhj_old_display_miss_for_display_damage_wnd_btlog(target, item)
  1358.   end
  1359.   #--------------------------------------------------------------------------
  1360.   # ● 显示回避 (追加定义)
  1361.   #--------------------------------------------------------------------------
  1362.   alias hzhj_old_display_evasion_for_display_damage_wnd_btlog display_evasion
  1363.   def display_evasion(target, item)
  1364.     target.hzhj_damage = [:eva, :evasion, false]
  1365.     hzhj_old_display_evasion_for_display_damage_wnd_btlog(target, item)
  1366.   end
  1367.   #--------------------------------------------------------------------------
  1368.   # ● 显示 HP 伤害 (追加定义)
  1369.   #--------------------------------------------------------------------------
  1370.   alias hzhj_old_display_hp_damage_for_display_damage_wnd_btlog display_hp_damage
  1371.   def display_hp_damage(target, item)
  1372.     return if target.result.hp_damage == 0 && item && !item.damage.to_hp?
  1373.     value = target.result.hp_damage
  1374.     critical = target.result.critical
  1375.     target.hzhj_damage = [:hp, value, critical]
  1376.     hzhj_old_display_hp_damage_for_display_damage_wnd_btlog(target, item)
  1377.   end
  1378.   #--------------------------------------------------------------------------
  1379.   # ● 显示 MP 伤害 (追加定义)
  1380.   #--------------------------------------------------------------------------
  1381.   alias hzhj_old_display_mp_damage_for_display_damage_wnd_btlog display_mp_damage
  1382.   def display_mp_damage(target, item)
  1383.     return if target.dead? || target.result.mp_damage == 0
  1384.     value = target.result.mp_damage
  1385.     critical = target.result.critical
  1386.     target.hzhj_damage = [:mp, value, critical]
  1387.     hzhj_old_display_mp_damage_for_display_damage_wnd_btlog(target, item)
  1388.   end
  1389.   #--------------------------------------------------------------------------
  1390.   # ● 显示 TP 伤害 (追加定义)
  1391.   #--------------------------------------------------------------------------
  1392.   alias hzhj_old_display_tp_damage_for_display_damage_wnd_btlog display_tp_damage
  1393.   def display_tp_damage(target, item)
  1394.     return if target.dead? || target.result.tp_damage == 0
  1395.     value = target.result.tp_damage
  1396.     critical = target.result.critical
  1397.     target.hzhj_damage = [:tp, value, critical]
  1398.     hzhj_old_display_tp_damage_for_display_damage_wnd_btlog(target, item)
  1399.   end
  1400. end
  1401.  
  1402. class RPG::Animation
  1403.   def need_move
  1404.     return @need_move unless @need_move.nil?
  1405.     if /@[Rr][Mm]/ =~ @name
  1406.       return (@need_move = true)
  1407.     else
  1408.       return (@need_move = false)
  1409.     end
  1410.   end
  1411.   def move_se
  1412.     return @move_se unless @move_se.nil?
  1413.     @move_se = RPG::SE.new
  1414.     if /@[Ss][Ee]\[(.+?)\]/ =~ @name
  1415.       @move_se.name = $1.clone
  1416.     end
  1417.     return @move_se
  1418.   end
  1419.   attr_writer :need_move
  1420.   attr_writer :move_se
  1421. end
  1422. #==============================================================================
  1423. # ■ Game_Battler
  1424. #==============================================================================
  1425. class Game_Battler < Game_BattlerBase
  1426.   include Hzhj::HorizontalBattleSystem
  1427.   #--------------------------------------------------------------------------
  1428.   # ● 属性
  1429.   #--------------------------------------------------------------------------
  1430.   attr_accessor :add_x                    # X 坐标变化量
  1431.   attr_accessor :add_y                    # Y 坐标变化量
  1432.   attr_accessor :move_speed_x             # 战斗图 X 移动速度
  1433.   attr_accessor :move_speed_y             # 战斗图 Y 移动速度
  1434.   #--------------------------------------------------------------------------
  1435.   # ● 初始化(追加定义)
  1436.   #--------------------------------------------------------------------------
  1437.   alias hzhj_old_init_for_real_move_game_battler initialize
  1438.   def initialize
  1439.     @add_x = 0
  1440.     @add_y = 0
  1441.     @move_speed_x = 0
  1442.     @move_speed_y = 0
  1443.     hzhj_old_init_for_real_move_game_battler
  1444.   end
  1445.   #--------------------------------------------------------------------------
  1446.   # ● 真实 X 坐标(新增定义)
  1447.   #--------------------------------------------------------------------------
  1448.   def real_screen_x
  1449.     return screen_x + add_x
  1450.   end
  1451.   #--------------------------------------------------------------------------
  1452.   # ● 真实 Y 坐标(新增定义)
  1453.   #--------------------------------------------------------------------------
  1454.   def real_screen_y
  1455.     return screen_y + add_y
  1456.   end
  1457.   #--------------------------------------------------------------------------
  1458.   # ● 返回自己的战斗位置(新增定义)
  1459.   #--------------------------------------------------------------------------
  1460.   def come_back_self_position(duration)
  1461.     return if dead?
  1462.     tx = screen_x
  1463.     ty = screen_y
  1464.     addx = tx - real_screen_x
  1465.     addy = ty - real_screen_y
  1466.     return if addx == 0 && addy == 0
  1467.     @add_x = 0
  1468.     @add_y = 0
  1469.     @move_speed_x = [(addx.abs / duration.to_f).ceil, 1].max
  1470.     @move_speed_y = [(addy.abs / duration.to_f).ceil, 1].max
  1471.   end
  1472.   #--------------------------------------------------------------------------
  1473.   # ● 设置移动信息(新增定义)
  1474.   #--------------------------------------------------------------------------
  1475.   def setup_move_info(target_battler, duration, move_se)
  1476.     return if dead?
  1477.     tbmp = Cache.battler(target_battler.battler_name, target_battler.battler_hue)
  1478.     sbmp = Cache.battler(@battler_name, @battler_hue)
  1479.     tbw = tbmp.width / DynamicPatternMax + RealMoveBmpAddW
  1480.     sbw = sbmp.width / DynamicPatternMax + RealMoveBmpAddW
  1481.     tbh = tbmp.height + RealMoveBmpAddH
  1482.     sbh = sbmp.height + RealMoveBmpAddH
  1483.     d = actor? ? ActorDirection : 10 - ActorDirection
  1484.     tx = target_battler.real_screen_x
  1485.     ty = target_battler.real_screen_y
  1486.     case d
  1487.     when 1
  1488.       tx = tx + tbw / 2 + sbw / 2
  1489.       ty = ty - sbh / 2
  1490.     when 2
  1491.       ty = ty - sbh / 2
  1492.     when 3
  1493.       tx = tx - tbw / 2 - sbw / 2
  1494.       ty = ty - sbh / 2
  1495.     when 4
  1496.       tx = tx + tbw / 2 + sbw / 2
  1497.     when 6
  1498.       tx = tx - tbw / 2 - sbw / 2
  1499.     when 7
  1500.       tx = tx + tbw / 2 + sbw / 2
  1501.       ty = ty + sbh / 2
  1502.     when 8
  1503.       ty = ty + sbh / 2
  1504.     when 9
  1505.       tx = tx - tbw / 2 - sbw / 2
  1506.       ty = ty + sbh / 2
  1507.     end
  1508.     addx = tx - real_screen_x
  1509.     addy = ty - real_screen_y
  1510.     return if addx == 0 && addy == 0
  1511.     @add_x = tx - screen_x if addx != 0
  1512.     @add_y = ty - screen_y if addy != 0
  1513.     @move_speed_x = [(addx.abs / duration.to_f).ceil, 1].max
  1514.     @move_speed_y = [(addy.abs / duration.to_f).ceil, 1].max
  1515.     move_se.play
  1516.   end
  1517. end
  1518. #==============================================================================
  1519. # ■ Sprite_Battler
  1520. #==============================================================================
  1521. class Sprite_Battler < Sprite_Base
  1522.   #--------------------------------------------------------------------------
  1523.   # ● 初始化(追加定义)
  1524.   #--------------------------------------------------------------------------
  1525.   alias hzhj_old_init_for_real_move_spr_battler initialize
  1526.   def initialize(viewport, battler = nil)
  1527.     hzhj_old_init_for_real_move_spr_battler(viewport, battler)
  1528.     init_position(@battler) if @battler
  1529.   end
  1530.   #--------------------------------------------------------------------------
  1531.   # ● 设置战斗者(追加定义)
  1532.   #--------------------------------------------------------------------------
  1533.   alias hzhj_old_set_battler_for_real_move_spr_battler battler=
  1534.   def battler=(value)
  1535.     if @battler != value && value
  1536.       init_position(value)
  1537.     end
  1538.     hzhj_old_set_battler_for_real_move_spr_battler(value)
  1539.   end
  1540.   #--------------------------------------------------------------------------
  1541.   # ● 初始化位置(新增定义)
  1542.   #--------------------------------------------------------------------------
  1543.   def init_position(battler)
  1544.     battler.add_x = 0
  1545.     battler.add_y = 0
  1546.     self.x = battler.real_screen_x
  1547.     self.y = battler.real_screen_y
  1548.     self.z = battler.screen_z
  1549.   end
  1550.   #--------------------------------------------------------------------------
  1551.   # ● 移动中判定(新增定义)
  1552.   #--------------------------------------------------------------------------
  1553.   def moving?
  1554.     return false unless @battler
  1555.     (x != @battler.real_screen_x or y != @battler.real_screen_y) && @battler
  1556.   end
  1557.   #--------------------------------------------------------------------------
  1558.   # ● 位置的更新(重定义)
  1559.   #--------------------------------------------------------------------------
  1560.   def update_position
  1561.     if !@battler.dead?
  1562.       if x < @battler.real_screen_x
  1563.         self.x = [x + @battler.move_speed_x, @battler.real_screen_x].min
  1564.       elsif x > @battler.real_screen_x
  1565.         self.x = [x - @battler.move_speed_x, @battler.real_screen_x].max
  1566.       end
  1567.       if y < @battler.real_screen_y
  1568.         self.y = [y + @battler.move_speed_y, @battler.real_screen_y].min
  1569.       elsif y > @battler.real_screen_y
  1570.         self.y = [y - @battler.move_speed_y, @battler.real_screen_y].max
  1571.       end
  1572.       self.z = y + 100
  1573.     end
  1574.   end
  1575. end
  1576. #==============================================================================
  1577. # ■ Spriteset_Battle
  1578. #==============================================================================
  1579. class Spriteset_Battle
  1580.   #--------------------------------------------------------------------------
  1581.   # ● 判定是否移动中(新增定义)
  1582.   #--------------------------------------------------------------------------
  1583.   def moving?
  1584.     battler_sprites.any? {|sprite| sprite.moving? }
  1585.   end
  1586. end
  1587. #==============================================================================
  1588. # ■ Scene_Battle
  1589. #==============================================================================
  1590. class Scene_Battle < Scene_Base
  1591.   #--------------------------------------------------------------------------
  1592.   # ● 等待战斗图移动的结束(新增定义)
  1593.   #--------------------------------------------------------------------------
  1594.   def wait_for_move
  1595.     update_for_wait
  1596.     update_for_wait while @spriteset.moving?
  1597.   end
  1598. end
  1599.  
  1600. class RPG::Troop
  1601.   include Hzhj::HorizontalBattleSystem
  1602.   def display_enemy_bar
  1603.     return @display_enemy_bar unless @display_enemy_bar.nil?
  1604.     if /@ebar/i =~ @name
  1605.       return (@display_enemy_bar = !DefaultDisplayEnemyBar)
  1606.     else
  1607.       return (@display_enemy_bar = DefaultDisplayEnemyBar)
  1608.     end
  1609.   end
  1610.   attr_writer :display_enemy_bar
  1611. end
  1612. #==============================================================================
  1613. # ■ Game_Troop
  1614. #==============================================================================
  1615. class Game_Troop < Game_Unit
  1616.   attr_accessor :display_enemy_bar      # 是否显示敌人HP条、MP条、TP条
  1617.   #--------------------------------------------------------------------------
  1618.   # ● 设置
  1619.   #--------------------------------------------------------------------------
  1620.   alias hzhj_old_setup_for_display_enemy_bar_game_troop setup
  1621.   def setup(troop_id)
  1622.     hzhj_old_setup_for_display_enemy_bar_game_troop(troop_id)
  1623.     @display_enemy_bar = troop.display_enemy_bar
  1624.   end
  1625. end
  1626. #==============================================================================
  1627. # ■ Window_BattleEnemy
  1628. #==============================================================================
  1629. class Window_BattleEnemy < Window_Selectable
  1630.   #--------------------------------------------------------------------------
  1631.   # ● 取得列数
  1632.   #--------------------------------------------------------------------------
  1633.   def col_max
  1634.     if $game_troop.display_enemy_bar
  1635.       return 1
  1636.     else
  1637.       return 2
  1638.     end
  1639.   end
  1640.   #--------------------------------------------------------------------------
  1641.   # ● 刷新
  1642.   #--------------------------------------------------------------------------
  1643.   def refresh
  1644.     create_contents
  1645.     super
  1646.   end
  1647.   #--------------------------------------------------------------------------
  1648.   # ● 描画项目
  1649.   #--------------------------------------------------------------------------
  1650.   def draw_item(index)
  1651.     if $game_troop.display_enemy_bar
  1652.       enemy = $game_troop.alive_members[index]
  1653.       draw_basic_area(basic_area_rect(index), enemy)
  1654.       draw_gauge_area(gauge_area_rect(index), enemy)
  1655.     else
  1656.       change_color(normal_color)
  1657.       name = $game_troop.alive_members[index].name
  1658.       draw_text(item_rect_for_text(index), name)
  1659.     end
  1660.   end
  1661.   #--------------------------------------------------------------------------
  1662.   # ● 取得基本区域的矩形
  1663.   #--------------------------------------------------------------------------
  1664.   def basic_area_rect(index)
  1665.     rect = item_rect_for_text(index)
  1666.     rect.width -= gauge_area_width + 10
  1667.     rect
  1668.   end
  1669.   #--------------------------------------------------------------------------
  1670.   # ● 取得值槽区域的矩形
  1671.   #--------------------------------------------------------------------------
  1672.   def gauge_area_rect(index)
  1673.     rect = item_rect_for_text(index)
  1674.     rect.x += rect.width - gauge_area_width
  1675.     rect.width = gauge_area_width
  1676.     rect
  1677.   end
  1678.   #--------------------------------------------------------------------------
  1679.   # ● 取得值槽区域的宽度
  1680.   #--------------------------------------------------------------------------
  1681.   def gauge_area_width
  1682.     return 220
  1683.   end
  1684.   #--------------------------------------------------------------------------
  1685.   # ● 描画基本区域
  1686.   #--------------------------------------------------------------------------
  1687.   def draw_basic_area(rect, actor)
  1688.     draw_actor_name(actor, rect.x + 0, rect.y, 100)
  1689.     draw_actor_icons(actor, rect.x + 104, rect.y, rect.width - 104)
  1690.   end
  1691.   #--------------------------------------------------------------------------
  1692.   # ● 描画值槽区域
  1693.   #--------------------------------------------------------------------------
  1694.   def draw_gauge_area(rect, actor)
  1695.     if $data_system.opt_display_tp
  1696.       draw_gauge_area_with_tp(rect, actor)
  1697.     else
  1698.       draw_gauge_area_without_tp(rect, actor)
  1699.     end
  1700.   end
  1701.   #--------------------------------------------------------------------------
  1702.   # ● 描画值槽区域(包括 TP 值)
  1703.   #--------------------------------------------------------------------------
  1704.   def draw_gauge_area_with_tp(rect, actor)
  1705.     draw_actor_hp(actor, rect.x + 0, rect.y, 72)
  1706.     draw_actor_mp(actor, rect.x + 82, rect.y, 64)
  1707.     draw_actor_tp(actor, rect.x + 156, rect.y, 64)
  1708.   end
  1709.   #--------------------------------------------------------------------------
  1710.   # ● 描画值槽区域(不包括 TP 值)
  1711.   #--------------------------------------------------------------------------
  1712.   def draw_gauge_area_without_tp(rect, actor)
  1713.     draw_actor_hp(actor, rect.x + 0, rect.y, 134)
  1714.     draw_actor_mp(actor, rect.x + 144,  rect.y, 76)
  1715.   end
  1716. end
  1717.  
  1718. #==============================================================================
  1719. # ■ Sprite_Battler
  1720. #==============================================================================
  1721. class Sprite_Battler < Sprite_Base
  1722.   include Hzhj::HorizontalBattleSystem
  1723.   #--------------------------------------------------------------------------
  1724.   # ● 初始化(追加定义)
  1725.   #--------------------------------------------------------------------------
  1726.   alias hzhj_old_init_for_dynamic_spr_battler initialize
  1727.   def initialize(viewport, battler = nil)
  1728.     hzhj_old_init_for_dynamic_spr_battler(viewport, battler)
  1729.     @dynamic_duration = 0
  1730.     @dynamic_duration_max = DynamicPatternMax * OnePatternDuration
  1731.   end
  1732.   #--------------------------------------------------------------------------
  1733.   # ● 源位图(Source Bitmap)的更新(重定义)
  1734.   #--------------------------------------------------------------------------
  1735.   def update_bitmap
  1736.     new_bitmap = Cache.battler(@battler.battler_name, @battler.battler_hue)
  1737.     if bitmap != new_bitmap
  1738.       self.bitmap = new_bitmap
  1739.       init_visibility
  1740.       @dynamic_duration = 0
  1741.       @sx = 0
  1742.       @sw = bitmap.width / DynamicPatternMax
  1743.       @sh = bitmap.height
  1744.       self.ox = @sw / 2
  1745.       self.oy = @sh
  1746.       src_rect.set(@sx, 0, @sw, @sh)
  1747.     end
  1748.   end
  1749.   #--------------------------------------------------------------------------
  1750.   # ● 原点的更新(重定义)
  1751.   #--------------------------------------------------------------------------
  1752.   def update_origin
  1753.     if bitmap
  1754.       @dynamic_duration += 1
  1755.       @dynamic_duration %= @dynamic_duration_max
  1756.       @sx = @dynamic_duration / OnePatternDuration * @sw
  1757.       src_rect.set(@sx, 0, @sw, @sh)
  1758.     end
  1759.   end
  1760.   #--------------------------------------------------------------------------
  1761.   # ● 返回普通设定(追加定义)
  1762.   #--------------------------------------------------------------------------
  1763.   alias hzhj_old_revert_to_normal_for_dynamic_spr_battler revert_to_normal
  1764.   def revert_to_normal
  1765.     hzhj_old_revert_to_normal_for_dynamic_spr_battler
  1766.     self.ox = @sw / 2 if bitmap
  1767.   end
  1768.   #--------------------------------------------------------------------------
  1769.   # ● BOSS 战败(崩坏)效果的更新(追加定义)
  1770.   #--------------------------------------------------------------------------
  1771.   alias hzhj_old_update_boss_col_for_dynamic_spr_battler update_boss_collapse
  1772.   def update_boss_collapse
  1773.     hzhj_old_update_boss_col_for_dynamic_spr_battler
  1774.     self.ox = @sw / 2 + @effect_duration % 2 * 4 - 2
  1775.   end
  1776. end
  1777.  
  1778. #==============================================================================
  1779. # ■ Game_Battler
  1780. #==============================================================================
  1781. class Game_Battler < Game_BattlerBase
  1782.   def set_normal_battler_name
  1783.     @battler_name = @battler_name.split(/★/)[0]
  1784.   end
  1785.   def set_beaten_battler_name
  1786.     if guard?
  1787.       if (UseActorGuardGraphic && actor?) or
  1788.          (UseEnemyGuardGraphic && enemy?)
  1789.         set_guard_battler_name
  1790.         return
  1791.       end
  1792.     end
  1793.     @battler_name = @battler_name.split(/★/)[0] + "★1"
  1794.     if UseActorWBSE && actor?
  1795.       Audio.se_play("Audio/SE/AWBSE_#{id}", 100, 100)
  1796.     elsif UseEnemyWBSE && enemy?
  1797.       Audio.se_play("Audio/SE/EWBSE_#{enemy_id}", 100, 100)
  1798.     end
  1799.   end
  1800.   def set_dead_battler_name
  1801.     @battler_name = @battler_name.split(/★/)[0] + "★2"
  1802.   end
  1803.   def set_guard_battler_name
  1804.     @battler_name = @battler_name.split(/★/)[0] + "★3"
  1805.     if UseActorGDSE && actor?
  1806.       Audio.se_play("Audio/SE/AGDSE_#{id}", 100, 100)
  1807.     elsif UseEnemyGDSE && enemy?
  1808.       Audio.se_play("Audio/SE/EGDSE_#{enemy_id}", 100, 100)
  1809.     end
  1810.   end
  1811. end
  1812. #==============================================================================
  1813. # ■ Sprite_Battler
  1814. #==============================================================================
  1815. class Sprite_Battler < Sprite_Base
  1816.   #--------------------------------------------------------------------------
  1817.   # ● 初始化(追加定义)
  1818.   #--------------------------------------------------------------------------
  1819.   alias hzhj_old_init_for_dead_spr_battler initialize
  1820.   def initialize(viewport, battler = nil)
  1821.     hzhj_old_init_for_dead_spr_battler(viewport, battler)
  1822.     @dead_graphic_used = false
  1823.     if @battler
  1824.       @battler.set_normal_battler_name
  1825.       if @battler.dead?
  1826.         if (UseActorDeadGraphic && @battler.actor?) or
  1827.            (UseEnemyDeadGraphic && @battler.enemy?)
  1828.           @battler.set_dead_battler_name
  1829.           @dead_graphic_used = true
  1830.         end
  1831.       end
  1832.     end
  1833.     @beaten_duration = -1
  1834.   end
  1835.   #--------------------------------------------------------------------------
  1836.   # ● 设置战斗者(追加定义)
  1837.   #--------------------------------------------------------------------------
  1838.   alias hzhj_old_set_battler_for_dead_spr_battler battler=
  1839.   def battler=(value)
  1840.     if @battler != value
  1841.       @dead_graphic_used = false
  1842.       if value
  1843.         value.set_normal_battler_name
  1844.         if value.dead?
  1845.           if (UseActorDeadGraphic && value.actor?) or
  1846.              (UseEnemyDeadGraphic && value.enemy?)
  1847.             value.set_dead_battler_name
  1848.             @dead_graphic_used = true
  1849.           end
  1850.         end
  1851.       end
  1852.       @beaten_duration = -1
  1853.     end
  1854.     hzhj_old_set_battler_for_dead_spr_battler(value)
  1855.   end
  1856.   #--------------------------------------------------------------------------
  1857.   # ● 源位图(Source Bitmap)的更新(重定义)
  1858.   #--------------------------------------------------------------------------
  1859.   alias hzhj_old_update_bitmap_for_was_beaten_spr_battler update_bitmap
  1860.   def update_bitmap
  1861.     if @beaten_duration > 0
  1862.       @beaten_duration -= 1
  1863.     elsif @beaten_duration == 0
  1864.       @beaten_duration = -1
  1865.       set_bitmap(:normal)
  1866.     end
  1867.     hzhj_old_update_bitmap_for_was_beaten_spr_battler
  1868.   end
  1869.   #--------------------------------------------------------------------------
  1870.   # ● 初始化可视状态(追加定义)
  1871.   #--------------------------------------------------------------------------
  1872.   alias hzhj_old_visibility_for_dead_spr_battler init_visibility
  1873.   def init_visibility
  1874.     hzhj_old_visibility_for_dead_spr_battler
  1875.     if @battler.dead?
  1876.       if (UseActorDeadGraphic && @battler.actor?) or
  1877.          (UseEnemyDeadGraphic && @battler.enemy?)
  1878.         self.opacity = 255
  1879.       end
  1880.     end
  1881.   end
  1882.   #--------------------------------------------------------------------------
  1883.   # ● 效果开始(追加定义)
  1884.   #--------------------------------------------------------------------------
  1885.   alias hzhj_old_start_effect_for_dead_spr_battler start_effect
  1886.   def start_effect(effect_type)
  1887.     if effect_type == :appear
  1888.       if @dead_graphic_used
  1889.         set_bitmap(:normal)
  1890.         @effect_type = nil
  1891.         @effect_duration = 0
  1892.         @dead_graphic_used = false
  1893.         @battler_visible = true
  1894.         return
  1895.       end
  1896.     elsif effect_type == :collapse or
  1897.           effect_type == :boss_collapse or
  1898.           effect_type == :instant_collapse
  1899.       if @beaten_duration >= 0
  1900.         @beaten_duration = -1
  1901.         set_bitmap(:normal)
  1902.       end
  1903.       if (UseActorDeadGraphic && @battler.actor?) or
  1904.          (UseEnemyDeadGraphic && @battler.enemy?)
  1905.         set_bitmap(:dead)
  1906.         @effect_type = nil
  1907.         @effect_duration = 0
  1908.         @dead_graphic_used = true
  1909.         @battler_visible = false
  1910.         return
  1911.       end
  1912.     end
  1913.     hzhj_old_start_effect_for_dead_spr_battler(effect_type)
  1914.   end
  1915.   #--------------------------------------------------------------------------
  1916.   # ● 设置新的位图(新增定义)
  1917.   #--------------------------------------------------------------------------
  1918.   def set_bitmap(sym)
  1919.     case sym
  1920.     when :normal
  1921.       @battler.set_normal_battler_name
  1922.     when :was_beaten
  1923.       @battler.set_beaten_battler_name
  1924.     when :dead
  1925.       @battler.set_dead_battler_name
  1926.     else
  1927.       return
  1928.     end
  1929.     new_bitmap = Cache.battler(@battler.battler_name, @battler.battler_hue)
  1930.     if bitmap != new_bitmap
  1931.       self.bitmap = new_bitmap
  1932.       @dynamic_duration = 0
  1933.       @sx = 0
  1934.       @sw = bitmap.width / DynamicPatternMax
  1935.       @sh = bitmap.height
  1936.       self.ox = @sw / 2
  1937.       self.oy = @sh
  1938.       src_rect.set(@sx, 0, @sw, @sh)
  1939.     end
  1940.     update_origin
  1941.     update_position
  1942.   end
  1943. end
  1944.  
  1945. #==============================================================================
  1946. # ■ Scene_Battle
  1947. #==============================================================================
  1948. class Scene_Battle < Scene_Base
  1949.   #--------------------------------------------------------------------------
  1950.   # ● 发动技能/物品(新增定义)
  1951.   #--------------------------------------------------------------------------
  1952.   def hzhj_invoke_item(target, item, damage_target)
  1953.     refresh_status
  1954.     @log_window.display_action_results(damage_target, item)
  1955.     @subject.damage_section_displayed = false
  1956.     @subject.last_target_index = target.index
  1957.     return if target.dead?
  1958.     if rand < target.item_cnt(@subject, item)
  1959.       hzhj_invoke_counter_attack(target, item)
  1960.     elsif rand < target.item_mrf(@subject, item)
  1961.       hzhj_invoke_magic_reflection(target, item)
  1962.     end
  1963.   end
  1964.   #--------------------------------------------------------------------------
  1965.   # ● 发动物理反击(新增定义)
  1966.   #--------------------------------------------------------------------------
  1967.   def hzhj_invoke_counter_attack(target, item)
  1968.     @log_window.display_counter(target, item)
  1969.     attack_skill = $data_skills[target.attack_skill_id]
  1970.     @subject.item_apply(target, attack_skill)
  1971.     need_move = false
  1972.     animation1 = $data_animations[target.animation1_id]
  1973.     need_move = animation1.need_move if animation1
  1974.     ary = [@subject]
  1975.     if need_move
  1976.       target.setup_move_info(@subject, RealMoveDuration, animation1.move_se)
  1977.       wait_for_move
  1978.     end
  1979.     @subject.damage_section_displayed = false
  1980.     @subject.not_damage_section = false
  1981.     show_subject_animation(target.animation1_id, target)
  1982.     show_normal_animation(ary, target.atk_animation_id1, false)
  1983.     show_normal_animation(ary, target.atk_animation_id2, true)
  1984.     @log_window.wait
  1985.     wait_for_animation
  1986.     if need_move && target.alive?
  1987.       target.come_back_self_position(RealMoveDuration)
  1988.       wait_for_move
  1989.     end
  1990.     refresh_status
  1991.     @log_window.display_action_results(@subject, attack_skill)
  1992.   end
  1993.   #--------------------------------------------------------------------------
  1994.   # ● 发动魔法反射(新增定义)
  1995.   #--------------------------------------------------------------------------
  1996.   def hzhj_invoke_magic_reflection(target, item)
  1997.     @subject.damage_section_displayed = false
  1998.     @subject.not_damage_section = false
  1999.     @log_window.display_reflection(target, item)
  2000.     @subject.item_apply(@subject, item)
  2001.     refresh_status
  2002.     @log_window.display_action_results(@subject, item)
  2003.   end
  2004. end
  2005.  
  2006. #==============================================================================
  2007. # ■ Game_Battler
  2008. #==============================================================================
  2009. class Game_Battler < Game_BattlerBase
  2010.   attr_accessor :damage_section_displayed
  2011.   attr_accessor :not_damage_section
  2012. end
  2013. #==============================================================================
  2014. # ■ Game_Actor
  2015. #==============================================================================
  2016. class Game_Actor < Game_Battler
  2017.   #--------------------------------------------------------------------------
  2018.   # ● 执行伤害效果
  2019.   #--------------------------------------------------------------------------
  2020.   alias hzhj_old_per_damage_for_damage_section_game_actor perform_damage_effect
  2021.   def perform_damage_effect
  2022.     unless damage_section_displayed
  2023.       hzhj_old_per_damage_for_damage_section_game_actor
  2024.     end
  2025.   end
  2026. end
  2027. #==============================================================================
  2028. # ■ Game_Enemy
  2029. #==============================================================================
  2030. class Game_Enemy < Game_Battler
  2031.   #--------------------------------------------------------------------------
  2032.   # ● 执行伤害效果
  2033.   #--------------------------------------------------------------------------
  2034.   alias hzhj_old_per_damage_for_damage_section_game_enemy perform_damage_effect
  2035.   def perform_damage_effect
  2036.     unless damage_section_displayed
  2037.       hzhj_old_per_damage_for_damage_section_game_enemy
  2038.     end
  2039.   end
  2040. end
  2041. #==============================================================================
  2042. # ■ Sprite_Battler
  2043. #==============================================================================
  2044. class Sprite_Battler < Sprite_Base
  2045.   #--------------------------------------------------------------------------
  2046.   # ● SE 和闪烁时机的处理
  2047.   #--------------------------------------------------------------------------
  2048.   def animation_process_timing(timing)
  2049.     if timing.se.name == DamageSectionDisplaySEName
  2050.       hp_value = @battler.result.hp_damage
  2051.       mp_value = @battler.result.mp_damage
  2052.       tp_value = @battler.result.tp_damage
  2053.       value = args = nil
  2054.       was_beaten = false
  2055.       if hp_value != 0 && !@battler.not_damage_section
  2056.         was_beaten = true if hp_value > 0
  2057.         value = hp_value * timing.flash_color.red.to_i / 100
  2058.         critical = @battler.result.critical
  2059.         args = [:hp, value, critical]
  2060.       elsif mp_value != 0 && !@battler.not_damage_section
  2061.         was_beaten = true if mp_value > 0
  2062.         value = mp_value * timing.flash_color.red.to_i / 100
  2063.         critical = @battler.result.critical
  2064.         args = [:mp, value, critical]
  2065.       elsif tp_value != 0 && !@battler.not_damage_section
  2066.         was_beaten = true if tp_value > 0
  2067.         value = tp_value * timing.flash_color.red.to_i / 100
  2068.         critical = @battler.result.critical
  2069.         args = [:tp, value, critical]
  2070.       end
  2071.       if value && args
  2072.         args[3] = @battler.actor? ? :actor : (@battler.enemy? ? :enemy : nil)
  2073.         @battler.damage_section_displayed = true
  2074.         start_damage(args)
  2075.         if UseBeatenGraphic && was_beaten
  2076.           set_bitmap(:was_beaten)
  2077.           @beaten_duration = BeatenGraphicDuration
  2078.         end
  2079.       end
  2080.       return
  2081.     end
  2082.     super(timing)
  2083.   end
  2084. end
  2085. #==============================================================================
  2086. # ■ Scene_Battle
  2087. #==============================================================================
  2088. class Scene_Battle < Scene_Base
  2089.   #--------------------------------------------------------------------------
  2090.   # ● 应用技能/物品效果(新增定义)
  2091.   #--------------------------------------------------------------------------
  2092.   def hzhj_apply_item_effects(target, item)
  2093.     target.damage_section_displayed = false
  2094.     target.not_damage_section = false
  2095.     target = apply_substitute(target, item)
  2096.     target.damage_section_displayed = false
  2097.     target.not_damage_section = false
  2098.     target.item_apply(@subject, item)
  2099.     return target
  2100.   end
  2101. end
  2102. #==============================================================================
  2103. # ■ 此脚本来自 [url]www.66rpg.com[/url]
  2104. #================================================
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
8629
在线时间
1465 小时
注册时间
2012-6-6
帖子
349
4
发表于 2017-1-9 22:43:19 | 只看该作者



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

评分

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

查看全部评分

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
40 小时
注册时间
2011-7-23
帖子
55
5
 楼主| 发表于 2017-1-9 22:57:52 | 只看该作者
感谢 ,我马上试一下
回复 支持 反对

使用道具 举报

Lv1.梦旅人

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

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-11-17 03:44

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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