Skip to content

Commit

Permalink
Dynamic Hidden Power Types
Browse files Browse the repository at this point in the history
  • Loading branch information
Galaxeeh committed Aug 3, 2024
1 parent 346b29f commit 8e965cd
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 4 deletions.
1 change: 1 addition & 0 deletions include/config/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#define P_TWO_FRAME_FRONT_SPRITES TRUE // In Pokémon Emerald, Pokémon front sprites always consist of two frames. This config can revert it to only use the first frame, as is the case in the other Gen 3 games.
#define P_ONLY_OBTAINABLE_SHINIES FALSE // If TRUE, Pokémon encountered in the Battle Pyramid won't be shiny.
#define P_NO_SHINIES_WITHOUT_POKEBALLS FALSE // If TRUE, Pokémon encountered when the player is out of Poké Balls won't be shiny
#define P_DYNAMIC_HIDDEN_POWER_TYPES FALSE // If TRUE, Pokémon will display their Hidden Power type in summary screens and in battle.

// Learnset helper toggles
#define P_LEARNSET_HELPER_TEACHABLE TRUE // If TRUE, teachable_learnsets.h will be populated by tools/learnset_helpers/teachable.py using the included JSON files based on available TMs and tutors.
Expand Down
29 changes: 28 additions & 1 deletion src/battle_controller_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -1725,7 +1725,9 @@ static void MoveSelectionDisplayMoveType(u32 battler)
{
if (IsGimmickSelected(battler, GIMMICK_TERA) || GetActiveGimmick(battler) == GIMMICK_TERA)
type = GetBattlerTeraType(battler);
end = StringCopy(txtPtr, gTypesInfo[type].name);
}

else if (moveInfo->moves[gMoveSelectionCursor[battler]] == MOVE_IVY_CUDGEL)
{
speciesId = gBattleMons[battler].species;
Expand All @@ -1734,21 +1736,46 @@ static void MoveSelectionDisplayMoveType(u32 battler)
|| speciesId == SPECIES_OGERPON_HEARTHFLAME_MASK || speciesId == SPECIES_OGERPON_HEARTHFLAME_MASK_TERA
|| speciesId == SPECIES_OGERPON_CORNERSTONE_MASK || speciesId == SPECIES_OGERPON_CORNERSTONE_MASK_TERA)
type = gBattleMons[battler].type2;
end = StringCopy(txtPtr, gTypesInfo[type].name);
}
// Max Guard is a Normal-type move
else if (gMovesInfo[moveInfo->moves[gMoveSelectionCursor[battler]]].category == DAMAGE_CATEGORY_STATUS
&& (GetActiveGimmick(battler) == GIMMICK_DYNAMAX || IsGimmickSelected(battler, GIMMICK_DYNAMAX)))
{
type = TYPE_NORMAL;
end = StringCopy(txtPtr, gTypesInfo[type].name);
}

else if (moveInfo->moves[gMoveSelectionCursor[battler]] == MOVE_TERA_STARSTORM)
{
if (gBattleMons[battler].species == SPECIES_TERAPAGOS_STELLAR
|| (IsGimmickSelected(battler, GIMMICK_TERA) && gBattleMons[battler].species == SPECIES_TERAPAGOS_TERASTAL))
type = TYPE_STELLAR;
end = StringCopy(txtPtr, gTypesInfo[type].name);
}

//Dynamic Hidden Power types
else if (P_DYNAMIC_HIDDEN_POWER_TYPES && moveInfo->moves[gMoveSelectionCursor[battler]] == MOVE_HIDDEN_POWER)
{
u8 typeBits = ((GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_HP_IV) & 1) << 0)
| ((GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_ATK_IV) & 1) << 1)
| ((GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_DEF_IV) & 1) << 2)
| ((GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_SPEED_IV) & 1) << 3)
| ((GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_SPATK_IV) & 1) << 4)
| ((GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_SPDEF_IV) & 1) << 5);

u8 type = (15 * typeBits) / 63 + 2;
if (type >= TYPE_MYSTERY)
type++;
type |= 0xC0;
end = StringCopy(txtPtr, gTypesInfo[type & 0x3F].name);
}

else
{
end = StringCopy(txtPtr, gTypesInfo[type].name);
}

end = StringCopy(txtPtr, gTypesInfo[type].name);
PrependFontIdToFit(txtPtr, end, FONT_NORMAL, WindowWidthPx(B_WIN_MOVE_TYPE) - 25);
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_MOVE_TYPE);
}
Expand Down
48 changes: 45 additions & 3 deletions src/pokemon_summary_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -3959,12 +3959,34 @@ static void SetMoveTypeIcons(void)
{
u8 i;
struct PokeSummary *summary = &sMonSummaryScreen->summary;
struct Pokemon *mon = &sMonSummaryScreen->currentMon;
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (summary->moves[i] != MOVE_NONE)
if (summary->moves[i] != MOVE_NONE)
{
SetTypeSpritePosAndPal(gMovesInfo[summary->moves[i]].type, 85, 32 + (i * 16), i + SPRITE_ARR_ID_TYPE);

if (P_DYNAMIC_HIDDEN_POWER_TYPES && summary->moves[i] == MOVE_HIDDEN_POWER)
{
u8 typeBits = ((GetMonData(mon, MON_DATA_HP_IV) & 1) << 0)
| ((GetMonData(mon, MON_DATA_ATK_IV) & 1) << 1)
| ((GetMonData(mon, MON_DATA_DEF_IV) & 1) << 2)
| ((GetMonData(mon, MON_DATA_SPEED_IV) & 1) << 3)
| ((GetMonData(mon, MON_DATA_SPATK_IV) & 1) << 4)
| ((GetMonData(mon, MON_DATA_SPDEF_IV) & 1) << 5);

u8 type = (15 * typeBits) / 63 + 2;
if (type >= TYPE_MYSTERY)
type++;
type |= 0xC0;
SetTypeSpritePosAndPal(type & 0x3F, 85, 32 + (i * 16), i + SPRITE_ARR_ID_TYPE);
}

else
{
SetTypeSpritePosAndPal(gMovesInfo[summary->moves[i]].type, 85, 32 + (i * 16), i + SPRITE_ARR_ID_TYPE);
}
}

else
SetSpriteInvisibility(i + SPRITE_ARR_ID_TYPE, TRUE);
}
Expand All @@ -3985,14 +4007,34 @@ static void SetContestMoveTypeIcons(void)

static void SetNewMoveTypeIcon(void)
{
struct Pokemon *mon = &sMonSummaryScreen->currentMon;

if (sMonSummaryScreen->newMove == MOVE_NONE)
{
SetSpriteInvisibility(SPRITE_ARR_ID_TYPE + 4, TRUE);
}
else
{
if (sMonSummaryScreen->currPageIndex == PSS_PAGE_BATTLE_MOVES)
SetTypeSpritePosAndPal(gMovesInfo[sMonSummaryScreen->newMove].type, 85, 96, SPRITE_ARR_ID_TYPE + 4);
if (P_DYNAMIC_HIDDEN_POWER_TYPES && sMonSummaryScreen->newMove == MOVE_HIDDEN_POWER)
{
u8 typeBits = ((GetMonData(mon, MON_DATA_HP_IV) & 1) << 0)
| ((GetMonData(mon, MON_DATA_ATK_IV) & 1) << 1)
| ((GetMonData(mon, MON_DATA_DEF_IV) & 1) << 2)
| ((GetMonData(mon, MON_DATA_SPEED_IV) & 1) << 3)
| ((GetMonData(mon, MON_DATA_SPATK_IV) & 1) << 4)
| ((GetMonData(mon, MON_DATA_SPDEF_IV) & 1) << 5);

u8 type = (15 * typeBits) / 63 + 2;
if (type >= TYPE_MYSTERY)
type++;
type |= 0xC0;
SetTypeSpritePosAndPal(type & 0x3F, 85, 96, SPRITE_ARR_ID_TYPE + 4);
}
else
{
SetTypeSpritePosAndPal(gMovesInfo[sMonSummaryScreen->newMove].type, 85, 96, SPRITE_ARR_ID_TYPE + 4);
}
else
SetTypeSpritePosAndPal(NUMBER_OF_MON_TYPES + gMovesInfo[sMonSummaryScreen->newMove].contestCategory, 85, 96, SPRITE_ARR_ID_TYPE + 4);
}
Expand Down

0 comments on commit 8e965cd

Please sign in to comment.