| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 3 |
| 经验 | |
| 最后登录 | 2024-2-3 |
| 在线时间 | 398 小时 |
- 梦石
- 0
- 星屑
- 293
- 在线时间
- 398 小时
- 注册时间
- 2011-5-20
- 回帖
- 94
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 893299399 于 2013-7-19 10:47 编辑
横版战斗和MOG_Adv_Battle_Hud这两个脚本以前可以一起用,为什么现在一用就出错?
http://pan.baidu.com/share/link? ... 98&uk=923321122 这是工程下载地址,太大传不进附件,下面是那两个脚本
[pre lang="ruby" line="1"]#==============================================================================
# ■ 此脚本来自 www.66rpg.com
#------------------------------------------------------------------------------
# 名称:横版战斗模板
# 作者:后知后觉(hzhj.tnt@163.com)
# 版本:v1.7 2012-02-09
# 使用协议:在保留此脚本相关信息的情况下
# 可任意使用、修改及修改后发布.
# 如是修改后发布.请在作者标注那里加上 某某某改 等信息
# 感谢你来这里谈谈你对这个工程的看法或报告BUG.
# http://rpg.blue/thread-216673-1-1.html
# 使用说明:
# 请来发布帖查看:
# http://rpg.blue/thread-216673-1-1.html
#==============================================================================
module Hzhj
module HorizontalBattleSystem
# 取得参战角色的最大数.如果要改大.需要在下面的坐标设置里增加对应的条目
MaxBattleMembers = 4
ActorsBattlePosition = {}
# 设置角色战斗图形的坐标
# 等号左边的[]号里面的1 2 3 4 表示角色在队伍里的位置
# 等号右边的[]号里面的两个数字分别表示 X坐标 Y坐标
# 每次进入战斗的时候都会以这里设置的信息作为初始化位置.
# 如果你把上面的 MaxBattleMembers 改大了.比如改成了 5.
# 那么你需要在下面新增一行代码设置队伍中第5位置的坐标.
# 就像这样 ActorsBattlePosition[5] = [X坐标, Y坐标]
ActorsBattlePosition[1] = [450, 220]
ActorsBattlePosition[2] = [422, 272]
ActorsBattlePosition[3] = [466, 228]
ActorsBattlePosition[4] = [510, 272]
# 设置伤害值图形的色相 取值范围 0~360
DamageBitmapHue = 0
# 伤害值分段显示的标志SE文件名
DamageSectionDisplaySEName = "DamageSection"
# 动画 Z 坐标值默认变化量
DefaultAniAddZ = 768
# 状态动画 Z 坐标值默认变化量
DefaultLoopAniAddZ = 20
# 战斗中角色的面向
ActorDirection = 4
# 真位移的帧数
RealMoveDuration = 20
# 真位移移动前会计算目标点.会获取攻防双方战斗图大小来进行计算.
# 下面2个是对战斗图 width height 进行修正.
# 为正则扩大 为负则缩小.单位 像素.
# 一般来说不必修改.只有像梦幻群侠传那种战斗图四边有很多透明区域时才修正.
RealMoveBmpAddW = 0
RealMoveBmpAddH = 0
# 使用技能、物品的过程默认使用RMVA模式
# 在该模式下.本脚本提供的很多功能受限无法使用.
DefaultUseRmvaMode = false
# 默认显示敌人的HP条、MP条、TP条
DefaultDisplayEnemyBar = true
# 一张战斗图中有几个样式(帧、格)
DynamicPatternMax = 4
# 一张战斗图中的一个样式持续多少帧
OnePatternDuration = 15
# 角色使用战斗死亡图形
UseActorDeadGraphic = true
# 敌人使用战斗死亡图形
UseEnemyDeadGraphic = false
# 使用挨打图形
UseBeatenGraphic = false
# 挨打图形维持帧数
BeatenGraphicDuration = 30
# 是否使用角色防御图 只有同时使用了挨打图.此项才有效.
UseActorGuardGraphic = true
# 是否使用敌人防御图 只有同时使用了挨打图.此项才有效.
UseEnemyGuardGraphic = false
# 角色是否使用挨打SE
UseActorWBSE = false
# 敌人是否使用挨打SE
UseEnemyWBSE = false
# 角色是否使用防御SE
UseActorGDSE = false
# 敌人是否使用防御SE
UseEnemyGDSE = false
end
end
class RPG::Actor < RPG::BaseItem
def battler_name
return @battler_name unless @battler_name.nil?
if /@btname\[(.+?)\]/ =~ @note
return (@battler_name = $1.clone)
else
return (@battler_name = "#{@name}_#{@nickname}")
end
end
def battler_hue
return @battler_hue unless @battler_hue.nil?
if /@bthue\[([0-9]+?)\]/ =~ @note
return (@battler_hue = $1.to_i.abs)
else
return (@battler_hue = 0)
end
end
attr_writer :battler_name
attr_writer :battler_hue
end
#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ● 属性(新增定义)
#--------------------------------------------------------------------------
attr_writer :battler_name # 战斗图形文件名
attr_writer :battler_hue # 战斗图形色相
#--------------------------------------------------------------------------
# ● 设置(追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_setup_for_add_actor_battle_graphic setup
def setup(actor_id)
hzhj_old_setup_for_add_actor_battle_graphic(actor_id)
@battler_name = actor.battler_name
@battler_hue = actor.battler_hue
end
#--------------------------------------------------------------------------
# ● 是否使用活动块(重定义)
#--------------------------------------------------------------------------
def use_sprite?
return true
end
#--------------------------------------------------------------------------
# ● 取得战斗画面 X 坐标(新增定义)
#--------------------------------------------------------------------------
def screen_x
return ActorsBattlePosition[index + 1][0]
end
#--------------------------------------------------------------------------
# ● 取得战斗画面 Y 坐标(新增定义)
#--------------------------------------------------------------------------
def screen_y
return ActorsBattlePosition[index + 1][1]
end
#--------------------------------------------------------------------------
# ● 取得战斗画面 Z 坐标(新增定义)
#--------------------------------------------------------------------------
def screen_z
return real_screen_y + 100
end
end
#==============================================================================
# ■ Game_Enemy
#==============================================================================
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# ● 属性(新增定义)
#--------------------------------------------------------------------------
attr_writer :battler_name # 战斗图形文件名
attr_writer :battler_hue # 战斗图形色相
#--------------------------------------------------------------------------
# ● 取得战斗画面 Z 坐标(重定义)
#--------------------------------------------------------------------------
def screen_z
return real_screen_y + 100
end
end
#==============================================================================
# ■ Game_Party
#==============================================================================
class Game_Party < Game_Unit
include Hzhj::HorizontalBattleSystem
#--------------------------------------------------------------------------
# ● 取得参战角色的最大数(重定义)
#--------------------------------------------------------------------------
def max_battle_members
return MaxBattleMembers
end
end
class RPG::Animation
def wait_subject_duration
return @wait_subject_duration unless @wait_subject_duration.nil?
if /@w\[(\-??\d+?)\]/ =~ @name
@wait_subject_duration = $1.to_i
else
@wait_subject_duration = 0
end
return @wait_subject_duration
end
attr_writer :wait_subject_duration
end
class RPG::UsableItem < RPG::BaseItem
include Hzhj::HorizontalBattleSystem
def animation1_id
return @animation1_id unless @animation1_id.nil?
if /@a1id\[(\d+?)\]/i =~ @note
return (@animation1_id = $1.to_i)
else
return (@animation1_id = 0)
end
end
def wljn
return @wljn unless @wljn.nil?
if /@wljn/i =~ @note
return (@wljn = true)
else
return (@wljn = false)
end
end
def rmva_mode
return @rmva_mode unless @rmva_mode.nil?
if /@rmva/i =~ @note
return (@rmva_mode = !DefaultUseRmvaMode)
else
return (@rmva_mode = DefaultUseRmvaMode)
end
end
attr_writer :animation1_id
attr_writer :wljn
attr_writer :rmva_mode
end
class RPG::Weapon < RPG::EquipItem
def animation1_id
return @animation1_id unless @animation1_id.nil?
if /@a1id\[(\d+?)\]/ =~ @note
return (@animation1_id = $1.to_i)
else
return (@animation1_id = 0)
end
end
attr_writer :animation1_id
end
class RPG::Enemy < RPG::BaseItem
def animation1_id
return @animation1_id unless @animation1_id.nil?
if /@a1id\[(\d+?)\]/ =~ @note
return (@animation1_id = $1.to_i)
else
return (@animation1_id = 0)
end
end
def animation2_id
return @animation2_id unless @animation2_id.nil?
if /@a2id\[(\d+?)\]/ =~ @note
return (@animation2_id = $1.to_i)
else
return (@animation2_id = 0)
end
end
def animation3_id
return @animation3_id unless @animation3_id.nil?
if /@a3id\[(\d+?)\]/ =~ @note
return (@animation3_id = $1.to_i)
else
return (@animation3_id = 0)
end
end
attr_writer :animation1_id
attr_writer :animation2_id
attr_writer :animation3_id
end
#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ● 取得普通攻击的行动方动画 ID (新增定义)
#--------------------------------------------------------------------------
def animation1_id
if dual_wield?
return weapons[0].animation1_id if weapons[0]
return weapons[1] ? weapons[1].animation1_id : 0
else
return weapons[0] ? weapons[0].animation1_id : 0
end
end
end
#==============================================================================
# ■ Game_Enemy
#==============================================================================
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# ● 取得普通攻击的行动方动画 ID (新增定义)
#--------------------------------------------------------------------------
def animation1_id
return enemy.animation1_id
end
#--------------------------------------------------------------------------
# ● 取得普通攻击的动画 ID (新增定义)
#--------------------------------------------------------------------------
def atk_animation_id1
return enemy.animation2_id
end
#--------------------------------------------------------------------------
# ● 取得普通攻击的动画 ID (二刀流:武器2)(新增定义)
#--------------------------------------------------------------------------
def atk_animation_id2
return enemy.animation3_id
end
end
#==============================================================================
# ■ Scene_Battle
#==============================================================================
class Scene_Battle < Scene_Base
include Hzhj::HorizontalBattleSystem
#--------------------------------------------------------------------------
# ● 使用技能/物品(重定义)
#--------------------------------------------------------------------------
def use_item
item = @subject.current_action.item
@log_window.display_use_item(@subject, item)
@subject.use_item(item)
refresh_status
targets = @subject.current_action.make_targets.compact
show_animation(targets, item.animation_id)
end
#--------------------------------------------------------------------------
# ● 显示动画(重定义)
#--------------------------------------------------------------------------
def show_animation(targets, animation_id)
item = @subject.current_action.item
if item.rmva_mode
show_rmva_animation(targets, animation_id, item)
else
show_hzhj_animation(targets, animation_id, item)
end
end
#--------------------------------------------------------------------------
# ● RMVA模式显示动画(新增定义)
#--------------------------------------------------------------------------
def show_rmva_animation(targets, animation_id, item)
@subject.damage_section_displayed = false
@subject.not_damage_section = true
targets.each do |target|
target.damage_section_displayed = false
target.not_damage_section = true
end
if animation_id < 0
show_attack_animation(targets)
else
show_rmva_usable_animation(targets, animation_id, item)
end
end
#--------------------------------------------------------------------------
# ● HZHJ模式显示动画(新增定义)
#--------------------------------------------------------------------------
def show_hzhj_animation(targets, animation_id, item)
if animation_id < 0
show_hzhj_attack_animation(targets, item)
else
if item.wljn
show_wljn_skill_animation(targets, animation_id, item)
else
show_magic_skill_animation(targets, animation_id, item)
end
end
end
#--------------------------------------------------------------------------
# ● HZHJ模式显示攻击动画(重定义)
#--------------------------------------------------------------------------
def show_hzhj_attack_animation(targets, item)
ary = []
need_move = false
animation1 = $data_animations[@subject.animation1_id]
need_move = animation1.need_move if animation1
come_back = true
targets.each_with_index do |target, i|
ary[0] = target
item.repeats.times do
next if target.dead? && item.damage.type == 1
next if @subject.dead?
next if !@subject.current_action
if need_move && come_back
come_back = false
@subject.setup_move_info(target, RealMoveDuration, animation1.move_se)
wait_for_move
end
damage_target = hzhj_apply_item_effects(target, item)
show_subject_animation(@subject.animation1_id)
show_normal_animation(ary, @subject.atk_animation_id1, false)
show_normal_animation(ary, @subject.atk_animation_id2, true)
@log_window.wait
wait_for_animation
hzhj_invoke_item(target, item, damage_target)
end
if need_move
if target != targets[i+1] or target.dead?
come_back = true
@subject.come_back_self_position(RealMoveDuration)
wait_for_move
else
come_back = false
end
end
end
end
#--------------------------------------------------------------------------
# ● HZHJ模式显示物理技能类动画(新增定义)
#--------------------------------------------------------------------------
def show_wljn_skill_animation(targets, animation_id, item)
ary = []
need_move = false
animation1 = $data_animations[item.animation1_id]
need_move = animation1.need_move if animation1
come_back = true
targets.each_with_index do |target, i|
ary[0] = target
item.repeats.times do
next if target.dead? && item.damage.type == 1
next if @subject.dead?
next if !@subject.current_action
if need_move && come_back
come_back = false
@subject.setup_move_info(target, RealMoveDuration, animation1.move_se)
wait_for_move
end
damage_target = hzhj_apply_item_effects(target, item)
show_subject_animation(item.animation1_id)
show_normal_animation(ary, animation_id, false)
@log_window.wait
wait_for_animation
hzhj_invoke_item(target, item, damage_target)
end
if need_move
if target != targets[i+1] or target.dead?
come_back = true
@subject.come_back_self_position(RealMoveDuration)
wait_for_move
else
come_back = false
end
end
end
end
#--------------------------------------------------------------------------
# ● HZHJ模式显示魔法技能类动画(新增定义)
#--------------------------------------------------------------------------
def show_magic_skill_animation(targets, animation_id, item)
ary = []
damage_targets = {}
item.repeats.times do
next if @subject.dead?
next if !@subject.current_action
ary.clear
damage_targets.clear
targets.each do |target|
next if target.dead? && item.damage.type == 1
ary << target
damage_targets[target] = hzhj_apply_item_effects(target, item)
end
next if ary.empty?
show_subject_animation(item.animation1_id)
show_normal_animation(ary, animation_id)
@log_window.wait
wait_for_animation
ary.each do |target|
hzhj_invoke_item(target, item, damage_targets[target])
end
if [9, 10].include?(item.scope)
ary.each do |target|
if target.alive?
target.come_back_self_position(RealMoveDuration)
end
end
wait_for_move
end
end
end
#--------------------------------------------------------------------------
# ● RMVA模式显示攻击动画(重定义)
#--------------------------------------------------------------------------
def show_attack_animation(targets)
item = @subject.current_action.item
show_subject_animation(@subject.animation1_id)
show_normal_animation(targets, @subject.atk_animation_id1, false)
show_normal_animation(targets, @subject.atk_animation_id2, true)
@log_window.wait
wait_for_animation
targets.each {|target| item.repeats.times { invoke_item(target, item) } }
end
#--------------------------------------------------------------------------
# ● RMVA模式显示技能、物品动画 (新增定义)
#--------------------------------------------------------------------------
def show_rmva_usable_animation(targets, animation_id, item)
show_subject_animation(item.animation1_id)
show_normal_animation(targets, animation_id)
@log_window.wait
wait_for_animation
targets.each {|target| item.repeats.times { invoke_item(target, item) } }
if [9, 10].include?(item.scope)
targets.each do |target|
if target.alive?
target.come_back_self_position(RealMoveDuration)
end
end
wait_for_move
end
end
#--------------------------------------------------------------------------
# ● 显示行动方动画(新增定义)
#--------------------------------------------------------------------------
def show_subject_animation(animation_id, subject = @subject, mirror = false)
animation = $data_animations[animation_id]
if animation
subject.animation_id = animation_id
subject.animation_mirror = mirror
if animation.wait_subject_duration < 0
wait_for_animation
elsif animation.wait_subject_duration > 0
animation.wait_subject_duration.times{update_for_wait}
end
end
end
end
class RPG::Animation
include Hzhj::HorizontalBattleSystem
def ani_z_correction
return @ani_z_correction unless @ani_z_correction.nil?
if /@az\[(\-??\d+?)\]/ =~ @name
return (@ani_z_correction = $1.to_i)
else
return (@ani_z_correction = DefaultAniAddZ)
end
end
def loop_z_correction
return @loop_z_correction unless @loop_z_correction.nil?
if /@lz\[(\-??\d+?)\]/ =~ @name
return (@loop_z_correction = $1.to_i)
else
return (@loop_z_correction = DefaultLoopAniAddZ)
end
end
attr_writer :ani_z_correction
attr_writer :loop_z_correction
end
class RPG::State < RPG::BaseItem
def animation_id
return @animation_id unless @animation_id.nil?
if /@aid\[(\d+?)\]/ =~ @note
return (@animation_id = $1.to_i)
else
return (@animation_id = 0)
end
end
attr_writer :animation_id
end
#==============================================================================
# ■ Game_BattlerBase
#==============================================================================
class Game_BattlerBase
#--------------------------------------------------------------------------
# ● 实例变量(新增定义)
#--------------------------------------------------------------------------
attr_reader :hzhj_add_state_id
attr_reader :hzhj_remove_state_id
attr_accessor :need_update_state_animation
#--------------------------------------------------------------------------
# ● 初始化(追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_init_for_state_ani_game_battler_base initialize
def initialize
@hzhj_add_state_id = []
@hzhj_remove_state_id = []
@need_update_state_animation = false
@states = []
@state_turns = {}
@state_steps = {}
hzhj_old_init_for_state_ani_game_battler_base
end
#--------------------------------------------------------------------------
# ● 清除状态信息(追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_clear_states_for_state_ani_game_battler_base clear_states
def clear_states
old_states = @states.clone
hzhj_old_clear_states_for_state_ani_game_battler_base
bingji = old_states | @states
return if bingji.empty?
set_add_state_id(bingji & @states)
set_remove_state_id(bingji & old_states)
end
#--------------------------------------------------------------------------
# ● 消除状态(追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_erase_state_for_state_ani_game_battler_base erase_state
def erase_state(state_id)
old_states = @states.clone
hzhj_old_erase_state_for_state_ani_game_battler_base(state_id)
bingji = old_states | @states
return if bingji.empty?
set_add_state_id(bingji & @states)
set_remove_state_id(bingji & old_states)
end
#--------------------------------------------------------------------------
# ● 设置增加的状态(新增定义)
#--------------------------------------------------------------------------
def set_add_state_id(zjdzt)
for i in zjdzt
if $data_states.animation_id > 0
if not @hzhj_add_state_id.include?(i)
@hzhj_add_state_id.push(i)
end
end
end
end
#--------------------------------------------------------------------------
# ● 设置解除的状态(新增定义)
#--------------------------------------------------------------------------
def set_remove_state_id(jsdzt)
for i in jsdzt
if $data_states.animation_id > 0
if not @hzhj_remove_state_id.include?(i)
ani_id = $data_states.animation_id
not_end_loop_animation = false
for state in self.states
if state.animation_id == ani_id
not_end_loop_animation = true
break
end
end
unless not_end_loop_animation
@hzhj_remove_state_id.push(i)
end
end
end
end
end
end
#==============================================================================
# ■ Game_Battler
#==============================================================================
class Game_Battler < Game_BattlerBase
#--------------------------------------------------------------------------
# ● 附加新的状态(追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_add_new_state_for_state_ani_game_battler add_new_state
def add_new_state(state_id)
old_states = @states.clone
hzhj_old_add_new_state_for_state_ani_game_battler(state_id)
bingji = old_states | @states
return if bingji.empty?
set_add_state_id(bingji & @states)
set_remove_state_id(bingji & old_states)
end
end
#==============================================================================
# ■ Sprite_Base
#==============================================================================
class Sprite_Base < Sprite
#--------------------------------------------------------------------------
# ● 初始化(追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_init_for_state_ani_spr_base initialize
def initialize(*args)
hzhj_old_init_for_state_ani_spr_base(*args)
@hzhj_loop_animations = []
@hzhj_loop_durations = {}
@hzhj_loop_sprites = {}
@hzhj_loop_bitmap1s = {}
@hzhj_loop_bitmap2s = {}
@hzhj_loop_ani_oxs = {}
@hzhj_loop_ani_oys = {}
@flash_nil_duration = 0
end
#--------------------------------------------------------------------------
# ● 释放(追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_dispose_for_state_ani_spr_base dispose
def dispose
dispose_loop_animation
hzhj_old_dispose_for_state_ani_spr_base
end
#--------------------------------------------------------------------------
# ● 设定动画的活动块(追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_ani_set_spr_for_state_ani_spr_base animation_set_sprites
def animation_set_sprites(*args)
hzhj_old_ani_set_spr_for_state_ani_spr_base(*args)
@ani_sprites.each{|sprite|sprite.z += @animation.ani_z_correction}
end
#--------------------------------------------------------------------------
# ● 判断是否有循环动画(新增定义)
#--------------------------------------------------------------------------
def loop_animation?
return (not @hzhj_loop_animations.empty?)
end
#--------------------------------------------------------------------------
# ● 开始播放循环动画(新增定义)
#--------------------------------------------------------------------------
def start_loop_animation(animation)
return if @hzhj_loop_animations.include?(animation)
if animation.nil?
dispose_loop_animation
return
end
set_animation_rate
@hzhj_loop_animations.push(animation)
init_loop_animation_duration(animation)
load_loop_animation_bitmap(animation)
make_loop_animation_sprites(animation)
set_loop_animation_origin(animation)
end
#--------------------------------------------------------------------------
# ● 初始化循环动画播放位置(新增定义)
#--------------------------------------------------------------------------
def init_loop_animation_duration(animation)
@hzhj_loop_durations[animation] = animation.frame_max * @ani_rate + 1
end
#--------------------------------------------------------------------------
# ● 读取循环动画图像(新增定义)
#--------------------------------------------------------------------------
def load_loop_animation_bitmap(animation)
animation1_name = animation.animation1_name
animation1_hue = animation.animation1_hue
animation2_name = animation.animation2_name
animation2_hue = animation.animation2_hue
bitmap1 = Cache.animation(animation1_name, animation1_hue)
bitmap2 = Cache.animation(animation2_name, animation2_hue)
if @@_reference_count.include?(bitmap1)
@@_reference_count[bitmap1] += 1
else
@@_reference_count[bitmap1] = 1
end
if @@_reference_count.include?(bitmap2)
@@_reference_count[bitmap2] += 1
else
@@_reference_count[bitmap2] = 1
end
@hzhj_loop_bitmap1s[animation] = bitmap1
@hzhj_loop_bitmap2s[animation] = bitmap2
Graphics.frame_reset
end
#--------------------------------------------------------------------------
# ● 生成循环动画活动块(新增定义)
#--------------------------------------------------------------------------
def make_loop_animation_sprites(animation)
sprites = []
if @use_sprite
16.times do
sprite = ::Sprite.new(viewport)
sprite.visible = false
sprites.push(sprite)
end
end
@hzhj_loop_sprites[animation] = sprites
end
#--------------------------------------------------------------------------
# ● 设定循环动画的原点(新增定义)
#--------------------------------------------------------------------------
def set_loop_animation_origin(animation)
if animation.position == 3
if viewport == nil
ani_ox = Graphics.width / 2
ani_oy = Graphics.height / 2
else
ani_ox = viewport.rect.width / 2
ani_oy = viewport.rect.height / 2
end
else
ani_ox = x - ox + width / 2
ani_oy = y - oy + height / 2
if animation.position == 0
ani_oy -= height / 2
elsif animation.position == 2
ani_oy += height / 2
end
end
@hzhj_loop_ani_oxs[animation] = ani_ox
@hzhj_loop_ani_oys[animation] = ani_oy
end
#--------------------------------------------------------------------------
# ● 释放所有循环动画(新增定义)
#--------------------------------------------------------------------------
def dispose_loop_animation
return unless loop_animation?
for animation in @hzhj_loop_animations.clone
end_loop_animation(animation)
end
@hzhj_loop_durations.clear
@hzhj_loop_sprites.clear
@hzhj_loop_bitmap1s.clear
@hzhj_loop_bitmap2s.clear
@hzhj_loop_ani_oxs.clear
@hzhj_loop_ani_oys.clear
@hzhj_loop_animations.clear
end
#--------------------------------------------------------------------------
# ● 结束某个循环动画(新增定义)
#--------------------------------------------------------------------------
def end_loop_animation(animation)
return if not @hzhj_loop_animations.include?(animation)
bitmap1 = @hzhj_loop_bitmap1s[animation]
@@_reference_count[bitmap1] -= 1
if @@_reference_count[bitmap1] == 0
@@_reference_count.delete(bitmap1)
bitmap1.dispose
end
bitmap2 = @hzhj_loop_bitmap2s[animation]
@@_reference_count[bitmap2] -= 1
if @@_reference_count[bitmap2] == 0
@@_reference_count.delete(bitmap2)
bitmap2.dispose
end
sprites = @hzhj_loop_sprites[animation]
for sprite in sprites
sprite.dispose
end
@hzhj_loop_durations.delete(animation)
@hzhj_loop_sprites.delete(animation)
@hzhj_loop_bitmap1s.delete(animation)
@hzhj_loop_bitmap2s.delete(animation)
@hzhj_loop_ani_oxs.delete(animation)
@hzhj_loop_ani_oys.delete(animation)
@hzhj_loop_animations.delete(animation)
end
#--------------------------------------------------------------------------
# ● 刷新(追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_update_for_state_ani_spr_base update
def update
hzhj_old_update_for_state_ani_spr_base
update_loop_animation
end
#--------------------------------------------------------------------------
# ● 刷新循环动画(新增定义)
#--------------------------------------------------------------------------
def update_loop_animation
@flash_nil_duration -= 1 if @flash_nil_duration > 0
return unless loop_animation?
for animation in @hzhj_loop_animations
@hzhj_loop_durations[animation] -= 1
duration = @hzhj_loop_durations[animation]
if duration % @ani_rate == 0
if duration > 0
set_loop_animation_origin(animation)
frame_index = animation.frame_max
frame_index -= (duration + @ani_rate - 1) / @ani_rate
args = []
args[0] = @hzhj_loop_sprites[animation]
args[1] = @hzhj_loop_bitmap1s[animation]
args[2] = @hzhj_loop_bitmap2s[animation]
args[3] = @hzhj_loop_ani_oxs[animation]
args[4] = @hzhj_loop_ani_oys[animation]
args[5] = animation.loop_z_correction
args[6] = ((not flash_nil? or animation.to_screen?) and visible)
loop_animation_set_sprites(animation.frames[frame_index], args)
animation.timings.each do |timing|
loop_animation_process_timing(timing) if timing.frame == frame_index
end
else
init_loop_animation_duration(animation)
redo
end
end
end
end
#--------------------------------------------------------------------------
# ● 设定循环动画的活动块(新增定义)
#--------------------------------------------------------------------------
def loop_animation_set_sprites(frame, args)
sprites = args[0]
bitmap1 = args[1]
bitmap2 = args[2]
ani_ox = args[3]
ani_oy = args[4]
loop_z_correction = args[5]
state_visible = args[6]
cell_data = frame.cell_data
sprites.each_with_index do |sprite, i|
next unless sprite
pattern = cell_data[i, 0]
if !pattern || pattern < 0
sprite.visible = false
next
end
sprite.bitmap = pattern < 100 ? bitmap1 : bitmap2
sprite.visible = state_visible
sprite.src_rect.set(pattern % 5 * 192,
pattern % 100 / 5 * 192, 192, 192)
sprite.x = ani_ox + cell_data[i, 1]
sprite.y = ani_oy + cell_data[i, 2]
sprite.angle = cell_data[i, 4]
sprite.mirror = (cell_data[i, 5] == 1)
if loop_z_correction > 9999
sprite.z = loop_z_correction % 10000 + i
elsif loop_z_correction < -9999
sprite.z = loop_z_correction % -10000 + i
else
sprite.z = self.z + loop_z_correction + i
end
sprite.ox = 96
sprite.oy = 96
sprite.zoom_x = cell_data[i, 3] / 100.0
sprite.zoom_y = cell_data[i, 3] / 100.0
sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
sprite.blend_type = cell_data[i, 7]
end
end
#--------------------------------------------------------------------------
# ● 循环动画SE 和闪烁时机的处理(新增定义)
#--------------------------------------------------------------------------
def loop_animation_process_timing(timing)
timing.se.play
case timing.flash_scope
when 1
self.flash(timing.flash_color, timing.flash_duration * @ani_rate)
when 2
if viewport
viewport.flash(timing.flash_color, timing.flash_duration * @ani_rate)
end
when 3
self.flash(nil, timing.flash_duration * @ani_rate)
end
end
#--------------------------------------------------------------------------
# ● 设置闪烁(追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_flash_for_state_ani_spr_base flash
def flash(*args)
if args[0].nil?
@flash_nil_duration = args[1]
else
@flash_nil_duration = 0
end
hzhj_old_flash_for_state_ani_spr_base(*args)
end
#--------------------------------------------------------------------------
# ● 判断是否正处于【隐藏目标】(新增定义)
#--------------------------------------------------------------------------
def flash_nil?
return (@flash_nil_duration > 0)
end
end
#==============================================================================
# ■ Sprite_Battler
#==============================================================================
class Sprite_Battler < Sprite_Base
#--------------------------------------------------------------------------
# ● 初始化(追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_init_for_state_ani_spr_battler initialize
def initialize(*args)
hzhj_old_init_for_state_ani_spr_battler(*args)
init_battler_add_state_id
end
#--------------------------------------------------------------------------
# ● 初始化战斗者要播放状态动画的状态(新增定义)
#--------------------------------------------------------------------------
def init_battler_add_state_id
if @battler.nil?
dispose_loop_animation
else
@battler.hzhj_add_state_id.clear
@battler.hzhj_remove_state_id.clear
@battler.need_update_state_animation = true
for state in @battler.states
next if state.nil?
next if $data_animations[state.animation_id].nil?
@battler.hzhj_add_state_id.push(state.id)
end
end
end
#--------------------------------------------------------------------------
# ● 设置战斗者(追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_battlerdy_for_state_ani_spr_battler battler=
def battler=(value)
old_battler = @battler
hzhj_old_battlerdy_for_state_ani_spr_battler(value)
if old_battler != @battler
init_battler_add_state_id
end
end
#--------------------------------------------------------------------------
# ● 刷新(追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_update_for_state_ani_spr_battler update
def update
hzhj_old_update_for_state_ani_spr_battler
if @battler
if @battler.need_update_state_animation
@battler.need_update_state_animation = false
if not @battler.hzhj_add_state_id.empty?
for i in @battler.hzhj_add_state_id
if @battler.state?(i)
ani_id = $data_states.animation_id
animation = $data_animations[ani_id]
start_loop_animation(animation) if not animation.nil?
end
end
@battler.hzhj_add_state_id.clear
end
if not @battler.hzhj_remove_state_id.empty?
for i in @battler.hzhj_remove_state_id
if not @battler.state?(i)
ani_id = $data_states.animation_id
animation = $data_animations[ani_id]
end_loop_animation(animation) if not animation.nil?
end
end
@battler.hzhj_remove_state_id.clear
end
end
end
end
end
#==============================================================================
# ■ Window_BattleLog
#==============================================================================
class Window_BattleLog < Window_Selectable
#--------------------------------------------------------------------------
# ● 显示状态附加/解除(追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_display_status_for_state_ani_wnd_btlog display_changed_states
def display_changed_states(target)
target.need_update_state_animation = true
hzhj_old_display_status_for_state_ani_wnd_btlog(target)
end
end
#==============================================================================
# ■ Sprite_Damage (新增类)
#==============================================================================
class Sprite_Damage < Sprite
include Hzhj::HorizontalBattleSystem
#--------------------------------------------------------------------------
# ● 获取/生成伤害值源图
#--------------------------------------------------------------------------
@@obmp = nil
def self.obmp
if @@obmp.nil? or @@obmp.disposed?
@@obmp = Bitmap.new(180, 256)
@@obmp.font.bold = true
@@obmp.font.shadow = false
@@obmp.font.outline = true
@@obmp.font.out_color = Color.new(255, 255, 255, 255)
@@obmp.font.size = 32
colors = []
colors.push(Color.new(255, 0, 0, 255))
colors.push(Color.new(255, 128, 128, 255))
colors.push(Color.new( 0, 0, 255, 255))
colors.push(Color.new(128, 128, 255, 255))
colors.push(Color.new( 0, 255, 0, 255))
colors.push(Color.new(128, 255, 128, 255))
colors.each_with_index do |color, hi|
@@obmp.font.color = color
for wi in 0..9
@@obmp.draw_text(wi * 18, hi * 32, 18, 32, "#{wi}", 1)
end
end
@@obmp.font.size = 20
@@obmp.font.italic = true
@@obmp.font.out_color = Color.new(0, 0, 0, 255)
@@obmp.font.color = Color.new(255, 255, 255, 255)
@@obmp.draw_text( 0, 192, 90, 32, "Critical", 1)
@@obmp.draw_text(90, 192, 90, 32, "Miss", 1)
@@obmp.draw_text( 0, 224, 90, 32, "Evasion", 1)
@@obmp.hue_change(DamageBitmapHue)
end
return @@obmp
end
#--------------------------------------------------------------------------
# ● 初始化
#--------------------------------------------------------------------------
def initialize(viewport, args)
super(viewport)
@type = args[0]
@value = args[1]
@critical = args[2]
self.x = args[4]
self.y = args[5]
self.z = args[6] + Graphics.height * 5
make_move(args[3])
refresh
end
#--------------------------------------------------------------------------
# ● 生成移动数据
#--------------------------------------------------------------------------
def make_move(battler_obj_class)
@move = []
case battler_obj_class
when :actor
make_move_actor
when :enemy
make_move_enemy
else
make_move_default
end
end
#--------------------------------------------------------------------------
# ● 生成移动数据 默认
#--------------------------------------------------------------------------
def make_move_default
45.times do |n|
if n % 3 == 0
ady = n < 21 ? -6 : -1
opa = n < 21 ? 255 : 255-(n-21)*6
@move.push([0, ady, opa])
else
@move.push([0, 0, -1])
end
end
end
#--------------------------------------------------------------------------
# ● 生成移动数据 角色
#--------------------------------------------------------------------------
def make_move_actor
make_move_default
end
#--------------------------------------------------------------------------
# ● 生成移动数据 敌人
#--------------------------------------------------------------------------
def make_move_enemy
make_move_default
end
#--------------------------------------------------------------------------
# ● 描绘
#--------------------------------------------------------------------------
def refresh
if not self.bitmap.nil?
self.bitmap.dispose
self.bitmap = nil
end
begin
@obmp = Cache.animation("damage", DamageBitmapHue)
rescue Errno::ENOENT
@obmp = Sprite_Damage.obmp
end
@numw = @obmp.width / 10
@numh = @obmp.height / 8
@strw = @obmp.width / 2
case @value
when Numeric
blt_obmp_numeric
when Symbol
blt_obmp_text
end
end
#--------------------------------------------------------------------------
# ● 通过源图描绘数字
#--------------------------------------------------------------------------
def blt_obmp_numeric
nums = @value.to_i.abs.to_s.split("")
nbmpw = nums.size * @numw
bmph = @numh
cbmpw = 0
crect = nil
dy = 0
if @critical
cbmpw = @strw
bmph *= 2
crect = Rect.new(0, @numh * 6, @strw, @numh)
dy = @numh
end
self.bitmap = Bitmap.new([nbmpw, cbmpw, 32].max, [bmph, 32].max)
self.ox = bitmap.width / 2
self.oy = bmph /2
bitmap.blt((bitmap.width - cbmpw) / 2, 0, @obmp, crect) if crect
dx = (bitmap.width - nbmpw) / 2
ry = 0
case @type
when :hp
ry = @value >= 0 ? 0 : @numh
when :mp
ry = @value >= 0 ? @numh * 2 : @numh * 3
when :tp
ry = @value >= 0 ? @numh * 4 : @numh * 5
else
return
end
rect = Rect.new(0, ry, @numw, @numh)
nums.each_with_index do |str, i|
rect.x = str.to_i * @numw
bitmap.blt(dx, dy, @obmp, rect)
dx += @numw
end
end
#--------------------------------------------------------------------------
# ● 通过源图描绘文字
#--------------------------------------------------------------------------
def blt_obmp_text
self.bitmap = Bitmap.new([@strw, 32].max, [@numh, 32].max)
self.ox = @strw / 2
self.oy = @numh / 2
rx = ry = 0
case @type
when :miss
rx = @strw
ry = @numh * 6
when :eva
ry = @numh * 7
else
return
end
rect = Rect.new(rx, ry, @strw, @numh)
bitmap.blt(0, 0, @obmp, rect)
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
bitmap.dispose if bitmap
super
end
#--------------------------------------------------------------------------
# ● 移动中判定
#--------------------------------------------------------------------------
def moving?
return (not @move.empty?)
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def update
super
if moving?
ary = @move.shift
self.x += ary[0]
self.y += ary[1]
self.opacity = ary[2] if ary[2] >= 0
end
end
end
#==============================================================================
# ■ Game_BattlerBase
#==============================================================================
class Game_BattlerBase
#--------------------------------------------------------------------------
# ● 实例变量(新增定义)
#--------------------------------------------------------------------------
attr_accessor :hzhj_damage
#--------------------------------------------------------------------------
# ● 初始化(追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_init_for_display_damage_game_battler_base initialize
def initialize
@hzhj_damage = []
hzhj_old_init_for_display_damage_game_battler_base
end
end
#==============================================================================
# ■ Sprite_Base
#==============================================================================
class Sprite_Base < Sprite
#--------------------------------------------------------------------------
# ● 初始化(追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_init_for_display_damage_spr_base initialize
def initialize(*args)
hzhj_old_init_for_display_damage_spr_base(*args)
@hzhj_damage_sprites = []
end
#--------------------------------------------------------------------------
# ● 释放(追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_dispose_for_display_damage_spr_base dispose
def dispose
hzhj_old_dispose_for_display_damage_spr_base
dispose_damage
end
#--------------------------------------------------------------------------
# ● 判断是否有伤害在显示(新增定义)
#--------------------------------------------------------------------------
def damage?
return (not @hzhj_damage_sprites.empty?)
end
#--------------------------------------------------------------------------
# ● 开始显示伤害(新增定义)
#--------------------------------------------------------------------------
def start_damage(args)
args[4] = x - ox + width / 2
args[5] = y - oy + height / 2
args[6] = z
@hzhj_damage_sprites.push(Sprite_Damage.new(viewport, args))
end
#--------------------------------------------------------------------------
# ● 释放所有伤害显示(新增定义)
#--------------------------------------------------------------------------
def dispose_damage
return unless damage?
@hzhj_damage_sprites.each{|sprite|sprite.dispose}
@hzhj_damage_sprites.clear
end
#--------------------------------------------------------------------------
# ● 刷新(追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_update_for_display_damage_spr_base update
def update
hzhj_old_update_for_display_damage_spr_base
update_damage
end
#--------------------------------------------------------------------------
# ● 刷新显示伤害(新增定义)
#--------------------------------------------------------------------------
def update_damage
return unless damage?
@hzhj_damage_sprites.each_with_index do |sprite, i|
if sprite.moving?
sprite.update
else
sprite.dispose
@hzhj_damage_sprites = nil
end
end
@hzhj_damage_sprites.delete(nil)
end
end
#==============================================================================
# ■ Sprite_Battler
#==============================================================================
class Sprite_Battler < Sprite_Base
#--------------------------------------------------------------------------
# ● 刷新(追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_update_for_display_damage_spr_battler update
def update
hzhj_old_update_for_display_damage_spr_battler
if @battler
if not @battler.hzhj_damage.empty?
unless @battler.damage_section_displayed
args = @battler.hzhj_damage.clone
args[3] = @battler.actor? ? :actor : (@battler.enemy? ? :enemy : nil)
start_damage(args)
end
@battler.hzhj_damage.clear
end
end
end
end
#==============================================================================
# ■ Window_BattleLog
#==============================================================================
class Window_BattleLog < Window_Selectable
#--------------------------------------------------------------------------
# ● 显示 MISS (追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_display_miss_for_display_damage_wnd_btlog display_miss
def display_miss(target, item)
target.hzhj_damage = [:miss, :miss, false]
hzhj_old_display_miss_for_display_damage_wnd_btlog(target, item)
end
#--------------------------------------------------------------------------
# ● 显示回避 (追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_display_evasion_for_display_damage_wnd_btlog display_evasion
def display_evasion(target, item)
target.hzhj_damage = [:eva, :evasion, false]
hzhj_old_display_evasion_for_display_damage_wnd_btlog(target, item)
end
#--------------------------------------------------------------------------
# ● 显示 HP 伤害 (追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_display_hp_damage_for_display_damage_wnd_btlog display_hp_damage
def display_hp_damage(target, item)
return if target.result.hp_damage == 0 && item && !item.damage.to_hp?
value = target.result.hp_damage
critical = target.result.critical
target.hzhj_damage = [:hp, value, critical]
hzhj_old_display_hp_damage_for_display_damage_wnd_btlog(target, item)
end
#--------------------------------------------------------------------------
# ● 显示 MP 伤害 (追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_display_mp_damage_for_display_damage_wnd_btlog display_mp_damage
def display_mp_damage(target, item)
return if target.dead? || target.result.mp_damage == 0
value = target.result.mp_damage
critical = target.result.critical
target.hzhj_damage = [:mp, value, critical]
hzhj_old_display_mp_damage_for_display_damage_wnd_btlog(target, item)
end
#--------------------------------------------------------------------------
# ● 显示 TP 伤害 (追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_display_tp_damage_for_display_damage_wnd_btlog display_tp_damage
def display_tp_damage(target, item)
return if target.dead? || target.result.tp_damage == 0
value = target.result.tp_damage
critical = target.result.critical
target.hzhj_damage = [:tp, value, critical]
hzhj_old_display_tp_damage_for_display_damage_wnd_btlog(target, item)
end
end
class RPG::Animation
def need_move
return @need_move unless @need_move.nil?
if /@[Rr][Mm]/ =~ @name
return (@need_move = true)
else
return (@need_move = false)
end
end
def move_se
return @move_se unless @move_se.nil?
@move_se = RPG::SE.new
if /@[Ss][Ee]\[(.+?)\]/ =~ @name
@move_se.name = $1.clone
end
return @move_se
end
attr_writer :need_move
attr_writer :move_se
end
#==============================================================================
# ■ Game_Battler
#==============================================================================
class Game_Battler < Game_BattlerBase
include Hzhj::HorizontalBattleSystem
#--------------------------------------------------------------------------
# ● 属性
#--------------------------------------------------------------------------
attr_accessor :add_x # X 坐标变化量
attr_accessor :add_y # Y 坐标变化量
attr_accessor :move_speed_x # 战斗图 X 移动速度
attr_accessor :move_speed_y # 战斗图 Y 移动速度
#--------------------------------------------------------------------------
# ● 初始化(追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_init_for_real_move_game_battler initialize
def initialize
@add_x = 0
@add_y = 0
@move_speed_x = 0
@move_speed_y = 0
hzhj_old_init_for_real_move_game_battler
end
#--------------------------------------------------------------------------
# ● 真实 X 坐标(新增定义)
#--------------------------------------------------------------------------
def real_screen_x
return screen_x + add_x
end
#--------------------------------------------------------------------------
# ● 真实 Y 坐标(新增定义)
#--------------------------------------------------------------------------
def real_screen_y
return screen_y + add_y
end
#--------------------------------------------------------------------------
# ● 返回自己的战斗位置(新增定义)
#--------------------------------------------------------------------------
def come_back_self_position(duration)
return if dead?
tx = screen_x
ty = screen_y
addx = tx - real_screen_x
addy = ty - real_screen_y
return if addx == 0 && addy == 0
@add_x = 0
@add_y = 0
@move_speed_x = [(addx.abs / duration.to_f).ceil, 1].max
@move_speed_y = [(addy.abs / duration.to_f).ceil, 1].max
end
#--------------------------------------------------------------------------
# ● 设置移动信息(新增定义)
#--------------------------------------------------------------------------
def setup_move_info(target_battler, duration, move_se)
return if dead?
tbmp = Cache.battler(target_battler.battler_name, target_battler.battler_hue)
sbmp = Cache.battler(@battler_name, @battler_hue)
tbw = tbmp.width / DynamicPatternMax + RealMoveBmpAddW
sbw = sbmp.width / DynamicPatternMax + RealMoveBmpAddW
tbh = tbmp.height + RealMoveBmpAddH
sbh = sbmp.height + RealMoveBmpAddH
d = actor? ? ActorDirection : 10 - ActorDirection
tx = target_battler.real_screen_x
ty = target_battler.real_screen_y
case d
when 1
tx = tx + tbw / 2 + sbw / 2
ty = ty - sbh / 2
when 2
ty = ty - sbh / 2
when 3
tx = tx - tbw / 2 - sbw / 2
ty = ty - sbh / 2
when 4
tx = tx + tbw / 2 + sbw / 2
when 6
tx = tx - tbw / 2 - sbw / 2
when 7
tx = tx + tbw / 2 + sbw / 2
ty = ty + sbh / 2
when 8
ty = ty + sbh / 2
when 9
tx = tx - tbw / 2 - sbw / 2
ty = ty + sbh / 2
end
addx = tx - real_screen_x
addy = ty - real_screen_y
return if addx == 0 && addy == 0
@add_x = tx - screen_x if addx != 0
@add_y = ty - screen_y if addy != 0
@move_speed_x = [(addx.abs / duration.to_f).ceil, 1].max
@move_speed_y = [(addy.abs / duration.to_f).ceil, 1].max
move_se.play
end
end
#==============================================================================
# ■ Sprite_Battler
#==============================================================================
class Sprite_Battler < Sprite_Base
#--------------------------------------------------------------------------
# ● 初始化(追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_init_for_real_move_spr_battler initialize
def initialize(viewport, battler = nil)
hzhj_old_init_for_real_move_spr_battler(viewport, battler)
init_position(@battler) if @battler
end
#--------------------------------------------------------------------------
# ● 设置战斗者(追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_set_battler_for_real_move_spr_battler battler=
def battler=(value)
if @battler != value && value
init_position(value)
end
hzhj_old_set_battler_for_real_move_spr_battler(value)
end
#--------------------------------------------------------------------------
# ● 初始化位置(新增定义)
#--------------------------------------------------------------------------
def init_position(battler)
battler.add_x = 0
battler.add_y = 0
self.x = battler.real_screen_x
self.y = battler.real_screen_y
self.z = battler.screen_z
end
#--------------------------------------------------------------------------
# ● 移动中判定(新增定义)
#--------------------------------------------------------------------------
def moving?
return false unless @battler
(x != @battler.real_screen_x or y != @battler.real_screen_y) && @battler
end
#--------------------------------------------------------------------------
# ● 位置的更新(重定义)
#--------------------------------------------------------------------------
def update_position
if !@battler.dead?
if x < @battler.real_screen_x
self.x = [x + @battler.move_speed_x, @battler.real_screen_x].min
elsif x > @battler.real_screen_x
self.x = [x - @battler.move_speed_x, @battler.real_screen_x].max
end
if y < @battler.real_screen_y
self.y = [y + @battler.move_speed_y, @battler.real_screen_y].min
elsif y > @battler.real_screen_y
self.y = [y - @battler.move_speed_y, @battler.real_screen_y].max
end
self.z = y + 100
end
end
end
#==============================================================================
# ■ Spriteset_Battle
#==============================================================================
class Spriteset_Battle
#--------------------------------------------------------------------------
# ● 判定是否移动中(新增定义)
#--------------------------------------------------------------------------
def moving?
battler_sprites.any? {|sprite| sprite.moving? }
end
end
#==============================================================================
# ■ Scene_Battle
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# ● 等待战斗图移动的结束(新增定义)
#--------------------------------------------------------------------------
def wait_for_move
update_for_wait
update_for_wait while @spriteset.moving?
end
end
class RPG::Troop
include Hzhj::HorizontalBattleSystem
def display_enemy_bar
return @display_enemy_bar unless @display_enemy_bar.nil?
if /@ebar/i =~ @name
return (@display_enemy_bar = !DefaultDisplayEnemyBar)
else
return (@display_enemy_bar = DefaultDisplayEnemyBar)
end
end
attr_writer :display_enemy_bar
end
#==============================================================================
# ■ Game_Troop
#==============================================================================
class Game_Troop < Game_Unit
attr_accessor :display_enemy_bar # 是否显示敌人HP条、MP条、TP条
#--------------------------------------------------------------------------
# ● 设置
#--------------------------------------------------------------------------
alias hzhj_old_setup_for_display_enemy_bar_game_troop setup
def setup(troop_id)
hzhj_old_setup_for_display_enemy_bar_game_troop(troop_id)
@display_enemy_bar = troop.display_enemy_bar
end
end
#==============================================================================
# ■ Window_BattleEnemy
#==============================================================================
class Window_BattleEnemy < Window_Selectable
#--------------------------------------------------------------------------
# ● 取得列数
#--------------------------------------------------------------------------
def col_max
if $game_troop.display_enemy_bar
return 1
else
return 2
end
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
create_contents
super
end
#--------------------------------------------------------------------------
# ● 描画项目
#--------------------------------------------------------------------------
def draw_item(index)
if $game_troop.display_enemy_bar
enemy = $game_troop.alive_members[index]
draw_basic_area(basic_area_rect(index), enemy)
draw_gauge_area(gauge_area_rect(index), enemy)
else
change_color(normal_color)
name = $game_troop.alive_members[index].name
draw_text(item_rect_for_text(index), name)
end
end
#--------------------------------------------------------------------------
# ● 取得基本区域的矩形
#--------------------------------------------------------------------------
def basic_area_rect(index)
rect = item_rect_for_text(index)
rect.width -= gauge_area_width + 10
rect
end
#--------------------------------------------------------------------------
# ● 取得值槽区域的矩形
#--------------------------------------------------------------------------
def gauge_area_rect(index)
rect = item_rect_for_text(index)
rect.x += rect.width - gauge_area_width
rect.width = gauge_area_width
rect
end
#--------------------------------------------------------------------------
# ● 取得值槽区域的宽度
#--------------------------------------------------------------------------
def gauge_area_width
return 220
end
#--------------------------------------------------------------------------
# ● 描画基本区域
#--------------------------------------------------------------------------
def draw_basic_area(rect, actor)
draw_actor_name(actor, rect.x + 0, rect.y, 100)
draw_actor_icons(actor, rect.x + 104, rect.y, rect.width - 104)
end
#--------------------------------------------------------------------------
# ● 描画值槽区域
#--------------------------------------------------------------------------
def draw_gauge_area(rect, actor)
if $data_system.opt_display_tp
draw_gauge_area_with_tp(rect, actor)
else
draw_gauge_area_without_tp(rect, actor)
end
end
#--------------------------------------------------------------------------
# ● 描画值槽区域(包括 TP 值)
#--------------------------------------------------------------------------
def draw_gauge_area_with_tp(rect, actor)
draw_actor_hp(actor, rect.x + 0, rect.y, 72)
draw_actor_mp(actor, rect.x + 82, rect.y, 64)
draw_actor_tp(actor, rect.x + 156, rect.y, 64)
end
#--------------------------------------------------------------------------
# ● 描画值槽区域(不包括 TP 值)
#--------------------------------------------------------------------------
def draw_gauge_area_without_tp(rect, actor)
draw_actor_hp(actor, rect.x + 0, rect.y, 134)
draw_actor_mp(actor, rect.x + 144, rect.y, 76)
end
end
#==============================================================================
# ■ Sprite_Battler
#==============================================================================
class Sprite_Battler < Sprite_Base
include Hzhj::HorizontalBattleSystem
#--------------------------------------------------------------------------
# ● 初始化(追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_init_for_dynamic_spr_battler initialize
def initialize(viewport, battler = nil)
hzhj_old_init_for_dynamic_spr_battler(viewport, battler)
@dynamic_duration = 0
@dynamic_duration_max = DynamicPatternMax * OnePatternDuration
end
#--------------------------------------------------------------------------
# ● 源位图(Source Bitmap)的更新(重定义)
#--------------------------------------------------------------------------
def update_bitmap
new_bitmap = Cache.battler(@battler.battler_name, @battler.battler_hue)
if bitmap != new_bitmap
self.bitmap = new_bitmap
init_visibility
@dynamic_duration = 0
@sx = 0
@sw = bitmap.width / DynamicPatternMax
@sh = bitmap.height
self.ox = @sw / 2
self.oy = @sh
src_rect.set(@sx, 0, @sw, @sh)
end
end
#--------------------------------------------------------------------------
# ● 原点的更新(重定义)
#--------------------------------------------------------------------------
def update_origin
if bitmap
@dynamic_duration += 1
@dynamic_duration %= @dynamic_duration_max
@sx = @dynamic_duration / OnePatternDuration * @sw
src_rect.set(@sx, 0, @sw, @sh)
end
end
#--------------------------------------------------------------------------
# ● 返回普通设定(追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_revert_to_normal_for_dynamic_spr_battler revert_to_normal
def revert_to_normal
hzhj_old_revert_to_normal_for_dynamic_spr_battler
self.ox = @sw / 2 if bitmap
end
#--------------------------------------------------------------------------
# ● BOSS 战败(崩坏)效果的更新(追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_update_boss_col_for_dynamic_spr_battler update_boss_collapse
def update_boss_collapse
hzhj_old_update_boss_col_for_dynamic_spr_battler
self.ox = @sw / 2 + @effect_duration % 2 * 4 - 2
end
end
#==============================================================================
# ■ Game_Battler
#==============================================================================
class Game_Battler < Game_BattlerBase
def set_normal_battler_name
@battler_name = @battler_name.split(/★/)[0]
end
def set_beaten_battler_name
if guard?
if (UseActorGuardGraphic && actor?) or
(UseEnemyGuardGraphic && enemy?)
set_guard_battler_name
return
end
end
@battler_name = @battler_name.split(/★/)[0] + "★1"
if UseActorWBSE && actor?
Audio.se_play("Audio/SE/AWBSE_#{id}", 100, 100)
elsif UseEnemyWBSE && enemy?
Audio.se_play("Audio/SE/EWBSE_#{enemy_id}", 100, 100)
end
end
def set_dead_battler_name
@battler_name = @battler_name.split(/★/)[0] + "★2"
end
def set_guard_battler_name
@battler_name = @battler_name.split(/★/)[0] + "★3"
if UseActorGDSE && actor?
Audio.se_play("Audio/SE/AGDSE_#{id}", 100, 100)
elsif UseEnemyGDSE && enemy?
Audio.se_play("Audio/SE/EGDSE_#{enemy_id}", 100, 100)
end
end
end
#==============================================================================
# ■ Sprite_Battler
#==============================================================================
class Sprite_Battler < Sprite_Base
#--------------------------------------------------------------------------
# ● 初始化(追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_init_for_dead_spr_battler initialize
def initialize(viewport, battler = nil)
hzhj_old_init_for_dead_spr_battler(viewport, battler)
@dead_graphic_used = false
if @battler
@battler.set_normal_battler_name
if @battler.dead?
if (UseActorDeadGraphic && @battler.actor?) or
(UseEnemyDeadGraphic && @battler.enemy?)
@battler.set_dead_battler_name
@dead_graphic_used = true
end
end
end
@beaten_duration = -1
end
#--------------------------------------------------------------------------
# ● 设置战斗者(追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_set_battler_for_dead_spr_battler battler=
def battler=(value)
if @battler != value
@dead_graphic_used = false
if value
value.set_normal_battler_name
if value.dead?
if (UseActorDeadGraphic && value.actor?) or
(UseEnemyDeadGraphic && value.enemy?)
value.set_dead_battler_name
@dead_graphic_used = true
end
end
end
@beaten_duration = -1
end
hzhj_old_set_battler_for_dead_spr_battler(value)
end
#--------------------------------------------------------------------------
# ● 源位图(Source Bitmap)的更新(重定义)
#--------------------------------------------------------------------------
alias hzhj_old_update_bitmap_for_was_beaten_spr_battler update_bitmap
def update_bitmap
if @beaten_duration > 0
@beaten_duration -= 1
elsif @beaten_duration == 0
@beaten_duration = -1
set_bitmap(:normal)
end
hzhj_old_update_bitmap_for_was_beaten_spr_battler
end
#--------------------------------------------------------------------------
# ● 初始化可视状态(追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_visibility_for_dead_spr_battler init_visibility
def init_visibility
hzhj_old_visibility_for_dead_spr_battler
if @battler.dead?
if (UseActorDeadGraphic && @battler.actor?) or
(UseEnemyDeadGraphic && @battler.enemy?)
self.opacity = 255
end
end
end
#--------------------------------------------------------------------------
# ● 效果开始(追加定义)
#--------------------------------------------------------------------------
alias hzhj_old_start_effect_for_dead_spr_battler start_effect
def start_effect(effect_type)
if effect_type == :appear
if @dead_graphic_used
set_bitmap(:normal)
@effect_type = nil
@effect_duration = 0
@dead_graphic_used = false
@battler_visible = true
return
end
elsif effect_type == :collapse or
effect_type == :boss_collapse or
effect_type == :instant_collapse
if @beaten_duration >= 0
@beaten_duration = -1
set_bitmap(:normal)
end
if (UseActorDeadGraphic && @battler.actor?) or
(UseEnemyDeadGraphic && @battler.enemy?)
set_bitmap(:dead)
@effect_type = nil
@effect_duration = 0
@dead_graphic_used = true
@battler_visible = false
return
end
end
hzhj_old_start_effect_for_dead_spr_battler(effect_type)
end
#--------------------------------------------------------------------------
# ● 设置新的位图(新增定义)
#--------------------------------------------------------------------------
def set_bitmap(sym)
case sym
when :normal
@battler.set_normal_battler_name
when :was_beaten
@battler.set_beaten_battler_name
when :dead
@battler.set_dead_battler_name
else
return
end
new_bitmap = Cache.battler(@battler.battler_name, @battler.battler_hue)
if bitmap != new_bitmap
self.bitmap = new_bitmap
@dynamic_duration = 0
@sx = 0
@sw = bitmap.width / DynamicPatternMax
@sh = bitmap.height
self.ox = @sw / 2
self.oy = @sh
src_rect.set(@sx, 0, @sw, @sh)
end
update_origin
update_position
end
end
#==============================================================================
# ■ Scene_Battle
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# ● 发动技能/物品(新增定义)
#--------------------------------------------------------------------------
def hzhj_invoke_item(target, item, damage_target)
refresh_status
@log_window.display_action_results(damage_target, item)
@subject.damage_section_displayed = false
@subject.last_target_index = target.index
return if target.dead?
if rand < target.item_cnt(@subject, item)
hzhj_invoke_counter_attack(target, item)
elsif rand < target.item_mrf(@subject, item)
hzhj_invoke_magic_reflection(target, item)
end
end
#--------------------------------------------------------------------------
# ● 发动物理反击(新增定义)
#--------------------------------------------------------------------------
def hzhj_invoke_counter_attack(target, item)
@log_window.display_counter(target, item)
attack_skill = $data_skills[target.attack_skill_id]
@subject.item_apply(target, attack_skill)
need_move = false
animation1 = $data_animations[target.animation1_id]
need_move = animation1.need_move if animation1
ary = [@subject]
if need_move
target.setup_move_info(@subject, RealMoveDuration, animation1.move_se)
wait_for_move
end
@subject.damage_section_displayed = false
@subject.not_damage_section = false
show_subject_animation(target.animation1_id, target)
show_normal_animation(ary, target.atk_animation_id1, false)
show_normal_animation(ary, target.atk_animation_id2, true)
@log_window.wait
wait_for_animation
if need_move && target.alive?
target.come_back_self_position(RealMoveDuration)
wait_for_move
end
refresh_status
@log_window.display_action_results(@subject, attack_skill)
end
#--------------------------------------------------------------------------
# ● 发动魔法反射(新增定义)
#--------------------------------------------------------------------------
def hzhj_invoke_magic_reflection(target, item)
@subject.damage_section_displayed = false
@subject.not_damage_section = false
@log_window.display_reflection(target, item)
@subject.item_apply(@subject, item)
refresh_status
@log_window.display_action_results(@subject, item)
end
end
#==============================================================================
# ■ Game_Battler
#==============================================================================
class Game_Battler < Game_BattlerBase
attr_accessor :damage_section_displayed
attr_accessor :not_damage_section
end
#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ● 执行伤害效果
#--------------------------------------------------------------------------
alias hzhj_old_per_damage_for_damage_section_game_actor perform_damage_effect
def perform_damage_effect
unless damage_section_displayed
hzhj_old_per_damage_for_damage_section_game_actor
end
end
end
#==============================================================================
# ■ Game_Enemy
#==============================================================================
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# ● 执行伤害效果
#--------------------------------------------------------------------------
alias hzhj_old_per_damage_for_damage_section_game_enemy perform_damage_effect
def perform_damage_effect
unless damage_section_displayed
hzhj_old_per_damage_for_damage_section_game_enemy
end
end
end
#==============================================================================
# ■ Sprite_Battler
#==============================================================================
class Sprite_Battler < Sprite_Base
#--------------------------------------------------------------------------
# ● SE 和闪烁时机的处理
#--------------------------------------------------------------------------
def animation_process_timing(timing)
if timing.se.name == DamageSectionDisplaySEName
hp_value = @battler.result.hp_damage
mp_value = @battler.result.mp_damage
tp_value = @battler.result.tp_damage
value = args = nil
was_beaten = false
if hp_value != 0 && !@battler.not_damage_section
was_beaten = true if hp_value > 0
value = hp_value * timing.flash_color.red.to_i / 100
critical = @battler.result.critical
args = [:hp, value, critical]
elsif mp_value != 0 && !@battler.not_damage_section
was_beaten = true if mp_value > 0
value = mp_value * timing.flash_color.red.to_i / 100
critical = @battler.result.critical
args = [:mp, value, critical]
elsif tp_value != 0 && !@battler.not_damage_section
was_beaten = true if tp_value > 0
value = tp_value * timing.flash_color.red.to_i / 100
critical = @battler.result.critical
args = [:tp, value, critical]
end
if value && args
args[3] = @battler.actor? ? :actor : (@battler.enemy? ? :enemy : nil)
@battler.damage_section_displayed = true
start_damage(args)
if UseBeatenGraphic && was_beaten
set_bitmap(:was_beaten)
@beaten_duration = BeatenGraphicDuration
end
end
return
end
super(timing)
end
end
#==============================================================================
# ■ Scene_Battle
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# ● 应用技能/物品效果(新增定义)
#--------------------------------------------------------------------------
def hzhj_apply_item_effects(target, item)
target.damage_section_displayed = false
target.not_damage_section = false
target = apply_substitute(target, item)
target.damage_section_displayed = false
target.not_damage_section = false
target.item_apply(@subject, item)
return target
end
end
#==============================================================================
# ■ 此脚本来自 www.66rpg.com
#==============================================================================
[/pre]
[pre lang="ruby" line="1"]#==============================================================================
# +++ MOG - ADVANCED BATTLE HUD (v1.6) +++
#==============================================================================
# By Moghunter
# http://www.atelier-rgss.com/
#==============================================================================
# Sistema de hud avançado de batalha.
#==============================================================================
#==============================================================================
# ● Histórico (Version History)
#==============================================================================
# v 1.6 - Corrigido o erro quando o MP ou TP maximo é iguál a zero.
# v 1.5 - Corrigido a animação da face quando uma skill tem a função charge.
# v 1.4 - Corrigido o erro de crash randômico. (relativo a dispose de imagem.)
# v 1.3 - Script 100% independente do sistema de AT System.
# - Correção da posição inicial da janela de Fuga.
# - Correção da posição do cursor nos aliados quando a face está
# desabilitada.
# v 1.2 - Corrigido a prioridade das condições.
# v 1.1 - Corrigido o glitch inicial da prioridade da face.
# v 1.0 - Primeiro lançamento.
#==============================================================================
#==============================================================================
# ■ - FACE ANIMADAS DOS PERSONAGENS - (Opcional)
#==============================================================================
# 1 - Grave as imagens das faces dos personagens na pasta.
#
# GRAPHICS/BATTLERS/
#
# 2 - Nomeie a imagem com o mesmo nome do personagem. (EG - Hertor.png)
# 3 - A largura da imagem deverá ser dividido por 5. (A escolha do tamanho
# da face é livre desde que a lagura dividido pela altura seja igual a 5 )
#
#==============================================================================
#==============================================================================
# ■ BATTLE HUD SETTING
#==============================================================================
module MOG_BATTLE_HUD
# Ativar Battlers dos personagens em faces, deixe desativado em caso de haver
# outros scripts que usam battlers dos personagens em seu projeto.
BATTLER_FACE_ENABLE = true
#Definição geral da posição da HUD.
HUD_POSITION = [5,315]
#Definição da posição da face
FACE_POSITION = [60,30]
#Definição da posição do numero de HP.
HP_NUMBER_POSITION = [85,28]
#Definição da posição do medidor de HP.
HP_METER_POSITION = [27,37]
#Definição da posição do numero de MP.
MP_NUMBER_POSITION = [101,46]
#Definição da posição do medidor de MP.
MP_METER_POSITION = [43,55]
#Definição da posição do numero de TP.
TP_NUMBER_POSITION = [85,64]
#Definição da posição do medidor de TP.
TP_METER_POSITION = [27,73]
#Definição da posição das condições
STATES_POSITION = [5,1]
#Definição da posição do comando de batalha.
COMMAND_POSITION = [0,-145]
#Definição da posição do espaço da HUD entre os membros do grupo.
MEMBERS_SPACE = [136,0]
#Definição da prioridade da HUD.
BATTLE_HUD_Z = 50
#Definição da velocidade de animação dos medidores.
METER_FLOW_SPEED = 2
#Ativa o layout mais limpo nas janelas de item e skill.
ITEM_SKILL_WINDOWS_CLEAN_STYLE = true
#Definição da opacidade das janelas.
ITEM_SKILL_WINDOW_OPACITY = 0
end
#==============================================================================
# ■ CURSOR SETTING
#==============================================================================
module MOG_BATTLE_CURSOR
#Definição da posição do cursor em relação ao alvo.
CURSOR_POSITION = [-45, -16]
#Definição da posição do nome do alvo.
CURSOR_NAME_POSITION = [-10, 35]
#Ativar efeito deslizar.
CURSOR_SLIDE_EFFECT = true
#Ativar animação de levitação.
CURSOR_FLOAT_EFFECT = true
end
if MOG_BATTLE_HUD::BATTLER_FACE_ENABLE #BATTLER_FACE SYSTEM START
#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
attr_accessor :battler_face
attr_accessor :screen_x
attr_accessor :screen_y
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias mog_battle_hud_initialize setup
def setup(actor_id)
mog_battle_hud_initialize(actor_id)
battler_sprite_setup
end
#--------------------------------------------------------------------------
# ● Battler Sprite Setup
#--------------------------------------------------------------------------
def battler_sprite_setup
@battler_face = [0,0,0]
@battler_name = @name
@screen_x = 0
@screen_y = 0
end
#--------------------------------------------------------------------------
# ● Use Sprite?
#--------------------------------------------------------------------------
def use_sprite?
return true
end
#--------------------------------------------------------------------------
# ● Screen Z
#--------------------------------------------------------------------------
def screen_z
return MOG_BATTLE_HUD::BATTLE_HUD_Z + 4
end
#------------------------------------------------------------------------
# ● Screen X
#------------------------------------------------------------------------
def screen_x
return FACE_POSITION[0] + HUD_POSITION[0] + (MEMBERS_SPACE[0] * index)
end
#------------------------------------------------------------------------
# ● Screen Y
#------------------------------------------------------------------------
def screen_y
return FACE_POSITION[1] + HUD_POSITION[1] + (MEMBERS_SPACE[1] * index)
end
end
#==============================================================================
# ■ Sprite_Battler
#==============================================================================
class Sprite_Battler < Sprite_Base
include MOG_BATTLE_HUD
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias mog_battle_hud_initialize initialize
def initialize(viewport, battler = nil)
battle_hud_setup
mog_battle_hud_initialize(viewport, battler)
end
#--------------------------------------------------------------------------
# ● Battle Hud Setup
#--------------------------------------------------------------------------
def battle_hud_setup
@old_face_index = 0
end
#--------------------------------------------------------------------------
# ● Dispose
#--------------------------------------------------------------------------
alias mog_battle_hud_dispose dispose
def dispose
mog_battle_hud_dispose
if @f_im != nil
@f_im.dispose
end
end
#--------------------------------------------------------------------------
# ● Update Bitmap
#--------------------------------------------------------------------------
alias mog_battle_hud_update_bitmap update_bitmap
def update_bitmap
if @battler.is_a?(Game_Actor)
create_actor_battler
update_actor_battler
return
end
mog_battle_hud_update_bitmap
end
#--------------------------------------------------------------------------
# ● Create Actor Battler
#--------------------------------------------------------------------------
def create_actor_battler
return if self.bitmap != nil
@f_im = Cache.battler(@battler.battler_name, 0)
@f_cw = @f_im.width / 5
@f_ch = @f_im.height
self.bitmap = Bitmap.new(@f_cw,@f_ch)
x = FACE_POSITION[0] + HUD_POSITION[0] + (MEMBERS_SPACE[0] * @battler.index)
y = FACE_POSITION[1] + HUD_POSITION[1] + (MEMBERS_SPACE[1] * @battler.index)
@org_pos = [x,y]
@battler.battler_face = [0,0,0]
@battler_visible = true
@low_hp = @battler.mhp * 30 / 100
self.z = @battler.screen_z + 100
make_face(true)
end
#--------------------------------------------------------------------------
# ● Face Base Setting
#--------------------------------------------------------------------------
def face_base_setting
self.x = @org_pos[0]
self.y = @org_pos[1]
self.z = @battler.screen_z
self.zoom_x = 1
self.zoom_y = 1
self.mirror = false
end
#--------------------------------------------------------------------------
# ● Check Base Face
#--------------------------------------------------------------------------
def check_base_face(reset)
face_base_setting
return if @battler.battler_face[2] > 0
@battler.battler_face = [0,0,0] if reset and @battler.battler_face[1] != 2
@battler.battler_face[0] = 3 if @battler.hp < @low_hp
@battler.battler_face[0] = 4 if @battler.hp == 0
end
#--------------------------------------------------------------------------
# ● Make Face
#--------------------------------------------------------------------------
def make_face(reset = false)
self.bitmap.clear
check_base_face(reset)
src_rect_back = Rect.new(@f_cw * @battler.battler_face[0], 0, @f_cw, @f_ch)
self.bitmap.blt(0,0, @f_im, src_rect_back)
@old_face_index = @battler.battler_face[0]
end
#--------------------------------------------------------------------------
# ● Update Actor Battler
#--------------------------------------------------------------------------
def update_actor_battler
return if self.bitmap == nil
update_face_effect
update_face_reset_time
update_face_z
make_face if @old_face_index != @battler.battler_face[0]
end
#--------------------------------------------------------------------------
# ● Update Face Z
#--------------------------------------------------------------------------
def update_face_z
self.z = @battler.screen_z + BATTLE_HUD_Z rescue 100
end
#--------------------------------------------------------------------------
# ● Update Face Reset Time
#--------------------------------------------------------------------------
def update_face_reset_time
return if @battler.battler_face[2] == 0
@battler.battler_face[2] -= 1
if @battler.battler_face[2] == 0 or
(@battler.hp < @low_hp and @battler.battler_face[0] == 0)
make_face(true)
end
end
#--------------------------------------------------------------------------
# ● Update Face Effect
#--------------------------------------------------------------------------
def update_face_effect
return if @battler.battler_face[2] == 0
case @battler.battler_face[1]
when 0
face_damage
when 1..2
face_heal
when 3
face_action
end
end
#--------------------------------------------------------------------------
# ● Face Damage
#--------------------------------------------------------------------------
def face_damage
self.x = (@org_pos[0] - (@battler.battler_face[2] /2)) + rand(@battler.battler_face[2])
end
#--------------------------------------------------------------------------
# ● Face Heal
#--------------------------------------------------------------------------
def face_heal
case @battler.battler_face[2]
when 20..40
self.zoom_x += 0.01
self.zoom_y = self.zoom_x
when 0..20
self.zoom_x -= 0.01
self.zoom_y = self.zoom_x
end
end
#--------------------------------------------------------------------------
# ● Face Action
#--------------------------------------------------------------------------
def face_action
case @battler.battler_face[2]
when 25..50
self.zoom_x += 0.01
self.zoom_y = self.zoom_x
self.mirror = true
when 0..25
self.zoom_x -= 0.01
self.zoom_y = self.zoom_x
self.mirror = false
end
self.zoom_x = self.zoom_x > 1.5 ? self.zoom_x = 1.5 : self.zoom_x < 1 ? 1 : self.zoom_x
self.zoom_y = self.zoom_y > 1.5 ? self.zoom_y = 1.5 : self.zoom_y < 1 ? 1 : self.zoom_y
end
#--------------------------------------------------------------------------
# ● Update Position
#--------------------------------------------------------------------------
alias mog_battle_hud_update_position update_position
def update_position
return if @battle.is_a?(Game_Actor)
mog_battle_hud_update_position
end
#--------------------------------------------------------------------------
# ● Update Collapse
#--------------------------------------------------------------------------
alias mog_battle_hud_update_collapse update_collapse
def update_collapse
return if @battler.is_a?(Game_Actor)
mog_battle_hud_update_collapse
end
#--------------------------------------------------------------------------
# ● Update Instant Collapse
#--------------------------------------------------------------------------
alias mog_battle_hud_update_instant_collapse update_instant_collapse
def update_instant_collapse
return if @battler.is_a?(Game_Actor)
mog_battle_hud_update_instant_collapse
end
end
#==============================================================================
# ■ Battle Manager
#==============================================================================
class << BattleManager
#--------------------------------------------------------------------------
# ● Battle End
#--------------------------------------------------------------------------
alias mog_battle_hud_battle_process_victory process_victory
def process_victory
execute_face_effect
mog_battle_hud_battle_process_victory
end
#--------------------------------------------------------------------------
# ● Prepare
#--------------------------------------------------------------------------
def execute_face_effect
for i in $game_party.members
if i.hp > 0
i.battler_face = [1,2,40]
end
end
end
end
#==============================================================================
# ■ Game Action
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# ● Show Animations
#--------------------------------------------------------------------------
alias mog_battle_hud_show_animation show_animation
def show_animation(targets, animation_id)
# execute_battle_cry(2, @subject.current_action.item.id, @subject)
make_face_action_battle
mog_battle_hud_show_animation(targets, animation_id)
end
#--------------------------------------------------------------------------
# ● Make Face Action
#--------------------------------------------------------------------------
def make_face_action_battle
return if !@subject.is_a?(Game_Actor)
@subject.battler_face = [2,3,50]
end
end
#==============================================================================
# ■ Game Battler
#==============================================================================
class Game_Battler < Game_BattlerBase
#--------------------------------------------------------------------------
# ● Item Apply
#--------------------------------------------------------------------------
alias mog_battle_hud_item_apply item_apply
def item_apply(user, item)
old_hp = self.hp
old_mp = self.mp
mog_battle_hud_item_apply(user, item)
check_face_effect(old_hp,old_mp) if can_check_face_effect?(old_hp,old_mp)
end
#--------------------------------------------------------------------------
# ● Check Face Effect
#--------------------------------------------------------------------------
def check_face_effect(old_hp,old_mp)
if self.hp > old_hp or self.mp > old_mp
self.battler_face = [1,1,40]
elsif self.hp < old_hp
self.battler_face = [3,0,40]
end
end
#--------------------------------------------------------------------------
# ● Added New State
#--------------------------------------------------------------------------
alias mog_battle_hud_add_new_state add_new_state
def add_new_state(state_id)
mog_battle_hud_add_new_state(state_id)
if self.is_a?(Game_Actor)
self.battler_face = [1,1,40] if $data_states[state_id].note =~ /<Good State>/
self.battler_face = [3,0,40] if $data_states[state_id].note =~ /<Bad State>/
end
end
#--------------------------------------------------------------------------
# ● Regenerate HP
#--------------------------------------------------------------------------
alias mog_battle_hud_regenerate_hp regenerate_hp
def regenerate_hp
old_hp = self.hp
old_mp = self.mp
mog_battle_hud_regenerate_hp
check_face_effect(old_hp,old_mp) if can_check_face_effect?(old_hp,old_mp)
end
#--------------------------------------------------------------------------
# ● Regenerate MP
#--------------------------------------------------------------------------
alias mog_battle_hud_regenerate_mp regenerate_mp
def regenerate_mp
old_hp = self.hp
old_mp = self.mp
mog_battle_hud_regenerate_mp
check_face_effect(old_hp,old_mp) if can_check_face_effect?(old_hp,old_mp)
end
#--------------------------------------------------------------------------
# ● Can Check Face Effect
#--------------------------------------------------------------------------
def can_check_face_effect?(old_hp,old_mp)
return false if self.is_a?(Game_Enemy)
return true if old_hp != self.hp
return true if old_mp != self.mp
return false
end
end
#==============================================================================
# ■ Scene_Battle
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# ● Invoke Counter Attack
#--------------------------------------------------------------------------
alias mog_battle_hud_invoke_counter_attack invoke_counter_attack
def invoke_counter_attack(target, item)
mog_battle_hud_invoke_counter_attack(target, item)
if target.is_a?(Game_Actor) and target.battler_face[0] != 2
target.battler_face = [2,3,50]
end
end
#--------------------------------------------------------------------------
# ● Invoke Magic Reflection
#--------------------------------------------------------------------------
alias mog_battle_hud_invoke_magic_reflection invoke_magic_reflection
def invoke_magic_reflection(target, item)
mog_battle_hud_invoke_magic_reflection(target, item)
if target.is_a?(Game_Actor) and target.battler_face[0] != 2
target.battler_face = [2,3,50]
end
end
end
end #BATTLER FACE SYSTEM END --------------------------------------------------
#==============================================================================
# ■ Battle_Hud
#==============================================================================
class Battle_Hud
include MOG_BATTLE_HUD
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
def initialize(actor)
dispose
@actor = actor
@x = HUD_POSITION[0] + (MEMBERS_SPACE[0] * @actor.index)
@y = HUD_POSITION[1] + (MEMBERS_SPACE[1] * @actor.index)
pre_cache
create_layout
create_hp_number
create_hp_meter
create_mp_number
create_mp_meter
create_tp_number
create_tp_meter
create_states
end
#--------------------------------------------------------------------------
# ● Pre Cache
#--------------------------------------------------------------------------
def pre_cache
@number = Cache.system("Battle_Hud_Number")
@number_cw = @number.width / 10
@number_ch = @number.height / 4
@meter = Cache.system("Battle_Hud_Meter")
@meter_cw = @meter.width / 3
@meter_ch = @meter.height / 3
@icon = Cache.system("Iconset")
end
#--------------------------------------------------------------------------
# ● Create Layout
#--------------------------------------------------------------------------
def create_layout
@layout = Sprite.new
@layout.bitmap = Cache.system("Battle_Hud_Layout")
@layout.z = BATTLE_HUD_Z
@layout.x = @x
@layout.y = @y
end
#--------------------------------------------------------------------------
# ● Create HP Number
#--------------------------------------------------------------------------
def create_hp_number
@hp = @actor.hp
@hp_old = @actor.hp
@hp_ref = @hp_old
@hp_refresh = false
@hp_number = Sprite.new
@hp_number.bitmap = Bitmap.new((@number_cw * 6),@number_ch)
@hp_number.z = BATTLE_HUD_Z + 2
@hp_number.x = @x + HP_NUMBER_POSITION[0]
@hp_number.y = @y + HP_NUMBER_POSITION[1]
refresh_hp_number
end
#--------------------------------------------------------------------------
# ● Create HP Meter
#--------------------------------------------------------------------------
def create_hp_meter
@hp_meter = Sprite.new
@hp_meter.bitmap = Bitmap.new(@meter_cw,@meter_ch)
@hp_meter.z = BATTLE_HUD_Z + 1
@hp_meter.x = @x + HP_METER_POSITION[0]
@hp_meter.y = @y + HP_METER_POSITION[1]
@hp_flow = rand(@meter_cw * 2)
@hp_width_old = @meter_cw * @actor.hp / @actor.mhp
hp_flow_update
end
#--------------------------------------------------------------------------
# ● Hp Flow Update
#--------------------------------------------------------------------------
def hp_flow_update
@hp_meter.bitmap.clear
hp_width = @meter_cw * @actor.hp / @actor.mhp
#execute_damage_flow(hp_width)
hp_src_rect = Rect.new(@hp_flow, 0,hp_width, @meter_ch)
@hp_meter.bitmap.blt(0,0, @meter, hp_src_rect)
@hp_flow += METER_FLOW_SPEED
@hp_flow = 0 if @hp_flow >= @meter_cw * 2
end
#--------------------------------------------------------------------------
# ● Execute Damage Flow
#--------------------------------------------------------------------------
def execute_damage_flow(hp_width)
n = (@hp_width_old - hp_width).abs * 3 / 100
damage_flow = [[n, 2].min,0.5].max
@hp_width_old -= damage_flow
@hp_width_old = hp_width if @hp_width_old < hp_width
src_rect_old = Rect.new(@hp_flow, @meter_ch * 3,@hp_width_old, @meter_ch)
@hp_meter.bitmap.blt(0,0, @meter, src_rect_old)
end
#--------------------------------------------------------------------------
# ● Update HP Number
#--------------------------------------------------------------------------
def update_hp_number
@hp_refresh = true
n = 2 * (@actor.hp - @hp_old).abs / 100
hp_ref = [[n, 100].min,1].max
if @hp_old < @actor.hp
@hp += hp_ref
if @hp >= @actor.hp
@hp_old = @actor.hp
@hp = @actor.hp
@hp_ref = 0
end
elsif @hp_old > @actor.hp
@hp -= hp_ref
if @hp <= @actor.hp
@hp_old = @actor.hp
@hp = @actor.hp
@hp_ref = 0
end
end
end
#--------------------------------------------------------------------------
# ● Refresh HP Number
#--------------------------------------------------------------------------
def refresh_hp_number
@hp_number.bitmap.clear
number_value = @hp.abs.to_s.split(//)
hp_color = @hp < @actor.mhp * 30 / 100 ? @number_ch : 0
center_x = 0
for r in 0..number_value.size - 1
number_value_abs = number_value[r].to_i
src_rect = Rect.new(@number_cw * number_value_abs, hp_color, @number_cw, @number_ch)
@hp_number.bitmap.blt((@number_cw + 1) * r, 0, @number, src_rect)
center_x += 1
end
@hp_number.x = @x + HP_NUMBER_POSITION[0] - (center_x * (@number_cw + 1))
@hp_refresh = false if @hp == @actor.hp
end
#--------------------------------------------------------------------------
# ● Create MP Number
#--------------------------------------------------------------------------
def create_mp_number
@mp = @actor.mp
@mp_old = @actor.mp
@mp_ref = @mp_old
@mp_refresh = false
@mp_number = Sprite.new
@mp_number.bitmap = Bitmap.new((@number_cw * 6),@number_ch)
@mp_number.z = BATTLE_HUD_Z + 2
@mp_number.x = @x + MP_NUMBER_POSITION[0]
@mp_number.y = @y + MP_NUMBER_POSITION[1]
refresh_mp_number
end
#--------------------------------------------------------------------------
# ● Create MP Meter
#--------------------------------------------------------------------------
def create_mp_meter
@mp_meter = Sprite.new
@mp_meter.bitmap = Bitmap.new(@meter_cw,@meter_ch)
@mp_meter.z = BATTLE_HUD_Z + 1
@mp_meter.x = @x + MP_METER_POSITION[0]
@mp_meter.y = @y + MP_METER_POSITION[1]
@mp_flow = rand(@meter_cw * 2)
@mp_width_old = @meter_cw * @actor.mp / @actor.mmp rescue 0
mp_flow_update
end
#--------------------------------------------------------------------------
# ● Mp Flow Update
#--------------------------------------------------------------------------
def mp_flow_update
return if @actor.mmp == 0
@mp_meter.bitmap.clear
mp_width = @meter_cw * @actor.mp / @actor.mmp rescue 0
src_rect = Rect.new(@mp_flow, @meter_ch,mp_width, @meter_ch)
@mp_meter.bitmap.blt(0,0, @meter, src_rect)
@mp_flow += METER_FLOW_SPEED
@mp_flow = 0 if @mp_flow >= @meter_cw * 2
end
#--------------------------------------------------------------------------
# ● Update MP Number
#--------------------------------------------------------------------------
def update_mp_number
@mp_refresh = true
n = 2 * (@actor.mp - @mp_old).abs / 100
mp_ref = [[n, 100].min,1].max
if @mp_old < @actor.mp
@mp += mp_ref
if @mp >= @actor.mp
@mp_old = @actor.mp
@mp = @actor.mp
@mp_ref = 0
end
elsif @mp_old > @actor.mp
@mp -= mp_ref
if @mp <= @actor.mp
@mp_old = @actor.mp
@mp = @actor.mp
@mp_ref = 0
end
end
end
#--------------------------------------------------------------------------
# ● Refresh MP Number
#--------------------------------------------------------------------------
def refresh_mp_number
@mp_number.bitmap.clear
number_value = @mp.abs.to_s.split(//)
center_x = 0
for r in 0..number_value.size - 1
number_value_abs = number_value[r].to_i
src_rect = Rect.new(@number_cw * number_value_abs, @number_ch * 2, @number_cw, @number_ch)
@mp_number.bitmap.blt((@number_cw + 1) * r, 0, @number, src_rect)
center_x += 1
end
@mp_number.x = @x + MP_NUMBER_POSITION[0] - (center_x * (@number_cw + 1))
@mp_refresh = false if @mp == @actor.mp
end
#--------------------------------------------------------------------------
# ● Create TP Number
#--------------------------------------------------------------------------
def create_tp_number
@tp = @actor.tp
@tp_old = @actor.tp
@tp_ref = @tp_old
@tp_refresh = false
@tp_number = Sprite.new
@tp_number.bitmap = Bitmap.new((@number_cw * 6),@number_ch)
@tp_number.z = BATTLE_HUD_Z + 2
@tp_number.x = @x + TP_NUMBER_POSITION[0]
@tp_number.y = @y + TP_NUMBER_POSITION[1]
refresh_tp_number
end
#--------------------------------------------------------------------------
# ● Create TP Meter
#--------------------------------------------------------------------------
def create_tp_meter
@tp_meter = Sprite.new
@tp_meter.bitmap = Bitmap.new(@meter_cw,@meter_ch)
@tp_meter.z = BATTLE_HUD_Z + 1
@tp_meter.x = @x + TP_METER_POSITION[0]
@tp_meter.y = @y + TP_METER_POSITION[1]
@tp_flow = rand(@meter_cw * 2)
@tp_width_old = @meter_cw * @actor.tp / @actor.max_tp rescue 0
tp_flow_update
end
#--------------------------------------------------------------------------
# ● TP Flow Update
#--------------------------------------------------------------------------
def tp_flow_update
return if @actor.max_tp == 0
@tp_meter.bitmap.clear
tp_width = @meter_cw * @actor.tp / @actor.max_tp rescue 0
src_rect = Rect.new(@tp_flow, @meter_ch * 2,tp_width, @meter_ch)
@tp_meter.bitmap.blt(0,0, @meter, src_rect)
@tp_flow += METER_FLOW_SPEED
@tp_flow = 0 if @tp_flow >= @meter_cw * 2
end
#--------------------------------------------------------------------------
# ● Update TP Number
#--------------------------------------------------------------------------
def update_tp_number
@tp_refresh = true
n = 2 * (@actor.tp - @tp_old).abs / 100
tp_ref = [[n, 100].min,1].max
if @tp_old < @actor.tp
@tp += tp_ref
if @tp >= @actor.tp
@tp_old = @actor.tp
@tp = @actor.tp
@tp_ref = 0
end
elsif @tp_old > @actor.tp
@tp -= tp_ref
if @tp <= @actor.tp
@tp_old = @actor.tp
@tp = @actor.tp
@tp_ref = 0
end
end
end
#--------------------------------------------------------------------------
# ● Refresh TP Number
#--------------------------------------------------------------------------
def refresh_tp_number
@tp_number.bitmap.clear
number_value = @tp.truncate.to_s.split(//)
center_x = 0
for r in 0..number_value.size - 1
number_value_abs = number_value[r].to_i
src_rect = Rect.new(@number_cw * number_value_abs, @number_ch * 3, @number_cw, @number_ch)
@tp_number.bitmap.blt((@number_cw + 1) * r, 0, @number, src_rect)
center_x += 1
end
@tp_number.x = @x + TP_NUMBER_POSITION[0] - (center_x * (@number_cw + 1))
@tp_refresh = false if @tp == @actor.tp
end
#--------------------------------------------------------------------------
# ● Create_States
#--------------------------------------------------------------------------
def create_states
refresh_states
@status = Sprite.new
@status.bitmap = Bitmap.new(24,24)
@status.x = @x + STATES_POSITION[0]
@status.y = @y + STATES_POSITION[1]
@status_flow = -24
@states_speed = 50
@status.z = BATTLE_HUD_Z + 2
@old_states = @actor.states
flow_states
end
#--------------------------------------------------------------------------
# ● Flow_Status
#--------------------------------------------------------------------------
def flow_states
return if @actor.states.size == 0 and !@status.visible
@states_speed = 0
@status.bitmap.clear
src_rect = Rect.new(@status_flow,0, 24,24)
@status.bitmap.blt(0,0, @actor_status, src_rect)
@status.visible = @actor.states.size == 0 ? false : true
@status_flow += 1
@status_flow = -24 if @status_flow >= @states_size - 24
end
#--------------------------------------------------------------------------
# ● Refresh States
#--------------------------------------------------------------------------
def refresh_states
refresh_icon if @icon == nil or @icon.disposed?
@old_states = @actor.states
if @actor_status != nil
@actor_status.dispose
@actor_status = nil
end
@states_size = @actor.states.size > 0 ? (48 * @actor.states.size) : 24
@actor_status = Bitmap.new(@states_size,24)
index = 0
for i in @actor.states
rect = Rect.new(i.icon_index % 16 * 24, i.icon_index / 16 * 24, 24, 24)
@actor_status.blt(48 * index , 0, @icon, rect)
index += 1
end
end
#--------------------------------------------------------------------------
# ● Refresh Icon
#--------------------------------------------------------------------------
def refresh_icon
if @icon != nil
if !@icon.disposed?
@icon.dispose
end
@icon = nil
end
@icon = Cache.system("Iconset")
end
#--------------------------------------------------------------------------
# ● Dispose
#--------------------------------------------------------------------------
def dispose
return if @meter == nil
@meter.dispose
@meter = nil
@number.dispose
if @icon != nil
if !@icon.disposed?
@icon.dispose
end
@icon = nil
end
@layout.bitmap.dispose
@layout.dispose
@hp_number.bitmap.dispose
@hp_number.dispose
@hp_meter.bitmap.dispose
@hp_meter.dispose
@mp_number.bitmap.dispose
@mp_number.dispose
@mp_meter.bitmap.dispose
@mp_meter.dispose
@tp_number.bitmap.dispose
@tp_number.dispose
@tp_meter.bitmap.dispose
@tp_meter.dispose
@status.bitmap.dispose
@status.dispose
if @actor_status != nil
@actor_status.dispose
@actor_status = nil
end
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update
return if @meter == nil
update_hp_number if @hp_old != @actor.hp
refresh_hp_number if @hp_refresh
update_mp_number if @mp_old != @actor.mp
refresh_mp_number if @mp_refresh
update_tp_number if @tp_old != @actor.tp
refresh_tp_number if @tp_refresh
refresh_states if @old_states != @actor.states
hp_flow_update
tp_flow_update
mp_flow_update
flow_states
end
end
#==============================================================================
# ■ Spriteset Battle
#==============================================================================
class Spriteset_Battle
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias mog_battle_hud_initialize initialize
def initialize
mog_battle_hud_initialize
create_battle_hud
end
#--------------------------------------------------------------------------
# ● Create Battle Hud
#--------------------------------------------------------------------------
def create_battle_hud
dispose_battle_hud
@battle_hud = []
for i in $game_party.members
@battle_hud.push(Battle_Hud.new(i))
end
end
#--------------------------------------------------------------------------
# ● Dispose
#--------------------------------------------------------------------------
alias mog_battle_hud_dispose dispose
def dispose
mog_battle_hud_dispose
dispose_battle_hud
end
#--------------------------------------------------------------------------
# ● Dispose Battle Hud
#--------------------------------------------------------------------------
def dispose_battle_hud
return if @battle_hud == nil
@battle_hud.each {|sprite| sprite.dispose }
@battle_hud.clear
@battle_hud = nil
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
alias mog_battle_hud_update update
def update
mog_battle_hud_update
update_battle_hud
end
#--------------------------------------------------------------------------
# ● Update Battle Hud
#--------------------------------------------------------------------------
def update_battle_hud
return if @battle_hud == nil
@battle_hud.each {|sprite| sprite.update }
end
end
#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
include MOG_BATTLE_HUD
attr_accessor :hud_x
attr_accessor :hud_y
#--------------------------------------------------------------------------
# ● HUD X
#--------------------------------------------------------------------------
def hud_x
return HUD_POSITION[0] + (MEMBERS_SPACE[0] * index)
end
#--------------------------------------------------------------------------
# ● HUD Y
#--------------------------------------------------------------------------
def hud_y
return HUD_POSITION[1] + (MEMBERS_SPACE[1] * index)
end
end
#==============================================================================
# ■ Scene Battle
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# ● Create Party Command Window
#--------------------------------------------------------------------------
alias mog_battle_hud_create_party_command_window create_party_command_window
def create_party_command_window
mog_battle_hud_create_party_command_window
set_party_window_position
end
#--------------------------------------------------------------------------
# ● Set Party Window Position
#--------------------------------------------------------------------------
def set_party_window_position
@party_command_window.viewport = nil
return if $mog_rgss3_at_system != nil
a_index = []
for actor in $game_party.alive_members
a_index = [actor.hud_x, actor.hud_y]
break
end
return if a_index.empty?
@party_command_window.x = MOG_BATTLE_HUD::COMMAND_POSITION[0] + a_index[0]
@party_command_window.y = MOG_BATTLE_HUD::COMMAND_POSITION[1] + a_index[1]
end
#--------------------------------------------------------------------------
# ● Set Party Window Position
#--------------------------------------------------------------------------
alias mog_battle_hud_start_party_command_selection start_party_command_selection
def start_party_command_selection
set_party_window_position
mog_battle_hud_start_party_command_selection
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
alias mog_battle_hud_update_basic update_basic
def update_basic
mog_battle_hud_update_basic
update_command_window_visible
end
#--------------------------------------------------------------------------
# ● Update Command Window Visible
#--------------------------------------------------------------------------
def update_command_window_visible
@status_window.visible = @status_window.active ? true : false
@actor_command_window.visible = @actor_command_window.active ? true : false
@skill_window.visible = @skill_window.active ? true : false
@item_window.visible = @item_window.active ? true : false
end
#--------------------------------------------------------------------------
# ● Start Actor Command Selection
#--------------------------------------------------------------------------
alias mog_battle_hud_start_actor_command_selection start_actor_command_selection
def start_actor_command_selection
mog_battle_hud_start_actor_command_selection
@actor_command_window.viewport = nil
@actor_command_window.x = MOG_BATTLE_HUD::COMMAND_POSITION[0] + $game_party.members[BattleManager.actor.index].hud_x
@actor_command_window.y = MOG_BATTLE_HUD::COMMAND_POSITION[1] + $game_party.members[BattleManager.actor.index].hud_y
@party_command_window.x = @actor_command_window.x
@party_command_window.y = @actor_command_window.y
end
end
#==============================================================================
# ■ Game Temp
#==============================================================================
class Game_Temp
attr_accessor :battle_cursor
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias mog_battle_cursor_initialize initialize
def initialize
@battle_cursor = [0,0,true,""]
mog_battle_cursor_initialize
end
end
#==============================================================================
# ■ Spriteset Battle
#==============================================================================
class Spriteset_Battle
include MOG_BATTLE_CURSOR
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias mog_battle_cursor_initialize initialize
def initialize
mog_battle_cursor_initialize
create_cursor
end
#--------------------------------------------------------------------------
# ● Create_Cursor
#--------------------------------------------------------------------------
def create_cursor
@cursor = Sprite.new
@cursor.bitmap = Cache.system("Battle_Cursor")
@cursor.z = 999
@cursor.visible = false
@cursor_new_x = -64
@cursor_new_y = -64
@cursor_float_y = 0
@cursor_float_duration = 0
@c_real_y = 0
@cursor_name = Sprite.new
@cursor_name.bitmap = Bitmap.new(120,32)
@cursor_name.z = @cursor.z + 1
@cursor_name.bitmap.font.size = 16
refresh_cursor_name
update_cursor_name
$game_temp.battle_cursor = [@cursor_new_x,@cursor_new_y,false]
end
#--------------------------------------------------------------------------
# ● Refresh Cursor Name
#--------------------------------------------------------------------------
def refresh_cursor_name
return if !(@cursor.x == $game_temp.battle_cursor[0] and
@cursor.y == @c_real_y)
@cursor_name_enemy = $game_temp.battle_cursor[3]
@cursor_name.bitmap.clear
@cursor_name.bitmap.draw_text(0,0,120,32,@cursor_name_enemy.to_s,1)
end
#--------------------------------------------------------------------------
# ● Dispose
#--------------------------------------------------------------------------
alias mog_battle_cursor_dispose dispose
def dispose
mog_battle_cursor_dispose
dispose_cursor
end
#--------------------------------------------------------------------------
# ● Dispose Cursor
#--------------------------------------------------------------------------
def dispose_cursor
@cursor.bitmap.dispose
@cursor.dispose
@cursor_name.bitmap.dispose
@cursor_name.dispose
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
alias mog_battle_cursor_update update
def update
mog_battle_cursor_update
update_battle_cursor
end
#--------------------------------------------------------------------------
# ● Update Battle Cursor
#--------------------------------------------------------------------------
def update_battle_cursor
return if @cursor == nil
@cursor.visible = $game_temp.battle_cursor[2]
update_cursor_name
if !@cursor.visible
@cursor.x = -64
@cursor.y = -64
@cursor.opacity = 0
update_cursor_name
return
end
@cursor.opacity += 15
update_cursor_float_effect
if CURSOR_SLIDE_EFFECT
update_cursor_slide_effect
else
@cursor.x = $game_temp.battle_cursor[0]
@cursor.y = $game_temp.battle_cursor[1]
end
end
#--------------------------------------------------------------------------
# ● Update Cursor Name
#--------------------------------------------------------------------------
def update_cursor_name
refresh_cursor_name if @cursor_name_enemy != $game_temp.battle_cursor[3]
@cursor_name.x = @cursor.x + CURSOR_NAME_POSITION[0]
@cursor_name.y = @cursor.y + CURSOR_NAME_POSITION[1]
@cursor_name.opacity = @cursor.opacity
@cursor_name.visible = @cursor.visible
end
#--------------------------------------------------------------------------
# ● Update Cursor Slide Effect
#--------------------------------------------------------------------------
def update_cursor_slide_effect
@cursor_new_x = $game_temp.battle_cursor[0]
@cursor_new_y = $game_temp.battle_cursor[1]
@cs_x = 5 + ((@cursor.x - @cursor_new_x).abs / 5)
@cs_y = 5 + ((@cursor.y - @cursor_new_y).abs / 5)
if @cursor.x > @cursor_new_x
@cursor.x -= @cs_x
@cursor.x = @cursor_new_x if @cursor.x < @cursor_new_x
elsif @cursor.x < @cursor_new_x
@cursor.x += @cs_x
@cursor.x = @cursor_new_x if @cursor.x > @cursor_new_x
end
@c_real_y = @cursor_new_y + @cursor_float_y
if @cursor.y > @cursor_new_y
@cursor.y -= @cs_y
@cursor.y = @c_real_y if @cursor.y < @c_real_y
elsif @cursor.y < @c_real_y
@cursor.y += @cs_y
@cursor.y = @c_real_y if @cursor.y > @c_real_y
end
end
#--------------------------------------------------------------------------
# ● Update Cursor Float Effect
#--------------------------------------------------------------------------
def update_cursor_float_effect
return if !CURSOR_FLOAT_EFFECT
@cursor_float_duration += 1
case @cursor_float_duration
when 0..20
@cursor_float_y += 1
when 21..40
@cursor_float_y -= 1
else
@cursor_float_y = 0
@cursor_float_duration = 0
end
end
end
#==============================================================================
# ■ Window BattleStatus
#==============================================================================
class Window_BattleStatus < Window_Selectable
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias mog_battle_hud_initialize initialize
def initialize
mog_battle_hud_initialize
self.visible = false
end
#--------------------------------------------------------------------------
# ● Refresh
#--------------------------------------------------------------------------
alias mog_battle_hud_refresh refresh
def refresh
return
mog_battle_hud_refresh
end
end
#==============================================================================
# ■ Scene Battle
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# ● Create Enemy Window
#--------------------------------------------------------------------------
def create_enemy_window
@enemy_window = Window_BattleEnemy_Cursor.new
@enemy_window.set_handler(:ok, method(:on_enemy_ok))
@enemy_window.set_handler(:cancel, method(:on_enemy_cancel))
end
#--------------------------------------------------------------------------
# ● Create Actor Window
#--------------------------------------------------------------------------
def create_actor_window
@actor_window = Window_BattleActor_Cursor.new
@actor_window.set_handler(:ok, method(:on_actor_ok))
@actor_window.set_handler(:cancel, method(:on_actor_cancel))
end
end
#==============================================================================
# ■ Window Selectable Battle_Cursor
#==============================================================================
class Window_Selectable_Battle_Cursor < Window_Base
attr_reader :index
#--------------------------------------------------------------------------
# ● Initialize
#-------------------------------------------------------------------------
def initialize(x, y, width, height)
super
@index = -1
@handler = {}
deactivate
end
#--------------------------------------------------------------------------
# ● Item Max
#--------------------------------------------------------------------------
def item_max
return 0
end
#--------------------------------------------------------------------------
# ● Active
#--------------------------------------------------------------------------
def active=(active)
super
end
#--------------------------------------------------------------------------
# ● Index
#--------------------------------------------------------------------------
def index=(index)
@index = index
end
#--------------------------------------------------------------------------
# ● Set Handler
#--------------------------------------------------------------------------
def set_handler(symbol, method)
@handler[symbol] = method
end
#--------------------------------------------------------------------------
# ● Handle?
#--------------------------------------------------------------------------
def handle?(symbol)
@handler.include?(symbol)
end
#--------------------------------------------------------------------------
# ● Call Handler
#--------------------------------------------------------------------------
def call_handler(symbol)
@handler[symbol].call if handle?(symbol)
end
#--------------------------------------------------------------------------
# ● Cursor Movable
#--------------------------------------------------------------------------
def cursor_movable?
active && open? && !@cursor_fix && !@cursor_all && item_max > 0
end
#--------------------------------------------------------------------------
# ● Cursor Down
#--------------------------------------------------------------------------
def cursor_down(wrap = false)
self.index += 1
check_index_limit
end
#--------------------------------------------------------------------------
# ● Cursor Right
#--------------------------------------------------------------------------
def cursor_right(wrap = false)
self.index += 1
check_index_limit
end
#--------------------------------------------------------------------------
# ● Cursor UP
#--------------------------------------------------------------------------
def cursor_up(wrap = false)
self.index -= 1
check_index_limit
end
#--------------------------------------------------------------------------
# ● Cursor Left
#--------------------------------------------------------------------------
def cursor_left(wrap = false)
self.index -= 1
check_index_limit(self.index)
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update
super
process_cursor_move
process_handling
end
#--------------------------------------------------------------------------
# ● Process Cursor Move
#--------------------------------------------------------------------------
def process_cursor_move
return unless cursor_movable?
last_index = @index
cursor_down (Input.trigger?(:DOWN)) if Input.repeat?(:DOWN)
cursor_up (Input.trigger?(:UP)) if Input.repeat?(:UP)
cursor_right(Input.trigger?(:RIGHT)) if Input.repeat?(:RIGHT)
cursor_left (Input.trigger?(:LEFT)) if Input.repeat?(:LEFT)
if @index != last_index
Sound.play_cursor
set_cursor_position(@index)
end
end
#--------------------------------------------------------------------------
# ● Process Handling
#--------------------------------------------------------------------------
def process_handling
return unless open? && active
return process_ok if ok_enabled? && Input.trigger?(:C)
return process_cancel if cancel_enabled? && Input.trigger?(:B)
end
#--------------------------------------------------------------------------
# ● OK Enabled
#--------------------------------------------------------------------------
def ok_enabled?
handle?(:ok)
end
#--------------------------------------------------------------------------
# ● Cancel Enabled
#--------------------------------------------------------------------------
def cancel_enabled?
handle?(:cancel)
end
#--------------------------------------------------------------------------
# ● Process OK
#--------------------------------------------------------------------------
def process_ok
if current_item_enabled?
Sound.play_ok
Input.update
deactivate
call_ok_handler
else
Sound.play_buzzer
end
end
#--------------------------------------------------------------------------
# ● Call OK Handler
#--------------------------------------------------------------------------
def call_ok_handler
call_handler(:ok)
end
#--------------------------------------------------------------------------
# ● Process Cancel
#--------------------------------------------------------------------------
def process_cancel
Sound.play_cancel
Input.update
deactivate
call_cancel_handler
end
#--------------------------------------------------------------------------
# ● Call Cancel Handler
#--------------------------------------------------------------------------
def call_cancel_handler
call_handler(:cancel)
end
#--------------------------------------------------------------------------
# ● Set Cursor Position
#--------------------------------------------------------------------------
def set_cursor_position(index)
end
#--------------------------------------------------------------------------
# ● Current Item Enabled?
#--------------------------------------------------------------------------
def current_item_enabled?
return true
end
#--------------------------------------------------------------------------
# ● Refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
end
#--------------------------------------------------------------------------
# ● Show
#--------------------------------------------------------------------------
def show
set_cursor_position(self.index)
$game_temp.battle_cursor[2] = true
super
end
#--------------------------------------------------------------------------
# ● Hide
#--------------------------------------------------------------------------
def hide
$game_temp.battle_cursor[2] = false
super
end
#--------------------------------------------------------------------------
# ● Check Index Limit
#--------------------------------------------------------------------------
def check_index_limit(index = self.index)
self.index = index
self.index = 0 if self.index >= item_max
self.index = (item_max - 1) if self.index < 0
end
end
#==============================================================================
# ■ Window_BattleEnemy
#==============================================================================
class Window_BattleEnemy_Cursor < Window_Selectable_Battle_Cursor
include MOG_BATTLE_CURSOR
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
def initialize
super(-32, -32, 32, 32)
self.index = 0
self.visible = false
set_cursor_position(self.index)
end
#--------------------------------------------------------------------------
# ● Item Max
#--------------------------------------------------------------------------
def item_max
$game_troop.alive_members.size
end
#--------------------------------------------------------------------------
# ● Enemy
#--------------------------------------------------------------------------
def enemy
$game_troop.alive_members[self.index]
end
#--------------------------------------------------------------------------
# ● Set Cursor Position
#--------------------------------------------------------------------------
def set_cursor_position(index)
check_index_limit(index)
return if $game_troop.alive_members[self.index] == nil
$game_temp.battle_cursor[0] = $game_troop.alive_members[self.index].screen_x + CURSOR_POSITION[0]
$game_temp.battle_cursor[1] = $game_troop.alive_members[self.index].screen_y + CURSOR_POSITION[1]
$game_temp.battle_cursor[3] = $game_troop.alive_members[self.index].name
end
end
#==============================================================================
# ■ Window_BattleActor Cursor
#==============================================================================
class Window_BattleActor_Cursor < Window_Selectable_Battle_Cursor
include MOG_BATTLE_CURSOR
include MOG_BATTLE_HUD
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
def initialize
super(-32, -32, 32, 32)
self.index = 0
self.visible = true
set_cursor_position(self.index)
end
#--------------------------------------------------------------------------
# ● Item Max
#--------------------------------------------------------------------------
def item_max
$game_party.members.size
end
#--------------------------------------------------------------------------
# ● Set Cursor Position
#--------------------------------------------------------------------------
def set_cursor_position(index)
check_index_limit(index)
return if $game_party.members[self.index] == nil
screen_x = $game_party.members[self.index].screen_x rescue nil
screen_y = $game_party.members[self.index].screen_y rescue nil
if screen_x == nil or screen_y == nil
screen_x = $game_party.members[self.index].hud_x + (HP_NUMBER_POSITION[0] / 3) + 32
screen_y = $game_party.members[self.index].hud_y + (HP_NUMBER_POSITION[1] / 2) + 32
end
$game_temp.battle_cursor[0] = screen_x + CURSOR_POSITION[0]
$game_temp.battle_cursor[1] = screen_y + CURSOR_POSITION[1]
$game_temp.battle_cursor[3] = $game_party.members[self.index].name
end
end
$mog_rgss3_battle_hud = true
[/pre] |
|