#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_ #_/ ◆ Adjustable Speed & 8-Way Directional Movement - KGC_Dash_8DirMove ◆ VX ◆ #_/ ◇ Last Update: 2008/11/16 ◇ #_/ ◆ Translation and Updates by by Mr. Anonymous ◆ #_/ ◆ http://ytomy.sakura.ne.jp/ ◆ #_/----------------------------------------------------------------------------- #_/ This script adds 8-way-directional movement and speed adjustment settings. #_/============================================================================= #_/ Install: Insert below KGC_TilesetExtension. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_ #==============================================================================# # ★ Customization ★ # #==============================================================================# module KGC module Dash_8DirMove # ◆ 8-Way Directional Movement ◆ # true = Enables the character to move in diagonal directions. # false = Disable diagonal movement, restricting the player to the default # movement system of up, down, left, and right. ENABLE_8DIR = true # ◆ 8-Way Directional Animation ◆ # I believe this toggle is to allow the system to use 8-way directional # animations for characters who have the additional spritesheets to do so. # By default an image with the additional frames should be suffixed with an # number sign/hash (#) unless otherwise specified below in SLANT_SUFFIX. # For example, let's say you have a sheet of Ralph with diagonal movements. # The original RTP image would be named $Ralph, while the diagonal sheet would # be named $Ralph# under this convention. ENABLE_8DIR_ANIMATION = false # ◆ Walk Speed ◆ # Allows you to change the default rate of speed the actor walks. # A DEFAULT_WALK_SPEED of 4 is the default RMVX walk speed. DEFAULT_WALK_SPEED = 4 # ◆ Dash Speed ◆ # Allows you to change the default rate of speed the actor dashes. # A DASH_SPEED_RATE of 3 is the default RMVX dash speed. DASH_SPEED_RATE = 3 end end #------------------------------------------------------------------------------# $imported = {} if $imported == nil $imported["Dash_8DirMove"] = true module KGC::Dash_8DirMove # Image Suffix SLANT_SUFFIX = "#" end #============================================================================== # □ KGC::Commands #============================================================================== module KGC module Commands module_function #-------------------------------------------------------------------------- # ○ Reset Walk Speed #-------------------------------------------------------------------------- def reset_walk_speed $game_player.reset_move_speed end #-------------------------------------------------------------------------- # ○ Set Walk Speed #-------------------------------------------------------------------------- def set_walk_speed(value) $game_system.temp_walk_speed = value end #-------------------------------------------------------------------------- # ○ Set Dash Speed #-------------------------------------------------------------------------- def set_dash_speed(value) $game_system.temp_dash_speed = value end end end class Game_Interpreter include KGC::Commands end #============================================================================== # □ Game_System # * Added by Mr. Anonymous 5/29/08 #============================================================================== class Game_System #-------------------------------------------------------------------------- # ● Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :temp_dash_speed # Temporary Dash Speed attr_accessor :temp_walk_speed # Temporary Walk Speed #-------------------------------------------------------------------------- # ● Initialize #-------------------------------------------------------------------------- alias initialize_KGC_Dash_8DirMove initialize def initialize initialize_KGC_Dash_8DirMove @temp_dash_speed = nil @temp_walk_speed = nil end end #============================================================================== # ■ Game_Party #============================================================================== class Game_Party < Game_Unit #-------------------------------------------------------------------------- # ○ Decrease Steps #-------------------------------------------------------------------------- def decrease_steps @steps -= 1 end end #============================================================================== # ■ Game_Character #============================================================================== class Game_Character #-------------------------------------------------------------------------- # ○ Direction (8-Way Movement) #-------------------------------------------------------------------------- def direction_8dir return @direction end #-------------------------------------------------------------------------- # ● Set Direction # direction : Directions #-------------------------------------------------------------------------- alias set_direction_KGC_Dash_8DirMove set_direction def set_direction(direction) last_dir = @direction set_direction_KGC_Dash_8DirMove(direction) if !@direction_fix && direction != 0 @direction_8dir = direction end end #-------------------------------------------------------------------------- # ● 左下に移動 #-------------------------------------------------------------------------- alias move_lower_left_KGC_Dash_8DirMove move_lower_left def move_lower_left move_lower_left_KGC_Dash_8DirMove @direction_8dir = 1 unless @direction_fix end #-------------------------------------------------------------------------- # ● 右下に移動 #-------------------------------------------------------------------------- alias move_lower_right_KGC_Dash_8DirMove move_lower_right def move_lower_right move_lower_right_KGC_Dash_8DirMove @direction_8dir = 3 unless @direction_fix end #-------------------------------------------------------------------------- # ● 左上に移動 #-------------------------------------------------------------------------- alias move_upper_left_KGC_Dash_8DirMove move_upper_left def move_upper_left move_upper_left_KGC_Dash_8DirMove @direction_8dir = 7 unless @direction_fix end #-------------------------------------------------------------------------- # ● 右上に移動 #-------------------------------------------------------------------------- alias move_upper_right_KGC_Dash_8DirMove move_upper_right def move_upper_right move_upper_right_KGC_Dash_8DirMove @direction_8dir = 9 unless @direction_fix end end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # ■ Game_Player #============================================================================== class Game_Player < Game_Character #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias initialize_KGC_Dash_8DirMove initialize def initialize initialize_KGC_Dash_8DirMove reset_move_speed end #-------------------------------------------------------------------------- # ○ 向き (8方向用) #-------------------------------------------------------------------------- def direction_8dir @direction_8dir = @direction if @direction_8dir == nil return @direction_8dir end #-------------------------------------------------------------------------- # ○ 移動速度のリセット #-------------------------------------------------------------------------- def reset_move_speed @move_speed = KGC::Dash_8DirMove::DEFAULT_WALK_SPEED end if KGC::Dash_8DirMove::ENABLE_8DIR #-------------------------------------------------------------------------- # ● 方向ボタン入力による移動処理 #-------------------------------------------------------------------------- def move_by_input return unless movable? return if $game_map.interpreter.running? # 予約済みの追加移動を実行 if @reserved_move != nil case @reserved_move when :down move_down if passable_l?(2) when :left move_left if passable_l?(4) when :right move_right if passable_l?(6) when :up move_up if passable_l?(8) end @reserved_move = nil return end last_steps = $game_party.steps case Input.dir8 when 1 if !passable_l?(2) && passable_l?(4) # 左だけ move_left @reserved_move = :down elsif passable_l?(2) && !passable_l?(4) # 下だけ move_down @reserved_move = :left elsif passable_l?(2) # 下に優先的に移動 move_down move_left end @direction = 2 when 2 move_down when 3 if !passable_l?(2) && passable_l?(6) # 右だけ move_right @reserved_move = :down elsif passable_l?(2) && !passable_l?(6) # 下だけ move_down @reserved_move = :right elsif passable_l?(2) # 下に優先的に移動 move_down move_right end @direction = 6 when 4 move_left when 6 move_right when 7 if !passable_l?(8) && passable_l?(4) # 左だけ move_left @reserved_move = :up elsif passable_l?(8) && !passable_l?(4) # 上だけ move_up @reserved_move = :left elsif passable_l?(8) # 上に優先的に移動 move_up move_left end @direction = 4 when 8 move_up when 9 if !passable_l?(8) && passable_l?(6) # 右だけ move_right @reserved_move = :up elsif passable_l?(8) && !passable_l?(6) # 上だけ move_up @reserved_move = :right elsif passable_l?(8) # 上に優先的に移動 move_up move_right end @direction = 8 else return end @direction_8dir = Input.dir8 # 2歩進んでいたら1歩戻す if $game_party.steps - last_steps == 2 $game_party.decrease_steps end end #-------------------------------------------------------------------------- # ○ 簡易移動可否判定 # d : 移動方向 #-------------------------------------------------------------------------- def passable_l?(d) if $imported["TilesetExtension"] return passable?(@x, @y, d) else case d when 1 return passable?(@x-1, @y+1) when 2 return passable?(@x, @y+1) when 3 return passable?(@x+1, @y+1) when 4 return passable?(@x-1, @y) when 6 return passable?(@x+1, @y) when 7 return passable?(@x-1, @y-1) when 8 return passable?(@x, @y-1) when 9 return passable?(@x+1, @y-1) end end return false end end # ENABLE_8DIR #-------------------------------------------------------------------------- # ● 移動時の更新 #-------------------------------------------------------------------------- def update_move distance = 2 ** @move_speed # 移動速度から移動距離に変換 if dash? # ダッシュ状態なら速度変更 distance *= KGC::Dash_8DirMove::DASH_SPEED_RATE #-------------------------------------------------------------------- # ● Process Temp Walk/Dash Speed # * Added by Mr. Anonymous 5/29/08 #-------------------------------------------------------------------- if $game_system.temp_dash_speed == nil @move_speed = KGC::Dash_8DirMove::DASH_SPEED_RATE else @move_speed = $game_system.temp_dash_speed end else if $game_system.temp_walk_speed == nil @move_speed = KGC::Dash_8DirMove::DEFAULT_WALK_SPEED else @move_speed = $game_system.temp_walk_speed end #--- End 5/29/08 Update end distance = Integer(distance) @real_x = [@real_x - distance, @x * 256].max if @x * 256 < @real_x @real_x = [@real_x + distance, @x * 256].min if @x * 256 > @real_x @real_y = [@real_y - distance, @y * 256].max if @y * 256 < @real_y @real_y = [@real_y + distance, @y * 256].min if @y * 256 > @real_y update_bush_depth unless moving? if @walk_anime @anime_count += 1.5 elsif @step_anime @anime_count += 1 end end end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # ■ Sprite_Character #============================================================================== if KGC::Dash_8DirMove::ENABLE_8DIR_ANIMATION class Sprite_Character < Sprite_Base #-------------------------------------------------------------------------- # ○ 定数 #-------------------------------------------------------------------------- SLANT_ANIME_TABLE = { 1=>2, 3=>6, 7=>4, 9=>8 } #-------------------------------------------------------------------------- # ● 転送元ビットマップの更新 #-------------------------------------------------------------------------- alias update_bitmap_KGC_Dash_8DirMove update_bitmap def update_bitmap name_changed = (@character_name != @character.character_name) update_bitmap_KGC_Dash_8DirMove if @tile_id > 0 # タイル画像使用 @enable_slant = false return end return unless name_changed # 画像名変化なし # 斜め移動アニメ有効判定 @enable_slant = true begin @character_name_slant = @character_name + KGC::Dash_8DirMove::SLANT_SUFFIX Cache.character(@character_name_slant) rescue @enable_slant = false end end #-------------------------------------------------------------------------- # ● 転送元矩形の更新 #-------------------------------------------------------------------------- alias update_src_rect_KGC_Dash_8DirMove update_src_rect def update_src_rect return if @tile_id > 0 # タイル画像 if @enable_slant update_src_rect_for_slant else update_src_rect_KGC_Dash_8DirMove end end #-------------------------------------------------------------------------- # ○ 斜め移動用転送元矩形の更新 #-------------------------------------------------------------------------- def update_src_rect_for_slant index = @character.character_index pattern = @character.pattern < 3 ? @character.pattern : 1 sx = (index % 4 * 3 + pattern) * @cw dir = @character.direction_8dir case dir % 2 when 0 # 上下左右 if @last_slant self.bitmap = Cache.character(@character_name) @last_slant = false end else # 斜め unless @last_slant self.bitmap = Cache.character(@character_name_slant) @last_slant = true end # 1, 3, 7, 9 を 2, 6, 4, 8 に変換 dir = SLANT_ANIME_TABLE[dir] end sy = (index / 4 * 4 + (dir - 2) / 2) * @ch self.src_rect.set(sx, sy, @cw, @ch) end end end # ENABLE_8DIR_ANIMATION