#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/ ◆Aggressive camera - KGC_BattleCamera◆
#_/----------------------------------------------------------------------------
#_/ The point of view locomotive function which is in the midst of fighting
#_/ is introduced
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#==============================================================================
# ★ Customization section ★
#==============================================================================
module KGC
# Battle Cam Variable
Battle_Cam_Variable = 25
# & camera drift speed initial value
BC_SPEED_INIT = 24
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
$imported['BattleCamera'] = true
$imported['Base Reinforce'] = true
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Game_Enemy
#==============================================================================
class Game_Enemy < Game_Battler
attr_reader :origin_x, :origin_y
#--------------------------------------------------------------------------
# ● Object initialization
#--------------------------------------------------------------------------
alias initialize_KGC_BattleCamera initialize
def initialize(troop_id, member_index)
# Executing the processing of the origin
initialize_KGC_BattleCamera(troop_id, member_index)
@origin_x = $data_troops[@troop_id].members[@member_index].x
@origin_y = $data_troops[@troop_id].members[@member_index].y
end
#--------------------------------------------------------------------------
# ● Acquisition in battle picture X coordinate
#--------------------------------------------------------------------------
def screen_x
return @origin_x - $scene.camera.x * self.zoom
end
#--------------------------------------------------------------------------
# ● Acquisition of battle picture Y-coordinate
#--------------------------------------------------------------------------
def screen_y
return @origin_y - $scene.camera.y * self.zoom
end
#--------------------------------------------------------------------------
# ● Acquisition of magnification ratio
#--------------------------------------------------------------------------
def zoom
if $game_variables[KGC::Battle_Cam_Variable] == 0
n = (1.00 + $scene.camera.z / 512.00) * ((@origin_y - 304) / 256.00 + 1)
else
n = 1
end
return n
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Sprite_Battler
#==============================================================================
class Sprite_Battler < RPG::Sprite
#--------------------------------------------------------------------------
# ● Frame renewal
#--------------------------------------------------------------------------
alias update_KGC_BattleCamera update
def update
# Executing the processing of the origin
update_KGC_BattleCamera
return if @battler == nil
if $game_variables[KGC::Battle_Cam_Variable] == 0
if @battler.is_a?(Game_Enemy)
# Magnification ratio adjustment
self.zoom_x = self.zoom_y = @battler.zoom
end
end
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Spriteset_Battle
#==============================================================================
class Spriteset_Battle
#--------------------------------------------------------------------------
# ● Renewal
#--------------------------------------------------------------------------
alias update_KGC_BattleCamera update
def update
# Executing the processing of the origin
update_KGC_BattleCamera
if $DEBUG
if Input::trigger?(Input::Z)
c = $scene.camera
zoom = c.z / 512.00 + 1
p "#{c.x}, #{c.y}, #{c.z}"
p "#{@battleback_sprite.x + 320}, #{@battleback_sprite.y + 304}, #{zoom}"
end
end
# Camera movement decision
if $game_variables[KGC::Battle_Cam_Variable] == 0
cx, cy, cz = $scene.camera.x, $scene.camera.y, $scene.camera.z
bx, by = @battleback_sprite.x + 320, @battleback_sprite.y + 304
if bx != cx || by != cy || @bz != cz
# Magnification ratio adjustment
zoom = cz / 512.00 + 1
@battleback_sprite.zoom_x = zoom * 1.5
@battleback_sprite.zoom_y = zoom * 1.5
# All the embody decisions
if $imported['Base Reinforce']# && KGC::BR_BATTLEBACK_FULL
@battleback_sprite.ox = @battleback_sprite.bitmap.width * 0.52 # X OFFSET!
@battleback_sprite.oy = @battleback_sprite.bitmap.height / 2
mag_x = 600.0 / @battleback_sprite.bitmap.width
mag_y = 300.0 / @battleback_sprite.bitmap.height
@battleback_sprite.zoom_x *= mag_x
@battleback_sprite.zoom_y *= mag_y
end
# Coordinate adjustment
@battleback_sprite.x = -cx * zoom / 2 - 320 + @battleback_sprite.ox * 2
@battleback_sprite.y = -cy * zoom / 2 - 144 + @battleback_sprite.oy * 2
@bz = cz
end
end
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Camera
#------------------------------------------------------------------------------
# It is the class which handles the camera which is in the midst of fighting
#==============================================================================
class Camera
#--------------------------------------------------------------------------
# ● Open instance variable
#--------------------------------------------------------------------------
attr_reader :x, :y, :z
attr_accessor :move_speed
#--------------------------------------------------------------------------
# ● Object initialization
#--------------------------------------------------------------------------
def initialize
@x, @y, @z = 0, 0, 0
@move_x = @move_y = @move_z = 0
@move_speed = KGC::BC_SPEED_INIT
end
#--------------------------------------------------------------------------
# ● Movement
#--------------------------------------------------------------------------
def move(x, y, z)
@move_x, @move_y, @move_z = x - @x - 320, y - @y - 160, z - @z
end
#--------------------------------------------------------------------------
# ● It moves to the object enemy
#--------------------------------------------------------------------------
def move_target(target)
return if target == nil || !target.is_a?(Game_Enemy)
if $game_variables[KGC::Battle_Cam_Variable] == 0
tx, ty = target.origin_x, target.origin_y - 144
tz = (304 - target.origin_y) * 5
move(tx, ty, tz)
end
end
#--------------------------------------------------------------------------
# ● It moves to the center
#--------------------------------------------------------------------------
def centering
@move_x, @move_y, @move_z = -@x, -@y, -@z
end
#--------------------------------------------------------------------------
# ● Renewal
#--------------------------------------------------------------------------
def update
# X-coordinate movement
if $game_variables[KGC::Battle_Cam_Variable] == 0
mv = [[@move_x.abs * @move_speed / 160, 1].max, @move_speed].min
if @move_x > 0
@x += mv
@move_x = [@move_x - mv, 0].max
elsif @move_x < 0
@x -= mv
@move_x = [@move_x + mv, 0].min
end
# Y-coordinate movement
mv = [[@move_y.abs * @move_speed / 160, 1].max, @move_speed].min
if @move_y > 0
@y += mv
@move_y = [@move_y - mv, 0].max
elsif @move_y < 0
@y -= mv
@move_y = [@move_y + mv, 0].min
end
# Z coordinate movement
mv = [[@move_z.abs * @move_speed / 96, 1].max, @move_speed * 2].min
if @move_z > 0
@z += mv
@move_z = [@move_z - mv, 0].max
elsif @move_z < 0
@z -= mv
@move_z = [@move_z + mv, 0].min
end
end
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Scene_Battle (Division definition 1)
#==============================================================================
class Scene_Battle
attr_reader :camera
#--------------------------------------------------------------------------
# ● Main processing
#--------------------------------------------------------------------------
alias main_KGC_BattleCamera main
def main
# Camera compilation
@camera = Camera.new
# Executing the processing of the origin
main_KGC_BattleCamera
end
#--------------------------------------------------------------------------
# ● Frame renewal
#--------------------------------------------------------------------------
alias update_KGC_BattleCamera update
def update
@camera.update
# Executing the processing of the origin
update_KGC_BattleCamera
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Scene_Battle (Division definition 3)
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# ● Frame renewal (actor command phase: Enemy selection)
#--------------------------------------------------------------------------
alias update_phase3_enemy_select_KGC_BattleCamera update_phase3_enemy_select
def update_phase3_enemy_select
# Selective object zoom up
if $game_variables[KGC::Battle_Cam_Variable] == 0
if !$imported['ActiveCountBattle'] || @action_battler == nil
@camera.move_target(@enemy_arrow.enemy)
end
end
# Executing the processing of the origin
update_phase3_enemy_select_KGC_BattleCamera
end
#--------------------------------------------------------------------------
# ● Enemy selection end
#--------------------------------------------------------------------------
alias end_enemy_select_KGC_BattleCamera end_enemy_select
def end_enemy_select
# The camera is reset to the center
if $game_variables[KGC::Battle_Cam_Variable] == 0
if !$imported['ActiveCountBattle'] || @action_battler == nil
@camera.move(320, 160, 0)
end
end
# Executing the processing of the origin
end_enemy_select_KGC_BattleCamera
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Scene_Battle (Division definition 4)
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# ● Frame renewal (main phase step 3: Conduct side animation)
#--------------------------------------------------------------------------
alias update_phase4_step3_KGC_BattleCamera update_phase4_step3
def update_phase4_step3
# camera movement
if $game_variables[KGC::Battle_Cam_Variable] == 0
if @active_battler.is_a?(Game_Actor) && @target_battlers != []
if @target_battlers.size > 1
@camera.move(320, 160, -96)
else
@camera.move_target(@target_battlers[0])
end
elsif @active_battler.is_a?(Game_Enemy)
@camera.move_target(@active_battler)
end
end
# Executing the processing of the origin
update_phase4_step3_KGC_BattleCamera
end
#--------------------------------------------------------------------------
# ● Frame renewal (main phase step 6: Refreshment)
#--------------------------------------------------------------------------
alias update_phase4_step6_KGC_BattleCamera update_phase4_step6
def update_phase4_step6
# Moving the camera to initial position
@camera.centering
# Executing the processing of the origin
update_phase4_step6_KGC_BattleCamera
end
end