$VIPArcherScript ||= {};$VIPArcherScript[:dir8_move] = 20161106
module VIPArcher end
module VIPArcher::Dir_8
OFF_SW = 0
STEP_ANIME_SW = 1
WAIT_TIME = 150
ANIME_TIME = 25
GAP_TIME = 90
end
class Game_Player
include VIPArcher::Dir_8
attr_reader :static_anime
def move_by_input
return if !movable? || $game_map.interpreter.running?
if [1, 3, 7, 9].include?(Input.dir8)
case Input.dir8
when 1 then move_diagonal(4, 2)
when 3 then move_diagonal(6, 2)
when 7 then move_diagonal(4, 8)
when 9 then move_diagonal(6, 8)
end; return if @move_succeed
end unless $game_switches[OFF_SW]
move_straight(Input.dir4) if Input.dir4 > 0
end
def is_dash?
return dash? && @stop_count.zero?
end
alias dir8_update update
def update
dir8_update
return if $game_switches[STEP_ANIME_SW]
@step_anime = case @stop_count
when WAIT_TIME...WAIT_TIME + ANIME_TIME then @static_anime = true
when WAIT_TIME + ANIME_TIME then @stop_count = WAIT_TIME - GAP_TIME
@static_anime = false else @static_anime = false end
end
end
class Game_Event
def is_dash?
return !@locked && @move_speed >= 5 && @stop_count.zero?
end
end
class Game_CharacterBase
alias dir8_move_diagonal move_diagonal
def move_diagonal(horz, vert)
return @move_succeed = false if !passable?(@x, @y, horz) && !passable?(@x, @y, vert)
return move_straight(horz) if passable?(@x, @y, horz) && !passable?(@x, @y, vert)
return move_straight(vert) if passable?(@x, @y, vert) && !passable?(@x, @y, horz)
dir8_move_diagonal(horz, vert)
case [horz,vert]
when [4,2] then set_direction(1)
when [4,8] then set_direction(3)
when [6,2] then set_direction(7)
when [6,8] then set_direction(9)
end
end
end
class Sprite_Character < Sprite_Base
def is_dir8?
return @character_name =~ /^\@.+/
end
def update_src_rect
return if @tile_id != 0
index = @character.character_index
pattern = @character.pattern < 3 ? @character.pattern : 1
index = if @character.is_dash? then 1
elsif @character.instance_of?(Game_Player) && $game_player.static_anime
2 else 0 end if is_dir8?
sx = (index % 4 * 3 + pattern) * @cw
unless @character.direction.even?
index += 4 if is_dir8?
sy = (index / 4 * 4 + (@character.direction + 1) / 3) * @ch
else
sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
end
self.src_rect.set(sx, sy, @cw, @ch)
end
end