Skip to content

Commit

Permalink
Pret Merge (7th of August) (#5116)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bassoonian authored Aug 8, 2024
2 parents 0b1f06b + b8dab58 commit c390999
Show file tree
Hide file tree
Showing 18 changed files with 111 additions and 115 deletions.
20 changes: 10 additions & 10 deletions include/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -832,18 +832,18 @@ STATIC_ASSERT(sizeof(((struct BattleStruct *)0)->palaceFlags) * 8 >= MAX_BATTLER
#define IS_BATTLER_OF_BASE_TYPE(battlerId, type)((GetBattlerType(battlerId, 0, TRUE) == type || GetBattlerType(battlerId, 1, TRUE) == type || (GetBattlerType(battlerId, 2, TRUE) != TYPE_MYSTERY && GetBattlerType(battlerId, 2, TRUE) == type)))
#define IS_BATTLER_TYPELESS(battlerId)(GetBattlerType(battlerId, 0, FALSE) == TYPE_MYSTERY && GetBattlerType(battlerId, 1, FALSE) == TYPE_MYSTERY && GetBattlerType(battlerId, 2, FALSE) == TYPE_MYSTERY)

#define SET_BATTLER_TYPE(battlerId, type) \
{ \
gBattleMons[battlerId].type1 = type; \
gBattleMons[battlerId].type2 = type; \
gBattleMons[battlerId].type3 = TYPE_MYSTERY; \
#define SET_BATTLER_TYPE(battlerId, type) \
{ \
gBattleMons[battlerId].types[0] = type; \
gBattleMons[battlerId].types[1] = type; \
gBattleMons[battlerId].types[2] = TYPE_MYSTERY; \
}

#define RESTORE_BATTLER_TYPE(battlerId) \
{ \
gBattleMons[battlerId].type1 = gSpeciesInfo[gBattleMons[battlerId].species].types[0]; \
gBattleMons[battlerId].type2 = gSpeciesInfo[gBattleMons[battlerId].species].types[1]; \
gBattleMons[battlerId].type3 = TYPE_MYSTERY; \
#define RESTORE_BATTLER_TYPE(battlerId) \
{ \
gBattleMons[battlerId].types[0] = gSpeciesInfo[gBattleMons[battlerId].species].types[0]; \
gBattleMons[battlerId].types[1] = gSpeciesInfo[gBattleMons[battlerId].species].types[1]; \
gBattleMons[battlerId].types[2] = TYPE_MYSTERY; \
}

#define IS_BATTLER_PROTECTED(battlerId)(gProtectStructs[battlerId].protected \
Expand Down
4 changes: 1 addition & 3 deletions include/battle_controllers.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,7 @@ struct ChooseMoveStruct
u8 currentPp[MAX_MON_MOVES];
u8 maxPp[MAX_MON_MOVES];
u16 species;
u8 monType1;
u8 monType2;
u8 monType3;
u8 monTypes[3];
struct ZMoveData zmove;
};

Expand Down
4 changes: 1 addition & 3 deletions include/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,7 @@ struct BattlePokemon
/*0x17*/ u32 abilityNum:2;
/*0x18*/ s8 statStages[NUM_BATTLE_STATS];
/*0x20*/ u16 ability;
/*0x22*/ u8 type1;
/*0x23*/ u8 type2;
/*0x24*/ u8 type3;
/*0x22*/ u8 types[3];
/*0x25*/ u8 pp[MAX_MON_MOVES];
/*0x29*/ u16 hp;
/*0x2B*/ u8 level;
Expand Down
32 changes: 16 additions & 16 deletions src/battle_ai_switch_items.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ static bool32 HasBadOdds(u32 battler, bool32 emitResult)
opposingBattler = GetBattlerAtPosition(opposingPosition);

// Gets types of player (opposingBattler) and computer (battler)
atkType1 = gBattleMons[opposingBattler].type1;
atkType2 = gBattleMons[opposingBattler].type2;
defType1 = gBattleMons[battler].type1;
defType2 = gBattleMons[battler].type2;
atkType1 = gBattleMons[opposingBattler].types[0];
atkType2 = gBattleMons[opposingBattler].types[1];
defType1 = gBattleMons[battler].types[0];
defType2 = gBattleMons[battler].types[1];

// Check AI moves for damage dealt
for (i = 0; i < MAX_MON_MOVES; i++)
Expand Down Expand Up @@ -1236,8 +1236,8 @@ static u32 GetBestMonTypeMatchup(struct Pokemon *party, int firstId, int lastId,
u16 species = GetMonData(&party[i], MON_DATA_SPECIES);
uq4_12_t typeEffectiveness = UQ_4_12(1.0);

u8 atkType1 = gBattleMons[opposingBattler].type1;
u8 atkType2 = gBattleMons[opposingBattler].type2;
u8 atkType1 = gBattleMons[opposingBattler].types[0];
u8 atkType2 = gBattleMons[opposingBattler].types[1];
u8 defType1 = gSpeciesInfo[species].types[0];
u8 defType2 = gSpeciesInfo[species].types[1];

Expand Down Expand Up @@ -1337,7 +1337,7 @@ static bool32 IsMonGrounded(u16 heldItemEffect, u32 ability, u8 type1, u8 type2)
// Gets hazard damage
static u32 GetSwitchinHazardsDamage(u32 battler, struct BattlePokemon *battleMon)
{
u8 defType1 = battleMon->type1, defType2 = battleMon->type2, tSpikesLayers;
u8 defType1 = battleMon->types[0], defType2 = battleMon->types[1], tSpikesLayers;
u16 heldItemEffect = ItemId_GetHoldEffect(battleMon->item);
u32 maxHP = battleMon->maxHP, ability = battleMon->ability, status = battleMon->status1;
u32 spikesDamage = 0, tSpikesDamage = 0, hazardDamage = 0;
Expand Down Expand Up @@ -1404,17 +1404,17 @@ static s32 GetSwitchinWeatherImpact(void)
if (holdEffect != HOLD_EFFECT_SAFETY_GOGGLES && ability != ABILITY_MAGIC_GUARD && ability != ABILITY_OVERCOAT)
{
if ((gBattleWeather & B_WEATHER_HAIL)
&& (AI_DATA->switchinCandidate.battleMon.type1 != TYPE_ICE || AI_DATA->switchinCandidate.battleMon.type2 != TYPE_ICE)
&& (AI_DATA->switchinCandidate.battleMon.types[0] != TYPE_ICE || AI_DATA->switchinCandidate.battleMon.types[1] != TYPE_ICE)
&& ability != ABILITY_SNOW_CLOAK && ability != ABILITY_ICE_BODY)
{
weatherImpact = maxHP / 16;
if (weatherImpact == 0)
weatherImpact = 1;
}
else if ((gBattleWeather & B_WEATHER_SANDSTORM)
&& (AI_DATA->switchinCandidate.battleMon.type1 != TYPE_GROUND && AI_DATA->switchinCandidate.battleMon.type2 != TYPE_GROUND
&& AI_DATA->switchinCandidate.battleMon.type1 != TYPE_ROCK && AI_DATA->switchinCandidate.battleMon.type2 != TYPE_ROCK
&& AI_DATA->switchinCandidate.battleMon.type1 != TYPE_STEEL && AI_DATA->switchinCandidate.battleMon.type2 != TYPE_STEEL
&& (AI_DATA->switchinCandidate.battleMon.types[0] != TYPE_GROUND && AI_DATA->switchinCandidate.battleMon.types[1] != TYPE_GROUND
&& AI_DATA->switchinCandidate.battleMon.types[0] != TYPE_ROCK && AI_DATA->switchinCandidate.battleMon.types[1] != TYPE_ROCK
&& AI_DATA->switchinCandidate.battleMon.types[0] != TYPE_STEEL && AI_DATA->switchinCandidate.battleMon.types[1] != TYPE_STEEL
&& ability != ABILITY_SAND_VEIL && ability != ABILITY_SAND_RUSH && ability != ABILITY_SAND_FORCE))
{
weatherImpact = maxHP / 16;
Expand Down Expand Up @@ -1465,7 +1465,7 @@ static u32 GetSwitchinRecurringHealing(void)
// Items
if (ability != ABILITY_KLUTZ)
{
if (holdEffect == HOLD_EFFECT_BLACK_SLUDGE && (AI_DATA->switchinCandidate.battleMon.type1 == TYPE_POISON || AI_DATA->switchinCandidate.battleMon.type2 == TYPE_POISON))
if (holdEffect == HOLD_EFFECT_BLACK_SLUDGE && (AI_DATA->switchinCandidate.battleMon.types[0] == TYPE_POISON || AI_DATA->switchinCandidate.battleMon.types[1] == TYPE_POISON))
{
recurringHealing = maxHP / 16;
if (recurringHealing == 0)
Expand Down Expand Up @@ -1499,7 +1499,7 @@ static u32 GetSwitchinRecurringDamage(void)
// Items
if (ability != ABILITY_MAGIC_GUARD && ability != ABILITY_KLUTZ)
{
if (holdEffect == HOLD_EFFECT_BLACK_SLUDGE && AI_DATA->switchinCandidate.battleMon.type1 != TYPE_POISON && AI_DATA->switchinCandidate.battleMon.type2 != TYPE_POISON)
if (holdEffect == HOLD_EFFECT_BLACK_SLUDGE && AI_DATA->switchinCandidate.battleMon.types[0] != TYPE_POISON && AI_DATA->switchinCandidate.battleMon.types[1] != TYPE_POISON)
{
passiveDamage = maxHP / 8;
if (passiveDamage == 0)
Expand All @@ -1524,7 +1524,7 @@ static u32 GetSwitchinRecurringDamage(void)
// Gets one turn of status damage
static u32 GetSwitchinStatusDamage(u32 battler)
{
u8 defType1 = AI_DATA->switchinCandidate.battleMon.type1, defType2 = AI_DATA->switchinCandidate.battleMon.type2;
u8 defType1 = AI_DATA->switchinCandidate.battleMon.types[0], defType2 = AI_DATA->switchinCandidate.battleMon.types[1];
u8 tSpikesLayers = gSideTimers[GetBattlerSide(battler)].toxicSpikesAmount;
u16 heldItemEffect = ItemId_GetHoldEffect(AI_DATA->switchinCandidate.battleMon.item);
u32 status = AI_DATA->switchinCandidate.battleMon.status1, ability = AI_DATA->switchinCandidate.battleMon.ability, maxHP = AI_DATA->switchinCandidate.battleMon.maxHP;
Expand Down Expand Up @@ -1706,7 +1706,7 @@ static u16 GetSwitchinTypeMatchup(u32 opposingBattler, struct BattlePokemon batt
// Check type matchup
u16 typeEffectiveness = UQ_4_12(1.0);
u8 atkType1 = gSpeciesInfo[gBattleMons[opposingBattler].species].types[0], atkType2 = gSpeciesInfo[gBattleMons[opposingBattler].species].types[1],
defType1 = battleMon.type1, defType2 = battleMon.type2;
defType1 = battleMon.types[0], defType2 = battleMon.types[1];

// Multiply type effectiveness by a factor depending on type matchup
typeEffectiveness = uq4_12_multiply(typeEffectiveness, (GetTypeModifier(atkType1, defType1)));
Expand Down Expand Up @@ -2002,7 +2002,7 @@ static u32 GetBestMonIntegrated(struct Pokemon *party, int firstId, int lastId,
if (aceMonId != PARTY_SIZE
&& (gMovesInfo[gLastUsedMove].effect == EFFECT_HIT_ESCAPE || gMovesInfo[gLastUsedMove].effect == EFFECT_PARTING_SHOT || gMovesInfo[gLastUsedMove].effect == EFFECT_BATON_PASS))
return aceMonId;

return PARTY_SIZE;
}

Expand Down
16 changes: 8 additions & 8 deletions src/battle_ai_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ void SaveBattlerData(u32 battlerId)
AI_THINKING_STRUCT->saved[battlerId].moves[i] = gBattleMons[battlerId].moves[i];
}
// Save and restore types even for AI controlled battlers in case it gets changed during move evaluation process.
AI_THINKING_STRUCT->saved[battlerId].types[0] = gBattleMons[battlerId].type1;
AI_THINKING_STRUCT->saved[battlerId].types[1] = gBattleMons[battlerId].type2;
AI_THINKING_STRUCT->saved[battlerId].types[0] = gBattleMons[battlerId].types[0];
AI_THINKING_STRUCT->saved[battlerId].types[1] = gBattleMons[battlerId].types[1];
}

static bool32 ShouldFailForIllusion(u32 illusionSpecies, u32 battlerId)
Expand Down Expand Up @@ -218,11 +218,11 @@ void SetBattlerData(u32 battlerId)
if (illusionSpecies != SPECIES_NONE && ShouldFailForIllusion(illusionSpecies, battlerId))
{
// If the battler's type has not been changed, AI assumes the types of the illusion mon.
if (gBattleMons[battlerId].type1 == gSpeciesInfo[species].types[0]
&& gBattleMons[battlerId].type2 == gSpeciesInfo[species].types[1])
if (gBattleMons[battlerId].types[0] == gSpeciesInfo[species].types[0]
&& gBattleMons[battlerId].types[1] == gSpeciesInfo[species].types[1])
{
gBattleMons[battlerId].type1 = gSpeciesInfo[illusionSpecies].types[0];
gBattleMons[battlerId].type2 = gSpeciesInfo[illusionSpecies].types[1];
gBattleMons[battlerId].types[0] = gSpeciesInfo[illusionSpecies].types[0];
gBattleMons[battlerId].types[1] = gSpeciesInfo[illusionSpecies].types[1];
}
species = illusionSpecies;
}
Expand Down Expand Up @@ -262,8 +262,8 @@ void RestoreBattlerData(u32 battlerId)
for (i = 0; i < 4; i++)
gBattleMons[battlerId].moves[i] = AI_THINKING_STRUCT->saved[battlerId].moves[i];
}
gBattleMons[battlerId].type1 = AI_THINKING_STRUCT->saved[battlerId].types[0];
gBattleMons[battlerId].type2 = AI_THINKING_STRUCT->saved[battlerId].types[1];
gBattleMons[battlerId].types[0] = AI_THINKING_STRUCT->saved[battlerId].types[0];
gBattleMons[battlerId].types[1] = AI_THINKING_STRUCT->saved[battlerId].types[1];
}

u32 GetHealthPercentage(u32 battlerId)
Expand Down
2 changes: 1 addition & 1 deletion src/battle_controller_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -1733,7 +1733,7 @@ static void MoveSelectionDisplayMoveType(u32 battler)
if (speciesId == SPECIES_OGERPON_WELLSPRING_MASK || speciesId == SPECIES_OGERPON_WELLSPRING_MASK_TERA
|| 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;
type = gBattleMons[battler].types[1];
}
// Max Guard is a Normal-type move
else if (gMovesInfo[moveInfo->moves[gMoveSelectionCursor[battler]]].category == DAMAGE_CATEGORY_STATUS
Expand Down
6 changes: 3 additions & 3 deletions src/battle_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -1670,7 +1670,7 @@ static void PrintSecondaryEntries(struct BattleDebugMenu *data)
case LIST_ITEM_TYPES:
for (i = 0; i < 3; i++)
{
u8 *types = &gBattleMons[data->battlerId].type1;
u8 *types = &gBattleMons[data->battlerId].types[0];

PadString(gTypesInfo[types[i]].name, text);
printer.currentY = printer.y = (i * yMultiplier) + sSecondaryListTemplate.upText_Y;
Expand Down Expand Up @@ -2070,9 +2070,9 @@ static void SetUpModifyArrows(struct BattleDebugMenu *data)
data->modifyArrows.minValue = 0;
data->modifyArrows.maxValue = NUMBER_OF_MON_TYPES - 1;
data->modifyArrows.maxDigits = 2;
data->modifyArrows.modifiedValPtr = (u8 *)((&gBattleMons[data->battlerId].type1) + data->currentSecondaryListItemId);
data->modifyArrows.modifiedValPtr = (u8 *)((&gBattleMons[data->battlerId].types[0]) + data->currentSecondaryListItemId);
data->modifyArrows.typeOfVal = VAL_U8;
data->modifyArrows.currValue = *(u8 *)((&gBattleMons[data->battlerId].type1) + data->currentSecondaryListItemId);
data->modifyArrows.currValue = *(u8 *)((&gBattleMons[data->battlerId].types[0]) + data->currentSecondaryListItemId);
break;
case LIST_ITEM_STATS:
data->modifyArrows.minValue = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/battle_gfx_sfx_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,7 @@ void LoadAndCreateEnemyShadowSprites(void)
u32 i;

LoadCompressedSpriteSheet(&gSpriteSheet_EnemyShadow);

// initialize shadow sprite ids
for (i = 0; i < gBattlersCount; i++)
{
Expand All @@ -1123,7 +1123,7 @@ void LoadAndCreateEnemyShadowSprites(void)

battler = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
CreateEnemyShadowSprite(battler);

if (IsDoubleBattle())
{
battler = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
Expand Down
34 changes: 17 additions & 17 deletions src/battle_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3368,9 +3368,9 @@ const u8* FaintClearSetData(u32 battler)

gBattleResources->flags->flags[battler] = 0;

gBattleMons[battler].type1 = gSpeciesInfo[gBattleMons[battler].species].types[0];
gBattleMons[battler].type2 = gSpeciesInfo[gBattleMons[battler].species].types[1];
gBattleMons[battler].type3 = TYPE_MYSTERY;
gBattleMons[battler].types[0] = gSpeciesInfo[gBattleMons[battler].species].types[0];
gBattleMons[battler].types[1] = gSpeciesInfo[gBattleMons[battler].species].types[1];
gBattleMons[battler].types[2] = TYPE_MYSTERY;

Ai_UpdateFaintData(battler);
TryBattleFormChange(battler, FORM_CHANGE_FAINT);
Expand Down Expand Up @@ -3470,9 +3470,9 @@ static void DoBattleIntro(void)
else
{
memcpy(&gBattleMons[battler], &gBattleResources->bufferB[battler][4], sizeof(struct BattlePokemon));
gBattleMons[battler].type1 = gSpeciesInfo[gBattleMons[battler].species].types[0];
gBattleMons[battler].type2 = gSpeciesInfo[gBattleMons[battler].species].types[1];
gBattleMons[battler].type3 = TYPE_MYSTERY;
gBattleMons[battler].types[0] = gSpeciesInfo[gBattleMons[battler].species].types[0];
gBattleMons[battler].types[1] = gSpeciesInfo[gBattleMons[battler].species].types[1];
gBattleMons[battler].types[2] = TYPE_MYSTERY;
gBattleMons[battler].ability = GetAbilityBySpecies(gBattleMons[battler].species, gBattleMons[battler].abilityNum);
gBattleStruct->hpOnSwitchout[GetBattlerSide(battler)] = gBattleMons[battler].hp;
gBattleMons[battler].status2 = 0;
Expand Down Expand Up @@ -4263,9 +4263,9 @@ static void HandleTurnActionSelectionState(void)

moveInfo.zmove = gBattleStruct->zmove;
moveInfo.species = gBattleMons[battler].species;
moveInfo.monType1 = gBattleMons[battler].type1;
moveInfo.monType2 = gBattleMons[battler].type2;
moveInfo.monType3 = gBattleMons[battler].type3;
moveInfo.monTypes[0] = gBattleMons[battler].types[0];
moveInfo.monTypes[1] = gBattleMons[battler].types[1];
moveInfo.monTypes[2] = gBattleMons[battler].types[2];

for (i = 0; i < MAX_MON_MOVES; i++)
{
Expand Down Expand Up @@ -5828,26 +5828,26 @@ void SetTypeBeforeUsingMove(u32 move, u32 battlerAtk)
{
if (GetActiveGimmick(battlerAtk) == GIMMICK_TERA && GetBattlerTeraType(battlerAtk) != TYPE_STELLAR)
gBattleStruct->dynamicMoveType = GetBattlerTeraType(battlerAtk);
else if (gBattleMons[battlerAtk].type1 != TYPE_MYSTERY)
gBattleStruct->dynamicMoveType = gBattleMons[battlerAtk].type1 | F_DYNAMIC_TYPE_SET;
else if (gBattleMons[battlerAtk].type2 != TYPE_MYSTERY)
gBattleStruct->dynamicMoveType = gBattleMons[battlerAtk].type2 | F_DYNAMIC_TYPE_SET;
else if (gBattleMons[battlerAtk].type3 != TYPE_MYSTERY)
gBattleStruct->dynamicMoveType = gBattleMons[battlerAtk].type3 | F_DYNAMIC_TYPE_SET;
else if (gBattleMons[battlerAtk].types[0] != TYPE_MYSTERY)
gBattleStruct->dynamicMoveType = gBattleMons[battlerAtk].types[0] | F_DYNAMIC_TYPE_SET;
else if (gBattleMons[battlerAtk].types[1] != TYPE_MYSTERY)
gBattleStruct->dynamicMoveType = gBattleMons[battlerAtk].types[1] | F_DYNAMIC_TYPE_SET;
else if (gBattleMons[battlerAtk].types[2] != TYPE_MYSTERY)
gBattleStruct->dynamicMoveType = gBattleMons[battlerAtk].types[2] | F_DYNAMIC_TYPE_SET;
}
else if (gMovesInfo[move].effect == EFFECT_RAGING_BULL
&& (gBattleMons[battlerAtk].species == SPECIES_TAUROS_PALDEAN_COMBAT_BREED
|| gBattleMons[battlerAtk].species == SPECIES_TAUROS_PALDEAN_BLAZE_BREED
|| gBattleMons[battlerAtk].species == SPECIES_TAUROS_PALDEAN_AQUA_BREED))
{
gBattleStruct->dynamicMoveType = gBattleMons[battlerAtk].type2 | F_DYNAMIC_TYPE_SET;
gBattleStruct->dynamicMoveType = gBattleMons[battlerAtk].types[1] | F_DYNAMIC_TYPE_SET;
}
else if (gMovesInfo[move].effect == EFFECT_IVY_CUDGEL
&& (gBattleMons[battlerAtk].species == SPECIES_OGERPON_WELLSPRING_MASK || gBattleMons[battlerAtk].species == SPECIES_OGERPON_WELLSPRING_MASK_TERA
|| gBattleMons[battlerAtk].species == SPECIES_OGERPON_HEARTHFLAME_MASK || gBattleMons[battlerAtk].species == SPECIES_OGERPON_HEARTHFLAME_MASK_TERA
|| gBattleMons[battlerAtk].species == SPECIES_OGERPON_CORNERSTONE_MASK || gBattleMons[battlerAtk].species == SPECIES_OGERPON_CORNERSTONE_MASK_TERA ))
{
gBattleStruct->dynamicMoveType = gBattleMons[battlerAtk].type2 | F_DYNAMIC_TYPE_SET;
gBattleStruct->dynamicMoveType = gBattleMons[battlerAtk].types[1] | F_DYNAMIC_TYPE_SET;
}
else if (gMovesInfo[move].effect == EFFECT_NATURAL_GIFT)
{
Expand Down
Loading

0 comments on commit c390999

Please sign in to comment.