sync documentation of CountAliveMonsInBattle()

This commit is contained in:
jiangzhengwenjz
2019-07-18 04:39:01 +08:00
parent c7d3ad06b0
commit f7af77d22c
4 changed files with 31 additions and 31 deletions
+1 -1
View File
@@ -1005,7 +1005,7 @@ _0802EB04:
cmp r0, 0 cmp r0, 0
bne _0802EB3A bne _0802EB3A
movs r0, 0 movs r0, 0
bl CountAliveMons bl CountAliveMonsInBattle
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
cmp r0, 0x1 cmp r0, 0x1
+2 -2
View File
@@ -19745,7 +19745,7 @@ _0802753C:
cmp r0, 0 cmp r0, 0
beq _080275AC beq _080275AC
movs r0, 0x1 movs r0, 0x1
bl CountAliveMons bl CountAliveMonsInBattle
lsls r0, 24 lsls r0, 24
lsrs r1, r0, 24 lsrs r1, r0, 24
cmp r1, 0x2 cmp r1, 0x2
@@ -22207,7 +22207,7 @@ _0802887C:
cmp r0, 0 cmp r0, 0
beq _080288EC beq _080288EC
movs r0, 0x1 movs r0, 0x1
bl CountAliveMons bl CountAliveMonsInBattle
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
cmp r0, 0x2 cmp r0, 0x2
+8 -7
View File
@@ -540,11 +540,6 @@ extern const u16 *const gLevelUpLearnsets[];
extern const u8 gFacilityClassToPicIndex[]; extern const u8 gFacilityClassToPicIndex[];
extern const u8 gFacilityClassToTrainerClass[]; extern const u8 gFacilityClassToTrainerClass[];
u8 CountAliveMons(u8 caseId);
#define BATTLE_ALIVE_EXCEPT_ACTIVE 0
#define BATTLE_ALIVE_ATK_SIDE 1
#define BATTLE_ALIVE_DEF_SIDE 2
void ZeroBoxMonData(struct BoxPokemon *boxMon); void ZeroBoxMonData(struct BoxPokemon *boxMon);
void ZeroMonData(struct Pokemon *mon); void ZeroMonData(struct Pokemon *mon);
void ZeroPlayerPartyMons(void); void ZeroPlayerPartyMons(void);
@@ -568,8 +563,14 @@ void SetBattleMonMoveSlot(struct BattlePokemon *mon, u16 move, u8 slot);
u16 MonTryLearningNewMove(struct Pokemon *mon, bool8 firstMove); u16 MonTryLearningNewMove(struct Pokemon *mon, bool8 firstMove);
void DeleteFirstMoveAndGiveMoveToMon(struct Pokemon *mon, u16 move); void DeleteFirstMoveAndGiveMoveToMon(struct Pokemon *mon, u16 move);
s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *defender, u32 move, u16 sideStatus, u16 powerOverride, u8 typeOverride, u8 battlerIdAtk, u8 battlerIdDef); s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *defender, u32 move, u16 sideStatus, u16 powerOverride, u8 typeOverride, u8 battlerIdAtk, u8 battlerIdDef);
u8 CountAliveMons(u8 a1);
u8 GetDefaultMoveTarget(u8 a1); #define BATTLE_ALIVE_EXCEPT_ACTIVE 0
#define BATTLE_ALIVE_ATK_SIDE 1
#define BATTLE_ALIVE_DEF_SIDE 2
u8 CountAliveMonsInBattle(u8 caseId);
u8 GetDefaultMoveTarget(u8 battlerId);
u8 GetMonGender(struct Pokemon *mon); u8 GetMonGender(struct Pokemon *mon);
u8 GetBoxMonGender(struct BoxPokemon *boxMon); u8 GetBoxMonGender(struct BoxPokemon *boxMon);
u8 GetGenderFromSpeciesAndPersonality(u16 species, u32 personality); u8 GetGenderFromSpeciesAndPersonality(u16 species, u32 personality);
+20 -21
View File
@@ -2475,13 +2475,13 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de
if ((sideStatus & SIDE_STATUS_REFLECT) && gCritMultiplier == 1) if ((sideStatus & SIDE_STATUS_REFLECT) && gCritMultiplier == 1)
{ {
if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && CountAliveMons(2) == 2) if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && CountAliveMonsInBattle(BATTLE_ALIVE_DEF_SIDE) == 2)
damage = 2 * (damage / 3); damage = 2 * (damage / 3);
else else
damage /= 2; damage /= 2;
} }
if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && gBattleMoves[move].target == 8 && CountAliveMons(2) == 2) if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && gBattleMoves[move].target == 8 && CountAliveMonsInBattle(BATTLE_ALIVE_DEF_SIDE) == 2)
damage /= 2; damage /= 2;
// moves always do at least 1 damage. // moves always do at least 1 damage.
@@ -2522,13 +2522,13 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de
if ((sideStatus & SIDE_STATUS_LIGHTSCREEN) && gCritMultiplier == 1) if ((sideStatus & SIDE_STATUS_LIGHTSCREEN) && gCritMultiplier == 1)
{ {
if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && CountAliveMons(2) == 2) if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && CountAliveMonsInBattle(BATTLE_ALIVE_DEF_SIDE) == 2)
damage = 2 * (damage / 3); damage = 2 * (damage / 3);
else else
damage /= 2; damage /= 2;
} }
if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && gBattleMoves[move].target == 8 && CountAliveMons(2) == 2) if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && gBattleMoves[move].target == 8 && CountAliveMonsInBattle(BATTLE_ALIVE_DEF_SIDE) == 2)
damage /= 2; damage /= 2;
// are effects of weather negated with cloud nine or air lock // are effects of weather negated with cloud nine or air lock
@@ -2574,28 +2574,28 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de
return damage + 2; return damage + 2;
} }
u8 CountAliveMons(u8 a1) u8 CountAliveMonsInBattle(u8 caseId)
{ {
s32 i; s32 i;
u8 retVal = 0; u8 retVal = 0;
switch (a1) switch (caseId)
{ {
case 0: case BATTLE_ALIVE_EXCEPT_ACTIVE:
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (i != gActiveBattler && !(gAbsentBattlerFlags & gBitTable[i])) if (i != gActiveBattler && !(gAbsentBattlerFlags & gBitTable[i]))
retVal++; retVal++;
} }
break; break;
case 1: case BATTLE_ALIVE_ATK_SIDE:
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (GetBattlerSide(i) == GetBattlerSide(sBattler_AI) && !(gAbsentBattlerFlags & gBitTable[i])) if (GetBattlerSide(i) == GetBattlerSide(sBattler_AI) && !(gAbsentBattlerFlags & gBitTable[i]))
retVal++; retVal++;
} }
break; break;
case 2: case BATTLE_ALIVE_DEF_SIDE:
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (GetBattlerSide(i) == GetBattlerSide(gBattlerTarget) && !(gAbsentBattlerFlags & gBitTable[i])) if (GetBattlerSide(i) == GetBattlerSide(gBattlerTarget) && !(gAbsentBattlerFlags & gBitTable[i]))
@@ -2607,29 +2607,28 @@ u8 CountAliveMons(u8 a1)
return retVal; return retVal;
} }
u8 GetDefaultMoveTarget(u8 a1) u8 GetDefaultMoveTarget(u8 battlerId)
{ {
u8 status = GetBattlerPosition(a1) & 1; u8 opposing = BATTLE_OPPOSITE(GetBattlerPosition(battlerId) & BIT_SIDE);
status ^= 1;
if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE))
return GetBattlerAtPosition(status); return GetBattlerAtPosition(opposing);
if (CountAliveMons(0) > 1) if (CountAliveMonsInBattle(BATTLE_ALIVE_EXCEPT_ACTIVE) > 1)
{ {
u8 val; u8 position;
if ((Random() & 1) == 0) if ((Random() & 1) == 0)
val = status ^ 2; position = BATTLE_PARTNER(opposing);
else else
val = status; position = opposing;
return GetBattlerAtPosition(val); return GetBattlerAtPosition(position);
} }
else else
{ {
if ((gAbsentBattlerFlags & gBitTable[status])) if ((gAbsentBattlerFlags & gBitTable[opposing]))
return GetBattlerAtPosition(status ^ 2); return GetBattlerAtPosition(BATTLE_PARTNER(opposing));
else else
return GetBattlerAtPosition(status); return GetBattlerAtPosition(opposing);
} }
} }