diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/battle.h | 76 | ||||
-rw-r--r-- | include/constants/battle_constants.h | 73 | ||||
-rw-r--r-- | include/macros/battle_script.inc | 2 | ||||
-rw-r--r-- | include/pokemon.h | 4 | ||||
-rw-r--r-- | include/rom_8077ABC.h | 12 |
5 files changed, 113 insertions, 54 deletions
diff --git a/include/battle.h b/include/battle.h index 6fa5c1ffe..48194d711 100644 --- a/include/battle.h +++ b/include/battle.h @@ -13,20 +13,48 @@ #define BATTLE_BANKS_COUNT 4 -#define IDENTITY_PLAYER_MON1 0 -#define IDENTITY_OPPONENT_MON1 1 -#define IDENTITY_PLAYER_MON2 2 -#define IDENTITY_OPPONENT_MON2 3 - -#define SIDE_PLAYER 0x0 -#define SIDE_OPPONENT 0x1 - -#define BIT_SIDE 0x1 -#define BIT_MON 0x2 - -#define GET_BANK_IDENTITY(bank)((gBanksByIdentity[bank])) -#define GET_BANK_SIDE(bank)((GetBankIdentity(bank) & BIT_SIDE)) -#define GET_BANK_SIDE2(bank)((GET_BANK_IDENTITY(bank) & BIT_SIDE)) +#define B_POSITION_PLAYER_LEFT 0 +#define B_POSITION_OPPONENT_LEFT 1 +#define B_POSITION_PLAYER_RIGHT 2 +#define B_POSITION_OPPONENT_RIGHT 3 + +#define GET_BATTLER_POSITION(bank)((gBanksByIdentity[bank])) +#define GET_BATTLER_SIDE(bank)((GetBattlerPosition(bank) & BIT_SIDE)) +#define GET_BATTLER_SIDE2(bank)((GET_BATTLER_POSITION(bank) & BIT_SIDE)) + +// 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 + +// 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 +#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 enum { @@ -179,7 +207,7 @@ struct BattleStruct /* 0x2000000 */ /*0x1605F*/ u8 sentInPokes; /*0x16060*/ u8 unk16060[4]; /*0x16064*/ u8 unk16064[4]; - /*0x16068*/ u8 unk16068[4]; + /*0x16068*/ u8 monToSwitchIntoId[MAX_BATTLERS_COUNT]; /*0x1606C*/ u8 unk1606C[4][3]; /*0x16078*/ u8 unk16078; /*0x16079*/ u8 caughtNick[11]; @@ -519,21 +547,21 @@ struct sideTimer struct WishFutureKnock { - u8 futureSightCounter[MAX_BANKS_BATTLE]; - u8 futureSightAttacker[MAX_BANKS_BATTLE]; - s32 futureSightDmg[MAX_BANKS_BATTLE]; - u16 futureSightMove[MAX_BANKS_BATTLE]; - u8 wishCounter[MAX_BANKS_BATTLE]; - u8 wishUserID[MAX_BANKS_BATTLE]; + 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]; + u8 wishUserID[MAX_BATTLERS_COUNT]; u8 weatherDuration; u8 knockedOffPokes[2]; }; extern struct UnkBattleStruct1 unk_2016A00; -extern struct DisableStruct gDisableStructs[MAX_BANKS_BATTLE]; +extern struct DisableStruct gDisableStructs[MAX_BATTLERS_COUNT]; extern struct BattleResults gBattleResults; -extern struct ProtectStruct gProtectStructs[MAX_BANKS_BATTLE]; -extern struct SpecialStatus gSpecialStatuses[MAX_BANKS_BATTLE]; +extern struct ProtectStruct gProtectStructs[MAX_BATTLERS_COUNT]; +extern struct SpecialStatus gSpecialStatuses[MAX_BATTLERS_COUNT]; extern struct sideTimer gSideTimers[2]; extern struct WishFutureKnock gWishFutureKnock; extern struct AI_ThinkingStruct gAIThinkingSpace; diff --git a/include/constants/battle_constants.h b/include/constants/battle_constants.h index 49768f33e..65f44d8aa 100644 --- a/include/constants/battle_constants.h +++ b/include/constants/battle_constants.h @@ -1,12 +1,47 @@ #ifndef GUARD_CONSTANTS_BATTLE_CONSTANTS_H #define GUARD_CONSTANTS_BATTLE_CONSTANTS_H -// Bank sides -#define SIDE_PLAYER 0x0 -#define SIDE_OPPONENT 0x1 - -#define BIT_SIDE 0x1 -#define BIT_MON 0x2 +/* + * 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. + * 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. + * + * + ------------------------- + + * | Opponent's side | + * | Right Left | + * | 3 1 | + * | | + * | Player's side | + * | Left Right | + * | 0 2 | + * ----------------------------+ + * | | + * | | + * +---------------------------+ + */ + +#define MAX_BATTLERS_COUNT 4 + +#define B_POSITION_PLAYER_LEFT 0 +#define B_POSITION_OPPONENT_LEFT 1 +#define B_POSITION_PLAYER_RIGHT 2 +#define B_POSITION_OPPONENT_RIGHT 3 + +// 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) + +#define B_SIDE_PLAYER 0 +#define B_SIDE_OPPONENT 1 + +#define B_FLANK_LEFT 0 +#define B_FLANK_RIGHT 1 + +#define BIT_SIDE 1 +#define BIT_FLANK 2 #define STATUS_SLEEP 0x7 #define STATUS_POISON 0x8 @@ -88,19 +123,16 @@ #define HITMARKER_FAINTED(bank) ((gBitTable[bank] << 0x1C)) #define HITMARKER_UNK(bank) ((0x10000000 << bank)) -#define MOVESTATUS_MISSED (1 << 0) -#define MOVESTATUS_SUPEREFFECTIVE (1 << 1) -#define MOVESTATUS_NOTVERYEFFECTIVE (1 << 2) -#define MOVESTATUS_NOTAFFECTED (1 << 3) -#define MOVESTATUS_ONEHITKO (1 << 4) -#define MOVESTATUS_FAILED (1 << 5) -#define MOVESTATUS_ENDURED (1 << 6) -#define MOVESTATUS_HUNGON (1 << 7) - -#define IDENTITY_PLAYER_MON1 0 -#define IDENTITY_OPPONENT_MON1 1 -#define IDENTITY_PLAYER_MON2 2 -#define IDENTITY_OPPONENT_MON2 3 +// Flags describing move's result +#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) #define BATTLE_TYPE_DOUBLE 0x0001 #define BATTLE_TYPE_LINK 0x0002 @@ -206,11 +238,8 @@ #define WEATHER_HAS_EFFECT ((!AbilityBattleEffects(ABILITYEFFECT_CHECK_ON_FIELD, 0, ABILITY_CLOUD_NINE, 0, 0) && !AbilityBattleEffects(ABILITYEFFECT_CHECK_ON_FIELD, 0, ABILITY_AIR_LOCK, 0, 0))) -#define MOVESTATUS_NOEFFECT ((MOVESTATUS_MISSED | MOVESTATUS_NOTAFFECTED | MOVESTATUS_FAILED)) - #define MAX_TRAINER_ITEMS 4 #define MAX_MON_MOVES 4 -#define MAX_BANKS_BATTLE 4 #define WEATHER_RAIN_TEMPORARY (1 << 0) #define WEATHER_RAIN_DOWNPOUR (1 << 1) diff --git a/include/macros/battle_script.inc b/include/macros/battle_script.inc index e4fa0c454..d92e28934 100644 --- a/include/macros/battle_script.inc +++ b/include/macros/battle_script.inc @@ -1402,7 +1402,7 @@ .endm .macro jumpifmovehadnoeffect jumpptr - jumpifbyte COMMON_BITS, gBattleMoveFlags, MOVESTATUS_MISSED | MOVESTATUS_NOTAFFECTED | MOVESTATUS_FAILED, \jumpptr + jumpifbyte COMMON_BITS, gMoveResultFlags, MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE | MOVE_RESULT_FAILED, \jumpptr .endm .macro jumpifbattletype flags, jumpptr diff --git a/include/pokemon.h b/include/pokemon.h index 169045c0c..90d384d91 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -312,6 +312,8 @@ struct UnknownPokemonStruct /*0x2B*/u8 friendship; }; +#define BATTLE_STATS_NO 8 + struct BattlePokemon { /*0x00*/ u16 species; @@ -329,7 +331,7 @@ struct BattlePokemon /*0x17*/ u32 spDefenseIV:5; /*0x17*/ u32 isEgg:1; /*0x17*/ u32 altAbility:1; - /*0x18*/ s8 statStages[8]; + /*0x18*/ s8 statStages[BATTLE_STATS_NO]; /*0x20*/ u8 ability; /*0x21*/ u8 type1; /*0x22*/ u8 type2; diff --git a/include/rom_8077ABC.h b/include/rom_8077ABC.h index 1910b7cb2..272509b8f 100644 --- a/include/rom_8077ABC.h +++ b/include/rom_8077ABC.h @@ -23,11 +23,11 @@ u8 GetBankSide(u8); u8 GetBankSide(u8 side); u8 GetBankSide(u8 slot); u8 GetBankSide(u8); -u8 GetBankIdentity(u8); -u8 GetBankIdentity(u8 slot); -u8 GetBankByIdentity(u8); -u8 GetBankByIdentity(u8); -u8 GetBankByIdentity(u8 state); +u8 GetBattlerPosition(u8); +u8 GetBattlerPosition(u8 slot); +u8 GetBattlerAtPosition(u8); +u8 GetBattlerAtPosition(u8); +u8 GetBattlerAtPosition(u8 state); bool8 IsBankSpritePresent(u8); bool8 IsDoubleBattle(); u8 IsDoubleBattle(void); @@ -58,7 +58,7 @@ void sub_8079C08(struct Task *task, u8 a2, s16 a3, s16 a4, s16 a5, s16 a6, u16 a u8 sub_8079C74(struct Task *task); void sub_8079E24(); u8 sub_8079E90(u8 slot); -u8 GetBankIdentity_permutated(u8 slot); +u8 GetBattlerPosition_permutated(u8 slot); void sub_807A784(u8 taskId); void sub_807A850(struct Task *task, u8 taskId); void sub_807A8D4(struct Sprite *sprite); |