Suggested changes

- Various style fixes
- Add BATTLE_ALIVE_EXCEPT_ATTACKER case to CountAliveMonsInBattle
This commit is contained in:
BuffelSaft 2022-10-24 22:19:35 +13:00
parent 7bca475d77
commit d9cc98a4fe
5 changed files with 39 additions and 37 deletions

View File

@ -332,6 +332,7 @@
#define BATTLE_ALIVE_EXCEPT_ACTIVE 0 #define BATTLE_ALIVE_EXCEPT_ACTIVE 0
#define BATTLE_ALIVE_ATK_SIDE 1 #define BATTLE_ALIVE_ATK_SIDE 1
#define BATTLE_ALIVE_DEF_SIDE 2 #define BATTLE_ALIVE_DEF_SIDE 2
#define BATTLE_ALIVE_EXCEPT_ATTACKER 3
#define SKIP_FRONT_ANIM (1 << 7) #define SKIP_FRONT_ANIM (1 << 7)

View File

@ -4841,7 +4841,7 @@ static void TurnValuesCleanUp(bool8 var0)
} }
if (gDisableStructs[gActiveBattler].substituteHP == 0) if (gDisableStructs[gActiveBattler].substituteHP == 0)
gBattleMons[gActiveBattler].status2 &= ~(STATUS2_SUBSTITUTE); gBattleMons[gActiveBattler].status2 &= ~STATUS2_SUBSTITUTE;
gSpecialStatuses[gActiveBattler].parentalBondState = PARENTAL_BOND_OFF; gSpecialStatuses[gActiveBattler].parentalBondState = PARENTAL_BOND_OFF;
} }

View File

@ -1451,7 +1451,7 @@ static void Cmd_attackcanceler(void)
if (AtkCanceller_UnableToUseMove()) if (AtkCanceller_UnableToUseMove())
return; return;
if (!gSpecialStatuses[gBattlerAttacker].parentalBondState if (gSpecialStatuses[gBattlerAttacker].parentalBondState == PARENTAL_BOND_OFF
&& GetBattlerAbility(gBattlerAttacker) == ABILITY_PARENTAL_BOND && GetBattlerAbility(gBattlerAttacker) == ABILITY_PARENTAL_BOND
&& IsMoveAffectedByParentalBond(gCurrentMove, gBattlerAttacker) && IsMoveAffectedByParentalBond(gCurrentMove, gBattlerAttacker)
&& !(gAbsentBattlerFlags & gBitTable[gBattlerTarget]) && !(gAbsentBattlerFlags & gBitTable[gBattlerTarget])
@ -14847,14 +14847,12 @@ bool8 IsMoveAffectedByParentalBond(u16 move, u8 battlerId)
{ {
// Both foes are alive, spread move strikes once // Both foes are alive, spread move strikes once
case MOVE_TARGET_BOTH: case MOVE_TARGET_BOTH:
if (IsBattlerAlive(gBattlerTarget) && IsBattlerAlive(BATTLE_PARTNER(gBattlerTarget))) if (CountAliveMonsInBattle(BATTLE_ALIVE_DEF_SIDE) >= 2)
return FALSE; return FALSE;
break; break;
// Either both foes or one foe and its ally are alive; spread move strikes once // Either both foes or one foe and its ally are alive; spread move strikes once
case MOVE_TARGET_FOES_AND_ALLY: case MOVE_TARGET_FOES_AND_ALLY:
if (IsBattlerAlive(BATTLE_PARTNER(gBattlerTarget)) if (CountAliveMonsInBattle(BATTLE_ALIVE_EXCEPT_ATTACKER) >= 2)
|| (IsBattlerAlive(BATTLE_PARTNER(battlerId))
&& (IsBattlerAlive(BATTLE_PARTNER(gBattlerTarget)) || IsBattlerAlive(gBattlerTarget))))
return FALSE; return FALSE;
break; break;
default: default:

View File

@ -10495,8 +10495,7 @@ bool32 CanTargetBattler(u8 battlerAtk, u8 battlerDef, u16 move)
static void SetRandomMultiHitCounter() static void SetRandomMultiHitCounter()
{ {
#if (B_MULTI_HIT_CHANCE >= GEN_5) #if (B_MULTI_HIT_CHANCE >= GEN_5)
{
// Based on Gen 5's odds // Based on Gen 5's odds
// 35% for 2 hits // 35% for 2 hits
// 35% for 3 hits // 35% for 3 hits
@ -10511,9 +10510,7 @@ static void SetRandomMultiHitCounter()
gMultiHitCounter = 4; gMultiHitCounter = 4;
else else
gMultiHitCounter = 5; gMultiHitCounter = 5;
} #else
#else
{
// 2 and 3 hits: 37.5% // 2 and 3 hits: 37.5%
// 4 and 5 hits: 12.5% // 4 and 5 hits: 12.5%
gMultiHitCounter = Random() % 4; gMultiHitCounter = Random() % 4;
@ -10521,6 +10518,5 @@ static void SetRandomMultiHitCounter()
gMultiHitCounter = (Random() % 4) + 2; gMultiHitCounter = (Random() % 4) + 2;
else else
gMultiHitCounter += 2; gMultiHitCounter += 2;
} #endif
#endif
} }

View File

@ -4238,6 +4238,13 @@ u8 CountAliveMonsInBattle(u8 caseId)
retVal++; retVal++;
} }
break; break;
case BATTLE_ALIVE_EXCEPT_ATTACKER:
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
if (i != gBattlerAttacker && !(gAbsentBattlerFlags & gBitTable[i]))
retVal++;
}
break;
} }
return retVal; return retVal;