diff --git a/asm/macros/btlcmd.inc b/asm/macros/btlcmd.inc index dbc6c8f05b..14a1d0fd06 100644 --- a/asm/macros/btlcmd.inc +++ b/asm/macros/btlcmd.inc @@ -1,11 +1,26 @@ .ifndef ASM_BATTLE_SCRIPT_INC .set ASM_BATTLE_SCRIPT_INC, 1 #define __ASM_PM_ + #include "constants/battle.h" +#include "constants/items.h" +#include "constants/species.h" #include "gmm/pl_msg_0368.h" #include "battle/btlcmd.h" + + .include "consts/generated/asm/abilities.inc" .include "consts/generated/asm/battle.inc" + .include "consts/generated/asm/battle_controller_params.inc" + .include "consts/generated/asm/battle_lib_params.inc" + .include "consts/generated/asm/battle_subscripts.inc" .include "consts/generated/asm/btlcmd.inc" + .include "consts/generated/asm/gender.inc" + .include "consts/generated/asm/items.inc" + .include "consts/generated/asm/moves.inc" + .include "consts/generated/asm/pokemon.inc" + + .equ FALSE 0 + .equ TRUE 1 .macro PlayEncounterAnimation .long 0 diff --git a/consts/battle.json b/consts/battle.json index 3cbe7521af..8916b8fb48 100644 --- a/consts/battle.json +++ b/consts/battle.json @@ -16,7 +16,10 @@ "@MessageStatusCondition", "@TurnFlag", "@CheckSideConditionOp", - "@SideCondition" + "@SideCondition", + "@Throw", + "@Capture", + "@YesNoType" ], "battle_lib_params": [ "@BattleContextParam", @@ -925,6 +928,34 @@ "AFTER_MOVE_MESSAGE_ONE_HIT", "AFTER_MOVE_MESSAGE_MULTI_HIT" ] + }, + "@Throw": { + "type": "enum", + "values": [ + "BTLSCR_THROW_POKE_BALL", + "BTLSCR_THROW_SAFARI_BALL", + "BTLSCR_THROW_SAFARI_ROCK", + "BTLSCR_THROW_SAFARI_BAIT", + "BTLSCR_THROW_PARK_BALL" + ] + }, + "@Capture": { + "type": "enum", + "values": [ + "CAPTURE_NORMAL", + "CAPTURE_SAFARI" + ] + }, + "@YesNoType": { + "type": "enum", + "values": [ + "YES_NO_BASIC", + "YES_NO_FORGET_MOVE", + "YES_NO_GIVE_UP_ON_MOVE", + "YES_NO_NEXT_MON", + "YES_NO_CHANGE_MON", + "YES_NO_GIVE_NICKNAME" + ] } } } diff --git a/include/battle/btlcmd.h b/include/battle/btlcmd.h index b23bda55ce..898cd9b72b 100644 --- a/include/battle/btlcmd.h +++ b/include/battle/btlcmd.h @@ -5,6 +5,12 @@ #include "consts/generated/c/btlcmd.h" #endif +// TODO: move these to constgen +#define TRAINER_MESSAGE_LOSE 1 +#define TRAINER_MESSAGE_LOSE_1 4 +#define TRAINER_MESSAGE_LOSE_2 8 +#define TRAINER_MESSAGE_WIN 100 + #define BTLSCR_MSG_TEMP (0xFF) #define WEATHER_EFFECT_HYDRATION 1 diff --git a/include/constants/battle/condition.h b/include/constants/battle/condition.h index ab7b6c8922..5744564e33 100644 --- a/include/constants/battle/condition.h +++ b/include/constants/battle/condition.h @@ -2,31 +2,51 @@ #define POKEPLATINUM_CONSTANTS_BATTLE_CONDITION_H #define MON_CONDITION_NONE 0 -#define MON_CONDITION_SLEEP ((1 << 0) | (1 << 1) | (1 << 2)) // counter for the number of sleep turns remaining +#define MON_CONDITION_SLEEP_0 (1 << 0) +#define MON_CONDITION_SLEEP_1 (1 << 1) +#define MON_CONDITION_SLEEP_2 (1 << 2) #define MON_CONDITION_POISON (1 << 3) #define MON_CONDITION_BURN (1 << 4) #define MON_CONDITION_FREEZE (1 << 5) #define MON_CONDITION_PARALYSIS (1 << 6) #define MON_CONDITION_TOXIC (1 << 7) -#define MON_CONDITION_TOXIC_COUNTER ((1 << 8) | (1 << 9) | (1 << 10) | (1 << 11)) // counter for increasing Toxic damage -#define MON_CONDITION_TOXIC_COUNT_INC ((1 << 8)) // increment value for the Toxic counter +#define MON_CONDITION_TOXIC_COUNTER_0 (1 << 8) +#define MON_CONDITION_TOXIC_COUNTER_1 (1 << 9) +#define MON_CONDITION_TOXIC_COUNTER_2 (1 << 10) +#define MON_CONDITION_TOXIC_COUNTER_3 (1 << 11) +#define MON_CONDITION_TOXIC_COUNT_INC MON_CONDITION_TOXIC_COUNTER_0 + +#define MON_CONDITION_SLEEP (MON_CONDITION_SLEEP_0 | MON_CONDITION_SLEEP_1 | MON_CONDITION_SLEEP_2) +#define MON_CONDITION_TOXIC_COUNTER (MON_CONDITION_TOXIC_COUNTER_0 | MON_CONDITION_TOXIC_COUNTER_1 | MON_CONDITION_TOXIC_COUNTER_2 | MON_CONDITION_TOXIC_COUNTER_3) #define MON_CONDITION_ANY_POISON (MON_CONDITION_POISON | MON_CONDITION_TOXIC | MON_CONDITION_TOXIC_COUNTER) #define MON_CONDITION_ANY (MON_CONDITION_SLEEP | MON_CONDITION_POISON | MON_CONDITION_BURN | MON_CONDITION_FREEZE | MON_CONDITION_PARALYSIS | MON_CONDITION_TOXIC) +#define MON_CONDITION_NOT_SLEEP ~MON_CONDITION_SLEEP #define MON_CONDITION_CAN_SYNCHRONIZE (MON_CONDITION_POISON | MON_CONDITION_BURN | MON_CONDITION_PARALYSIS) #define MON_CONDITION_FACADE_BOOST (MON_CONDITION_TOXIC | MON_CONDITION_POISON | MON_CONDITION_BURN | MON_CONDITION_PARALYSIS) #define VOLATILE_CONDITION_NONE 0 -#define VOLATILE_CONDITION_CONFUSION ((1 << 0) | (1 << 1) | (1 << 2)) // counter for the number of confusion turns remaining +#define VOLATILE_CONDITION_CONFUSION_0 (1 << 0) +#define VOLATILE_CONDITION_CONFUSION_1 (1 << 1) +#define VOLATILE_CONDITION_CONFUSION_2 (1 << 2) #define VOLATILE_CONDITION_FLINCH (1 << 3) -#define VOLATILE_CONDITION_UPROAR ((1 << 4) | (1 << 5) | (1 << 6)) // counter for the number of Uproar turns remaining +#define VOLATILE_CONDITION_UPROAR_0 (1 << 4) +#define VOLATILE_CONDITION_UPROAR_1 (1 << 5) +#define VOLATILE_CONDITION_UPROAR_2 (1 << 6) // 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_BIDE_0 (1 << 8) +#define VOLATILE_CONDITION_BIDE_1 (1 << 9) +#define VOLATILE_CONDITION_THRASH_0 (1 << 10) +#define VOLATILE_CONDITION_THRASH_1 (1 << 11) #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_BIND_0 (1 << 13) +#define VOLATILE_CONDITION_BIND_1 (1 << 14) +#define VOLATILE_CONDITION_BIND_2 (1 << 15) +#define VOLATILE_CONDITION_ATTRACT_0 (1 << 16) +#define VOLATILE_CONDITION_ATTRACT_1 (1 << 17) +#define VOLATILE_CONDITION_ATTRACT_2 (1 << 18) +#define VOLATILE_CONDITION_ATTRACT_3 (1 << 19) #define VOLATILE_CONDITION_FOCUS_ENERGY (1 << 20) #define VOLATILE_CONDITION_TRANSFORM (1 << 21) #define VOLATILE_CONDITION_RECHARGING (1 << 22) @@ -40,6 +60,13 @@ #define VOLATILE_CONDITION_DEFENSE_CURL (1 << 30) #define VOLATILE_CONDITION_TORMENT (1 << 31) +#define VOLATILE_CONDITION_CONFUSION (VOLATILE_CONDITION_CONFUSION_0 | VOLATILE_CONDITION_CONFUSION_1 | VOLATILE_CONDITION_CONFUSION_2) +#define VOLATILE_CONDITION_UPROAR (VOLATILE_CONDITION_UPROAR_0 | VOLATILE_CONDITION_UPROAR_1 | VOLATILE_CONDITION_UPROAR_2) +#define VOLATILE_CONDITION_BIDE (VOLATILE_CONDITION_BIDE_0 | VOLATILE_CONDITION_BIDE_1) +#define VOLATILE_CONDITION_THRASH (VOLATILE_CONDITION_THRASH_0 | VOLATILE_CONDITION_THRASH_1) +#define VOLATILE_CONDITION_BIND (VOLATILE_CONDITION_BIND_0 | VOLATILE_CONDITION_BIND_1 | VOLATILE_CONDITION_BIND_2) +#define VOLATILE_CONDITION_ATTRACT (VOLATILE_CONDITION_ATTRACT_0 | VOLATILE_CONDITION_ATTRACT_1 | VOLATILE_CONDITION_ATTRACT_2 | VOLATILE_CONDITION_ATTRACT_3) + #define VOLATILE_CONDITION_BATON_PASSED (VOLATILE_CONDITION_FOCUS_ENERGY \ | VOLATILE_CONDITION_MEAN_LOOK \ | VOLATILE_CONDITION_CONFUSION \ @@ -55,21 +82,27 @@ #define VOLATILE_CONDITION_BIND_SHIFT 13 #define VOLATILE_CONDITION_ATTRACT_SHIFT 16 -#define SIDE_CONDITION_REFLECT (1 << 0) -#define SIDE_CONDITION_LIGHT_SCREEN (1 << 1) -#define SIDE_CONDITION_SPIKES (1 << 2) -#define SIDE_CONDITION_SAFEGUARD (1 << 3) -#define SIDE_CONDITION_FUTURE_SIGHT (1 << 4) -#define SIDE_CONDITION_WISH (1 << 5) -#define SIDE_CONDITION_MIST (1 << 6) -#define SIDE_CONDITION_STEALTH_ROCK (1 << 7) -#define SIDE_CONDITION_TAILWIND ((1 << 8) | (1 << 9)) // counter for the number of Tailwind turns remaining -#define SIDE_CONDITION_TOXIC_SPIKES (1 << 10) +#define SIDE_CONDITION_REFLECT (1 << 0) +#define SIDE_CONDITION_LIGHT_SCREEN (1 << 1) +#define SIDE_CONDITION_SPIKES (1 << 2) +#define SIDE_CONDITION_SAFEGUARD (1 << 3) +#define SIDE_CONDITION_FUTURE_SIGHT (1 << 4) +#define SIDE_CONDITION_WISH (1 << 5) +#define SIDE_CONDITION_MIST (1 << 6) +#define SIDE_CONDITION_STEALTH_ROCK (1 << 7) +#define SIDE_CONDITION_TAILWIND_0 (1 << 8) +#define SIDE_CONDITION_TAILWIND_1 (1 << 9) +#define SIDE_CONDITION_TOXIC_SPIKES (1 << 10) // unused flag: 1 << 11 -#define SIDE_CONDITION_LUCKY_CHANT ((1 << 12) | (1 << 13) | (1 << 14)) // counter for the number of Lucky Chant turns remaining +#define SIDE_CONDITION_LUCKY_CHANT_0 (1 << 12) +#define SIDE_CONDITION_LUCKY_CHANT_1 (1 << 13) +#define SIDE_CONDITION_LUCKY_CHANT_2 (1 << 14) -#define SIDE_CONDITION_TAILWIND_SHIFT (1 << 8) -#define SIDE_CONDITION_LUCKY_CHANT_SHIFT (1 << 12) +#define SIDE_CONDITION_TAILWIND (SIDE_CONDITION_TAILWIND_0 | SIDE_CONDITION_TAILWIND_1) +#define SIDE_CONDITION_LUCKY_CHANT (SIDE_CONDITION_LUCKY_CHANT_0 | SIDE_CONDITION_LUCKY_CHANT_1 | SIDE_CONDITION_LUCKY_CHANT_2) + +#define SIDE_CONDITION_TAILWIND_SHIFT SIDE_CONDITION_TAILWIND_0 +#define SIDE_CONDITION_LUCKY_CHANT_SHIFT SIDE_CONDITION_LUCKY_CHANT_0 #define FIELD_CONDITION_RAINING_TEMP (1 << 0) #define FIELD_CONDITION_RAINING_PERM (1 << 1) @@ -80,9 +113,13 @@ #define FIELD_CONDITION_HAILING_TEMP (1 << 6) #define FIELD_CONDITION_HAILING_PERM (1 << 7) #define FIELD_CONDITION_UPROAR ((1 << 8) | (1 << 9) | (1 << 10) | (1 << 11)) // mask for which clients are in an Uproar -#define FIELD_CONDITION_GRAVITY ((1 << 12) | (1 << 13) | (1 << 14)) // counter for the number of Gravity turns remaining +#define FIELD_CONDITION_GRAVITY_0 (1 << 12) +#define FIELD_CONDITION_GRAVITY_1 (1 << 13) +#define FIELD_CONDITION_GRAVITY_2 (1 << 14) #define FIELD_CONDITION_DEEP_FOG (1 << 15) -#define FIELD_CONDITION_TRICK_ROOM ((1 << 16) | (1 << 17) | (1 << 18)) // counter for the number of Trick Room turns remaining +#define FIELD_CONDITION_TRICK_ROOM_0 (1 << 16) +#define FIELD_CONDITION_TRICK_ROOM_1 (1 << 17) +#define FIELD_CONDITION_TRICK_ROOM_2 (1 << 18) #define FIELD_CONDITION_RAINING (FIELD_CONDITION_RAINING_TEMP | FIELD_CONDITION_RAINING_PERM) #define FIELD_CONDITION_SANDSTORM (FIELD_CONDITION_SANDSTORM_TEMP | FIELD_CONDITION_SANDSTORM_PERM) @@ -99,6 +136,11 @@ | FIELD_CONDITION_DEEP_FOG) #define FIELD_CONDITION_CASTFORM (FIELD_CONDITION_RAINING | FIELD_CONDITION_SUNNY | FIELD_CONDITION_HAILING) +#define FIELD_CONDITION_GRAVITY (FIELD_CONDITION_GRAVITY_0 | FIELD_CONDITION_GRAVITY_1 | FIELD_CONDITION_GRAVITY_2) +#define FIELD_CONDITION_GRAVITY_INIT (FIELD_CONDITION_GRAVITY_0 | FIELD_CONDITION_GRAVITY_2) +#define FIELD_CONDITION_TRICK_ROOM (FIELD_CONDITION_TRICK_ROOM_0 | FIELD_CONDITION_TRICK_ROOM_1 | FIELD_CONDITION_TRICK_ROOM_2) +#define FIELD_CONDITION_TRICK_ROOM_INIT (FIELD_CONDITION_TRICK_ROOM_0 | FIELD_CONDITION_TRICK_ROOM_2) + #define FIELD_CONDITION_UPROAR_SHIFT 8 #define FIELD_CONDITION_GRAVITY_SHIFT 12 #define FIELD_CONDITION_TRICK_ROOM_SHIFT 16 diff --git a/include/constants/battle/moves.h b/include/constants/battle/moves.h index cd88831fd5..ed0d465e55 100644 --- a/include/constants/battle/moves.h +++ b/include/constants/battle/moves.h @@ -2,16 +2,19 @@ #define POKEPLATINUM_CONSTANTS_BATTLE_MOVES_H #define MOVE_EFFECT_NONE 0 -#define MOVE_EFFECT_LEECH_SEED_RECIPIENT ((1 << 0) | (1 << 1)) // each bit defines which opponent receives the healing effect +#define MOVE_EFFECT_LEECH_SEED_RECIPIENT_0 (1 << 0) +#define MOVE_EFFECT_LEECH_SEED_RECIPIENT_1 (1 << 1) #define MOVE_EFFECT_LEECH_SEED (1 << 2) -#define MOVE_EFFECT_LOCK_ON ((1 << 3) | (1 << 4)) // counter for the number of Lock On turns remaining +#define MOVE_EFFECT_LOCK_ON_0 (1 << 3) +#define MOVE_EFFECT_LOCK_ON_1 (1 << 4) #define MOVE_EFFECT_PERISH_SONG (1 << 5) #define MOVE_EFFECT_AIRBORNE (1 << 6) // Fly, Bounce #define MOVE_EFFECT_UNDERGROUND (1 << 7) // Dig #define MOVE_EFFECT_MINIMIZE (1 << 8) #define MOVE_EFFECT_CHARGE (1 << 9) #define MOVE_EFFECT_INGRAIN (1 << 10) -#define MOVE_EFFECT_YAWN ((1 << 11) | (1 << 12)) +#define MOVE_EFFECT_YAWN_0 (1 << 11) +#define MOVE_EFFECT_YAWN_1 (1 << 12) #define MOVE_EFFECT_IMPRISON (1 << 13) // applied to mons which use Imprison #define MOVE_EFFECT_GRUDGE (1 << 14) #define MOVE_EFFECT_NO_CRITICAL (1 << 15) // checked for, but never set @@ -31,6 +34,10 @@ #define MOVE_EFFECT_SHADOW_FORCE (1 << 29) #define MOVE_EFFECT_IMPRISONED (1 << 30) // applied to mons which are affected by Imprison +#define MOVE_EFFECT_LEECH_SEED_RECIPIENT (MOVE_EFFECT_LEECH_SEED_RECIPIENT_0 | MOVE_EFFECT_LEECH_SEED_RECIPIENT_1) +#define MOVE_EFFECT_LOCK_ON (MOVE_EFFECT_LOCK_ON_0 | MOVE_EFFECT_LOCK_ON_1) +#define MOVE_EFFECT_YAWN (MOVE_EFFECT_YAWN_0 | MOVE_EFFECT_YAWN_1) + #define MOVE_EFFECT_SEMI_INVULNERABLE (MOVE_EFFECT_AIRBORNE | MOVE_EFFECT_UNDERGROUND | MOVE_EFFECT_UNDERWATER | MOVE_EFFECT_SHADOW_FORCE) #define MOVE_EFFECT_BATON_PASSED (MOVE_EFFECT_LEECH_SEED_RECIPIENT | MOVE_EFFECT_LEECH_SEED | MOVE_EFFECT_LOCK_ON | MOVE_EFFECT_PERISH_SONG | MOVE_EFFECT_INGRAIN \ diff --git a/include/constants/battle/system_control.h b/include/constants/battle/system_control.h index 022377f8cf..33a7992288 100644 --- a/include/constants/battle/system_control.h +++ b/include/constants/battle/system_control.h @@ -42,16 +42,19 @@ #define SYSCTL_MON_FAINTED_SHIFT 24 #define SYSCTL_MON_SELFDESTRUCTED_SHIFT 28 +#define SYSCTL_NO_EXPERIENCE_GIVEN (1 << 0) #define SYSCTL_UPDATE_STAT_STAGES (1 << 1) #define SYSCTL_ATTACK_MESSAGE_SHOWN (1 << 2) #define SYSCTL_MAGIC_COAT_REFLECTED (1 << 3) #define SYSCTL_UTURN_ACTIVE (1 << 4) #define SYSCTL_FIRST_DAMAGE_MSG_SHOWN (1 << 5) #define SYSCTL_MOVE_SUCCEEDED (1 << 6) // this only reflects that the move is executed, not whether it hit or missed +#define SYSCTL_STAT_STAGE_CHANGE_SHOWN (1 << 7) #define SYSCTL_RECOVER_HP_VISUAL (1 << 8) #define SYSCTL_FORM_CHANGE (1 << 26) +#define SYSCTL_RECALC_MON_STATS (1 << 27) -#define SYSCTL_LINK_WAITING ((1 << 24) | (1 << 25) | SYSCTL_FORM_CHANGE | (1 << 27)) +#define SYSCTL_LINK_WAITING ((1 << 24) | (1 << 25) | SYSCTL_FORM_CHANGE | SYSCTL_RECALC_MON_STATS) #define SYSCTL_PAYOUT_EXP ((1 << 28) | (1 << 29) | (1 << 30) | (1 << 31)) #define SYSCTL_INIT2 (~(SYSCTL_UPDATE_STAT_STAGES \ diff --git a/include/constants/battle/turn_flags.h b/include/constants/battle/turn_flags.h index 57ecef3418..c74379d96b 100644 --- a/include/constants/battle/turn_flags.h +++ b/include/constants/battle/turn_flags.h @@ -1,6 +1,7 @@ #ifndef POKEPLATINUM_CONSTANTS_BATTLE_TURN_FLAGS_H #define POKEPLATINUM_CONSTANTS_BATTLE_TURN_FLAGS_H +#define SELF_TURN_FLAG_CLEAR 0 // unused: 1 << 0 #define SELF_TURN_FLAG_PLUCK_BERRY (1 << 1) #define SELF_TURN_FLAG_INFATUATED (1 << 2)