summaryrefslogtreecommitdiff
path: root/include/battle.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/battle.h')
-rw-r--r--include/battle.h79
1 files changed, 38 insertions, 41 deletions
diff --git a/include/battle.h b/include/battle.h
index e32e621cc..9434b9aa8 100644
--- a/include/battle.h
+++ b/include/battle.h
@@ -17,6 +17,11 @@
#define GET_BATTLER_SIDE(battler) (GetBattlerPosition(battler) & BIT_SIDE)
#define GET_BATTLER_SIDE2(battler) (GET_BATTLER_POSITION(battler) & BIT_SIDE)
+// Used to exclude moves learned temporarily by Transform or Mimic
+#define MOVE_IS_PERMANENT(battler, moveSlot) \
+ (!(gBattleMons[battler].status2 & STATUS2_TRANSFORMED) \
+ && !(gDisableStructs[battler].mimickedMoves & gBitTable[moveSlot]))
+
// Battle Actions
// These determine what each battler will do in a turn
#define B_ACTION_USE_MOVE 0
@@ -32,32 +37,21 @@
#define B_ACTION_EXEC_SCRIPT 10
#define B_ACTION_TRY_FINISH 11
#define B_ACTION_FINISHED 12
-
#define B_ACTION_CANCEL_PARTNER 12 // when choosing an action
#define B_ACTION_NOTHING_FAINTED 13 // when choosing an action
#define B_ACTION_NONE 0xFF
-// array entries for battle communication
-#define MULTIUSE_STATE 0
-#define CURSOR_POSITION 1
-#define TASK_ID 1 // task Id and cursor position share the same field
-#define SPRITES_INIT_STATE1 1 // shares the Id as well
-#define SPRITES_INIT_STATE2 2
-#define MOVE_EFFECT_BYTE 3
-#define ACTIONS_CONFIRMED_COUNT 4
-#define MULTISTRING_CHOOSER 5
-#define MISS_TYPE 6
-#define MSG_DISPLAY 7
-#define BATTLE_COMMUNICATION_ENTRIES_COUNT 8
-
-#define MOVE_TARGET_SELECTED 0x0
-#define MOVE_TARGET_DEPENDS 0x1
-#define MOVE_TARGET_USER_OR_SELECTED 0x2
-#define MOVE_TARGET_RANDOM 0x4
-#define MOVE_TARGET_BOTH 0x8
-#define MOVE_TARGET_USER 0x10
-#define MOVE_TARGET_FOES_AND_ALLY 0x20
-#define MOVE_TARGET_OPPONENTS_FIELD 0x40
+#define MOVE_TARGET_SELECTED 0
+#define MOVE_TARGET_DEPENDS (1 << 0)
+#define MOVE_TARGET_USER_OR_SELECTED (1 << 1)
+#define MOVE_TARGET_RANDOM (1 << 2)
+#define MOVE_TARGET_BOTH (1 << 3)
+#define MOVE_TARGET_USER (1 << 4)
+#define MOVE_TARGET_FOES_AND_ALLY (1 << 5)
+#define MOVE_TARGET_OPPONENTS_FIELD (1 << 6)
+
+// For the second argument of GetMoveTarget, when no target override is needed
+#define NO_TARGET_OVERRIDE 0
#define BATTLE_BUFFER_LINK_SIZE 0x1000
@@ -115,7 +109,7 @@ struct ProtectStruct
u32 confusionSelfDmg:1;
u32 targetNotAffected:1;
u32 chargingTurn:1;
- u32 fleeFlag:2; // For RunAway and Smoke Ball.
+ u32 fleeType:2; // 0: Normal, 1: FLEE_ITEM, 2: FLEE_ABILITY
u32 usedImprisonedMove:1;
u32 loveImmobility:1;
u32 usedDisabledMove:1;
@@ -138,7 +132,7 @@ struct SpecialStatus
u32 intimidatedMon:1;
u32 traced:1;
u32 ppNotAffectedByPressure:1;
- u32 flag40:1;
+ u32 faintedHasReplacement:1;
u32 focusBanded:1;
s32 dmg;
s32 physicalDmg;
@@ -377,9 +371,9 @@ struct BattleStruct
u8 field_52;
u8 sentInPokes;
bool8 selectionScriptFinished[MAX_BATTLERS_COUNT];
- u8 field_58[4];
+ u8 battlerPartyIndexes[MAX_BATTLERS_COUNT];
u8 monToSwitchIntoId[MAX_BATTLERS_COUNT];
- u8 field_60[4][3];
+ u8 battlerPartyOrders[MAX_BATTLERS_COUNT][PARTY_SIZE / 2];
u8 runTries;
u8 caughtMonNick[POKEMON_NAME_LENGTH + 1];
u8 unused_2;
@@ -398,7 +392,7 @@ struct BattleStruct
u8 stringMoveType;
u8 expGetterBattlerId;
u8 unused_5;
- u8 field_91; // related to gAbsentBattlerFlags, possibly absent flags turn ago?
+ u8 absentBattlerFlags;
u8 palaceFlags; // First 4 bits are "is < 50% HP and not asleep" for each battler, last 4 bits are selected moves to pass to AI
u8 field_93; // related to choosing pokemon?
u8 wallyBattleState;
@@ -426,7 +420,7 @@ struct BattleStruct
u8 unused_6[3];
u8 givenExpMons; // Bits for enemy party's pokemon that gave exp to player's party.
u8 lastTakenMoveFrom[MAX_BATTLERS_COUNT * MAX_BATTLERS_COUNT * 2]; // a 3-D array [target][attacker][byte]
- u16 castformPalette[MAX_BATTLERS_COUNT][16];
+ u16 castformPalette[NUM_CASTFORM_FORMS][16];
union {
struct LinkBattlerHeader linkBattlerHeader;
u32 battleVideo[2];
@@ -447,12 +441,16 @@ struct BattleStruct
u8 alreadyStatusedMoveAttempt; // As bits for battlers; For example when using Thunder Wave on an already paralyzed pokemon.
};
-#define GET_MOVE_TYPE(move, typeArg) \
-{ \
- if (gBattleStruct->dynamicMoveType) \
- typeArg = gBattleStruct->dynamicMoveType & 0x3F; \
- else \
- typeArg = gBattleMoves[move].type; \
+#define F_DYNAMIC_TYPE_1 (1 << 6)
+#define F_DYNAMIC_TYPE_2 (1 << 7)
+#define DYNAMIC_TYPE_MASK (F_DYNAMIC_TYPE_1 - 1)
+
+#define GET_MOVE_TYPE(move, typeArg) \
+{ \
+ if (gBattleStruct->dynamicMoveType) \
+ typeArg = gBattleStruct->dynamicMoveType & DYNAMIC_TYPE_MASK; \
+ else \
+ typeArg = gBattleMoves[move].type; \
}
#define IS_TYPE_PHYSICAL(moveType)(moveType < TYPE_MYSTERY)
@@ -476,6 +474,8 @@ struct BattleStruct
#define SET_STATCHANGER(statId, stage, goesDown)(gBattleScripting.statChanger = (statId) + (stage << 4) + (goesDown << 7))
+// NOTE: The members of this struct have hard-coded offsets
+// in include/constants/battle_script_commands.h
struct BattleScripting
{
s32 painSplitHp;
@@ -498,18 +498,15 @@ struct BattleScripting
u8 battleStyle;
u8 drawlvlupboxState;
u8 learnMoveState;
- u8 field_20;
+ u8 pursuitDoublesAttacker;
u8 reshowMainState;
u8 reshowHelperState;
u8 levelUpHP;
- u8 windowsType; // 0 - normal, 1 - battle arena
+ u8 windowsType; // B_WIN_TYPE_*
u8 multiplayerId;
u8 specialTrainerBattleType;
};
-// rom_80A5C6C
-
-
struct BattleSpriteInfo
{
u16 invisible:1; // 0x1
@@ -624,8 +621,8 @@ extern u8 gBattleTextBuff3[TEXT_BUFF_ARRAY_COUNT];
extern u32 gBattleTypeFlags;
extern u8 gBattleTerrain;
extern u32 gUnusedFirstBattleVar1;
-extern u8 *gUnknown_0202305C;
-extern u8 *gUnknown_02023060;
+extern u8 *gBattleAnimBgTileBuffer;
+extern u8 *gBattleAnimBgTilemapBuffer;
extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200];
extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200];
extern u8 gActiveBattler;