Improved & Special Move Commands Version 1.0
by Woratana
Release Date: 20/03/2008
Introduction This script will edit old move commands and add new move commands.
It script will be good for minigame, ABS (for enemy's move route), or any system to do with move thing~
Features Version 1.0 - Here's the edited and new commands list~
?=====?=====?=====?=====?=====?=====?=====?=====?=====? + COMMANDS LIST + ?=====?=====?=====?=====?=====?=====?=====?=====?=====? ################################ ? IMPROVED MOVE COMMANDS ? ? SAFE JUMP: Don't Jump if its destination is OUT OF THE SCREEN (or) NOT PASSABLE. (Old jump will not check before jump) ? IMPROVED RANDOM MOVE Find the movable direction before move. (Old random move will just skip to move in that frame, if its destination is not passable.) ? IMPROVED COLLIDE_WITH_CHARACTERS CHECK 'Same as Characters' events are able to walk on other 'Below Characters' events. ? Note: If you don't want one of this improved command, just delete its part. (I put all of their command name above their script part) ################################ ################################ ? SPECIAL(NEW) MOVE COMMANDS ? ++[HOW TO USE]++ ? Open 'Move Route' window, (or event command 'Set Move Route') Click 'Script...' and type the move command you want... ? MOVE TOWARD POSITION X/Y move_toward_pos(x,y) ? MOVE AWAY FROM POSITION X/Y move_away_from_pos(x,y) ? MOVE TOWARD EVENT ID move_toward_event(id) ? MOVE AWAY FROM EVENT ID move_away_from_event(id) ? TURN TOWARD POSITION X/Y turn_toward_pos(x,y) ? TURN AWAY FROM POSITION X/Y turn_away_from_pos(x,y) ? TURN TOWARD EVENT ID turn_toward_event(id) ? TURN AWAY FROM EVENT ID turn_away_from_event(id) ################################
Script Place it above main
Spoiler for Script :
#=============================================================== # ? [VX] ? Improved & Special Move Commands ? ? #-------------------------------------------------------------- # ? by Woratana [woratana@hotmail.com] # ? Released on: 20/03/2008 # ? Version: 1.0 #-------------------------------------------------------------- =begin ?=====?=====?=====?=====?=====?=====?=====?=====?=====? + COMMANDS LIST + ?=====?=====?=====?=====?=====?=====?=====?=====?=====? ################################ ? IMPROVED MOVE COMMANDS ? ? SAFE JUMP: Don't Jump if its destination is OUT OF THE SCREEN (or) NOT PASSABLE. (Old jump will not check before jump) ? IMPROVED RANDOM MOVE Find the movable direction before move. (Old random move will just skip to move in that frame, if its destination is not passable.) ? IMPROVED COLLIDE_WITH_CHARACTERS CHECK 'Same as Characters' events are able to walk on other 'Below Characters' events. ? Note: If you don't want one of this improved command, just delete its part. (I put all of their command name above their script part) ################################ ################################ ? SPECIAL(NEW) MOVE COMMANDS ? ++[HOW TO USE]++ ? Open 'Move Route' window, (or event command 'Set Move Route') Click 'Script...' and type the move command you want... ? MOVE TOWARD POSITION X/Y move_toward_pos(x,y) ? MOVE AWAY FROM POSITION X/Y move_away_from_pos(x,y) ? MOVE TOWARD EVENT ID move_toward_event(id) ? MOVE AWAY FROM EVENT ID move_away_from_event(id) ? TURN TOWARD POSITION X/Y turn_toward_pos(x,y) ? TURN AWAY FROM POSITION X/Y turn_away_from_pos(x,y) ? TURN TOWARD EVENT ID turn_toward_event(id) ? TURN AWAY FROM EVENT ID turn_away_from_event(id) ################################ =end class Game_Character ################################################################## # IMPROVED MOVE COMMANDS ################################################################## #------------------------------------------------------------- # SAFE JUMP #------------------------------------------------------------- def jump(x_plus, y_plus) if x_plus.abs > y_plus.abs # ?????????? x_plus < 0 ? turn_left : turn_right elsif x_plus.abs > y_plus.abs # ?????????? y_plus < 0 ? turn_up : turn_down end new_x = @x + x_plus new_y = @y + y_plus if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y) @x += x_plus @y += y_plus distance = Math.sqrt(x_plus * x_plus + y_plus * y_plus).round @jump_peak = 10 + distance - @move_speed @jump_count = @jump_peak * 2 @stop_count = 0 straighten end end #------------------------------------------------------------- # IMPROVED RANDOM MOVE #------------------------------------------------------------- def move_random safe = false checked = [] while safe == false break if checked.include?(0) and checked.include?(1) and checked.include?(2) and checked.include?(3) case rand(4) when 0; return if checked.include?(0); checked.push 0 if passable?(@x, @y + 1) safe = true; move_down(false) end when 1; return if checked.include?(1); checked.push 1 if passable?(@x - 1, @y) safe = true; move_left(false) end when 2; return if checked.include?(2); checked.push 2 if passable?(@x + 1, @y) safe = true; move_right(false) end when 3; return if checked.include?(3); checked.push 3 if passable?(@x - 1, @y) safe = true; move_up(false) end end end end #---------------------------------------------------------------------- # IMPROVED COLLIDE_WITH_CHARACTERS CHECK #---------------------------------------------------------------------- def collide_with_characters?(x, y) for event in $game_map.events_xy(x, y) # Matches event position unless event.through # Passage OFF? return true if event.priority_type == 1 # Target is normal char end end if @priority_type == 1 # Self is normal char return true if $game_player.pos_nt?(x, y) # Matches player position return true if $game_map.boat.pos_nt?(x, y) # Matches boat position return true if $game_map.ship.pos_nt?(x, y) # Matches ship position end return false end ################################################################## # SPECIAL(NEW) MOVE COMMANDS ################################################################## #-------------------------------------------------------------------------- # * Move toward Position #-------------------------------------------------------------------------- def move_toward_pos(x,y) sx = distance_x_from_pos(x) sy = distance_y_from_pos(y) if sx != 0 or sy != 0 if sx.abs > sy.abs # Horizontal distance is longer sx > 0 ? move_left : move_right # Prioritize left-right if @move_failed and sy != 0 sy > 0 ? move_up : move_down end else # Vertical distance is longer sy > 0 ? move_up : move_down # Prioritize up-down if @move_failed and sx != 0 sx > 0 ? move_left : move_right end end end end #-------------------------------------------------------------------------- # * Move away from Position #-------------------------------------------------------------------------- def move_away_from_pos(x,y) sx = distance_x_from_pos(x) sy = distance_y_from_pos(y) if sx != 0 or sy != 0 if sx.abs > sy.abs # Horizontal distance is longer sx > 0 ? move_right : move_left # Prioritize left-right if @move_failed and sy != 0 sy > 0 ? move_down : move_up end else # Vertical distance is longer sy > 0 ? move_down : move_up # Prioritize up-down if @move_failed and sx != 0 sx > 0 ? move_right : move_left end end end end #-------------------------------------------------------------------------- # * Move toward Event #-------------------------------------------------------------------------- def move_toward_event(id) move_toward_pos($game_map.events[id].x,$game_map.events[id].y) end #-------------------------------------------------------------------------- # * Move away from Event #-------------------------------------------------------------------------- def move_away_from_event(id) move_away_from_pos($game_map.events[id].x,$game_map.events[id].y) end #-------------------------------------------------------------------------- # * Turn toward Position #-------------------------------------------------------------------------- def turn_toward_pos(x,y) sx = distance_x_from_pos(x) sy = distance_y_from_pos(y) if sx.abs > sy.abs # Horizontal distance is longer sx > 0 ? turn_left : turn_right elsif sx.abs < sy.abs # Vertical distance is longer sy > 0 ? turn_up : turn_down end end #-------------------------------------------------------------------------- # * Turn away from Position #-------------------------------------------------------------------------- def turn_away_from_pos(x,y) sx = distance_x_from_pos(x) sy = distance_y_from_pos(y) if sx.abs > sy.abs # Horizontal distance is longer sx > 0 ? turn_right : turn_left elsif sx.abs < sy.abs # Vertical distance is longer sy > 0 ? turn_down : turn_up end end #-------------------------------------------------------------------------- # * Turn toward Event #-------------------------------------------------------------------------- def turn_toward_event(id) turn_toward_pos($game_map.events[id].x,$game_map.events[id].y) end #-------------------------------------------------------------------------- # * Turn away from Event #-------------------------------------------------------------------------- def turn_away_from_event(id) turn_away_from_pos($game_map.events[id].x,$game_map.events[id].y) end #-------------------------------------------------------------------------- # * Calculate X Distance From Event #-------------------------------------------------------------------------- def distance_x_from_pos(x) sx = @x - x if $game_map.loop_horizontal? # When looping horizontally if sx.abs > $game_map.width / 2 # Larger than half the map width? sx -= $game_map.width # Subtract map width end end return sx end #-------------------------------------------------------------------------- # * Calculate Y Distance From Event #-------------------------------------------------------------------------- def distance_y_from_pos(y) sy = @y - y if $game_map.loop_vertical? # When looping vertically if sy.abs > $game_map.height / 2 # Larger than half the map height? sy -= $game_map.height # Subtract map height end end return sy end end
Instruction You just need to place the script above main, for edited old commands.
For special/new commands,
? Open 'Move Route' window, (or event command 'Set Move Route') Click 'Script...' and type the move command you want...
Author's Notes Free for use in your non-commercial work if credit included. If your project is commercial, please contact me.
Please do not redistribute this script without permission. If you want to post it on any forum, please link to this topic.