summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjiangzhengwenjz <jiangzhengwenjzw@qq.com>2019-07-18 04:39:01 +0800
committerjiangzhengwenjz <jiangzhengwenjzw@qq.com>2019-07-18 05:06:53 +0800
commitf7af77d22c84d9b8cba25145e26204a05ccf1455 (patch)
treeee1bf474be710622c92fb46690577b73cb655786
parentc7d3ad06b062abf6acb2eaa2b19da86a7acdab19 (diff)
sync documentation of CountAliveMonsInBattle()
-rw-r--r--asm/battle_controller_player.s2
-rw-r--r--asm/battle_script_commands.s4
-rw-r--r--include/pokemon.h15
-rw-r--r--src/pokemon.c41
4 files changed, 31 insertions, 31 deletions
diff --git a/asm/battle_controller_player.s b/asm/battle_controller_player.s
index 2a2419a7b..e3db6d88e 100644
--- a/asm/battle_controller_player.s
+++ b/asm/battle_controller_player.s
@@ -1005,7 +1005,7 @@ _0802EB04:
cmp r0, 0
bne _0802EB3A
movs r0, 0
- bl CountAliveMons
+ bl CountAliveMonsInBattle
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
diff --git a/asm/battle_script_commands.s b/asm/battle_script_commands.s
index 747859147..42d1f653d 100644
--- a/asm/battle_script_commands.s
+++ b/asm/battle_script_commands.s
@@ -19745,7 +19745,7 @@ _0802753C:
cmp r0, 0
beq _080275AC
movs r0, 0x1
- bl CountAliveMons
+ bl CountAliveMonsInBattle
lsls r0, 24
lsrs r1, r0, 24
cmp r1, 0x2
@@ -22207,7 +22207,7 @@ _0802887C:
cmp r0, 0
beq _080288EC
movs r0, 0x1
- bl CountAliveMons
+ bl CountAliveMonsInBattle
lsls r0, 24
lsrs r0, 24
cmp r0, 0x2
diff --git a/include/pokemon.h b/include/pokemon.h
index 971e0b5aa..9dd5850b4 100644
--- a/include/pokemon.h
+++ b/include/pokemon.h
@@ -540,11 +540,6 @@ extern const u16 *const gLevelUpLearnsets[];
extern const u8 gFacilityClassToPicIndex[];
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 ZeroMonData(struct Pokemon *mon);
void ZeroPlayerPartyMons(void);
@@ -568,8 +563,14 @@ void SetBattleMonMoveSlot(struct BattlePokemon *mon, u16 move, u8 slot);
u16 MonTryLearningNewMove(struct Pokemon *mon, bool8 firstMove);
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);
-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 GetBoxMonGender(struct BoxPokemon *boxMon);
u8 GetGenderFromSpeciesAndPersonality(u16 species, u32 personality);
diff --git a/src/pokemon.c b/src/pokemon.c
index 84ef2fb63..755c59555 100644
--- a/src/pokemon.c
+++ b/src/pokemon.c
@@ -2475,13 +2475,13 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de
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);
else
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;
// 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 ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && CountAliveMons(2) == 2)
+ if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && CountAliveMonsInBattle(BATTLE_ALIVE_DEF_SIDE) == 2)
damage = 2 * (damage / 3);
else
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;
// 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;
}
-u8 CountAliveMons(u8 a1)
+u8 CountAliveMonsInBattle(u8 caseId)
{
s32 i;
u8 retVal = 0;
- switch (a1)
+ switch (caseId)
{
- case 0:
+ case BATTLE_ALIVE_EXCEPT_ACTIVE:
for (i = 0; i < 4; i++)
{
if (i != gActiveBattler && !(gAbsentBattlerFlags & gBitTable[i]))
retVal++;
}
break;
- case 1:
+ case BATTLE_ALIVE_ATK_SIDE:
for (i = 0; i < 4; i++)
{
if (GetBattlerSide(i) == GetBattlerSide(sBattler_AI) && !(gAbsentBattlerFlags & gBitTable[i]))
retVal++;
}
break;
- case 2:
+ case BATTLE_ALIVE_DEF_SIDE:
for (i = 0; i < 4; i++)
{
if (GetBattlerSide(i) == GetBattlerSide(gBattlerTarget) && !(gAbsentBattlerFlags & gBitTable[i]))
@@ -2607,29 +2607,28 @@ u8 CountAliveMons(u8 a1)
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))
- return GetBattlerAtPosition(status);
- if (CountAliveMons(0) > 1)
+ return GetBattlerAtPosition(opposing);
+ if (CountAliveMonsInBattle(BATTLE_ALIVE_EXCEPT_ACTIVE) > 1)
{
- u8 val;
+ u8 position;
if ((Random() & 1) == 0)
- val = status ^ 2;
+ position = BATTLE_PARTNER(opposing);
else
- val = status;
- return GetBattlerAtPosition(val);
+ position = opposing;
+ return GetBattlerAtPosition(position);
}
else
{
- if ((gAbsentBattlerFlags & gBitTable[status]))
- return GetBattlerAtPosition(status ^ 2);
+ if ((gAbsentBattlerFlags & gBitTable[opposing]))
+ return GetBattlerAtPosition(BATTLE_PARTNER(opposing));
else
- return GetBattlerAtPosition(status);
+ return GetBattlerAtPosition(opposing);
}
}