12-06-2009, 07:38 AM
Introduction
Tired of walking around at a snail's pace? Standardized cardinal movement pissing you off? Looking for a little eye candy? Then this script's for you - the single most advanced movement system in the realm of the RGSS! Now, newly translated from Portuguese with some slight new features, such as...
- Formatted code
- User-friendly annotations
- Brand new customizations
- ... and more!
(Disclaimer: And by most, I mean qua itself.)
Features
This script is ACTION PACKED, I tell you!
- 8-Directional Movement
- Additional character poses... quarter view and dashing!
- Unique dashing system that includes cooldown effect
- Status afflictions that affect movement speed, including, but not limited to...
- CONFUSED! Move in the opposite direction!
- CRAZY! Runs around like a headless chicken!
- CONFUSED! Move in the opposite direction!
- Parameter leveling system that affects speed. Go faster as you level!
- A pretty customizable UI
Screenshots
Hahah. Yeah, okay.
Demo
Script
Content Hidden
Code:
#=============================================================================
# MOG_Advanced Move System V2.0EX
#-----------------------------------------------------------------------------
# By Moghunter
# Translated, edited and annotated by Helel @ rmvxp.com
# http://www.atelier-rgss.com
#=============================================================================
# Adds an advanced movement system, that includes:
# * Character Dashing
# * State Afflictions
# * Dash Bar Effects
# * Custom Speed Levelling
# * ... and more!
#
# - Compatible with SDK 2.4 (last tested: 12/5/09)
# - Works hand-in-hand with the XAS system.
#=============================================================================
# You need to have a picture named "Dash_Bar" in the pictures folder.
# (See post for more details)
#--------------------------------- INCLUDED ----------------------------------
# With this script, you can now show different character animations for each
# movement phase.
#
# * To show a character runnning, you need this image in your
# character folder:
# "Name_of_character_DASH.png"
#
# * To show a character's quarter view (used in diagonal movement), you
# need this image in your character folder:
# "Name_of_character_quarter.png"
#
# * To show a character's quarter view WITH running, you need this in your
# character folder:
# "Name_of_characteer_dash_quarter.png"
#
# Ex:
# Name of character = 001-Fighter01.png
# * 001-Fighter01_dash.png
# * 001-Fighter01_quarter.png
# * 001-Fighter01_dash_quarter.png
#=============================================================================
#===========================================================================
# ** module MOG
#===========================================================================
module MOG
#===========================================================================
# Basic Customization
#===========================================================================
#----------------------------------------------------------------------
# Value of DASH bar duration, eg how long you can run for.
#----------------------------------------------------------------------
$max_dash = 200
#----------------------------------------------------------------------
# Value of DASH bar expense, eg how much energy it takes to run.
#----------------------------------------------------------------------
DASH_DOWN = 3
#----------------------------------------------------------------------
# Value of DASH bar recovery. Default: 1
#----------------------------------------------------------------------
DASH_UP = 1
#----------------------------------------------------------------------
# Running speed.
#----------------------------------------------------------------------
DASH_SPEED = 5
#----------------------------------------------------------------------
# Walking (normal) speed. 4 = default
#----------------------------------------------------------------------
NORMAL_SPEED = 4
#----------------------------------------------------------------------
# Input button for DASH.
#----------------------------------------------------------------------
BUTTON = Input::X
#----------------------------------------------------------------------
# WINDOWSKIN of the DASH WINDOW. To get rid of, just delete the name.
#----------------------------------------------------------------------
DASH_SKIN = "001-Blue01"
#----------------------------------------------------------------------
# Transparency of the WINDOWSKIN.
#----------------------------------------------------------------------
DASH_OPACITY = 200
#----------------------------------------------------------------------
# Horizontal position of the bar.
#----------------------------------------------------------------------
POS_X = 15
#----------------------------------------------------------------------
# Vertical position of the bar.
#----------------------------------------------------------------------
POS_Y = 5
#----------------------------------------------------------------------
# Sound made when the DASH BAR reaches 100% charge.
#----------------------------------------------------------------------
SE_PLAY = "032-Switch01"
#----------------------------------------------------------------------
# Percentage of DASH BAR that counts as 'low.'
# * Changes number color to LOW_COLOR, and the bar display.
#----------------------------------------------------------------------
LOW = 20
LOW_COLOR = Color.new(255,0,0,255)
#----------------------------------------------------------------------
# Name of the text on the bar. Default: Dash
#----------------------------------------------------------------------
DASH_NAME = "Dash"
DASH_BAR = RPG::Cache.picture("Dash_Bar") # Name of bar picture.
DASH_COLOR = Color.new(50,250,50,255) # Color of DASH_NAME
NUMBER_COLOR = Color.new(50,250,250,255) # Color of number %.
DASH_SHADOW = Color.new(0,0,0,255) # Color of DASH_NAME's shadow.
NUMBER_SHADOW = Color.new(0,0,0,255) # Color of the number's shadow.
NUMBER_BLINK = true # Allow randomization of number color at 100% charge?
#----------------------------------------------------------------------
# Names of the font on the bar.
#----------------------------------------------------------------------
FONT_NUMBER = "Georgia" # Font face of bar numbers
FONT_DASH = "Arial" # Font face of DASH_NAME
FONT_SIZE = 14 # Font Size
#----------------------------------------------------------------------
# Switch that deactivates the system.
#----------------------------------------------------------------------
SWIT = 4928
#----------------------------------------------------------------------
# Update speed of the window. The higher, the joltier, slower, and less laggy.
#----------------------------------------------------------------------
ADVMOVREF = 5
#===========================================================================
# Status Customization
#===========================================================================
# With these scripts are included several status effects that affect
# character movement OUTSIDE of battle.
#
# * HASTE - Increases dash bar recovery.
# * SLOW - Decreases the character speed from default.
# * CONFUSE - Invert your command directions.
# eg, going left makes your character go right.
# * DELAY - Dash bar will be drained and will not recover.
# * POISON - Causes consecutive damage to the character while moving.
# * CRAZY - The character's movement is randomized.
# * REGEN - Recovers the health of the character while moving.
# * FAST - Increases the character speed from default.
#
# !! NOTE: Some conditions annul another. (Ex: Poison and Regen)
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
# Define the state ID for these conditions.
#---------------------------------------------------------------------------
# * Syntax:
# STATE = ID #
#---------------------------------------------------------------------------
HASTE = 18
SLOW = 19
CONFUSE = 6
DELAY = 11
POISON = 3
CRAZY = 20
REGEN = 21
FAST = 22
#---------------------------------------------------------------------------
# Define the duration of the states on the map.
#---------------------------------------------------------------------------
# * Syntax:
# STATE_TIME = DURATION. Default = 15 seconds
#---------------------------------------------------------------------------
HASTE_TIME = 15
SLOW_TIME = 15
CONFUSE_TIME = 15
DELAY_TIME = 15
POISON_TIME = 15
CRAZY_TIME = 15
REGEN_TIME = 15
FAST_TIME = 15
#---------------------------------------------------------------------------
# How much HASTE will multiply the recovery rate by. Default = 3
#---------------------------------------------------------------------------
HASTE_UP = 3
#---------------------------------------------------------------------------
# Speed of character decreased underneath SLOW. Default = 2
#---------------------------------------------------------------------------
SLOW_SPEED = 2
#---------------------------------------------------------------------------
# % of HP damaged while in poison condition.
#---------------------------------------------------------------------------
POISON_DAMAGE = 10
#---------------------------------------------------------------------------
# % of HP restored while in REGEN condition.
#---------------------------------------------------------------------------
REGEN_RESTORE = 3
#---------------------------------------------------------------------------
# How much FAST will increase the default speed.
#---------------------------------------------------------------------------
FAST_SPEED = 1
#===========================================================================
# Leveling System
#===========================================================================
#---------------------------------------------------------------------------
# Should speed be affected by level? If FALSE, ignore rest.
#---------------------------------------------------------------------------
LEVEL = true
#---------------------------------------------------------------------------
# Maximum speed.
#---------------------------------------------------------------------------
MAX_SPEED = 6
#---------------------------------------------------------------------------
# Parameter that will be used to calculate speed.
# 0 = Level
# 1 = HP
# 2 = MP
# 3 = STR
# 4 = DEX
# 5 = AGL
# 6 = INT
# 7 = Steps
# 8 = Variable
# 9.. = Normal
#---------------------------------------------------------------------------
LEVEL_SISTEMA = 0
#---------------------------------------------------------------------------
# If above is set to 8 (variable), input variable number.
#---------------------------------------------------------------------------
VARI = 5
#---------------------------------------------------------------------------
# Speed calculation method
# 0 = from first actor
# 1 = from party average (bugged atm)
#---------------------------------------------------------------------------
ACTOR = 0
#---------------------------------------------------------------------------
# Calculate the increment gained from parameter increase
#---------------------------------------------------------------------------
#
# * LEVEL_CALCULO = Dashing increase by parameter.
#
# * LEVEL_CALCULO2 = Increases MAX DASH VALUE so that, in effect, the
# character will have more points to spend when running,
# leading less of a decrease with the DASH BAR while
# running.
#
# * LEVEL CALCULO3 = Increases the recovery speed of the DASH BAR.
#
#---------------------------------------------------------------------------
# Dashing increment
# * Parameter divided by value below.
# - 99 leads to a + 1 dash speed at level 99. (99/99 = 1)
#---------------------------------------------------------------------------
LEVEL_CALCULO = 99
#---------------------------------------------------------------------------
# Max value of DASH BAR.
# * Parameter is multiplied by value below.
# - 1 leads to a 99 point increase in the dash bar. (99 * 1 = 99)
#---------------------------------------------------------------------------
LEVEL_CALCULO2 = 1
#---------------------------------------------------------------------------
# Recovery speed of the DASH BAR.
# * Parameter is divided by the value below
# - 1 leads to a 99% recovery at level 99. (99 / 1 = 99)
#---------------------------------------------------------------------------
LEVEL_CALCULO3 = 1
#===========================================================================
# End Customization
#===========================================================================
end
#---------------------------------------------------------------------------
# * SDK Log Script
#---------------------------------------------------------------------------
begin
SDK.log("Advanced Move System EX", "Moghunter", 2, "02.12.09")
if SDK.state("Advanced Move System EX") != true
@advanced_move_system_ex_disabled = true
end
rescue
end
#---------------------------------------------------------------------------
# * Begin SDK Enable Test
#---------------------------------------------------------------------------
if !@advanced_move_system_ex_disabled
$dash = 0
$valor0 = 0
$slow = 0
$xrxs = {} if $xrxs == nil
$mogscript = {} if $mogscript == nil
$mogscript["adv_move"] = true
#===========================================================================
# ** Window_Base
#===========================================================================
class Window_Base < Window
#-----------------------------------------------------------------------
# * Draw Dash(x,y)
# x : horizontal screen position
# y : vertical screen position
#-----------------------------------------------------------------------
def dash(x,y)
# Set Bar values
val0 = $dash
val1 = $max_dash + $valor0
valor = 100 * val0 / val1
dash_back = MOG::DASH_BAR
# Draw Bar picture
cw = dash_back.width
ch = 17
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x , y - ch, dash_back, src_rect)
# Draw value in Bar
dash = MOG::DASH_BAR
cw = dash.width * $dash / val1
ch = 17
if valor <= MOG::LOW
src_rect = Rect.new(0, 17, cw, ch)
else
src_rect = Rect.new(0, 34, cw, ch)
end
self.contents.blt(x , y - ch, dash, src_rect)
self.contents.font.size = MOG::FONT_SIZE
self.contents.font.name = MOG::FONT_DASH
self.contents.font.bold = true
self.contents.font.color = MOG::DASH_SHADOW
self.contents.draw_text(x + 1 , y - 36, 120, 32,MOG::DASH_NAME)
self.contents.font.color = MOG::DASH_COLOR
self.contents.draw_text(x , y - 35, 120, 32,MOG::DASH_NAME)
# Draw Bar Value
self.contents.font.name = MOG::FONT_NUMBER
self.contents.font.color = MOG::NUMBER_SHADOW
if valor >= 100
valor = 100
elsif valor < 0
valor = 0
end
self.contents.draw_text(x - 6, y - 29, 120, 32,valor.to_s + "%",2 )
if valor <= 0
if MOG::NUMBER_BLINK == true
r = rand(0) + 250
g = rand(200) + 50
b = rand(200) + 50
self.contents.font.color = Color.new(r,g,b,255)
else
self.contents.font.color = MOG::NUMBER_COLOR
end
elsif valor <= MOG::LOW
self.contents.font.color = MOG::LOW_COLOR
elsif valor >= 100
if MOG::NUMBER_BLINK == true
r = rand(200) + 50
g = rand(200) + 50
b = rand(0) + 250
self.contents.font.color = Color.new(r,g,b,255)
else
self.contents.font.color = MOG::NUMBER_COLOR
end
else
self.contents.font.color = MOG::NUMBER_COLOR
end
self.contents.draw_text(x - 5, y - 30, 120, 32,valor.to_s + "%",2 )
end
end
#===========================================================================
# ** Window_Dash
#===========================================================================
class Window_Dash < Window_Base
#-----------------------------------------------------------------------
# * Object Initialization
#-----------------------------------------------------------------------
def initialize
super(0, 0, 155, 60)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = MOG::DASH_OPACITY
self.windowskin = RPG::Cache.windowskin(MOG::DASH_SKIN)
refresh
end
#-----------------------------------------------------------------------
# * Refresh
#-----------------------------------------------------------------------
def refresh
self.contents.clear
dash(5,30)
end
end
#===========================================================================
# ** Scene_Map
#===========================================================================
class Scene_Map
#-----------------------------------------------------------------------
# * Main Processing
#-----------------------------------------------------------------------
alias mog_dash_main main
def main
@dash_win = Window_Dash.new
@dash_win.x = MOG::POS_X
@dash_win.y = MOG::POS_Y
@re = 0
mog_dash_main
@dash_win.dispose
end
#-----------------------------------------------------------------------
# * Update
#-----------------------------------------------------------------------
alias mog_dash_update update
def update
if $game_switches[MOG::SWIT] == true
@dash_win.visible = false
else
@dash_win.visible = true
end
@re += 1
if @re >= MOG::ADVMOVREF
@re = 0
end
if @re == 0
@dash_win.refresh
end
mog_dash_update
end
end
#===========================================================================
# ** Game_Player
#===========================================================================
class Game_Player < Game_Character
@@poin = 0
#------------------------------------------------------------------------
# * Update Character Movement
#------------------------------------------------------------------------
def update
last_moving = moving?
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
end
#----------------------------------------------------------------------
# * Confusion State Handling
#----------------------------------------------------------------------
if actor.state?(MOG::CONFUSE)
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing
case Input.dir8
when 1
move_right
move_up
when 2
move_up
when 3
move_up
move_left
when 4
move_right
when 6
move_left
when 7
move_down
move_right
when 8
move_down
when 9
move_left
move_down
end
end
#----------------------------------------------------------------------
# * Crazy State Handling
#----------------------------------------------------------------------
elsif actor.state?(MOG::CRAZY)
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing
case rand(8)
when 1
move_right
move_up
when 2
move_up
when 3
move_up
move_left
when 4
move_right
when 5
move_left
when 6
move_down
move_right
when 7
move_down
when 8
move_left
move_down
end
end
#----------------------------------------------------------------------
# * Movement Handling
#----------------------------------------------------------------------
else
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing
case Input.dir8
when 1
move_left
move_down
when 2
move_down
when 3
move_down
move_right
when 4
move_left
when 6
move_right
when 7
move_up
move_left
when 8
move_up
when 9
move_right
move_up
end
end
end
#----------------------------------------------------------------------
# * Screen Positioning
#----------------------------------------------------------------------
last_real_x = @real_x
last_real_y = @real_y
super
if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
$game_map.scroll_down(@real_y - last_real_y)
end
if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
$game_map.scroll_left(last_real_x - @real_x)
end
if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
$game_map.scroll_right(@real_x - last_real_x)
end
if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
$game_map.scroll_up(last_real_y - @real_y)
end
#----------------------------------------------------------------------
# * Encounter and Event Processing
#----------------------------------------------------------------------
unless moving?
if last_moving
result = check_event_trigger_here([1,2])
if result == false
unless $DEBUG and Input.press?(Input::CTRL)
if @encounter_count > 0
@encounter_count -= 1
end
end
end
end
if Input.trigger?(Input::C)
check_event_trigger_here([0])
check_event_trigger_there([0,1,2])
end
end
end
#------------------------------------------------------------------------
# * Check for character diagonal image existence
#------------------------------------------------------------------------
def img_dia_exist?(actor)
begin
RPG::Cache.character(actor.character_name.to_s + "_quarter", actor.character_hue)
rescue
return false
end
return true
end
#------------------------------------------------------------------------
# * Check for character dash and quarter image existence
#------------------------------------------------------------------------
def img_dia_dash_exist?(actor)
begin
RPG::Cache.character(actor.character_name.to_s + "_dash_quarter", actor.character_hue)
rescue
return false
end
return true
end
#------------------------------------------------------------------------
# * Check for character dash image existence
#------------------------------------------------------------------------
def img_exist?(actor)
begin
RPG::Cache.character(actor.character_name.to_s + "_dash", actor.character_hue)
rescue
return false
end
return true
end
#------------------------------------------------------------------------
# * Update for Dash processing
#------------------------------------------------------------------------
alias mog_dash_update update
def update
se_01 = $dash
se_02 = $max_dash + $valor0
se_03 = 100 * se_01 / se_02
if se_03 >= 100
se_03 = 100
@@poin += 1
end
if @@poin == 1
Audio.se_play("Audio/SE/" + MOG::SE_PLAY, 100, 100) rescue nil
end
if MOG::ACTOR == 0
actor = $game_party.actors[0]
else
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
end
end
#----------------------------------------------------------------------
# * Process changing character poses
#----------------------------------------------------------------------
if Input.press?(MOG::BUTTON) and se_03 > 0
case Input.dir8
when 1
if img_dia_dash_exist?(actor)
@character_name = actor.character_name + "_dash_quarter"
end
when 2
if img_exist?(actor)
@character_name = actor.character_name + "_dash"
end
when 3
if img_dia_dash_exist?(actor)
@character_name = actor.character_name + "_dash_quarter"
end
when 4
if img_exist?(actor)
@character_name = actor.character_name + "_dash"
end
when 6
if img_exist?(actor)
@character_name = actor.character_name + "_dash"
end
when 7
if img_dia_dash_exist?(actor)
@character_name = actor.character_name + "_dash_quarter"
end
when 8
if img_exist?(actor)
@character_name = actor.character_name + "_dash"
end
when 9
if img_dia_dash_exist?(actor)
@character_name = actor.character_name + "_dash_quarter"
end
end
else
case Input.dir8
when 1
if img_dia_exist?(actor)
@character_name = actor.character_name + "_quarter"
end
when 2
@character_name = actor.character_name
when 3
if img_dia_exist?(actor)
@character_name = actor.character_name + "_quarter"
end
when 4
@character_name = actor.character_name
when 6
@character_name = actor.character_name
when 7
if img_dia_exist?(actor)
@character_name = actor.character_name + "_quarter"
end
when 8
@character_name = actor.character_name
when 9
if img_dia_exist?(actor)
@character_name = actor.character_name + "_quarter"
end
end
end
#----------------------------------------------------------------------
# * Adjust Parameter of Level-based System
#----------------------------------------------------------------------
if MOG::LEVEL_SISTEMA == 0
tipo = actor.level
elsif MOG::LEVEL_SISTEMA == 1
tipo = actor.maxhp
elsif MOG::LEVEL_SISTEMA == 2
tipo = actor.maxsp
elsif MOG::LEVEL_SISTEMA == 3
tipo = actor.str
elsif MOG::LEVEL_SISTEMA == 4
tipo = actor.dex
elsif MOG::LEVEL_SISTEMA == 5
tipo = actor.agi
elsif MOG::LEVEL_SISTEMA == 6
tipo = actor.int
elsif MOG::LEVEL_SISTEMA == 7
tipo = $game_party.steps
elsif MOG::LEVEL_SISTEMA == 8
tipo = $game_variables[MOG::VARI]
else
tipo = 0
end
#----------------------------------------------------------------------
# * Calculate Values
#----------------------------------------------------------------------
if MOG::LEVEL == true
calculo = tipo * MOG::LEVEL_CALCULO2
$valor0 = calculo
else
$valor0 = 0
end
#----------------------------------------------------------------------
# * Limit to max dash value
#----------------------------------------------------------------------
if $dash >= $max_dash + $valor0
$dash = $max_dash + $valor0
elsif $dash <= 0
$dash = 0
end
#----------------------------------------------------------------------
# * Process to Speed
#----------------------------------------------------------------------
if MOG::LEVEL == true
valor1 = tipo / MOG::LEVEL_CALCULO
else
valor1 = 0
end
#----------------------------------------------------------------------
# * Dash Processing
#----------------------------------------------------------------------
unless $game_system.map_interpreter.running? or $game_temp.message_window_showing
if Input.press?(MOG::BUTTON)
@@poin = 0
if $dash >= 10
valor5 = MOG::DASH_SPEED + $valor0
if valor5 > MOG::MAX_SPEED
if actor.state?(MOG::SLOW)
@move_speed = MOG::MAX_SPEED - MOG::SLOW_SPEED - $slow
elsif actor.state?(MOG::FAST)
@move_speed = MOG::NORMAL_SPEED + MOG::FAST_SPEED - $slow
else
@move_speed = MOG::MAX_SPEED - $slow
end
else
if actor.state?(MOG::SLOW)
@move_speed = MOG::DASH_SPEED + valor1 - MOG::SLOW_SPEED - $slow
elsif actor.state?(MOG::FAST)
@move_speed = MOG::NORMAL_SPEED + MOG::FAST_SPEED - $slow
else
@move_speed = MOG::DASH_SPEED - $slow
end
end
$dash -= MOG::DASH_DOWN
else
$dash -= MOG::DASH_DOWN
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
for i in 1...$data_states.size
state = $data_states[i]
if actor.state?(MOG::SLOW)
@move_speed = MOG::NORMAL_SPEED - MOG::SLOW_SPEED - $slow
elsif actor.state?(MOG::FAST)
@move_speed = MOG::NORMAL_SPEED + MOG::FAST_SPEED - $slow
else
@move_speed = MOG::NORMAL_SPEED - $slow
end
end
end
end
else
#------------------------------------------------------------------
# * Diminishing Speed
#------------------------------------------------------------------
if MOG::LEVEL == true
valor3 = tipo / MOG::LEVEL_CALCULO3
else
valor3 = 0
end
#------------------------------------------------------------------
# * Delay State
#------------------------------------------------------------------
if actor.state?(MOG::DELAY)
$dash -= MOG::DASH_UP + valor3
@move_speed = MOG::NORMAL_SPEED - $slow
else
speed1 = MOG::DASH_UP + valor3
speed2 = (MOG::DASH_UP + valor3) * MOG::HASTE_UP
if actor.state?(MOG::HASTE)
$dash += speed2
else
$dash += speed1
end
@move_speed = MOG::NORMAL_SPEED - $slow
if actor.state?(MOG::SLOW)
@move_speed = MOG::NORMAL_SPEED - MOG::SLOW_SPEED - $slow
elsif actor.state?(MOG::FAST)
@move_speed = MOG::NORMAL_SPEED + MOG::FAST_SPEED - $slow
else
@move_speed = MOG::NORMAL_SPEED - $slow
end
end
end
end
mog_dash_update
end
end
#===========================================================================
# ** Game_Character
#===========================================================================
class Game_Character
#------------------------------------------------------------------------
# * Move Random
#------------------------------------------------------------------------
def move_random
case rand(8)
when 0
move_down(false)
when 1
move_left(false)
when 2
move_right(false)
when 3
move_up(false)
when 4
move_lower_left
when 5
move_lower_right
when 6
move_upper_left
when 7
move_upper_right
end
end
#------------------------------------------------------------------------
# * Move Toward Player
#------------------------------------------------------------------------
def move_toward_player
sx = @x - $game_player.x
sy = @y - $game_player.y
if sx == 0 and sy == 0
return
end
abs_sx = sx.abs
abs_sy = sy.abs
if abs_sx == abs_sy
rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
end
if abs_sx
if sx < 0 and sy > 0
move_upper_right
elsif sx > 0 and sy > 0
move_upper_left
elsif sx > 0 and sy < 0
move_lower_left
elsif sx < 0 and sy < 0
move_lower_right
elsif sx < 0
move_right
elsif sx > 0
move_left
elsif sy > 0
move_up
elsif sy < 0
move_down
end
end
end
#------------------------------------------------------------------------
# * Move Away from Player
#------------------------------------------------------------------------
def move_away_from_player
sx = @x - $game_player.x
sy = @y - $game_player.y
if sx == 0 and sy == 0
return
end
abs_sx = sx.abs
abs_sy = sy.abs
if abs_sx == abs_sy
rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
end
if abs_sx
if sx < 0 and sy > 0
move_lower_left
elsif sx > 0 and sy > 0
move_lower_right
elsif sx > 0 and sy < 0
move_upper_right
elsif sx < 0 and sy < 0
move_upper_left
elsif sx < 0
move_left
elsif sx > 0
move_right
elsif sy > 0
move_down
elsif sy < 0
move_up
end
end
end
end
#===========================================================================
# ** Game_Actor
#===========================================================================
class Game_System
include MOG
#-------------------------------------------------------------------------
# * Public Instance Variables
#-------------------------------------------------------------------------
attr_accessor :states_haste
attr_accessor :states_slow
attr_accessor :states_confuse
attr_accessor :states_delay
attr_accessor :states_poison
attr_accessor :states_crazy
attr_accessor :states_regen
attr_accessor :states_fast
#------------------------------------------------------------------------
# * Object Initialization
#------------------------------------------------------------------------
alias mog_advmove_initialize initialize
def initialize
mog_advmove_initialize
@states_haste = 40 * HASTE_TIME
@states_slow = 40 * SLOW_TIME
@states_confuse = 40 * CONFUSE_TIME
@states_delay = 40 * DELAY_TIME
@states_poison = 40 * POISON_TIME
@states_crazy = 40 * CRAZY_TIME
@states_regen = 40 * REGEN_TIME
@states_fast = 40 * FAST_TIME
end
end
#===========================================================================
# ** Scene_Map
#===========================================================================
class Scene_Map
include MOG
#-------------------------------------------------------------------------
# * Main Processing
#-------------------------------------------------------------------------
alias mog_advmovmain main
def main
@status_ref = 0
mog_advmovmain
end
#-------------------------------------------------------------------------
# * Update
#-------------------------------------------------------------------------
alias mog_advmove_update update
def update
mog_advmove_update
# If XAS system is being used.
if $xrxs["xas"] == true
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
end
# If XAS add-on AUTOGAMEOVER is being used.
if XAS_BA::AUTOGAMEOVER == true and $game_party.all_dead?
$scene = Scene_Gameover.new rescue nil
end
end
@status_ref += 1
if @status_ref >= 30
@status_ref = 0
end
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
for i in 1...$data_states.size
state = $data_states[i]
if actor.state?(i) == true
# Decrease HASTE duration.
if actor.state?(MOG::HASTE)
$game_system.states_haste -= 1
end
# Decrease SLOW duration.
if actor.state?(MOG::SLOW)
$game_system.states_slow -= 1
end
# Decrease CONFUSE duration.
if actor.state?(MOG::CONFUSE)
$game_system.states_confuse -= 1
end
# Decrease DELAY duration.
if actor.state?(MOG::DELAY)
$game_system.states_delay -= 1
end
# Decrease POISON duration.
if actor.state?(MOG::POISON)
$game_system.states_poison -= 1
end
# Decrease CRAZY duration.
if actor.state?(MOG::CRAZY)
$game_system.states_crazy -= 1
end
# Decrease REGEN duration.
if actor.state?(MOG::REGEN)
$game_system.states_regen -= 1
end
# Decrease FAST duration.
if actor.state?(MOG::FAST)
$game_system.states_fast -= 1
end
# Deals REGEN restoration.
if actor.state?(MOG::REGEN) == true and @status_ref == 0
# Unless actor is dead
unless actor.state?(1)
damage = -(actor.maxhp * MOG::REGEN_RESTORE / 100)
actor.hp -= damage
end
# If XAS system is being used.
if $xrxs["xas"] == true
$game_player.battler.damage = damage
$game_player.battler.damage_pop = true
end
if $mogscript["mpstelen"] == true
$game_player.wref = true
end
# Deals POISON damage
elsif actor.state?(MOG::POISON) == true and @status_ref == 0
damage = actor.maxhp * MOG::POISON_DAMAGE / 100
if actor.hp > damage
actor.hp -= damage
# If XAS system is being used.
if $xrxs["xas"] == true
$game_player.battler.damage = damage
$game_player.battler.damage_pop = true
end
if $mogscript["mpstelen"] == true
$game_player.wref = true
end
end
end
end
# If HASTE state exceeds duration.
if $game_system.states_haste <= 0
actor.remove_state(HASTE)
$game_system.states_haste = 40 * HASTE_TIME
if $mogscript["mpstelen"] == true
$game_player.wref = true
end
end
# If SLOW state exceeds duration.
if $game_system.states_slow <= 0
actor.remove_state(SLOW)
$game_system.states_slow = 40 * SLOW_TIME
if $mogscript["mpstelen"] == true
$game_player.wref = true
end
end
# if CONFUSE state exceeds duration.
if $game_system.states_confuse <= 0
actor.remove_state(CONFUSE)
$game_system.states_confuse = 40 * CONFUSE_TIME
if $mogscript["mpstelen"] == true
$game_player.wref = true
end
end
# If DELAY state exceeds duration.
if $game_system.states_delay <= 0
actor.remove_state(DELAY)
$game_system.states_delay = 40 * DELAY_TIME
if $mogscript["mpstelen"] == true
$game_player.wref = true
end
end
# If POISON state exceeds duration.
if $game_system.states_poison <= 0
actor.remove_state(POISON)
$game_system.states_poison = 40 * POISON_TIME
if $mogscript["mpstelen"] == true
$game_player.wref = true
end
end
# If CRAZY state exceeds duration.
if $game_system.states_crazy <= 0
actor.remove_state(CRAZY)
$game_system.states_crazy = 40 * CRAZY_TIME
if $mogscript["mpstelen"] == true
$game_player.wref = true
end
end
# If REGEN state exceeds duration.
if $game_system.states_regen <= 0
actor.remove_state(REGEN)
$game_system.states_regen = 40 * REGEN_TIME
if $mogscript["mpstelen"] == true
$game_player.wref = true
end
end
# If FAST state exceeds duration.
if $game_system.states_fast <= 0
actor.remove_state(FAST)
$game_system.states_fast = 40 * FAST_TIME
if $mogscript["mpstelen"] == true
$game_player.wref = true
end
end
end
end
end
end
#===========================================================================
# ** Game_Party
#===========================================================================
class Game_Party
#-------------------------------------------------------------------------
# * Check Map Slip Damage
#-------------------------------------------------------------------------
def check_map_slip_damage
for actor in @actors
if actor.hp > 0 and actor.slip_damage?
# Deals poison damage.
actor.hp -= [actor.maxhp / 100, 1].max
valor = [actor.maxhp / 100, 1].max
# If XAS system is being used.
if $xrxs["xas"] == true
$game_player.battler.damage = valor
$game_player.battler.damage_pop = true
end
if $mogscript["mpstelen"] == true
$game_player.wref = true
end
if actor.hp == 0
$game_system.se_play($data_system.actor_collapse_se)
end
$game_screen.start_flash(Color.new(255,0,0,128), 4)
$game_temp.gameover = $game_party.all_dead?
end
end
end
end
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end
#===========================================================================
# ** End of Script
#===========================================================================
Instructions
Customization:
It's in the script, but here's a reference.
Content Hidden
Code:
#===========================================================================
# ** module MOG
#===========================================================================
module MOG
#===========================================================================
# Basic Customization
#===========================================================================
#----------------------------------------------------------------------
# Value of DASH bar duration, eg how long you can run for.
#----------------------------------------------------------------------
$max_dash = 200
#----------------------------------------------------------------------
# Value of DASH bar expense, eg how much energy it takes to run.
#----------------------------------------------------------------------
DASH_DOWN = 3
#----------------------------------------------------------------------
# Value of DASH bar recovery. Default: 1
#----------------------------------------------------------------------
DASH_UP = 1
#----------------------------------------------------------------------
# Running speed.
#----------------------------------------------------------------------
DASH_SPEED = 5
#----------------------------------------------------------------------
# Walking (normal) speed. 4 = default
#----------------------------------------------------------------------
NORMAL_SPEED = 4
#----------------------------------------------------------------------
# Input button for DASH.
#----------------------------------------------------------------------
BUTTON = Input::X
#----------------------------------------------------------------------
# WINDOWSKIN of the DASH WINDOW. To get rid of, just delete the name.
#----------------------------------------------------------------------
DASH_SKIN = "001-Blue01"
#----------------------------------------------------------------------
# Transparency of the WINDOWSKIN.
#----------------------------------------------------------------------
DASH_OPACITY = 200
#----------------------------------------------------------------------
# Horizontal position of the bar.
#----------------------------------------------------------------------
POS_X = 15
#----------------------------------------------------------------------
# Vertical position of the bar.
#----------------------------------------------------------------------
POS_Y = 5
#----------------------------------------------------------------------
# Sound made when the DASH BAR reaches 100% charge.
#----------------------------------------------------------------------
SE_PLAY = "032-Switch01"
#----------------------------------------------------------------------
# Percentage of DASH BAR that counts as 'low.'
# * Changes number color to LOW_COLOR, and the bar display.
#----------------------------------------------------------------------
LOW = 20
LOW_COLOR = Color.new(255,0,0,255)
#----------------------------------------------------------------------
# Name of the text on the bar. Default: Dash
#----------------------------------------------------------------------
DASH_NAME = "Dash"
DASH_BAR = RPG::Cache.picture("Dash_Bar") # Name of bar picture.
DASH_COLOR = Color.new(50,250,50,255) # Color of DASH_NAME
NUMBER_COLOR = Color.new(50,250,250,255) # Color of number %.
DASH_SHADOW = Color.new(0,0,0,255) # Color of DASH_NAME's shadow.
NUMBER_SHADOW = Color.new(0,0,0,255) # Color of the number's shadow.
NUMBER_BLINK = true # Allow randomization of number color at 100% charge?
#----------------------------------------------------------------------
# Names of the font on the bar.
#----------------------------------------------------------------------
FONT_NUMBER = "Georgia" # Font face of bar numbers
FONT_DASH = "Arial" # Font face of DASH_NAME
FONT_SIZE = 14 # Font Size
#----------------------------------------------------------------------
# Switch that deactivates the system.
#----------------------------------------------------------------------
SWIT = 4928
#----------------------------------------------------------------------
# Update speed of the window. The higher, the joltier, slower, and less laggy.
#----------------------------------------------------------------------
ADVMOVREF = 5
#===========================================================================
# Status Customization
#===========================================================================
# With these scripts are included several status effects that affect
# character movement OUTSIDE of battle.
#
# * HASTE - Increases dash bar recovery.
# * SLOW - Decreases the character speed from default.
# * CONFUSE - Invert your command directions.
# eg, going left makes your character go right.
# * DELAY - Dash bar will not recover.
# * POISON - Causes consecutive damage to the character while moving.
# * CRAZY - The character's movement is randomized.
# * REGEN - Recovers the health of the character while moving.
# * FAST - Increases the character speed from default.
#
# !! NOTE: Some conditions annul another. (Ex: Poison and Regen)
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
# Define the state ID for these conditions.
#---------------------------------------------------------------------------
# * Syntax:
# STATE = ID #
#---------------------------------------------------------------------------
HASTE = 18
SLOW = 19
CONFUSE = 6
DELAY = 11
POISON = 3
CRAZY = 20
REGEN = 21
FAST = 22
#---------------------------------------------------------------------------
# Define the duration of the states on the map.
#---------------------------------------------------------------------------
# * Syntax:
# STATE_TIME = DURATION. Default = 15 seconds
#---------------------------------------------------------------------------
HASTE_TIME = 15
SLOW_TIME = 15
CONFUSE_TIME = 15
DELAY_TIME = 15
POISON_TIME = 15
CRAZY_TIME = 15
REGEN_TIME = 15
FAST_TIME = 15
#---------------------------------------------------------------------------
# How much HASTE will multiply the recovery rate by. Default = 3
#---------------------------------------------------------------------------
HASTE_UP = 3
#---------------------------------------------------------------------------
# Speed of character decreased underneath SLOW. Default = 2
#---------------------------------------------------------------------------
SLOW_SPEED = 2
#---------------------------------------------------------------------------
# % of HP damaged while in poison condition.
#---------------------------------------------------------------------------
POISON_DAMAGE = 10
#---------------------------------------------------------------------------
# % of HP restored while in REGEN condition.
#---------------------------------------------------------------------------
REGEN_RESTORE = 3
#---------------------------------------------------------------------------
# How much FAST will increase the default speed.
#---------------------------------------------------------------------------
FAST_SPEED = 1
#===========================================================================
# Leveling System
#===========================================================================
#---------------------------------------------------------------------------
# Should speed be affected by level? If FALSE, ignore rest.
#---------------------------------------------------------------------------
LEVEL = true
#---------------------------------------------------------------------------
# Maximum speed.
#---------------------------------------------------------------------------
MAX_SPEED = 6
#---------------------------------------------------------------------------
# Parameter that will be used to calculate speed.
# 0 = Level
# 1 = HP
# 2 = MP
# 3 = STR
# 4 = DEX
# 5 = AGL
# 6 = INT
# 7 = Steps
# 8 = Variable
# 9.. = Normal
#---------------------------------------------------------------------------
LEVEL_SISTEMA = 0
#---------------------------------------------------------------------------
# If above is set to 8 (variable), input variable number.
#---------------------------------------------------------------------------
VARI = 5
#---------------------------------------------------------------------------
# Speed calculation method
# 0 = from first actor
# 1 = from party average (bugged atm)
#---------------------------------------------------------------------------
ACTOR = 0
#---------------------------------------------------------------------------
# Calculate the increment gained from parameter increase
#---------------------------------------------------------------------------
#
# * LEVEL_CALCULO = Dashing increase by parameter.
#
# * LEVEL_CALCULO2 = Increases MAX DASH VALUE so that, in effect, the
# character will have more points to spend when running,
# leading less of a decrease with the DASH BAR while
# running.
#
# * LEVEL CALCULO3 = Increases the recovery speed of the DASH BAR.
#
#---------------------------------------------------------------------------
# Dashing increment
# * Parameter divided by value below.
# - 99 leads to a + 1 dash speed at level 99. (99/99 = 1)
#---------------------------------------------------------------------------
LEVEL_CALCULO = 99
#---------------------------------------------------------------------------
# Max value of DASH BAR.
# * Parameter is multiplied by value below.
# - 1 leads to a 99 point increase in the dash bar. (99 * 1 = 99)
#---------------------------------------------------------------------------
LEVEL_CALCULO2 = 1
#---------------------------------------------------------------------------
# Recovery speed of the DASH BAR.
# * Parameter is divided by the value below
# - 1 leads to a 99% recovery at level 99. (99 / 1 = 99)
#---------------------------------------------------------------------------
LEVEL_CALCULO3 = 1
#===========================================================================
# End Customization
#===========================================================================
end
Content Hidden
Rename this to "Dash_Bar" and put it in your Pictures folder.
Content Hidden
Rename this to "001-Fighter01_dash" and put it in your Characters folder.
Rename this to "001-Fighter01_quarter" and put it in your Characters folder.
Credits to Paradog for these images. Site: http://2d6.parasite.jp/
Rename this to "001-Fighter01_quarter" and put it in your Characters folder.
Credits to Paradog for these images. Site: http://2d6.parasite.jp/
FAQ
Reserved.
Compatibility
Rewrites Game_Player Update and Game_Party check_map_slip_damage.
- Compatible with SDK2.4. (Optional)
- Add-on to the XAS system.
- Partially works with Fukuyama's 'Train Actor'; additional poses does not work. LINK
- Partially works with Ccoa's Caterpillar script; lead character can outrun the rest of the party. LINK
- Will probably not work with other 8-Way directional scripts.
Credits and Thanks
Moghunter, for making this script in the first place!
Sandgolem for the SDK log method.
Author's Notes
I couldn't find this script posted on Moghunter's site, so this version may not be the most up to date or recent. Translation is freely paraphrased and the code formatting is still albeit non-standard.
I know enough about RGSS to make small edits and corrections and you are free to request new features if you like, but the chances of them appearing are so infinitesimal that you're better off asking someone else. =)
I WILL, however, help you with the set up if you wish.
Terms and Conditions
As I did not make this script (merely translated and edited it, somewhat), please comply with Moghunter's terms, as translated by DerVVulfman and paraphrased.
Content Hidden
Quote:..
Terms of usage:..
- Atelier-RGSS scripts are allowed to be used in commercial or private projects as long as I (Moghunter) and this site are mentioned in the credits.
- Atelier-RGSS scripts are free to be posted in other sites or forums, as long as there is a mention of their origin.
- Linking directly to the scripts, demos, games/projects of Atelier-RGSS is forbidden.