Changed type1 and type2 to be consistent (#2021)

* Changed type1 and type2 in gBattleMons to match gSpeciesInfo
* Changed monType1 and monType2 to monTypes to match gSpeciesInfo
This commit is contained in:
psf
2024-08-06 22:44:03 -07:00
committed by GitHub
parent 9a3c6d072b
commit 312749dd31
10 changed files with 56 additions and 58 deletions

View File

@@ -465,11 +465,11 @@ STATIC_ASSERT(sizeof(((struct BattleStruct *)0)->palaceFlags) * 8 >= MAX_BATTLER
#define TARGET_TURN_DAMAGED ((gSpecialStatuses[gBattlerTarget].physicalDmg != 0 || gSpecialStatuses[gBattlerTarget].specialDmg != 0))
#define IS_BATTLER_OF_TYPE(battlerId, type)((gBattleMons[battlerId].type1 == type || gBattleMons[battlerId].type2 == type))
#define IS_BATTLER_OF_TYPE(battlerId, type)((gBattleMons[battlerId].types[0] == type || gBattleMons[battlerId].types[1] == type))
#define SET_BATTLER_TYPE(battlerId, type) \
{ \
gBattleMons[battlerId].type1 = type; \
gBattleMons[battlerId].type2 = type; \
gBattleMons[battlerId].types[0] = type; \
gBattleMons[battlerId].types[1] = type; \
}
#define GET_STAT_BUFF_ID(n)((n & 0xF)) // first four bits 0x1, 0x2, 0x4, 0x8

View File

@@ -124,8 +124,7 @@ struct ChooseMoveStruct
u8 currentPp[MAX_MON_MOVES];
u8 maxPp[MAX_MON_MOVES];
u16 species;
u8 monType1;
u8 monType2;
u8 monTypes[2];
};
enum

View File

@@ -276,8 +276,7 @@ struct BattlePokemon
/*0x17*/ u32 abilityNum:1;
/*0x18*/ s8 statStages[NUM_BATTLE_STATS];
/*0x20*/ u8 ability;
/*0x21*/ u8 type1;
/*0x22*/ u8 type2;
/*0x21*/ u8 types[2];
/*0x23*/ u8 unknown;
/*0x24*/ u8 pp[MAX_MON_MOVES];
/*0x28*/ u16 hp;

View File

@@ -1119,16 +1119,16 @@ static void Cmd_get_type(void)
switch (typeVar)
{
case AI_TYPE1_USER: // AI user primary type
AI_THINKING_STRUCT->funcResult = gBattleMons[sBattler_AI].type1;
AI_THINKING_STRUCT->funcResult = gBattleMons[sBattler_AI].types[0];
break;
case AI_TYPE1_TARGET: // target primary type
AI_THINKING_STRUCT->funcResult = gBattleMons[gBattlerTarget].type1;
AI_THINKING_STRUCT->funcResult = gBattleMons[gBattlerTarget].types[0];
break;
case AI_TYPE2_USER: // AI user secondary type
AI_THINKING_STRUCT->funcResult = gBattleMons[sBattler_AI].type2;
AI_THINKING_STRUCT->funcResult = gBattleMons[sBattler_AI].types[1];
break;
case AI_TYPE2_TARGET: // target secondary type
AI_THINKING_STRUCT->funcResult = gBattleMons[gBattlerTarget].type2;
AI_THINKING_STRUCT->funcResult = gBattleMons[gBattlerTarget].types[1];
break;
case AI_TYPE_MOVE: // type of move being pointed to
AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->moveConsidered].type;
@@ -1527,7 +1527,7 @@ static void Cmd_if_type_effectiveness(void)
// TypeCalc does not assign to gMoveResultFlags, Cmd_typecalc does
// This makes the check for gMoveResultFlags below always fail
// This is how you get the "dual non-immunity" glitch, where AI
// This is how you get the "dual non-immunity" glitch, where AI
// will use ineffective moves on immune pokémon if the second type
// has a non-neutral, non-immune effectiveness
#ifdef BUGFIX

View File

@@ -706,8 +706,8 @@ u8 GetMostSuitableMonToSwitchInto(void)
u8 type1 = gSpeciesInfo[species].types[0];
u8 type2 = gSpeciesInfo[species].types[1];
u8 typeDmg = TYPE_MUL_NORMAL;
ModulateByTypeEffectiveness(gBattleMons[opposingBattler].type1, type1, type2, &typeDmg);
ModulateByTypeEffectiveness(gBattleMons[opposingBattler].type2, type1, type2, &typeDmg);
ModulateByTypeEffectiveness(gBattleMons[opposingBattler].types[0], type1, type2, &typeDmg);
ModulateByTypeEffectiveness(gBattleMons[opposingBattler].types[1], type1, type2, &typeDmg);
/* Possible bug: this comparison gives the type that takes the most damage, when
a "good" AI would want to select the type that takes the least damage. Unknown if this

View File

@@ -485,7 +485,7 @@ static void HandleInputChooseMove(void)
PlaySE(SE_SELECT);
if (moveInfo->moves[gMoveSelectionCursor[gActiveBattler]] == MOVE_CURSE)
{
if (moveInfo->monType1 != TYPE_GHOST && moveInfo->monType2 != TYPE_GHOST)
if (moveInfo->monTypes[0] != TYPE_GHOST && moveInfo->monTypes[1] != TYPE_GHOST)
moveTarget = MOVE_TARGET_USER;
else
moveTarget = MOVE_TARGET_SELECTED;

View File

@@ -264,7 +264,7 @@ u16 ChooseMoveAndTargetInBattlePalace(void)
if (moveInfo->moves[chosenMoveId] == MOVE_CURSE)
{
if (moveInfo->monType1 != TYPE_GHOST && moveInfo->monType2 != TYPE_GHOST)
if (moveInfo->monTypes[0] != TYPE_GHOST && moveInfo->monTypes[1] != TYPE_GHOST)
moveTarget = MOVE_TARGET_USER;
else
moveTarget = MOVE_TARGET_SELECTED;

View File

@@ -3343,8 +3343,8 @@ void FaintClearSetData(void)
gBattleResources->flags->flags[gActiveBattler] = 0;
gBattleMons[gActiveBattler].type1 = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[0];
gBattleMons[gActiveBattler].type2 = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[1];
gBattleMons[gActiveBattler].types[0] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[0];
gBattleMons[gActiveBattler].types[1] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[1];
ClearBattlerMoveHistory(gActiveBattler);
ClearBattlerAbilityHistory(gActiveBattler);
@@ -3411,8 +3411,8 @@ static void BattleIntroDrawTrainersOrMonsSprites(void)
for (i = 0; i < sizeof(struct BattlePokemon); i++)
ptr[i] = gBattleBufferB[gActiveBattler][4 + i];
gBattleMons[gActiveBattler].type1 = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[0];
gBattleMons[gActiveBattler].type2 = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[1];
gBattleMons[gActiveBattler].types[0] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[0];
gBattleMons[gActiveBattler].types[1] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[1];
gBattleMons[gActiveBattler].ability = GetAbilityBySpecies(gBattleMons[gActiveBattler].species, gBattleMons[gActiveBattler].abilityNum);
hpOnSwitchout = &gBattleStruct->hpOnSwitchout[GetBattlerSide(gActiveBattler)];
*hpOnSwitchout = gBattleMons[gActiveBattler].hp;
@@ -4173,8 +4173,8 @@ static void HandleTurnActionSelectionState(void)
struct ChooseMoveStruct moveInfo;
moveInfo.species = gBattleMons[gActiveBattler].species;
moveInfo.monType1 = gBattleMons[gActiveBattler].type1;
moveInfo.monType2 = gBattleMons[gActiveBattler].type2;
moveInfo.monTypes[0] = gBattleMons[gActiveBattler].types[0];
moveInfo.monTypes[1] = gBattleMons[gActiveBattler].types[1];
for (i = 0; i < MAX_MON_MOVES; i++)
{

View File

@@ -1395,11 +1395,11 @@ static void Cmd_typecalc(void)
else if (TYPE_EFFECT_ATK_TYPE(i) == moveType)
{
// check type1
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type1)
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[0])
ModulateDmgByType(TYPE_EFFECT_MULTIPLIER(i));
// check type2
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type2 &&
gBattleMons[gBattlerTarget].type1 != gBattleMons[gBattlerTarget].type2)
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[1] &&
gBattleMons[gBattlerTarget].types[0] != gBattleMons[gBattlerTarget].types[1])
ModulateDmgByType(TYPE_EFFECT_MULTIPLIER(i));
}
i += 3;
@@ -1454,14 +1454,14 @@ static void CheckWonderGuardAndLevitate(void)
if (TYPE_EFFECT_ATK_TYPE(i) == moveType)
{
// check no effect
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type1
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[0]
&& TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT)
{
gMoveResultFlags |= MOVE_RESULT_DOESNT_AFFECT_FOE;
gProtectStructs[gBattlerAttacker].targetNotAffected = 1;
}
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type2 &&
gBattleMons[gBattlerTarget].type1 != gBattleMons[gBattlerTarget].type2 &&
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[1] &&
gBattleMons[gBattlerTarget].types[0] != gBattleMons[gBattlerTarget].types[1] &&
TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT)
{
gMoveResultFlags |= MOVE_RESULT_DOESNT_AFFECT_FOE;
@@ -1469,18 +1469,18 @@ static void CheckWonderGuardAndLevitate(void)
}
// check super effective
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type1 && TYPE_EFFECT_MULTIPLIER(i) == 20)
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[0] && TYPE_EFFECT_MULTIPLIER(i) == 20)
flags |= 1;
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type2
&& gBattleMons[gBattlerTarget].type1 != gBattleMons[gBattlerTarget].type2
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[1]
&& gBattleMons[gBattlerTarget].types[0] != gBattleMons[gBattlerTarget].types[1]
&& TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE)
flags |= 1;
// check not very effective
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type1 && TYPE_EFFECT_MULTIPLIER(i) == 5)
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[0] && TYPE_EFFECT_MULTIPLIER(i) == 5)
flags |= 2;
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type2
&& gBattleMons[gBattlerTarget].type1 != gBattleMons[gBattlerTarget].type2
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[1]
&& gBattleMons[gBattlerTarget].types[0] != gBattleMons[gBattlerTarget].types[1]
&& TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NOT_EFFECTIVE)
flags |= 2;
}
@@ -1570,11 +1570,11 @@ u8 TypeCalc(u16 move, u8 attacker, u8 defender)
else if (TYPE_EFFECT_ATK_TYPE(i) == moveType)
{
// check type1
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[defender].type1)
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[defender].types[0])
ModulateDmgByType2(TYPE_EFFECT_MULTIPLIER(i), move, &flags);
// check type2
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[defender].type2 &&
gBattleMons[defender].type1 != gBattleMons[defender].type2)
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[defender].types[1] &&
gBattleMons[defender].types[0] != gBattleMons[defender].types[1])
ModulateDmgByType2(TYPE_EFFECT_MULTIPLIER(i), move, &flags);
}
i += 3;
@@ -3971,7 +3971,7 @@ static void Cmd_jumpiftype2(void)
{
u8 battlerId = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
if (gBattlescriptCurrInstr[2] == gBattleMons[battlerId].type1 || gBattlescriptCurrInstr[2] == gBattleMons[battlerId].type2)
if (gBattlescriptCurrInstr[2] == gBattleMons[battlerId].types[0] || gBattlescriptCurrInstr[2] == gBattleMons[battlerId].types[1])
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3);
else
gBattlescriptCurrInstr += 7;
@@ -4520,7 +4520,7 @@ static void Cmd_typecalc2(void)
if (TYPE_EFFECT_ATK_TYPE(i) == moveType)
{
// check type1
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type1)
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[0])
{
if (TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT)
{
@@ -4537,22 +4537,22 @@ static void Cmd_typecalc2(void)
}
}
// check type2
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type2)
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[1])
{
if (gBattleMons[gBattlerTarget].type1 != gBattleMons[gBattlerTarget].type2
if (gBattleMons[gBattlerTarget].types[0] != gBattleMons[gBattlerTarget].types[1]
&& TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT)
{
gMoveResultFlags |= MOVE_RESULT_DOESNT_AFFECT_FOE;
break;
}
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type2
&& gBattleMons[gBattlerTarget].type1 != gBattleMons[gBattlerTarget].type2
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[1]
&& gBattleMons[gBattlerTarget].types[0] != gBattleMons[gBattlerTarget].types[1]
&& TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NOT_EFFECTIVE)
{
flags |= MOVE_RESULT_NOT_VERY_EFFECTIVE;
}
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type2
&& gBattleMons[gBattlerTarget].type1 != gBattleMons[gBattlerTarget].type2
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].types[1]
&& gBattleMons[gBattlerTarget].types[0] != gBattleMons[gBattlerTarget].types[1]
&& TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE)
{
flags |= MOVE_RESULT_SUPER_EFFECTIVE;
@@ -4623,8 +4623,8 @@ static void Cmd_switchindataupdate(void)
for (i = 0; i < sizeof(struct BattlePokemon); i++)
monData[i] = gBattleBufferB[gActiveBattler][4 + i];
gBattleMons[gActiveBattler].type1 = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[0];
gBattleMons[gActiveBattler].type2 = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[1];
gBattleMons[gActiveBattler].types[0] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[0];
gBattleMons[gActiveBattler].types[1] = gSpeciesInfo[gBattleMons[gActiveBattler].species].types[1];
gBattleMons[gActiveBattler].ability = GetAbilityBySpecies(gBattleMons[gActiveBattler].species, gBattleMons[gActiveBattler].abilityNum);
// check knocked off item
@@ -7354,8 +7354,8 @@ static void Cmd_tryconversiontypechange(void)
else
moveType = TYPE_NORMAL;
}
if (moveType != gBattleMons[gBattlerAttacker].type1
&& moveType != gBattleMons[gBattlerAttacker].type2)
if (moveType != gBattleMons[gBattlerAttacker].types[0]
&& moveType != gBattleMons[gBattlerAttacker].types[1])
{
break;
}
@@ -7381,7 +7381,7 @@ static void Cmd_tryconversiontypechange(void)
moveType = TYPE_NORMAL;
}
}
while (moveType == gBattleMons[gBattlerAttacker].type1 || moveType == gBattleMons[gBattlerAttacker].type2);
while (moveType == gBattleMons[gBattlerAttacker].types[0] || moveType == gBattleMons[gBattlerAttacker].types[1]);
SET_BATTLER_TYPE(gBattlerAttacker, moveType);
PREPARE_TYPE_BUFFER(gBattleTextBuff1, moveType);
@@ -7548,12 +7548,12 @@ static void Cmd_weatherdamage(void)
{
if (gBattleWeather & B_WEATHER_SANDSTORM)
{
if (gBattleMons[gBattlerAttacker].type1 != TYPE_ROCK
&& gBattleMons[gBattlerAttacker].type1 != TYPE_STEEL
&& gBattleMons[gBattlerAttacker].type1 != TYPE_GROUND
&& gBattleMons[gBattlerAttacker].type2 != TYPE_ROCK
&& gBattleMons[gBattlerAttacker].type2 != TYPE_STEEL
&& gBattleMons[gBattlerAttacker].type2 != TYPE_GROUND
if (gBattleMons[gBattlerAttacker].types[0] != TYPE_ROCK
&& gBattleMons[gBattlerAttacker].types[0] != TYPE_STEEL
&& gBattleMons[gBattlerAttacker].types[0] != TYPE_GROUND
&& gBattleMons[gBattlerAttacker].types[1] != TYPE_ROCK
&& gBattleMons[gBattlerAttacker].types[1] != TYPE_STEEL
&& gBattleMons[gBattlerAttacker].types[1] != TYPE_GROUND
&& gBattleMons[gBattlerAttacker].ability != ABILITY_SAND_VEIL
&& !(gStatuses3[gBattlerAttacker] & STATUS3_UNDERGROUND)
&& !(gStatuses3[gBattlerAttacker] & STATUS3_UNDERWATER))

View File

@@ -4670,8 +4670,8 @@ void CopyPlayerPartyMonToBattleData(u8 battlerId, u8 partyIndex)
gBattleMons[battlerId].isEgg = GetMonData(&gPlayerParty[partyIndex], MON_DATA_IS_EGG, NULL);
gBattleMons[battlerId].abilityNum = GetMonData(&gPlayerParty[partyIndex], MON_DATA_ABILITY_NUM, NULL);
gBattleMons[battlerId].otId = GetMonData(&gPlayerParty[partyIndex], MON_DATA_OT_ID, NULL);
gBattleMons[battlerId].type1 = gSpeciesInfo[gBattleMons[battlerId].species].types[0];
gBattleMons[battlerId].type2 = gSpeciesInfo[gBattleMons[battlerId].species].types[1];
gBattleMons[battlerId].types[0] = gSpeciesInfo[gBattleMons[battlerId].species].types[0];
gBattleMons[battlerId].types[1] = gSpeciesInfo[gBattleMons[battlerId].species].types[1];
gBattleMons[battlerId].ability = GetAbilityBySpecies(gBattleMons[battlerId].species, gBattleMons[battlerId].abilityNum);
GetMonData(&gPlayerParty[partyIndex], MON_DATA_NICKNAME, nickname);
StringCopy_Nickname(gBattleMons[battlerId].nickname, nickname);