decomp calc dmg and clean up battle ai

This commit is contained in:
DizzyEggg 2017-09-04 21:43:13 +02:00
parent 92892d140a
commit 2702b0ec9b
19 changed files with 1749 additions and 1249 deletions

View File

@ -4237,7 +4237,7 @@ _0804207C:
adds r0, r1, 0
movs r2, 0x1
movs r3, 0
bl sub_806957C
bl CalculateBaseDamage
ldr r1, =gBattleMoveDamage
str r0, [r1]
ldr r0, =gProtectStructs
@ -11133,7 +11133,7 @@ _08045F8C:
adds r0, r1, 0
movs r2, 0x1
movs r3, 0
bl sub_806957C
bl CalculateBaseDamage
ldr r1, =gBattleMoveDamage
str r0, [r1]
ldr r1, =gBankTarget

View File

@ -1572,7 +1572,7 @@ atk05_damagecalc1: @ 8046D8C
str r4, [sp, 0x8]
ldrb r4, [r5]
str r4, [sp, 0xC]
bl sub_806957C
bl CalculateBaseDamage
ldr r4, =gBattleMoveDamage
ldr r1, =gCritMultiplier
ldrb r1, [r1]
@ -1670,7 +1670,7 @@ sub_8046E7C: @ 8046E7C
str r4, [sp, 0x4]
str r7, [sp, 0x8]
str r5, [sp, 0xC]
bl sub_806957C
bl CalculateBaseDamage
ldr r4, =gBattleMoveDamage
movs r1, 0
strh r1, [r6]
@ -18750,7 +18750,7 @@ _0805035C:
cmp r0, 0
beq _080503CC
movs r0, 0x1
bl sub_8069DEC
bl CountAliveMonsInBattle
lsls r0, 24
lsrs r1, r0, 24
cmp r1, 0x2
@ -19329,7 +19329,7 @@ _08050828:
str r4, [sp, 0x8]
ldrb r4, [r5]
str r4, [sp, 0xC]
bl sub_806957C
bl CalculateBaseDamage
ldrb r2, [r6]
lsls r1, r2, 3
subs r1, r2
@ -21033,7 +21033,7 @@ _080516A4:
cmp r0, 0
beq _08051714
movs r0, 0x1
bl sub_8069DEC
bl CountAliveMonsInBattle
lsls r0, 24
lsrs r0, 24
cmp r0, 0x2
@ -26497,7 +26497,7 @@ _080545DC:
str r4, [sp, 0x8]
ldrb r4, [r6]
str r4, [sp, 0xC]
bl sub_806957C
bl CalculateBaseDamage
ldrb r1, [r6]
lsls r1, 2
mov r2, r8

View File

@ -991,7 +991,7 @@ _08057D24:
cmp r0, 0
bne _08057D5A
movs r0, 0
bl sub_8069DEC
bl CountAliveMonsInBattle
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1

File diff suppressed because it is too large Load Diff

View File

@ -5,8 +5,8 @@
.text
thumb_func_start sub_8069DEC
sub_8069DEC: @ 8069DEC
thumb_func_start CountAliveMonsInBattle
CountAliveMonsInBattle: @ 8069DEC
push {r4-r6,lr}
lsls r0, 24
lsrs r0, 24
@ -115,10 +115,10 @@ _08069EC2:
pop {r1}
bx r1
.pool
thumb_func_end sub_8069DEC
thumb_func_end CountAliveMonsInBattle
thumb_func_start sub_8069ED8
sub_8069ED8: @ 8069ED8
thumb_func_start ShouldGetStatBadgeBoost
ShouldGetStatBadgeBoost: @ 8069ED8
push {r4,r5,lr}
lsls r0, 16
lsrs r5, r0, 16
@ -162,7 +162,7 @@ _08069F2E:
pop {r4,r5}
pop {r1}
bx r1
thumb_func_end sub_8069ED8
thumb_func_end ShouldGetStatBadgeBoost
thumb_func_start sub_8069F34
sub_8069F34: @ 8069F34
@ -186,7 +186,7 @@ sub_8069F34: @ 8069F34
.pool
_08069F5C:
movs r0, 0
bl sub_8069DEC
bl CountAliveMonsInBattle
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1

View File

@ -14889,7 +14889,7 @@ _0803CFDC:
adds r4, r0, r1
ldrh r0, [r4, 0x6]
muls r3, r0
ldr r2, =gUnknown_08329D2E
ldr r2, =gStatStageRatios
movs r1, 0x1B
ldrsb r1, [r4, r1]
lsls r1, 1
@ -14993,7 +14993,7 @@ _0803D0B8:
ldrh r0, [r4, 0x6]
adds r3, r0, 0
muls r3, r7
ldr r2, =gUnknown_08329D2E
ldr r2, =gStatStageRatios
movs r1, 0x1B
ldrsb r1, [r4, r1]
lsls r1, 1

View File

@ -4443,7 +4443,7 @@ _0817EFC2:
mov r6, r9
ldrb r4, [r6]
str r4, [sp, 0xC]
bl sub_806957C
bl CalculateBaseDamage
adds r3, r0, 0
ldr r4, =gBattleMoveDamage
str r3, [r4]

View File

@ -67,7 +67,7 @@ gUnknown_08329D26:: @ 8329D26
gUnknown_08329D2A:: @ 8329D2A
.incbin "baserom.gba", 0x329d2a, 0x4
gUnknown_08329D2E:: @ 8329D2E
gStatStageRatios:: @ 8329D2E
.incbin "baserom.gba", 0x329d2e, 0x1a
gUnknown_08329D48:: @ 8329D48

View File

@ -17,11 +17,20 @@
#define BATTLE_TYPE_LEGENDARY 0x2000
#define BATTLE_TYPE_REGI 0x4000
#define BATTLE_TYPE_TWO_VS_ONE 0x8000
#define BATTLE_TYPE_DOME 0x10000
#define BATTLE_TYPE_PALACE 0x20000
#define BATTLE_TYPE_ARENA 0x40000
#define BATTLE_TYPE_FACTORY 0x80000
#define BATTLE_TYPE_x100000 0x100000
#define BATTLE_TYPE_PYRAMID 0x200000
#define BATTLE_TYPE_INGAME_PARTNER 0x400000
#define BATTLE_TYPE_RECORDED 0x1000000
#define BATTLE_TYPE_GROUDON 0x10000000
#define BATTLE_TYPE_KYORGE 0x20000000
#define BATTLE_TYPE_RAYQUAZA 0x40000000
#define BATTLE_TYPE_FRONTIER (BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_x100000 | BATTLE_TYPE_PYRAMID)
#define AI_ACTION_UNK1 0x0001
#define AI_ACTION_UNK2 0x0002
#define AI_ACTION_UNK3 0x0004
@ -31,4 +40,239 @@
#define AI_ACTION_UNK7 0x0040
#define AI_ACTION_UNK8 0x0080
#define STATUS_SLEEP 0x7
#define STATUS_POISON 0x8
#define STATUS_BURN 0x10
#define STATUS_FREEZE 0x20
#define STATUS_PARALYSIS 0x40
#define STATUS_TOXIC_POISON 0x80
#define STATUS_TOXIC_COUNTER 0xF00
#define STATUS_PSN_ANY ((STATUS_POISON | STATUS_TOXIC_POISON))
#define STATUS_ANY ((STATUS_SLEEP | STATUS_POISON | STATUS_BURN | STATUS_FREEZE | STATUS_PARALYSIS | STATUS_TOXIC_POISON))
#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
#define STATUS2_INFATUATION 0x000F0000
#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
#define STATUS3_LEECHSEED_BANK 0x3
#define STATUS3_LEECHSEED 0x4
#define STATUS3_ALWAYS_HITS 0x18 //two bits
#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
#define STATUS3_YAWN 0x1800 //two bits
#define STATUS3_IMPRISIONED 0x2000
#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
#define STATUS3_SEMI_INVULNERABLE ((STATUS3_UNDERGROUND | STATUS3_ON_AIR | STATUS3_UNDERWATER))
#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
#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
#define HITMARKER_x8000000 0x08000000
#define HITMARKER_FAINTED(bank) ((gBitTable[bank] << 0x1C))
#define HITMARKER_UNK(bank) ((0x10000000 << bank))
#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)
#define ABILITYEFFECT_ON_SWITCHIN 0x0
#define ABILITYEFFECT_ENDTURN 0x1
#define ABILITYEFFECT_MOVES_BLOCK 0x2
#define ABILITYEFFECT_ABSORBING 0x3
#define ABILITYEFFECT_CONTACT 0x4
#define ABILITYEFFECT_IMMUNITY 0x5
#define ABILITYEFFECT_FORECAST 0x6
#define ABILITYEFFECT_SYNCHRONIZE 0x7
#define ABILITYEFFECT_ATK_SYNCHRONIZE 0x8
#define ABILITYEFFECT_INTIMIDATE1 0x9
#define ABILITYEFFECT_INTIMIDATE2 0xA
#define ABILITYEFFECT_TRACE 0xB
#define ABILITYEFFECT_CHECK_OTHER_SIDE 0xC
#define ABILITYEFFECT_CHECK_BANK_SIDE 0xD
#define ABILITYEFFECT_FIELD_SPORT 0xE
#define ABILITYEFFECT_CHECK_FIELD_EXCEPT_BANK 0xF
#define ABILITYEFFECT_COUNT_OTHER_SIZE 0x10
#define ABILITYEFFECT_COUNT_BANK_SIDE 0x11
#define ABILITYEFFECT_COUNT_ON_FIELD 0x12
#define ABILITYEFFECT_CHECK_ON_FIELD 0x13
#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_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 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)
#define WEATHER_RAIN_PERMANENT (1 << 2)
#define WEATHER_RAIN_ANY ((WEATHER_RAIN_TEMPORARY | WEATHER_RAIN_DOWNPOUR | WEATHER_RAIN_PERMANENT))
#define WEATHER_SANDSTORM_TEMPORARY (1 << 3)
#define WEATHER_SANDSTORM_PERMANENT (1 << 4)
#define WEATHER_SANDSTORM_ANY ((WEATHER_SANDSTORM_TEMPORARY | WEATHER_SANDSTORM_PERMANENT))
#define WEATHER_SUN_TEMPORARY (1 << 5)
#define WEATHER_SUN_PERMANENT (1 << 6)
#define WEATHER_SUN_ANY ((WEATHER_SUN_TEMPORARY | WEATHER_SUN_PERMANENT))
#define WEATHER_HAIL (1 << 7)
u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg);
u8 GetBankSide(u8 bank);
// TODO: get rid of void* and make actual struct fields
struct UnknownFlags
{
u32 flags[4];
};
#define UNKNOWN_FLAG_FLASH_FIRE 1
struct DisableStruct
{
/*0x00*/ u32 unk0;
/*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;
/*0x0F*/ u8 perishSong1 : 4;
/*0x0F*/ u8 perishSong2 : 4;
/*0x10*/ u8 furyCutterCounter;
/*0x11*/ u8 rolloutTimer1 : 4;
/*0x11*/ u8 rolloutTimer2 : 4;
/*0x12*/ u8 chargeTimer1 : 4;
/*0x12*/ u8 chargeTimer2 : 4;
/*0x13*/ u8 tauntTimer1:4;
/*0x13*/ u8 tauntTimer2:4;
/*0x14*/ u8 bankPreventingEscape;
/*0x15*/ u8 bankWithSureHit;
/*0x16*/ u8 isFirstTurn;
/*0x17*/ u8 unk17;
/*0x18*/ u8 truantCounter : 1;
/*0x18*/ u8 unk18_a : 3;
/*0x18*/ u8 unk18_b : 4;
/*0x19*/ u8 rechargeCounter;
/*0x1A*/ u8 unk1A[2];
};
extern struct DisableStruct gDisableStructs[];
//size should be 0x1C
struct AI_ThinkingStruct
{
u8 aiState;
u8 movesetIndex;
u16 moveConsidered;
s8 score[4];
u32 funcResult;
u32 aiFlags;
u8 aiAction;
u8 aiLogicId;
u8 filler12[6];
u8 unk18[4];
};
struct UsedMoves
{
u16 moves[4];
u16 unknown[4];
};
//size should be 0x54
struct BattleHistory
{
struct UsedMoves usedMoves[4];
u8 abilities[4];
u8 itemEffects[4];
u16 TrainerItems[4];
u8 unk50;
};
struct BattleScriptsStack
{
u8 *ptr[8];
u8 size;
};
struct BattleResources
{
void* secretBaseOpponent;
struct UnknownFlags *flags;
struct BattleScriptsStack* battleScriptsStack;
void* battleCallbackStack;
void* statsBeforeLvlUp;
struct AI_ThinkingStruct *ai;
struct BattleHistory *battleHistory;
struct BattleScriptsStack *AI_ScriptsStack;
};
extern struct BattleResources* gBattleResources;
#endif

View File

@ -0,0 +1,222 @@
#ifndef GUARD_BATTLE_MOVE_EFFECTS_H
#define GUARD_BATTLE_MOVE_EFFECTS_H
enum
{
EFFECT_HIT,
EFFECT_SLEEP,
EFFECT_POISON_HIT,
EFFECT_ABSORB,
EFFECT_BURN_HIT,
EFFECT_FREEZE_HIT,
EFFECT_PARALYZE_HIT,
EFFECT_EXPLOSION,
EFFECT_DREAM_EATER,
EFFECT_MIRROR_MOVE,
EFFECT_ATTACK_UP,
EFFECT_DEFENSE_UP,
EFFECT_SPEED_UP,
EFFECT_SPECIAL_ATTACK_UP,
EFFECT_SPECIAL_DEFENSE_UP,
EFFECT_ACCURACY_UP,
EFFECT_EVASION_UP,
EFFECT_ALWAYS_HIT,
EFFECT_ATTACK_DOWN,
EFFECT_DEFENSE_DOWN,
EFFECT_SPEED_DOWN,
EFFECT_SPECIAL_ATTACK_DOWN, // unused
EFFECT_SPECIAL_DEFENSE_DOWN, // unused
EFFECT_ACCURACY_DOWN,
EFFECT_EVASION_DOWN,
EFFECT_HAZE,
EFFECT_BIDE,
EFFECT_RAMPAGE,
EFFECT_ROAR,
EFFECT_MULTI_HIT,
EFFECT_CONVERSION,
EFFECT_FLINCH_HIT,
EFFECT_RESTORE_HP,
EFFECT_TOXIC,
EFFECT_PAY_DAY,
EFFECT_LIGHT_SCREEN,
EFFECT_TRI_ATTACK,
EFFECT_REST,
EFFECT_OHKO,
EFFECT_RAZOR_WIND,
EFFECT_SUPER_FANG,
EFFECT_DRAGON_RAGE,
EFFECT_TRAP,
EFFECT_HIGH_CRITICAL,
EFFECT_DOUBLE_HIT,
EFFECT_RECOIL_IF_MISS,
EFFECT_MIST,
EFFECT_FOCUS_ENERGY,
EFFECT_RECOIL,
EFFECT_CONFUSE,
EFFECT_ATTACK_UP_2,
EFFECT_DEFENSE_UP_2,
EFFECT_SPEED_UP_2,
EFFECT_SPECIAL_ATTACK_UP_2,
EFFECT_SPECIAL_DEFENSE_UP_2,
EFFECT_ACCURACY_UP_2,
EFFECT_EVASION_UP_2,
EFFECT_TRANSFORM,
EFFECT_ATTACK_DOWN_2,
EFFECT_DEFENSE_DOWN_2,
EFFECT_SPEED_DOWN_2,
EFFECT_SPECIAL_ATTACK_DOWN_2,
EFFECT_SPECIAL_DEFENSE_DOWN_2,
EFFECT_ACCURACY_DOWN_2,
EFFECT_EVASION_DOWN_2,
EFFECT_REFLECT,
EFFECT_POISON,
EFFECT_PARALYZE,
EFFECT_ATTACK_DOWN_HIT,
EFFECT_DEFENSE_DOWN_HIT,
EFFECT_SPEED_DOWN_HIT,
EFFECT_SPECIAL_ATTACK_DOWN_HIT,
EFFECT_SPECIAL_DEFENSE_DOWN_HIT,
EFFECT_ACCURACY_DOWN_HIT,
EFFECT_EVASION_DOWN_HIT,
EFFECT_SKY_ATTACK,
EFFECT_CONFUSE_HIT,
EFFECT_TWINEEDLE,
EFFECT_VITAL_THROW,
EFFECT_SUBSTITUTE,
EFFECT_RECHARGE,
EFFECT_RAGE,
EFFECT_MIMIC,
EFFECT_METRONOME,
EFFECT_LEECH_SEED,
EFFECT_SPLASH,
EFFECT_DISABLE,
EFFECT_LEVEL_DAMAGE,
EFFECT_PSYWAVE,
EFFECT_COUNTER,
EFFECT_ENCORE,
EFFECT_PAIN_SPLIT,
EFFECT_SNORE,
EFFECT_CONVERSION_2,
EFFECT_LOCK_ON,
EFFECT_SKETCH,
EFFECT_UNUSED_60, // thaw
EFFECT_SLEEP_TALK,
EFFECT_DESTINY_BOND,
EFFECT_FLAIL,
EFFECT_SPITE,
EFFECT_FALSE_SWIPE,
EFFECT_HEAL_BELL,
EFFECT_QUICK_ATTACK,
EFFECT_TRIPLE_KICK,
EFFECT_THIEF,
EFFECT_MEAN_LOOK,
EFFECT_NIGHTMARE,
EFFECT_MINIMIZE,
EFFECT_CURSE,
EFFECT_UNUSED_6E,
EFFECT_PROTECT,
EFFECT_SPIKES,
EFFECT_FORESIGHT,
EFFECT_PERISH_SONG,
EFFECT_SANDSTORM,
EFFECT_ENDURE,
EFFECT_ROLLOUT,
EFFECT_SWAGGER,
EFFECT_FURY_CUTTER,
EFFECT_ATTRACT,
EFFECT_RETURN,
EFFECT_PRESENT,
EFFECT_FRUSTRATION,
EFFECT_SAFEGUARD,
EFFECT_THAW_HIT,
EFFECT_MAGNITUDE,
EFFECT_BATON_PASS,
EFFECT_PURSUIT,
EFFECT_RAPID_SPIN,
EFFECT_SONICBOOM,
EFFECT_UNUSED_83,
EFFECT_MORNING_SUN,
EFFECT_SYNTHESIS,
EFFECT_MOONLIGHT,
EFFECT_HIDDEN_POWER,
EFFECT_RAIN_DANCE,
EFFECT_SUNNY_DAY,
EFFECT_DEFENSE_UP_HIT,
EFFECT_ATTACK_UP_HIT,
EFFECT_ALL_STATS_UP_HIT,
EFFECT_UNUSED_8D, // incomplete fake out in gen 2
EFFECT_BELLY_DRUM,
EFFECT_PSYCH_UP,
EFFECT_MIRROR_COAT,
EFFECT_SKULL_BASH,
EFFECT_TWISTER,
EFFECT_EARTHQUAKE,
EFFECT_FUTURE_SIGHT,
EFFECT_GUST,
EFFECT_FLINCH_HIT_2, // STOMP ASTONISH EXTRASENSORY NEEDLE_ARM
EFFECT_SOLARBEAM,
EFFECT_THUNDER,
EFFECT_TELEPORT,
EFFECT_BEAT_UP,
EFFECT_FLY,
EFFECT_DEFENSE_CURL,
EFFECT_SOFTBOILED,
EFFECT_FAKE_OUT,
EFFECT_UPROAR,
EFFECT_STOCKPILE,
EFFECT_SPIT_UP,
EFFECT_SWALLOW,
EFFECT_UNUSED_A3,
EFFECT_HAIL,
EFFECT_TORMENT,
EFFECT_FLATTER,
EFFECT_WILL_O_WISP,
EFFECT_MEMENTO,
EFFECT_FACADE,
EFFECT_FOCUS_PUNCH,
EFFECT_SMELLINGSALT,
EFFECT_FOLLOW_ME,
EFFECT_NATURE_POWER,
EFFECT_CHARGE,
EFFECT_TAUNT,
EFFECT_HELPING_HAND,
EFFECT_TRICK,
EFFECT_ROLE_PLAY,
EFFECT_WISH,
EFFECT_ASSIST,
EFFECT_INGRAIN,
EFFECT_SUPERPOWER,
EFFECT_MAGIC_COAT,
EFFECT_RECYCLE,
EFFECT_REVENGE,
EFFECT_BRICK_BREAK,
EFFECT_YAWN,
EFFECT_KNOCK_OFF,
EFFECT_ENDEAVOR,
EFFECT_ERUPTION,
EFFECT_SKILL_SWAP,
EFFECT_IMPRISON,
EFFECT_REFRESH,
EFFECT_GRUDGE,
EFFECT_SNATCH,
EFFECT_LOW_KICK,
EFFECT_SECRET_POWER,
EFFECT_DOUBLE_EDGE,
EFFECT_TEETER_DANCE,
EFFECT_BLAZE_KICK,
EFFECT_MUD_SPORT,
EFFECT_POISON_FANG,
EFFECT_WEATHER_BALL,
EFFECT_OVERHEAT,
EFFECT_TICKLE,
EFFECT_COSMIC_POWER,
EFFECT_SKY_UPPERCUT,
EFFECT_BULK_UP,
EFFECT_POISON_TAIL,
EFFECT_WATER_SPORT,
EFFECT_CALM_MIND,
EFFECT_DRAGON_DANCE,
EFFECT_CAMOUFLAGE,
};
#endif // GUARD_BATTLE_MOVE_EFFECTS_H

View File

@ -19,9 +19,29 @@ struct Berry
u8 smoothness;
};
// with no const fields
struct Berry2
{
u8 name[7];
u8 firmness;
u16 size;
u8 maxYield;
u8 minYield;
u8 *description1;
u8 *description2;
u8 stageDuration;
u8 spicy;
u8 dry;
u8 sweet;
u8 bitter;
u8 sour;
u8 smoothness;
};
struct EnigmaBerry
{
struct Berry berry;
struct Berry2 berry;
u8 pic[(6 * 6) * TILE_SIZE_4BPP];
u16 palette[16];
u8 description1[45];

72
include/hold_effects.h Normal file
View File

@ -0,0 +1,72 @@
#ifndef GUARD_HOLD_EFFECTS_H
#define GUARD_HOLD_EFFECTS_H
#define HOLD_EFFECT_NONE 0
#define HOLD_EFFECT_RESTORE_HP 1
#define HOLD_EFFECT_CURE_PAR 2
#define HOLD_EFFECT_CURE_SLP 3
#define HOLD_EFFECT_CURE_PSN 4
#define HOLD_EFFECT_CURE_BRN 5
#define HOLD_EFFECT_CURE_FRZ 6
#define HOLD_EFFECT_RESTORE_PP 7
#define HOLD_EFFECT_CURE_CONFUSION 8
#define HOLD_EFFECT_CURE_STATUS 9
#define HOLD_EFFECT_CONFUSE_SPICY 10
#define HOLD_EFFECT_CONFUSE_DRY 11
#define HOLD_EFFECT_CONFUSE_SWEET 12
#define HOLD_EFFECT_CONFUSE_BITTER 13
#define HOLD_EFFECT_CONFUSE_SOUR 14
#define HOLD_EFFECT_ATTACK_UP 15
#define HOLD_EFFECT_DEFENSE_UP 16
#define HOLD_EFFECT_SPEED_UP 17
#define HOLD_EFFECT_SP_ATTACK_UP 18
#define HOLD_EFFECT_SP_DEFENSE_UP 19
#define HOLD_EFFECT_CRITICAL_UP 20
#define HOLD_EFFECT_RANDOM_STAT_UP 21
#define HOLD_EFFECT_EVASION_UP 22
#define HOLD_EFFECT_RESTORE_STATS 23
#define HOLD_EFFECT_MACHO_BRACE 24
#define HOLD_EFFECT_EXP_SHARE 25
#define HOLD_EFFECT_QUICK_CLAW 26
#define HOLD_EFFECT_HAPPINESS_UP 27
#define HOLD_EFFECT_CURE_ATTRACT 28
#define HOLD_EFFECT_CHOICE_BAND 29
#define HOLD_EFFECT_FLINCH 30
#define HOLD_EFFECT_BUG_POWER 31
#define HOLD_EFFECT_DOUBLE_PRIZE 32
#define HOLD_EFFECT_REPEL 33
#define HOLD_EFFECT_SOUL_DEW 34
#define HOLD_EFFECT_DEEP_SEA_TOOTH 35
#define HOLD_EFFECT_DEEP_SEA_SCALE 36
#define HOLD_EFFECT_CAN_ALWAYS_RUN 37
#define HOLD_EFFECT_PREVENT_EVOLVE 38
#define HOLD_EFFECT_FOCUS_BAND 39
#define HOLD_EFFECT_LUCKY_EGG 40
#define HOLD_EFFECT_SCOPE_LENS 41
#define HOLD_EFFECT_STEEL_POWER 42
#define HOLD_EFFECT_LEFTOVERS 43
#define HOLD_EFFECT_DRAGON_SCALE 44
#define HOLD_EFFECT_LIGHT_BALL 45
#define HOLD_EFFECT_GROUND_POWER 46
#define HOLD_EFFECT_ROCK_POWER 47
#define HOLD_EFFECT_GRASS_POWER 48
#define HOLD_EFFECT_DARK_POWER 49
#define HOLD_EFFECT_FIGHTING_POWER 50
#define HOLD_EFFECT_ELECTRIC_POWER 51
#define HOLD_EFFECT_WATER_POWER 52
#define HOLD_EFFECT_FLYING_POWER 53
#define HOLD_EFFECT_POISON_POWER 54
#define HOLD_EFFECT_ICE_POWER 55
#define HOLD_EFFECT_GHOST_POWER 56
#define HOLD_EFFECT_PSYCHIC_POWER 57
#define HOLD_EFFECT_FIRE_POWER 58
#define HOLD_EFFECT_DRAGON_POWER 59
#define HOLD_EFFECT_NORMAL_POWER 60
#define HOLD_EFFECT_UP_GRADE 61
#define HOLD_EFFECT_SHELL_BELL 62
#define HOLD_EFFECT_LUCKY_PUNCH 63
#define HOLD_EFFECT_METAL_POWDER 64
#define HOLD_EFFECT_THICK_CLUB 65
#define HOLD_EFFECT_STICK 66
#endif // GUARD_HOLD_EFFECTS_H

389
include/items.h Normal file
View File

@ -0,0 +1,389 @@
#ifndef GUARD_ITEMS_H
#define GUARD_ITEMS_H
enum
{
ITEM_NONE, // 0x000
ITEM_MASTER_BALL, // 0x001
ITEM_ULTRA_BALL, // 0x002
ITEM_GREAT_BALL, // 0x003
ITEM_POKE_BALL, // 0x004
ITEM_SAFARI_BALL, // 0x005
ITEM_NET_BALL, // 0x006
ITEM_DIVE_BALL, // 0x007
ITEM_NEST_BALL, // 0x008
ITEM_REPEAT_BALL, // 0x009
ITEM_TIMER_BALL, // 0x00a
ITEM_LUXURY_BALL, // 0x00b
ITEM_PREMIER_BALL, // 0x00c
ITEM_POTION, // 0x00d
ITEM_ANTIDOTE, // 0x00e
ITEM_BURN_HEAL, // 0x00f
ITEM_ICE_HEAL, // 0x010
ITEM_AWAKENING, // 0x011
ITEM_PARALYZE_HEAL, // 0x012
ITEM_FULL_RESTORE, // 0x013
ITEM_MAX_POTION, // 0x014
ITEM_HYPER_POTION, // 0x015
ITEM_SUPER_POTION, // 0x016
ITEM_FULL_HEAL, // 0x017
ITEM_REVIVE, // 0x018
ITEM_MAX_REVIVE, // 0x019
ITEM_FRESH_WATER, // 0x01a
ITEM_SODA_POP, // 0x01b
ITEM_LEMONADE, // 0x01c
ITEM_MOOMOO_MILK, // 0x01d
ITEM_ENERGY_POWDER, // 0x01e
ITEM_ENERGY_ROOT, // 0x01f
ITEM_HEAL_POWDER, // 0x020
ITEM_REVIVAL_HERB, // 0x021
ITEM_ETHER, // 0x022
ITEM_MAX_ETHER, // 0x023
ITEM_ELIXIR, // 0x024
ITEM_MAX_ELIXIR, // 0x025
ITEM_LAVA_COOKIE, // 0x026
ITEM_BLUE_FLUTE, // 0x027
ITEM_YELLOW_FLUTE, // 0x028
ITEM_RED_FLUTE, // 0x029
ITEM_BLACK_FLUTE, // 0x02a
ITEM_WHITE_FLUTE, // 0x02b
ITEM_BERRY_JUICE, // 0x02c
ITEM_SACRED_ASH, // 0x02d
ITEM_SHOAL_SALT, // 0x02e
ITEM_SHOAL_SHELL, // 0x02f
ITEM_RED_SHARD, // 0x030
ITEM_BLUE_SHARD, // 0x031
ITEM_YELLOW_SHARD, // 0x032
ITEM_GREEN_SHARD, // 0x033
ITEM_034,
ITEM_035,
ITEM_036,
ITEM_037,
ITEM_038,
ITEM_039,
ITEM_03A,
ITEM_03B,
ITEM_03C,
ITEM_03D,
ITEM_03E,
ITEM_HP_UP, // 0x03f
ITEM_PROTEIN, // 0x040
ITEM_IRON, // 0x041
ITEM_CARBOS, // 0x042
ITEM_CALCIUM, // 0x043
ITEM_RARE_CANDY, // 0x044
ITEM_PP_UP, // 0x045
ITEM_ZINC, // 0x046
ITEM_PP_MAX, // 0x047
ITEM_048,
ITEM_GUARD_SPEC, // 0x049
ITEM_DIRE_HIT, // 0x04a
ITEM_X_ATTACK, // 0x04b
ITEM_X_DEFEND, // 0x04c
ITEM_X_SPEED, // 0x04d
ITEM_X_ACCURACY, // 0x04e
ITEM_X_SPECIAL, // 0x04f
ITEM_POKE_DOLL, // 0x050
ITEM_FLUFFY_TAIL, // 0x051
ITEM_052,
ITEM_SUPER_REPEL, // 0x053
ITEM_MAX_REPEL, // 0x054
ITEM_ESCAPE_ROPE, // 0x055
ITEM_REPEL, // 0x056
ITEM_057,
ITEM_058,
ITEM_059,
ITEM_05A,
ITEM_05B,
ITEM_05C,
ITEM_SUN_STONE, // 0x05d
ITEM_MOON_STONE, // 0x05e
ITEM_FIRE_STONE, // 0x05f
ITEM_THUNDER_STONE, // 0x060
ITEM_WATER_STONE, // 0x061
ITEM_LEAF_STONE, // 0x062
ITEM_063,
ITEM_064,
ITEM_065,
ITEM_066,
ITEM_TINY_MUSHROOM, // 0x067
ITEM_BIG_MUSHROOM, // 0x068
ITEM_069,
ITEM_PEARL, // 0x06a
ITEM_BIG_PEARL, // 0x06b
ITEM_STARDUST, // 0x06c
ITEM_STAR_PIECE, // 0x06d
ITEM_NUGGET, // 0x06e
ITEM_HEART_SCALE, // 0x06f
ITEM_070,
ITEM_071,
ITEM_072,
ITEM_073,
ITEM_074,
ITEM_075,
ITEM_076,
ITEM_077,
ITEM_078,
ITEM_ORANGE_MAIL, // 0x079
ITEM_HARBOR_MAIL, // 0x07a
ITEM_GLITTER_MAIL, // 0x07b
ITEM_MECH_MAIL, // 0x07c
ITEM_WOOD_MAIL, // 0x07d
ITEM_WAVE_MAIL, // 0x07e
ITEM_BEAD_MAIL, // 0x07f
ITEM_SHADOW_MAIL, // 0x080
ITEM_TROPIC_MAIL, // 0x081
ITEM_DREAM_MAIL, // 0x082
ITEM_FAB_MAIL, // 0x083
ITEM_RETRO_MAIL, // 0x084
ITEM_CHERI_BERRY, // 0x085
ITEM_CHESTO_BERRY, // 0x086
ITEM_PECHA_BERRY, // 0x087
ITEM_RAWST_BERRY, // 0x088
ITEM_ASPEAR_BERRY, // 0x089
ITEM_LEPPA_BERRY, // 0x08a
ITEM_ORAN_BERRY, // 0x08b
ITEM_PERSIM_BERRY, // 0x08c
ITEM_LUM_BERRY, // 0x08d
ITEM_SITRUS_BERRY, // 0x08e
ITEM_FIGY_BERRY, // 0x08f
ITEM_WIKI_BERRY, // 0x090
ITEM_MAGO_BERRY, // 0x091
ITEM_AGUAV_BERRY, // 0x092
ITEM_IAPAPA_BERRY, // 0x093
ITEM_RAZZ_BERRY, // 0x094
ITEM_BLUK_BERRY, // 0x095
ITEM_NANAB_BERRY, // 0x096
ITEM_WEPEAR_BERRY, // 0x097
ITEM_PINAP_BERRY, // 0x098
ITEM_POMEG_BERRY, // 0x099
ITEM_KELPSY_BERRY, // 0x09a
ITEM_QUALOT_BERRY, // 0x09b
ITEM_HONDEW_BERRY, // 0x09c
ITEM_GREPA_BERRY, // 0x09d
ITEM_TAMATO_BERRY, // 0x09e
ITEM_CORNN_BERRY, // 0x09f
ITEM_MAGOST_BERRY, // 0x0a0
ITEM_RABUTA_BERRY, // 0x0a1
ITEM_NOMEL_BERRY, // 0x0a2
ITEM_SPELON_BERRY, // 0x0a3
ITEM_PAMTRE_BERRY, // 0x0a4
ITEM_WATMEL_BERRY, // 0x0a5
ITEM_DURIN_BERRY, // 0x0a6
ITEM_BELUE_BERRY, // 0x0a7
ITEM_LIECHI_BERRY, // 0x0a8
ITEM_GANLON_BERRY, // 0x0a9
ITEM_SALAC_BERRY, // 0x0aa
ITEM_PETAYA_BERRY, // 0x0ab
ITEM_APICOT_BERRY, // 0x0ac
ITEM_LANSAT_BERRY, // 0x0ad
ITEM_STARF_BERRY, // 0x0ae
ITEM_ENIGMA_BERRY, // 0x0af
ITEM_0B0,
ITEM_0B1,
ITEM_0B2,
ITEM_BRIGHT_POWDER, // 0x0b3
ITEM_WHITE_HERB, // 0x0b4
ITEM_MACHO_BRACE, // 0x0b5
ITEM_EXP_SHARE, // 0x0b6
ITEM_QUICK_CLAW, // 0x0b7
ITEM_SOOTHE_BELL, // 0x0b8
ITEM_MENTAL_HERB, // 0x0b9
ITEM_CHOICE_BAND, // 0x0ba
ITEM_KINGS_ROCK, // 0x0bb
ITEM_SILVER_POWDER, // 0x0bc
ITEM_AMULET_COIN, // 0x0bd
ITEM_CLEANSE_TAG, // 0x0be
ITEM_SOUL_DEW, // 0x0bf
ITEM_DEEP_SEA_TOOTH, // 0x0c0
ITEM_DEEP_SEA_SCALE, // 0x0c1
ITEM_SMOKE_BALL, // 0x0c2
ITEM_EVERSTONE, // 0x0c3
ITEM_FOCUS_BAND, // 0x0c4
ITEM_LUCKY_EGG, // 0x0c5
ITEM_SCOPE_LENS, // 0x0c6
ITEM_METAL_COAT, // 0x0c7
ITEM_LEFTOVERS, // 0x0c8
ITEM_DRAGON_SCALE, // 0x0c9
ITEM_LIGHT_BALL, // 0x0ca
ITEM_SOFT_SAND, // 0x0cb
ITEM_HARD_STONE, // 0x0cc
ITEM_MIRACLE_SEED, // 0x0cd
ITEM_BLACK_GLASSES, // 0x0ce
ITEM_BLACK_BELT, // 0x0cf
ITEM_MAGNET, // 0x0d0
ITEM_MYSTIC_WATER, // 0x0d1
ITEM_SHARP_BEAK, // 0x0d2
ITEM_POISON_BARB, // 0x0d3
ITEM_NEVER_MELT_ICE, // 0x0d4
ITEM_SPELL_TAG, // 0x0d5
ITEM_TWISTED_SPOON, // 0x0d6
ITEM_CHARCOAL, // 0x0d7
ITEM_DRAGON_FANG, // 0x0d8
ITEM_SILK_SCARF, // 0x0d9
ITEM_UP_GRADE, // 0x0da
ITEM_SHELL_BELL, // 0x0db
ITEM_SEA_INCENSE, // 0x0dc
ITEM_LAX_INCENSE, // 0x0dd
ITEM_LUCKY_PUNCH, // 0x0de
ITEM_METAL_POWDER, // 0x0df
ITEM_THICK_CLUB, // 0x0e0
ITEM_STICK, // 0x0e1
ITEM_0E2,
ITEM_0E3,
ITEM_0E4,
ITEM_0E5,
ITEM_0E6,
ITEM_0E7,
ITEM_0E8,
ITEM_0E9,
ITEM_0EA,
ITEM_0EB,
ITEM_0EC,
ITEM_0ED,
ITEM_0EE,
ITEM_0EF,
ITEM_0F0,
ITEM_0F1,
ITEM_0F2,
ITEM_0F3,
ITEM_0F4,
ITEM_0F5,
ITEM_0F6,
ITEM_0F7,
ITEM_0F8,
ITEM_0F9,
ITEM_0FA,
ITEM_0FB,
ITEM_0FC,
ITEM_0FD,
ITEM_RED_SCARF, // 0x0fe
ITEM_BLUE_SCARF, // 0x0ff
ITEM_PINK_SCARF, // 0x100
ITEM_GREEN_SCARF, // 0x101
ITEM_YELLOW_SCARF, // 0x102
ITEM_MACH_BIKE, // 0x103
ITEM_COIN_CASE, // 0x104
ITEM_ITEMFINDER, // 0x105
ITEM_OLD_ROD, // 0x106
ITEM_GOOD_ROD, // 0x107
ITEM_SUPER_ROD, // 0x108
ITEM_SS_TICKET, // 0x109
ITEM_CONTEST_PASS, // 0x10a
ITEM_10B,
ITEM_WAILMER_PAIL, // 0x10c
ITEM_DEVON_GOODS, // 0x10d
ITEM_SOOT_SACK, // 0x10e
ITEM_BASEMENT_KEY, // 0x10f
ITEM_ACRO_BIKE, // 0x110
ITEM_POKEBLOCK_CASE, // 0x111
ITEM_LETTER, // 0x112
ITEM_EON_TICKET, // 0x113
ITEM_RED_ORB, // 0x114
ITEM_BLUE_ORB, // 0x115
ITEM_SCANNER, // 0x116
ITEM_GO_GOGGLES, // 0x117
ITEM_METEORITE, // 0x118
ITEM_ROOM_1_KEY, // 0x119
ITEM_ROOM_2_KEY, // 0x11a
ITEM_ROOM_4_KEY, // 0x11b
ITEM_ROOM_6_KEY, // 0x11c
ITEM_STORAGE_KEY, // 0x11d
ITEM_ROOT_FOSSIL, // 0x11e
ITEM_CLAW_FOSSIL, // 0x11f
ITEM_DEVON_SCOPE, // 0x120
ITEM_TM01, // 0x121
ITEM_TM02, // 0x122
ITEM_TM03, // 0x123
ITEM_TM04, // 0x124
ITEM_TM05, // 0x125
ITEM_TM06, // 0x126
ITEM_TM07, // 0x127
ITEM_TM08, // 0x128
ITEM_TM09, // 0x129
ITEM_TM10, // 0x12a
ITEM_TM11, // 0x12b
ITEM_TM12, // 0x12c
ITEM_TM13, // 0x12d
ITEM_TM14, // 0x12e
ITEM_TM15, // 0x12f
ITEM_TM16, // 0x130
ITEM_TM17, // 0x131
ITEM_TM18, // 0x132
ITEM_TM19, // 0x133
ITEM_TM20, // 0x134
ITEM_TM21, // 0x135
ITEM_TM22, // 0x136
ITEM_TM23, // 0x137
ITEM_TM24, // 0x138
ITEM_TM25, // 0x139
ITEM_TM26, // 0x13a
ITEM_TM27, // 0x13b
ITEM_TM28, // 0x13c
ITEM_TM29, // 0x13d
ITEM_TM30, // 0x13e
ITEM_TM31, // 0x13f
ITEM_TM32, // 0x140
ITEM_TM33, // 0x141
ITEM_TM34, // 0x142
ITEM_TM35, // 0x143
ITEM_TM36, // 0x144
ITEM_TM37, // 0x145
ITEM_TM38, // 0x146
ITEM_TM39, // 0x147
ITEM_TM40, // 0x148
ITEM_TM41, // 0x149
ITEM_TM42, // 0x14a
ITEM_TM43, // 0x14b
ITEM_TM44, // 0x14c
ITEM_TM45, // 0x14d
ITEM_TM46, // 0x14e
ITEM_TM47, // 0x14f
ITEM_TM48, // 0x150
ITEM_TM49, // 0x151
ITEM_TM50, // 0x152
ITEM_HM01, // 0x153
ITEM_HM02, // 0x154
ITEM_HM03, // 0x155
ITEM_HM04, // 0x156
ITEM_HM05, // 0x157
ITEM_HM06, // 0x158
ITEM_HM07, // 0x159
ITEM_HM08, // 0x15a
ITEM_15B,
ITEM_15C,
// FireRed/LeafGreen
ITEM_OAKS_PARCEL, // 0x15d
ITEM_POKE_FLUTE, // 0x15e
ITEM_SECRET_KEY, // 0x15f
ITEM_BIKE_VOUCHER, // 0x160
ITEM_GOLD_TEETH, // 0x161
ITEM_OLD_AMBER, // 0x162
ITEM_CARD_KEY, // 0x163
ITEM_LIFT_KEY, // 0x164
ITEM_HELIX_FOSSIL, // 0x165
ITEM_DOME_FOSSIL, // 0x166
ITEM_SILPH_SCOPE, // 0x167
ITEM_BICYCLE, // 0x168
ITEM_TOWN_MAP, // 0x169
ITEM_VS_SEEKER, // 0x16a
ITEM_FAME_CHECKER, // 0x16b
ITEM_TM_CASE, // 0x16c
ITEM_BERRY_POUCH, // 0x16d
ITEM_TEACHY_TV, // 0x16e
ITEM_TRI_PASS, // 0x16f
ITEM_RAINBOW_PASS, // 0x170
ITEM_TEA, // 0x171
ITEM_MYSTIC_TICKET, // 0x172
ITEM_AURORA_TICKET, // 0x173
ITEM_POWDER_JAR, // 0x174
ITEM_RUBY, // 0x175
ITEM_SAPPHIRE, // 0x176
// Emerald
ITEM_MAGMA_EMBLEM, // 0x177
ITEM_OLD_SEA_MAP, // 0x178
};
#endif // GUARD_ITEMS_H

363
include/moves.h Normal file
View File

@ -0,0 +1,363 @@
#ifndef GUARD_MOVES_H
#define GUARD_MOVES_H
enum
{
MOVE_NONE,
MOVE_POUND,
MOVE_KARATE_CHOP,
MOVE_DOUBLE_SLAP,
MOVE_COMET_PUNCH,
MOVE_MEGA_PUNCH,
MOVE_PAY_DAY,
MOVE_FIRE_PUNCH,
MOVE_ICE_PUNCH,
MOVE_THUNDER_PUNCH,
MOVE_SCRATCH,
MOVE_VICE_GRIP,
MOVE_GUILLOTINE,
MOVE_RAZOR_WIND,
MOVE_SWORDS_DANCE,
MOVE_CUT,
MOVE_GUST,
MOVE_WING_ATTACK,
MOVE_WHIRLWIND,
MOVE_FLY,
MOVE_BIND,
MOVE_SLAM,
MOVE_VINE_WHIP,
MOVE_STOMP,
MOVE_DOUBLE_KICK,
MOVE_MEGA_KICK,
MOVE_JUMP_KICK,
MOVE_ROLLING_KICK,
MOVE_SAND_ATTACK,
MOVE_HEADBUTT,
MOVE_HORN_ATTACK,
MOVE_FURY_ATTACK,
MOVE_HORN_DRILL,
MOVE_TACKLE,
MOVE_BODY_SLAM,
MOVE_WRAP,
MOVE_TAKE_DOWN,
MOVE_THRASH,
MOVE_DOUBLE_EDGE,
MOVE_TAIL_WHIP,
MOVE_POISON_STING,
MOVE_TWINEEDLE,
MOVE_PIN_MISSILE,
MOVE_LEER,
MOVE_BITE,
MOVE_GROWL,
MOVE_ROAR,
MOVE_SING,
MOVE_SUPERSONIC,
MOVE_SONIC_BOOM,
MOVE_DISABLE,
MOVE_ACID,
MOVE_EMBER,
MOVE_FLAMETHROWER,
MOVE_MIST,
MOVE_WATER_GUN,
MOVE_HYDRO_PUMP,
MOVE_SURF,
MOVE_ICE_BEAM,
MOVE_BLIZZARD,
MOVE_PSYBEAM,
MOVE_BUBBLE_BEAM,
MOVE_AURORA_BEAM,
MOVE_HYPER_BEAM,
MOVE_PECK,
MOVE_DRILL_PECK,
MOVE_SUBMISSION,
MOVE_LOW_KICK,
MOVE_COUNTER,
MOVE_SEISMIC_TOSS,
MOVE_STRENGTH,
MOVE_ABSORB,
MOVE_MEGA_DRAIN,
MOVE_LEECH_SEED,
MOVE_GROWTH,
MOVE_RAZOR_LEAF,
MOVE_SOLAR_BEAM,
MOVE_POISON_POWDER,
MOVE_STUN_SPORE,
MOVE_SLEEP_POWDER,
MOVE_PETAL_DANCE,
MOVE_STRING_SHOT,
MOVE_DRAGON_RAGE,
MOVE_FIRE_SPIN,
MOVE_THUNDER_SHOCK,
MOVE_THUNDERBOLT,
MOVE_THUNDER_WAVE,
MOVE_THUNDER,
MOVE_ROCK_THROW,
MOVE_EARTHQUAKE,
MOVE_FISSURE,
MOVE_DIG,
MOVE_TOXIC,
MOVE_CONFUSION,
MOVE_PSYCHIC,
MOVE_HYPNOSIS,
MOVE_MEDITATE,
MOVE_AGILITY,
MOVE_QUICK_ATTACK,
MOVE_RAGE,
MOVE_TELEPORT,
MOVE_NIGHT_SHADE,
MOVE_MIMIC,
MOVE_SCREECH,
MOVE_DOUBLE_TEAM,
MOVE_RECOVER,
MOVE_HARDEN,
MOVE_MINIMIZE,
MOVE_SMOKESCREEN,
MOVE_CONFUSE_RAY,
MOVE_WITHDRAW,
MOVE_DEFENSE_CURL,
MOVE_BARRIER,
MOVE_LIGHT_SCREEN,
MOVE_HAZE,
MOVE_REFLECT,
MOVE_FOCUS_ENERGY,
MOVE_BIDE,
MOVE_METRONOME,
MOVE_MIRROR_MOVE,
MOVE_SELF_DESTRUCT,
MOVE_EGG_BOMB,
MOVE_LICK,
MOVE_SMOG,
MOVE_SLUDGE,
MOVE_BONE_CLUB,
MOVE_FIRE_BLAST,
MOVE_WATERFALL,
MOVE_CLAMP,
MOVE_SWIFT,
MOVE_SKULL_BASH,
MOVE_SPIKE_CANNON,
MOVE_CONSTRICT,
MOVE_AMNESIA,
MOVE_KINESIS,
MOVE_SOFT_BOILED,
MOVE_HI_JUMP_KICK,
MOVE_GLARE,
MOVE_DREAM_EATER,
MOVE_POISON_GAS,
MOVE_BARRAGE,
MOVE_LEECH_LIFE,
MOVE_LOVELY_KISS,
MOVE_SKY_ATTACK,
MOVE_TRANSFORM,
MOVE_BUBBLE,
MOVE_DIZZY_PUNCH,
MOVE_SPORE,
MOVE_FLASH,
MOVE_PSYWAVE,
MOVE_SPLASH,
MOVE_ACID_ARMOR,
MOVE_CRABHAMMER,
MOVE_EXPLOSION,
MOVE_FURY_SWIPES,
MOVE_BONEMERANG,
MOVE_REST,
MOVE_ROCK_SLIDE,
MOVE_HYPER_FANG,
MOVE_SHARPEN,
MOVE_CONVERSION,
MOVE_TRI_ATTACK,
MOVE_SUPER_FANG,
MOVE_SLASH,
MOVE_SUBSTITUTE,
MOVE_STRUGGLE,
MOVE_SKETCH,
MOVE_TRIPLE_KICK,
MOVE_THIEF,
MOVE_SPIDER_WEB,
MOVE_MIND_READER,
MOVE_NIGHTMARE,
MOVE_FLAME_WHEEL,
MOVE_SNORE,
MOVE_CURSE,
MOVE_FLAIL,
MOVE_CONVERSION_2,
MOVE_AEROBLAST,
MOVE_COTTON_SPORE,
MOVE_REVERSAL,
MOVE_SPITE,
MOVE_POWDER_SNOW,
MOVE_PROTECT,
MOVE_MACH_PUNCH,
MOVE_SCARY_FACE,
MOVE_FAINT_ATTACK,
MOVE_SWEET_KISS,
MOVE_BELLY_DRUM,
MOVE_SLUDGE_BOMB,
MOVE_MUD_SLAP,
MOVE_OCTAZOOKA,
MOVE_SPIKES,
MOVE_ZAP_CANNON,
MOVE_FORESIGHT,
MOVE_DESTINY_BOND,
MOVE_PERISH_SONG,
MOVE_ICY_WIND,
MOVE_DETECT,
MOVE_BONE_RUSH,
MOVE_LOCK_ON,
MOVE_OUTRAGE,
MOVE_SANDSTORM,
MOVE_GIGA_DRAIN,
MOVE_ENDURE,
MOVE_CHARM,
MOVE_ROLLOUT,
MOVE_FALSE_SWIPE,
MOVE_SWAGGER,
MOVE_MILK_DRINK,
MOVE_SPARK,
MOVE_FURY_CUTTER,
MOVE_STEEL_WING,
MOVE_MEAN_LOOK,
MOVE_ATTRACT,
MOVE_SLEEP_TALK,
MOVE_HEAL_BELL,
MOVE_RETURN,
MOVE_PRESENT,
MOVE_FRUSTRATION,
MOVE_SAFEGUARD,
MOVE_PAIN_SPLIT,
MOVE_SACRED_FIRE,
MOVE_MAGNITUDE,
MOVE_DYNAMIC_PUNCH,
MOVE_MEGAHORN,
MOVE_DRAGON_BREATH,
MOVE_BATON_PASS,
MOVE_ENCORE,
MOVE_PURSUIT,
MOVE_RAPID_SPIN,
MOVE_SWEET_SCENT,
MOVE_IRON_TAIL,
MOVE_METAL_CLAW,
MOVE_VITAL_THROW,
MOVE_MORNING_SUN,
MOVE_SYNTHESIS,
MOVE_MOONLIGHT,
MOVE_HIDDEN_POWER,
MOVE_CROSS_CHOP,
MOVE_TWISTER,
MOVE_RAIN_DANCE,
MOVE_SUNNY_DAY,
MOVE_CRUNCH,
MOVE_MIRROR_COAT,
MOVE_PSYCH_UP,
MOVE_EXTREME_SPEED,
MOVE_ANCIENT_POWER,
MOVE_SHADOW_BALL,
MOVE_FUTURE_SIGHT,
MOVE_ROCK_SMASH,
MOVE_WHIRLPOOL,
MOVE_BEAT_UP,
MOVE_FAKE_OUT,
MOVE_UPROAR,
MOVE_STOCKPILE,
MOVE_SPIT_UP,
MOVE_SWALLOW,
MOVE_HEAT_WAVE,
MOVE_HAIL,
MOVE_TORMENT,
MOVE_FLATTER,
MOVE_WILL_O_WISP,
MOVE_MEMENTO,
MOVE_FACADE,
MOVE_FOCUS_PUNCH,
MOVE_SMELLING_SALT,
MOVE_FOLLOW_ME,
MOVE_NATURE_POWER,
MOVE_CHARGE,
MOVE_TAUNT,
MOVE_HELPING_HAND,
MOVE_TRICK,
MOVE_ROLE_PLAY,
MOVE_WISH,
MOVE_ASSIST,
MOVE_INGRAIN,
MOVE_SUPERPOWER,
MOVE_MAGIC_COAT,
MOVE_RECYCLE,
MOVE_REVENGE,
MOVE_BRICK_BREAK,
MOVE_YAWN,
MOVE_KNOCK_OFF,
MOVE_ENDEAVOR,
MOVE_ERUPTION,
MOVE_SKILL_SWAP,
MOVE_IMPRISON,
MOVE_REFRESH,
MOVE_GRUDGE,
MOVE_SNATCH,
MOVE_SECRET_POWER,
MOVE_DIVE,
MOVE_ARM_THRUST,
MOVE_CAMOUFLAGE,
MOVE_TAIL_GLOW,
MOVE_LUSTER_PURGE,
MOVE_MIST_BALL,
MOVE_FEATHER_DANCE,
MOVE_TEETER_DANCE,
MOVE_BLAZE_KICK,
MOVE_MUD_SPORT,
MOVE_ICE_BALL,
MOVE_NEEDLE_ARM,
MOVE_SLACK_OFF,
MOVE_HYPER_VOICE,
MOVE_POISON_FANG,
MOVE_CRUSH_CLAW,
MOVE_BLAST_BURN,
MOVE_HYDRO_CANNON,
MOVE_METEOR_MASH,
MOVE_ASTONISH,
MOVE_WEATHER_BALL,
MOVE_AROMATHERAPY,
MOVE_FAKE_TEARS,
MOVE_AIR_CUTTER,
MOVE_OVERHEAT,
MOVE_ODOR_SLEUTH,
MOVE_ROCK_TOMB,
MOVE_SILVER_WIND,
MOVE_METAL_SOUND,
MOVE_GRASS_WHISTLE,
MOVE_TICKLE,
MOVE_COSMIC_POWER,
MOVE_WATER_SPOUT,
MOVE_SIGNAL_BEAM,
MOVE_SHADOW_PUNCH,
MOVE_EXTRASENSORY,
MOVE_SKY_UPPERCUT,
MOVE_SAND_TOMB,
MOVE_SHEER_COLD,
MOVE_MUDDY_WATER,
MOVE_BULLET_SEED,
MOVE_AERIAL_ACE,
MOVE_ICICLE_SPEAR,
MOVE_IRON_DEFENSE,
MOVE_BLOCK,
MOVE_HOWL,
MOVE_DRAGON_CLAW,
MOVE_FRENZY_PLANT,
MOVE_BULK_UP,
MOVE_BOUNCE,
MOVE_MUD_SHOT,
MOVE_POISON_TAIL,
MOVE_COVET,
MOVE_VOLT_TACKLE,
MOVE_MAGICAL_LEAF,
MOVE_WATER_SPORT,
MOVE_CALM_MIND,
MOVE_LEAF_BLADE,
MOVE_DRAGON_DANCE,
MOVE_ROCK_BLAST,
MOVE_SHOCK_WAVE,
MOVE_WATER_PULSE,
MOVE_DOOM_DESIRE,
MOVE_PSYCHO_BOOST,
};
#endif // GUARD_MOVES_H

View File

@ -269,6 +269,56 @@ struct PokemonStorage
/*0x83C2*/ u8 boxWallpapers[14];
};
struct BattlePokemon
{
/*0x00*/ u16 species;
/*0x02*/ u16 attack;
/*0x04*/ u16 defense;
/*0x06*/ u16 speed;
/*0x08*/ u16 spAttack;
/*0x0A*/ u16 spDefense;
/*0x0C*/ u16 moves[4];
/*0x14*/ u32 hpIV:5;
/*0x14*/ u32 attackIV:5;
/*0x15*/ u32 defenseIV:5;
/*0x15*/ u32 speedIV:5;
/*0x16*/ u32 spAttackIV:5;
/*0x17*/ u32 spDefenseIV:5;
/*0x17*/ u32 isEgg:1;
/*0x17*/ u32 altAbility:1;
/*0x18*/ s8 statStages[8];
/*0x20*/ u8 ability;
/*0x21*/ u8 type1;
/*0x22*/ u8 type2;
/*0x23*/ u8 unknown;
/*0x24*/ u8 pp[4];
/*0x28*/ u16 hp;
/*0x2A*/ u8 level;
/*0x2B*/ u8 friendship;
/*0x2C*/ u16 maxHP;
/*0x2E*/ u16 item;
/*0x30*/ u8 nickname[POKEMON_NAME_LENGTH + 1];
/*0x3B*/ u8 ppBonuses;
/*0x3C*/ u8 otName[8];
/*0x44*/ u32 experience;
/*0x48*/ u32 personality;
/*0x4C*/ u32 status1;
/*0x50*/ u32 status2;
/*0x54*/ u32 otId;
};
enum
{
STAT_STAGE_HP, // 0
STAT_STAGE_ATK, // 1
STAT_STAGE_DEF, // 2
STAT_STAGE_SPEED, // 3
STAT_STAGE_SPATK, // 4
STAT_STAGE_SPDEF, // 5
STAT_STAGE_ACC, // 6
STAT_STAGE_EVASION, // 7
};
struct BaseStats
{
/* 0x00 */ u8 baseHP;

View File

@ -64,7 +64,7 @@ SECTIONS {
asm/battle_9.o(.text);
asm/battle_controller_linkopponent.o(.text);
asm/pokemon_1.o(.text);
asm/calculate_base_damage.o(.text);
src/calculate_base_damage.o(.text);
asm/pokemon_2.o(.text);
asm/pokemon_3.o(.text);
src/trig.o(.text);

View File

@ -3,6 +3,7 @@
#include "battle.h"
#include "species.h"
#include "abilities.h"
#include "rng.h"
#define AIScriptRead32(ptr) ((ptr)[0] | (ptr)[1] << 8 | (ptr)[2] << 16 | (ptr)[3] << 24)
#define AIScriptRead16(ptr) ((ptr)[0] | (ptr)[1] << 8)
@ -10,9 +11,7 @@
#define AIScriptReadPtr(ptr) (u8*) AIScriptRead32(ptr)
#define AI_THINKING_STRUCT ((struct AI_ThinkingStruct *)(gBattleResources->ai))
#define UNK_2016A00_STRUCT ((struct UnknownStruct2 *)(gBattleResources->unk18))
#define UNK_2016C00_STRUCT ((struct UnknownStruct4 *)(gBattleResources->unk1C))
#define UNK_BATTLE_STRUCT ((struct UnknownStruct1 *)(gBattleResources))
#define BATTLE_HISTORY ((struct BattleHistory *)(gBattleResources->battleHistory))
#define AI_ACTION_UNK1 0x0001
#define AI_ACTION_UNK2 0x0002
@ -54,112 +53,6 @@ struct Trainer
/*0x24*/ void *party;
};
#define POKEMON_NAME_LENGTH 10
struct BattlePokemon
{
/* 0x00 */ u16 species;
/* 0x02 */ u16 attack;
/* 0x04 */ u16 defense;
/* 0x06 */ u16 speed;
/* 0x08 */ u16 spAttack;
/* 0x0A */ u16 spDefense;
/* 0x0C */ u16 moves[4];
/* 0x14 */ u32 hpIV:5;
/* 0x14 */ u32 attackIV:5;
/* 0x15 */ u32 defenseIV:5;
/* 0x15 */ u32 speedIV:5;
/* 0x16 */ u32 spAttackIV:5;
/* 0x17 */ u32 spDefenseIV:5;
/* 0x17 */ u32 isEgg:1;
/* 0x17 */ u32 altAbility:1;
/* 0x18 */ s8 statStages[8];
/* 0x20 */ u8 ability;
/* 0x21 */ u8 type1;
/* 0x22 */ u8 type2;
/* 0x23 */ u8 unknown;
/* 0x24 */ u8 pp[4];
/* 0x28 */ u16 hp;
/* 0x2A */ u8 level;
/* 0x2B */ u8 friendship;
/* 0x2C */ u16 maxHP;
/* 0x2E */ u16 item;
/* 0x30 */ u8 nickname[POKEMON_NAME_LENGTH + 1];
/* 0x3B */ u8 ppBonuses;
/* 0x3C */ u8 otName[8];
/* 0x44 */ u32 experience;
/* 0x48 */ u32 personality;
/* 0x4C */ u32 status1;
/* 0x50 */ u32 status2;
/* 0x54 */ u32 otId;
};
//size should be 0x1C
struct AI_ThinkingStruct
{
u8 aiState;
u8 movesetIndex;
u16 moveConsidered;
s8 score[4];
u32 funcResult;
u32 aiFlags;
u8 aiAction;
u8 aiLogicId;
u8 filler12[6];
u8 unk18[4];
};
//size should be 0x54
struct UnknownStruct2
{
u16 unk0[2][8];
u8 unk20[2];
u8 filler20[0x1E];
u8 unk40[4];
u8 unk44[4];
u16 unk48[4];
u8 unk50;
};
struct UnknownStruct4
{
u8 *ptr[8];
u8 unk20;
};
struct SimpleUnknownStruct
{
u32 unkArray[4]; // unknown size
};
struct UnknownStruct1
{
u8 unk0;
u8 filler1[0x3];
struct SimpleUnknownStruct *unk4;
u8 filler8[0xC];
struct AI_ThinkingStruct *ai;
struct UnknownStruct2 *unk18;
struct UnknownStruct4 *unk1C;
};
struct UnknownStruct5
{
u8 filler0[0x3];
u16 unk4;
u16 unk6;
u8 unk8;
u8 unk9;
u8 fillerA[0x9];
u8 taunt:4;
u8 unkC:4;
u8 fillerD[0x2];
u8 unk16;
u8 filler17[0x4];
};
extern struct UnknownStruct5 gDisableStructs[];
/*
gAIScriptPtr is a pointer to the next battle AI cmd command to read.
when a command finishes processing, gAIScriptPtr is incremented by
@ -177,7 +70,6 @@ extern u8 gBankTarget;
extern u8 gAbsentBankFlags;
extern u16 gUnknown_02024248[];
extern u8 *gBattleStruct;
extern struct UnknownStruct1 *gBattleResources;
extern u16 gUnknown_02038BCA;
extern u16 gUnknown_02038BCC;
extern u8 gPlayerMonIndex;
@ -211,8 +103,6 @@ typedef void (*BattleAICmdFunc)(void);
extern const BattleAICmdFunc sBattleAICmdTable[];
extern u8 sub_803FECC();
extern u16 Random();
extern u8 GetBankSide();
extern u32 sub_8186438();
extern u32 sub_81A6FB4();
@ -225,8 +115,8 @@ void BattleAI_DoAIProcessing(void);
void BattleAI_HandleItemUseBeforeAISetup(u8 a)
{
s32 i;
u8 *data = (u8 *)gBattleResources->unk18;
u8 *data = (u8 *)gBattleResources->battleHistory;
for (i = 0; (u32)i < 0x54; i++)
data[i] = 0;
if ((gBattleTypeFlags & 0x0A7F098A) == 8)
@ -235,12 +125,12 @@ void BattleAI_HandleItemUseBeforeAISetup(u8 a)
{
if (gTrainers[gUnknown_02038BCA].items[i] != 0)
{
gBattleResources->unk18->unk48[gBattleResources->unk18->unk50] = gTrainers[gUnknown_02038BCA].items[i];
gBattleResources->unk18->unk50++;
gBattleResources->battleHistory->TrainerItems[gBattleResources->battleHistory->unk50] = gTrainers[gUnknown_02038BCA].items[i];
gBattleResources->battleHistory->unk50++;
}
}
}
BattleAI_SetupAIData(a);
}
@ -273,7 +163,7 @@ void BattleAI_SetupAIData(u8 a)
AI_THINKING_STRUCT->unk18[i] = 100 - (Random() % 16);
}
gBattleResources->unk1C->unk20 = 0;
gBattleResources->AI_ScriptsStack->size = 0;
gPlayerMonIndex = gActiveBank;
if (gBattleTypeFlags & 1)
{
@ -311,7 +201,7 @@ u8 sub_8130BA4(void)
{
u16 r4 = gCurrentMove;
u8 ret;
if (!(gBattleTypeFlags & 1))
ret = BattleAI_GetAIActionToUse();
else
@ -327,7 +217,7 @@ u8 BattleAI_GetAIActionToUse(void)
u8 consideredMoveArray[4];
u8 numOfBestMoves;
s32 i;
sub_8131074();
while (AI_THINKING_STRUCT->aiFlags != 0)
@ -391,7 +281,7 @@ u8 sub_8130CF4(void)
//u8 *sp1C = spC;
//u8 *sp18 = sp8;
//u8 *sp20 = spC;
for (i = 0; i < 4; i++) //_08130D14
{
if (i == gPlayerMonIndex || gBattleMons[i].hp == 0)
@ -465,9 +355,9 @@ u8 sub_8130CF4(void)
}
//_08130EAE
}
//#define i r5
//_08130EC4
r5_2 = sp0[0];
sp8[0] = 0;
@ -835,15 +725,15 @@ void BattleAI_DoAIProcessing(void)
void sub_8131074(void)
{
s32 i;
for (i = 0; i < 4; i++)
{
if (gBattleResources->unk18->unk0[gBankTarget][i] == gUnknown_02024248[gBankTarget])
if (gBattleResources->battleHistory->usedMoves[gBankTarget].moves[i] == gUnknown_02024248[gBankTarget])
break;
if (gBattleResources->unk18->unk0[gBankTarget][i] != gUnknown_02024248[gBankTarget] //HACK: This redundant condition is a hack to make the asm match.
&& gBattleResources->unk18->unk0[gBankTarget][i] == 0)
if (gBattleResources->battleHistory->usedMoves[gBankTarget].moves[i] != gUnknown_02024248[gBankTarget] //HACK: This redundant condition is a hack to make the asm match.
&& gBattleResources->battleHistory->usedMoves[gBankTarget].moves[i] == 0)
{
gBattleResources->unk18->unk0[gBankTarget][i] = gUnknown_02024248[gBankTarget];
gBattleResources->battleHistory->usedMoves[gBankTarget].moves[i] = gUnknown_02024248[gBankTarget];
break;
}
}
@ -852,29 +742,29 @@ void sub_8131074(void)
void sub_81310F0(u8 a)
{
s32 i;
for (i = 0; i < 4; i++)
gBattleResources->unk18->unk0[a][i] = 0;
gBattleResources->battleHistory->usedMoves[a].moves[i] = 0;
}
void RecordAbilityBattle(u8 a, u8 b)
{
gBattleResources->unk18->unk40[a] = b;
gBattleResources->battleHistory->abilities[a] = b;
}
void sub_8131130(u8 a)
{
gBattleResources->unk18->unk40[a] = 0;
gBattleResources->battleHistory->abilities[a] = 0;
}
void b_history__record_item_x12_of_player(u8 a, u8 b)
{
gBattleResources->unk18->unk44[a] = b;
gBattleResources->battleHistory->itemEffects[a] = b;
}
void sub_8131160(u8 a)
{
gBattleResources->unk18->unk44[a] = 0;
gBattleResources->battleHistory->itemEffects[a] = 0;
}
void BattleAICmd_if_random_less_than(void)
@ -1372,7 +1262,7 @@ u8 sub_8131E70(u8 index)
void BattleAICmd_unk_5F(void)
{
u8 index = sub_8131E70(gAIScriptPtr[1]);
if(gBattleMons[index].type1 == gAIScriptPtr[2] || gBattleMons[index].type2 == gAIScriptPtr[2])
{
AI_THINKING_STRUCT->funcResult = 1;
@ -1754,16 +1644,16 @@ void BattleAICmd_get_ability(void)
if(gActiveBank != index)
{
if(UNK_2016A00_STRUCT->unk40[index] != 0)
if(BATTLE_HISTORY->abilities[index] != 0)
{
AI_THINKING_STRUCT->funcResult = UNK_2016A00_STRUCT->unk40[index];
AI_THINKING_STRUCT->funcResult = BATTLE_HISTORY->abilities[index];
gAIScriptPtr += 2;
return;
}
// abilities that prevent fleeing.
if (gBattleMons[index].ability == ABILITY_SHADOW_TAG
|| gBattleMons[index].ability == ABILITY_MAGNET_PULL
if (gBattleMons[index].ability == ABILITY_SHADOW_TAG
|| gBattleMons[index].ability == ABILITY_MAGNET_PULL
|| gBattleMons[index].ability == ABILITY_ARENA_TRAP)
{
AI_THINKING_STRUCT->funcResult = gBattleMons[index].ability;
@ -1784,7 +1674,7 @@ void BattleAICmd_get_ability(void)
{
AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[index].species].ability2;
}
}
}
else
{
AI_THINKING_STRUCT->funcResult = gBaseStats[gBattleMons[index].species].ability1; // it's definitely ability 1.
@ -1809,20 +1699,20 @@ void tai60_unk(void)
u8 index = sub_8131E70(gAIScriptPtr[1]);
u8 arg2 = gAIScriptPtr[2];
u8 var;
if(gAIScriptPtr[1] == 0 || gAIScriptPtr[1] == 2)
{
// _0813253A
if(UNK_2016A00_STRUCT->unk40[index] != 0)
if(BATTLE_HISTORY->abilities[index] != 0)
{
var = UNK_2016A00_STRUCT->unk40[index];
var = BATTLE_HISTORY->abilities[index];
AI_THINKING_STRUCT->funcResult = var;
}
else
{
// _0813255C
if (gBattleMons[index].ability == ABILITY_SHADOW_TAG
|| gBattleMons[index].ability == ABILITY_MAGNET_PULL
if (gBattleMons[index].ability == ABILITY_SHADOW_TAG
|| gBattleMons[index].ability == ABILITY_MAGNET_PULL
|| gBattleMons[index].ability == ABILITY_ARENA_TRAP)
{
var = gBattleMons[index].ability;
@ -1862,7 +1752,7 @@ void tai60_unk(void)
// _081325BC
var = gBattleMons[index].ability;
}
// _081325CA
if(var == ABILITY_NONE)
{
@ -2317,7 +2207,7 @@ void BattleAICmd_if_has_move(void)
{
int i;
u16 *temp_ptr = (u16 *)(gAIScriptPtr + 2);
switch(gAIScriptPtr[1])
{
case 1:
@ -2336,7 +2226,7 @@ void BattleAICmd_if_has_move(void)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
return;
}
}
case 3: // new to Emerald
if(gBattleMons[gPlayerMonIndex ^ 2].hp == 0)
{
@ -2360,12 +2250,12 @@ void BattleAICmd_if_has_move(void)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
return;
}
}
case 0:
case 2:
for (i = 0; i < 4; i++)
{
if (UNK_2016A00_STRUCT->unk0[gBankTarget][i] == *temp_ptr)
if (BATTLE_HISTORY->usedMoves[gBankTarget].moves[i] == *temp_ptr)
break;
}
if (i == 4)
@ -2385,7 +2275,7 @@ void BattleAICmd_if_dont_have_move(void)
{
int i;
u16 *temp_ptr = (u16 *)(gAIScriptPtr + 2);
switch(gAIScriptPtr[1])
{
case 1:
@ -2409,7 +2299,7 @@ void BattleAICmd_if_dont_have_move(void)
case 2:
for (i = 0; i < 4; i++)
{
if (UNK_2016A00_STRUCT->unk0[gBankTarget][i] == *temp_ptr)
if (BATTLE_HISTORY->usedMoves[gBankTarget].moves[i] == *temp_ptr)
break;
}
if (i != 4)
@ -2447,7 +2337,7 @@ void BattleAICmd_if_move_effect(void)
case 2: // _08133090
for (i = 0; i < 4; i++)
{
if (gBattleMons[gPlayerMonIndex].moves[i] != 0 && gBattleMoves[UNK_2016A00_STRUCT->unk0[gBankTarget][i]].effect == gAIScriptPtr[2])
if (gBattleMons[gPlayerMonIndex].moves[i] != 0 && gBattleMoves[BATTLE_HISTORY->usedMoves[gBankTarget].moves[i]].effect == gAIScriptPtr[2])
break;
}
if (i == 4)
@ -2480,7 +2370,7 @@ void BattleAICmd_if_not_move_effect(void)
case 2: // _08133188
for (i = 0; i < 4; i++)
{
if (UNK_2016A00_STRUCT->unk0[gBankTarget][i] && gBattleMoves[UNK_2016A00_STRUCT->unk0[gBankTarget][i]].effect == gAIScriptPtr[2])
if (BATTLE_HISTORY->usedMoves[gBankTarget].moves[i] && gBattleMoves[BATTLE_HISTORY->usedMoves[gBankTarget].moves[i]].effect == gAIScriptPtr[2])
break;
}
if (i != 4)
@ -2502,7 +2392,7 @@ void BattleAICmd_if_last_move_did_damage(void)
if (gAIScriptPtr[2] == 0)
{
if (gDisableStructs[index].unk4 == 0)
if (gDisableStructs[index].disabledMove == 0)
{
gAIScriptPtr += 7;
return;
@ -2515,7 +2405,7 @@ void BattleAICmd_if_last_move_did_damage(void)
gAIScriptPtr += 7;
return;
}
else if (gDisableStructs[index].unk6 != 0)
else if (gDisableStructs[index].encoredMove != 0)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
return;
@ -2528,7 +2418,7 @@ void BattleAICmd_if_encored(void)
switch (gAIScriptPtr[1])
{
case 0: // _08109348
if (gDisableStructs[gActiveBank].unk4 == AI_THINKING_STRUCT->moveConsidered)
if (gDisableStructs[gActiveBank].disabledMove == AI_THINKING_STRUCT->moveConsidered)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
return;
@ -2536,7 +2426,7 @@ void BattleAICmd_if_encored(void)
gAIScriptPtr += 6;
return;
case 1: // _08109370
if (gDisableStructs[gActiveBank].unk6 == AI_THINKING_STRUCT->moveConsidered)
if (gDisableStructs[gActiveBank].encoredMove == AI_THINKING_STRUCT->moveConsidered)
{
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
return;
@ -2581,7 +2471,7 @@ void BattleAICmd_get_hold_effect(void)
if (gActiveBank != index)
{
AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(UNK_2016A00_STRUCT->unk44[index]);
AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(BATTLE_HISTORY->itemEffects[index]);
}
else
AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(gBattleMons[index].item);
@ -2594,16 +2484,16 @@ void tai62_unk(void)
u8 index = sub_8131E70(gAIScriptPtr[1]);
u16 item;
u8 var1, var2;
if((index & 1) == (gPlayerMonIndex & 1))
item = gBattleMons[index].item;
else
item = UNK_2016A00_STRUCT->unk44[index];
item = BATTLE_HISTORY->itemEffects[index];
// strange way of loading a 16-bit argument from the AI command.
var2 = gAIScriptPtr[2];
var1 = gAIScriptPtr[3];
if((var1 | var2) == item)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
else
@ -2633,7 +2523,7 @@ void BattleAICmd_is_first_turn(void)
else
index = gBankTarget;
AI_THINKING_STRUCT->funcResult = gDisableStructs[index].unk16;
AI_THINKING_STRUCT->funcResult = gDisableStructs[index].isFirstTurn;
gAIScriptPtr += 2;
}
@ -2647,7 +2537,7 @@ void BattleAICmd_get_stockpile_count(void)
else
index = gBankTarget;
AI_THINKING_STRUCT->funcResult = gDisableStructs[index].unk9;
AI_THINKING_STRUCT->funcResult = gDisableStructs[index].stockpileCounter;
gAIScriptPtr += 2;
}
@ -2704,7 +2594,7 @@ void BattleAICmd_get_protect_count(void)
else
index = gBankTarget;
AI_THINKING_STRUCT->funcResult = gDisableStructs[index].unk8;
AI_THINKING_STRUCT->funcResult = gDisableStructs[index].protectUses;
gAIScriptPtr += 2;
}
@ -2783,7 +2673,7 @@ void BattleAICmd_if_level_cond(void)
void BattleAICmd_if_taunted(void)
{
if (gDisableStructs[gBankTarget].taunt != 0)
if (gDisableStructs[gBankTarget].tauntTimer1 != 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
@ -2791,7 +2681,7 @@ void BattleAICmd_if_taunted(void)
void BattleAICmd_if_not_taunted(void)
{
if (gDisableStructs[gBankTarget].taunt == 0)
if (gDisableStructs[gBankTarget].tauntTimer1 == 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
else
gAIScriptPtr += 5;
@ -2808,8 +2698,8 @@ void tai5E_unk(void)
void tai61_unk(void)
{
u8 index = sub_8131E70(gAIScriptPtr[1]);
if(UNK_BATTLE_STRUCT->unk4->unkArray[index] & 1)
if(gBattleResources->flags->flags[index] & 1)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
else
gAIScriptPtr += 6;
@ -2817,20 +2707,20 @@ void tai61_unk(void)
void b_mc_stack_push(u8 *var)
{
UNK_2016C00_STRUCT->ptr[UNK_2016C00_STRUCT->unk20++] = var;
gBattleResources->AI_ScriptsStack->ptr[gBattleResources->AI_ScriptsStack->size++] = var;
}
void b_mc_stack_push_cursor(void)
{
UNK_2016C00_STRUCT->ptr[UNK_2016C00_STRUCT->unk20++] = gAIScriptPtr;
gBattleResources->AI_ScriptsStack->ptr[gBattleResources->AI_ScriptsStack->size++] = gAIScriptPtr;
}
bool8 b_mc_stack_pop_cursor(void)
{
if (UNK_2016C00_STRUCT->unk20 != 0)
if (gBattleResources->AI_ScriptsStack->size != 0)
{
--UNK_2016C00_STRUCT->unk20;
gAIScriptPtr = UNK_2016C00_STRUCT->ptr[UNK_2016C00_STRUCT->unk20];
--gBattleResources->AI_ScriptsStack->size;
gAIScriptPtr = gBattleResources->AI_ScriptsStack->ptr[gBattleResources->AI_ScriptsStack->size];
return TRUE;
}
else

284
src/calculate_base_damage.c Normal file
View File

@ -0,0 +1,284 @@
#include "global.h"
#include "abilities.h"
#include "battle.h"
#include "hold_effects.h"
#include "event_data.h"
#include "item.h"
#include "items.h"
#include "pokemon.h"
#include "species.h"
#include "moves.h"
#include "battle_move_effects.h"
extern u32 gBattleTypeFlags;
extern struct BattlePokemon gBattleMons[4];
extern u16 gCurrentMove;
extern u8 gCritMultiplier;
extern u16 gBattleWeather;
extern struct BattleEnigmaBerry gEnigmaBerries[];
extern u16 gBattleMovePower;
extern u16 gTrainerBattleOpponent;
u8 CountAliveMonsInBattle(u8);
bool8 ShouldGetStatBadgeBoost(u16 flagId, u8 bank);
extern const struct BattleMove gBattleMoves[];
extern const u8 gHoldEffectToType[][2];
extern const u8 gStatStageRatios[][2];
#define APPLY_STAT_MOD(var, mon, stat, statIndex) \
{ \
(var) = (stat) * (gStatStageRatios)[(mon)->statStages[(statIndex)]][0]; \
(var) /= (gStatStageRatios)[(mon)->statStages[(statIndex)]][1]; \
}
s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *defender, u32 move, u16 sideStatus, u16 powerOverride, u8 typeOverride, u8 bankAtk, u8 bankDef)
{
u32 i;
s32 damage = 0;
s32 damageHelper;
u8 type;
u16 attack, defense;
u16 spAttack, spDefense;
u8 defenderHoldEffect;
u8 defenderHoldEffectParam;
u8 attackerHoldEffect;
u8 attackerHoldEffectParam;
if (!powerOverride)
gBattleMovePower = gBattleMoves[move].power;
else
gBattleMovePower = powerOverride;
if (!typeOverride)
type = gBattleMoves[move].type;
else
type = typeOverride & 0x3F;
attack = attacker->attack;
defense = defender->defense;
spAttack = attacker->spAttack;
spDefense = defender->spDefense;
if (attacker->item == ITEM_ENIGMA_BERRY)
{
attackerHoldEffect = gEnigmaBerries[bankAtk].holdEffect;
attackerHoldEffectParam = gEnigmaBerries[bankAtk].holdEffectParam;
}
else
{
attackerHoldEffect = ItemId_GetHoldEffect(attacker->item);
attackerHoldEffectParam = ItemId_GetHoldEffectParam(attacker->item);
}
if (defender->item == ITEM_ENIGMA_BERRY)
{
defenderHoldEffect = gEnigmaBerries[bankDef].holdEffect;
defenderHoldEffectParam = gEnigmaBerries[bankDef].holdEffectParam;
}
else
{
defenderHoldEffect = ItemId_GetHoldEffect(defender->item);
defenderHoldEffectParam = ItemId_GetHoldEffectParam(defender->item);
}
if (attacker->ability == ABILITY_HUGE_POWER || attacker->ability == ABILITY_PURE_POWER)
attack *= 2;
if (ShouldGetStatBadgeBoost(BADGE01_GET, bankAtk))
attack = (110 * attack) / 100;
if (ShouldGetStatBadgeBoost(BADGE05_GET, bankDef))
defense = (110 * defense) / 100;
if (ShouldGetStatBadgeBoost(BADGE07_GET, bankAtk))
spAttack = (110 * spAttack) / 100;
if (ShouldGetStatBadgeBoost(BADGE07_GET, bankDef))
spDefense = (110 * spDefense) / 100;
for (i = 0; i < 17; i++)
{
if (attackerHoldEffect == gHoldEffectToType[i][0]
&& type == gHoldEffectToType[i][1])
{
if (type <= 8)
attack = (attack * (attackerHoldEffectParam + 100)) / 100;
else
spAttack = (spAttack * (attackerHoldEffectParam + 100)) / 100;
break;
}
}
if (attackerHoldEffect == HOLD_EFFECT_CHOICE_BAND)
attack = (150 * attack) / 100;
if (attackerHoldEffect == HOLD_EFFECT_SOUL_DEW && !(gBattleTypeFlags & (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_FRONTIER)) && (attacker->species == SPECIES_LATIAS || attacker->species == SPECIES_LATIOS))
spAttack = (150 * spAttack) / 100;
if (defenderHoldEffect == HOLD_EFFECT_SOUL_DEW && !(gBattleTypeFlags & (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_FRONTIER)) && (defender->species == SPECIES_LATIAS || defender->species == SPECIES_LATIOS))
spDefense = (150 * spDefense) / 100;
if (attackerHoldEffect == HOLD_EFFECT_DEEP_SEA_TOOTH && attacker->species == SPECIES_CLAMPERL)
spAttack *= 2;
if (defenderHoldEffect == HOLD_EFFECT_DEEP_SEA_SCALE && defender->species == SPECIES_CLAMPERL)
spDefense *= 2;
if (attackerHoldEffect == HOLD_EFFECT_LIGHT_BALL && attacker->species == SPECIES_PIKACHU)
spAttack *= 2;
if (defenderHoldEffect == HOLD_EFFECT_METAL_POWDER && defender->species == SPECIES_DITTO)
defense *= 2;
if (attackerHoldEffect == HOLD_EFFECT_THICK_CLUB && (attacker->species == SPECIES_CUBONE || attacker->species == SPECIES_MAROWAK))
attack *= 2;
if (defender->ability == ABILITY_THICK_FAT && (type == TYPE_FIRE || type == TYPE_ICE))
spAttack /= 2;
if (attacker->ability == ABILITY_HUSTLE)
attack = (150 * attack) / 100;
if (attacker->ability == ABILITY_PLUS && AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, ABILITY_MINUS, 0, 0))
spAttack = (150 * spAttack) / 100;
if (attacker->ability == ABILITY_MINUS && AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, ABILITY_PLUS, 0, 0))
spAttack = (150 * spAttack) / 100;
if (attacker->ability == ABILITY_GUTS && attacker->status1)
attack = (150 * attack) / 100;
if (defender->ability == ABILITY_MARVEL_SCALE && defender->status1)
defense = (150 * defense) / 100;
if (type == TYPE_ELECTRIC && AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, 0, 0xFD, 0))
gBattleMovePower /= 2;
if (type == TYPE_FIRE && AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, 0, 0xFE, 0))
gBattleMovePower /= 2;
if (type == TYPE_GRASS && attacker->ability == ABILITY_OVERGROW && attacker->hp <= (attacker->maxHP / 3))
gBattleMovePower = (150 * gBattleMovePower) / 100;
if (type == TYPE_FIRE && attacker->ability == ABILITY_BLAZE && attacker->hp <= (attacker->maxHP / 3))
gBattleMovePower = (150 * gBattleMovePower) / 100;
if (type == TYPE_WATER && attacker->ability == ABILITY_TORRENT && attacker->hp <= (attacker->maxHP / 3))
gBattleMovePower = (150 * gBattleMovePower) / 100;
if (type == TYPE_BUG && attacker->ability == ABILITY_SWARM && attacker->hp <= (attacker->maxHP / 3))
gBattleMovePower = (150 * gBattleMovePower) / 100;
if (gBattleMoves[gCurrentMove].effect == EFFECT_EXPLOSION)
defense /= 2;
if (type < TYPE_MYSTERY) // is physical
{
if (gCritMultiplier == 2)
{
if (attacker->statStages[STAT_STAGE_ATK] > 6)
APPLY_STAT_MOD(damage, attacker, attack, STAT_STAGE_ATK)
else
damage = attack;
}
else
APPLY_STAT_MOD(damage, attacker, attack, STAT_STAGE_ATK)
damage = damage * gBattleMovePower;
damage *= (2 * attacker->level / 5 + 2);
if (gCritMultiplier == 2)
{
if (defender->statStages[STAT_STAGE_DEF] < 6)
APPLY_STAT_MOD(damageHelper, defender, defense, STAT_STAGE_DEF)
else
damageHelper = defense;
}
else
APPLY_STAT_MOD(damageHelper, defender, defense, STAT_STAGE_DEF)
damage = damage / damageHelper;
damage /= 50;
if ((attacker->status1 & STATUS_BURN) && attacker->ability != ABILITY_GUTS)
damage /= 2;
if ((sideStatus & SIDE_STATUS_REFLECT) && gCritMultiplier == 1)
{
if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && CountAliveMonsInBattle(2) == 2)
damage = 2 * (damage / 3);
else
damage /= 2;
}
if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && gBattleMoves[move].target == 8 && CountAliveMonsInBattle(2) == 2)
damage /= 2;
// moves always do at least 1 damage.
if (damage == 0)
damage = 1;
}
if (type == TYPE_MYSTERY)
damage = 0; // is ??? type. does 0 damage.
if (type > TYPE_MYSTERY) // is special?
{
if (gCritMultiplier == 2)
{
if (attacker->statStages[STAT_STAGE_SPATK] > 6)
APPLY_STAT_MOD(damage, attacker, spAttack, STAT_STAGE_SPATK)
else
damage = spAttack;
}
else
APPLY_STAT_MOD(damage, attacker, spAttack, STAT_STAGE_SPATK)
damage = damage * gBattleMovePower;
damage *= (2 * attacker->level / 5 + 2);
if (gCritMultiplier == 2)
{
if (defender->statStages[STAT_STAGE_SPDEF] < 6)
APPLY_STAT_MOD(damageHelper, defender, spDefense, STAT_STAGE_SPDEF)
else
damageHelper = spDefense;
}
else
APPLY_STAT_MOD(damageHelper, defender, spDefense, STAT_STAGE_SPDEF)
damage = (damage / damageHelper);
damage /= 50;
if ((sideStatus & SIDE_STATUS_LIGHTSCREEN) && gCritMultiplier == 1)
{
if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && CountAliveMonsInBattle(2) == 2)
damage = 2 * (damage / 3);
else
damage /= 2;
}
if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && gBattleMoves[move].target == 8 && CountAliveMonsInBattle(2) == 2)
damage /= 2;
// are effects of weather negated with cloud nine or air lock
if (!AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, ABILITY_CLOUD_NINE, 0, 0)
&& !AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, ABILITY_AIR_LOCK, 0, 0))
{
if (gBattleWeather & WEATHER_RAIN_TEMPORARY)
{
switch (type)
{
case TYPE_FIRE:
damage /= 2;
break;
case TYPE_WATER:
damage = (15 * damage) / 10;
break;
}
}
// any weather except sun weakens solar beam
if ((gBattleWeather & (WEATHER_RAIN_ANY | WEATHER_SANDSTORM_ANY | WEATHER_HAIL)) && gCurrentMove == MOVE_SOLAR_BEAM)
damage /= 2;
// sunny
if (gBattleWeather & WEATHER_SUN_ANY)
{
switch (type)
{
case TYPE_FIRE:
damage = (15 * damage) / 10;
break;
case TYPE_WATER:
damage /= 2;
break;
}
}
}
// flash fire triggered
if ((gBattleResources->flags->flags[bankAtk] & UNKNOWN_FLAG_FLASH_FIRE) && type == TYPE_FIRE)
damage = (15 * damage) / 10;
}
return damage + 2;
}

View File

@ -63,11 +63,20 @@ void SetSaveBlocksPointers(u16 offset)
SetBagItemsPointers();
SetDecorationInventoriesPointers();
}
struct SaveBlocksInOne
{
struct SaveBlock2 sav2;
struct SaveBlock1 sav1;
struct PokemonStorage sav3;
};
/*
void MoveSaveBlocks_ResetHeap(void)
{
void *vblankCB, *hblankCB;
u32 encryptionKey;
struct SaveBlocksInOne* copiedSavs;
// save interrupt functions and turn them off
vblankCB = gMain.vblankCallback;
@ -76,19 +85,21 @@ void MoveSaveBlocks_ResetHeap(void)
gMain.hblankCallback = NULL;
gUnknown_0203CF5C = NULL;
copiedSavs = (void*)(gHeap);
// copy saveblocks' content
memcpy(gHeap, gSaveBlock2Ptr, sizeof(struct SaveBlock2));
memcpy(gHeap + sizeof(struct SaveBlock2), gSaveBlock1Ptr, sizeof(struct SaveBlock1));
memcpy(gHeap + sizeof(struct SaveBlock2) + sizeof(struct SaveBlock1), gPokemonStoragePtr, sizeof(struct PokemonStorage));
copiedSavs->sav2 = *gSaveBlock2Ptr;
copiedSavs->sav1 = *gSaveBlock1Ptr;
copiedSavs->sav3 = *gPokemonStoragePtr;
// change saveblocks' pointers
// argument is a sum of the individual trainerId bytes
SetSaveBlocksPointers(gHeap[10] + gHeap[11] + gHeap[12] + gHeap[13]);
SetSaveBlocksPointers(copiedSavs->sav2.playerTrainerId[0] + copiedSavs->sav2.playerTrainerId[1] + copiedSavs->sav2.playerTrainerId[2] + copiedSavs->sav2.playerTrainerId[3]);
// restore saveblock data since the pointers changed
memcpy(gSaveBlock2Ptr, gHeap, sizeof(struct SaveBlock2));
memcpy(gSaveBlock1Ptr, gHeap + sizeof(struct SaveBlock2), sizeof(struct SaveBlock1));
memcpy(gPokemonStoragePtr, gHeap + sizeof(struct SaveBlock2) + sizeof(struct SaveBlock1), sizeof(struct PokemonStorage));
*gSaveBlock2Ptr = copiedSavs->sav2;
*gSaveBlock1Ptr = copiedSavs->sav1;
*gPokemonStoragePtr = copiedSavs->sav3;
// heap was destroyed in the copying process, so reset it
InitHeap(gHeap, sizeof(gHeap));