mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-02-24 21:25:30 +01:00
Merge pull request #798 from GriffinRichards/constants-baction
Use misc battle constants
This commit is contained in:
commit
1e1a4076f0
@ -1841,7 +1841,7 @@ void LaunchBattleAnimation(const u8 *const animsTable[], u16 tableId, bool8 isMo
|
|||||||
UpdateOamPriorityInAllHealthboxes(0);
|
UpdateOamPriorityInAllHealthboxes(0);
|
||||||
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
|
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
|
||||||
{
|
{
|
||||||
if (GetBattlerSide(i) != 0)
|
if (GetBattlerSide(i) != B_SIDE_PLAYER)
|
||||||
gAnimBattlerSpecies[i] = GetMonData(&gEnemyParty[gBattlerPartyIndexes[i]], MON_DATA_SPECIES);
|
gAnimBattlerSpecies[i] = GetMonData(&gEnemyParty[gBattlerPartyIndexes[i]], MON_DATA_SPECIES);
|
||||||
else
|
else
|
||||||
gAnimBattlerSpecies[i] = GetMonData(&gPlayerParty[gBattlerPartyIndexes[i]], MON_DATA_SPECIES);
|
gAnimBattlerSpecies[i] = GetMonData(&gPlayerParty[gBattlerPartyIndexes[i]], MON_DATA_SPECIES);
|
||||||
|
@ -3560,7 +3560,7 @@ void sub_8100640(struct Sprite* sprite)
|
|||||||
else
|
else
|
||||||
battler = gBattleAnimTarget;
|
battler = gBattleAnimTarget;
|
||||||
|
|
||||||
if (GetBattlerSide(battler) != 0)
|
if (GetBattlerSide(battler) != B_SIDE_PLAYER)
|
||||||
{
|
{
|
||||||
sprite->data[4] = 0;
|
sprite->data[4] = 0;
|
||||||
sprite->data[2] = gBattleAnimArgs[3];
|
sprite->data[2] = gBattleAnimArgs[3];
|
||||||
@ -3731,7 +3731,7 @@ static void sub_81009DC(struct Sprite* sprite)
|
|||||||
|
|
||||||
void sub_81009F8(struct Sprite* sprite)
|
void sub_81009F8(struct Sprite* sprite)
|
||||||
{
|
{
|
||||||
if (GetBattlerSide(gBattleAnimAttacker) != 0)
|
if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER)
|
||||||
{
|
{
|
||||||
sprite->pos1.x -= gBattleAnimArgs[0];
|
sprite->pos1.x -= gBattleAnimArgs[0];
|
||||||
sprite->pos1.y += gBattleAnimArgs[1];
|
sprite->pos1.y += gBattleAnimArgs[1];
|
||||||
@ -3828,7 +3828,7 @@ void sub_8100B88(struct Sprite* sprite)
|
|||||||
|
|
||||||
sprite->pos1.x = a;
|
sprite->pos1.x = a;
|
||||||
sprite->pos1.y = b;
|
sprite->pos1.y = b;
|
||||||
if (GetBattlerSide(gBattleAnimTarget) == 0)
|
if (GetBattlerSide(gBattleAnimTarget) == B_SIDE_PLAYER)
|
||||||
sprite->pos1.y += 8;
|
sprite->pos1.y += 8;
|
||||||
|
|
||||||
sprite->callback = AnimSliceStep;
|
sprite->callback = AnimSliceStep;
|
||||||
|
@ -1479,7 +1479,7 @@ void AnimSonicBoomProjectile(struct Sprite *sprite)
|
|||||||
{
|
{
|
||||||
gBattleAnimArgs[2] = -gBattleAnimArgs[2];
|
gBattleAnimArgs[2] = -gBattleAnimArgs[2];
|
||||||
}
|
}
|
||||||
else if (GetBattlerSide(gBattleAnimAttacker) != 0)
|
else if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER)
|
||||||
{
|
{
|
||||||
gBattleAnimArgs[2] = -gBattleAnimArgs[2];
|
gBattleAnimArgs[2] = -gBattleAnimArgs[2];
|
||||||
gBattleAnimArgs[1] = -gBattleAnimArgs[1];
|
gBattleAnimArgs[1] = -gBattleAnimArgs[1];
|
||||||
@ -1646,7 +1646,7 @@ void sub_8103CF0(u8 taskId)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((gBattlerPositions[gBattleAnimTarget] & 1) == 0)
|
if ((gBattlerPositions[gBattleAnimTarget] & BIT_SIDE) == B_SIDE_PLAYER)
|
||||||
{
|
{
|
||||||
gTasks[taskId].data[4] = 1;
|
gTasks[taskId].data[4] = 1;
|
||||||
gBattleAnimArgs[0] = -gBattleAnimArgs[0];
|
gBattleAnimArgs[0] = -gBattleAnimArgs[0];
|
||||||
|
@ -234,16 +234,16 @@ static void InitSinglePlayerBtlControllers(void)
|
|||||||
gBattleMainFunc = BeginBattleIntro;
|
gBattleMainFunc = BeginBattleIntro;
|
||||||
|
|
||||||
gBattlerControllerFuncs[0] = SetControllerToRecordedPlayer;
|
gBattlerControllerFuncs[0] = SetControllerToRecordedPlayer;
|
||||||
gBattlerPositions[0] = 0;
|
gBattlerPositions[0] = B_POSITION_PLAYER_LEFT;
|
||||||
|
|
||||||
gBattlerControllerFuncs[1] = SetControllerToOpponent;
|
gBattlerControllerFuncs[1] = SetControllerToOpponent;
|
||||||
gBattlerPositions[1] = 1;
|
gBattlerPositions[1] = B_POSITION_OPPONENT_LEFT;
|
||||||
|
|
||||||
gBattlerControllerFuncs[2] = SetControllerToRecordedPlayer;
|
gBattlerControllerFuncs[2] = SetControllerToRecordedPlayer;
|
||||||
gBattlerPositions[2] = 2;
|
gBattlerPositions[2] = B_POSITION_PLAYER_RIGHT;
|
||||||
|
|
||||||
gBattlerControllerFuncs[3] = SetControllerToOpponent;
|
gBattlerControllerFuncs[3] = SetControllerToOpponent;
|
||||||
gBattlerPositions[3] = 3;
|
gBattlerPositions[3] = B_POSITION_OPPONENT_RIGHT;
|
||||||
|
|
||||||
gBattlersCount = MAX_BATTLERS_COUNT;
|
gBattlersCount = MAX_BATTLERS_COUNT;
|
||||||
|
|
||||||
@ -524,12 +524,12 @@ static void InitLinkBtlControllers(void)
|
|||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
case 3:
|
case 3:
|
||||||
gBattlerPositions[gLinkPlayers[i].id] = 0;
|
gBattlerPositions[gLinkPlayers[i].id] = B_POSITION_PLAYER_LEFT;
|
||||||
gBattlerPartyIndexes[gLinkPlayers[i].id] = 0;
|
gBattlerPartyIndexes[gLinkPlayers[i].id] = 0;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
gBattlerPositions[gLinkPlayers[i].id] = 2;
|
gBattlerPositions[gLinkPlayers[i].id] = B_POSITION_PLAYER_RIGHT;
|
||||||
gBattlerPartyIndexes[gLinkPlayers[i].id] = 3;
|
gBattlerPartyIndexes[gLinkPlayers[i].id] = 3;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -544,12 +544,12 @@ static void InitLinkBtlControllers(void)
|
|||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
case 3:
|
case 3:
|
||||||
gBattlerPositions[gLinkPlayers[i].id] = 0;
|
gBattlerPositions[gLinkPlayers[i].id] = B_POSITION_PLAYER_LEFT;
|
||||||
gBattlerPartyIndexes[gLinkPlayers[i].id] = 0;
|
gBattlerPartyIndexes[gLinkPlayers[i].id] = 0;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
gBattlerPositions[gLinkPlayers[i].id] = 2;
|
gBattlerPositions[gLinkPlayers[i].id] = B_POSITION_PLAYER_RIGHT;
|
||||||
gBattlerPartyIndexes[gLinkPlayers[i].id] = 3;
|
gBattlerPartyIndexes[gLinkPlayers[i].id] = 3;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -561,12 +561,12 @@ static void InitLinkBtlControllers(void)
|
|||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
case 3:
|
case 3:
|
||||||
gBattlerPositions[gLinkPlayers[i].id] = 1;
|
gBattlerPositions[gLinkPlayers[i].id] = B_POSITION_OPPONENT_LEFT;
|
||||||
gBattlerPartyIndexes[gLinkPlayers[i].id] = 0;
|
gBattlerPartyIndexes[gLinkPlayers[i].id] = 0;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
gBattlerPositions[gLinkPlayers[i].id] = 3;
|
gBattlerPositions[gLinkPlayers[i].id] = B_POSITION_OPPONENT_RIGHT;
|
||||||
gBattlerPartyIndexes[gLinkPlayers[i].id] = 3;
|
gBattlerPartyIndexes[gLinkPlayers[i].id] = 3;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -779,7 +779,7 @@ bool8 BattleInitAllSprites(u8 *state1, u8 *battlerId)
|
|||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
InitBattlerHealthboxCoords(*battlerId);
|
InitBattlerHealthboxCoords(*battlerId);
|
||||||
if (gBattlerPositions[*battlerId] <= 1)
|
if (gBattlerPositions[*battlerId] <= B_POSITION_OPPONENT_LEFT)
|
||||||
DummyBattleInterfaceFunc(gHealthboxSpriteIds[*battlerId], FALSE);
|
DummyBattleInterfaceFunc(gHealthboxSpriteIds[*battlerId], FALSE);
|
||||||
else
|
else
|
||||||
DummyBattleInterfaceFunc(gHealthboxSpriteIds[*battlerId], TRUE);
|
DummyBattleInterfaceFunc(gHealthboxSpriteIds[*battlerId], TRUE);
|
||||||
|
@ -4025,7 +4025,7 @@ void BattleTurnPassed(void)
|
|||||||
|
|
||||||
if (gBattleOutcome != 0)
|
if (gBattleOutcome != 0)
|
||||||
{
|
{
|
||||||
gCurrentActionFuncId = 12;
|
gCurrentActionFuncId = B_ACTION_FINISHED;
|
||||||
gBattleMainFunc = RunTurnActionsFunctions;
|
gBattleMainFunc = RunTurnActionsFunctions;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -4979,7 +4979,7 @@ static void CheckFocusPunch_ClearVarsBeforeTurnStarts(void)
|
|||||||
static void RunTurnActionsFunctions(void)
|
static void RunTurnActionsFunctions(void)
|
||||||
{
|
{
|
||||||
if (gBattleOutcome != 0)
|
if (gBattleOutcome != 0)
|
||||||
gCurrentActionFuncId = 12;
|
gCurrentActionFuncId = B_ACTION_FINISHED;
|
||||||
|
|
||||||
*(&gBattleStruct->savedTurnActionNumber) = gCurrentTurnActionNumber;
|
*(&gBattleStruct->savedTurnActionNumber) = gCurrentTurnActionNumber;
|
||||||
sTurnActionsFuncsTable[gCurrentActionFuncId]();
|
sTurnActionsFuncsTable[gCurrentActionFuncId]();
|
||||||
@ -5139,7 +5139,7 @@ static void HandleEndTurn_MonFled(void)
|
|||||||
|
|
||||||
static void HandleEndTurn_FinishBattle(void)
|
static void HandleEndTurn_FinishBattle(void)
|
||||||
{
|
{
|
||||||
if (gCurrentActionFuncId == 0xB || gCurrentActionFuncId == 0xC)
|
if (gCurrentActionFuncId == B_ACTION_TRY_FINISH || gCurrentActionFuncId == B_ACTION_FINISHED)
|
||||||
{
|
{
|
||||||
if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK
|
if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK
|
||||||
| BATTLE_TYPE_x2000000
|
| BATTLE_TYPE_x2000000
|
||||||
@ -5284,7 +5284,7 @@ static void ReturnFromBattleToOverworld(void)
|
|||||||
|
|
||||||
void RunBattleScriptCommands_PopCallbacksStack(void)
|
void RunBattleScriptCommands_PopCallbacksStack(void)
|
||||||
{
|
{
|
||||||
if (gCurrentActionFuncId == 0xB || gCurrentActionFuncId == 0xC)
|
if (gCurrentActionFuncId == B_ACTION_TRY_FINISH || gCurrentActionFuncId == B_ACTION_FINISHED)
|
||||||
{
|
{
|
||||||
if (gBattleResources->battleCallbackStack->size != 0)
|
if (gBattleResources->battleCallbackStack->size != 0)
|
||||||
gBattleResources->battleCallbackStack->size--;
|
gBattleResources->battleCallbackStack->size--;
|
||||||
@ -5592,7 +5592,7 @@ static void HandleAction_UseItem(void)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_ATK)
|
PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_ATK)
|
||||||
PREPARE_STRING_BUFFER(gBattleTextBuff2, 0xD2)
|
PREPARE_STRING_BUFFER(gBattleTextBuff2, CHAR_X)
|
||||||
|
|
||||||
while (!((*(gBattleStruct->AI_itemFlags + (gBattlerAttacker >> 1))) & 1))
|
while (!((*(gBattleStruct->AI_itemFlags + (gBattlerAttacker >> 1))) & 1))
|
||||||
{
|
{
|
||||||
|
@ -1217,10 +1217,10 @@ static bool8 SetupContestGraphics(u8 *stateVar)
|
|||||||
CreateApplauseMeterSprite();
|
CreateApplauseMeterSprite();
|
||||||
sub_80DC5E8();
|
sub_80DC5E8();
|
||||||
sub_80DC7EC();
|
sub_80DC7EC();
|
||||||
gBattlerPositions[0] = 0;
|
gBattlerPositions[0] = B_POSITION_PLAYER_LEFT;
|
||||||
gBattlerPositions[1] = 1;
|
gBattlerPositions[1] = B_POSITION_OPPONENT_LEFT;
|
||||||
gBattlerPositions[2] = 3;
|
gBattlerPositions[2] = B_POSITION_OPPONENT_RIGHT;
|
||||||
gBattlerPositions[3] = 2;
|
gBattlerPositions[3] = B_POSITION_PLAYER_RIGHT;
|
||||||
gBattleTypeFlags = 0;
|
gBattleTypeFlags = 0;
|
||||||
gBattlerAttacker = 2;
|
gBattlerAttacker = 2;
|
||||||
gBattlerTarget = 3;
|
gBattlerTarget = 3;
|
||||||
|
@ -949,7 +949,7 @@ static u16 sub_8109930(u8 spriteId)
|
|||||||
{
|
{
|
||||||
u16 var1 = gSprites[spriteId].pos1.y + gSprites[spriteId].pos2.y + gSprites[spriteId].centerToCornerVecY;
|
u16 var1 = gSprites[spriteId].pos1.y + gSprites[spriteId].pos2.y + gSprites[spriteId].centerToCornerVecY;
|
||||||
|
|
||||||
if (GetBattlerSide(gBattleAnimAttacker) == 0)
|
if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_PLAYER)
|
||||||
{
|
{
|
||||||
var1 = ((var1 << 16) + 0x4A0000) >> 16;
|
var1 = ((var1 << 16) + 0x4A0000) >> 16;
|
||||||
}
|
}
|
||||||
@ -1059,7 +1059,7 @@ static void sub_8109AFC(struct Sprite *sprite)
|
|||||||
StartSpriteAnim(sprite, gBattleAnimArgs[2]);
|
StartSpriteAnim(sprite, gBattleAnimArgs[2]);
|
||||||
sprite->data[7] = gBattleAnimArgs[2];
|
sprite->data[7] = gBattleAnimArgs[2];
|
||||||
|
|
||||||
if (GetBattlerSide(gBattleAnimAttacker) != 0)
|
if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER)
|
||||||
{
|
{
|
||||||
sprite->data[4] = 4;
|
sprite->data[4] = 4;
|
||||||
}
|
}
|
||||||
@ -1073,7 +1073,7 @@ static void sub_8109AFC(struct Sprite *sprite)
|
|||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
sprite->data[1] += 192;
|
sprite->data[1] += 192;
|
||||||
if (GetBattlerSide(gBattleAnimAttacker) != 0)
|
if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER)
|
||||||
{
|
{
|
||||||
sprite->pos2.y = -(sprite->data[1] >> 8);
|
sprite->pos2.y = -(sprite->data[1] >> 8);
|
||||||
}
|
}
|
||||||
|
@ -735,7 +735,7 @@ void AnimSwirlingSnowball_Step2(struct Sprite *sprite)
|
|||||||
void AnimSwirlingSnowball_Step3(struct Sprite *sprite)
|
void AnimSwirlingSnowball_Step3(struct Sprite *sprite)
|
||||||
{
|
{
|
||||||
s16 tempVar;
|
s16 tempVar;
|
||||||
tempVar = GetBattlerSide(gBattleAnimAttacker) != 0 ? 20 : -20;
|
tempVar = GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER ? 20 : -20;
|
||||||
|
|
||||||
if (sprite->data[5] <= 31)
|
if (sprite->data[5] <= 31)
|
||||||
{
|
{
|
||||||
@ -1190,12 +1190,12 @@ void InitPoisonGasCloudAnim(struct Sprite *sprite)
|
|||||||
if (GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X_2) < GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2))
|
if (GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X_2) < GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2))
|
||||||
sprite->data[7] = 0x8000;
|
sprite->data[7] = 0x8000;
|
||||||
|
|
||||||
if (!(gBattlerPositions[gBattleAnimTarget] & 1))
|
if ((gBattlerPositions[gBattleAnimTarget] & BIT_SIDE) == B_SIDE_PLAYER)
|
||||||
{
|
{
|
||||||
gBattleAnimArgs[1] = -gBattleAnimArgs[1];
|
gBattleAnimArgs[1] = -gBattleAnimArgs[1];
|
||||||
gBattleAnimArgs[3] = -gBattleAnimArgs[3];
|
gBattleAnimArgs[3] = -gBattleAnimArgs[3];
|
||||||
|
|
||||||
if ((sprite->data[7] & 0x8000) && !(gBattlerPositions[gBattleAnimAttacker] & 1))
|
if ((sprite->data[7] & 0x8000) && (gBattlerPositions[gBattleAnimAttacker] & BIT_SIDE) == B_SIDE_PLAYER)
|
||||||
sprite->subpriority = gSprites[GetAnimBattlerSpriteId(ANIM_TARGET)].subpriority + 1;
|
sprite->subpriority = gSprites[GetAnimBattlerSpriteId(ANIM_TARGET)].subpriority + 1;
|
||||||
|
|
||||||
sprite->data[6] = 1;
|
sprite->data[6] = 1;
|
||||||
|
@ -3197,13 +3197,13 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de
|
|||||||
|
|
||||||
if ((sideStatus & SIDE_STATUS_REFLECT) && gCritMultiplier == 1)
|
if ((sideStatus & SIDE_STATUS_REFLECT) && gCritMultiplier == 1)
|
||||||
{
|
{
|
||||||
if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && CountAliveMonsInBattle(2) == 2)
|
if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && CountAliveMonsInBattle(BATTLE_ALIVE_DEF_SIDE) == 2)
|
||||||
damage = 2 * (damage / 3);
|
damage = 2 * (damage / 3);
|
||||||
else
|
else
|
||||||
damage /= 2;
|
damage /= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && gBattleMoves[move].target == 8 && CountAliveMonsInBattle(2) == 2)
|
if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && gBattleMoves[move].target == 8 && CountAliveMonsInBattle(BATTLE_ALIVE_DEF_SIDE) == 2)
|
||||||
damage /= 2;
|
damage /= 2;
|
||||||
|
|
||||||
// moves always do at least 1 damage.
|
// moves always do at least 1 damage.
|
||||||
@ -3244,13 +3244,13 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de
|
|||||||
|
|
||||||
if ((sideStatus & SIDE_STATUS_LIGHTSCREEN) && gCritMultiplier == 1)
|
if ((sideStatus & SIDE_STATUS_LIGHTSCREEN) && gCritMultiplier == 1)
|
||||||
{
|
{
|
||||||
if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && CountAliveMonsInBattle(2) == 2)
|
if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && CountAliveMonsInBattle(BATTLE_ALIVE_DEF_SIDE) == 2)
|
||||||
damage = 2 * (damage / 3);
|
damage = 2 * (damage / 3);
|
||||||
else
|
else
|
||||||
damage /= 2;
|
damage /= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && gBattleMoves[move].target == 8 && CountAliveMonsInBattle(2) == 2)
|
if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && gBattleMoves[move].target == 8 && CountAliveMonsInBattle(BATTLE_ALIVE_DEF_SIDE) == 2)
|
||||||
damage /= 2;
|
damage /= 2;
|
||||||
|
|
||||||
// are effects of weather negated with cloud nine or air lock
|
// are effects of weather negated with cloud nine or air lock
|
||||||
|
Loading…
x
Reference in New Issue
Block a user