add party menu defines

This commit is contained in:
DizzyEggg 2018-07-07 19:57:09 +02:00
parent 1c48e58574
commit 008d961b2a
11 changed files with 69 additions and 51 deletions

View File

@ -16079,8 +16079,8 @@ _081B89A6:
bx r1
thumb_func_end sub_81B8984
thumb_func_start sub_81B89AC
sub_81B89AC: @ 81B89AC
thumb_func_start OpenPartyMenuInBattle
OpenPartyMenuInBattle: @ 81B89AC
push {r4,lr}
sub sp, 0xC
adds r4, r0, 0
@ -16107,7 +16107,7 @@ sub_81B89AC: @ 81B89AC
pop {r0}
bx r0
.pool
thumb_func_end sub_81B89AC
thumb_func_end OpenPartyMenuInBattle
thumb_func_start sub_81B89F0
sub_81B89F0: @ 81B89F0
@ -16288,7 +16288,7 @@ _081B8B94:
ldrb r0, [r0, 0xB]
cmp r0, 0x4
bne _081B8BA8
bl sub_806E994
bl SetMonPreventsSwitchingString
b _081B8C46
.pool
_081B8BA8:

View File

@ -177,7 +177,7 @@ struct ProtectStruct
/* field_0 */
u32 protected:1;
u32 endured:1;
u32 onlyStruggle:1;
u32 noValidMoves:1;
u32 helpingHand:1;
u32 bounceMove:1;
u32 stealMove:1;
@ -456,7 +456,7 @@ struct BattleStruct
u8 field_46;
u8 field_47;
u8 focusPunchBattlerId;
u8 field_49;
u8 battlerPreventingSwitchout;
u8 moneyMultiplier;
u8 savedTurnActionNumber;
u8 switchInAbilitiesCounter;
@ -509,7 +509,7 @@ struct BattleStruct
u8 field_A7;
u16 hpOnSwitchout[2];
u32 savedBattleTypeFlags;
u8 field_B0;
u8 abilityPreventingSwitchout;
u8 hpScale;
u8 synchronizeMoveEffect;
bool8 anyMonHasTransformed;

View File

@ -65,6 +65,8 @@ enum
REQUEST_TOUGH_RIBBON_BATTLE,
};
// Special arguments for Battle Controller functions.
#define RESET_ACTION_MOVE_SELECTION 0
#define RESET_ACTION_SELECTION 1
#define RESET_MOVE_SELECTION 2
@ -76,10 +78,11 @@ enum
#define BALL_3_SHAKES_SUCCESS 4
#define BALL_TRAINER_BLOCK 5
#define RET_VALUE_LEVELLED_UP 11
#define INSTANT_HP_BAR_DROP 32767
// Special return values in gBattleBufferB from Battle Controller functions.
#define RET_VALUE_LEVELLED_UP 11
struct UnusedControllerStruct
{
u8 field_0:7;

View File

@ -1,6 +1,8 @@
#ifndef GUARD_PARTY_MENU_H
#define GUARD_PARTY_MENU_H
#include "task.h"
enum
{
AILMENT_NONE,
@ -11,6 +13,16 @@ enum
AILMENT_BRN
};
enum
{
PARTY_CHOOSE_MON,
PARTY_MUST_CHOOSE_MON,
PARTY_CANT_SWITCH,
PARTY_USE_ITEM_ON,
PARTY_ABILITY_PREVENTS,
PARTY_GIVE_ITEM,
};
struct Struct203CEC8
{
u8 filler[0x9];
@ -38,5 +50,6 @@ void sub_81B1F18(u8 taskId, u8 pokemonIdx, s8 a, s16 hp, TaskFunc func);
void sub_81B1B5C(void *a, u8 b);
u8 sub_81B1BD4();
void sub_81B8448();
void OpenPartyMenuInBattle(u8 caseId);
#endif // GUARD_PARTY_MENU_H

View File

@ -593,7 +593,7 @@ bool8 IsTradedMon(struct Pokemon *mon);
bool8 IsOtherTrainer(u32 otId, u8 *otName);
void MonRestorePP(struct Pokemon *mon);
void BoxMonRestorePP(struct BoxPokemon *boxMon);
void sub_806E994(void);
void SetMonPreventsSwitchingString(void);
void SetWildMonHeldItem(void);
bool8 IsMonShiny(struct Pokemon *mon);
bool8 IsShinyOtIdPersonality(u32 otId, u32 personality);

View File

@ -30,6 +30,7 @@
#include "battle_setup.h"
#include "item_use.h"
#include "recorded_battle.h"
#include "party_menu.h"
extern u8 gUnknown_0203CEE8;
extern u8 gUnknown_0203CEE9;
@ -45,7 +46,6 @@ extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[];
extern void sub_8172EF0(u8 battlerId, struct Pokemon *mon);
extern void sub_81B89AC(u8 arg0);
extern void sub_81AABB0(void);
extern void sub_81A57E4(u8 battlerId, u16 stringId);
extern void sub_81851A8(u8 *);
@ -120,7 +120,7 @@ static void MoveSelectionDisplayMoveType(void);
static void MoveSelectionDisplayMoveNames(void);
static void HandleMoveSwitchting(void);
static void sub_8058FC0(void);
static void sub_8059828(void);
static void WaitForMonSelection(void);
static void CompleteWhenChoseItem(void);
static void Task_LaunchLvlUpAnim(u8 taskId);
static void Task_PrepareToGiveExpWithExpBar(u8 taskId);
@ -1337,21 +1337,21 @@ static void CompleteOnInactiveTextPrinter2(void)
PlayerBufferExecCompleted();
}
static void sub_80597CC(void)
static void OpenPartyMenuToChooseMon(void)
{
if (!gPaletteFade.active)
{
u8 r4;
u8 caseId;
gBattlerControllerFuncs[gActiveBattler] = sub_8059828;
r4 = gTasks[gUnknown_03005D7C[gActiveBattler]].data[0];
gBattlerControllerFuncs[gActiveBattler] = WaitForMonSelection;
caseId = gTasks[gUnknown_03005D7C[gActiveBattler]].data[0];
DestroyTask(gUnknown_03005D7C[gActiveBattler]);
FreeAllWindowBuffers();
sub_81B89AC(r4);
OpenPartyMenuInBattle(caseId);
}
}
static void sub_8059828(void)
static void WaitForMonSelection(void)
{
if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active)
{
@ -2655,7 +2655,7 @@ static void PlayerHandleChoosePokemon(void)
for (i = 0; i < 3; i++)
gUnknown_0203CF00[i] = gBattleBufferA[gActiveBattler][4 + i];
if (gBattleTypeFlags & BATTLE_TYPE_ARENA && (gBattleBufferA[gActiveBattler][1] & 0xF) != 2)
if (gBattleTypeFlags & BATTLE_TYPE_ARENA && (gBattleBufferA[gActiveBattler][1] & 0xF) != PARTY_CANT_SWITCH)
{
BtlController_EmitChosenMonReturnValue(1, gBattlerPartyIndexes[gActiveBattler] + 1, gUnknown_0203CF00);
PlayerBufferExecCompleted();
@ -2664,11 +2664,11 @@ static void PlayerHandleChoosePokemon(void)
{
gUnknown_03005D7C[gActiveBattler] = CreateTask(TaskDummy, 0xFF);
gTasks[gUnknown_03005D7C[gActiveBattler]].data[0] = gBattleBufferA[gActiveBattler][1] & 0xF;
*(&gBattleStruct->field_49) = gBattleBufferA[gActiveBattler][1] >> 4;
*(&gBattleStruct->battlerPreventingSwitchout) = gBattleBufferA[gActiveBattler][1] >> 4;
*(&gBattleStruct->field_8B) = gBattleBufferA[gActiveBattler][2];
*(&gBattleStruct->field_B0) = gBattleBufferA[gActiveBattler][3];
BeginNormalPaletteFade(-1, 0, 0, 16, 0);
gBattlerControllerFuncs[gActiveBattler] = sub_80597CC;
*(&gBattleStruct->abilityPreventingSwitchout) = gBattleBufferA[gActiveBattler][3];
BeginNormalPaletteFade(-1, 0, 0, 0x10, 0);
gBattlerControllerFuncs[gActiveBattler] = OpenPartyMenuToChooseMon;
gBattlerInMenuId = gActiveBattler;
}
}

View File

@ -1181,7 +1181,7 @@ void BtlController_EmitChooseItem(u8 bufferId, u8 *arg1)
PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 4);
}
void BtlController_EmitChoosePokemon(u8 bufferId, u8 caseId, u8 arg2, u8 abilityId, u8* arg4)
void BtlController_EmitChoosePokemon(u8 bufferId, u8 caseId, u8 arg2, u8 abilityId, u8 *arg4)
{
s32 i;
@ -1191,7 +1191,7 @@ void BtlController_EmitChoosePokemon(u8 bufferId, u8 caseId, u8 arg2, u8 ability
sBattleBuffersTransferData[3] = abilityId;
for (i = 0; i < 3; i++)
sBattleBuffersTransferData[4 + i] = arg4[i];
PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 8); // but only 7 bytes were written
PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 8); // Only 7 bytes were written.
}
void BtlController_EmitCmd23(u8 bufferId)

View File

@ -51,6 +51,7 @@
#include "decompress.h"
#include "international_string_util.h"
#include "pokeball.h"
#include "party_menu.h"
struct UnknownPokemonStruct4
{
@ -3232,7 +3233,7 @@ void FaintClearSetData(void)
gProtectStructs[gActiveBattler].protected = 0;
gProtectStructs[gActiveBattler].endured = 0;
gProtectStructs[gActiveBattler].onlyStruggle = 0;
gProtectStructs[gActiveBattler].noValidMoves = 0;
gProtectStructs[gActiveBattler].helpingHand = 0;
gProtectStructs[gActiveBattler].bounceMove = 0;
gProtectStructs[gActiveBattler].stealMove = 0;
@ -4141,11 +4142,11 @@ static void HandleTurnActionSelectionState(void)
u8 position = GetBattlerPosition(gActiveBattler);
switch (gBattleCommunication[gActiveBattler])
{
case STATE_TURN_START_RECORD: // recorded battle related on start of every turn
case STATE_TURN_START_RECORD: // Recorded battle related action on start of every turn.
RecordedBattle_CopyBattlerMoves();
gBattleCommunication[gActiveBattler] = STATE_BEFORE_ACTION_CHOSEN;
break;
case STATE_BEFORE_ACTION_CHOSEN: // choose an action
case STATE_BEFORE_ACTION_CHOSEN: // Choose an action.
*(gBattleStruct->monToSwitchIntoId + gActiveBattler) = PARTY_SIZE;
if (gBattleTypeFlags & BATTLE_TYPE_MULTI
|| (position & BIT_FLANK) == B_FLANK_LEFT
@ -4177,7 +4178,7 @@ static void HandleTurnActionSelectionState(void)
}
}
break;
case STATE_WAIT_ACTION_CHOSEN: // try to perform an action
case STATE_WAIT_ACTION_CHOSEN: // Try to perform an action.
if (!(gBattleControllerExecFlags & ((gBitTable[gActiveBattler]) | (0xF0000000) | (gBitTable[gActiveBattler] << 4) | (gBitTable[gActiveBattler] << 8) | (gBitTable[gActiveBattler] << 0xC))))
{
RecordedBattle_SetBattlerAction(gActiveBattler, gBattleBufferB[gActiveBattler][1]);
@ -4248,7 +4249,7 @@ static void HandleTurnActionSelectionState(void)
|| gBattleTypeFlags & BATTLE_TYPE_ARENA
|| gStatuses3[gActiveBattler] & STATUS3_ROOTED)
{
BtlController_EmitChoosePokemon(0, 2, 6, ABILITY_NONE, gBattleStruct->field_60[gActiveBattler]);
BtlController_EmitChoosePokemon(0, PARTY_CANT_SWITCH, 6, ABILITY_NONE, gBattleStruct->field_60[gActiveBattler]);
}
else if ((i = ABILITY_ON_OPPOSING_FIELD(gActiveBattler, ABILITY_SHADOW_TAG))
|| ((i = ABILITY_ON_OPPOSING_FIELD(gActiveBattler, ABILITY_ARENA_TRAP))
@ -4257,16 +4258,16 @@ static void HandleTurnActionSelectionState(void)
|| ((i = AbilityBattleEffects(ABILITYEFFECT_CHECK_FIELD_EXCEPT_BATTLER, gActiveBattler, ABILITY_MAGNET_PULL, 0, 0))
&& IS_BATTLER_OF_TYPE(gActiveBattler, TYPE_STEEL)))
{
BtlController_EmitChoosePokemon(0, ((i - 1) << 4) | 4, 6, gLastUsedAbility, gBattleStruct->field_60[gActiveBattler]);
BtlController_EmitChoosePokemon(0, ((i - 1) << 4) | PARTY_ABILITY_PREVENTS, 6, gLastUsedAbility, gBattleStruct->field_60[gActiveBattler]);
}
else
{
if (gActiveBattler == 2 && gChosenActionByBattler[0] == B_ACTION_SWITCH)
BtlController_EmitChoosePokemon(0, 0, *(gBattleStruct->monToSwitchIntoId + 0), ABILITY_NONE, gBattleStruct->field_60[gActiveBattler]);
BtlController_EmitChoosePokemon(0, PARTY_CHOOSE_MON, *(gBattleStruct->monToSwitchIntoId + 0), ABILITY_NONE, gBattleStruct->field_60[gActiveBattler]);
else if (gActiveBattler == 3 && gChosenActionByBattler[1] == B_ACTION_SWITCH)
BtlController_EmitChoosePokemon(0, 0, *(gBattleStruct->monToSwitchIntoId + 1), ABILITY_NONE, gBattleStruct->field_60[gActiveBattler]);
BtlController_EmitChoosePokemon(0, PARTY_CHOOSE_MON, *(gBattleStruct->monToSwitchIntoId + 1), ABILITY_NONE, gBattleStruct->field_60[gActiveBattler]);
else
BtlController_EmitChoosePokemon(0, 0, 6, ABILITY_NONE, gBattleStruct->field_60[gActiveBattler]);
BtlController_EmitChoosePokemon(0, PARTY_CHOOSE_MON, 6, ABILITY_NONE, gBattleStruct->field_60[gActiveBattler]);
}
MarkBattlerForControllerExec(gActiveBattler);
break;
@ -4304,7 +4305,7 @@ static void HandleTurnActionSelectionState(void)
RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))), 1);
}
else if (gChosenActionByBattler[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))] == B_ACTION_USE_MOVE
&& (gProtectStructs[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))].onlyStruggle
&& (gProtectStructs[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))].noValidMoves
|| gDisableStructs[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))].encoredMove))
{
RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))), 1);
@ -4705,7 +4706,7 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves)
{
if (gChosenActionByBattler[battler1] == B_ACTION_USE_MOVE)
{
if (gProtectStructs[battler1].onlyStruggle)
if (gProtectStructs[battler1].noValidMoves)
moveBattler1 = MOVE_STRUGGLE;
else
moveBattler1 = gBattleMons[battler1].moves[*(gBattleStruct->chosenMovePositions + battler1)];
@ -4715,7 +4716,7 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves)
if (gChosenActionByBattler[battler2] == B_ACTION_USE_MOVE)
{
if (gProtectStructs[battler2].onlyStruggle)
if (gProtectStructs[battler2].noValidMoves)
moveBattler2 = MOVE_STRUGGLE;
else
moveBattler2 = gBattleMons[battler2].moves[*(gBattleStruct->chosenMovePositions + battler2)];
@ -4917,7 +4918,7 @@ static void CheckFocusPunch_ClearVarsBeforeTurnStarts(void)
if (gChosenMoveByBattler[gActiveBattler] == MOVE_FOCUS_PUNCH
&& !(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP)
&& !(gDisableStructs[gBattlerAttacker].truantCounter)
&& !(gProtectStructs[gActiveBattler].onlyStruggle))
&& !(gProtectStructs[gActiveBattler].noValidMoves))
{
BattleScriptExecute(BattleScript_FocusPunchSetUp);
return;
@ -5290,9 +5291,9 @@ static void HandleAction_UseMove(void)
gCurrMovePos = gChosenMovePos = *(gBattleStruct->chosenMovePositions + gBattlerAttacker);
// choose move
if (gProtectStructs[gBattlerAttacker].onlyStruggle)
if (gProtectStructs[gBattlerAttacker].noValidMoves)
{
gProtectStructs[gBattlerAttacker].onlyStruggle = 0;
gProtectStructs[gBattlerAttacker].noValidMoves = 0;
gCurrentMove = gChosenMove = MOVE_STRUGGLE;
gHitMarker |= HITMARKER_NO_PPDEDUCT;
*(gBattleStruct->moveTarget + gBattlerAttacker) = GetMoveTarget(MOVE_STRUGGLE, 0);

View File

@ -40,6 +40,7 @@
#include "constants/battle_string_ids.h"
#include "battle_setup.h"
#include "overworld.h"
#include "party_menu.h"
extern u16 gBattle_BG1_X;
extern u16 gBattle_BG1_Y;
@ -5143,7 +5144,7 @@ static void sub_804CF10(u8 arg0)
*(gBattleStruct->monToSwitchIntoId + gActiveBattler) = 6;
gBattleStruct->field_93 &= ~(gBitTable[gActiveBattler]);
BtlController_EmitChoosePokemon(0, 1, arg0, 0, gBattleStruct->field_60[gActiveBattler]);
BtlController_EmitChoosePokemon(0, PARTY_MUST_CHOOSE_MON, arg0, 0, gBattleStruct->field_60[gActiveBattler]);
MarkBattlerForControllerExec(gActiveBattler);
}
@ -5382,9 +5383,9 @@ static void atk50_openpartyscreen(void)
else
{
if (gBattlescriptCurrInstr[1] & 0x80)
hitmarkerFaintBits = 0; // used here as the caseId for the EmitChoose function
hitmarkerFaintBits = PARTY_CHOOSE_MON; // Used here as the caseId for the EmitChoose function.
else
hitmarkerFaintBits = 1;
hitmarkerFaintBits = PARTY_MUST_CHOOSE_MON;
battlerId = GetBattlerForBattleScript(gBattlescriptCurrInstr[1] & ~(0x80));
if (gSpecialStatuses[battlerId].flag40)

View File

@ -455,12 +455,12 @@ bool8 AreAllMovesUnusable(void)
if (unusable == 0xF) // All moves are unusable.
{
gProtectStructs[gActiveBattler].onlyStruggle = 1;
gProtectStructs[gActiveBattler].noValidMoves = 1;
gSelectionBattleScripts[gActiveBattler] = BattleScript_NoMovesLeft;
}
else
{
gProtectStructs[gActiveBattler].onlyStruggle = 0;
gProtectStructs[gActiveBattler].noValidMoves = 0;
}
return (unusable == 0xF);

View File

@ -5582,19 +5582,19 @@ void BoxMonRestorePP(struct BoxPokemon *boxMon)
}
}
void sub_806E994(void)
void SetMonPreventsSwitchingString(void)
{
gLastUsedAbility = gBattleStruct->field_B0;
gLastUsedAbility = gBattleStruct->abilityPreventingSwitchout;
gBattleTextBuff1[0] = B_BUFF_PLACEHOLDER_BEGIN;
gBattleTextBuff1[1] = B_BUFF_MON_NICK_WITH_PREFIX;
gBattleTextBuff1[2] = gBattleStruct->field_49;
gBattleTextBuff1[2] = gBattleStruct->battlerPreventingSwitchout;
gBattleTextBuff1[4] = B_BUFF_EOS;
if (!GetBattlerSide(gBattleStruct->field_49))
gBattleTextBuff1[3] = pokemon_order_func(gBattlerPartyIndexes[gBattleStruct->field_49]);
if (GetBattlerSide(gBattleStruct->battlerPreventingSwitchout) == B_SIDE_PLAYER)
gBattleTextBuff1[3] = pokemon_order_func(gBattlerPartyIndexes[gBattleStruct->battlerPreventingSwitchout]);
else
gBattleTextBuff1[3] = gBattlerPartyIndexes[gBattleStruct->field_49];
gBattleTextBuff1[3] = gBattlerPartyIndexes[gBattleStruct->battlerPreventingSwitchout];
PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff2, gBattlerInMenuId, pokemon_order_func(gBattlerPartyIndexes[gBattlerInMenuId]))