Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document battle commands 0x34 - 0x43 #92

Merged
merged 6 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/battle/battle_mon.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ typedef struct BattleMon {
u16 OTName[TRAINER_NAME_LEN + 1];

u32 exp;
u32 pid;
u32 personality;
u32 status;
u32 statusVolatile;
u32 OTId;
Expand Down
5 changes: 5 additions & 0 deletions include/battle/btlcmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ enum OpCode {
VALOP_AND,
};

enum CheckAbilityOp {
CHECK_ABILITY_HAVE,
CHECK_ABILITY_NONE,
};

enum StatusEffect {
STATUS_EFFECT_LEVEL_UP = 8,

Expand Down
2 changes: 1 addition & 1 deletion include/battle/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#define NO_TARGET_MULTI_TURN (battleCtx->defender == BATTLER_NONE \
&& BattleMove_IsMultiTurn(battleCtx, battleCtx->moveCur) == TRUE \
&& ( \
(ATTACKING_MON.statusVolatile & VOLATILE_CONDITION_CHARGE_TURN) \
(ATTACKING_MON.statusVolatile & VOLATILE_CONDITION_MOVE_LOCKED) \
|| (battleCtx->battleStatusMask & SYSCTL_LAST_OF_MULTI_TURN) \
))
#define NO_TARGET (NO_TARGET_SINGLE_TURN || NO_TARGET_MULTI_TURN)
Expand Down
2 changes: 1 addition & 1 deletion include/constants/battle/condition.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
// unused flag: 1 << 7
#define VOLATILE_CONDITION_BIDE ((1 << 8) | (1 << 9)) // counter for the number of Bide turns remaining
#define VOLATILE_CONDITION_THRASH ((1 << 10) | (1 << 11)) // counter for the number of Thrash turns remaining
#define VOLATILE_CONDITION_CHARGE_TURN (1 << 12)
#define VOLATILE_CONDITION_MOVE_LOCKED (1 << 12)
#define VOLATILE_CONDITION_BIND ((1 << 13) | (1 << 14) | (1 << 15)) // counter for the number of Bind turns remaining
#define VOLATILE_CONDITION_ATTRACT ((1 << 16) | (1 << 17) | (1 << 18) | (1 << 19)) // each bit here defines which battlers the mon is infatuated with
#define VOLATILE_CONDITION_FOCUS_ENERGY (1 << 20)
Expand Down
44 changes: 40 additions & 4 deletions include/overlay016/ov16_0225177C.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,16 @@ void BattleIO_ClearBuffer(BattleContext *battleCtx, int battler);
* presented via outBuf
*/
int BattleMon_Get(BattleContext *battleCtx, int battler, enum BattleMonParam paramID, void *buf);
void ov16_022523E8(BattleContext * param0, int param1, int param2, const void * param3);

/**
* @brief Set a data field value for a given battler.
*
* @param battleCtx
* @param battler The requested battler
* @param paramID ID of the field to retrieve from the battler
* @param buf Buffer input for the value to be set
*/
void BattleMon_Set(BattleContext *battleCtx, int battler, enum BattleMonParam paramID, const void *buf);
void ov16_02252A14(BattleContext * param0, int param1, int param2, int param3);
void ov16_02252A2C(BattleMon * param0, int param1, int param2);
u8 BattleSystem_CompareBattlerSpeed(BattleSystem * param0, BattleContext * param1, int param2, int param3, int param4);
Expand Down Expand Up @@ -258,8 +267,27 @@ int BattleSystem_Defender(BattleSystem *battleSys, BattleContext *battleCtx, int
void BattleSystem_RedirectTarget(BattleSystem * param0, BattleContext * param1, int param2, u16 param3);
BOOL BattleMove_TriggerRedirectionAbilities(BattleSystem * param0, BattleContext * param1);
void BattleMon_CopyToParty(BattleSystem * param0, BattleContext * param1, int param2);
void ov16_02253EF0(BattleSystem * param0, BattleContext * param1, int param2);
void BattleSystem_BreakMultiTurn(BattleSystem * param0, BattleContext * param1, int param2);

/**
* @brief Locks the battler into their current move.
*
* @param battleSys
* @param battleCtx
* @param battler
*/
void Battler_LockMoveChoice(BattleSystem *battleSys, BattleContext *battleCtx, int battler);

/**
* @brief Unlocks the battler's future move choices.
*
* This will also, as a convenience, toggle off the flags for Bide and semi-
* invulnerable moves and reset the counters for Rollout and Fury Cutter.
*
* @param battleSys
* @param battleCtx
* @param battler
*/
void Battler_UnlockMoveChoice(BattleSystem *battleSys, BattleContext *battleCtx, int battler);
int ov16_02253F7C(BattleContext * param0, int param1);
BOOL BattleSystem_CheckTrainerMessage(BattleSystem * param0, BattleContext * param1);
void BattleContext_Init(BattleContext * param0);
Expand Down Expand Up @@ -531,7 +559,15 @@ int BattleSystem_CalcDamageVariance(BattleSystem *battleSys, BattleContext *batt
int BattleSystem_CalcCriticalMulti(BattleSystem *battleSys, BattleContext *battleCtx, int attacker, int defender, int criticalStage, u32 sideConditions);
BOOL ov16_0225AFF4(u16 param0);
BOOL ov16_0225B02C(BattleSystem * param0, BattleContext * param1, int param2, u16 param3);
BOOL ov16_0225B084(BattleContext * param0, u16 param1);

/**
* @brief Check if a given move can be Encored.
*
* @param battleCtx
* @param move
* @return TRUE if the move can be Encored, FALSE otherwise.
*/
BOOL BattleSystem_CanEncoreMove(BattleContext *battleCtx, u16 move);
BOOL ov16_0225B0C0(BattleContext * param0, u16 param1);

/**
Expand Down
6 changes: 3 additions & 3 deletions include/overlay016/ov16_0226485C.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ void BattleIO_UpdateExpGauge(BattleSystem * param0, BattleContext * param1, int
void BattleIO_PlayFaintingSequence(BattleSystem * param0, BattleContext * param1, int param2);
void BattleIO_PlaySound(BattleSystem * param0, BattleContext * param1, int param2, int param3);
void BattleIO_FadeOut(BattleSystem * param0, BattleContext * param1);
void ov16_02265EE8(BattleSystem * param0, int param1, int param2);
void ov16_02265FB8(BattleSystem * param0, int param1, int param2);
void ov16_02265FD8(BattleSystem * param0, int param1, int param2);
void BattleIO_ToggleVanish(BattleSystem * param0, int param1, int param2);
void BattleIO_SetStatusIcon(BattleSystem * param0, int param1, int param2);
void BattleIO_TrainerMessage(BattleSystem * param0, int param1, int param2);
void BattleIO_PlayStatusEffect(BattleSystem * param0, BattleContext * param1, int param2, int param3);
void ov16_02266028(BattleSystem * param0, BattleContext * param1, int param2, int param3, int param4);
void ov16_02266058(BattleSystem * param0, BattleContext * param1, int param2, int param3);
Expand Down
6 changes: 3 additions & 3 deletions src/overlay016/battle_controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -2328,7 +2328,7 @@ static BOOL BattleController_DecrementPP(BattleSystem *battleSys, BattleContext
}
} else if (ATTACKING_MON.ppCur[moveSlot] == 0
&& (battleCtx->battleStatusMask & SYSCTL_LAST_OF_MULTI_TURN) == FALSE
&& (ATTACKING_MON.statusVolatile & VOLATILE_CONDITION_CHARGE_TURN) == FALSE
&& (ATTACKING_MON.statusVolatile & VOLATILE_CONDITION_MOVE_LOCKED) == FALSE
&& (ATTACKING_MON.statusVolatile & VOLATILE_CONDITION_THRASH) == FALSE
&& MON_IS_UPROARING(battleCtx->attacker) == FALSE
&& moveSlot < LEARNED_MOVES_MAX) {
Expand Down Expand Up @@ -2371,7 +2371,7 @@ static BOOL BattleController_HasNoTarget(BattleSystem *battleSys, BattleContext
&& result == FALSE
&& solarMove == FALSE
&& Battler_HeldItemEffect(battleCtx, battleCtx->attacker) != HOLD_EFFECT_CHARGE_SKIP
&& (ATTACKING_MON.statusVolatile & VOLATILE_CONDITION_CHARGE_TURN) == FALSE) {
&& (ATTACKING_MON.statusVolatile & VOLATILE_CONDITION_MOVE_LOCKED) == FALSE) {
battleCtx->defender = battleCtx->attacker;
}

Expand Down Expand Up @@ -3051,7 +3051,7 @@ static int BattleController_CheckMoveHitOverrides(BattleSystem *battleSys, Battl
&& (MOVE_DATA(move).flags & MOVE_FLAG_CAN_PROTECT)
&& (move != MOVE_CURSE || BattleSystem_IsGhostCurse(battleCtx, move, attacker) == TRUE) // Ghost-Curse can be Protected
&& (BattleMove_IsMultiTurn(battleCtx, move) == FALSE || (battleCtx->battleStatusMask & SYSCTL_LAST_OF_MULTI_TURN))) {
BattleSystem_BreakMultiTurn(battleSys, battleCtx, attacker);
Battler_UnlockMoveChoice(battleSys, battleCtx, attacker);
battleCtx->moveStatusFlags |= MOVE_STATUS_PROTECTED;
return 0;
}
Expand Down
Loading