From 289acf7c32d08606daf9846089d9b4df0e6c50f6 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Thu, 18 Jan 2024 17:01:42 -0300 Subject: [PATCH 1/2] Fix braces style --- src/battle_ai_main.c | 7 ++++--- src/battle_ai_switch_items.c | 18 ++++++++++++------ src/battle_ai_util.c | 3 ++- src/battle_anim.c | 16 ++++++++++------ src/battle_anim_normal.c | 6 ++++-- src/battle_util.c | 16 +++++++++++----- src/daycare.c | 3 ++- src/field_effect.c | 3 ++- 8 files changed, 47 insertions(+), 25 deletions(-) diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index 8465da05b203..e9732c3423fa 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -548,9 +548,9 @@ static u32 ChooseMoveOrAction_Singles(u32 battlerAi) AI_THINKING_STRUCT->aiLogicId++; } - for (i = 0; i < MAX_MON_MOVES; i++) { + for (i = 0; i < MAX_MON_MOVES; i++) + { gBattleStruct->aiFinalScore[battlerAi][gBattlerTarget][i] = AI_THINKING_STRUCT->score[i]; - } // Check special AI actions. @@ -676,7 +676,8 @@ static u32 ChooseMoveOrAction_Doubles(u32 battlerAi) } } - for (j = 0; j < MAX_MON_MOVES; j++) { + for (j = 0; j < MAX_MON_MOVES; j++) + { gBattleStruct->aiFinalScore[battlerAi][gBattlerTarget][j] = AI_THINKING_STRUCT->score[j]; } } diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index 299d420de90e..b61db988aded 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -597,7 +597,8 @@ static bool32 ShouldSwitchIfAbilityBenefit(u32 battler, bool32 emitResult) ||IsNeutralizingGasOnField()) return FALSE; - switch(AI_DATA->abilities[battler]) { + switch(AI_DATA->abilities[battler]) + { case ABILITY_NATURAL_CURE: moduloChance = 4; //25% //Attempt to cure bad ailment @@ -2001,7 +2002,8 @@ static bool32 AiExpectsToFaintPlayer(u32 battler) if (GetBattlerSide(target) != GetBattlerSide(battler) && CanIndexMoveFaintTarget(battler, target, gBattleStruct->aiMoveOrAction[battler], 0) - && AI_WhoStrikesFirst(battler, target, GetAIChosenMove(battler)) == AI_IS_FASTER) { + && AI_WhoStrikesFirst(battler, target, GetAIChosenMove(battler)) == AI_IS_FASTER) + { // We expect to faint the target and move first -> dont use an item return TRUE; } @@ -2127,7 +2129,8 @@ static bool32 AI_ShouldHeal(u32 battler, u32 healAmount) if (gBattleMons[battler].hp < gBattleMons[battler].maxHP / 4 || gBattleMons[battler].hp == 0 - || (healAmount != 0 && gBattleMons[battler].maxHP - gBattleMons[battler].hp > healAmount)) { + || (healAmount != 0 && gBattleMons[battler].maxHP - gBattleMons[battler].hp > healAmount)) + { // We have low enough HP to consider healing shouldHeal = !AI_OpponentCanFaintAiWithMod(battler, healAmount); // if target can kill us even after we heal, why bother } @@ -2139,9 +2142,12 @@ static bool32 AI_OpponentCanFaintAiWithMod(u32 battler, u32 healAmount) { u32 i; // Check special cases to NOT heal - for (i = 0; i < gBattlersCount; i++) { - if (GetBattlerSide(i) == B_SIDE_PLAYER) { - if (CanTargetFaintAiWithMod(i, battler, healAmount, 0)) { + for (i = 0; i < gBattlersCount; i++) + { + if (GetBattlerSide(i) == B_SIDE_PLAYER) + { + if (CanTargetFaintAiWithMod(i, battler, healAmount, 0)) + { // Target is expected to faint us return TRUE; } diff --git a/src/battle_ai_util.c b/src/battle_ai_util.c index 5234314ebcf3..6ac8db68368b 100644 --- a/src/battle_ai_util.c +++ b/src/battle_ai_util.c @@ -538,7 +538,8 @@ s32 AI_CalcDamage(u32 move, u32 battlerAtk, u32 battlerDef, u8 *typeEffectivenes u32 i; gBattleStruct->beatUpSlot = 0; dmg = 0; - for (i = 0; i < partyCount; i++) { + for (i = 0; i < partyCount; i++) + { dmg += CalculateMoveDamage(move, battlerAtk, battlerDef, moveType, 0, FALSE, FALSE, FALSE); } gBattleStruct->beatUpSlot = 0; diff --git a/src/battle_anim.c b/src/battle_anim.c index a80cc3d1f7f1..c9e3789ee576 100644 --- a/src/battle_anim.c +++ b/src/battle_anim.c @@ -447,18 +447,21 @@ static u8 GetBattleAnimMoveTargets(u8 battlerArgIndex, u8 *targets) switch (GetBattlerMoveTargetType(gBattleAnimAttacker, gAnimMoveIndex)) { case MOVE_TARGET_FOES_AND_ALLY: - if (IS_ALIVE_AND_PRESENT(BATTLE_PARTNER(BATTLE_OPPOSITE(battler)))) { + if (IS_ALIVE_AND_PRESENT(BATTLE_PARTNER(BATTLE_OPPOSITE(battler)))) + { targets[idx++] = BATTLE_PARTNER(BATTLE_OPPOSITE(battler)); numTargets++; } // fallthrough case MOVE_TARGET_BOTH: - if (IS_ALIVE_AND_PRESENT(battler)) { + if (IS_ALIVE_AND_PRESENT(battler)) + { targets[idx++] = battler; numTargets++; } battler = BATTLE_PARTNER(battler); - if (IS_ALIVE_AND_PRESENT(battler)) { + if (IS_ALIVE_AND_PRESENT(battler)) + { targets[idx++] = battler; numTargets++; } @@ -555,8 +558,8 @@ static void CreateSpriteOnTargets(const struct SpriteTemplate *template, u8 argV if (ntargets == 0) return; - for (i = 0; i < ntargets; i++) { - + for (i = 0; i < ntargets; i++) + { if (overwriteAnimTgt) gBattleAnimArgs[battlerArgIndex] = targets[i]; @@ -673,7 +676,8 @@ static void Cmd_createvisualtaskontargets(void) sBattleAnimScriptPtr++; // copy task arguments - for (i = 0; i < numArgs; i++) { + for (i = 0; i < numArgs; i++) + { gBattleAnimArgs[i] = T1_READ_16(sBattleAnimScriptPtr); sBattleAnimScriptPtr += 2; } diff --git a/src/battle_anim_normal.c b/src/battle_anim_normal.c index 3b2de5ddbbd5..6333cc8183c9 100644 --- a/src/battle_anim_normal.c +++ b/src/battle_anim_normal.c @@ -418,12 +418,14 @@ u32 UnpackSelectedBattlePalettes(s16 selector) switch (moveTarget) { case MOVE_TARGET_BOTH: - if (target) { + if (target) + { targetPartner |= 1; } break; case MOVE_TARGET_FOES_AND_ALLY: - if (target) { + if (target) + { targetPartner |= 1; attackerPartner |= 1; } diff --git a/src/battle_util.c b/src/battle_util.c index e056fcd6e614..d4234db47a4c 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5639,7 +5639,8 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32 switch (GetBattlerAbility(battler)) { case ABILITY_OPPORTUNIST: - if (gProtectStructs[battler].activateOpportunist == 2) { + if (gProtectStructs[battler].activateOpportunist == 2) + { gBattleScripting.savedBattler = gBattlerAttacker; gBattleScripting.battler = gBattlerAttacker = gBattlerAbility = battler; gProtectStructs[battler].activateOpportunist--; @@ -6621,14 +6622,18 @@ static u8 TryConsumeMirrorHerb(u32 battler, bool32 execute) { u8 effect = 0; - if (gProtectStructs[battler].eatMirrorHerb) { + if (gProtectStructs[battler].eatMirrorHerb) + { gLastUsedItem = gBattleMons[battler].item; gBattleScripting.savedBattler = gBattlerAttacker; gBattleScripting.battler = gBattlerAttacker = battler; gProtectStructs[battler].eatMirrorHerb = 0; - if (execute) { + if (execute) + { BattleScriptExecute(BattleScript_MirrorHerbCopyStatChangeEnd2); - } else { + } + else + { BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_MirrorHerbCopyStatChange; } @@ -6882,7 +6887,8 @@ u8 ItemBattleEffects(u8 caseID, u32 battler, bool32 moveTurn) u8 atkHoldEffectParam; u16 atkItem; - if (caseID != ITEMEFFECT_USE_LAST_ITEM) { + if (caseID != ITEMEFFECT_USE_LAST_ITEM) + { gLastUsedItem = gBattleMons[battler].item; battlerHoldEffect = GetBattlerHoldEffect(battler, TRUE); } diff --git a/src/daycare.c b/src/daycare.c index 6ecc4c7669b6..15012ecbf1ec 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -495,7 +495,8 @@ static s32 GetParentToInheritNature(struct DayCare *daycare) #if P_NATURE_INHERITANCE == GEN_3 && (GetBoxMonGender(&daycare->mons[i].mon) == MON_FEMALE || IS_DITTO(GetBoxMonData(&daycare->mons[i].mon, MON_DATA_SPECIES))) #endif - ) { + ) + { slot = i; numWithEverstone++; } diff --git a/src/field_effect.c b/src/field_effect.c index 8309e10b8e2f..bece73b025fb 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -3956,7 +3956,8 @@ static void UseVsSeeker_DoPlayerAnimation(struct Task *task) task->data[0]++; } -static void UseVsSeeker_ResetPlayerGraphics(struct Task *task) { +static void UseVsSeeker_ResetPlayerGraphics(struct Task *task) +{ struct ObjectEvent* playerObj = &gObjectEvents[gPlayerAvatar.objectEventId]; if (!ObjectEventClearHeldMovementIfFinished(playerObj)) From 029d24f780fbca8804a045095746be999c7a19c4 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Thu, 18 Jan 2024 17:31:39 -0300 Subject: [PATCH 2/2] Unified 2 conditions --- src/battle_ai_switch_items.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index b61db988aded..b4940c1ad60a 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -2144,13 +2144,10 @@ static bool32 AI_OpponentCanFaintAiWithMod(u32 battler, u32 healAmount) // Check special cases to NOT heal for (i = 0; i < gBattlersCount; i++) { - if (GetBattlerSide(i) == B_SIDE_PLAYER) + if (GetBattlerSide(i) == B_SIDE_PLAYER && CanTargetFaintAiWithMod(i, battler, healAmount, 0)) { - if (CanTargetFaintAiWithMod(i, battler, healAmount, 0)) - { - // Target is expected to faint us - return TRUE; - } + // Target is expected to faint us + return TRUE; } } return FALSE;