Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================#
- # Footsteps for v17 #
- # by Marin #
- #==============================================================================#
- # If an event walks on a tile with terrain tag 3 (Sand), it will produce #
- # visual footprints. Works with Following Pokémon. #
- #==============================================================================#
- # Please give credit when using this. #
- #==============================================================================#
- class Sprite_Character
- # This is the amount the opacity is lowered per frame. It needs to go 256 -> 0,
- # which means setting this to 4 would make each step pair last 64 frames (~1.5s)
- FADE_OUT_SPEED = 4
- # A configurable X/Y offset for the step sprites, in case they don't align
- # nicely with the player's graphic.
- WALK_X_OFFSET = -16
- WALK_Y_OFFSET = 0
- # A configurable X/Y offset for bike print sprites, in case they don't align
- # nicely with the player's graphic.
- BIKE_X_OFFSET = -16
- BIKE_Y_OFFSET = 0
- # If true, both the player AND the follower will create footprints.
- # If false, only the follower will create footprints.
- DUPLICATE_FOOSTEPS_WITH_FOLLOWER = false
- CHARNAME_MAY_NOT_INCLUDE = [
- "NoFootprint",
- ".noprint",
- ".nostep",
- ".nofootprint",
- ".nofootstep"
- ]
- alias footsteps_initialize initialize
- def initialize(*args)
- footsteps_initialize(*args)
- @steps = []
- end
- alias footsteps_update update
- def update
- footsteps_update
- @old_x ||= @character.x
- @old_y ||= @character.y
- if (@character.x != @old_x || @character.y != @old_y) && !["", "nil"].include?(@character.character_name) &&
- (!@character.respond_to?(:name) || !CHARNAME_MAY_NOT_INCLUDE.include?(@character.name))
- if @character == $game_player && $PokemonTemp.dependentEvents &&
- $PokemonTemp.dependentEvents.respond_to?(:realEvents) &&
- $PokemonTemp.dependentEvents.realEvents.select { |e| !["", "nil"].include?(e.character_name) }.size > 0 &&
- !DUPLICATE_FOOSTEPS_WITH_FOLLOWER
- make_steps = false
- else
- tilesetid = @character.map.instance_eval { @map.tileset_id }
- make_steps = [2,1,0].any? do |e|
- tile_id = @character.map.data[@old_x, @old_y, e]
- next $data_tilesets[tilesetid].terrain_tags[tile_id] == PBTerrain::Sand
- end
- end
- if make_steps
- fstep = Sprite.new(self.viewport)
- fstep.z = 0
- dirs = [nil,"DownLeft","Down","DownRight","Left","Still","Right","UpLeft",
- "Up", "UpRight"]
- if @character == $game_player && $PokemonGlobal.bicycle
- fstep.bmp("Graphics/Characters/steps#{dirs[@character.direction]}Bike")
- else
- fstep.bmp("Graphics/Characters/steps#{dirs[@character.direction]}")
- end
- @steps ||= []
- if @character == $game_player && $PokemonGlobal.bicycle
- x = BIKE_X_OFFSET
- y = BIKE_Y_OFFSET
- else
- x = WALK_X_OFFSET
- y = WALK_Y_OFFSET
- end
- @steps << [fstep, @old_x + x / Game_Map::TILEWIDTH.to_f, @old_y + y / Game_Map::TILEHEIGHT.to_f, self.src_rect.width / 2]
- end
- end
- @old_x = @character.x
- @old_y = @character.y
- if @steps
- for i in 0...@steps.size
- next unless @steps[i]
- sprite, x, y, ox = @steps[i]
- sprite.x = -@character.map.display_x / Game_Map::XSUBPIXEL + (x + 1) * Game_Map::TILEWIDTH
- sprite.y = -@character.map.display_y / Game_Map::YSUBPIXEL + (y + 1) * Game_Map::TILEHEIGHT
- sprite.x -= ox
- sprite.y -= Game_Map::TILEHEIGHT
- sprite.opacity -= FADE_OUT_SPEED
- if sprite.opacity <= 0
- sprite.dispose
- @steps[i] = nil
- end
- end
- @steps.compact!
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement