diff options
-rw-r--r-- | asm/battle_2.s | 2 | ||||
-rw-r--r-- | asm/battle_3.s | 6 | ||||
-rw-r--r-- | asm/battle_4.s | 74 | ||||
-rw-r--r-- | asm/battle_9.s | 6 | ||||
-rw-r--r-- | include/battle.h | 438 | ||||
-rw-r--r-- | src/battle_2.c | 201 | ||||
-rw-r--r-- | src/battle_ai.c | 249 | ||||
-rw-r--r-- | src/pokemon_3.c | 10 | ||||
-rw-r--r-- | src/tv.c | 23 |
9 files changed, 654 insertions, 355 deletions
diff --git a/asm/battle_2.s b/asm/battle_2.s index c1f75dad5..ed4140583 100644 --- a/asm/battle_2.s +++ b/asm/battle_2.s @@ -4092,7 +4092,7 @@ _08014522: adds r1, r2 adds r1, 0x20 ldrb r1, [r1] - bl sub_81074C4 + bl RecordAbilityBattle ldr r2, _08014568 @ =gSpecialStatuses ldrb r1, [r4] lsls r0, r1, 2 diff --git a/asm/battle_3.s b/asm/battle_3.s index ffe32f27b..8f3097c3d 100644 --- a/asm/battle_3.s +++ b/asm/battle_3.s @@ -8590,7 +8590,7 @@ _08019F7C: beq _08019F92 adds r1, r0, 0 mov r0, r10 - bl sub_81074C4 + bl RecordAbilityBattle _08019F92: mov r0, r9 add sp, 0x28 @@ -9185,7 +9185,7 @@ _0801A4A8: str r3, [sp, 0xC] adds r0, r7, 0 adds r1, r5, 0 - bl sub_81074F8 + bl RecordItemBattle bl _0801AD5A .align 2, 0 _0801A4C4: .4byte gBattleMoveDamage @@ -11475,7 +11475,7 @@ _0801B7C2: adds r0, 0x20 ldrb r1, [r0] adds r0, r5, 0 - bl sub_81074C4 + bl RecordAbilityBattle ldr r1, _0801B804 @ =gSpecialStatuses lsls r0, r5, 2 adds r0, r5 diff --git a/asm/battle_4.s b/asm/battle_4.s index 5436d3e55..6747abc6c 100644 --- a/asm/battle_4.s +++ b/asm/battle_4.s @@ -291,7 +291,7 @@ _0801BE7E: mov r2, r8 ldrb r0, [r2] ldrb r1, [r4] - bl sub_81074C4 + bl RecordAbilityBattle b _0801BFF4 .align 2, 0 _0801BEB8: .4byte gNoOfAllBanks @@ -1812,8 +1812,8 @@ _0801CAF0: .4byte gProtectStructs _0801CAF4: .4byte gBattlescriptCurrInstr thumb_func_end atk05_damagecalc1 - thumb_func_start sub_801CAF8 -sub_801CAF8: @ 801CAF8 + thumb_func_start AI_CalcDmg +AI_CalcDmg: @ 801CAF8 push {r4-r7,lr} mov r7, r9 mov r6, r8 @@ -1923,7 +1923,7 @@ _0801CBDC: .4byte 0x0001601f _0801CBE0: .4byte gStatuses3 _0801CBE4: .4byte gBattleMoves _0801CBE8: .4byte gProtectStructs - thumb_func_end sub_801CAF8 + thumb_func_end AI_CalcDmg thumb_func_start battle_attack_damage_modulate_by_effectivity battle_attack_damage_modulate_by_effectivity: @ 801CBEC @@ -2143,7 +2143,7 @@ _0801CD44: strb r2, [r0, 0x6] ldrb r0, [r4] ldrb r1, [r3] - bl sub_81074C4 + bl RecordAbilityBattle b _0801CE58 .align 2, 0 _0801CD94: .4byte gBattleMoves @@ -2300,7 +2300,7 @@ _0801CE94: strb r0, [r1, 0x6] ldrb r0, [r5] ldrb r1, [r3] - bl sub_81074C4 + bl RecordAbilityBattle _0801CED6: ldr r0, _0801CF1C @ =gBattleMoveFlags ldrb r1, [r0] @@ -2412,7 +2412,7 @@ _0801CF94: strb r1, [r0, 0x6] ldrb r0, [r3] movs r1, 0x1A - bl sub_81074C4 + bl RecordAbilityBattle b _0801D1A4 .align 2, 0 _0801CFC8: .4byte gBattleMons @@ -2657,7 +2657,7 @@ _0801D14E: mov r1, r8 ldrb r0, [r1] movs r1, 0x19 - bl sub_81074C4 + bl RecordAbilityBattle _0801D1A4: pop {r3,r4} mov r8, r3 @@ -2778,8 +2778,8 @@ _0801D27A: bx r0 thumb_func_end b_attack_effectivity_adapt - thumb_func_start move_effectiveness_something -move_effectiveness_something: @ 801D280 + thumb_func_start TypeCalc +TypeCalc: @ 801D280 push {r4-r7,lr} mov r7, r10 mov r6, r9 @@ -3020,7 +3020,7 @@ _0801D44C: .4byte gTypeEffectiveness _0801D450: .4byte gBattleMons _0801D454: .4byte gBankTarget _0801D458: .4byte gBattleMoves - thumb_func_end move_effectiveness_something + thumb_func_end TypeCalc thumb_func_start ai_rate_move ai_rate_move: @ 801D45C @@ -3280,7 +3280,7 @@ _0801D632: bcs _0801D670 ldrb r0, [r5] movs r1, 0x27 - bl sub_81074F8 + bl RecordItemBattle ldr r2, _0801D6FC @ =gSpecialStatuses ldrb r1, [r5] lsls r0, r1, 2 @@ -3484,7 +3484,7 @@ _0801D7E2: bcs _0801D820 ldrb r0, [r5] movs r1, 0x27 - bl sub_81074F8 + bl RecordItemBattle ldr r2, _0801D890 @ =gSpecialStatuses ldrb r1, [r5] lsls r0, r1, 2 @@ -5294,7 +5294,7 @@ _0801E64A: mov r3, r8 ldrb r0, [r3] movs r1, 0x11 - bl sub_81074C4 + bl RecordAbilityBattle ldr r4, _0801E67C @ =gBattlescriptCurrInstr ldr r0, [r4] adds r0, 0x1 @@ -5417,7 +5417,7 @@ _0801E72E: mov r3, r8 ldrb r0, [r3] movs r1, 0x29 - bl sub_81074C4 + bl RecordAbilityBattle ldr r4, _0801E750 @ =gBattlescriptCurrInstr ldr r0, [r4] adds r0, 0x1 @@ -5608,7 +5608,7 @@ _0801E8A6: mov r3, r8 ldrb r0, [r3] movs r1, 0x7 - bl sub_81074C4 + bl RecordAbilityBattle ldr r4, _0801E8C8 @ =gBattlescriptCurrInstr ldr r0, [r4] adds r0, 0x1 @@ -5651,7 +5651,7 @@ _0801E8FE: mov r1, r8 ldrb r0, [r1] movs r1, 0x11 - bl sub_81074C4 + bl RecordAbilityBattle ldr r4, _0801E93C @ =gBattlescriptCurrInstr ldr r0, [r4] adds r0, 0x1 @@ -6081,7 +6081,7 @@ _0801ECF4: mov r1, r8 ldrb r0, [r1] movs r1, 0x27 - bl sub_81074C4 + bl RecordAbilityBattle ldr r1, _0801ED10 @ =gBattlescriptCurrInstr ldr r0, _0801ED14 @ =BattleScript_FlinchPrevention str r0, [r1] @@ -6712,7 +6712,7 @@ _0801F214: strb r0, [r1] ldrb r0, [r7] ldrb r1, [r1] - bl sub_81074C4 + bl RecordAbilityBattle b _0801F5FA .align 2, 0 _0801F254: .4byte gBankAttacker @@ -7044,7 +7044,7 @@ _0801F500: str r0, [r1] ldrb r0, [r5] movs r1, 0x3C - bl sub_81074C4 + bl RecordAbilityBattle b _0801F5FA .align 2, 0 _0801F534: .4byte gLastUsedAbility @@ -8058,7 +8058,7 @@ _0801FD5C: ldrb r1, [r0] adds r0, r4, 0 _0801FD80: - bl sub_81074C4 + bl RecordAbilityBattle ldr r0, _0801FD98 @ =0x02000000 ldr r1, _0801FD9C @ =0x000160f8 adds r0, r1 @@ -12829,7 +12829,7 @@ atk4A_damageflags: @ 80222DC strb r2, [r0, 0x6] ldrb r0, [r7] ldrb r1, [r3] - bl sub_81074C4 + bl RecordAbilityBattle b _08022452 .align 2, 0 _08022340: .4byte gBattleMoves @@ -13030,7 +13030,7 @@ _08022494: strb r0, [r1, 0x6] ldrb r0, [r2] ldrb r1, [r3] - bl sub_81074C4 + bl RecordAbilityBattle _080224CE: ldr r0, _08022518 @ =gBattleMoveFlags ldrb r1, [r0] @@ -13310,7 +13310,7 @@ _080226EA: ldr r1, [sp, 0x50] str r1, [r0] _08022710: - bl sub_8010B88 + bl SwitchInClearStructs ldr r0, _08022778 @ =0x02000000 ldr r3, _08022754 @ =gActiveBank ldrb r2, [r3] @@ -17237,7 +17237,7 @@ _08024726: bcs _08024764 ldrb r0, [r5] movs r1, 0x27 - bl sub_81074F8 + bl RecordItemBattle ldr r2, _080247F0 @ =gSpecialStatuses ldrb r1, [r5] lsls r0, r1, 2 @@ -17919,7 +17919,7 @@ atk70_record_ability_usage_of_side: @ 8024CB8 ldrb r0, [r1] ldr r1, _08024CE8 @ =gLastUsedAbility ldrb r1, [r1] - bl sub_81074C4 + bl RecordAbilityBattle ldr r0, [r4] adds r0, 0x1 str r0, [r4] @@ -18739,7 +18739,7 @@ _08025354: adds r1, r6 adds r1, 0x20 ldrb r1, [r1] - bl sub_81074C4 + bl RecordAbilityBattle ldr r1, _08025380 @ =gBattlescriptCurrInstr ldr r0, _08025384 @ =gUnknown_081D9834 str r0, [r1] @@ -19746,7 +19746,7 @@ _08025B2C: str r4, [r5] ldrb r1, [r2] adds r0, r3, 0 - bl sub_81074C4 + bl RecordAbilityBattle b _08025B56 .align 2, 0 _08025B44: .4byte gBattleMons @@ -20345,7 +20345,7 @@ _08025FE0: strb r0, [r1] ldrb r0, [r2] ldrb r1, [r1] - bl sub_81074C4 + bl RecordAbilityBattle ldr r0, _0802602C @ =gActiveBank ldrb r1, [r0] lsls r0, r1, 2 @@ -20401,7 +20401,7 @@ _08026040: strb r0, [r1] ldrb r0, [r3] ldrb r1, [r1] - bl sub_81074C4 + bl RecordAbilityBattle b _08025F74 .align 2, 0 _08026090: .4byte gActiveBank @@ -20449,7 +20449,7 @@ _080260CA: strb r0, [r1] ldrb r0, [r3] ldrb r1, [r1] - bl sub_81074C4 + bl RecordAbilityBattle b _08025F74 .align 2, 0 _080260FC: .4byte gActiveBank @@ -21840,7 +21840,7 @@ _08026BCE: bcs _08026C0C ldrb r0, [r5] movs r1, 0x27 - bl sub_81074F8 + bl RecordItemBattle ldr r2, _08026C54 @ =gSpecialStatuses ldrb r1, [r5] lsls r0, r1, 2 @@ -21880,7 +21880,7 @@ _08026C0C: ldr r1, _08026C50 @ =gBankTarget ldrb r0, [r1] movs r1, 0x5 - bl sub_81074C4 + bl RecordAbilityBattle b _08026E40 .align 2, 0 _08026C4C: .4byte gStringBank @@ -22497,7 +22497,7 @@ _080270F0: strb r2, [r0] ldrb r0, [r5] movs r1, 0xC - bl sub_81074C4 + bl RecordAbilityBattle b _0802721C .align 2, 0 _0802714C: .4byte gBattlePartyID @@ -25469,7 +25469,7 @@ _080288C0: .4byte gBattleMons _080288C4: ldrb r1, [r1] adds r0, r3, 0 - bl sub_81074C4 + bl RecordAbilityBattle ldrb r0, [r5, 0x5] movs r1, 0x1 orrs r0, r1 @@ -25532,7 +25532,7 @@ _08028950: .4byte gBattleMons _08028954: ldrb r1, [r1] adds r0, r3, 0 - bl sub_81074C4 + bl RecordAbilityBattle ldr r1, _080289AC @ =gBattleCommunication ldrb r0, [r1, 0x5] orrs r0, r6 @@ -28815,7 +28815,7 @@ _0802A334: strb r0, [r1] ldrb r0, [r7] ldrb r1, [r1] - bl sub_81074C4 + bl RecordAbilityBattle b _0802A49A .align 2, 0 _0802A360: .4byte gBattlescriptCurrInstr diff --git a/asm/battle_9.s b/asm/battle_9.s index 887fbd702..fffb56dc9 100644 --- a/asm/battle_9.s +++ b/asm/battle_9.s @@ -1847,7 +1847,7 @@ _08036EA4: ldrb r1, [r0] adds r0, r4, 0 mov r2, r10 - bl move_effectiveness_something + bl TypeCalc movs r1, 0x2 ands r1, r0 cmp r1, 0 @@ -1976,11 +1976,11 @@ _08036F90: beq _08036FCC ldrb r0, [r6] mov r1, r10 - bl sub_801CAF8 + bl AI_CalcDmg ldrb r1, [r6] adds r0, r4, 0 mov r2, r10 - bl move_effectiveness_something + bl TypeCalc _08036FCC: mov r2, r8 ldr r0, [r2] diff --git a/include/battle.h b/include/battle.h index 395cf042a..a67dc70c5 100644 --- a/include/battle.h +++ b/include/battle.h @@ -28,8 +28,82 @@ #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 STATUS2_CONFUSION 0x00000007 +#define STATUS2_UPROAR 0x00000070 +#define STATUS2_LOCK_CONFUSE 0x00000C00 +#define STATUS2_MULTIPLETURNS 0x00001000 +#define STATUS2_WRAPPED 0x0000E000 +#define STATUS2_FOCUS_ENERGRY 0x00100000 +#define STATUS2_TRANSFORMED 0x00200000 +#define STATUS2_RECHARGE 0x00400000 +#define STATUS2_RAGE 0x00800000 +#define STATUS2_SUBSTITUTE 0x01000000 +#define STATUS2_ESCAPE_PREVENTION 0x04000000 +#define STATUS2_NIGHTMARE 0x08000000 +#define STATUS2_CURSED 0x10000000 +#define STATUS2_FORESIGHT 0x20000000 + +#define STATUS3_LEECHSEED_RECEIVER 0x3 //two bits for the bank that gets hp +#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_CHARGED_UP 0x200 +#define STATUS3_ROOTED 0x400 +#define STATUS3_GRUDGE 0x4000 +#define STATUS3_CANT_SCORE_A_CRIT 0x8000 +#define STATUS3_MUDSPORT 0x10000 +#define STATUS3_WATERSPORT 0x20000 +#define STATUS3_UNDERWATER 0x40000 + +#define HITMARKER_x20 0x0000020 +#define HITMARKER_DESTINYBOND 0x0000040 +#define HITMARKER_NO_ANIMATIONS 0x0000080 +#define HITMARKER_IGNORE_SUBSTITUTE 0x0000100 +#define HITMARKER_NO_ATTACKSTRING 0x0000200 +#define HITMARKER_ATTACKSTRING_PRINTED 0x0000400 +#define HITMARKER_NO_PPDEDUCT 0x0000800 +#define HITMARKER_IGNORE_SAFEGUARD 0x0002000 +#define HITMARKER_SYNCHRONISE_EFFECT 0x0004000 +#define HITMARKER_IGNORE_ON_AIR 0x0010000 +#define HITMARKER_IGNORE_UNDERGROUND 0x0020000 +#define HITMARKER_IGNORE_UNDERWATER 0x0040000 +#define HITMARKER_x80000 0x0080000 +#define HITMARKER_x100000 0x0100000 +#define HITMARKER_x400000 0x0400000 +#define HITMARKER_x800000 0x0800000 +#define HITMARKER_GRUDGE 0x1000000 +#define HITMARKER_OBEYS 0x2000000 +#define HITMARKER_FAINTED(bank) ((gBitTable[bank] << 0x1C)) +#define HITMARKER_UNK(bank) ((0x10000000 << bank)) + #define MAX_TRAINER_ITEMS 4 #define MAX_MON_MOVES 4 +#define MAX_BANKS_BATTLE 4 + +#define weather_rain 1 +#define weather_downpour 2 +#define weather_permament_rain 4 +#define WEATHER_RAINY ((weather_rain | weather_downpour | weather_permament_rain)) + +#define weather_sandstorm 8 +#define weather_permament_sandstorm 0x10 +#define WEATHER_SANDSTORMY ((weather_sandstorm | weather_permament_sandstorm)) + +#define weather_sun 0x20 +#define weather_permament_sun 0x40 +#define WEATHER_SUNNY ((weather_sun | weather_permament_sun)) + +#define weather_hail 0x80 // needed to match the hack that is get_item, thanks cam, someone else clean this up later. extern u8 unk_2000000[]; @@ -85,79 +159,247 @@ struct AI_ThinkingStruct /* 0x2016800 */ /* 0x18 */ u8 simulatedRNG[4]; }; -struct SmallBattleStruct1 -{ - u8 unk1; - u8 unk2; - u8 unk3; - u8 unk4; - // unknown size -}; - -struct SmallItemStruct -{ - u8 itemLocal[2][3]; -}; - struct BattleStruct /* 0x2000000 */ { u8 filler0[0x15DDE]; /*0x15DDE*/ u8 unk15DDE; /*0x15DDF*/ u8 unk15DDF; - /*0x15DE0*/ u8 filler15DE0[0x23C]; // 0xAF off? - struct SmallBattleStruct1 unk; - u8 filler1[0x68]; - /* 0x16089 */ u8 safariFleeRate; - u8 filler1_2[0x42]; - /* 0x160CB */ u8 linkPlayerIndex; - /* 0x160CC */ struct SmallItemStruct item; + /*0x15DE0*/ u8 filler15DE0[0x222]; + /*0x16002*/ u8 AnimTurn; + /*0x16003*/ u8 ScriptingActive; + /*0x16004*/ u8 WrappedMove1[4]; + /*0x16008*/ u8 WrappedMove2[4]; + /*0x1600C*/ u8 cmd49StateTracker; + /*0x1600D*/ u8 unk1600D; + /*0x1600E*/ u8 unk1600E; + /*0x1600F*/ u8 atk23StateTracker; + /*0x16010*/ u8 unk16010; + /*0x16011*/ u8 unk16011; + /*0x16012*/ u8 unk16012; + /*0x16013*/ u8 unk16013; + /*0x16014*/ u8 unk16014; + /*0x16015*/ u8 unk16015; + /*0x16016*/ u8 unk16016; + /*0x16017*/ u8 unk16017; + /*0x16018*/ u8 expGetterID; + /*0x16019*/ u8 unk16019; + /*0x1601A*/ u8 unk1601A; + /*0x1601B*/ u8 wildVictorySong; + /*0x1601C*/ u8 DynamicMoveType; + /*0x1601D*/ u8 unk1601D; + /*0x1601E*/ u8 statChanger; + /*0x1601F*/ u8 DmgMultiplier; + /*0x16020*/ u8 WrappedBy[4]; + /*0x16024*/ u8 unk16024; + /*0x16025*/ u8 unk16025; + /*0x16026*/ u8 unk16026; + /*0x16027*/ u8 unk16027; + /*0x16028*/ u8 unk16028; + /*0x16029*/ u8 unk16029; + /*0x1602A*/ u8 unk1602A; + /*0x1602B*/ u8 unk1602B; + /*0x1602C*/ u8 unk1602C; + /*0x1602D*/ u8 unk1602D; + /*0x1602E*/ u8 unk1602E; + /*0x1602F*/ u8 unk1602F; + /*0x16030*/ u8 unk16030; + /*0x16031*/ u8 unk16031; + /*0x16032*/ u8 unk16032; + /*0x16033*/ u8 unk16033; + /*0x16034*/ u8 unk16034; + /*0x16035*/ u8 unk16035; + /*0x16036*/ u8 unk16036; + /*0x16037*/ u8 unk16037; + /*0x16038*/ u8 unk16038; + /*0x16039*/ u8 unk16039; + /*0x1603A*/ u8 unk1603A; + /*0x1603B*/ u8 unk1603B; + /*0x1603C*/ u8 unk1603C; + /*0x1603D*/ u8 unk1603D; + /*0x1603E*/ u8 unk1603E; + /*0x1603F*/ u8 unk1603F; + /*0x16040*/ u8 unk16040; + /*0x16041*/ u8 unk16041; + /*0x16042*/ u8 unk16042; + /*0x16043*/ u8 unk16043; + /*0x16044*/ u8 unk16044; + /*0x16045*/ u8 unk16045; + /*0x16046*/ u8 unk16046; + /*0x16047*/ u8 unk16047; + /*0x16048*/ u8 unk16048; + /*0x16049*/ u8 unk16049; + /*0x1604A*/ u8 unk1604A; + /*0x1604B*/ u8 unk1604B; + /*0x1604C*/ u8 unk1604C; + /*0x1604D*/ u8 unk1604D; + /*0x1604E*/ u8 unk1604E; + /*0x1604F*/ u8 unk1604F; + /*0x16050*/ u8 unk16050; + /*0x16051*/ u8 unk16051; + /*0x16052*/ u8 unk16052; + /*0x16053*/ u8 unk16053; + /*0x16054*/ u8 unk16054; + /*0x16055*/ u8 unk16055; + /*0x16056*/ u8 unk16056; + /*0x16057*/ u8 unk16057; + /*0x16058*/ u8 unk16058; + /*0x16059*/ u8 unk16059; + /*0x1605A*/ u8 unk1605A; + /*0x1605B*/ u8 unk1605B; + /*0x1605C*/ u16 exp; + /*0x1605E*/ u8 unk1605E; + /*0x1605F*/ u8 sentInPokes; + /*0x16060*/ u8 unk16060[4]; + /*0x16064*/ u8 unk16064; + /*0x16065*/ u8 unk16065; + /*0x16066*/ u8 unk16066; + /*0x16067*/ u8 unk16067; + /*0x16068*/ u8 unk16068; + /*0x16069*/ u8 unk16069; + /*0x1606A*/ u8 unk1606A; + /*0x1606B*/ u8 unk1606B; + /*0x1606C*/ u8 unk1606C; + /*0x1606D*/ u8 unk1606D; + /*0x1606E*/ u8 unk1606E; + /*0x1606F*/ u8 unk1606F; + /*0x16070*/ u8 unk16070; + /*0x16071*/ u8 unk16071; + /*0x16072*/ u8 unk16072; + /*0x16073*/ u8 unk16073; + /*0x16074*/ u8 unk16074; + /*0x16075*/ u8 unk16075; + /*0x16076*/ u8 unk16076; + /*0x16077*/ u8 unk16077; + /*0x16078*/ u8 unk16078; + /*0x16079*/ u8 unk16079; + /*0x1607A*/ u8 unk1607A; + /*0x1607B*/ u8 unk1607B; + /*0x1607C*/ u8 unk1607C; + /*0x1607D*/ u8 unk1607D; + /*0x1607E*/ u8 unk1607E; + /*0x1607F*/ u8 unk1607F; + /*0x16080*/ u8 unk16080; + /*0x16081*/ u8 unk16081; + /*0x16082*/ u8 unk16082; + /*0x16083*/ u8 unk16083; + /*0x16084*/ u8 unk16084; + /*0x16085*/ u8 unk16085; + /*0x16086*/ u8 unk16086; + /*0x16087*/ u8 unk16087; + /*0x16088*/ u8 safariFleeRate; + /*0x16089*/ u8 unk16089; + /*0x1608A*/ u8 unk1608A; + /*0x1608B*/ u8 unk1608B; + /*0x1608C*/ u8 ChosenMoveID[4]; + /*0x16090*/ u8 unk16090; + /*0x16091*/ u8 unk16091; + /*0x16092*/ u8 unk16092; + /*0x16093*/ u8 unk16093; + /*0x16094*/ u8 unk16094; + /*0x16095*/ u8 unk16095; + /*0x16096*/ u8 unk16096; + /*0x16097*/ u8 unk16097; + /*0x16098*/ u8 unk16098; + /*0x16099*/ u8 unk16099; + /*0x1609A*/ u8 unk1609a; + /*0x1609B*/ u8 unk1609b; + /*0x1609C*/ u8 unk1609C; + /*0x1609D*/ u8 unk1609D; + /*0x1609E*/ u8 unk1609E; + /*0x1609F*/ u8 unk1609F; + /*0x160A0*/ u8 unk160a0; + /*0x160A1*/ u8 AnimTargetsHit; + /*0x160A2*/ u8 expGetterBank; + /*0x160A3*/ u8 unk160A3; + /*0x160A4*/ u8 AnimArg1; + /*0x160A5*/ u8 AnimArg2; + /*0x160A6*/ u8 unk160A6; + /*0x160A7*/ u8 unk160A7; + /*0x160A8*/ u8 unk160A8; + /*0x160A9*/ u8 unk160A9; + /*0x160AA*/ u8 unk160Aa; + /*0x160AB*/ u8 unk160Ab; + /*0x160AC*/ u8 unk160AC; + /*0x160AD*/ u8 unk160AD; + /*0x160AE*/ u8 unk160AE; + /*0x160AF*/ u8 unk160AF; + /*0x160B0*/ u8 unk160B0; + /*0x160B1*/ u8 unk160B1; + /*0x160B2*/ u8 unk160B2; + /*0x160B3*/ u8 unk160B3; + /*0x160B4*/ u8 unk160B4; + /*0x160B5*/ u8 unk160B5; + /*0x160B6*/ u8 unk160B6; + /*0x160B7*/ u8 unk160B7; + /*0x160B8*/ u8 unk160B8; + /*0x160B9*/ u8 unk160B9; + /*0x160BA*/ u8 unk160Ba; + /*0x160BB*/ u8 unk160Bb; + /*0x160BC*/ u8 unk160BC; + /*0x160BD*/ u8 unk160BD; + /*0x160BE*/ u8 unk160BE; + /*0x160BF*/ u8 unk160BF; + /*0x160C0*/ u8 unk160C0; + /*0x160C1*/ u8 unk160C1; + /*0x160C2*/ u8 unk160C2; + /*0x160C3*/ u8 unk160C3; + /*0x160C4*/ u8 unk160C4; + /*0x160C5*/ u8 unk160C5; + /*0x160C6*/ u8 unk160C6; + /*0x160C7*/ u8 unk160C7; + /*0x160C8*/ u8 unk160C8; + /*0x160C9*/ u8 unk160C9; + /*0x160CA*/ u8 SynchroniseEffect; + /*0x160CB*/ u8 linkPlayerIndex; + /*0x160CC*/ u16 UsedHeldItems[4]; u8 filler2[0x72E]; - /* 0x16800 */ struct AI_ThinkingStruct ai; /* 0x2016800 */ - u8 filler1681C[0x1E4]; /* 0x16A00 */ struct UnkBattleStruct1 unk_2016A00_2; }; -struct UnkBattleStruct4 +struct DisableStruct { /*0x00*/ u8 filler0[0x3]; - /*0x04*/ u16 unk4; - /*0x06*/ u16 unk6; - /*0x08*/ u8 unk8; - /*0x09*/ u8 unk9; - /*0x0A*/ u8 unkA; + /*0x04*/ u16 DisabledMove; + /*0x06*/ u16 EncoredMove; + /*0x08*/ u8 ProtectUses; + /*0x09*/ u8 StockpileCounter; + /*0x0A*/ u8 SubstituteHP; u8 fillerB[4]; u8 unkF_0:4; u8 unkF_4:4; u8 filler10[3]; /*0x13*/ u8 taunt:4; /*0x13*/ u8 unkC:4; - /*0x14*/ u8 unk14; - /*0x15*/ u8 unk15; - /*0x16*/ u8 unk16; - /*0x17*/ u8 filler17[0x4]; + /*0x14*/ u8 BankPreventingEscape; + /*0x15*/ u8 BankWithSureHit; + /*0x16*/ u8 IsFirstTurn; + /*0x17*/ u8 unk17; + /*0x18*/ u8 TruantCounter; + /*0x19*/ u8 RechargeCounter; + /*0x1A*/ u8 unk1A[2]; }; -struct Struct30042E0 +struct BattleResults { - u8 unk0; - u8 unk1; - u8 unk2; - u8 unk3; - u8 unk4; - u8 unk5_0:1; - u8 unk5_1:1; - u16 unk6; - u8 unk8[10]; + u8 PlayerFaintCounter; //0x0 + u8 OpponentFaintCounter; //0x1 + u8 unk2; //0x2 + u8 unk3; //0x3 + u8 unk4; //0x4 + u8 unk5_0:1; //0x5 + u8 unk5_1:1; //0x5 + u16 Poke1Species; //0x6 + u8 PokeString1[10]; //0x8 u8 unk12; - u8 unk13; - u8 unk14[10]; + u8 BattleTurnCounter; //0x13 + u8 PokeString2[10]; //0x14 u8 filler1E[2]; - u16 unk20; - u16 unk22; - u16 unk24; - u16 unk26; - u16 unk28; - u8 unk2A[10]; + u16 LastOpponentSpecies; //0x20 + u16 LastUsedMove; //0x22 + u16 OpponentMove; //0x24 + u16 OpponentSpecies; //0x26 + u16 CaughtPoke; //0x28 + u8 CaughtNick[10]; //0x2A u8 filler34[2]; u8 unk36[10]; }; @@ -202,8 +444,95 @@ struct Struct2017840 u8 unk9_0:1; }; +struct ProtectStruct +{ + /*field0*/ + u32 Protected:1; + u32 Endured:1; + u32 OnlyStruggle:1; + u32 HelpingHand:1; + u32 BounceMove:1; + u32 StealMove:1; + u32 Flag0Unknown:1; + u32 PrlzImmobility:1; + /*field1*/ + u32 ConfusionSelfDmg:1; + u32 NotEffective:1; + u32 ChargingTurn:1; + u32 FleeFlag:2; //for RunAway and Smoke Ball + u32 UsedImprisionedMove:1; + u32 LoveImmobility:1; + u32 UsedDisabledMove:1; + /*field2*/ + u32 UsedTauntedMove:1; + u32 Flag2Unknown:1; + u32 FlinchImmobility:1; + u32 NotFirstStrike:1; + u32 Free : 4; + /*field3*/ + u32 field3 : 8; + u32 PhysicalDmg; + u32 SpecialDmg; + u8 PhysicalBank; + u8 SpecialBank; + u16 fieldE; +}; + +struct SpecialStatus +{ + u8 statLowered : 1; + u8 lightningRodRedirected : 1; + u8 restoredBankSprite: 1; + u8 intimidatedPoke : 1; + u8 traced : 1; + u8 flag20 : 1; + u8 flag40 : 1; + u8 focusBanded : 1; + u8 field1[3]; + u32 moveturnLostHP; + u32 moveturnlostHP_physical; + u32 moveturnLostHP_special; + u8 moveturnPhysicalBank; + u8 moveturnSpecialBank; + u8 field12; + u8 field13; +}; + +struct sideTimer +{ + u8 reflectTimer; + u8 reflectBank; + u8 lightscreenTimer; + u8 lightscreenBank; + u8 mistTimer; + u8 mistBank; + u8 safeguardTimer; + u8 safeguardBank; + u8 followmeTimer; + u8 followmeTarget; + u8 spikesAmount; + u8 fieldB; +}; + +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 wishUserBank[MAX_BANKS_BATTLE]; + u8 weatherDuration; + u8 knockedOffPokes[2]; +}; + extern struct UnkBattleStruct1 unk_2016A00; -extern struct UnkBattleStruct4 gDisableStructs[]; +extern struct DisableStruct gDisableStructs[MAX_BANKS_BATTLE]; +extern struct BattleResults gBattleResults; +extern struct ProtectStruct gProtectStructs[MAX_BANKS_BATTLE]; +extern struct SpecialStatus gSpecialStatuses[MAX_BANKS_BATTLE]; +extern struct sideTimer gSideTimer[2]; +extern struct WishFutureKnock gWishFutureKnock; extern struct AI_ThinkingStruct gAIThinkingSpace; // TODO: move ewram to global.h @@ -253,7 +582,6 @@ void sub_8010800(void); void sub_8010824(void); void sub_8010874(void); void bc_8012FAC(void); -void bc_load_battlefield(void); void sub_8011384(void); void bc_801333C(void); void bc_battle_begin_message(void); @@ -290,8 +618,8 @@ u8 AbilityBattleEffects(u8, u8, u8, u8, u16); u8 sub_801A02C(); // asm/battle_4.o -void sub_801CAF8(u8, u8); -void move_effectiveness_something(u16, u8, u8); +void AI_CalcDmg(u8, u8); +void TypeCalc(u16, u8, u8); // asm/battle_5.o void nullsub_91(void); diff --git a/src/battle_2.c b/src/battle_2.c index 2b13fc45d..3701da608 100644 --- a/src/battle_2.c +++ b/src/battle_2.c @@ -26,6 +26,9 @@ #include "trig.h" #include "unknown_task.h" #include "util.h" +#include "items.h" +#include "hold_effects.h" +#include "battle_move_effects.h" struct UnknownStruct6 { @@ -70,30 +73,6 @@ struct UnknownStruct12 u8 filler4[0x54]; }; -struct UnknownStruct13 -{ - u32 unk0_0:1; - u32 unk0_1:1; - u32 unk0_2:1; - u32 unk0_3:1; - u32 unk0_4:1; - u32 unk0_5:1; - u32 unk0_6:1; - u32 unk0_7:1; - u32 unk1_0:1; - u32 unk1_1:1; - u32 unk1_2:1; - u32 unk1_3:2; - u32 unk1_5:1; - u32 unk1_6:1; - u32 unk1_7:1; - u32 unk2_0:1; - u32 unk2_1:1; - u32 unk2_2:1; - u32 unk2_3:1; - u8 filler4[12]; -}; - extern const u16 gUnknown_08D004E0[]; extern const struct MonCoords gCastformFrontSpriteCoords[]; @@ -166,7 +145,6 @@ extern u16 gChosenMovesByBanks[]; extern u32 gHitMarker; extern u8 gUnknown_02024C70[]; extern u16 gSideAffecting[]; -extern u8 gSideTimer[][12]; extern u32 gStatuses3[]; //extern u8 gDisableStructs[][0x1C]; extern u16 gPauseCounterBattle; @@ -175,8 +153,6 @@ extern u16 gRandomTurnNumber; extern u8 gBattleCommunication[]; extern u8 gUnknown_02024D1F[]; // I don't actually know what type this is. extern u8 gBattleOutcome; -extern struct UnknownStruct13 gProtectStructs[]; -extern u8 gWishFutureKnock[]; extern u16 gUnknown_02024DE8; extern u8 gActionSelectionCursor[]; extern u8 gMoveSelectionCursor[]; @@ -199,7 +175,6 @@ extern u16 gUnknown_030042C0; extern u16 gUnknown_030042C4; extern MainCallback gPreBattleCallback1; extern void (*gBattleMainFunc)(void); -extern struct Struct30042E0 gBattleResults; extern u8 gLeveledUpInBattle; extern void (*gBattleBankFunc[])(void); extern u8 gHealthboxIDs[]; @@ -219,6 +194,7 @@ extern u32 gBattleMoveDamage; extern struct BattlePokemon gBattleMons[]; extern u8 gBattleMoveFlags; +static void BattlePrepIntroSlide(void); void sub_800E7C4(void) { @@ -1495,43 +1471,43 @@ void sub_80105EC(struct Sprite *sprite) } } -void dp11b_obj_instanciate(u8 a, u8 b, s8 c, s8 d) +void dp11b_obj_instanciate(u8 bank, u8 b, s8 c, s8 d) { u8 spriteId; - u8 r7; + u8 objectID; if (b) { - if (ewram17810[a].unk0_1) + if (ewram17810[bank].unk0_1) return; } else { - if (ewram17810[a].unk0_2) + if (ewram17810[bank].unk0_2) return; } spriteId = CreateInvisibleSpriteWithCallback(objc_dp11b_pingpong); if (b == TRUE) { - r7 = gHealthboxIDs[a]; - ewram17810[a].unk2 = spriteId; - ewram17810[a].unk0_1 = 1; + objectID = gHealthboxIDs[bank]; + ewram17810[bank].unk2 = spriteId; + ewram17810[bank].unk0_1 = 1; gSprites[spriteId].data0 = 0x80; } else { - r7 = gObjectBankIDs[a]; - ewram17810[a].unk3 = spriteId; - ewram17810[a].unk0_2 = 1; + objectID = gObjectBankIDs[bank]; + ewram17810[bank].unk3 = spriteId; + ewram17810[bank].unk0_2 = 1; gSprites[spriteId].data0 = 0xC0; } gSprites[spriteId].data1 = c; gSprites[spriteId].data2 = d; - gSprites[spriteId].data3 = r7; + gSprites[spriteId].data3 = objectID; gSprites[spriteId].data4 = b; - gSprites[r7].pos2.x = 0; - gSprites[r7].pos2.y = 0; + gSprites[objectID].pos2.x = 0; + gSprites[objectID].pos2.y = 0; } void dp11b_obj_free(u8 a, u8 b) @@ -1586,7 +1562,6 @@ void sub_8010800(void) void sub_8010824(void) { gBattleMainFunc(); - gActiveBank = 0; for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) gBattleBankFunc[gActiveBank](); @@ -1595,7 +1570,7 @@ void sub_8010824(void) void sub_8010874(void) { s32 i; - s32 j; + u32 j; u8 *r4; TurnValuesCleanUp(0); @@ -1609,7 +1584,7 @@ void sub_8010874(void) for (j = 0; j < (u32)0x1C; j++) r4[j] = 0; - gDisableStructs[i].unk16 = 2; + gDisableStructs[i].IsFirstTurn = 2; gUnknown_02024C70[i] = 0; gLastUsedMove[i] = 0; gMoveHitWith[i] = 0; @@ -1626,7 +1601,7 @@ void sub_8010874(void) gSideAffecting[i] = 0; r4 = (u8 *)&gSideTimer[i]; - for (j = 0; j < (u32)12; j++) + for (j = 0; j < 12; j++) r4[j] = 0; } @@ -1639,8 +1614,8 @@ void sub_8010874(void) r4[i] = 0; gHitMarker = 0; - if ((gBattleTypeFlags & 2) == 0 && gSaveBlock2.optionsBattleSceneOff == TRUE) - gHitMarker = 0x80; + if ((gBattleTypeFlags & BATTLE_TYPE_LINK) == 0 && gSaveBlock2.optionsBattleSceneOff == TRUE) + gHitMarker = HITMARKER_NO_ANIMATIONS; ewram16084 = gSaveBlock2.optionsBattleStyle; gMultiHitCounter = 0; gBattleOutcome = 0; @@ -1679,37 +1654,37 @@ void sub_8010874(void) ewram160C9 = 6; ewram16113 = 0; for (i = 0; i < 11; i++) - gBattleResults.unk36[i] = 0; - gBattleResults.unk13 = 0; - gBattleResults.unk0 = 0; - gBattleResults.unk1 = 0; + gBattleResults.unk36[i] = 0; + gBattleResults.BattleTurnCounter = 0; + gBattleResults.PlayerFaintCounter = 0; + gBattleResults.OpponentFaintCounter = 0; gBattleResults.unk2 = 0; gBattleResults.unk3 = 0; gBattleResults.unk4 = 0; gBattleResults.unk5_0 = 0; gBattleResults.unk5_1 = 0; - gBattleResults.unk20 = 0; - gBattleResults.unk22 = 0; - gBattleResults.unk24 = 0; - gBattleResults.unk6 = 0; - gBattleResults.unk26 = 0; - gBattleResults.unk28 = 0; + gBattleResults.LastOpponentSpecies = 0; + gBattleResults.LastUsedMove = 0; + gBattleResults.OpponentMove = 0; + gBattleResults.Poke1Species = 0; + gBattleResults.OpponentSpecies = 0; + gBattleResults.CaughtPoke = 0; for (i = 0; i < 10; i++) { - gBattleResults.unk8[i] = 0; - gBattleResults.unk14[i] = 0; - gBattleResults.unk2A[i] = 0; + gBattleResults.PokeString1[i] = 0; + gBattleResults.PokeString2[i] = 0; + gBattleResults.CaughtNick[i] = 0; } } -void sub_8010B88(void) +void SwitchInClearStructs(void) { - struct UnkBattleStruct4 sp0 = gDisableStructs[gActiveBank]; + struct DisableStruct sp0 = gDisableStructs[gActiveBank]; s32 i; u8 *ptr; u32 *ptr2; - if (gBattleMoves[gCurrentMove].effect != 0x7F) + if (gBattleMoves[gCurrentMove].effect != EFFECT_BATON_PASS) { for (i = 0; i < 8; i++) gBattleMons[gActiveBank].statStages[i] = 6; @@ -1717,27 +1692,27 @@ void sub_8010B88(void) { struct UnknownStruct12 *sp20 = &gUnknown_02024AD0[i]; - if ((sp20->unk0 & 0x04000000) && gDisableStructs[i].unk14 == gActiveBank) + if ((sp20->unk0 & 0x04000000) && gDisableStructs[i].BankPreventingEscape == gActiveBank) sp20->unk0 &= ~0x04000000; - if ((gStatuses3[i] & 0x18) && gDisableStructs[i].unk15 == gActiveBank) + if ((gStatuses3[i] & STATUS3_ALWAYS_HITS) && gDisableStructs[i].BankWithSureHit == gActiveBank) { - gStatuses3[i] &= ~0x18; - gDisableStructs[i].unk15 = 0; + gStatuses3[i] &= ~STATUS3_ALWAYS_HITS; + gDisableStructs[i].BankWithSureHit = 0; } } } - if (gBattleMoves[gCurrentMove].effect == 0x7F) + if (gBattleMoves[gCurrentMove].effect == EFFECT_BATON_PASS) { - gBattleMons[gActiveBank].status2 &= 0x15100007; - gStatuses3[gActiveBank] &= 0x3043F; + gBattleMons[gActiveBank].status2 &= (STATUS2_CONFUSION | STATUS2_FOCUS_ENERGRY | STATUS2_SUBSTITUTE | STATUS2_ESCAPE_PREVENTION | STATUS2_CURSED); + gStatuses3[gActiveBank] &= (STATUS3_LEECHSEED_RECEIVER | STATUS3_LEECHSEED | STATUS3_ALWAYS_HITS | STATUS3_PERISH_SONG | STATUS3_ROOTED | STATUS3_MUDSPORT | STATUS3_WATERSPORT); for (i = 0; i < gNoOfAllBanks; i++) { if (GetBankSide(gActiveBank) != GetBankSide(i) - && (gStatuses3[i] & 0x18) != 0 - && (gDisableStructs[i].unk15 == gActiveBank)) + && (gStatuses3[i] & STATUS3_ALWAYS_HITS) != 0 + && (gDisableStructs[i].BankWithSureHit == gActiveBank)) { - gStatuses3[i] &= ~0x18; + gStatuses3[i] &= ~STATUS3_ALWAYS_HITS; gStatuses3[i] |= 0x10; } } @@ -1763,15 +1738,15 @@ void sub_8010B88(void) for (i = 0; i < (u32)0x1C; i++) ptr[i] = 0; - if (gBattleMoves[gCurrentMove].effect == 0x7F) + if (gBattleMoves[gCurrentMove].effect == EFFECT_BATON_PASS) { - gDisableStructs[gActiveBank].unkA = sp0.unkA; - gDisableStructs[gActiveBank].unk15 = sp0.unk15; + gDisableStructs[gActiveBank].SubstituteHP = sp0.SubstituteHP; + gDisableStructs[gActiveBank].BankWithSureHit = sp0.BankWithSureHit; gDisableStructs[gActiveBank].unkF_0 = sp0.unkF_0; gDisableStructs[gActiveBank].unkF_4 = sp0.unkF_4; } - gDisableStructs[gActiveBank].unk16 = 2; + gDisableStructs[gActiveBank].IsFirstTurn = 2; gLastUsedMove[gActiveBank] = 0; gMoveHitWith[gActiveBank] = 0; gUnknown_02024C44[gActiveBank] = 0; @@ -1806,12 +1781,12 @@ void UndoEffectsAfterFainting(void) gStatuses3[gActiveBank] = 0; for (i = 0; i < gNoOfAllBanks; i++) { - if ((gBattleMons[i].status2 & 0x4000000) && gDisableStructs[i].unk14 == gActiveBank) - gBattleMons[i].status2 &= ~0x4000000; + if ((gBattleMons[i].status2 & STATUS2_ESCAPE_PREVENTION) && gDisableStructs[i].BankPreventingEscape == gActiveBank) + gBattleMons[i].status2 &= ~STATUS2_ESCAPE_PREVENTION; if (gBattleMons[i].status2 & (gBitTable[gActiveBank] << 16)) gBattleMons[i].status2 &= ~(gBitTable[gActiveBank] << 16); - if ((gBattleMons[i].status2 & 0xE000) && ewram[0x16020 + i] == gActiveBank) - gBattleMons[i].status2 &= ~0xE000; + if ((gBattleMons[i].status2 & STATUS2_WRAPPED) && ewram[0x16020 + i] == gActiveBank) + gBattleMons[i].status2 &= ~STATUS2_WRAPPED; } gActionSelectionCursor[gActiveBank] = 0; gMoveSelectionCursor[gActiveBank] = 0; @@ -1819,27 +1794,27 @@ void UndoEffectsAfterFainting(void) ptr = (u8 *)&gDisableStructs[gActiveBank]; for (i = 0; i < (u32)0x1C; i++) ptr[i] = 0; - gProtectStructs[gActiveBank].unk0_0 = 0; - gProtectStructs[gActiveBank].unk0_1 = 0; - gProtectStructs[gActiveBank].unk0_2 = 0; - gProtectStructs[gActiveBank].unk0_3 = 0; - gProtectStructs[gActiveBank].unk0_4 = 0; - gProtectStructs[gActiveBank].unk0_5 = 0; - gProtectStructs[gActiveBank].unk0_6 = 0; - gProtectStructs[gActiveBank].unk0_7 = 0; - gProtectStructs[gActiveBank].unk1_0 = 0; - gProtectStructs[gActiveBank].unk1_1 = 0; - gProtectStructs[gActiveBank].unk1_2 = 0; - gProtectStructs[gActiveBank].unk1_3 = 0; - gProtectStructs[gActiveBank].unk1_5 = 0; - gProtectStructs[gActiveBank].unk1_6 = 0; - gProtectStructs[gActiveBank].unk1_7 = 0; - gProtectStructs[gActiveBank].unk2_0 = 0; - gProtectStructs[gActiveBank].unk2_1 = 0; - gProtectStructs[gActiveBank].unk2_2 = 0; - gProtectStructs[gActiveBank].unk2_3 = 0; - - gDisableStructs[gActiveBank].unk16 = 2; + gProtectStructs[gActiveBank].Protected = 0; + gProtectStructs[gActiveBank].Endured = 0; + gProtectStructs[gActiveBank].OnlyStruggle = 0; + gProtectStructs[gActiveBank].HelpingHand = 0; + gProtectStructs[gActiveBank].BounceMove = 0; + gProtectStructs[gActiveBank].StealMove = 0; + gProtectStructs[gActiveBank].Flag0Unknown = 0; + gProtectStructs[gActiveBank].PrlzImmobility = 0; + gProtectStructs[gActiveBank].ConfusionSelfDmg = 0; + gProtectStructs[gActiveBank].NotEffective = 0; + gProtectStructs[gActiveBank].ChargingTurn = 0; + gProtectStructs[gActiveBank].FleeFlag = 0; + gProtectStructs[gActiveBank].UsedImprisionedMove = 0; + gProtectStructs[gActiveBank].LoveImmobility = 0; + gProtectStructs[gActiveBank].UsedDisabledMove = 0; + gProtectStructs[gActiveBank].UsedTauntedMove = 0; + gProtectStructs[gActiveBank].Flag2Unknown = 0; + gProtectStructs[gActiveBank].FlinchImmobility = 0; + gProtectStructs[gActiveBank].NotFirstStrike = 0; + + gDisableStructs[gActiveBank].IsFirstTurn = 2; gLastUsedMove[gActiveBank] = 0; gMoveHitWith[gActiveBank] = 0; gUnknown_02024C44[gActiveBank] = 0; @@ -1878,7 +1853,7 @@ void bc_8012FAC(void) { gBattleCommunication[1]++; if (gBattleCommunication[1] == gNoOfAllBanks) - gBattleMainFunc = bc_load_battlefield; + gBattleMainFunc = BattlePrepIntroSlide; else gBattleCommunication[0] = 0; } @@ -1886,7 +1861,7 @@ void bc_8012FAC(void) } } -void bc_load_battlefield(void) +static void BattlePrepIntroSlide(void) { if (gBattleExecBuffer == 0) { @@ -2294,7 +2269,7 @@ void BattleTurnPassed(void) if (sub_80170DC() != 0) return; TurnValuesCleanUp(0); - gHitMarker &= ~0x200; + gHitMarker &= ~HITMARKER_NO_ATTACKSTRING; gHitMarker &= ~0x80000; gHitMarker &= ~0x400000; gHitMarker &= ~0x100000; @@ -2311,8 +2286,8 @@ void BattleTurnPassed(void) gBattleMainFunc = sub_80138F0; return; } - if (gBattleResults.unk13 < 0xFF) - gBattleResults.unk13++; + if (gBattleResults.BattleTurnCounter < 0xFF) + gBattleResults.BattleTurnCounter++; for (i = 0; i < gNoOfAllBanks; i++) { gActionForBanks[i] = 0xFF; @@ -2331,12 +2306,12 @@ u8 CanRunFromBattle(void) u8 r6; s32 i; - if (gBattleMons[gActiveBank].item == 0xAF) + if (gBattleMons[gActiveBank].item == ITEM_ENIGMA_BERRY) r2 = gEnigmaBerries[gActiveBank].holdEffect; else r2 = ItemId_GetHoldEffect(gBattleMons[gActiveBank].item); gStringBank = gActiveBank; - if (r2 == 0x25) + if (r2 == HOLD_EFFECT_CAN_ALWAYS_RUN) return 0; if (gBattleTypeFlags & BATTLE_TYPE_LINK) return 0; @@ -2346,7 +2321,7 @@ u8 CanRunFromBattle(void) for (i = 0; i < gNoOfAllBanks; i++) { if (r6 != GetBankSide(i) - && gBattleMons[i].ability == 0x17) + && gBattleMons[i].ability == ABILITY_SHADOW_TAG) { ewram16003 = i; gLastUsedAbility = gBattleMons[i].ability; @@ -2357,7 +2332,7 @@ u8 CanRunFromBattle(void) && gBattleMons[gActiveBank].ability != ABILITY_LEVITATE && gBattleMons[gActiveBank].type1 != 2 && gBattleMons[gActiveBank].type2 != 2 - && gBattleMons[i].ability == 0x47) + && gBattleMons[i].ability == ABILITY_ARENA_TRAP) { ewram16003 = i; gLastUsedAbility = gBattleMons[i].ability; @@ -2365,7 +2340,7 @@ u8 CanRunFromBattle(void) return 2; } } - i = AbilityBattleEffects(15, gActiveBank, 0x2A, 0, 0); + i = AbilityBattleEffects(15, gActiveBank, ABILITY_MAGNET_PULL, 0, 0); if (i != 0 && (gBattleMons[gActiveBank].type1 == 8 || gBattleMons[gActiveBank].type2 == 8)) { ewram16003 = i - 1; @@ -2373,7 +2348,7 @@ u8 CanRunFromBattle(void) gBattleCommunication[5] = 2; return 2; } - if ((gBattleMons[gActiveBank].status2 & 0x0400E000) || (gStatuses3[gActiveBank] & 0x400)) + if ((gBattleMons[gActiveBank].status2 & (STATUS2_ESCAPE_PREVENTION | STATUS2_WRAPPED)) || (gStatuses3[gActiveBank] & STATUS3_ROOTED)) { gBattleCommunication[5] = 0; return 1; diff --git a/src/battle_ai.c b/src/battle_ai.c index fabe0b61d..b31df7ba0 100644 --- a/src/battle_ai.c +++ b/src/battle_ai.c @@ -15,7 +15,7 @@ extern u16 gBattleTypeFlags; extern u16 gBattleWeather; extern u8 gActiveBank; -extern u8 gBattlePartyID[][2]; +extern u16 gBattlePartyID[MAX_BANKS_BATTLE]; extern u16 gCurrentMove; extern int gBattleMoveDamage; extern u8 gBankAttacker; @@ -23,13 +23,10 @@ extern u8 gBankTarget; extern u8 gAbsentBankFlags; extern u8 gBattleMoveFlags; extern u16 gDynamicBasePower; -extern u16 gLastUsedMove[]; -extern u32 gUnknown_02024ACC[]; -extern u32 gStatuses3[]; -extern u16 gSideAffecting[]; -extern struct BattlePokemon gBattleMons[]; -extern struct BattlePokemon gUnknown_02024A8C[]; -extern u8 gBattleResults[]; +extern u16 gLastUsedMove[MAX_BANKS_BATTLE]; +extern u32 gStatuses3[MAX_BANKS_BATTLE]; +extern u16 gSideAffecting[2]; +extern struct BattlePokemon gBattleMons[MAX_BANKS_BATTLE]; extern u8 gCritMultiplier; extern u16 gTrainerBattleOpponent; extern u8 *BattleAIs[]; @@ -120,7 +117,7 @@ static void BattleAICmd_get_gender(void); static void BattleAICmd_is_first_turn(void); static void BattleAICmd_get_stockpile_count(void); static void BattleAICmd_is_double_battle(void); -static void BattleAICmd_get_item(void); +static void BattleAICmd_get_used_item(void); static void BattleAICmd_get_move_type_from_result(void); static void BattleAICmd_get_move_power_from_result(void); static void BattleAICmd_get_move_effect_from_result(void); @@ -142,84 +139,84 @@ typedef void (*BattleAICmdFunc)(void); static const BattleAICmdFunc sBattleAICmdTable[] = { - BattleAICmd_if_random_less_than, - BattleAICmd_if_random_greater_than, - BattleAICmd_if_random_equal, - BattleAICmd_if_random_not_equal, - BattleAICmd_score, - BattleAICmd_if_hp_less_than, - BattleAICmd_if_hp_more_than, - BattleAICmd_if_hp_equal, - BattleAICmd_if_hp_not_equal, - BattleAICmd_if_status, - BattleAICmd_if_not_status, - BattleAICmd_if_status2, - BattleAICmd_if_not_status2, - BattleAICmd_if_status3, - BattleAICmd_if_not_status3, - BattleAICmd_if_status4, - BattleAICmd_if_not_status4, - BattleAICmd_if_less_than, - BattleAICmd_if_more_than, - BattleAICmd_if_equal, - BattleAICmd_if_not_equal, - BattleAICmd_if_less_than_32, - BattleAICmd_if_more_than_32, - BattleAICmd_if_equal_32, - BattleAICmd_if_not_equal_32, - BattleAICmd_if_move, - BattleAICmd_if_not_move, - BattleAICmd_if_in_bytes, - BattleAICmd_if_not_in_bytes, - BattleAICmd_if_in_words, - BattleAICmd_if_not_in_words, - BattleAICmd_if_user_can_damage, - BattleAICmd_if_user_cant_damage, - BattleAICmd_get_turn_count, - BattleAICmd_get_type, - BattleAICmd_get_move_power, - BattleAICmd_is_most_powerful_move, - BattleAICmd_get_move, - BattleAICmd_if_arg_equal, - BattleAICmd_if_arg_not_equal, - BattleAICmd_if_would_go_first, - BattleAICmd_if_would_not_go_first, - BattleAICmd_nullsub_2A, - BattleAICmd_nullsub_2B, - BattleAICmd_count_alive_pokemon, - BattleAICmd_get_considered_move, - BattleAICmd_get_considered_move_effect, - BattleAICmd_get_ability, - BattleAICmd_get_highest_possible_damage, - BattleAICmd_if_damage_bonus, - BattleAICmd_nullsub_32, - BattleAICmd_nullsub_33, - BattleAICmd_if_status_in_party, - BattleAICmd_if_status_not_in_party, - BattleAICmd_get_weather, - BattleAICmd_if_effect, - BattleAICmd_if_not_effect, - BattleAICmd_if_stat_level_less_than, - BattleAICmd_if_stat_level_more_than, - BattleAICmd_if_stat_level_equal, - BattleAICmd_if_stat_level_not_equal, - BattleAICmd_if_can_faint, - BattleAICmd_if_cant_faint, - BattleAICmd_if_has_move, - BattleAICmd_if_dont_have_move, - BattleAICmd_if_move_effect, - BattleAICmd_if_not_move_effect, - BattleAICmd_if_last_move_did_damage, - BattleAICmd_if_encored, - BattleAICmd_flee, - BattleAICmd_if_random_100, - BattleAICmd_watch, - BattleAICmd_get_hold_effect, - BattleAICmd_get_gender, - BattleAICmd_is_first_turn, - BattleAICmd_get_stockpile_count, - BattleAICmd_is_double_battle, - BattleAICmd_get_item, + BattleAICmd_if_random_less_than, //0x0 + BattleAICmd_if_random_greater_than, //0x1 + BattleAICmd_if_random_equal, //0x2 + BattleAICmd_if_random_not_equal, //0x3 + BattleAICmd_score, //0x4 + BattleAICmd_if_hp_less_than, //0x5 + BattleAICmd_if_hp_more_than, //0x6 + BattleAICmd_if_hp_equal, //0x7 + BattleAICmd_if_hp_not_equal, //0x8 + BattleAICmd_if_status, //0x9 + BattleAICmd_if_not_status, //0xA + BattleAICmd_if_status2, //0xB + BattleAICmd_if_not_status2, //0xC + BattleAICmd_if_status3, //0xD + BattleAICmd_if_not_status3, //0xE + BattleAICmd_if_status4, //0xF + BattleAICmd_if_not_status4, //0x10 + BattleAICmd_if_less_than, //0x11 + BattleAICmd_if_more_than, //0x12 + BattleAICmd_if_equal, //0x13 + BattleAICmd_if_not_equal, //0x14 + BattleAICmd_if_less_than_32, //0x15 + BattleAICmd_if_more_than_32, //0x16 + BattleAICmd_if_equal_32, //0x17 + BattleAICmd_if_not_equal_32, //0x18 + BattleAICmd_if_move, //0x19 + BattleAICmd_if_not_move, //0x1A + BattleAICmd_if_in_bytes, //0x1B + BattleAICmd_if_not_in_bytes, //0x1C + BattleAICmd_if_in_words, //0x1D + BattleAICmd_if_not_in_words, //0x1E + BattleAICmd_if_user_can_damage, //0x1F + BattleAICmd_if_user_cant_damage, //0x20 + BattleAICmd_get_turn_count, //0x21 + BattleAICmd_get_type, //0x22 + BattleAICmd_get_move_power, //0x23 + BattleAICmd_is_most_powerful_move, //0x24 + BattleAICmd_get_move, //0x25 + BattleAICmd_if_arg_equal, //0x26 + BattleAICmd_if_arg_not_equal, //0x27 + BattleAICmd_if_would_go_first, //0x28 + BattleAICmd_if_would_not_go_first, //0x29 + BattleAICmd_nullsub_2A, //0x2A + BattleAICmd_nullsub_2B, //0x2B + BattleAICmd_count_alive_pokemon, //0x2C + BattleAICmd_get_considered_move, //0x2D + BattleAICmd_get_considered_move_effect, //0x2E + BattleAICmd_get_ability, //0x2F + BattleAICmd_get_highest_possible_damage, //0x30 + BattleAICmd_if_damage_bonus, //0x31 + BattleAICmd_nullsub_32, //0x32 + BattleAICmd_nullsub_33, //0x33 + BattleAICmd_if_status_in_party, //0x34 + BattleAICmd_if_status_not_in_party, //0x35 + BattleAICmd_get_weather, //0x36 + BattleAICmd_if_effect, //0x37 + BattleAICmd_if_not_effect, //0x38 + BattleAICmd_if_stat_level_less_than, //0x39 + BattleAICmd_if_stat_level_more_than, //0x3A + BattleAICmd_if_stat_level_equal, //0x3B + BattleAICmd_if_stat_level_not_equal, //0x3C + BattleAICmd_if_can_faint, //0x3D + BattleAICmd_if_cant_faint, //0x3E + BattleAICmd_if_has_move, //0x3F + BattleAICmd_if_dont_have_move, //0x40 + BattleAICmd_if_move_effect, //0x41 + BattleAICmd_if_not_move_effect, //0x42 + BattleAICmd_if_last_move_did_damage, //0x43 + BattleAICmd_if_encored, //0x44 + BattleAICmd_flee, //0x45 + BattleAICmd_if_random_100, //0x46 + BattleAICmd_watch, //0x47 + BattleAICmd_get_hold_effect, //0x48 + BattleAICmd_get_gender, //0x49 + BattleAICmd_is_first_turn, //0x4A + BattleAICmd_get_stockpile_count, //0x4B + BattleAICmd_is_double_battle, //0x4C + BattleAICmd_get_used_item, //0x4D BattleAICmd_get_move_type_from_result, BattleAICmd_get_move_power_from_result, BattleAICmd_get_move_effect_from_result, @@ -449,13 +446,13 @@ void unref_sub_81074A0(u8 a) UNK_2016A00_STRUCT->movesUsed[a / 2][i] = 0; } -void sub_81074C4(u8 a, u8 b) +void RecordAbilityBattle(u8 a, u8 b) { if (GetBankSide(a) == 0) UNK_2016A00_STRUCT->unk20[GetBankIdentity(a) & 1] = b; } -void sub_81074F8(u8 a, u8 b) +void RecordItemBattle(u8 a, u8 b) { if (GetBankSide(a) == 0) UNK_2016A00_STRUCT->unk22[GetBankIdentity(a) & 1] = b; @@ -899,7 +896,7 @@ static void BattleAICmd_if_user_cant_damage(void) static void BattleAICmd_get_turn_count(void) { - AI_THINKING_STRUCT->funcResult = gBattleResults[19]; + AI_THINKING_STRUCT->funcResult = gBattleResults.BattleTurnCounter; gAIScriptPtr += 1; } @@ -946,8 +943,8 @@ static void BattleAICmd_is_most_powerful_move(void) && sDiscouragedPowerfulMoveEffects[i] == 0xFFFF) { gDynamicBasePower = 0; - unk_2000000[0x1601C] = 0; // why is this a manual array? - unk_2000000[0x1601F] = 1; + ewram[0x1601C] = 0; // why is this a manual array? + ewram[0x1601F] = 1; gBattleMoveFlags = 0; gCritMultiplier = 1; @@ -965,8 +962,8 @@ static void BattleAICmd_is_most_powerful_move(void) && gBattleMoves[gBattleMons[gBankAttacker].moves[i]].power > 1) { gCurrentMove = gBattleMons[gBankAttacker].moves[i]; - sub_801CAF8(gBankAttacker, gBankTarget); - move_effectiveness_something(gCurrentMove, gBankAttacker, gBankTarget); + AI_CalcDmg(gBankAttacker, gBankTarget); + TypeCalc(gCurrentMove, gBankAttacker, gBankTarget); damages[i] = (gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[i]) / 100; if (damages[i] == 0) // moves always do at least 1 damage. @@ -1135,11 +1132,11 @@ _081082BA:\n\ ldrb r0, [r7]\n\ ldr r4, _08108354 @ =gBankTarget\n\ ldrb r1, [r4]\n\ - bl sub_801CAF8\n\ + bl AI_CalcDmg\n\ ldrh r0, [r5]\n\ ldrb r1, [r7]\n\ ldrb r2, [r4]\n\ - bl move_effectiveness_something\n\ + bl TypeCalc\n\ mov r4, sp\n\ add r4, r8\n\ ldr r2, _08108358 @ =gBattleMoveDamage\n\ @@ -1312,14 +1309,14 @@ static void BattleAICmd_count_alive_pokemon(void) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { u32 status; - var = gBattlePartyID[index][0]; + var = gBattlePartyID[index]; status = GetBankIdentity(index) ^ 2; - var2 = gBattlePartyID[GetBankByPlayerAI(status)][0]; + var2 = gBattlePartyID[GetBankByPlayerAI(status)]; } else { - var = gBattlePartyID[index][0]; - var2 = gBattlePartyID[index][0]; + var = gBattlePartyID[index]; + var2 = gBattlePartyID[index]; } for (i = 0; i < 6; i++) @@ -1415,8 +1412,8 @@ static void BattleAICmd_get_highest_possible_damage(void) s32 i; gDynamicBasePower = 0; - BATTLE_STRUCT->unk.unk1 = 0; - BATTLE_STRUCT->unk.unk4 = 1; + BATTLE_STRUCT->DynamicMoveType = 0; + BATTLE_STRUCT->DmgMultiplier = 1; gBattleMoveFlags = 0; gCritMultiplier = 1; AI_THINKING_STRUCT->funcResult = 0; @@ -1428,7 +1425,7 @@ static void BattleAICmd_get_highest_possible_damage(void) if (gCurrentMove) { - move_effectiveness_something(gCurrentMove, gBankAttacker, gBankTarget); + TypeCalc(gCurrentMove, gBankAttacker, gBankTarget); // reduce by 1/3. if (gBattleMoveDamage == 120) @@ -1455,15 +1452,15 @@ static void BattleAICmd_if_damage_bonus(void) u8 damageVar; gDynamicBasePower = 0; - BATTLE_STRUCT->unk.unk1 = 0; - BATTLE_STRUCT->unk.unk4 = 1; + BATTLE_STRUCT->DynamicMoveType = 0; + BATTLE_STRUCT->DmgMultiplier = 1; gBattleMoveFlags = 0; gCritMultiplier = 1; gBattleMoveDamage = 40; gCurrentMove = AI_THINKING_STRUCT->moveConsidered; - move_effectiveness_something(gCurrentMove, gBankAttacker, gBankTarget); + TypeCalc(gCurrentMove, gBankAttacker, gBankTarget); if (gBattleMoveDamage == 120) gBattleMoveDamage = 80; @@ -1565,13 +1562,13 @@ static void BattleAICmd_if_status_not_in_party(void) static void BattleAICmd_get_weather(void) { - if (gBattleWeather & 7) + if (gBattleWeather & WEATHER_RAINY) AI_THINKING_STRUCT->funcResult = WEATHER_RAIN; - if (gBattleWeather & 0x18) + if (gBattleWeather & WEATHER_SANDSTORMY) AI_THINKING_STRUCT->funcResult = WEATHER_SANDSTORM; - if (gBattleWeather & 0x60) + if (gBattleWeather & WEATHER_SUNNY) AI_THINKING_STRUCT->funcResult = WEATHER_SUN; - if (gBattleWeather & 0x80) + if (gBattleWeather & weather_hail) AI_THINKING_STRUCT->funcResult = WEATHER_HAIL; gAIScriptPtr += 1; @@ -1662,13 +1659,13 @@ static void BattleAICmd_if_can_faint(void) } gDynamicBasePower = 0; - BATTLE_STRUCT->unk.unk1 = 0; - BATTLE_STRUCT->unk.unk4 = 1; + BATTLE_STRUCT->DynamicMoveType = 0; + BATTLE_STRUCT->DmgMultiplier = 1; gBattleMoveFlags = 0; gCritMultiplier = 1; gCurrentMove = AI_THINKING_STRUCT->moveConsidered; - sub_801CAF8(gBankAttacker, gBankTarget); - move_effectiveness_something(gCurrentMove, gBankAttacker, gBankTarget); + AI_CalcDmg(gBankAttacker, gBankTarget); + TypeCalc(gCurrentMove, gBankAttacker, gBankTarget); gBattleMoveDamage = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[AI_THINKING_STRUCT->movesetIndex] / 100; @@ -1691,13 +1688,13 @@ static void BattleAICmd_if_cant_faint(void) } gDynamicBasePower = 0; - BATTLE_STRUCT->unk.unk1 = 0; - BATTLE_STRUCT->unk.unk4 = 1; + BATTLE_STRUCT->DynamicMoveType = 0; + BATTLE_STRUCT->DmgMultiplier = 1; gBattleMoveFlags = 0; gCritMultiplier = 1; gCurrentMove = AI_THINKING_STRUCT->moveConsidered; - sub_801CAF8(gBankAttacker, gBankTarget); - move_effectiveness_something(gCurrentMove, gBankAttacker, gBankTarget); + AI_CalcDmg(gBankAttacker, gBankTarget); + TypeCalc(gCurrentMove, gBankAttacker, gBankTarget); gBattleMoveDamage = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[AI_THINKING_STRUCT->movesetIndex] / 100; @@ -1846,7 +1843,7 @@ static 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; @@ -1859,7 +1856,7 @@ static 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; @@ -1872,7 +1869,7 @@ static 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; @@ -1880,7 +1877,7 @@ static 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; @@ -1957,7 +1954,7 @@ static 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; } @@ -1971,7 +1968,7 @@ static 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; } @@ -1983,7 +1980,7 @@ static void BattleAICmd_is_double_battle(void) gAIScriptPtr += 1; } -static void BattleAICmd_get_item(void) +static void BattleAICmd_get_used_item(void) { u8 index; @@ -2028,7 +2025,7 @@ static 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; } diff --git a/src/pokemon_3.c b/src/pokemon_3.c index cb8eb2a46..d3ecf04dd 100644 --- a/src/pokemon_3.c +++ b/src/pokemon_3.c @@ -1296,15 +1296,15 @@ void BoxMonRestorePP(struct BoxPokemon *boxMon) void sub_8040B8C(void) { - gLastUsedAbility = BATTLE_STRUCT->filler1_2[0x37]; + gLastUsedAbility = BATTLE_STRUCT->unk160C0;; gBattleTextBuff1[0] = 0xFD; gBattleTextBuff1[1] = 4; - gBattleTextBuff1[2] = BATTLE_STRUCT->filler1[0x34]; + gBattleTextBuff1[2] = BATTLE_STRUCT->unk16054; gBattleTextBuff1[4] = EOS; - if (!GetBankSide(BATTLE_STRUCT->filler1[0x34])) - gBattleTextBuff1[3] = pokemon_order_func(gBattlePartyID[BATTLE_STRUCT->filler1[0x34]]); + if (!GetBankSide(BATTLE_STRUCT->unk16054)) + gBattleTextBuff1[3] = pokemon_order_func(gBattlePartyID[BATTLE_STRUCT->unk16054]); else - gBattleTextBuff1[3] = gBattlePartyID[BATTLE_STRUCT->filler1[0x34]]; + gBattleTextBuff1[3] = gBattlePartyID[BATTLE_STRUCT->unk16054]; gBattleTextBuff2[0] = 0xFD; gBattleTextBuff2[1] = 4; gBattleTextBuff2[2] = gBankInMenu; @@ -44,7 +44,6 @@ struct UnkTvStruct s8 var0; }; -extern struct Struct30042E0 gBattleResults; extern u8 gUnknown_0300430A[11]; struct OutbreakPokemon @@ -430,15 +429,15 @@ void TakeTVShowInSearchOfTrainersOffTheAir(void); void GabbyAndTyBeforeInterview(void) { u8 i; - gSaveBlock1.gabbyAndTyData.mon1 = gBattleResults.unk6; - gSaveBlock1.gabbyAndTyData.mon2 = gBattleResults.unk26; - gSaveBlock1.gabbyAndTyData.lastMove = gBattleResults.unk22; + gSaveBlock1.gabbyAndTyData.mon1 = gBattleResults.Poke1Species; + gSaveBlock1.gabbyAndTyData.mon2 = gBattleResults.OpponentSpecies; + gSaveBlock1.gabbyAndTyData.lastMove = gBattleResults.LastUsedMove; if (gSaveBlock1.gabbyAndTyData.battleNum != 0xff) { gSaveBlock1.gabbyAndTyData.battleNum ++; } gSaveBlock1.gabbyAndTyData.valA_0 = gBattleResults.unk5_0; - if (gBattleResults.unk0) + if (gBattleResults.PlayerFaintCounter) { gSaveBlock1.gabbyAndTyData.valA_1 = 1; } else @@ -612,11 +611,11 @@ void sub_80BDEC8(void) { total = 0; sub_80BEB20(); sub_80BE778(); - if (gBattleResults.unk28 == 0) { + if (gBattleResults.CaughtPoke == 0) { sub_80BE074(); } else { sub_80BE028(); - if (sub_80BF77C(0xffff) == 0 && StringCompareWithoutExtCtrlCodes(gSpeciesNames[gBattleResults.unk28], gBattleResults.unk2A) != 0) { + if (sub_80BF77C(0xffff) == 0 && StringCompareWithoutExtCtrlCodes(gSpeciesNames[gBattleResults.CaughtPoke], gBattleResults.CaughtNick) != 0) { gUnknown_03005D38.var0 = sub_80BF74C(gSaveBlock1.tvShows); if (gUnknown_03005D38.var0 != -1 && sub_80BF1B4(TVSHOW_POKEMON_TODAY_CAUGHT) != 1) { for (i=0; i<11; i++) { @@ -642,8 +641,8 @@ void sub_80BDEC8(void) { show->pokemonToday.var12 = total; show->pokemonToday.ball = item; StringCopy(show->pokemonToday.playerName, gSaveBlock2.playerName); - StringCopy(show->pokemonToday.nickname, gBattleResults.unk2A); - show->pokemonToday.species = gBattleResults.unk28; + StringCopy(show->pokemonToday.nickname, gBattleResults.CaughtNick); + show->pokemonToday.species = gBattleResults.CaughtPoke; sub_80BE138(show); show->pokemonToday.language = GAME_LANGUAGE; show->pokemonToday.language2 = sub_80BDEAC(show->pokemonToday.nickname); @@ -663,8 +662,8 @@ void sub_80BE028(void) { buffer->worldOfMasters.var00 = TVSHOW_WORLD_OF_MASTERS; } buffer->worldOfMasters.var02++; - buffer->worldOfMasters.var04 = gBattleResults.unk28; - buffer->worldOfMasters.var08 = gBattleResults.unk6; + buffer->worldOfMasters.var04 = gBattleResults.CaughtPoke; + buffer->worldOfMasters.var08 = gBattleResults.Poke1Species; buffer->worldOfMasters.var0a = gMapHeader.name; } @@ -689,7 +688,7 @@ void sub_80BE074(void) { asm_comment("Here the wrong registers are used to hold the show ID and flag."); show->pokemonTodayFailed.var00 = TVSHOW_POKEMON_TODAY_FAILED; show->pokemonTodayFailed.var01 = flag; - show->pokemonTodayFailed.species = gBattleResults.unk6; + show->pokemonTodayFailed.species = gBattleResults.Poke1Species; show->pokemonTodayFailed.species2 = gBattleResults.unk20; show->pokemonTodayFailed.var10 = total; show->pokemonTodayFailed.var11 = gBattleOutcome; |