Fixes Hidden Power dynamic type bug (#5463)

This commit is contained in:
Alex 2024-10-03 10:36:35 +02:00 committed by GitHub
parent 2597d8a35a
commit f082fe7e42
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 84 additions and 94 deletions

View file

@ -5829,8 +5829,9 @@ u32 GetDynamicMoveType(struct Pokemon *mon, u32 move, u32 battler, u8 *ateBoost)
type3 = TYPE_MYSTERY;
}
if (moveEffect == EFFECT_WEATHER_BALL)
switch (moveEffect)
{
case EFFECT_WEATHER_BALL:
if (gMain.inBattle && WEATHER_HAS_EFFECT)
{
if (gBattleWeather & B_WEATHER_RAIN && holdEffect != HOLD_EFFECT_UTILITY_UMBRELLA)
@ -5864,79 +5865,86 @@ u32 GetDynamicMoveType(struct Pokemon *mon, u32 move, u32 battler, u8 *ateBoost)
}
return moveType;
}
}
else if (moveEffect == EFFECT_HIDDEN_POWER)
{
u8 typeBits;
if (gMain.inBattle)
break;
case EFFECT_HIDDEN_POWER:
{
typeBits = ((gBattleMons[battler].hpIV & 1) << 0)
| ((gBattleMons[battler].attackIV & 1) << 1)
| ((gBattleMons[battler].defenseIV & 1) << 2)
| ((gBattleMons[battler].speedIV & 1) << 3)
| ((gBattleMons[battler].spAttackIV & 1) << 4)
| ((gBattleMons[battler].spDefenseIV & 1) << 5);
}
else
{
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);
}
u32 typeBits = 0;
if (gMain.inBattle)
{
typeBits = ((gBattleMons[battler].hpIV & 1) << 0)
| ((gBattleMons[battler].attackIV & 1) << 1)
| ((gBattleMons[battler].defenseIV & 1) << 2)
| ((gBattleMons[battler].speedIV & 1) << 3)
| ((gBattleMons[battler].spAttackIV & 1) << 4)
| ((gBattleMons[battler].spDefenseIV & 1) << 5);
}
else
{
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);
}
// Subtract 6 instead of 1 below because 5 types are excluded (TYPE_NONE, TYPE_NORMAL, TYPE_MYSTERY, TYPE_FAIRY and TYPE_STELLAR)
// The final + 2 skips past TYPE_NONE and Normal.
moveType = ((NUMBER_OF_MON_TYPES - 6) * typeBits) / 63 + 2;
if (moveType >= TYPE_MYSTERY)
moveType++;
return (moveType | F_DYNAMIC_TYPE_IGNORE_PHYSICALITY);
}
else if (moveEffect == EFFECT_CHANGE_TYPE_ON_ITEM && holdEffect == gMovesInfo[move].argument)
{
return ItemId_GetSecondaryId(heldItem);
}
else if (moveEffect == EFFECT_REVELATION_DANCE && GetActiveGimmick(battler) != GIMMICK_Z_MOVE)
{
u8 teraType;
if (GetActiveGimmick(battler) == GIMMICK_TERA && ((teraType = GetMonData(mon, MON_DATA_TERA_TYPE)) != TYPE_STELLAR))
return teraType;
else if (type1 != TYPE_MYSTERY && !(gBattleResources->flags->flags[battler] & RESOURCE_FLAG_ROOST && type1 == TYPE_FLYING))
return type1;
else if (type2 != TYPE_MYSTERY && !(gBattleResources->flags->flags[battler] & RESOURCE_FLAG_ROOST && type2 == TYPE_FLYING))
// Subtract 6 instead of 1 below because 5 types are excluded (TYPE_NONE, TYPE_NORMAL, TYPE_MYSTERY, TYPE_FAIRY and TYPE_STELLAR)
// The final + 2 skips past TYPE_NONE and Normal.
moveType = ((NUMBER_OF_MON_TYPES - 6) * typeBits) / 63 + 2;
if (moveType >= TYPE_MYSTERY)
moveType++;
return ((moveType | F_DYNAMIC_TYPE_IGNORE_PHYSICALITY) & 0x3F);
}
break;
case EFFECT_CHANGE_TYPE_ON_ITEM:
if (holdEffect == gMovesInfo[move].argument)
return ItemId_GetSecondaryId(heldItem);
break;
case EFFECT_REVELATION_DANCE:
if (GetActiveGimmick(battler) != GIMMICK_Z_MOVE)
{
u32 teraType;
if (GetActiveGimmick(battler) == GIMMICK_TERA && ((teraType = GetMonData(mon, MON_DATA_TERA_TYPE)) != TYPE_STELLAR))
return teraType;
else if (type1 != TYPE_MYSTERY && !(gBattleResources->flags->flags[battler] & RESOURCE_FLAG_ROOST && type1 == TYPE_FLYING))
return type1;
else if (type2 != TYPE_MYSTERY && !(gBattleResources->flags->flags[battler] & RESOURCE_FLAG_ROOST && type2 == TYPE_FLYING))
return type2;
else if (gBattleResources->flags->flags[battler] & RESOURCE_FLAG_ROOST)
return (B_ROOST_PURE_FLYING >= GEN_5 ? TYPE_NORMAL : TYPE_MYSTERY);
else if (type3 != TYPE_MYSTERY)
return type3;
else
return TYPE_MYSTERY;
}
break;
case EFFECT_RAGING_BULL:
switch (species)
{
case SPECIES_TAUROS_PALDEA_COMBAT:
case SPECIES_TAUROS_PALDEA_BLAZE:
case SPECIES_TAUROS_PALDEA_AQUA:
return type2;
else if (gBattleResources->flags->flags[battler] & RESOURCE_FLAG_ROOST)
return (B_ROOST_PURE_FLYING >= GEN_5 ? TYPE_NORMAL : TYPE_MYSTERY);
else if (type3 != TYPE_MYSTERY)
return type3;
else
return TYPE_MYSTERY;
}
else if (moveEffect == EFFECT_RAGING_BULL
&& (species == SPECIES_TAUROS_PALDEA_COMBAT
|| species == SPECIES_TAUROS_PALDEA_BLAZE
|| species == SPECIES_TAUROS_PALDEA_AQUA))
{
return type2;
}
else if (moveEffect == EFFECT_IVY_CUDGEL
&& (species == SPECIES_OGERPON_WELLSPRING || species == SPECIES_OGERPON_WELLSPRING_TERA
|| species == SPECIES_OGERPON_HEARTHFLAME || species == SPECIES_OGERPON_HEARTHFLAME_TERA
|| species == SPECIES_OGERPON_CORNERSTONE || species == SPECIES_OGERPON_CORNERSTONE_TERA))
{
return type2;
}
else if (moveEffect == EFFECT_NATURAL_GIFT)
{
}
break;
case EFFECT_IVY_CUDGEL:
switch (species)
{
case SPECIES_OGERPON_WELLSPRING:
case SPECIES_OGERPON_HEARTHFLAME:
case SPECIES_OGERPON_CORNERSTONE:
case SPECIES_OGERPON_WELLSPRING_TERA:
case SPECIES_OGERPON_HEARTHFLAME_TERA:
case SPECIES_OGERPON_CORNERSTONE_TERA:
return type2;
}
break;
case EFFECT_NATURAL_GIFT:
if (ItemId_GetPocket(heldItem) == POCKET_BERRIES)
return gNaturalGiftTable[ITEM_TO_BERRY(heldItem)].type;
else
return moveType;
}
else if (moveEffect == EFFECT_TERRAIN_PULSE)
{
case EFFECT_TERRAIN_PULSE:
if (gMain.inBattle)
{
if (IsBattlerTerrainAffected(battler, STATUS_FIELD_TERRAIN_ANY))
@ -5969,14 +5977,15 @@ u32 GetDynamicMoveType(struct Pokemon *mon, u32 move, u32 battler, u8 *ateBoost)
}
return moveType;
}
}
else if (moveEffect == EFFECT_TERA_BLAST && GetActiveGimmick(battler) == GIMMICK_TERA)
{
return GetMonData(mon, MON_DATA_TERA_TYPE);
}
else if (moveEffect == EFFECT_TERA_STARSTORM && species == SPECIES_TERAPAGOS_STELLAR)
{
return TYPE_STELLAR;
break;
case EFFECT_TERA_BLAST:
if (GetActiveGimmick(battler) == GIMMICK_TERA)
return GetMonData(mon, MON_DATA_TERA_TYPE);
break;
case EFFECT_TERA_STARSTORM:
if (species == SPECIES_TERAPAGOS_STELLAR)
return TYPE_STELLAR;
break;
}
if (moveType == TYPE_NORMAL

View file

@ -6931,25 +6931,6 @@ void UpdateDaysPassedSinceFormChange(u16 days)
}
}
static inline u32 CalculateHiddenPowerType(struct Pokemon *mon)
{
u32 typehp;
u32 type;
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);
type = (15 * typeBits) / 63 + 2;
if (type >= TYPE_MYSTERY)
type++;
type |= 0xC0;
typehp = type & 0x3F;
return typehp;
}
u32 CheckDynamicMoveType(struct Pokemon *mon, u32 move, u32 battler)
{
u32 moveType = GetDynamicMoveType(mon, move, battler, NULL);