diff --git a/gflib/sprite.c b/gflib/sprite.c index c3fc9f081d..25de92ac4a 100644 --- a/gflib/sprite.c +++ b/gflib/sprite.c @@ -1576,7 +1576,6 @@ void FreeAllSpritePalettes(void) u8 LoadSpritePalette(const struct SpritePalette *palette) { u8 index = IndexOfSpritePaletteTag(palette->tag); - u8 i; if (index != 0xFF) return index; diff --git a/include/battle_util.h b/include/battle_util.h index cac58be549..42d7c54d88 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -177,7 +177,7 @@ s32 CalculateMoveDamageVars(u32 move, u32 battlerAtk, u32 battlerDef, u32 moveTy uq4_12_t CalcTypeEffectivenessMultiplier(u32 move, u32 moveType, u32 battlerAtk, u32 battlerDef, u32 defAbility, bool32 recordAbilities); uq4_12_t CalcPartyMonTypeEffectivenessMultiplier(u16 move, u16 speciesDef, u16 abilityDef); uq4_12_t GetTypeModifier(u32 atkType, u32 defType); -u16 GetTypeEffectiveness(struct Pokemon *mon, u8 moveType); +uq4_12_t GetTypeEffectiveness(struct Pokemon *mon, u8 moveType); s32 GetStealthHazardDamage(u8 hazardType, u32 battler); s32 GetStealthHazardDamageByTypesAndHP(u8 hazardType, u8 type1, u8 type2, u32 maxHp); bool32 CanMegaEvolve(u32 battler); diff --git a/include/pokemon.h b/include/pokemon.h index 3291177050..d7f09179ba 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -744,6 +744,7 @@ void PlayMapChosenOrBattleBGM(u16 songId); void CreateTask_PlayMapChosenOrBattleBGM(u16 songId); const u32 *GetMonFrontSpritePal(struct Pokemon *mon); const u32 *GetMonSpritePalFromSpeciesAndPersonality(u16 species, bool32 isShiny, u32 personality); +const u32 *GetMonSpritePalFromSpecies(u16 species, bool32 isShiny, bool32 isFemale); bool8 IsMoveHM(u16 move); bool8 IsMonSpriteNotFlipped(u16 species); s8 GetMonFlavorRelation(struct Pokemon *mon, u8 flavor); diff --git a/src/battle_controllers.c b/src/battle_controllers.c index 3e229100b0..59bc16389f 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -11,6 +11,7 @@ #include "battle_setup.h" #include "battle_tv.h" #include "cable_club.h" +#include "event_object_movement.h" #include "link.h" #include "link_rfu.h" #include "palette.h" diff --git a/src/battle_util.c b/src/battle_util.c index aecb713d8a..bbb3b92ab7 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -9927,11 +9927,11 @@ static uq4_12_t GetInverseTypeMultiplier(uq4_12_t multiplier) } } -u16 GetTypeEffectiveness(struct Pokemon *mon, u8 moveType) +uq4_12_t GetTypeEffectiveness(struct Pokemon *mon, u8 moveType) { - u16 modifier = UQ_4_12(1.0); + uq4_12_t modifier = UQ_4_12(1.0); u16 abilityDef = GetMonAbility(mon); - u16 speciesDef = GetMonData(&mon, MON_DATA_SPECIES); + u16 speciesDef = GetMonData(mon, MON_DATA_SPECIES); u8 type1 = gSpeciesInfo[speciesDef].types[0]; u8 type2 = gSpeciesInfo[speciesDef].types[1]; diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 2c6b50110a..6096186c89 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -1683,7 +1683,7 @@ static void CopyObjectGraphicsInfoToSpriteTemplate_WithMovementType(u16 graphics CopyObjectGraphicsInfoToSpriteTemplate(graphicsId, sMovementTypeCallbacks[movementType], spriteTemplate, subspriteTables); } -static void MakeSpriteTemplateFromObjectEventTemplate(const struct ObjectEventTemplate *objectEventTemplate, struct SpriteTemplate *spriteTemplate, const struct SubspriteTable **subspriteTables) +static void UNUSED MakeSpriteTemplateFromObjectEventTemplate(const struct ObjectEventTemplate *objectEventTemplate, struct SpriteTemplate *spriteTemplate, const struct SubspriteTable **subspriteTables) { CopyObjectGraphicsInfoToSpriteTemplate_WithMovementType(objectEventTemplate->graphicsId, objectEventTemplate->movementType, spriteTemplate, subspriteTables); } @@ -1694,10 +1694,9 @@ static u8 LoadDynamicFollowerPaletteFromGraphicsId(u16 graphicsId, bool8 shiny, { u16 species = ((graphicsId & OBJ_EVENT_GFX_SPECIES_MASK) - OBJ_EVENT_GFX_MON_BASE); u8 form = (graphicsId >> OBJ_EVENT_GFX_SPECIES_BITS); - const struct CompressedSpritePalette *spritePalette = &(shiny ? gMonShinyPaletteTable : gMonPaletteTable)[species]; u8 paletteNum = LoadDynamicFollowerPalette(species, form, shiny); if (template) - template->paletteTag = spritePalette->tag; + template->paletteTag = species; return paletteNum; } @@ -1709,7 +1708,7 @@ u8 CreateObjectGraphicsSprite(u16 graphicsId, void (*callback)(struct Sprite *), const struct ObjectEventGraphicsInfo *graphicsInfo; struct Sprite *sprite; u8 spriteId; - u32 paletteNum; + u32 UNUSED paletteNum; spriteTemplate = Alloc(sizeof(struct SpriteTemplate)); CopyObjectGraphicsInfoToSpriteTemplate(graphicsId, callback, spriteTemplate, &subspriteTables); @@ -1854,12 +1853,12 @@ static u8 LoadDynamicFollowerPalette(u16 species, u8 form, bool8 shiny) u8 paletteNum; // Note that the shiny palette tag is `species + SPECIES_SHINY_TAG`, which must be increased with more pokemon // so that palette tags do not overlap - const struct CompressedSpritePalette *spritePalette = &(shiny ? gMonShinyPaletteTable : gMonPaletteTable)[species]; - if ((paletteNum = IndexOfSpritePaletteTag(spritePalette->tag)) == 0xFF) + const u32 *palette = GetMonSpritePalFromSpecies(species, shiny, FALSE); //ETODO + if ((paletteNum = IndexOfSpritePaletteTag(species)) == 0xFF) { // Load compressed palette - LoadCompressedSpritePalette(spritePalette); - paletteNum = IndexOfSpritePaletteTag(spritePalette->tag); // Tag is always present + LoadCompressedSpritePaletteWithTag(palette, species); + paletteNum = IndexOfSpritePaletteTag(species); // Tag is always present if (gWeatherPtr->currWeather != WEATHER_FOG_HORIZONTAL) // don't want to weather blend in fog UpdateSpritePaletteWithWeather(paletteNum); } @@ -1931,39 +1930,21 @@ static void RefreshFollowerGraphics(struct ObjectEvent *objEvent) #endif } -// Like vanilla's CastformDataTypeChange, but for overworld weather -static u8 GetOverworldCastformForm(void) +static u16 GetOverworldCastformSpecies(void) { switch (GetCurrentWeather()) { case WEATHER_SUNNY_CLOUDS: case WEATHER_DROUGHT: - return CASTFORM_FIRE; + return SPECIES_CASTFORM_SUNNY; case WEATHER_RAIN: case WEATHER_RAIN_THUNDERSTORM: case WEATHER_DOWNPOUR: - return CASTFORM_WATER; + return SPECIES_CASTFORM_RAINY; case WEATHER_SNOW: - return CASTFORM_ICE; + return SPECIES_CASTFORM_SNOWY; } - return CASTFORM_NORMAL; -} - -static u16 GetOverworldCastformSpecies(void) -{ - switch(GetOverworldCastformForm()) - { - case CASTFORM_FIRE: - return SPECIES_CASTFORM_SUNNY; - break; - case CASTFORM_WATER: - return SPECIES_CASTFORM_RAINY; - break; - case CASTFORM_ICE: - return SPECIES_CASTFORM_SNOWY; - break; - } - return SPECIES_CASTFORM; + return SPECIES_CASTFORM_NORMAL; } static bool8 GetMonInfo(struct Pokemon * mon, u16 *species, u8 *form, u8 *shiny) @@ -1998,12 +1979,12 @@ static bool8 GetFollowerInfo(u16 *species, u8 *form, u8 *shiny) void UpdateFollowingPokemon(void) { // Update following pokemon if any struct ObjectEvent *objEvent = GetFollowerObject(); - struct Sprite *sprite; u16 species; bool8 shiny; u8 form; // Avoid spawning large (>32x32) follower pokemon inside buildings - if (GetFollowerInfo(&species, &form, &shiny) && !(gMapHeader.mapType == MAP_TYPE_INDOOR && SpeciesToGraphicsInfo(species, 0)->height > 32) && !FlagGet(FLAG_TEMP_HIDE_FOLLOWER)) { + if (GetFollowerInfo(&species, &form, &shiny) && !(gMapHeader.mapType == MAP_TYPE_INDOOR && SpeciesToGraphicsInfo(species, 0)->height > 32) && !FlagGet(FLAG_TEMP_HIDE_FOLLOWER)) + { if (objEvent == NULL) { // Spawn follower struct ObjectEventTemplate template = { .localId = OBJ_EVENT_ID_FOLLOWER, @@ -2024,6 +2005,7 @@ void UpdateFollowingPokemon(void) { // Update following pokemon if any { RemoveFollowingPokemon(); } + } } // Remove follower object. Idempotent. @@ -2075,6 +2057,7 @@ static u8 RandomWeightedIndex(u8 *weights, u8 length) if (random_value <= cum_weight) return i; } + return length; } // Pool of "unconditional" follower messages TODO: Should this be elsewhere ? @@ -2765,7 +2748,7 @@ u8 LoadPlayerObjectEventPalette(u8 gender) paletteTag = FLDEFF_PAL_TAG_MAY; break; } - LoadObjectEventPalette(paletteTag); + return LoadObjectEventPalette(paletteTag); } static void UNUSED LoadObjectEventPaletteSet(u16 *paletteTags) @@ -2846,7 +2829,7 @@ void LoadSpecialObjectReflectionPalette(u16 tag, u8 slot) } } -static void _PatchObjectPalette(u16 tag, u8 slot) +static void UNUSED _PatchObjectPalette(u16 tag, u8 slot) { PatchObjectPalette(tag, slot); } @@ -5108,7 +5091,6 @@ static bool8 EndFollowerTransformEffect(struct ObjectEvent *objectEvent, struct static bool8 TryStartFollowerTransformEffect(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - u32 multi; if (GET_BASE_SPECIES_ID(OW_SPECIES(objectEvent)) == SPECIES_CASTFORM && OW_SPECIES(objectEvent) != GetOverworldCastformSpecies()) { @@ -5814,6 +5796,7 @@ bool8 ScrFunc_IsFollowerFieldMoveUser(struct ScriptContext *ctx) { return FALSE; } + return FALSE; } void SetTrainerMovementType(struct ObjectEvent *objectEvent, u8 movementType) @@ -9383,10 +9366,10 @@ static void DoTracksGroundEffect_SlitherTracks(struct ObjectEvent *objEvent, str // each byte in that row is for the next direction of the bike in the order // of down, up, left, right. static const u8 slitherTracks_Transitions[4][4] = { - 1, 2, 7, 8, - 1, 2, 6, 5, - 5, 8, 3, 4, - 6, 7, 3, 4, + {1, 2, 7, 8}, + {1, 2, 6, 5}, + {5, 8, 3, 4}, + {6, 7, 3, 4}, }; if (objEvent->currentCoords.x != objEvent->previousCoords.x || objEvent->currentCoords.y != objEvent->previousCoords.y) @@ -9514,7 +9497,7 @@ static void (*const sGroundEffectFuncs[])(struct ObjectEvent *objEvent, struct S GroundEffect_Seaweed // GROUND_EFFECT_FLAG_SEAWEED }; -static void GroundEffect_Shadow(struct ObjectEvent *objEvent, struct Sprite *sprite) +static void UNUSED GroundEffect_Shadow(struct ObjectEvent *objEvent, struct Sprite *sprite) { SetUpShadow(objEvent, sprite); } diff --git a/src/pokemon.c b/src/pokemon.c index 74bdea00cf..91b0d088e4 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -5384,6 +5384,28 @@ const u32 *GetMonSpritePalFromSpeciesAndPersonality(u16 species, bool32 isShiny, } } +const u32 *GetMonSpritePalFromSpecies(u16 species, bool32 isShiny, bool32 isFemale) +{ + if (isShiny) + { + if (gSpeciesInfo[species].shinyPaletteFemale != NULL && isFemale) + return gSpeciesInfo[species].shinyPaletteFemale; + else if (gSpeciesInfo[species].shinyPalette != NULL) + return gSpeciesInfo[species].shinyPalette; + else + return gSpeciesInfo[SPECIES_NONE].shinyPalette; + } + else + { + if (gSpeciesInfo[species].paletteFemale != NULL && isFemale) + return gSpeciesInfo[species].paletteFemale; + else if (gSpeciesInfo[species].palette != NULL) + return gSpeciesInfo[species].palette; + else + return gSpeciesInfo[SPECIES_NONE].palette; + } +} + bool8 IsMoveHM(u16 move) { int i = 0; diff --git a/src/pokemon_debug.c b/src/pokemon_debug.c index f34afe278d..2b26e47e41 100644 --- a/src/pokemon_debug.c +++ b/src/pokemon_debug.c @@ -678,29 +678,6 @@ static void UpdateBattlerValue(struct PokemonDebugMenu *data) } } -//Sprite functions -static const u32 *GetMonSpritePalStructCustom(u16 species, bool8 isFemale, bool8 isShiny) -{ - if (isShiny) - { - if (gSpeciesInfo[species].shinyPaletteFemale != NULL && isFemale) - return gSpeciesInfo[species].shinyPaletteFemale; - else if (gSpeciesInfo[species].shinyPalette != NULL) - return gSpeciesInfo[species].shinyPalette; - else - return gSpeciesInfo[SPECIES_NONE].shinyPalette; - } - else - { - if (gSpeciesInfo[species].paletteFemale != NULL && isFemale) - return gSpeciesInfo[species].paletteFemale; - else if (gSpeciesInfo[species].palette != NULL) - return gSpeciesInfo[species].palette; - else - return gSpeciesInfo[SPECIES_NONE].palette; - } -} - static void BattleLoadOpponentMonSpriteGfxCustom(u16 species, bool8 isFemale, bool8 isShiny, u8 battlerId) { const void *lzPaletteData; @@ -1111,7 +1088,7 @@ void CB2_Debug_Pokemon(void) PrintInstructionsOnWindow(data); //Palettes - palette = GetMonSpritePalStructCustom(species, data->isFemale, data->isShiny); + palette = GetMonSpritePalFromSpecies(species, data->isShiny, data->isFemale); LoadCompressedSpritePaletteWithTag(palette, species); //Front HandleLoadSpecialPokePic(TRUE, gMonSpritesGfxPtr->sprites.ptr[1], species, (data->isFemale ? FEMALE_PERSONALITY : MALE_PERSONALITY)); @@ -1663,7 +1640,7 @@ static void ReloadPokemonSprites(struct PokemonDebugMenu *data) PrintInstructionsOnWindow(data); //Palettes - palette = GetMonSpritePalStructCustom(species, data->isFemale, data->isShiny); + palette = GetMonSpritePalFromSpecies(species, data->isShiny, data->isFemale); LoadCompressedSpritePaletteWithTag(palette, species); //Front HandleLoadSpecialPokePic(TRUE, gMonSpritesGfxPtr->sprites.ptr[1], species, (data->isFemale ? FEMALE_PERSONALITY : MALE_PERSONALITY));