pokeemerald/include/battle.h

993 lines
30 KiB
C
Raw Normal View History

#ifndef GUARD_BATTLE_H
#define GUARD_BATTLE_H
2017-10-06 17:06:45 +02:00
// should they be included here or included individually by every file?
#include "battle_util.h"
#include "battle_script_commands.h"
2018-01-16 23:15:02 +01:00
#include "battle_main.h"
2017-10-10 21:45:07 +02:00
#include "battle_ai_switch_items.h"
2017-11-04 16:11:13 +01:00
#include "battle_gfx_sfx_util.h"
2017-11-12 16:39:21 +01:00
#include "battle_util2.h"
2017-12-17 20:10:57 +01:00
#include "battle_bg.h"
2017-10-06 17:06:45 +02:00
2017-09-26 22:39:59 +02:00
/*
2018-01-16 21:01:31 +01:00
* A battler may be in one of four positions on the field. The first bit determines
* what side the battler is on, either the player's side or the opponent's side.
2018-02-06 23:09:39 +01:00
* The second bit determines what flank the battler is on, either the left or right.
* Note that the opponent's flanks are drawn corresponding to their perspective, so
* their right mon appears on the left, and their left mon appears on the right.
* The battler ID is usually the same as the position, except in the case of link battles.
2018-01-16 21:01:31 +01:00
*
2018-02-06 02:46:59 +01:00
* + ------------------------- +
2018-02-06 23:09:39 +01:00
* | Opponent's side |
* | Right Left |
2018-02-06 02:46:59 +01:00
* | 3 1 |
* | |
* | Player's side |
2018-02-06 23:09:39 +01:00
* | Left Right |
2018-02-06 02:46:59 +01:00
* | 0 2 |
* ----------------------------+
* | |
* | |
* +---------------------------+
2018-01-16 21:01:31 +01:00
*/
2017-09-26 22:39:59 +02:00
2018-02-06 02:46:59 +01:00
#define MAX_BATTLERS_COUNT 4
2017-09-17 14:10:32 +02:00
2018-01-16 21:01:31 +01:00
#define B_POSITION_PLAYER_LEFT 0
#define B_POSITION_OPPONENT_LEFT 1
#define B_POSITION_PLAYER_RIGHT 2
#define B_POSITION_OPPONENT_RIGHT 3
2017-09-26 22:39:59 +02:00
2018-02-06 23:09:39 +01:00
// These macros can be used with either battler ID or positions to get the partner or the opposite mon
#define BATTLE_OPPOSITE(id) ((id) ^ 1)
#define BATTLE_PARTNER(id) ((id) ^ 2)
2018-01-16 22:12:38 +01:00
2018-02-06 02:46:59 +01:00
#define B_SIDE_PLAYER 0
#define B_SIDE_OPPONENT 1
2017-09-26 22:39:59 +02:00
2018-02-06 23:09:39 +01:00
#define B_FLANK_LEFT 0
#define B_FLANK_RIGHT 1
2018-02-06 02:46:59 +01:00
#define BIT_SIDE 1
#define BIT_FLANK 2
2017-09-26 22:39:59 +02:00
2018-02-06 02:46:59 +01:00
#define GET_BATTLER_POSITION(battler) (gBattlerPositions[battler])
#define GET_BATTLER_SIDE(battler) (GetBattlerPosition(battler) & BIT_SIDE)
#define GET_BATTLER_SIDE2(battler) (GET_BATTLER_POSITION(battler) & BIT_SIDE)
2018-01-16 22:12:38 +01:00
// Battle Type Flags
2017-09-26 22:39:59 +02:00
#define BATTLE_TYPE_DOUBLE 0x0001
#define BATTLE_TYPE_LINK 0x0002
#define BATTLE_TYPE_WILD 0x0004
#define BATTLE_TYPE_TRAINER 0x0008
#define BATTLE_TYPE_FIRST_BATTLE 0x0010
#define BATTLE_TYPE_20 0x0020
2017-09-02 16:03:53 +02:00
#define BATTLE_TYPE_MULTI 0x0040
#define BATTLE_TYPE_SAFARI 0x0080
#define BATTLE_TYPE_BATTLE_TOWER 0x0100
#define BATTLE_TYPE_WALLY_TUTORIAL 0x0200
#define BATTLE_TYPE_ROAMER 0x0400
#define BATTLE_TYPE_EREADER_TRAINER 0x0800
#define BATTLE_TYPE_KYOGRE_GROUDON 0x1000
#define BATTLE_TYPE_LEGENDARY 0x2000
#define BATTLE_TYPE_REGI 0x4000
2017-09-05 09:41:48 +02:00
#define BATTLE_TYPE_TWO_OPPONENTS 0x8000
2017-09-04 21:43:13 +02:00
#define BATTLE_TYPE_DOME 0x10000
#define BATTLE_TYPE_PALACE 0x20000
#define BATTLE_TYPE_ARENA 0x40000
#define BATTLE_TYPE_FACTORY 0x80000
2017-11-28 23:02:09 +01:00
#define BATTLE_TYPE_PIKE 0x100000
2017-09-04 21:43:13 +02:00
#define BATTLE_TYPE_PYRAMID 0x200000
#define BATTLE_TYPE_INGAME_PARTNER 0x400000
2017-09-17 15:19:15 +02:00
#define BATTLE_TYPE_x800000 0x800000
2017-09-02 21:43:53 +02:00
#define BATTLE_TYPE_RECORDED 0x1000000
2017-09-05 09:41:48 +02:00
#define BATTLE_TYPE_x2000000 0x2000000
#define BATTLE_TYPE_x4000000 0x4000000
#define BATTLE_TYPE_SECRET_BASE 0x8000000
2017-09-02 21:43:53 +02:00
#define BATTLE_TYPE_GROUDON 0x10000000
2017-12-16 01:15:19 +01:00
#define BATTLE_TYPE_KYOGRE 0x20000000
2017-09-02 21:43:53 +02:00
#define BATTLE_TYPE_RAYQUAZA 0x40000000
2017-10-02 23:32:39 +02:00
#define BATTLE_TYPE_x80000000 0x80000000
2018-01-16 21:01:31 +01:00
#define BATTLE_TYPE_FRONTIER (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_PIKE | 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_PIKE)
2018-01-16 22:12:38 +01:00
extern u32 gBattleTypeFlags;
2017-10-06 00:12:01 +02:00
#define TRAINER_OPPONENT_3FE 0x3FE
2017-10-01 01:12:42 +02:00
#define TRAINER_OPPONENT_C00 0xC00
#define TRAINER_OPPONENT_800 0x800
2017-09-11 14:42:13 +02:00
#define STEVEN_PARTNER_ID 0xC03
2017-09-11 18:27:54 +02:00
#define SECRET_BASE_OPPONENT 0x400
2017-09-11 14:42:13 +02:00
2018-01-16 22:12:38 +01:00
#define B_OUTCOME_WON 0x1
#define B_OUTCOME_LOST 0x2
#define B_OUTCOME_DREW 0x3
#define B_OUTCOME_RAN 0x4
#define B_OUTCOME_PLAYER_TELEPORTED 0x5
#define B_OUTCOME_POKE_FLED 0x6
#define B_OUTCOME_CAUGHT_POKE 0x7
#define B_OUTCOME_NO_SAFARI_BALLS 0x8
#define B_OUTCOME_FORFEITED 0x9
#define B_OUTCOME_POKE_TELEPORTED 0xA
#define B_OUTCOME_LINK_BATTLE_RAN 0x80
extern u8 gBattleOutcome;
// Non-volatile status conditions
// These persist remain outside of battle and after switching out
#define STATUS1_NONE 0x0
#define STATUS1_SLEEP 0x7
#define STATUS1_POISON 0x8
#define STATUS1_BURN 0x10
#define STATUS1_FREEZE 0x20
#define STATUS1_PARALYSIS 0x40
#define STATUS1_TOXIC_POISON 0x80
#define STATUS1_TOXIC_COUNTER 0xF00
#define STATUS1_PSN_ANY (STATUS1_POISON | STATUS1_TOXIC_POISON)
#define STATUS1_ANY (STATUS1_SLEEP | STATUS1_POISON | STATUS1_BURN | STATUS1_FREEZE | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON)
// Volatile status ailments
// These are removed after exiting the battle or switching out
#define STATUS2_CONFUSION 0x00000007
#define STATUS2_FLINCHED 0x00000008
#define STATUS2_UPROAR 0x00000070
#define STATUS2_BIDE 0x00000300 // two bits 0x100, 0x200
#define STATUS2_LOCK_CONFUSE 0x00000C00
#define STATUS2_MULTIPLETURNS 0x00001000
#define STATUS2_WRAPPED 0x0000E000
2018-02-06 02:46:59 +01:00
#define STATUS2_INFATUATION 0x000F0000 // 4 bits, one for every battler
#define STATUS2_INFATUATED_WITH(battler) (gBitTable[battler] << 16)
2018-01-16 22:12:38 +01:00
#define STATUS2_FOCUS_ENERGY 0x00100000
#define STATUS2_TRANSFORMED 0x00200000
#define STATUS2_RECHARGE 0x00400000
#define STATUS2_RAGE 0x00800000
#define STATUS2_SUBSTITUTE 0x01000000
#define STATUS2_DESTINY_BOND 0x02000000
#define STATUS2_ESCAPE_PREVENTION 0x04000000
#define STATUS2_NIGHTMARE 0x08000000
#define STATUS2_CURSED 0x10000000
#define STATUS2_FORESIGHT 0x20000000
#define STATUS2_DEFENSE_CURL 0x40000000
#define STATUS2_TORMENT 0x80000000
2018-02-06 02:46:59 +01:00
// Seems like per-battler statuses. Not quite sure how to categorize these
2017-09-04 21:43:13 +02:00
#define STATUS3_LEECHSEED_BANK 0x3
#define STATUS3_LEECHSEED 0x4
2017-09-26 22:39:59 +02:00
#define STATUS3_ALWAYS_HITS 0x18 // two bits
2017-09-04 21:43:13 +02:00
#define STATUS3_PERISH_SONG 0x20
#define STATUS3_ON_AIR 0x40
#define STATUS3_UNDERGROUND 0x80
#define STATUS3_MINIMIZED 0x100
#define STATUS3_ROOTED 0x400
#define STATUS3_CHARGED_UP 0x200
2017-10-06 17:06:45 +02:00
#define STATUS3_YAWN 0x1800 // two bits
#define STATUS3_IMPRISONED_OTHERS 0x2000
2017-09-04 21:43:13 +02:00
#define STATUS3_GRUDGE 0x4000
#define STATUS3_CANT_SCORE_A_CRIT 0x8000
#define STATUS3_MUDSPORT 0x10000
#define STATUS3_WATERSPORT 0x20000
#define STATUS3_UNDERWATER 0x40000
#define STATUS3_INTIMIDATE_POKES 0x80000
#define STATUS3_TRACE 0x100000
2018-01-16 22:12:38 +01:00
#define STATUS3_SEMI_INVULNERABLE (STATUS3_UNDERGROUND | STATUS3_ON_AIR | STATUS3_UNDERWATER)
2018-02-06 02:46:59 +01:00
extern u32 gStatuses3[MAX_BATTLERS_COUNT];
2017-09-04 21:43:13 +02:00
2018-02-06 23:09:39 +01:00
// Not really sure what a "hitmarker" is.
2017-09-04 21:43:13 +02:00
2017-10-06 17:06:45 +02:00
#define HITMARKER_x10 0x00000010
2017-09-04 21:43:13 +02:00
#define HITMARKER_x20 0x00000020
#define HITMARKER_DESTINYBOND 0x00000040
#define HITMARKER_NO_ANIMATIONS 0x00000080
#define HITMARKER_IGNORE_SUBSTITUTE 0x00000100
#define HITMARKER_NO_ATTACKSTRING 0x00000200
#define HITMARKER_ATTACKSTRING_PRINTED 0x00000400
#define HITMARKER_NO_PPDEDUCT 0x00000800
#define HITMARKER_PURSUIT_TRAP 0x00001000
#define HITMARKER_IGNORE_SAFEGUARD 0x00002000
#define HITMARKER_SYNCHRONISE_EFFECT 0x00004000
2017-10-06 17:06:45 +02:00
#define HITMARKER_RUN 0x00008000
2017-09-04 21:43:13 +02:00
#define HITMARKER_IGNORE_ON_AIR 0x00010000
#define HITMARKER_IGNORE_UNDERGROUND 0x00020000
#define HITMARKER_IGNORE_UNDERWATER 0x00040000
#define HITMARKER_UNABLE_TO_USE_MOVE 0x00080000
#define HITMARKER_x100000 0x00100000
#define HITMARKER_x200000 0x00200000
#define HITMARKER_x400000 0x00400000
#define HITMARKER_x800000 0x00800000
#define HITMARKER_GRUDGE 0x01000000
#define HITMARKER_OBEYS 0x02000000
2017-10-06 17:06:45 +02:00
#define HITMARKER_x4000000 0x04000000
2017-09-04 21:43:13 +02:00
#define HITMARKER_x8000000 0x08000000
2018-02-06 02:46:59 +01:00
#define HITMARKER_FAINTED(battler) (gBitTable[battler] << 0x1C)
#define HITMARKER_UNK(battler) (0x10000000 << battler)
2018-01-16 22:12:38 +01:00
extern u32 gHitMarker;
// Per-side statuses that affect an entire party
2017-09-04 21:43:13 +02:00
#define SIDE_STATUS_REFLECT (1 << 0)
#define SIDE_STATUS_LIGHTSCREEN (1 << 1)
#define SIDE_STATUS_X4 (1 << 2)
#define SIDE_STATUS_SPIKES (1 << 4)
#define SIDE_STATUS_SAFEGUARD (1 << 5)
#define SIDE_STATUS_FUTUREATTACK (1 << 6)
#define SIDE_STATUS_MIST (1 << 8)
#define SIDE_STATUS_SPIKES_DAMAGED (1 << 9)
2018-01-16 22:12:38 +01:00
extern u16 gSideStatuses[2];
2018-02-06 23:09:39 +01:00
// Battle Actions
// These determine what each battler will do in a turn
#define B_ACTION_USE_MOVE 0
#define B_ACTION_USE_ITEM 1
#define B_ACTION_SWITCH 2
#define B_ACTION_RUN 3
#define B_ACTION_SAFARI_WATCH_CAREFULLY 4
#define B_ACTION_SAFARI_BALL 5
#define B_ACTION_SAFARI_POKEBLOCK 6
#define B_ACTION_SAFARI_GO_NEAR 7
#define B_ACTION_SAFARI_RUN 8
// The exact purposes of these are unclear
#define B_ACTION_UNKNOWN9 9
#define B_ACTION_EXEC_SCRIPT 10 // when executing an action
#define B_ACTION_CANCEL_PARTNER 12 // when choosing an action
#define B_ACTION_FINISHED 12 // when executing an action
#define B_ACTION_NOTHING_FAINTED 13 // when choosing an action
#define B_ACTION_NONE 0xFF
2017-10-04 19:25:14 +02:00
2018-01-16 22:12:38 +01:00
#define MOVE_RESULT_MISSED (1 << 0)
#define MOVE_RESULT_SUPER_EFFECTIVE (1 << 1)
#define MOVE_RESULT_NOT_VERY_EFFECTIVE (1 << 2)
#define MOVE_RESULT_DOESNT_AFFECT_FOE (1 << 3)
#define MOVE_RESULT_ONE_HIT_KO (1 << 4)
#define MOVE_RESULT_FAILED (1 << 5)
#define MOVE_RESULT_FOE_ENDURED (1 << 6)
#define MOVE_RESULT_FOE_HUNG_ON (1 << 7)
#define MOVE_RESULT_NO_EFFECT (MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE | MOVE_RESULT_FAILED)
2017-09-04 21:43:13 +02:00
#define MAX_TRAINER_ITEMS 4
#define MAX_MON_MOVES 4
2018-01-16 22:12:38 +01:00
// Battle Weather flags
2017-09-04 21:43:13 +02:00
#define WEATHER_RAIN_TEMPORARY (1 << 0)
2018-01-16 22:12:38 +01:00
#define WEATHER_RAIN_DOWNPOUR (1 << 1) // unused
2017-09-04 21:43:13 +02:00
#define WEATHER_RAIN_PERMANENT (1 << 2)
2018-01-16 22:12:38 +01:00
#define WEATHER_RAIN_ANY (WEATHER_RAIN_TEMPORARY | WEATHER_RAIN_DOWNPOUR | WEATHER_RAIN_PERMANENT)
2017-09-04 21:43:13 +02:00
#define WEATHER_SANDSTORM_TEMPORARY (1 << 3)
#define WEATHER_SANDSTORM_PERMANENT (1 << 4)
2018-01-16 22:12:38 +01:00
#define WEATHER_SANDSTORM_ANY (WEATHER_SANDSTORM_TEMPORARY | WEATHER_SANDSTORM_PERMANENT)
2017-09-04 21:43:13 +02:00
#define WEATHER_SUN_TEMPORARY (1 << 5)
#define WEATHER_SUN_PERMANENT (1 << 6)
2018-01-16 22:12:38 +01:00
#define WEATHER_SUN_ANY (WEATHER_SUN_TEMPORARY | WEATHER_SUN_PERMANENT)
2017-09-04 21:43:13 +02:00
#define WEATHER_HAIL (1 << 7)
2018-01-16 22:12:38 +01:00
#define WEATHER_HAIL_ANY (WEATHER_HAIL)
#define WEATHER_ANY (WEATHER_RAIN_ANY | WEATHER_SANDSTORM_ANY | WEATHER_SUN_ANY | WEATHER_HAIL_ANY)
extern u16 gBattleWeather;
2017-09-04 21:43:13 +02:00
2017-09-27 23:43:45 +02:00
#define BATTLE_TERRAIN_GRASS 0
#define BATTLE_TERRAIN_LONG_GRASS 1
#define BATTLE_TERRAIN_SAND 2
#define BATTLE_TERRAIN_UNDERWATER 3
#define BATTLE_TERRAIN_WATER 4
#define BATTLE_TERRAIN_POND 5
2017-11-28 23:02:09 +01:00
#define BATTLE_TERRAIN_MOUNTAIN 6
2017-09-27 23:43:45 +02:00
#define BATTLE_TERRAIN_CAVE 7
2017-11-28 23:02:09 +01:00
#define BATTLE_TERRAIN_BUILDING 8
2017-10-27 18:52:21 +02:00
#define BATTLE_TERRAIN_PLAIN 9
2017-09-27 23:43:45 +02:00
2018-01-16 22:12:38 +01:00
extern u8 gBattleTerrain;
2017-09-17 14:10:32 +02:00
// array entries for battle communication
2017-10-01 01:12:42 +02:00
#define MULTIUSE_STATE 0x0
#define CURSOR_POSITION 0x1
#define TASK_ID 0x1 // task Id and cursor position share the same field
#define SPRITES_INIT_STATE1 0x1 // shares the Id as well
#define SPRITES_INIT_STATE2 0x2
#define MOVE_EFFECT_BYTE 0x3
2017-10-04 19:25:14 +02:00
#define ACTIONS_CONFIRMED_COUNT 0x4
2017-10-01 01:12:42 +02:00
#define MULTISTRING_CHOOSER 0x5
#define MSG_DISPLAY 0x7
2017-10-02 23:32:39 +02:00
#define BATTLE_COMMUNICATION_ENTRIES_COUNT 0x8
2017-09-17 14:10:32 +02:00
#define MOVE_TARGET_SELECTED 0x0
#define MOVE_TARGET_DEPENDS 0x1
#define MOVE_TARGET_USER 0x2
#define MOVE_TARGET_RANDOM 0x4
#define MOVE_TARGET_x10 0x10
#define MOVE_TARGET_BOTH 0x8
#define MOVE_TARGET_FOES_AND_ALLY 0x20
#define MOVE_TARGET_OPPONENTS_FIELD 0x40
2017-09-04 21:43:13 +02:00
// defines for the u8 array gTypeEffectiveness
#define TYPE_EFFECT_ATK_TYPE(i)((gTypeEffectiveness[i + 0]))
#define TYPE_EFFECT_DEF_TYPE(i)((gTypeEffectiveness[i + 1]))
#define TYPE_EFFECT_MULTIPLIER(i)((gTypeEffectiveness[i + 2]))
// defines for the gTypeEffectiveness multipliers
2017-09-20 00:28:00 +02:00
#define TYPE_MUL_NO_EFFECT 0
#define TYPE_MUL_NOT_EFFECTIVE 5
#define TYPE_MUL_NORMAL 10
#define TYPE_MUL_SUPER_EFFECTIVE 20
// special type table Ids
#define TYPE_FORESIGHT 0xFE
#define TYPE_ENDTABLE 0xFF
2017-09-22 21:33:49 +02:00
#define BS_GET_TARGET 0
#define BS_GET_ATTACKER 1
#define BS_GET_EFFECT_BANK 2
#define BS_GET_gBank1 3
#define BS_GET_BANK_0 7
2017-09-26 22:39:59 +02:00
#define BS_ATTACKER_WITH_PARTNER 4 // for atk98_status_icon_update
2017-09-22 21:33:49 +02:00
#define BS_GET_ATTACKER_SIDE 8 // for atk1E_jumpifability
#define BS_GET_NOT_ATTACKER_SIDE 9 // for atk1E_jumpifability
#define BS_GET_SCRIPTING_BANK 10
#define BS_GET_OPPONENT1 12
#define BS_GET_PLAYER2 13
#define BS_GET_OPPONENT2 14
// for battle script commands
#define CMP_EQUAL 0x0
#define CMP_NOT_EQUAL 0x1
#define CMP_GREATER_THAN 0x2
#define CMP_LESS_THAN 0x3
#define CMP_COMMON_BITS 0x4
#define CMP_NO_COMMON_BITS 0x5
2017-09-20 00:28:00 +02:00
2017-09-25 00:09:13 +02:00
struct TrainerMonNoItemDefaultMoves
{
2017-10-01 18:54:01 +02:00
u16 iv;
2017-09-25 00:09:13 +02:00
u8 lvl;
2017-10-01 18:54:01 +02:00
u16 species;
2017-09-25 00:09:13 +02:00
};
2018-02-06 02:46:59 +01:00
u8 GetBattlerSide(u8 battler);
2017-09-04 21:43:13 +02:00
2017-09-25 00:09:13 +02:00
struct TrainerMonItemDefaultMoves
{
2017-10-01 18:54:01 +02:00
u16 iv;
2017-09-25 00:09:13 +02:00
u8 lvl;
2017-10-01 18:54:01 +02:00
u16 species;
2017-09-25 00:09:13 +02:00
u16 heldItem;
};
struct TrainerMonNoItemCustomMoves
{
2017-10-01 18:54:01 +02:00
u16 iv;
2017-09-25 00:09:13 +02:00
u8 lvl;
2017-10-01 18:54:01 +02:00
u16 species;
2017-09-25 00:09:13 +02:00
u16 moves[4];
};
struct TrainerMonItemCustomMoves
{
2017-10-01 18:54:01 +02:00
u16 iv;
2017-09-25 00:09:13 +02:00
u8 lvl;
2017-10-01 18:54:01 +02:00
u16 species;
2017-09-25 00:09:13 +02:00
u16 heldItem;
u16 moves[4];
};
union TrainerMonPtr
{
2017-11-28 23:02:09 +01:00
struct TrainerMonNoItemDefaultMoves *NoItemDefaultMoves;
struct TrainerMonNoItemCustomMoves *NoItemCustomMoves;
struct TrainerMonItemDefaultMoves *ItemDefaultMoves;
struct TrainerMonItemCustomMoves *ItemCustomMoves;
2017-09-25 00:09:13 +02:00
};
2017-09-05 09:41:48 +02:00
struct Trainer
{
/*0x00*/ u8 partyFlags;
/*0x01*/ u8 trainerClass;
2017-09-11 11:35:41 +02:00
/*0x02*/ u8 encounterMusic_gender; // last bit is gender
2017-09-05 09:41:48 +02:00
/*0x03*/ u8 trainerPic;
/*0x04*/ u8 trainerName[12];
/*0x10*/ u16 items[4];
/*0x18*/ bool8 doubleBattle;
/*0x1C*/ u32 aiFlags;
/*0x20*/ u8 partySize;
2017-09-25 00:09:13 +02:00
/*0x24*/ union TrainerMonPtr party;
2017-09-05 09:41:48 +02:00
};
extern const struct Trainer gTrainers[];
2017-09-04 21:43:13 +02:00
2017-09-11 11:35:41 +02:00
#define TRAINER_ENCOUNTER_MUSIC(trainer)((gTrainers[trainer].encounterMusic_gender & 0x7F))
2017-09-04 21:43:13 +02:00
struct UnknownFlags
{
u32 flags[4];
};
#define UNKNOWN_FLAG_FLASH_FIRE 1
struct DisableStruct
{
/*0x00*/ u32 transformedMonPersonality;
2017-09-04 21:43:13 +02:00
/*0x04*/ u16 disabledMove;
/*0x06*/ u16 encoredMove;
/*0x08*/ u8 protectUses;
/*0x09*/ u8 stockpileCounter;
/*0x0A*/ u8 substituteHP;
/*0x0B*/ u8 disableTimer1 : 4;
/*0x0B*/ u8 disableTimer2 : 4;
/*0x0C*/ u8 encoredMovePos;
/*0x0D*/ u8 unkD;
/*0x0E*/ u8 encoreTimer1 : 4;
/*0x0E*/ u8 encoreTimer2 : 4;
2017-11-12 17:11:06 +01:00
/*0x0F*/ u8 perishSongTimer1 : 4;
/*0x0F*/ u8 perishSongTimer2 : 4;
2017-09-04 21:43:13 +02:00
/*0x10*/ u8 furyCutterCounter;
2017-10-06 17:06:45 +02:00
/*0x11*/ u8 rolloutCounter1 : 4;
/*0x11*/ u8 rolloutCounter2 : 4;
2017-09-04 21:43:13 +02:00
/*0x12*/ u8 chargeTimer1 : 4;
/*0x12*/ u8 chargeTimer2 : 4;
/*0x13*/ u8 tauntTimer1:4;
/*0x13*/ u8 tauntTimer2:4;
2018-02-06 23:09:39 +01:00
/*0x14*/ u8 battlerPreventingEscape;
/*0x15*/ u8 battlerWithSureHit;
2017-09-04 21:43:13 +02:00
/*0x16*/ u8 isFirstTurn;
/*0x17*/ u8 unk17;
/*0x18*/ u8 truantCounter : 1;
2017-09-25 00:09:13 +02:00
/*0x18*/ u8 truantUnknownBit : 1;
/*0x18*/ u8 unk18_a_2 : 2;
2017-09-04 21:43:13 +02:00
/*0x18*/ u8 unk18_b : 4;
/*0x19*/ u8 rechargeCounter;
/*0x1A*/ u8 unk1A[2];
};
2018-02-06 02:46:59 +01:00
extern struct DisableStruct gDisableStructs[MAX_BATTLERS_COUNT];
2017-09-17 14:10:32 +02:00
struct ProtectStruct
{
/* field_0 */
u32 protected:1;
u32 endured:1;
u32 onlyStruggle:1;
u32 helpingHand:1;
u32 bounceMove:1;
u32 stealMove:1;
u32 flag0Unknown:1;
u32 prlzImmobility:1;
/* field_1 */
u32 confusionSelfDmg:1;
2017-10-06 17:06:45 +02:00
u32 targetNotAffected:1;
2017-09-17 14:10:32 +02:00
u32 chargingTurn:1;
u32 fleeFlag:2; // for RunAway and Smoke Ball
u32 usedImprisionedMove:1;
u32 loveImmobility:1;
u32 usedDisabledMove:1;
/* field_2 */
u32 usedTauntedMove:1; // 0x1
u32 flag2Unknown:1; // 0x2
u32 flinchImmobility:1; // 0x4
u32 notFirstStrike:1; // 0x8
u32 flag_x10 : 1; // 0x10
u32 flag_x20 : 1; // 0x20
u32 flag_x40 : 1; // 0x40
u32 flag_x80 : 1; // 0x80
/* field_3 */
u32 field3 : 8;
/* field_4 */ u32 physicalDmg;
/* field_8 */ u32 specialDmg;
2018-02-07 22:53:40 +01:00
/* field_C */ u8 physicalBattlerId;
/* field_D */ u8 specialBattlerId;
2017-09-17 14:10:32 +02:00
/* field_E */ u16 fieldE;
};
2018-02-06 02:46:59 +01:00
extern struct ProtectStruct gProtectStructs[MAX_BATTLERS_COUNT];
2017-09-17 14:10:32 +02:00
struct SpecialStatus
{
2017-09-26 22:39:59 +02:00
u8 statLowered : 1; // 0x1
u8 lightningRodRedirected : 1; // 0x2
u8 restoredBankSprite: 1; // 0x4
u8 intimidatedPoke : 1; // 0x8
u8 traced : 1; // 0x10
2017-09-17 14:10:32 +02:00
u8 flag20 : 1;
u8 flag40 : 1;
u8 focusBanded : 1;
u8 field1[3];
2018-02-07 22:53:40 +01:00
s32 dmg;
s32 physicalDmg;
s32 specialDmg;
u8 physicalBattlerId;
u8 specialBattlerId;
2017-09-17 14:10:32 +02:00
u8 field12;
u8 field13;
};
2018-02-06 02:46:59 +01:00
extern struct SpecialStatus gSpecialStatuses[MAX_BATTLERS_COUNT];
2017-09-17 14:10:32 +02:00
struct SideTimer
{
/*0x00*/ u8 reflectTimer;
2018-02-07 22:53:40 +01:00
/*0x01*/ u8 reflectBattlerId;
2017-09-17 14:10:32 +02:00
/*0x02*/ u8 lightscreenTimer;
2018-02-07 22:53:40 +01:00
/*0x03*/ u8 lightscreenBattlerId;
2017-09-17 14:10:32 +02:00
/*0x04*/ u8 mistTimer;
2018-02-07 22:53:40 +01:00
/*0x05*/ u8 mistBattlerId;
2017-09-17 14:10:32 +02:00
/*0x06*/ u8 safeguardTimer;
2018-02-07 22:53:40 +01:00
/*0x07*/ u8 safeguardBattlerId;
2017-09-17 14:10:32 +02:00
/*0x08*/ u8 followmeTimer;
/*0x09*/ u8 followmeTarget;
/*0x0A*/ u8 spikesAmount;
/*0x0B*/ u8 fieldB;
};
extern struct SideTimer gSideTimers[];
struct WishFutureKnock
{
2018-02-06 02:46:59 +01:00
u8 futureSightCounter[MAX_BATTLERS_COUNT];
u8 futureSightAttacker[MAX_BATTLERS_COUNT];
s32 futureSightDmg[MAX_BATTLERS_COUNT];
u16 futureSightMove[MAX_BATTLERS_COUNT];
u8 wishCounter[MAX_BATTLERS_COUNT];
2018-02-07 22:53:40 +01:00
u8 wishMonId[MAX_BATTLERS_COUNT];
2017-09-17 14:10:32 +02:00
u8 weatherDuration;
u8 knockedOffPokes[2];
2017-09-17 14:10:32 +02:00
};
extern struct WishFutureKnock gWishFutureKnock;
2017-09-04 21:43:13 +02:00
struct AI_ThinkingStruct
{
u8 aiState;
u8 movesetIndex;
u16 moveConsidered;
s8 score[4];
u32 funcResult;
u32 aiFlags;
u8 aiAction;
u8 aiLogicId;
u8 filler12[6];
2017-09-05 09:41:48 +02:00
u8 simulatedRNG[4];
2017-09-04 21:43:13 +02:00
};
struct UsedMoves
{
2018-02-06 02:46:59 +01:00
u16 moves[MAX_BATTLERS_COUNT];
u16 unknown[MAX_BATTLERS_COUNT];
2017-09-04 21:43:13 +02:00
};
struct BattleHistory
{
2018-02-06 02:46:59 +01:00
struct UsedMoves usedMoves[MAX_BATTLERS_COUNT];
u8 abilities[MAX_BATTLERS_COUNT];
u8 itemEffects[MAX_BATTLERS_COUNT];
u16 trainerItems[MAX_BATTLERS_COUNT];
2017-09-05 09:41:48 +02:00
u8 itemsNo;
2017-09-04 21:43:13 +02:00
};
struct BattleScriptsStack
{
2017-09-17 14:10:32 +02:00
const u8 *ptr[8];
2017-09-04 21:43:13 +02:00
u8 size;
};
2017-09-17 17:14:32 +02:00
struct BattleCallbacksStack
{
void (*function[8])(void);
u8 size;
};
2017-09-22 21:33:49 +02:00
struct StatsArray
{
u16 hp;
u16 atk;
u16 def;
u16 spd;
u16 spAtk;
u16 spDef;
};
2017-09-04 21:43:13 +02:00
struct BattleResources
{
2017-09-12 00:01:12 +02:00
struct SecretBaseRecord* secretBase;
2017-09-04 21:43:13 +02:00
struct UnknownFlags *flags;
struct BattleScriptsStack* battleScriptsStack;
2017-09-17 17:14:32 +02:00
struct BattleCallbacksStack* battleCallbackStack;
2017-09-22 21:33:49 +02:00
struct StatsArray* statsBeforeLvlUp;
2017-09-04 21:43:13 +02:00
struct AI_ThinkingStruct *ai;
struct BattleHistory *battleHistory;
struct BattleScriptsStack *AI_ScriptsStack;
};
extern struct BattleResources* gBattleResources;
2017-09-05 09:41:48 +02:00
struct BattleResults
{
u8 playerFaintCounter; // 0x0
u8 opponentFaintCounter; // 0x1
2017-09-25 00:09:13 +02:00
u8 playerSwitchesCounter; // 0x2
2017-09-05 09:41:48 +02:00
u8 unk3; // 0x3
u8 unk4; // 0x4
Decompile TV (#80) * ClearTVShowData * special_0x44 * DoTVShow (nonmatching because align) * DoTVShowBravoTrainerPokemonProfile * Update field names * DoTVShowBravoTrainerBattleTower * Renaming of struct fields * sub_80EBFF4 and UpdateTVScreensOnMap * SetTVMetatilesOnMap * Power buttons for the TV screens on the map * special_0x45 * sub_80EC18C * special_0x4a * ResetGabbyAndTy * GabbyAndTyBeforeInterview * GabbyAndTyAfterInterview * Through IsTVShowInSearchOfTrainersAiring * GabbyAndTyGetLastQuote * GabbyAndTyGetLastBattleTrivia * GabbyAndTySetScriptVarsToFieldObjectLocalIds * InterviewAfter; use TVShow as a precursor for making the individual show structs anonymous * Make TV structs anonymous within the union * Move the TV union to its own subheader * Move TV show enums to the global.tv.h subheader * Funcion renaming * Apply static attributes where able * PutPokemonTodayCaughtOnAir * sub_80EC8A4 * PutPokemonTodayFailedOnTheAir * sub_80EC9E8, sub_80ECA10 * sub_80ECA38 * sub_80ECB00 * Put3CheersForPokeblocksOnTheAir * PutFanClubSpecialOnTheAir * ContestLiveUpdates_BeforeInterview * Other before-interview Contest Live Updates functions * ContestLiveUpdates_BeforeInterview_5 * InterviewAfter_BravoTrainerPokemonProfile * BravoTrainerPokemonProfile_BeforeInterview1 * BravoTrainerPokemonProfile_BeforeInterview2 * Disassemble TV data * Decompile TV data * InterviewAfter_BravoTrainerBattleTowerProfile * SaveRecordedItemPurchasesForTVShow * PutNameRaterShowOnTheAir * StartMassOutbreak * PutLilycoveContestLadyShowOnTheAir * InterviewAfter_FanClubLetter * Rip TV strings * InterviewAfter_RecentHappenings * InterviewAfter_PkmnFanClubOpinions * sub_80ED718 * EndMassOutbreak * sub_80ED888 * sub_80ED8B4 * UpdateMassOutbreakTimeLeft * sub_80ED950 * PutFishingAdviceShowOnTheAir * through sub_80EDA80 * ewram and common syms are now fetched from the object files * BSS symbols are taken from the tv.o file * through sub_80EDC60 * sub_80EDCE8 * sub_80EDD78 * through sub_80EDE84 * nomatching sub_80EDE98 * sub_80EDFB4 * sub_80EE104 * sub_80EE104 * sub_80EE184 * sub_80EE2CC * sub_80EE35C * sub_80EE44C * sub_80EE4DC * sub_80EE5A4 * sub_80EE69C * sub_80EE72C * sub_80EE7C0 * sub_80EE818 * sub_80EE8C8 * sub_80EEA70 * sub_80EEB98 * sub_80EEBF4 * through sub_80EED60 * Functions relating to Pokemon News * sub_80EEF6C * GetPriceReduction * IsPriceDiscounted * sub_80EF120 * through sub_80EF370 * sub_80EF40C * HasMixableShowAlreadyBeenSpawnedWithPlayerID * TV_SortPurchasesByQuantity * FindActiveBroadcastByShowType_SetScriptResult * InterviewBefore * through sub_80EF88C * through sub_80EF93C * through sub_80EFA24 * through TV_BernoulliTrial * sub_80EFB58 * sub_80EFBA4 * sub_80EFBDC * through sub_80EFD98 * ChangePokemonNickname * ChangeBoxPokemonNickname * sub_80EFF9C * through player_id_to_dword * CheckForBigMovieOrEmergencyNewsOnTV * GetMomOrDadStringForTVMessage * sub_80F01E8 * sub_80F0358 * sub_80F049C * TV record mixing functions * sub_80F06D0 * sub_80F0708 nonmatching * through sub_80F0B24 * sub_80F0B64 * through sub_80F0C04 * sub_80F0C7C * sub_80F0D60 * sub_80F0E58 * sub_80F0E84 * through sub_80F0F24 * sub_80F0F64 * sub_80F1208 * sub_80F1254 * sub_80F1290 * sub_80F12A4 * sub_80F14F8 * DoTVShowTodaysSmartShopper * DoTVShowTheNameRaterShow * DoTVShowPokemonTodaySuccessfulCapture * DoTVShowPokemonTodayFailedCapture * DoTVShowPokemonFanClubLetter * DoTVShowRecentHappenings * DoTVShowPokemonFanClubOpinions * DoTVShowPokemonNewsMassOutbreak * DoTVShowPokemonContestLiveUpdates * DoTVShowPokemonBattleUpdate * DoTVShow3CheersForPokeblocks * DoTVShowInSearchOfTrainers * Label GabbyAndTyData fields; remove ddump comments from data/text/tv.inc * DoTVShowPokemonAngler * DoTVShowTheWorldOfMasters; update RAM symbols and field names * Decorate static functions * DoTVShowTodaysRivalTrainer; region map enums * TVDewfordTrendWatcherNetworkTextGroup * DoTVShowHoennTreasureInvestigators * DoTVShowFindThatGamer * DoTVShowBreakingNewsTV * DoTVShowSecretBaseVisit * DoTVShowPokemonLotterWinnerFlashReport * DoTVShowThePokemonBattleSeminar * DoTVShowTrainerFanClubSpecial, DoTVShowTrainerFanClub * DoTVShowSpotTheCuties * DoTVShowPokemonNewsBattleFrontier * DoTVShowWhatsNo1InHoennToday * Helpers for DoTVShowSecretBaseSecrets * DoTVShowSecretBaseSecrets * DoTVShowSafariFanClub * Finish decompilation of tv.s * Some renaming * Rename text group pointers * revoke statis; pokenews enums * Labels are number one * Label all TV struct fields * Make data/text/tv.inc more readable * Split data/text/tv.inc * Rename pokenews text pointers * Frontier Symbol constants; indicate static rodata objects with 's' prefix * Fix leading spaces/tabs F*** CLion sometimes * Fix inconsequential warning
2017-10-13 17:09:36 +02:00
u8 unk5_0:1; // 0x5
u8 usedMasterBall:1; // 0x5
u8 caughtMonBall:4; // 0x5
u8 unk5_6:1; // 0x5
u8 unk5_7:1; // 0x5
2017-10-06 00:12:01 +02:00
u16 playerMon1Species; // 0x6
u8 playerMon1Name[11]; // 0x8
2017-09-05 09:41:48 +02:00
u8 battleTurnCounter; // 0x13
2017-10-06 00:12:01 +02:00
u8 playerMon2Name[11]; // 0x14
2017-10-06 17:06:45 +02:00
u8 field_1F; // 0x1F
2017-09-05 09:41:48 +02:00
u16 lastOpponentSpecies; // 0x20
2017-10-06 00:12:01 +02:00
u16 lastUsedMovePlayer; // 0x22
u16 lastUsedMoveOpponent; // 0x24
u16 playerMon2Species; // 0x26
2017-09-28 15:34:21 +02:00
u16 caughtMonSpecies; // 0x28
u8 caughtMonNick[10]; // 0x2A
2018-02-07 22:53:40 +01:00
u8 filler34[2]; // 0x34
Decompile TV (#80) * ClearTVShowData * special_0x44 * DoTVShow (nonmatching because align) * DoTVShowBravoTrainerPokemonProfile * Update field names * DoTVShowBravoTrainerBattleTower * Renaming of struct fields * sub_80EBFF4 and UpdateTVScreensOnMap * SetTVMetatilesOnMap * Power buttons for the TV screens on the map * special_0x45 * sub_80EC18C * special_0x4a * ResetGabbyAndTy * GabbyAndTyBeforeInterview * GabbyAndTyAfterInterview * Through IsTVShowInSearchOfTrainersAiring * GabbyAndTyGetLastQuote * GabbyAndTyGetLastBattleTrivia * GabbyAndTySetScriptVarsToFieldObjectLocalIds * InterviewAfter; use TVShow as a precursor for making the individual show structs anonymous * Make TV structs anonymous within the union * Move the TV union to its own subheader * Move TV show enums to the global.tv.h subheader * Funcion renaming * Apply static attributes where able * PutPokemonTodayCaughtOnAir * sub_80EC8A4 * PutPokemonTodayFailedOnTheAir * sub_80EC9E8, sub_80ECA10 * sub_80ECA38 * sub_80ECB00 * Put3CheersForPokeblocksOnTheAir * PutFanClubSpecialOnTheAir * ContestLiveUpdates_BeforeInterview * Other before-interview Contest Live Updates functions * ContestLiveUpdates_BeforeInterview_5 * InterviewAfter_BravoTrainerPokemonProfile * BravoTrainerPokemonProfile_BeforeInterview1 * BravoTrainerPokemonProfile_BeforeInterview2 * Disassemble TV data * Decompile TV data * InterviewAfter_BravoTrainerBattleTowerProfile * SaveRecordedItemPurchasesForTVShow * PutNameRaterShowOnTheAir * StartMassOutbreak * PutLilycoveContestLadyShowOnTheAir * InterviewAfter_FanClubLetter * Rip TV strings * InterviewAfter_RecentHappenings * InterviewAfter_PkmnFanClubOpinions * sub_80ED718 * EndMassOutbreak * sub_80ED888 * sub_80ED8B4 * UpdateMassOutbreakTimeLeft * sub_80ED950 * PutFishingAdviceShowOnTheAir * through sub_80EDA80 * ewram and common syms are now fetched from the object files * BSS symbols are taken from the tv.o file * through sub_80EDC60 * sub_80EDCE8 * sub_80EDD78 * through sub_80EDE84 * nomatching sub_80EDE98 * sub_80EDFB4 * sub_80EE104 * sub_80EE104 * sub_80EE184 * sub_80EE2CC * sub_80EE35C * sub_80EE44C * sub_80EE4DC * sub_80EE5A4 * sub_80EE69C * sub_80EE72C * sub_80EE7C0 * sub_80EE818 * sub_80EE8C8 * sub_80EEA70 * sub_80EEB98 * sub_80EEBF4 * through sub_80EED60 * Functions relating to Pokemon News * sub_80EEF6C * GetPriceReduction * IsPriceDiscounted * sub_80EF120 * through sub_80EF370 * sub_80EF40C * HasMixableShowAlreadyBeenSpawnedWithPlayerID * TV_SortPurchasesByQuantity * FindActiveBroadcastByShowType_SetScriptResult * InterviewBefore * through sub_80EF88C * through sub_80EF93C * through sub_80EFA24 * through TV_BernoulliTrial * sub_80EFB58 * sub_80EFBA4 * sub_80EFBDC * through sub_80EFD98 * ChangePokemonNickname * ChangeBoxPokemonNickname * sub_80EFF9C * through player_id_to_dword * CheckForBigMovieOrEmergencyNewsOnTV * GetMomOrDadStringForTVMessage * sub_80F01E8 * sub_80F0358 * sub_80F049C * TV record mixing functions * sub_80F06D0 * sub_80F0708 nonmatching * through sub_80F0B24 * sub_80F0B64 * through sub_80F0C04 * sub_80F0C7C * sub_80F0D60 * sub_80F0E58 * sub_80F0E84 * through sub_80F0F24 * sub_80F0F64 * sub_80F1208 * sub_80F1254 * sub_80F1290 * sub_80F12A4 * sub_80F14F8 * DoTVShowTodaysSmartShopper * DoTVShowTheNameRaterShow * DoTVShowPokemonTodaySuccessfulCapture * DoTVShowPokemonTodayFailedCapture * DoTVShowPokemonFanClubLetter * DoTVShowRecentHappenings * DoTVShowPokemonFanClubOpinions * DoTVShowPokemonNewsMassOutbreak * DoTVShowPokemonContestLiveUpdates * DoTVShowPokemonBattleUpdate * DoTVShow3CheersForPokeblocks * DoTVShowInSearchOfTrainers * Label GabbyAndTyData fields; remove ddump comments from data/text/tv.inc * DoTVShowPokemonAngler * DoTVShowTheWorldOfMasters; update RAM symbols and field names * Decorate static functions * DoTVShowTodaysRivalTrainer; region map enums * TVDewfordTrendWatcherNetworkTextGroup * DoTVShowHoennTreasureInvestigators * DoTVShowFindThatGamer * DoTVShowBreakingNewsTV * DoTVShowSecretBaseVisit * DoTVShowPokemonLotterWinnerFlashReport * DoTVShowThePokemonBattleSeminar * DoTVShowTrainerFanClubSpecial, DoTVShowTrainerFanClub * DoTVShowSpotTheCuties * DoTVShowPokemonNewsBattleFrontier * DoTVShowWhatsNo1InHoennToday * Helpers for DoTVShowSecretBaseSecrets * DoTVShowSecretBaseSecrets * DoTVShowSafariFanClub * Finish decompilation of tv.s * Some renaming * Rename text group pointers * revoke statis; pokenews enums * Labels are number one * Label all TV struct fields * Make data/text/tv.inc more readable * Split data/text/tv.inc * Rename pokenews text pointers * Frontier Symbol constants; indicate static rodata objects with 's' prefix * Fix leading spaces/tabs F*** CLion sometimes * Fix inconsequential warning
2017-10-13 17:09:36 +02:00
u8 catchAttempts[11]; // 0x36
2017-09-05 09:41:48 +02:00
};
extern struct BattleResults gBattleResults;
struct BattleStruct
{
2017-09-17 14:10:32 +02:00
u8 turnEffectsTracker;
2018-02-07 22:53:40 +01:00
u8 turnEffectsBattlerId;
2017-09-17 14:10:32 +02:00
u8 filler2;
2018-02-07 22:53:40 +01:00
u8 turnCountersTracker;
2017-09-17 14:10:32 +02:00
u8 wrappedMove[8]; // ask gamefreak why they declared it that way
2017-09-05 09:41:48 +02:00
u8 moveTarget[4];
2018-02-07 22:53:40 +01:00
u8 expGetterMonId;
2017-09-05 09:41:48 +02:00
u8 field_11;
u8 wildVictorySong;
u8 dynamicMoveType;
u8 wrappedBy[4];
2017-09-27 23:43:45 +02:00
u16 assistPossibleMoves[5 * 4]; // 5 mons, each of them knowing 4 moves
2017-09-11 14:42:13 +02:00
u8 field_40;
u8 field_41;
u8 field_42;
u8 field_43;
u8 field_44;
u8 field_45;
u8 field_46;
u8 field_47;
2018-02-07 22:53:40 +01:00
u8 focusPunchBattlerId;
2017-09-11 14:42:13 +02:00
u8 field_49;
2017-09-17 17:14:32 +02:00
u8 moneyMultiplier;
u8 savedTurnActionNumber;
2017-10-02 23:32:39 +02:00
u8 switchInAbilitiesCounter;
2017-12-02 14:08:55 +01:00
u8 faintedActionsState;
2018-02-07 22:53:40 +01:00
u8 faintedActionsBattlerId;
2017-09-11 14:42:13 +02:00
u8 field_4F;
2017-09-22 21:33:49 +02:00
u16 expValue;
2017-09-11 14:42:13 +02:00
u8 field_52;
2017-09-22 21:33:49 +02:00
u8 sentInPokes;
2018-02-06 02:46:59 +01:00
bool8 selectionScriptFinished[MAX_BATTLERS_COUNT];
2017-09-24 00:29:52 +02:00
u8 field_58[4];
2018-02-06 02:46:59 +01:00
u8 monToSwitchIntoId[MAX_BATTLERS_COUNT];
2017-09-24 00:29:52 +02:00
u8 field_60[4][3];
2017-10-06 00:12:01 +02:00
u8 runTries;
2017-09-28 15:34:21 +02:00
u8 caughtMonNick[11];
2017-09-11 14:42:13 +02:00
u8 field_78;
u8 field_79;
u8 field_7A;
2017-09-05 09:41:48 +02:00
u8 field_7B;
u8 field_7C;
u8 field_7D;
u8 field_7E;
u8 formToChangeInto;
2018-02-06 02:46:59 +01:00
u8 chosenMovePositions[MAX_BATTLERS_COUNT];
u8 stateIdAfterSelScript[MAX_BATTLERS_COUNT];
u8 field_88;
u8 field_89;
u8 field_8A;
u8 field_8B;
u8 field_8C;
u8 field_8D;
2017-10-07 15:15:47 +02:00
u8 stringMoveType;
2018-02-07 22:53:40 +01:00
u8 expGetterBattlerId;
u8 field_90;
u8 field_91;
u8 field_92;
u8 field_93;
2017-10-24 21:45:41 +02:00
u8 wallyBattleState;
u8 wallyMovesState;
u8 wallyWaitFrames;
u8 wallyMoveFrames;
2017-09-23 20:13:45 +02:00
u8 mirrorMoves[8]; // ask gamefreak why they declared it that way
u8 field_A0;
u8 field_A1;
u8 field_A2;
u8 field_A3;
u8 field_A4;
u8 field_A5;
u8 field_A6;
u8 field_A7;
2017-10-01 01:12:42 +02:00
u16 hpOnSwitchout[2];
u32 savedBattleTypeFlags;
u8 field_B0;
u8 hpScale;
u8 synchronizeMoveEffect;
u8 field_B3;
2017-10-01 01:12:42 +02:00
void (*savedCallback)(void);
2018-02-06 02:46:59 +01:00
u16 usedHeldItems[MAX_BATTLERS_COUNT];
2017-10-26 23:12:48 +02:00
u8 chosenItem[4]; // why is this an u8?
2017-10-11 12:49:42 +02:00
u8 AI_itemType[2];
u8 AI_itemFlags[2];
2018-02-06 02:46:59 +01:00
u16 choicedMove[MAX_BATTLERS_COUNT];
u16 changedItems[MAX_BATTLERS_COUNT];
2017-09-17 14:10:32 +02:00
u8 intimidateBank;
2017-10-02 23:32:39 +02:00
u8 switchInItemsCounter;
2017-09-17 15:19:15 +02:00
u8 field_DA;
2017-09-17 14:10:32 +02:00
u8 turnSideTracker;
u8 fillerDC[0xDF-0xDC];
2017-09-17 15:19:15 +02:00
u8 field_DF;
2017-09-23 20:13:45 +02:00
u8 mirrorMoveArrays[32];
2018-02-06 02:46:59 +01:00
u16 castformPalette[MAX_BATTLERS_COUNT][16];
2017-10-01 01:12:42 +02:00
u8 field_180;
u8 field_181;
u8 field_182;
u8 field_183;
struct BattleEnigmaBerry battleEnigmaBerry;
2017-12-02 14:08:55 +01:00
u8 wishPerishSongState;
2018-02-07 22:53:40 +01:00
u8 wishPerishSongBattlerId;
2017-10-02 23:32:39 +02:00
bool8 overworldWeatherDone;
2017-09-17 14:10:32 +02:00
u8 atkCancellerTracker;
2017-10-13 17:22:50 +02:00
u8 field_1A4[96];
u8 field_204[104];
u8 field_26C[40];
2018-02-06 02:46:59 +01:00
u8 AI_monToSwitchIntoId[MAX_BATTLERS_COUNT];
2017-09-22 21:33:49 +02:00
u8 field_298[8];
u8 field_2A0;
u8 field_2A1;
2017-09-26 22:39:59 +02:00
u8 field_2A2;
2017-09-05 09:41:48 +02:00
};
extern struct BattleStruct* gBattleStruct;
2017-09-20 00:28:00 +02:00
#define GET_MOVE_TYPE(move, typeArg) \
{ \
if (gBattleStruct->dynamicMoveType) \
2017-09-20 00:28:00 +02:00
typeArg = gBattleStruct->dynamicMoveType & 0x3F; \
else \
2017-09-20 00:28:00 +02:00
typeArg = gBattleMoves[move].type; \
}
#define MOVE_EFFECT_SLEEP 0x1
#define MOVE_EFFECT_POISON 0x2
#define MOVE_EFFECT_BURN 0x3
#define MOVE_EFFECT_FREEZE 0x4
#define MOVE_EFFECT_PARALYSIS 0x5
#define MOVE_EFFECT_TOXIC 0x6
#define MOVE_EFFECT_CONFUSION 0x7
#define MOVE_EFFECT_FLINCH 0x8
#define MOVE_EFFECT_TRI_ATTACK 0x9
#define MOVE_EFFECT_UPROAR 0xA
#define MOVE_EFFECT_PAYDAY 0xB
#define MOVE_EFFECT_CHARGING 0xC
#define MOVE_EFFECT_WRAP 0xD
#define MOVE_EFFECT_RECOIL_25 0xE
2017-09-22 21:33:49 +02:00
#define MOVE_EFFECT_ATK_PLUS_1 0xF
#define MOVE_EFFECT_DEF_PLUS_1 0x10
#define MOVE_EFFECT_SPD_PLUS_1 0x11
#define MOVE_EFFECT_SP_ATK_PLUS_1 0x12
#define MOVE_EFFECT_SP_DEF_PLUS_1 0x13
#define MOVE_EFFECT_ACC_PLUS_1 0x14
#define MOVE_EFFECT_EVS_PLUS_1 0x15
#define MOVE_EFFECT_ATK_MINUS_1 0x16
#define MOVE_EFFECT_DEF_MINUS_1 0x17
#define MOVE_EFFECT_SPD_MINUS_1 0x18
#define MOVE_EFFECT_SP_ATK_MINUS_1 0x19
#define MOVE_EFFECT_SP_DEF_MINUS_1 0x1A
#define MOVE_EFFECT_ACC_MINUS_1 0x1B
#define MOVE_EFFECT_EVS_MINUS_1 0x1C
#define MOVE_EFFECT_RECHARGE 0x1D
#define MOVE_EFFECT_RAGE 0x1E
#define MOVE_EFFECT_STEAL_ITEM 0x1F
#define MOVE_EFFECT_PREVENT_ESCAPE 0x20
#define MOVE_EFFECT_NIGHTMARE 0x21
#define MOVE_EFFECT_ALL_STATS_UP 0x22
#define MOVE_EFFECT_RAPIDSPIN 0x23
#define MOVE_EFFECT_REMOVE_PARALYSIS 0x24
#define MOVE_EFFECT_ATK_DEF_DOWN 0x25
#define MOVE_EFFECT_RECOIL_33_PARALYSIS 0x26
2017-09-22 21:33:49 +02:00
#define MOVE_EFFECT_ATK_PLUS_2 0x27
#define MOVE_EFFECT_DEF_PLUS_2 0x28
#define MOVE_EFFECT_SPD_PLUS_2 0x29
#define MOVE_EFFECT_SP_ATK_PLUS_2 0x2A
#define MOVE_EFFECT_SP_DEF_PLUS_2 0x2B
#define MOVE_EFFECT_ACC_PLUS_2 0x2C
#define MOVE_EFFECT_EVS_PLUS_2 0x2D
#define MOVE_EFFECT_ATK_MINUS_2 0x2E
#define MOVE_EFFECT_DEF_MINUS_2 0x2F
#define MOVE_EFFECT_SPD_MINUS_2 0x30
#define MOVE_EFFECT_SP_ATK_MINUS_2 0x31
#define MOVE_EFFECT_SP_DEF_MINUS_2 0x32
#define MOVE_EFFECT_ACC_MINUS_2 0x33
#define MOVE_EFFECT_EVS_MINUS_2 0x34
#define MOVE_EFFECT_THRASH 0x35
#define MOVE_EFFECT_KNOCK_OFF 0x36
2017-09-22 21:33:49 +02:00
#define MOVE_EFFECT_NOTHING_37 0x37
#define MOVE_EFFECT_NOTHING_38 0x38
#define MOVE_EFFECT_NOTHING_39 0x39
#define MOVE_EFFECT_NOTHING_3A 0x3A
#define MOVE_EFFECT_SP_ATK_TWO_DOWN 0x3B
2017-09-22 21:33:49 +02:00
#define MOVE_EFFECT_NOTHING_3C 0x3C
#define MOVE_EFFECT_NOTHING_3D 0x3D
#define MOVE_EFFECT_NOTHING_3E 0x3E
#define MOVE_EFFECT_NOTHING_3F 0x3F
#define MOVE_EFFECT_AFFECTS_USER 0x40
2017-09-22 21:33:49 +02:00
#define MOVE_EFFECT_CERTAIN 0x80
#define GET_STAT_BUFF_ID(n)((n & 0xF)) // first four bits 0x1, 0x2, 0x4, 0x8
2017-09-26 22:39:59 +02:00
#define GET_STAT_BUFF_VALUE(n)(((n >> 4) & 7)) // 0x10, 0x20, 0x40
2017-09-22 21:33:49 +02:00
#define STAT_BUFF_NEGATIVE 0x80 // 0x80, the sign bit
#define SET_STAT_BUFF_VALUE(n)(((s8)(((s8)(n) << 4)) & 0xF0))
2017-11-26 11:55:17 +01:00
#define SET_STATCHANGER(statId, stage, goesDown)(gBattleScripting.statChanger = (statId) + (stage << 4) + (goesDown << 7))
2017-09-05 09:41:48 +02:00
struct BattleScripting
{
2017-09-26 22:39:59 +02:00
s32 painSplitHp;
s32 bideDmg;
u8 multihitString[6];
2017-09-05 09:41:48 +02:00
u8 dmgMultiplier;
u8 twoTurnsMoveStringId;
2017-09-17 14:10:32 +02:00
u8 animArg1;
u8 animArg2;
u16 tripleKickPower;
2017-09-17 14:10:32 +02:00
u8 atk49_state;
2018-02-06 23:09:39 +01:00
u8 battlerWithAbility;
u8 multihitMoveEffect;
2018-02-06 02:46:59 +01:00
u8 battler;
2017-09-20 00:28:00 +02:00
u8 animTurn;
u8 animTargetsHit;
2017-09-17 17:14:32 +02:00
u8 statChanger;
2017-09-22 21:33:49 +02:00
u8 field_1B;
u8 atk23_state;
2017-10-02 23:32:39 +02:00
u8 battleStyle;
2017-09-26 22:39:59 +02:00
u8 atk6C_state;
2017-09-25 00:09:13 +02:00
u8 learnMoveState;
2017-09-28 15:34:21 +02:00
u8 field_20;
2017-10-09 18:18:40 +02:00
u8 reshowMainState;
u8 reshowHelperState;
2017-10-01 01:12:42 +02:00
u8 field_23;
u8 field_24;
u8 multiplayerId;
2017-09-05 09:41:48 +02:00
};
extern struct BattleScripting gBattleScripting;
2017-10-09 18:18:40 +02:00
enum
{
BACK_PIC_BRENDAN,
BACK_PIC_MAY,
BACK_PIC_RED,
BACK_PIC_LEAF,
BACK_PIC_RS_BRENDAN,
BACK_PIC_RS_MAY,
BACK_PIC_WALLY,
BACK_PIC_STEVEN
};
2017-09-22 21:33:49 +02:00
// rom_80A5C6C
2018-02-06 02:46:59 +01:00
u8 GetBattlerSide(u8 bank);
u8 GetBattlerPosition(u8 bank);
u8 GetBattlerAtPosition(u8 bank);
2017-10-01 18:54:01 +02:00
struct BattleSpriteInfo
{
u16 invisible : 1; // 0x1
2017-11-04 16:11:13 +01:00
u16 lowHpSong : 1; // 0x2
2017-10-01 18:54:01 +02:00
u16 behindSubstitute : 1; // 0x4
u16 flag_x8 : 1; // 0x8
u16 hpNumbersNoBars : 1; // 0x10
u16 transformSpecies;
};
struct BattleAnimationInfo
{
2017-11-04 16:11:13 +01:00
u16 animArg; // to fill up later
2017-10-18 21:42:00 +02:00
u8 field_2;
u8 field_3;
u8 field_4;
u8 field_5;
u8 field_6;
u8 field_7;
2017-10-22 18:43:15 +02:00
u8 ballThrowCaseId;
2017-10-18 21:42:00 +02:00
u8 field_9_x1 : 1;
u8 field_9_x2 : 1;
u8 field_9_x1C : 3;
u8 field_9_x20 : 1;
u8 field_9_x40 : 1;
u8 field_9_x80 : 1;
2017-11-02 18:19:49 +01:00
u8 field_A;
u8 field_B;
u8 field_C;
u8 field_D;
u8 field_E;
u8 field_F;
2017-10-01 18:54:01 +02:00
};
2017-10-02 23:32:39 +02:00
struct BattleHealthboxInfo
{
u8 flag_x1 : 1;
u8 flag_x2 : 1;
u8 flag_x4 : 1;
2017-12-02 19:39:07 +01:00
u8 ballAnimActive : 1; // 0x8
2017-10-22 18:43:15 +02:00
u8 statusAnimActive : 1; // x10
u8 animFromTableActive : 1; // x20
u8 specialAnimActive : 1; //x40
u8 flag_x80 : 1;
u8 field_1_x1 : 1;
2017-10-24 15:25:20 +02:00
u8 field_1_x1E : 4;
u8 field_1_x20 : 1;
u8 field_1_x40 : 1;
u8 field_1_x80 : 1;
2017-10-02 23:32:39 +02:00
u8 field_2;
u8 field_3;
2017-10-22 18:43:15 +02:00
u8 animationState;
2017-10-02 23:32:39 +02:00
u8 field_5;
u8 field_6;
2017-11-04 16:11:13 +01:00
u8 shadowSpriteId;
2017-10-02 23:32:39 +02:00
u8 field_8;
u8 field_9;
u8 field_A;
u8 field_B;
};
2017-10-16 18:12:27 +02:00
struct BattleBarInfo
{
u8 healthboxSpriteId;
2017-10-19 15:28:41 +02:00
s32 maxValue;
s32 currentValue;
2017-10-22 18:43:15 +02:00
s32 receivedValue;
2017-10-16 18:12:27 +02:00
s32 field_10;
};
2017-10-01 18:54:01 +02:00
struct BattleSpriteData
{
2018-02-06 23:09:39 +01:00
struct BattleSpriteInfo *battlerData;
2017-10-02 23:32:39 +02:00
struct BattleHealthboxInfo *healthBoxesData;
2017-10-01 18:54:01 +02:00
struct BattleAnimationInfo *animationData;
2017-10-16 18:12:27 +02:00
struct BattleBarInfo *battleBars;
2017-10-01 18:54:01 +02:00
};
extern struct BattleSpriteData *gBattleSpritesDataPtr;
2017-10-13 17:22:50 +02:00
#define BATTLE_BUFFER_LINK_SIZE 0x1000
extern u8 *gLinkBattleSendBuffer;
extern u8 *gLinkBattleRecvBuffer;
2017-11-12 16:39:21 +01:00
extern u8 *gUnknown_0202305C;
extern u8 *gUnknown_02023060;
// Move this somewhere else
2017-09-11 18:27:54 +02:00
#include "sprite.h"
2017-10-01 01:12:42 +02:00
struct MonSpritesGfx
2017-09-11 11:35:41 +02:00
{
void* firstDecompressed; // ptr to the decompressed sprite of the first pokemon
void* sprites[4];
2017-09-11 18:27:54 +02:00
struct SpriteTemplate templates[4];
2017-11-04 16:11:13 +01:00
struct SpriteFrameImage field_74[4][4];
u8 field_F4[0x80];
u8 *barFontGfx;
void *field_178;
void *field_17C;
2017-09-11 11:35:41 +02:00
};
Decompile TV (#80) * ClearTVShowData * special_0x44 * DoTVShow (nonmatching because align) * DoTVShowBravoTrainerPokemonProfile * Update field names * DoTVShowBravoTrainerBattleTower * Renaming of struct fields * sub_80EBFF4 and UpdateTVScreensOnMap * SetTVMetatilesOnMap * Power buttons for the TV screens on the map * special_0x45 * sub_80EC18C * special_0x4a * ResetGabbyAndTy * GabbyAndTyBeforeInterview * GabbyAndTyAfterInterview * Through IsTVShowInSearchOfTrainersAiring * GabbyAndTyGetLastQuote * GabbyAndTyGetLastBattleTrivia * GabbyAndTySetScriptVarsToFieldObjectLocalIds * InterviewAfter; use TVShow as a precursor for making the individual show structs anonymous * Make TV structs anonymous within the union * Move the TV union to its own subheader * Move TV show enums to the global.tv.h subheader * Funcion renaming * Apply static attributes where able * PutPokemonTodayCaughtOnAir * sub_80EC8A4 * PutPokemonTodayFailedOnTheAir * sub_80EC9E8, sub_80ECA10 * sub_80ECA38 * sub_80ECB00 * Put3CheersForPokeblocksOnTheAir * PutFanClubSpecialOnTheAir * ContestLiveUpdates_BeforeInterview * Other before-interview Contest Live Updates functions * ContestLiveUpdates_BeforeInterview_5 * InterviewAfter_BravoTrainerPokemonProfile * BravoTrainerPokemonProfile_BeforeInterview1 * BravoTrainerPokemonProfile_BeforeInterview2 * Disassemble TV data * Decompile TV data * InterviewAfter_BravoTrainerBattleTowerProfile * SaveRecordedItemPurchasesForTVShow * PutNameRaterShowOnTheAir * StartMassOutbreak * PutLilycoveContestLadyShowOnTheAir * InterviewAfter_FanClubLetter * Rip TV strings * InterviewAfter_RecentHappenings * InterviewAfter_PkmnFanClubOpinions * sub_80ED718 * EndMassOutbreak * sub_80ED888 * sub_80ED8B4 * UpdateMassOutbreakTimeLeft * sub_80ED950 * PutFishingAdviceShowOnTheAir * through sub_80EDA80 * ewram and common syms are now fetched from the object files * BSS symbols are taken from the tv.o file * through sub_80EDC60 * sub_80EDCE8 * sub_80EDD78 * through sub_80EDE84 * nomatching sub_80EDE98 * sub_80EDFB4 * sub_80EE104 * sub_80EE104 * sub_80EE184 * sub_80EE2CC * sub_80EE35C * sub_80EE44C * sub_80EE4DC * sub_80EE5A4 * sub_80EE69C * sub_80EE72C * sub_80EE7C0 * sub_80EE818 * sub_80EE8C8 * sub_80EEA70 * sub_80EEB98 * sub_80EEBF4 * through sub_80EED60 * Functions relating to Pokemon News * sub_80EEF6C * GetPriceReduction * IsPriceDiscounted * sub_80EF120 * through sub_80EF370 * sub_80EF40C * HasMixableShowAlreadyBeenSpawnedWithPlayerID * TV_SortPurchasesByQuantity * FindActiveBroadcastByShowType_SetScriptResult * InterviewBefore * through sub_80EF88C * through sub_80EF93C * through sub_80EFA24 * through TV_BernoulliTrial * sub_80EFB58 * sub_80EFBA4 * sub_80EFBDC * through sub_80EFD98 * ChangePokemonNickname * ChangeBoxPokemonNickname * sub_80EFF9C * through player_id_to_dword * CheckForBigMovieOrEmergencyNewsOnTV * GetMomOrDadStringForTVMessage * sub_80F01E8 * sub_80F0358 * sub_80F049C * TV record mixing functions * sub_80F06D0 * sub_80F0708 nonmatching * through sub_80F0B24 * sub_80F0B64 * through sub_80F0C04 * sub_80F0C7C * sub_80F0D60 * sub_80F0E58 * sub_80F0E84 * through sub_80F0F24 * sub_80F0F64 * sub_80F1208 * sub_80F1254 * sub_80F1290 * sub_80F12A4 * sub_80F14F8 * DoTVShowTodaysSmartShopper * DoTVShowTheNameRaterShow * DoTVShowPokemonTodaySuccessfulCapture * DoTVShowPokemonTodayFailedCapture * DoTVShowPokemonFanClubLetter * DoTVShowRecentHappenings * DoTVShowPokemonFanClubOpinions * DoTVShowPokemonNewsMassOutbreak * DoTVShowPokemonContestLiveUpdates * DoTVShowPokemonBattleUpdate * DoTVShow3CheersForPokeblocks * DoTVShowInSearchOfTrainers * Label GabbyAndTyData fields; remove ddump comments from data/text/tv.inc * DoTVShowPokemonAngler * DoTVShowTheWorldOfMasters; update RAM symbols and field names * Decorate static functions * DoTVShowTodaysRivalTrainer; region map enums * TVDewfordTrendWatcherNetworkTextGroup * DoTVShowHoennTreasureInvestigators * DoTVShowFindThatGamer * DoTVShowBreakingNewsTV * DoTVShowSecretBaseVisit * DoTVShowPokemonLotterWinnerFlashReport * DoTVShowThePokemonBattleSeminar * DoTVShowTrainerFanClubSpecial, DoTVShowTrainerFanClub * DoTVShowSpotTheCuties * DoTVShowPokemonNewsBattleFrontier * DoTVShowWhatsNo1InHoennToday * Helpers for DoTVShowSecretBaseSecrets * DoTVShowSecretBaseSecrets * DoTVShowSafariFanClub * Finish decompilation of tv.s * Some renaming * Rename text group pointers * revoke statis; pokenews enums * Labels are number one * Label all TV struct fields * Make data/text/tv.inc more readable * Split data/text/tv.inc * Rename pokenews text pointers * Frontier Symbol constants; indicate static rodata objects with 's' prefix * Fix leading spaces/tabs F*** CLion sometimes * Fix inconsequential warning
2017-10-13 17:09:36 +02:00
extern struct BattleSpritesGfx* gMonSpritesGfx;
extern u8 gBattleOutcome;
extern u16 gLastUsedItem;
extern u32 gBattleTypeFlags;
2017-10-01 01:12:42 +02:00
extern struct MonSpritesGfx* gMonSpritesGfxPtr;
2017-10-27 04:49:51 +02:00
extern u16 gTrainerBattleOpponent_A;
2017-09-11 11:35:41 +02:00
#endif // GUARD_BATTLE_H