#==============================================================================
# F14 - 战斗镜头 - By芙蕾娅
#------------------------------------------------------------------------------
# ★ - 新增 ☆ - 修改 ■ - 删除 ● - 无变更
#==============================================================================
module Freya
# 镜头帧速,数字越小越快
Camera_Frame_Speed = 12
# 镜头放大率,正常大小1.0,默认放大1.2
Take_Zoom = 1.2
# 背景增大率,默认0.1
# 避免默认素材背景在镜头移动后出现黑边所做的处理
Back_Zoom = 0.1
end
#==============================================================================
# ■ Battle_Camera
#------------------------------------------------------------------------------
# 保存着战斗镜头的讯息
#==============================================================================
class Battle_Camera
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :x
attr_accessor :y
attr_accessor :zoom
attr_accessor :new_zoom
attr_reader :center_width
attr_reader :center_height
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize
@x = @new_x = @center_width = Graphics.width / 2
@y = @new_y = @center_height = Graphics.height / 1.5
@zoom = @new_zoom = 1.0
@frame_speed = Freya::Camera_Frame_Speed
end
#--------------------------------------------------------------------------
# ● 初始化帧率
#--------------------------------------------------------------------------
def reset_frame_speed
@frame_speed = Freya::Camera_Frame_Speed
end
#--------------------------------------------------------------------------
# ● 设置镜头瞄准对象
#--------------------------------------------------------------------------
def look(target,zoom=nil,speed=nil)
if target.is_a?(Game_Enemy)
reset_frame_speed
@new_x = target.screen_x
@new_y = target.screen_y
@new_zoom = zoom unless zoom.nil?
@frame_speed = speed unless speed.nil?
end
end
#--------------------------------------------------------------------------
# ● 将镜头移至中心
#--------------------------------------------------------------------------
def center(zoom = 1.0)
@new_x = @center_width
@new_y = @center_height
@new_zoom = zoom
end
#--------------------------------------------------------------------------
# ● 计算x坐标
#--------------------------------------------------------------------------
def battler_x(battler)
distance = battler.screen_x - @x
value = distance * (@zoom - 1.0)
pos = battler.screen_x - (@x - @center_width)
return pos + value
end
#--------------------------------------------------------------------------
# ● 计算y坐标
#--------------------------------------------------------------------------
def battler_y(battler)
distance = battler.screen_y - @y
value = distance * (@zoom - 1.0)
pos = battler.screen_y - (@y - @center_height)
return pos + value
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
if @x != @new_x
@x = (@new_x - @x > 0) ?
[@x + move_speed_x, @new_x].min : [@x - move_speed_x, @new_x].max
end
if @y != @new_y
@y = (@new_y - @y > 0) ?
[@y + move_speed_y, @new_y].min : [@y - move_speed_y, @new_y].max
end
if @zoom != @new_zoom
@zoom = (@new_zoom - @zoom > 0) ?
[@zoom + zoom_speed, @new_zoom].min : [@zoom - zoom_speed, @new_zoom].max
end
end
#--------------------------------------------------------------------------
# ● 镜头x坐标与指定点x坐标的距离
#--------------------------------------------------------------------------
def dis_x
(@x - @new_x).abs
end
#--------------------------------------------------------------------------
# ● 镜头y坐标与指定点y坐标的距离
#--------------------------------------------------------------------------
def dis_y
(@y - @new_y).abs
end
#--------------------------------------------------------------------------
# ● 镜头放大率与指定放大率的差距
#--------------------------------------------------------------------------
def dis_zoom
(@zoom - @new_zoom).abs
end
#--------------------------------------------------------------------------
# ● 镜头x坐标移动速度
#--------------------------------------------------------------------------
def move_speed_x
return [(dis_x / @frame_speed).to_i, 1].max
end
#--------------------------------------------------------------------------
# ● 镜头y坐标移动速度
#--------------------------------------------------------------------------
def move_speed_y
return [(dis_y / @frame_speed).to_i, 1].max
end
#--------------------------------------------------------------------------
# ● 镜头缩放速度
#--------------------------------------------------------------------------
def zoom_speed
return [(dis_zoom / @frame_speed), 0.01].max
end
end
#==============================================================================
# ■ Sprite_Battler
#------------------------------------------------------------------------------
# 显示战斗者的精灵。根据 Game_Battler 类的实例自动变化。
#==============================================================================
class Sprite_Battler < Sprite_Base
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :hp_gauge
#--------------------------------------------------------------------------
# ☆ 设置动画的精灵
#--------------------------------------------------------------------------
def animation_set_sprites(frame)
cell_data = frame.cell_data
set_animation_origin
@ani_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 ? @ani_bitmap1 : @ani_bitmap2
sprite.visible = true
sprite.src_rect.set(pattern % 5 * 192,
pattern % 100 / 5 * 192, 192, 192)
if @ani_mirror
sprite.x = @ani_ox - cell_data[i, 1]
sprite.y = @ani_oy + cell_data[i, 2]
sprite.angle = (360 - cell_data[i, 4])
sprite.mirror = (cell_data[i, 5] == 0)
else
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)
end
sprite.z = self.z + 300 + i
sprite.ox = 96
sprite.oy = 96
sprite.zoom_x = cell_data[i, 3] / 100.0 * self.zoom_x
sprite.zoom_y = cell_data[i, 3] / 100.0 * self.zoom_y
sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
sprite.blend_type = cell_data[i, 7]
end
end
end
#==============================================================================
# ■ Spriteset_Battle
#------------------------------------------------------------------------------
# 处理战斗画面的精灵的类。本类在 Scene_Battle 类的内部使用。
#==============================================================================
class Spriteset_Battle
#--------------------------------------------------------------------------
# ★ 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :battle_camera
#--------------------------------------------------------------------------
# ☆ 初始化对象
#--------------------------------------------------------------------------
alias initialize_freya_camera initialize
def initialize
create_camera
initialize_freya_camera
end
#--------------------------------------------------------------------------
# ★ 创建镜头
#--------------------------------------------------------------------------
def create_camera
@battle_camera = Battle_Camera.new
end
#--------------------------------------------------------------------------
# ☆ 更新画面
#--------------------------------------------------------------------------
alias update_freya_camera update
def update
update_freya_camera
update_camera
end
#--------------------------------------------------------------------------
# ● 刷新镜头
#--------------------------------------------------------------------------
def update_camera
@battle_camera.update
update_battleback_position
update_enemy_position
end
#--------------------------------------------------------------------------
# ● 刷新背景坐标
#--------------------------------------------------------------------------
def update_battleback_position
zom = Freya::Take_Zoom + Freya::Back_Zoom
zoom = @back1_sprite.zoom_x = @back2_sprite.zoom_x = @battle_camera.zoom * zom
zoom = @back1_sprite.zoom_y = @back2_sprite.zoom_y = @battle_camera.zoom * zom
x = @back1_sprite.ox
y = @back1_sprite.oy
bbx = (x - (@battle_camera.x - @battle_camera.center_width))
bby = (y - (@battle_camera.y - @battle_camera.center_height))
@back1_sprite.x = @back2_sprite.x = bbx
@back1_sprite.y = @back2_sprite.y = bby
end
#--------------------------------------------------------------------------
# ● 刷新敌人坐标
#--------------------------------------------------------------------------
def update_enemy_position
for sprite in @enemy_sprites
next if sprite.nil? || sprite.battler.nil?
sprite.zoom_x = @battle_camera.zoom
sprite.zoom_y = @battle_camera.zoom
sprite.x = @battle_camera.battler_x(sprite.battler)
sprite.y = @battle_camera.battler_y(sprite.battler)
unless sprite.hp_gauge.nil?
sprite.hp_gauge.x = sprite.x - sprite.hp_gauge.width / 2
sprite.hp_gauge.y = sprite.y
end
end
end
end
#==============================================================================
# ■ Scene_Battle
#------------------------------------------------------------------------------
# 战斗画面
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# ★ 获取镜头
#--------------------------------------------------------------------------
def camera
return @spriteset.battle_camera
end
#--------------------------------------------------------------------------
# ☆ 使用技能/物品
#--------------------------------------------------------------------------
def use_item
camera.look(@subject,Freya::Take_Zoom)
wait(Freya::Camera_Frame_Speed)
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
camera.look(targets,Freya::Take_Zoom)
wait(Freya::Camera_Frame_Speed)
show_animation(targets, item.animation_id)
targets.each {|target| item.repeats.times { invoke_item(target, item) } }
camera.center
end
#--------------------------------------------------------------------------
# ☆ 应用技能/物品效果
#--------------------------------------------------------------------------
alias apply_item_effects_freya_camera apply_item_effects
def apply_item_effects(target, item)
camera.look(target, Freya::Take_Zoom)
wait(Freya::Camera_Frame_Speed)
apply_item_effects_freya_camera(target, item)
end
#--------------------------------------------------------------------------
# ☆ 发动反击
#--------------------------------------------------------------------------
alias invoke_counter_attack_freya_camera invoke_counter_attack
def invoke_counter_attack(target, item)
camera.look(target, Freya::Take_Zoom)
wait(Freya::Camera_Frame_Speed)
invoke_counter_attack_freya_camera(target, item)
end
#--------------------------------------------------------------------------
# ☆ 发动反射魔法攻击
#--------------------------------------------------------------------------
alias invoke_magic_reflection_freya_camera invoke_magic_reflection
def invoke_magic_reflection(target, item)
camera.look(target, Freya::Take_Zoom)
wait(Freya::Camera_Frame_Speed)
invoke_magic_reflection_freya_camera(target, item)
end
#--------------------------------------------------------------------------
# ☆ 显示普通动画
#--------------------------------------------------------------------------
def show_normal_animation(targets, animation_id, mirror = false)
animation = $data_animations[animation_id]
if animation
camera.center if animation.to_screen?
targets.each do |target|
camera.look(target, Freya::Take_Zoom) unless animation.to_screen?
target.animation_id = animation_id
target.animation_mirror = mirror
abs_wait_short unless animation.to_screen?
end
abs_wait_short if animation.to_screen?
end
end
end
$imported = {} if $imported.nil?
$imported["YES-BattlePopup"] = true
#==============================================================================
# ■ BattleLuna
#==============================================================================
module BattleLuna
module Addon
BATTLE_POPUP = {
# Basic Configuration.
:basic_setting => {
:enable => true, # Set to false to disable popup.
:state_popup => false, # Set to false to disable state popup.
:buff_popup => false, # Set to false to disable buff popup.
:delay => 6, # Delay between each popup.
:no_delay => [:critical, :drained, :weakpoint, :resistant, :absorbed],
},
# Configuration for words.
:word_setting => {
:default => "%s", # SprintF for Default.
:hp_dmg => "%s ", # SprintF for HP damage.
:hp_heal => "%s ", # SprintF for HP healing.
:mp_dmg => "%s MP", # SprintF for MP damage.
:mp_heal => "%s MP", # SprintF for MP healing.
:tp_dmg => "%s TP", # SprintF for MP damage.
:tp_heal => "%s TP", # SprintF for MP healing.
:drained => "吸收", # Text display for draining HP/MP.
:critical => "命中要害", # Text display for critical hit.
:missed => "MISS", # Text display for missed attack.
:evaded => "MISS", # Text display for evaded attack.
:nulled => "0", # Text display for nulled attack.
:failed => "失败", # Text display for a failed attack.
:add_state => "+%s", # SprintF for added states.
:rem_state => "-%s", # SprintF for removed states.
:dur_state => "%s", # SprintF for during states.
:weakpoint => "属性克制", # Appears if foe is weak to element.
:resistant => "属性抵抗", # Appears if foe is resistant to element.
:immune => "属性免疫", # Appears if foe is immune to element.
:absorbed => "属性吸收", # Appears if foe can absorb the element.
:add_buff => "%s", # Appears when a positive buff is applied.
:add_debuff => "%s", # Appears when a negative buff is applied.
},
# Configuration for popup visual.
:style_setting => {
# Type => [Red, Green, Blue, Size, Bold, Italic, Font],
:default => [255, 255, 255, 32, true, false, "Bitstream Arrus Black Italic BT"],
:hp_dmg => [255, 255, 255, 32, true, false, "Bitstream Arrus Black Italic BT"],
:hp_heal => [0, 255, 0, 32, true, false, "Bitstream Arrus Black Italic BT"],
:mp_dmg => [0, 0, 255, 32, true, false, "Bitstream Arrus Black Italic BT"],
:mp_heal => [0, 255, 255, 32, true, false, "Bitstream Arrus Black Italic BT"],
:tp_dmg => [0, 255, 0, 32, true, false, "Bitstream Arrus Black Italic BT"],
:tp_heal => [255, 255, 0, 32, true, false, "Bitstream Arrus Black Italic BT"],
:drained => [0, 255, 0, 32, true, false, "Bitstream Arrus Black Italic BT"],
:critical => [255, 255, 0, 32, true, false, "Bitstream Arrus Black Italic BT"],
:missed => [255, 255, 255, 32, true, false, "Bitstream Arrus Black Italic BT"],
:evaded => [255, 255, 255, 32, true, false, "Bitstream Arrus Black Italic BT"],
:nulled => [255, 255, 255, 32, true, false, "Bitstream Arrus Black Italic BT"],
:failed => [255, 255, 255, 32, true, false, "Bitstream Arrus Black Italic BT"],
:add_state => [255, 255, 255, 32, true, false, "Bitstream Arrus Black Italic BT"],
:rem_state => [255, 255, 255, 32, true, false, "Bitstream Arrus Black Italic BT"],
:dur_state => [255, 255, 255, 32, true, false, "Bitstream Arrus Black Italic BT"],
:weakpoint => [255, 100, 100, 32, true, false, "Bitstream Arrus Black Italic BT"],
:resistant => [100, 100, 255, 32, true, false, "Bitstream Arrus Black Italic BT"],
:immune => [255, 255, 255, 32, true, false, "Bitstream Arrus Black Italic BT"],
:absorbed => [255, 255, 255, 32, true, false, "Bitstream Arrus Black Italic BT"],
:add_buff => [255, 255, 255, 32, true, false, "Bitstream Arrus Black Italic BT"],
:add_debuff => [255, 255, 255, 32, true, false, "Bitstream Arrus Black Italic BT"],
:lvup => [255, 255, 255, 20, false, false, "Bitstream Arrus Black Italic BT"],
},
# Configuration for popup effect.
:effect_setting => {
# Type => [Effect sequence],
:default => [:up, :wait],
:hp_dmg => [:jump_2, :wait],
:hp_heal => [:up, :wait],
:mp_dmg => [:jump_2, :wait],
:mp_heal => [:up, :wait],
:tp_dmg => [:jump_2, :wait],
:tp_heal => [:up, :wait],
:drained => [:affect, :jump_2, :wait],
:critical => [:affect, :jump_2, :wait],
:missed => [:up , :wait],
:evaded => [:up , :wait],
:nulled => [:up , :wait],
:failed => [:up , :wait],
:add_state => [:affect, :up , :wait],
:rem_state => [:affect, :up , :wait],
:dur_state => [:affect, :up , :wait],
:weakpoint => [:affect, :jump_2, :wait],
:resistant => [:affect, :jump_2, :wait],
:immune => [:up , :wait],
:absorbed => [:affect, :jump_2, :wait],
:add_buff => [:affect, :up , :wait],
:add_debuff => [:affect, :up , :wait],
:lvup => [:up, :wait],
},
:effect_setup => {
#:type => [ZoomX, ZoomY, StartX, StartY, MoveX, MoveY, Gravt, Opacity, Dur, Random],
:up => [1.0 , 1.0 , 0.0 , 0.0 , 0.0 , -1.0 , 0.0 , 255 , 32 , false ],
:jump_1 => [1.0 , 1.0 , 0.0 , 0.0 , 0.0 , -6.4 , 0.4 , 255 , 15 , false ],
:jump_2 => [1.0 , 1.0 , 0.0 , -2.0 , 0.0 , -3.2 , 0.2 , 255 , 15 , false ],
:wait => [1.0 , 1.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0 , 20 , false ],
:affect => [1.0 , 1.0 , 0.0 , -32.0 , 0.0 , 0.0 , 0.0 , 255 , 1 , false ],
},
} # End BATTLE_POPUP.
end # Addon
end # BattleLuna
#==============================================================================
# ■ Game_BattlerBase
#==============================================================================
class Game_BattlerBase
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :popups
#--------------------------------------------------------------------------
# new method: create_popup
#--------------------------------------------------------------------------
def create_popup(data, rule = :default)
return unless SceneManager.scene_is?(Scene_Battle)
return unless BattleLuna::Addon::BATTLE_POPUP[:basic_setting][:enable]
@popups ||= []
@popups.push([data, rule])
end
#--------------------------------------------------------------------------
# new method: make_damage_popups
#--------------------------------------------------------------------------
def make_damage_popups(user)
if @result.hp_drain != 0
rule = :drained
user.create_popup(["", nil], rule)
rule = :hp_dmg if @result.hp_drain < 0
rule = :hp_heal if @result.hp_drain > 0
value = @result.hp_drain.abs
user.create_popup(["#{value}", nil], rule)
end
if @result.mp_drain != 0
rule = :drained
user.create_popup(["", nil], rule)
rule = :mp_dmg if @result.mp_drain < 0
rule = :mp_heal if @result.mp_drain > 0
value = @result.mp_drain.abs
user.create_popup(["#{value}", nil], rule)
end
#---
rule = :critical
create_popup(["", nil], rule) if @result.critical
if @result.hp_damage != 0
rule = :hp_dmg if @result.hp_damage > 0
rule = :hp_heal if @result.hp_damage < 0
value = @result.hp_damage.abs
create_popup(["#{value}", nil], rule)
end
if @result.mp_damage != 0
rule = :mp_dmg if @result.mp_damage > 0
rule = :mp_heal if @result.mp_damage < 0
value = @result.mp_damage.abs
create_popup(["#{value}", nil], rule)
end
if @result.tp_damage != 0
rule = :tp_dmg if @result.tp_damage > 0
rule = :tp_heal if @result.tp_damage < 0
value = @result.tp_damage.abs
create_popup(["#{value}", nil], rule)
end
end
#--------------------------------------------------------------------------
# alias method: erase_state
#--------------------------------------------------------------------------
alias battle_luna_dp_erase_state erase_state unless $imported["YEA-BattleEngine"]
def erase_state(state_id)
make_state_popup(state_id, :rem_state) if @states.include?(state_id)
if $imported["YEA-BattleEngine"]
game_battlerbase_erase_state_abe(state_id)
else
battle_luna_dp_erase_state(state_id)
end
end
#--------------------------------------------------------------------------
# new method: make_during_state_popup
#--------------------------------------------------------------------------
def make_during_state_popup
state_id = most_important_state_id
return if state_id == 0
make_state_popup(state_id, :dur_state)
end
#--------------------------------------------------------------------------
# new method: most_important_state_id
#--------------------------------------------------------------------------
def most_important_state_id
states.each {|state| return state.id unless state.message3.empty? }
return 0
end
#--------------------------------------------------------------------------
# new method: make_state_popup
#--------------------------------------------------------------------------
def make_state_popup(state_id, type)
return unless BattleLuna::Addon::BATTLE_POPUP[:basic_setting][:state_popup]
state = $data_states[state_id]
return if state.icon_index == 0
create_popup(["#{state.name}", state.icon_index], type)
end
#--------------------------------------------------------------------------
# new method: make_miss_popups
#--------------------------------------------------------------------------
def make_miss_popups(user, item)
return if dead?
if @result.missed
rule = :missed
create_popup(["", nil], rule)
end
if @result.evaded
rule = :evaded
create_popup(["", nil], rule)
end
if @result.hit? && [email protected]
rule = :failed
create_popup(["", nil], rule)
end
if @result.hit? && item.damage.to_hp?
if @result.hp_damage == 0 && @result.mp_damage == 0
rule = :nulled
create_popup(["", nil], rule)
end
end
end
#--------------------------------------------------------------------------
# new method: make_rate_popup
#--------------------------------------------------------------------------
def make_rate_popup(rate)
return if rate == 1.0
if rate > 1.0
rule = :weakpoint
elsif rate == 0.0
rule = :immune
elsif rate < 0.0
rule = :absorbed
else
rule = :resistant
end
create_popup(["", nil], rule)
end
#--------------------------------------------------------------------------
# new method: make_buff_popup
#--------------------------------------------------------------------------
def make_buff_popup(param_id, positive = true)
return unless BattleLuna::Addon::BATTLE_POPUP[:basic_setting][:buff_popup]
return unless SceneManager.scene_is?(Scene_Battle)
return unless alive?
name = Vocab::param(param_id)
if positive
rule = :add_buff
buff_level = 1
else
rule = :add_debuff
buff_level = -1
end
icon = buff_icon_index(buff_level, param_id)
create_popup(["#{name}", icon], rule)
end
end # Game_BattlerBase
#==============================================================================
# ■ Game_Battler
#==============================================================================
class Game_Battler < Game_BattlerBase
#--------------------------------------------------------------------------
# alias method: on_battle_end
#--------------------------------------------------------------------------
alias battle_luna_dp_on_battle_end on_battle_end
def on_battle_end
battle_luna_dp_on_battle_end
@popups ||= []
@popups.clear
end
#--------------------------------------------------------------------------
# alias method: item_apply
#--------------------------------------------------------------------------
alias battle_luna_dp_item_apply item_apply unless $imported["YEA-BattleEngine"]
def item_apply(user, item)
if $imported["YEA-BattleEngine"]
game_battler_item_apply_abe(user, item)
else
battle_luna_dp_item_apply(user, item)
end
@result.restore_damage
make_miss_popups(user, item)
make_damage_popups(user)
end
#--------------------------------------------------------------------------
# alias method: make_damage_value
#--------------------------------------------------------------------------
alias battle_luna_dp_make_damage_value make_damage_value unless $imported["YEA-BattleEngine"]
def make_damage_value(user, item)
if $imported["YEA-BattleEngine"]
game_battler_make_damage_value_abe(user, item)
else
battle_luna_dp_make_damage_value(user, item)
end
rate = item_element_rate(user, item)
make_rate_popup(rate)
end
#--------------------------------------------------------------------------
# alias method: execute_damage
#--------------------------------------------------------------------------
alias battle_luna_dp_execute_damage execute_damage unless $imported["YEA-BattleEngine"]
def execute_damage(user)
if $imported["YEA-BattleEngine"]
game_battler_execute_damage_abe(user)
else
battle_luna_dp_execute_damage(user)
end
#make_damage_popups(user)
end
#--------------------------------------------------------------------------
# alias method: item_effect_recover_hp
#--------------------------------------------------------------------------
alias battle_luna_dp_item_effect_recover_hp item_effect_recover_hp unless $imported["YEA-BattleEngine"]
def item_effect_recover_hp(user, item, effect)
if $imported["YEA-BattleEngine"]
game_battler_item_effect_recover_hp_abe(user, item, effect)
else
battle_luna_dp_item_effect_recover_hp(user, item, effect)
end
#make_damage_popups(user)
end
#--------------------------------------------------------------------------
# alias method: item_effect_recover_mp
#--------------------------------------------------------------------------
alias battle_luna_item_effect_recover_mp item_effect_recover_mp unless $imported["YEA-BattleEngine"]
def item_effect_recover_mp(user, item, effect)
if $imported["YEA-BattleEngine"]
game_battler_item_effect_recover_mp_abe(user, item, effect)
else
battle_luna_item_effect_recover_mp(user, item, effect)
end
#make_damage_popups(user)
end
#--------------------------------------------------------------------------
# alias method: item_effect_gain_tp
#--------------------------------------------------------------------------
alias battle_luna_item_effect_gain_tp item_effect_gain_tp unless $imported["YEA-BattleEngine"]
def item_effect_gain_tp(user, item, effect)
if $imported["YEA-BattleEngine"]
game_battler_item_effect_gain_tp_abe(user, item, effect)
else
battle_luna_item_effect_gain_tp(user, item, effect)
end
#make_damage_popups(user)
end
#--------------------------------------------------------------------------
# alias method: add_new_state
#--------------------------------------------------------------------------
alias battle_luna_dp_add_new_state add_new_state unless $imported["YEA-BattleEngine"]
def add_new_state(state_id)
if $imported["YEA-BattleEngine"]
game_battler_add_new_state_abe(state_id)
else
battle_luna_dp_add_new_state(state_id)
end
make_state_popup(state_id, :add_state) if @states.include?(state_id)
end
#--------------------------------------------------------------------------
# alias method: add_buff
#--------------------------------------------------------------------------
alias battle_luna_dp_add_buff add_buff unless $imported["YEA-BattleEngine"]
def add_buff(param_id, turns)
make_buff_popup(param_id, true)
if $imported["YEA-BattleEngine"]
game_battler_add_buff_abe(param_id, turns)
else
battle_luna_dp_add_buff(param_id, turns)
end
end
#--------------------------------------------------------------------------
# alias method: add_debuff
#--------------------------------------------------------------------------
alias battle_luna_dp_add_debuff add_debuff unless $imported["YEA-BattleEngine"]
def add_debuff(param_id, turns)
make_buff_popup(param_id, false)
if $imported["YEA-BattleEngine"]
game_battler_add_debuff_abe(param_id, turns)
else
battle_luna_dp_add_debuff(param_id, turns)
end
end
#--------------------------------------------------------------------------
# alias method: regenerate_all
#--------------------------------------------------------------------------
alias battle_luna_dp_regenerate_all regenerate_all unless $imported["YEA-BattleEngine"]
def regenerate_all
if $imported["YEA-BattleEngine"]
game_battler_regenerate_all_abe
else
battle_luna_dp_regenerate_all
end
return unless alive?
make_damage_popups(self)
end
end # Game_Battler
#==============================================================================
# ■ Sprite_Battler
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# new method: screen_x
#--------------------------------------------------------------------------
unless Game_Actor.instance_methods.include?(:screen_x)
def screen_x
0
end
end
#--------------------------------------------------------------------------
# new method: screen_y
#--------------------------------------------------------------------------
unless Game_Actor.instance_methods.include?(:screen_y)
def screen_y
0
end
end
#--------------------------------------------------------------------------
# new method: screen_z
#--------------------------------------------------------------------------
unless Game_Actor.instance_methods.include?(:screen_z)
def screen_y
0
end
end
end # Game_Actor
#==============================================================================
# ■ Sprite_Battler
#==============================================================================
class Sprite_Battler < Sprite_Base
#--------------------------------------------------------------------------
# alias method: initialize
#--------------------------------------------------------------------------
alias battle_luna_dp_initialize initialize
def initialize(viewport, battler = nil)
battle_luna_dp_initialize(viewport, battler)
@popups = []
@popup_delay = 0
end
#--------------------------------------------------------------------------
# alias method: setup_new_effect
#--------------------------------------------------------------------------
alias battle_luna_dp_setup_new_effect setup_new_effect
def setup_new_effect
battle_luna_dp_setup_new_effect
setup_popups
end
#--------------------------------------------------------------------------
# new method: setup_popups
#--------------------------------------------------------------------------
def setup_popups
setting = BattleLuna::Addon::BATTLE_POPUP
return unless @battler.use_sprite?
@battler.popups ||= []
@popup_delay -= 1
return if @popup_delay > 0
array = @battler.popups.shift
return if array.nil?
create_new_popup(array[0], array[1])
return if @battler.popups.size == 0
return if setting[:basic_setting][:no_delay].include?(array[1])
@popup_delay = setting[:basic_setting][:delay]
end
#--------------------------------------------------------------------------
# new method: create_new_popup
#--------------------------------------------------------------------------
def create_new_popup(data, rule)
return unless @battler
return unless SceneManager.scene.is_a?(Scene_Battle)
viewport = self.viewport
popup = Sprite_PopupLuna.new(viewport, @battler, data, rule)
@popups.push(popup)
end
#--------------------------------------------------------------------------
# alias method: update
#--------------------------------------------------------------------------
alias battle_luna_dp_update update
def update
battle_luna_dp_update
update_popups
end
#--------------------------------------------------------------------------
# new method: update_popups
#--------------------------------------------------------------------------
def update_popups
@popups.each { |popup| popup.update }
@popups.each_with_index { |sprite, index|
next unless sprite.disposed?
@popups[index] = nil
}
@popups.compact!
end
#--------------------------------------------------------------------------
# alias method: dispose
#--------------------------------------------------------------------------
alias battle_luna_dp_dispose dispose
def dispose
@popups.each { |popup| popup.dispose }
@popups.clear
battle_luna_dp_dispose
end
end # Sprite_Battler
#==============================================================================
# ■ Sprite_PopupLuna
#==============================================================================
class Sprite_PopupLuna < Sprite
#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize(viewport, battler, data, rule)
super(viewport)
@data = data
@rule = rule
#---
@style = rule
@style = :default unless setting[:style_setting].has_key?(@style)
@style = setting[:style_setting][@style]
#---
@effects = rule
@effects = :default unless setting[:effect_setting].has_key?(@effects)
@effects = setting[:effect_setting][@effects].dup
#---
@current_effect = nil
@duration = 0
@battler = battler
#---
start_popup
start_effect
update
end
#--------------------------------------------------------------------------
# setting
#--------------------------------------------------------------------------
def setting
BattleLuna::Addon::BATTLE_POPUP
end
#--------------------------------------------------------------------------
# start_popup
#--------------------------------------------------------------------------
def start_popup
self.bitmap = create_bitmap
self.x = @battler.screen_x
self.y = @battler.screen_y
self.ox = self.bitmap.width / 2
self.oy = self.bitmap.height
self.z = @battler.screen_z + 350
end
#--------------------------------------------------------------------------
# create_bitmap
#--------------------------------------------------------------------------
def create_bitmap
bw = Graphics.width
bw = bw + 48 if @data[1]
bh = @style[3] * 2
bitmap = Bitmap.new(bw, bh)
#---
bitmap.font.color.set(@style[0], @style[1], @style[2])
bitmap.font.size = @style[3]
bitmap.font.bold = @style[4]
bitmap.font.italic = @style[5]
bitmap.font.name = @style[6]
#---
dx = @data[1] ? 24 : 0; dy = 0
text = setting[:word_setting][@rule]
text = setting[:word_setting][:default] unless text
text = sprintf(text, @data[0])
bitmap.draw_text(dx, dy, bw - dx, bh, text, 1)
#---
text_width = bitmap.text_size(text).width
if @data[1]
icon_bitmap = Cache.system("Iconset")
icon_index = @data[1].to_i
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
bitmap.blt((bw-text_width)/2-32, (bh - 24)/2, icon_bitmap, rect)
end
bitmap
end
#--------------------------------------------------------------------------
# start_effect
#--------------------------------------------------------------------------
def start_effect
@current_effect = @effects.shift
return dispose if @current_effect.nil?
effect = setting[:effect_setup][@current_effect]
@duration = effect[8]
#---
@zoom_x_rate = (effect[0] - self.zoom_x) / @duration
@zoom_y_rate = (effect[1] - self.zoom_y) / @duration
#---
@move_x = effect[4]
@move_y = effect[5]
if effect[9]
@move_x = @move_x * rand(0)
@move_x = rand(10) % 2 == 0 ? -@move_x : @move_x
end
#---
@gravity = effect[6]
#---
@opacity_rate = (effect[7] - self.opacity) / @duration.to_f
#---
self.x += effect[2]
self.y += effect[3]
end
#--------------------------------------------------------------------------
# update
#--------------------------------------------------------------------------
def update
super
update_zoom
update_move
update_opacity
update_effect
end
#--------------------------------------------------------------------------
# update_effect
#--------------------------------------------------------------------------
def update_effect
@duration -= 1
return if @duration > 0
start_effect
end
#--------------------------------------------------------------------------
# update_zoom
#--------------------------------------------------------------------------
def update_zoom
self.zoom_x += @zoom_x_rate
self.zoom_y += @zoom_y_rate
end
#--------------------------------------------------------------------------
# update_move
#--------------------------------------------------------------------------
def update_move
self.x += @move_x
self.y += @move_y
@move_y += @gravity
end
#--------------------------------------------------------------------------
# update_opacity
#--------------------------------------------------------------------------
def update_opacity
self.opacity += @opacity_rate
end
#--------------------------------------------------------------------------
# dispose
#--------------------------------------------------------------------------
def dispose
self.bitmap.dispose if self.bitmap
super
end
end # Sprite_PopupLuna
#==============================================================================
# ■ Window_BattleHelp
#==============================================================================
if $imported["YEA-BattleEngine"]
class Window_BattleHelp < Window_Help
#--------------------------------------------------------------------------
# alias method: update
#--------------------------------------------------------------------------
alias battle_luna_yea_be_update update
def update
battle_luna_yea_be_update
return unless $imported["YEA-BattleEngine"]
return unless @actor_window && @enemy_window
if !self.visible and @text != ""
@text = ""
return refresh
end
update_battler_name
end
end # Window_BattleHelp
end
#==============================================================================
# ■ Sprite_Battler
#==============================================================================
class Sprite_Battler < Sprite_Base
#--------------------------------------------------------------------------
# alias method: create_new_popup
# Compatible with YEA - Battle Engine.
#--------------------------------------------------------------------------
if $imported["YEA-BattleEngine"] && !$imported["YES-BattlePopup"]
alias battle_luna_yea_create_new_popup create_new_popup
def create_new_popup(value, rules, flags)
battle_luna_yea_create_new_popup(value, rules, flags)
@popups.each { |popup|
popup.viewport = nil
popup.z = @battler.screen_z + 1000
}
end
end
end # Sprite_Battler
#==============================================================================
# ■ Game_ActionResult
#==============================================================================
class Game_ActionResult
#--------------------------------------------------------------------------
# alias method: clear_stored_damage
#--------------------------------------------------------------------------
alias battle_luna_yea_clear_stored_damage clear_stored_damage if $imported["YEA-BattleEngine"]
def clear_stored_damage
battle_luna_yea_clear_stored_damage unless $imported["YES-BattlePopup"]
end
#--------------------------------------------------------------------------
# alias method: store_damage
#--------------------------------------------------------------------------
alias battle_luna_yea_store_damage store_damage if $imported["YEA-BattleEngine"]
def store_damage
battle_luna_yea_store_damage unless $imported["YES-BattlePopup"]
end
#--------------------------------------------------------------------------
# alias method: restore_damage
#--------------------------------------------------------------------------
alias battle_luna_yea_restore_damage restore_damage if $imported["YEA-BattleEngine"]
def restore_damage
battle_luna_yea_restore_damage unless $imported["YES-BattlePopup"]
end
end # Game_ActionResult
#==#==============================================================================
# ■エネミーの状態を表示 for RGSS3 Ver0.80-α
# □作成者 kure
#==============================================================================
$kure_base_script = {} if $kure_base_script == nil
$kure_base_script[:InfoBar] = 100
p "エネミーの情報表示"
module KURE
module InfoBar
#初期設定(変更しない事)-----------------------------------------------------
COLOR = []
#表示色(IDによって割り当てが決まっています。)
#バーの背景色(ID0)
COLOR[0] = Color.new(32 ,32, 64, 255)
#HPバーの色(ID1,ID2)
COLOR[1] = Color.new(224 ,128, 64, 255)
COLOR[2] = Color.new(240 ,192, 64, 255)
end
end
#==============================================================================
# ■ RPG::Enemy(追加定義)
#==============================================================================
class RPG::Enemy < RPG::BaseItem
#--------------------------------------------------------------------------
# ☆ バーの表示幅の定義(追加定義)
#--------------------------------------------------------------------------
def infobar_width
@note.match(/<情報表示幅\s?(\d+)\s?>/)
return 100 unless $1
return $1.to_i
end
#--------------------------------------------------------------------------
# ☆ バーの表示幅の定義(追加定義)
#--------------------------------------------------------------------------
def infobar_visible?
return false if @note.include?("<情報非表示>")
return true
end
end
#==============================================================================
# ■ Game_Enemy
#==============================================================================
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# ☆ バーの表示幅の定義(追加定義)
#--------------------------------------------------------------------------
def infobar_width
return enemy.infobar_width
end
#--------------------------------------------------------------------------
# ☆ バーの表示幅の定義(追加定義)
#--------------------------------------------------------------------------
def infobar_visible?
return enemy.infobar_visible?
end
end
#==============================================================================
# ■ Spriteset_Battle
#==============================================================================
class Spriteset_Battle
#--------------------------------------------------------------------------
# ● 敵キャラスプライトの作成(エイリアス再定義)
#--------------------------------------------------------------------------
alias k_basescript_before_create_enemies create_enemies
def create_enemies
k_basescript_before_create_enemies
@enemy_info_bar = $game_troop.members.reverse.collect do |enemy|
Sprite_Infobar.new(@viewport1, enemy)
end
end
#--------------------------------------------------------------------------
# ● 敵キャラスプライトの更新(エイリアス再定義)
#--------------------------------------------------------------------------
alias k_basescript_before_update_enemies update_enemies
def update_enemies
k_basescript_before_update_enemies
@enemy_info_bar.each {|sprite| sprite.update }
end
#--------------------------------------------------------------------------
# ● 敵キャラスプライトの解放(エイリアス再定義)
#--------------------------------------------------------------------------
alias k_basescript_before_dispose_enemies dispose_enemies
def dispose_enemies
k_basescript_before_dispose_enemies
@enemy_info_bar.each {|sprite| sprite.dispose }
end
end
#==============================================================================
# ■ Sprite_Infobar
#==============================================================================
class Sprite_Infobar < Sprite_Base
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :battler
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(viewport, battler = nil)
super(viewport)
@battler = battler
@fill_w = nil
@bitmap_data = Cache.battler(battler.battler_name, battler.battler_hue)
@state = battler.states
@icon_set = Cache.system("Iconset")
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
super
if @battler
@use_sprite = @battler.use_sprite?
if @use_sprite
update_bitmap
update_origin
update_position
end
else
self.bitmap = nil
end
end
#--------------------------------------------------------------------------
# ● 解放
#--------------------------------------------------------------------------
def dispose
bitmap.dispose if bitmap
super
end
#--------------------------------------------------------------------------
# ● 転送元ビットマップの更新
#--------------------------------------------------------------------------
def update_bitmap
fill_w = @battler.infobar_width * (@battler.hp.to_f / @battler.mhp)
state = battler.states
if @fill_w != fill_w or @state != state
@fill_w = fill_w
@state = state
width = @battler.infobar_width + 4
new_bitmap = Bitmap.new(width, 35)
@state.each_with_index {|state, index|
next if 24 * (index + 1) > new_bitmap.width
rect = Rect.new(state.icon_index % 16 * 24, state.icon_index / 16 * 24, 24, 24)
new_bitmap.blt(24 * index, 0, @icon_set, rect, 255)
}
#new_bitmap.fill_rect(0, 25, width, 10, color(0))
#new_bitmap.gradient_fill_rect(2, 27, fill_w, 6, color(1), color(2))
self.bitmap = new_bitmap
init_visibility
self.opacity = 0 unless @battler.infobar_visible?
end
end
#--------------------------------------------------------------------------
# ● 可視状態の初期化
#--------------------------------------------------------------------------
def init_visibility
@battler_visible = @battler.alive?
self.opacity = 0 unless @battler_visible
end
#--------------------------------------------------------------------------
# ● 文字色取得
#--------------------------------------------------------------------------
def color(num)
return KURE::InfoBar::COLOR[num]
end
#--------------------------------------------------------------------------
# ● 原点の更新
#--------------------------------------------------------------------------
def update_origin
if bitmap
self.ox = bitmap.width / 2
self.oy = bitmap.height
end
end
#--------------------------------------------------------------------------
# ● 位置の更新
#--------------------------------------------------------------------------
def update_position
self.x = @battler.screen_x + 30
self.y = @battler.screen_y + 0
self.z = @battler.screen_z + 10
end
end
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |