Skip to content

Commit

Permalink
Merge pull request #287 from tillgeissler/extend_constant_usage
Browse files Browse the repository at this point in the history
Extend usages of constants and enums
  • Loading branch information
lhearachel authored Nov 1, 2024
2 parents 4665604 + 57acd10 commit 0899ebe
Show file tree
Hide file tree
Showing 72 changed files with 682 additions and 662 deletions.
8 changes: 4 additions & 4 deletions src/battle/battle_controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -1481,7 +1481,7 @@ static void BattleController_CheckMonConditions(BattleSystem *battleSys, BattleC
break;

case MON_COND_CHECK_STATE_BAD_DREAMS:
battleCtx->scriptTemp = BattleSystem_CountAbility(battleSys, battleCtx, 4, battler, ABILITY_BAD_DREAMS);
battleCtx->scriptTemp = BattleSystem_CountAbility(battleSys, battleCtx, COUNT_ALIVE_BATTLERS_THEIR_SIDE_FLAG, battler, ABILITY_BAD_DREAMS);

if ((battleCtx->battleMons[battler].status & MON_CONDITION_SLEEP)
&& Battler_Ability(battleCtx, battler) != ABILITY_MAGIC_GUARD
Expand Down Expand Up @@ -2237,19 +2237,19 @@ static BOOL BattleController_DecrementPP(BattleSystem *battleSys, BattleContext
int ppCost = 1;
if (ATTACKER_SELF_TURN_FLAGS.skipPressureCheck == FALSE && battleCtx->defender != BATTLER_NONE) {
if (battleCtx->moveTemp == MOVE_IMPRISON) {
ppCost += BattleSystem_CountAbility(battleSys, battleCtx, 3, battleCtx->attacker, ABILITY_PRESSURE);
ppCost += BattleSystem_CountAbility(battleSys, battleCtx, COUNT_ALIVE_BATTLERS_THEIR_SIDE, battleCtx->attacker, ABILITY_PRESSURE);
} else {
switch (battleCtx->aiContext.moveTable[battleCtx->moveTemp].range) {
case RANGE_ALL_ADJACENT:
case RANGE_FIELD:
// Number of mons on the field with Pressure
ppCost += BattleSystem_CountAbility(battleSys, battleCtx, 9, battleCtx->attacker, ABILITY_PRESSURE);
ppCost += BattleSystem_CountAbility(battleSys, battleCtx, COUNT_ALIVE_BATTLERS_EXCEPT_ME, battleCtx->attacker, ABILITY_PRESSURE);
break;

case RANGE_ADJACENT_OPPONENTS:
case RANGE_OPPONENT_SIDE:
// Number of mons on the enemy side with Pressure
ppCost += BattleSystem_CountAbility(battleSys, battleCtx, 3, battleCtx->attacker, ABILITY_PRESSURE);
ppCost += BattleSystem_CountAbility(battleSys, battleCtx, COUNT_ALIVE_BATTLERS_THEIR_SIDE, battleCtx->attacker, ABILITY_PRESSURE);
break;

case RANGE_USER_SIDE:
Expand Down
2 changes: 1 addition & 1 deletion src/battle/battle_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1600,7 +1600,7 @@ void ov16_02266B78(BattleSystem *param0, BattleContext *param1, UnkStruct_ov16_0

param2->unk_0C = param1->battleMons[param5].friendship;

if ((BattleSystem_CountAbility(param0, param1, 8, 0, 13) == 0) && (BattleSystem_CountAbility(param0, param1, 8, 0, 76) == 0)) {
if ((BattleSystem_CountAbility(param0, param1, COUNT_ALIVE_BATTLERS, 0, ABILITY_CLOUD_NINE) == 0) && (BattleSystem_CountAbility(param0, param1, COUNT_ALIVE_BATTLERS, 0, ABILITY_AIR_LOCK) == 0)) {
param2->unk_10 = param1->fieldConditionsMask;
} else {
param2->unk_10 = 0;
Expand Down
22 changes: 11 additions & 11 deletions src/battle/battle_io_command.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,27 +628,27 @@ static void ov16_0225C47C(BattleSystem *param0, BattlerData *param1)
v2 = BattleSystem_PartyPokemon(param0, param1->battler, v0->unk_01_0);

if ((v0->unk_18 & 0x200000) == 0) {
for (v1 = 0; v1 < 4; v1++) {
for (v1 = 0; v1 < LEARNED_MOVES_MAX; v1++) {
if ((v0->unk_01_4 & FlagIndex(v1)) == 0) {
Pokemon_SetValue(v2, 54 + v1, (u8 *)&v0->unk_0E[v1]);
Pokemon_SetValue(v2, 58 + v1, (u8 *)&v0->unk_12[v1]);
Pokemon_SetValue(v2, MON_DATA_MOVE1 + v1, (u8 *)&v0->unk_0E[v1]);
Pokemon_SetValue(v2, MON_DATA_MOVE1_CUR_PP + v1, (u8 *)&v0->unk_12[v1]);
}
}
}

if ((v0->unk_08 & FlagIndex(v0->unk_01_0)) == 0) {
Pokemon_SetValue(v2, 6, (u8 *)&v0->unk_0C);
Pokemon_SetValue(v2, MON_DATA_HELD_ITEM, (u8 *)&v0->unk_0C);
}

Pokemon_SetValue(v2, 163, (u8 *)&v0->unk_02);
Pokemon_SetValue(v2, 160, (u8 *)&v0->unk_04);
Pokemon_SetValue(v2, MON_DATA_CURRENT_HP, (u8 *)&v0->unk_02);
Pokemon_SetValue(v2, MON_DATA_STATUS_CONDITION, (u8 *)&v0->unk_04);

if (v0->unk_26) {
Pokemon_SetValue(v2, 112, (u8 *)&v0->unk_1C);
Pokemon_SetValue(v2, MON_DATA_FORM, (u8 *)&v0->unk_1C);
}

if (v0->unk_24) {
Pokemon_SetValue(v2, 10, (u8 *)&v0->unk_20);
Pokemon_SetValue(v2, MON_DATA_ABILITY, (u8 *)&v0->unk_20);
Pokemon_CalcLevelAndStats(v2);
}

Expand Down Expand Up @@ -696,13 +696,13 @@ static void ov16_0225C5E0(BattleSystem *param0, BattlerData *param1)
v1 = BattleSystem_PartyPokemon(param0, param1->battler, v2);

if (v0->unk_01 == 104) {
v4 = 0;
v4 = ABILITY_NONE;
} else {
v4 = Pokemon_GetValue(v1, MON_DATA_ABILITY, NULL);
}

if ((v0->unk_02 != 215) || ((v0->unk_02 == 215) && (v4 != 43))) {
Pokemon_SetValue(v1, 160, (u8 *)&v5);
if ((v0->unk_02 != 215) || ((v0->unk_02 == 215) && (v4 != ABILITY_SOUNDPROOF))) {
Pokemon_SetValue(v1, MON_DATA_STATUS_CONDITION, (u8 *)&v5);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/battle/battle_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -4357,7 +4357,7 @@ BOOL BattleSystem_TriggerAbilityOnHit(BattleSystem *battleSys, BattleContext *ba
case ABILITY_AFTERMATH:
if (battleCtx->defender == battleCtx->faintedMon
&& Battler_Ability(battleCtx, battleCtx->attacker) != ABILITY_MAGIC_GUARD
&& BattleSystem_CountAbility(battleSys, battleCtx, 8, 0, ABILITY_DAMP) == 0
&& BattleSystem_CountAbility(battleSys, battleCtx, COUNT_ALIVE_BATTLERS, 0, ABILITY_DAMP) == 0
&& (battleCtx->battleStatusMask2 & SYSCTL_UTURN_ACTIVE) == FALSE
&& ATTACKING_MON.curHP
&& (battleCtx->moveStatusFlags & MOVE_STATUS_NO_EFFECTS) == FALSE
Expand Down
6 changes: 3 additions & 3 deletions src/battle/battle_script.c
Original file line number Diff line number Diff line change
Expand Up @@ -10922,7 +10922,7 @@ static void BattleScript_CatchMonTask(SysTask *param0, void *param1)
v3 = BattleSystem_PartyPokemon(v2->battleSys, v1, v2->battleCtx->selectedPartySlot[v1]);

if (v19->unk_14 == 0) {
Pokemon_SetValue(v3, 120, v19->unk_18);
Pokemon_SetValue(v3, MON_DATA_NICKNAME_STRBUF_AND_FLAG, v19->unk_18);
ov16_0223F24C(v2->battleSys, (1 + 48));
}

Expand Down Expand Up @@ -10974,9 +10974,9 @@ static void BattleScript_CatchMonTask(SysTask *param0, void *param1)

sub_02079A94(v24, v26);

for (v27 = 0; v27 < 4; v27++) {
for (v27 = 0; v27 < LEARNED_MOVES_MAX; v27++) {
v28 = Pokemon_GetValue(v3, MON_DATA_MOVE1_MAX_PP + v27, NULL);
Pokemon_SetValue(v3, 58 + v27, &v28);
Pokemon_SetValue(v3, MON_DATA_MOVE1_CUR_PP + v27, &v28);
}

if (Pokemon_SetGiratinaForm(v3) != -1) {
Expand Down
2 changes: 1 addition & 1 deletion src/battle/ov16_0223B140.c
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ static void ov16_0223C2C0(BattleSystem *param0, BattleParams *param1)
for (v1 = 0; v1 < Party_GetCurrentCount(param1->parties[v0]); v1++) {
v3 = Party_GetPokemonBySlotIndex(param1->parties[v0], v1);
v5 = Pokemon_GetGender(v3);
Pokemon_SetValue(v3, 111, &v5);
Pokemon_SetValue(v3, MON_DATA_GENDER, &v5);
}
}
}
Expand Down
45 changes: 23 additions & 22 deletions src/battle/ov16_0223DF00.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "constants/items.h"
#include "consts/battle.h"
#include "consts/game_records.h"
#include "consts/species.h"

#include "struct_decls/battle_system.h"
#include "struct_decls/pokedexdata_decl.h"
Expand Down Expand Up @@ -661,7 +662,7 @@ BOOL BattleSystem_UseBagItem(BattleSystem *battleSys, int battler, int partySlot
param = Pokemon_GetValue(mon, MON_DATA_STATUS_CONDITION, NULL);
if (param & MON_CONDITION_PARALYSIS) {
param &= ~MON_CONDITION_PARALYSIS;
Pokemon_SetValue(mon, 160, &param);
Pokemon_SetValue(mon, MON_DATA_STATUS_CONDITION, &param);

if (selectedSlot == partySlot || targetSlot == partySlot) {
param = BattleMon_Get(battleCtx, battler, BATTLEMON_STATUS, NULL);
Expand Down Expand Up @@ -1072,37 +1073,37 @@ void ov16_0223EE70(BattleSystem *param0)
v2 = BattleSystem_PartyPokemon(param0, 0, v0);
v3 = Pokemon_GetValue(v2, MON_DATA_SPECIES_EGG, NULL);

if ((v3 == 412) && (param0->unk_2414[0] & FlagIndex(v0))) {
if ((v3 == SPECIES_BURMY) && (param0->unk_2414[0] & FlagIndex(v0))) {
switch (BattleSystem_Terrain(param0)) {
default:
case 2:
case TERRAIN_GRASS:
v1 = 0;
break;
case 0:
case 1:
case 4:
case 5:
case 17:
case 23:
case TERRAIN_PLAIN:
case TERRAIN_SAND:
case TERRAIN_MOUNTAIN:
case TERRAIN_CAVE:
case TERRAIN_DISTORTION_WORLD:
case TERRAIN_GIRATINA:
v1 = 1;
break;
case 9:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 18:
case 19:
case 20:
case 21:
case 22:
case TERRAIN_BUILDING:
case TERRAIN_BRIDGE:
case TERRAIN_AARON:
case TERRAIN_BERTHA:
case TERRAIN_FLINT:
case TERRAIN_LUCIAN:
case TERRAIN_CYNTHIA:
case TERRAIN_BATTLE_TOWER:
case TERRAIN_BATTLE_FACTORY:
case TERRAIN_BATTLE_ARCADE:
case TERRAIN_BATTLE_CASTLE:
case TERRAIN_BATTLE_HALL:
v1 = 2;
break;
}

Pokemon_SetValue(v2, 112, &v1);
Pokemon_SetValue(v2, MON_DATA_FORM, &v1);
}
}
}
Expand Down
Loading

0 comments on commit 0899ebe

Please sign in to comment.