#============================================================================== # Zenith RGSS16 雪原足跡表示 ver1.01 #   by 水夜 #  http://zenith.ifdef.jp/ #------------------------------------------------------------------------------ # 特定の地形タグのタイルに足跡を残します。 #============================================================================== #============================================================================== # □ カスタマイズポイント #============================================================================== module ZENITH16 # 足跡画像ファイル設定 # # {地形タグ => "ファイル名", 地形タグ => "ファイル名", ・・・} # # という風に、地形タグごとにコンマで区切って設定してください。 # FOOTPRINT_PICTURE = {1=>"footprint"} # 足跡が消えるまでの時間 DISPOSE_TIME = 200 # 足跡の数の上限 MAX_NUMBER = 40 end #============================================================================== # ■ Sprite_Footprint #============================================================================== class Sprite_Footprint < RPG::Sprite #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :count # カウント #-------------------------------------------------------------------------- # ● オブジェクト初期化 # viewport : ビューポート #-------------------------------------------------------------------------- def initialize(viewport, data) super(viewport) # データ取得 @data = data @count = data[3] # ビットマップ作成 self.bitmap = Bitmap.new(32, 32) src_bitmap = RPG::Cache.picture(ZENITH16::FOOTPRINT_PICTURE[data[4]]) case data[0] when 0 src_rect = Rect.new(0, 0, 32, 32) when 1 src_rect = Rect.new(0, 32, 32, 32) end self.bitmap.blt(0, 0, src_bitmap, src_rect) self.ox = 16 self.oy = 32 moveto(data[1], data[2]) update end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- def dispose if self.bitmap != nil self.bitmap.dispose end super end #-------------------------------------------------------------------------- # ● 指定位置に移動 # x : X 座標 # y : Y 座標 #-------------------------------------------------------------------------- def moveto(x, y) @x = x % $game_map.width @y = y % $game_map.height @real_x = @x * 128 @real_y = @y * 128 end #-------------------------------------------------------------------------- # ● 画面 X 座標の取得 #-------------------------------------------------------------------------- def screen_x # 実座標とマップの表示位置から画面座標を求める return (@real_x - $game_map.display_x + 3) / 4 + 16 end #-------------------------------------------------------------------------- # ● 画面 Y 座標の取得 #-------------------------------------------------------------------------- def screen_y # 実座標とマップの表示位置から画面座標を求める return (@real_y - $game_map.display_y + 3) / 4 + 32 end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super # スプライトの座標を設定 self.x = screen_x self.y = screen_y # カウントダウン if @count > 0 @data[3] -= 1 @count -= 1 else self.opacity -= 20 if self.opacity == 0 return true end end return false end end class Game_Character #-------------------------------------------------------------------------- # ● 下に移動 #-------------------------------------------------------------------------- alias zenith16_move_down move_down def move_down(turn_enabled = true) # 通行可能な場合 if passable?(@x, @y, 2) # 足跡作成 make_footprint end # 呼び戻す zenith16_move_down(turn_enabled) end #-------------------------------------------------------------------------- # ● 左に移動 #-------------------------------------------------------------------------- alias zenith16_move_left move_left def move_left(turn_enabled = true) # 通行可能な場合 if passable?(@x, @y, 4) # 足跡作成 make_footprint end # 呼び戻す zenith16_move_left(turn_enabled) end #-------------------------------------------------------------------------- # ● 右に移動 #-------------------------------------------------------------------------- alias zenith16_move_right move_right def move_right(turn_enabled = true) # 通行可能な場合 if passable?(@x, @y, 6) # 足跡作成 make_footprint end # 呼び戻す zenith16_move_right(turn_enabled) end #-------------------------------------------------------------------------- # ● 上に移動 #-------------------------------------------------------------------------- alias zenith16_move_up move_up def move_up(turn_enabled = true) # 通行可能な場合 if passable?(@x, @y, 8) # 足跡作成 make_footprint end # 呼び戻す zenith16_move_up(turn_enabled) end #-------------------------------------------------------------------------- # ● 左下に移動 #-------------------------------------------------------------------------- def move_lower_left # 向き固定でない場合 unless @direction_fix # 右向きだった場合は左を、上向きだった場合は下を向く @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction) end # 下→左、左→下 のどちらかのコースが通行可能な場合 if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4)) or (passable?(@x, @y, 4) and passable?(@x - 1, @y, 2)) # 足跡作成 make_footprint # 座標を更新 @x -= 1 @y += 1 # 歩数増加 increase_steps end end #-------------------------------------------------------------------------- # ● 右下に移動 #-------------------------------------------------------------------------- def move_lower_right # 向き固定でない場合 unless @direction_fix # 左向きだった場合は右を、上向きだった場合は下を向く @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction) end # 下→右、右→下 のどちらかのコースが通行可能な場合 if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6)) or (passable?(@x, @y, 6) and passable?(@x + 1, @y, 2)) # 足跡作成 make_footprint # 座標を更新 @x += 1 @y += 1 # 歩数増加 increase_steps end end #-------------------------------------------------------------------------- # ● 左上に移動 #-------------------------------------------------------------------------- def move_upper_left # 向き固定でない場合 unless @direction_fix # 右向きだった場合は左を、下向きだった場合は上を向く @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction) end # 上→左、左→上 のどちらかのコースが通行可能な場合 if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) or (passable?(@x, @y, 4) and passable?(@x - 1, @y, 8)) # 足跡作成 make_footprint # 座標を更新 @x -= 1 @y -= 1 # 歩数増加 increase_steps end end #-------------------------------------------------------------------------- # ● 右上に移動 #-------------------------------------------------------------------------- def move_upper_right # 向き固定でない場合 unless @direction_fix # 左向きだった場合は右を、下向きだった場合は上を向く @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction) end # 上→右、右→上 のどちらかのコースが通行可能な場合 if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) or (passable?(@x, @y, 6) and passable?(@x + 1, @y, 8)) # 足跡作成 make_footprint # 座標を更新 @x += 1 @y -= 1 # 歩数増加 increase_steps end end #-------------------------------------------------------------------------- # ● 足跡作成 #-------------------------------------------------------------------------- def make_footprint # 地形タグが違う または 足跡イベントでない場合 if !ZENITH16::FOOTPRINT_PICTURE.keys.include?(terrain_tag) or !footprint? return end if @direction == 4 or @direction == 6 type = 0 else type = 1 end data = [type, @x, @y, ZENITH16::DISPOSE_TIME, terrain_tag] # 足跡データを追加 $game_map.footprints.push(data) end #-------------------------------------------------------------------------- # ● 足跡判定 #-------------------------------------------------------------------------- def footprint? if self.is_a?(Game_Event) and !self.event.name.include?("[足跡]") return false end return true end end class Game_Map #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :footprints # 足跡データ #-------------------------------------------------------------------------- # ● セットアップ #-------------------------------------------------------------------------- alias zenith16_setup setup def setup(map_id) # 呼び戻す zenith16_setup(map_id) # 足跡データ @footprints = [] end end class Game_Event < Game_Character #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :event # イベント end class Spriteset_Map #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :foot_sprites # 足跡スプライト #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias zenith16_initialize initialize def initialize # 足跡スプライト格納用配列作成 @foot_sprites = [] # 呼び戻す zenith16_initialize end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- alias zenith16_dispose dispose def dispose # 呼び戻す zenith16_dispose # 足跡スプライトを解放 for sprite in @foot_sprites sprite.dispose end end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- alias zenith16_update update def update for data in $game_map.footprints i = $game_map.footprints.index(data) # 足跡スプライト作成 if @foot_sprites[i] == nil @foot_sprites[i] = Sprite_Footprint.new(@viewport1, data) end # 足跡スプライト更新 if @foot_sprites[i].update # 足跡スプライト解放 @foot_sprites[i].dispose @foot_sprites.delete(@foot_sprites[i]) # 足跡データも削除 $game_map.footprints.delete(data) end end # 最大数を超えた場合、先頭の足跡の残りカウントを 0 に if @foot_sprites.size >= ZENITH16::MAX_NUMBER @foot_sprites[0].count = 0 end # 呼び戻す zenith16_update end end class Scene_Map #-------------------------------------------------------------------------- # ● 足跡消去 #-------------------------------------------------------------------------- def dispose_footprints # 全ての足跡の残りカウントを 0 に for sprite in @spriteset.foot_sprites sprite.count = 0 end end end