more battle files cleaning

This commit is contained in:
DizzyEggg 2018-03-01 00:59:52 +01:00
parent a28dfd6da4
commit b846015343
22 changed files with 894 additions and 960 deletions

View File

@ -478,6 +478,15 @@ struct BattleStruct
#define IS_MOVE_PHYSICAL(moveType)(moveType < TYPE_MYSTERY)
#define IS_MOVE_SPECIAL(moveType)(moveType > TYPE_MYSTERY)
#define TARGET_TURN_DAMAGED ((gSpecialStatuses[gBattlerTarget].physicalDmg != 0 || gSpecialStatuses[gBattlerTarget].specialDmg != 0))
#define IS_BATTLER_OF_TYPE(battlerId, type)((gBattleMons[battlerId].type1 == type || gBattleMons[battlerId].type2 == type))
#define SET_BATTLER_TYPE(battlerId, type) \
{ \
gBattleMons[battlerId].type1 = type; \
gBattleMons[battlerId].type2 = type; \
}
#define GET_STAT_BUFF_ID(n)((n & 0xF)) // first four bits 0x1, 0x2, 0x4, 0x8
#define GET_STAT_BUFF_VALUE(n)(((n >> 4) & 7)) // 0x10, 0x20, 0x40
#define STAT_BUFF_NEGATIVE 0x80 // 0x80, the sign bit

View File

@ -49,36 +49,36 @@ void PressurePPLose(u8 bankDef, u8 bankAtk, u16 move);
void PressurePPLoseOnUsingPerishSong(u8 bankAtk);
void PressurePPLoseOnUsingImprision(u8 bankAtk);
void MarkAllBattlersForControllerExec(void); // unused
void MarkBattlerForControllerExec(u8 bank);
void MarkBattlerForControllerExec(u8 battlerId);
void sub_803F850(u8 arg0);
void CancelMultiTurnMoves(u8 bank);
bool8 WasUnableToUseMove(u8 bank);
void PrepareStringBattle(u16 stringId, u8 bank);
void CancelMultiTurnMoves(u8 battlerId);
bool8 WasUnableToUseMove(u8 battlerId);
void PrepareStringBattle(u16 stringId, u8 battlerId);
void ResetSentPokesToOpponentValue(void);
void sub_803F9EC(u8 bank);
void sub_803FA70(u8 bank);
void sub_803F9EC(u8 battlerId);
void sub_803FA70(u8 battlerId);
void BattleScriptPush(const u8* bsPtr);
void BattleScriptPushCursor(void);
void BattleScriptPop(void);
u8 TrySetCantSelectMoveBattleScript(void);
u8 CheckMoveLimitations(u8 bank, u8 unusableMoves, u8 check);
u8 CheckMoveLimitations(u8 battlerId, u8 unusableMoves, u8 check);
bool8 AreAllMovesUnusable(void);
u8 GetImprisonedMovesCount(u8 bank, u16 move);
u8 GetImprisonedMovesCount(u8 battlerId, u16 move);
u8 UpdateTurnCounters(void);
u8 TurnBasedEffects(void);
bool8 HandleWishPerishSongOnTurnEnd(void);
bool8 HandleFaintedMonActions(void);
void TryClearRageStatuses(void);
u8 AtkCanceller_UnableToUseMove(void);
bool8 sub_80423F4(u8 bank, u8 r1, u8 r2);
u8 CastformDataTypeChange(u8 bank);
u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg);
bool8 sub_80423F4(u8 battlerId, u8 r1, u8 r2);
u8 CastformDataTypeChange(u8 battlerId);
u8 AbilityBattleEffects(u8 caseID, u8 battlerId, u8 ability, u8 special, u16 moveArg);
void BattleScriptExecute(const u8* BS_ptr);
void BattleScriptPushCursorAndCallback(const u8* BS_ptr);
u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn);
void ClearFuryCutterDestinyBondGrudge(u8 bank);
u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn);
void ClearFuryCutterDestinyBondGrudge(u8 battlerId);
void HandleAction_RunBattleScript(void);
u8 GetMoveTarget(u16 move, u8 useMoveTarget);
u8 GetMoveTarget(u16 move, u8 setTarget);
u8 IsMonDisobedient(void);
#endif // GUARD_BATTLE_UTIL_H

View File

@ -12,10 +12,6 @@
#include "util.h"
#include "constants/battle_ai.h"
#define AIScriptRead32(ptr) ((ptr)[0] | (ptr)[1] << 8 | (ptr)[2] << 16 | (ptr)[3] << 24)
#define AIScriptRead16(ptr) ((ptr)[0] | (ptr)[1] << 8)
#define AIScriptReadPtr(ptr) (const u8*) AIScriptRead32(ptr)
#define AI_ACTION_DONE 0x0001
#define AI_ACTION_FLEE 0x0002
#define AI_ACTION_WATCH 0x0004
@ -652,7 +648,7 @@ static void BattleAICmd_if_random_less_than(void)
u16 random = Random();
if (random % 256 < gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
@ -662,7 +658,7 @@ static void BattleAICmd_if_random_greater_than(void)
u16 random = Random();
if (random % 256 > gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
@ -672,7 +668,7 @@ static void BattleAICmd_if_random_equal(void)
u16 random = Random();
if (random % 256 == gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
@ -682,7 +678,7 @@ static void BattleAICmd_if_random_not_equal(void)
u16 random = Random();
if (random % 256 != gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
@ -707,7 +703,7 @@ static void BattleAICmd_if_hp_less_than(void)
battlerId = gBattlerTarget;
if ((u32)(100 * gBattleMons[battlerId].hp / gBattleMons[battlerId].maxHP) < gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
else
gAIScriptPtr += 7;
}
@ -722,7 +718,7 @@ static void BattleAICmd_if_hp_more_than(void)
battlerId = gBattlerTarget;
if ((u32)(100 * gBattleMons[battlerId].hp / gBattleMons[battlerId].maxHP) > gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
else
gAIScriptPtr += 7;
}
@ -737,7 +733,7 @@ static void BattleAICmd_if_hp_equal(void)
battlerId = gBattlerTarget;
if ((u32)(100 * gBattleMons[battlerId].hp / gBattleMons[battlerId].maxHP) == gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
else
gAIScriptPtr += 7;
}
@ -752,7 +748,7 @@ static void BattleAICmd_if_hp_not_equal(void)
battlerId = gBattlerTarget;
if ((u32)(100 * gBattleMons[battlerId].hp / gBattleMons[battlerId].maxHP) != gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
else
gAIScriptPtr += 7;
}
@ -767,10 +763,10 @@ static void BattleAICmd_if_status(void)
else
battlerId = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2);
status = T1_READ_32(gAIScriptPtr + 2);
if ((gBattleMons[battlerId].status1 & status) != 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
}
@ -785,10 +781,10 @@ static void BattleAICmd_if_not_status(void)
else
battlerId = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2);
status = T1_READ_32(gAIScriptPtr + 2);
if ((gBattleMons[battlerId].status1 & status) == 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
}
@ -803,10 +799,10 @@ static void BattleAICmd_if_status2(void)
else
battlerId = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2);
status = T1_READ_32(gAIScriptPtr + 2);
if ((gBattleMons[battlerId].status2 & status) != 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
}
@ -821,10 +817,10 @@ static void BattleAICmd_if_not_status2(void)
else
battlerId = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2);
status = T1_READ_32(gAIScriptPtr + 2);
if ((gBattleMons[battlerId].status2 & status) == 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
}
@ -839,10 +835,10 @@ static void BattleAICmd_if_status3(void)
else
battlerId = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2);
status = T1_READ_32(gAIScriptPtr + 2);
if ((gStatuses3[battlerId] & status) != 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
}
@ -857,10 +853,10 @@ static void BattleAICmd_if_not_status3(void)
else
battlerId = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2);
status = T1_READ_32(gAIScriptPtr + 2);
if ((gStatuses3[battlerId] & status) == 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
}
@ -876,10 +872,10 @@ static void BattleAICmd_if_side_affecting(void)
battlerId = gBattlerTarget;
side = GET_BATTLER_SIDE(battlerId);
status = AIScriptRead32(gAIScriptPtr + 2);
status = T1_READ_32(gAIScriptPtr + 2);
if ((gSideStatuses[side] & status) != 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
}
@ -895,10 +891,10 @@ static void BattleAICmd_if_not_side_affecting(void)
battlerId = gBattlerTarget;
side = GET_BATTLER_SIDE(battlerId);
status = AIScriptRead32(gAIScriptPtr + 2);
status = T1_READ_32(gAIScriptPtr + 2);
if ((gSideStatuses[side] & status) == 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 6);
else
gAIScriptPtr += 10;
}
@ -906,7 +902,7 @@ static void BattleAICmd_if_not_side_affecting(void)
static void BattleAICmd_if_less_than(void)
{
if (AI_THINKING_STRUCT->funcResult < gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
@ -914,7 +910,7 @@ static void BattleAICmd_if_less_than(void)
static void BattleAICmd_if_more_than(void)
{
if (AI_THINKING_STRUCT->funcResult > gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
@ -922,7 +918,7 @@ static void BattleAICmd_if_more_than(void)
static void BattleAICmd_if_equal(void)
{
if (AI_THINKING_STRUCT->funcResult == gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
@ -930,80 +926,80 @@ static void BattleAICmd_if_equal(void)
static void BattleAICmd_if_not_equal(void)
{
if (AI_THINKING_STRUCT->funcResult != gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
static void BattleAICmd_if_less_than_ptr(void)
{
const u8 *value = AIScriptReadPtr(gAIScriptPtr + 1);
const u8 *value = T1_READ_PTR(gAIScriptPtr + 1);
if (AI_THINKING_STRUCT->funcResult < *value)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 5);
else
gAIScriptPtr += 9;
}
static void BattleAICmd_if_more_than_ptr(void)
{
const u8 *value = AIScriptReadPtr(gAIScriptPtr + 1);
const u8 *value = T1_READ_PTR(gAIScriptPtr + 1);
if (AI_THINKING_STRUCT->funcResult > *value)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 5);
else
gAIScriptPtr += 9;
}
static void BattleAICmd_if_equal_ptr(void)
{
const u8 *value = AIScriptReadPtr(gAIScriptPtr + 1);
const u8 *value = T1_READ_PTR(gAIScriptPtr + 1);
if (AI_THINKING_STRUCT->funcResult == *value)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 5);
else
gAIScriptPtr += 9;
}
static void BattleAICmd_if_not_equal_ptr(void)
{
const u8 *value = AIScriptReadPtr(gAIScriptPtr + 1);
const u8 *value = T1_READ_PTR(gAIScriptPtr + 1);
if (AI_THINKING_STRUCT->funcResult != *value)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 5);
else
gAIScriptPtr += 9;
}
static void BattleAICmd_if_move(void)
{
u16 move = AIScriptRead16(gAIScriptPtr + 1);
u16 move = T1_READ_16(gAIScriptPtr + 1);
if (AI_THINKING_STRUCT->moveConsidered == move)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
else
gAIScriptPtr += 7;
}
static void BattleAICmd_if_not_move(void)
{
u16 move = AIScriptRead16(gAIScriptPtr + 1);
u16 move = T1_READ_16(gAIScriptPtr + 1);
if (AI_THINKING_STRUCT->moveConsidered != move)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
else
gAIScriptPtr += 7;
}
static void BattleAICmd_if_in_bytes(void)
{
const u8 *ptr = AIScriptReadPtr(gAIScriptPtr + 1);
const u8 *ptr = T1_READ_PTR(gAIScriptPtr + 1);
while (*ptr != 0xFF)
{
if (AI_THINKING_STRUCT->funcResult == *ptr)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 5);
return;
}
ptr++;
@ -1013,7 +1009,7 @@ static void BattleAICmd_if_in_bytes(void)
static void BattleAICmd_if_not_in_bytes(void)
{
const u8 *ptr = AIScriptReadPtr(gAIScriptPtr + 1);
const u8 *ptr = T1_READ_PTR(gAIScriptPtr + 1);
while (*ptr != 0xFF)
{
@ -1024,18 +1020,18 @@ static void BattleAICmd_if_not_in_bytes(void)
}
ptr++;
}
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 5);
}
static void BattleAICmd_if_in_hwords(void)
{
const u16 *ptr = (const u16 *)AIScriptReadPtr(gAIScriptPtr + 1);
const u16 *ptr = (const u16 *)T1_READ_PTR(gAIScriptPtr + 1);
while (*ptr != 0xFFFF)
{
if (AI_THINKING_STRUCT->funcResult == *ptr)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 5);
return;
}
ptr++;
@ -1045,7 +1041,7 @@ static void BattleAICmd_if_in_hwords(void)
static void BattleAICmd_if_not_in_hwords(void)
{
const u16 *ptr = (u16 *)AIScriptReadPtr(gAIScriptPtr + 1);
const u16 *ptr = (u16 *)T1_READ_PTR(gAIScriptPtr + 1);
while (*ptr != 0xFFFF)
{
@ -1056,7 +1052,7 @@ static void BattleAICmd_if_not_in_hwords(void)
}
ptr++;
}
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 5);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 5);
}
static void BattleAICmd_if_user_has_attacking_move(void)
@ -1072,7 +1068,7 @@ static void BattleAICmd_if_user_has_attacking_move(void)
if (i == 4)
gAIScriptPtr += 5;
else
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
}
static void BattleAICmd_if_user_has_no_attacking_moves(void)
@ -1088,7 +1084,7 @@ static void BattleAICmd_if_user_has_no_attacking_moves(void)
if (i != 4)
gAIScriptPtr += 5;
else
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
}
static void BattleAICmd_get_turn_count(void)
@ -1237,7 +1233,7 @@ static void BattleAICmd_get_last_used_bank_move(void)
static void BattleAICmd_if_equal_(void) // same as if_equal
{
if (gAIScriptPtr[1] == AI_THINKING_STRUCT->funcResult)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
@ -1245,7 +1241,7 @@ static void BattleAICmd_if_equal_(void) // same as if_equal
static void BattleAICmd_if_not_equal_(void) // same as if_not_equal
{
if (gAIScriptPtr[1] != AI_THINKING_STRUCT->funcResult)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
@ -1253,7 +1249,7 @@ static void BattleAICmd_if_not_equal_(void) // same as if_not_equal
static void BattleAICmd_if_user_goes(void)
{
if (GetWhoStrikesFirst(sBattler_AI, gBattlerTarget, TRUE) == gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
@ -1261,7 +1257,7 @@ static void BattleAICmd_if_user_goes(void)
static void BattleAICmd_if_user_doesnt_go(void)
{
if (GetWhoStrikesFirst(sBattler_AI, gBattlerTarget, TRUE) != gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
@ -1527,7 +1523,7 @@ static void BattleAICmd_if_type_effectiveness(void)
damageVar = gBattleMoveDamage;
if (damageVar == gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
@ -1559,7 +1555,7 @@ static void BattleAICmd_if_status_in_party(void)
party = (GetBattlerSide(battlerId) == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
statusToCompareTo = AIScriptRead32(gAIScriptPtr + 2);
statusToCompareTo = T1_READ_32(gAIScriptPtr + 2);
for (i = 0; i < PARTY_SIZE; i++)
{
@ -1569,7 +1565,7 @@ static void BattleAICmd_if_status_in_party(void)
if (species != SPECIES_NONE && species != SPECIES_EGG && hp != 0 && status == statusToCompareTo)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 6);
return;
}
}
@ -1596,7 +1592,7 @@ static void BattleAICmd_if_status_not_in_party(void)
party = (GetBattlerSide(battlerId) == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
statusToCompareTo = AIScriptRead32(gAIScriptPtr + 2);
statusToCompareTo = T1_READ_32(gAIScriptPtr + 2);
for (i = 0; i < PARTY_SIZE; i++)
{
@ -1610,7 +1606,7 @@ static void BattleAICmd_if_status_not_in_party(void)
}
}
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 6);
}
static void BattleAICmd_get_weather(void)
@ -1630,7 +1626,7 @@ static void BattleAICmd_get_weather(void)
static void BattleAICmd_if_effect(void)
{
if (gBattleMoves[AI_THINKING_STRUCT->moveConsidered].effect == gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
@ -1638,7 +1634,7 @@ static void BattleAICmd_if_effect(void)
static void BattleAICmd_if_not_effect(void)
{
if (gBattleMoves[AI_THINKING_STRUCT->moveConsidered].effect != gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}
@ -1653,7 +1649,7 @@ static void BattleAICmd_if_stat_level_less_than(void)
battlerId = gBattlerTarget;
if (gBattleMons[battlerId].statStages[gAIScriptPtr[2]] < gAIScriptPtr[3])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4);
else
gAIScriptPtr += 8;
}
@ -1668,7 +1664,7 @@ static void BattleAICmd_if_stat_level_more_than(void)
battlerId = gBattlerTarget;
if (gBattleMons[battlerId].statStages[gAIScriptPtr[2]] > gAIScriptPtr[3])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4);
else
gAIScriptPtr += 8;
}
@ -1683,7 +1679,7 @@ static void BattleAICmd_if_stat_level_equal(void)
battlerId = gBattlerTarget;
if (gBattleMons[battlerId].statStages[gAIScriptPtr[2]] == gAIScriptPtr[3])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4);
else
gAIScriptPtr += 8;
}
@ -1698,7 +1694,7 @@ static void BattleAICmd_if_stat_level_not_equal(void)
battlerId = gBattlerTarget;
if (gBattleMons[battlerId].statStages[gAIScriptPtr[2]] != gAIScriptPtr[3])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4);
else
gAIScriptPtr += 8;
}
@ -1727,7 +1723,7 @@ static void BattleAICmd_if_can_faint(void)
gBattleMoveDamage = 1;
if (gBattleMons[gBattlerTarget].hp <= gBattleMoveDamage)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
@ -1754,7 +1750,7 @@ static void BattleAICmd_if_cant_faint(void)
// this macro is missing the damage 0 = 1 assumption.
if (gBattleMons[gBattlerTarget].hp > gBattleMoveDamage)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
@ -1779,7 +1775,7 @@ static void BattleAICmd_if_has_move(void)
}
else
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4);
return;
}
case AI_USER_PARTNER:
@ -1803,7 +1799,7 @@ static void BattleAICmd_if_has_move(void)
}
else
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4);
return;
}
case AI_TARGET:
@ -1820,7 +1816,7 @@ static void BattleAICmd_if_has_move(void)
}
else
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4);
return;
}
}
@ -1847,7 +1843,7 @@ static void BattleAICmd_if_doesnt_have_move(void)
}
else
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4);
return;
}
case AI_TARGET:
@ -1864,7 +1860,7 @@ static void BattleAICmd_if_doesnt_have_move(void)
}
else
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4);
return;
}
}
@ -1886,7 +1882,7 @@ static void BattleAICmd_if_has_move_with_effect(void)
if (i == 4)
gAIScriptPtr += 7;
else
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
break;
case AI_TARGET:
case AI_TARGET_PARTNER:
@ -1899,7 +1895,7 @@ static void BattleAICmd_if_has_move_with_effect(void)
if (i == 4)
gAIScriptPtr += 7;
else
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
break;
}
}
@ -1920,7 +1916,7 @@ static void BattleAICmd_if_doesnt_have_move_with_effect(void)
if (i != 4)
gAIScriptPtr += 7;
else
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
break;
case AI_TARGET:
case AI_TARGET_PARTNER:
@ -1932,7 +1928,7 @@ static void BattleAICmd_if_doesnt_have_move_with_effect(void)
if (i != 4)
gAIScriptPtr += 7;
else
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
break;
}
}
@ -1953,7 +1949,7 @@ static void BattleAICmd_if_any_move_disabled_or_encored(void)
gAIScriptPtr += 7;
return;
}
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
return;
}
else if (gAIScriptPtr[2] != 1) // ignore the macro if its not 0 or 1.
@ -1963,7 +1959,7 @@ static void BattleAICmd_if_any_move_disabled_or_encored(void)
}
else if (gDisableStructs[battlerId].encoredMove != 0)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
return;
}
gAIScriptPtr += 7;
@ -1976,7 +1972,7 @@ static void BattleAICmd_if_curr_move_disabled_or_encored(void)
case 0:
if (gDisableStructs[gActiveBattler].disabledMove == AI_THINKING_STRUCT->moveConsidered)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
return;
}
gAIScriptPtr += 6;
@ -1984,7 +1980,7 @@ static void BattleAICmd_if_curr_move_disabled_or_encored(void)
case 1:
if (gDisableStructs[gActiveBattler].encoredMove == AI_THINKING_STRUCT->moveConsidered)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
return;
}
gAIScriptPtr += 6;
@ -2005,7 +2001,7 @@ static void BattleAICmd_if_random_safari_flee(void)
u8 safariFleeRate = gBattleStruct->field_7B * 5; // safari flee rate, from 0-20
if ((u8)(Random() % 100) < safariFleeRate)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
@ -2048,7 +2044,7 @@ static void BattleAICmd_if_holds_item(void)
var1 = gAIScriptPtr[3];
if ((var1 | var2) == item)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4);
else
gAIScriptPtr += 8;
}
@ -2183,12 +2179,12 @@ static void BattleAICmd_nullsub_57(void)
static void BattleAICmd_call(void)
{
AIStackPushVar(gAIScriptPtr + 5);
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
}
static void BattleAICmd_goto(void)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
}
static void BattleAICmd_end(void)
@ -2204,7 +2200,7 @@ static void BattleAICmd_if_level_cond(void)
case 0: // greater than
if (gBattleMons[sBattler_AI].level > gBattleMons[gBattlerTarget].level)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
return;
}
gAIScriptPtr += 6;
@ -2212,7 +2208,7 @@ static void BattleAICmd_if_level_cond(void)
case 1: // less than
if (gBattleMons[sBattler_AI].level < gBattleMons[gBattlerTarget].level)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
return;
}
gAIScriptPtr += 6;
@ -2220,7 +2216,7 @@ static void BattleAICmd_if_level_cond(void)
case 2: // equal
if (gBattleMons[sBattler_AI].level == gBattleMons[gBattlerTarget].level)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
return;
}
gAIScriptPtr += 6;
@ -2231,7 +2227,7 @@ static void BattleAICmd_if_level_cond(void)
static void BattleAICmd_if_target_taunted(void)
{
if (gDisableStructs[gBattlerTarget].tauntTimer1 != 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
@ -2239,7 +2235,7 @@ static void BattleAICmd_if_target_taunted(void)
static void BattleAICmd_if_target_not_taunted(void)
{
if (gDisableStructs[gBattlerTarget].tauntTimer1 == 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
@ -2247,7 +2243,7 @@ static void BattleAICmd_if_target_not_taunted(void)
static void BattleAICmd_if_target_is_ally(void)
{
if ((sBattler_AI & BIT_SIDE) == (gBattlerTarget & BIT_SIDE))
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
}
@ -2257,7 +2253,7 @@ static void BattleAICmd_if_flash_fired(void)
u8 battlerId = BattleAI_GetWantedBank(gAIScriptPtr[1]);
if (gBattleResources->flags->flags[battlerId] & UNKNOWN_FLAG_FLASH_FIRE)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
}

View File

@ -9,8 +9,6 @@
#include "util.h"
#include "constants/items.h"
extern const u8 * const gItemEffectTable[]; // todo: fix once struct is declared
// this file's functions
static bool8 HasSuperEffectiveMoveAgainstOpponents(bool8 noRng);
static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent);

View File

@ -19,10 +19,6 @@
// sprites start at 10000 and thus must be subtracted of 10000 to account for the true index.
#define GET_TRUE_SPRITE_INDEX(i) ((i - 10000))
#define SCRIPT_READ_16(ptr) ((ptr)[0] | ((ptr)[1] << 8))
#define SCRIPT_READ_32(ptr) (((ptr)[0]) + ((ptr)[1] << 8) + ((ptr)[2] << 16) + ((ptr)[3] << 24))
#define SCRIPT_READ_PTR(ptr) ((const u8*)(SCRIPT_READ_32(ptr)))
#define ANIM_SPRITE_INDEX_COUNT 8
extern u16 gBattle_WIN0H;
@ -352,7 +348,7 @@ static void ScriptCmd_loadspritegfx(void)
u16 index;
sBattleAnimScriptPtr++;
index = SCRIPT_READ_16(sBattleAnimScriptPtr);
index = T1_READ_16(sBattleAnimScriptPtr);
LoadCompressedObjectPicUsingHeap(&gBattleAnimPicTable[GET_TRUE_SPRITE_INDEX(index)]);
LoadCompressedObjectPaletteUsingHeap(&gBattleAnimPaletteTable[GET_TRUE_SPRITE_INDEX(index)]);
sBattleAnimScriptPtr += 2;
@ -366,7 +362,7 @@ static void ScriptCmd_unloadspritegfx(void)
u16 index;
sBattleAnimScriptPtr++;
index = SCRIPT_READ_16(sBattleAnimScriptPtr);
index = T1_READ_16(sBattleAnimScriptPtr);
FreeSpriteTilesByTag(gBattleAnimPicTable[GET_TRUE_SPRITE_INDEX(index)].tag);
FreeSpritePaletteByTag(gBattleAnimPicTable[GET_TRUE_SPRITE_INDEX(index)].tag);
sBattleAnimScriptPtr += 2;
@ -382,7 +378,7 @@ static void ScriptCmd_createsprite(void)
s16 subpriority;
sBattleAnimScriptPtr++;
template = (const struct SpriteTemplate *)(SCRIPT_READ_32(sBattleAnimScriptPtr));
template = (const struct SpriteTemplate *)(T2_READ_32(sBattleAnimScriptPtr));
sBattleAnimScriptPtr += 4;
argVar = sBattleAnimScriptPtr[0];
@ -392,7 +388,7 @@ static void ScriptCmd_createsprite(void)
sBattleAnimScriptPtr++;
for (i = 0; i < argsCount; i++)
{
gBattleAnimArgs[i] = SCRIPT_READ_16(sBattleAnimScriptPtr);
gBattleAnimArgs[i] = T1_READ_16(sBattleAnimScriptPtr);
sBattleAnimScriptPtr += 2;
}
@ -433,7 +429,7 @@ static void ScriptCmd_createvisualtask(void)
sBattleAnimScriptPtr++;
taskFunc = (TaskFunc)SCRIPT_READ_32(sBattleAnimScriptPtr);
taskFunc = (TaskFunc)T2_READ_32(sBattleAnimScriptPtr);
sBattleAnimScriptPtr += 4;
taskPriority = sBattleAnimScriptPtr[0];
@ -444,7 +440,7 @@ static void ScriptCmd_createvisualtask(void)
for (i = 0; i < numArgs; i++)
{
gBattleAnimArgs[i] = SCRIPT_READ_16(sBattleAnimScriptPtr);
gBattleAnimArgs[i] = T1_READ_16(sBattleAnimScriptPtr);
sBattleAnimScriptPtr += 2;
}
@ -542,26 +538,26 @@ static void ScriptCmd_end(void)
static void ScriptCmd_playse(void)
{
sBattleAnimScriptPtr++;
PlaySE(SCRIPT_READ_16(sBattleAnimScriptPtr));
PlaySE(T1_READ_16(sBattleAnimScriptPtr));
sBattleAnimScriptPtr += 2;
}
#define t1_MONBG_BANK 0
#define t1_MONBG_BATTLER 0
#define t1_MON_IN_BG2 1
#define t1_CREATE_ANOTHER_TASK 2
#define t1_IS_SECONDMON_BG 3
#define t2_BANK_SPRITE_ID 0
#define t2_BATTLER_SPRITE_ID 0
#define t2_MON_IN_BG2 5
#define t2_MONBG_BANK 6
#define t2_MONBG_BATTLER 6
static void sub_80A40F4(u8 taskId)
{
u8 newTaskId;
s16 *selfData = gTasks[taskId].data;
u8 bankSpriteId = gBattlerSpriteIds[selfData[t1_MONBG_BANK]];
gSprites[bankSpriteId].invisible = 1;
u8 battlerSpriteId = gBattlerSpriteIds[selfData[t1_MONBG_BATTLER]];
gSprites[battlerSpriteId].invisible = 1;
if (!selfData[t1_CREATE_ANOTHER_TASK])
{
@ -570,9 +566,9 @@ static void sub_80A40F4(u8 taskId)
}
newTaskId = CreateTask(task_pA_ma0A_obj_to_bg_pal, 10);
gTasks[newTaskId].data[t2_BANK_SPRITE_ID] = bankSpriteId;
gTasks[newTaskId].data[1] = gSprites[bankSpriteId].pos1.x + gSprites[bankSpriteId].pos2.x;
gTasks[newTaskId].data[2] = gSprites[bankSpriteId].pos1.y + gSprites[bankSpriteId].pos2.y;
gTasks[newTaskId].data[t2_BATTLER_SPRITE_ID] = battlerSpriteId;
gTasks[newTaskId].data[1] = gSprites[battlerSpriteId].pos1.x + gSprites[battlerSpriteId].pos2.x;
gTasks[newTaskId].data[2] = gSprites[battlerSpriteId].pos1.y + gSprites[battlerSpriteId].pos2.y;
if (!selfData[t1_MON_IN_BG2])
{
@ -586,7 +582,7 @@ static void sub_80A40F4(u8 taskId)
}
gTasks[newTaskId].data[t2_MON_IN_BG2] = selfData[t1_MON_IN_BG2];
gTasks[newTaskId].data[t2_MONBG_BANK] = selfData[t1_MONBG_BANK];
gTasks[newTaskId].data[t2_MONBG_BATTLER] = selfData[t1_MONBG_BATTLER];
sMonAnimTaskIdArray[selfData[t1_IS_SECONDMON_BG]] = newTaskId;
DestroyAnimVisualTask(taskId);
}
@ -595,48 +591,48 @@ static void ScriptCmd_monbg(void)
{
bool8 toBG_2;
u8 taskId;
u8 bank;
u8 battlerId;
u8 animBank;
sBattleAnimScriptPtr++;
animBank = sBattleAnimScriptPtr[0];
if (animBank & ANIM_TARGET)
bank = gBattleAnimTarget;
battlerId = gBattleAnimTarget;
else
bank = gBattleAnimAttacker;
battlerId = gBattleAnimAttacker;
if (IsBattlerSpriteVisible(bank))
if (IsBattlerSpriteVisible(battlerId))
{
u8 position = GetBattlerPosition(bank);
u8 position = GetBattlerPosition(battlerId);
if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest())
toBG_2 = FALSE;
else
toBG_2 = TRUE;
sub_80A438C(bank, toBG_2, FALSE);
sub_80A438C(battlerId, toBG_2, FALSE);
taskId = CreateTask(sub_80A40F4, 10);
gAnimVisualTaskCount++;
gTasks[taskId].data[t1_MONBG_BANK] = bank;
gTasks[taskId].data[t1_MONBG_BATTLER] = battlerId;
gTasks[taskId].data[t1_MON_IN_BG2] = toBG_2;
gTasks[taskId].data[t1_CREATE_ANOTHER_TASK] = TRUE;
gTasks[taskId].data[t1_IS_SECONDMON_BG] = 0;
}
bank ^= BIT_FLANK;
if (IsBattlerSpriteVisible(bank))
battlerId ^= BIT_FLANK;
if (IsBattlerSpriteVisible(battlerId))
{
u8 position = GetBattlerPosition(bank);
u8 position = GetBattlerPosition(battlerId);
if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest())
toBG_2 = FALSE;
else
toBG_2 = TRUE;
sub_80A438C(bank, toBG_2, FALSE);
sub_80A438C(battlerId, toBG_2, FALSE);
taskId = CreateTask(sub_80A40F4, 10);
gAnimVisualTaskCount++;
gTasks[taskId].data[0] = bank;
gTasks[taskId].data[0] = battlerId;
gTasks[taskId].data[1] = toBG_2;
gTasks[taskId].data[t1_CREATE_ANOTHER_TASK] = TRUE;
gTasks[taskId].data[t1_IS_SECONDMON_BG] = 1;
@ -647,33 +643,33 @@ static void ScriptCmd_monbg(void)
gAnimScriptCallback = WaitAnimFrameCount;
}
bool8 IsBattlerSpriteVisible(u8 bank)
bool8 IsBattlerSpriteVisible(u8 battlerId)
{
if (IsContest())
{
if (bank == gBattleAnimAttacker)
if (battlerId == gBattleAnimAttacker)
return TRUE;
else
return FALSE;
}
if (!IsBattlerSpritePresent(bank))
if (!IsBattlerSpritePresent(battlerId))
return FALSE;
if (IsContest())
return TRUE; // this line wont ever be reached.
if (!gBattleSpritesDataPtr->battlerData[bank].invisible || !gSprites[gBattlerSpriteIds[bank]].invisible)
if (!gBattleSpritesDataPtr->battlerData[battlerId].invisible || !gSprites[gBattlerSpriteIds[battlerId]].invisible)
return TRUE;
return FALSE;
}
void sub_80A438C(u8 bank, bool8 toBG_2, bool8 setSpriteInvisible)
void sub_80A438C(u8 battlerId, bool8 toBG_2, bool8 setSpriteInvisible)
{
struct UnknownAnimStruct2 unknownStruct;
u8 bankSpriteId;
u8 battlerSpriteId;
if (!toBG_2)
{
u8 bankIdentity;
u8 battlerPosition;
if (IsContest() == TRUE)
{
@ -694,28 +690,28 @@ void sub_80A438C(u8 bank, bool8 toBG_2, bool8 setSpriteInvisible)
SetAnimBgAttribute(1, BG_ANIM_SCREEN_SIZE, 1);
SetAnimBgAttribute(1, BG_ANIM_AREA_OVERFLOW_MODE, 0);
bankSpriteId = gBattlerSpriteIds[bank];
battlerSpriteId = gBattlerSpriteIds[battlerId];
gBattle_BG1_X = -(gSprites[bankSpriteId].pos1.x + gSprites[bankSpriteId].pos2.x) + 0x20;
gBattle_BG1_X = -(gSprites[battlerSpriteId].pos1.x + gSprites[battlerSpriteId].pos2.x) + 0x20;
if (IsContest() && IsSpeciesNotUnown(gContestResources->field_18->field_0))
gBattle_BG1_X--;
gBattle_BG1_Y = -(gSprites[bankSpriteId].pos1.y + gSprites[bankSpriteId].pos2.y) + 0x20;
gBattle_BG1_Y = -(gSprites[battlerSpriteId].pos1.y + gSprites[battlerSpriteId].pos2.y) + 0x20;
if (setSpriteInvisible)
gSprites[gBattlerSpriteIds[bank]].invisible = 1;
gSprites[gBattlerSpriteIds[battlerId]].invisible = 1;
SetGpuReg(REG_OFFSET_BG1HOFS, gBattle_BG1_X);
SetGpuReg(REG_OFFSET_BG1VOFS, gBattle_BG1_Y);
LoadPalette(&gPlttBufferUnfaded[0x100 + bank * 16], unknownStruct.unk8 * 16, 0x20);
CpuCopy32(&gPlttBufferUnfaded[0x100 + bank * 16], (void*)(BG_PLTT + unknownStruct.unk8 * 32), 0x20);
LoadPalette(&gPlttBufferUnfaded[0x100 + battlerId * 16], unknownStruct.unk8 * 16, 0x20);
CpuCopy32(&gPlttBufferUnfaded[0x100 + battlerId * 16], (void*)(BG_PLTT + unknownStruct.unk8 * 32), 0x20);
if (IsContest())
bankIdentity = 0;
battlerPosition = 0;
else
bankIdentity = GetBattlerPosition(bank);
battlerPosition = GetBattlerPosition(battlerId);
sub_8118FBC(1, 0, 0, bankIdentity, unknownStruct.unk8, unknownStruct.unk0, unknownStruct.unk4, unknownStruct.unkA);
sub_8118FBC(1, 0, 0, battlerPosition, unknownStruct.unk8, unknownStruct.unk0, unknownStruct.unk4, unknownStruct.unkA);
if (IsContest())
sub_80A46A0();
@ -731,21 +727,21 @@ void sub_80A438C(u8 bank, bool8 toBG_2, bool8 setSpriteInvisible)
SetAnimBgAttribute(2, BG_ANIM_SCREEN_SIZE, 1);
SetAnimBgAttribute(2, BG_ANIM_AREA_OVERFLOW_MODE, 0);
bankSpriteId = gBattlerSpriteIds[bank];
battlerSpriteId = gBattlerSpriteIds[battlerId];
gBattle_BG2_X = -(gSprites[bankSpriteId].pos1.x + gSprites[bankSpriteId].pos2.x) + 0x20;
gBattle_BG2_Y = -(gSprites[bankSpriteId].pos1.y + gSprites[bankSpriteId].pos2.y) + 0x20;
gBattle_BG2_X = -(gSprites[battlerSpriteId].pos1.x + gSprites[battlerSpriteId].pos2.x) + 0x20;
gBattle_BG2_Y = -(gSprites[battlerSpriteId].pos1.y + gSprites[battlerSpriteId].pos2.y) + 0x20;
if (setSpriteInvisible)
gSprites[gBattlerSpriteIds[bank]].invisible = 1;
gSprites[gBattlerSpriteIds[battlerId]].invisible = 1;
SetGpuReg(REG_OFFSET_BG2HOFS, gBattle_BG2_X);
SetGpuReg(REG_OFFSET_BG2VOFS, gBattle_BG2_Y);
LoadPalette(&gPlttBufferUnfaded[0x100 + bank * 16], 0x90, 0x20);
CpuCopy32(&gPlttBufferUnfaded[0x100 + bank * 16], (void*)(BG_PLTT + 0x120), 0x20);
LoadPalette(&gPlttBufferUnfaded[0x100 + battlerId * 16], 0x90, 0x20);
CpuCopy32(&gPlttBufferUnfaded[0x100 + battlerId * 16], (void*)(BG_PLTT + 0x120), 0x20);
sub_8118FBC(2, 0, 0, GetBattlerPosition(bank), unknownStruct.unk8, unknownStruct.unk0 + 0x1000, unknownStruct.unk4 + 0x400, unknownStruct.unkA);
sub_8118FBC(2, 0, 0, GetBattlerPosition(battlerId), unknownStruct.unk8, unknownStruct.unk0 + 0x1000, unknownStruct.unk4 + 0x400, unknownStruct.unkA);
}
}
@ -852,7 +848,7 @@ static void task_pA_ma0A_obj_to_bg_pal(u8 taskId)
static void ScriptCmd_clearmonbg(void)
{
u8 animBankId;
u8 bank;
u8 battlerId;
u8 taskId;
sBattleAnimScriptPtr++;
@ -864,20 +860,20 @@ static void ScriptCmd_clearmonbg(void)
animBankId = ANIM_DEF_PARTNER;
if (animBankId == ANIM_ATTACKER || animBankId == ANIM_ATK_PARTNER)
bank = gBattleAnimAttacker;
battlerId = gBattleAnimAttacker;
else
bank = gBattleAnimTarget;
battlerId = gBattleAnimTarget;
if (sMonAnimTaskIdArray[0] != 0xFF)
gSprites[gBattlerSpriteIds[bank]].invisible = 0;
gSprites[gBattlerSpriteIds[battlerId]].invisible = 0;
if (animBankId > 1 && sMonAnimTaskIdArray[1] != 0xFF)
gSprites[gBattlerSpriteIds[bank ^ BIT_FLANK]].invisible = 0;
gSprites[gBattlerSpriteIds[battlerId ^ BIT_FLANK]].invisible = 0;
else
animBankId = 0;
taskId = CreateTask(sub_80A4980, 5);
gTasks[taskId].data[0] = animBankId;
gTasks[taskId].data[2] = bank;
gTasks[taskId].data[2] = battlerId;
sBattleAnimScriptPtr++;
}
@ -913,7 +909,7 @@ static void sub_80A4980(u8 taskId)
static void ScriptCmd_monbg_22(void)
{
bool8 toBG_2;
u8 bank;
u8 battlerId;
u8 animBankId;
sBattleAnimScriptPtr++;
@ -926,31 +922,31 @@ static void ScriptCmd_monbg_22(void)
animBankId = ANIM_DEF_PARTNER;
if (animBankId == ANIM_ATTACKER || animBankId == ANIM_ATK_PARTNER)
bank = gBattleAnimAttacker;
battlerId = gBattleAnimAttacker;
else
bank = gBattleAnimTarget;
battlerId = gBattleAnimTarget;
if (IsBattlerSpriteVisible(bank))
if (IsBattlerSpriteVisible(battlerId))
{
u8 position = GetBattlerPosition(bank);
u8 position = GetBattlerPosition(battlerId);
if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest())
toBG_2 = FALSE;
else
toBG_2 = TRUE;
sub_80A438C(bank, toBG_2, FALSE);
sub_80A438C(battlerId, toBG_2, FALSE);
}
bank ^= BIT_FLANK;
if (animBankId > 1 && IsBattlerSpriteVisible(bank))
battlerId ^= BIT_FLANK;
if (animBankId > 1 && IsBattlerSpriteVisible(battlerId))
{
u8 position = GetBattlerPosition(bank);
u8 position = GetBattlerPosition(battlerId);
if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest())
toBG_2 = FALSE;
else
toBG_2 = TRUE;
sub_80A438C(bank, toBG_2, FALSE);
sub_80A438C(battlerId, toBG_2, FALSE);
}
sBattleAnimScriptPtr++;
@ -959,7 +955,7 @@ static void ScriptCmd_monbg_22(void)
static void ScriptCmd_clearmonbg_23(void)
{
u8 animBankId;
u8 bank;
u8 battlerId;
u8 taskId;
sBattleAnimScriptPtr++;
@ -971,20 +967,20 @@ static void ScriptCmd_clearmonbg_23(void)
animBankId = ANIM_DEF_PARTNER;
if (animBankId == ANIM_ATTACKER || animBankId == ANIM_ATK_PARTNER)
bank = gBattleAnimAttacker;
battlerId = gBattleAnimAttacker;
else
bank = gBattleAnimTarget;
battlerId = gBattleAnimTarget;
if (IsBattlerSpriteVisible(bank))
gSprites[gBattlerSpriteIds[bank]].invisible = 0;
if (animBankId > 1 && IsBattlerSpriteVisible(bank ^ BIT_FLANK))
gSprites[gBattlerSpriteIds[bank ^ BIT_FLANK]].invisible = 0;
if (IsBattlerSpriteVisible(battlerId))
gSprites[gBattlerSpriteIds[battlerId]].invisible = 0;
if (animBankId > 1 && IsBattlerSpriteVisible(battlerId ^ BIT_FLANK))
gSprites[gBattlerSpriteIds[battlerId ^ BIT_FLANK]].invisible = 0;
else
animBankId = 0;
taskId = CreateTask(sub_80A4BB0, 5);
gTasks[taskId].data[0] = animBankId;
gTasks[taskId].data[2] = bank;
gTasks[taskId].data[2] = battlerId;
sBattleAnimScriptPtr++;
}
@ -995,30 +991,30 @@ static void sub_80A4BB0(u8 taskId)
if (gTasks[taskId].data[1] != 1)
{
bool8 toBG_2;
u8 bank = gTasks[taskId].data[2];
u8 position = GetBattlerPosition(bank);
u8 battlerId = gTasks[taskId].data[2];
u8 position = GetBattlerPosition(battlerId);
if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest())
toBG_2 = FALSE;
else
toBG_2 = TRUE;
if (IsBattlerSpriteVisible(bank))
if (IsBattlerSpriteVisible(battlerId))
sub_80A477C(toBG_2);
if (gTasks[taskId].data[0] > 1 && IsBattlerSpriteVisible(bank ^ BIT_FLANK))
if (gTasks[taskId].data[0] > 1 && IsBattlerSpriteVisible(battlerId ^ BIT_FLANK))
sub_80A477C(toBG_2 ^ 1);
DestroyTask(taskId);
}
}
#undef t1_MONBG_BANK
#undef t1_MONBG_BATTLER
#undef t1_MON_IN_BG2
#undef t1_CREATE_ANOTHER_TASK
#undef t1_IS_SECONDMON_BG
#undef t2_BANK_SPRITE_ID
#undef t2_BATTLER_SPRITE_ID
#undef t2_MON_IN_BG2
#undef t2_MONBG_BANK
#undef t2_MONBG_BATTLER
static void ScriptCmd_setalpha(void)
{
@ -1052,7 +1048,7 @@ static void ScriptCmd_call(void)
{
sBattleAnimScriptPtr++;
sBattleAnimScriptRetAddr = sBattleAnimScriptPtr + 4;
sBattleAnimScriptPtr = SCRIPT_READ_PTR(sBattleAnimScriptPtr);
sBattleAnimScriptPtr = T2_READ_PTR(sBattleAnimScriptPtr);
}
static void ScriptCmd_return(void)
@ -1069,7 +1065,7 @@ static void ScriptCmd_setarg(void)
sBattleAnimScriptPtr++;
argId = sBattleAnimScriptPtr[0];
sBattleAnimScriptPtr++;
value = SCRIPT_READ_16(sBattleAnimScriptPtr);
value = T1_READ_16(sBattleAnimScriptPtr);
sBattleAnimScriptPtr = addr + 4;
gBattleAnimArgs[argId] = value;
}
@ -1079,7 +1075,7 @@ static void ScriptCmd_choosetwoturnanim(void)
sBattleAnimScriptPtr++;
if (gAnimMoveTurn & 1)
sBattleAnimScriptPtr += 4;
sBattleAnimScriptPtr = SCRIPT_READ_PTR(sBattleAnimScriptPtr);
sBattleAnimScriptPtr = T2_READ_PTR(sBattleAnimScriptPtr);
}
static void ScriptCmd_jumpifmoveturn(void)
@ -1090,7 +1086,7 @@ static void ScriptCmd_jumpifmoveturn(void)
sBattleAnimScriptPtr++;
if (toCheck == gAnimMoveTurn)
sBattleAnimScriptPtr = SCRIPT_READ_PTR(sBattleAnimScriptPtr);
sBattleAnimScriptPtr = T2_READ_PTR(sBattleAnimScriptPtr);
else
sBattleAnimScriptPtr += 4;
}
@ -1098,7 +1094,7 @@ static void ScriptCmd_jumpifmoveturn(void)
static void ScriptCmd_goto(void)
{
sBattleAnimScriptPtr++;
sBattleAnimScriptPtr = SCRIPT_READ_PTR(sBattleAnimScriptPtr);
sBattleAnimScriptPtr = T2_READ_PTR(sBattleAnimScriptPtr);
}
// Uses of this function that rely on a TRUE return are expecting inBattle to not be ticked as defined in contest behavior. As a result, if misused, this function cannot reliably discern between field and contest status and could result in undefined behavior.
@ -1354,7 +1350,7 @@ static void ScriptCmd_playsewithpan(void)
s8 pan;
sBattleAnimScriptPtr++;
songId = SCRIPT_READ_16(sBattleAnimScriptPtr);
songId = T1_READ_16(sBattleAnimScriptPtr);
pan = sBattleAnimScriptPtr[2];
PlaySE12WithPanning(songId, BattleAnimAdjustPanning(pan));
sBattleAnimScriptPtr += 3;
@ -1385,7 +1381,7 @@ static void ScriptCmd_panse_1B(void)
u8 taskId;
sBattleAnimScriptPtr++;
songNum = SCRIPT_READ_16(sBattleAnimScriptPtr);
songNum = T1_READ_16(sBattleAnimScriptPtr);
currentPanArg = sBattleAnimScriptPtr[2];
incrementPan = sBattleAnimScriptPtr[3];
incrementPanArg = sBattleAnimScriptPtr[4];
@ -1457,7 +1453,7 @@ static void ScriptCmd_panse_26(void)
u8 taskId;
sBattleAnimScriptPtr++;
songId = SCRIPT_READ_16(sBattleAnimScriptPtr);
songId = T1_READ_16(sBattleAnimScriptPtr);
currentPan = sBattleAnimScriptPtr[2];
targetPan = sBattleAnimScriptPtr[3];
incrementPan = sBattleAnimScriptPtr[4];
@ -1484,7 +1480,7 @@ static void ScriptCmd_panse_27(void)
u8 taskId;
sBattleAnimScriptPtr++;
songId = SCRIPT_READ_16(sBattleAnimScriptPtr);
songId = T1_READ_16(sBattleAnimScriptPtr);
currentPanArg = sBattleAnimScriptPtr[2];
targetPanArg = sBattleAnimScriptPtr[3];
incrementPanArg = sBattleAnimScriptPtr[4];
@ -1528,7 +1524,7 @@ static void ScriptCmd_loopsewithpan(void)
u8 taskId;
sBattleAnimScriptPtr++;
songId = SCRIPT_READ_16(sBattleAnimScriptPtr);
songId = T1_READ_16(sBattleAnimScriptPtr);
panningArg = sBattleAnimScriptPtr[2];
framesToWait = sBattleAnimScriptPtr[3];
numberOfPlays = sBattleAnimScriptPtr[4];
@ -1585,7 +1581,7 @@ static void ScriptCmd_waitplaysewithpan(void)
u8 taskId;
sBattleAnimScriptPtr++;
songId = SCRIPT_READ_16(sBattleAnimScriptPtr);
songId = T1_READ_16(sBattleAnimScriptPtr);
panningArg = sBattleAnimScriptPtr[2];
framesToWait = sBattleAnimScriptPtr[3];
panning = BattleAnimAdjustPanning(panningArg);
@ -1620,13 +1616,13 @@ static void ScriptCmd_createsoundtask(void)
s32 i;
sBattleAnimScriptPtr++;
func = (TaskFunc)SCRIPT_READ_32(sBattleAnimScriptPtr);
func = (TaskFunc)T2_READ_32(sBattleAnimScriptPtr);
sBattleAnimScriptPtr += 4;
numArgs = sBattleAnimScriptPtr[0];
sBattleAnimScriptPtr++;
for (i = 0; i < numArgs; i++)
{
gBattleAnimArgs[i] = SCRIPT_READ_16(sBattleAnimScriptPtr);
gBattleAnimArgs[i] = T1_READ_16(sBattleAnimScriptPtr);
sBattleAnimScriptPtr += 2;
}
taskId = CreateTask(func, 1);
@ -1669,10 +1665,10 @@ static void ScriptCmd_jumpargeq(void)
sBattleAnimScriptPtr++;
argId = sBattleAnimScriptPtr[0];
valueToCheck = SCRIPT_READ_16(sBattleAnimScriptPtr + 1);
valueToCheck = T1_READ_16(sBattleAnimScriptPtr + 1);
if (valueToCheck == gBattleAnimArgs[argId])
sBattleAnimScriptPtr = SCRIPT_READ_PTR(sBattleAnimScriptPtr + 3);
sBattleAnimScriptPtr = T2_READ_PTR(sBattleAnimScriptPtr + 3);
else
sBattleAnimScriptPtr += 7;
}
@ -1681,7 +1677,7 @@ static void ScriptCmd_jumpifcontest(void)
{
sBattleAnimScriptPtr++;
if (IsContest())
sBattleAnimScriptPtr = SCRIPT_READ_PTR(sBattleAnimScriptPtr);
sBattleAnimScriptPtr = T2_READ_PTR(sBattleAnimScriptPtr);
else
sBattleAnimScriptPtr += 4;
}
@ -1689,19 +1685,19 @@ static void ScriptCmd_jumpifcontest(void)
static void ScriptCmd_monbgprio_28(void)
{
u8 wantedBank;
u8 bank;
u8 bankIdentity;
u8 battlerId;
u8 battlerPosition;
wantedBank = sBattleAnimScriptPtr[1];
sBattleAnimScriptPtr += 2;
if (wantedBank != ANIM_ATTACKER)
bank = gBattleAnimTarget;
battlerId = gBattleAnimTarget;
else
bank = gBattleAnimAttacker;
battlerId = gBattleAnimAttacker;
bankIdentity = GetBattlerPosition(bank);
if (!IsContest() && (bankIdentity == B_POSITION_PLAYER_LEFT || bankIdentity == B_POSITION_OPPONENT_RIGHT))
battlerPosition = GetBattlerPosition(battlerId);
if (!IsContest() && (battlerPosition == B_POSITION_PLAYER_LEFT || battlerPosition == B_POSITION_OPPONENT_RIGHT))
{
SetAnimBgAttribute(1, BG_ANIM_PRIORITY, 1);
SetAnimBgAttribute(2, BG_ANIM_PRIORITY, 2);
@ -1721,20 +1717,20 @@ static void ScriptCmd_monbgprio_29(void)
static void ScriptCmd_monbgprio_2A(void)
{
u8 wantedBank;
u8 bankIdentity;
u8 bank;
u8 battlerPosition;
u8 battlerId;
wantedBank = sBattleAnimScriptPtr[1];
sBattleAnimScriptPtr += 2;
if (GetBattlerSide(gBattleAnimAttacker) != GetBattlerSide(gBattleAnimTarget))
{
if (wantedBank != ANIM_ATTACKER)
bank = gBattleAnimTarget;
battlerId = gBattleAnimTarget;
else
bank = gBattleAnimAttacker;
battlerId = gBattleAnimAttacker;
bankIdentity = GetBattlerPosition(bank);
if (!IsContest() && (bankIdentity == B_POSITION_PLAYER_LEFT || bankIdentity == B_POSITION_OPPONENT_RIGHT))
battlerPosition = GetBattlerPosition(battlerId);
if (!IsContest() && (battlerPosition == B_POSITION_PLAYER_LEFT || battlerPosition == B_POSITION_OPPONENT_RIGHT))
{
SetAnimBgAttribute(1, BG_ANIM_PRIORITY, 1);
SetAnimBgAttribute(2, BG_ANIM_PRIORITY, 2);

View File

@ -33,7 +33,7 @@ extern struct UnusedControllerStruct gUnknown_02022D0C;
extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
extern void sub_8172EF0(u8 bank, struct Pokemon *mon);
extern void sub_8172EF0(u8 battlerId, struct Pokemon *mon);
extern void sub_806A068(u16, u8);
extern void sub_81851A8(u8 *);
extern u16 sub_8068B48(void);
@ -103,7 +103,7 @@ static void LinkOpponentBufferExecCompleted(void);
static void sub_8064DD0(void);
static u32 CopyLinkOpponentMonData(u8 monId, u8 *dst);
static void SetLinkOpponentMonData(u8 monId);
static void sub_8066494(u8 bank, bool8 dontClearSubstituteBit);
static void sub_8066494(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void);
static void LinkOpponentDoMoveAnimation(void);
static void sub_8067618(u8 taskId);
@ -1159,36 +1159,36 @@ static void LinkOpponentHandleSwitchInAnim(void)
gBattlerControllerFuncs[gActiveBattler] = sub_8064F40;
}
static void sub_8066494(u8 bank, bool8 dontClearSubstituteBit)
static void sub_8066494(u8 battlerId, bool8 dontClearSubstituteBit)
{
u16 species;
ClearTemporarySpeciesSpriteData(bank, dontClearSubstituteBit);
gBattlerPartyIndexes[bank] = gBattleBufferA[bank][1];
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES);
gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714);
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[bank]], bank);
sub_806A068(species, GetBattlerPosition(bank));
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714);
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId);
sub_806A068(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[bank] = CreateSprite(
gBattlerSpriteIds[battlerId] = CreateSprite(
&gUnknown_0202499C,
GetBattlerSpriteCoord(bank, 2),
GetBattlerSpriteDefault_Y(bank),
sub_80A82E4(bank));
GetBattlerSpriteCoord(battlerId, 2),
GetBattlerSpriteDefault_Y(battlerId),
sub_80A82E4(battlerId));
gSprites[gUnknown_03005D7C[bank]].data[1] = gBattlerSpriteIds[bank];
gSprites[gUnknown_03005D7C[bank]].data[2] = bank;
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[bank]].data[0] = bank;
gSprites[gBattlerSpriteIds[bank]].data[2] = species;
gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
gSprites[gBattlerSpriteIds[battlerId]].oam.paletteNum = battlerId;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], gBattleMonForms[battlerId]);
gSprites[gBattlerSpriteIds[bank]].invisible = TRUE;
gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT);
gSprites[gUnknown_03005D7C[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT);
}
static void LinkOpponentHandleReturnMonToBall(void)
@ -1337,7 +1337,7 @@ static void LinkOpponentHandleTrainerSlide(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2; // this line is redundant, because LinkOpponentBufferExecCompleted changes the battle bank function
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2; // this line is redundant, because LinkOpponentBufferExecCompleted changes the battle battlerId function
LinkOpponentBufferExecCompleted();
}
@ -1548,11 +1548,11 @@ static void LinkOpponentHandleStatusIconUpdate(void)
{
if (!mplay_80342A4(gActiveBattler))
{
u8 bank;
u8 battlerId;
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON);
bank = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0;
battlerId = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[battlerId].statusAnimActive = 0;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
}
}

View File

@ -32,7 +32,7 @@ extern struct UnusedControllerStruct gUnknown_02022D0C;
extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[];
extern void sub_8172EF0(u8 bank, struct Pokemon *mon);
extern void sub_8172EF0(u8 battlerId, struct Pokemon *mon);
extern void sub_806A068(u16, u8);
extern void sub_81851A8(u8 *);
extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId);
@ -101,7 +101,7 @@ static void LinkPartnerBufferExecCompleted(void);
static void sub_814B554(void);
static u32 CopyLinkPartnerMonData(u8 monId, u8 *dst);
static void SetLinkPartnerMonData(u8 monId);
static void sub_814CC98(u8 bank, bool8 dontClearSubstituteBit);
static void sub_814CC98(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void);
static void LinkPartnerDoMoveAnimation(void);
static void sub_814DCCC(u8 taskId);
@ -1045,35 +1045,35 @@ static void LinkPartnerHandleSwitchInAnim(void)
gBattlerControllerFuncs[gActiveBattler] = sub_814B69C;
}
static void sub_814CC98(u8 bank, bool8 dontClearSubstituteBit)
static void sub_814CC98(u8 battlerId, bool8 dontClearSubstituteBit)
{
u16 species;
ClearTemporarySpeciesSpriteData(bank, dontClearSubstituteBit);
gBattlerPartyIndexes[bank] = gBattleBufferA[bank][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES);
gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714);
sub_806A068(species, GetBattlerPosition(bank));
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714);
sub_806A068(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[bank] = CreateSprite(
gBattlerSpriteIds[battlerId] = CreateSprite(
&gUnknown_0202499C,
GetBattlerSpriteCoord(bank, 2),
GetBattlerSpriteDefault_Y(bank),
sub_80A82E4(bank));
GetBattlerSpriteCoord(battlerId, 2),
GetBattlerSpriteDefault_Y(battlerId),
sub_80A82E4(battlerId));
gSprites[gUnknown_03005D7C[bank]].data[1] = gBattlerSpriteIds[bank];
gSprites[gUnknown_03005D7C[bank]].data[2] = bank;
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[bank]].data[0] = bank;
gSprites[gBattlerSpriteIds[bank]].data[2] = species;
gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
gSprites[gBattlerSpriteIds[battlerId]].oam.paletteNum = battlerId;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], gBattleMonForms[battlerId]);
gSprites[gBattlerSpriteIds[bank]].invisible = TRUE;
gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
gSprites[gUnknown_03005D7C[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
}
static void LinkPartnerHandleReturnMonToBall(void)
@ -1372,11 +1372,11 @@ static void LinkPartnerHandleStatusIconUpdate(void)
{
if (!mplay_80342A4(gActiveBattler))
{
u8 bank;
u8 battlerId;
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON);
bank = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0;
battlerId = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[battlerId].statusAnimActive = 0;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
}
}

View File

@ -36,9 +36,9 @@ extern struct UnusedControllerStruct gUnknown_02022D0C;
extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
extern void sub_8172EF0(u8 bank, struct Pokemon *mon);
extern void sub_8172EF0(u8 battlerId, struct Pokemon *mon);
extern void sub_806A068(u16, u8);
extern void sub_81A57E4(u8 bank, u16 stringId);
extern void sub_81A57E4(u8 battlerId, u16 stringId);
extern u8 sub_81A4CB0(void);
extern u8 sub_81D5588(u16 trainerId);
extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId);
@ -108,7 +108,7 @@ static void OpponentBufferExecCompleted(void);
static void sub_805FC80(void);
static u32 GetOpponentMonData(u8 monId, u8 *dst);
static void SetOpponentMonData(u8 monId);
static void sub_80613DC(u8 bank, bool8 dontClearSubstituteBit);
static void sub_80613DC(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void);
static void OpponentDoMoveAnimation(void);
static void sub_806280C(struct Sprite *sprite);
@ -1153,36 +1153,36 @@ static void OpponentHandleSwitchInAnim(void)
gBattlerControllerFuncs[gActiveBattler] = sub_805FDF0;
}
static void sub_80613DC(u8 bank, bool8 dontClearSubstituteBit)
static void sub_80613DC(u8 battlerId, bool8 dontClearSubstituteBit)
{
u16 species;
ClearTemporarySpeciesSpriteData(bank, dontClearSubstituteBit);
gBattlerPartyIndexes[bank] = gBattleBufferA[bank][1];
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES);
gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714);
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[bank]], bank);
sub_806A068(species, GetBattlerPosition(bank));
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714);
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId);
sub_806A068(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[bank] = CreateSprite(&gUnknown_0202499C,
GetBattlerSpriteCoord(bank, 2),
GetBattlerSpriteDefault_Y(bank),
sub_80A82E4(bank));
gBattlerSpriteIds[battlerId] = CreateSprite(&gUnknown_0202499C,
GetBattlerSpriteCoord(battlerId, 2),
GetBattlerSpriteDefault_Y(battlerId),
sub_80A82E4(battlerId));
gSprites[gBattlerSpriteIds[bank]].data[0] = bank;
gSprites[gBattlerSpriteIds[bank]].data[2] = species;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
gSprites[gUnknown_03005D7C[bank]].data[1] = gBattlerSpriteIds[bank];
gSprites[gUnknown_03005D7C[bank]].data[2] = bank;
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank;
gSprites[gBattlerSpriteIds[battlerId]].oam.paletteNum = battlerId;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], gBattleMonForms[battlerId]);
gSprites[gBattlerSpriteIds[bank]].invisible = TRUE;
gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT);
gSprites[gUnknown_03005D7C[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT);
}
static void OpponentHandleReturnMonToBall(void)
@ -1697,11 +1697,11 @@ static void OpponentHandleStatusIconUpdate(void)
{
if (!mplay_80342A4(gActiveBattler))
{
u8 bank;
u8 battlerId;
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON);
bank = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0;
battlerId = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[battlerId].statusAnimActive = 0;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
}
}

View File

@ -43,11 +43,11 @@ extern struct SpriteTemplate gUnknown_0202499C;
extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[];
extern void sub_8172EF0(u8 bank, struct Pokemon *mon);
extern void sub_8172EF0(u8 battlerId, struct Pokemon *mon);
extern void sub_81B89AC(u8 arg0);
extern void sub_81AABB0(void);
extern void sub_806A068(u16, u8);
extern void sub_81A57E4(u8 bank, u16 stringId);
extern void sub_81A57E4(u8 battlerId, u16 stringId);
extern void sub_81851A8(u8 *);
// this file's functions
@ -130,7 +130,7 @@ static void sub_80595A4(u8 taskId);
static void PrintLinkStandbyMsg(void);
static u32 CopyPlayerMonData(u8 monId, u8 *dst);
static void SetPlayerMonData(u8 monId);
static void sub_805B258(u8 bank, bool8 dontClearSubstituteBit);
static void sub_805B258(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void);
static void PlayerDoMoveAnimation(void);
static void task05_08033660(u8 taskId);
@ -1149,10 +1149,10 @@ static void CompleteOnInactiveTextPrinter(void)
static void Task_GiveExpToMon(u8 taskId)
{
u32 monId = (u8)(gTasks[taskId].tExpTask_monId);
u8 bank = gTasks[taskId].tExpTask_bank;
u8 battlerId = gTasks[taskId].tExpTask_bank;
s16 gainedExp = gTasks[taskId].tExpTask_gainedExp;
if (IsDoubleBattle() == TRUE || monId != gBattlerPartyIndexes[bank]) // give exp without the expbar
if (IsDoubleBattle() == TRUE || monId != gBattlerPartyIndexes[battlerId]) // give exp without the expbar
{
struct Pokemon *mon = &gPlayerParty[monId];
u16 species = GetMonData(mon, MON_DATA_SPECIES);
@ -1168,12 +1168,12 @@ static void Task_GiveExpToMon(u8 taskId)
CalculateMonStats(mon);
gainedExp -= nextLvlExp - currExp;
savedActiveBank = gActiveBattler;
gActiveBattler = bank;
gActiveBattler = battlerId;
BtlController_EmitTwoReturnValues(1, RET_VALUE_LEVELLED_UP, gainedExp);
gActiveBattler = savedActiveBank;
if (IsDoubleBattle() == TRUE
&& ((u16)(monId) == gBattlerPartyIndexes[bank] || (u16)(monId) == gBattlerPartyIndexes[bank ^ BIT_FLANK]))
&& ((u16)(monId) == gBattlerPartyIndexes[battlerId] || (u16)(monId) == gBattlerPartyIndexes[battlerId ^ BIT_FLANK]))
gTasks[taskId].func = sub_8059544;
else
gTasks[taskId].func = DestroyExpTaskAndCompleteOnInactiveTextPrinter;
@ -1182,7 +1182,7 @@ static void Task_GiveExpToMon(u8 taskId)
{
currExp += gainedExp;
SetMonData(mon, MON_DATA_EXP, &currExp);
gBattlerControllerFuncs[bank] = CompleteOnInactiveTextPrinter;
gBattlerControllerFuncs[battlerId] = CompleteOnInactiveTextPrinter;
DestroyTask(taskId);
}
}
@ -1196,7 +1196,7 @@ static void Task_PrepareToGiveExpWithExpBar(u8 taskId)
{
u8 monIndex = gTasks[taskId].tExpTask_monId;
s32 gainedExp = gTasks[taskId].tExpTask_gainedExp;
u8 bank = gTasks[taskId].tExpTask_bank;
u8 battlerId = gTasks[taskId].tExpTask_bank;
struct Pokemon *mon = &gPlayerParty[monIndex];
u8 level = GetMonData(mon, MON_DATA_LEVEL);
u16 species = GetMonData(mon, MON_DATA_SPECIES);
@ -1206,7 +1206,7 @@ static void Task_PrepareToGiveExpWithExpBar(u8 taskId)
exp -= currLvlExp;
expToNextLvl = gExperienceTables[gBaseStats[species].growthRate][level + 1] - currLvlExp;
SetBattleBarStruct(bank, gHealthboxSpriteIds[bank], expToNextLvl, exp, -gainedExp);
SetBattleBarStruct(battlerId, gHealthboxSpriteIds[battlerId], expToNextLvl, exp, -gainedExp);
PlaySE(SE_EXP);
gTasks[taskId].func = sub_8059400;
}
@ -1221,11 +1221,11 @@ static void sub_8059400(u8 taskId)
{
u8 monId = gTasks[taskId].tExpTask_monId;
s16 gainedExp = gTasks[taskId].tExpTask_gainedExp;
u8 bank = gTasks[taskId].tExpTask_bank;
u8 battlerId = gTasks[taskId].tExpTask_bank;
s16 r4;
r4 = sub_8074AA0(bank, gHealthboxSpriteIds[bank], EXP_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[bank]);
r4 = sub_8074AA0(battlerId, gHealthboxSpriteIds[battlerId], EXP_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battlerId]);
if (r4 == -1)
{
u8 level;
@ -1247,7 +1247,7 @@ static void sub_8059400(u8 taskId)
CalculateMonStats(&gPlayerParty[monId]);
gainedExp -= expOnNextLvl - currExp;
savedActiveBank = gActiveBattler;
gActiveBattler = bank;
gActiveBattler = battlerId;
BtlController_EmitTwoReturnValues(1, RET_VALUE_LEVELLED_UP, gainedExp);
gActiveBattler = savedActiveBank;
gTasks[taskId].func = sub_8059544;
@ -1256,7 +1256,7 @@ static void sub_8059400(u8 taskId)
{
currExp += gainedExp;
SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &currExp);
gBattlerControllerFuncs[bank] = CompleteOnInactiveTextPrinter;
gBattlerControllerFuncs[battlerId] = CompleteOnInactiveTextPrinter;
DestroyTask(taskId);
}
}
@ -1265,30 +1265,30 @@ static void sub_8059400(u8 taskId)
static void sub_8059544(u8 taskId)
{
u8 bank = gTasks[taskId].tExpTask_bank;
u8 battlerId = gTasks[taskId].tExpTask_bank;
u8 monIndex = gTasks[taskId].tExpTask_monId;
if (IsDoubleBattle() == TRUE && monIndex == gBattlerPartyIndexes[bank ^ BIT_FLANK])
bank ^= BIT_FLANK;
if (IsDoubleBattle() == TRUE && monIndex == gBattlerPartyIndexes[battlerId ^ BIT_FLANK])
battlerId ^= BIT_FLANK;
InitAndLaunchSpecialAnimation(bank, bank, bank, B_ANIM_LVL_UP);
InitAndLaunchSpecialAnimation(battlerId, battlerId, battlerId, B_ANIM_LVL_UP);
gTasks[taskId].func = sub_80595A4;
}
static void sub_80595A4(u8 taskId)
{
u8 bank = gTasks[taskId].tExpTask_bank;
u8 battlerId = gTasks[taskId].tExpTask_bank;
if (!gBattleSpritesDataPtr->healthBoxesData[bank].specialAnimActive)
if (!gBattleSpritesDataPtr->healthBoxesData[battlerId].specialAnimActive)
{
u8 monIndex = gTasks[taskId].tExpTask_monId;
GetMonData(&gPlayerParty[monIndex], MON_DATA_LEVEL); // Unused return value
if (IsDoubleBattle() == TRUE && monIndex == gBattlerPartyIndexes[bank ^ BIT_FLANK])
UpdateHealthboxAttribute(gHealthboxSpriteIds[bank ^ BIT_FLANK], &gPlayerParty[monIndex], HEALTHBOX_ALL);
if (IsDoubleBattle() == TRUE && monIndex == gBattlerPartyIndexes[battlerId ^ BIT_FLANK])
UpdateHealthboxAttribute(gHealthboxSpriteIds[battlerId ^ BIT_FLANK], &gPlayerParty[monIndex], HEALTHBOX_ALL);
else
UpdateHealthboxAttribute(gHealthboxSpriteIds[bank], &gPlayerParty[monIndex], HEALTHBOX_ALL);
UpdateHealthboxAttribute(gHealthboxSpriteIds[battlerId], &gPlayerParty[monIndex], HEALTHBOX_ALL);
gTasks[taskId].func = DestroyExpTaskAndCompleteOnInactiveTextPrinter;
}
@ -1297,12 +1297,12 @@ static void sub_80595A4(u8 taskId)
static void DestroyExpTaskAndCompleteOnInactiveTextPrinter(u8 taskId)
{
u8 monIndex;
u8 bank;
u8 battlerId;
monIndex = gTasks[taskId].tExpTask_monId;
GetMonData(&gPlayerParty[monIndex], MON_DATA_LEVEL); // Unused return value
bank = gTasks[taskId].tExpTask_bank;
gBattlerControllerFuncs[bank] = CompleteOnInactiveTextPrinter;
battlerId = gTasks[taskId].tExpTask_bank;
gBattlerControllerFuncs[battlerId] = CompleteOnInactiveTextPrinter;
DestroyTask(taskId);
}
@ -2191,35 +2191,35 @@ static void PlayerHandleSwitchInAnim(void)
gBattlerControllerFuncs[gActiveBattler] = sub_805902C;
}
static void sub_805B258(u8 bank, bool8 dontClearSubstituteBit)
static void sub_805B258(u8 battlerId, bool8 dontClearSubstituteBit)
{
u16 species;
ClearTemporarySpeciesSpriteData(bank, dontClearSubstituteBit);
gBattlerPartyIndexes[bank] = gBattleBufferA[bank][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES);
gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714);
sub_806A068(species, GetBattlerPosition(bank));
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714);
sub_806A068(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[bank] = CreateSprite(
gBattlerSpriteIds[battlerId] = CreateSprite(
&gUnknown_0202499C,
GetBattlerSpriteCoord(bank, 2),
GetBattlerSpriteDefault_Y(bank),
sub_80A82E4(bank));
GetBattlerSpriteCoord(battlerId, 2),
GetBattlerSpriteDefault_Y(battlerId),
sub_80A82E4(battlerId));
gSprites[gUnknown_03005D7C[bank]].data[1] = gBattlerSpriteIds[bank];
gSprites[gUnknown_03005D7C[bank]].data[2] = bank;
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[bank]].data[0] = bank;
gSprites[gBattlerSpriteIds[bank]].data[2] = species;
gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
gSprites[gBattlerSpriteIds[battlerId]].oam.paletteNum = battlerId;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], gBattleMonForms[battlerId]);
gSprites[gBattlerSpriteIds[bank]].invisible = TRUE;
gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
gSprites[gUnknown_03005D7C[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
}
static void PlayerHandleReturnMonToBall(void)
@ -2741,11 +2741,11 @@ static void PlayerHandleStatusIconUpdate(void)
{
if (!mplay_80342A4(gActiveBattler))
{
u8 bank;
u8 battlerId;
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON);
bank = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0;
battlerId = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[battlerId].statusAnimActive = 0;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
}
}
@ -2954,13 +2954,13 @@ static void PlayerHandleIntroTrainerBallThrow(void)
void sub_805CC00(struct Sprite *sprite)
{
u8 bank = sprite->data[5];
u8 battlerId = sprite->data[5];
FreeSpriteOamMatrix(sprite);
FreeSpritePaletteByTag(GetSpritePaletteTagByPaletteNum(sprite->oam.paletteNum));
DestroySprite(sprite);
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[bank]], bank);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], 0);
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[battlerId]], battlerId);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], 0);
}
static void task05_08033660(u8 taskId)

View File

@ -33,7 +33,7 @@ extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[];
extern void sub_81358F4(void);
extern void sub_8172EF0(u8 bank, struct Pokemon *mon);
extern void sub_8172EF0(u8 battlerId, struct Pokemon *mon);
extern void sub_806A068(u16, u8);
extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId);
@ -107,7 +107,7 @@ static void sub_81BB688(u8 taskId);
static void sub_81BB9A0(void);
static u32 CopyPlayerPartnerMonData(u8 monId, u8 *dst);
static void SetPlayerPartnerMonData(u8 monId);
static void sub_81BD0E4(u8 bank, bool8 dontClearSubstituteBit);
static void sub_81BD0E4(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void);
static void PlayerPartnerDoMoveAnimation(void);
static void sub_81BE2C8(u8 taskId);
@ -324,10 +324,10 @@ static void CompleteOnInactiveTextPrinter(void)
static void Task_GiveExpToMon(u8 taskId)
{
u32 monId = (u8)(gTasks[taskId].tExpTask_monId);
u8 bank = gTasks[taskId].tExpTask_bank;
u8 battlerId = gTasks[taskId].tExpTask_bank;
s16 gainedExp = gTasks[taskId].tExpTask_gainedExp;
if (IsDoubleBattle() == TRUE || monId != gBattlerPartyIndexes[bank]) // give exp without the expbar
if (IsDoubleBattle() == TRUE || monId != gBattlerPartyIndexes[battlerId]) // give exp without the expbar
{
struct Pokemon *mon = &gPlayerParty[monId];
u16 species = GetMonData(mon, MON_DATA_SPECIES);
@ -343,12 +343,12 @@ static void Task_GiveExpToMon(u8 taskId)
CalculateMonStats(mon);
gainedExp -= nextLvlExp - currExp;
savedActiveBank = gActiveBattler;
gActiveBattler = bank;
gActiveBattler = battlerId;
BtlController_EmitTwoReturnValues(1, RET_VALUE_LEVELLED_UP, gainedExp);
gActiveBattler = savedActiveBank;
if (IsDoubleBattle() == TRUE
&& ((u16)(monId) == gBattlerPartyIndexes[bank] || (u16)(monId) == gBattlerPartyIndexes[bank ^ BIT_FLANK]))
&& ((u16)(monId) == gBattlerPartyIndexes[battlerId] || (u16)(monId) == gBattlerPartyIndexes[battlerId ^ BIT_FLANK]))
gTasks[taskId].func = sub_81BB628;
else
gTasks[taskId].func = DestroyExpTaskAndCompleteOnInactiveTextPrinter;
@ -357,7 +357,7 @@ static void Task_GiveExpToMon(u8 taskId)
{
currExp += gainedExp;
SetMonData(mon, MON_DATA_EXP, &currExp);
gBattlerControllerFuncs[bank] = CompleteOnInactiveTextPrinter;
gBattlerControllerFuncs[battlerId] = CompleteOnInactiveTextPrinter;
DestroyTask(taskId);
}
}
@ -371,7 +371,7 @@ static void Task_PrepareToGiveExpWithExpBar(u8 taskId)
{
u8 monIndex = gTasks[taskId].tExpTask_monId;
s32 gainedExp = gTasks[taskId].tExpTask_gainedExp;
u8 bank = gTasks[taskId].tExpTask_bank;
u8 battlerId = gTasks[taskId].tExpTask_bank;
struct Pokemon *mon = &gPlayerParty[monIndex];
u8 level = GetMonData(mon, MON_DATA_LEVEL);
u16 species = GetMonData(mon, MON_DATA_SPECIES);
@ -381,7 +381,7 @@ static void Task_PrepareToGiveExpWithExpBar(u8 taskId)
exp -= currLvlExp;
expToNextLvl = gExperienceTables[gBaseStats[species].growthRate][level + 1] - currLvlExp;
SetBattleBarStruct(bank, gHealthboxSpriteIds[bank], expToNextLvl, exp, -gainedExp);
SetBattleBarStruct(battlerId, gHealthboxSpriteIds[battlerId], expToNextLvl, exp, -gainedExp);
PlaySE(SE_EXP);
gTasks[taskId].func = sub_81BB4E4;
}
@ -396,11 +396,11 @@ static void sub_81BB4E4(u8 taskId)
{
u8 monId = gTasks[taskId].tExpTask_monId;
s16 gainedExp = gTasks[taskId].tExpTask_gainedExp;
u8 bank = gTasks[taskId].tExpTask_bank;
u8 battlerId = gTasks[taskId].tExpTask_bank;
s16 r4;
r4 = sub_8074AA0(bank, gHealthboxSpriteIds[bank], EXP_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[bank]);
r4 = sub_8074AA0(battlerId, gHealthboxSpriteIds[battlerId], EXP_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battlerId]);
if (r4 == -1)
{
u8 level;
@ -422,7 +422,7 @@ static void sub_81BB4E4(u8 taskId)
CalculateMonStats(&gPlayerParty[monId]);
gainedExp -= expOnNextLvl - currExp;
savedActiveBank = gActiveBattler;
gActiveBattler = bank;
gActiveBattler = battlerId;
BtlController_EmitTwoReturnValues(1, RET_VALUE_LEVELLED_UP, gainedExp);
gActiveBattler = savedActiveBank;
gTasks[taskId].func = sub_81BB628;
@ -431,7 +431,7 @@ static void sub_81BB4E4(u8 taskId)
{
currExp += gainedExp;
SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &currExp);
gBattlerControllerFuncs[bank] = CompleteOnInactiveTextPrinter;
gBattlerControllerFuncs[battlerId] = CompleteOnInactiveTextPrinter;
DestroyTask(taskId);
}
}
@ -440,30 +440,30 @@ static void sub_81BB4E4(u8 taskId)
static void sub_81BB628(u8 taskId)
{
u8 bank = gTasks[taskId].tExpTask_bank;
u8 battlerId = gTasks[taskId].tExpTask_bank;
u8 monIndex = gTasks[taskId].tExpTask_monId;
if (IsDoubleBattle() == TRUE && monIndex == gBattlerPartyIndexes[bank ^ BIT_FLANK])
bank ^= BIT_FLANK;
if (IsDoubleBattle() == TRUE && monIndex == gBattlerPartyIndexes[battlerId ^ BIT_FLANK])
battlerId ^= BIT_FLANK;
InitAndLaunchSpecialAnimation(bank, bank, bank, B_ANIM_LVL_UP);
InitAndLaunchSpecialAnimation(battlerId, battlerId, battlerId, B_ANIM_LVL_UP);
gTasks[taskId].func = sub_81BB688;
}
static void sub_81BB688(u8 taskId)
{
u8 bank = gTasks[taskId].tExpTask_bank;
u8 battlerId = gTasks[taskId].tExpTask_bank;
if (!gBattleSpritesDataPtr->healthBoxesData[bank].specialAnimActive)
if (!gBattleSpritesDataPtr->healthBoxesData[battlerId].specialAnimActive)
{
u8 monIndex = gTasks[taskId].tExpTask_monId;
GetMonData(&gPlayerParty[monIndex], MON_DATA_LEVEL); // Unused return value
if (IsDoubleBattle() == TRUE && monIndex == gBattlerPartyIndexes[bank ^ BIT_FLANK])
UpdateHealthboxAttribute(gHealthboxSpriteIds[bank ^ BIT_FLANK], &gPlayerParty[monIndex], HEALTHBOX_ALL);
if (IsDoubleBattle() == TRUE && monIndex == gBattlerPartyIndexes[battlerId ^ BIT_FLANK])
UpdateHealthboxAttribute(gHealthboxSpriteIds[battlerId ^ BIT_FLANK], &gPlayerParty[monIndex], HEALTHBOX_ALL);
else
UpdateHealthboxAttribute(gHealthboxSpriteIds[bank], &gPlayerParty[monIndex], HEALTHBOX_ALL);
UpdateHealthboxAttribute(gHealthboxSpriteIds[battlerId], &gPlayerParty[monIndex], HEALTHBOX_ALL);
gTasks[taskId].func = DestroyExpTaskAndCompleteOnInactiveTextPrinter;
}
@ -472,12 +472,12 @@ static void sub_81BB688(u8 taskId)
static void DestroyExpTaskAndCompleteOnInactiveTextPrinter(u8 taskId)
{
u8 monIndex;
u8 bank;
u8 battlerId;
monIndex = gTasks[taskId].tExpTask_monId;
GetMonData(&gPlayerParty[monIndex], MON_DATA_LEVEL); // Unused return value
bank = gTasks[taskId].tExpTask_bank;
gBattlerControllerFuncs[bank] = CompleteOnInactiveTextPrinter;
battlerId = gTasks[taskId].tExpTask_bank;
gBattlerControllerFuncs[battlerId] = CompleteOnInactiveTextPrinter;
DestroyTask(taskId);
}
@ -1232,35 +1232,35 @@ static void PlayerPartnerHandleSwitchInAnim(void)
gBattlerControllerFuncs[gActiveBattler] = sub_81BBAE8;
}
static void sub_81BD0E4(u8 bank, bool8 dontClearSubstituteBit)
static void sub_81BD0E4(u8 battlerId, bool8 dontClearSubstituteBit)
{
u16 species;
ClearTemporarySpeciesSpriteData(bank, dontClearSubstituteBit);
gBattlerPartyIndexes[bank] = gBattleBufferA[bank][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES);
gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714);
sub_806A068(species, GetBattlerPosition(bank));
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714);
sub_806A068(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[bank] = CreateSprite(
gBattlerSpriteIds[battlerId] = CreateSprite(
&gUnknown_0202499C,
GetBattlerSpriteCoord(bank, 2),
GetBattlerSpriteDefault_Y(bank),
sub_80A82E4(bank));
GetBattlerSpriteCoord(battlerId, 2),
GetBattlerSpriteDefault_Y(battlerId),
sub_80A82E4(battlerId));
gSprites[gUnknown_03005D7C[bank]].data[1] = gBattlerSpriteIds[bank];
gSprites[gUnknown_03005D7C[bank]].data[2] = bank;
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[bank]].data[0] = bank;
gSprites[gBattlerSpriteIds[bank]].data[2] = species;
gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
gSprites[gBattlerSpriteIds[battlerId]].oam.paletteNum = battlerId;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], gBattleMonForms[battlerId]);
gSprites[gBattlerSpriteIds[bank]].invisible = TRUE;
gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
gSprites[gUnknown_03005D7C[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
}
static void PlayerPartnerHandleReturnMonToBall(void)
@ -1625,11 +1625,11 @@ static void PlayerPartnerHandleStatusIconUpdate(void)
{
if (!mplay_80342A4(gActiveBattler))
{
u8 bank;
u8 battlerId;
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON);
bank = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0;
battlerId = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[battlerId].statusAnimActive = 0;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
}
}

View File

@ -35,7 +35,7 @@ extern u8 gUnknown_0203C7B4;
extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
extern void sub_8172EF0(u8 bank, struct Pokemon *mon);
extern void sub_8172EF0(u8 battlerId, struct Pokemon *mon);
extern void sub_806A068(u16, u8);
extern u16 sub_8068B48(void);
extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId);
@ -104,7 +104,7 @@ static void RecordedOpponentBufferExecCompleted(void);
static void sub_8186F14(void);
static u32 CopyRecordedOpponentMonData(u8 monId, u8 *dst);
static void SetRecordedOpponentMonData(u8 monId);
static void sub_81885D8(u8 bank, bool8 dontClearSubstituteBit);
static void sub_81885D8(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void);
static void RecordedOpponentDoMoveAnimation(void);
static void sub_8189548(u8 taskId);
@ -1144,35 +1144,35 @@ static void RecordedOpponentHandleSwitchInAnim(void)
gBattlerControllerFuncs[gActiveBattler] = sub_8187084;
}
static void sub_81885D8(u8 bank, bool8 dontClearSubstituteBit)
static void sub_81885D8(u8 battlerId, bool8 dontClearSubstituteBit)
{
u16 species;
ClearTemporarySpeciesSpriteData(bank, dontClearSubstituteBit);
gBattlerPartyIndexes[bank] = gBattleBufferA[bank][1];
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES);
gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714);
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[bank]], bank);
sub_806A068(species, GetBattlerPosition(bank));
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714);
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId);
sub_806A068(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[bank] = CreateSprite(&gUnknown_0202499C,
GetBattlerSpriteCoord(bank, 2),
GetBattlerSpriteDefault_Y(bank),
sub_80A82E4(bank));
gBattlerSpriteIds[battlerId] = CreateSprite(&gUnknown_0202499C,
GetBattlerSpriteCoord(battlerId, 2),
GetBattlerSpriteDefault_Y(battlerId),
sub_80A82E4(battlerId));
gSprites[gUnknown_03005D7C[bank]].data[1] = gBattlerSpriteIds[bank];
gSprites[gUnknown_03005D7C[bank]].data[2] = bank;
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[bank]].data[0] = bank;
gSprites[gBattlerSpriteIds[bank]].data[2] = species;
gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
gSprites[gBattlerSpriteIds[battlerId]].oam.paletteNum = battlerId;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], gBattleMonForms[battlerId]);
gSprites[gBattlerSpriteIds[bank]].invisible = TRUE;
gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT);
gSprites[gUnknown_03005D7C[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT);
}
static void RecordedOpponentHandleReturnMonToBall(void)
@ -1490,11 +1490,11 @@ static void RecordedOpponentHandleStatusIconUpdate(void)
{
if (!mplay_80342A4(gActiveBattler))
{
u8 bank;
u8 battlerId;
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON);
bank = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0;
battlerId = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[battlerId].statusAnimActive = 0;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
}
}

View File

@ -35,7 +35,7 @@ extern struct UnusedControllerStruct gUnknown_02022D0C;
extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[];
extern void sub_8172EF0(u8 bank, struct Pokemon *mon);
extern void sub_8172EF0(u8 battlerId, struct Pokemon *mon);
extern void sub_806A068(u16, u8);
extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId);
@ -103,7 +103,7 @@ static void RecordedPlayerBufferExecCompleted(void);
static void sub_818A328(void);
static u32 CopyRecordedPlayerMonData(u8 monId, u8 *dst);
static void SetRecordedPlayerMonData(u8 monId);
static void sub_818BA6C(u8 bank, bool8 dontClearSubstituteBit);
static void sub_818BA6C(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void);
static void RecordedPlayerDoMoveAnimation(void);
static void sub_818CC24(u8 taskId);
@ -1129,35 +1129,35 @@ static void RecordedPlayerHandleSwitchInAnim(void)
gBattlerControllerFuncs[gActiveBattler] = sub_818A470;
}
static void sub_818BA6C(u8 bank, bool8 dontClearSubstituteBit)
static void sub_818BA6C(u8 battlerId, bool8 dontClearSubstituteBit)
{
u16 species;
ClearTemporarySpeciesSpriteData(bank, dontClearSubstituteBit);
gBattlerPartyIndexes[bank] = gBattleBufferA[bank][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES);
gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714);
sub_806A068(species, GetBattlerPosition(bank));
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714);
sub_806A068(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[bank] = CreateSprite(
gBattlerSpriteIds[battlerId] = CreateSprite(
&gUnknown_0202499C,
GetBattlerSpriteCoord(bank, 2),
GetBattlerSpriteDefault_Y(bank),
sub_80A82E4(bank));
GetBattlerSpriteCoord(battlerId, 2),
GetBattlerSpriteDefault_Y(battlerId),
sub_80A82E4(battlerId));
gSprites[gUnknown_03005D7C[bank]].data[1] = gBattlerSpriteIds[bank];
gSprites[gUnknown_03005D7C[bank]].data[2] = bank;
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[bank]].data[0] = bank;
gSprites[gBattlerSpriteIds[bank]].data[2] = species;
gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
gSprites[gBattlerSpriteIds[battlerId]].oam.paletteNum = battlerId;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], gBattleMonForms[battlerId]);
gSprites[gBattlerSpriteIds[bank]].invisible = TRUE;
gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
gSprites[gUnknown_03005D7C[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
}
static void RecordedPlayerHandleReturnMonToBall(void)
@ -1512,11 +1512,11 @@ static void RecordedPlayerHandleStatusIconUpdate(void)
{
if (!mplay_80342A4(gActiveBattler))
{
u8 bank;
u8 battlerId;
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON);
bank = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0;
battlerId = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[battlerId].statusAnimActive = 0;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
}
}

View File

@ -37,7 +37,7 @@ extern struct UnusedControllerStruct gUnknown_02022D0C;
extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[];
extern void sub_8172EF0(u8 bank, struct Pokemon *mon);
extern void sub_8172EF0(u8 battlerId, struct Pokemon *mon);
extern void sub_806A068(u16, u8);
// this file's functions
@ -1457,31 +1457,31 @@ static void WallyHandleIntroTrainerBallThrow(void)
gBattlerControllerFuncs[gActiveBattler] = nullsub_21;
}
static void sub_816AA80(u8 bank)
static void sub_816AA80(u8 battlerId)
{
u16 species;
gBattleSpritesDataPtr->battlerData[bank].transformSpecies = 0;
gBattlerPartyIndexes[bank] = gBattleBufferA[bank][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES);
gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714);
sub_806A068(species, GetBattlerPosition(bank));
gBattlerSpriteIds[bank] = CreateSprite(&gUnknown_0202499C,
GetBattlerSpriteCoord(bank, 2),
GetBattlerSpriteDefault_Y(bank),
sub_80A82E4(bank));
gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies = 0;
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714);
sub_806A068(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[battlerId] = CreateSprite(&gUnknown_0202499C,
GetBattlerSpriteCoord(battlerId, 2),
GetBattlerSpriteDefault_Y(battlerId),
sub_80A82E4(battlerId));
gSprites[gUnknown_03005D7C[bank]].data[1] = gBattlerSpriteIds[bank];
gSprites[gUnknown_03005D7C[bank]].data[2] = bank;
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[bank]].data[0] = bank;
gSprites[gBattlerSpriteIds[bank]].data[2] = species;
gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
gSprites[gBattlerSpriteIds[battlerId]].oam.paletteNum = battlerId;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]);
gSprites[gBattlerSpriteIds[bank]].invisible = TRUE;
gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], gBattleMonForms[battlerId]);
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
}
static void sub_816AC04(u8 taskId)

View File

@ -18,9 +18,8 @@ extern u8 gUnknown_02022D0A;
static EWRAM_DATA u8 sBattleBuffersTransferData[0x100] = {};
extern void task00_08081A90(u8 taskId); // cable_club
extern void sub_81B8D64(u8 bank, u8 arg1); // party_menu
extern void sub_81B8D64(u8 battlerId, u8 arg1); // party_menu
// this file's funcionts
static void CreateTasksForSendRecvLinkBuffers(void);
@ -868,7 +867,7 @@ void sub_8033648(void)
static void Task_HandleCopyReceivedLinkBuffersData(u8 taskId)
{
u16 blockSize;
u8 bank;
u8 battlerId;
u8 var;
if (gTasks[taskId].data[15] != gTasks[taskId].data[14])
@ -879,17 +878,17 @@ static void Task_HandleCopyReceivedLinkBuffersData(u8 taskId)
gTasks[taskId].data[12] = 0;
gTasks[taskId].data[15] = 0;
}
bank = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_ACTIVE_BANK];
battlerId = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_ACTIVE_BANK];
blockSize = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_SIZE_LO] | (gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_SIZE_HI] << 8);
switch (gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 0])
{
case 0:
if (gBattleControllerExecFlags & gBitTable[bank])
if (gBattleControllerExecFlags & gBitTable[battlerId])
return;
memcpy(gBattleBufferA[bank], &gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 8], blockSize);
sub_803F850(bank);
memcpy(gBattleBufferA[battlerId], &gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 8], blockSize);
sub_803F850(battlerId);
if (!(gBattleTypeFlags & BATTLE_TYPE_WILD))
{
@ -900,11 +899,11 @@ static void Task_HandleCopyReceivedLinkBuffersData(u8 taskId)
}
break;
case 1:
memcpy(gBattleBufferB[bank], &gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 8], blockSize);
memcpy(gBattleBufferB[battlerId], &gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 8], blockSize);
break;
case 2:
var = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_DATA];
gBattleControllerExecFlags &= ~(gBitTable[bank] << (var * 4));
gBattleControllerExecFlags &= ~(gBitTable[battlerId] << (var * 4));
break;
}

View File

@ -21,6 +21,7 @@
#include "safari_zone.h"
#include "battle_anim.h"
#include "constants/rgb.h"
#include "data2.h"
struct TestingBar
{
@ -154,7 +155,6 @@ enum
};
extern const u8 * const gNatureNamePointers[];
extern const u8 gSpeciesNames[][POKEMON_NAME_LENGTH + 1];
// strings
extern const u8 gText_Slash[];
@ -162,8 +162,6 @@ extern const u8 gText_HighlightDarkGrey[];
extern const u8 gText_DynColor2[];
extern const u8 gText_DynColor2Male[];
extern const u8 gText_DynColor1Female[];
extern const u8 gText_SafariBalls[];
extern const u8 gText_SafariBallLeft[];
// graphics
extern const u8 gBattleInterface_BallStatusBarGfx[];
@ -198,10 +196,10 @@ static void SpriteCB_StatusSummaryBar(struct Sprite *sprite);
static void SpriteCB_StatusSummaryBallsOnBattleStart(struct Sprite *sprite);
static void SpriteCB_StatusSummaryBallsOnSwitchout(struct Sprite *sprite);
static u8 GetStatusIconForBankId(u8 statusElementId, u8 bank);
static u8 GetStatusIconForBankId(u8 statusElementId, u8 battlerId);
static s32 sub_8074DB8(s32 maxValue, s32 currValue, s32 receivedValue, s32 *arg3, u8 arg4, u16 arg5);
static u8 GetScaledExpFraction(s32 currValue, s32 receivedValue, s32 maxValue, u8 scale);
static void sub_8074B9C(u8 bank, u8 whichBar);
static void sub_8074B9C(u8 battlerId, u8 whichBar);
static u8 sub_8074E8C(s32 maxValue, s32 currValue, s32 receivedValue, s32 *arg3, u8 *arg4, u8 arg5);
static void sub_8074F88(struct TestingBar *barInfo, s32 *arg1, u16 *arg2);
@ -1034,13 +1032,13 @@ static void sub_8072924(struct Sprite *sprite)
sprite->pos2.y = gSprites[otherSpriteId].pos2.y;
}
void SetBattleBarStruct(u8 bank, u8 healthboxSpriteId, s32 maxVal, s32 currVal, s32 receivedValue)
void SetBattleBarStruct(u8 battlerId, u8 healthboxSpriteId, s32 maxVal, s32 currVal, s32 receivedValue)
{
gBattleSpritesDataPtr->battleBars[bank].healthboxSpriteId = healthboxSpriteId;
gBattleSpritesDataPtr->battleBars[bank].maxValue = maxVal;
gBattleSpritesDataPtr->battleBars[bank].currentValue = currVal;
gBattleSpritesDataPtr->battleBars[bank].receivedValue = receivedValue;
gBattleSpritesDataPtr->battleBars[bank].field_10 = -32768;
gBattleSpritesDataPtr->battleBars[battlerId].healthboxSpriteId = healthboxSpriteId;
gBattleSpritesDataPtr->battleBars[battlerId].maxValue = maxVal;
gBattleSpritesDataPtr->battleBars[battlerId].currentValue = currVal;
gBattleSpritesDataPtr->battleBars[battlerId].receivedValue = receivedValue;
gBattleSpritesDataPtr->battleBars[battlerId].field_10 = -32768;
}
void SetHealthboxSpriteInvisible(u8 healthboxSpriteId)
@ -1281,12 +1279,12 @@ static void UpdateHpTextInHealthboxInDoubles(u8 healthboxSpriteId, s16 value, u8
}
else
{
u8 bank;
u8 battlerId;
memcpy(text, sUnknown_0832C3D8, sizeof(sUnknown_0832C3D8));
bank = gSprites[healthboxSpriteId].data[6];
battlerId = gSprites[healthboxSpriteId].data[6];
if (gBattleSpritesDataPtr->battlerData[bank].hpNumbersNoBars) // don't print text if only bars are visible
if (gBattleSpritesDataPtr->battlerData[battlerId].hpNumbersNoBars) // don't print text if only bars are visible
{
u8 var = 4;
u8 r7;
@ -1327,7 +1325,7 @@ static void UpdateHpTextInHealthboxInDoubles(u8 healthboxSpriteId, s16 value, u8
}
else
{
if (GetBattlerSide(bank) == B_SIDE_PLAYER) // impossible to reach part, because the bank is from the opponent's side
if (GetBattlerSide(battlerId) == B_SIDE_PLAYER) // impossible to reach part, because the battlerId is from the opponent's side
{
CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_116),
(void*)(OBJ_VRAM0) + ((gSprites[healthboxSpriteId].oam.tileNum + 52) * 32),
@ -1469,7 +1467,7 @@ void SwapHpBarsWithHpText(void)
}
}
u8 CreatePartyStatusSummarySprites(u8 bank, struct HpAndStatus *partyInfo, u8 arg2, bool8 isBattleStart)
u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo, u8 arg2, bool8 isBattleStart)
{
bool8 isOpponent;
s16 bar_X, bar_Y, bar_pos2_X, bar_data0;
@ -1478,9 +1476,9 @@ u8 CreatePartyStatusSummarySprites(u8 bank, struct HpAndStatus *partyInfo, u8 ar
u8 ballIconSpritesIds[6];
u8 taskId;
if (!arg2 || GetBattlerPosition(bank) != B_POSITION_OPPONENT_RIGHT)
if (!arg2 || GetBattlerPosition(battlerId) != B_POSITION_OPPONENT_RIGHT)
{
if (GetBattlerSide(bank) == B_SIDE_PLAYER)
if (GetBattlerSide(battlerId) == B_SIDE_PLAYER)
{
isOpponent = FALSE;
bar_X = 136, bar_Y = 96;
@ -1559,7 +1557,7 @@ u8 CreatePartyStatusSummarySprites(u8 bank, struct HpAndStatus *partyInfo, u8 ar
gSprites[ballIconSpritesIds[i]].data[2] = isOpponent;
}
if (GetBattlerSide(bank) == B_SIDE_PLAYER)
if (GetBattlerSide(battlerId) == B_SIDE_PLAYER)
{
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
{
@ -1658,7 +1656,7 @@ u8 CreatePartyStatusSummarySprites(u8 bank, struct HpAndStatus *partyInfo, u8 ar
}
taskId = CreateTask(TaskDummy, 5);
gTasks[taskId].data[0] = bank;
gTasks[taskId].data[0] = battlerId;
gTasks[taskId].data[1] = barSpriteId;
for (i = 0; i < 6; i++)
@ -1680,12 +1678,12 @@ void sub_8073C30(u8 taskId)
u8 sp[6];
u8 r7;
u8 r10;
u8 bank;
u8 battlerId;
s32 i;
r7 = gTasks[taskId].data[10];
r10 = gTasks[taskId].data[1];
bank = gTasks[taskId].data[0];
battlerId = gTasks[taskId].data[0];
for (i = 0; i < 6; i++)
sp[i] = gTasks[taskId].data[3 + i];
@ -1704,7 +1702,7 @@ void sub_8073C30(u8 taskId)
{
for (i = 0; i < 6; i++)
{
if (GetBattlerSide(bank) != B_SIDE_PLAYER)
if (GetBattlerSide(battlerId) != B_SIDE_PLAYER)
{
gSprites[sp[5 - i]].data[1] = 7 * i;
gSprites[sp[5 - i]].data[3] = 0;
@ -1752,7 +1750,7 @@ static void sub_8073E64(u8 taskId)
u8 sp[6];
s32 i;
u8 bank = gTasks[taskId].data[0];
u8 battlerId = gTasks[taskId].data[0];
gTasks[taskId].data[15]--;
if (gTasks[taskId].data[15] == -1)
{
@ -1780,7 +1778,7 @@ static void sub_8073E64(u8 taskId)
}
else if (gTasks[taskId].data[15] == -3)
{
gBattleSpritesDataPtr->healthBoxesData[bank].flag_x1 = 0;
gBattleSpritesDataPtr->healthBoxesData[battlerId].flag_x1 = 0;
SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
DestroyTask(taskId);
@ -1792,7 +1790,7 @@ static void sub_8073F98(u8 taskId)
u8 sp[6];
s32 i;
u8 bank = gTasks[taskId].data[0];
u8 battlerId = gTasks[taskId].data[0];
gTasks[taskId].data[15]--;
if (gTasks[taskId].data[15] >= 0)
{
@ -1813,7 +1811,7 @@ static void sub_8073F98(u8 taskId)
}
else if (gTasks[taskId].data[15] == -3)
{
gBattleSpritesDataPtr->healthBoxesData[bank].flag_x1 = 0;
gBattleSpritesDataPtr->healthBoxesData[battlerId].flag_x1 = 0;
SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
DestroyTask(taskId);
@ -1976,17 +1974,17 @@ static void UpdateNickInHealthbox(u8 healthboxSpriteId, struct Pokemon *mon)
static void TryAddPokeballIconToHealthbox(u8 healthboxSpriteId, bool8 noStatus)
{
u8 bank, healthboxSpriteId_2;
u8 battlerId, healthboxSpriteId_2;
if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL)
return;
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER)
return;
bank = gSprites[healthboxSpriteId].data[6];
if (GetBattlerSide(bank) == B_SIDE_PLAYER)
battlerId = gSprites[healthboxSpriteId].data[6];
if (GetBattlerSide(battlerId) == B_SIDE_PLAYER)
return;
if (!GetSetPokedexFlag(SpeciesToNationalPokedexNum(GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES)), FLAG_GET_CAUGHT))
if (!GetSetPokedexFlag(SpeciesToNationalPokedexNum(GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES)), FLAG_GET_CAUGHT))
return;
healthboxSpriteId_2 = gSprites[healthboxSpriteId].data[5];
@ -2000,17 +1998,17 @@ static void TryAddPokeballIconToHealthbox(u8 healthboxSpriteId, bool8 noStatus)
static void UpdateStatusIconInHealthbox(u8 healthboxSpriteId)
{
s32 i;
u8 bank, healthboxSpriteId_2;
u8 battlerId, healthboxSpriteId_2;
u32 status, pltAdder;
const u8 *statusGfxPtr;
s16 tileNumAdder;
u8 statusPalId;
bank = gSprites[healthboxSpriteId].data[6];
battlerId = gSprites[healthboxSpriteId].data[6];
healthboxSpriteId_2 = gSprites[healthboxSpriteId].data[5];
if (GetBattlerSide(bank) == B_SIDE_PLAYER)
if (GetBattlerSide(battlerId) == B_SIDE_PLAYER)
{
status = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_STATUS);
status = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_STATUS);
if (!IsDoubleBattle())
tileNumAdder = 0x1A;
else
@ -2018,33 +2016,33 @@ static void UpdateStatusIconInHealthbox(u8 healthboxSpriteId)
}
else
{
status = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_STATUS);
status = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_STATUS);
tileNumAdder = 0x11;
}
if (status & STATUS1_SLEEP)
{
statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_SLP_BANK0, bank));
statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_SLP_BANK0, battlerId));
statusPalId = PAL_STATUS_SLP;
}
else if (status & STATUS1_PSN_ANY)
{
statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_PSN_BANK0, bank));
statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_PSN_BANK0, battlerId));
statusPalId = PAL_STATUS_PSN;
}
else if (status & STATUS1_BURN)
{
statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_BRN_BANK0, bank));
statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_BRN_BANK0, battlerId));
statusPalId = PAL_STATUS_BRN;
}
else if (status & STATUS1_FREEZE)
{
statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_FRZ_BANK0, bank));
statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_FRZ_BANK0, battlerId));
statusPalId = PAL_STATUS_FRZ;
}
else if (status & STATUS1_PARALYSIS)
{
statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_PRZ_BANK0, bank));
statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_PRZ_BANK0, battlerId));
statusPalId = PAL_STATUS_PAR;
}
else
@ -2054,7 +2052,7 @@ static void UpdateStatusIconInHealthbox(u8 healthboxSpriteId)
for (i = 0; i < 3; i++)
CpuCopy32(statusGfxPtr, (void*)(OBJ_VRAM0 + (gSprites[healthboxSpriteId].oam.tileNum + tileNumAdder + i) * 32), 32);
if (!gBattleSpritesDataPtr->battlerData[bank].hpNumbersNoBars)
if (!gBattleSpritesDataPtr->battlerData[battlerId].hpNumbersNoBars)
CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_1), (void *)(OBJ_VRAM0 + gSprites[healthboxSpriteId_2].oam.tileNum * 32), 64);
TryAddPokeballIconToHealthbox(healthboxSpriteId, TRUE);
@ -2062,14 +2060,14 @@ static void UpdateStatusIconInHealthbox(u8 healthboxSpriteId)
}
pltAdder = gSprites[healthboxSpriteId].oam.paletteNum * 16;
pltAdder += bank + 12;
pltAdder += battlerId + 12;
FillPalette(sStatusIconColors[statusPalId], pltAdder + 0x100, 2);
CpuCopy16(gPlttBufferUnfaded + 0x100 + pltAdder, (void*)(OBJ_PLTT + pltAdder * 2), 2);
CpuCopy32(statusGfxPtr, (void*)(OBJ_VRAM0 + (gSprites[healthboxSpriteId].oam.tileNum + tileNumAdder) * 32), 96);
if (IsDoubleBattle() == TRUE || GetBattlerSide(bank) == B_SIDE_OPPONENT)
if (IsDoubleBattle() == TRUE || GetBattlerSide(battlerId) == B_SIDE_OPPONENT)
{
if (!gBattleSpritesDataPtr->battlerData[bank].hpNumbersNoBars)
if (!gBattleSpritesDataPtr->battlerData[battlerId].hpNumbersNoBars)
{
CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_0), (void*)(OBJ_VRAM0 + gSprites[healthboxSpriteId_2].oam.tileNum * 32), 32);
CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_65), (void*)(OBJ_VRAM0 + (gSprites[healthboxSpriteId_2].oam.tileNum + 1) * 32), 32);
@ -2078,58 +2076,58 @@ static void UpdateStatusIconInHealthbox(u8 healthboxSpriteId)
TryAddPokeballIconToHealthbox(healthboxSpriteId, FALSE);
}
static u8 GetStatusIconForBankId(u8 statusElementId, u8 bank)
static u8 GetStatusIconForBankId(u8 statusElementId, u8 battlerId)
{
u8 ret = statusElementId;
switch (statusElementId)
{
case HEALTHBOX_GFX_STATUS_PSN_BANK0:
if (bank == 0)
if (battlerId == 0)
ret = HEALTHBOX_GFX_STATUS_PSN_BANK0;
else if (bank == 1)
else if (battlerId == 1)
ret = HEALTHBOX_GFX_STATUS_PSN_BANK1;
else if (bank == 2)
else if (battlerId == 2)
ret = HEALTHBOX_GFX_STATUS_PSN_BANK2;
else
ret = HEALTHBOX_GFX_STATUS_PSN_BANK3;
break;
case HEALTHBOX_GFX_STATUS_PRZ_BANK0:
if (bank == 0)
if (battlerId == 0)
ret = HEALTHBOX_GFX_STATUS_PRZ_BANK0;
else if (bank == 1)
else if (battlerId == 1)
ret = HEALTHBOX_GFX_STATUS_PRZ_BANK1;
else if (bank == 2)
else if (battlerId == 2)
ret = HEALTHBOX_GFX_STATUS_PRZ_BANK2;
else
ret = HEALTHBOX_GFX_STATUS_PRZ_BANK3;
break;
case HEALTHBOX_GFX_STATUS_SLP_BANK0:
if (bank == 0)
if (battlerId == 0)
ret = HEALTHBOX_GFX_STATUS_SLP_BANK0;
else if (bank == 1)
else if (battlerId == 1)
ret = HEALTHBOX_GFX_STATUS_SLP_BANK1;
else if (bank == 2)
else if (battlerId == 2)
ret = HEALTHBOX_GFX_STATUS_SLP_BANK2;
else
ret = HEALTHBOX_GFX_STATUS_SLP_BANK3;
break;
case HEALTHBOX_GFX_STATUS_FRZ_BANK0:
if (bank == 0)
if (battlerId == 0)
ret = HEALTHBOX_GFX_STATUS_FRZ_BANK0;
else if (bank == 1)
else if (battlerId == 1)
ret = HEALTHBOX_GFX_STATUS_FRZ_BANK1;
else if (bank == 2)
else if (battlerId == 2)
ret = HEALTHBOX_GFX_STATUS_FRZ_BANK2;
else
ret = HEALTHBOX_GFX_STATUS_FRZ_BANK3;
break;
case HEALTHBOX_GFX_STATUS_BRN_BANK0:
if (bank == 0)
if (battlerId == 0)
ret = HEALTHBOX_GFX_STATUS_BRN_BANK0;
else if (bank == 1)
else if (battlerId == 1)
ret = HEALTHBOX_GFX_STATUS_BRN_BANK1;
else if (bank == 2)
else if (battlerId == 2)
ret = HEALTHBOX_GFX_STATUS_BRN_BANK2;
else
ret = HEALTHBOX_GFX_STATUS_BRN_BANK3;
@ -2170,10 +2168,10 @@ static void UpdateLeftNoOfBallsTextOnHealthbox(u8 healthboxSpriteId)
void UpdateHealthboxAttribute(u8 healthboxSpriteId, struct Pokemon *mon, u8 elementId)
{
s32 maxHp, currHp;
u8 bank = gSprites[healthboxSpriteId].data[6];
u8 battlerId = gSprites[healthboxSpriteId].data[6];
if (elementId == HEALTHBOX_ALL && !IsDoubleBattle())
GetBattlerSide(bank); // pointless function call
GetBattlerSide(battlerId); // pointless function call
if (GetBattlerSide(gSprites[healthboxSpriteId].data[6]) == B_SIDE_PLAYER)
{
@ -2190,8 +2188,8 @@ void UpdateHealthboxAttribute(u8 healthboxSpriteId, struct Pokemon *mon, u8 elem
LoadBattleBarGfx(0);
maxHp = GetMonData(mon, MON_DATA_MAX_HP);
currHp = GetMonData(mon, MON_DATA_HP);
SetBattleBarStruct(bank, healthboxSpriteId, maxHp, currHp, 0);
sub_8074AA0(bank, healthboxSpriteId, HEALTH_BAR, 0);
SetBattleBarStruct(battlerId, healthboxSpriteId, maxHp, currHp, 0);
sub_8074AA0(battlerId, healthboxSpriteId, HEALTH_BAR, 0);
}
isDoubles = IsDoubleBattle();
if (!isDoubles && (elementId == HEALTHBOX_EXP_BAR || elementId == HEALTHBOX_ALL))
@ -2208,8 +2206,8 @@ void UpdateHealthboxAttribute(u8 healthboxSpriteId, struct Pokemon *mon, u8 elem
currLevelExp = gExperienceTables[gBaseStats[species].growthRate][level];
currExpBarValue = exp - currLevelExp;
maxExpBarValue = gExperienceTables[gBaseStats[species].growthRate][level + 1] - currLevelExp;
SetBattleBarStruct(bank, healthboxSpriteId, maxExpBarValue, currExpBarValue, isDoubles);
sub_8074AA0(bank, healthboxSpriteId, EXP_BAR, 0);
SetBattleBarStruct(battlerId, healthboxSpriteId, maxExpBarValue, currExpBarValue, isDoubles);
sub_8074AA0(battlerId, healthboxSpriteId, EXP_BAR, 0);
}
if (elementId == HEALTHBOX_NICK || elementId == HEALTHBOX_ALL)
UpdateNickInHealthbox(healthboxSpriteId, mon);
@ -2229,8 +2227,8 @@ void UpdateHealthboxAttribute(u8 healthboxSpriteId, struct Pokemon *mon, u8 elem
LoadBattleBarGfx(0);
maxHp = GetMonData(mon, MON_DATA_MAX_HP);
currHp = GetMonData(mon, MON_DATA_HP);
SetBattleBarStruct(bank, healthboxSpriteId, maxHp, currHp, 0);
sub_8074AA0(bank, healthboxSpriteId, HEALTH_BAR, 0);
SetBattleBarStruct(battlerId, healthboxSpriteId, maxHp, currHp, 0);
sub_8074AA0(battlerId, healthboxSpriteId, HEALTH_BAR, 0);
}
if (elementId == HEALTHBOX_NICK || elementId == HEALTHBOX_ALL)
UpdateNickInHealthbox(healthboxSpriteId, mon);
@ -2239,44 +2237,44 @@ void UpdateHealthboxAttribute(u8 healthboxSpriteId, struct Pokemon *mon, u8 elem
}
}
s32 sub_8074AA0(u8 bank, u8 healthboxSpriteId, u8 whichBar, u8 arg3)
s32 sub_8074AA0(u8 battlerId, u8 healthboxSpriteId, u8 whichBar, u8 arg3)
{
s32 var;
if (whichBar == HEALTH_BAR) // health bar
{
var = sub_8074DB8(gBattleSpritesDataPtr->battleBars[bank].maxValue,
gBattleSpritesDataPtr->battleBars[bank].currentValue,
gBattleSpritesDataPtr->battleBars[bank].receivedValue,
&gBattleSpritesDataPtr->battleBars[bank].field_10,
var = sub_8074DB8(gBattleSpritesDataPtr->battleBars[battlerId].maxValue,
gBattleSpritesDataPtr->battleBars[battlerId].currentValue,
gBattleSpritesDataPtr->battleBars[battlerId].receivedValue,
&gBattleSpritesDataPtr->battleBars[battlerId].field_10,
6, 1);
}
else // exp bar
{
u16 expFraction = GetScaledExpFraction(gBattleSpritesDataPtr->battleBars[bank].currentValue,
gBattleSpritesDataPtr->battleBars[bank].receivedValue,
gBattleSpritesDataPtr->battleBars[bank].maxValue, 8);
u16 expFraction = GetScaledExpFraction(gBattleSpritesDataPtr->battleBars[battlerId].currentValue,
gBattleSpritesDataPtr->battleBars[battlerId].receivedValue,
gBattleSpritesDataPtr->battleBars[battlerId].maxValue, 8);
if (expFraction == 0)
expFraction = 1;
expFraction = abs(gBattleSpritesDataPtr->battleBars[bank].receivedValue / expFraction);
expFraction = abs(gBattleSpritesDataPtr->battleBars[battlerId].receivedValue / expFraction);
var = sub_8074DB8(gBattleSpritesDataPtr->battleBars[bank].maxValue,
gBattleSpritesDataPtr->battleBars[bank].currentValue,
gBattleSpritesDataPtr->battleBars[bank].receivedValue,
&gBattleSpritesDataPtr->battleBars[bank].field_10,
var = sub_8074DB8(gBattleSpritesDataPtr->battleBars[battlerId].maxValue,
gBattleSpritesDataPtr->battleBars[battlerId].currentValue,
gBattleSpritesDataPtr->battleBars[battlerId].receivedValue,
&gBattleSpritesDataPtr->battleBars[battlerId].field_10,
8, expFraction);
}
if (whichBar == EXP_BAR || (whichBar == HEALTH_BAR && !gBattleSpritesDataPtr->battlerData[bank].hpNumbersNoBars))
sub_8074B9C(bank, whichBar);
if (whichBar == EXP_BAR || (whichBar == HEALTH_BAR && !gBattleSpritesDataPtr->battlerData[battlerId].hpNumbersNoBars))
sub_8074B9C(battlerId, whichBar);
if (var == -1)
gBattleSpritesDataPtr->battleBars[bank].field_10 = 0;
gBattleSpritesDataPtr->battleBars[battlerId].field_10 = 0;
return var;
}
static void sub_8074B9C(u8 bank, u8 whichBar)
static void sub_8074B9C(u8 battlerId, u8 whichBar)
{
u8 array[8];
u8 subRet, level;
@ -2286,10 +2284,10 @@ static void sub_8074B9C(u8 bank, u8 whichBar)
switch (whichBar)
{
case HEALTH_BAR:
subRet = sub_8074E8C(gBattleSpritesDataPtr->battleBars[bank].maxValue,
gBattleSpritesDataPtr->battleBars[bank].currentValue,
gBattleSpritesDataPtr->battleBars[bank].receivedValue,
&gBattleSpritesDataPtr->battleBars[bank].field_10,
subRet = sub_8074E8C(gBattleSpritesDataPtr->battleBars[battlerId].maxValue,
gBattleSpritesDataPtr->battleBars[battlerId].currentValue,
gBattleSpritesDataPtr->battleBars[battlerId].receivedValue,
&gBattleSpritesDataPtr->battleBars[battlerId].field_10,
array, 6);
barElementId = 3;
if (subRet <= 0x18)
@ -2300,7 +2298,7 @@ static void sub_8074B9C(u8 bank, u8 whichBar)
}
for (i = 0; i < 6; i++)
{
u8 healthboxSpriteId_2 = gSprites[gBattleSpritesDataPtr->battleBars[bank].healthboxSpriteId].data[5];
u8 healthboxSpriteId_2 = gSprites[gBattleSpritesDataPtr->battleBars[battlerId].healthboxSpriteId].data[5];
if (i < 2)
CpuCopy32(GetHealthboxElementGfxPtr(barElementId) + array[i] * 32,
(void*)(OBJ_VRAM0 + (gSprites[healthboxSpriteId_2].oam.tileNum + 2 + i) * 32), 32);
@ -2310,12 +2308,12 @@ static void sub_8074B9C(u8 bank, u8 whichBar)
}
break;
case EXP_BAR:
sub_8074E8C(gBattleSpritesDataPtr->battleBars[bank].maxValue,
gBattleSpritesDataPtr->battleBars[bank].currentValue,
gBattleSpritesDataPtr->battleBars[bank].receivedValue,
&gBattleSpritesDataPtr->battleBars[bank].field_10,
sub_8074E8C(gBattleSpritesDataPtr->battleBars[battlerId].maxValue,
gBattleSpritesDataPtr->battleBars[battlerId].currentValue,
gBattleSpritesDataPtr->battleBars[battlerId].receivedValue,
&gBattleSpritesDataPtr->battleBars[battlerId].field_10,
array, 8);
level = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_LEVEL);
level = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_LEVEL);
if (level == MAX_MON_LEVEL)
{
for (i = 0; i < 8; i++)
@ -2325,10 +2323,10 @@ static void sub_8074B9C(u8 bank, u8 whichBar)
{
if (i < 4)
CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_12) + array[i] * 32,
(void*)(OBJ_VRAM0 + (gSprites[gBattleSpritesDataPtr->battleBars[bank].healthboxSpriteId].oam.tileNum + 0x24 + i) * 32), 32);
(void*)(OBJ_VRAM0 + (gSprites[gBattleSpritesDataPtr->battleBars[battlerId].healthboxSpriteId].oam.tileNum + 0x24 + i) * 32), 32);
else
CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_12) + array[i] * 32,
(void*)(OBJ_VRAM0 + 0xB80 + (i + gSprites[gBattleSpritesDataPtr->battleBars[bank].healthboxSpriteId].oam.tileNum) * 32), 32);
(void*)(OBJ_VRAM0 + 0xB80 + (i + gSprites[gBattleSpritesDataPtr->battleBars[battlerId].healthboxSpriteId].oam.tileNum) * 32), 32);
}
break;
}

View File

@ -4038,8 +4038,7 @@ u8 IsRunningFromBattleImpossible(void)
}
if (side != GetBattlerSide(i)
&& gBattleMons[gActiveBattler].ability != ABILITY_LEVITATE
&& gBattleMons[gActiveBattler].type1 != TYPE_FLYING
&& gBattleMons[gActiveBattler].type2 != TYPE_FLYING
&& !IS_BATTLER_OF_TYPE(gActiveBattler, TYPE_FLYING)
&& gBattleMons[i].ability == ABILITY_ARENA_TRAP)
{
gBattleScripting.battler = i;
@ -4049,7 +4048,7 @@ u8 IsRunningFromBattleImpossible(void)
}
}
i = AbilityBattleEffects(ABILITYEFFECT_CHECK_FIELD_EXCEPT_BANK, gActiveBattler, ABILITY_MAGNET_PULL, 0, 0);
if (i != 0 && (gBattleMons[gActiveBattler].type1 == TYPE_STEEL || gBattleMons[gActiveBattler].type2 == TYPE_STEEL))
if (i != 0 && IS_BATTLER_OF_TYPE(gActiveBattler, TYPE_STEEL))
{
gBattleScripting.battler = i - 1;
gLastUsedAbility = gBattleMons[i - 1].ability;
@ -4236,12 +4235,10 @@ static void HandleTurnActionSelectionState(void)
}
else if ((i = AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBattler, ABILITY_SHADOW_TAG, 0, 0))
|| ((i = AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBattler, ABILITY_ARENA_TRAP, 0, 0))
&& gBattleMons[gActiveBattler].type1 != TYPE_FLYING
&& gBattleMons[gActiveBattler].type2 != TYPE_FLYING
&& !IS_BATTLER_OF_TYPE(gActiveBattler, TYPE_FLYING)
&& gBattleMons[gActiveBattler].ability != ABILITY_LEVITATE)
|| ((i = AbilityBattleEffects(ABILITYEFFECT_CHECK_FIELD_EXCEPT_BANK, gActiveBattler, ABILITY_MAGNET_PULL, 0, 0))
&& (gBattleMons[gActiveBattler].type1 == TYPE_STEEL
|| gBattleMons[gActiveBattler].type2 == TYPE_STEEL)))
&& IS_BATTLER_OF_TYPE(gActiveBattler, TYPE_STEEL)))
{
BtlController_EmitChoosePokemon(0, ((i - 1) << 4) | 4, 6, gLastUsedAbility, gBattleStruct->field_60[gActiveBattler]);
}

View File

@ -1196,7 +1196,7 @@ const u8 gText_NewLine[] = _("\n");
const u8 gText_Are[] = _("are");
const u8 gText_Are2[] = _("are");
const u8 gText_BadEgg[] = _("Bad EGG");
const u8 gText_BattleWallyName[] = _("WALLY");
const u8 gText_BattleWallyName[] = _("WALLY");
const u8 gText_Win[] = _("{HIGHLIGHT TRANSPARENT}Win");
const u8 gText_Loss[] = _("{HIGHLIGHT TRANSPARENT}Loss");
const u8 gText_Draw[] = _("{HIGHLIGHT TRANSPARENT}Draw");
@ -1705,7 +1705,7 @@ u32 BattleStringExpandPlaceholdersToDisplayedString(const u8* src)
BattleStringExpandPlaceholders(src, gDisplayedStringBattle);
}
static const u8* TryGetStatusString(u8* src)
static const u8* TryGetStatusString(u8 *src)
{
u32 i;
u8 status[8];
@ -1736,8 +1736,8 @@ static const u8* TryGetStatusString(u8* src)
return NULL;
}
#define HANDLE_NICKNAME_STRING_CASE(bank, monIndex) \
if (GetBattlerSide(bank) != B_SIDE_PLAYER) \
#define HANDLE_NICKNAME_STRING_CASE(battlerId, monIndex) \
if (GetBattlerSide(battlerId) != B_SIDE_PLAYER) \
{ \
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) \
toCpy = sText_FoePkmnPrefix; \
@ -1758,10 +1758,10 @@ static const u8* TryGetStatusString(u8* src)
StringGetEnd10(text); \
toCpy = text;
u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst)
{
u32 dstID = 0; // if they used dstID, why not use srcID as well?
const u8* toCpy = NULL;
const u8 *toCpy = NULL;
u8 text[30];
u8 multiplayerID;
s32 i;
@ -1866,7 +1866,7 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
StringGetEnd10(text);
toCpy = text;
break;
case B_TXT_ATK_NAME_WITH_PREFIX_MON1: // attacker name with prefix, only bank 0/1
case B_TXT_ATK_NAME_WITH_PREFIX_MON1: // attacker name with prefix, only battlerId 0/1
HANDLE_NICKNAME_STRING_CASE(gBattlerAttacker,
gBattlerPartyIndexes[GetBattlerAtPosition(GET_BATTLER_SIDE(gBattlerAttacker))])
break;
@ -1885,13 +1885,13 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
case B_TXT_DEF_NAME_WITH_PREFIX: // target name with prefix
HANDLE_NICKNAME_STRING_CASE(gBattlerTarget, gBattlerPartyIndexes[gBattlerTarget])
break;
case B_TXT_EFF_NAME_WITH_PREFIX: // effect bank name with prefix
case B_TXT_EFF_NAME_WITH_PREFIX: // effect battlerId name with prefix
HANDLE_NICKNAME_STRING_CASE(gEffectBattler, gBattlerPartyIndexes[gEffectBattler])
break;
case B_TXT_ACTIVE_NAME_WITH_PREFIX: // active bank name with prefix
case B_TXT_ACTIVE_NAME_WITH_PREFIX: // active battlerId name with prefix
HANDLE_NICKNAME_STRING_CASE(gActiveBattler, gBattlerPartyIndexes[gActiveBattler])
break;
case B_TXT_SCR_ACTIVE_NAME_WITH_PREFIX: // scripting active bank name with prefix
case B_TXT_SCR_ACTIVE_NAME_WITH_PREFIX: // scripting active battlerId name with prefix
HANDLE_NICKNAME_STRING_CASE(gBattleScripting.battler, gBattlerPartyIndexes[gBattleScripting.battler])
break;
case B_TXT_CURRENT_MOVE: // current move name
@ -1961,7 +1961,7 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
case B_TXT_SCR_ACTIVE_ABILITY: // scripting active ability
toCpy = gAbilityNames[gBattlerAbilities[gBattleScripting.battler]];
break;
case B_TXT_EFF_ABILITY: // effect bank ability
case B_TXT_EFF_ABILITY: // effect battlerId ability
toCpy = gAbilityNames[gBattlerAbilities[gEffectBattler]];
break;
case B_TXT_TRAINER1_CLASS: // trainer class name

File diff suppressed because it is too large Load Diff

View File

@ -32,6 +32,7 @@
#include "overworld.h"
#include "field_weather.h"
#include "gym_leader_rematch.h"
#include "field_map_obj_helpers.h"
enum
{
@ -56,18 +57,12 @@ extern bool8 InBattlePyramid(void);
extern bool8 InBattlePike(void);
extern bool32 InTrainerHill(void);
extern bool32 FieldPoisonEffectIsRunning(void);
extern void overworld_free_bg_tilemaps(void);
extern void prev_quest_postbuffer_cursor_backup_reset(void);
extern void ResetPoisonStepCounter(void);
extern void sub_81BE72C(void);
extern void FreezeMapObjects(void);
extern void sub_808BCF4(void);
extern void sub_80EECC8(void);
extern void Overworld_ClearSavedMusic(void);
extern void CB2_WhiteOut(void);
extern void sub_80AF6F0(void);
extern void PlayBattleBGM(void);
extern u8 Overworld_GetFlashLevel(void);
extern u16 sub_81A9AA8(u8 localId);
extern u16 sub_81D6180(u8 localId);
extern bool8 GetBattlePyramidTrainerFlag(u8 mapObjId);

View File

@ -23,7 +23,6 @@
#include "link.h"
#include "berry.h"
extern u8 weather_get_current(void);
// rom const data
@ -1664,36 +1663,31 @@ u8 CastformDataTypeChange(u8 battler)
u8 formChange = 0;
if (gBattleMons[battler].species != SPECIES_CASTFORM || gBattleMons[battler].ability != ABILITY_FORECAST || gBattleMons[battler].hp == 0)
return CASTFORM_NO_CHANGE;
if (!WEATHER_HAS_EFFECT && gBattleMons[battler].type1 != TYPE_NORMAL && gBattleMons[battler].type2 != TYPE_NORMAL)
if (!WEATHER_HAS_EFFECT && !IS_BATTLER_OF_TYPE(battler, TYPE_NORMAL))
{
gBattleMons[battler].type1 = TYPE_NORMAL;
gBattleMons[battler].type2 = TYPE_NORMAL;
SET_BATTLER_TYPE(battler, TYPE_NORMAL);
return CASTFORM_TO_NORMAL;
}
if (!WEATHER_HAS_EFFECT)
return CASTFORM_NO_CHANGE;
if (!(gBattleWeather & (WEATHER_RAIN_ANY | WEATHER_SUN_ANY | WEATHER_HAIL)) && gBattleMons[battler].type1 != TYPE_NORMAL && gBattleMons[battler].type2 != TYPE_NORMAL)
if (!(gBattleWeather & (WEATHER_RAIN_ANY | WEATHER_SUN_ANY | WEATHER_HAIL_ANY)) && !IS_BATTLER_OF_TYPE(battler, TYPE_NORMAL))
{
gBattleMons[battler].type1 = TYPE_NORMAL;
gBattleMons[battler].type2 = TYPE_NORMAL;
SET_BATTLER_TYPE(battler, TYPE_NORMAL);
formChange = CASTFORM_TO_NORMAL;
}
if (gBattleWeather & WEATHER_SUN_ANY && gBattleMons[battler].type1 != TYPE_FIRE && gBattleMons[battler].type2 != TYPE_FIRE)
if (gBattleWeather & WEATHER_SUN_ANY && !IS_BATTLER_OF_TYPE(battler, TYPE_FIRE))
{
gBattleMons[battler].type1 = TYPE_FIRE;
gBattleMons[battler].type2 = TYPE_FIRE;
SET_BATTLER_TYPE(battler, TYPE_FIRE);
formChange = CASTFORM_TO_FIRE;
}
if (gBattleWeather & WEATHER_RAIN_ANY && gBattleMons[battler].type1 != TYPE_WATER && gBattleMons[battler].type2 != TYPE_WATER)
if (gBattleWeather & WEATHER_RAIN_ANY && !IS_BATTLER_OF_TYPE(battler, TYPE_WATER))
{
gBattleMons[battler].type1 = TYPE_WATER;
gBattleMons[battler].type2 = TYPE_WATER;
SET_BATTLER_TYPE(battler, TYPE_WATER);
formChange = CASTFORM_TO_WATER;
}
if (gBattleWeather & WEATHER_HAIL && gBattleMons[battler].type1 != TYPE_ICE && gBattleMons[battler].type2 != TYPE_ICE)
if (gBattleWeather & WEATHER_HAIL_ANY && !IS_BATTLER_OF_TYPE(battler, TYPE_ICE))
{
gBattleMons[battler].type1 = TYPE_ICE;
gBattleMons[battler].type2 = TYPE_ICE;
SET_BATTLER_TYPE(battler, TYPE_ICE);
formChange = CASTFORM_TO_ICE;
}
return formChange;
@ -2023,14 +2017,12 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& move != MOVE_STRUGGLE
&& gBattleMoves[move].power != 0
&& (gSpecialStatuses[gBattlerTarget].physicalDmg || gSpecialStatuses[gBattlerTarget].specialDmg)
&& gBattleMons[battler].type1 != moveType
&& gBattleMons[battler].type2 != moveType
&& TARGET_TURN_DAMAGED
&& !IS_BATTLER_OF_TYPE(battler, moveType)
&& gBattleMons[battler].hp != 0)
{
gBattleMons[battler].type1 = moveType;
gBattleMons[battler].type2 = moveType;
PREPARE_TYPE_BUFFER(gBattleTextBuff1, moveType)
SET_BATTLER_TYPE(battler, moveType);
PREPARE_TYPE_BUFFER(gBattleTextBuff1, moveType);
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_ColorChangeActivates;
effect++;
@ -2040,7 +2032,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& gBattleMons[gBattlerAttacker].hp != 0
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& (gSpecialStatuses[gBattlerTarget].physicalDmg || gSpecialStatuses[gBattlerTarget].specialDmg)
&& TARGET_TURN_DAMAGED
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT))
{
gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 16;
@ -2055,7 +2047,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& gBattleMons[gBattlerAttacker].hp != 0
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& (gSpecialStatuses[gBattlerTarget].physicalDmg || gSpecialStatuses[gBattlerTarget].specialDmg)
&& TARGET_TURN_DAMAGED
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)
&& (Random() % 10) == 0)
{
@ -2078,7 +2070,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& gBattleMons[gBattlerAttacker].hp != 0
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& (gSpecialStatuses[gBattlerTarget].physicalDmg || gSpecialStatuses[gBattlerTarget].specialDmg)
&& TARGET_TURN_DAMAGED
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)
&& (Random() % 3) == 0)
{
@ -2093,7 +2085,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& gBattleMons[gBattlerAttacker].hp != 0
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& (gSpecialStatuses[gBattlerTarget].physicalDmg || gSpecialStatuses[gBattlerTarget].specialDmg)
&& TARGET_TURN_DAMAGED
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)
&& (Random() % 3) == 0)
{
@ -2109,7 +2101,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
&& gBattleMons[gBattlerAttacker].hp != 0
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)
&& (gSpecialStatuses[gBattlerTarget].physicalDmg || gSpecialStatuses[gBattlerTarget].specialDmg)
&& TARGET_TURN_DAMAGED
&& (Random() % 3) == 0)
{
gBattleCommunication[MOVE_EFFECT_BYTE] = MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_BURN;
@ -2124,7 +2116,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
&& gBattleMons[gBattlerAttacker].hp != 0
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)
&& (gSpecialStatuses[gBattlerTarget].physicalDmg || gSpecialStatuses[gBattlerTarget].specialDmg)
&& TARGET_TURN_DAMAGED
&& gBattleMons[gBattlerTarget].hp != 0
&& (Random() % 3) == 0
&& gBattleMons[gBattlerAttacker].ability != ABILITY_OBLIVIOUS
@ -3134,7 +3126,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
{
case HOLD_EFFECT_FLINCH:
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& (gSpecialStatuses[gBattlerTarget].physicalDmg || gSpecialStatuses[gBattlerTarget].specialDmg)
&& TARGET_TURN_DAMAGED
&& (Random() % 100) < atkQuality
&& gBattleMoves[gCurrentMove].flags & FLAG_KINGSROCK_AFFECTED
&& gBattleMons[gBattlerTarget].hp)
@ -3186,14 +3178,14 @@ void HandleAction_RunBattleScript(void) // identical to RunBattleScriptCommands
gBattleScriptingCommandsTable[*gBattlescriptCurrInstr]();
}
u8 GetMoveTarget(u16 move, u8 useMoveTarget)
u8 GetMoveTarget(u16 move, u8 setTarget)
{
u8 targetBank = 0;
u8 moveTarget;
u8 side;
if (useMoveTarget)
moveTarget = useMoveTarget - 1;
if (setTarget)
moveTarget = setTarget - 1;
else
moveTarget = gBattleMoves[move].target;

View File

@ -76,26 +76,26 @@ void FreeBattleResources(void)
void AdjustFriendshipOnBattleFaint(u8 battlerId)
{
u8 opposingBank;
u8 opposingBattlerId;
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{
u8 opposingBank2;
u8 opposingBattlerId2;
opposingBank = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
opposingBank2 = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
opposingBattlerId = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
opposingBattlerId2 = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
if (gBattleMons[opposingBank2].level > gBattleMons[opposingBank].level)
opposingBank = opposingBank2;
if (gBattleMons[opposingBattlerId2].level > gBattleMons[opposingBattlerId].level)
opposingBattlerId = opposingBattlerId2;
}
else
{
opposingBank = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
opposingBattlerId = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
}
if (gBattleMons[opposingBank].level > gBattleMons[battlerId].level)
if (gBattleMons[opposingBattlerId].level > gBattleMons[battlerId].level)
{
if (gBattleMons[opposingBank].level - gBattleMons[battlerId].level > 29)
if (gBattleMons[opposingBattlerId].level - gBattleMons[battlerId].level > 29)
AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[battlerId]], 8);
else
AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[battlerId]], 6);

View File

@ -43,7 +43,7 @@ static void sub_80768F0(struct Sprite *sprite);
static void sub_80769A8(struct Sprite *sprite);
static void sub_80769CC(struct Sprite *sprite);
static void SpriteCB_HitAnimHealthoxEffect(struct Sprite *sprite);
static u16 GetBankPokeballItemId(u8 bank);
static u16 GetBattlerPokeballItemId(u8 battlerId);
// rom const data
@ -317,11 +317,11 @@ const struct SpriteTemplate gBallSpriteTemplates[POKEBALL_COUNT] =
},
};
#define tFrames data[0]
#define tPan data[1]
#define tThrowId data[2]
#define tBank data[3]
#define tOpponentBank data[4]
#define tFrames data[0]
#define tPan data[1]
#define tThrowId data[2]
#define tBattler data[3]
#define tOpponentBattler data[4]
u8 DoPokeballSendOutAnimation(s16 pan, u8 kindOfThrow)
{
@ -333,17 +333,17 @@ u8 DoPokeballSendOutAnimation(s16 pan, u8 kindOfThrow)
taskId = CreateTask(Task_DoPokeballSendOutAnim, 5);
gTasks[taskId].tPan = pan;
gTasks[taskId].tThrowId = kindOfThrow;
gTasks[taskId].tBank = gActiveBattler;
gTasks[taskId].tBattler = gActiveBattler;
return 0;
}
#define sBank data[6]
#define sBattler data[6]
static void Task_DoPokeballSendOutAnim(u8 taskId)
{
u16 throwCaseId;
u8 bank;
u8 battlerId;
u16 itemId, ballId;
u8 ballSpriteId;
bool8 notSendOut = FALSE;
@ -355,12 +355,12 @@ static void Task_DoPokeballSendOutAnim(u8 taskId)
}
throwCaseId = gTasks[taskId].tThrowId;
bank = gTasks[taskId].tBank;
battlerId = gTasks[taskId].tBattler;
if (GetBattlerSide(bank) != B_SIDE_PLAYER)
itemId = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_POKEBALL);
if (GetBattlerSide(battlerId) != B_SIDE_PLAYER)
itemId = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_POKEBALL);
else
itemId = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_POKEBALL);
itemId = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_POKEBALL);
ballId = ItemIdToBallId(itemId);
LoadBallGfx(ballId);
@ -372,15 +372,15 @@ static void Task_DoPokeballSendOutAnim(u8 taskId)
switch (throwCaseId)
{
case POKEBALL_PLAYER_SENDOUT:
gBattlerTarget = bank;
gBattlerTarget = battlerId;
gSprites[ballSpriteId].pos1.x = 24;
gSprites[ballSpriteId].pos1.y = 68;
gSprites[ballSpriteId].callback = SpriteCB_PlayerMonSendOut_1;
break;
case POKEBALL_OPPONENT_SENDOUT:
gSprites[ballSpriteId].pos1.x = GetBattlerSpriteCoord(bank, BANK_X_POS);
gSprites[ballSpriteId].pos1.y = GetBattlerSpriteCoord(bank, BANK_Y_POS) + 24;
gBattlerTarget = bank;
gSprites[ballSpriteId].pos1.x = GetBattlerSpriteCoord(battlerId, BANK_X_POS);
gSprites[ballSpriteId].pos1.y = GetBattlerSpriteCoord(battlerId, BANK_Y_POS) + 24;
gBattlerTarget = battlerId;
gSprites[ballSpriteId].data[0] = 0;
gSprites[ballSpriteId].callback = SpriteCB_OpponentMonSendOut;
break;
@ -390,7 +390,7 @@ static void Task_DoPokeballSendOutAnim(u8 taskId)
break;
}
gSprites[ballSpriteId].sBank = gBattlerTarget;
gSprites[ballSpriteId].sBattler = gBattlerTarget;
if (!notSendOut)
{
DestroyTask(taskId);
@ -404,7 +404,7 @@ static void Task_DoPokeballSendOutAnim(u8 taskId)
gSprites[ballSpriteId].data[5] = -40;
sub_80A68D4(&gSprites[ballSpriteId]);
gSprites[ballSpriteId].oam.affineParam = taskId;
gTasks[taskId].tOpponentBank = gBattlerTarget;
gTasks[taskId].tOpponentBattler = gBattlerTarget;
gTasks[taskId].func = TaskDummy;
PlaySE(SE_NAGERU);
}
@ -415,7 +415,7 @@ static void SpriteCB_TestBallThrow(struct Sprite *sprite)
{
u16 ballId;
u8 taskId = sprite->oam.affineParam;
u8 opponentBank = gTasks[taskId].tOpponentBank;
u8 opponentBattler = gTasks[taskId].tOpponentBattler;
u8 noOfShakes = gTasks[taskId].tThrowId;
StartSpriteAnim(sprite, 1);
@ -425,10 +425,10 @@ static void SpriteCB_TestBallThrow(struct Sprite *sprite)
sprite->pos2.x = 0;
sprite->pos2.y = 0;
sprite->data[5] = 0;
ballId = ItemIdToBallId(GetBankPokeballItemId(opponentBank));
ballId = ItemIdToBallId(GetBattlerPokeballItemId(opponentBattler));
LaunchBallStarsTask(sprite->pos1.x, sprite->pos1.y - 5, 1, 0x1C, ballId);
sprite->data[0] = LaunchBallFadeMonTask(FALSE, opponentBank, 14, ballId);
sprite->sBank = opponentBank;
sprite->data[0] = LaunchBallFadeMonTask(FALSE, opponentBattler, 14, ballId);
sprite->sBattler = opponentBattler;
sprite->data[7] = noOfShakes;
DestroyTask(taskId);
sprite->callback = sub_80756D4;
@ -438,8 +438,8 @@ static void SpriteCB_TestBallThrow(struct Sprite *sprite)
#undef tFrames
#undef tPan
#undef tThrowId
#undef tBank
#undef tOpponentBank
#undef tBattler
#undef tOpponentBattler
static void sub_80756D4(struct Sprite *sprite)
{
@ -452,9 +452,9 @@ static void sub_80756E0(struct Sprite *sprite)
{
sprite->data[5] = 0;
sprite->callback = sub_807574C;
StartSpriteAffineAnim(&gSprites[gBattlerSpriteIds[sprite->sBank]], 2);
AnimateSprite(&gSprites[gBattlerSpriteIds[sprite->sBank]]);
gSprites[gBattlerSpriteIds[sprite->sBank]].data[1] = 0;
StartSpriteAffineAnim(&gSprites[gBattlerSpriteIds[sprite->sBattler]], 2);
AnimateSprite(&gSprites[gBattlerSpriteIds[sprite->sBattler]]);
gSprites[gBattlerSpriteIds[sprite->sBattler]].data[1] = 0;
}
}
@ -463,17 +463,17 @@ static void sub_807574C(struct Sprite *sprite)
sprite->data[5]++;
if (sprite->data[5] == 11)
PlaySE(SE_SUIKOMU);
if (gSprites[gBattlerSpriteIds[sprite->sBank]].affineAnimEnded)
if (gSprites[gBattlerSpriteIds[sprite->sBattler]].affineAnimEnded)
{
StartSpriteAnim(sprite, 2);
gSprites[gBattlerSpriteIds[sprite->sBank]].invisible = TRUE;
gSprites[gBattlerSpriteIds[sprite->sBattler]].invisible = TRUE;
sprite->data[5] = 0;
sprite->callback = sub_80757E4;
}
else
{
gSprites[gBattlerSpriteIds[sprite->sBank]].data[1] += 0x60;
gSprites[gBattlerSpriteIds[sprite->sBank]].pos2.y = -gSprites[gBattlerSpriteIds[sprite->sBank]].data[1] >> 8;
gSprites[gBattlerSpriteIds[sprite->sBattler]].data[1] += 0x60;
gSprites[gBattlerSpriteIds[sprite->sBattler]].pos2.y = -gSprites[gBattlerSpriteIds[sprite->sBattler]].data[1] >> 8;
}
}
@ -641,7 +641,7 @@ static void sub_8075970(struct Sprite *sprite)
#define tCryTaskSpecies data[0]
#define tCryTaskPan data[1]
#define tCryTaskWantedCry data[2]
#define tCryTaskBank data[3]
#define tCryTaskBattler data[3]
#define tCryTaskMonSpriteId data[4]
#define tCryTaskMonPtr1 data[5]
#define tCryTaskMonPtr2 data[6]
@ -653,7 +653,7 @@ static void Task_PlayCryWhenReleasedFromBall(u8 taskId)
u8 wantedCry = gTasks[taskId].tCryTaskWantedCry;
s8 pan = gTasks[taskId].tCryTaskPan;
u16 species = gTasks[taskId].tCryTaskSpecies;
u8 bank = gTasks[taskId].tCryTaskBank;
u8 battlerId = gTasks[taskId].tCryTaskBattler;
u8 monSpriteId = gTasks[taskId].tCryTaskMonSpriteId;
struct Pokemon *mon = (void*)(u32)((gTasks[taskId].tCryTaskMonPtr1 << 0x10) | (u16)(gTasks[taskId].tCryTaskMonPtr2));
@ -669,7 +669,7 @@ static void Task_PlayCryWhenReleasedFromBall(u8 taskId)
PlayCry3(species, pan, 0);
else
PlayCry3(species, pan, 11);
gBattleSpritesDataPtr->healthBoxesData[bank].field_1_x40 = 0;
gBattleSpritesDataPtr->healthBoxesData[battlerId].field_1_x40 = 0;
DestroyTask(taskId);
break;
case 2:
@ -685,7 +685,7 @@ static void Task_PlayCryWhenReleasedFromBall(u8 taskId)
else
PlayCry4(species, pan, 12);
gBattleSpritesDataPtr->healthBoxesData[bank].field_1_x40 = 0;
gBattleSpritesDataPtr->healthBoxesData[battlerId].field_1_x40 = 0;
DestroyTask(taskId);
}
else
@ -724,7 +724,7 @@ static void Task_PlayCryWhenReleasedFromBall(u8 taskId)
else
PlayCry4(species, pan, 11);
gBattleSpritesDataPtr->healthBoxesData[bank].field_1_x40 = 0;
gBattleSpritesDataPtr->healthBoxesData[battlerId].field_1_x40 = 0;
DestroyTask(taskId);
break;
}
@ -732,13 +732,13 @@ static void Task_PlayCryWhenReleasedFromBall(u8 taskId)
static void SpriteCB_ReleaseMonFromBall(struct Sprite *sprite)
{
u8 bank = sprite->sBank;
u8 battlerId = sprite->sBattler;
u32 ballId;
StartSpriteAnim(sprite, 1);
ballId = ItemIdToBallId(GetBankPokeballItemId(bank));
ballId = ItemIdToBallId(GetBattlerPokeballItemId(battlerId));
LaunchBallStarsTask(sprite->pos1.x, sprite->pos1.y - 5, 1, 0x1C, ballId);
sprite->data[0] = LaunchBallFadeMonTask(1, sprite->sBank, 14, ballId);
sprite->data[0] = LaunchBallFadeMonTask(1, sprite->sBattler, 14, ballId);
sprite->callback = HandleBallAnimEnd;
if (gMain.inBattle)
@ -749,19 +749,19 @@ static void SpriteCB_ReleaseMonFromBall(struct Sprite *sprite)
u16 wantedCryCase;
u8 taskId;
if (GetBattlerSide(bank) != B_SIDE_PLAYER)
if (GetBattlerSide(battlerId) != B_SIDE_PLAYER)
{
mon = &gEnemyParty[gBattlerPartyIndexes[bank]];
mon = &gEnemyParty[gBattlerPartyIndexes[battlerId]];
pan = 25;
}
else
{
mon = &gPlayerParty[gBattlerPartyIndexes[bank]];
mon = &gPlayerParty[gBattlerPartyIndexes[battlerId]];
pan = -25;
}
species = GetMonData(mon, MON_DATA_SPECIES);
if ((bank == GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) || bank == GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT))
if ((battlerId == GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) || battlerId == GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT))
&& IsDoubleBattle() && gBattleSpritesDataPtr->animationData->field_9_x1)
{
if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK)
@ -777,39 +777,39 @@ static void SpriteCB_ReleaseMonFromBall(struct Sprite *sprite)
if (!IsDoubleBattle() || !gBattleSpritesDataPtr->animationData->field_9_x1)
wantedCryCase = 0;
else if (bank == GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) || bank == GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT))
else if (battlerId == GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) || battlerId == GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT))
wantedCryCase = 1;
else
wantedCryCase = 2;
gBattleSpritesDataPtr->healthBoxesData[bank].field_1_x40 = 1;
gBattleSpritesDataPtr->healthBoxesData[battlerId].field_1_x40 = 1;
taskId = CreateTask(Task_PlayCryWhenReleasedFromBall, 3);
gTasks[taskId].tCryTaskSpecies = species;
gTasks[taskId].tCryTaskPan = pan;
gTasks[taskId].tCryTaskWantedCry = wantedCryCase;
gTasks[taskId].tCryTaskBank = bank;
gTasks[taskId].tCryTaskMonSpriteId = gBattlerSpriteIds[sprite->sBank];
gTasks[taskId].tCryTaskBattler = battlerId;
gTasks[taskId].tCryTaskMonSpriteId = gBattlerSpriteIds[sprite->sBattler];
gTasks[taskId].tCryTaskMonPtr1 = (u32)(mon) >> 0x10;
gTasks[taskId].tCryTaskMonPtr2 = (u32)(mon);
gTasks[taskId].tCryTaskState = 0;
}
StartSpriteAffineAnim(&gSprites[gBattlerSpriteIds[sprite->sBank]], 1);
StartSpriteAffineAnim(&gSprites[gBattlerSpriteIds[sprite->sBattler]], 1);
if (GetBattlerSide(sprite->sBank) == B_SIDE_OPPONENT)
gSprites[gBattlerSpriteIds[sprite->sBank]].callback = sub_8039B58;
if (GetBattlerSide(sprite->sBattler) == B_SIDE_OPPONENT)
gSprites[gBattlerSpriteIds[sprite->sBattler]].callback = sub_8039B58;
else
gSprites[gBattlerSpriteIds[sprite->sBank]].callback = sub_8039E44;
gSprites[gBattlerSpriteIds[sprite->sBattler]].callback = sub_8039E44;
AnimateSprite(&gSprites[gBattlerSpriteIds[sprite->sBank]]);
gSprites[gBattlerSpriteIds[sprite->sBank]].data[1] = 0x1000;
AnimateSprite(&gSprites[gBattlerSpriteIds[sprite->sBattler]]);
gSprites[gBattlerSpriteIds[sprite->sBattler]].data[1] = 0x1000;
}
#undef tCryTaskSpecies
#undef tCryTaskPan
#undef tCryTaskWantedCry
#undef tCryTaskBank
#undef tCryTaskBattler
#undef tCryTaskMonSpriteId
#undef tCryTaskMonPtr1
#undef tCryTaskMonPtr2
@ -828,37 +828,37 @@ static void sub_8075FB4(struct Sprite *sprite)
static void HandleBallAnimEnd(struct Sprite *sprite)
{
bool8 affineAnimEnded = FALSE;
u8 bank = sprite->sBank;
u8 battlerId = sprite->sBattler;
gSprites[gBattlerSpriteIds[bank]].invisible = FALSE;
gSprites[gBattlerSpriteIds[battlerId]].invisible = FALSE;
if (sprite->animEnded)
sprite->invisible = TRUE;
if (gSprites[gBattlerSpriteIds[bank]].affineAnimEnded)
if (gSprites[gBattlerSpriteIds[battlerId]].affineAnimEnded)
{
StartSpriteAffineAnim(&gSprites[gBattlerSpriteIds[bank]], 0);
StartSpriteAffineAnim(&gSprites[gBattlerSpriteIds[battlerId]], 0);
affineAnimEnded = TRUE;
}
else
{
gSprites[gBattlerSpriteIds[bank]].data[1] -= 288;
gSprites[gBattlerSpriteIds[bank]].pos2.y = gSprites[gBattlerSpriteIds[bank]].data[1] >> 8;
gSprites[gBattlerSpriteIds[battlerId]].data[1] -= 288;
gSprites[gBattlerSpriteIds[battlerId]].pos2.y = gSprites[gBattlerSpriteIds[battlerId]].data[1] >> 8;
}
if (sprite->animEnded && affineAnimEnded)
{
s32 i, doneBanks;
s32 i, doneBattlers;
gSprites[gBattlerSpriteIds[bank]].pos2.y = 0;
gSprites[gBattlerSpriteIds[battlerId]].pos2.y = 0;
gDoingBattleAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[bank].ballAnimActive = 0;
gBattleSpritesDataPtr->healthBoxesData[battlerId].ballAnimActive = 0;
FreeSpriteOamMatrix(sprite);
DestroySprite(sprite);
for (doneBanks = 0, i = 0; i < MAX_BATTLERS_COUNT; i++)
for (doneBattlers = 0, i = 0; i < MAX_BATTLERS_COUNT; i++)
{
if (gBattleSpritesDataPtr->healthBoxesData[i].ballAnimActive == 0)
doneBanks++;
doneBattlers++;
}
if (doneBanks == MAX_BATTLERS_COUNT)
if (doneBattlers == MAX_BATTLERS_COUNT)
{
for (i = 0; i < POKEBALL_COUNT; i++)
FreeBallGfx(i);
@ -868,7 +868,7 @@ static void HandleBallAnimEnd(struct Sprite *sprite)
static void sub_80760F8(struct Sprite *sprite)
{
u8 bank = sprite->sBank;
u8 battlerId = sprite->sBattler;
sprite->data[4]++;
if (sprite->data[4] == 40)
@ -883,21 +883,21 @@ static void sub_80760F8(struct Sprite *sprite)
}
else if (sprite->data[4] == 315)
{
FreeOamMatrix(gSprites[gBattlerSpriteIds[sprite->sBank]].oam.matrixNum);
DestroySprite(&gSprites[gBattlerSpriteIds[sprite->sBank]]);
FreeOamMatrix(gSprites[gBattlerSpriteIds[sprite->sBattler]].oam.matrixNum);
DestroySprite(&gSprites[gBattlerSpriteIds[sprite->sBattler]]);
DestroySpriteAndFreeResources(sprite);
if (gMain.inBattle)
gBattleSpritesDataPtr->healthBoxesData[bank].ballAnimActive = 0;
gBattleSpritesDataPtr->healthBoxesData[battlerId].ballAnimActive = 0;
}
}
static void SpriteCB_PlayerMonSendOut_1(struct Sprite *sprite)
{
sprite->data[0] = 25;
sprite->data[2] = GetBattlerSpriteCoord(sprite->sBank, 2);
sprite->data[4] = GetBattlerSpriteCoord(sprite->sBank, 3) + 24;
sprite->data[2] = GetBattlerSpriteCoord(sprite->sBattler, 2);
sprite->data[4] = GetBattlerSpriteCoord(sprite->sBattler, 3) + 24;
sprite->data[5] = -30;
sprite->oam.affineParam = sprite->sBank;
sprite->oam.affineParam = sprite->sBattler;
sub_80A68D4(sprite);
sprite->callback = SpriteCB_PlayerMonSendOut_2;
}
@ -923,7 +923,7 @@ static void SpriteCB_PlayerMonSendOut_2(struct Sprite *sprite)
}
r4 = sprite->data[0];
sub_80A6F3C(sprite);
sprite->data[7] += sprite->sBank / 3;
sprite->data[7] += sprite->sBattler / 3;
sprite->pos2.y += Sin(HIBYTE(sprite->data[7]), sprite->data[5]);
sprite->oam.affineParam += 0x100;
if ((sprite->oam.affineParam >> 8) % 3 != 0)
@ -946,11 +946,11 @@ static void SpriteCB_PlayerMonSendOut_2(struct Sprite *sprite)
sprite->pos1.y += sprite->pos2.y;
sprite->pos2.y = 0;
sprite->pos2.x = 0;
sprite->sBank = sprite->oam.affineParam & 0xFF;
sprite->sBattler = sprite->oam.affineParam & 0xFF;
sprite->data[0] = 0;
if (IsDoubleBattle() && gBattleSpritesDataPtr->animationData->field_9_x1
&& sprite->sBank == GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT))
&& sprite->sBattler == GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT))
sprite->callback = SpriteCB_ReleaseMon2FromBall;
else
sprite->callback = SpriteCB_ReleaseMonFromBall;
@ -976,26 +976,26 @@ static void SpriteCB_OpponentMonSendOut(struct Sprite *sprite)
{
sprite->data[0] = 0;
if (IsDoubleBattle() && gBattleSpritesDataPtr->animationData->field_9_x1
&& sprite->sBank == GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT))
&& sprite->sBattler == GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT))
sprite->callback = SpriteCB_ReleaseMon2FromBall;
else
sprite->callback = SpriteCB_ReleaseMonFromBall;
}
}
#undef sBank
#undef sBattler
static u8 LaunchBallStarsTaskForPokeball(u8 x, u8 y, u8 kindOfStars, u8 d)
{
return LaunchBallStarsTask(x, y, kindOfStars, d, BALL_POKE);
}
static u8 LaunchBallFadeMonTaskForPokeball(bool8 unFadeLater, u8 bank, u32 arg2)
static u8 LaunchBallFadeMonTaskForPokeball(bool8 unFadeLater, u8 battlerId, u32 arg2)
{
return LaunchBallFadeMonTask(unFadeLater, bank, arg2, BALL_POKE);
return LaunchBallFadeMonTask(unFadeLater, battlerId, arg2, BALL_POKE);
}
void CreatePokeballSpriteToReleaseMon(u8 monSpriteId, u8 bank, u8 x, u8 y, u8 oamPriority, u8 subpriortiy, u8 g, u32 h, u16 species)
void CreatePokeballSpriteToReleaseMon(u8 monSpriteId, u8 battlerId, u8 x, u8 y, u8 oamPriority, u8 subpriortiy, u8 g, u32 h, u16 species)
{
u8 spriteId;
@ -1012,7 +1012,7 @@ void CreatePokeballSpriteToReleaseMon(u8 monSpriteId, u8 bank, u8 x, u8 y, u8 oa
gSprites[monSpriteId].data[7] = species;
gSprites[spriteId].data[1] = g;
gSprites[spriteId].data[2] = bank;
gSprites[spriteId].data[2] = battlerId;
gSprites[spriteId].data[3] = h;
gSprites[spriteId].data[4] = h >> 0x10;
gSprites[spriteId].oam.priority = oamPriority;
@ -1027,7 +1027,7 @@ static void sub_8076524(struct Sprite *sprite)
{
u8 r5;
u8 r7 = sprite->data[0];
u8 bank = sprite->data[2];
u8 battlerId = sprite->data[2];
u32 r4 = (u16)sprite->data[3] | ((u16)sprite->data[4] << 16);
if (sprite->subpriority != 0)
@ -1037,7 +1037,7 @@ static void sub_8076524(struct Sprite *sprite)
StartSpriteAnim(sprite, 1);
LaunchBallStarsTaskForPokeball(sprite->pos1.x, sprite->pos1.y - 5, sprite->oam.priority, r5);
sprite->data[1] = LaunchBallFadeMonTaskForPokeball(1, bank, r4);
sprite->data[1] = LaunchBallFadeMonTaskForPokeball(1, battlerId, r4);
sprite->callback = sub_80765E0;
gSprites[r7].invisible = FALSE;
StartSpriteAffineAnim(&gSprites[r7], 1);
@ -1175,16 +1175,16 @@ static void DestroySpriteAndFreeResources_(struct Sprite *sprite)
DestroySpriteAndFreeResources(sprite);
}
void sub_8076918(u8 bank)
void sub_8076918(u8 battlerId)
{
struct Sprite *healthboxSprite = &gSprites[gHealthboxSpriteIds[bank]];
struct Sprite *healthboxSprite = &gSprites[gHealthboxSpriteIds[battlerId]];
healthboxSprite->data[0] = 5;
healthboxSprite->data[1] = 0;
healthboxSprite->pos2.x = 0x73;
healthboxSprite->pos2.y = 0;
healthboxSprite->callback = sub_80769CC;
if (GetBattlerSide(bank) != B_SIDE_PLAYER)
if (GetBattlerSide(battlerId) != B_SIDE_PLAYER)
{
healthboxSprite->data[0] = -healthboxSprite->data[0];
healthboxSprite->data[1] = -healthboxSprite->data[1];
@ -1192,7 +1192,7 @@ void sub_8076918(u8 bank)
healthboxSprite->pos2.y = -healthboxSprite->pos2.y;
}
gSprites[healthboxSprite->data[5]].callback(&gSprites[healthboxSprite->data[5]]);
if (GetBattlerPosition(bank) == B_POSITION_PLAYER_RIGHT)
if (GetBattlerPosition(battlerId) == B_POSITION_PLAYER_RIGHT)
healthboxSprite->callback = sub_80769A8;
}
@ -1214,13 +1214,13 @@ static void sub_80769CC(struct Sprite *sprite)
sprite->callback = SpriteCallbackDummy;
}
void DoHitAnimHealthboxEffect(u8 bank)
void DoHitAnimHealthboxEffect(u8 battlerId)
{
u8 spriteId;
spriteId = CreateInvisibleSpriteWithCallback(SpriteCB_HitAnimHealthoxEffect);
gSprites[spriteId].data[0] = 1;
gSprites[spriteId].data[1] = gHealthboxSpriteIds[bank];
gSprites[spriteId].data[1] = gHealthboxSpriteIds[battlerId];
gSprites[spriteId].callback = SpriteCB_HitAnimHealthoxEffect;
}
@ -1267,10 +1267,10 @@ void FreeBallGfx(u8 ballId)
FreeSpritePaletteByTag(gBallSpritePalettes[ballId].tag);
}
static u16 GetBankPokeballItemId(u8 bank)
static u16 GetBattlerPokeballItemId(u8 battlerId)
{
if (GetBattlerSide(bank) == B_SIDE_PLAYER)
return GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_POKEBALL);
if (GetBattlerSide(battlerId) == B_SIDE_PLAYER)
return GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_POKEBALL);
else
return GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_POKEBALL);
return GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_POKEBALL);
}