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

Project1

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

[已经过期] 使用三个不同的战斗脚本后,战斗卡成狗

[复制链接]

Lv2.观梦者

梦石
0
星屑
293
在线时间
398 小时
注册时间
2011-5-20
帖子
128
跳转到指定楼层
1
发表于 2014-7-16 15:48:02 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

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

RUBY 代码复制
  1. #==============================================================================
  2. # +++ MOG - Advanced Battle Hud (v2.6) +++
  3. #==============================================================================
  4. # By Moghunter
  5. # [url]http://www.atelier-rgss.com/[/url]
  6. #==============================================================================
  7. # Sistema de hud avançado de batalha.
  8. #==============================================================================
  9.  
  10. #==============================================================================
  11. # ● Histórico (Version History)
  12. #==============================================================================
  13. # v 2.6 - Melhor codificação
  14. # v 2.5 - Melhoria na performance
  15. #       - Correção de bugs.
  16. #==============================================================================
  17. #
  18. # Battle_AT_Layout.png
  19. # Battle_AT_Meter.png
  20. #
  21. #==============================================================================
  22. # ■ - FACE ANIMADAS DOS PERSONAGENS - (Opcional)
  23. #==============================================================================
  24. # 1 - Grave as imagens das faces dos personagens na pasta.
  25. #
  26. # GRAPHICS/BATTLERS/
  27. #
  28. # 2 - Nomeie a imagem com o mesmo nome do personagem. (EG - Hertor.png)
  29. # 3 - A largura da imagem deverá ser dividido por 5. (A escolha do tamanho
  30. #     da face é livre desde que a lagura dividido pela altura seja igual a 5 )
  31. #
  32. #==============================================================================
  33.  
  34. #==============================================================================
  35. # ■ BATTLE HUD SETTING
  36. #==============================================================================
  37. module MOG_BATTLE_HUD
  38.   # Ativar Battlers dos personagens em faces, deixe desativado em caso de haver
  39.   # outros scripts que usam battlers dos personagens em seu projeto.
  40.   BATTLER_FACE_ENABLE = true
  41.   #Definição geral da posição da HUD.
  42.   HUD_POSITION = [5,315]
  43.   #Definição da posição da face
  44.   FACE_POSITION = [60,30]
  45.   #Definição da posição do numero de HP.
  46.   HP_NUMBER_POSITION = [85,28]
  47.   #Definição da posição do medidor de HP.
  48.   HP_METER_POSITION = [27,37]
  49.   #Definição da posição do numero de MP.
  50.   MP_NUMBER_POSITION = [101,46]
  51.   #Definição da posição do medidor de MP.
  52.   MP_METER_POSITION = [43,55]  
  53.   #Definição da posição do numero de TP.
  54.   TP_NUMBER_POSITION = [85,64]
  55.   #Definição da posição do medidor de TP.
  56.   TP_METER_POSITION = [27,73]   
  57.   #Definição da posição das condições
  58.   STATES_POSITION = [5,1]
  59.   #Definição da posição do comando de batalha.
  60.   COMMAND_POSITION = [0,-145]  
  61.   #Definição da posição do espaço da HUD entre os membros do grupo.
  62.   MEMBERS_SPACE = [136,0]
  63.   #Definição da prioridade da HUD.
  64.   BATTLE_HUD_Z = 0
  65.   #Definição da velocidade de animação dos medidores.
  66.   METER_FLOW_SPEED = 2
  67.   #Ativa o layout mais limpo nas janelas de item e skill.
  68.   ITEM_SKILL_WINDOWS_CLEAN_STYLE = true
  69.   #Definição da opacidade das janelas.
  70.   ITEM_SKILL_WINDOW_OPACITY = 0
  71.  
  72. end
  73.  
  74. #==============================================================================
  75. # ■ Game Temp
  76. #==============================================================================
  77. class Game_Temp
  78.  
  79.   attr_accessor :cache_battle_hud
  80.  
  81.   #--------------------------------------------------------------------------
  82.   # ● Initialize
  83.   #--------------------------------------------------------------------------   
  84.   alias mog_battle_hud_initialize initialize
  85.   def initialize
  86.       mog_battle_hud_initialize
  87.       pre_cache_battle_hud
  88.   end
  89.  
  90.   #--------------------------------------------------------------------------
  91.   # ● Pre Cache Battle Hud
  92.   #--------------------------------------------------------------------------  
  93.   def pre_cache_battle_hud
  94.       @cache_battle_hud = []
  95.       @cache_battle_hud.push(Cache.system("Battle_Hud_Number"))
  96.       @cache_battle_hud.push(Cache.system("Battle_Hud_Meter"))
  97.       @cache_battle_hud.push(Cache.system("IconSet"))
  98.       @cache_battle_hud.push(Cache.system("Battle_Hud_Layout"))
  99.   end
  100.  
  101. end
  102.  
  103. #==============================================================================
  104. # ■ Battle_Hud
  105. #==============================================================================
  106. class Battle_Hud
  107.   include MOG_BATTLE_HUD
  108.  
  109.   #--------------------------------------------------------------------------
  110.   # ● Initialize
  111.   #--------------------------------------------------------------------------   
  112.   def initialize(actor)      
  113.       @actor = actor
  114.       @x = HUD_POSITION[0] + (MEMBERS_SPACE[0] * @actor.index)
  115.       @y = HUD_POSITION[1] + (MEMBERS_SPACE[1] * @actor.index)
  116.       @flow_speed = 0
  117.       pre_cache
  118.       create_layout
  119.       create_hp_number
  120.       create_hp_meter
  121.       create_mp_number
  122.       create_mp_meter
  123.       create_tp_number
  124.       create_tp_meter
  125.       create_states
  126.   end
  127.  
  128.   #--------------------------------------------------------------------------
  129.   # ● Pre Cache
  130.   #--------------------------------------------------------------------------      
  131.   def pre_cache
  132.       $game_temp.pre_cache_battle_hud
  133.       @number = $game_temp.cache_battle_hud[0]
  134.       @number_cw = @number.width / 10
  135.       @number_ch = @number.height / 4
  136.       @meter = $game_temp.cache_battle_hud[1]
  137.       @meter_cw = @meter.width / 3
  138.       @meter_ch = @meter.height / 3
  139.       @icon = $game_temp.cache_battle_hud[2]
  140.   end
  141.  
  142.   #--------------------------------------------------------------------------
  143.   # ● Create Layout
  144.   #--------------------------------------------------------------------------      
  145.   def create_layout
  146.       @layout = Sprite.new
  147.       @layout.bitmap = $game_temp.cache_battle_hud[3]
  148.       @layout.z = BATTLE_HUD_Z
  149.       @layout.x = @x
  150.       @layout.y = @y
  151.   end
  152.  
  153.   #--------------------------------------------------------------------------
  154.   # ● Create HP Number
  155.   #--------------------------------------------------------------------------        
  156.   def create_hp_number
  157.       @hp = @actor.hp
  158.       @hp_old = @actor.hp
  159.       @hp_ref = @hp_old
  160.       @hp_refresh = false
  161.       @hp_number = Sprite.new
  162.       @hp_number.bitmap = Bitmap.new((@number_cw * 6),@number_ch)
  163.       @hp_number.z = BATTLE_HUD_Z + 2
  164.       @hp_number.x = @x + HP_NUMBER_POSITION[0]
  165.       @hp_number.y = @y + HP_NUMBER_POSITION[1]
  166.       refresh_hp_number
  167.   end
  168.  
  169.   #--------------------------------------------------------------------------
  170.   # ● Create HP Meter
  171.   #--------------------------------------------------------------------------      
  172.   def create_hp_meter
  173.       @hp_meter = Sprite.new
  174.       @hp_meter.bitmap = Bitmap.new(@meter_cw,@meter_ch)
  175.       @hp_meter.z =  BATTLE_HUD_Z + 1
  176.       @hp_meter.x = @x + HP_METER_POSITION[0]
  177.       @hp_meter.y = @y + HP_METER_POSITION[1]
  178.       @hp_flow = rand(@meter_cw * 2)
  179.       @hp_width_old = @meter_cw * @actor.hp / @actor.mhp
  180.       hp_flow_update
  181.   end  
  182.  
  183.   #--------------------------------------------------------------------------
  184.   # ● Hp Flow Update
  185.   #--------------------------------------------------------------------------
  186.   def hp_flow_update
  187.       @hp_meter.bitmap.clear
  188.       hp_width = @meter_cw * @actor.hp / @actor.mhp
  189.       hp_src_rect = Rect.new(@hp_flow, 0,hp_width, @meter_ch)
  190.       @hp_meter.bitmap.blt(0,0, @meter, hp_src_rect)
  191.       @hp_flow += METER_FLOW_SPEED
  192.       @hp_flow = 0 if @hp_flow >=  @meter_cw * 2      
  193.   end
  194.  
  195.   #--------------------------------------------------------------------------
  196.   # ● Execute Damage Flow
  197.   #--------------------------------------------------------------------------
  198.   def execute_damage_flow(hp_width)
  199.      n = (@hp_width_old - hp_width).abs * 3 / 100
  200.      damage_flow = [[n, 2].min,0.5].max
  201.      @hp_width_old -= damage_flow         
  202.      @hp_width_old = hp_width if @hp_width_old < hp_width
  203.      src_rect_old = Rect.new(@hp_flow, @meter_ch * 3,@hp_width_old, @meter_ch)
  204.      @hp_meter.bitmap.blt(0,0, @meter, src_rect_old)      
  205.   end  
  206.  
  207.   #--------------------------------------------------------------------------
  208.   # ● Update HP Number
  209.   #--------------------------------------------------------------------------      
  210.   def update_hp_number
  211.       @hp_refresh = true
  212.       n =  2 * (@actor.hp - @hp_old).abs / 100
  213.       hp_ref = [[n, 100].min,1].max
  214.       if @hp_old < @actor.hp
  215.           @hp += hp_ref     
  216.           if @hp >= @actor.hp
  217.              @hp_old = @actor.hp
  218.              @hp = @actor.hp   
  219.              @hp_ref = 0
  220.           end              
  221.         elsif @hp_old > @actor.hp   
  222.            @hp -= hp_ref               
  223.            if @hp <= @actor.hp
  224.               @hp_old = @actor.hp
  225.               @hp = @actor.hp   
  226.               @hp_ref = 0
  227.            end            
  228.         end         
  229.   end  
  230.  
  231.   #--------------------------------------------------------------------------
  232.   # ● Refresh HP Number
  233.   #--------------------------------------------------------------------------      
  234.   def refresh_hp_number
  235.       @flow_speed = METER_FLOW_SPEED
  236.       @hp_number.bitmap.clear
  237.       number_value = @hp.abs.to_s.split(//)
  238.       hp_color = @hp < @actor.mhp * 30 / 100 ? @number_ch : 0
  239.       center_x = 0
  240.       for r in 0..number_value.size - 1         
  241.          number_value_abs = number_value[r].to_i
  242.          src_rect = Rect.new(@number_cw * number_value_abs, hp_color, @number_cw, @number_ch)
  243.          @hp_number.bitmap.blt((@number_cw + 1) *  r, 0, @number, src_rect)
  244.          center_x += 1
  245.       end
  246.       @hp_number.x = @x + HP_NUMBER_POSITION[0] - (center_x * (@number_cw + 1))
  247.       @hp_refresh = false if @hp == @actor.hp      
  248.   end  
  249.  
  250.   #--------------------------------------------------------------------------
  251.   # ● Create MP Number
  252.   #--------------------------------------------------------------------------        
  253.   def create_mp_number
  254.       @mp = @actor.mp
  255.       @mp_old = @actor.mp
  256.       @mp_ref = @mp_old
  257.       @mp_refresh = false
  258.       @mp_number = Sprite.new
  259.       @mp_number.bitmap = Bitmap.new((@number_cw * 6),@number_ch)
  260.       @mp_number.z = BATTLE_HUD_Z + 2
  261.       @mp_number.x = @x + MP_NUMBER_POSITION[0]
  262.       @mp_number.y = @y + MP_NUMBER_POSITION[1]
  263.       refresh_mp_number
  264.   end
  265.  
  266.   #--------------------------------------------------------------------------
  267.   # ● Create MP Meter
  268.   #--------------------------------------------------------------------------      
  269.   def create_mp_meter
  270.       @mp_meter = Sprite.new
  271.       @mp_meter.bitmap = Bitmap.new(@meter_cw,@meter_ch)
  272.       @mp_meter.z =  BATTLE_HUD_Z + 1
  273.       @mp_meter.x = @x + MP_METER_POSITION[0]
  274.       @mp_meter.y = @y + MP_METER_POSITION[1]
  275.       @mp_flow = rand(@meter_cw * 2)
  276.       @mp_width_old = @meter_cw * @actor.mp / @actor.mmp rescue 0
  277.       mp_flow_update
  278.   end  
  279.  
  280.   #--------------------------------------------------------------------------
  281.   # ● Mp Flow Update
  282.   #--------------------------------------------------------------------------
  283.   def mp_flow_update
  284.       return if @actor.mmp == 0
  285.       @mp_meter.bitmap.clear
  286.       mp_width = @meter_cw * @actor.mp / @actor.mmp rescue 0
  287.       src_rect = Rect.new(@mp_flow, @meter_ch,mp_width, @meter_ch)
  288.       @mp_meter.bitmap.blt(0,0, @meter, src_rect)
  289.       @mp_flow += METER_FLOW_SPEED
  290.       @mp_flow = 0 if @mp_flow >=  @meter_cw * 2      
  291.     end
  292.  
  293.   #--------------------------------------------------------------------------
  294.   # ● Update MP Number
  295.   #--------------------------------------------------------------------------      
  296.   def update_mp_number
  297.       @mp_refresh = true
  298.       n =  2 * (@actor.mp - @mp_old).abs / 100
  299.       mp_ref = [[n, 100].min,1].max
  300.       if @mp_old < @actor.mp
  301.           @mp += mp_ref     
  302.           if @mp >= @actor.mp
  303.              @mp_old = @actor.mp
  304.              @mp = @actor.mp   
  305.              @mp_ref = 0
  306.           end              
  307.         elsif @mp_old > @actor.mp   
  308.            @mp -= mp_ref               
  309.            if @mp <= @actor.mp
  310.               @mp_old = @actor.mp
  311.               @mp = @actor.mp   
  312.               @mp_ref = 0
  313.            end            
  314.         end         
  315.   end  
  316.  
  317.   #--------------------------------------------------------------------------
  318.   # ● Refresh MP Number
  319.   #--------------------------------------------------------------------------      
  320.   def refresh_mp_number
  321.       @flow_speed = METER_FLOW_SPEED
  322.       @mp_number.bitmap.clear
  323.       number_value = @mp.abs.to_s.split(//)
  324.       center_x = 0
  325.       for r in 0..number_value.size - 1         
  326.          number_value_abs = number_value[r].to_i
  327.          src_rect = Rect.new(@number_cw * number_value_abs, @number_ch * 2, @number_cw, @number_ch)
  328.          @mp_number.bitmap.blt((@number_cw + 1) *  r, 0, @number, src_rect)
  329.          center_x += 1
  330.       end
  331.       @mp_number.x = @x + MP_NUMBER_POSITION[0] - (center_x * (@number_cw + 1))
  332.       @mp_refresh = false if @mp == @actor.mp      
  333.   end  
  334.  
  335.   #--------------------------------------------------------------------------
  336.   # ● Create TP Number
  337.   #--------------------------------------------------------------------------        
  338.   def create_tp_number
  339.       @tp = @actor.tp
  340.       @tp_old = @actor.tp
  341.       @tp_ref = @tp_old
  342.       @tp_refresh = false
  343.       @tp_number = Sprite.new
  344.       @tp_number.bitmap = Bitmap.new((@number_cw * 6),@number_ch)
  345.       @tp_number.z = BATTLE_HUD_Z + 2
  346.       @tp_number.x = @x + TP_NUMBER_POSITION[0]
  347.       @tp_number.y = @y + TP_NUMBER_POSITION[1]
  348.       refresh_tp_number
  349.   end
  350.  
  351.   #--------------------------------------------------------------------------
  352.   # ● Create TP Meter
  353.   #--------------------------------------------------------------------------      
  354.   def create_tp_meter
  355.       @tp_meter = Sprite.new
  356.       @tp_meter.bitmap = Bitmap.new(@meter_cw,@meter_ch)
  357.       @tp_meter.z =  BATTLE_HUD_Z + 1
  358.       @tp_meter.x = @x + TP_METER_POSITION[0]
  359.       @tp_meter.y = @y + TP_METER_POSITION[1]
  360.       @tp_flow = rand(@meter_cw * 2)
  361.       @tp_width_old = @meter_cw * @actor.tp / @actor.max_tp rescue 0
  362.       tp_flow_update
  363.   end  
  364.  
  365.   #--------------------------------------------------------------------------
  366.   # ● TP Flow Update
  367.   #--------------------------------------------------------------------------
  368.   def tp_flow_update
  369.       return if @actor.max_tp == 0
  370.       @tp_meter.bitmap.clear
  371.       tp_width = @meter_cw * @actor.tp / @actor.max_tp rescue 0
  372.       src_rect = Rect.new(@tp_flow, @meter_ch * 2,tp_width, @meter_ch)
  373.       @tp_meter.bitmap.blt(0,0, @meter, src_rect)
  374.       @tp_flow += METER_FLOW_SPEED
  375.       @tp_flow = 0 if @tp_flow >=  @meter_cw * 2      
  376.   end
  377.  
  378.   #--------------------------------------------------------------------------
  379.   # ● Update TP Number
  380.   #--------------------------------------------------------------------------      
  381.   def update_tp_number
  382.       @tp_refresh = true
  383.       n =  2 * (@actor.tp - @tp_old).abs / 100
  384.       tp_ref = [[n, 100].min,1].max
  385.       if @tp_old < @actor.tp
  386.           @tp += tp_ref     
  387.           if @tp >= @actor.tp
  388.              @tp_old = @actor.tp
  389.              @tp = @actor.tp   
  390.              @tp_ref = 0
  391.           end              
  392.         elsif @tp_old > @actor.tp   
  393.            @tp -= tp_ref               
  394.            if @tp <= @actor.tp
  395.               @tp_old = @actor.tp
  396.               @tp = @actor.tp   
  397.               @tp_ref = 0
  398.            end           
  399.          end            
  400.   end      
  401.  
  402.   #--------------------------------------------------------------------------
  403.   # ● Refresh TP Number
  404.   #--------------------------------------------------------------------------      
  405.   def refresh_tp_number
  406.       @flow_speed = METER_FLOW_SPEED
  407.       @tp_number.bitmap.clear
  408.       number_value = @tp.truncate.to_s.split(//)
  409.       center_x = 0
  410.       for r in 0..number_value.size - 1        
  411.          number_value_abs = number_value[r].to_i
  412.          src_rect = Rect.new(@number_cw * number_value_abs, @number_ch * 3, @number_cw, @number_ch)
  413.          @tp_number.bitmap.blt((@number_cw + 1) *  r, 0, @number, src_rect)
  414.          center_x += 1
  415.       end
  416.       @tp_number.x = @x + TP_NUMBER_POSITION[0] - (center_x * (@number_cw + 1))
  417.       @tp_refresh = false if @tp == @actor.tp
  418.   end   
  419.  
  420.   #--------------------------------------------------------------------------
  421.   # ● Create_States
  422.   #--------------------------------------------------------------------------      
  423.   def create_states
  424.       refresh_states
  425.       @status = Sprite.new
  426.       @status.bitmap = Bitmap.new(24,24)
  427.       @status.x = @x + STATES_POSITION[0]
  428.       @status.y = @y + STATES_POSITION[1]      
  429.       @status_flow = -24
  430.       @states_speed = 50
  431.       @status.z = BATTLE_HUD_Z + 2
  432.       @old_states = @actor.states
  433.       flow_states
  434.   end  
  435.  
  436.   #--------------------------------------------------------------------------
  437.   # ● Flow_Status
  438.   #--------------------------------------------------------------------------         
  439.   def flow_states
  440.       return if @actor.states.size == 0 and !@status.visible
  441.       @states_speed = 0
  442.       @status.bitmap.clear
  443.       src_rect = Rect.new(@status_flow,0, 24,24)
  444.       @status.bitmap.blt(0,0, @actor_status, src_rect)
  445.       @status.visible = @actor.states.size == 0 ? false : true
  446.       @status_flow += 1
  447.       @status_flow = -24 if @status_flow >= @states_size - 24
  448.   end   
  449.  
  450.   #--------------------------------------------------------------------------
  451.   # ● Refresh States
  452.   #--------------------------------------------------------------------------        
  453.   def refresh_states
  454.       @old_states = @actor.states
  455.       @actor_status.dispose if @actor_status != nil
  456.       @states_size = @actor.states.size > 0 ? (48 * @actor.states.size) : 24
  457.       @actor_status = Bitmap.new(@states_size,24)
  458.       index = 0
  459.       for i in  @actor.states
  460.          rect = Rect.new(i.icon_index % 16 * 24, i.icon_index / 16 * 24, 24, 24)
  461.          @actor_status.blt(48 * index , 0, @icon, rect)
  462.          index += 1
  463.       end
  464.   end  
  465.  
  466.   #--------------------------------------------------------------------------
  467.   # ● Dispose
  468.   #--------------------------------------------------------------------------   
  469.   def dispose
  470.       return if @layout == nil
  471.       @layout.dispose
  472.       @hp_number.bitmap.dispose
  473.       @hp_number.dispose
  474.       @hp_meter.bitmap.dispose
  475.       @hp_meter.dispose
  476.       @mp_number.bitmap.dispose
  477.       @mp_number.dispose
  478.       @mp_meter.bitmap.dispose
  479.       @mp_meter.dispose      
  480.       @tp_number.bitmap.dispose
  481.       @tp_number.dispose
  482.       @tp_meter.bitmap.dispose
  483.       @tp_meter.dispose
  484.       @status.bitmap.dispose
  485.       @status.dispose
  486.       @actor_status.dispose if @actor_status != nil
  487.       @layout = nil
  488.   end
  489.  
  490.   #--------------------------------------------------------------------------
  491.   # ● Update
  492.   #--------------------------------------------------------------------------   
  493.   def update
  494.       return if @meter == nil
  495.       update_hp_number if @hp_old != @actor.hp
  496.       refresh_hp_number if @hp_refresh
  497.       update_mp_number if @mp_old != @actor.mp
  498.       refresh_mp_number if @mp_refresh
  499.       update_tp_number if @tp_old != @actor.tp
  500.       refresh_tp_number if @tp_refresh
  501.       refresh_states if @old_states != @actor.states
  502.       @flow_speed += 1
  503.       if @flow_speed >= METER_FLOW_SPEED
  504.          @flow_speed = 0
  505.          hp_flow_update
  506.          tp_flow_update
  507.          mp_flow_update
  508.       end
  509.       flow_states
  510.   end
  511.  
  512. end
  513.  
  514. #==============================================================================
  515. # ■ Game_System
  516. #==============================================================================
  517. class Game_System
  518.  
  519.   attr_accessor :battler_hud
  520.  
  521.   #--------------------------------------------------------------------------
  522.   # ● Initialize
  523.   #--------------------------------------------------------------------------   
  524.   alias mog_adv_battle_hud_initialize initialize
  525.   def initialize      
  526.       @battler_hud = false
  527.       mog_adv_battle_hud_initialize
  528.   end  
  529.  
  530. end
  531.  
  532. #==============================================================================
  533. # ■ Spriteset Battle
  534. #==============================================================================
  535. class Spriteset_Battle
  536.  
  537.   #--------------------------------------------------------------------------
  538.   # ● Initialize
  539.   #--------------------------------------------------------------------------  
  540.   alias mog_battle_hud_initialize initialize
  541.   def initialize
  542.       mog_battle_hud_initialize
  543.       create_battle_hud      
  544.   end
  545.  
  546.   #--------------------------------------------------------------------------
  547.   # ● Create Battle Hud
  548.   #--------------------------------------------------------------------------   
  549.   def create_battle_hud
  550.       @battle_hud = []
  551.       for i in $game_party.battle_members
  552.           @battle_hud.push(Battle_Hud.new(i))
  553.       end
  554.   end
  555.  
  556.   #--------------------------------------------------------------------------
  557.   # ● Dispose
  558.   #--------------------------------------------------------------------------      
  559.   alias mog_battle_hud_dispose dispose
  560.   def dispose
  561.       mog_battle_hud_dispose
  562.       dispose_battle_hud
  563.   end  
  564.  
  565.   #--------------------------------------------------------------------------
  566.   # ● Dispose Battle Hud
  567.   #--------------------------------------------------------------------------        
  568.   def dispose_battle_hud
  569.       return if @battle_hud == nil
  570.       @battle_hud.each {|sprite| sprite.dispose }
  571.       @battle_hud = nil
  572.   end
  573.  
  574.   #--------------------------------------------------------------------------
  575.   # ● Update
  576.   #--------------------------------------------------------------------------        
  577.   alias mog_battle_hud_update update
  578.   def update
  579.       mog_battle_hud_update
  580.       update_battle_hud
  581.   end
  582.  
  583.   #--------------------------------------------------------------------------
  584.   # ● Update Battle Hud
  585.   #--------------------------------------------------------------------------         
  586.   def update_battle_hud
  587.       return if @battle_hud == nil
  588.       @battle_hud.each {|sprite| sprite.update }
  589.   end
  590.  
  591. end
  592.  
  593. #==============================================================================
  594. # ■ Game_Actor  #测试
  595. #==============================================================================
  596. class Game_Actor < Game_Battler
  597.   include MOG_BATTLE_HUD
  598.  
  599.    attr_accessor :hud_x
  600.    attr_accessor :hud_y
  601.  
  602.   #--------------------------------------------------------------------------
  603.   # ● HUD X
  604.   #--------------------------------------------------------------------------     
  605.   def hud_x
  606.       return HUD_POSITION[0] + (MEMBERS_SPACE[0] * index)
  607.   end
  608.  
  609.   #--------------------------------------------------------------------------
  610.   # ● HUD Y
  611.   #--------------------------------------------------------------------------   
  612.   def hud_y
  613.       return HUD_POSITION[1] + (MEMBERS_SPACE[1] * index)
  614.   end
  615.  
  616. end  
  617.  
  618. #==============================================================================
  619. # ■ Scene Battle
  620. #==============================================================================
  621. class Scene_Battle < Scene_Base
  622.  
  623.   #--------------------------------------------------------------------------
  624.   # ● Create Party Command Window
  625.   #--------------------------------------------------------------------------   
  626.   alias mog_battle_hud_create_party_command_window create_party_command_window
  627.   def create_party_command_window
  628.       mog_battle_hud_create_party_command_window
  629.       set_party_window_position
  630.   end  
  631.  
  632.   #--------------------------------------------------------------------------
  633.   # ● Set Party Window Position
  634.   #--------------------------------------------------------------------------      
  635.   def set_party_window_position
  636.       @party_command_window.viewport = nil  
  637.       return if $mog_rgss3_at_system != nil
  638.       a_index = []
  639.       for actor in $game_party.alive_members
  640.           a_index = [actor.hud_x, actor.hud_y]
  641.           break
  642.       end
  643.       return if a_index.empty?
  644.       @party_command_window.x = MOG_BATTLE_HUD::COMMAND_POSITION[0] + a_index[0]
  645.       @party_command_window.y = MOG_BATTLE_HUD::COMMAND_POSITION[1] + a_index[1]      
  646.   end  
  647.  
  648.   #--------------------------------------------------------------------------
  649.   # ● Set Party Window Position
  650.   #--------------------------------------------------------------------------        
  651.   alias mog_battle_hud_start_party_command_selection start_party_command_selection
  652.   def start_party_command_selection
  653.       set_party_window_position
  654.       mog_battle_hud_start_party_command_selection
  655.   end  
  656.  
  657.   #--------------------------------------------------------------------------
  658.   # ● Update
  659.   #--------------------------------------------------------------------------  
  660.   alias mog_battle_hud_update_basic update_basic
  661.   def update_basic
  662.       mog_battle_hud_update_basic
  663.       update_command_window_visible
  664.   end  
  665.  
  666.   #--------------------------------------------------------------------------
  667.   # ● Update Command Window Visible
  668.   #--------------------------------------------------------------------------   
  669.   def update_command_window_visible
  670.       @status_window.visible = @status_window.active ? true : false
  671.       @actor_command_window.visible = @actor_command_window.active ? true : false
  672.       @skill_window.visible = @skill_window.active ? true : false
  673.       @item_window.visible = @item_window.active ? true : false      
  674.   end
  675.  
  676. #~   #--------------------------------------------------------------------------
  677. #~   # ● Start Actor Command Selection    #测试
  678. #~   #--------------------------------------------------------------------------   
  679.   alias mog_battle_hud_start_actor_command_selection start_actor_command_selection
  680.   def start_actor_command_selection
  681.       mog_battle_hud_start_actor_command_selection
  682.       @actor_command_window.viewport = nil
  683.       @actor_command_window.x = MOG_BATTLE_HUD::COMMAND_POSITION[0] + $game_party.members[BattleManager.actor.index].hud_x
  684.       @actor_command_window.y = MOG_BATTLE_HUD::COMMAND_POSITION[1] + $game_party.members[BattleManager.actor.index].hud_y
  685.       @party_command_window.x = @actor_command_window.x
  686.       @party_command_window.y = @actor_command_window.y  
  687.   end  
  688.  
  689. end
  690.  
  691. #~ #==============================================================================
  692. #~ # ■ Game_Actor
  693. #~ #==============================================================================
  694. #~ class Game_Actor < Game_Battler
  695. #~   include MOG_BATTLE_HUD
  696. #~   
  697. #~   attr_accessor :battler_face
  698. #~   attr_accessor :battler_face_name
  699. #~   attr_accessor :screen_x
  700. #~   attr_accessor :screen_y
  701. #~   attr_accessor :screen_z
  702. #~   
  703. #~   #--------------------------------------------------------------------------
  704. #~   # ● Initialize
  705. #~   #--------------------------------------------------------------------------
  706. #~   alias mog_battle_hud_initialize setup
  707. #~   def setup(actor_id)
  708. #~       mog_battle_hud_initialize(actor_id)
  709. #~       battler_sprite_setup
  710. #~   end  
  711. #~     
  712. #~   #--------------------------------------------------------------------------
  713. #~   # ● Battler Sprite Setup
  714. #~   #--------------------------------------------------------------------------  
  715. #~   def battler_sprite_setup
  716. #~       @battler_face = [0,0,0]
  717. #~       @battler_face_name = @name + "_Face"
  718. #~   end
  719.  
  720. #~   if BATTLER_FACE_ENABLE
  721. #~   #--------------------------------------------------------------------------
  722. #~   # ● Use Sprite?
  723. #~   #--------------------------------------------------------------------------
  724. #~   def use_sprite?
  725. #~       return true
  726. #~   end
  727. #~   end
  728. #~   
  729. #~ end
  730.  
  731. #~ #==============================================================================
  732. #~ # ■ Sprite_Battler
  733. #~ #==============================================================================
  734. #~ class Sprite_Battler < Sprite_Base
  735. #~   include MOG_BATTLE_HUD
  736. #~   
  737. #~   #--------------------------------------------------------------------------
  738. #~   # ● Dispose
  739. #~   #--------------------------------------------------------------------------   
  740. #~   alias mog_battler_face_dispose dispose
  741. #~   def dispose
  742. #~       mog_battler_face_dispose
  743. #~       dispose_battler_face
  744. #~   end  
  745. #~   
  746. #~   #--------------------------------------------------------------------------
  747. #~   # ● Update
  748. #~   #--------------------------------------------------------------------------   
  749. #~   alias mog_battler_face_update update
  750. #~   def update
  751. #~       refresh_face_battler
  752. #~       mog_battler_face_update
  753. #~       update_battler_face
  754. #~   end
  755. #~     
  756. #~   #--------------------------------------------------------------------------
  757. #~   # ● Refresh Face Battler
  758. #~   #--------------------------------------------------------------------------     
  759. #~   def refresh_face_battler
  760. #~       return if @face_sprite != nil
  761. #~       return if @battler == nil
  762. #~       return if @battler.is_a?(Game_Enemy)
  763. #~       setup_battler_screen if @battler.screen_x == nil or $game_system.battler_hud
  764. #~       @face_sprite = Battler_Face_Sprite.new(self.viewport, @battler)
  765. #~   end  
  766. #~   
  767. #~   #--------------------------------------------------------------------------
  768. #~   # ● Setup Battler Screen
  769. #~   #--------------------------------------------------------------------------      
  770. #~   def setup_battler_screen
  771. #~       $game_system.battler_hud = true
  772. #~       @battler.screen_x = FACE_POSITION[0] + HUD_POSITION[0] + (MEMBERS_SPACE[0] * @battler.index)
  773. #~       @battler.screen_y = FACE_POSITION[1] + HUD_POSITION[1] + (MEMBERS_SPACE[1] * @battler.index)
  774. #~       @battler.screen_z = 103 if @battler.screen_z == nil
  775. #~   end  
  776. #~   
  777. #~   #--------------------------------------------------------------------------
  778. #~   # ● Dispose Battler Face
  779. #~   #--------------------------------------------------------------------------      
  780. #~   def dispose_battler_face
  781. #~       return if @face_sprite == nil
  782. #~       @face_sprite.dispose  
  783. #~   end
  784. #~   
  785. #~   #--------------------------------------------------------------------------
  786. #~   # ● Update Battler Face
  787. #~   #--------------------------------------------------------------------------      
  788. #~   def update_battler_face
  789. #~       return if @face_sprite == nil
  790. #~       @face_sprite.update_actor_battler
  791. #~   end  
  792. #~   
  793. #~   #--------------------------------------------------------------------------
  794. #~   # ● Update Posiion
  795. #~   #--------------------------------------------------------------------------         
  796. #~   alias mog_battler_face_update_position update_position
  797. #~   def update_position
  798. #~       mog_battler_face_update_position
  799. #~       update_face_z
  800. #~   end  
  801. #~   
  802. #~   #--------------------------------------------------------------------------
  803. #~   # ● Update Face Z
  804. #~   #--------------------------------------------------------------------------         
  805. #~   def update_face_z
  806. #~       return if @face_sprite == nil
  807. #~       @face_sprite.update_face_z(self.z)
  808. #~   end
  809.  
  810. #~   #--------------------------------------------------------------------------
  811. #~   # ● Update Collapse
  812. #~   #--------------------------------------------------------------------------                          
  813. #~    alias mog_battle_hud_update_collapse update_collapse
  814. #~    def update_collapse
  815. #~        if face_can_cancel_method?
  816. #~          self.opacity = 255
  817. #~          self.visible = true
  818. #~          return
  819. #~       end
  820. #~        mog_battle_hud_update_collapse
  821. #~    end  
  822. #~   
  823. #~   #--------------------------------------------------------------------------
  824. #~   # ● Update Instant Collapse
  825. #~   #--------------------------------------------------------------------------                             
  826. #~    alias mog_battle_hud_update_instant_collapse update_instant_collapse
  827. #~    def update_instant_collapse
  828. #~       if face_can_cancel_method?
  829. #~          self.opacity = 255
  830. #~          self.visible = true
  831. #~          return
  832. #~       end
  833. #~        mog_battle_hud_update_instant_collapse
  834. #~    end  
  835. #~   
  836. #~   #--------------------------------------------------------------------------
  837. #~   # ● Init Visibility
  838. #~   #--------------------------------------------------------------------------                                
  839. #~   alias mog_battle_face_init_visibility init_visibility
  840. #~   def init_visibility
  841. #~       if face_can_cancel_method?
  842. #~          self.opacity = 255
  843. #~          self.visible = true
  844. #~          return
  845. #~       end
  846. #~       mog_battle_face_init_visibility
  847. #~   end
  848. #~   
  849. #~   #--------------------------------------------------------------------------
  850. #~   # ● Face Can Cancel Method
  851. #~   #--------------------------------------------------------------------------                                 
  852. #~   def face_can_cancel_method?
  853. #~       return false if !BATTLER_FACE_ENABLE
  854. #~       return false if @battler.is_a?(Game_Enemy)
  855. #~       return false if !$game_system.battler_hud
  856. #~       return true
  857. #~   end  
  858. #~   
  859. #~ end
  860.  
  861. #~ #==============================================================================
  862. #~ # ■ Battler Face Sprite
  863. #~ #==============================================================================
  864. #~ class Battler_Face_Sprite < Sprite
  865. #~   include MOG_BATTLE_HUD
  866. #~   
  867. #~   #--------------------------------------------------------------------------
  868. #~   # ● Initialize
  869. #~   #--------------------------------------------------------------------------               
  870. #~    def initialize(viewport = nil,battler)
  871. #~        super(viewport)
  872. #~        @battler = battler
  873. #~        @f_im = Cache.battler(@battler.battler_face_name, 0)
  874. #~        @f_cw = @f_im.width / 5
  875. #~        @f_ch = @f_im.height
  876. #~        self.bitmap = Bitmap.new(@f_cw,@f_ch)
  877. #~        x = -(@f_cw / 2) + FACE_POSITION[0] + HUD_POSITION[0] + (MEMBERS_SPACE[0] * @battler.index)
  878. #~        y = -@f_ch + FACE_POSITION[1] + HUD_POSITION[1] + (MEMBERS_SPACE[1] * @battler.index)
  879. #~        @org_pos = [x,y]
  880. #~        @battler.battler_face = [0,0,0]
  881. #~        @battler_visible = true
  882. #~        @low_hp = @battler.mhp * 30 / 100
  883. #~        @old_face_index = 0
  884. #~        self.z = @battler.screen_z
  885. #~        make_face(true)
  886. #~    end
  887. #~   
  888. #~   #--------------------------------------------------------------------------
  889. #~   # ● Dispose
  890. #~   #--------------------------------------------------------------------------                       
  891. #~   def dispose
  892. #~       super
  893. #~       dispose_battler_face_sprite
  894. #~   end   
  895.  
  896. #~   #--------------------------------------------------------------------------
  897. #~   # ● Dispose Battler Face Sprite
  898. #~   #--------------------------------------------------------------------------                    
  899. #~   def dispose_battler_face_sprite
  900. #~        self.bitmap.dispose
  901. #~        @f_im.dispose
  902. #~   end  
  903. #~   
  904. #~   #--------------------------------------------------------------------------
  905. #~   # ● Update
  906. #~   #--------------------------------------------------------------------------  
  907. #~   def update_face_sprite(battler)
  908. #~       @battler = battler
  909. #~       update_face_reset_time
  910. #~       update_face_effect
  911. #~   end
  912. #~   
  913. #~   #--------------------------------------------------------------------------
  914. #~   # ● Face Base Setting
  915. #~   #--------------------------------------------------------------------------                 
  916. #~   def face_base_setting
  917. #~       self.x = @org_pos[0]
  918. #~       self.y = @org_pos[1]
  919. #~       self.zoom_x = 1
  920. #~       self.zoom_y = 1
  921. #~       self.mirror = false   
  922. #~   end
  923. #~   
  924. #~   #--------------------------------------------------------------------------
  925. #~   # ● Check Base Face
  926. #~   #--------------------------------------------------------------------------              
  927. #~    def check_base_face(reset)
  928. #~        face_base_setting
  929. #~        return if @battler.battler_face[2] > 0
  930. #~        @battler.battler_face = [0,0,0] if reset and @battler.battler_face[1] != 2  
  931. #~        @battler.battler_face[0] = 3 if @battler.hp < @low_hp
  932. #~        @battler.battler_face[0] = 4 if @battler.hp == 0
  933. #~    end  
  934. #~   
  935. #~   #--------------------------------------------------------------------------
  936. #~   # ● Make Face
  937. #~   #--------------------------------------------------------------------------              
  938. #~    def make_face(reset = false)
  939. #~        self.bitmap.clear
  940. #~        check_base_face(reset)
  941. #~        src_rect_back = Rect.new(@f_cw * @battler.battler_face[0], 0, @f_cw, @f_ch)
  942. #~        self.bitmap.blt(0,0, @f_im, src_rect_back)
  943. #~        @old_face_index = @battler.battler_face[0]
  944. #~    end  
  945.  
  946. #~   #--------------------------------------------------------------------------
  947. #~   # ● Update Actor Battler
  948. #~   #--------------------------------------------------------------------------           
  949. #~    def update_actor_battler
  950. #~        return if self.bitmap == nil
  951. #~        update_face_effect
  952. #~        update_face_reset_time
  953. #~        make_face if @old_face_index != @battler.battler_face[0]              
  954. #~    end
  955. #~   
  956. #~   #--------------------------------------------------------------------------
  957. #~   # ● Update Face Z
  958. #~   #--------------------------------------------------------------------------                 
  959. #~   def update_face_z(value)
  960. #~       self.z = value + 2
  961. #~   end  
  962. #~   
  963. #~   #--------------------------------------------------------------------------
  964. #~   # ● Update Face Reset Time
  965. #~   #--------------------------------------------------------------------------              
  966. #~    def update_face_reset_time
  967. #~        return if @battler.battler_face[2] == 0
  968. #~        @battler.battler_face[2] -= 1
  969. #~        if @battler.battler_face[2] == 0 or
  970. #~          (@battler.hp < @low_hp and @battler.battler_face[0] == 0)
  971. #~           make_face(true)
  972. #~        end   
  973. #~    end
  974.  
  975. #~   #--------------------------------------------------------------------------
  976. #~   # ● Update Face Effect
  977. #~   #--------------------------------------------------------------------------                 
  978. #~    def update_face_effect
  979. #~        return if @battler.battler_face[2] == 0
  980. #~        case @battler.battler_face[1]
  981. #~           when 0
  982. #~              face_damage
  983. #~           when 1..2
  984. #~              face_heal
  985. #~           when 3
  986. #~              face_action
  987. #~        end
  988. #~    end  
  989. #~   
  990. #~   #--------------------------------------------------------------------------
  991. #~   # ● Face Damage
  992. #~   #--------------------------------------------------------------------------                    
  993. #~    def face_damage
  994. #~        self.x = (@org_pos[0] - (@battler.battler_face[2] /2)) + rand(@battler.battler_face[2])
  995. #~    end  
  996. #~   
  997. #~   #--------------------------------------------------------------------------
  998. #~   # ● Face Heal
  999. #~   #--------------------------------------------------------------------------                    
  1000. #~    def face_heal
  1001. #~        case  @battler.battler_face[2]
  1002. #~          when 20..40
  1003. #~              self.zoom_x += 0.01
  1004. #~              self.zoom_y = self.zoom_x
  1005. #~          when 0..20
  1006. #~              self.zoom_x -= 0.01
  1007. #~              self.zoom_y = self.zoom_x      
  1008. #~        end
  1009. #~    end     
  1010. #~   
  1011. #~   #--------------------------------------------------------------------------
  1012. #~   # ● Face Action
  1013. #~   #--------------------------------------------------------------------------                    
  1014. #~    def face_action
  1015. #~        case  @battler.battler_face[2]
  1016. #~          when 25..50
  1017. #~              self.zoom_x += 0.01
  1018. #~              self.zoom_y = self.zoom_x
  1019. #~              self.mirror = true
  1020. #~          when 0..25
  1021. #~              self.zoom_x -= 0.01
  1022. #~              self.zoom_y = self.zoom_x
  1023. #~              self.mirror = false
  1024. #~        end
  1025. #~        self.zoom_x = self.zoom_x > 1.5 ? self.zoom_x = 1.5 : self.zoom_x < 1 ? 1 : self.zoom_x
  1026. #~        self.zoom_y = self.zoom_y > 1.5 ? self.zoom_y = 1.5 : self.zoom_y < 1 ? 1 : self.zoom_y
  1027. #~    end
  1028. #~      
  1029. #~  end
  1030. #~  
  1031. #~   #==============================================================================
  1032. #~ # ■ Battle Manager
  1033. #~ #==============================================================================
  1034. #~ class << BattleManager
  1035. #~   
  1036. #~   #--------------------------------------------------------------------------
  1037. #~   # ● Battle End
  1038. #~   #--------------------------------------------------------------------------                    
  1039. #~   alias mog_battle_hud_battle_process_victory process_victory
  1040. #~   def process_victory
  1041. #~       execute_face_effect   
  1042. #~       mog_battle_hud_battle_process_victory
  1043. #~   end
  1044. #~   
  1045. #~   #--------------------------------------------------------------------------
  1046. #~   # ● Prepare
  1047. #~   #--------------------------------------------------------------------------                  
  1048. #~   def execute_face_effect
  1049. #~       for i in $game_party.members
  1050. #~           i.battler_face = [1,2,40] if i.hp > 0   
  1051. #~       end  
  1052. #~   end
  1053. #~   
  1054. #~ end
  1055.  
  1056. #~ #==============================================================================
  1057. #~ # ■ Game Action
  1058. #~ #==============================================================================
  1059. #~ class Scene_Battle < Scene_Base
  1060. #~   
  1061. #~   #--------------------------------------------------------------------------
  1062. #~   # ● Show Animations
  1063. #~   #--------------------------------------------------------------------------     
  1064. #~   alias mog_battle_hud_show_animation show_animation
  1065. #~   def show_animation(targets, animation_id)
  1066. #~       make_face_action_battle
  1067. #~       mog_battle_hud_show_animation(targets, animation_id)
  1068. #~   end
  1069. #~   
  1070. #~   #--------------------------------------------------------------------------
  1071. #~   # ● Make Face Action
  1072. #~   #--------------------------------------------------------------------------                  
  1073. #~   def make_face_action_battle
  1074. #~       return if [email protected]_a?(Game_Actor)
  1075. #~       @subject.battler_face = [2,3,50]
  1076. #~   end   
  1077. #~   
  1078. #~ end  
  1079.  
  1080. #==============================================================================
  1081. # ■ Game Battler
  1082. #==============================================================================
  1083. class Game_Battler < Game_BattlerBase
  1084.  
  1085.   #--------------------------------------------------------------------------
  1086.   # ● Item Apply
  1087.   #--------------------------------------------------------------------------               
  1088.   alias mog_battle_hud_item_apply item_apply
  1089.   def item_apply(user, item)
  1090.       old_hp = self.hp
  1091.       old_mp = self.mp
  1092.       mog_battle_hud_item_apply(user, item)
  1093. #~       check_face_effect(old_hp,old_mp) if can_check_face_effect?(old_hp,old_mp)
  1094.   end
  1095.  
  1096. #~   #--------------------------------------------------------------------------
  1097. #~   # ● Check Face Effect
  1098. #~   #--------------------------------------------------------------------------  
  1099. #~   def check_face_effect(old_hp,old_mp)
  1100. #~       if self.hp > old_hp or self.mp > old_mp
  1101. #~          self.battler_face = [1,1,40]
  1102. #~       elsif self.hp < old_hp
  1103. #~          self.battler_face = [3,0,40]
  1104. #~       end  
  1105. #~   end  
  1106.  
  1107.   #--------------------------------------------------------------------------
  1108.   # ● Added New State
  1109.   #--------------------------------------------------------------------------  
  1110.   alias mog_battle_hud_add_new_state add_new_state
  1111.   def add_new_state(state_id)
  1112.       mog_battle_hud_add_new_state(state_id)
  1113.       if self.is_a?(Game_Actor)
  1114.          self.battler_face = [1,1,40] if $data_states[state_id].note =~ /<Good State>/
  1115.          self.battler_face = [3,0,40] if $data_states[state_id].note =~ /<Bad State>/
  1116.       end   
  1117.   end   
  1118.  
  1119.   #--------------------------------------------------------------------------
  1120.   # ● Regenerate HP
  1121.   #--------------------------------------------------------------------------
  1122.   alias mog_battle_hud_regenerate_hp regenerate_hp
  1123.   def regenerate_hp
  1124.       old_hp = self.hp
  1125.       old_mp = self.mp   
  1126.       mog_battle_hud_regenerate_hp
  1127. #~       check_face_effect(old_hp,old_mp) if can_check_face_effect?(old_hp,old_mp)
  1128.   end
  1129.  
  1130.   #--------------------------------------------------------------------------
  1131.   # ● Regenerate MP
  1132.   #--------------------------------------------------------------------------
  1133.   alias mog_battle_hud_regenerate_mp regenerate_mp
  1134.   def regenerate_mp
  1135.       old_hp = self.hp
  1136.       old_mp = self.mp   
  1137.       mog_battle_hud_regenerate_mp
  1138. #~       check_face_effect(old_hp,old_mp) if can_check_face_effect?(old_hp,old_mp)
  1139.   end  
  1140.  
  1141.   #--------------------------------------------------------------------------
  1142.   # ● Can Check Face Effect
  1143.   #--------------------------------------------------------------------------                  
  1144.   def can_check_face_effect?(old_hp,old_mp)
  1145.       return false if self.is_a?(Game_Enemy)
  1146.       return true if old_hp != self.hp
  1147.       return true if old_mp != self.mp
  1148.       return false
  1149.   end
  1150.  
  1151. end
  1152.  
  1153. #==============================================================================
  1154. # ■ Scene_Battle
  1155. #==============================================================================
  1156. class Scene_Battle < Scene_Base
  1157.  
  1158.   #--------------------------------------------------------------------------
  1159.   # ● Invoke Counter Attack
  1160.   #--------------------------------------------------------------------------        
  1161.   alias mog_battle_hud_invoke_counter_attack invoke_counter_attack
  1162.   def invoke_counter_attack(target, item)
  1163.       mog_battle_hud_invoke_counter_attack(target, item)
  1164.       if target.is_a?(Game_Actor) and target.battler_face[0] != 2        
  1165.          target.battler_face = [2,3,50]
  1166.       end  
  1167.   end  
  1168.  
  1169.   #--------------------------------------------------------------------------
  1170.   # ● Invoke Magic Reflection
  1171.   #--------------------------------------------------------------------------        
  1172.   alias mog_battle_hud_invoke_magic_reflection invoke_magic_reflection
  1173.   def invoke_magic_reflection(target, item)
  1174.       mog_battle_hud_invoke_magic_reflection(target, item)
  1175.       if target.is_a?(Game_Actor) and target.battler_face[0] != 2        
  1176.          target.battler_face = [2,3,50]
  1177.       end  
  1178.   end   
  1179.  
  1180. end
  1181.  
  1182. #==============================================================================
  1183. # ■ Scene Battle
  1184. #==============================================================================  
  1185. class Scene_Battle < Scene_Base
  1186.  
  1187.   #--------------------------------------------------------------------------
  1188.   # ● select_enemy_selection
  1189.   #--------------------------------------------------------------------------
  1190.   alias mog_battle_cursor_select_enemy_selection select_enemy_selection
  1191.   def select_enemy_selection
  1192.       mog_battle_cursor_select_enemy_selection
  1193.       if $mog_rgss3_battle_cursor != nil
  1194.          @enemy_window.visible = false
  1195.          @info_viewport.rect.width = 0
  1196.       end   
  1197.   end
  1198.  
  1199.   #--------------------------------------------------------------------------
  1200.   # ● select_enemy_selection
  1201.   #--------------------------------------------------------------------------
  1202.   alias mog_battle_cursor_select_actor_selection select_actor_selection
  1203.   def select_actor_selection
  1204.       mog_battle_cursor_select_actor_selection
  1205.       if $mog_rgss3_battle_cursor != nil
  1206.          @actor_window.visible = false
  1207.          @info_viewport.rect.width = 0
  1208.       end   
  1209.   end
  1210.  
  1211. end  
  1212.  
  1213. $mog_rgss3_battle_hud = true

RUBY 代码复制
  1. #==============================================================================
  2. # +++ MOG - AT System  (v0.7 Beta) +++
  3. #==============================================================================
  4. # By Moghunter
  5. # [url]http://www.atelier-rgss.com/[/url]
  6. #==============================================================================
  7. # Sistema de batalha de turnos em tempo real.
  8. #==============================================================================
  9.  
  10. #==============================================================================
  11. # ● Histórico (Version History)
  12. #==============================================================================
  13. # v 0.7 - Melhoria na performance.
  14. #==============================================================================
  15.  
  16. #==============================================================================
  17. # ● AT SYSTEM
  18. #==============================================================================
  19. # A velocidade de AT é baseaddo na agilidade do Battler.
  20. # Em caso de batalhas preventivas (Preemptive) os aliados começarão com AT em
  21. # 80% e os inimigos começarão com AT em 0 (Zero)
  22. # Em batalhas surpresas (Surprise) é o inverso das batalhas preventivas.
  23. # Em batalhas normais todos os battlers começarão com AT em 40%.
  24. #==============================================================================
  25. # ● CAST TIME
  26. #==============================================================================
  27. # Para definir uma habilidade ou item com a função de Cast Time basta definir
  28. # o valor da velocidade (Speed) diferente de 0 (Zero).
  29. #
  30. # NOTA - Não é possível ativar 2 ou mais habilidades com a função Cast Time no
  31. # mesmo turno. (Caso você esteja usando características de Multi Action em
  32. # seu projeto.)
  33. #==============================================================================
  34. module MOG_AT_SYSTEM
  35.   #Som quando o sistema AT estiver no maximo
  36.   SE_ACTIVE = "Decision2"
  37.   #Definição do valor de AT para ativar a ação.(Gauge Meter).
  38.   AT_GAUGE_METER = 5000
  39.   # Definição do tipo de duração (Contagem/formula) de um turno.
  40.   # Essa definição influência na ativação dos eventos de batalha.
  41.   # (BATTLE EVENTS)
  42.   #
  43.   # 0 - Duração de um turno é um valor fixo.
  44.   # 1 - Duração de um turno é multiplicado pela quantidade de batllers.
  45.   # 2 - Duração de um turno é baseado na média de agilidade dos battlers.
  46.   #
  47.   TURN_DURATION_TYPE = 1
  48.   # Definição de valor usado para calcular a duração de um turno.
  49.   TURN_DURATION = 60
  50.   # Definição da animação quando o battler usa habilidades de carregamento.
  51.   CAST_ANIMATION = 49
  52.   # Ativar a janela de LOG, deixe desativado se desejar uma batalha mais
  53.   # dinâmica.
  54.   WAIT_LOG_WINDOW = true
  55.   # Ativar a mensagem inicial com os nomes dos inimigos.
  56.   MESSAGE_ENEMY_APPEAR = false
  57.   # Definição da posição da janela de mensagem.
  58.   # 0 - Superior
  59.   # 1 - Centro
  60.   # 2 - Inferior  
  61.   MESSAGE_POSITION = 0
  62.   # Tipo de posicionamento da Hud.
  63.   # 0 - Posição fixa.
  64.   # 1 - Posição baseado no valor X e Y do battler.
  65.   AT_HUD_POSITION_TYPE = 0
  66.   #Posição geral (Inicial) da Hud.
  67.   AT_HUD_POSITION = [25,400]
  68.   #Posição do medidor de AT
  69.   AT_METER_POSITION = [29,1]
  70.   #Definição da posição do espaço da HUD entre os membros do grupo.
  71.   #
  72.   #MEMBERS_SPACE = [Horizontal ,Vertical]
  73.   #
  74.   MEMBERS_SPACE = [136,0]
  75.   #Velocidade de animação do medidor de at, defina 0 se não quiser a animação.
  76.   AT_METER_FLOW_SPEED = 3
  77.   #Prioridade da Hud.
  78.   BATTLE_HUD_Z = 0   
  79.  
  80. end
  81.  
  82. #==============================================================================
  83. # ■ Game_System
  84. #==============================================================================
  85. class Game_System
  86.  
  87.   attr_accessor :at_max
  88.  
  89.   #--------------------------------------------------------------------------
  90.   # ● Initialize
  91.   #--------------------------------------------------------------------------         
  92.   alias mog_at_system_initialize initialize
  93.   def initialize
  94.       @at_max = [[MOG_AT_SYSTEM::AT_GAUGE_METER, 999999].min, 100].max
  95.       mog_at_system_initialize
  96.   end
  97.  
  98. end
  99.  
  100. #==============================================================================
  101. # ■ BattleManager
  102. #==============================================================================
  103. module BattleManager
  104.  
  105.   #--------------------------------------------------------------------------
  106.   # ● Battle Start
  107.   #--------------------------------------------------------------------------  
  108.   def self.battle_start
  109.       $game_system.battle_count += 1
  110.       $game_party.on_battle_start
  111.       $game_troop.on_battle_start
  112.       if MOG_AT_SYSTEM::MESSAGE_ENEMY_APPEAR
  113.          $game_troop.enemy_names.each do |name|
  114.          $game_message.add(sprintf(Vocab::Emerge, name))
  115.          end
  116.       end
  117.       if @preemptive
  118.          $game_message.add(sprintf(Vocab::Preemptive, $game_party.name))
  119.       elsif @surprise
  120.          $game_message.add(sprintf(Vocab::Surprise, $game_party.name))
  121.       end
  122.       wait_for_message
  123.   end
  124.  
  125.   #--------------------------------------------------------------------------
  126.   # ● Input Start
  127.   #--------------------------------------------------------------------------
  128.   def self.input_start_at(battler)
  129.       if @phase != :input
  130.          @phase = :input
  131.          battler.make_actions
  132.          clear_actor
  133.       end
  134.       return !@surprise && battler.inputable?
  135.   end
  136.  
  137.   #--------------------------------------------------------------------------
  138.   # ● Turn Start
  139.   #--------------------------------------------------------------------------
  140.   def self.turn_start
  141.       @phase = :turn
  142.       clear_actor
  143.       make_action_orders
  144.   end  
  145.  
  146.   #--------------------------------------------------------------------------
  147.   # ● Preemtive Attack
  148.   #--------------------------------------------------------------------------  
  149.   def self.preemptive_attack
  150.       @preemptive
  151.   end  
  152.  
  153.   #--------------------------------------------------------------------------
  154.   # ● Suprise Attack
  155.   #--------------------------------------------------------------------------   
  156.   def self.surprise_attack
  157.       @surprise
  158.   end   
  159.  
  160. end  
  161.  
  162. #==============================================================================
  163. # ■ Game Action
  164. #==============================================================================
  165. class Game_Action  
  166.  
  167.   #--------------------------------------------------------------------------
  168.   # ● Prepare
  169.   #--------------------------------------------------------------------------            
  170.   alias mog_at_system_prepare prepare
  171.   def prepare
  172.       mog_at_system_prepare
  173.       set_cast_action
  174.   end
  175.  
  176.   #--------------------------------------------------------------------------
  177.   # ● Set Cast Action
  178.   #--------------------------------------------------------------------------               
  179.   def set_cast_action
  180.       return if forcing
  181.       if @item.object != nil and @item.object.speed != 0 and @subject.at_cast.empty?
  182.          @subject.at_cast = [@item.object,@item.object.speed.abs,@target_index]
  183.          @item.object = nil
  184.          @subject.animation_id = MOG_AT_SYSTEM::CAST_ANIMATION
  185.          @subject.at = 0
  186.          BattleManager.turn_end if @subject.auto_battle?
  187.       elsif !@subject.at_cast.empty?
  188.          if @subject.at_cast[1] == 0
  189.             @item.object = @subject.at_cast[0]
  190.             @target_index = @subject.at_cast[2]            
  191.             @subject.at_cast.clear
  192.          else   
  193.             @item.object = nil
  194.          end
  195.       end  
  196.   end  
  197.  
  198. end
  199.  
  200.  
  201. #==============================================================================
  202. # ■ Game Battler Base
  203. #==============================================================================
  204. class Game_BattlerBase  
  205.  
  206.   #--------------------------------------------------------------------------
  207.   # ● Inputable?
  208.   #--------------------------------------------------------------------------            
  209.   def inputable?
  210.       normal? && !auto_battle? && self.at == $game_system.at_max
  211.   end
  212.  
  213. end
  214.  
  215. #==============================================================================
  216. # ■ Game_Battler
  217. #==============================================================================
  218. class Game_Battler < Game_BattlerBase
  219.  
  220.    attr_accessor :at
  221.    attr_accessor :at_cast
  222.    attr_accessor :at_turn_duration
  223.    attr_accessor :at_action
  224.  
  225.   #--------------------------------------------------------------------------
  226.   # ● Initialize
  227.   #--------------------------------------------------------------------------      
  228.    alias mog_at_system_initialize initialize
  229.    def initialize
  230.        mog_at_system_initialize
  231.        @at = 0
  232.        @at_cast = []
  233.        @at_cast_selectable = true
  234.        @at_turn_duration = 0
  235.        @at_action = nil
  236.    end
  237.  
  238.   #--------------------------------------------------------------------------
  239.   # ● At
  240.   #--------------------------------------------------------------------------         
  241.    def at
  242.        n = at_active? ? $game_system.at_max : 0
  243.        return [[@at, n].min, 0].max
  244.    end  
  245.  
  246.   #--------------------------------------------------------------------------
  247.   # ● At Active
  248.   #--------------------------------------------------------------------------            
  249.    def at_active?
  250.        return false if restriction >= 4
  251.        return false if self.hp == 0
  252.        return true
  253.    end  
  254.  
  255.   #--------------------------------------------------------------------------
  256.   # ● Added New State
  257.   #--------------------------------------------------------------------------  
  258.   alias mog_at_system_add_new_state add_new_state
  259.   def add_new_state(state_id)
  260.       mog_at_system_add_new_state(state_id)
  261.       if restriction >= 4
  262.          self.at_cast.clear
  263.          self.at = 0
  264.       end   
  265.   end   
  266.  
  267.   #--------------------------------------------------------------------------
  268.   # ● can AT?
  269.   #--------------------------------------------------------------------------   
  270.   def can_upd_at?
  271.       return false if restriction >= 4
  272.       return false if self.hp == 0
  273.       return false if !self.at_cast.empty?
  274.       return false if self.at_action != nil
  275.       return true
  276.   end
  277.  
  278. end
  279.  
  280. #==============================================================================
  281. # ■ Game Enemy
  282. #==============================================================================
  283. class Game_Enemy < Game_Battler
  284.  
  285.   #--------------------------------------------------------------------------
  286.   # ● Tranform
  287.   #--------------------------------------------------------------------------  
  288.    alias mog_at_system_transform transform
  289.    def transform(enemy_id)
  290.        mog_at_system_transform(enemy_id)
  291.        self.at = 0
  292.        self.at_cast.clear
  293.    end
  294. end   
  295.  
  296. if !MOG_AT_SYSTEM::WAIT_LOG_WINDOW
  297. #==============================================================================
  298. # ■ BattleManager
  299. #==============================================================================
  300. class Window_BattleLog < Window_Selectable
  301.  
  302.   #--------------------------------------------------------------------------
  303.   # ● Refresh
  304.   #--------------------------------------------------------------------------   
  305.   def refresh
  306.   end  
  307.  
  308.   #--------------------------------------------------------------------------
  309.   # ● Message Speed
  310.   #--------------------------------------------------------------------------   
  311.   def message_speed
  312.       return 5
  313.   end
  314.  
  315. end
  316. end
  317.  
  318. #==============================================================================
  319. # ■ Scene Battle
  320. #==============================================================================
  321. class Scene_Battle < Scene_Base
  322.   include MOG_AT_SYSTEM
  323.  
  324.   #--------------------------------------------------------------------------
  325.   # ● AT Wait
  326.   #--------------------------------------------------------------------------         
  327.   alias mog_at_system_start start
  328.   def start
  329.       reset_at_parameter  
  330.       mog_at_system_start
  331.   end  
  332.  
  333.   #--------------------------------------------------------------------------
  334.   # ● Battle Start
  335.   #--------------------------------------------------------------------------
  336.   def battle_start
  337.       BattleManager.battle_start
  338.       process_event
  339.       set_turn_duration
  340.   end
  341.  
  342.   #--------------------------------------------------------------------------
  343.   # ● Reset AT Parameter
  344.   #--------------------------------------------------------------------------  
  345.   def reset_at_parameter
  346.       return if @at_phase != nil
  347.       @at_phase = 0
  348.       n_at = $game_system.at_max * 40 / 100
  349.       p_at = $game_system.at_max * 90 / 100
  350.       s_at = 0
  351.       all_battle_members.each do |battler|
  352.           if BattleManager.preemptive_attack
  353.              battler.at = p_at if battler.is_a?(Game_Actor)
  354.              battler.at = s_at if battler.is_a?(Game_Enemy)
  355.           elsif BattleManager.surprise_attack   
  356.              battler.at = p_at if battler.is_a?(Game_Enemy)
  357.              battler.at = s_at if battler.is_a?(Game_Actor)
  358.           else   
  359.              battler.at = n_at
  360.           end
  361.           if battler.at >= $game_system.at_max
  362.              battler.at = $game_system.at_max - 1
  363.           end
  364.           battler.at = 0 if battler.at < 0  
  365.           battler.at_cast.clear
  366.         end
  367.   end
  368.  
  369.   #--------------------------------------------------------------------------
  370.   # ● Set Turn Duration
  371.   #--------------------------------------------------------------------------
  372.   def set_turn_duration
  373.       max_battlers = all_battle_members.size > 0 ? all_battle_members.size : 1
  374.       case TURN_DURATION_TYPE
  375.         when 1
  376.            n  = TURN_DURATION * max_battlers
  377.         when 2
  378.            turn_sp = 0
  379.            all_battle_members.each do |battler|
  380.                turn_sp += battler.agi
  381.            end  
  382.            n = TURN_DURATION + (turn_sp / max_battlers)
  383.         else
  384.            n = TURN_DURATION
  385.       end
  386.       turn_time_max = [[n, 9999].min, 120].max
  387.       @turn_duration = [0, turn_time_max]
  388.       if @status_window != nil
  389.          @status_window.open
  390.       end   
  391.   end   
  392.  
  393.   #--------------------------------------------------------------------------
  394.   # ● Turn End
  395.   #--------------------------------------------------------------------------
  396.   def turn_end
  397.       @at_phase = 0
  398.       all_battle_members.each do |battler|
  399.          if battler.at >= $game_system.at_max
  400.             battler.at = 0
  401.             refresh_status
  402.             @log_window.display_auto_affected_status(battler)
  403.             @log_window.wait_and_clear
  404.          end
  405.       end
  406.       BattleManager.turn_end
  407.   end
  408.  
  409.   #--------------------------------------------------------------------------
  410.   # ● Update Turn Duration
  411.   #--------------------------------------------------------------------------            
  412.   def update_turn_duration
  413.       return if @turn_duration == nil or @turn_duration[0] == nil
  414.       @turn_duration[0] += 1
  415.       if @turn_duration[0] >= @turn_duration[1]
  416.          @turn_duration[0] = 0
  417.          $game_troop.increase_turn
  418.          process_event
  419.          check_states_effect_turn
  420.       end  
  421.   end
  422.  
  423.   #--------------------------------------------------------------------------
  424.   # ● Check States Effect Turn
  425.   #--------------------------------------------------------------------------               
  426.   def check_states_effect_turn
  427.       all_battle_members.each do |battler|  
  428.           battler.on_turn_end if battler.restriction >= 4
  429.       end  
  430.   end  
  431.  
  432.   #--------------------------------------------------------------------------
  433.   # ● Update AT System
  434.   #--------------------------------------------------------------------------           
  435.   def update_at_system      
  436.       reset_at_parameter if @at_phase == nil
  437.       set_turn_duration if @turn_duration == nil
  438.       return if !can_update_at?
  439.       update_turn_duration
  440.       all_battle_members.each do |battler|
  441.           update_battler_turn_duration(battler)
  442.           if !battler.at_cast.empty?
  443.              battler.at_cast[1] -= 1
  444.              if battler.at_cast[1] <= 0
  445.                 execute_at_cast(battler)
  446.                 break
  447.              end
  448.           else
  449.              battler.at += battler.agi
  450.           end   
  451.           if battler.at >= $game_system.at_max
  452.              battler.on_turn_end
  453.              update_at_actor(battler)
  454.              update_at_enemy(battler)
  455.              battler.current_action.prepare if battler.current_action
  456.              if battler.at_cast.empty?
  457.                 @at_phase = 1
  458.                 turn_start if battler.is_a?(Game_Enemy)
  459.              end            
  460.              break
  461.           end   
  462.       end  
  463.   end
  464.  
  465.   #--------------------------------------------------------------------------
  466.   # ● Update Battler Turn Duration
  467.   #--------------------------------------------------------------------------            
  468.   def update_battler_turn_duration(battler)
  469.       if battler.restriction >= 4
  470.          battler.at_turn_duration += 1
  471.          if battler.at_turn_duration >= $game_system.at_max
  472.             battler.on_turn_end
  473.             battler.at_turn_duration = 0
  474.          end   
  475.       else   
  476.          battler.at_turn_duration = 0
  477.       end  
  478.   end  
  479.  
  480.   #--------------------------------------------------------------------------
  481.   # ● Execute AT CAST
  482.   #--------------------------------------------------------------------------            
  483.   def execute_at_cast(battler)
  484.       @subject = battler
  485.       battler.make_actions  
  486.       turn_start
  487.   end  
  488.  
  489.   #--------------------------------------------------------------------------
  490.   # ● Update AT Actor
  491.   #--------------------------------------------------------------------------            
  492.   def update_at_actor(battler)   
  493.       return if !battler.is_a?(Game_Actor)
  494.       Audio.se_play("Audio/SE/" + SE_ACTIVE,100,100)  
  495.       start_party_command_selection_at(battler)
  496.   end
  497.  
  498.   #--------------------------------------------------------------------------
  499.   # ● Update AT Enemy
  500.   #--------------------------------------------------------------------------            
  501.   def update_at_enemy(battler)   
  502.       return if !battler.is_a?(Game_Enemy)
  503.       battler.make_actions
  504.   end   
  505.  
  506.   #--------------------------------------------------------------------------
  507.   # ● Can Update AT
  508.   #--------------------------------------------------------------------------            
  509.   def can_update_at?
  510.       return false if $game_troop.interpreter.running?
  511.       return false if BattleManager.action_forced?
  512.       return false if @at_phase != 0
  513.       return false if $game_message.visible
  514.       return false if BattleManager.in_turn?
  515.       return true
  516.   end   
  517.  
  518.   #--------------------------------------------------------------------------
  519.   # ● Star Party Command Selection at
  520.   #--------------------------------------------------------------------------
  521.   def start_party_command_selection_at(battler)
  522.       unless scene_changing?
  523.          refresh_status
  524.          @status_window.unselect
  525.          @status_window.open
  526.          if BattleManager.input_start_at(battler)
  527.             @actor_command_window.close
  528.             next_command
  529.          else
  530.            turn_start
  531.          end
  532.       end
  533.   end  
  534.  
  535.   #--------------------------------------------------------------------------
  536.   # ● Update Basic
  537.   #--------------------------------------------------------------------------        
  538.   alias mog_at_system_update_basic update_basic
  539.   def update_basic
  540.       mog_at_system_update_basic
  541.       update_at_system
  542.       update_party_command
  543.       $game_message.position = MESSAGE_POSITION
  544.   end
  545.  
  546.   #--------------------------------------------------------------------------
  547.   # ● Update Party Command
  548.   #--------------------------------------------------------------------------      
  549.   def update_party_command
  550.       return if !@party_command_window.active
  551.       return if !@actor_command_window.visible
  552.       return if $game_message.visible
  553.       if Input.trigger?(:B)
  554.          next_command
  555.          Sound.play_cancel
  556.          @party_command_window.active = false
  557.       end  
  558.   end
  559.  
  560. end
  561.  
  562.  
  563. #==============================================================================
  564. # ■ Game Temp
  565. #==============================================================================
  566. class Game_Temp
  567.  
  568.   attr_accessor :cache_at_meter
  569.  
  570.   #--------------------------------------------------------------------------
  571.   # ● Initialize
  572.   #--------------------------------------------------------------------------      
  573.   alias mog_at_meter_initialize initialize
  574.   def initialize
  575.       mog_at_meter_initialize
  576.       cache_atmeter
  577.   end
  578.  
  579.   #--------------------------------------------------------------------------
  580.   # ● Cache ATmeter
  581.   #--------------------------------------------------------------------------      
  582.   def cache_atmeter
  583.       @cache_at_meter = []
  584.       @cache_at_meter.push(Cache.system("Battle_AT_Meter"))
  585.       @cache_at_meter.push(Cache.system("Battle_AT_Layout"))
  586.   end
  587.  
  588. end
  589.  
  590. #==============================================================================
  591. # ■ AT Meter
  592. #==============================================================================
  593. class AT_Meter
  594.  
  595.   include MOG_AT_SYSTEM
  596.  
  597.   #--------------------------------------------------------------------------
  598.   # ● Initialize
  599.   #--------------------------------------------------------------------------   
  600.   def initialize(actor)
  601.       @actor = actor
  602.       @flow_speed = 0
  603.       if AT_HUD_POSITION_TYPE == 1 and @actor.use_sprite?
  604.          @x = AT_HUD_POSITION[0] +  @actor.screen_x rescue 0
  605.          @y = AT_HUD_POSITION[1] +  @actor.screnn_y rescue 0
  606.       else   
  607.          @x = AT_HUD_POSITION[0] + (MEMBERS_SPACE[0] * @actor.index)
  608.          @y = AT_HUD_POSITION[1] + (MEMBERS_SPACE[1] * @actor.index)        
  609.       end
  610.       pre_cache
  611.       create_layout
  612.       create_at_meter
  613.   end
  614.  
  615.   #--------------------------------------------------------------------------
  616.   # ● Pre Cache
  617.   #--------------------------------------------------------------------------      
  618.   def pre_cache
  619.       @meter = $game_temp.cache_at_meter[0]
  620.       @meter_cw = @meter.width / 3
  621.       @meter_ch = @meter.height / 3
  622.   end
  623.  
  624.   #--------------------------------------------------------------------------
  625.   # ● Create Layout
  626.   #--------------------------------------------------------------------------      
  627.   def create_layout
  628.       @layout = Sprite.new
  629.       @layout.bitmap = $game_temp.cache_at_meter[1]
  630.       @layout.z = BATTLE_HUD_Z
  631.       @layout.x = @x
  632.       @layout.y = @y
  633.   end
  634.  
  635.   #--------------------------------------------------------------------------
  636.   # ● Create AT Meter
  637.   #--------------------------------------------------------------------------      
  638.   def create_at_meter
  639.       @at_meter = Sprite.new
  640.       @at_meter.bitmap = Bitmap.new(@meter_cw,@meter_ch)
  641.       @at_meter.z =  BATTLE_HUD_Z + 50
  642.       @at_meter.x = @x + AT_METER_POSITION[0]
  643.       @at_meter.y = @y + AT_METER_POSITION[1]
  644.       @at_flow = rand(@meter_cw * 2)
  645.       at_flow_update
  646.   end  
  647.  
  648.   #--------------------------------------------------------------------------
  649.   # ● Dispose
  650.   #--------------------------------------------------------------------------   
  651.   def dispose
  652.       return if @layout == nil
  653.       @layout.dispose
  654.       @layout = nil
  655.       @at_meter.bitmap.dispose
  656.       @at_meter.dispose
  657.   end  
  658.  
  659.   #--------------------------------------------------------------------------
  660.   # ● Update
  661.   #--------------------------------------------------------------------------  
  662.   def update
  663.       return if @layout == nil
  664.       at_position
  665.       @flow_speed += 1
  666.       if @flow_speed >= AT_METER_FLOW_SPEED
  667.          @flow_speed = 0
  668.          at_flow_update
  669.       end
  670.   end
  671.  
  672.   #--------------------------------------------------------------------------
  673.   # ● Update
  674.   #--------------------------------------------------------------------------   
  675.   def at_position
  676.       return unless AT_HUD_POSITION_TYPE == 1 and @actor.use_sprite?
  677.       @x = AT_HUD_POSITION[0] +  @actor.screen_x rescue 0
  678.       @y = AT_HUD_POSITION[1] +  @actor.screnn_y rescue 0
  679.       @layout.x = @x
  680.       @layout.y = @y
  681.       @at_meter.x = @x + AT_METER_POSITION[0]
  682.       @at_meter.y = @y + AT_METER_POSITION[1]
  683.   end
  684.  
  685.   #--------------------------------------------------------------------------
  686.   # ● AT Flow Update
  687.   #--------------------------------------------------------------------------
  688.   def at_flow_update
  689.       @at_meter.bitmap.clear
  690.       if !@actor.at_cast.empty?
  691.          max_cast = @actor.at_cast[0].speed.abs != 0 ? @actor.at_cast[0].speed.abs : 1
  692.          at_width = @meter_cw * @actor.at_cast[1] / max_cast
  693.          ch = @meter_ch * 2
  694.       else
  695.          at_width = @meter_cw * @actor.at / $game_system.at_max
  696.          ch = @actor.at < $game_system.at_max ? 0 : @meter_ch
  697.       end  
  698.       src_rect = Rect.new(@at_flow, ch,at_width, @meter_ch)
  699.       @at_meter.bitmap.blt(0,0, @meter, src_rect)
  700.       @at_flow += AT_METER_FLOW_SPEED
  701.       @at_flow = 0 if @at_flow >=  @meter_cw * 2      
  702.   end   
  703.  
  704. end  
  705.  
  706. #==============================================================================
  707. # ■ Spriteset Battle
  708. #==============================================================================
  709. class Spriteset_Battle
  710.  
  711.   #--------------------------------------------------------------------------
  712.   # ● Initialize
  713.   #--------------------------------------------------------------------------           
  714.   alias mog_at_system_initialize initialize
  715.   def initialize
  716.       mog_at_system_initialize
  717.       create_at_meter
  718.   end  
  719.  
  720.   #--------------------------------------------------------------------------
  721.   # ● Create AT Meter
  722.   #--------------------------------------------------------------------------            
  723.   def create_at_meter     
  724.       @at_meter = []
  725.       for i in $game_party.battle_members
  726.           @at_meter.push(AT_Meter.new(i))
  727.       end      
  728.   end  
  729.  
  730.   #--------------------------------------------------------------------------
  731.   # ● Dispose
  732.   #--------------------------------------------------------------------------      
  733.   alias mog_at_system_dispose dispose
  734.   def dispose
  735.       mog_at_system_dispose
  736.       dispose_at_meter
  737.   end
  738.  
  739.   #--------------------------------------------------------------------------
  740.   # ● Dispose AT Meter
  741.   #--------------------------------------------------------------------------        
  742.   def dispose_at_meter
  743.       return if @at_meter == nil
  744.       @at_meter.each {|sprite| sprite.dispose }
  745.       @at_meter = nil
  746.   end  
  747.  
  748.   #--------------------------------------------------------------------------
  749.   # ● Update
  750.   #--------------------------------------------------------------------------        
  751.   alias mog_at_system_update update
  752.   def update
  753.       mog_at_system_update
  754.       update_at_meter
  755.   end  
  756.  
  757.   #--------------------------------------------------------------------------
  758.   # ● Update AT Meter
  759.   #--------------------------------------------------------------------------         
  760.   def update_at_meter
  761.       return if @at_meter == nil
  762.       @at_meter.each {|sprite| sprite.update }
  763.   end  
  764.  
  765. end
  766.  
  767. $mog_rgss3_at_system = true

点评

附件太大,等好心人帮你解决吧。喵。  发表于 2014-7-16 16:28
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-9-25 15:25

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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