#==============================================================================
# ** Advance Movement System
#------------------------------------------------------------------------------
# SephirothSpawn
# Version 1
# 2006-04-24
#------------------------------------------------------------------------------
# Script Concepts By: Homer, XK8 & Others
#------------------------------------------------------------------------------
# Walking, Sneaking, Dashing, Jumping & Isometric System
#------------------------------------------------------------------------------
# * Features & Syntax:
#
# ~ Sneaking
# To Enable Sneaking:
# $game_player.enable_sneaking = true (On) or false (Off)
# Editing Sneak Button
# Sneak_Button = Input::Constant
# Editing Sneak Speed
# Sneak_Speed = move_speed (Should Be less than 4)
# Editing Sneak Cost Per Second
# Sneak_Cost = number_of_seconds
# Editing Sneak Recover Per Second
# Sneak_Recover = number_of_seconds
# Modifing Max Sneak Level
# Change the 5, under def max_sneak_level
# For unlimited sneak, replace 5 + @max_sneak_bonus with nil
# Increasing Max Sneak Bonus
# $game_player.max_sneak_bonus
# Show Sneak Animation (Uses Alternate File)
# $game_player.enable_sneaking_animation
# (Filename + _sneak)
#
# ~ Dashing
# To Enable Dashing:
# $game_player.enable_dashing = true (On) or false (Off)
# Editing Dash Button
# Dash_Button = Input::Constant
# Editing Dash Speed
# Dash_Speed = move_speed (Should Be greather than 4)
# Editing Dash Cost Per Second
# Dash_Cost = number_of_seconds
# Editing Dash Recover Per Second
# Dash_Recover = number_of_seconds
# Modifing Max Dash Level
# Change the 5, under def max_dash_level
# For unlimited dash, replace 5 + @max_sneak_bonus with nil
# Increasing Max Dash Bonus
# $game_player.max_dash_bonus
# Show Dash Animation (Uses Alternate File)
# $game_player.enable_dash_animation
# (Filename + _sneak)
#
# ~ Jumping
# To Enable Jumping:
# $game_player.enable_jumping = true (On) or false (Off)
# Editing Jump Button
# Jump_Button = Input::Constant
# Jump Distances
# S_Jump_Dis = Sneaking Jump Distance
# W_Jump_Dis = Walking Jump Distance
# D_Jump_Dis = Dashing Jump Distance
# Show Jump Animation (Uses Alternate File)
# $game_player.enable_jump_animation
# (Filename + _jump)
#
# ~ Isometric Movement
# To Enable Isometric Movement
# $game_player.enable_isometric = true (On) or false (Off)
# To Enable Isometric Animation (Uses 4 * 8 Sprite Sheet)
# $game_player.enable_isometric_animation
# (Filename + _iso)
#
# ~ Filenaming
# Sneak
# Filename_sneak
# Dash
# Filename_dash
# Standing
# Filename_stand
# Jumping
# Filename_jump
# Isometric Movement
# Filename_iso
# Isometric + Sneak
# Filename_iso_sneak
# Isometric + Dash
# Filename_iso_dash
# Isometric + Standing
# Filename_iso_stand
# Isometric + Jumping
# Filename_iso_jump
#==============================================================================
#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Advance Movement System', 'SephirothSpawn', 1, '2006-04-24')
#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.state('Advance Movement System') == true
#==============================================================================
# ** Game_Player
#==============================================================================
class Game_Player < Game_Character
#--------------------------------------------------------------------------
# * Buttons, Speed & Distance
#--------------------------------------------------------------------------
Sneak_Button = Input::X # Input Button it Sneak
Dash_Button = Input::Y # Input Button it Dash
Jump_Button = Input::Z # Input Button it Jump
Sneak_Speed = 3 # Sneak Speed (4 is Normal Walking)
Walk_Speed = 4 # Walk Speed (4 is Normal Walking)
Dash_Speed = 5 # Dash Speed (4 is Normal Walking)
S_Jump_Dis = 2 # Sneak Jump Distance (Jump Distance W/ Sneak)
W_Jump_Dis = 2 # Walk Jump Distance (Jump Distance W/ Walk)
D_Jump_Dis = 3 # Dash Jump Distance (Jump Distance W/ Dash)
Sneak_Cost = 1 # Number of Seconds to Decrease Sneak
Sneak_Recover = 2 # Number of Seconds to Recover Sneak
Dash_Cost = 1 # Number of Seconds to Decrease Dash
Dash_Recover = 2 # Number of Seconds to Recover Dash
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :current_sneak_level # Sneak Stamina Left
attr_reader :current_dash_level # Dash Stamina Left
attr_accessor :max_sneak_bonus # Sneak Bonus (To Max)
attr_accessor :max_dash_bonus # Dash Bonus (To Max)
attr_accessor :enable_sneaking # Sneak Enabler
attr_accessor :enable_dashing # Dash Enabler
attr_accessor :enable_jumping # Jump Enabler
attr_accessor :enable_isometric # Isometric Movement Enabler
attr_accessor :enable_sneaking_animation # Sneak Animation
attr_accessor :enable_dashing_animation # Dash Animation
attr_accessor :enable_jumping_animation # Jump Animation
attr_accessor :enable_isometric_animation # Isometric Animation
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias seph_wsdanim_gameplayer_init initialize
alias seph_wsdanim_gameplayer_refresh refresh
alias seph_wsdanim_gameplayer_update update
alias seph_wsdanim_gameplayer_uj update_jump
alias seph_wsdanim_gameplayer_um update_move
alias seph_wsdanim_gameplayer_us update_stop
alias seph_wsdanim_gameplayer_upm update_player_movement
alias seph_wsdanim_gameplayer_md move_down
alias seph_wsdanim_gameplayer_ml move_left
alias seph_wsdanim_gameplayer_mr move_right
alias seph_wsdanim_gameplayer_mu move_up
alias seph_wsdanim_gameplayer_mll move_lower_left
alias seph_wsdanim_gameplayer_mlr move_lower_right
alias seph_wsdanim_gameplayer_mul move_upper_left
alias seph_wsdanim_gameplayer_mur move_upper_right
alias seph_wsdanim_gameplayer_mrand move_random
alias seph_wsdanim_gameplayer_mf move_forward
alias seph_wsdanim_gameplayer_mb move_backward
alias seph_wsdanim_gameplayer_cett check_event_trigger_there
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Original Initialization
seph_wsdanim_gameplayer_init
# Enable Movement Features Test
@enable_sneaking = false # Enable Sneaking Test
@enable_dashing = false # Enable Dashing Test
@enable_jumping = false # Enable Jumping Test
@enable_isometric = true # Enable Isometric Test
# Enable Movement Features Animation Test
@enable_standing_animation = false # Enable Stand Animation Test
@enable_sneaking_animation = false # Enable Sneak Animation Test
@enable_dashing_animation = true # Enable Dashing Animation Test
@enable_jumping_animation = true # Enable Jumping Animation Test
@enable_isometric_animation = false # Enable Isometric Animation Test
# Sneak & Bonuses
@max_sneak_bonus = 0
@max_dash_bonus = 0
# Sets Current Sneak & Dash Level
@current_sneak_level = max_dash_level # Starting Sneak Level
@current_dash_level = max_sneak_level # Starting Dash Level
# Sneaking & Dashing
@sneaking = false
@dashing = false
# Jump Direction
@jump_direction = @direction
# Isometric
if @enable_isometric_animation
@character_name += '_iso'
end
# Duplicate Character Name
@dup_character_name = @character_name
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
# Original Refresh Method
seph_wsdanim_gameplayer_refresh
# Isometric
if @enable_isometric_animation
@character_name += '_iso'
end
# Duplicate Character Name
@dup_character_name = @character_name
end
#--------------------------------------------------------------------------
# * Player Movement Update
#--------------------------------------------------------------------------
def update
# If Sneak Enabled
if @enable_sneaking && !@dashing
# Update Sneak
update_sneak
# Update Sneak Level
update_sneak_level unless max_sneak_level.nil?
end
# Id Dash Enabled
if @enable_dashing && !@sneaking
# Update Dash
update_dash
# Update Dash Level
update_dash_level unless max_dash_level.nil?
end
# Update Walking
update_walk
# If Jumping Enabled
if @enable_jumping
# Update Jump
update_jumping
end
# Original Update Player Movement
seph_wsdanim_gameplayer_update
end
#--------------------------------------------------------------------------
# * Frame Update (jump)
#--------------------------------------------------------------------------
def update_jump
# Original Update Jump
seph_wsdanim_gameplayer_uj
# Jump Animation
if @enable_jumping_animation
unless @character_name.include?('_jump')
@character_name = @dup_character_name + '_jump'
end
# Isometric Animation
if @enable_isometric_animation
@direction = @jump_direction
end
end
@jump_direction = @direction
end
#--------------------------------------------------------------------------
# * Update frame (move)
#--------------------------------------------------------------------------
def update_move
# Original Update Move
seph_wsdanim_gameplayer_um
# Sneak Animation
if @sneaking && @enable_sneaking_animation
unless @character_name.include?('_sneak')
@character_name = @dup_character_name + '_sneak'
end
elsif @dashing && @enable_dashing_animation
unless @character_name.include?('_dash')
@character_name = @dup_character_name + '_dash'
end
else
@character_name = @dup_character_name
end
# Isometric Animation
@direction = @jump_direction if enable_isometric_animation
end
#--------------------------------------------------------------------------
# * Frame Update (stop)
#--------------------------------------------------------------------------
def update_stop
# Original Update Stop
seph_wsdanim_gameplayer_us
# Restore Character Name
if @pattern == @original_pattern
@character_name = @dup_character_name
end
# Standing Animations
if @enable_standing_animation
@step_anime = true
unless @character_name.include?('_stand')
@character_name = @dup_character_name + '_stand'
end
else
@step_anime = false
@character_name = @dup_character_name
end
# Isometric Animation
@direction = @jump_direction if enable_isometric_animation
end
#--------------------------------------------------------------------------
# * Player Movement Update
#--------------------------------------------------------------------------
def update_player_movement
# If Isometic Enabled
if @enable_isometric
# Branch Point By Input
case Input.dir8
when 1 # Down-Left
move_lower_left
return
when 3 # Down-Right
move_lower_right
return
when 7
move_upper_left
return
when 9
move_upper_right
return
end
end
# Original Update Player Movement
seph_wsdanim_gameplayer_upm
end
#--------------------------------------------------------------------------
# * Move Down
#--------------------------------------------------------------------------
def move_down(turn_enabled = true)
# Original Move Down
seph_wsdanim_gameplayer_md(turn_enabled)
# Adjust Jump Direction
@jump_direction = @direction
end
#--------------------------------------------------------------------------
# * Move Left
#--------------------------------------------------------------------------
def move_left(turn_enabled = true)
# Original Move Left
seph_wsdanim_gameplayer_ml(turn_enabled)
# Adjust Jump Direction
@jump_direction = @direction
end
#--------------------------------------------------------------------------
# * Move Right
#--------------------------------------------------------------------------
def move_right(turn_enabled = true)
# Original Move Right
seph_wsdanim_gameplayer_mr(turn_enabled)
# Adjust Jump Direction
@jump_direction = @direction
end
#--------------------------------------------------------------------------
# * Move up
#--------------------------------------------------------------------------
def move_up(turn_enabled = true)
# Original Move Up
seph_wsdanim_gameplayer_mu(turn_enabled)
# Adjust Jump Direction
@jump_direction = @direction
end
#--------------------------------------------------------------------------
# * Move Lower Left
#--------------------------------------------------------------------------
def move_lower_left
# Original Move Lower Left
seph_wsdanim_gameplayer_mll
# Isometric Animation
@direction = 10 if enable_isometric_animation
# Jump Direction
@jump_direction = 10
end
#--------------------------------------------------------------------------
# * Move Lower Right
#--------------------------------------------------------------------------
def move_lower_right
# Original Move Lower Right
seph_wsdanim_gameplayer_mlr
# Isometric Animation
@direction = 12 if enable_isometric_animation
# Jump Direction
@jump_direction = 12
end
#--------------------------------------------------------------------------
# * Move Upper Left
#--------------------------------------------------------------------------
def move_upper_left
# Original Move Upper Left
seph_wsdanim_gameplayer_mul
# Isometric Animation
@direction = 14 if enable_isometric_animation
# Jump Direction
@jump_direction = 14
end
#--------------------------------------------------------------------------
# * Move Upper Right
#--------------------------------------------------------------------------
def move_upper_right
# Original Move Upper Right
seph_wsdanim_gameplayer_mur
# Isometric Animation
@direction = 16 if enable_isometric_animation
# Jump Direction
@jump_direction = 16
end
#--------------------------------------------------------------------------
# * Move at Random
#--------------------------------------------------------------------------
def move_random
# Isometric Movement
case rand(8)
when 4 # Down-Left
move_lower_left
when 5 # Down-Right
move_lower_right
when 6 # Up-Left
move_upper_left
when 7 # up-Right
move_upper_right
else
# Original Movement
seph_wsdanim_gameplayer_mrand
end
end
#--------------------------------------------------------------------------
# * 1 Step Forward
#--------------------------------------------------------------------------
def move_forward
# Isometric Movement
case @jump_direction
when 10
move_lower_left
when 12
move_lower_right
when 14
move_upper_left
when 16
move_upper_right
else
# Original Movement
seph_wsdanim_gameplayer_mf
end
end
#--------------------------------------------------------------------------
# * 1 Step Backward
#--------------------------------------------------------------------------
def move_backward
# Remember direction fix situation
last_direction_fix = @direction_fix
# Force direction fix
@direction_fix = true
# Isometric Movement
case @jump_direction
when 10
move_upper_right
when 12
move_upper_left
when 14
move_lower_right
when 16
move_lower_left
else
# Original Movement
seph_wsdanim_gameplayer_mb
end
# Return direction fix situation back to normal
@direction_fix = last_direction_fix
end
#--------------------------------------------------------------------------
# * Max Sneak Level
# ~ Nil For Unlimited
#--------------------------------------------------------------------------
def max_sneak_level
return 5 + @max_sneak_bonus
end
#--------------------------------------------------------------------------
# * Max Dash Level
# ~ Nil For Unlimited
#--------------------------------------------------------------------------
def max_dash_level
return 5 + @max_dash_bonus
end
#--------------------------------------------------------------------------
# * Frame Update : Sneak
#--------------------------------------------------------------------------
def update_sneak
# If Sneak Button is Pressed
if Input.press?(Sneak_Button)
# If Sneak Level is Greater than 0 (Or Max is nil)
if @current_sneak_level > 0 || max_sneak_level.nil?
# Turn Sneaking On
@sneaking = true
# Adjust Move Speed
@move_speed = Sneak_Speed
return
end
end
# Turn Sneaking Off
@sneaking = false
end
#--------------------------------------------------------------------------
# * Frame Update : Sneak Level
#--------------------------------------------------------------------------
def update_sneak_level
# If Sneaking
if @sneaking
# Lose 1 Every Sneak Cost
if Graphics.frame_count % (Graphics.frame_rate * Sneak_Cost) == 0
# Decrease Sneak
@current_sneak_level -= 1
end
# Recover Sneak
else
# Gain 1 Every Sneak Recover
if Graphics.frame_count % (Graphics.frame_rate * Sneak_Recover) == 0
# Increase Sneak Level
@current_sneak_level += 1 if @current_sneak_level < max_sneak_level
end
end
end
#--------------------------------------------------------------------------
# * Frame Update : Dash
#--------------------------------------------------------------------------
def update_dash
# If Dash Button is Pressed
if Input.press?(Dash_Button)
# If Dash Level is Greater than 0 (Or Max is nil)
if @current_dash_level > 0 || max_dash_level.nil?
# Turn Dash On
@dashing = true
# Adjust Move Speed
@move_speed = Dash_Speed
return
end
end
# Turn Dash Off
@dashing = false
end
#--------------------------------------------------------------------------
# * Frame Update : Dash Level
#--------------------------------------------------------------------------
def update_dash_level
# If Dashing
if @dashing
# Lose 1 Every Dash Cost
if Graphics.frame_count % (Graphics.frame_rate * Dash_Cost) == 0
# Decrease Dash
@current_dash_level -= 1
end
# Recover Dash
else
# Gain 1 Every Dash Recover
if Graphics.frame_count % (Graphics.frame_rate * Dash_Recover) == 0
# Increase Dash Level
@current_dash_level += 1 if @current_dash_level < max_dash_level
end
end
end
#--------------------------------------------------------------------------
# * Frame Update : Walk
#--------------------------------------------------------------------------
def update_walk
# Reset Move Speed (Walking)
unless @sneaking || @dashing
@move_speed = Walk_Speed
end
end
#--------------------------------------------------------------------------
# * Frame Update : Jumping
#--------------------------------------------------------------------------
def update_jumping
# If Jump Button Pressed
if Input.trigger?(Jump_Button)
# Gets Distance
dist = @sneaking ? S_Jump_Dis : @dashing ? D_Jump_Dis : W_Jump_Dis
# Case Jump Direction
case @jump_direction
when 2 # Down
jump(0, dist)
when 4 # Left
jump(- dist, 0)
when 6 # Right
jump(dist, 0)
when 8 # Up
jump(0, - dist)
when 10 # Down-Left
jump(- dist, dist)
when 12 # Down-Right
jump(dist, dist)
when 14 # Up-Left
jump(- dist, - dist)
when 16 # Up-Right
jump(dist, - dist)
end
end
end
#--------------------------------------------------------------------------
# * Front Event Starting Determinant
#--------------------------------------------------------------------------
def check_event_trigger_there(triggers)
# If event is running
if $game_system.map_interpreter.running?
return false
end
# Isometric Direction
if @enable_isometric_animation
if [10, 12, 14, 16].include?(@jump_direction)
check_event_trigger_there_iso(triggers)
return
end
end
# Original Check Event Trigger
seph_wsdanim_gameplayer_cett(triggers)
end
#--------------------------------------------------------------------------
# * Front Event Starting Determinant (Isometric)
#--------------------------------------------------------------------------
def check_event_trigger_there_iso(triggers)
result = false
# Calculate front event coordinates
case @jump_direction
when 10
new_x, new_y = @x - 1, @y + 1
when 12
new_x, new_y = @x + 1, @y + 1
when 14
new_x, new_y = @x - 1, @y - 1
when 16
new_x, new_y = @x + 1, @y - 1
end
# All event loops
for event in $game_map.events.values
# If event coordinates and triggers are consistent
if event.x == new_x and event.y == new_y and
triggers.include?(event.trigger)
# If starting determinant is front event (other than jumping)
if not event.jumping? and not event.over_trigger?
event.start
result = true
end
end
end
# If fitting event is not found
if result == false
# If front tile is a counter
if $game_map.counter?(new_x, new_y)
# Calculate 1 tile inside coordinates
new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
# All event loops
for event in $game_map.events.values
# If event coordinates and triggers are consistent
if event.x == new_x and event.y == new_y and
triggers.include?(event.trigger)
# If starting determinant is front event (other than jumping)
if not event.jumping? and not event.over_trigger?
event.start
result = true
end
end
end
end
end
return result
end
end
#==============================================================================
# ** Sprite_Character
#==============================================================================
class Sprite_Character < RPG::Sprite
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias seph_wsdanim_sprchara_update update
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
# If Game Player
if @character.is_a?(Game_Player)
if @character.enable_isometric_animation
# If tile ID, file name, or hue are different from current ones
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue
# Remember tile ID, file name, and hue
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
# If tile ID value is valid
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name,
@tile_id, @character.character_hue)
self.src_rect.set(0, 0, 32, 32)
self.ox = 16
self.oy = 32
# If tile ID value is invalid
else
self.bitmap = RPG::Cache.character(@character.character_name,
@character.character_hue)
@cw = bitmap.width / 4
@ch = bitmap.height / 8
self.ox = @cw / 2
self.oy = @ch
end
end
# Set visible situation
self.visible = (not @character.transparent)
# If graphic is character
if @tile_id == 0
# Set rectangular transfer
sx = @character.pattern * @cw
sy = (@character.direction - 2) / 2 * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
# Set sprite coordinates
self.x = @character.screen_x
self.y = @character.screen_y
self.z = @character.screen_z(@ch)
# Set opacity level, blend method, and bush depth
self.opacity = @character.opacity
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
# Animation
if @character.animation_id != 0
animation = $data_animations[@character.animation_id]
animation(animation, true)
@character.animation_id = 0
end
return
end
end
# Original Update
seph_wsdanim_sprchara_update
end
end
#------------------------------------------------------------------------------
# * End SDK Enable Test
#------------------------------------------------------------------------------
end