PDA

View Full Version : Minkoff's Custom Battle System help!


MistTribe
July 20th, 2006, 08:06 PM
Okay Im using Minkoffs CBS and I wanted to know can someone please edit the animation script so that my enemys arent animated? Please...!! heres the script.

#==============================================================================
# ** Sprite_Battler
#------------------------------------------------------------------------------
# Minkoff's Custom Battle System // Thanks, Prexus
#==============================================================================

class Sprite_Battler < RPG::Sprite
#--------------------------------------------------------------------------
# * Initialize
#--------------------------------------------------------------------------
alias cbs_initialize initialize
def initialize(viewport, battler = nil)
@frame = 0
@pose = 0
@default = 0
@speed = 7
@frames = 4
@poses = 10
@last_time = 0
@last_move_time = 0
@stationary_enemies = true
@stationary_actors = false
@phasing = true
cbs_initialize(viewport, battler)
viewport.z = 99
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
alias cbs_update update
def update
return unless @battler

# Regular Update
cbs_update

# Start Routine
unless @started
@width = @width / @frames
@height = @height / @poses
@battler.display_x = @battler.screen_x
@battler.display_y = @battler.screen_y
end

# Setup Sprite
self.src_rect.set(@width * @frame, @height * @pose, @width, @height)
self.mirror = @battler.is_a?(Game_Enemy) unless @started

# Position Sprite
self.x = @battler.display_x
self.y = @battler.display_y
self.z = @battler.display_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 = @default
end
end
@last_time = time

# Set Default Pose
if @battler.default
@default = @battler.default
@pose = @battler.default unless @battler.pose
@battler.default = nil
end

# Set Pose
if @battler.pose
@pose = @battler.pose
@freeze = @battler.freeze
@battler.pose = nil
@battler.freeze = nil
@frame = 0
end

# Move It
move if @battler.moving

# Finish Up
@started = true
end
#--------------------------------------------------------------------------
# * Move
#--------------------------------------------------------------------------
def move
# Stationary Battlers
if (@battler.is_a?(Game_Enemy) and @stationary_enemies) or
(@battler.is_a?(Game_Actor) and @stationary_actors)
battler.moving = false
return
end

time = Graphics.frame_count / (Graphics.frame_rate.to_f / (@speed * 5))
if @last_move_time < time

# Pause to Attack
return unless [@default, 5, 4].include?(@pose)

# Set Running Pose
@pose = @attacked ? 5 : 4

# Phasing
d1 = (@battler.display_x - @battler.original_x).abs
d2 = (@battler.display_y - @battler.original_y).abs
d3 = (@battler.display_x - @battler.destination_x).abs
d4 = (@battler.display_y - @battler.destination_y).abs
self.opacity = [255 - ([d1 + d2, d3 + d4].min * 2.5).to_i, 0].max if @phasing

# Calculate Difference
difference_x = (@battler.display_x - @battler.destination_x).abs
difference_y = (@battler.display_y - @battler.destination_y).abs

# Move Back
if [difference_x, difference_y].max.between?(0, 5) and !@attacked
@battler.destination_x = @battler.original_x
@battler.destination_y = @battler.original_y
@battler.original_x = @battler.display_x
@battler.original_y = @battler.display_y
@battler.moving = false
@attacked = true
@pose = @default
return
end

# Done? Reset, Stop
if [difference_x, difference_y].max.between?(0, 5)
@battler.moving = false
@attacked = false
@pose = @default
return
end

# Movement Patterns
if difference_x > difference_y
increment_x = 1
increment_y = difference_y <= 2 ? difference_y / 8 : 1 / (difference_x / difference_y) + 0.5
elsif difference_y > difference_x
increment_y = 1
increment_x = difference_x <= 2 ? difference_x / 8 : 1 / (difference_y / difference_x) + 0.5
else
increment_x = 1
increment_y = 1
end
incriment_x = (increment_x * 8).to_i
incriment_y = (increment_y * 8).to_i
@battler.display_x += incriment_x * (@battler.destination_x - @battler.display_x > 0 ? 1 : -1)
@battler.display_y += incriment_y * (@battler.destination_y - @battler.display_y > 0 ? 1 : -1)
end
@last_move_time = time
end

def collapse
@default = 2
end
end

#==============================================================================
# ** Game_Battler
#==============================================================================

class Game_Battler
#--------------------------------------------------------------------------
# * Animation Variables
#--------------------------------------------------------------------------
attr_accessor :moving # Moving?
attr_accessor :display_x # Current X
attr_accessor :display_y # Current Y
attr_accessor :original_x # Original X
attr_accessor :original_y # Orginal Y
attr_accessor :destination_x # Destination X
attr_accessor :destination_y # Destination Y
attr_accessor :pose # Sprite Pose
attr_accessor :freeze # Freeze Sprite?
attr_accessor :default # Default Pose
attr_accessor :moved # Moved?
attr_accessor :cast # Cast?
#--------------------------------------------------------------------------
# * Set Movement
#--------------------------------------------------------------------------
def setmove(original_x, original_y, destination_x, destination_y)
@original_x = original_x
@original_y = original_y
@destination_x = destination_x + (self.is_a?(Game_Actor) ? 40 : -40)
@destination_y = destination_y
@moving = true
end
#--------------------------------------------------------------------------
# * Set Pose
#--------------------------------------------------------------------------
def setpose(pose, freeze = false)
@pose = pose
@freeze = freeze
end
#--------------------------------------------------------------------------
# * Set Default Pose
#--------------------------------------------------------------------------
def setdefault(default)
@default = default
end
end

#==============================================================================
# ** Game_Actor
#==============================================================================

class Game_Actor
#--------------------------------------------------------------------------
# * Actor X Coordinate
#--------------------------------------------------------------------------
def screen_x
if self.index != nil
return self.index * 45 + 450
else
return 0
end
end
#--------------------------------------------------------------------------
# * Actor Y Coordinate
#--------------------------------------------------------------------------
def screen_y
return self.index * 35 + 200
end
#--------------------------------------------------------------------------
# * Actor Z Coordinate
#--------------------------------------------------------------------------
def screen_z
return screen_y
end
end

#==============================================================================
# ** Scene_Battle
#==============================================================================

class Scene_Battle
#--------------------------------------------------------------------------
# * 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)
end
#--------------------------------------------------------------------------
# * Action Animation, Movement
#--------------------------------------------------------------------------
alias cbs_update_phase4_step3 update_phase4_step3
def update_phase4_step3(battler)
return if battler.moving
battler.setdefault(0)
case battler.current_action.kind
when 0 # Basic
if battler.moved
battler.setpose(6 + rand(2))
elsif battler.guarding?
battler.setdefault(3)
else
for target in battler.target
battler.setmove(battler.screen_x, battler.screen_y, target.screen_x, target.screen_y)
end
battler.moved = true
return
end
when 1 # Skill
battler.setpose(8)
for target in battler.target
battler.cast = (battler.is_a?(Game_Actor) == target.is_a?(Game_Enemy))
end
when 2 # Item
battler.setpose(8)
end
cbs_update_phase4_step3(battler)
end
#--------------------------------------------------------------------------
# * Hit Animation, Reset
#--------------------------------------------------------------------------
alias cbs_update_phase4_step4 update_phase4_step4
def update_phase4_step4(battler)
for target in battler.target
target.setpose(1) if (battler.moved or battler.cast) and target.damage != "Miss"
end
if battler.moved
battler.moving = true
end
battler.moved = false
battler.cast = false
cbs_update_phase4_step4(battler)
end
#--------------------------------------------------------------------------
# * Victory Animation
#--------------------------------------------------------------------------
alias cbs_start_phase5 start_phase5
def start_phase5
for actor in $game_party.actors
return if actor.moving
end
for actor in $game_party.actors
actor.setpose(9, true) unless actor.dead?
end
cbs_start_phase5
end
end

#==============================================================================
# ** Spriteset_Battle
#==============================================================================

class Spriteset_Battle
#--------------------------------------------------------------------------
# * 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
end

#==============================================================================
# ** Arrow_Base
#==============================================================================

class Arrow_Base < Sprite
#--------------------------------------------------------------------------
# * Reposition Arrows
#--------------------------------------------------------------------------
alias cbs_initialize initialize
def initialize(viewport)
cbs_initialize(viewport)
self.ox = 32
self.oy = 40
end
end