From c0cf7da7bb3a32bc31ed8244b4050fb50d91f90d Mon Sep 17 00:00:00 2001 From: chardub Date: Sun, 27 Apr 2025 00:14:10 -0400 Subject: [PATCH] Overworld Outfits --- .../008_AnimatedBitmap.rb | 4 + .../Gameplay/Terrain/PIF_TerrainTags.rb | 121 ++++++++++++++++++ .../Graphics/Tilemaps/PIF_TilemapRenderer.rb | 13 ++ .../Overrides/Outfits_Sprite_Character.rb | 90 +++++++++++++ .../Overrides/Outfits_Sprite_Player.rb | 4 + .../Overrides/Outfits_Sprite_SurfBase.rb | 35 +++++ .../Sprites/013_Sprite_Player_Offsets.rb | 35 +++++ PBS/metadata.txt | 24 ++-- 8 files changed, 314 insertions(+), 12 deletions(-) create mode 100644 Data/Scripts/998_InfiniteFusion/Gameplay/Terrain/PIF_TerrainTags.rb create mode 100644 Data/Scripts/998_InfiniteFusion/Outfits/Overrides/Outfits_Sprite_SurfBase.rb create mode 100644 Data/Scripts/998_InfiniteFusion/Outfits/Sprites/013_Sprite_Player_Offsets.rb diff --git a/Data/Scripts/007_Objects and windows/008_AnimatedBitmap.rb b/Data/Scripts/007_Objects and windows/008_AnimatedBitmap.rb index 9cdf1b363..0bf1bf98b 100644 --- a/Data/Scripts/007_Objects and windows/008_AnimatedBitmap.rb +++ b/Data/Scripts/007_Objects and windows/008_AnimatedBitmap.rb @@ -5,6 +5,8 @@ class AnimatedBitmap def initialize(file, hue = 0) raise "Filename is nil (missing graphic)." if file.nil? path = file + @path = path + filename = "" if file.last != "/" # Isn't just a directory split_file = file.split(/[\\\/]/) @@ -31,6 +33,8 @@ class AnimatedBitmap def dispose; @bitmap.dispose; end def deanimate; @bitmap.deanimate; end def copy; @bitmap.copy; end + + def path; @path end end #=============================================================================== diff --git a/Data/Scripts/998_InfiniteFusion/Gameplay/Terrain/PIF_TerrainTags.rb b/Data/Scripts/998_InfiniteFusion/Gameplay/Terrain/PIF_TerrainTags.rb new file mode 100644 index 000000000..b19079490 --- /dev/null +++ b/Data/Scripts/998_InfiniteFusion/Gameplay/Terrain/PIF_TerrainTags.rb @@ -0,0 +1,121 @@ +# frozen_string_literal: true + +module GameData + class TerrainTag + attr_reader :flowerRed + attr_reader :flowerPink + attr_reader :flowerYellow + attr_reader :flowerBlue + attr_reader :flower + attr_reader :trashcan + attr_reader :sharpedoObstacle + + alias original_TerrainTag_init initialize + def initialize(hash) + original_TerrainTag_init(hash) + @waterCurrent = hash[:waterCurrent] || false + @flowerRed = hash[:flowerRed] || false + @flowerYellow = hash[:flowerYellow] || false + @flowerPink = hash[:flowerPink] || false + @flowerBlue = hash[:flowerBlue] || false + @flower = hash[:flower] || false + @trashcan = hash[:trashcan] || false + @sharpedoObstacle = hash[:sharpedoObstacle] || false + end + + end +end + + +GameData::TerrainTag.register({ + :id => :WaterCurrent, + :id_number => 6, + :can_surf => true, + :can_fish => true, + :waterCurrent => true, + :battle_environment => :MovingWater + }) + + +GameData::TerrainTag.register({ + :id => :FlowerRed, + :id_number => 17, + :flowerRed => true, + :flower => true + }) +GameData::TerrainTag.register({ + :id => :FlowerYellow, + :id_number => 18, + :flowerYellow => true, + :flower => true + }) +GameData::TerrainTag.register({ + :id => :FlowerPink, + :id_number => 19, + :flowerPink => true, + :flower => true + }) +GameData::TerrainTag.register({ + :id => :FlowerBlue, + :id_number => 20, + :flowerBlue => true, + :flower => true + }) +GameData::TerrainTag.register({ + :id => :FlowerOther, + :id_number => 21, + :flower => true + }) +GameData::TerrainTag.register({ + :id => :Trashcan, + :id_number => 22, + :trashcan => true + }) + +GameData::TerrainTag.register({ + :id => :SharpedoObstacle, + :id_number => 23, + :sharpedoObstacle => true + }) + +GameData::TerrainTag.register({ + :id => :Grass_alt1, + :id_number => 24, + :shows_grass_rustle => true, + :land_wild_encounters => true, + :battle_environment => :Grass + }) + +GameData::TerrainTag.register({ + :id => :Grass_alt2, + :id_number => 25, + :shows_grass_rustle => true, + :land_wild_encounters => true, + :battle_environment => :Grass + }) + +GameData::TerrainTag.register({ + :id => :Grass_alt3, + :id_number => 26, + :shows_grass_rustle => true, + :land_wild_encounters => true, + :battle_environment => :Grass + }) + +GameData::TerrainTag.register({ + :id => :StillWater, + :id_number => 27, + :can_surf => true, + :can_fish => true, + :battle_environment => :StillWater, + :shows_reflections => true + }) + + + + + +GameData::TerrainTag.register({ + :id => :NoEffect, + :id_number => 99 + }) \ No newline at end of file diff --git a/Data/Scripts/998_InfiniteFusion/Graphics/Tilemaps/PIF_TilemapRenderer.rb b/Data/Scripts/998_InfiniteFusion/Graphics/Tilemaps/PIF_TilemapRenderer.rb index deb81b550..40ca1987e 100644 --- a/Data/Scripts/998_InfiniteFusion/Graphics/Tilemaps/PIF_TilemapRenderer.rb +++ b/Data/Scripts/998_InfiniteFusion/Graphics/Tilemaps/PIF_TilemapRenderer.rb @@ -94,5 +94,18 @@ class TilemapRenderer refresh_tile_src_rect(tile, tile_id) end + + def refresh_tile_z(tile, map, y, layer, tile_id) + if false#tile.shows_reflection + tile.z = -2000 + elsif tile.bridge && $PokemonGlobal.bridge > 0 + tile.z = 0 + else + priority = tile.priority + tile.z = (priority == 0) ? 0 : (y * SOURCE_TILE_HEIGHT) + (priority * SOURCE_TILE_HEIGHT) + SOURCE_TILE_HEIGHT + 1 + end + end + + end diff --git a/Data/Scripts/998_InfiniteFusion/Outfits/Overrides/Outfits_Sprite_Character.rb b/Data/Scripts/998_InfiniteFusion/Outfits/Overrides/Outfits_Sprite_Character.rb index 69df90ca6..be7b16c37 100644 --- a/Data/Scripts/998_InfiniteFusion/Outfits/Overrides/Outfits_Sprite_Character.rb +++ b/Data/Scripts/998_InfiniteFusion/Outfits/Overrides/Outfits_Sprite_Character.rb @@ -86,8 +86,98 @@ class Sprite_Character end end + def refresh_graphic + return if !should_update? + @manual_refresh=false + @tile_id = @character.tile_id + @character_name = @character.character_name + @character_hue = @character.character_hue + @oldbushdepth = @character.bush_depth + @charbitmap&.dispose + @charbitmap = nil + @bushbitmap&.dispose + @bushbitmap = nil + if @tile_id >= 384 + @charbitmap = pbGetTileBitmap(@character.map.tileset_name, @tile_id, + @character_hue, @character.width, @character.height) + @charbitmapAnimated = false + @spriteoffset = false + @cw = Game_Map::TILE_WIDTH * @character.width + @ch = Game_Map::TILE_HEIGHT * @character.height + self.src_rect.set(0, 0, @cw, @ch) + self.ox = @cw / 2 + self.oy = @ch + elsif @character_name != "" + @charbitmap = updateCharacterBitmap() + + RPG::Cache.retain("Graphics/Characters/", @character_name, @character_hue) if @character == $game_player + @charbitmapAnimated = true + + @spriteoffset = @character_name[/fish/i] || @character_name[/dive/i] || @character_name[/surf/i] + + @cw = @charbitmap.width / 4 + @ch = @charbitmap.height / 4 + self.ox = @cw / 2 + else + self.bitmap = nil + @cw = 0 + @ch = 0 + @reflection&.update + end + @character.sprite_size = [@cw, @ch] + end + def update + if self.pending_bitmap + self.bitmap = self.pending_bitmap + self.pending_bitmap = nil + end + return if @character.is_a?(Game_Event) && !@character.should_update? + super + refresh_graphic + #return if !@charbitmap + @charbitmap.update if @charbitmapAnimated + bushdepth = @character.bush_depth + if bushdepth == 0 + if @character == $game_player + self.bitmap = getClothedPlayerSprite() + else + self.bitmap = (@charbitmapAnimated) ? @charbitmap.bitmap : @charbitmap + end + else + @bushbitmap = BushBitmap.new(@charbitmap, (@tile_id >= 384), bushdepth) if !@bushbitmap + self.bitmap = @bushbitmap.bitmap + end + + self.visible = !@character.transparent + if @tile_id == 0 + sx = @character.pattern * @cw + sy = ((@character.direction - 2) / 2) * @ch + self.src_rect.set(sx, sy, @cw, @ch) + self.oy = (@spriteoffset rescue false) ? @ch - 16 : @ch + self.oy -= @character.bob_height + end + if self.visible + applyDayNightTone() + end + this_x = @character.screen_x + this_x = ((this_x - (Graphics.width / 2)) * TilemapRenderer::ZOOM_X) + (Graphics.width / 2) if TilemapRenderer::ZOOM_X != 1 + self.x = this_x + this_y = @character.screen_y + this_y = ((this_y - (Graphics.height / 2)) * TilemapRenderer::ZOOM_Y) + (Graphics.height / 2) if TilemapRenderer::ZOOM_Y != 1 + self.y = this_y + self.z = @character.screen_z(@ch) + self.opacity = @character.opacity + self.blend_type = @character.blend_type + if @character.animation_id && @character.animation_id != 0 + animation = $data_animations[@character.animation_id] + animation(animation, true, @character.animation_height || 3, @character.animation_regular_tone || false) + @character.animation_id = 0 + end + @reflection&.update + @surfbase&.update + end # def update # if self.pending_bitmap # self.bitmap = self.pending_bitmap diff --git a/Data/Scripts/998_InfiniteFusion/Outfits/Overrides/Outfits_Sprite_Player.rb b/Data/Scripts/998_InfiniteFusion/Outfits/Overrides/Outfits_Sprite_Player.rb index 805ca2f5a..597ef4ad0 100644 --- a/Data/Scripts/998_InfiniteFusion/Outfits/Overrides/Outfits_Sprite_Player.rb +++ b/Data/Scripts/998_InfiniteFusion/Outfits/Overrides/Outfits_Sprite_Player.rb @@ -81,6 +81,10 @@ class Sprite_Player < Sprite_Character def generateClothedBitmap() + echoln "yo!" + echoln @charbitmap.path + + return if !@charbitmap @charbitmap.bitmap.clone #nekkid sprite baseBitmap = @charbitmap.bitmap.clone #nekkid sprite diff --git a/Data/Scripts/998_InfiniteFusion/Outfits/Overrides/Outfits_Sprite_SurfBase.rb b/Data/Scripts/998_InfiniteFusion/Outfits/Overrides/Outfits_Sprite_SurfBase.rb new file mode 100644 index 000000000..1e9d6cd51 --- /dev/null +++ b/Data/Scripts/998_InfiniteFusion/Outfits/Overrides/Outfits_Sprite_SurfBase.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +class Sprite_SurfBase + + def initialize(parent_sprite, viewport = nil) + @parent_sprite = parent_sprite + @sprite = nil + @viewport = viewport + @disposed = false + + @surfbitmap = update_surf_bitmap(:SURF) + @divebitmap = update_surf_bitmap(:DIVE) + + @cws = @surfbitmap.width / 4 + @chs = @surfbitmap.height / 4 + @cwd = @divebitmap.width / 4 + @chd = @divebitmap.height / 4 + update + end + + def update_surf_bitmap(type) + species = $Trainer.surfing_pokemon + path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "surfmon_board" if type == :SURF + path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + "divemon_Head" if type == :DIVE + if species + shape = species.shape + basePath = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_SURFBASE_FOLDER + action = "divemon" if type == :DIVE + action = "surfmon" if type == :SURF + path = "#{basePath}#{action}_#{shape.to_s}" + end + return AnimatedBitmap.new(path) + end + +end diff --git a/Data/Scripts/998_InfiniteFusion/Outfits/Sprites/013_Sprite_Player_Offsets.rb b/Data/Scripts/998_InfiniteFusion/Outfits/Sprites/013_Sprite_Player_Offsets.rb new file mode 100644 index 000000000..3618c71e5 --- /dev/null +++ b/Data/Scripts/998_InfiniteFusion/Outfits/Sprites/013_Sprite_Player_Offsets.rb @@ -0,0 +1,35 @@ + +#[FRAME1 [x,y]],[FRAME2 [x,y], etc.] +# +# exact number of pixels that the sprite needs to be moved for each frame +# add 2 pixels on even frames +module Outfit_Offsets + BASE_OFFSET = [[0, 0], [0, 0], [0, 0], [0, 0]] + + + RUN_OFFSETS_DOWN = [[0, 2], [0, 6], [0, 2], [0, 6]] + RUN_OFFSETS_LEFT = [[-2, -2], [-2, -2], [-2, -2], [-2, -2]] + RUN_OFFSETS_RIGHT = [[2, -2], [2, -2], [2, -2], [2, -2]] + RUN_OFFSETS_UP = [[0, -2], [0, -2], [0, -2], [0, -2]] + + SURF_OFFSETS_DOWN = [[0, -6], [0, -4], [0, -6], [0, -4]] + SURF_OFFSETS_LEFT = [[-2, -10], [-2, -8], [-2, -10], [-2, -8]] + SURF_OFFSETS_RIGHT = [[4, -10], [4, -8], [4, -10], [4, -8]] + #SURF_OFFSETS_UP = [[0, -6], [0, -4], [0, -6], [0, -4]] + SURF_OFFSETS_UP = [[0, -10], [0, -8], [0, -10], [0, -8]] + + DIVE_OFFSETS_DOWN = [[0, -6], [0, -4], [0, -6], [0, -4]] + DIVE_OFFSETS_LEFT = [[6, -8], [6, -6], [6, -8], [6, -6]] + DIVE_OFFSETS_RIGHT = [[-6, -8], [-6, -6], [-6, -8], [-6, -6]] + DIVE_OFFSETS_UP = [[0, -2], [0, 0], [0, -2], [0, 0]] + + BIKE_OFFSETS_DOWN = [[0, -2], [2, 0], [0, -2], [-2, 0]] + BIKE_OFFSETS_LEFT = [[-4, -4], [-2, -2], [-4, -4], [-6, -2]] + BIKE_OFFSETS_RIGHT = [[4, -4], [2, -2], [4, -4], [6, -2]] + BIKE_OFFSETS_UP = [[0, -2], [-2, 0], [0, -2], [2, 0]] + + FISH_OFFSETS_DOWN = [[0, -6], [0, -2], [0, -8], [2, -6]] + FISH_OFFSETS_LEFT = [[0, -8], [-6, -6], [0, -8], [2, -8]] + FISH_OFFSETS_RIGHT = [[0, -8], [6, -6], [0, -8], [-2, -8]] + FISH_OFFSETS_UP = [[0, -6], [0, -6], [0, -6], [2, -4]] +end diff --git a/PBS/metadata.txt b/PBS/metadata.txt index 5647de8c0..976e02f43 100644 --- a/PBS/metadata.txt +++ b/PBS/metadata.txt @@ -14,20 +14,20 @@ BicycleBGM = Bicycle #------------------------------- [1] TrainerType = POKEMONTRAINER_Red -WalkCharset = trainer_POKEMONTRAINER_Red -RunCharset = boy_run -CycleCharset = boy_bike -SurfCharset = boy_surf -DiveCharset = boy_surf -FishCharset = boy_fish_offset +WalkCharset = walk +RunCharset = run +CycleCharset = bike +SurfCharset = surf +DiveCharset = dive +FishCharset = fish SurfFishCharset = boy_fish_offset #------------------------------- [2] TrainerType = POKEMONTRAINER_Leaf -WalkCharset = trainer_POKEMONTRAINER_Leaf -RunCharset = girl_run -CycleCharset = girl_bike -SurfCharset = girl_surf -DiveCharset = girl_surf -FishCharset = girl_fish_offset +WalkCharset = walk +RunCharset = run +CycleCharset = bike +SurfCharset = surf +DiveCharset = dive +FishCharset = fish SurfFishCharset = girl_fish_offset