Skip to content

Commit

Permalink
Document battle commands 0x60 - 0x8F
Browse files Browse the repository at this point in the history
  • Loading branch information
lhearachel committed Oct 29, 2023
1 parent 183a716 commit e933d09
Show file tree
Hide file tree
Showing 12 changed files with 1,700 additions and 1,120 deletions.
13 changes: 13 additions & 0 deletions include/battle/btlcmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ enum BattleScriptVars {
#define BTLSCR_SWITCHED_MON_AFTER 22
#define BTLSCR_MSG_TEMP (0xFF)

#define WEATHER_EFFECT_HYDRATION 1
#define WEATHER_EFFECT_SOLAR_POWER 2

enum OpCode {
IFOP_EQU = 0,
IFOP_NEQ,
Expand Down Expand Up @@ -148,5 +151,15 @@ enum StatusEffect {
STATUS_EFFECT_SUBSTITUTE_OFF,
};

enum MessageStatusCondition {
MSGCOND_SLEEP = 0,
MSGCOND_POISON,
MSGCOND_BURN,
MSGCOND_PARALYSIS,
MSGCOND_FREEZE,
MSGCOND_CONFUSION,
MSGCOND_INFATUATION,
};

#endif // POKEPLATINUM_BATTLE_BTLCMD_H

9 changes: 7 additions & 2 deletions include/battle/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

#define ATTACKING_MON (battleCtx->battleMons[battleCtx->attacker])
#define DEFENDING_MON (battleCtx->battleMons[battleCtx->defender])
#define ATTACKING_MOVE (battleCtx->moveSlot[battleCtx->attacker])
#define ATTACKER_ACTION (battleCtx->battlerActions[battleCtx->attacker])
#define FAINTED_MON (battleCtx->battleMons[battleCtx->faintedMon])

#define ATTACKER_MOVE_SLOT (battleCtx->moveSlot[battleCtx->attacker])
#define ATTACKER_ACTION (battleCtx->battlerActions[battleCtx->attacker])

#define ATTACKER_TURN_FLAGS (battleCtx->turnFlags[battleCtx->attacker])
#define DEFENDER_TURN_FLAGS (battleCtx->turnFlags[battleCtx->defender])
Expand Down Expand Up @@ -59,6 +61,9 @@

#define NO_CLOUD_NINE (BattleSystem_CountAbility(battleSys, battleCtx, COUNT_ALIVE_BATTLERS, 0, ABILITY_CLOUD_NINE) == FALSE \
&& BattleSystem_CountAbility(battleSys, battleCtx, COUNT_ALIVE_BATTLERS, 0, ABILITY_AIR_LOCK) == FALSE)
#define NO_WEATHER ((battleCtx->fieldConditionsMask & FIELD_CONDITION_WEATHER) == FALSE \
|| BattleSystem_CountAbility(battleSys, battleCtx, COUNT_ALIVE_BATTLERS, 0, ABILITY_CLOUD_NINE) \
|| BattleSystem_CountAbility(battleSys, battleCtx, COUNT_ALIVE_BATTLERS, 0, ABILITY_AIR_LOCK))
#define WEATHER_IS_RAIN (battleCtx->fieldConditionsMask & FIELD_CONDITION_RAINING)
#define WEATHER_IS_SAND (battleCtx->fieldConditionsMask & FIELD_CONDITION_SANDSTORM)
#define WEATHER_IS_SUN (battleCtx->fieldConditionsMask & FIELD_CONDITION_SUNNY)
Expand Down
6 changes: 6 additions & 0 deletions include/constants/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#define BATTLE_TYPE_NO_ABILITIES (BATTLE_TYPE_SAFARI | BATTLE_TYPE_PAL_PARK)
#define BATTLE_TYPE_2vs2_TAG (BATTLE_TYPE_2vs2 | BATTLE_TYPE_TAG)
#define BATTLE_TYPE_ALWAYS_CATCH (BATTLE_TYPE_PAL_PARK | BATTLE_TYPE_CATCH_TUTORIAL)
#define BATTLE_TYPE_RESTORE_ITEMS_AFTER (BATTLE_TYPE_LINK | BATTLE_TYPE_FRONTIER)

#define MAX_LINK_BATTLERS 4
#define MAX_BATTLERS 4
Expand Down Expand Up @@ -122,6 +123,11 @@
#define TYPE_MULTI_NOT_VERY_EFF 5
#define TYPE_MULTI_SUPER_EFF 20

#define SOUNDPROOF_SLOT_1 (1 << 0)
#define SOUNDPROOF_SLOT_2 (1 << 1)
#define NO_PARTNER_SLOT_1 (1 << 2)
#define NO_PARTNER_SLOT_2 (1 << 3)

enum BattleActions {
BATTLE_ACTION_PICK_COMMAND = 0,
BATTLE_ACTION_CHOOSE_TARGET,
Expand Down
1 change: 1 addition & 0 deletions include/constants/battle/moves.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
| MOVE_EFFECT_EMBARGO \
| MOVE_EFFECT_HEAL_BLOCK \
| MOVE_EFFECT_MAGNET_RISE)
#define MOVE_EFFECT_NO_WEATHER_DAMAGE (MOVE_EFFECT_UNDERGROUND | MOVE_EFFECT_UNDERWATER)

#define MOVE_EFFECT_LOCK_ON_SHIFT 3
#define MOVE_EFFECT_YAWN_SHIFT 11
Expand Down
8 changes: 8 additions & 0 deletions include/constants/battle/system_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@
#define SYSCTL_SKIP_STOLEN_CHECK (1 << 7)

#define SYSCTL_HIT_MULTIPLE_TARGETS (SYSCTL_SKIP_OBEDIENCE_CHECK | SYSCTL_SKIP_STATUS_CHECK | SYSCTL_SKIP_PP_DECREMENT)
#define SYSCTL_TWO_HITS (SYSCTL_SKIP_OBEDIENCE_CHECK | SYSCTL_SKIP_STATUS_CHECK | SYSCTL_SKIP_PP_DECREMENT)
#define SYSCTL_MULTI_HIT_MOVE (SYSCTL_SKIP_OBEDIENCE_CHECK \
| SYSCTL_SKIP_STATUS_CHECK \
| SYSCTL_SKIP_PP_DECREMENT \
| SYSCTL_SKIP_IMMUNITY_TRIGGERS \
| SYSCTL_SKIP_ACCURACY_CHECK \
| SYSCTL_SKIP_ACCURACY_OVERRIDES \
| SYSCTL_SKIP_STOLEN_CHECK)

#define BATTLER_STATUS_SWITCHING 1

Expand Down
3 changes: 3 additions & 0 deletions include/constants/narc_files/battle_skill_subseq.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ enum NARCFilesBattleSubSeq {

BATTLE_SUBSEQ_SAFEGUARD_END = 110,

BATTLE_SUBSEQ_BREAK_BIND_EFFECT = 116,
BATTLE_SUBSEQ_BLOW_AWAY_HAZARDS,

BATTLE_SUBSEQ_FUTURE_SIGHT_DAMAGE = 121,

BATTLE_SUBSEQ_MOVE_FAIL_TAUNTED = 133,
Expand Down
2 changes: 1 addition & 1 deletion include/overlay016/ov16_0225177C.h
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ BOOL BattleSystem_IsGhostCurse(BattleContext * param0, u16 param1, int param2);
* @return FALSE
*/
BOOL BattleSystem_CanStealItem(BattleSystem *battleSys, BattleContext *battleCtx, int battler);
BOOL ov16_022559DC(BattleContext * param0, int param1);
BOOL BattleSystem_NotHoldingMail(BattleContext * param0, int param1);

/**
* @brief Determine if a target can be Whirlwinded away by an attacker.
Expand Down
2 changes: 1 addition & 1 deletion include/overlay016/ov16_0226485C.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void BattleIO_RefreshHPGauge(BattleSystem * param0, BattleContext * param1, int
void BattleIO_UpdatePartyMon(BattleSystem * param0, BattleContext * param1, int param2);
void ov16_02266460(BattleSystem * param0, int param1);
void BattleIO_StopGaugeAnimation(BattleSystem *battleSys, int battler);
void ov16_02266498(BattleSystem * param0, BattleContext * param1, int param2, int param3);
void BattleIO_RefreshPartyStatus(BattleSystem * param0, BattleContext * param1, int param2, int param3);
void BattleIO_ForgetMove(BattleSystem * param0, int param1, int param2, int param3);
void ov16_022664F8(BattleSystem * param0, int param1, int param2, int param3);
void ov16_0226651C(BattleSystem * param0, int param1);
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 @@ -2211,7 +2211,7 @@ static int BattleController_CheckObedience(BattleSystem *battleSys, BattleContex

rand1 = ((BattleSystem_RandNext(battleSys) & 0xFF) * (ATTACKING_MON.level + maxLevel)) >> 8;
if (rand1 < maxLevel) {
rand1 = BattleSystem_CheckStruggling(battleSys, battleCtx, battleCtx->attacker, FlagIndex(ATTACKING_MOVE), STRUGGLE_CHECK_ALL);
rand1 = BattleSystem_CheckStruggling(battleSys, battleCtx, battleCtx->attacker, FlagIndex(ATTACKER_MOVE_SLOT), STRUGGLE_CHECK_ALL);

if (rand1 == 0xF) {
*nextSeq = BATTLE_SUBSEQ_DISOBEY_DO_NOTHING;
Expand All @@ -2222,8 +2222,8 @@ static int BattleController_CheckObedience(BattleSystem *battleSys, BattleContex
rand2 = BattleSystem_RandNext(battleSys) & 3;
} while (rand1 & FlagIndex(rand2));

ATTACKING_MOVE = rand2;
battleCtx->moveTemp = ATTACKING_MON.moves[ATTACKING_MOVE];
ATTACKER_MOVE_SLOT = rand2;
battleCtx->moveTemp = ATTACKING_MON.moves[ATTACKER_MOVE_SLOT];
battleCtx->moveCur = battleCtx->moveTemp;
battleCtx->defender = BattleSystem_Defender(battleSys, battleCtx, battleCtx->attacker, battleCtx->moveTemp, TRUE, 0);

Expand Down
Loading

0 comments on commit e933d09

Please sign in to comment.