Change abilities in base stats to array

This commit is contained in:
DizzyEggg 2019-05-14 15:42:55 +02:00 committed by huderlem
parent 33979f0fa6
commit 4ae1e014bc
9 changed files with 417 additions and 805 deletions

View File

@ -329,8 +329,7 @@ struct BaseStats
/* 0x13 */ u8 growthRate;
/* 0x14 */ u8 eggGroup1;
/* 0x15 */ u8 eggGroup2;
/* 0x16 */ u8 ability1;
/* 0x17 */ u8 ability2;
/* 0x16 */ u8 abilities[2];
/* 0x18 */ u8 safariZoneFleeRate;
/* 0x19 */ u8 bodyColor : 7;
u8 noFlip : 1;

View File

@ -1364,24 +1364,24 @@ static void BattleAICmd_get_ability(void)
return;
}
if (gBaseStats[gBattleMons[battlerId].species].ability1 != ABILITY_NONE)
if (gBaseStats[gBattleMons[battlerId].species].abilities[0] != ABILITY_NONE)
{
if (gBaseStats[gBattleMons[battlerId].species].ability2 != ABILITY_NONE)
if (gBaseStats[gBattleMons[battlerId].species].abilities[1] != ABILITY_NONE)
{
// AI has no knowledge of opponent, so it guesses which ability.
if (Random() & 1)
AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[battlerId].species].ability1;
AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[battlerId].species].abilities[0];
else
AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[battlerId].species].ability2;
AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[battlerId].species].abilities[1];
}
else
{
AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[battlerId].species].ability1; // It's definitely ability 1.
AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[battlerId].species].abilities[0]; // It's definitely ability 1.
}
}
else
{
AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[battlerId].species].ability2; // AI can't actually reach this part since no pokemon has ability 2 and no ability 1.
AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[battlerId].species].abilities[1]; // AI can't actually reach this part since no pokemon has ability 2 and no ability 1.
}
}
else
@ -1412,15 +1412,15 @@ static void BattleAICmd_check_ability(void)
{
ability = gBattleMons[battlerId].ability;
}
else if (gBaseStats[gBattleMons[battlerId].species].ability1 != ABILITY_NONE)
else if (gBaseStats[gBattleMons[battlerId].species].abilities[0] != ABILITY_NONE)
{
if (gBaseStats[gBattleMons[battlerId].species].ability2 != ABILITY_NONE)
if (gBaseStats[gBattleMons[battlerId].species].abilities[1] != ABILITY_NONE)
{
u8 abilityDummyVariable = ability; // Needed to match.
if (gBaseStats[gBattleMons[battlerId].species].ability1 != abilityDummyVariable
&& gBaseStats[gBattleMons[battlerId].species].ability2 != abilityDummyVariable)
if (gBaseStats[gBattleMons[battlerId].species].abilities[0] != abilityDummyVariable
&& gBaseStats[gBattleMons[battlerId].species].abilities[1] != abilityDummyVariable)
{
ability = gBaseStats[gBattleMons[battlerId].species].ability1;
ability = gBaseStats[gBattleMons[battlerId].species].abilities[0];
}
else
{
@ -1429,12 +1429,12 @@ static void BattleAICmd_check_ability(void)
}
else
{
ability = gBaseStats[gBattleMons[battlerId].species].ability1;
ability = gBaseStats[gBattleMons[battlerId].species].abilities[0];
}
}
else
{
ability = gBaseStats[gBattleMons[battlerId].species].ability2; // AI can't actually reach this part since no pokemon has ability 2 and no ability 1.
ability = gBaseStats[gBattleMons[battlerId].species].abilities[1]; // AI can't actually reach this part since no pokemon has ability 2 and no ability 1.
}
}
else

View File

@ -198,9 +198,9 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)
species = GetMonData(&party[i], MON_DATA_SPECIES);
if (GetMonData(&party[i], MON_DATA_ABILITY_NUM) != 0)
monAbility = gBaseStats[species].ability2;
monAbility = gBaseStats[species].abilities[1];
else
monAbility = gBaseStats[species].ability1;
monAbility = gBaseStats[species].abilities[0];
if (absorbingTypeAbility == monAbility && Random() & 1)
{
@ -393,9 +393,9 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent)
species = GetMonData(&party[i], MON_DATA_SPECIES);
if (GetMonData(&party[i], MON_DATA_ABILITY_NUM) != 0)
monAbility = gBaseStats[species].ability2;
monAbility = gBaseStats[species].abilities[1];
else
monAbility = gBaseStats[species].ability1;
monAbility = gBaseStats[species].abilities[0];
moveFlags = AI_TypeCalc(gLastLandedMoves[gActiveBattler], species, monAbility);
if (moveFlags & flags)

View File

@ -2903,7 +2903,7 @@ static int GetTypeEffectivenessPoints(int move, int targetSpecies, int arg2)
defType1 = gBaseStats[targetSpecies].type1;
defType2 = gBaseStats[targetSpecies].type2;
defAbility = gBaseStats[targetSpecies].ability1;
defAbility = gBaseStats[targetSpecies].abilities[0];
moveType = gBattleMoves[move].type;
if (defAbility == ABILITY_LEVITATE && moveType == TYPE_GROUND)
@ -5447,9 +5447,9 @@ static u16 GetWinningMove(int winnerTournamentId, int loserTournamentId, u8 roun
targetSpecies = gFacilityTrainerMons[gSaveBlock2Ptr->frontier.domeMonIds[loserTournamentId][k]].species;
if (var & 1)
targetAbility = gBaseStats[targetSpecies].ability2;
targetAbility = gBaseStats[targetSpecies].abilities[1];
else
targetAbility = gBaseStats[targetSpecies].ability1;
targetAbility = gBaseStats[targetSpecies].abilities[0];
var = AI_TypeCalc(moveIds[i * 4 + j], targetSpecies, targetAbility);
if (var & MOVE_RESULT_NOT_VERY_EFFECTIVE && var & MOVE_RESULT_SUPER_EFFECTIVE)

View File

@ -1152,7 +1152,7 @@ bool32 TryGenerateBattlePikeWildMon(bool8 checkKeenEyeIntimidate)
MON_DATA_EXP,
&gExperienceTables[gBaseStats[wildMons[headerId][pikeMonId].species].growthRate][monLevel]);
if (gBaseStats[wildMons[headerId][pikeMonId].species].ability2)
if (gBaseStats[wildMons[headerId][pikeMonId].species].abilities[1])
abilityNum = Random() % 2;
else
abilityNum = 0;

View File

@ -1409,7 +1409,7 @@ void GenerateBattlePyramidWildMon(void)
break;
case 2:
default:
if (gBaseStats[wildMons[id].species].ability2)
if (gBaseStats[wildMons[id].species].abilities[1])
{
i = GetMonData(&gEnemyParty[0], MON_DATA_PERSONALITY, NULL) % 2;
SetMonData(&gEnemyParty[0], MON_DATA_ABILITY_NUM, &i);

View File

@ -9845,9 +9845,9 @@ static void atkE5_pickup(void)
heldItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM);
if (GetMonData(&gPlayerParty[i], MON_DATA_ABILITY_NUM))
ability = gBaseStats[species].ability2;
ability = gBaseStats[species].abilities[1];
else
ability = gBaseStats[species].ability1;
ability = gBaseStats[species].abilities[0];
if (ability == ABILITY_PICKUP
&& species != 0
@ -9868,9 +9868,9 @@ static void atkE5_pickup(void)
heldItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM);
if (GetMonData(&gPlayerParty[i], MON_DATA_ABILITY_NUM))
ability = gBaseStats[species].ability2;
ability = gBaseStats[species].abilities[1];
else
ability = gBaseStats[species].ability1;
ability = gBaseStats[species].abilities[0];
if (ability == ABILITY_PICKUP
&& species != 0

File diff suppressed because it is too large Load Diff

View File

@ -2248,7 +2248,7 @@ void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV,
SetBoxMonData(boxMon, MON_DATA_SPDEF_IV, &iv);
}
if (gBaseStats[species].ability2)
if (gBaseStats[species].abilities[1])
{
value = personality & 1;
SetBoxMonData(boxMon, MON_DATA_ABILITY_NUM, &value);
@ -4432,9 +4432,9 @@ u8 GetMonsStateToDoubles_2(void)
u8 GetAbilityBySpecies(u16 species, bool8 abilityNum)
{
if (abilityNum)
gLastUsedAbility = gBaseStats[species].ability2;
gLastUsedAbility = gBaseStats[species].abilities[1];
else
gLastUsedAbility = gBaseStats[species].ability1;
gLastUsedAbility = gBaseStats[species].abilities[0];
return gLastUsedAbility;
}