giant battle handler is done wohohohhohoho

This commit is contained in:
DizzyEggg 2017-10-03 21:35:27 +02:00
parent db58d5e24a
commit 46fe1f441f
11 changed files with 530 additions and 1751 deletions

File diff suppressed because it is too large Load Diff

View File

@ -8648,7 +8648,7 @@ sub_805C158: @ 805C158
lsls r0, 24
cmp r0, 0
bne _0805C194
ldr r1, =gUnknown_0203BD30
ldr r1, =gBattlePalaceMoveSelectionRngValue
ldr r0, =gRngValue
ldr r0, [r0]
str r0, [r1]

View File

@ -271,8 +271,8 @@ _08184FF0:
.pool
thumb_func_end RecordedBattle_SetBankAction
thumb_func_start sub_8185008
sub_8185008: @ 8185008
thumb_func_start RecordedBattle_ClearBankAction
RecordedBattle_ClearBankAction: @ 8185008
push {r4-r7,lr}
lsls r0, 24
lsrs r5, r0, 24
@ -310,7 +310,7 @@ _08185046:
pop {r0}
bx r0
.pool
thumb_func_end sub_8185008
thumb_func_end RecordedBattle_ClearBankAction
thumb_func_start sub_8185054
sub_8185054: @ 8185054

View File

@ -2786,8 +2786,8 @@ _08033D7C:
.pool
thumb_func_end EmitPrintStringPlayerOnly
thumb_func_start dp01_build_cmdbuf_x12_a_bb
dp01_build_cmdbuf_x12_a_bb: @ 8033DE4
thumb_func_start EmitChooseAction
EmitChooseAction: @ 8033DE4
push {r4,lr}
adds r4, r1, 0
lsls r0, 24
@ -2807,7 +2807,7 @@ dp01_build_cmdbuf_x12_a_bb: @ 8033DE4
pop {r0}
bx r0
.pool
thumb_func_end dp01_build_cmdbuf_x12_a_bb
thumb_func_end EmitChooseAction
thumb_func_start EmitCmd13
EmitCmd13: @ 8033E10
@ -2827,8 +2827,8 @@ EmitCmd13: @ 8033E10
.pool
thumb_func_end EmitCmd13
thumb_func_start sub_8033E30
sub_8033E30: @ 8033E30
thumb_func_start EmitChooseMove
EmitChooseMove: @ 8033E30
push {r4-r6,lr}
adds r5, r3, 0
lsls r0, 24
@ -2858,10 +2858,10 @@ _08033E4C:
pop {r0}
bx r0
.pool
thumb_func_end sub_8033E30
thumb_func_end EmitChooseMove
thumb_func_start sub_8033E6C
sub_8033E6C: @ 8033E6C
thumb_func_start EmitOpenBag
EmitOpenBag: @ 8033E6C
push {r4,r5,lr}
adds r4, r1, 0
lsls r0, 24
@ -2886,7 +2886,7 @@ _08033E7E:
pop {r0}
bx r0
.pool
thumb_func_end sub_8033E6C
thumb_func_end EmitOpenBag
thumb_func_start EmitChoosePokemon
EmitChoosePokemon: @ 8033EA0
@ -3624,8 +3624,8 @@ EmitCmd49: @ 80343D4
.pool
thumb_func_end EmitCmd49
thumb_func_start dp01_build_cmdbuf_x32_32_32_32
dp01_build_cmdbuf_x32_32_32_32: @ 80343F4
thumb_func_start Emit_x32
Emit_x32: @ 80343F4
push {lr}
lsls r0, 24
lsrs r0, 24
@ -3640,7 +3640,7 @@ dp01_build_cmdbuf_x32_32_32_32: @ 80343F4
pop {r0}
bx r0
.pool
thumb_func_end dp01_build_cmdbuf_x32_32_32_32
thumb_func_end Emit_x32
thumb_func_start EmitSpriteInvisibility
EmitSpriteInvisibility: @ 8034414

View File

@ -561,7 +561,7 @@ BattleScript_BerryStatRaiseEnd2:: @ 82DB84E
BattleScript_BerryFocusEnergyEnd2:: @ 82DB869
.incbin "baserom.gba", 0x2db869, 0x10
gUnknown_082DB879:: @ 82DB879
BattleScript_ActionSelectionItemsCantBeUsed:: @ 82DB879
.incbin "baserom.gba", 0x2db879, 0x4
gUnknown_082DB87D:: @ 82DB87D

View File

@ -61,7 +61,8 @@
#define STEVEN_PARTNER_ID 0xC03
#define SECRET_BASE_OPPONENT 0x400
#define BATTLE_TYPE_FRONTIER (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_x100000 | BATTLE_TYPE_PYRAMID)
#define BATTLE_TYPE_FRONTIER (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_x100000 | BATTLE_TYPE_PYRAMID)
#define BATTLE_TYPE_FRONTIER_NO_PYRAMID (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_x100000)
#define BATTLE_WON 0x1
#define BATTLE_LOST 0x2
@ -136,6 +137,7 @@
#define HITMARKER_PURSUIT_TRAP 0x00001000
#define HITMARKER_IGNORE_SAFEGUARD 0x00002000
#define HITMARKER_SYNCHRONISE_EFFECT 0x00004000
#define HITMARKER_x8000 0x00008000
#define HITMARKER_IGNORE_ON_AIR 0x00010000
#define HITMARKER_IGNORE_UNDERGROUND 0x00020000
#define HITMARKER_IGNORE_UNDERWATER 0x00040000
@ -614,10 +616,7 @@ struct BattleStruct
u8 field_7E;
u8 formToChangeInto;
u8 chosenMovesIds[4];
u8 field_84;
u8 field_85;
u8 field_86;
u8 field_87;
u8 field_84[4];
u8 field_88;
u8 field_89;
u8 field_8A;
@ -906,7 +905,7 @@ void BattleTurnPassed(void);
void BattleScriptPush(const u8* bsPtr);
void BattleScriptPushCursor(void);
void BattleScriptPop(void);
u8 sub_803FB4C(void); // msg, can't select a move
u8 TrySetCantSelectMoveBattleScript(void);
u8 CheckMoveLimitations(u8 bank, u8 unusableMoves, u8 check);
bool8 AreAllMovesUnusable(void);
u8 GetImprisonedMovesCount(u8 bank, u16 move);

View File

@ -14,6 +14,16 @@ struct MovePpInfo
u8 ppBonuses;
};
struct ChooseMoveStruct
{
u16 moves[4];
u8 ppNumbers[4];
u8 ppWithBonusNumbers[4];
u16 species;
u8 monType1;
u8 monType2;
};
#define REQUEST_ALL_BATTLE 0x0
#define REQUEST_SPECIES_BATTLE 0x1
#define REQUEST_HELDITEM_BATTLE 0x2
@ -40,8 +50,8 @@ void EmitSpriteInvisibility(u8 bufferId, bool8 isInvisible);
void EmitReturnPokeToBall(u8 bufferId, u8 arg1);
void EmitGetMonData(u8 bufferId, u8 arg1, u8 arg2);
void EmitSwitchInAnim(u8 bufferId, u8 partyId, bool8 dontClearSubstituteBit);
void EmitChoosePokemon(u8 bufferId, u8 caseId, u8 arg2, u8 abilityId, const u8* arg4);
void EmitLinkStandbyMsg(u8 bufferId, u8 arg1, u8 arg2);
void EmitChoosePokemon(u8 bufferId, u8 caseId, u8 arg2, u8 abilityId, u8* arg4);
void EmitLinkStandbyMsg(u8 bufferId, u8 arg1, bool32 arg2);
void EmitTrainerSlide(u8 bufferId);
void EmitTrainerSlideBack(u8 bufferId);
void EmitFaintingCry(u8 bufferId);
@ -56,6 +66,10 @@ void EmitIntroSlide(u8 bufferId, u8 terrainId);
void EmitDrawTrainerPic(u8 bufferId);
void EmitLoadMonSprite(u8 bufferId);
void EmitIntroTrainerBallThrow(u8 bufferId);
void EmitChooseAction(u8 bufferId, u8 arg1, u16 arg2);
void EmitChooseMove(u8 bufferId, bool8 isDoubleBattle, bool8 NoPpNumber, struct ChooseMoveStruct* movePpData);
void EmitOpenBag(u8 bufferId, u8* arg1);
void Emit_x32(u8 bufferId);
#define RESET_ACTION_MOVE_SELECTION 0
#define RESET_ACTION_SELECTION 1

View File

@ -6,10 +6,13 @@ extern u32 gRecordedBattleRngSeed;
void sub_8185F84(void);
void sub_8184E58(void);
void RecordedBattle_SetBankAction(u8 bank, u8 action);
void RecordedBattle_ClearBankAction(u8 bank, u8 bytesToClear);
void sub_8185F90(u16 arg0);
bool8 sub_8186450(void);
u8 sub_8185FAC(void);
u8 sub_8185FB8(void);
u8 MoveRecordedBattleToSaveData(void);
void sub_818603C(u8);
void sub_8185FD0(void);
#endif // GUARD_RECORDED_BATTLE_H

View File

@ -132,6 +132,7 @@ extern u8 gActionForBanks[BATTLE_BANKS_COUNT];
extern u16 gChosenMovesByBanks[BATTLE_BANKS_COUNT];
extern u8 gFightStateTracker;
extern u8 gLastUsedAbility;
extern u16 gLastUsedItem;
extern const u8 gSpeciesNames[][POKEMON_NAME_LENGTH + 1];
extern const struct BattleMove gBattleMoves[];
@ -168,6 +169,8 @@ extern void sub_80B3AF8(u8 taskId); // cable club
extern void sub_8076918(u8 bank);
extern void sub_80729D0(u8 healthoxSpriteId);
extern void sub_81A56B4(void); // battle frontier 2
extern void sub_81B8FB0(u8, u8); // party menu
extern u8 pokemon_order_func(u8); // party menu
// this file's functions
static void CB2_InitBattleInternal(void);
@ -214,6 +217,9 @@ static void BattleIntroPlayer1SendsOutMonAnimation(void);
static void TryDoEventsBeforeFirstTurn(void);
void sub_803BE74(void);
void bc_bs_exec(void);
void sub_803D2E8(void);
void sub_803CDF8(void);
bool8 sub_803CDB8(void);
void CB2_InitBattle(void)
{
@ -3736,3 +3742,475 @@ u8 IsRunningFromBattleImpossible(void)
}
return 0;
}
extern u8 gUnknown_0203CF00[];
void sub_803BDA0(u8 bank)
{
s32 i;
u8 r4;
u8 r1;
// gBattleStruct->field_60[bank][i]
for (i = 0; i < 3; i++)
gUnknown_0203CF00[i] = *(bank * 3 + i + (u8*)(gBattleStruct->field_60));
r4 = pokemon_order_func(gBattlePartyID[bank]);
r1 = pokemon_order_func(*(gBattleStruct->field_5C + bank));
sub_81B8FB0(r4, r1);
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{
for (i = 0; i < 3; i++)
{
*(bank * 3 + i + (u8*)(gBattleStruct->field_60)) = gUnknown_0203CF00[i];
*((bank ^ BIT_MON) * 3 + i + (u8*)(gBattleStruct->field_60)) = gUnknown_0203CF00[i];
}
}
else
{
for (i = 0; i < 3; i++)
{
*(bank * 3 + i + (u8*)(gBattleStruct->field_60)) = gUnknown_0203CF00[i];
}
}
}
extern const u8* gBattlescriptPtrsForSelection[BATTLE_BANKS_COUNT];
extern const u8* gBattlescriptCurrInstr;
extern const u8 BattleScript_ActionSelectionItemsCantBeUsed[];
extern const u8 gUnknown_082DAB11[];
extern const u8 gUnknown_082DB9BA[];
extern const u8 gUnknown_082DAAFE[];
extern const u8 gUnknown_082DAB0B[];
extern u32 gBattlePalaceMoveSelectionRngValue;
void sub_803BE74(void)
{
s32 i;
gBattleCommunication[4] = 0;
for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++)
{
u8 identity = GetBankIdentity(gActiveBank);
switch (gBattleCommunication[gActiveBank])
{
case 0:
sub_8185FD0();
gBattleCommunication[gActiveBank] = 1;
break;
case 1:
*(gBattleStruct->field_5C + gActiveBank) = 6;
if (gBattleTypeFlags & BATTLE_TYPE_MULTI
|| !(identity & BIT_MON)
|| gBattleStruct->field_91 & gBitTable[GetBankByIdentity(identity ^ BIT_MON)]
|| gBattleCommunication[GetBankByIdentity(identity ^ BIT_MON)] == 5)
{
if (gBattleStruct->field_91 & gBitTable[gActiveBank])
{
gActionForBanks[gActiveBank] = 13;
if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI))
gBattleCommunication[gActiveBank] = 5;
else
gBattleCommunication[gActiveBank] = 4;
}
else
{
if (gBattleMons[gActiveBank].status2 & STATUS2_MULTIPLETURNS
|| gBattleMons[gActiveBank].status2 & STATUS2_RECHARGE)
{
gActionForBanks[gActiveBank] = 0;
gBattleCommunication[gActiveBank] = 4;
}
else
{
EmitChooseAction(0, gActionForBanks[0], gBattleBufferB[0][1] | (gBattleBufferB[0][2] << 8));
MarkBufferBankForExecution(gActiveBank);
gBattleCommunication[gActiveBank]++;
}
}
}
break;
case 2:
if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC))))
{
RecordedBattle_SetBankAction(gActiveBank, gBattleBufferB[gActiveBank][1]);
gActionForBanks[gActiveBank] = gBattleBufferB[gActiveBank][1];
switch (gBattleBufferB[gActiveBank][1])
{
case 0:
if (AreAllMovesUnusable())
{
gBattleCommunication[gActiveBank] = 6;
*(gBattleStruct->field_54 + gActiveBank) = 0;
*(gBattleStruct->field_84 + gActiveBank) = 4;
*(gBattleStruct->moveTarget + gActiveBank) = gBattleBufferB[gActiveBank][3];
return;
}
else if (gDisableStructs[gActiveBank].encoredMove != 0)
{
gChosenMovesByBanks[gActiveBank] = gDisableStructs[gActiveBank].encoredMove;
*(gBattleStruct->chosenMovesIds + gActiveBank) = gDisableStructs[gActiveBank].encoredMovePos;
gBattleCommunication[gActiveBank] = 4;
return;
}
else
{
struct ChooseMoveStruct moveInfo;
moveInfo.species = gBattleMons[gActiveBank].species;
moveInfo.monType1 = gBattleMons[gActiveBank].type1;
moveInfo.monType2 = gBattleMons[gActiveBank].type2;
for (i = 0; i < 4; i++)
{
moveInfo.moves[i] = gBattleMons[gActiveBank].moves[i];
moveInfo.ppNumbers[i] = gBattleMons[gActiveBank].pp[i];
moveInfo.ppWithBonusNumbers[i] = CalculatePPWithBonus(
gBattleMons[gActiveBank].moves[i],
gBattleMons[gActiveBank].ppBonuses,
i);
}
EmitChooseMove(0, (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) != 0, FALSE, &moveInfo);
MarkBufferBankForExecution(gActiveBank);
}
break;
case 1:
if (gBattleTypeFlags & (BATTLE_TYPE_LINK
| BATTLE_TYPE_FRONTIER_NO_PYRAMID
| BATTLE_TYPE_EREADER_TRAINER
| BATTLE_TYPE_x2000000))
{
RecordedBattle_ClearBankAction(gActiveBank, 1);
gBattlescriptPtrsForSelection[gActiveBank] = BattleScript_ActionSelectionItemsCantBeUsed;
gBattleCommunication[gActiveBank] = 6;
*(gBattleStruct->field_54 + gActiveBank) = 0;
*(gBattleStruct->field_84 + gActiveBank) = 1;
return;
}
else
{
EmitOpenBag(0, gBattleStruct->field_60[gActiveBank]);
MarkBufferBankForExecution(gActiveBank);
}
break;
case 2:
*(gBattleStruct->field_58 + gActiveBank) = gBattlePartyID[gActiveBank];
if (gBattleMons[gActiveBank].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION)
|| gBattleTypeFlags & BATTLE_TYPE_ARENA
|| gStatuses3[gActiveBank] & STATUS3_ROOTED)
{
EmitChoosePokemon(0, 2, 6, ABILITY_NONE, gBattleStruct->field_60[gActiveBank]);
}
else if ((i = AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBank, ABILITY_SHADOW_TAG, 0, 0))
|| ((i = AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBank, ABILITY_ARENA_TRAP, 0, 0))
&& gBattleMons[gActiveBank].type1 != TYPE_FLYING
&& gBattleMons[gActiveBank].type2 != TYPE_FLYING
&& gBattleMons[gActiveBank].ability != ABILITY_LEVITATE)
|| ((i = AbilityBattleEffects(ABILITYEFFECT_CHECK_FIELD_EXCEPT_BANK, gActiveBank, ABILITY_MAGNET_PULL, 0, 0))
&& (gBattleMons[gActiveBank].type1 == TYPE_STEEL
|| gBattleMons[gActiveBank].type2 == TYPE_STEEL)))
{
EmitChoosePokemon(0, ((i - 1) << 4) | 4, 6, gLastUsedAbility, gBattleStruct->field_60[gActiveBank]);
}
else
{
if (gActiveBank == 2 && gActionForBanks[0] == 2)
EmitChoosePokemon(0, 0, *(gBattleStruct->field_5C + 0), ABILITY_NONE, gBattleStruct->field_60[gActiveBank]);
else if (gActiveBank == 3 && gActionForBanks[1] == 2)
EmitChoosePokemon(0, 0, *(gBattleStruct->field_5C + 1), ABILITY_NONE, gBattleStruct->field_60[gActiveBank]);
else
EmitChoosePokemon(0, 0, 6, ABILITY_NONE, gBattleStruct->field_60[gActiveBank]);
}
MarkBufferBankForExecution(gActiveBank);
break;
case 5:
if (IsPlayerPartyAndPokemonStorageFull())
{
gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DAB11;
gBattleCommunication[gActiveBank] = 6;
*(gBattleStruct->field_54 + gActiveBank) = 0;
*(gBattleStruct->field_84 + gActiveBank) = 1;
return;
}
break;
case 6:
EmitOpenBag(0, gBattleStruct->field_60[gActiveBank]);
MarkBufferBankForExecution(gActiveBank);
break;
case 12:
gBattleCommunication[gActiveBank] = 7;
gBattleCommunication[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)] = 1;
RecordedBattle_ClearBankAction(gActiveBank, 1);
if (gBattleMons[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)].status2 & STATUS2_MULTIPLETURNS
|| gBattleMons[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)].status2 & STATUS2_RECHARGE)
{
Emit_x32(0);
MarkBufferBankForExecution(gActiveBank);
return;
}
else if (gActionForBanks[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)] == 2)
{
RecordedBattle_ClearBankAction(GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON), 2);
}
else if (gActionForBanks[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)] == 3)
{
RecordedBattle_ClearBankAction(GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON), 1);
}
else if (gActionForBanks[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)] == 0
&& (gProtectStructs[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)].onlyStruggle
|| gDisableStructs[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)].encoredMove))
{
RecordedBattle_ClearBankAction(GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON), 1);
}
else if (gBattleTypeFlags & BATTLE_TYPE_PALACE
&& gActionForBanks[GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON)] == 0)
{
gRngValue = gBattlePalaceMoveSelectionRngValue;
RecordedBattle_ClearBankAction(GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON), 1);
}
else
{
RecordedBattle_ClearBankAction(GetBankByIdentity(GetBankIdentity(gActiveBank) ^ BIT_MON), 3);
}
Emit_x32(0);
MarkBufferBankForExecution(gActiveBank);
return;
}
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER
&& gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_x4000000)
&& gBattleBufferB[gActiveBank][1] == 3)
{
gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DB9BA;
gBattleCommunication[gActiveBank] = 8;
*(gBattleStruct->field_54 + gActiveBank) = 0;
*(gBattleStruct->field_84 + gActiveBank) = 1;
return;
}
else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER
&& !(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000))
&& gBattleBufferB[gActiveBank][1] == 3)
{
BattleScriptExecute(gUnknown_082DAAFE);
gBattleCommunication[gActiveBank] = 1;
}
else if (IsRunningFromBattleImpossible() != 0
&& gBattleBufferB[gActiveBank][1] == 3)
{
gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DAB0B;
gBattleCommunication[gActiveBank] = 6;
*(gBattleStruct->field_54 + gActiveBank) = 0;
*(gBattleStruct->field_84 + gActiveBank) = 1;
return;
}
else
{
gBattleCommunication[gActiveBank]++;
}
}
break;
case 3:
if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC))))
{
switch (gActionForBanks[gActiveBank])
{
case 0:
switch (gBattleBufferB[gActiveBank][1])
{
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
gActionForBanks[gActiveBank] = gBattleBufferB[gActiveBank][1];
return;
case 15:
gActionForBanks[gActiveBank] = 2;
sub_803CDF8();
return;
default:
sub_818603C(2);
if ((gBattleBufferB[gActiveBank][2] | (gBattleBufferB[gActiveBank][3] << 8)) == 0xFFFF)
{
gBattleCommunication[gActiveBank] = 1;
RecordedBattle_ClearBankAction(gActiveBank, 1);
}
else if (TrySetCantSelectMoveBattleScript())
{
RecordedBattle_ClearBankAction(gActiveBank, 1);
gBattleCommunication[gActiveBank] = 6;
*(gBattleStruct->field_54 + gActiveBank) = 0;
gBattleBufferB[gActiveBank][1] = 0;
*(gBattleStruct->field_84 + gActiveBank) = 2;
return;
}
else
{
if (!(gBattleTypeFlags & BATTLE_TYPE_PALACE))
{
RecordedBattle_SetBankAction(gActiveBank, gBattleBufferB[gActiveBank][2]);
RecordedBattle_SetBankAction(gActiveBank, gBattleBufferB[gActiveBank][3]);
}
*(gBattleStruct->chosenMovesIds + gActiveBank) = gBattleBufferB[gActiveBank][2];
gChosenMovesByBanks[gActiveBank] = gBattleMons[gActiveBank].moves[*(gBattleStruct->chosenMovesIds + gActiveBank)];
*(gBattleStruct->moveTarget + gActiveBank) = gBattleBufferB[gActiveBank][3];
gBattleCommunication[gActiveBank]++;
}
break;
}
break;
case 1:
if ((gBattleBufferB[gActiveBank][1] | (gBattleBufferB[gActiveBank][2] << 8)) == 0)
{
gBattleCommunication[gActiveBank] = 1;
}
else
{
gLastUsedItem = (gBattleBufferB[gActiveBank][1] | (gBattleBufferB[gActiveBank][2] << 8));
gBattleCommunication[gActiveBank]++;
}
break;
case 2:
if (gBattleBufferB[gActiveBank][1] == 6)
{
gBattleCommunication[gActiveBank] = 1;
RecordedBattle_ClearBankAction(gActiveBank, 1);
}
else
{
sub_803CDF8();
gBattleCommunication[gActiveBank]++;
}
break;
case 3:
gHitMarker |= HITMARKER_x8000;
gBattleCommunication[gActiveBank]++;
break;
case 4:
gBattleCommunication[gActiveBank]++;
break;
case 5:
gBattleCommunication[gActiveBank]++;
break;
case 6:
if ((gBattleBufferB[gActiveBank][1] | (gBattleBufferB[gActiveBank][2] << 8)) != 0)
{
gBattleCommunication[gActiveBank]++;
}
else
{
gBattleCommunication[gActiveBank] = 1;
}
break;
case 7:
gBattleCommunication[gActiveBank]++;
break;
case 8:
gHitMarker |= HITMARKER_x8000;
gBattleCommunication[gActiveBank]++;
break;
case 9:
gBattleCommunication[gActiveBank]++;
break;
}
}
break;
case 4:
if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC))))
{
i = (sub_803CDB8() != 0);
if (((gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_DOUBLE)) != BATTLE_TYPE_DOUBLE)
|| (identity & BIT_MON)
|| (*(&gBattleStruct->field_91) & gBitTable[GetBankByIdentity(identity ^ BIT_MON)]))
{
EmitLinkStandbyMsg(0, 0, i);
}
else
{
EmitLinkStandbyMsg(0, 1, i);
}
MarkBufferBankForExecution(gActiveBank);
gBattleCommunication[gActiveBank]++;
}
break;
case 5:
if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC))))
{
gBattleCommunication[4]++;
}
break;
case 6:
if (*(gBattleStruct->field_54 + gActiveBank) != 0)
{
gBattleCommunication[gActiveBank] = *(gBattleStruct->field_84 + gActiveBank);
}
else
{
gBankAttacker = gActiveBank;
gBattlescriptCurrInstr = gBattlescriptPtrsForSelection[gActiveBank];
if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC))))
{
gBattleScriptingCommandsTable[gBattlescriptCurrInstr[0]]();
}
gBattlescriptPtrsForSelection[gActiveBank] = gBattlescriptCurrInstr;
}
break;
case 7:
if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC))))
{
gBattleCommunication[gActiveBank] = 1;
}
break;
case 8:
if (*(gBattleStruct->field_54 + gActiveBank) != 0)
{
if (gBattleBufferB[gActiveBank][1] == 13)
{
gHitMarker |= HITMARKER_x8000;
gActionForBanks[gActiveBank] = 3;
gBattleCommunication[gActiveBank] = 4;
}
else
{
RecordedBattle_ClearBankAction(gActiveBank, 1);
gBattleCommunication[gActiveBank] = *(gBattleStruct->field_84 + gActiveBank);
}
}
else
{
gBankAttacker = gActiveBank;
gBattlescriptCurrInstr = gBattlescriptPtrsForSelection[gActiveBank];
if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC))))
{
gBattleScriptingCommandsTable[gBattlescriptCurrInstr[0]]();
}
gBattlescriptPtrsForSelection[gActiveBank] = gBattlescriptCurrInstr;
}
break;
}
}
if (gBattleCommunication[4] == gNoOfAllBanks)
{
sub_818603C(1);
gBattleMainFunc = sub_803D2E8;
if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER)
{
for (i = 0; i < gNoOfAllBanks; i++)
{
if (gActionForBanks[i] == 2)
sub_80571DC(i, *(gBattleStruct->field_5C + i));
}
}
}
}

View File

@ -19,7 +19,7 @@
#include "calculate_base_damage.h"
extern const u8* gBattlescriptCurrInstr;
extern const u8* gUnknown_02024220[BATTLE_BANKS_COUNT];
extern const u8* gBattlescriptPtrsForSelection[BATTLE_BANKS_COUNT];
extern const u8* gUnknown_02024230[BATTLE_BANKS_COUNT];
extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT];
extern u8 gActiveBank;
@ -200,7 +200,7 @@ void BattleScriptPop(void)
gBattlescriptCurrInstr = BATTLESCRIPTS_STACK->ptr[--BATTLESCRIPTS_STACK->size];
}
u8 sub_803FB4C(void) // msg, can't select a move
u8 TrySetCantSelectMoveBattleScript(void)
{
u8 limitations = 0;
u16 move = gBattleMons[gActiveBank].moves[gBattleBufferB[gActiveBank][2]];
@ -218,7 +218,7 @@ u8 sub_803FB4C(void) // msg, can't select a move
}
else
{
gUnknown_02024220[gActiveBank] = gUnknown_082DAE1F;
gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DAE1F;
limitations = 1;
}
}
@ -233,7 +233,7 @@ u8 sub_803FB4C(void) // msg, can't select a move
}
else
{
gUnknown_02024220[gActiveBank] = gUnknown_082DB089;
gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DB089;
limitations++;
}
}
@ -248,7 +248,7 @@ u8 sub_803FB4C(void) // msg, can't select a move
}
else
{
gUnknown_02024220[gActiveBank] = gUnknown_082DB0A0;
gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DB0A0;
limitations++;
}
}
@ -263,7 +263,7 @@ u8 sub_803FB4C(void) // msg, can't select a move
}
else
{
gUnknown_02024220[gActiveBank] = gUnknown_082DB181;
gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DB181;
limitations++;
}
}
@ -285,7 +285,7 @@ u8 sub_803FB4C(void) // msg, can't select a move
}
else
{
gUnknown_02024220[gActiveBank] = gUnknown_082DB812;
gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DB812;
limitations++;
}
}
@ -298,7 +298,7 @@ u8 sub_803FB4C(void) // msg, can't select a move
}
else
{
gUnknown_02024220[gActiveBank] = gUnknown_082DB076;
gBattlescriptPtrsForSelection[gActiveBank] = gUnknown_082DB076;
limitations++;
}
}
@ -349,7 +349,7 @@ bool8 AreAllMovesUnusable(void)
if (unusable == 0xF) // all moves are unusable
{
gProtectStructs[gActiveBank].onlyStruggle = 1;
gUnknown_02024220[gActiveBank] = BattleScript_NoMovesLeft;
gBattlescriptPtrsForSelection[gActiveBank] = BattleScript_NoMovesLeft;
}
else
{

View File

@ -382,7 +382,7 @@ gBattlescriptCurrInstr: @ 2024214
gActionForBanks: @ 202421C
.space 0x4
gUnknown_02024220: @ 2024220
gBattlescriptPtrsForSelection: @ 2024220
.space 0x10
gUnknown_02024230: @ 2024230
@ -1671,7 +1671,7 @@ gUnknown_0203BD28: @ 203BD28
gRecordedBattleRngSeed: @ 203BD2C
.space 0x4
gUnknown_0203BD30: @ 203BD30
gBattlePalaceMoveSelectionRngValue: @ 203BD30
.space 0x4
gUnknown_0203BD34: @ 203BD34