#=============================================================================== # Simple 8-Directional Movement # By Jet10985 (Jet) #=============================================================================== # This script allows the player to move diagonally if they press 2 directional # buttons are the same time. # This script has: 2 customization options. #=============================================================================== # Overwritten Methods: # None #------------------------------------------------------------------------------- # Aliased methods: # Game_Player: increase_steps # Sprite_Character: update_src_rect #=============================================================================== module Jet8Dir # Do you want the player have use a specific sprite while moving diagonally? USE_8DIR_SPRITES = true # These are the sprites used depending on what actor is the first in the party # if you allowed the use diagonal sprite. The config follows this format: # actor_index => ["sprite name", graphic_index], # You must include a , after every config item if there is another item # afterwards. DIAG_CHAR_SPRITES = { 1 => ["$DiagSprite (1)", 0], 2 => ["$DiagSprite (2)", 0] } end #=============================================================================== # DON'T EDIT FURTHER UNLESS YOU KNOW WHAT TO DO. #=============================================================================== class Game_Player def move_by_input return unless movable? return if $game_map.interpreter.running? case Input.dir8 when 1; move_lower_left when 2; move_down when 3; move_lower_right when 4; move_left when 6; move_right when 7; move_upper_left when 8; move_up when 9; move_upper_right end end alias jet6742_increase_steps increase_steps unless $@ def increase_steps jet6742_increase_steps update_diag_sprite end def move_lower_left @direction = 1 super if @move_failed move_down move_left unless $game_map.interpreter.running? end end def move_lower_right @direction = 3 super if @move_failed move_down move_right unless $game_map.interpreter.running? end end def move_upper_left @direction = 7 super if @move_failed move_up move_left unless $game_map.interpreter.running? end end def move_upper_right @direction = 9 super if @move_failed move_up move_right unless $game_map.interpreter.running? end end def update_diag_sprite return unless Jet8Dir::USE_8DIR_SPRITES if [1, 3, 7, 9].include?(@direction) begin set_graphic(Jet8Dir::DIAG_CHAR_SPRITES[$game_party.members[0].id][0], Jet8Dir::DIAG_CHAR_SPRITES[$game_party.members[0].id][1]) unless Jet8Dir::DIAG_CHAR_SPRITES[$game_party.members[0].id][0] == @character_name and Jet8Dir::DIAG_CHAR_SPRITES[$game_party.members[0].id][1] == @character_index rescue end else set_graphic($game_party.members[0].character_name, $game_party.members[0].character_index) unless $game_party.members[0].character_name == @character_name and $game_party.members[0].character_index == @character_index end end end class Sprite_Character alias jet5734_update_src_rect update_src_rect unless $@ def update_src_rect if @character.direction % 2 == 0 jet5734_update_src_rect else case @character.direction when 1 dir = 2 when 7 dir = 4 when 3 dir = 6 when 9 dir = 8 end if @tile_id == 0 && @character.is_a?(Game_Player) index = @character.character_index pattern = @character.pattern < 3 ? @character.pattern : 1 sx = (index % 4 * 3 + pattern) * @cw sy = (index / 4 * 4 + (dir - 2) / 2) * @ch self.src_rect.set(sx, sy, @cw, @ch) end end end end