Okay, Ericmor, here you go.
There is a slight, not really noticable glitch:
If you have characters at the top of the screen who attack enemies at the bottom (or the other way), their zoom/character height will be slightly different (the characters will look like they are a little bit taller/smaller). It is not really to be noticed unless somebody tells you. If you want, I can refine the zoom function a little, but I suggest you try it first. Also read the note I added there. I was trying to use the camera fully, even during the fight, not only enemy selection, but the cam code and the ASB code are interfering too much with each other. To do that, somebody would need to completely rewrite these two scripts into one.
#==============================================================================
#------------------------------------------------------------------------------
# Animated Side-view Battle System - by Minkoff
#------------------------------------------------------------------------------
# 3D Pseudio Battle Camera - by KGC
#------------------------------------------------------------------------------
# - merged together by Blizzard
#------------------------------------------------------------------------------
#
# - Note from Blizzard:
#
# Don't put enemies too far to the right or too far to the left. The camera
# will go out of your screen and the battleback will glitch. I have left all
# the commented lines from the ASB, but KGC's comment were not readable, so I
# have removed them. If you want to disable the camera for whatever reason
# you can define which switch should perform the disabling (below). Turning on
# the switch with the ID called BLOCK_SWITCH will disable the camera then.
#
# N-Joy! =D
#
#==============================================================================
#==============================================================================
# module KGC
#==============================================================================
module KGC
$game_special_elements = {}
$imported = {}
$data_states = load_data("Data/States.rxdata")
$data_system = load_data("Data/System.rxdata")
BC_SPEED_INIT = 24 # you can change this number
BLOCK_SWITCH = 25 # you can change this number
end
$imported["BattleCamera"] = true
$imported["Base Reinforce"] = true
#==============================================================================
# ** Sprite_Battler
#==============================================================================
class Sprite_Battler < RPG::Sprite
#--------------------------------------------------------------------------
# * Initialize
#--------------------------------------------------------------------------
alias cbs_initialize initialize
def initialize(viewport, battler = nil)
# Configuration
@speed = 6
@frames = 8
@poses = 11
@mirror_enemies = true
@stationary_enemies = false
@stationary_actors = false
@calculate_speed = false
@phasing = false
# DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU'RE DOING
@frame, @pose = 0, 0
@last_time = 0
@last_move_time = 0
cbs_initialize(viewport, battler)
self.mirror = !!battler and @mirror_enemies
viewport.z = 99
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
alias cbs_update update
def update
return unless @battler
# Regular Update
cbs_update
# Start Routine
unless @started
@pose = state
@width = @width / @frames
@height = @height / @poses
@display_x = @battler.screen_x
@display_y = @battler.screen_y
@destination_x = @display_x
@destination_y = @display_y
@started = true
end
# Cut Out Frame
self.src_rect.set(@width * @frame, @height * @pose, @width, @height)
# Position Sprite
if moving and not $scene.camera.moving
self.x = @display_x
self.y = @display_y
else
self.x = @battler.screen_x
self.y = @battler.screen_y
end
self.z = @battler.screen_y
self.ox = @width / 2
self.oy = @height
# Setup Animation
time = Graphics.frame_count / (Graphics.frame_rate / @speed)
if @last_time < time
@frame = (@frame + 1) % @frames
if @frame == 0
if @freeze
@frame = @frames - 1
return
end
@pose = state
end
end
@last_time = time
# Move It
move if moving and not $scene.camera.moving
# KGC
#return if @battler == nil
unless $game_switches[BLOCK_SWITCH]
factor1 = Math.sqrt((240 + @display_y.to_f) / (240 + @battler.origin_y))
factor2 = (240 + @display_y.to_f) / (240 + @battler.origin_y)
if @display_y > @battler.origin_y
n = @battler.zoom - 1 + factor1 * factor2
else
n = @battler.zoom - 1 + factor2 * factor2
end
else
n = 1
end
self.zoom_x = self.zoom_y = n
end
#--------------------------------------------------------------------------
# * Current State
#--------------------------------------------------------------------------
def state
# Damage State
if [nil,{}].include?(@battler.damage)
# Battler Fine
@state = 0
# Battler Wounded
@state = 2 if @battler.hp < @battler.maxhp / 4
# Battler Dead
if @battler.dead?
@state = 10
# Fix Opacity
self.opacity = 255
end
end
# Guarding State
@state = 3 if @battler.guarding?
# Moving State
if moving
# Battler Moving Left
@state = 4 if moving.eql?(0)
# Battler Moving Right
@state = 5 if moving.eql?(1)
end
# Return State
return @state
end
#--------------------------------------------------------------------------
# * Move
#--------------------------------------------------------------------------
def move
time = Graphics.frame_count / (Graphics.frame_rate.to_f / (@speed * 5))
if @last_move_time < time
# Pause for Animation
return if @pose != state
# Phasing
if @phasing
d1 = (@display_x - @origin_x).abs
d2 = (@display_y - @origin_y).abs
d3 = (@display_x - @destination_x).abs
d4 = (@display_y - @destination_y).abs
self.opacity = [255 - ([d1 + d2, d3 + d4].min * 1.75).to_i, 0].max
end
# Calculate Difference
difference_x = (@display_x - @destination_x).abs
difference_y = (@display_y - @destination_y).abs
# Done? Reset, Stop
if [difference_x, difference_y].max.between?(0, 8)
@display_x = @destination_x
@display_y = @destination_y
@pose = state
return
end
# Calculate Movement Increments
increment_x = increment_y = 1
if difference_x < difference_y
increment_x = 1.0 / (difference_y.to_f / difference_x)
elsif difference_y < difference_x
increment_y = 1.0 / (difference_x.to_f / difference_y)
end
# Calculate Movement Speed
if @calculate_speed
total = 0; $game_party.actors.each{ |actor| total += actor.agi }
speed = @battler.agi.to_f / (total / $game_party.actors.size)
increment_x *= speed
increment_y *= speed
end
# Multiply and Move
multiplier_x = (@destination_x - @display_x > 0 ? 8 : -8)
multiplier_y = (@destination_y - @display_y > 0 ? 8 : -8)
@display_x += (increment_x * multiplier_x).to_i
@display_y += (increment_y * multiplier_y).to_i
end
@last_move_time = time
end
#--------------------------------------------------------------------------
# * Set Movement
#--------------------------------------------------------------------------
def setmove(destination_x, destination_y)
unless (@battler.is_a?(Game_Enemy) and @stationary_enemies) or
(@battler.is_a?(Game_Actor) and @stationary_actors)
@original_x = @display_x
@original_y = @display_y
@destination_x = destination_x
@destination_y = destination_y
end
end
#--------------------------------------------------------------------------
# * Movement Check
#--------------------------------------------------------------------------
def moving
if (@display_x != @destination_x and @display_y != @destination_y and !@battler.dead?)
return (@display_x > @destination_x ? 0 : 1)
end
end
#--------------------------------------------------------------------------
# * Set Pose
#--------------------------------------------------------------------------
def pose=(pose)
@pose = pose
@frame = 0
end
#--------------------------------------------------------------------------
# * Freeze
#--------------------------------------------------------------------------
def freeze
@freeze = true
end
#--------------------------------------------------------------------------
# * Fallen Pose
#--------------------------------------------------------------------------
def collapse
end
end
#==============================================================================
# Game_Enemy
#==============================================================================
class Game_Enemy < Game_Battler
attr_reader :origin_x, :origin_y
alias initialize_KGC_BattleCamera initialize
def initialize(troop_id, member_index)
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
def screen_x
return @origin_x - $scene.camera.x * self.zoom
end
def old_screen_x
return screen_x
end
def screen_y
return @origin_y - $scene.camera.y * self.zoom
end
def old_screen_y
return screen_y
end
def zoom
unless $game_switches[BLOCK_SWITCH]
n = (1.00 + $scene.camera.z / 512.00) * ((@origin_y - 304) / 256.00 + 1)
else
n = 1
end
return n
end
end
#==============================================================================
# ** Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
attr_reader :origin_x, :origin_y
alias setup_KGC_BattleCamera setup
def setup(actor_id)
setup_KGC_BattleCamera(actor_id)
@origin_x = 0
@origin_y = 0
end
def screen_x
return @origin_x - $scene.camera.x * self.zoom
end
def screen_y
return @origin_y - $scene.camera.y * self.zoom
end
def old_screen_x
if self.index != nil
return self.index * 45 + 450
else
return 0
end
end
def old_screen_y
return self.index * 35 + 200
end
def old_screen_z
return 320 - old_screen_y
end
def zoom
unless $game_switches[BLOCK_SWITCH]
n = (1.00 + $scene.camera.z / 512.00) * ((@origin_y - 304) / 256.00 + 1)
else
n = 1
end
return n
end
def set_coordinates
@origin_x = old_screen_x
@origin_y = old_screen_y
end
end
#==============================================================================
# ** Scene_Battle
#==============================================================================
class Scene_Battle
attr_reader :camera
#--------------------------------------------------------------------------
# * KGC
#--------------------------------------------------------------------------
alias main_KGC_BattleCamera main
def main
@camera = Camera.new
for actor in $game_party.actors
actor.set_coordinates
end
main_KGC_BattleCamera
end
#--------------------------------------------------------------------------
# * KGC
#--------------------------------------------------------------------------
alias update_KGC_BattleCamera update
def update
@camera.update
update_KGC_BattleCamera
end
#--------------------------------------------------------------------------
# * Action Animation, Movement
#--------------------------------------------------------------------------
alias cbs_update_phase4_step3 update_phase4_step3
def update_phase4_step3(battler = @active_battler)
@rtab = !@target_battlers
target = (@rtab ? battler.target : @target_battlers)[0]
@moved = {} unless @moved
return if @spriteset.battler(battler).moving
case battler.current_action.kind
when 0 # Attack
if not (@moved[battler] or battler.guarding?)
offset = (battler.is_a?(Game_Actor) ? 40 : -40)
@spriteset.battler(battler).setmove(target.origin_x + offset, target.origin_y) ###
@moved[battler] = true
return
elsif not battler.guarding?
@spriteset.battler(battler).pose = 6 #+ rand(2)
@spriteset.battler(battler).setmove(battler.origin_x, battler.origin_y) ###
end
when 1 # Skill
@spriteset.battler(battler).pose = 8
when 2 # Item
@spriteset.battler(battler).pose = 8
end
@moved[battler] = false
@rtab ? cbs_update_phase4_step3(battler) : cbs_update_phase4_step3
end
#--------------------------------------------------------------------------
# * Hit Animation
#--------------------------------------------------------------------------
alias cbs_update_phase4_step4 update_phase4_step4
def update_phase4_step4(battler = @active_battler)
for target in (@rtab ? battler.target : @target_battlers)
damage = (@rtab ? target.damage[battler] : target.damage)
if damage.is_a?(Numeric) and damage > 0
@spriteset.battler(target).pose = 1
end
end
@rtab ? cbs_update_phase4_step4(battler) : cbs_update_phase4_step4
end
#--------------------------------------------------------------------------
# * Victory Animation
#--------------------------------------------------------------------------
alias cbs_start_phase5 start_phase5
def start_phase5
for actor in $game_party.actors
return if @spriteset.battler(actor).moving
end
for actor in $game_party.actors
unless actor.dead?
@spriteset.battler(actor).pose = 9
@spriteset.battler(actor).freeze
end
end
cbs_start_phase5
end
#--------------------------------------------------------------------------
# * Change Arrow Viewport
#--------------------------------------------------------------------------
alias cbs_start_enemy_select start_enemy_select
def start_enemy_select
cbs_start_enemy_select
@enemy_arrow.dispose
@enemy_arrow = Arrow_Enemy.new(@spriteset.viewport2)
@enemy_arrow.help_window = @help_window
end
#--------------------------------------------------------------------------
# * KGC
#--------------------------------------------------------------------------
alias update_phase3_enemy_select_KGC_BattleCamera update_phase3_enemy_select
def update_phase3_enemy_select
unless $game_switches[BLOCK_SWITCH]
if !$imported["ActiveCountBattle"] || @action_battler == nil
@camera.move_target(@enemy_arrow.enemy)
end
end
update_phase3_enemy_select_KGC_BattleCamera
end
#--------------------------------------------------------------------------
# * KGC
#--------------------------------------------------------------------------
alias end_enemy_select_KGC_BattleCamera end_enemy_select
def end_enemy_select
unless $game_switches[BLOCK_SWITCH]
if !$imported["ActiveCountBattle"] || @action_battler == nil
@camera.move(160, 160, 0)
end
end
end_enemy_select_KGC_BattleCamera
end
end
#==============================================================================
# ** Spriteset_Battle
#==============================================================================
class Spriteset_Battle
attr_reader :actor_sprites
#--------------------------------------------------------------------------
# * Change Enemy Viewport
#--------------------------------------------------------------------------
alias cbs_initialize initialize
def initialize
cbs_initialize
@enemy_sprites = []
for enemy in $game_troop.enemies.reverse
@enemy_sprites.push(Sprite_Battler.new(@viewport2, enemy))
end
end
#--------------------------------------------------------------------------
# * Find Sprite From Battler Handle
#--------------------------------------------------------------------------
def battler(handle)
for sprite in @actor_sprites + @enemy_sprites
return sprite if sprite.battler == handle
end
end
#--------------------------------------------------------------------------
# * KGC
#--------------------------------------------------------------------------
alias update_KGC_BattleCamera update
def update
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
unless $game_switches[BLOCK_SWITCH]
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
zoom = cz / 512.00 + 1
@battleback_sprite.zoom_x = zoom * 1.5
@battleback_sprite.zoom_y = zoom * 1.5
if $imported["Base Reinforce"]
@battleback_sprite.ox = @battleback_sprite.bitmap.width * 0.52
@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
@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
#==============================================================================
# ** Arrow_Base
#==============================================================================
class Arrow_Base < Sprite
#--------------------------------------------------------------------------
# * Reposition Arrows
#--------------------------------------------------------------------------
alias cbs_initialize initialize
def initialize(viewport)
cbs_initialize(viewport)
self.ox = 14
self.oy = 10
end
end
#==============================================================================
# Camera
#==============================================================================
class Camera
attr_reader :moving
attr_reader :x, :y, :z
attr_accessor :move_speed
def initialize
@x, @y, @z = 0, 0, 0
@move_x = @move_y = @move_z = 0
@move_speed = KGC::BC_SPEED_INIT
@moving = false
end
def move(x, y, z)
@move_x, @move_y, @move_z = x - @x - 160, y - @y - 160, z - @z
end
def move_target(target)
return if target == nil || !target.is_a?(Game_Enemy)
unless $game_switches[BLOCK_SWITCH]
tx, ty = target.origin_x, target.origin_y - 144
tz = (304 - target.origin_y) * 5
move(tx, ty, tz)
end
end
def centering
@move_x, @move_y, @move_z = -@x, -@y, -@z
end
def update
unless $game_switches[BLOCK_SWITCH]
@moving = false
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
@moving = true
elsif @move_x < 0
@x -= mv
@move_x = [@move_x + mv, 0].min
@moving = true
end
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
@moving = true
elsif @move_y < 0
@y -= mv
@move_y = [@move_y + mv, 0].min
@moving = true
end
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
@moving = true
elsif @move_z < 0
@z -= mv
@move_z = [@move_z + mv, 0].min
@moving = true
end
end
end
end
BTW, make that girl look older. She just looks too young. And give her some tighter clothes, that will also make her look older.