From cc3a146066f69625efa87823a3a18bb40116f31e Mon Sep 17 00:00:00 2001 From: HailSanta <53960937+HailSanta@users.noreply.github.com> Date: Tue, 10 Jan 2023 01:33:09 -0500 Subject: [PATCH] battle substates cleanup I (#906) * cleanup in progress * celebrate done * progress * etc * substate enums done * flag fixup * brevity * msg name fix Co-authored-by: HailSanta --- include/common_structs.h | 18 +- include/effects.h | 2 +- include/enums.h | 649 +++-- include/functions.h | 2 +- include/variables.h | 4 +- src/16F740.c | 2325 +++++++++-------- src/16c8e0.c | 94 +- src/17D6A0.c | 854 +++--- src/182B30.c | 4 +- src/18C790.c | 924 +++---- src/18F340.c | 16 +- src/190B20.c | 102 +- src/19FAF0.c | 24 +- src/1A5830.c | 40 +- src/1AC760.c | 26 +- src/415D90.c | 902 +++---- src/80850_len_3060.c | 2 +- src/actor_api.c | 20 +- src/battle/action_cmd/break_free.c | 2 +- src/battle/area_arn/actor/hyper_cleft.c | 2 +- src/battle/area_arn/actor/hyper_paragoomba.c | 2 +- src/battle/area_arn/actor/hypergoomba.c | 2 +- src/battle/area_arn/actor/tubba_blubba.c | 2 +- src/battle/area_arn/actor/tubbas_heart.c | 2 +- src/battle/area_dgb/actor/tubba_blubba.c | 2 +- src/battle/area_dig/actor/tubba_blubba.c | 2 +- src/battle/area_flo/actor/amazy_dayzee.c | 2 +- src/battle/area_flo/actor/crazee_dayzee.c | 2 +- src/battle/area_flo/actor/lakitu.c | 2 +- src/battle/area_flo/actor/ruff_puff.c | 2 +- src/battle/area_flo2/actor/huff_n_puff.c | 2 +- src/battle/area_flo2/actor/monty_mole_boss.c | 4 +- src/battle/area_flo2/actor/spike.c | 2 +- src/battle/area_flo2/actor/tuff_puff.c | 2 +- src/battle/area_hos/actor/goombario_tutor.c | 2 +- src/battle/area_hos/actor/magikoopa.c | 8 +- .../area_isk_part_1/actor/pokey_mummy.c | 2 +- .../area_isk_part_1/actor/stone_chomp.c | 2 +- .../area_isk_part_2/actor/chain_chomp.c | 2 +- src/battle/area_isk_part_2/actor/tutankoopa.c | 2 +- src/battle/area_iwa/actor/buzzar.c | 2 +- src/battle/area_iwa/actor/cleft.c | 2 +- src/battle/area_jan/actor/hurt_plant.c | 2 +- src/battle/area_jan/actor/jungle_fuzzy.c | 2 +- src/battle/area_jan/actor/m_bush.c | 2 +- src/battle/area_jan/actor/spear_guy.c | 2 +- src/battle/area_kgr/actor/fuzzipede.c | 2 +- src/battle/area_kkj/actor/kammy_koopa.c | 2 +- .../area_kmr_part_2/actor/blue_goomba.c | 2 +- .../area_kmr_part_2/actor/blue_goomba2.c | 2 +- .../area_kmr_part_2/actor/goomba_king.c | 2 +- .../area_kmr_part_2/actor/goomnut_tree.c | 2 +- src/battle/area_kmr_part_2/actor/red_goomba.c | 2 +- .../area_kmr_part_2/actor/red_goomba2.c | 2 +- .../area_kmr_part_3/actor/egg_jr_troopa.c | 2 +- .../area_kmr_part_3/actor/final_jr_troopa.c | 2 +- src/battle/area_kmr_part_3/actor/jr_troopa.c | 2 +- .../area_kmr_part_3/actor/mage_jr_troopa.c | 2 +- .../area_kmr_part_3/actor/para_jr_troopa.c | 2 +- src/battle/area_kmr_part_3/actor/paragoomba.c | 2 +- .../area_kmr_part_3/actor/spiked_goomba.c | 2 +- .../actor/spiked_para_jr_troopa.c | 2 +- src/battle/area_kpa/actor/bony_beetle.c | 2 +- src/battle/area_kpa/actor/dry_bones.c | 2 +- src/battle/area_kpa2/actor/bowser.c | 2 +- src/battle/area_kpa2/actor/bowser_intro.c | 4 +- src/battle/area_kpa2/actor/bowser_phase_1.c | 2 +- src/battle/area_kpa2/actor/bowser_phase_2.c | 2 +- src/battle/area_kpa2/actor/bowser_phase_3.c | 2 +- src/battle/area_kpa3/actor/anti_guy.c | 2 +- src/battle/area_kpa4/actor/bombshell_bill.c | 2 +- .../area_kpa4/actor/bombshell_bill_blaster.c | 2 +- src/battle/area_kzn/actor/lava_bubble.c | 2 +- src/battle/area_kzn2/actor/lava_bud.c | 2 +- src/battle/area_kzn2/actor/lava_piranha.c | 2 +- src/battle/area_kzn2/actor/petit_piranha.c | 2 +- .../area_kzn2/actor/petit_piranha_bomb.c | 2 +- src/battle/area_mac/actor/chan.c | 4 +- src/battle/area_mac/actor/lee.c | 20 +- src/battle/area_mac/actor/master1.c | 4 +- src/battle/area_mac/actor/master2.c | 4 +- src/battle/area_mac/actor/master3.c | 4 +- src/battle/area_mim/actor/forest_fuzzy.c | 2 +- src/battle/area_mim/actor/piranha_plant.c | 2 +- src/battle/area_nok/actor/kent_c_koopa.c | 2 +- src/battle/area_omo/actor/anti_guy.c | 2 +- src/battle/area_omo/actor/blue_shy_guy.c | 2 +- src/battle/area_omo/actor/green_shy_guy.c | 2 +- src/battle/area_omo/actor/groove_guy.c | 2 +- src/battle/area_omo/actor/pink_shy_guy.c | 2 +- src/battle/area_omo/actor/pyro_guy.c | 2 +- src/battle/area_omo/actor/sky_guy.c | 2 +- src/battle/area_omo/actor/spy_guy.c | 2 +- src/battle/area_omo/actor/yellow_shy_guy.c | 2 +- src/battle/area_omo2/actor/general_guy.c | 2 +- src/battle/area_omo2/actor/light_bulb.c | 2 +- src/battle/area_omo2/actor/toy_tank.c | 2 +- src/battle/area_omo2_1/actor/shy_squad.c | 2 +- src/battle/area_omo2_2/actor/stilt_guy.c | 2 +- src/battle/area_omo2_3/actor/shy_stack.c | 2 +- src/battle/area_omo2_4/actor/signal_guy.c | 2 +- src/battle/area_omo2_5/actor/shy_squad_dup.c | 2 +- src/battle/area_omo2_6/actor/shy_guy_dup.c | 2 +- .../area_omo3/actor/big_lantern_ghost.c | 2 +- src/battle/area_pra/actor/albino_dino.c | 2 +- src/battle/area_pra2/actor/crystal_bit.c | 6 +- src/battle/area_pra2/actor/crystal_king.c | 4 +- src/battle/area_sam/actor/frost_piranha.c | 2 +- src/battle/area_sam/actor/gulpit.c | 2 +- src/battle/area_sam/actor/gulpit_rocks.c | 2 +- src/battle/area_sam2/actor/monstar.c | 2 +- src/battle/area_tik/actor/dark_koopa.c | 2 +- src/battle/area_tik/actor/dark_paratroopa.c | 2 +- src/battle/area_tik/actor/gloomba.c | 2 +- src/battle/area_tik/actor/paragloomba.c | 2 +- src/battle/area_tik/actor/spiked_gloomba.c | 2 +- src/battle/area_tik2/actor/blooper.c | 2 +- src/battle/area_tik2/actor/blooper_baby.c | 2 +- src/battle/area_tik2/actor/electro_blooper.c | 2 +- src/battle/area_tik2/actor/super_blooper.c | 2 +- .../area_trd_part_1/actor/bill_blaster.c | 2 +- src/battle/area_trd_part_1/actor/bob_omb.c | 2 +- .../area_trd_part_1/actor/bullet_bill.c | 2 +- .../area_trd_part_2/actor/blue_ninja_koopa.c | 2 +- .../area_trd_part_2/actor/fake_bowser.c | 2 +- .../area_trd_part_2/actor/green_ninja_koopa.c | 2 +- .../area_trd_part_2/actor/red_ninja_koopa.c | 2 +- .../actor/yellow_ninja_koopa.c | 2 +- src/battle/area_trd_part_3/actor/eldstar.c | 2 +- src/battle/battle.c | 16 +- src/battle/battle.h | 2 +- src/battle/common/actor/bandit.inc.c | 4 +- src/battle/common/actor/buzzy_beetle.inc.c | 2 +- src/battle/common/actor/bzzap.inc.c | 2 +- src/battle/common/actor/clubba.inc.c | 2 +- src/battle/common/actor/duplighost.inc.c | 2 +- src/battle/common/actor/ember.inc.c | 2 +- src/battle/common/actor/fuzzy.inc.c | 2 +- src/battle/common/actor/ghost_bombette.inc.c | 2 +- src/battle/common/actor/ghost_bow.inc.c | 2 +- src/battle/common/actor/ghost_goombario.inc.c | 2 +- src/battle/common/actor/ghost_kooper.inc.c | 2 +- .../common/actor/ghost_lakilester.inc.c | 2 +- src/battle/common/actor/ghost_parakarry.inc.c | 2 +- src/battle/common/actor/ghost_sushie.inc.c | 2 +- src/battle/common/actor/ghost_watt.inc.c | 2 +- src/battle/common/actor/goomba.inc.c | 2 +- src/battle/common/actor/gray_magikoopa.inc.c | 4 +- src/battle/common/actor/green_magikoopa.inc.c | 4 +- src/battle/common/actor/hammer_bro.inc.c | 2 +- src/battle/common/actor/koopa_troopa.inc.c | 2 +- src/battle/common/actor/koopatrol.inc.c | 2 +- src/battle/common/actor/magikoopa.inc.c | 8 +- src/battle/common/actor/medi_guy.inc.c | 2 +- src/battle/common/actor/monty_mole.inc.c | 4 +- src/battle/common/actor/paragoomba.inc.c | 2 +- src/battle/common/actor/paratroopa.inc.c | 2 +- src/battle/common/actor/pokey.inc.c | 2 +- src/battle/common/actor/putrid_piranha.inc.c | 2 +- src/battle/common/actor/red_magikoopa.inc.c | 4 +- src/battle/common/actor/red_shy_guy.inc.c | 2 +- src/battle/common/actor/slot_machine.inc.c | 4 +- src/battle/common/actor/spike_top.inc.c | 2 +- src/battle/common/actor/spiked_goomba.inc.c | 2 +- src/battle/common/actor/spiny.inc.c | 2 +- src/battle/common/actor/swooper.inc.c | 2 +- src/battle/common/actor/swoopula.inc.c | 2 +- src/battle/common/actor/whacka.inc.c | 2 +- src/battle/common/actor/white_clubba.inc.c | 2 +- src/battle/common/actor/white_magikoopa.inc.c | 4 +- .../common/actor/yellow_magikoopa.inc.c | 4 +- src/battle/item/food.c | 4 +- src/battle/item/life_shroom.c | 4 +- src/battle/item/mushroom.c | 4 +- src/battle/item/stone_cap.c | 2 +- src/battle/item/super_soda.c | 6 +- src/battle/item/tasty_tonic.c | 2 +- src/battle/move/hammer_charge_0/74F130.c | 4 +- src/battle/move/hammer_charge_1/7595B0.c | 4 +- src/battle/move/hammer_charge_2/75E5D0.c | 4 +- src/battle/move/jump_charge_0/74D570.c | 4 +- src/battle/move/jump_charge_1/75C980.c | 4 +- src/battle/move/jump_charge_2/761920.c | 4 +- src/battle/partner/bombette.c | 2 +- src/battle/partner/bow.c | 4 +- src/battle/partner/goombario.c | 2 +- src/battle/partner/goompa.c | 2 +- src/battle/partner/kooper.c | 2 +- src/battle/partner/lakilester.c | 2 +- src/battle/partner/parakarry.c | 2 +- src/battle/partner/sushie.c | 2 +- src/battle/partner/twink.c | 4 +- src/battle/partner/watt.c | 2 +- src/battle/star/refresh/78B600.c | 2 +- src/effects/disable_x.c | 10 +- src/encounter.c | 4 +- src/fio.c | 2 +- src/level_up.c | 2 +- src/move_script.c | 2 +- src/msg.c | 24 +- src/starpoint.c | 26 +- src/world/area_jan/jan.h | 58 +- src/world/area_jan/jan_17/B837C0.c | 9 - src/world/area_jan/jan_17/jan_17.h | 9 +- src/world/area_jan/jan_17/jan_17_0_header.c | 13 + src/world/area_jan/jan_17/jan_17_1_music.c | 12 + src/world/area_jan/jan_17/jan_17_2_main.c | 39 + src/world/area_jan/jan_17/jan_17_3_entity.c | 9 + src/world/area_jan/jan_18/B83B90.c | 4 - src/world/area_jan/jan_18/jan_18.h | 9 +- src/world/area_jan/jan_18/jan_18_0_header.c | 14 + src/world/area_jan/jan_18/jan_18_1_music.c | 7 + src/world/area_jan/jan_18/jan_18_2_main.c | 26 + src/world/area_jan/jan_18/jan_18_3_entity.c | 8 + src/world/area_jan/jan_19/B83E60.c | 9 - src/world/area_jan/jan_19/jan_19.h | 9 +- src/world/area_jan/jan_19/jan_19_0_header.c | 13 + src/world/area_jan/jan_19/jan_19_1_music.c | 7 + src/world/area_jan/jan_19/jan_19_2_main.c | 32 + src/world/area_jan/jan_19/jan_19_3_entity.c | 9 + src/world/world.c | 7 +- tools/splat_ext/msg.yaml | 2 +- tools/star_rod_idx_to_c.py | 2 +- ver/us/asm/bss.s | 4 +- ver/us/splat.yaml | 28 +- ver/us/symbol_addrs.txt | 54 +- 226 files changed, 3802 insertions(+), 3125 deletions(-) delete mode 100644 src/world/area_jan/jan_17/B837C0.c create mode 100644 src/world/area_jan/jan_17/jan_17_0_header.c create mode 100644 src/world/area_jan/jan_17/jan_17_1_music.c create mode 100644 src/world/area_jan/jan_17/jan_17_2_main.c create mode 100644 src/world/area_jan/jan_17/jan_17_3_entity.c delete mode 100644 src/world/area_jan/jan_18/B83B90.c create mode 100644 src/world/area_jan/jan_18/jan_18_0_header.c create mode 100644 src/world/area_jan/jan_18/jan_18_1_music.c create mode 100644 src/world/area_jan/jan_18/jan_18_2_main.c create mode 100644 src/world/area_jan/jan_18/jan_18_3_entity.c delete mode 100644 src/world/area_jan/jan_19/B83E60.c create mode 100644 src/world/area_jan/jan_19/jan_19_0_header.c create mode 100644 src/world/area_jan/jan_19/jan_19_1_music.c create mode 100644 src/world/area_jan/jan_19/jan_19_2_main.c create mode 100644 src/world/area_jan/jan_19/jan_19_3_entity.c diff --git a/include/common_structs.h b/include/common_structs.h index 16e6815bad..f1316e7cc1 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -1863,18 +1863,18 @@ typedef struct Actor { /* 0x1BA */ char unk_1BA[2]; /* 0x1BC */ s8 hpFraction; /* used to render HP bar */ /* 0x1BD */ char unk_1BD[3]; - /* 0x1C0 */ EvtScript* idleScriptSource; - /* 0x1C4 */ EvtScript* takeTurnScriptSource; - /* 0x1C8 */ EvtScript* onHitScriptSource; - /* 0x1CC */ EvtScript* onTurnChanceScriptSource; + /* 0x1C0 */ EvtScript* idleSource; + /* 0x1C4 */ EvtScript* takeTurnSource; + /* 0x1C8 */ EvtScript* handleEventSource; + /* 0x1CC */ EvtScript* handlePhaseSource; /* 0x1D0 */ struct Evt* idleScript; /* 0x1D4 */ struct Evt* takeTurnScript; - /* 0x1D8 */ struct Evt* onHitScript; - /* 0x1DC */ struct Evt* onTurnChangeScript; + /* 0x1D8 */ struct Evt* handleEventScript; + /* 0x1DC */ struct Evt* handlePhaseScript; /* 0x1E0 */ s32 idleScriptID; - /* 0x1E4 */ s32 takeTurnID; - /* 0x1E8 */ s32 onHitID; - /* 0x1EC */ s32 onTurnChangeID; + /* 0x1E4 */ s32 takeTurnScriptID; + /* 0x1E8 */ s32 handleEventScriptID; + /* 0x1EC */ s32 handleBatttlePhaseScriptID; /* 0x1F0 */ s8 lastEventType; /* 0x1F1 */ s8 turnPriority; /* 0x1F2 */ s8 enemyIndex; /* actorID = this | 200 */ diff --git a/include/effects.h b/include/effects.h index e1bd3036b5..936b3646af 100644 --- a/include/effects.h +++ b/include/effects.h @@ -1295,7 +1295,7 @@ typedef struct DisableXFXData { /* 0x30 */ f32 unk_30; /* 0x34 */ f32 scale; /* 0x38 */ s32 unk_38; - /* 0x3C */ s32 unk_3C; + /* 0x3C */ s32 koDuration; /* 0x40 */ f32 unk_40; /* 0x44 */ s32 unk_44; } DisableXFXData; // size = 0x48 diff --git a/include/enums.h b/include/enums.h index a9656bf528..8465f056ef 100644 --- a/include/enums.h +++ b/include/enums.h @@ -4050,13 +4050,13 @@ enum BattleStatusFlags1 { BS_FLAGS1_100000 = 0x00100000, // player in back (after pressing z) BS_FLAGS1_200000 = 0x00200000, // enemy turn pending BS_FLAGS1_PLAYER_DEFENDING = 0x00400000, // player is defending - BS_FLAGS1_800000 = 0x00800000, // don’t game over on loss + BS_FLAGS1_NO_GAME_OVER = 0x00800000, // don’t game over on loss BS_FLAGS1_STAR_POINTS_DROPPED = 0x01000000, BS_FLAGS1_2000000 = 0x02000000, - BS_FLAGS1_HUSTLE_DRINK_ON = 0x04000000, + BS_FLAGS1_HUSTLED = 0x04000000, BS_FLAGS1_8000000 = 0x08000000, - BS_FLAGS1_10000000 = 0x10000000, // prevent hammer charge - BS_FLAGS1_20000000 = 0x20000000, // prevent jump charge + BS_FLAGS1_HAMMER_CHARGED = 0x10000000, + BS_FLAGS1_JUMP_CHARGED = 0x20000000, BS_FLAGS1_40000000 = 0x40000000, BS_FLAGS1_ATK_BLOCKED = 0x80000000, }; @@ -4067,8 +4067,8 @@ enum BattleStatusFlags2 { BS_FLAGS2_4 = 0x00000004, BS_FLAGS2_8 = 0x00000008, BS_FLAGS2_10 = 0x00000010, - BS_FLAGS2_20 = 0x00000020, - BS_FLAGS2_40 = 0x00000040, + BS_FLAGS2_CANT_FLEE = 0x00000020, + BS_FLAGS2_PEACH_BATTLE = 0x00000040, BS_FLAGS2_80 = 0x00000080, BS_FLAGS2_100 = 0x00000100, BS_FLAGS2_200 = 0x00000200, @@ -4081,7 +4081,7 @@ enum BattleStatusFlags2 { BS_FLAGS2_1000000 = 0x01000000, BS_FLAGS2_2000000 = 0x02000000, BS_FLAGS2_4000000 = 0x04000000, - BS_FLAGS2_8000000 = 0x08000000, + BS_FLAGS2_HAS_RUSH = 0x08000000, BS_FLAGS2_10000000 = 0x10000000, }; @@ -4126,205 +4126,488 @@ enum BattleStates { }; enum BattleSubStates { - BATTLE_SUB_STATE_UNK_0 = 0x00000000, - BATTLE_SUB_STATE_UNK_1 = 0x00000001, - BATTLE_SUB_STATE_UNK_2 = 0x00000002, - BATTLE_SUB_STATE_UNK_3 = 0x00000003, - BATTLE_SUB_STATE_UNK_4 = 0x00000004, - BATTLE_SUB_STATE_BEGIN_LEVEL_UP = 0x00000005, - BATTLE_SUB_STATE_LEVEL_UP_SHOW_HUD = 0x00000006, - BATTLE_SUB_STATE_UNK_7 = 0x00000007, - BATTLE_SUB_STATE_UNK_8 = 0x00000008, - BATTLE_SUB_STATE_UNK_9 = 0x00000009, - BATTLE_SUB_STATE_PLAYER_DEFEATED = 0x0000000A, - BATTLE_SUB_STATE_UNK_B = 0x0000000B, - BATTLE_SUB_STATE_UNK_C = 0x0000000C, - BATTLE_SUB_STATE_UNK_D = 0x0000000D, - BATTLE_SUB_STATE_UNK_E = 0x0000000E, - BATTLE_SUB_STATE_UNK_F = 0x0000000F, - BATTLE_SUB_STATE_UNK_10 = 0x00000010, - BATTLE_SUB_STATE_UNK_14 = 0x00000014, - BATTLE_SUB_STATE_UNK_15 = 0x00000015, - BATTLE_SUB_STATE_UNK_16 = 0x00000016, - BATTLE_SUB_STATE_UNK_17 = 0x00000017, - BATTLE_SUB_STATE_UNK_18 = 0x00000018, - BATTLE_SUB_STATE_UNK_1E = 0x0000001E, - BATTLE_SUB_STATE_UNK_1F = 0x0000001F, - BATTLE_SUB_STATE_UNK_20 = 0x00000020, - BATTLE_SUB_STATE_UNK_21 = 0x00000021, - BATTLE_SUB_STATE_UNK_22 = 0x00000022, - BATTLE_SUB_STATE_UNK_28 = 0x00000028, - BATTLE_SUB_STATE_UNK_29 = 0x00000029, - BATTLE_SUB_STATE_UNK_2A = 0x0000002A, - BATTLE_SUB_STATE_UNK_2B = 0x0000002B, - BATTLE_SUB_STATE_UNK_2C = 0x0000002C, - BATTLE_SUB_STATE_UNK_33 = 0x00000033, - BATTLE_SUB_STATE_UNK_34 = 0x00000034, - BATTLE_SUB_STATE_UNK_35 = 0x00000035, - BATTLE_SUB_STATE_UNK_36 = 0x00000036, - BATTLE_SUB_STATE_UNK_3D = 0x0000003D, - BATTLE_SUB_STATE_UNK_3E = 0x0000003E, - BATTLE_SUB_STATE_UNK_3F = 0x0000003F, - BATTLE_SUB_STATE_UNK_40 = 0x00000040, - BATTLE_SUB_STATE_UNK_41 = 0x00000041, - BATTLE_SUB_STATE_UNK_46 = 0x00000046, - BATTLE_SUB_STATE_UNK_64 = 0x00000064, - BATTLE_SUB_STATE_UNK_C8 = 0x000000C8, - BATTLE_SUB_STATE_UNK_C9 = 0x000000C9, - BATTLE_SUB_STATE_UNK_CA = 0x000000CA, - BATTLE_SUB_STATE_UNK_CB = 0x000000CB, - BATTLE_SUB_STATE_UNK_CC = 0x000000CC, - BATTLE_SUB_STATE_UNK_CD = 0x000000CD, - BATTLE_SUB_STATE_UNK_12C = 0x0000012C, - BATTLE_SUB_STATE_UNK_12D = 0x0000012D, - BATTLE_SUB_STATE_UNK_12E = 0x0000012E, + // shared + BTL_SUBSTATE_INIT = 0, + + // BATTLE_STATE_NORMAL_START + BTL_SUBSTATE_NORMAL_START_UNK_0 = 0, + BTL_SUBSTATE_NORMAL_START_UNK_1 = 1, + BTL_SUBSTATE_NORMAL_START_UNK_4 = 4, + BTL_SUBSTATE_NORMAL_START_UNK_7 = 7, + BTL_SUBSTATE_NORMAL_START_UNK_8 = 8, + + // BATTLE_STATE_FIRST_STRIKE + BTL_SUBSTATE_FIRST_STRIKE_UNK_0 = 0, + BTL_SUBSTATE_FIRST_STRIKE_UNK_1 = 1, + BTL_SUBSTATE_FIRST_STRIKE_UNK_2 = 2, + BTL_SUBSTATE_FIRST_STRIKE_UNK_3 = 3, + + // BATTLE_STATE_PARTNER_FIRST_STRIKE + BTL_SUBSTATE_PARTNER_FIRST_STRIKE_UNK_0 = 0, + BTL_SUBSTATE_PARTNER_FIRST_STRIKE_UNK_1 = 1, + BTL_SUBSTATE_PARTNER_FIRST_STRIKE_UNK_2 = 2, + BTL_SUBSTATE_PARTNER_FIRST_STRIKE_UNK_3 = 3, + + // BATTLE_STATE_ENEMY_FIRST_STRIKE + BTL_SUBSTATE_ENEMY_FIRST_STRIKE_UNK_0 = 0, + BTL_SUBSTATE_ENEMY_FIRST_STRIKE_UNK_2 = 2, + + // BATTLE_STATE_BEGIN_TURN + BTL_SUBSTATE_BEGIN_TURN_INIT = 0, + BTL_SUBSTATE_BEGIN_TURN_AWAIT_ENEMY_SCRIPTS = 5, + BTL_SUBSTATE_BEGIN_TURN_AWAIT_ENEMY_DEATH = 10, + + // BATTLE_STATE_END_TURN + BTL_SUBSTATE_END_TURN_INIT = 0, + BTL_SUBSTATE_END_TURN_CHECK_FOR_SWAP = 1, + BTL_SUBSTATE_END_TURN_AWAIT_SCRIPTS = 2, + BTL_SUBSTATE_END_TURN_BEGIN_NEXT = 3, + BTL_SUBSTATE_END_TURN_UNK_4 = 4, + BTL_SUBSTATE_END_TURN_PERFORM_SWAP = 11, + BTL_SUBSTATE_END_TURN_START_SCRIPTS = 12, + + // BATTLE_STATE_BEGIN_PLAYER_TURN + BTL_SUBSTATE_BEGIN_PLAYER_TURN_INIT = 0, + BTL_SUBSTATE_BEGIN_PLAYER_TURN_TRY_COMMAND_RECOVER = 1, + BTL_SUBSTATE_BEGIN_PLAYER_TURN_AWAIT_OUTTA_SIGHT = 2, + BTL_SUBSTATE_BEGIN_PLAYER_TURN_CHECK_OUTTA_SIGHT = 10, + BTL_SUBSTATE_BEGIN_PLAYER_TURN_CHECK_CLOUD_NINE = 11, + BTL_SUBSTATE_BEGIN_PLAYER_TURN_AWAIT_CLOUD_NINE = 12, + BTL_SUBSTATE_BEGIN_PLAYER_TURN_CHECK_TURBO_CHARGE = 15, + BTL_SUBSTATE_BEGIN_PLAYER_TURN_AWAIT_TURBO_CHARGE = 16, + BTL_SUBSTATE_BEGIN_PLAYER_TURN_AWAIT_PARTNER_SCRIPT = 20, + BTL_SUBSTATE_BEGIN_PLAYER_TURN_TRY_STATUS_DAMAGE = 21, + BTL_SUBSTATE_BEGIN_PLAYER_TURN_TRY_STATUS_RECOVER = 22, + BTL_SUBSTATE_BEGIN_PLAYER_TURN_END_DELAY = 30, + BTL_SUBSTATE_BEGIN_PLAYER_TURN_RESET_STATE = 100, + + // BATTLE_STATE_BEGIN_PARTNER_TURN + BTL_SUBSTATE_BEGIN_PARTNER_TURN_INIT = 0, + BTL_SUBSTATE_BEGIN_PARTNER_TURN_AWAIT_RECOVER_DONE = 1, + BTL_SUBSTATE_BEGIN_PARTNER_TURN_EXEC_TURN_SCRIPT = 8, + BTL_SUBSTATE_BEGIN_PARTNER_TURN_AWAIT_TURN_SCRIPT = 9, + BTL_SUBSTATE_BEGIN_PARTNER_TURN_END_DELAY = 10, + BTL_SUBSTATE_BEGIN_PARTNER_TURN_RESET_STATE = 100, + + // BATTLE_STATE_9 + BTL_SUBSTATE_9_INIT = 0, + BTL_SUBSTATE_9_1 = 1, + BTL_SUBSTATE_9_2 = 2, + BTL_SUBSTATE_9_3 = 3, + BTL_SUBSTATE_9_4 = 4, + BTL_SUBSTATE_9_5 = 5, + BTL_SUBSTATE_9_6 = 6, + BTL_SUBSTATE_9_7 = 7, + + // BATTLE_STATE_9 + // BATTLE_STATE_SWITCH_TO_PLAYER + // BATTLE_STATE_SWITCH_TO_PARTNER + + // BATTLE_STATE_PREPARE_MENU + BATTLE_SUBSTATE_PREPARE_MENU_UNK_70 = 70, + + // BATTLE_STATE_PLAYER_MENU + // BATTLE_STATE_PARTNER_MENU + + // BATTLE_STATE_PEACH_MENU + BTL_SUBSTATE_PEACH_MENU_UNK_0 = 0, + BTL_SUBSTATE_PEACH_MENU_UNK_1 = 1, + BTL_SUBSTATE_PEACH_MENU_UNK_2 = 2, + BTL_SUBSTATE_PEACH_MENU_UNK_3 = 3, + BTL_SUBSTATE_PEACH_MENU_UNK_4 = 4, + BTL_SUBSTATE_PEACH_MENU_UNK_5 = 5, + BTL_SUBSTATE_PEACH_MENU_UNK_6 = 6, + BTL_SUBSTATE_PEACH_MENU_UNK_7 = 7, + BTL_SUBSTATE_PEACH_MENU_UNK_8 = 8, + BTL_SUBSTATE_PEACH_MENU_UNK_9 = 9, + BTL_SUBSTATE_PEACH_MENU_UNK_A = 10, + BTL_SUBSTATE_PEACH_MENU_UNK_B = 11, + + // BATTLE_STATE_TWINK_MENU + BTL_SUBSTATE_TWINK_MENU_INIT = 0, + BTL_SUBSTATE_TWINK_MENU_UNK_1 = 1, + BTL_SUBSTATE_TWINK_MENU_UNK_2 = 2, + BTL_SUBSTATE_TWINK_MENU_UNK_3 = 3, + BTL_SUBSTATE_TWINK_MENU_UNK_4 = 4, + BTL_SUBSTATE_TWINK_MENU_UNK_5 = 5, + BTL_SUBSTATE_TWINK_MENU_UNK_6 = 6, + BTL_SUBSTATE_TWINK_MENU_UNK_7 = 7, + BTL_SUBSTATE_TWINK_MENU_SHOW_CANT_SWITCH = 8, + BTL_SUBSTATE_TWINK_MENU_AWAIT_CANT_SWITCH_POPUP = 9, + BTL_SUBSTATE_TWINK_MENU_PERFORM_SWAP = 10, + BTL_SUBSTATE_TWINK_MENU_UNK_B = 11, + + // BATTLE_STATE_SELECT_TARGET + BTL_SUBSTATE_SELECT_TARGET_INIT = 0, + BTL_SUBSTATE_SELECT_TARGET_CHOOSE = 1, + BTL_SUBSTATE_SELECT_TARGET_DONE = 2, + BTL_SUBSTATE_SELECT_TARGET_CANCEL = 10, + + // BATTLE_STATE_PLAYER_MOVE + BTL_SUBSTATE_PLAYER_MOVE_INIT = 0, + BTL_SUBSTATE_PLAYER_MOVE_BEGIN_SHOW_TIP = 1, + BTL_SUBSTATE_PLAYER_MOVE_SHOW_TIP_DELAY = 2, + BTL_SUBSTATE_PLAYER_MOVE_EXECUTE_MOVE = 3, + BTL_SUBSTATE_PLAYER_MOVE_HANDLE_RESULTS = 4, + BTL_SUBSTATE_PLAYER_MOVE_AWAIT_ENEMY_STATUS_POPUP = 11, + BTL_SUBSTATE_PLAYER_MOVE_POST_ENEMY_STATUS_POPUP = 12, + BTL_SUBSTATE_PLAYER_MOVE_CHECK_PLAYER_STATUS = 20, + BTL_SUBSTATE_PLAYER_MOVE_AWAIT_PLAYER_STATUS_POPUP = 21, + BTL_SUBSTATE_PLAYER_MOVE_POST_PLAYER_STATUS_POPUP = 22, + BTL_SUBSTATE_PLAYER_MOVE_AWAIT_DONE = 30, + + // BATTLE_STATE_PARTNER_MOVE + BTL_SUBSTATE_PARTNER_MOVE_UNK_0 = 0, + BTL_SUBSTATE_PARTNER_MOVE_UNK_2 = 2, + BTL_SUBSTATE_PARTNER_MOVE_UNK_3 = 3, + BTL_SUBSTATE_PARTNER_MOVE_UNK_B = 11, + BTL_SUBSTATE_PARTNER_MOVE_UNK_C = 12, + BTL_SUBSTATE_PARTNER_MOVE_UNK_14 = 20, + BTL_SUBSTATE_PARTNER_MOVE_UNK_15 = 21, + BTL_SUBSTATE_PARTNER_MOVE_UNK_16 = 22, + BTL_SUBSTATE_PARTNER_MOVE_UNK_1E = 30, + + // BATTLE_STATE_NEXT_ENEMY + BTL_SUBSTATE_NEXT_ENEMY_INIT = 0, + BTL_SUBSTATE_NEXT_ENEMY_UNK_1 = 1, + BTL_SUBSTATE_NEXT_ENEMY_DONE = 2, // enemy has been found + + // BATTLE_STATE_ENEMY_MOVE + BTL_SUBSTATE_ENEMY_MOVE_EXECUTE = 0, + BTL_SUBSTATE_ENEMY_MOVE_UNK_1 = 1, + BTL_SUBSTATE_ENEMY_MOVE_AWAIT_SCRIPTS = 2, + BTL_SUBSTATE_ENEMY_MOVE_AWAIT_PLAYER_POPUP_DONE = 11, // wait for popups regarding player status to finish + BTL_SUBSTATE_ENEMY_MOVE_POST_PLAYER_POPUP_DELAY = 12, // a brief delay after the popup vanishes + BTL_SUBSTATE_ENEMY_MOVE_CHECK_PARTNER = 20, + BTL_SUBSTATE_ENEMY_MOVE_AWAIT_PARTNER_POPUP_DONE = 21, // wait for popups regarding partner status to finish + BTL_SUBSTATE_ENEMY_MOVE_POST_PARTNER_POPUP_DELAY = 22, // a brief delay after the popup vanishes + BTL_SUBSTATE_ENEMY_MOVE_DONE = 30, + + // BATTLE_STATE_END_PLAYER_TURN + BTL_SUBSTATE_END_PLAYER_TURN_UNK_0 = 0, + BTL_SUBSTATE_END_PLAYER_TURN_UNK_5 = 5, + BTL_SUBSTATE_END_PLAYER_TURN_UNK_6 = 6, + BTL_SUBSTATE_END_PLAYER_TURN_UNK_A = 10, + + // BATTLE_STATE_END_PARTNER_TURN + + // BATTLE_STATE_RUN_AWAY + BTL_SUBSTATE_RUN_AWAY_UNK_0 = 0, + BTL_SUBSTATE_RUN_AWAY_UNK_2 = 2, + BTL_SUBSTATE_RUN_AWAY_UNK_3 = 3, + BTL_SUBSTATE_RUN_AWAY_UNK_4 = 4, + BTL_SUBSTATE_RUN_AWAY_UNK_A = 10, + BTL_SUBSTATE_RUN_AWAY_UNK_B = 11, + + // BATTLE_STATE_DEFEND + BTL_SUBSTATE_DEFEND_INIT = 0, + BTL_SUBSTATE_DEFEND_AWAIT_SCRIPT = 1, + + // BATTLE_STATE_VICTORY + BTL_SUBSTATE_VICTORY_UNK_0 = 0, + BTL_SUBSTATE_VICTORY_UNK_1 = 1, + BTL_SUBSTATE_VICTORY_UNK_2 = 2, + BTL_SUBSTATE_VICTORY_UNK_3 = 3, + BTL_SUBSTATE_VICTORY_UNK_4 = 4, + BTL_SUBSTATE_VICTORY_UNK_5 = 5, + BTL_SUBSTATE_VICTORY_UNK_A = 10, + BTL_SUBSTATE_VICTORY_UNK_B = 11, + BTL_SUBSTATE_VICTORY_UNK_C = 12, + + // BATTLE_STATE_DEFEAT + BTL_SUBSTATE_DEFEAT_UNK_0 = 0, + BTL_SUBSTATE_DEFEAT_UNK_1 = 1, + BTL_SUBSTATE_DEFEAT_UNK_2 = 2, + BTL_SUBSTATE_DEFEAT_UNK_A = 10, + + // BATTLE_STATE_28 + + // BATTLE_STATE_CHANGE_PARTNER + BTL_SUBSTATE_CHANGE_PARTNER_UNK_0 = 0, + BTL_SUBSTATE_CHANGE_PARTNER_UNK_2 = 2, + BTL_SUBSTATE_CHANGE_PARTNER_UNK_3 = 3, + BTL_SUBSTATE_CHANGE_PARTNER_UNK_4 = 4, + BTL_SUBSTATE_CHANGE_PARTNER_UNK_5 = 5, + BTL_SUBSTATE_CHANGE_PARTNER_UNK_6 = 6, + BTL_SUBSTATE_CHANGE_PARTNER_UNK_7 = 7, + + // BATTLE_STATE_END_TRAINING_BATTLE + BTL_SUBSTATE_END_TRAINING_UNK_0 = 0, + BTL_SUBSTATE_END_TRAINING_UNK_A = 10, + BTL_SUBSTATE_END_TRAINING_UNK_B = 11, + BTL_SUBSTATE_END_TRAINING_UNK_C = 12, + BTL_SUBSTATE_END_TRAINING_UNK_D = 13, + BTL_SUBSTATE_END_TRAINING_UNK_E = 14, + + // BATTLE_STATE_31 + + // BATTLE_STATE_END_BATTLE (TODO) + BTL_SUBSTATE_END_BATTLE_UNK_0 = 0, + BTL_SUBSTATE_END_BATTLE_UNK_1 = 1, + BTL_SUBSTATE_END_BATTLE_UNK_2 = 2, + BTL_SUBSTATE_END_BATTLE_AWAIT_STAGE_SCRIPT = 3, + BTL_SUBSTATE_END_BATTLE_CLEANUP = 4, + + // BATTLE_STATE_CELEBRATION + BTL_SUBSTATE_CELEBRATE_INIT = 0, + BTL_SUBSTATE_CELEBRATE_LOAD_STAR_POINTS = 1, + BTL_SUBSTATE_CELEBRATE_TALLY_STAR_POINTS = 2, + BTL_SUBSTATE_CELEBRATE_POST_STAR_POINTS = 3, + BTL_SUBSTATE_CELEBRATE_LEVEL_UP_LOAD = 4, + BTL_SUBSTATE_CELEBRATE_LEVEL_UP_BEGIN = 5, + BTL_SUBSTATE_CELEBRATE_LEVEL_UP_CREATE_HUD = 6, + BTL_SUBSTATE_CELEBRATE_LEVEL_UP_SHOW_HUD = 7, + BTL_SUBSTATE_CELEBRATE_LEVEL_UP_CHOOSE = 8, + BTL_SUBSTATE_CELEBRATE_LEVEL_UP_UPGRADE = 9, + BTL_SUBSTATE_CELEBRATE_LEVEL_UP_FADE_OUT = 10, + BTL_SUBSTATE_CELEBRATE_LEVEL_UP_DESTROY_HUD = 11, + BTL_SUBSTATE_CELEBRATE_LEVEL_UP_INVALID = 15, + BTL_SUBSTATE_CELEBRATE_LEVEL_UP_INVALID_DELAY = 16, + BTL_SUBSTATE_CELEBRATE_SKIPPABLE_END_DELAY = 20, + BTL_SUBSTATE_CELEBRATE_WALK_AWAY = 21, + BTL_SUBSTATE_CELEBRATE_DONE = 22, + + // BATTLE_STATE_34 + + // BATTLE_STATE_END_DEMO_BATTLE + BTL_SUBSTATE_END_DEMO_BATTLE_UNK_0 = 0, + BTL_SUBSTATE_END_DEMO_BATTLE_UNK_1 = 1, + BTL_SUBSTATE_END_DEMO_BATTLE_UNK_2 = 2, + BTL_SUBSTATE_END_DEMO_BATTLE_UNK_3 = 3, + BTL_SUBSTATE_END_DEMO_BATTLE_UNK_4 = 4, }; -enum BattleSubStatesPlayer { - BATTLE_SUB_STATE_PLAYER_NONE = 0, +// used with BATTLE_STATE_PLAYER_MENU +enum BattlePlayerMenuSubstates { + BTL_SUBSTATE_PLAYER_MENU_NONE = 0, // Main menu - BATTLE_SUB_STATE_PLAYER_MAIN_MENU_1 = 1, - BATTLE_SUB_STATE_PLAYER_MAIN_MENU_2 = 2, - BATTLE_SUB_STATE_PLAYER_MAIN_MENU_3 = 3, - BATTLE_SUB_STATE_PLAYER_MAIN_MENU_4 = 4, - BATTLE_SUB_STATE_PLAYER_MAIN_MENU_5 = 5, - BATTLE_SUB_STATE_PLAYER_MAIN_MENU_6 = 6, - BATTLE_SUB_STATE_PLAYER_MAIN_MENU_7 = 7, - BATTLE_SUB_STATE_PLAYER_MAIN_MENU_8 = 8, - BATTLE_SUB_STATE_PLAYER_MAIN_MENU_9 = 9, - BATTLE_SUB_STATE_PLAYER_MAIN_MENU_10 = 10, - BATTLE_SUB_STATE_PLAYER_MAIN_MENU_11 = 11, - BATTLE_SUB_STATE_PLAYER_MAIN_MENU_12 = 12, - BATTLE_SUB_STATE_PLAYER_MAIN_MENU_13 = 13, - BATTLE_SUB_STATE_PLAYER_MAIN_MENU_14 = 14, + BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_1 = 1, + BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_2 = 2, + BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_3 = 3, + BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_4 = 4, + BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_5 = 5, + BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_6 = 6, + BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_7 = 7, + BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_8 = 8, + BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_9 = 9, + BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_10 = 10, + BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_11 = 11, + BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_12 = 12, + BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_13 = 13, + BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_14 = 14, // Unknown - BATTLE_SUB_STATE_PLAYER_UNKNOWN_1 = 20, - BATTLE_SUB_STATE_PLAYER_UNKNOWN_2 = 21, - BATTLE_SUB_STATE_PLAYER_UNKNOWN_3 = 22, - BATTLE_SUB_STATE_PLAYER_UNKNOWN_4 = 23, - BATTLE_SUB_STATE_PLAYER_UNKNOWN_5 = 24, - BATTLE_SUB_STATE_PLAYER_UNKNOWN_6 = 25, + BTL_SUBSTATE_PLAYER_MENU_UNKNOWN_1 = 20, + BTL_SUBSTATE_PLAYER_MENU_UNKNOWN_2 = 21, + BTL_SUBSTATE_PLAYER_MENU_UNKNOWN_3 = 22, + BTL_SUBSTATE_PLAYER_MENU_UNKNOWN_4 = 23, + BTL_SUBSTATE_PLAYER_MENU_UNKNOWN_5 = 24, + BTL_SUBSTATE_PLAYER_MENU_UNKNOWN_6 = 25, // Change Member - BATTLE_SUB_STATE_PLAYER_CHANGE_MEMBER_1 = 30, - BATTLE_SUB_STATE_PLAYER_CHANGE_MEMBER_2 = 31, - BATTLE_SUB_STATE_PLAYER_CHANGE_MEMBER_3 = 32, - BATTLE_SUB_STATE_PLAYER_CHANGE_MEMBER_4 = 33, - BATTLE_SUB_STATE_PLAYER_CHANGE_MEMBER_5 = 34, - BATTLE_SUB_STATE_PLAYER_CHANGE_MEMBER_6 = 35, - BATTLE_SUB_STATE_PLAYER_CHANGE_MEMBER_7 = 36, + BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_1 = 30, + BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_2 = 31, + BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_3 = 32, + BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_4 = 33, + BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_5 = 34, + BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_6 = 35, + BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_7 = 36, // Items - BATTLE_SUB_STATE_PLAYER_ITEMS_1 = 40, - BATTLE_SUB_STATE_PLAYER_ITEMS_2 = 41, - BATTLE_SUB_STATE_PLAYER_ITEMS_3 = 42, - BATTLE_SUB_STATE_PLAYER_ITEMS_4 = 43, - BATTLE_SUB_STATE_PLAYER_ITEMS_5 = 44, - BATTLE_SUB_STATE_PLAYER_ITEMS_6 = 45, + BTL_SUBSTATE_PLAYER_MENU_ITEMS_1 = 40, + BTL_SUBSTATE_PLAYER_MENU_ITEMS_2 = 41, + BTL_SUBSTATE_PLAYER_MENU_ITEMS_3 = 42, + BTL_SUBSTATE_PLAYER_MENU_ITEMS_4 = 43, + BTL_SUBSTATE_PLAYER_MENU_ITEMS_5 = 44, + BTL_SUBSTATE_PLAYER_MENU_ITEMS_6 = 45, // Star Spirits - BATTLE_SUB_STATE_PLAYER_STAR_SPIRITS_1 = 60, - BATTLE_SUB_STATE_PLAYER_STAR_SPIRITS_2 = 61, - BATTLE_SUB_STATE_PLAYER_STAR_SPIRITS_3 = 62, - BATTLE_SUB_STATE_PLAYER_STAR_SPIRITS_4 = 63, - BATTLE_SUB_STATE_PLAYER_STAR_SPIRITS_5 = 64, - BATTLE_SUB_STATE_PLAYER_STAR_SPIRITS_6 = 65, - BATTLE_SUB_STATE_PLAYER_STAR_SPIRITS_7 = 66, + BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_1 = 60, + BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_2 = 61, + BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_3 = 62, + BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_4 = 63, + BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_5 = 64, + BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_6 = 65, + BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_7 = 66, // Unused - BATTLE_SUB_STATE_PLAYER_UNUSED_1 = 70, - BATTLE_SUB_STATE_PLAYER_UNUSED_2 = 71, - BATTLE_SUB_STATE_PLAYER_UNUSED_3 = 72, - BATTLE_SUB_STATE_PLAYER_UNUSED_4 = 73, - BATTLE_SUB_STATE_PLAYER_UNUSED_5 = 74, - BATTLE_SUB_STATE_PLAYER_UNUSED_6 = 75, + BTL_SUBSTATE_PLAYER_MENU_UNUSED_1 = 70, + BTL_SUBSTATE_PLAYER_MENU_UNUSED_2 = 71, + BTL_SUBSTATE_PLAYER_MENU_UNUSED_3 = 72, + BTL_SUBSTATE_PLAYER_MENU_UNUSED_4 = 73, + BTL_SUBSTATE_PLAYER_MENU_UNUSED_5 = 74, + BTL_SUBSTATE_PLAYER_MENU_UNUSED_6 = 75, // Berserker - BATTLE_SUB_STATE_PLAYER_BERSERKER_1 = 100, + BTL_SUBSTATE_PLAYER_MENU_BERSERKER_1 = 100, // Strategies - BATTLE_SUB_STATE_PLAYER_STRATEGIES_1 = 200, - BATTLE_SUB_STATE_PLAYER_STRATEGIES_2 = 201, - BATTLE_SUB_STATE_PLAYER_STRATEGIES_3 = 202, - BATTLE_SUB_STATE_PLAYER_STRATEGIES_4 = 203, - BATTLE_SUB_STATE_PLAYER_STRATEGIES_5 = 204, - BATTLE_SUB_STATE_PLAYER_STRATEGIES_6 = 205, - BATTLE_SUB_STATE_PLAYER_STRATEGIES_8 = 207, + BTL_SUBSTATE_PLAYER_MENU_BUILD_STRATEGIES = 200, + BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_2 = 201, + BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_3 = 202, + BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_4 = 203, + BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_5 = 204, + BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_6 = 205, + BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_8 = 207, // initialize - BATTLE_SUB_STATE_PLAYER_INIT_12C = 300, - BATTLE_SUB_STATE_PLAYER_INIT_MENU = 302, + BTL_SUBSTATE_PLAYER_MENU_INIT_12C = 300, + BTL_SUBSTATE_PLAYER_MENU_INIT_MENU = 302, }; -enum BattleSubStatesPartner { - BATTLE_SUB_STATE_PARTNER_NONE = 0, +enum BattlePartnerMenuSubstates { + BTL_SUBSTATE_PARTNER_MENU_NONE = 0, // Main menu - BATTLE_SUB_STATE_PARTNER_MAIN_MENU_1 = 2, - BATTLE_SUB_STATE_PARTNER_MAIN_MENU_2 = 3, - BATTLE_SUB_STATE_PARTNER_MAIN_MENU_3 = 4, - BATTLE_SUB_STATE_PARTNER_MAIN_MENU_4 = 5, - BATTLE_SUB_STATE_PARTNER_MAIN_MENU_5 = 6, - BATTLE_SUB_STATE_PARTNER_MAIN_MENU_6 = 7, - BATTLE_SUB_STATE_PARTNER_MAIN_MENU_7 = 8, - BATTLE_SUB_STATE_PARTNER_MAIN_MENU_8 = 9, + BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_1 = 2, + BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_2 = 3, + BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_3 = 4, + BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_4 = 5, + BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_5 = 6, + BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_6 = 7, + BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_7 = 8, + BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_8 = 9, // Abilities - BATTLE_SUB_STATE_PARTNER_ABILITIES_1 = 10, - BATTLE_SUB_STATE_PARTNER_ABILITIES_2 = 11, - BATTLE_SUB_STATE_PARTNER_ABILITIES_3 = 12, - BATTLE_SUB_STATE_PARTNER_ABILITIES_4 = 13, - BATTLE_SUB_STATE_PARTNER_ABILITIES_5 = 14, - BATTLE_SUB_STATE_PARTNER_ABILITIES_6 = 15, - BATTLE_SUB_STATE_PARTNER_ABILITIES_7 = 16, + BTL_SUBSTATE_PARTNER_MENU_ABILITIES_1 = 10, + BTL_SUBSTATE_PARTNER_MENU_ABILITIES_2 = 11, + BTL_SUBSTATE_PARTNER_MENU_ABILITIES_3 = 12, + BTL_SUBSTATE_PARTNER_MENU_ABILITIES_4 = 13, + BTL_SUBSTATE_PARTNER_MENU_ABILITIES_5 = 14, + BTL_SUBSTATE_PARTNER_MENU_ABILITIES_6 = 15, + BTL_SUBSTATE_PARTNER_MENU_ABILITIES_7 = 16, // Unknown, referenced only in btl_state_draw_partner_menu - BATTLE_SUB_STATE_PARTNER_UNKNOWN_1 = 20, - BATTLE_SUB_STATE_PARTNER_UNKNOWN_2 = 21, - BATTLE_SUB_STATE_PARTNER_UNKNOWN_3 = 22, - BATTLE_SUB_STATE_PARTNER_UNKNOWN_4 = 23, - BATTLE_SUB_STATE_PARTNER_UNKNOWN_5 = 24, + BTL_SUBSTATE_PARTNER_MENU_UNKNOWN_1 = 20, + BTL_SUBSTATE_PARTNER_MENU_UNKNOWN_2 = 21, + BTL_SUBSTATE_PARTNER_MENU_UNKNOWN_3 = 22, + BTL_SUBSTATE_PARTNER_MENU_UNKNOWN_4 = 23, + BTL_SUBSTATE_PARTNER_MENU_UNKNOWN_5 = 24, // Change Partner - BATTLE_SUB_STATE_PARTNER_CHANGE_PARTNER_1 = 30, - BATTLE_SUB_STATE_PARTNER_CHANGE_PARTNER_2 = 31, - BATTLE_SUB_STATE_PARTNER_CHANGE_PARTNER_3 = 32, - BATTLE_SUB_STATE_PARTNER_CHANGE_PARTNER_4 = 33, - BATTLE_SUB_STATE_PARTNER_CHANGE_PARTNER_5 = 34, - BATTLE_SUB_STATE_PARTNER_CHANGE_PARTNER_6 = 35, - BATTLE_SUB_STATE_PARTNER_CHANGE_PARTNER_7 = 36, + BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_1 = 30, + BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_2 = 31, + BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_3 = 32, + BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_4 = 33, + BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_5 = 34, + BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_6 = 35, + BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_7 = 36, // Items - BATTLE_SUB_STATE_PARTNER_ITEMS_1 = 40, - BATTLE_SUB_STATE_PARTNER_ITEMS_2 = 41, - BATTLE_SUB_STATE_PARTNER_ITEMS_3 = 42, - BATTLE_SUB_STATE_PARTNER_ITEMS_4 = 43, - BATTLE_SUB_STATE_PARTNER_ITEMS_5 = 44, - BATTLE_SUB_STATE_PARTNER_ITEMS_6 = 45, + BTL_SUBSTATE_PARTNER_MENU_ITEMS_1 = 40, + BTL_SUBSTATE_PARTNER_MENU_ITEMS_2 = 41, + BTL_SUBSTATE_PARTNER_MENU_ITEMS_3 = 42, + BTL_SUBSTATE_PARTNER_MENU_ITEMS_4 = 43, + BTL_SUBSTATE_PARTNER_MENU_ITEMS_5 = 44, + BTL_SUBSTATE_PARTNER_MENU_ITEMS_6 = 45, // Switch partner (unused) - BATTLE_SUB_STATE_PARTNER_UNUSED_CHANGE_PARTNER_1 = 50, - BATTLE_SUB_STATE_PARTNER_UNUSED_CHANGE_PARTNER_2 = 51, - BATTLE_SUB_STATE_PARTNER_UNUSED_CHANGE_PARTNER_3 = 52, - BATTLE_SUB_STATE_PARTNER_UNUSED_CHANGE_PARTNER_4 = 53, - BATTLE_SUB_STATE_PARTNER_UNUSED_CHANGE_PARTNER_5 = 54, - BATTLE_SUB_STATE_PARTNER_UNUSED_CHANGE_PARTNER_6 = 55, - BATTLE_SUB_STATE_PARTNER_UNUSED_CHANGE_PARTNER_7 = 56, + BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_1 = 50, + BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_2 = 51, + BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_3 = 52, + BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_4 = 53, + BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_5 = 54, + BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_6 = 55, + BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_7 = 56, // Focus - BATTLE_SUB_STATE_PARTNER_FOCUS_1 = 60, - BATTLE_SUB_STATE_PARTNER_FOCUS_2 = 61, - BATTLE_SUB_STATE_PARTNER_FOCUS_3 = 62, - BATTLE_SUB_STATE_PARTNER_FOCUS_4 = 63, - BATTLE_SUB_STATE_PARTNER_FOCUS_5 = 64, - BATTLE_SUB_STATE_PARTNER_FOCUS_6 = 65, + BTL_SUBSTATE_PARTNER_MENU_FOCUS_1 = 60, + BTL_SUBSTATE_PARTNER_MENU_FOCUS_2 = 61, + BTL_SUBSTATE_PARTNER_MENU_FOCUS_3 = 62, + BTL_SUBSTATE_PARTNER_MENU_FOCUS_4 = 63, + BTL_SUBSTATE_PARTNER_MENU_FOCUS_5 = 64, + BTL_SUBSTATE_PARTNER_MENU_FOCUS_6 = 65, // Strategies - BATTLE_SUB_STATE_PARTNER_STRATEGIES_1 = 200, - BATTLE_SUB_STATE_PARTNER_STRATEGIES_2 = 201, - BATTLE_SUB_STATE_PARTNER_STRATEGIES_3 = 202, - BATTLE_SUB_STATE_PARTNER_STRATEGIES_4 = 203, - BATTLE_SUB_STATE_PARTNER_STRATEGIES_5 = 204, - BATTLE_SUB_STATE_PARTNER_STRATEGIES_6 = 205, + BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_1 = 200, + BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_2 = 201, + BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_3 = 202, + BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_4 = 203, + BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_5 = 204, + BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_6 = 205, // initialize - BATTLE_SUB_STATE_PARTNER_12D = 301, - BATTLE_SUB_STATE_PARTNER_INIT_MENU = 302, + BTL_SUBSTATE_PARTNER_MENU_12D = 301, + BTL_SUBSTATE_PARTNER_MENU_INIT_MENU = 302, }; -enum BattleSubStatesState5 { - BATTLE_SUB_STATE_5_0 = 0, - BATTLE_SUB_STATE_5_1 = 1, - BATTLE_SUB_STATE_5_2 = 2, - BATTLE_SUB_STATE_5_3 = 3, - BATTLE_SUB_STATE_5_4 = 4, - BATTLE_SUB_STATE_5_5 = 5, - BATTLE_SUB_STATE_5_6 = 6, - BATTLE_SUB_STATE_5_7 = 7, +enum BattleMessages { + BTL_MSG_00 = 0x00, + BTL_MSG_01 = 0x01, + BTL_MSG_02 = 0x02, + BTL_MSG_03 = 0x03, + BTL_MSG_04 = 0x04, + BTL_MSG_05 = 0x05, + BTL_MSG_06 = 0x06, + BTL_MSG_07 = 0x07, + BTL_MSG_08 = 0x08, + BTL_MSG_09 = 0x09, + BTL_MSG_0A = 0x0A, + BTL_MSG_0B = 0x0B, + BTL_MSG_0C = 0x0C, + BTL_MSG_0D = 0x0D, + BTL_MSG_0E = 0x0E, + BTL_MSG_0F = 0x0F, + BTL_MSG_10 = 0x10, + BTL_MSG_11 = 0x11, + BTL_MSG_12 = 0x12, + BTL_MSG_13 = 0x13, + BTL_MSG_14 = 0x14, + BTL_MSG_15 = 0x15, + BTL_MSG_16 = 0x16, + BTL_MSG_17 = 0x17, + BTL_MSG_18 = 0x18, + BTL_MSG_19 = 0x19, + BTL_MSG_1A = 0x1A, + BTL_MSG_1B = 0x1B, + BTL_MSG_1C = 0x1C, + BTL_MSG_1D = 0x1D, + BTL_MSG_1E = 0x1E, + BTL_MSG_1F = 0x1F, + BTL_MSG_20 = 0x20, + BTL_MSG_21 = 0x21, + BTL_MSG_22 = 0x22, + BTL_MSG_23 = 0x23, + BTL_MSG_24 = 0x24, + BTL_MSG_25 = 0x25, + BTL_MSG_26 = 0x26, + BTL_MSG_27 = 0x27, + BTL_MSG_28 = 0x28, + BTL_MSG_29 = 0x29, + BTL_MSG_2A = 0x2A, + BTL_MSG_2B = 0x2B, + BTL_MSG_2C = 0x2C, + BTL_MSG_2D = 0x2D, + BTL_MSG_2E = 0x2E, + BTL_MSG_2F = 0x2F, + BTL_MSG_30 = 0x30, + BTL_MSG_31 = 0x31, + BTL_MSG_32 = 0x32, + BTL_MSG_33 = 0x33, + BTL_MSG_34 = 0x34, + BTL_MSG_35 = 0x35, + BTL_MSG_36 = 0x36, + BTL_MSG_37 = 0x37, + BTL_MSG_38 = 0x38, + BTL_MSG_39 = 0x39, + BTL_MSG_3A = 0x3A, + BTL_MSG_3B = 0x3B, + BTL_MSG_3C = 0x3C, + BTL_MSG_3D = 0x3D, + BTL_MSG_3E = 0x3E, + BTL_MSG_3F = 0x3F, + BTL_MSG_40 = 0x40, + BTL_MSG_41 = 0x41, + BTL_MSG_42 = 0x42, + BTL_MSG_43 = 0x43, + BTL_MSG_44 = 0x44, + BTL_MSG_45 = 0x45, + BTL_MSG_46 = 0x46, + BTL_MSG_47 = 0x47, + BTL_MSG_48 = 0x48, + BTL_MSG_49 = 0x49, + BTL_MSG_4A = 0x4A, + BTL_MSG_4B = 0x4B, + BTL_MSG_4C = 0x4C, + BTL_MSG_4D = 0x4D, + BTL_MSG_4E = 0x4E, + BTL_MSG_4F = 0x4F, + BTL_MSG_50 = 0x50, + BTL_MSG_51 = 0x51, + BTL_MSG_52 = 0x52, + BTL_MSG_53 = 0x53, + BTL_MSG_54 = 0x54, +}; + +enum DebugEnemyContactModes { + DEBUG_CONTACT_NONE = 0, // contact with enemies behaves normally + DEBUG_CONTACT_CANT_TOUCH = 1, // enemies pass through the player and cannot start battles + DEBUG_CONTACT_DIE_ON_TOUCH = 2, // enemies die on contact in the overworld + DEBUG_CONTACT_DIE_IN_BATTLE = 3, // all enemies wll die during BATTLE_STATE_BEGIN_TURN + DEBUG_CONTACT_AUTO_FLEE = 4, // the player flees during BATTLE_STATE_BEGIN_TURN }; enum DebuffTypes { @@ -5871,7 +6154,7 @@ enum MsgStateFlags { MSG_STATE_FLAG_20 = 0x000020, MSG_STATE_FLAG_40 = 0x000040, MSG_STATE_FLAG_80 = 0x000080, - MSG_STATE_FLAG_100 = 0x000100, + MSG_STATE_FLAG_PRINT_QUICKLY = 0x000100, MSG_STATE_FLAG_400 = 0x000400, MSG_STATE_FLAG_4000 = 0x004000, MSG_STATE_FLAG_8000 = 0x008000, diff --git a/include/functions.h b/include/functions.h index a56836d88a..6fbbf96b87 100644 --- a/include/functions.h +++ b/include/functions.h @@ -315,7 +315,7 @@ void btl_state_update_begin_partner_turn(void); void btl_state_draw_begin_partner_turn(void); void btl_state_update_switch_to_partner(void); void btl_state_draw_switch_to_partner(void); -void func_80242FE0(void); +void btl_state_update_9(void); void func_80243910(void); void btl_state_update_prepare_menu(void); void btl_state_draw_prepare_menu(void); diff --git a/include/variables.h b/include/variables.h index 3df328d3e8..4b306b5b34 100644 --- a/include/variables.h +++ b/include/variables.h @@ -20,9 +20,9 @@ extern s32 gBattleState; extern BattleStatus gBattleStatus; extern s32 D_800DC4D0; extern s32 D_800DC4D4; -extern s32 D_800DC4D8; +extern s32 gDefeatedBattleSubstate; extern s32 gBattleSubState; -extern s32 D_800DC4E4; +extern s32 gDefeatedBattleState; extern s32 gCurrentBattleID; extern s32 D_800DC4E0; extern s32 D_800DC4EC; diff --git a/src/16F740.c b/src/16F740.c index a553da9c64..7abf6f3726 100644 --- a/src/16F740.c +++ b/src/16F740.c @@ -35,40 +35,40 @@ void btl_merlee_on_start_turn(void) { PlayerData* playerData = &gPlayerData; do { - if (!(gBattleStatus.flags2 & BS_FLAGS2_40) && - battleStatus->nextMerleeSpellType != 3 && - battleStatus->nextMerleeSpellType != 4 && + if (!(gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) && + battleStatus->nextMerleeSpellType != MERLEE_SPELL_3 && + battleStatus->nextMerleeSpellType != MERLEE_SPELL_4 && playerData->merleeCastsLeft > 0) { if (playerData->merleeTurnCount <= 0) { s32 temp = rand_int(100); if (currentEncounter->currentEnemy != NULL) { - if (currentEncounter->currentEnemy->flags & ENEMY_FLAGS_40000) { + if (currentEncounter->currentEnemy->flags & ACTOR_FLAG_40000) { if (temp <= 45) { - playerData->merleeSpellType = 1; + playerData->merleeSpellType = MERLEE_SPELL_1; } else if (temp <= 90) { - playerData->merleeSpellType = 2; + playerData->merleeSpellType = MERLEE_SPELL_2; } else { - playerData->merleeSpellType = 3; + playerData->merleeSpellType = MERLEE_SPELL_3; } } else if (temp <= 30) { - playerData->merleeSpellType = 1; + playerData->merleeSpellType = MERLEE_SPELL_1; } else if (temp <= 60) { - playerData->merleeSpellType = 2; + playerData->merleeSpellType = MERLEE_SPELL_2; } else if (temp <= 80) { - playerData->merleeSpellType = 3; + playerData->merleeSpellType = MERLEE_SPELL_3; } else { - playerData->merleeSpellType = 4; + playerData->merleeSpellType = MERLEE_SPELL_4; } } else if (temp <= 30) { - playerData->merleeSpellType = 1; + playerData->merleeSpellType = MERLEE_SPELL_1; } else if (temp <= 60) { - playerData->merleeSpellType = 2; + playerData->merleeSpellType = MERLEE_SPELL_2; } else if (temp <= 80) { - playerData->merleeSpellType = 3; + playerData->merleeSpellType = MERLEE_SPELL_3; } else { - playerData->merleeSpellType = 4; + playerData->merleeSpellType = MERLEE_SPELL_4; } temp = rand_int(10) + 6; @@ -92,43 +92,43 @@ void btl_merlee_on_first_strike(void) { PlayerData* playerData = &gPlayerData; do { - if (!(gBattleStatus.flags2 & BS_FLAGS2_40) && - battleStatus->nextMerleeSpellType != 3 && - battleStatus->nextMerleeSpellType != 4 && + if (!(gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) && + battleStatus->nextMerleeSpellType != MERLEE_SPELL_3 && + battleStatus->nextMerleeSpellType != MERLEE_SPELL_4 && playerData->merleeCastsLeft > 0) { if (playerData->merleeTurnCount <= 0) { s32 temp = rand_int(100); if (currentEncounter->currentEnemy != NULL) { - if (currentEncounter->currentEnemy->flags & ENEMY_FLAGS_40000) { + if (currentEncounter->currentEnemy->flags & ACTOR_FLAG_40000) { if (temp <= 45) { - playerData->merleeSpellType = 1; + playerData->merleeSpellType = MERLEE_SPELL_1; } else if (temp <= 90) { - playerData->merleeSpellType = 2; + playerData->merleeSpellType = MERLEE_SPELL_2; } else { - playerData->merleeSpellType = 3; + playerData->merleeSpellType = MERLEE_SPELL_3; } } else if (temp <= 30) { - playerData->merleeSpellType = 1; + playerData->merleeSpellType = MERLEE_SPELL_1; } else if (temp <= 60) { - playerData->merleeSpellType = 2; + playerData->merleeSpellType = MERLEE_SPELL_2; } else if (temp <= 80) { - playerData->merleeSpellType = 3; + playerData->merleeSpellType = MERLEE_SPELL_3; } else { - playerData->merleeSpellType = 4; + playerData->merleeSpellType = MERLEE_SPELL_4; } } else if (temp <= 30) { - playerData->merleeSpellType = 1; + playerData->merleeSpellType = MERLEE_SPELL_1; } else if (temp <= 60) { - playerData->merleeSpellType = 2; + playerData->merleeSpellType = MERLEE_SPELL_2; } else if (temp <= 80) { - playerData->merleeSpellType = 3; + playerData->merleeSpellType = MERLEE_SPELL_3; } else { - playerData->merleeSpellType = 4; + playerData->merleeSpellType = MERLEE_SPELL_4; } - if (playerData->merleeSpellType != 4) { + if (playerData->merleeSpellType != MERLEE_SPELL_4) { // same outcome either way. has to be written like this, and the check does exist in the code. bug? if (playerData->merleeTurnCount == -1) { temp = rand_int(5) + 5; @@ -142,7 +142,7 @@ void btl_merlee_on_first_strike(void) { playerData->merleeTurnCount = temp; } - if (playerData->merleeSpellType == 3 || playerData->merleeSpellType == 4) { + if (playerData->merleeSpellType == MERLEE_SPELL_3 || playerData->merleeSpellType == MERLEE_SPELL_4) { if (playerData->merleeTurnCount >= 2) { playerData->merleeTurnCount--; } else { @@ -159,9 +159,9 @@ void btl_set_state(s32 battleState) { s32 flags = gBattleStatus.flags2; gBattleState = battleState; D_800DC4E0 = 1; - gBattleSubState = BATTLE_SUB_STATE_UNK_0; + gBattleSubState = BTL_SUBSTATE_INIT; - flags &= BS_FLAGS2_40; + flags &= BS_FLAGS2_PEACH_BATTLE; if (flags) { switch (battleState) { case BATTLE_STATE_PARTNER_MENU: @@ -212,9 +212,9 @@ void btl_state_update_normal_start(void) { battleStatus->currentStage = stage; switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_0: + case BTL_SUBSTATE_NORMAL_START_UNK_0: D_8029F240 = battle->formationSize; - set_screen_overlay_params_back(0xFF, -1.0f); + set_screen_overlay_params_back(255, -1.0f); compressedAsset = load_asset_by_name(stage->shape, &size); decode_yay0(compressedAsset, &D_80210000); general_heap_free(compressedAsset); @@ -250,7 +250,7 @@ void btl_state_update_normal_start(void) { battleStatus->pendingStarPoints = 0; battleStatus->incrementStarPointDelay = 0; battleStatus->damageTaken = 0; - battleStatus->nextMerleeSpellType = 0; + battleStatus->nextMerleeSpellType = MERLEE_SPELL_0; battleStatus->actionCommandMode = ACTION_COMMAND_MODE_NOT_LEARNED; gCameras[CAM_DEFAULT].flags |= CAMERA_FLAGS_ENABLED; gCameras[CAM_BATTLE].flags |= CAMERA_FLAGS_ENABLED; @@ -267,9 +267,9 @@ void btl_state_update_normal_start(void) { battleStatus->jumpCharge = 0; battleStatus->unk_98 = 0; battleStatus->hpDrainCount = 0; - gBattleStatus.flags2 |= BS_FLAGS2_20; + gBattleStatus.flags2 |= BS_FLAGS2_CANT_FLEE; if (currentEncounter->allowFleeing) { - gBattleStatus.flags2 &= ~BS_FLAGS2_20; + gBattleStatus.flags2 &= ~BS_FLAGS2_CANT_FLEE; } battleStatus->unk_8D = 10; battleStatus->unk_95 = 0; @@ -310,12 +310,12 @@ void btl_state_update_normal_start(void) { battleStatus->buffEffect = fx_partner_buff(0, 0.0f, 0.0f, 0.0f, 0.0f, 0); func_800E9810(); gCurrentCameraID = CAM_BATTLE; - script = start_script(D_80280EB8, 0xA, 0); + script = start_script(D_80280EB8, EVT_PRIORITY_A, 0); battleStatus->camMovementScript = script; - gBattleSubState = BATTLE_SUB_STATE_UNK_1; + gBattleSubState = BTL_SUBSTATE_NORMAL_START_UNK_1; battleStatus->camMovementScriptID = script->id; break; - case BATTLE_SUB_STATE_UNK_1: + case BTL_SUBSTATE_NORMAL_START_UNK_1: if (!does_script_exist(battleStatus->camMovementScriptID)) { UiStatus* uiStatus = &gUIStatus; @@ -384,17 +384,17 @@ void btl_state_update_normal_start(void) { script = start_script(D_80284A20, EVT_PRIORITY_A, 0); } actor->takeTurnScript = script; - actor->takeTurnID = script->id; + actor->takeTurnScriptID = script->id; script->owner1.actorID = ACTOR_PLAYER; load_partner_actor(); - gBattleSubState = BATTLE_SUB_STATE_UNK_4; + gBattleSubState = BTL_SUBSTATE_NORMAL_START_UNK_4; } break; - case BATTLE_SUB_STATE_UNK_4: + case BTL_SUBSTATE_NORMAL_START_UNK_4: cond = FALSE; for (i = 0; i < D_8029F240; i++) { actor = battleStatus->enemyActors[i]; - if (does_script_exist(actor->takeTurnID)) { + if (does_script_exist(actor->takeTurnScriptID)) { cond = TRUE; break; } else { @@ -404,11 +404,11 @@ void btl_state_update_normal_start(void) { if (!cond) { actor = battleStatus->playerActor; - if (!does_script_exist(actor->takeTurnID)) { + if (!does_script_exist(actor->takeTurnScriptID)) { actor->takeTurnScript = NULL; actor = battleStatus->partnerActor; if (actor != NULL) { - if (!does_script_exist(battleStatus->partnerActor->takeTurnID)) { + if (!does_script_exist(battleStatus->partnerActor->takeTurnScriptID)) { actor->takeTurnScript = NULL; } else { return; @@ -444,7 +444,7 @@ void btl_state_update_normal_start(void) { script = start_script(&MarioEnterStage, 0xA, 0); } actor->takeTurnScript = script; - actor->takeTurnID = script->id; + actor->takeTurnScriptID = script->id; script->owner1.actorID = ACTOR_PLAYER; } @@ -455,21 +455,21 @@ void btl_state_update_normal_start(void) { actor = battleStatus->enemyActors[0]; script = start_script(&DoDizzyAttack, 0xA, 0); actor->takeTurnScript = script; - actor->takeTurnID = script->id; + actor->takeTurnScriptID = script->id; script->owner1.enemyID = ACTOR_ENEMY0; } D_80280A30 = 305; D_8029F248 = 0; - gBattleSubState = BATTLE_SUB_STATE_UNK_7; + gBattleSubState = BTL_SUBSTATE_NORMAL_START_UNK_7; break; } } } break; - case BATTLE_SUB_STATE_UNK_7: + case BTL_SUBSTATE_NORMAL_START_UNK_7: if (D_80280A30 == 0) { - gBattleSubState = BATTLE_SUB_STATE_UNK_8; + gBattleSubState = BTL_SUBSTATE_NORMAL_START_UNK_8; break; } @@ -488,9 +488,9 @@ void btl_state_update_normal_start(void) { D_80280A30 = 0; } break; - case BATTLE_SUB_STATE_UNK_8: + case BTL_SUBSTATE_NORMAL_START_UNK_8: if (battleStatus->unk_8C == 0) { - set_screen_overlay_params_front(0xFF, -1.0f); + set_screen_overlay_params_front(255, -1.0f); btl_set_state(BATTLE_STATE_BEGIN_TURN); } break; @@ -525,7 +525,7 @@ void btl_state_update_begin_turn(void) { s32 j; s16* enemyIDs; - if (gBattleSubState == 0) { + if (gBattleSubState == BTL_SUBSTATE_BEGIN_TURN_INIT) { battleStatus->flags2 &= ~BS_FLAGS2_2; battleStatus->flags2 &= ~BS_FLAGS2_4; battleStatus->flags2 &= ~BS_FLAGS2_8; @@ -533,15 +533,16 @@ void btl_state_update_begin_turn(void) { battleStatus->merleeAttackBoost = 0; battleStatus->merleeDefenseBoost = 0; battleStatus->flags2 &= ~BS_FLAGS2_1000000; - player->disableDismissTimer = 0; + player->flags |= ACTOR_FLAG_8000000 | ACTOR_FLAG_4000000; + player->disableDismissTimer = 0; if (partner != NULL) { player->flags |= ACTOR_FLAG_8000000 | ACTOR_FLAG_4000000; partner->disableDismissTimer = 0; } if (battleStatus->hustleTurns != 0) { - gBattleStatus.flags1 |= BS_FLAGS1_HUSTLE_DRINK_ON; + gBattleStatus.flags1 |= BS_FLAGS1_HUSTLED; } numEnemyActors = 0; @@ -552,8 +553,9 @@ void btl_state_update_begin_turn(void) { numEnemyActors++; } } - battleStatus->numEnemyActors = numEnemyActors; + + // sort enemies by x-position or turn priority enemyIDs = battleStatus->enemyIDs; for (i = 0; i < numEnemyActors - 1; i++) { for (j = i + 1; j < numEnemyActors; j++) { @@ -572,84 +574,85 @@ void btl_state_update_begin_turn(void) { } } } - battleStatus->nextEnemyIndex = 0; - btl_merlee_on_start_turn(); - battleStatus->rushFlags = RUSH_FLAG_NONE; - gBattleStatus.flags2 &= ~BS_FLAGS2_8000000; - if (!(gBattleStatus.flags2 & BS_FLAGS2_40)) { + btl_merlee_on_start_turn(); + + battleStatus->rushFlags = RUSH_FLAG_NONE; + gBattleStatus.flags2 &= ~BS_FLAGS2_HAS_RUSH; + + if (!(gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE)) { if (playerData->curHP < 2 && is_ability_active(ABILITY_MEGA_RUSH)) { - gBattleStatus.flags2 |= BS_FLAGS2_8000000; + gBattleStatus.flags2 |= BS_FLAGS2_HAS_RUSH; battleStatus->rushFlags |= RUSH_FLAG_MEGA; } if (playerData->curHP < 6 && is_ability_active(ABILITY_POWER_RUSH) && !(battleStatus->rushFlags & RUSH_FLAG_MEGA)) { - gBattleStatus.flags2 |= BS_FLAGS2_8000000; + gBattleStatus.flags2 |= BS_FLAGS2_HAS_RUSH; battleStatus->rushFlags |= RUSH_FLAG_POWER; } } - if (!(gBattleStatus.flags1 & BS_FLAGS1_20000000)) { + if (!(gBattleStatus.flags1 & BS_FLAGS1_JUMP_CHARGED)) { battleStatus->jumpCharge = 0; } - if (!(gBattleStatus.flags1 & BS_FLAGS1_10000000)) { + if (!(gBattleStatus.flags1 & BS_FLAGS1_HAMMER_CHARGED)) { battleStatus->hammerCharge = 0; } - if (gGameStatusPtr->debugEnemyContact == 4) { + if (gGameStatusPtr->debugEnemyContact == DEBUG_CONTACT_AUTO_FLEE) { btl_set_state(BATTLE_STATE_RUN_AWAY); return; } - if (gGameStatusPtr->debugEnemyContact == 3) { + if (gGameStatusPtr->debugEnemyContact == DEBUG_CONTACT_DIE_IN_BATTLE) { for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { enemy = battleStatus->enemyActors[i]; - if (enemy != NULL && enemy->onHitScriptSource != NULL) { - Evt* script = start_script(enemy->onHitScriptSource, 0xA, 0); + if (enemy != NULL && enemy->handleEventSource != NULL) { + Evt* script = start_script(enemy->handleEventSource, EVT_PRIORITY_A, 0); - enemy->onHitScript = script; + enemy->handleEventScript = script; script->owner1.actorID = i | ACTOR_ENEMY0; - enemy->onHitID = script->id; + enemy->handleEventScriptID = script->id; enemy->lastEventType = EVENT_DEATH; } } - gBattleSubState = BATTLE_SUB_STATE_PLAYER_DEFEATED; + gBattleSubState = BTL_SUBSTATE_BEGIN_TURN_AWAIT_ENEMY_DEATH; } else { for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { enemy = battleStatus->enemyActors[i]; - if (enemy != NULL && enemy->onTurnChanceScriptSource != NULL) { + if (enemy != NULL && enemy->handlePhaseSource != NULL) { battleStatus->battlePhase = PHASE_PLAYER_BEGIN; - script = start_script(enemy->onTurnChanceScriptSource, 0xA, 0); - enemy->onTurnChangeScript = script; - enemy->onTurnChangeID = script->id; + script = start_script(enemy->handlePhaseSource, EVT_PRIORITY_A, 0); + enemy->handlePhaseScript = script; + enemy->handleBatttlePhaseScriptID = script->id; script->owner1.actorID = i | ACTOR_ENEMY0; } } partner = battleStatus->partnerActor; if (partner != NULL) { - if (partner->onTurnChanceScriptSource != NULL) { + if (partner->handlePhaseSource != NULL) { battleStatus->battlePhase = PHASE_PLAYER_BEGIN; - script = start_script(partner->onTurnChanceScriptSource, 0xA, 0); - partner->onTurnChangeScript = script; - partner->onTurnChangeID = script->id; + script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0); + partner->handlePhaseScript = script; + partner->handleBatttlePhaseScriptID = script->id; script->owner1.actorID = ACTOR_PARTNER; } } - gBattleSubState = BATTLE_SUB_STATE_BEGIN_LEVEL_UP; + gBattleSubState = BTL_SUBSTATE_BEGIN_TURN_AWAIT_ENEMY_SCRIPTS; } } - if (gBattleSubState == BATTLE_SUB_STATE_BEGIN_LEVEL_UP) { + if (gBattleSubState == BTL_SUBSTATE_BEGIN_TURN_AWAIT_ENEMY_SCRIPTS) { cond = FALSE; for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { enemy = battleStatus->enemyActors[i]; - if (enemy != NULL && enemy->onTurnChanceScriptSource != NULL && does_script_exist(enemy->onTurnChangeID)) { + if (enemy != NULL && enemy->handlePhaseSource != NULL && does_script_exist(enemy->handleBatttlePhaseScriptID)) { cond = TRUE; } } - if (partner != NULL && partner->onTurnChanceScriptSource != NULL && does_script_exist(partner->onTurnChangeID)) { + if (partner != NULL && partner->handlePhaseSource != NULL && does_script_exist(partner->handleBatttlePhaseScriptID)) { cond = TRUE; } @@ -661,11 +664,11 @@ void btl_state_update_begin_turn(void) { } } - if (gBattleSubState == BATTLE_SUB_STATE_PLAYER_DEFEATED) { + if (gBattleSubState == BTL_SUBSTATE_BEGIN_TURN_AWAIT_ENEMY_DEATH) { cond = FALSE; for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { enemy = battleStatus->enemyActors[i]; - if (enemy != NULL && enemy->onHitScriptSource != NULL && does_script_exist(enemy->onHitID)) { + if (enemy != NULL && enemy->handleEventSource != NULL && does_script_exist(enemy->handleEventScriptID)) { cond = TRUE; } } @@ -694,78 +697,88 @@ void btl_state_update_begin_player_turn(void) { s32 koDuration; s32 temp; - if (gBattleSubState == BATTLE_SUB_STATE_UNK_0) { + if (gBattleSubState == BTL_SUBSTATE_BEGIN_PLAYER_TURN_INIT) { btl_cam_use_preset(BTL_CAM_PRESET_C); btl_cam_move(5); - gBattleSubState = BATTLE_SUB_STATE_UNK_64; - } - - if (gBattleSubState != BATTLE_SUB_STATE_UNK_14) { - if (gBattleSubState == BATTLE_SUB_STATE_UNK_64 && btl_cam_is_moving_done()) { - gBattleStatus.flags1 &= ~BS_FLAGS1_80000; - reset_actor_turn_info(); - battleStatus->unk_86 = 127; - battleStatus->blockResult = 127; - battleStatus->selectedMoveID = 0; - gBattleStatus.flags1 |= BS_FLAGS1_8; - gBattleStatus.flags2 &= ~BS_FLAGS2_1000000; - player->disableDismissTimer = 0; - player->flags |= ACTOR_FLAG_8000000 | ACTOR_FLAG_4000000; - - if (partner != NULL) { - player->flags |= ACTOR_FLAG_8000000 | ACTOR_FLAG_4000000; - partner->disableDismissTimer = 0; - } - - battleStatus->unk_8C = 0; - D_8029F254 = 0; - D_8029F258 = 0; - - if (battleStatus->outtaSightActive == 0) { - gBattleSubState = BATTLE_SUB_STATE_PLAYER_DEFEATED; - } else { - battleStatus->battlePhase = PHASE_ENEMY_BEGIN; - script = start_script(partner->onTurnChanceScriptSource, EVT_PRIORITY_A, 0); - partner->onTurnChangeScript = script; - gBattleSubState = BATTLE_SUB_STATE_UNK_14; - partner->onTurnChangeID = script->id; - script->owner1.actorID = ACTOR_PARTNER; - } - } - } else if (!does_script_exist(partner->onTurnChangeID)) { - battleStatus->outtaSightActive = 0; - gBattleSubState = BATTLE_SUB_STATE_PLAYER_DEFEATED; - gBattleStatus.flags2 |= BS_FLAGS2_4; - } - - if (gBattleSubState != BATTLE_SUB_STATE_UNK_2) { - if (gBattleSubState == BATTLE_SUB_STATE_PLAYER_DEFEATED && (battleStatus->unk_8C == 0)) { - if (battleStatus->waterBlockTurnsLeft != 0) { - battleStatus->waterBlockTurnsLeft--; - battleStatus->buffEffect->data.partnerBuff->unk_0C[FX_BUFF_DATA_WATER_BLOCK].turnsLeft = battleStatus->waterBlockTurnsLeft; - if (battleStatus->waterBlockTurnsLeft <= 0) { - battleStatus->waterBlockEffect->flags |= 0x10; - fx_water_block(1, player->currentPos.x, player->currentPos.y + 18.0f, player->currentPos.z + 5.0f, 1.5f, 10); - fx_water_splash(0, player->currentPos.x - 10.0f, player->currentPos.y + 5.0f, player->currentPos.z + 5.0f, 1.0f, 24); - fx_water_splash(0, player->currentPos.x - 15.0f, player->currentPos.y + 32.0f, player->currentPos.z + 5.0f, 1.0f, 24); - fx_water_splash(1, player->currentPos.x + 15.0f, player->currentPos.y + 22.0f, player->currentPos.z + 5.0f, 1.0f, 24); - battleStatus->waterBlockEffect = NULL; - sfx_play_sound(SOUND_299); - btl_show_battle_message(0x27, 60); - gBattleSubState = BATTLE_SUB_STATE_UNK_2; - } else { - gBattleSubState = BATTLE_SUB_STATE_UNK_B; - } - } else { - gBattleSubState = BATTLE_SUB_STATE_UNK_B; - } - } - } else if (!btl_is_popup_displayed()) { - gBattleSubState = BATTLE_SUB_STATE_UNK_B; + gBattleSubState = BTL_SUBSTATE_BEGIN_PLAYER_TURN_RESET_STATE; } switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_B: + case BTL_SUBSTATE_BEGIN_PLAYER_TURN_RESET_STATE: + if (btl_cam_is_moving_done()) { + gBattleStatus.flags1 &= ~BS_FLAGS1_80000; + reset_actor_turn_info(); + battleStatus->unk_86 = 127; + battleStatus->blockResult = 127; + battleStatus->selectedMoveID = 0; + gBattleStatus.flags1 |= BS_FLAGS1_8; + gBattleStatus.flags2 &= ~BS_FLAGS2_1000000; + player->disableDismissTimer = 0; + player->flags |= ACTOR_FLAG_8000000 | ACTOR_FLAG_4000000; + + if (partner != NULL) { + player->flags |= ACTOR_FLAG_8000000 | ACTOR_FLAG_4000000; + partner->disableDismissTimer = 0; + } + + battleStatus->unk_8C = 0; + D_8029F254 = 0; + D_8029F258 = 0; + + if (battleStatus->outtaSightActive == 0) { + gBattleSubState = BTL_SUBSTATE_BEGIN_PLAYER_TURN_CHECK_OUTTA_SIGHT; + } else { + battleStatus->battlePhase = PHASE_ENEMY_BEGIN; + script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0); + partner->handlePhaseScript = script; + gBattleSubState = BTL_SUBSTATE_BEGIN_PLAYER_TURN_AWAIT_PARTNER_SCRIPT; + partner->handleBatttlePhaseScriptID = script->id; + script->owner1.actorID = ACTOR_PARTNER; + } + } + break; + case BTL_SUBSTATE_BEGIN_PLAYER_TURN_AWAIT_PARTNER_SCRIPT: + if (!does_script_exist(partner->handleBatttlePhaseScriptID)) { + battleStatus->outtaSightActive = 0; + gBattleSubState = BTL_SUBSTATE_BEGIN_PLAYER_TURN_CHECK_OUTTA_SIGHT; + gBattleStatus.flags2 |= BS_FLAGS2_4; + } + break; + } + + switch (gBattleSubState) { + case BTL_SUBSTATE_BEGIN_PLAYER_TURN_CHECK_OUTTA_SIGHT: + if (battleStatus->unk_8C == 0) { + if (battleStatus->waterBlockTurnsLeft != 0) { + battleStatus->waterBlockTurnsLeft--; + battleStatus->buffEffect->data.partnerBuff->unk_0C[FX_BUFF_DATA_WATER_BLOCK].turnsLeft = battleStatus->waterBlockTurnsLeft; + if (battleStatus->waterBlockTurnsLeft <= 0) { + battleStatus->waterBlockEffect->flags |= EFFECT_INSTANCE_FLAGS_10; + fx_water_block(1, player->currentPos.x, player->currentPos.y + 18.0f, player->currentPos.z + 5.0f, 1.5f, 10); + fx_water_splash(0, player->currentPos.x - 10.0f, player->currentPos.y + 5.0f, player->currentPos.z + 5.0f, 1.0f, 24); + fx_water_splash(0, player->currentPos.x - 15.0f, player->currentPos.y + 32.0f, player->currentPos.z + 5.0f, 1.0f, 24); + fx_water_splash(1, player->currentPos.x + 15.0f, player->currentPos.y + 22.0f, player->currentPos.z + 5.0f, 1.0f, 24); + battleStatus->waterBlockEffect = NULL; + sfx_play_sound(SOUND_299); + btl_show_battle_message(BTL_MSG_27, 60); + gBattleSubState = BTL_SUBSTATE_BEGIN_PLAYER_TURN_AWAIT_OUTTA_SIGHT; + } else { + gBattleSubState = BTL_SUBSTATE_BEGIN_PLAYER_TURN_CHECK_CLOUD_NINE; + } + } else { + gBattleSubState = BTL_SUBSTATE_BEGIN_PLAYER_TURN_CHECK_CLOUD_NINE; + } + } + break; + case BTL_SUBSTATE_BEGIN_PLAYER_TURN_AWAIT_OUTTA_SIGHT: + if (!btl_is_popup_displayed()) { + gBattleSubState = BTL_SUBSTATE_BEGIN_PLAYER_TURN_CHECK_CLOUD_NINE; + } + break; + } + + switch (gBattleSubState) { + case BTL_SUBSTATE_BEGIN_PLAYER_TURN_CHECK_CLOUD_NINE: if (battleStatus->cloudNineTurnsLeft != 0) { battleStatus->cloudNineTurnsLeft--; battleStatus->buffEffect->data.partnerBuff->unk_0C[FX_BUFF_DATA_CLOUD_NINE].turnsLeft = battleStatus->cloudNineTurnsLeft; @@ -773,81 +786,83 @@ void btl_state_update_begin_player_turn(void) { if (battleStatus->cloudNineTurnsLeft <= 0) { remove_effect(battleStatus->cloudNineEffect); battleStatus->cloudNineEffect = NULL; - btl_show_battle_message(0x29, 60); - gBattleSubState = BATTLE_SUB_STATE_UNK_C; + btl_show_battle_message(BTL_MSG_29, 60); + gBattleSubState = BTL_SUBSTATE_BEGIN_PLAYER_TURN_AWAIT_CLOUD_NINE; } else { - gBattleSubState = BATTLE_SUB_STATE_UNK_F; + gBattleSubState = BTL_SUBSTATE_BEGIN_PLAYER_TURN_CHECK_TURBO_CHARGE; } } else { - gBattleSubState = BATTLE_SUB_STATE_UNK_F; + gBattleSubState = BTL_SUBSTATE_BEGIN_PLAYER_TURN_CHECK_TURBO_CHARGE; } break; - case BATTLE_SUB_STATE_UNK_C: + case BTL_SUBSTATE_BEGIN_PLAYER_TURN_AWAIT_CLOUD_NINE: if (!btl_is_popup_displayed()) { - gBattleSubState = BATTLE_SUB_STATE_UNK_F; + gBattleSubState = BTL_SUBSTATE_BEGIN_PLAYER_TURN_CHECK_TURBO_CHARGE; } break; } switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_F: + case BTL_SUBSTATE_BEGIN_PLAYER_TURN_CHECK_TURBO_CHARGE: if (battleStatus->turboChargeTurnsLeft != 0) { if (gBattleStatus.flags2 & BS_FLAGS2_100) { gBattleStatus.flags2 &= ~BS_FLAGS2_100; - gBattleSubState = BATTLE_SUB_STATE_UNK_15; + gBattleSubState = BTL_SUBSTATE_BEGIN_PLAYER_TURN_TRY_STATUS_DAMAGE; } else { battleStatus->turboChargeTurnsLeft--; battleStatus->buffEffect->data.partnerBuff->unk_0C[FX_BUFF_DATA_TURBO_CHARGE].turnsLeft = battleStatus->turboChargeTurnsLeft; if (battleStatus->turboChargeTurnsLeft <= 0) { - btl_show_battle_message(0x2B, 60); - gBattleSubState = BATTLE_SUB_STATE_UNK_10; + btl_show_battle_message(BTL_MSG_2B, 60); + gBattleSubState = BTL_SUBSTATE_BEGIN_PLAYER_TURN_AWAIT_TURBO_CHARGE; } else { - gBattleSubState = BATTLE_SUB_STATE_UNK_15; + gBattleSubState = BTL_SUBSTATE_BEGIN_PLAYER_TURN_TRY_STATUS_DAMAGE; } } } else { - gBattleSubState = BATTLE_SUB_STATE_UNK_15; + gBattleSubState = BTL_SUBSTATE_BEGIN_PLAYER_TURN_TRY_STATUS_DAMAGE; } break; - case BATTLE_SUB_STATE_UNK_10: + case BTL_SUBSTATE_BEGIN_PLAYER_TURN_AWAIT_TURBO_CHARGE: if (0) { // TODO relocated block - required to match back: player->koStatus = STATUS_DAZE; - player->disableEffect->data.disableX->unk_3C = player->koDuration; + player->disableEffect->data.disableX->koDuration = player->koDuration; goto later; } if (!btl_is_popup_displayed()) { - gBattleSubState = BATTLE_SUB_STATE_UNK_15; + gBattleSubState = BTL_SUBSTATE_BEGIN_PLAYER_TURN_TRY_STATUS_DAMAGE; } break; } - if (gBattleSubState == BATTLE_SUB_STATE_UNK_15) { + if (gBattleSubState == BTL_SUBSTATE_BEGIN_PLAYER_TURN_TRY_STATUS_DAMAGE) { if (player->debuff == STATUS_POISON && player->stoneStatus == 0) { gBattleStatus.flags1 |= BS_FLAGS1_SP_EVT_ACTIVE; - dispatch_damage_event_player_0(1, 0xA); + dispatch_damage_event_player_0(1, EVENT_HIT); } battleStatus->rushFlags = RUSH_FLAG_NONE; - gBattleStatus.flags2 &= ~BS_FLAGS2_8000000; - if (!(gBattleStatus.flags2 & BS_FLAGS2_40)) { + gBattleStatus.flags2 &= ~BS_FLAGS2_HAS_RUSH; + if (!(gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE)) { if (playerData->curHP <= 1 && is_ability_active(ABILITY_MEGA_RUSH)) { - gBattleStatus.flags2 |= BS_FLAGS2_8000000; + gBattleStatus.flags2 |= BS_FLAGS2_HAS_RUSH; battleStatus->rushFlags |= RUSH_FLAG_MEGA; } if (playerData->curHP < 6 && is_ability_active(ABILITY_POWER_RUSH) && !(battleStatus->rushFlags & RUSH_FLAG_MEGA)) { - gBattleStatus.flags2 |= BS_FLAGS2_8000000; + gBattleStatus.flags2 |= BS_FLAGS2_HAS_RUSH; battleStatus->rushFlags |= RUSH_FLAG_POWER; } } - gBattleSubState = BATTLE_SUB_STATE_UNK_16; + gBattleSubState = BTL_SUBSTATE_BEGIN_PLAYER_TURN_TRY_STATUS_RECOVER; } - if (gBattleSubState == BATTLE_SUB_STATE_UNK_16 && - (player->onHitScript == NULL || !does_script_exist(player->onHitID))) - { - player->onHitScript = NULL; - if (!btl_check_player_defeated()) { + if (gBattleSubState == BTL_SUBSTATE_BEGIN_PLAYER_TURN_TRY_STATUS_RECOVER) { + if (player->handleEventScript == NULL || !does_script_exist(player->handleEventScriptID)) { + player->handleEventScript = NULL; + if (btl_check_player_defeated()) { + return; + } + D_8029F254 = 0; player->disableDismissTimer = 0; player->flags |= ACTOR_FLAG_8000000 | ACTOR_FLAG_4000000; @@ -925,10 +940,10 @@ back: } else if (temp != debuffDuration) { player->koStatus = 0; player->koDuration = 0; - player->disableEffect->data.disableX->unk_3C = 0; + player->disableEffect->data.disableX->koDuration = 0; } } -later: + later: for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { Actor* enemy = battleStatus->enemyActors[i]; @@ -945,66 +960,68 @@ later: } } } - gBattleSubState = BATTLE_SUB_STATE_UNK_1; - } else { - return; + gBattleSubState = BTL_SUBSTATE_BEGIN_PLAYER_TURN_TRY_COMMAND_RECOVER; } } - if (gBattleSubState == BATTLE_SUB_STATE_UNK_1) { - if (!btl_check_enemies_defeated()) { - temp = 1; - battleStatus->unk_8C = 0; - if (battleStatus->hammerLossTurns >= 0) { - battleStatus->hammerLossTurns--; - if (battleStatus->hammerLossTurns == -1) { - script = start_script(&RegainAbility, EVT_PRIORITY_A, 0); - player->takeTurnScript = script; - player->takeTurnID = script->id; - script->varTable[0] = 1; - temp = 9; - script->owner1.actorID = ACTOR_PLAYER; - script->varTable[10] = 1; - battleStatus->unk_8C = 1; - } - } - - if (battleStatus->jumpLossTurns >= 0) { - battleStatus->jumpLossTurns--; - if (battleStatus->jumpLossTurns == -1) { - script = start_script(&RegainAbility, EVT_PRIORITY_A, 0); - player->takeTurnScript = script; - player->takeTurnID = script->id; - script->varTable[0] = temp; - script->owner1.actorID = ACTOR_PLAYER; - script->varTable[10] = 0; - battleStatus->unk_8C = 1; - temp += 8; - } - } - - if (battleStatus->itemLossTurns >= 0) { - battleStatus->itemLossTurns--; - if (battleStatus->itemLossTurns == -1) { - script = start_script(&RegainAbility, EVT_PRIORITY_A, 0); - player->takeTurnScript = script; - player->takeTurnID = script->id; - script->varTable[10] = 2; - script->owner1.actorID = ACTOR_PLAYER; - script->varTable[0] = temp; - battleStatus->unk_8C = 1; - } - } - gBattleSubState = BATTLE_SUB_STATE_UNK_1E; - } else { + if (gBattleSubState == BTL_SUBSTATE_BEGIN_PLAYER_TURN_TRY_COMMAND_RECOVER) { + if (btl_check_enemies_defeated()) { return; } + temp = 1; + battleStatus->unk_8C = 0; + if (battleStatus->hammerLossTurns >= 0) { + battleStatus->hammerLossTurns--; + if (battleStatus->hammerLossTurns == -1) { + script = start_script(&RegainAbility, EVT_PRIORITY_A, 0); + player->takeTurnScript = script; + player->takeTurnScriptID = script->id; + script->owner1.actorID = ACTOR_PLAYER; + script->varTable[0] = temp; + temp += 8; + script->varTable[10] = 1; // hammer + battleStatus->unk_8C = 1; + } + } + + if (battleStatus->jumpLossTurns >= 0) { + battleStatus->jumpLossTurns--; + if (battleStatus->jumpLossTurns == -1) { + script = start_script(&RegainAbility, EVT_PRIORITY_A, 0); + player->takeTurnScript = script; + player->takeTurnScriptID = script->id; + script->owner1.actorID = ACTOR_PLAYER; + script->varTable[0] = temp; + temp += 8; + script->varTable[10] = 0; // jump + battleStatus->unk_8C = 1; + } + } + + if (battleStatus->itemLossTurns >= 0) { + battleStatus->itemLossTurns--; + if (battleStatus->itemLossTurns == -1) { + script = start_script(&RegainAbility, EVT_PRIORITY_A, 0); + player->takeTurnScript = script; + player->takeTurnScriptID = script->id; + script->owner1.actorID = ACTOR_PLAYER; + script->varTable[0] = temp; + temp += 8; + script->varTable[10] = 2; // item + battleStatus->unk_8C = 1; + } + } + gBattleSubState = BTL_SUBSTATE_BEGIN_PLAYER_TURN_END_DELAY; } - if (gBattleSubState == BATTLE_SUB_STATE_UNK_1E && (player->onHitScript == NULL || !does_script_exist(player->onHitID))) { - player->onHitScript = NULL; + if (gBattleSubState == BTL_SUBSTATE_BEGIN_PLAYER_TURN_END_DELAY) { + if (player->handleEventScript == NULL || !does_script_exist(player->handleEventScriptID)) { + player->handleEventScript = NULL; + + if (btl_check_player_defeated() || btl_check_enemies_defeated()) { + return; + } - if (!btl_check_player_defeated() && !btl_check_enemies_defeated()) { if (D_8029F258 != 0) { D_8029F258--; return; @@ -1028,7 +1045,7 @@ void btl_state_update_switch_to_player(void) { Actor* partner = gBattleStatus.partnerActor; s32 i; - if (gBattleSubState == BATTLE_SUB_STATE_UNK_0) { + if (gBattleSubState == BTL_SUBSTATE_INIT) { gBattleStatus.flags1 &= ~BS_FLAGS1_80000; reset_actor_turn_info(); gBattleStatus.selectedMoveID = MOVE_NONE; @@ -1044,8 +1061,8 @@ void btl_state_update_switch_to_player(void) { Actor* enemy = gBattleStatus.enemyActors[i]; if (enemy != NULL) { - enemy->flags |= ENEMY_FLAGS_80000; - enemy->flags |= ENEMY_FLAGS_8000000; + enemy->flags |= ACTOR_FLAG_80000; + enemy->flags |= ACTOR_FLAG_8000000; } } @@ -1060,17 +1077,18 @@ void btl_state_update_begin_partner_turn(void) { BattleStatus* battleStatus = &gBattleStatus; Actor* partner = battleStatus->partnerActor; Actor* enemy; + Evt* script; s32 i; - if (gBattleSubState == BATTLE_SUB_STATE_UNK_0) { + if (gBattleSubState == BTL_SUBSTATE_BEGIN_PARTNER_TURN_INIT) { if (partner == NULL) { D_8029F254 = 1; - gBattleSubState = BATTLE_SUB_STATE_PLAYER_DEFEATED; + gBattleSubState = BTL_SUBSTATE_BEGIN_PARTNER_TURN_END_DELAY; } else if ((battleStatus->flags2 & (BS_FLAGS2_4 | BS_FLAGS2_2)) != (BS_FLAGS2_4 | BS_FLAGS2_2)) { if (!(partner->flags & ACTOR_FLAG_NO_ATTACK)) { btl_cam_use_preset(BTL_CAM_PRESET_C); btl_cam_move(5); - gBattleSubState = BATTLE_SUB_STATE_UNK_64; + gBattleSubState = BTL_SUBSTATE_BEGIN_PARTNER_TURN_RESET_STATE; } else { btl_set_state(BATTLE_STATE_9); return; @@ -1081,7 +1099,7 @@ void btl_state_update_begin_partner_turn(void) { } } - if (gBattleSubState == BATTLE_SUB_STATE_UNK_64) { + if (gBattleSubState == BTL_SUBSTATE_BEGIN_PARTNER_TURN_RESET_STATE) { if (btl_cam_is_moving_done()) { D_8029F258 = 0; reset_actor_turn_info(); @@ -1098,11 +1116,11 @@ void btl_state_update_begin_partner_turn(void) { D_8029F254 = 1; D_8029F258 = 20; if (partner->koDuration > 0) { - partner->disableEffect->data.disableX->unk_3C = partner->koDuration; + partner->disableEffect->data.disableX->koDuration = partner->koDuration; } else { partner->koStatus = 0; dispatch_event_partner(EVENT_RECOVER_PARTNER); - partner->disableEffect->data.disableX->unk_3C = 0; + partner->disableEffect->data.disableX->koDuration = 0; gBattleStatus.flags2 |= BS_FLAGS2_8; } } @@ -1113,14 +1131,14 @@ void btl_state_update_begin_partner_turn(void) { enemy->flags |= ACTOR_FLAG_8000000 | ACTOR_FLAG_4000000; } } - gBattleSubState = BATTLE_SUB_STATE_UNK_1; + gBattleSubState = BTL_SUBSTATE_BEGIN_PARTNER_TURN_AWAIT_RECOVER_DONE; } } - if (gBattleSubState == BATTLE_SUB_STATE_UNK_1) { + if (gBattleSubState == BTL_SUBSTATE_BEGIN_PARTNER_TURN_AWAIT_RECOVER_DONE) { if (partner != NULL) { - if (partner->onHitScript == NULL || !does_script_exist(partner->onHitID)) { - partner->onHitScript = NULL; + if (partner->handleEventScript == NULL || !does_script_exist(partner->handleEventScriptID)) { + partner->handleEventScript = NULL; } else { goto block_27; // TODO find a way to remove } @@ -1130,30 +1148,28 @@ void btl_state_update_begin_partner_turn(void) { if (btl_check_player_defeated() || btl_check_enemies_defeated()) { return; } - gBattleSubState = BATTLE_SUB_STATE_UNK_8; + gBattleSubState = BTL_SUBSTATE_BEGIN_PARTNER_TURN_EXEC_TURN_SCRIPT; } block_27: - if (gBattleSubState == BATTLE_SUB_STATE_UNK_8) { - if (partner->onTurnChanceScriptSource != NULL) { - Evt* script; - + if (gBattleSubState == BTL_SUBSTATE_BEGIN_PARTNER_TURN_EXEC_TURN_SCRIPT) { + if (partner->handlePhaseSource != NULL) { battleStatus->battlePhase = PHASE_ENEMY_BEGIN; - script = start_script(partner->onTurnChanceScriptSource, EVT_PRIORITY_A, 0); - partner->onTurnChangeScript = script; - partner->onTurnChangeID = script->id; + script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0); + partner->handlePhaseScript = script; + partner->handleBatttlePhaseScriptID = script->id; script->owner1.actorID = ACTOR_PARTNER; } - gBattleSubState = BATTLE_SUB_STATE_UNK_9; + gBattleSubState = BTL_SUBSTATE_BEGIN_PARTNER_TURN_AWAIT_TURN_SCRIPT; } - if (gBattleSubState == BATTLE_SUB_STATE_UNK_9 && - (partner->onTurnChanceScriptSource == NULL || !does_script_exist(partner->onTurnChangeID))) - { - gBattleSubState = BATTLE_SUB_STATE_PLAYER_DEFEATED; + if (gBattleSubState == BTL_SUBSTATE_BEGIN_PARTNER_TURN_AWAIT_TURN_SCRIPT) { + if (partner->handlePhaseSource == NULL || !does_script_exist(partner->handleBatttlePhaseScriptID)) { + gBattleSubState = BTL_SUBSTATE_BEGIN_PARTNER_TURN_END_DELAY; + } } - if (gBattleSubState == BATTLE_SUB_STATE_PLAYER_DEFEATED) { + if (gBattleSubState == BTL_SUBSTATE_BEGIN_PARTNER_TURN_END_DELAY) { if (D_8029F258 != 0) { D_8029F258--; return; @@ -1176,7 +1192,7 @@ void btl_state_update_switch_to_partner(void) { Actor* partner = gBattleStatus.partnerActor; s32 i; - if (gBattleSubState == BATTLE_SUB_STATE_UNK_0) { + if (gBattleSubState == BTL_SUBSTATE_INIT) { reset_actor_turn_info(); gBattleStatus.flags1 |= BS_FLAGS1_80000; gBattleStatus.selectedMoveID = MOVE_NONE; @@ -1189,8 +1205,8 @@ void btl_state_update_switch_to_partner(void) { for (i = 0; i < ARRAY_COUNT(gBattleStatus.enemyActors); i++) { Actor* enemy = gBattleStatus.enemyActors[i]; if (enemy != NULL) { - enemy->flags |= ENEMY_FLAGS_80000; - enemy->flags |= ENEMY_FLAGS_8000000; + enemy->flags |= ACTOR_FLAG_80000; + enemy->flags |= ACTOR_FLAG_8000000; } } @@ -1201,7 +1217,7 @@ void btl_state_update_switch_to_partner(void) { void btl_state_draw_switch_to_partner(void) { } -void func_80242FE0(void) { +void btl_state_update_9(void) { BattleStatus* battleStatus = &gBattleStatus; Actor* player = battleStatus->playerActor; Actor* partner = battleStatus->partnerActor; @@ -1213,7 +1229,7 @@ void func_80242FE0(void) { s32 oldKoDuration; - if (gBattleSubState == BATTLE_SUB_STATE_5_0) { + if (gBattleSubState == BTL_SUBSTATE_9_INIT) { if (gBattleStatus.flags2 & BS_FLAGS2_2) { if (partner != NULL) { if (!(gBattleStatus.flags2 & BS_FLAGS2_4) && !(partner->flags & ACTOR_FLAG_NO_ATTACK)) { @@ -1229,7 +1245,7 @@ void func_80242FE0(void) { partner->flags |= ACTOR_FLAG_4000000; } - gBattleSubState = BATTLE_SUB_STATE_5_1; + gBattleSubState = BTL_SUBSTATE_9_1; D_8029F258 = 0; gBattleStatus.flags2 &= ~BS_FLAGS2_2; gBattleStatus.flags2 &= ~BS_FLAGS2_4; @@ -1241,15 +1257,15 @@ void func_80242FE0(void) { } } - if (gBattleSubState == BATTLE_SUB_STATE_5_1) { + if (gBattleSubState == BTL_SUBSTATE_9_1) { cond = FALSE; for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { actor = battleStatus->enemyActors[i]; - if (actor != NULL && actor->onHitScript != NULL) { - if (does_script_exist(actor->onHitID)) { + if (actor != NULL && actor->handleEventScript != NULL) { + if (does_script_exist(actor->handleEventScriptID)) { cond = TRUE; } else { - actor->onHitScript = NULL; + actor->handleEventScript = NULL; } } } @@ -1312,10 +1328,10 @@ void func_80242FE0(void) { actor->koDuration = actor->debuffDuration; if (actor->koDuration > 0) { actor->koStatus = STATUS_DAZE; - actor->disableEffect->data.disableX->unk_3C = actor->koDuration; + actor->disableEffect->data.disableX->koDuration = actor->koDuration; } else if (oldKoDuration != actor->koDuration) { actor->koStatus = 0; - actor->disableEffect->data.disableX->unk_3C = 0; + actor->disableEffect->data.disableX->koDuration = 0; } if (actor->debuff == STATUS_POISON) { gBattleStatus.flags1 |= BS_FLAGS1_SP_EVT_ACTIVE; @@ -1324,69 +1340,71 @@ void func_80242FE0(void) { } } } - gBattleSubState = BATTLE_SUB_STATE_5_2; + gBattleSubState = BTL_SUBSTATE_9_2; } } - if (gBattleSubState == BATTLE_SUB_STATE_5_2 && (player->onHitScript == NULL || !does_script_exist(player->onHitID))) { - player->onHitScript = NULL; - if (partner != NULL) { - if (partner->onHitScript == NULL || !does_script_exist(partner->onHitID)) { - partner->onHitScript = NULL; - goto block_52; // TODO find a way to remove - } - } else { -block_52: - cond = FALSE; - for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { - actor = battleStatus->enemyActors[i]; - if ((actor != NULL) && (actor->onHitScript != NULL)) { - if (does_script_exist(actor->onHitID)) { - cond = TRUE; - } else { - actor->onHitScript = NULL; + if (gBattleSubState == BTL_SUBSTATE_9_2) { + if(player->handleEventScript == NULL || !does_script_exist(player->handleEventScriptID)) { + player->handleEventScript = NULL; + if (partner != NULL) { + if (partner->handleEventScript == NULL || !does_script_exist(partner->handleEventScriptID)) { + partner->handleEventScript = NULL; + goto block_52; // TODO find a way to remove + } + } else { + block_52: + cond = FALSE; + for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { + actor = battleStatus->enemyActors[i]; + if ((actor != NULL) && (actor->handleEventScript != NULL)) { + if (does_script_exist(actor->handleEventScriptID)) { + cond = TRUE; + } else { + actor->handleEventScript = NULL; + } } } - } - if (!cond) { - if (btl_check_player_defeated() || btl_check_enemies_defeated()) { - return; - } - - btl_cam_use_preset(BTL_CAM_PRESET_C); - if (partner == NULL || !(gBattleStatus.flags1 & BS_FLAGS1_100000)) { - gBattleSubState = BATTLE_SUB_STATE_5_4; - } else if (gBattleStatus.flags2 & BS_FLAGS2_40) { - gBattleSubState = BATTLE_SUB_STATE_5_4; - } else { - player->flags &= ~ACTOR_FLAG_8000000; - partner->flags &= ~ACTOR_FLAG_8000000; - player->flags |= ACTOR_FLAG_4000000; - partner->flags |= ACTOR_FLAG_4000000; - state = &partner->state; - if (!battleStatus->outtaSightActive) { - partner->state.currentPos.x = partner->homePos.x; - partner->state.currentPos.z = partner->homePos.z; - partner->state.goalPos.x = player->homePos.x; - partner->state.goalPos.z = player->homePos.z; - } else { - partner->state.currentPos.x = partner->homePos.x; - partner->state.currentPos.z = partner->homePos.z; - partner->state.goalPos.x = partner->homePos.x; - partner->state.goalPos.z = partner->homePos.z + 5.0f; - partner->homePos.x = player->homePos.x; - partner->homePos.z = player->homePos.z; + if (!cond) { + if (btl_check_player_defeated() || btl_check_enemies_defeated()) { + return; + } + + btl_cam_use_preset(BTL_CAM_PRESET_C); + if (partner == NULL || !(gBattleStatus.flags1 & BS_FLAGS1_100000)) { + gBattleSubState = BTL_SUBSTATE_9_4; + } else if (gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) { + gBattleSubState = BTL_SUBSTATE_9_4; + } else { + player->flags &= ~ACTOR_FLAG_8000000; + partner->flags &= ~ACTOR_FLAG_8000000; + player->flags |= ACTOR_FLAG_4000000; + partner->flags |= ACTOR_FLAG_4000000; + state = &partner->state; + if (!battleStatus->outtaSightActive) { + partner->state.currentPos.x = partner->homePos.x; + partner->state.currentPos.z = partner->homePos.z; + partner->state.goalPos.x = player->homePos.x; + partner->state.goalPos.z = player->homePos.z; + } else { + partner->state.currentPos.x = partner->homePos.x; + partner->state.currentPos.z = partner->homePos.z; + partner->state.goalPos.x = partner->homePos.x; + partner->state.goalPos.z = partner->homePos.z + 5.0f; + partner->homePos.x = player->homePos.x; + partner->homePos.z = player->homePos.z; + } + state->moveTime = 4; + state->angle = 0.0f; + gBattleSubState = BTL_SUBSTATE_9_3; } - state->moveTime = 4; - state->angle = 0.0f; - gBattleSubState = BATTLE_SUB_STATE_5_3; } } } } - if (gBattleSubState == BATTLE_SUB_STATE_5_3) { + if (gBattleSubState == BTL_SUBSTATE_9_3) { if (partner->state.moveTime != 0) { partner->currentPos.x += (partner->state.goalPos.x - partner->currentPos.x) / partner->state.moveTime; partner->currentPos.z += (partner->state.goalPos.z - partner->currentPos.z) / partner->state.moveTime; @@ -1415,12 +1433,12 @@ block_52: player->homePos.x = player->currentPos.x; player->homePos.z = player->currentPos.z; } - gBattleSubState = BATTLE_SUB_STATE_5_4; + gBattleSubState = BTL_SUBSTATE_9_4; gBattleStatus.flags1 &= ~ACTOR_FLAG_100000; } } - if (gBattleSubState == BATTLE_SUB_STATE_5_4) { + if (gBattleSubState == BTL_SUBSTATE_9_4) { if (D_8029F258 != 0) { D_8029F258--; } else { @@ -1430,7 +1448,7 @@ block_52: battleStatus->battlePhase = PHASE_MERLEE_DEFENSE_BONUS; script = start_script(&PlayerScriptDispatcher, EVT_PRIORITY_A, 0); player->takeTurnScript = script; - player->takeTurnID = script->id; + player->takeTurnScriptID = script->id; script->owner1.actorID = ACTOR_PLAYER; } gBattleStatus.flags1 &= ~BS_FLAGS1_2; @@ -1440,7 +1458,7 @@ block_52: partner->flags &= ~ACTOR_FLAG_8000000; partner->flags |= ACTOR_FLAG_4000000; } - gBattleSubState = BATTLE_SUB_STATE_5_5; + gBattleSubState = BTL_SUBSTATE_9_5; gBattleStatus.flags2 &= ~BS_FLAGS2_2; gBattleStatus.flags2 &= ~BS_FLAGS2_4; gBattleStatus.flags2 &= ~BS_FLAGS2_8; @@ -1448,38 +1466,38 @@ block_52: } } - if (gBattleSubState == BATTLE_SUB_STATE_5_5) { - if (player->takeTurnScript == NULL || (does_script_exist(player->takeTurnID) == 0)) { + if (gBattleSubState == BTL_SUBSTATE_9_5) { + if (player->takeTurnScript == NULL || (does_script_exist(player->takeTurnScriptID) == 0)) { player->takeTurnScript = NULL; for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { actor = battleStatus->enemyActors[i]; - if (actor != NULL && actor->onTurnChanceScriptSource != NULL) { + if (actor != NULL && actor->handlePhaseSource != NULL) { battleStatus->battlePhase = PHASE_PLAYER_END; - script = start_script(actor->onTurnChanceScriptSource, EVT_PRIORITY_A, 0); - actor->onTurnChangeScript = script; - actor->onTurnChangeID = script->id; + script = start_script(actor->handlePhaseSource, EVT_PRIORITY_A, 0); + actor->handlePhaseScript = script; + actor->handleBatttlePhaseScriptID = script->id; script->owner1.enemyID = i | ACTOR_CLASS_ENEMY; } } - gBattleSubState = BATTLE_SUB_STATE_5_6; + gBattleSubState = BTL_SUBSTATE_9_6; } } cond = FALSE; - if (gBattleSubState == BATTLE_SUB_STATE_5_6) { + if (gBattleSubState == BTL_SUBSTATE_9_6) { for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { actor = battleStatus->enemyActors[i]; - if (actor != NULL && actor->onTurnChanceScriptSource != NULL && does_script_exist(actor->onTurnChangeID)) { + if (actor != NULL && actor->handlePhaseSource != NULL && does_script_exist(actor->handleBatttlePhaseScriptID)) { cond = TRUE; } } if (!cond) { - gBattleSubState = BATTLE_SUB_STATE_5_7; + gBattleSubState = BTL_SUBSTATE_9_7; } } - if (gBattleSubState == BATTLE_SUB_STATE_5_7) { + if (gBattleSubState == BTL_SUBSTATE_9_7) { btl_set_state(BATTLE_STATE_NEXT_ENEMY); } } @@ -1506,9 +1524,9 @@ void btl_state_update_prepare_menu(void) { if (battleStatus->flags1 & BS_FLAGS1_80000) { btl_set_state(BATTLE_STATE_PARTNER_MENU); - } else if (gBattleSubState == BATTLE_SUB_STATE_UNK_46) { + } else if (gBattleSubState == BATTLE_SUBSTATE_PREPARE_MENU_UNK_70) { btl_set_state(BATTLE_STATE_PLAYER_MENU); - gBattleSubState = BATTLE_SUB_STATE_UNK_46; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_UNUSED_1; } else { btl_set_state(BATTLE_STATE_PLAYER_MENU); } @@ -1526,18 +1544,18 @@ void btl_state_update_end_turn(void) { Evt* script; s32 i; - if (gBattleSubState == BATTLE_SUB_STATE_UNK_0) { + if (gBattleSubState == BTL_SUBSTATE_END_TURN_INIT) { s32 cond = FALSE; for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { actor = battleStatus->enemyActors[i]; - if (actor != NULL && actor->onHitScript != NULL) { - if (does_script_exist(actor->onHitID)) { + if (actor != NULL && actor->handleEventScript != NULL) { + if (does_script_exist(actor->handleEventScriptID)) { do { cond = TRUE; } while (0); // TODO required to match } else { - actor->onHitScript = NULL; + actor->handleEventScript = NULL; } } } @@ -1546,7 +1564,7 @@ void btl_state_update_end_turn(void) { for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { actor = battleStatus->enemyActors[i]; if (actor != NULL && actor->takeTurnScript != NULL) { - if (does_script_exist(actor->takeTurnID)) { + if (does_script_exist(actor->takeTurnScriptID)) { cond = TRUE; } else { actor->takeTurnScript = NULL; @@ -1556,16 +1574,16 @@ void btl_state_update_end_turn(void) { if (!cond) { btl_cam_use_preset(BTL_CAM_PRESET_C); - gBattleSubState = BATTLE_SUB_STATE_UNK_1; + gBattleSubState = BTL_SUBSTATE_END_TURN_CHECK_FOR_SWAP; } } } - if (gBattleSubState == BATTLE_SUB_STATE_UNK_1) { - if (gBattleStatus.flags2 & BS_FLAGS2_40) { - gBattleSubState = BATTLE_SUB_STATE_UNK_C; + if (gBattleSubState == BTL_SUBSTATE_END_TURN_CHECK_FOR_SWAP) { + if (gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) { + gBattleSubState = BTL_SUBSTATE_END_TURN_START_SCRIPTS; } else if (!(gBattleStatus.flags1 & BS_FLAGS1_100000)) { - gBattleSubState = BATTLE_SUB_STATE_UNK_C; + gBattleSubState = BTL_SUBSTATE_END_TURN_START_SCRIPTS; } else { player->flags &= ~ACTOR_FLAG_8000000; partner->flags &= ~ACTOR_FLAG_8000000; @@ -1577,11 +1595,11 @@ void btl_state_update_end_turn(void) { partner->state.goalPos.z = player->homePos.z; partner->state.moveTime = 4; partner->state.angle = 0.0f; - gBattleSubState = BATTLE_SUB_STATE_UNK_B; + gBattleSubState = BTL_SUBSTATE_END_TURN_PERFORM_SWAP; } } - if (gBattleSubState == BATTLE_SUB_STATE_UNK_B) { + if (gBattleSubState == BTL_SUBSTATE_END_TURN_PERFORM_SWAP) { if (partner->state.moveTime != 0) { partner->currentPos.x += (partner->state.goalPos.x - partner->currentPos.x) / partner->state.moveTime; partner->currentPos.z += (partner->state.goalPos.z - partner->currentPos.z) / partner->state.moveTime; @@ -1606,16 +1624,16 @@ void btl_state_update_end_turn(void) { player->homePos.z = player->currentPos.z; player->flags |= ACTOR_FLAG_8000000; partner->flags |= ACTOR_FLAG_8000000; - if (gBattleStatus.flags2 & BS_FLAGS2_40) { + if (gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) { gBattleStatus.flags1 |= BS_FLAGS1_100000; } else { gBattleStatus.flags1 &= ~BS_FLAGS1_100000; } - gBattleSubState = BATTLE_SUB_STATE_UNK_C; + gBattleSubState = BTL_SUBSTATE_END_TURN_START_SCRIPTS; } } - if (gBattleSubState == BATTLE_SUB_STATE_UNK_C) { + if (gBattleSubState == BTL_SUBSTATE_END_TURN_START_SCRIPTS) { gBattleStatus.flags2 &= ~BS_FLAGS2_10000; player->disableDismissTimer = 0; player->flags |= ACTOR_FLAG_8000000 | ACTOR_FLAG_4000000; @@ -1633,49 +1651,51 @@ void btl_state_update_end_turn(void) { for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { actor = battleStatus->enemyActors[i]; - if (actor != NULL && actor->onTurnChanceScriptSource != NULL) { + if (actor != NULL && actor->handlePhaseSource != NULL) { battleStatus->battlePhase = PHASE_ENEMY_END; - script = start_script(actor->onTurnChanceScriptSource, 0xA, 0); - actor->onTurnChangeScript = script; - actor->onTurnChangeID = script->id; + script = start_script(actor->handlePhaseSource, EVT_PRIORITY_A, 0); + actor->handlePhaseScript = script; + actor->handleBatttlePhaseScriptID = script->id; script->owner1.enemyID = i | ACTOR_ENEMY0; } } - if (partner != NULL && partner->onTurnChanceScriptSource != NULL) { + if (partner != NULL && partner->handlePhaseSource != NULL) { battleStatus->battlePhase = PHASE_ENEMY_END; - script = start_script(partner->onTurnChanceScriptSource, 0xA, 0); - partner->onTurnChangeScript = script; - partner->onTurnChangeID = script->id; + script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0); + partner->handlePhaseScript = script; + partner->handleBatttlePhaseScriptID = script->id; script->owner1.actorID = ACTOR_PARTNER; } - gBattleSubState = BATTLE_SUB_STATE_UNK_2; + gBattleSubState = BTL_SUBSTATE_END_TURN_AWAIT_SCRIPTS; } - if (gBattleSubState == BATTLE_SUB_STATE_UNK_2) { + // wait for all end turn scripts to finish executing + if (gBattleSubState == BTL_SUBSTATE_END_TURN_AWAIT_SCRIPTS) { s32 cond = FALSE; for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { actor = battleStatus->enemyActors[i]; - if (actor != NULL && actor->onTurnChanceScriptSource != NULL && does_script_exist(actor->onTurnChangeID)) { + if (actor != NULL && actor->handlePhaseSource != NULL && does_script_exist(actor->handleBatttlePhaseScriptID)) { cond = TRUE; } } - if (partner != NULL && partner->onTurnChanceScriptSource != NULL && does_script_exist(partner->onTurnChangeID)) { + if (partner != NULL && partner->handlePhaseSource != NULL && does_script_exist(partner->handleBatttlePhaseScriptID)) { cond = TRUE; } if (!cond) { btl_cam_use_preset(BTL_CAM_PRESET_C); - gBattleSubState = BATTLE_SUB_STATE_UNK_3; + gBattleSubState = BTL_SUBSTATE_END_TURN_BEGIN_NEXT; } } + // proceed to next to switch (gBattleSubState) { - case 3: - case 4: - btl_set_state(5); + case BTL_SUBSTATE_END_TURN_BEGIN_NEXT: + case BTL_SUBSTATE_END_TURN_UNK_4: + btl_set_state(BATTLE_STATE_BEGIN_TURN); break; } } @@ -1700,7 +1720,7 @@ void btl_state_update_victory(void) { Evt* script; switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_0: + case BTL_SUBSTATE_VICTORY_UNK_0: player->flags &= ~(ACTOR_FLAG_8000000 | ACTOR_FLAG_4000000); if (partner != NULL) { partner->flags &= ~(ACTOR_FLAG_8000000 | ACTOR_FLAG_4000000); @@ -1708,35 +1728,35 @@ void btl_state_update_victory(void) { battleStatus->unk_8C = 0; if (battleStatus->outtaSightActive == 0) { - gBattleSubState = BATTLE_SUB_STATE_BEGIN_LEVEL_UP; + gBattleSubState = BTL_SUBSTATE_VICTORY_UNK_5; } else { if (battleStatus->outtaSightActive > 0) { D_8029F254 = 1; } battleStatus->battlePhase = PHASE_ENEMY_BEGIN; - script = start_script(partner->onTurnChanceScriptSource, EVT_PRIORITY_A, 0); - partner->onTurnChangeScript = script; - partner->onTurnChangeID = script->id; + script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0); + partner->handlePhaseScript = script; + partner->handleBatttlePhaseScriptID = script->id; script->owner1.actorID = ACTOR_PARTNER; - gBattleSubState = BATTLE_SUB_STATE_UNK_1; + gBattleSubState = BTL_SUBSTATE_VICTORY_UNK_1; } break; - case BATTLE_SUB_STATE_UNK_1: - if (!does_script_exist(partner->onTurnChangeID)) { + case BTL_SUBSTATE_VICTORY_UNK_1: + if (!does_script_exist(partner->handleBatttlePhaseScriptID)) { battleStatus->outtaSightActive = 0; - gBattleSubState = BATTLE_SUB_STATE_BEGIN_LEVEL_UP; + gBattleSubState = BTL_SUBSTATE_VICTORY_UNK_5; } break; } switch (gBattleSubState) { - case BATTLE_SUB_STATE_BEGIN_LEVEL_UP: + case BTL_SUBSTATE_VICTORY_UNK_5: player->flags &= ~(ACTOR_FLAG_8000000 | ACTOR_FLAG_4000000); if (partner != NULL) { partner->flags &= ~(ACTOR_FLAG_8000000 | ACTOR_FLAG_4000000); } - gBattleSubState = BATTLE_SUB_STATE_UNK_B; + gBattleSubState = BTL_SUBSTATE_VICTORY_UNK_B; gBattleStatus.flags2 &= ~BS_FLAGS2_2; gBattleStatus.flags2 &= ~BS_FLAGS2_4; gBattleStatus.flags2 &= ~BS_FLAGS2_8; @@ -1745,7 +1765,7 @@ void btl_state_update_victory(void) { gBattleStatus.flags1 &= ~BS_FLAGS1_8; if (player->koStatus == STATUS_DAZE) { dispatch_event_player(EVENT_RECOVER_PARTNER); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_DEFEATED; + gBattleSubState = BTL_SUBSTATE_VICTORY_UNK_A; } player->debuff = 0; player->staticStatus = 0; @@ -1753,12 +1773,12 @@ void btl_state_update_victory(void) { player->transparentStatus = 0; player->koStatus = 0; player->koDuration = 0; - player->disableEffect->data.disableX->unk_3C = 0; + player->disableEffect->data.disableX->koDuration = 0; if (partner != NULL) { if (partner->koStatus == STATUS_DAZE) { dispatch_event_partner(EVENT_RECOVER_PARTNER); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_DEFEATED; + gBattleSubState = BTL_SUBSTATE_VICTORY_UNK_A; } partner->debuff = 0; partner->staticStatus = 0; @@ -1766,27 +1786,27 @@ void btl_state_update_victory(void) { partner->transparentStatus = 0; partner->koStatus = 0; partner->koDuration = 0; - partner->disableEffect->data.disableX->unk_3C = 0; + partner->disableEffect->data.disableX->koDuration = 0; } break; - case BATTLE_SUB_STATE_PLAYER_DEFEATED: - if (player->onHitScript == NULL || !does_script_exist(player->onHitID)) { - player->onHitScript = NULL; + case BTL_SUBSTATE_VICTORY_UNK_A: + if (player->handleEventScript == NULL || !does_script_exist(player->handleEventScriptID)) { + player->handleEventScript = NULL; if (partner != NULL) { - if (partner->onHitScript == NULL || !does_script_exist(partner->onHitID)) { - partner->onHitScript = NULL; + if (partner->handleEventScript == NULL || !does_script_exist(partner->handleEventScriptID)) { + partner->handleEventScript = NULL; } else { break; } } - gBattleSubState = BATTLE_SUB_STATE_UNK_B; + gBattleSubState = BTL_SUBSTATE_VICTORY_UNK_B; } break; } - if (gBattleSubState == BATTLE_SUB_STATE_UNK_B) { + if (gBattleSubState == BTL_SUBSTATE_VICTORY_UNK_B) { if (partner == NULL || !(gBattleStatus.flags1 & BS_FLAGS1_100000)) { - gBattleSubState = BATTLE_SUB_STATE_UNK_2; + gBattleSubState = BTL_SUBSTATE_VICTORY_UNK_2; } else { partner->state.currentPos.x = partner->currentPos.x; partner->state.currentPos.z = partner->currentPos.z; @@ -1794,11 +1814,11 @@ void btl_state_update_victory(void) { partner->state.goalPos.z = player->currentPos.z; partner->state.moveTime = 4; partner->state.angle = 0.0f; - gBattleSubState = BATTLE_SUB_STATE_UNK_C; + gBattleSubState = BTL_SUBSTATE_VICTORY_UNK_C; } } - if (gBattleSubState == BATTLE_SUB_STATE_UNK_C) { + if (gBattleSubState == BTL_SUBSTATE_VICTORY_UNK_C) { if (partner->state.moveTime != 0) { partner->currentPos.x += (partner->state.goalPos.x - partner->currentPos.x) / partner->state.moveTime; @@ -1826,67 +1846,69 @@ void btl_state_update_victory(void) { partner->homePos.z = partner->currentPos.z; player->homePos.x = player->currentPos.x; player->homePos.z = player->currentPos.z; - gBattleSubState = BATTLE_SUB_STATE_UNK_2; + gBattleSubState = BTL_SUBSTATE_VICTORY_UNK_2; gBattleStatus.flags1 &= ~BS_FLAGS1_100000; } } - if (gBattleSubState == BATTLE_SUB_STATE_UNK_2) { + if (gBattleSubState == BTL_SUBSTATE_VICTORY_UNK_2) { btl_cam_use_preset(BTL_CAM_PRESET_C); - if (battleStatus->nextMerleeSpellType == 3) { + if (battleStatus->nextMerleeSpellType == MERLEE_SPELL_3) { if (battleStatus->totalStarPoints == 0) { - battleStatus->nextMerleeSpellType = 0; + battleStatus->nextMerleeSpellType = MERLEE_SPELL_0; playerData->merleeTurnCount = 0; playerData->merleeCastsLeft++; } else { battleStatus->battlePhase = PHASE_MERLEE_EXP_BONUS; script = start_script(&PlayerScriptDispatcher, EVT_PRIORITY_A, 0); player->takeTurnScript = script; - player->takeTurnID = script->id; + player->takeTurnScriptID = script->id; script->owner1.actorID = ACTOR_PLAYER; } } - gBattleSubState = BATTLE_SUB_STATE_UNK_3; + gBattleSubState = BTL_SUBSTATE_VICTORY_UNK_3; D_8029F248 = 0; gBattleStatus.flags1 &= ~BS_FLAGS1_2; } - if (gBattleSubState == BATTLE_SUB_STATE_UNK_3) { + if (gBattleSubState == BTL_SUBSTATE_VICTORY_UNK_3) { if (D_8029F248 != 0) { D_8029F248--; - } else if (player->takeTurnScript == NULL || !does_script_exist(player->takeTurnID)) { + } else if (player->takeTurnScript == NULL || !does_script_exist(player->takeTurnScriptID)) { player->takeTurnScript = NULL; - if (battleStatus->nextMerleeSpellType != 3) { - gBattleSubState = BATTLE_SUB_STATE_UNK_4; + if (battleStatus->nextMerleeSpellType != MERLEE_SPELL_3) { + gBattleSubState = BTL_SUBSTATE_VICTORY_UNK_4; } else { - battleStatus->incrementStarPointDelay = 0x14; - battleStatus->nextMerleeSpellType = 0; - gBattleSubState = BATTLE_SUB_STATE_UNK_4; + battleStatus->incrementStarPointDelay = 20; + battleStatus->nextMerleeSpellType = MERLEE_SPELL_0; + gBattleSubState = BTL_SUBSTATE_VICTORY_UNK_4; battleStatus->pendingStarPoints = battleStatus->totalStarPoints + battleStatus->pendingStarPoints + battleStatus->pendingStarPoints; } } } - if (gBattleSubState == BATTLE_SUB_STATE_UNK_4 && battleStatus->pendingStarPoints <= 0) { - if (gBattleStatus.flags1 & BS_FLAGS1_STAR_POINTS_DROPPED) { - gBattleStatus.flags1 &= ~BS_FLAGS1_ENEMY_FLED; - } - if (playerData->battlesWon < 9999) { - playerData->battlesWon++; - } - if (gBattleStatus.flags1 & BS_FLAGS1_ENEMY_FLED) { - currentEncounter->battleOutcome = OUTCOME_ENEMY_FLED; - } else { - currentEncounter->battleOutcome = OUTCOME_PLAYER_WON; - } - if (gBattleStatus.flags1 & BS_FLAGS1_DISABLE_CELEBRATION) { - if (!(gBattleStatus.flags2 & BS_FLAGS2_2000000)) { - bgm_set_song(0, -1, 0, 1500, 8); + if (gBattleSubState == BTL_SUBSTATE_VICTORY_UNK_4) { + if (battleStatus->pendingStarPoints <= 0) { + if (gBattleStatus.flags1 & BS_FLAGS1_STAR_POINTS_DROPPED) { + gBattleStatus.flags1 &= ~BS_FLAGS1_ENEMY_FLED; + } + if (playerData->battlesWon < 9999) { + playerData->battlesWon++; + } + if (gBattleStatus.flags1 & BS_FLAGS1_ENEMY_FLED) { + currentEncounter->battleOutcome = OUTCOME_ENEMY_FLED; + } else { + currentEncounter->battleOutcome = OUTCOME_PLAYER_WON; + } + if (gBattleStatus.flags1 & BS_FLAGS1_DISABLE_CELEBRATION) { + if (!(gBattleStatus.flags2 & BS_FLAGS2_2000000)) { + bgm_set_song(0, -1, 0, 1500, 8); + } + btl_set_state(BATTLE_STATE_END_BATTLE); + } else { + btl_set_state(BATTLE_STATE_CELEBRATION); } - btl_set_state(BATTLE_STATE_END_BATTLE); - } else { - btl_set_state(BATTLE_STATE_CELEBRATION); } } } @@ -1902,12 +1924,12 @@ void btl_state_update_end_training_battle(void) { Actor* partner = gBattleStatus.partnerActor; switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_0: + case BTL_SUBSTATE_END_TRAINING_UNK_0: player->flags &= ~(ACTOR_FLAG_8000000 | ACTOR_FLAG_4000000); if (partner != NULL) { partner->flags &= ~(ACTOR_FLAG_8000000 | ACTOR_FLAG_4000000); } - gBattleSubState = 0xB; + gBattleSubState = BTL_SUBSTATE_END_TRAINING_UNK_B; gBattleStatus.flags2 &= ~BS_FLAGS2_2; gBattleStatus.flags2 &= ~BS_FLAGS2_4; gBattleStatus.flags2 &= ~BS_FLAGS2_8; @@ -1915,7 +1937,7 @@ void btl_state_update_end_training_battle(void) { if (player->koStatus == STATUS_DAZE) { dispatch_event_player(EVENT_RECOVER_PARTNER); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_DEFEATED; + gBattleSubState = BTL_SUBSTATE_END_TRAINING_UNK_A; } player->debuff = 0; player->staticStatus = 0; @@ -1923,11 +1945,11 @@ void btl_state_update_end_training_battle(void) { player->transparentStatus = 0; player->koStatus = 0; player->koDuration = 0; - player->disableEffect->data.disableX->unk_3C = 0; + player->disableEffect->data.disableX->koDuration = 0; if (partner != NULL) { if (partner->koStatus == STATUS_DAZE) { dispatch_event_partner(EVENT_RECOVER_PARTNER); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_DEFEATED; + gBattleSubState = BTL_SUBSTATE_END_TRAINING_UNK_A; } partner->debuff = 0; partner->staticStatus = 0; @@ -1935,26 +1957,26 @@ void btl_state_update_end_training_battle(void) { partner->transparentStatus = 0; partner->koStatus = 0; partner->koDuration = 0; - partner->disableEffect->data.disableX->unk_3C = 0; + partner->disableEffect->data.disableX->koDuration = 0; } break; - case BATTLE_SUB_STATE_PLAYER_DEFEATED: - if (player->onHitScript == NULL || !does_script_exist(player->onHitID)) { - player->onHitScript = NULL; + case BTL_SUBSTATE_END_TRAINING_UNK_A: + if (player->handleEventScript == NULL || !does_script_exist(player->handleEventScriptID)) { + player->handleEventScript = NULL; if (partner != NULL) { - if (partner->onHitScript == NULL || !does_script_exist(partner->onHitID)) { - partner->onHitScript = NULL; + if (partner->handleEventScript == NULL || !does_script_exist(partner->handleEventScriptID)) { + partner->handleEventScript = NULL; } else { break; } } - gBattleSubState = BATTLE_SUB_STATE_UNK_B; + gBattleSubState = BTL_SUBSTATE_END_TRAINING_UNK_B; } break; } switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_B: + case BTL_SUBSTATE_END_TRAINING_UNK_B: battleStatus->unk_8C = 0; gBattleStatus.flags2 &= ~BS_FLAGS2_2; gBattleStatus.flags2 &= ~BS_FLAGS2_4; @@ -1962,33 +1984,33 @@ void btl_state_update_end_training_battle(void) { gBattleStatus.flags2 &= ~BS_FLAGS2_10; if (!battleStatus->outtaSightActive) { - gBattleSubState = BATTLE_SUB_STATE_UNK_D; + gBattleSubState = BTL_SUBSTATE_END_TRAINING_UNK_D; } else { Evt* script; battleStatus->battlePhase = PHASE_ENEMY_BEGIN; - script = start_script(partner->onTurnChanceScriptSource, EVT_PRIORITY_A, 0); - partner->onTurnChangeScript = script; - gBattleSubState = BATTLE_SUB_STATE_UNK_C; - partner->onTurnChangeID = script->id; + script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0); + partner->handlePhaseScript = script; + gBattleSubState = BTL_SUBSTATE_END_TRAINING_UNK_C; + partner->handleBatttlePhaseScriptID = script->id; script->owner1.actorID = ACTOR_PARTNER; } break; - case BATTLE_SUB_STATE_UNK_D: - if (!does_script_exist(partner->onTurnChangeID)) { + case BTL_SUBSTATE_END_TRAINING_UNK_D: + if (!does_script_exist(partner->handleBatttlePhaseScriptID)) { battleStatus->outtaSightActive = FALSE; - gBattleSubState = BATTLE_SUB_STATE_UNK_D; + gBattleSubState = BTL_SUBSTATE_END_TRAINING_UNK_D; } break; } switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_D: + case BTL_SUBSTATE_END_TRAINING_UNK_D: btl_cam_use_preset(BTL_CAM_PRESET_C); D_8029F248 = 30; - gBattleSubState = BATTLE_SUB_STATE_UNK_E; + gBattleSubState = BTL_SUBSTATE_END_TRAINING_UNK_E; break; - case BATTLE_SUB_STATE_UNK_E: + case BTL_SUBSTATE_END_TRAINING_UNK_E: if (D_8029F248 != 0) { D_8029F248--; return; @@ -2017,22 +2039,22 @@ void btl_state_update_end_battle(void) { s32 i; switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_0: + case BTL_SUBSTATE_END_BATTLE_UNK_0: D_80280A30 = 0; - if (gGameStatusPtr->debugEnemyContact == 2) { + if (gGameStatusPtr->debugEnemyContact == DEBUG_CONTACT_DIE_ON_TOUCH) { D_80280A30 = 255; } - if (encounterStatus->battleOutcome == OUTCOME_PLAYER_LOST && !(gBattleStatus.flags1 & BS_FLAGS1_800000)) { + if (encounterStatus->battleOutcome == OUTCOME_PLAYER_LOST && !(gBattleStatus.flags1 & BS_FLAGS1_NO_GAME_OVER)) { btl_cam_unfreeze(); btl_cam_use_preset(BTL_CAM_PRESET_B); set_screen_overlay_color(0, 0, 0, 0); set_screen_overlay_center(0, 0, 160, 120); } - gBattleSubState = BATTLE_SUB_STATE_UNK_1; + gBattleSubState = BTL_SUBSTATE_END_BATTLE_UNK_1; break; - case BATTLE_SUB_STATE_UNK_1: + case BTL_SUBSTATE_END_BATTLE_UNK_1: if (D_80280A30 == 255) { - gBattleSubState = BATTLE_SUB_STATE_UNK_2; + gBattleSubState = BTL_SUBSTATE_END_BATTLE_UNK_2; break; } D_80280A30 += battleStatus->unk_8D; @@ -2040,7 +2062,7 @@ void btl_state_update_end_battle(void) { D_80280A30 = 255; } break; - case BATTLE_SUB_STATE_UNK_2: + case BTL_SUBSTATE_END_BATTLE_UNK_2: D_80280A30 = 255; gBattleStatus.flags1 &= ~BS_FLAGS1_1; if (D_800DC064 == NULL) { @@ -2049,22 +2071,22 @@ void btl_state_update_end_battle(void) { stage = D_800DC064->stage;; } if (stage->postBattle == NULL) { - gBattleSubState = BATTLE_SUB_STATE_UNK_4; + gBattleSubState = BTL_SUBSTATE_END_BATTLE_CLEANUP; return; } script = start_script(stage->postBattle, EVT_PRIORITY_A, 0); battleStatus->controlScript = script; - gBattleSubState = BATTLE_SUB_STATE_UNK_3; battleStatus->controlScriptID = script->id; + gBattleSubState = BTL_SUBSTATE_END_BATTLE_AWAIT_STAGE_SCRIPT; break; - case BATTLE_SUB_STATE_UNK_3: + case BTL_SUBSTATE_END_BATTLE_AWAIT_STAGE_SCRIPT: if (!does_script_exist(battleStatus->controlScriptID)) { - gBattleSubState = BATTLE_SUB_STATE_UNK_4; + gBattleSubState = BTL_SUBSTATE_END_BATTLE_CLEANUP; // fallthrough } else { break; } - case BATTLE_SUB_STATE_UNK_4: + case BTL_SUBSTATE_END_BATTLE_CLEANUP: kill_all_scripts(); for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { if (battleStatus->enemyActors[i] != NULL) { @@ -2079,7 +2101,7 @@ void btl_state_update_end_battle(void) { if (battleStatus->nextMerleeSpellType == MERLEE_SPELL_4) { encounterStatus->merleeCoinBonus = TRUE; - battleStatus->nextMerleeSpellType = 0; + battleStatus->nextMerleeSpellType = MERLEE_SPELL_0; } encounterStatus->damageTaken = battleStatus->damageTaken; @@ -2091,12 +2113,12 @@ void btl_state_update_end_battle(void) { remove_all_effects(); set_windows_visible(0); - if (gBattleStatus.flags2 & BS_FLAGS2_40) { + if (gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) { decrement_status_menu_disabled(); } if (encounterStatus->battleOutcome == OUTCOME_PLAYER_LOST && - !(gBattleStatus.flags1 & BS_FLAGS1_800000)) + !(gBattleStatus.flags1 & BS_FLAGS1_NO_GAME_OVER)) { s16 areaID; s16 mapID; @@ -2106,7 +2128,7 @@ void btl_state_update_end_battle(void) { get_map_IDs_by_name("gv_01", &areaID, &mapID); gGameStatusPtr->areaID = areaID; gGameStatusPtr->mapID = mapID; - gGameStatusPtr->entryID = 0; + gGameStatusPtr->entryID = gv_01_ENTRY_0; set_game_mode(GAME_MODE_ENTER_WORLD); } else { btl_set_state(BATTLE_STATE_0); @@ -2121,8 +2143,8 @@ void btl_state_update_end_battle(void) { void btl_state_draw_end_battle(void) { Camera* camera = &gCameras[gCurrentCameraID]; - if (gCurrentEncounter.battleOutcome == OUTCOME_PLAYER_LOST && !(gBattleStatus.flags1 & BS_FLAGS1_800000)) { - camera->auxBoomZOffset += 0x100; + if (gCurrentEncounter.battleOutcome == OUTCOME_PLAYER_LOST && !(gBattleStatus.flags1 & BS_FLAGS1_NO_GAME_OVER)) { + camera->auxBoomZOffset += 256; set_screen_overlay_params_front(7, D_80280A30); } else { set_screen_overlay_params_front(0, D_80280A30); @@ -2134,16 +2156,16 @@ void btl_state_update_defend(void) { Evt* script; switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_0: + case BTL_SUBSTATE_DEFEND_INIT: gBattleStatus.unk_8C = 0; gBattleStatus.battlePhase = PHASE_USE_DEFEND; player->takeTurnScript = script = start_script(&PlayerScriptDispatcher, EVT_PRIORITY_A, 0); - player->takeTurnID = script->id; - gBattleSubState = BATTLE_SUB_STATE_UNK_1; + player->takeTurnScriptID = script->id; + gBattleSubState = BTL_SUBSTATE_DEFEND_AWAIT_SCRIPT; script->owner1.actorID = ACTOR_PLAYER; break; - case BATTLE_SUB_STATE_UNK_1: - if (!does_script_exist(player->takeTurnID) && gBattleStatus.unk_8C == 0) { + case BTL_SUBSTATE_DEFEND_AWAIT_SCRIPT: + if (!does_script_exist(player->takeTurnScriptID) && gBattleStatus.unk_8C == 0) { btl_set_state(BATTLE_STATE_END_PLAYER_TURN); } break; @@ -2166,7 +2188,7 @@ void btl_state_update_run_away(void) { s32 i; switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_0: + case BTL_SUBSTATE_RUN_AWAY_UNK_0: battleStatus->unk_8C = 0; gBattleStatus.flags1 &= ~BS_FLAGS1_ENEMY_FLED; gBattleStatus.flags2 |= BS_FLAGS2_10 | BS_FLAGS2_8 | BS_FLAGS2_4 | BS_FLAGS2_2; @@ -2200,30 +2222,30 @@ void btl_state_update_run_away(void) { } player->state.varTable[0] = var_f2 / var_s0; - if (gGameStatusPtr->debugEnemyContact == 4) { + if (gGameStatusPtr->debugEnemyContact == DEBUG_CONTACT_AUTO_FLEE) { player->state.varTable[0] = 100; } battleStatus->battlePhase = PHASE_RUN_AWAY_START; script = start_script(&PlayerScriptDispatcher, EVT_PRIORITY_A, 0); player->takeTurnScript = script; - player->takeTurnID = script->id; + player->takeTurnScriptID = script->id; script->owner1.actorID = ACTOR_PLAYER; if (partner != NULL && partner->koStatus == 0) { - script = start_script(partner->takeTurnScriptSource, EVT_PRIORITY_A, 0); + script = start_script(partner->takeTurnSource, EVT_PRIORITY_A, 0); partner->takeTurnScript = script; - partner->takeTurnID = script->id; + partner->takeTurnScriptID = script->id; script->owner1.actorID = ACTOR_PARTNER; } - gBattleSubState = BATTLE_SUB_STATE_UNK_2; + gBattleSubState = BTL_SUBSTATE_RUN_AWAY_UNK_2; break; - case 2: - if (!does_script_exist(player->takeTurnID) && battleStatus->unk_8C == 0) { + case BTL_SUBSTATE_RUN_AWAY_UNK_2: + if (!does_script_exist(player->takeTurnScriptID) && battleStatus->unk_8C == 0) { if (!(gBattleStatus.flags1 & BS_FLAGS1_ENEMY_FLED)) { - gBattleSubState = BATTLE_SUB_STATE_UNK_3; + gBattleSubState = BTL_SUBSTATE_RUN_AWAY_UNK_3; } else { currentEncounter->battleOutcome = OUTCOME_PLAYER_FLED; if (is_ability_active(ABILITY_RUNAWAY_PAY) == 0) { - gBattleSubState = BATTLE_SUB_STATE_UNK_B; + gBattleSubState = BTL_SUBSTATE_RUN_AWAY_UNK_B; } else { status_menu_start_blinking_starpoints(); func_8023E104(); @@ -2233,14 +2255,14 @@ void btl_state_update_run_away(void) { D_8029F25C = battleStatus->totalStarPoints * 100; D_8029F250 = 20; D_8029F260 = D_8029F25C / D_8029F250; - gBattleSubState = BATTLE_SUB_STATE_PLAYER_DEFEATED; + gBattleSubState = BTL_SUBSTATE_RUN_AWAY_UNK_A; } } } break; } - if (gBattleSubState == BATTLE_SUB_STATE_PLAYER_DEFEATED) { + if (gBattleSubState == BTL_SUBSTATE_RUN_AWAY_UNK_A) { if (battleStatus->totalStarPoints != 0) { s8 temp_v1_4; @@ -2267,12 +2289,12 @@ void btl_state_update_run_away(void) { } else { status_menu_stop_blinking_starpoints(); func_8023E11C(); - gBattleSubState = BATTLE_SUB_STATE_UNK_B; + gBattleSubState = BTL_SUBSTATE_RUN_AWAY_UNK_B; } } } - if (gBattleSubState == BATTLE_SUB_STATE_UNK_B) { + if (gBattleSubState == BTL_SUBSTATE_RUN_AWAY_UNK_B) { playerData->battlesFled++; if (!(gBattleStatus.flags2 & BS_FLAGS2_2000000)) { bgm_set_song(0, -1, 0, 1500, 8); @@ -2281,27 +2303,27 @@ void btl_state_update_run_away(void) { } switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_3: + case BTL_SUBSTATE_RUN_AWAY_UNK_3: battleStatus->battlePhase = PHASE_RUN_AWAY_FAIL; script = start_script(&PlayerScriptDispatcher, EVT_PRIORITY_A, 0); player->takeTurnScript = script; - player->takeTurnID = script->id; + player->takeTurnScriptID = script->id; script->owner1.actorID = ACTOR_PLAYER; if (partner != NULL && partner->koStatus == 0) { - script = start_script(partner->takeTurnScriptSource, EVT_PRIORITY_A, 0); + script = start_script(partner->takeTurnSource, EVT_PRIORITY_A, 0); partner->takeTurnScript = script; - partner->takeTurnID = script->id; + partner->takeTurnScriptID = script->id; script->owner1.actorID = ACTOR_PARTNER; } - gBattleSubState = BATTLE_SUB_STATE_UNK_4; + gBattleSubState = BTL_SUBSTATE_RUN_AWAY_UNK_4; break; - case BATTLE_SUB_STATE_UNK_4: + case BTL_SUBSTATE_RUN_AWAY_UNK_4: if (D_8029F248 != 0) { D_8029F248--; return; } - if (!does_script_exist(player->takeTurnID) && - (partner == NULL || !does_script_exist(partner->takeTurnID)) && + if (!does_script_exist(player->takeTurnScriptID) && + (partner == NULL || !does_script_exist(partner->takeTurnScriptID)) && battleStatus->unk_8C == 0) { btl_set_state(BATTLE_STATE_9); @@ -2321,13 +2343,13 @@ void btl_state_update_defeat(void) { Evt* script; switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_0: + case BTL_SUBSTATE_DEFEAT_UNK_0: battleStatus->flags1 &= ~BS_FLAGS1_8; - battleStatus->unk_8C = 0; gBattleStatus.flags2 &= ~BS_FLAGS2_2; gBattleStatus.flags2 &= ~BS_FLAGS2_4; gBattleStatus.flags2 &= ~BS_FLAGS2_8; gBattleStatus.flags2 &= ~BS_FLAGS2_10; + battleStatus->unk_8C = 0; if (player->debuff != 0) { if (player->debuff == 7) { @@ -2340,7 +2362,7 @@ void btl_state_update_defeat(void) { remove_status_debuff(player->hudElementDataIndex); player->koStatus = 0; player->koDuration = 0; - player->disableEffect->data.disableX->unk_3C = 0; + player->disableEffect->data.disableX->koDuration = 0; } btl_cam_use_preset(BTL_CAM_PRESET_25); @@ -2348,42 +2370,42 @@ void btl_state_update_defeat(void) { battleStatus->battlePhase = PHASE_RUN_AWAY_RESET; script = start_script(&PlayerScriptDispatcher, EVT_PRIORITY_A, 0); player->takeTurnScript = script; - player->takeTurnID = script->id; + player->takeTurnScriptID = script->id; script->owner1.actorID = ACTOR_PLAYER; if (partner != NULL) { - script = start_script(partner->takeTurnScriptSource, EVT_PRIORITY_A, 0); + script = start_script(partner->takeTurnSource, EVT_PRIORITY_A, 0); partner->takeTurnScript = script; - partner->takeTurnID = script->id; + partner->takeTurnScriptID = script->id; script->owner1.actorID = ACTOR_PARTNER; } - gBattleSubState = BATTLE_SUB_STATE_UNK_1; + gBattleSubState = BTL_SUBSTATE_DEFEAT_UNK_1; break; - case BATTLE_SUB_STATE_UNK_1: - if (!does_script_exist(player->takeTurnID) && battleStatus->unk_8C == 0) { + case BTL_SUBSTATE_DEFEAT_UNK_1: + if (!does_script_exist(player->takeTurnScriptID) && battleStatus->unk_8C == 0) { if (find_item(ITEM_LIFE_SHROOM) >= 0) { battleStatus->battlePhase = PHASE_USE_LIFE_SHROOM; script = start_script(&PlayerScriptDispatcher, EVT_PRIORITY_A, 0); player->takeTurnScript = script; - player->takeTurnID = script->id; + player->takeTurnScriptID = script->id; script->owner1.actorID = ACTOR_PLAYER; - gBattleSubState = BATTLE_SUB_STATE_UNK_2; + gBattleSubState = BTL_SUBSTATE_DEFEAT_UNK_2; } else { - gBattleSubState = BATTLE_SUB_STATE_PLAYER_DEFEATED; + gBattleSubState = BTL_SUBSTATE_DEFEAT_UNK_A; } } break; - case BATTLE_SUB_STATE_UNK_2: - if (!does_script_exist(player->takeTurnID) && battleStatus->unk_8C == 0) { - gBattleSubState = BATTLE_SUB_STATE_PLAYER_DEFEATED; + case BTL_SUBSTATE_DEFEAT_UNK_2: + if (!does_script_exist(player->takeTurnScriptID) && battleStatus->unk_8C == 0) { + gBattleSubState = BTL_SUBSTATE_DEFEAT_UNK_A; } break; } - if (gBattleSubState == BATTLE_SUB_STATE_PLAYER_DEFEATED) { + if (gBattleSubState == BTL_SUBSTATE_DEFEAT_UNK_A) { currentEncounter->battleOutcome = OUTCOME_PLAYER_LOST; if (!(gBattleStatus.flags2 & BS_FLAGS2_2000000)) { - bgm_set_song(0, -1, 0, 0x5DC, 8); + bgm_set_song(0, -1, 0, 1500, 8); } btl_set_state(BATTLE_STATE_END_BATTLE); } @@ -2413,7 +2435,7 @@ void btl_state_update_change_partner(void) { s32 i; switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_0: + case BTL_SUBSTATE_CHANGE_PARTNER_UNK_0: player->flags &= ~ACTOR_FLAG_8000000; partner->flags &= ~ACTOR_FLAG_8000000; battleStatus->unk_8C = 0; @@ -2433,10 +2455,10 @@ void btl_state_update_change_partner(void) { } battleStatus->unk_5C[0] = -1; - D_8029F248 = 0xA; - gBattleSubState = BATTLE_SUB_STATE_UNK_2; + D_8029F248 = 10; + gBattleSubState = BTL_SUBSTATE_CHANGE_PARTNER_UNK_2; - case BATTLE_SUB_STATE_UNK_2: + case BTL_SUBSTATE_CHANGE_PARTNER_UNK_2: if (D_8029F248 != 0) { D_8029F248--; break; @@ -2449,9 +2471,9 @@ void btl_state_update_change_partner(void) { state->unk_18.x = partner->currentPos.x; state->unk_18.y = 0.0f; state->unk_18.z = partner->currentPos.z; - gBattleSubState = BATTLE_SUB_STATE_UNK_3; + gBattleSubState = BTL_SUBSTATE_CHANGE_PARTNER_UNK_3; break; - case BATTLE_SUB_STATE_UNK_3: + case BTL_SUBSTATE_CHANGE_PARTNER_UNK_3: if (!does_script_exist(battleStatus->controlScriptID)) { btl_delete_actor(partner); playerData->currentPartner = battleStatus->unk_1AC; @@ -2466,13 +2488,13 @@ void btl_state_update_change_partner(void) { partner->currentPos.x = player->currentPos.x; partner->currentPos.y = player->currentPos.y + 25.0f; partner->currentPos.z = player->currentPos.z; - gBattleSubState = BATTLE_SUB_STATE_UNK_4; + gBattleSubState = BTL_SUBSTATE_CHANGE_PARTNER_UNK_4; } break; - case BATTLE_SUB_STATE_UNK_4: + case BTL_SUBSTATE_CHANGE_PARTNER_UNK_4: partner = battleStatus->partnerActor; if (partner != NULL) { - if (!does_script_exist(partner->takeTurnID)) { + if (!does_script_exist(partner->takeTurnScriptID)) { partner->takeTurnScript = NULL; } else { break; @@ -2483,32 +2505,32 @@ void btl_state_update_change_partner(void) { battleStatus->controlScript = script; battleStatus->controlScriptID = script->id; script->owner1.actorID = ACTOR_PARTNER; - gBattleSubState = BATTLE_SUB_STATE_BEGIN_LEVEL_UP; + gBattleSubState = BTL_SUBSTATE_CHANGE_PARTNER_UNK_5; break; - case BATTLE_SUB_STATE_BEGIN_LEVEL_UP: + case BTL_SUBSTATE_CHANGE_PARTNER_UNK_5: if (!does_script_exist(battleStatus->controlScriptID)) { partner = battleStatus->partnerActor; if (partner != NULL) { - if (partner->onTurnChanceScriptSource != NULL) { + if (partner->handlePhaseSource != NULL) { battleStatus->battlePhase = PHASE_PLAYER_BEGIN; - script = start_script(partner->onTurnChanceScriptSource, EVT_PRIORITY_A, 0); - partner->onTurnChangeScript = script; - partner->onTurnChangeID = script->id; + script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0); + partner->handlePhaseScript = script; + partner->handleBatttlePhaseScriptID = script->id; script->owner1.actorID = ACTOR_PARTNER; } } - gBattleSubState = BATTLE_SUB_STATE_LEVEL_UP_SHOW_HUD; + gBattleSubState = BTL_SUBSTATE_CHANGE_PARTNER_UNK_6; } break; - case BATTLE_SUB_STATE_LEVEL_UP_SHOW_HUD: + case BTL_SUBSTATE_CHANGE_PARTNER_UNK_6: partner = battleStatus->partnerActor; - if (partner == NULL || partner->onTurnChanceScriptSource == NULL - || !does_script_exist(partner->onTurnChangeID)) { + if (partner == NULL || partner->handlePhaseSource == NULL + || !does_script_exist(partner->handleBatttlePhaseScriptID)) { btl_cam_use_preset(BTL_CAM_PRESET_C); - gBattleSubState = BATTLE_SUB_STATE_UNK_7; + gBattleSubState = BTL_SUBSTATE_CHANGE_PARTNER_UNK_7; } break; - case BATTLE_SUB_STATE_UNK_7: + case BTL_SUBSTATE_CHANGE_PARTNER_UNK_7: if (battleStatus->unk_8C == 0) { gBattleStatus.flags2 &= ~BS_FLAGS2_10; if (!(gBattleStatus.flags1 & BS_FLAGS1_80000)) { @@ -2539,11 +2561,11 @@ void btl_state_update_player_move(void) { s32 messageIndex; Actor* actor; Evt* script; - s32 cond; - s8 temp_a0; + s32 foundEnemy; + s8 tipIndex; s32 i; - if (gBattleSubState == BATTLE_SUB_STATE_UNK_0) { + if (gBattleSubState == BTL_SUBSTATE_PLAYER_MOVE_INIT) { battleStatus->unk_86 = 127; battleStatus->blockResult = 127; battleStatus->unk_8C = 0; @@ -2578,304 +2600,319 @@ void btl_state_update_player_move(void) { } if (battleStatus->moveCategory == 0 || battleStatus->moveCategory == 1) { - if (battleStatus->nextMerleeSpellType == 1) { + if (battleStatus->nextMerleeSpellType == MERLEE_SPELL_1) { battleStatus->merleeAttackBoost = 3; - battleStatus->nextMerleeSpellType = 0; + battleStatus->nextMerleeSpellType = MERLEE_SPELL_0; battleStatus->battlePhase = PHASE_MERLEE_ATTACK_BONUS; - script = start_script(&PlayerScriptDispatcher, 0xA, 0); + script = start_script(&PlayerScriptDispatcher, EVT_PRIORITY_A, 0); player->takeTurnScript = script; - player->takeTurnID = script->id; + player->takeTurnScriptID = script->id; script->owner1.actorID = ACTOR_PLAYER; gBattleStatus.flags1 |= BS_FLAGS1_10000; close_action_command_instruction_popup(); - gBattleSubState = BATTLE_SUB_STATE_UNK_1; + gBattleSubState = BTL_SUBSTATE_PLAYER_MOVE_BEGIN_SHOW_TIP; } else { - gBattleSubState = BATTLE_SUB_STATE_UNK_3; + gBattleSubState = BTL_SUBSTATE_PLAYER_MOVE_EXECUTE_MOVE; gBattleStatus.flags1 &= ~BS_FLAGS1_2; } } else { - gBattleSubState = BATTLE_SUB_STATE_UNK_3; + gBattleSubState = BTL_SUBSTATE_PLAYER_MOVE_EXECUTE_MOVE; gBattleStatus.flags1 &= ~BS_FLAGS1_2; } } switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_1: - if (player->takeTurnScript == NULL || !does_script_exist(player->takeTurnID)) { + case BTL_SUBSTATE_PLAYER_MOVE_BEGIN_SHOW_TIP: + if (player->takeTurnScript == NULL || !does_script_exist(player->takeTurnScriptID)) { player->takeTurnScript = NULL; if (!is_ability_active(ABILITY_BERSERKER)) { if (battleStatus->selectedMoveID != MOVE_NONE) { - temp_a0 = gMoveTable[battleStatus->selectedMoveID].actionTip; - if (temp_a0 >= 0) { - btl_show_battle_message(temp_a0 + 0x2E, 60); + tipIndex = gMoveTable[battleStatus->selectedMoveID].actionTip; + if (tipIndex >= 0) { + btl_show_battle_message(BTL_MSG_2E + tipIndex, 60); } } } D_8029F248 = 2; - gBattleSubState = BATTLE_SUB_STATE_UNK_2; + gBattleSubState = BTL_SUBSTATE_PLAYER_MOVE_SHOW_TIP_DELAY; } break; - case BATTLE_SUB_STATE_UNK_2: + case BTL_SUBSTATE_PLAYER_MOVE_SHOW_TIP_DELAY: if (D_8029F248 != 0) { D_8029F248--; } else { - gBattleSubState = BATTLE_SUB_STATE_UNK_3; + gBattleSubState = BTL_SUBSTATE_PLAYER_MOVE_EXECUTE_MOVE; } break; } switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_3: + case BTL_SUBSTATE_PLAYER_MOVE_EXECUTE_MOVE: gBattleStatus.flags1 &= ~BS_FLAGS1_4000; gBattleStatus.flags1 &= ~BS_FLAGS1_10000; increment_status_menu_disabled(); gBattleStatus.flags1 |= BS_FLAGS1_100; reset_all_actor_sounds(player); battleStatus->battlePhase = PHASE_EXECUTE_ACTION; - if (gBattleStatus.flags2 & BS_FLAGS2_40) { - script = start_script(&PeachScriptDispatcher, 0xA, 0); + if (gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) { + script = start_script(&PeachScriptDispatcher, EVT_PRIORITY_A, 0); } else { - script = start_script(&PlayerScriptDispatcher, 0xA, 0); + script = start_script(&PlayerScriptDispatcher, EVT_PRIORITY_A, 0); } player->takeTurnScript = script; - gBattleSubState = BATTLE_SUB_STATE_UNK_4; - player->takeTurnID = script->id; + gBattleSubState = BTL_SUBSTATE_PLAYER_MOVE_HANDLE_RESULTS; + player->takeTurnScriptID = script->id; script->owner1.actorID = ACTOR_PLAYER; break; - case BATTLE_SUB_STATE_UNK_4: + case BTL_SUBSTATE_PLAYER_MOVE_HANDLE_RESULTS: + // wait for player battle phase script to finish if (!(gBattleStatus.flags1 & BS_FLAGS1_200000)) { - if (player->takeTurnScript != NULL && does_script_exist(player->takeTurnID)) { + if (player->takeTurnScript != NULL && does_script_exist(player->takeTurnScriptID)) { break; } player->takeTurnScript = NULL; } gBattleStatus.flags1 &= ~BS_FLAGS1_100; - if (player->onHitScript == NULL || !does_script_exist(player->onHitID)) { - player->onHitScript = NULL; - if (partner != NULL) { - if (partner->onHitScript != NULL && does_script_exist(partner->onHitID)) { - break; - } - partner->onHitScript = NULL; + + // wait for player battle event script to finish + if (player->handleEventScript != NULL && does_script_exist(player->handleEventScriptID)) { + break; + } + player->handleEventScript = NULL; + + // wait for partner battle event script to finish + if (partner != NULL) { + if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) { + break; } + partner->handleEventScript = NULL; + } - cond = FALSE; - for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { - actor = battleStatus->enemyActors[i]; - if (actor != NULL && actor->takeTurnScript != NULL) { - if (does_script_exist(actor->takeTurnID)) { - cond = TRUE; - } else { - actor->takeTurnScript = NULL; - } - } - } - - if (!cond) { - for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { - actor = battleStatus->enemyActors[i]; - if (actor != NULL && actor->onHitScript != NULL) { - if (does_script_exist(actor->onHitID)) { - cond = TRUE; - } else { - actor->onHitScript = NULL; - } - } - } - - if (!cond) { - for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { - actor = battleStatus->enemyActors[i]; - if (actor != NULL) { - actor->flags &= ~ACTOR_FLAG_80000; - } - } - - if (battleStatus->unk_8C == 0) { - if (gGameStatusPtr->demoFlags & 1) { - btl_set_state(BATTLE_STATE_END_DEMO_BATTLE); - break; - } - decrement_status_menu_disabled(); - gBattleStatus.flags1 |= BS_FLAGS1_8; - gBattleStatus.flags2 &= ~BS_FLAGS2_8; - if (btl_check_player_defeated()) { - return; - } - - if (battleStatus->moveCategory == 1) { - if ((battleStatus->selectedMoveID != MOVE_SMASH_CHARGE0) && - (battleStatus->selectedMoveID != MOVE_SMASH_CHARGE) && - (battleStatus->selectedMoveID != MOVE_SUPER_SMASH_CHARGE)) - { - gBattleStatus.flags1 &= ~BS_FLAGS1_10000000; - } - } - if (battleStatus->moveCategory == 0) { - if ((battleStatus->selectedMoveID != MOVE_JUMP_CHARGE0) && - (battleStatus->selectedMoveID != MOVE_JUMP_CHARGE) && - (battleStatus->selectedMoveID != MOVE_SUPER_JUMP_CHARGE)) - { - gBattleStatus.flags1 &= ~BS_FLAGS1_20000000; - } - } - - if (!(gBattleStatus.flags1 & BS_FLAGS1_20000000)) { - battleStatus->jumpCharge = 0; - } - if (!(gBattleStatus.flags1 & BS_FLAGS1_10000000)) { - battleStatus->hammerCharge = 0; - } - - for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { - actor = battleStatus->enemyActors[i]; - if (actor != NULL && !(actor->flags & ACTOR_FLAG_NO_DMG_APPLY)) { - actor->flags |= ACTOR_FLAG_8000000 | ACTOR_FLAG_4000000; - } - } - - cond = FALSE; - btl_update_ko_status(); - - for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { - actor = battleStatus->enemyActors[i]; - if (actor != NULL) { - if (actor->status != 0) { - cond = TRUE; - break; - } - } - } - - if (!cond) { - gBattleSubState = BATTLE_SUB_STATE_UNK_14; - } else { - btl_cam_use_preset(BTL_CAM_PRESET_D); - switch (actor->status) { - case 4: - messageIndex = 0x12; - break; - case 6: - messageIndex = 0x13; - break; - case 7: - messageIndex = 0x14; - break; - case 9: - messageIndex = 0x15; - break; - case 10: - messageIndex = 0x16; - break; - case 5: - messageIndex = 0x17; - break; - case 11: - messageIndex = 0x18; - break; - case 8: - messageIndex = 0x19; - break; - default: - messageIndex = 0; - gBattleSubState = BATTLE_SUB_STATE_UNK_14; - break; - } - sfx_play_sound(SOUND_2107); - btl_show_battle_message(messageIndex, 60); - for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { - actor = battleStatus->enemyActors[i]; - if (actor != NULL) { - actor->status = 0; - } - } - gBattleSubState = BATTLE_SUB_STATE_UNK_B; - } - } + // wait for all enemy battle phase scripts to finish + foundEnemy = FALSE; + for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { + actor = battleStatus->enemyActors[i]; + if (actor != NULL && actor->takeTurnScript != NULL) { + if (does_script_exist(actor->takeTurnScriptID)) { + foundEnemy = TRUE; + } else { + actor->takeTurnScript = NULL; } } } + if (foundEnemy) { + break; + } + + // wait for all enemy battle event scripts to finish + foundEnemy = FALSE; + for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { + actor = battleStatus->enemyActors[i]; + if (actor != NULL && actor->handleEventScript != NULL) { + if (does_script_exist(actor->handleEventScriptID)) { + foundEnemy = TRUE; + } else { + actor->handleEventScript = NULL; + } + } + } + if (foundEnemy) { + break; + } + + for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { + actor = battleStatus->enemyActors[i]; + if (actor != NULL) { + actor->flags &= ~ACTOR_FLAG_80000; + } + } + + if (battleStatus->unk_8C != 0) { + break; + } + + if (gGameStatusPtr->demoFlags & 1) { + btl_set_state(BATTLE_STATE_END_DEMO_BATTLE); + break; + } + + decrement_status_menu_disabled(); + gBattleStatus.flags1 |= BS_FLAGS1_8; + gBattleStatus.flags2 &= ~BS_FLAGS2_8; + if (btl_check_player_defeated()) { + return; + } + + if (battleStatus->moveCategory == 1) { + if ((battleStatus->selectedMoveID != MOVE_SMASH_CHARGE0) && + (battleStatus->selectedMoveID != MOVE_SMASH_CHARGE) && + (battleStatus->selectedMoveID != MOVE_SUPER_SMASH_CHARGE)) + { + gBattleStatus.flags1 &= ~BS_FLAGS1_HAMMER_CHARGED; + } + } + if (battleStatus->moveCategory == 0) { + if ((battleStatus->selectedMoveID != MOVE_JUMP_CHARGE0) && + (battleStatus->selectedMoveID != MOVE_JUMP_CHARGE) && + (battleStatus->selectedMoveID != MOVE_SUPER_JUMP_CHARGE)) + { + gBattleStatus.flags1 &= ~BS_FLAGS1_JUMP_CHARGED; + } + } + + if (!(gBattleStatus.flags1 & BS_FLAGS1_JUMP_CHARGED)) { + battleStatus->jumpCharge = 0; + } + if (!(gBattleStatus.flags1 & BS_FLAGS1_HAMMER_CHARGED)) { + battleStatus->hammerCharge = 0; + } + + for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { + actor = battleStatus->enemyActors[i]; + if (actor != NULL && !(actor->flags & ACTOR_FLAG_NO_DMG_APPLY)) { + actor->flags |= ACTOR_FLAG_8000000 | ACTOR_FLAG_4000000; + } + } + + btl_update_ko_status(); + + foundEnemy = FALSE; + for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { + actor = battleStatus->enemyActors[i]; + if (actor != NULL) { + if (actor->status != 0) { + foundEnemy = TRUE; + break; + } + } + } + + if (!foundEnemy) { + gBattleSubState = BTL_SUBSTATE_PLAYER_MOVE_CHECK_PLAYER_STATUS; + } else { + btl_cam_use_preset(BTL_CAM_PRESET_D); + switch (actor->status) { + case 4: + messageIndex = BTL_MSG_12; + break; + case 6: + messageIndex = BTL_MSG_13; + break; + case 7: + messageIndex = BTL_MSG_14; + break; + case 9: + messageIndex = BTL_MSG_15; + break; + case 10: + messageIndex = BTL_MSG_16; + break; + case 5: + messageIndex = BTL_MSG_17; + break; + case 11: + messageIndex = BTL_MSG_18; + break; + case 8: + messageIndex = BTL_MSG_19; + break; + default: + messageIndex = 0; + gBattleSubState = BTL_SUBSTATE_PLAYER_MOVE_CHECK_PLAYER_STATUS; + break; + } + sfx_play_sound(SOUND_2107); + btl_show_battle_message(messageIndex, 60); + for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { + actor = battleStatus->enemyActors[i]; + if (actor != NULL) { + actor->status = 0; + } + } + gBattleSubState = BTL_SUBSTATE_PLAYER_MOVE_AWAIT_ENEMY_STATUS_POPUP; + } break; - case BATTLE_SUB_STATE_UNK_B: + case BTL_SUBSTATE_PLAYER_MOVE_AWAIT_ENEMY_STATUS_POPUP: if (!btl_is_popup_displayed()) { btl_cam_use_preset(BTL_CAM_PRESET_C); btl_cam_move(15); D_8029F248 = 10; - gBattleSubState = BATTLE_SUB_STATE_UNK_C; + gBattleSubState = BTL_SUBSTATE_PLAYER_MOVE_POST_ENEMY_STATUS_POPUP; } break; - case BATTLE_SUB_STATE_UNK_C: + case BTL_SUBSTATE_PLAYER_MOVE_POST_ENEMY_STATUS_POPUP: if (D_8029F248 != 0) { D_8029F248--; } else { - gBattleSubState = BATTLE_SUB_STATE_UNK_14; + gBattleSubState = BTL_SUBSTATE_PLAYER_MOVE_CHECK_PLAYER_STATUS; } break; } switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_14: + case BTL_SUBSTATE_PLAYER_MOVE_CHECK_PLAYER_STATUS: if (player->status != 0) { btl_cam_use_preset(BTL_CAM_PRESET_33); switch (player->status) { case 4: - messageIndex = 0xA; + messageIndex = BTL_MSG_0A; break; case 6: - messageIndex = 0xB; + messageIndex = BTL_MSG_0B; break; case 7: - messageIndex = 0xC; + messageIndex = BTL_MSG_0C; break; case 9: - messageIndex = 0xD; + messageIndex = BTL_MSG_0D; break; case 10: - messageIndex = 0xE; + messageIndex = BTL_MSG_0E; break; case 5: - messageIndex = 0xF; + messageIndex = BTL_MSG_0F; break; case 11: - messageIndex = 0x10; + messageIndex = BTL_MSG_10; break; default: messageIndex = 0; - gBattleSubState = BATTLE_SUB_STATE_UNK_1E; + gBattleSubState = BTL_SUBSTATE_PLAYER_MOVE_AWAIT_DONE; break; } btl_show_battle_message(messageIndex, 60); player->status = 0; player->disableDismissTimer = 0; - gBattleSubState = BATTLE_SUB_STATE_UNK_15; player->flags |= ACTOR_FLAG_8000000; + gBattleSubState = BTL_SUBSTATE_PLAYER_MOVE_AWAIT_PLAYER_STATUS_POPUP; + } else { - gBattleSubState = BATTLE_SUB_STATE_UNK_1E; + gBattleSubState = BTL_SUBSTATE_PLAYER_MOVE_AWAIT_DONE; } break; - case BATTLE_SUB_STATE_UNK_15: + case BTL_SUBSTATE_PLAYER_MOVE_AWAIT_PLAYER_STATUS_POPUP: if (!btl_is_popup_displayed()) { btl_cam_use_preset(BTL_CAM_PRESET_C); btl_cam_move(15); D_8029F248 = 10; - gBattleSubState = BATTLE_SUB_STATE_UNK_16; + gBattleSubState = BTL_SUBSTATE_PLAYER_MOVE_POST_PLAYER_STATUS_POPUP; } break; - case BATTLE_SUB_STATE_UNK_16: + case BTL_SUBSTATE_PLAYER_MOVE_POST_PLAYER_STATUS_POPUP: if (D_8029F248 != 0) { D_8029F248--; } else { - gBattleSubState = BATTLE_SUB_STATE_UNK_1E; + gBattleSubState = BTL_SUBSTATE_PLAYER_MOVE_AWAIT_DONE; } break; } - if (gBattleSubState == BATTLE_SUB_STATE_UNK_1E && - (player->takeTurnScript == NULL || !does_script_exist(player->takeTurnID))) - { - player->takeTurnScript = NULL; - btl_set_state(BATTLE_STATE_END_PLAYER_TURN); + if (gBattleSubState == BTL_SUBSTATE_PLAYER_MOVE_AWAIT_DONE) { + if (player->takeTurnScript == NULL || !does_script_exist(player->takeTurnScriptID)) { + player->takeTurnScript = NULL; + btl_set_state(BATTLE_STATE_END_PLAYER_TURN); + } } } @@ -2888,18 +2925,18 @@ void btl_state_update_end_player_turn(void) { Actor* partner = battleStatus->partnerActor; Evt* script; - if (gBattleSubState == BATTLE_SUB_STATE_UNK_0) { + if (gBattleSubState == BTL_SUBSTATE_END_PLAYER_TURN_UNK_0) { if (battleStatus->moveCategory == 2 && battleStatus->itemUsesLeft >= 2) { - gBattleSubState = BATTLE_SUB_STATE_BEGIN_LEVEL_UP; + gBattleSubState = BTL_SUBSTATE_END_PLAYER_TURN_UNK_5; } else if ( !(gBattleStatus.flags2 & BS_FLAGS2_4000000) && !is_ability_active(ABILITY_HAPPY_HEART) && !is_ability_active(ABILITY_CRAZY_HEART) && !is_ability_active(ABILITY_HAPPY_FLOWER)) { - gBattleSubState = BATTLE_SUB_STATE_BEGIN_LEVEL_UP; + gBattleSubState = BTL_SUBSTATE_END_PLAYER_TURN_UNK_5; } else if (player->stoneStatus == STATUS_STONE || battleStatus->outtaSightActive) { - gBattleSubState = BATTLE_SUB_STATE_BEGIN_LEVEL_UP; + gBattleSubState = BTL_SUBSTATE_END_PLAYER_TURN_UNK_5; } else { s32 prevHPDrainCount = 0; s32 hpRecovery = 0; @@ -2921,12 +2958,12 @@ void btl_state_update_end_player_turn(void) { } if (prevHPDrainCount + hpRecovery + fpRecovery == 0) { - gBattleSubState = BATTLE_SUB_STATE_BEGIN_LEVEL_UP; + gBattleSubState = BTL_SUBSTATE_END_PLAYER_TURN_UNK_5; } else { battleStatus->battlePhase = PHASE_PLAYER_HAPPY; script = start_script(&PlayerScriptDispatcher, EVT_PRIORITY_A, 0); player->takeTurnScript = script; - player->takeTurnID = script->id; + player->takeTurnScriptID = script->id; script->owner1.actorID = ACTOR_PLAYER; if (gBattleStatus.flags2 & BS_FLAGS2_4000000) { script->varTable[10] += battleStatus->hpDrainCount; @@ -2947,16 +2984,16 @@ void btl_state_update_end_player_turn(void) { } gBattleStatus.flags2 &= ~BS_FLAGS2_4000000; - gBattleSubState = BATTLE_SUB_STATE_BEGIN_LEVEL_UP; + gBattleSubState = BTL_SUBSTATE_END_PLAYER_TURN_UNK_5; } } } - if (gBattleSubState == BATTLE_SUB_STATE_BEGIN_LEVEL_UP) { - if ((player->takeTurnScript == NULL) || !does_script_exist(player->takeTurnID)) { + if (gBattleSubState == BTL_SUBSTATE_END_PLAYER_TURN_UNK_5) { + if ((player->takeTurnScript == NULL) || !does_script_exist(player->takeTurnScriptID)) { player->takeTurnScript = NULL; - if (!(gBattleStatus.flags2 & BS_FLAGS2_40) || (gBattleStatus.flags1 & BS_FLAGS1_100000)) { - gBattleSubState = BATTLE_SUB_STATE_PLAYER_DEFEATED; + if (!(gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) || (gBattleStatus.flags1 & BS_FLAGS1_100000)) { + gBattleSubState = BTL_SUBSTATE_END_PLAYER_TURN_UNK_A; } else { player->state.currentPos.x = player->homePos.x; player->state.currentPos.z = player->homePos.z; @@ -2964,12 +3001,12 @@ void btl_state_update_end_player_turn(void) { player->state.goalPos.z = partner->homePos.z; player->state.moveTime = 4; player->state.angle = 0.0f; - gBattleSubState = BATTLE_SUB_STATE_LEVEL_UP_SHOW_HUD; + gBattleSubState = BTL_SUBSTATE_END_PLAYER_TURN_UNK_6; } } } - if (gBattleSubState == BATTLE_SUB_STATE_LEVEL_UP_SHOW_HUD) { + if (gBattleSubState == BTL_SUBSTATE_END_PLAYER_TURN_UNK_6) { if (player->state.moveTime != 0) { player->currentPos.x += (player->state.goalPos.x - player->currentPos.x) / player->state.moveTime; player->currentPos.z += (player->state.goalPos.z - player->currentPos.z) / player->state.moveTime; @@ -2994,66 +3031,68 @@ void btl_state_update_end_player_turn(void) { partner->homePos.x = partner->currentPos.x; partner->homePos.z = partner->currentPos.z; gBattleStatus.flags1 |= BS_FLAGS1_100000; - gBattleSubState = BATTLE_SUB_STATE_PLAYER_DEFEATED; + gBattleSubState = BTL_SUBSTATE_END_PLAYER_TURN_UNK_A; } } - if (gBattleSubState == BATTLE_SUB_STATE_PLAYER_DEFEATED && !btl_check_enemies_defeated()) { - if (battleStatus->moveCategory == 2 && battleStatus->itemUsesLeft >= 2) { - btl_cam_use_preset(BTL_CAM_PRESET_C); - btl_cam_move(10); - gBattleStatus.flags2 &= ~BS_FLAGS2_2; - } else { - gBattleStatus.flags2 |= BS_FLAGS2_2; - } + if (gBattleSubState == BTL_SUBSTATE_END_PLAYER_TURN_UNK_A) { + if(!btl_check_enemies_defeated()) { + if (battleStatus->moveCategory == 2 && battleStatus->itemUsesLeft >= 2) { + btl_cam_use_preset(BTL_CAM_PRESET_C); + btl_cam_move(10); + gBattleStatus.flags2 &= ~BS_FLAGS2_2; + } else { + gBattleStatus.flags2 |= BS_FLAGS2_2; + } - if (battleStatus->unk_94 < 0) { - battleStatus->unk_94 = 0; - battleStatus->itemUsesLeft = 0; - btl_set_state(BATTLE_STATE_END_TURN); - return; - } - - if (battleStatus->itemUsesLeft != 0) { - battleStatus->itemUsesLeft--; - if (battleStatus->itemUsesLeft != 0) { - btl_set_state(BATTLE_STATE_PREPARE_MENU); - gBattleSubState = BATTLE_SUB_STATE_UNK_46; + if (battleStatus->unk_94 < 0) { + battleStatus->unk_94 = 0; + battleStatus->itemUsesLeft = 0; + btl_set_state(BATTLE_STATE_END_TURN); return; } - if (gBattleStatus.flags1 & BS_FLAGS1_HUSTLE_DRINK_ON) { + if (battleStatus->itemUsesLeft != 0) { + battleStatus->itemUsesLeft--; + if (battleStatus->itemUsesLeft != 0) { + btl_set_state(BATTLE_STATE_PREPARE_MENU); + gBattleSubState = BATTLE_SUBSTATE_PREPARE_MENU_UNK_70; + return; + } + + if (gBattleStatus.flags1 & BS_FLAGS1_HUSTLED) { + if (battleStatus->hustleTurns != 0) { + battleStatus->hustleTurns--; + } + } + + if (battleStatus->hustleTurns != 0 && (gBattleStatus.flags1 & BS_FLAGS1_HUSTLED)) { + gBattleStatus.flags2 &= ~BS_FLAGS2_2; + + btl_set_state(BATTLE_STATE_PREPARE_MENU); + } else { + gBattleStatus.flags1 &= ~BS_FLAGS1_HUSTLED; + btl_set_state(BATTLE_STATE_BEGIN_PARTNER_TURN); + } + return; + } + + if (gBattleStatus.flags1 & BS_FLAGS1_HUSTLED) { if (battleStatus->hustleTurns != 0) { battleStatus->hustleTurns--; } } - if (battleStatus->hustleTurns != 0 && (gBattleStatus.flags1 & BS_FLAGS1_HUSTLE_DRINK_ON)) { + if (battleStatus->hustleTurns != 0 && (gBattleStatus.flags1 & BS_FLAGS1_HUSTLED)) { gBattleStatus.flags2 &= ~BS_FLAGS2_2; - btl_set_state(BATTLE_STATE_PREPARE_MENU); } else { - gBattleStatus.flags1 &= ~BS_FLAGS1_HUSTLE_DRINK_ON; - btl_set_state(BATTLE_STATE_BEGIN_PARTNER_TURN); - } - return; - } - - if (gBattleStatus.flags1 & BS_FLAGS1_HUSTLE_DRINK_ON) { - if (battleStatus->hustleTurns != 0) { - battleStatus->hustleTurns--; - } - } - - if (battleStatus->hustleTurns != 0 && (gBattleStatus.flags1 & BS_FLAGS1_HUSTLE_DRINK_ON)) { - gBattleStatus.flags2 &= ~BS_FLAGS2_2; - btl_set_state(BATTLE_STATE_PREPARE_MENU); - } else { - gBattleStatus.flags1 &= ~BS_FLAGS2_4000000; - if (!(gBattleStatus.flags2 & BS_FLAGS2_40)) { - btl_set_state(BATTLE_STATE_BEGIN_PARTNER_TURN); - } else { - btl_set_state(BATTLE_STATE_9); + gBattleStatus.flags1 &= ~BS_FLAGS2_4000000; + if (!(gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE)) { + btl_set_state(BATTLE_STATE_BEGIN_PARTNER_TURN); + } else { + btl_set_state(BATTLE_STATE_9); + } } } } @@ -3071,11 +3110,11 @@ void btl_state_update_partner_move(void) { Evt* script; s8 switchCondition; s32 phi_s3; - s32 phi_s0; + s32 messageIndex; s32 i; switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_0: + case BTL_SUBSTATE_PARTNER_MOVE_UNK_0: if (partner == NULL) { btl_set_state(BATTLE_STATE_9); } else { @@ -3101,10 +3140,10 @@ void btl_state_update_partner_move(void) { } } btl_cam_use_preset(BTL_CAM_PRESET_C); - gBattleSubState = BATTLE_SUB_STATE_UNK_2; + gBattleSubState = BTL_SUBSTATE_PARTNER_MOVE_UNK_2; } break; - case BATTLE_SUB_STATE_UNK_2: + case BTL_SUBSTATE_PARTNER_MOVE_UNK_2: for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { enemyActor = battleStatus->enemyActors[i]; if (enemyActor != NULL) { @@ -3118,15 +3157,15 @@ void btl_state_update_partner_move(void) { reset_actor_turn_info(); reset_all_actor_sounds(partner); battleStatus->battlePhase = PHASE_EXECUTE_ACTION; - script = start_script(partner->takeTurnScriptSource, EVT_PRIORITY_A, 0); + script = start_script(partner->takeTurnSource, EVT_PRIORITY_A, 0); partner->takeTurnScript = script; - partner->takeTurnID = script->id; + partner->takeTurnScriptID = script->id; script->owner1.actorID = ACTOR_PARTNER; - gBattleSubState = BATTLE_SUB_STATE_UNK_3; + gBattleSubState = BTL_SUBSTATE_PARTNER_MOVE_UNK_3; break; - case BATTLE_SUB_STATE_UNK_3: + case BTL_SUBSTATE_PARTNER_MOVE_UNK_3: if (!(gBattleStatus.flags1 & BS_FLAGS1_200000)) { - if (partner->takeTurnScript == NULL || !does_script_exist(partner->takeTurnID)) { + if (partner->takeTurnScript == NULL || !does_script_exist(partner->takeTurnScriptID)) { partner->takeTurnScript = NULL; } else { break; @@ -3134,15 +3173,15 @@ void btl_state_update_partner_move(void) { } gBattleStatus.flags1 &= ~BS_FLAGS1_100; - if ((partner->onHitScript == NULL || !does_script_exist(partner->onHitID)) - && ((partner->onHitScript = NULL, player->onHitScript == NULL) - || !does_script_exist(player->onHitID))) { + if ((partner->handleEventScript == NULL || !does_script_exist(partner->handleEventScriptID)) + && ((partner->handleEventScript = NULL, player->handleEventScript == NULL) + || !does_script_exist(player->handleEventScriptID))) { - player->onHitScript = NULL; + player->handleEventScript = NULL; for (phi_s3 = FALSE, i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { enemyActor = battleStatus->enemyActors[i]; if (enemyActor != NULL && enemyActor->takeTurnScript != NULL) { - if (does_script_exist(enemyActor->takeTurnID)) { + if (does_script_exist(enemyActor->takeTurnScriptID)) { phi_s3 = TRUE; } else { enemyActor->takeTurnScript = NULL; @@ -3153,11 +3192,11 @@ void btl_state_update_partner_move(void) { if (phi_s3 == FALSE) { for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { enemyActor = battleStatus->enemyActors[i]; - if (enemyActor != NULL && enemyActor->onHitScript != NULL) { - if (does_script_exist(enemyActor->onHitID)) { + if (enemyActor != NULL && enemyActor->handleEventScript != NULL) { + if (does_script_exist(enemyActor->handleEventScriptID)) { phi_s3 = TRUE; } else { - enemyActor->onHitScript = NULL; + enemyActor->handleEventScript = NULL; } } } @@ -3180,55 +3219,55 @@ void btl_state_update_partner_move(void) { partner->isGlowing = 0; gBattleStatus.flags1 &= ~BS_FLAGS1_40000000; } - if (btl_check_player_defeated() == FALSE) { - for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { - enemyActor = battleStatus->enemyActors[i]; - if (enemyActor != NULL) { - if (!(enemyActor->flags & ACTOR_FLAG_NO_DMG_APPLY)) { - enemyActor->flags |= (ACTOR_FLAG_8000000 | ACTOR_FLAG_4000000); - } + if (btl_check_player_defeated()) { + return; + } + + for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { + enemyActor = battleStatus->enemyActors[i]; + if (enemyActor != NULL) { + if (!(enemyActor->flags & ACTOR_FLAG_NO_DMG_APPLY)) { + enemyActor->flags |= (ACTOR_FLAG_8000000 | ACTOR_FLAG_4000000); } } + } - btl_update_ko_status(); + btl_update_ko_status(); - if (partner->status == 0xD && !btl_are_all_enemies_defeated()) { - btl_cam_use_preset(BTL_CAM_PRESET_54); - btl_show_battle_message(0x23, 60); - partner->status = 0; - partner->disableDismissTimer = 0; - gBattleSubState = BATTLE_SUB_STATE_UNK_B; - partner->flags |= ACTOR_FLAG_8000000; - } else { - gBattleSubState = BATTLE_SUB_STATE_UNK_14; - } + if (partner->status == 0xD && !btl_are_all_enemies_defeated()) { + btl_cam_use_preset(BTL_CAM_PRESET_54); + btl_show_battle_message(BTL_MSG_23, 60); + partner->status = 0; + partner->disableDismissTimer = 0; + gBattleSubState = BTL_SUBSTATE_PARTNER_MOVE_UNK_B; + partner->flags |= ACTOR_FLAG_8000000; } else { - return; + gBattleSubState = BTL_SUBSTATE_PARTNER_MOVE_UNK_14; } } } } } break; - case BATTLE_SUB_STATE_UNK_B: + case BTL_SUBSTATE_PARTNER_MOVE_UNK_B: if (btl_is_popup_displayed() == FALSE) { btl_cam_use_preset(BTL_CAM_PRESET_C); btl_cam_move(15); D_8029F248 = 10; - gBattleSubState = BATTLE_SUB_STATE_UNK_C; + gBattleSubState = BTL_SUBSTATE_PARTNER_MOVE_UNK_C; } break; - case BATTLE_SUB_STATE_UNK_C: + case BTL_SUBSTATE_PARTNER_MOVE_UNK_C: if (D_8029F248 != 0) { D_8029F248--; } else { - gBattleSubState = BATTLE_SUB_STATE_UNK_14; + gBattleSubState = BTL_SUBSTATE_PARTNER_MOVE_UNK_14; } break; } switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_14: + case BTL_SUBSTATE_PARTNER_MOVE_UNK_14: for (phi_s3 = FALSE, i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { enemyActor = battleStatus->enemyActors[i]; if (enemyActor != NULL) { @@ -3240,43 +3279,43 @@ void btl_state_update_partner_move(void) { } if (phi_s3 == FALSE) { - gBattleSubState = BATTLE_SUB_STATE_UNK_1E; + gBattleSubState = BTL_SUBSTATE_PARTNER_MOVE_UNK_1E; } else { btl_cam_use_preset(BTL_CAM_PRESET_D); switchCondition = enemyActor->status - 4; switch (switchCondition) { case 0: - phi_s0 = 0x12; + messageIndex = BTL_MSG_12; break; case 2: - phi_s0 = 0x13; + messageIndex = BTL_MSG_13; break; case 3: - phi_s0 = 0x14; + messageIndex = BTL_MSG_14; break; case 5: - phi_s0 = 0x15; + messageIndex = BTL_MSG_15; break; case 6: - phi_s0 = 0x16; + messageIndex = BTL_MSG_16; break; case 1: - phi_s0 = 0x17; + messageIndex = BTL_MSG_17; break; case 7: - phi_s0 = 0x18; + messageIndex = BTL_MSG_18; break; case 4: - phi_s0 = 0x19; + messageIndex = BTL_MSG_19; break; default: - phi_s0 = 0; - gBattleSubState = BATTLE_SUB_STATE_UNK_14; + messageIndex = 0; + gBattleSubState = BTL_SUBSTATE_PARTNER_MOVE_UNK_14; break; } sfx_play_sound(SOUND_2107); - btl_show_battle_message(phi_s0, 60); + btl_show_battle_message(messageIndex, 60); for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { enemyActor = battleStatus->enemyActors[i]; @@ -3284,28 +3323,30 @@ void btl_state_update_partner_move(void) { enemyActor->status = 0; } } - gBattleSubState = BATTLE_SUB_STATE_UNK_15; + gBattleSubState = BTL_SUBSTATE_PARTNER_MOVE_UNK_15; } break; - case BATTLE_SUB_STATE_UNK_15: + case BTL_SUBSTATE_PARTNER_MOVE_UNK_15: if (btl_is_popup_displayed() == FALSE) { btl_cam_use_preset(BTL_CAM_PRESET_C); btl_cam_move(15); D_8029F248 = 10; - gBattleSubState = BATTLE_SUB_STATE_UNK_16; + gBattleSubState = BTL_SUBSTATE_PARTNER_MOVE_UNK_16; } break; - case BATTLE_SUB_STATE_UNK_16: + case BTL_SUBSTATE_PARTNER_MOVE_UNK_16: if (D_8029F248 != 0) { D_8029F248--; } else { - gBattleSubState = BATTLE_SUB_STATE_UNK_1E; + gBattleSubState = BTL_SUBSTATE_PARTNER_MOVE_UNK_1E; } break; } - if (gBattleSubState == BATTLE_SUB_STATE_UNK_1E && (partner->takeTurnScript == NULL || - !does_script_exist(partner->takeTurnID))) { + if (gBattleSubState == BTL_SUBSTATE_PARTNER_MOVE_UNK_1E) { + if (partner->takeTurnScript != NULL && does_script_exist(partner->takeTurnScriptID)) { + return; + } partner->takeTurnScript = NULL; btl_set_state(BATTLE_STATE_END_PARTNER_TURN); } @@ -3317,18 +3358,19 @@ void btl_state_draw_partner_move(void) { void btl_state_update_end_partner_turn(void) { BattleStatus* battleStatus = &gBattleStatus; - if (gBattleSubState == BATTLE_SUB_STATE_UNK_0) { + if (gBattleSubState == BTL_SUBSTATE_INIT) { battleStatus->flags2 |= BS_FLAGS2_4; - if (!btl_check_enemies_defeated()) { - battleStatus->flags1 &= ~BS_FLAGS1_80000; - battleStatus->flags2 &= ~BS_FLAGS2_10; + if (btl_check_enemies_defeated()) { + return; + } + battleStatus->flags1 &= ~BS_FLAGS1_80000; + battleStatus->flags2 &= ~BS_FLAGS2_10; - if (battleStatus->unk_94 < 0) { - battleStatus->unk_94 = 0; - btl_set_state(BATTLE_STATE_END_TURN); - } else { - btl_set_state(BATTLE_STATE_9); - } + if (battleStatus->unk_94 < 0) { + battleStatus->unk_94 = 0; + btl_set_state(BATTLE_STATE_END_TURN); + } else { + btl_set_state(BATTLE_STATE_9); } } } @@ -3341,19 +3383,21 @@ void btl_state_update_next_enemy(void) { Actor* player = gBattleStatus.playerActor; Actor* partner = gBattleStatus.partnerActor; Actor* enemy; - s32 cond; + s32 skipEnemy; s32 i; switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_0: - case BATTLE_SUB_STATE_UNK_1: + case BTL_SUBSTATE_NEXT_ENEMY_INIT: + case BTL_SUBSTATE_NEXT_ENEMY_UNK_1: i = battleStatus->nextEnemyIndex; if (i >= battleStatus->numEnemyActors) { + // all enemies have been exhausted battleStatus->nextEnemyIndex = 0; btl_set_state(BATTLE_STATE_END_TURN); return; } + // find the next eligible enemy while (TRUE) { if (battleStatus->enemyIDs[i] >= 0) { u16 enemyID = battleStatus->enemyIDs[i]; @@ -3380,30 +3424,36 @@ void btl_state_update_next_enemy(void) { battleStatus->currentTurnEnemy = enemy; battleStatus->nextEnemyIndex = i; - cond = enemy->debuff == STATUS_SLEEP; + skipEnemy = FALSE; + + if (enemy->debuff == STATUS_SLEEP) { + skipEnemy = TRUE; + } if (enemy->debuff == STATUS_FEAR) { - cond = TRUE; + skipEnemy = TRUE; } if (enemy->debuff == STATUS_DIZZY) { - cond = TRUE; + skipEnemy = TRUE; } if (enemy->debuff == STATUS_PARALYZE) { - cond = TRUE; + skipEnemy = TRUE; } if (enemy->debuff == STATUS_FROZEN) { - cond = TRUE; + skipEnemy = TRUE; } if (enemy->debuff == STATUS_STOP) { - cond = TRUE; + skipEnemy = TRUE; } if (enemy->stoneStatus == STATUS_STONE) { - cond = TRUE; + skipEnemy = TRUE; } if (enemy->flags & ACTOR_FLAG_10000) { - cond = TRUE; + skipEnemy = TRUE; } - if (cond) { - gBattleSubState = BATTLE_SUB_STATE_UNK_0; + + if (skipEnemy) { + // reset state to fetch next enemy + gBattleSubState = BTL_SUBSTATE_NEXT_ENEMY_INIT; return; } @@ -3426,23 +3476,25 @@ void btl_state_update_next_enemy(void) { gBattleStatus.flags2 |= BS_FLAGS2_10000; D_8029F244 = enemy->unk_134; - if (enemy->onTurnChanceScriptSource != NULL) { + if (enemy->handlePhaseSource != NULL) { Evt* onTurnChanceScript; battleStatus->battlePhase = PHASE_ENEMY_BEGIN; - onTurnChanceScript = start_script(enemy->onTurnChanceScriptSource, EVT_PRIORITY_A, 0); - enemy->onTurnChangeScript = onTurnChanceScript; - enemy->onTurnChangeID = onTurnChanceScript->id; + onTurnChanceScript = start_script(enemy->handlePhaseSource, EVT_PRIORITY_A, 0); + enemy->handlePhaseScript = onTurnChanceScript; + enemy->handleBatttlePhaseScriptID = onTurnChanceScript->id; onTurnChanceScript->owner1.actorID = battleStatus->activeEnemyActorID; } - gBattleSubState = BATTLE_SUB_STATE_UNK_2; + gBattleSubState = BTL_SUBSTATE_NEXT_ENEMY_DONE; break; - case BATTLE_SUB_STATE_UNK_2: + case BTL_SUBSTATE_NEXT_ENEMY_DONE: if (battleStatus->unk_8C == 0) { enemy = get_actor(battleStatus->activeEnemyActorID); - if (enemy != NULL && enemy->unk_134 == D_8029F244) { - if (enemy->onTurnChanceScriptSource == NULL || !does_script_exist(enemy->onTurnChangeID)) { + if (enemy == NULL || enemy->unk_134 != D_8029F244) { + btl_set_state(BATTLE_STATE_NEXT_ENEMY); + } else { + if (enemy->handlePhaseSource == NULL || !does_script_exist(enemy->handleBatttlePhaseScriptID)) { if (battleStatus->unk_94 < 0) { battleStatus->unk_94 = 0; btl_set_state(BATTLE_STATE_END_TURN); @@ -3450,8 +3502,6 @@ void btl_state_update_next_enemy(void) { btl_set_state(BATTLE_STATE_ENEMY_MOVE); } } - } else { - btl_set_state(BATTLE_STATE_NEXT_ENEMY); } } break; @@ -3470,11 +3520,11 @@ void btl_state_update_enemy_move(void) { Evt* script; s32 messageIndex; - s32 cond; + s32 waitingForEnemyScript; switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_0: - case BATTLE_SUB_STATE_UNK_1: + case BTL_SUBSTATE_ENEMY_MOVE_EXECUTE: + case BTL_SUBSTATE_ENEMY_MOVE_UNK_1: gBattleStatus.flags1 &= ~BS_FLAGS1_2; gBattleStatus.flags1 &= ~BS_FLAGS1_200000; player->flags &= ~ACTOR_FLAG_8000000; @@ -3515,166 +3565,170 @@ void btl_state_update_enemy_move(void) { if (!(enemy->flags & ACTOR_FLAG_NO_ATTACK)) { reset_all_actor_sounds(enemy); battleStatus->battlePhase = PHASE_EXECUTE_ACTION; - script = start_script(enemy->takeTurnScriptSource, 0xA, 0); + script = start_script(enemy->takeTurnSource, EVT_PRIORITY_A, 0); enemy->takeTurnScript = script; - enemy->takeTurnID = script->id; + enemy->takeTurnScriptID = script->id; script->owner1.actorID = battleStatus->activeEnemyActorID; } - gBattleSubState = BATTLE_SUB_STATE_UNK_2; + gBattleSubState = BTL_SUBSTATE_ENEMY_MOVE_AWAIT_SCRIPTS; break; - case BATTLE_SUB_STATE_UNK_2: - if (player->takeTurnScript == NULL || !does_script_exist(player->takeTurnID)) { - player->takeTurnScript = NULL; + case BTL_SUBSTATE_ENEMY_MOVE_AWAIT_SCRIPTS: + if (player->takeTurnScript != NULL && does_script_exist(player->takeTurnScriptID)) { + break; + } + player->takeTurnScript = NULL; - if (player->onHitScript == NULL || !does_script_exist(player->onHitID)) { - player->onHitScript = NULL; - if (partner != NULL) { - if (partner->onHitScript == NULL || !does_script_exist(partner->onHitID)) { - partner->onHitScript = NULL; - } else { + if (player->handleEventScript != NULL && does_script_exist(player->handleEventScriptID)) { + break; + } + player->handleEventScript = NULL; + + if (partner != NULL) { + if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) { + break; + } + partner->handleEventScript = NULL; + } + + waitingForEnemyScript = FALSE; + for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { + enemy = battleStatus->enemyActors[i]; + if (enemy != NULL && enemy->handleEventScript != NULL) { + if (does_script_exist(enemy->handleEventScriptID)) { + waitingForEnemyScript = TRUE; + } else { + enemy->handleEventScript = NULL; + } + } + } + + if (waitingForEnemyScript) { + break; + } + + if (btl_check_player_defeated()) { + return; + } + + for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { + enemy = battleStatus->enemyActors[i]; + if (enemy != NULL && enemy->takeTurnScript != NULL) { + if (does_script_exist(enemy->takeTurnScriptID)) { + waitingForEnemyScript = TRUE; + } else { + enemy->takeTurnScript = NULL; + } + } + } + + if (!waitingForEnemyScript || (gBattleStatus.flags1 & BS_FLAGS1_200000)) { + gBattleStatus.flags1 &= ~BS_FLAGS1_100; + gBattleStatus.flags2 &= ~BS_FLAGS2_4000; + if (btl_check_enemies_defeated()) { + return; + } + + if (battleStatus->unk_8C == 0) { + if (gGameStatusPtr->demoFlags & 1) { + btl_set_state(BATTLE_STATE_END_DEMO_BATTLE); + } else { + btl_update_ko_status(); + if (player->status != 0) { + player->flags |= ACTOR_FLAG_8000000 | ACTOR_FLAG_4000000; + if (partner != NULL) { + partner->flags |= ACTOR_FLAG_8000000 | ACTOR_FLAG_4000000; + } + btl_cam_use_preset(BTL_CAM_PRESET_33); + + switch (player->status) { + case STATUS_DIZZY: + messageIndex = BTL_MSG_0A; + break; + case STATUS_SLEEP: + messageIndex = BTL_MSG_0B; + break; + case STATUS_FROZEN: + messageIndex = BTL_MSG_0C; + break; + case STATUS_POISON: + messageIndex = BTL_MSG_0D; + break; + case STATUS_SHRINK: + messageIndex = BTL_MSG_0E; + break; + case STATUS_PARALYZE: + messageIndex = BTL_MSG_0F; + break; + default: + messageIndex = 0; + gBattleSubState = BTL_SUBSTATE_ENEMY_MOVE_CHECK_PARTNER; + break; + } + btl_show_battle_message(messageIndex, 60); + player->status = 0; + gBattleSubState = BTL_SUBSTATE_ENEMY_MOVE_AWAIT_PLAYER_POPUP_DONE; + break; + } else { + gBattleSubState = BTL_SUBSTATE_ENEMY_MOVE_CHECK_PARTNER; break; - } - } - - cond = FALSE; - for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { - enemy = battleStatus->enemyActors[i]; - if (enemy != NULL && enemy->onHitScript != NULL) { - if (does_script_exist(enemy->onHitID)) { - cond = TRUE; - } else { - enemy->onHitScript = NULL; - } - } - } - - if (!cond) { - if (btl_check_player_defeated()) { - return; - } - - for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { - enemy = battleStatus->enemyActors[i]; - if (enemy != NULL && enemy->takeTurnScript != NULL) { - if (does_script_exist(enemy->takeTurnID)) { - cond = TRUE; - } else { - enemy->takeTurnScript = NULL; - } - } - } - - if (!cond || (gBattleStatus.flags1 & BS_FLAGS1_200000)) { - gBattleStatus.flags1 &= ~BS_FLAGS1_100; - gBattleStatus.flags2 &= ~BS_FLAGS2_4000; - if (btl_check_enemies_defeated()) { - return; - } - - if (battleStatus->unk_8C == 0) { - if (gGameStatusPtr->demoFlags & 1) { - btl_set_state(BATTLE_STATE_END_DEMO_BATTLE); - } else { - btl_update_ko_status(); - if (player->status != 0) { - player->flags |= ACTOR_FLAG_8000000 | ACTOR_FLAG_4000000; - if (partner != NULL) { - partner->flags |= ACTOR_FLAG_8000000 | ACTOR_FLAG_4000000; - } - btl_cam_use_preset(BTL_CAM_PRESET_33); - - switch (player->status) { - case STATUS_DIZZY: - messageIndex = 0xA; - break; - case STATUS_SLEEP: - messageIndex = 0xB; - break; - case STATUS_FROZEN: - messageIndex = 0xC; - break; - case STATUS_POISON: - messageIndex = 0xD; - break; - case STATUS_SHRINK: - messageIndex = 0xE; - break; - case STATUS_PARALYZE: - messageIndex = 0xF; - break; - default: - messageIndex = 0; - gBattleSubState = BATTLE_SUB_STATE_UNK_14; - break; - } - btl_show_battle_message(messageIndex, 60); - player->status = 0; - gBattleSubState = BATTLE_SUB_STATE_UNK_B; - break; - } else { - gBattleSubState = BATTLE_SUB_STATE_UNK_14; - break; - } - } - } } } } } break; - case BATTLE_SUB_STATE_UNK_B: + case BTL_SUBSTATE_ENEMY_MOVE_AWAIT_PLAYER_POPUP_DONE: if (!btl_is_popup_displayed()) { btl_cam_use_preset(BTL_CAM_PRESET_C); btl_cam_move(15); D_8029F248 = 10; - gBattleSubState = BATTLE_SUB_STATE_UNK_C; + gBattleSubState = BTL_SUBSTATE_ENEMY_MOVE_POST_PLAYER_POPUP_DELAY; } break; - case BATTLE_SUB_STATE_UNK_C: + case BTL_SUBSTATE_ENEMY_MOVE_POST_PLAYER_POPUP_DELAY: if (D_8029F248 != 0) { D_8029F248--; } else { - gBattleSubState = BATTLE_SUB_STATE_UNK_14; + gBattleSubState = BTL_SUBSTATE_ENEMY_MOVE_CHECK_PARTNER; break; } break; } switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_14: + case BTL_SUBSTATE_ENEMY_MOVE_CHECK_PARTNER: if (partner != NULL) { - if (partner->status == 0xD) { + if (partner->status == STATUS_DAZE) { player->flags |= ACTOR_FLAG_8000000 | ACTOR_FLAG_4000000; partner->flags |= ACTOR_FLAG_8000000 | ACTOR_FLAG_4000000; btl_cam_use_preset(BTL_CAM_PRESET_54); - btl_show_battle_message(0x23, 60); + btl_show_battle_message(BTL_MSG_23, 60); partner->status = 0; - gBattleSubState = BATTLE_SUB_STATE_UNK_15; + gBattleSubState = BTL_SUBSTATE_ENEMY_MOVE_AWAIT_PARTNER_POPUP_DONE; } else { - gBattleSubState = BATTLE_SUB_STATE_UNK_1E; + gBattleSubState = BTL_SUBSTATE_ENEMY_MOVE_DONE; } } else { - gBattleSubState = BATTLE_SUB_STATE_UNK_1E; + gBattleSubState = BTL_SUBSTATE_ENEMY_MOVE_DONE; } break; - case BATTLE_SUB_STATE_UNK_15: + case BTL_SUBSTATE_ENEMY_MOVE_AWAIT_PARTNER_POPUP_DONE: if (!btl_is_popup_displayed()) { btl_cam_use_preset(BTL_CAM_PRESET_C); btl_cam_move(15); D_8029F248 = 10; - gBattleSubState = BATTLE_SUB_STATE_UNK_16; + gBattleSubState = BTL_SUBSTATE_ENEMY_MOVE_POST_PARTNER_POPUP_DELAY; } break; - case BATTLE_SUB_STATE_UNK_16: + case BTL_SUBSTATE_ENEMY_MOVE_POST_PARTNER_POPUP_DELAY: if (D_8029F248 != 0) { D_8029F248--; } else { - gBattleSubState = BATTLE_SUB_STATE_UNK_1E; + gBattleSubState = BTL_SUBSTATE_ENEMY_MOVE_DONE; } break; } - if (gBattleSubState == BATTLE_SUB_STATE_UNK_1E) { + if (gBattleSubState == BTL_SUBSTATE_ENEMY_MOVE_DONE) { btl_set_state(BATTLE_STATE_NEXT_ENEMY); } } @@ -3690,28 +3744,28 @@ void btl_state_update_first_strike(void) { Actor* partner = gBattleStatus.partnerActor; Evt* script; Actor* enemy; - s32 cond; + s32 enemyScriptRunning; s32 i; switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_0: + case BTL_SUBSTATE_FIRST_STRIKE_UNK_0: D_8029F254 = 0; btl_merlee_on_first_strike(); if (playerData->playerFirstStrikes < 9999) { playerData->playerFirstStrikes++; } battleStatus->rushFlags = RUSH_FLAG_NONE; - gBattleStatus.flags2 &= ~BS_FLAGS2_8000000; + gBattleStatus.flags2 &= ~BS_FLAGS2_HAS_RUSH; - if (!(gBattleStatus.flags2 & BS_FLAGS2_40)) { + if (!(gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE)) { if (playerData->curHP < 2 && is_ability_active(ABILITY_MEGA_RUSH)) { - gBattleStatus.flags2 |= BS_FLAGS2_8000000; + gBattleStatus.flags2 |= BS_FLAGS2_HAS_RUSH; battleStatus->rushFlags |= RUSH_FLAG_MEGA; } if (playerData->curHP < 6 && is_ability_active(ABILITY_POWER_RUSH) && !(battleStatus->rushFlags & RUSH_FLAG_MEGA)) { - gBattleStatus.flags2 |= BS_FLAGS2_8000000; + gBattleStatus.flags2 |= BS_FLAGS2_HAS_RUSH; battleStatus->rushFlags |= RUSH_FLAG_POWER; } } @@ -3735,22 +3789,22 @@ void btl_state_update_first_strike(void) { } enemy = get_actor(ACTOR_ENEMY0); - if (enemy->onHitScriptSource != NULL) { + if (enemy->handleEventSource != NULL) { enemy->lastEventType = EVENT_BEGIN_FIRST_STRIKE; - script = start_script(enemy->onHitScriptSource, 0xA, EVT_FLAG_RUN_IMMEDIATELY); - enemy->onHitScript = script; - enemy->onHitID = script->id; + script = start_script(enemy->handleEventSource, EVT_PRIORITY_A, EVT_FLAG_RUN_IMMEDIATELY); + enemy->handleEventScript = script; + enemy->handleEventScriptID = script->id; script->owner1.actorID = enemy->actorID; } - gBattleSubState = BATTLE_SUB_STATE_UNK_1; + gBattleSubState = BTL_SUBSTATE_FIRST_STRIKE_UNK_1; break; - case BATTLE_SUB_STATE_UNK_1: + case BTL_SUBSTATE_FIRST_STRIKE_UNK_1: enemy = get_actor(ACTOR_ENEMY0); - if (enemy->onHitScriptSource != NULL) { - if (does_script_exist(enemy->onHitID)) { + if (enemy->handleEventSource != NULL) { + if (does_script_exist(enemy->handleEventScriptID)) { break; } else { - enemy->onHitScript = NULL; + enemy->handleEventScript = NULL; } } @@ -3766,14 +3820,14 @@ void btl_state_update_first_strike(void) { btl_cam_target_actor(0); reset_actor_turn_info(); battleStatus->battlePhase = PHASE_FIRST_STRIKE; - script = start_script(&PlayerScriptDispatcher, 0xA, 0); + script = start_script(&PlayerScriptDispatcher, EVT_PRIORITY_A, 0); player->takeTurnScript = script; D_8029F248 = 3; - gBattleSubState = BATTLE_SUB_STATE_UNK_2; - player->takeTurnID = script->id; + gBattleSubState = BTL_SUBSTATE_FIRST_STRIKE_UNK_2; + player->takeTurnScriptID = script->id; script->owner1.actorID = ACTOR_PLAYER; break; - case BATTLE_SUB_STATE_UNK_2: + case BTL_SUBSTATE_FIRST_STRIKE_UNK_2: if (D_8029F248 != 0) { D_8029F248--; } else { @@ -3781,94 +3835,100 @@ void btl_state_update_first_strike(void) { } if (!(gBattleStatus.flags1 & BS_FLAGS1_200000)) { - if (player->takeTurnScript != NULL && does_script_exist(player->takeTurnID)) { + if (player->takeTurnScript != NULL && does_script_exist(player->takeTurnScriptID)) { break; - } else { - player->takeTurnScript = NULL; } + player->takeTurnScript = NULL; } gBattleStatus.flags1 &= ~BS_FLAGS1_100; - if (player->onHitScript == NULL || !does_script_exist(player->onHitID)) { - player->onHitScript = NULL; + if (player->handleEventScript == NULL || !does_script_exist(player->handleEventScriptID)) { + player->handleEventScript = NULL; if (partner != NULL) { - if (partner->onHitScript != NULL && does_script_exist(partner->onHitID)) { + if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) { break; - } else { - partner->onHitScript = NULL; } + partner->handleEventScript = NULL; } - cond = FALSE; + enemyScriptRunning = FALSE; for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { enemy = battleStatus->enemyActors[i]; if (enemy != NULL && enemy->takeTurnScript != NULL) { - if (does_script_exist(enemy->takeTurnID)) { - cond = TRUE; + if (does_script_exist(enemy->takeTurnScriptID)) { + enemyScriptRunning = TRUE; } else { enemy->takeTurnScript = NULL; } } } + if (enemyScriptRunning) { + break; + } - if (!cond) { - for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { - enemy = battleStatus->enemyActors[i]; - if (enemy != NULL && enemy->onHitScript != NULL) { - if (does_script_exist(enemy->onHitID)) { - cond = TRUE; - } else { - enemy->onHitScript = NULL; - } + for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { + enemy = battleStatus->enemyActors[i]; + if (enemy != NULL && enemy->handleEventScript != NULL) { + if (does_script_exist(enemy->handleEventScriptID)) { + enemyScriptRunning = TRUE; + } else { + enemy->handleEventScript = NULL; } } + } + if (enemyScriptRunning) { + break; + } - if (!cond) { - for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { - enemy = battleStatus->enemyActors[i]; - if (enemy != NULL) { - enemy->flags &= ~ACTOR_FLAG_80000; - } + for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { + enemy = battleStatus->enemyActors[i]; + if (enemy != NULL) { + enemy->flags &= ~ACTOR_FLAG_80000; + } + } + + if (battleStatus->unk_8C == 0) { + decrement_status_menu_disabled(); + if (!(gGameStatusPtr->demoFlags & 1)) { + Actor* target; + + if (btl_check_player_defeated() || btl_check_enemies_defeated()) { + return; } - if (battleStatus->unk_8C == 0) { - decrement_status_menu_disabled(); - if (!(gGameStatusPtr->demoFlags & 1)) { - if (!btl_check_player_defeated() && !btl_check_enemies_defeated()) { - Actor* target = get_actor(player->targetActorID); - - if (target != NULL) { - if (target->onHitScriptSource != NULL) { - target->lastEventType = EVENT_END_FIRST_STRIKE; - script = start_script(target->onHitScriptSource, 0xA, EVT_FLAG_RUN_IMMEDIATELY); - target->onHitScript = script; - target->onHitID = script->id; - script->owner1.actorID = target->actorID; - } - } - gBattleSubState = BATTLE_SUB_STATE_UNK_3; - } - } else { - btl_set_state(BATTLE_STATE_END_DEMO_BATTLE); + target = get_actor(player->targetActorID); + if (target != NULL) { + if (target->handleEventSource != NULL) { + target->lastEventType = EVENT_END_FIRST_STRIKE; + script = start_script(target->handleEventSource, EVT_PRIORITY_A, EVT_FLAG_RUN_IMMEDIATELY); + target->handleEventScript = script; + target->handleEventScriptID = script->id; + script->owner1.actorID = target->actorID; } } + gBattleSubState = BTL_SUBSTATE_FIRST_STRIKE_UNK_3; + } else { + btl_set_state(BATTLE_STATE_END_DEMO_BATTLE); } } } break; - case BATTLE_SUB_STATE_UNK_3: - cond = FALSE; + case BTL_SUBSTATE_FIRST_STRIKE_UNK_3: + enemyScriptRunning = FALSE; for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { enemy = battleStatus->enemyActors[i]; - if (enemy != NULL && enemy->onHitScript != NULL) { - if (does_script_exist(enemy->onHitID)) { - cond = TRUE; + if (enemy != NULL && enemy->handleEventScript != NULL) { + if (does_script_exist(enemy->handleEventScriptID)) { + enemyScriptRunning = TRUE; } else { - enemy->onHitScript = NULL; + enemy->handleEventScript = NULL; } } } - if (!cond && (player->takeTurnScript == NULL || !does_script_exist(player->takeTurnID))) { + if (enemyScriptRunning) { + break; + } + if (player->takeTurnScript == NULL || !does_script_exist(player->takeTurnScriptID)) { player->takeTurnScript = NULL; btl_set_state(BATTLE_STATE_BEGIN_TURN); } @@ -3908,7 +3968,7 @@ void btl_state_update_partner_striking_first(void) { s32 i; switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_0: + case BTL_SUBSTATE_PARTNER_FIRST_STRIKE_UNK_0: D_8029F254 = 0; level = partner->actorBlueprint->level; switch (playerData->currentPartner) { @@ -3926,16 +3986,16 @@ void btl_state_update_partner_striking_first(void) { break; } actor = get_actor(ACTOR_ENEMY0); - if (actor->onHitScriptSource != NULL) { + if (actor->handleEventSource != NULL) { actor->lastEventType = EVENT_BEGIN_FIRST_STRIKE; - script = start_script(actor->onHitScriptSource, EVT_PRIORITY_A, EVT_FLAG_RUN_IMMEDIATELY); - actor->onHitScript = script; - actor->onHitID = script->id; + script = start_script(actor->handleEventSource, EVT_PRIORITY_A, EVT_FLAG_RUN_IMMEDIATELY); + actor->handleEventScript = script; + actor->handleEventScriptID = script->id; script->owner1.actorID = actor->actorID; } - gBattleSubState = BATTLE_SUB_STATE_UNK_1; + gBattleSubState = BTL_SUBSTATE_PARTNER_FIRST_STRIKE_UNK_1; break; - case BATTLE_SUB_STATE_UNK_1: + case BTL_SUBSTATE_PARTNER_FIRST_STRIKE_UNK_1: player_create_target_list(partner); target = &partner->targetData[partner->targetIndexList[0]]; partner->targetActorID = target->actorID; @@ -3951,32 +4011,32 @@ void btl_state_update_partner_striking_first(void) { btl_cam_target_actor(ACTOR_PARTNER); reset_actor_turn_info(); battleStatus->battlePhase = PHASE_FIRST_STRIKE; - script = start_script(partner->takeTurnScriptSource, EVT_PRIORITY_A, 0); + script = start_script(partner->takeTurnSource, EVT_PRIORITY_A, 0); partner->takeTurnScript = script; D_8029F248 = 3; - gBattleSubState = BATTLE_SUB_STATE_UNK_2; - partner->takeTurnID = script->id; + gBattleSubState = BTL_SUBSTATE_PARTNER_FIRST_STRIKE_UNK_2; + partner->takeTurnScriptID = script->id; script->owner1.actorID = ACTOR_PARTNER; break; - case BATTLE_SUB_STATE_UNK_2: + case BTL_SUBSTATE_PARTNER_FIRST_STRIKE_UNK_2: if (D_8029F248 != 0) { D_8029F248--; } else { D_8029F254 = 1; } - if (partner->takeTurnScript == NULL || !does_script_exist(partner->takeTurnID)) { + if (partner->takeTurnScript == NULL || !does_script_exist(partner->takeTurnScriptID)) { partner->takeTurnScript = NULL; - if (partner->onHitScript == NULL || !does_script_exist(partner->onHitID)) { - partner->onHitScript = NULL; - if (player->onHitScript == NULL || !does_script_exist(player->onHitID)) { - player->onHitScript = NULL; + if (partner->handleEventScript == NULL || !does_script_exist(partner->handleEventScriptID)) { + partner->handleEventScript = NULL; + if (player->handleEventScript == NULL || !does_script_exist(player->handleEventScriptID)) { + player->handleEventScript = NULL; found = FALSE; for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { actor = battleStatus->enemyActors[i]; if (actor != NULL && actor->takeTurnScript != NULL) { - if (does_script_exist(actor->takeTurnID)) { + if (does_script_exist(actor->takeTurnScriptID)) { found = TRUE; } else { actor->takeTurnScript = NULL; @@ -3987,11 +4047,11 @@ void btl_state_update_partner_striking_first(void) { if (!found) { for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { actor = battleStatus->enemyActors[i]; - if (actor != NULL && actor->onHitScript != NULL) { - if (does_script_exist(actor->onHitID)) { + if (actor != NULL && actor->handleEventScript != NULL) { + if (does_script_exist(actor->handleEventScriptID)) { found = TRUE; } else { - actor->onHitScript = NULL; + actor->handleEventScript = NULL; } } } @@ -4006,19 +4066,21 @@ void btl_state_update_partner_striking_first(void) { if (battleStatus->unk_8C == 0) { decrement_status_menu_disabled(); - if (!btl_check_player_defeated() && !btl_check_enemies_defeated()) { - actor = get_actor(partner->targetActorID); - if (actor != NULL) { - if (actor->onHitScriptSource != NULL) { - actor->lastEventType = EVENT_END_FIRST_STRIKE; - script = start_script(actor->onHitScriptSource, EVT_PRIORITY_A, EVT_FLAG_RUN_IMMEDIATELY); - actor->onHitScript = script; - actor->onHitID = script->id; - script->owner1.actorID = actor->actorID; - } - } - gBattleSubState = BATTLE_SUB_STATE_UNK_3; + if (btl_check_player_defeated() || btl_check_enemies_defeated()) { + return; } + + actor = get_actor(partner->targetActorID); + if (actor != NULL) { + if (actor->handleEventSource != NULL) { + actor->lastEventType = EVENT_END_FIRST_STRIKE; + script = start_script(actor->handleEventSource, EVT_PRIORITY_A, EVT_FLAG_RUN_IMMEDIATELY); + actor->handleEventScript = script; + actor->handleEventScriptID = script->id; + script->owner1.actorID = actor->actorID; + } + } + gBattleSubState = BTL_SUBSTATE_PARTNER_FIRST_STRIKE_UNK_3; } } } @@ -4026,16 +4088,16 @@ void btl_state_update_partner_striking_first(void) { } } break; - case BATTLE_SUB_STATE_UNK_3: + case BTL_SUBSTATE_PARTNER_FIRST_STRIKE_UNK_3: found = FALSE; for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { actor = battleStatus->enemyActors[i]; - if (actor != NULL && actor->onHitScript != NULL) { - if (does_script_exist(actor->onHitID)) { + if (actor != NULL && actor->handleEventScript != NULL) { + if (does_script_exist(actor->handleEventScriptID)) { found = TRUE; } else { - actor->onHitScript = NULL; + actor->handleEventScript = NULL; } } } @@ -4078,7 +4140,7 @@ void btl_state_update_enemy_striking_first(void) { s32 j; switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_0: + case BTL_SUBSTATE_ENEMY_FIRST_STRIKE_UNK_0: battleStatus->unk_8C = 0; battleStatus->lastAttackDamage = 0; battleStatus->unk_19A = 0; @@ -4145,14 +4207,14 @@ void btl_state_update_enemy_striking_first(void) { actor = battleStatus->currentTurnEnemy; reset_actor_turn_info(); battleStatus->battlePhase = PHASE_FIRST_STRIKE; - script = start_script(actor->takeTurnScriptSource, EVT_PRIORITY_A, 0); + script = start_script(actor->takeTurnSource, EVT_PRIORITY_A, 0); actor->takeTurnScript = script; D_8029F248 = 3; - actor->takeTurnID = script->id; - gBattleSubState = BATTLE_SUB_STATE_UNK_2; + actor->takeTurnScriptID = script->id; + gBattleSubState = BTL_SUBSTATE_ENEMY_FIRST_STRIKE_UNK_2; script->owner1.actorID = battleStatus->activeEnemyActorID; break; - case BATTLE_SUB_STATE_UNK_2: + case BTL_SUBSTATE_ENEMY_FIRST_STRIKE_UNK_2: if (D_8029F248 != 0) { D_8029F248--; } else { @@ -4160,15 +4222,15 @@ void btl_state_update_enemy_striking_first(void) { } actor = battleStatus->currentTurnEnemy; - if (actor->takeTurnScript == NULL || !does_script_exist(actor->takeTurnID)) { + if (actor->takeTurnScript == NULL || !does_script_exist(actor->takeTurnScriptID)) { actor->takeTurnScript = NULL; - if (player->onHitScript == NULL || !does_script_exist(player->onHitID)) { - player->onHitScript = NULL; + if (player->handleEventScript == NULL || !does_script_exist(player->handleEventScriptID)) { + player->handleEventScript = NULL; if (partner != NULL) { - if (partner->onHitScript == NULL || !does_script_exist(partner->onHitID)) { - partner->onHitScript = NULL; + if (partner->handleEventScript == NULL || !does_script_exist(partner->handleEventScriptID)) { + partner->handleEventScript = NULL; } else { return; } @@ -4179,7 +4241,7 @@ void btl_state_update_enemy_striking_first(void) { for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { actor = battleStatus->enemyActors[i]; if (actor != NULL && actor->takeTurnScript != NULL) { - if (does_script_exist(actor->takeTurnID)) { + if (does_script_exist(actor->takeTurnScriptID)) { cond = TRUE; } else { actor->takeTurnScript = NULL; @@ -4190,11 +4252,11 @@ void btl_state_update_enemy_striking_first(void) { if (!cond) { for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { actor = battleStatus->enemyActors[i]; - if (actor != NULL && actor->onHitScript != NULL) { - if (does_script_exist(actor->onHitID)) { + if (actor != NULL && actor->handleEventScript != NULL) { + if (does_script_exist(actor->handleEventScriptID)) { cond = TRUE; } else { - actor->onHitScript = NULL; + actor->handleEventScript = NULL; } } } @@ -4208,10 +4270,10 @@ void btl_state_update_enemy_striking_first(void) { } } - if (battleStatus->unk_8C == 0 && - !btl_check_player_defeated() && - !btl_check_enemies_defeated()) - { + if (battleStatus->unk_8C == 0) { + if (btl_check_player_defeated() || btl_check_enemies_defeated()) { + return; + } btl_set_state(BATTLE_STATE_BEGIN_TURN); } } @@ -4244,7 +4306,7 @@ void btl_state_update_end_demo_battle(void) { s32 i; switch (gBattleSubState) { - case 0: + case BTL_SUBSTATE_END_DEMO_BATTLE_UNK_0: D_80280A30 = 0; if (D_802809F6 == -1) { if (D_802809F8 != 0) { @@ -4252,16 +4314,16 @@ void btl_state_update_end_demo_battle(void) { break; } } - gBattleSubState = BATTLE_SUB_STATE_UNK_1; + gBattleSubState = BTL_SUBSTATE_END_DEMO_BATTLE_UNK_1; break; - case 1: + case BTL_SUBSTATE_END_DEMO_BATTLE_UNK_1: switch (D_802809F6) { case 255: - gBattleSubState = BATTLE_SUB_STATE_UNK_2; + gBattleSubState = BTL_SUBSTATE_END_DEMO_BATTLE_UNK_2; return; case -1: if (D_80280A30 == 255) { - gBattleSubState = BATTLE_SUB_STATE_UNK_2; + gBattleSubState = BTL_SUBSTATE_END_DEMO_BATTLE_UNK_2; return; } D_80280A30 += 50; @@ -4271,8 +4333,8 @@ void btl_state_update_end_demo_battle(void) { return; } break; - case 2: - D_80280A30 = 0xFF; + case BTL_SUBSTATE_END_DEMO_BATTLE_UNK_2: + D_80280A30 = 255; gBattleStatus.flags1 &= ~BS_FLAGS1_1; if (D_800DC064 == NULL) { stage = blah->stage; @@ -4281,19 +4343,20 @@ void btl_state_update_end_demo_battle(void) { } if (stage->postBattle == NULL) { - gBattleSubState = BATTLE_SUB_STATE_UNK_4; + gBattleSubState = BTL_SUBSTATE_END_DEMO_BATTLE_UNK_4; } else { battleStatus->controlScript = start_script(stage->postBattle, EVT_PRIORITY_A, 0); - gBattleSubState = BATTLE_SUB_STATE_UNK_3; battleStatus->controlScriptID = battleStatus->controlScript->id; + gBattleSubState = BTL_SUBSTATE_END_DEMO_BATTLE_UNK_3; } break; - case 3: + case BTL_SUBSTATE_END_DEMO_BATTLE_UNK_3: if (does_script_exist(battleStatus->controlScriptID)) { break; } - gBattleSubState = BATTLE_SUB_STATE_UNK_4; - case 4: + gBattleSubState = BTL_SUBSTATE_END_DEMO_BATTLE_UNK_4; + //fallthrough + case BTL_SUBSTATE_END_DEMO_BATTLE_UNK_4: kill_all_scripts(); for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { @@ -4312,7 +4375,7 @@ void btl_state_update_end_demo_battle(void) { remove_all_effects(); set_windows_visible(WINDOW_GROUP_ALL); - if (gBattleStatus.flags2 & BS_FLAGS2_40) { + if (gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) { decrement_status_menu_disabled(); } diff --git a/src/16c8e0.c b/src/16c8e0.c index c800974b2b..8dc5710066 100644 --- a/src/16c8e0.c +++ b/src/16c8e0.c @@ -191,10 +191,10 @@ void initialize_battle(void) { } if (gGameStatusPtr->peachFlags & PEACH_STATUS_FLAG_IS_PEACH) { - gBattleStatus.flags2 |= BS_FLAGS2_40; + gBattleStatus.flags2 |= BS_FLAGS2_PEACH_BATTLE; increment_status_menu_disabled(); } else { - gBattleStatus.flags2 &= ~BS_FLAGS2_40; + gBattleStatus.flags2 &= ~BS_FLAGS2_PEACH_BATTLE; } create_worker_world(NULL, func_8023ED5C); @@ -230,7 +230,7 @@ void initialize_battle(void) { } bSavedPartner = playerData->currentPartner; - if (gBattleStatus.flags2 & BS_FLAGS2_40) { + if (gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) { playerData->currentPartner = PARTNER_TWINK; } } @@ -291,110 +291,110 @@ void btl_update(void) { cond = TRUE; if (battleStatus->unk_95 == 0 || battleStatus->unk_95 != gBattleState) { switch (gBattleState) { - case -1: - case 0: + case BATTLE_STATE_NEGATIVE_1: + case BATTLE_STATE_0: return; - case 1: + case BATTLE_STATE_NORMAL_START: btl_state_update_normal_start(); cond = FALSE; break; - case 7: + case BATTLE_STATE_BEGIN_PLAYER_TURN: btl_state_update_begin_player_turn(); break; - case 8: + case BATTLE_STATE_BEGIN_PARTNER_TURN: btl_state_update_begin_partner_turn(); break; - case 9: - func_80242FE0(); + case BATTLE_STATE_9: + btl_state_update_9(); break; - case 5: + case BATTLE_STATE_BEGIN_TURN: btl_state_update_begin_turn(); break; - case 6: + case BATTLE_STATE_END_TURN: btl_state_update_end_turn(); break; - case 10: + case BATTLE_STATE_SWITCH_TO_PLAYER: btl_state_update_switch_to_player(); break; - case 11: + case BATTLE_STATE_SWITCH_TO_PARTNER: btl_state_update_switch_to_partner(); break; - case 12: + case BATTLE_STATE_PREPARE_MENU: btl_state_update_prepare_menu(); break; - case 13: + case BATTLE_STATE_PLAYER_MENU: btl_state_update_player_menu(); break; - case 14: + case BATTLE_STATE_PARTNER_MENU: btl_state_update_partner_menu(); break; - case 16: + case BATTLE_STATE_TWINK_MENU: btl_state_update_twink_menu(); break; - case 15: + case BATTLE_STATE_PEACH_MENU: btl_state_update_peach_menu(); break; - case 17: + case BATTLE_STATE_SELECT_TARGET: btl_state_update_select_target(); break; - case 18: + case BATTLE_STATE_PLAYER_MOVE: btl_state_update_player_move(); break; - case 2: + case BATTLE_STATE_FIRST_STRIKE: btl_state_update_first_strike(); break; - case 22: + case BATTLE_STATE_END_PLAYER_TURN: btl_state_update_end_player_turn(); break; - case 23: + case BATTLE_STATE_END_PARTNER_TURN: btl_state_update_end_partner_turn(); break; - case 21: + case BATTLE_STATE_ENEMY_MOVE: btl_state_update_enemy_move(); break; - case 3: + case BATTLE_STATE_PARTNER_FIRST_STRIKE: btl_state_update_partner_striking_first(); break; - case 20: + case BATTLE_STATE_NEXT_ENEMY: btl_state_update_next_enemy(); break; - case 19: + case BATTLE_STATE_PARTNER_MOVE: btl_state_update_partner_move(); break; - case 26: + case BATTLE_STATE_VICTORY: btl_state_update_victory(); break; - case 32: + case BATTLE_STATE_END_BATTLE: btl_state_update_end_battle(); break; - case 29: + case BATTLE_STATE_CHANGE_PARTNER: btl_state_update_change_partner(); break; - case 24: + case BATTLE_STATE_RUN_AWAY: btl_state_update_run_away(); break; - case 25: + case BATTLE_STATE_DEFEND: btl_state_update_defend(); break; - case 27: + case BATTLE_STATE_DEFEAT: btl_state_update_defeat(); break; - case 28: + case BATTLE_STATE_28: btl_state_update_1C(); break; - case 30: + case BATTLE_STATE_END_TRAINING_BATTLE: btl_state_update_end_training_battle(); break; - case 4: + case BATTLE_STATE_ENEMY_FIRST_STRIKE: btl_state_update_enemy_striking_first(); break; - case 34: + case BATTLE_STATE_34: btl_state_update_22(); break; - case 33: + case BATTLE_STATE_CELEBRATION: btl_state_update_celebration(); break; - case 35: + case BATTLE_STATE_END_DEMO_BATTLE: btl_state_update_end_demo_battle(); cond = FALSE; break; @@ -884,7 +884,7 @@ void btl_draw_enemy_health_bars(void) { } if (!(enemy->flags & (ACTOR_FLAG_40000 | ACTOR_FLAG_TARGET_ONLY)) && - ((gBattleStatus.flags1 & BS_FLAGS1_2) || (enemy->flags & ENEMY_FLAGS_80000)) && + ((gBattleStatus.flags1 & BS_FLAGS1_2) || (enemy->flags & ACTOR_FLAG_80000)) && is_actor_hp_bar_visible(enemy)) { f32 x = enemy->healthBarPosition.x; @@ -1114,11 +1114,11 @@ void btl_delete_actor(Actor* actor) { if (actor->idleScript != NULL) { kill_script_by_ID(actor->idleScriptID); } - if (actor->onHitScript != NULL) { - kill_script_by_ID(actor->onHitID); + if (actor->handleEventScript != NULL) { + kill_script_by_ID(actor->handleEventScriptID); } if (actor->takeTurnScript != NULL) { - kill_script_by_ID(actor->takeTurnID); + kill_script_by_ID(actor->takeTurnScriptID); } func_80266EE8(actor, 0); @@ -1179,11 +1179,11 @@ void btl_delete_player_actor(Actor* player) { if (player->idleScript != NULL) { kill_script_by_ID(player->idleScriptID); } - if (player->onHitScript != NULL) { - kill_script_by_ID(player->onHitID); + if (player->handleEventScript != NULL) { + kill_script_by_ID(player->handleEventScriptID); } if (player->takeTurnScript != NULL) { - kill_script_by_ID(player->takeTurnID); + kill_script_by_ID(player->takeTurnScriptID); } partsTable = player->partsTable; diff --git a/src/17D6A0.c b/src/17D6A0.c index 3d2979b611..94400c98fe 100644 --- a/src/17D6A0.c +++ b/src/17D6A0.c @@ -2389,25 +2389,115 @@ EntityModelScript* D_80283744[] = { }; s32 bMessages[] = { - MSG_Menus_Merlee_IncreaseAttack, MSG_Menus_Merlee_DecreaseDamage, MSG_Menus_Merlee_IncreaseStarPoints, MSG_Menus_Merlee_Exhausted, - MSG_Menus_ChargeHammer, MSG_Menus_ChargeHammerMore, MSG_Menus_ChargeJump, MSG_Menus_ChargeJumpMore, MSG_Menus_ChargeMaxedOut, - MSG_Menus_EnemyMissed, - MSG_Menus_PlayerDazed, MSG_Menus_PlayerAsleep, MSG_Menus_PlayerFrozen, MSG_Menus_PlayerPoisoned, MSG_Menus_PlayerShrunk, MSG_Menus_PlayerParalyzed, MSG_Menus_PlayerElectricCharge, MSG_Menus_PlayerTransparent, - MSG_Menus_EnemyDazed, MSG_Menus_EnemyAsleep, MSG_Menus_EnemyFrozen, MSG_Menus_EnemyPoisoned, MSG_Menus_EnemyShrunk, MSG_Menus_EnemyParalyzed, MSG_Menus_EnemyElectrified, MSG_Menus_EnemyCantMove, - MSG_Menus_StarEnergyRecharged, MSG_Menus_StarEnergyMaxedOut, MSG_Menus_StarEnergyFilled, - MSG_Menus_AttackUp, MSG_Menus_DefenseUp, MSG_Menus_0084, MSG_Menus_0085, - MSG_Menus_EnemyTransparent, MSG_Menus_EnemyElectricCharge, - MSG_Menus_PartnerInjured, MSG_Menus_ChargeGoombario, MSG_Menus_ChargeGoombarioMore, MSG_Menus_WaterBlockBegin, MSG_Menus_WaterBlockEnd, MSG_Menus_CloudNineBegin, MSG_Menus_CloudNineEnd, MSG_Menus_TurboChargeBegin, MSG_Menus_TurboChargeEnd, MSG_Menus_ChillOutBegin, MSG_Menus_CloudNineBegin, - MSG_Menus_00AF, MSG_Menus_00B0, MSG_Menus_00B1, MSG_Menus_00B2, MSG_Menus_00B3, MSG_Menus_00B4, MSG_Menus_00AF, MSG_Menus_00AF, MSG_Menus_00B5, MSG_Menus_00B6, MSG_Menus_00B7, MSG_Menus_00B8, MSG_Menus_00B9, MSG_Menus_00AF, MSG_Menus_00BA, MSG_Menus_00BB, MSG_Menus_00BC, MSG_Menus_00AF, MSG_Menus_00BD, MSG_Menus_00BE, MSG_Menus_00BF, - MSG_Menus_Battle_NoTarget_Jump, MSG_Menus_Battle_NoTarget_Hammer, MSG_Menus_Battle_NoTarget_Item, 0x00000000, 0x00000000, - MSG_Menus_00C3, MSG_Menus_00C6, MSG_Menus_00C6, MSG_Menus_00C6, MSG_Menus_00C7, MSG_Menus_00C7, MSG_Menus_00C7, MSG_Menus_00C8, - MSG_Menus_00C9, MSG_Menus_00CA, MSG_Menus_00C9, MSG_Menus_00CA, MSG_Menus_00C3, + [BTL_MSG_00] MSG_Menus_Merlee_IncreaseAttack, + [BTL_MSG_01] MSG_Menus_Merlee_DecreaseDamage, + [BTL_MSG_02] MSG_Menus_Merlee_IncreaseStarPoints, + [BTL_MSG_03] MSG_Menus_Merlee_Exhausted, + [BTL_MSG_04] MSG_Menus_ChargeHammer, + [BTL_MSG_05] MSG_Menus_ChargeHammerMore, + [BTL_MSG_06] MSG_Menus_ChargeJump, + [BTL_MSG_07] MSG_Menus_ChargeJumpMore, + [BTL_MSG_08] MSG_Menus_ChargeMaxedOut, + [BTL_MSG_09] MSG_Menus_EnemyMissed, + + // player status effects + [BTL_MSG_0A] MSG_Menus_PlayerDazed, + [BTL_MSG_0B] MSG_Menus_PlayerAsleep, + [BTL_MSG_0C] MSG_Menus_PlayerFrozen, + [BTL_MSG_0D] MSG_Menus_PlayerPoisoned, + [BTL_MSG_0E] MSG_Menus_PlayerShrunk, + [BTL_MSG_0F] MSG_Menus_PlayerParalyzed, + [BTL_MSG_10] MSG_Menus_PlayerElectricCharge, + [BTL_MSG_11] MSG_Menus_PlayerTransparent, + + // enemy status effects + [BTL_MSG_12] MSG_Menus_EnemyDazed, + [BTL_MSG_13] MSG_Menus_EnemyAsleep, + [BTL_MSG_14] MSG_Menus_EnemyFrozen, + [BTL_MSG_15] MSG_Menus_EnemyPoisoned, + [BTL_MSG_16] MSG_Menus_EnemyShrunk, + [BTL_MSG_17] MSG_Menus_EnemyParalyzed, + [BTL_MSG_18] MSG_Menus_EnemyElectrified, + [BTL_MSG_19] MSG_Menus_EnemyCantMove, + + [BTL_MSG_1A] MSG_Menus_StarEnergyRecharged, + [BTL_MSG_1B] MSG_Menus_StarEnergyMaxedOut, + [BTL_MSG_1C] MSG_Menus_StarEnergyFilled, + [BTL_MSG_1D] MSG_Menus_AttackUp, + [BTL_MSG_1E] MSG_Menus_DefenseUp, + [BTL_MSG_1F] MSG_Menus_0084, + [BTL_MSG_20] MSG_Menus_0085, + [BTL_MSG_21] MSG_Menus_EnemyTransparent, + [BTL_MSG_22] MSG_Menus_EnemyElectricCharge, + [BTL_MSG_23] MSG_Menus_PartnerInjured, + [BTL_MSG_24] MSG_Menus_ChargeGoombario, + [BTL_MSG_25] MSG_Menus_ChargeGoombarioMore, + [BTL_MSG_26] MSG_Menus_WaterBlockBegin, + [BTL_MSG_27] MSG_Menus_WaterBlockEnd, + [BTL_MSG_28] MSG_Menus_CloudNineBegin, + [BTL_MSG_29] MSG_Menus_CloudNineEnd, + [BTL_MSG_2A] MSG_Menus_TurboChargeBegin, + [BTL_MSG_2B] MSG_Menus_TurboChargeEnd, + [BTL_MSG_2C] MSG_Menus_ChillOutBegin, + [BTL_MSG_2D] MSG_Menus_CloudNineBegin, + [BTL_MSG_2E] MSG_Menus_00AF, + [BTL_MSG_2F] MSG_Menus_00B0, + [BTL_MSG_30] MSG_Menus_00B1, + [BTL_MSG_31] MSG_Menus_00B2, + [BTL_MSG_32] MSG_Menus_00B3, + [BTL_MSG_33] MSG_Menus_00B4, + [BTL_MSG_34] MSG_Menus_00AF, + [BTL_MSG_35] MSG_Menus_00AF, + [BTL_MSG_36] MSG_Menus_00B5, + [BTL_MSG_37] MSG_Menus_00B6, + [BTL_MSG_38] MSG_Menus_00B7, + [BTL_MSG_39] MSG_Menus_00B8, + [BTL_MSG_3A] MSG_Menus_00B9, + [BTL_MSG_3B] MSG_Menus_00AF, + [BTL_MSG_3C] MSG_Menus_00BA, + [BTL_MSG_3D] MSG_Menus_00BB, + [BTL_MSG_3E] MSG_Menus_00BC, + [BTL_MSG_3F] MSG_Menus_00AF, + [BTL_MSG_40] MSG_Menus_00BD, + [BTL_MSG_41] MSG_Menus_00BE, + [BTL_MSG_42] MSG_Menus_00BF, + [BTL_MSG_43] MSG_Menus_Battle_NoTarget_Jump, + [BTL_MSG_44] MSG_Menus_Battle_NoTarget_Hammer, + [BTL_MSG_45] MSG_Menus_Battle_NoTarget_Item, + [BTL_MSG_46] 0, + [BTL_MSG_47] 0, + [BTL_MSG_48] MSG_Menus_00C3, + [BTL_MSG_49] MSG_Menus_00C6, + [BTL_MSG_4A] MSG_Menus_00C6, + [BTL_MSG_4B] MSG_Menus_00C6, + [BTL_MSG_4C] MSG_Menus_00C7, + [BTL_MSG_4D] MSG_Menus_00C7, + [BTL_MSG_4E] MSG_Menus_00C7, + [BTL_MSG_4F] MSG_Menus_00C8, + [BTL_MSG_50] MSG_Menus_CantSwitch, + [BTL_MSG_51] MSG_Menus_00CA, + [BTL_MSG_52] MSG_Menus_CantSwitch, + [BTL_MSG_53] MSG_Menus_00CA, + [BTL_MSG_54] MSG_Menus_00C3, }; s32 bActorMessages[] = { - MSG_Menus_Party_Mario, MSG_Menus_Party_Goombario, MSG_Menus_Party_Kooper, MSG_Menus_Party_Bombette, MSG_Menus_Party_Parakarry, MSG_Menus_Party_Goompa, MSG_Menus_Party_Watt, MSG_Menus_Party_Sushie, MSG_Menus_Party_Lakilester, MSG_Menus_Party_Bow, MSG_Menus_Party_Goombaria, MSG_Menus_Party_Twink, MSG_Menus_Party_Peach + MSG_Menus_Party_Mario, + MSG_Menus_Party_Goombario, + MSG_Menus_Party_Kooper, + MSG_Menus_Party_Bombette, + MSG_Menus_Party_Parakarry, + MSG_Menus_Party_Goompa, + MSG_Menus_Party_Watt, + MSG_Menus_Party_Sushie, + MSG_Menus_Party_Lakilester, + MSG_Menus_Party_Bow, + MSG_Menus_Party_Goombaria, + MSG_Menus_Party_Twink, + MSG_Menus_Party_Peach }; -PopupMessage* D_802838F8 = NULL; + +PopupMessage* bPopupMessage = NULL; s32 D_802838FC_padding = 0; @@ -2575,7 +2665,7 @@ extern HudScript HES_TimingBlink; void func_8024F394(void* data); void func_8024F5AC(void* data); void func_8024F768(void* data); -void func_8024FB3C(void* popup); +void btl_update_message_popup(void* popup); void btl_show_message_popup(void* popup); void btl_popup_messages_init(void) { @@ -2902,17 +2992,17 @@ void btl_show_battle_message(s32 messageIndex, s32 duration) { PopupMessage* popup = btl_create_popup(); if (popup != NULL) { - popup->updateFunc = func_8024FB3C; + popup->updateFunc = btl_update_message_popup; popup->renderUIFunc = btl_show_message_popup; popup->unk_00 = 0; popup->renderWorldFunc = NULL; popup->messageIndex = messageIndex; popup->duration = duration; popup->unk_16 = 0; - popup->unk_17 = 1; + popup->unk_17 = TRUE; popup->message = NULL; D_8029F640 = 0; - D_802838F8 = popup; + bPopupMessage = popup; D_8029F64A = FALSE; D_8029F64C = 0; D_8029F64E = 0; @@ -2924,17 +3014,17 @@ void btl_show_variable_battle_message(s32 messageIndex, s32 duration, s32 varVal PopupMessage* popup = btl_create_popup(); if (popup != NULL) { - popup->updateFunc = func_8024FB3C; + popup->updateFunc = btl_update_message_popup; popup->renderUIFunc = btl_show_message_popup; popup->unk_00 = 0; popup->renderWorldFunc = NULL; popup->messageIndex = messageIndex; popup->duration = duration; popup->unk_16 = 0; - popup->unk_17 = 1; + popup->unk_17 = TRUE; popup->message = NULL; D_8029F640 = varValue; - D_802838F8 = popup; + bPopupMessage = popup; D_8029F64A = FALSE; D_8029F64C = 0; D_8029F64E = 0; @@ -2943,11 +3033,11 @@ void btl_show_variable_battle_message(s32 messageIndex, s32 duration, s32 varVal } s32 btl_is_popup_displayed(void) { - return D_802838F8 != NULL; + return bPopupMessage != NULL; } void btl_set_popup_duration(s32 duration) { - PopupMessage* popup = D_802838F8; + PopupMessage* popup = bPopupMessage; if (D_8029F64A && popup != NULL) { popup->duration = duration; @@ -2963,14 +3053,14 @@ void func_8024FAFC(void) { } void close_action_command_instruction_popup(void) { - PopupMessage* popup = D_802838F8; + PopupMessage* popup = bPopupMessage; - if (popup != NULL && popup->messageIndex < 67 && popup->messageIndex >= 46) { + if (popup != NULL && popup->messageIndex < BTL_MSG_43 && popup->messageIndex >= BTL_MSG_2E) { popup->duration = 0; } } -void func_8024FB3C(void* data) { +void btl_update_message_popup(void* data) { PopupMessage* popup = data; BattleStatus* battleStatus = &gBattleStatus; s32 shouldDisposeWindow = FALSE; @@ -2978,57 +3068,57 @@ void func_8024FB3C(void* data) { s32 temp_a0; switch (popup->messageIndex) { - case 0x0: - case 0x1: - case 0x2: - case 0x3: - case 0x4: - case 0x5: - case 0x6: - case 0x7: - case 0x8: - case 0x9: - case 0xA: - case 0xB: - case 0xC: - case 0xD: - case 0xE: - case 0xF: - case 0x10: - case 0x11: - case 0x12: - case 0x13: - case 0x14: - case 0x15: - case 0x16: - case 0x17: - case 0x18: - case 0x19: - case 0x1A: - case 0x1B: - case 0x1C: - case 0x1D: - case 0x1E: - case 0x1F: - case 0x20: - case 0x21: - case 0x22: - case 0x23: - case 0x24: - case 0x25: - case 0x26: - case 0x27: - case 0x28: - case 0x29: - case 0x2A: - case 0x2B: - case 0x2C: - case 0x2D: - case 0x50: - case 0x51: - case 0x52: - case 0x53: - case 0x54: + case BTL_MSG_00: + case BTL_MSG_01: + case BTL_MSG_02: + case BTL_MSG_03: + case BTL_MSG_04: + case BTL_MSG_05: + case BTL_MSG_06: + case BTL_MSG_07: + case BTL_MSG_08: + case BTL_MSG_09: + case BTL_MSG_0A: + case BTL_MSG_0B: + case BTL_MSG_0C: + case BTL_MSG_0D: + case BTL_MSG_0E: + case BTL_MSG_0F: + case BTL_MSG_10: + case BTL_MSG_11: + case BTL_MSG_12: + case BTL_MSG_13: + case BTL_MSG_14: + case BTL_MSG_15: + case BTL_MSG_16: + case BTL_MSG_17: + case BTL_MSG_18: + case BTL_MSG_19: + case BTL_MSG_1A: + case BTL_MSG_1B: + case BTL_MSG_1C: + case BTL_MSG_1D: + case BTL_MSG_1E: + case BTL_MSG_1F: + case BTL_MSG_20: + case BTL_MSG_21: + case BTL_MSG_22: + case BTL_MSG_23: + case BTL_MSG_24: + case BTL_MSG_25: + case BTL_MSG_26: + case BTL_MSG_27: + case BTL_MSG_28: + case BTL_MSG_29: + case BTL_MSG_2A: + case BTL_MSG_2B: + case BTL_MSG_2C: + case BTL_MSG_2D: + case BTL_MSG_50: + case BTL_MSG_51: + case BTL_MSG_52: + case BTL_MSG_53: + case BTL_MSG_54: switch (popup->unk_16) { default: break; @@ -3057,27 +3147,27 @@ void func_8024FB3C(void* data) { break; } break; - case 0x2E: - case 0x2F: - case 0x30: - case 0x31: - case 0x32: - case 0x33: - case 0x34: - case 0x35: - case 0x36: - case 0x37: - case 0x38: - case 0x39: - case 0x3A: - case 0x3B: - case 0x3C: - case 0x3D: - case 0x3E: - case 0x3F: - case 0x40: - case 0x41: - case 0x42: + case BTL_MSG_2E: + case BTL_MSG_2F: + case BTL_MSG_30: + case BTL_MSG_31: + case BTL_MSG_32: + case BTL_MSG_33: + case BTL_MSG_34: + case BTL_MSG_35: + case BTL_MSG_36: + case BTL_MSG_37: + case BTL_MSG_38: + case BTL_MSG_39: + case BTL_MSG_3A: + case BTL_MSG_3B: + case BTL_MSG_3C: + case BTL_MSG_3D: + case BTL_MSG_3E: + case BTL_MSG_3F: + case BTL_MSG_40: + case BTL_MSG_41: + case BTL_MSG_42: temp_a0 = battleStatus->actionCommandMode; D_8029F64A = TRUE; if (temp_a0 == ACTION_COMMAND_MODE_NOT_LEARNED) { @@ -3091,12 +3181,12 @@ void func_8024FB3C(void* data) { gBattleStatus.flags1 |= BS_FLAGS1_4000; gBattleStatus.flags1 &= ~BS_FLAGS1_10000; switch (popup->messageIndex) { - case 50: + case BTL_MSG_32: D_8029F642 = hud_element_create(&HES_StickNeutral); hud_element_set_flags(D_8029F642, HUD_ELEMENT_FLAGS_FILTER_TEX | HUD_ELEMENT_FLAGS_80); hud_element_set_render_pos(D_8029F642, -100, -100); break; - case 47: + case BTL_MSG_2F: D_8029F642 = hud_element_create(&HES_StickNeutral); hud_element_set_flags(D_8029F642, HUD_ELEMENT_FLAGS_FILTER_TEX | HUD_ELEMENT_FLAGS_80); hud_element_set_render_pos(D_8029F642, -100, -100); @@ -3105,7 +3195,7 @@ void func_8024FB3C(void* data) { hud_element_set_flags(D_8029F644, HUD_ELEMENT_FLAGS_80); hud_element_set_render_pos(D_8029F644, -100, -100); break; - case 51: + case BTL_MSG_33: D_8029F642 = hud_element_create(&HES_StickNeutral); hud_element_set_flags(D_8029F642, HUD_ELEMENT_FLAGS_FILTER_TEX | HUD_ELEMENT_FLAGS_80); hud_element_set_render_pos(D_8029F642, -100, -100); @@ -3115,7 +3205,7 @@ void func_8024FB3C(void* data) { hud_element_set_render_pos(D_8029F644, -100, -100); hud_element_create_transform_B(D_8029F644); break; - case 52: + case BTL_MSG_34: D_8029F642 = hud_element_create(&HES_CUpButton); hud_element_set_flags(D_8029F642, HUD_ELEMENT_FLAGS_FILTER_TEX | HUD_ELEMENT_FLAGS_80); hud_element_set_render_pos(D_8029F642, -100, -100); @@ -3132,12 +3222,12 @@ void func_8024FB3C(void* data) { hud_element_set_flags(D_8029F648, HUD_ELEMENT_FLAGS_80); hud_element_set_render_pos(D_8029F648, -100, -100); break; - case 53: + case BTL_MSG_35: D_8029F642 = hud_element_create(&HES_StickNeutral); hud_element_set_flags(D_8029F642, HUD_ELEMENT_FLAGS_FILTER_TEX | HUD_ELEMENT_FLAGS_80); hud_element_set_render_pos(D_8029F642, -100, -100); break; - case 54: + case BTL_MSG_36: D_8029F642 = hud_element_create(&HES_AButton); hud_element_set_flags(D_8029F642, HUD_ELEMENT_FLAGS_FILTER_TEX | HUD_ELEMENT_FLAGS_80); hud_element_set_render_pos(D_8029F642, -100, -100); @@ -3150,12 +3240,12 @@ void func_8024FB3C(void* data) { hud_element_set_flags(D_8029F646, HUD_ELEMENT_FLAGS_FILTER_TEX | HUD_ELEMENT_FLAGS_80); hud_element_set_render_pos(D_8029F646, -100, -100); break; - case 55: + case BTL_MSG_37: D_8029F642 = hud_element_create(&HES_StickNeutral); hud_element_set_flags(D_8029F642, HUD_ELEMENT_FLAGS_FILTER_TEX | HUD_ELEMENT_FLAGS_80); hud_element_set_render_pos(D_8029F642, -100, -100); break; - case 56: + case BTL_MSG_38: D_8029F642 = hud_element_create(&HES_TimingReady); hud_element_set_flags(D_8029F642, HUD_ELEMENT_FLAGS_80); hud_element_set_render_pos(D_8029F642, -100, -100); @@ -3164,7 +3254,7 @@ void func_8024FB3C(void* data) { hud_element_set_flags(D_8029F644, HUD_ELEMENT_FLAGS_FILTER_TEX | HUD_ELEMENT_FLAGS_80); hud_element_set_render_pos(D_8029F644, -100, -100); break; - case 57: + case BTL_MSG_39: D_8029F642 = hud_element_create(&HES_AButton); hud_element_set_flags(D_8029F642, HUD_ELEMENT_FLAGS_FILTER_TEX | HUD_ELEMENT_FLAGS_80); hud_element_set_render_pos(D_8029F642, -100, -100); @@ -3172,7 +3262,7 @@ void func_8024FB3C(void* data) { hud_element_set_flags(D_8029F642, HUD_ELEMENT_FLAGS_FILTER_TEX | HUD_ELEMENT_FLAGS_80); hud_element_set_render_pos(D_8029F642, -100, -100); break; - case 58: + case BTL_MSG_3A: D_8029F642 = hud_element_create(&HES_AButton); hud_element_set_flags(D_8029F642, HUD_ELEMENT_FLAGS_FILTER_TEX | HUD_ELEMENT_FLAGS_80); hud_element_set_render_pos(D_8029F642, -100, -100); @@ -3181,7 +3271,7 @@ void func_8024FB3C(void* data) { hud_element_set_flags(D_8029F644, HUD_ELEMENT_FLAGS_FILTER_TEX | HUD_ELEMENT_FLAGS_80); hud_element_set_render_pos(D_8029F644, -100, -100); break; - case 61: + case BTL_MSG_3D: D_8029F642 = hud_element_create(&HES_TimingReady); hud_element_set_flags(D_8029F642, HUD_ELEMENT_FLAGS_80); hud_element_set_render_pos(D_8029F642, -100, -100); @@ -3190,7 +3280,7 @@ void func_8024FB3C(void* data) { hud_element_set_flags(D_8029F644, HUD_ELEMENT_FLAGS_FILTER_TEX | HUD_ELEMENT_FLAGS_80); hud_element_set_render_pos(D_8029F644, -100, -100); break; - case 62: + case BTL_MSG_3E: D_8029F642 = hud_element_create(&HES_StickNeutral); hud_element_set_flags(D_8029F642, HUD_ELEMENT_FLAGS_FILTER_TEX | HUD_ELEMENT_FLAGS_80); hud_element_set_render_pos(D_8029F642, -100, -100); @@ -3205,19 +3295,19 @@ void func_8024FB3C(void* data) { hud_element_set_render_pos(D_8029F646, -100, -100); hud_element_create_transform_B(D_8029F646); break; - case 64: - case 65: + case BTL_MSG_40: + case BTL_MSG_41: D_8029F642 = hud_element_create(&HES_AButton); hud_element_set_flags(D_8029F642, HUD_ELEMENT_FLAGS_FILTER_TEX | HUD_ELEMENT_FLAGS_80); hud_element_set_render_pos(D_8029F642, -100, -100); // fallthrough - case 46: - case 48: - case 49: - case 59: - case 60: - case 63: - case 66: + case BTL_MSG_2E: + case BTL_MSG_30: + case BTL_MSG_31: + case BTL_MSG_3B: + case BTL_MSG_3C: + case BTL_MSG_3F: + case BTL_MSG_42: D_8029F642 = hud_element_create(&HES_AButton); hud_element_set_flags(D_8029F642, HUD_ELEMENT_FLAGS_FILTER_TEX | HUD_ELEMENT_FLAGS_80); hud_element_set_render_pos(D_8029F642, -100, -100); @@ -3234,70 +3324,70 @@ void func_8024FB3C(void* data) { } else if (!(gBattleStatus.flags1 & BS_FLAGS1_4000) && (temp_a0 != 2)) { set_window_update(WINDOW_ID_9, WINDOW_UPDATE_SHOW_TRANSPARENT); switch (popup->messageIndex) { - case 49: + case BTL_MSG_31: hud_element_set_script(D_8029F642, &HES_MashAButton); break; - case 50: + case BTL_MSG_32: hud_element_set_script(D_8029F642, &HES_StickMashLeft); break; - case 47: + case BTL_MSG_2F: hud_element_set_script(D_8029F642, &HES_StickTapLeft); hud_element_set_script(D_8029F644, &HES_TimingBlink); break; - case 51: + case BTL_MSG_33: hud_element_set_script(D_8029F642, &HES_StickTapLeft); hud_element_set_script(D_8029F644, &HES_AimTarget); break; - case 52: + case BTL_MSG_34: hud_element_set_script(D_8029F642, &HES_MashCUpButton); hud_element_set_script(D_8029F644, &HES_MashCDownButton1); hud_element_set_script(D_8029F646, &HES_MashCLeftButton); hud_element_set_script(D_8029F648, &HES_MashCRightButton1); break; - case 53: + case BTL_MSG_35: hud_element_set_script(D_8029F642, &HES_StickBackAndForth); break; - case 54: + case BTL_MSG_36: hud_element_set_script(D_8029F642, &HES_PressAButton); hud_element_set_script(D_8029F644, &HES_PressBButton); hud_element_set_script(D_8029F646, &HES_PressCDownButton); break; - case 55: + case BTL_MSG_37: hud_element_set_script(D_8029F642, &HES_RotateStickCW); break; - case 56: + case BTL_MSG_38: hud_element_set_script(D_8029F642, &HES_TimingBlink); hud_element_set_script(D_8029F644, &HES_MashAButton); break; - case 57: + case BTL_MSG_39: hud_element_set_script(D_8029F642, &HES_MashAButton); hud_element_set_script(D_8029F644, &HES_MashBButton2); break; - case 58: + case BTL_MSG_3A: hud_element_set_script(D_8029F642, &HES_MashAButton); hud_element_set_script(D_8029F644, &HES_MashBButton1); break; - case 59: + case BTL_MSG_3B: hud_element_set_script(D_8029F642, &HES_MashAButton); break; - case 61: + case BTL_MSG_3D: hud_element_set_script(D_8029F642, &HES_TimingBlink); hud_element_set_script(D_8029F644, &HES_PressAButton); break; - case 62: + case BTL_MSG_3E: hud_element_set_script(D_8029F642, &HES_StickTapRight); break; - case 63: + case BTL_MSG_3F: hud_element_set_script(D_8029F642, &HES_MashAButton); break; - case 64: - case 65: + case BTL_MSG_40: + case BTL_MSG_41: hud_element_set_script(D_8029F642, &HES_PressAButton); /* fallthrough */ - case 46: - case 48: - case 60: - case 66: + case BTL_MSG_2E: + case BTL_MSG_30: + case BTL_MSG_3C: + case BTL_MSG_42: hud_element_set_script(D_8029F642, &HES_PressAButton); break; } @@ -3331,36 +3421,36 @@ void func_8024FB3C(void* data) { popup->duration--; } else { switch (popup->messageIndex) { - case 46: - case 48: - case 49: - case 50: - case 53: - case 55: - case 59: - case 60: - case 63: - case 64: - case 65: - case 66: + case BTL_MSG_2E: + case BTL_MSG_30: + case BTL_MSG_31: + case BTL_MSG_32: + case BTL_MSG_35: + case BTL_MSG_37: + case BTL_MSG_3B: + case BTL_MSG_3C: + case BTL_MSG_3F: + case BTL_MSG_40: + case BTL_MSG_41: + case BTL_MSG_42: hud_element_free(D_8029F642); break; - case 47: - case 51: - case 56: - case 57: - case 58: - case 61: + case BTL_MSG_2F: + case BTL_MSG_33: + case BTL_MSG_38: + case BTL_MSG_39: + case BTL_MSG_3A: + case BTL_MSG_3D: hud_element_free(D_8029F642); hud_element_free(D_8029F644); break; - case 54: - case 62: + case BTL_MSG_36: + case BTL_MSG_3E: hud_element_free(D_8029F642); hud_element_free(D_8029F644); hud_element_free(D_8029F646); break; - case 52: + case BTL_MSG_34: hud_element_free(D_8029F642); hud_element_free(D_8029F644); hud_element_free(D_8029F646); @@ -3375,12 +3465,12 @@ void func_8024FB3C(void* data) { break; } break; - case 0x43: - case 0x44: - case 0x45: - case 0x46: - case 0x47: - case 0x48: + case BTL_MSG_43: + case BTL_MSG_44: + case BTL_MSG_45: + case BTL_MSG_46: + case BTL_MSG_47: + case BTL_MSG_48: switch (popup->unk_16) { default: break; @@ -3409,47 +3499,47 @@ void func_8024FB3C(void* data) { break; } break; - case 0x49: - case 0x4A: - case 0x4B: - case 0x4C: - case 0x4D: - case 0x4E: - case 0x4F: + case BTL_MSG_49: + case BTL_MSG_4A: + case BTL_MSG_4B: + case BTL_MSG_4C: + case BTL_MSG_4D: + case BTL_MSG_4E: + case BTL_MSG_4F: switch (popup->unk_16) { case 0: switch (popup->messageIndex) { - case 73: + case BTL_MSG_49: D_8029F642 = hud_element_create(&HES_Item_Hammer1); hud_element_set_flags(D_8029F642, HUD_ELEMENT_FLAGS_80); hud_element_set_render_pos(D_8029F642, -100, -100); break; - case 74: + case BTL_MSG_4A: D_8029F642 = hud_element_create(&HES_Item_Hammer2); hud_element_set_flags(D_8029F642, HUD_ELEMENT_FLAGS_80); hud_element_set_render_pos(D_8029F642, -100, -100); break; - case 75: + case BTL_MSG_4B: D_8029F642 = hud_element_create(&HES_Item_Hammer3); hud_element_set_flags(D_8029F642, HUD_ELEMENT_FLAGS_80); hud_element_set_render_pos(D_8029F642, -100, -100); break; - case 76: + case BTL_MSG_4C: D_8029F642 = hud_element_create(&HES_Item_Boots1); hud_element_set_flags(D_8029F642, HUD_ELEMENT_FLAGS_80); hud_element_set_render_pos(D_8029F642, -100, -100); break; - case 77: + case BTL_MSG_4D: D_8029F642 = hud_element_create(&HES_Item_Boots2); hud_element_set_flags(D_8029F642, HUD_ELEMENT_FLAGS_80); hud_element_set_render_pos(D_8029F642, -100, -100); break; - case 78: + case BTL_MSG_4E: D_8029F642 = hud_element_create(&HES_Item_Boots3); hud_element_set_flags(D_8029F642, HUD_ELEMENT_FLAGS_80); hud_element_set_render_pos(D_8029F642, -100, -100); break; - case 79: + case BTL_MSG_4F: D_8029F642 = hud_element_create(&HES_Item_Items); hud_element_set_flags(D_8029F642, HUD_ELEMENT_FLAGS_80); hud_element_set_render_pos(D_8029F642, -100, -100); @@ -3470,7 +3560,7 @@ void func_8024FB3C(void* data) { } if (shouldDisposeWindow) { set_window_update(WINDOW_ID_9, WINDOW_UPDATE_HIDE); - D_802838F8 = NULL; + bPopupMessage = NULL; free_popup(popup); } } @@ -3485,117 +3575,117 @@ void func_80250818(void* data, s32 x, s32 y) { y += 6; switch (popup->messageIndex) { - case 0x0: - case 0x1: - case 0x2: - case 0x3: - case 0x8: - case 0x9: - case 0xA: - case 0xB: - case 0xC: - case 0xD: - case 0xE: - case 0xF: - case 0x10: - case 0x11: - case 0x12: - case 0x13: - case 0x14: - case 0x15: - case 0x16: - case 0x17: - case 0x18: - case 0x19: - case 0x1A: - case 0x1B: - case 0x1C: - case 0x23: - case 0x24: - case 0x25: - case 0x26: - case 0x27: - case 0x28: - case 0x29: - case 0x2A: - case 0x2B: - case 0x2C: - case 0x2D: - case 0x43: - case 0x44: - case 0x45: - case 0x46: - case 0x47: - case 0x48: - case 0x50: - case 0x52: - case 0x53: - case 0x54: + case BTL_MSG_00: + case BTL_MSG_01: + case BTL_MSG_02: + case BTL_MSG_03: + case BTL_MSG_08: + case BTL_MSG_09: + case BTL_MSG_0A: + case BTL_MSG_0B: + case BTL_MSG_0C: + case BTL_MSG_0D: + case BTL_MSG_0E: + case BTL_MSG_0F: + case BTL_MSG_10: + case BTL_MSG_11: + case BTL_MSG_12: + case BTL_MSG_13: + case BTL_MSG_14: + case BTL_MSG_15: + case BTL_MSG_16: + case BTL_MSG_17: + case BTL_MSG_18: + case BTL_MSG_19: + case BTL_MSG_1A: + case BTL_MSG_1B: + case BTL_MSG_1C: + case BTL_MSG_23: + case BTL_MSG_24: + case BTL_MSG_25: + case BTL_MSG_26: + case BTL_MSG_27: + case BTL_MSG_28: + case BTL_MSG_29: + case BTL_MSG_2A: + case BTL_MSG_2B: + case BTL_MSG_2C: + case BTL_MSG_2D: + case BTL_MSG_43: + case BTL_MSG_44: + case BTL_MSG_45: + case BTL_MSG_46: + case BTL_MSG_47: + case BTL_MSG_48: + case BTL_MSG_50: + case BTL_MSG_52: + case BTL_MSG_53: + case BTL_MSG_54: messageID = bMessages[popup->messageIndex]; msgLinesIdx = get_msg_lines(messageID) - 1; draw_msg(messageID, x, y + D_802835D4[msgLinesIdx], 255, MSG_PAL_0F, 0); break; - case 0x4: - case 0x5: - case 0x6: - case 0x7: - case 0x1D: - case 0x1E: - case 0x1F: - case 0x20: - case 0x21: - case 0x22: + case BTL_MSG_04: + case BTL_MSG_05: + case BTL_MSG_06: + case BTL_MSG_07: + case BTL_MSG_1D: + case BTL_MSG_1E: + case BTL_MSG_1F: + case BTL_MSG_20: + case BTL_MSG_21: + case BTL_MSG_22: messageID = bMessages[popup->messageIndex]; msgLinesIdx = get_msg_lines(messageID) - 1; y += D_802835D4[msgLinesIdx]; set_message_value(D_8029F640, 0); draw_msg(messageID, x, y, 255, MSG_PAL_0F, 0); break; - case 0x51: + case BTL_MSG_51: messageID = bMessages[popup->messageIndex]; msgLinesIdx = get_msg_lines(messageID) - 1; y += D_802835D4[msgLinesIdx]; set_message_msg(bActorMessages[D_8029F640], 0); draw_msg(messageID, x, y, 255, MSG_PAL_0F, 0); break; - case 0x49: - case 0x4A: - case 0x4B: - case 0x4C: - case 0x4D: - case 0x4E: - case 0x4F: + case BTL_MSG_49: + case BTL_MSG_4A: + case BTL_MSG_4B: + case BTL_MSG_4C: + case BTL_MSG_4D: + case BTL_MSG_4E: + case BTL_MSG_4F: messageID = bMessages[popup->messageIndex]; draw_msg(messageID, x + 0x1D, y + 6, 255, MSG_PAL_0F, 0); hud_element_set_render_pos(D_8029F642, x + 13, y + 14); hud_element_draw_clipped(D_8029F642); break; - case 0x2E: - case 0x2F: - case 0x30: - case 0x31: - case 0x32: - case 0x33: - case 0x34: - case 0x35: - case 0x36: - case 0x37: - case 0x38: - case 0x39: - case 0x3A: - case 0x3B: - case 0x3C: - case 0x3D: - case 0x3E: - case 0x3F: - case 0x40: - case 0x41: - case 0x42: + case BTL_MSG_2E: + case BTL_MSG_2F: + case BTL_MSG_30: + case BTL_MSG_31: + case BTL_MSG_32: + case BTL_MSG_33: + case BTL_MSG_34: + case BTL_MSG_35: + case BTL_MSG_36: + case BTL_MSG_37: + case BTL_MSG_38: + case BTL_MSG_39: + case BTL_MSG_3A: + case BTL_MSG_3B: + case BTL_MSG_3C: + case BTL_MSG_3D: + case BTL_MSG_3E: + case BTL_MSG_3F: + case BTL_MSG_40: + case BTL_MSG_41: + case BTL_MSG_42: opacity = 255; if (popup->unk_16 < 2) { opacity = 160; } - if (popup->messageIndex == 0x3B) { + if (popup->messageIndex == BTL_MSG_3B) { opacity = 255; } @@ -3607,13 +3697,13 @@ void func_80250818(void* data, s32 x, s32 y) { draw_msg(messageID, x + 11, y + 6, opacity, MSG_PAL_0F, 0); switch (popup->messageIndex) { - case 46: + case BTL_MSG_2E: hud_element_set_render_pos(D_8029F642, x + 65, y + 14); hud_element_set_scale(D_8029F642, 0.5f); hud_element_set_alpha(D_8029F642, opacity); hud_element_draw_clipped(D_8029F642); break; - case 47: + case BTL_MSG_2F: hud_element_set_render_pos(D_8029F642, x + 55, y + 14); hud_element_set_scale(D_8029F642, 0.6f); hud_element_set_alpha(D_8029F642, opacity); @@ -3623,25 +3713,25 @@ void func_80250818(void* data, s32 x, s32 y) { hud_element_set_alpha(D_8029F644, opacity); hud_element_draw_clipped(D_8029F644); break; - case 48: + case BTL_MSG_30: hud_element_set_render_pos(D_8029F642, x + 64, y + 14); hud_element_set_scale(D_8029F642, 0.5f); hud_element_set_alpha(D_8029F642, opacity); hud_element_draw_clipped(D_8029F642); break; - case 49: + case BTL_MSG_31: hud_element_set_render_pos(D_8029F642, x + 67, y + 14); hud_element_set_scale(D_8029F642, 0.5f); hud_element_set_alpha(D_8029F642, opacity); hud_element_draw_clipped(D_8029F642); break; - case 50: + case BTL_MSG_32: hud_element_set_render_pos(D_8029F642, x + 56, y + 14); hud_element_set_scale(D_8029F642, 0.6f); hud_element_set_alpha(D_8029F642, opacity); hud_element_draw_clipped(D_8029F642); break; - case 51: + case BTL_MSG_33: hud_element_set_render_pos(D_8029F642, x + 65, y + 13); hud_element_set_scale(D_8029F642, 0.6f); hud_element_set_alpha(D_8029F642, opacity); @@ -3652,7 +3742,7 @@ void func_80250818(void* data, s32 x, s32 y) { hud_element_set_alpha(D_8029F644, opacity); func_80144218(D_8029F644); break; - case 54: + case BTL_MSG_36: hud_element_set_render_pos(D_8029F642, x + 86, y + 13); hud_element_set_scale(D_8029F642, 0.5f); hud_element_set_alpha(D_8029F642, opacity); @@ -3668,7 +3758,7 @@ void func_80250818(void* data, s32 x, s32 y) { hud_element_set_alpha(D_8029F646, opacity); hud_element_draw_clipped(D_8029F646); break; - case 56: + case BTL_MSG_38: hud_element_set_render_pos(D_8029F642, x + 105, y + 13); hud_element_set_alpha(D_8029F642, opacity); hud_element_draw_clipped(D_8029F642); @@ -3678,7 +3768,7 @@ void func_80250818(void* data, s32 x, s32 y) { hud_element_set_alpha(D_8029F644, opacity); hud_element_draw_clipped(D_8029F644); break; - case 58: + case BTL_MSG_3A: hud_element_set_render_pos(D_8029F642, x + 63, y + 14); hud_element_set_scale(D_8029F642, 0.5f); hud_element_set_alpha(D_8029F642, opacity); @@ -3689,13 +3779,13 @@ void func_80250818(void* data, s32 x, s32 y) { hud_element_set_alpha(D_8029F644, opacity); hud_element_draw_clipped(D_8029F644); break; - case 60: + case BTL_MSG_3C: hud_element_set_render_pos(D_8029F642, x + 124, y + 14); hud_element_set_scale(D_8029F642, 0.5f); hud_element_set_alpha(D_8029F642, opacity); hud_element_draw_clipped(D_8029F642); break; - case 61: + case BTL_MSG_3D: hud_element_set_render_pos(D_8029F642, x + 56, y + 31); hud_element_set_alpha(D_8029F642, opacity); hud_element_draw_clipped(D_8029F642); @@ -3705,7 +3795,7 @@ void func_80250818(void* data, s32 x, s32 y) { hud_element_set_alpha(D_8029F644, opacity); hud_element_draw_clipped(D_8029F644); break; - case 62: + case BTL_MSG_3E: hud_element_set_render_pos(D_8029F642, x + 107, y + 13); hud_element_set_scale(D_8029F642, 0.6f); hud_element_set_alpha(D_8029F642, opacity); @@ -3721,8 +3811,8 @@ void func_80250818(void* data, s32 x, s32 y) { hud_element_set_alpha(D_8029F646, opacity); func_80144218(D_8029F646); break; - case 64: - case 65: + case BTL_MSG_40: + case BTL_MSG_41: hud_element_set_render_pos(D_8029F642, x + 64, y + 13); hud_element_set_scale(D_8029F642, 0.5f); hud_element_set_alpha(D_8029F642, opacity); @@ -3743,56 +3833,56 @@ void btl_show_message_popup(void* data) { s32 height; switch (popup->messageIndex) { - case 0: - case 1: - case 2: - case 3: - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - case 15: - case 16: - case 17: - case 18: - case 19: - case 20: - case 21: - case 22: - case 23: - case 24: - case 25: - case 26: - case 27: - case 28: - case 35: - case 36: - case 37: - case 38: - case 39: - case 40: - case 41: - case 42: - case 43: - case 44: - case 45: - case 67: - case 68: - case 69: - case 70: - case 71: - case 72: - case 80: - case 82: - case 83: - case 84: - if (popup->unk_17 != 0) { + case BTL_MSG_00: + case BTL_MSG_01: + case BTL_MSG_02: + case BTL_MSG_03: + case BTL_MSG_08: + case BTL_MSG_09: + case BTL_MSG_0A: + case BTL_MSG_0B: + case BTL_MSG_0C: + case BTL_MSG_0D: + case BTL_MSG_0E: + case BTL_MSG_0F: + case BTL_MSG_10: + case BTL_MSG_11: + case BTL_MSG_12: + case BTL_MSG_13: + case BTL_MSG_14: + case BTL_MSG_15: + case BTL_MSG_16: + case BTL_MSG_17: + case BTL_MSG_18: + case BTL_MSG_19: + case BTL_MSG_1A: + case BTL_MSG_1B: + case BTL_MSG_1C: + case BTL_MSG_23: + case BTL_MSG_24: + case BTL_MSG_25: + case BTL_MSG_26: + case BTL_MSG_27: + case BTL_MSG_28: + case BTL_MSG_29: + case BTL_MSG_2A: + case BTL_MSG_2B: + case BTL_MSG_2C: + case BTL_MSG_2D: + case BTL_MSG_43: + case BTL_MSG_44: + case BTL_MSG_45: + case BTL_MSG_46: + case BTL_MSG_47: + case BTL_MSG_48: + case BTL_MSG_50: + case BTL_MSG_52: + case BTL_MSG_53: + case BTL_MSG_54: + if (popup->unk_17) { s32 messageID; - popup->unk_17 = 0; + popup->unk_17 = FALSE; messageID = bMessages[popup->messageIndex]; msgWidth = get_msg_width(messageID, 0) + 30; posX = 160 - (msgWidth / 2); @@ -3803,15 +3893,15 @@ void btl_show_message_popup(void* data) { set_window_update(WINDOW_ID_9, WINDOW_UPDATE_SHOW); } break; - case 73: - case 74: - case 75: - case 76: - case 77: - case 78: - case 79: - if (popup->unk_17 != 0) { - popup->unk_17 = 0; + case BTL_MSG_49: + case BTL_MSG_4A: + case BTL_MSG_4B: + case BTL_MSG_4C: + case BTL_MSG_4D: + case BTL_MSG_4E: + case BTL_MSG_4F: + if (popup->unk_17) { + popup->unk_17 = FALSE; msgWidth = get_msg_width(bMessages[popup->messageIndex], 0) + 55; posX = 160 - (msgWidth / 2); width = msgWidth; @@ -3820,20 +3910,20 @@ void btl_show_message_popup(void* data) { set_window_update(WINDOW_ID_9, WINDOW_UPDATE_SHOW); } break; - case 4: - case 5: - case 6: - case 7: - case 29: - case 30: - case 31: - case 32: - case 33: - case 34: - if (popup->unk_17 != 0) { + case BTL_MSG_04: + case BTL_MSG_05: + case BTL_MSG_06: + case BTL_MSG_07: + case BTL_MSG_1D: + case BTL_MSG_1E: + case BTL_MSG_1F: + case BTL_MSG_20: + case BTL_MSG_21: + case BTL_MSG_22: + if (popup->unk_17) { s32 messageID; - popup->unk_17 = 0; + popup->unk_17 = FALSE; messageID = bMessages[popup->messageIndex]; set_message_value(D_8029F640, 0); msgWidth = get_msg_width(messageID, 0) + 31; @@ -3845,11 +3935,11 @@ void btl_show_message_popup(void* data) { set_window_update(WINDOW_ID_9, WINDOW_UPDATE_SHOW); } break; - case 81: - if (popup->unk_17 != 0) { + case BTL_MSG_51: + if (popup->unk_17) { s32 messageID; - popup->unk_17 = 0; + popup->unk_17 = FALSE; messageID = bMessages[popup->messageIndex]; set_message_msg(bActorMessages[D_8029F640], 0); msgWidth = get_msg_width(messageID, 0) + 31; @@ -3861,31 +3951,31 @@ void btl_show_message_popup(void* data) { set_window_update(WINDOW_ID_9, WINDOW_UPDATE_SHOW); } break; - case 46: - case 47: - case 48: - case 49: - case 50: - case 51: - case 52: - case 53: - case 54: - case 55: - case 56: - case 57: - case 58: - case 59: - case 60: - case 61: - case 62: - case 63: - case 64: - case 65: - case 66: - if (popup->unk_17 != 0) { + case BTL_MSG_2E: + case BTL_MSG_2F: + case BTL_MSG_30: + case BTL_MSG_31: + case BTL_MSG_32: + case BTL_MSG_33: + case BTL_MSG_34: + case BTL_MSG_35: + case BTL_MSG_36: + case BTL_MSG_37: + case BTL_MSG_38: + case BTL_MSG_39: + case BTL_MSG_3A: + case BTL_MSG_3B: + case BTL_MSG_3C: + case BTL_MSG_3D: + case BTL_MSG_3E: + case BTL_MSG_3F: + case BTL_MSG_40: + case BTL_MSG_41: + case BTL_MSG_42: + if (popup->unk_17) { s32 messageID; - popup->unk_17 = 0; + popup->unk_17 = FALSE; messageID = bMessages[popup->messageIndex]; msgWidth = get_msg_width(messageID, 0) + 31; posX = 160 - (msgWidth / 2); @@ -3893,7 +3983,7 @@ void btl_show_message_popup(void* data) { width = msgWidth; numLines = get_msg_lines(messageID) - 1; height = bMsgHeights[numLines]; - if (popup->messageIndex == 0x3B) { + if (popup->messageIndex == BTL_MSG_3B) { posY = 120; D_8029F64C = 1; } @@ -3902,7 +3992,7 @@ void btl_show_message_popup(void* data) { posY = D_8029F64E + D_8029F650; set_window_properties(WINDOW_ID_9, posX, posY, width, height, 0, func_80250818, popup, -1); - if (popup->messageIndex == 0x3B) { + if (popup->messageIndex == BTL_MSG_3B) { set_window_update(WINDOW_ID_9, WINDOW_UPDATE_SHOW); } else { set_window_update(WINDOW_ID_9, WINDOW_UPDATE_SHOW_DARKENED); @@ -3944,8 +4034,8 @@ ApiStatus WaitForMessageBoxDone(Evt* script, s32 isInitialCall) { } ApiStatus ForceCloseMessageBox(Evt* script, s32 isInitialCall) { - if (D_802838F8 != NULL) { - D_802838F8->duration = 0; + if (bPopupMessage != NULL) { + bPopupMessage->duration = 0; } return ApiStatus_DONE2; } diff --git a/src/182B30.c b/src/182B30.c index 02b5832fb7..377660dd98 100644 --- a/src/182B30.c +++ b/src/182B30.c @@ -1474,7 +1474,7 @@ void appendGfx_player_actor(void* arg0) { enable_status_icon_boost_hammer(player->hudElementDataIndex); } - if ((player->flags & ACTOR_FLAG_8000000) && !(gBattleStatus.flags2 & BS_FLAGS2_40)) { + if ((player->flags & ACTOR_FLAG_8000000) && !(gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE)) { if (playerData->curHP > 1) { remove_status_icon_peril(player->hudElementDataIndex); do { @@ -2763,7 +2763,7 @@ void func_8025B5C0(s32 arg0, ActorPart* part, s32 yaw, Matrix4f mtx, s32 arg4, s decorationTable->numSpritePalettes++; } - if (gBattleStatus.flags2 & BS_FLAGS2_40) { + if (gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) { decorationTable->spriteColorVariations = 4; } else { decorationTable->spriteColorVariations = 6; diff --git a/src/18C790.c b/src/18C790.c index 6b36151415..72b5d07a01 100644 --- a/src/18C790.c +++ b/src/18C790.c @@ -1,6 +1,7 @@ #include "common.h" #include "effects.h" #include "hud_element.h" +#include "message_ids.h" #include "ld_addrs.h" #include "model.h" #include "script_api/battle.h" @@ -18,43 +19,68 @@ extern HudScript HES_ProjectorBeam; extern IconHudScriptPair gItemHudScripts[]; -BSS s32 D_8029FA80[4]; -BSS s32 D_8029FA90[3][7]; +// menu position index for level up screen +enum { + MENU_HP = 0, + MENU_FP = 1, + MENU_BP = 2, +}; + +// first index for LevelUpStatTextHEIDs +enum { + LVL_UP_FP = 0, + LVL_UP_HP = 1, + LVL_UP_BP = 2, +}; + +// second index for LevelUpStatTextHEIDs +enum { + LVL_UP_TITLE = 0, + LVL_UP_CUR_TENS = 1, + LVL_UP_CUR_ONES = 2, + LVL_UP_ARROW = 3, + LVL_UP_NEXT_TENS = 4, + LVL_UP_NEXT_ONES = 5, + LVL_UP_BONUS = 6, +}; + +BSS s32 LevelUpStatEmblemHEIDs[4]; +BSS s32 LevelUpStatTextHEIDs[3][7]; BSS s32 D_8029FAE4; // unused? -BSS s32 D_8029FAE8; +BSS s32 LevelUpSpotlightHEID; BSS s32 D_8029FAEC[23]; // unused? -BSS s32 D_8029FB48; -BSS s32 D_8029FB4C; +BSS s32 LevelUpSelectTextHEID; +BSS s32 CelebrateSubstateTime; BSS s32 D_8029FB50; -BSS s32 D_8029FB54; +BSS s32 EndBattleRewardStep; BSS s32 D_8029FB58[2]; // unused? -BSS s32 D_8029FB60[3]; -BSS s32 D_8029FB6C; -BSS s32 D_8029FB70; -BSS s32 D_8029FB74; -BSS s32 D_8029FB78; -BSS Evt* D_8029FB7C; -BSS s32 D_8029FB80; -BSS s32 D_8029FB84; -BSS s32 D_8029FB88; -BSS s32 D_8029FB8C; +BSS s32 CantLevelUpStat[3]; +BSS s32 EndBattleRewardTotal; +BSS s32 EndBattleRewardIncrement; +BSS s32 pendingLevelUps; +BSS s32 EndBattleRewardsDone; +BSS Evt* LevelUpScriptPtr; +BSS s32 LevelUpScriptID; +BSS s32 CelebrateStateTime; +BSS s32 LevelUpSelectTextOffsetX; +BSS s32 LevelUpSelectTextVelX; -extern EntityModelScript starpoint_model_script_starpoint; -extern EntityModelScript starpoint_model_script_starpoints; -extern EntityModelScript starpoint_model_script_digit_0; -extern EntityModelScript starpoint_model_script_digit_1; -extern EntityModelScript starpoint_model_script_digit_2; -extern EntityModelScript starpoint_model_script_digit_3; -extern EntityModelScript starpoint_model_script_digit_4; -extern EntityModelScript starpoint_model_script_digit_5; -extern EntityModelScript starpoint_model_script_digit_6; -extern EntityModelScript starpoint_model_script_digit_7; -extern EntityModelScript starpoint_model_script_digit_8; -extern EntityModelScript starpoint_model_script_digit_9; -extern EntityModelScript starpoint_model_script_dummy; +extern EntityModelScript EMS_starpoint_starpoint; +extern EntityModelScript EMS_starpoint_starpoints; +extern EntityModelScript EMS_starpoint_digit_0; +extern EntityModelScript EMS_starpoint_digit_1; +extern EntityModelScript EMS_starpoint_digit_2; +extern EntityModelScript EMS_starpoint_digit_3; +extern EntityModelScript EMS_starpoint_digit_4; +extern EntityModelScript EMS_starpoint_digit_5; +extern EntityModelScript EMS_starpoint_digit_6; +extern EntityModelScript EMS_starpoint_digit_7; +extern EntityModelScript EMS_starpoint_digit_8; +extern EntityModelScript EMS_starpoint_digit_9; +extern EntityModelScript EMS_starpoint_dummy; -extern EntityModelScript level_up_model_script; +extern EntityModelScript EMS_level_up; extern HudScript HES_level_up_flower; extern HudScript HES_level_up_leaves; @@ -133,38 +159,38 @@ extern HudScript HES_level_up_small_blue_arrow; extern HudScript HES_level_up_select_one_to_upgrade; -s32 D_80284150 = 255; +s32 bFadeToBlackAmt = 255; s32 D_80284154[] = { - 0, - ANIM_BattleGoombario_Walk, - ANIM_BattleKooper_Walk, - ANIM_BattleBombette_Walk, - ANIM_BattleParakarry_Walk, - ANIM_Goompa_Walk, - ANIM_BattleWatt_Walk, - ANIM_BattleSushie_Walk, - ANIM_BattleLakilester_Walk, - ANIM_BattleBow_Walk, - 0, - 0, + [PARTNER_NONE] = 0, + [PARTNER_GOOMBARIO] = ANIM_BattleGoombario_Walk, + [PARTNER_KOOPER] = ANIM_BattleKooper_Walk, + [PARTNER_BOMBETTE] = ANIM_BattleBombette_Walk, + [PARTNER_PARAKARRY] = ANIM_BattleParakarry_Walk, + [PARTNER_GOOMPA] = ANIM_Goompa_Walk, + [PARTNER_WATT] = ANIM_BattleWatt_Walk, + [PARTNER_SUSHIE] = ANIM_BattleSushie_Walk, + [PARTNER_LAKILESTER] = ANIM_BattleLakilester_Walk, + [PARTNER_BOW] = ANIM_BattleBow_Walk, + [PARTNER_GOOMBARIA] = 0, + [PARTNER_TWINK] = 0, 0 }; EntityModelScript* starpoint_digit_scripts[] = { - &starpoint_model_script_digit_0, - &starpoint_model_script_digit_1, - &starpoint_model_script_digit_2, - &starpoint_model_script_digit_3, - &starpoint_model_script_digit_4, - &starpoint_model_script_digit_5, - &starpoint_model_script_digit_6, - &starpoint_model_script_digit_7, - &starpoint_model_script_digit_8, - &starpoint_model_script_digit_9, + &EMS_starpoint_digit_0, + &EMS_starpoint_digit_1, + &EMS_starpoint_digit_2, + &EMS_starpoint_digit_3, + &EMS_starpoint_digit_4, + &EMS_starpoint_digit_5, + &EMS_starpoint_digit_6, + &EMS_starpoint_digit_7, + &EMS_starpoint_digit_8, + &EMS_starpoint_digit_9, }; -EntityModelScript* starpoint_space_script = &starpoint_model_script_dummy; +EntityModelScript* starpoint_space_script = &EMS_starpoint_dummy; HudScript* levelup_stat_scripts[3] = { &HES_level_up_FP, @@ -252,15 +278,15 @@ HudScript* level_up_small_digit_scripts[3][10] = { s32* virtual_entity_get_by_index(s32); -void func_80260948(s32 arg0, s32 posX, s32 posY); -void func_80260A20(s64 posX, s32 posY); +void draw_content_level_up_textbox(void* data, s32 posX, s32 posY); +void draw_content_cant_increase_popup(void* data, s32 posX, s32 posY); -ApiStatus func_8025DEB0(Evt* script, s32 isInitialCall) { +API_CALLABLE(GetRemainingStarPointsReward) { script->varTable[0] = (s8)gBattleStatus.totalStarPoints; return ApiStatus_DONE2; } -s32 func_8025DEC4(Evt* script, s32 isInitialCall) { +API_CALLABLE(GetStarPointDigitScripts) { s32 levelUp = FALSE; script->varTable[10] = gBattleStatus.totalStarPoints / 100; // star points in hundreds (levels to gain) @@ -284,11 +310,15 @@ s32 func_8025DEC4(Evt* script, s32 isInitialCall) { return ApiStatus_DONE2; } -ApiStatus func_8025E030(Evt* script, s32 isInitialCall) { - return D_8029FB78 != 0 ? ApiStatus_DONE2 : ApiStatus_BLOCK; +API_CALLABLE(AwaitBattleRewardsDone) { + if (EndBattleRewardsDone) { + return ApiStatus_DONE2; + } else { + return ApiStatus_BLOCK; + } } -ApiStatus func_8025E044(Evt* script, s32 isInitialCall) { +API_CALLABLE(InitStarPointModelFlags) { EntityModel* model; model = get_entity_model(*virtual_entity_get_by_index(script->varTable[6])); @@ -307,34 +337,31 @@ ApiStatus func_8025E044(Evt* script, s32 isInitialCall) { return ApiStatus_DONE2; } -ApiStatus func_8025E108(Evt* script, s32 isInitialCall) { +API_CALLABLE(InitLevelUpModelFlags) { EntityModel* model = get_entity_model(*virtual_entity_get_by_index(script->varTable[9])); - model->flags &= ~(MODEL_FLAGS_USES_CUSTOM_GFX | MODEL_FLAGS_FLAG_20 | MODEL_FLAGS_FLAG_40 - | MODEL_FLAGS_HAS_LOCAL_VERTEX_COPY | MODEL_FLAGS_USE_CAMERA_UNK_MATRIX | MODEL_FLAGS_FLAG_200 - | MODEL_FLAGS_HAS_TRANSFORM_APPLIED | MODEL_FLAGS_HAS_TEX_PANNER | MODEL_FLAGS_USES_TRANSFORM_MATRIX - | MODEL_FLAGS_FLAG_2000 | MODEL_FLAGS_FLAG_4000 | MODEL_FLAGS_FLAG_8000); + model->flags &= ~MODEL_FLAGS_MASK_FFF0; model->flags |= MODEL_FLAGS_TRANSFORM_GROUP_MEMBER; return ApiStatus_DONE2; } -ApiStatus func_8025E14C(Evt* script, s32 isInitialCall) { +API_CALLABLE(MakeLevelUpConfetti) { fx_confetti(3, 0.0f, 100.0f, 0.0f, 1.0f, 120); return ApiStatus_DONE2; } EvtScript EVS_ShowStarpoints = { EVT_SET(LVarF, 0) - EVT_CALL(func_8025DEB0) + EVT_CALL(GetRemainingStarPointsReward) EVT_IF_EQ(LVar0, 0) EVT_RETURN EVT_END_IF EVT_IF_LT(LVar0, 2) - EVT_CALL(CreateVirtualEntity, LVar6, EVT_PTR(starpoint_model_script_starpoint)) + EVT_CALL(CreateVirtualEntity, LVar6, EVT_PTR(EMS_starpoint_starpoint)) EVT_CALL(SetVirtualEntityPosition, LVar6, -278, 68, 70) EVT_CALL(SetVirtualEntityScale, LVar6, EVT_FLOAT(0.5), EVT_FLOAT(0.5), EVT_FLOAT(0.5)) EVT_ELSE - EVT_CALL(CreateVirtualEntity, LVar6, EVT_PTR(starpoint_model_script_starpoints)) + EVT_CALL(CreateVirtualEntity, LVar6, EVT_PTR(EMS_starpoint_starpoints)) EVT_CALL(SetVirtualEntityPosition, LVar6, -278, 68, 70) EVT_CALL(SetVirtualEntityScale, LVar6, EVT_FLOAT(0.5), EVT_FLOAT(0.5), EVT_FLOAT(0.5)) EVT_SET(LocalFlag(0), 1) @@ -347,7 +374,7 @@ EvtScript EVS_ShowStarpoints = { EVT_CASE_DEFAULT EVT_SET(LVarF, 1) EVT_END_SWITCH - EVT_CALL(func_8025DEC4) + EVT_CALL(GetStarPointDigitScripts) EVT_CALL(CreateVirtualEntity, LVar7, LVarA) EVT_CALL(SetVirtualEntityPosition, LVar7, -353, 68, 70) EVT_CALL(SetVirtualEntityScale, LVar7, EVT_FLOAT(0.5), EVT_FLOAT(0.5), EVT_FLOAT(0.5)) @@ -357,7 +384,7 @@ EvtScript EVS_ShowStarpoints = { EVT_CALL(CreateVirtualEntity, LVar9, LVarC) EVT_CALL(SetVirtualEntityPosition, LVar9, -323, 68, 70) EVT_CALL(SetVirtualEntityScale, LVar9, EVT_FLOAT(0.5), EVT_FLOAT(0.5), EVT_FLOAT(0.5)) - EVT_CALL(func_8025E044) + EVT_CALL(InitStarPointModelFlags) EVT_SWITCH(LVarF) EVT_CASE_EQ(3) EVT_SET(LVar0, -197) @@ -382,7 +409,7 @@ EvtScript EVS_ShowStarpoints = { EVT_CALL(SetVirtualEntityPosition, LVar9, LVar1, 68, 70) EVT_WAIT(1) EVT_END_LOOP - EVT_CALL(func_8025E030) + EVT_CALL(AwaitBattleRewardsDone) EVT_SWITCH(LVarF) EVT_CASE_EQ(3) EVT_SET(LVar0, 3) @@ -416,12 +443,12 @@ EvtScript EVS_ShowStarpoints = { }; EvtScript EVS_ShowLevelUp = { - EVT_CALL(CreateVirtualEntity, LVar9, EVT_PTR(level_up_model_script)) + EVT_CALL(CreateVirtualEntity, LVar9, EVT_PTR(EMS_level_up)) EVT_CALL(SetVirtualEntityPosition, LVar9, 0, 210, 70) - EVT_CALL(func_8025E108) + EVT_CALL(InitLevelUpModelFlags) EVT_CHILD_THREAD EVT_WAIT(4) - EVT_CALL(func_8025E14C) + EVT_CALL(MakeLevelUpConfetti) EVT_END_CHILD_THREAD EVT_THREAD EVT_WAIT(8) @@ -452,22 +479,18 @@ void btl_state_update_celebration(void) { s8 currentSubmenu; s32 newSubmenu; s32 id; - s32 x; - s32 y; - s32 z; + s32 x, y, z; s32 width; + s32 itemHudElemID; Evt* takeTurnScript; Evt* script; - s32 temp_v1_4; - s32 temp_v1_5; + s32 tensDigit; + s32 onesDigit; - s32 fpTens; - s32 fpOnes; - - s32 leftoverSP; - s32 oldSP; + s32 deltaSP; + s32 prevSP; s32 i; s32 j; @@ -475,62 +498,64 @@ void btl_state_update_celebration(void) { HudScript* new_var; switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_0: + case BTL_SUBSTATE_CELEBRATE_INIT: if (battleStatus->pendingStarPoints <= 0) { player->flags &= ~ACTOR_FLAG_8000000; - D_8029FB6C = battleStatus->totalStarPoints * 100; - D_8029FB74 = 0; + EndBattleRewardTotal = battleStatus->totalStarPoints * 100; + pendingLevelUps = 0; D_8029FB50 = 0; - D_80284150 = 0; - D_8029FB88 = 0; - D_8029FB8C = 0; + bFadeToBlackAmt = 0; + LevelUpSelectTextOffsetX = 0; + LevelUpSelectTextVelX = 0; sfx_play_sound(SOUND_D4); - oldSP = playerData->starPoints + battleStatus->totalStarPoints; - if (oldSP >= 100) { + prevSP = playerData->starPoints + battleStatus->totalStarPoints; + if (prevSP > 99) { bgm_set_song(0, SONG_LEVEL_UP, 0, 250, 8); } else { bgm_set_song(0, SONG_BATTLE_END, 0, 250, 8); } - D_8029FB84 = 0; + CelebrateStateTime = 0; btl_cam_use_preset(BTL_CAM_PRESET_23); - D_8029FB54 = 0; - D_8029FB4C = 1; - gBattleSubState = BATTLE_SUB_STATE_UNK_1; + EndBattleRewardStep = 0; + CelebrateSubstateTime = 1; + gBattleSubState = BTL_SUBSTATE_CELEBRATE_LOAD_STAR_POINTS; gBattleStatus.flags2 |= BS_FLAGS2_1; } break; - case BATTLE_SUB_STATE_UNK_1: - if (D_8029FB4C != 0) { - D_8029FB4C--; + case BTL_SUBSTATE_CELEBRATE_LOAD_STAR_POINTS: + if (CelebrateSubstateTime != 0) { + CelebrateSubstateTime--; } else if (btl_cam_is_moving_done()) { dma_copy(starpoint_ROM_START, starpoint_ROM_END, starpoint_VRAM); script = start_script(&EVS_ShowStarpoints, EVT_PRIORITY_A, 0); - D_8029FB78 = 0; - D_8029FB54 = 20; - D_8029FB70 = D_8029FB6C / D_8029FB54; + EndBattleRewardsDone = FALSE; + // divide reward into 20 increments + EndBattleRewardStep = 20; + EndBattleRewardIncrement = EndBattleRewardTotal / EndBattleRewardStep; player->takeTurnScript = script; - D_8029FB4C = 1; - player->takeTurnID = script->id; - script->owner1.enemyID = 0; - gBattleSubState = BATTLE_SUB_STATE_UNK_2; + CelebrateSubstateTime = 1; + player->takeTurnScriptID = script->id; + script->owner1.actorID = ACTOR_PLAYER; + gBattleSubState = BTL_SUBSTATE_CELEBRATE_TALLY_STAR_POINTS; } break; - case BATTLE_SUB_STATE_UNK_2: - if (D_8029FB4C == 0) { + case BTL_SUBSTATE_CELEBRATE_TALLY_STAR_POINTS: + if (CelebrateSubstateTime == 0) { if (battleStatus->totalStarPoints != 0) { - D_8029FB6C -= D_8029FB70; - oldSP = battleStatus->totalStarPoints; - battleStatus->totalStarPoints = D_8029FB6C / 100; - leftoverSP = oldSP - battleStatus->totalStarPoints; - if (leftoverSP > 0) { + // determine the remaining star point reward after this step and give the difference to the player + EndBattleRewardTotal -= EndBattleRewardIncrement; + prevSP = battleStatus->totalStarPoints; + battleStatus->totalStarPoints = EndBattleRewardTotal / 100; + deltaSP = prevSP - battleStatus->totalStarPoints; + if (deltaSP > 0) { sfx_play_sound(SOUND_215); } - playerData->starPoints += leftoverSP; - D_80284150 += 1; - if (D_8029FB54 == 0 && battleStatus->totalStarPoints != 0) { + playerData->starPoints += deltaSP; + bFadeToBlackAmt++; // ?? + if (EndBattleRewardStep == 0 && battleStatus->totalStarPoints != 0) { playerData->starPoints++; } } @@ -538,15 +563,15 @@ void btl_state_update_celebration(void) { playerData->starPoints = 0; } if (playerData->starPoints >= 100) { - D_8029FB74 = 1; + pendingLevelUps = 1; playerData->starPoints -= 100; } - if (playerData->level + D_8029FB74 == 27) { + if (playerData->level + pendingLevelUps == 27) { playerData->starPoints = 0; } if (battleStatus->totalStarPoints == 0) { - if (D_8029FB54 == 0) { - D_8029FB78 = 1; + if (EndBattleRewardStep == 0) { + EndBattleRewardsDone = TRUE; player->flags &= ~(ACTOR_FLAG_4000000 | ACTOR_FLAG_8000000); if (partner != NULL) { partner->flags &= ~(ACTOR_FLAG_4000000 | ACTOR_FLAG_8000000); @@ -554,57 +579,57 @@ void btl_state_update_celebration(void) { battleStatus->battlePhase = PHASE_CELEBRATE; script = start_script(&PlayerScriptDispatcher, EVT_PRIORITY_A, 0); player->takeTurnScript = script; - player->takeTurnID = script->id; + player->takeTurnScriptID = script->id; script->owner1.actorID = ACTOR_PLAYER; if (partner != NULL) { - script = start_script(partner->takeTurnScriptSource, EVT_PRIORITY_A, 0); + script = start_script(partner->takeTurnSource, EVT_PRIORITY_A, 0); partner->takeTurnScript = script; - partner->takeTurnID = script->id; + partner->takeTurnScriptID = script->id; script->owner1.actorID = ACTOR_PARTNER; } - D_8029FB4C = 40; - gBattleSubState = BATTLE_SUB_STATE_UNK_3; + CelebrateSubstateTime = 40; + gBattleSubState = BTL_SUBSTATE_CELEBRATE_POST_STAR_POINTS; } else { - D_8029FB54--; + EndBattleRewardStep--; } } } else { - D_8029FB4C--; + CelebrateSubstateTime--; } break; - case BATTLE_SUB_STATE_UNK_3: - if (D_8029FB4C == 0) { - if (D_8029FB74 == 0) { - gBattleSubState = BATTLE_SUB_STATE_UNK_14; + case BTL_SUBSTATE_CELEBRATE_POST_STAR_POINTS: + if (CelebrateSubstateTime == 0) { + if (pendingLevelUps == 0) { + gBattleSubState = BTL_SUBSTATE_CELEBRATE_SKIPPABLE_END_DELAY; } else { - gBattleSubState = BATTLE_SUB_STATE_UNK_4; + gBattleSubState = BTL_SUBSTATE_CELEBRATE_LEVEL_UP_LOAD; } break; } - D_8029FB4C--; + CelebrateSubstateTime--; break; - case BATTLE_SUB_STATE_UNK_4: - if (D_8029FB84 >= 99) { + case BTL_SUBSTATE_CELEBRATE_LEVEL_UP_LOAD: + if (CelebrateStateTime >= 99) { playerData->level++; btl_cam_use_preset(BTL_CAM_PRESET_C); btl_cam_move(5); dma_copy(level_up_ROM_START, level_up_ROM_END, level_up_VRAM); sfx_play_sound(SOUND_80000008); - D_8029FB84 = 0; - gBattleSubState = BATTLE_SUB_STATE_BEGIN_LEVEL_UP; + CelebrateStateTime = 0; + gBattleSubState = BTL_SUBSTATE_CELEBRATE_LEVEL_UP_BEGIN; } break; - case BATTLE_SUB_STATE_BEGIN_LEVEL_UP: - D_8029FB7C = start_script(&EVS_ShowLevelUp, EVT_PRIORITY_A, 0); - D_8029FB4C = 25; - gBattleSubState = BATTLE_SUB_STATE_LEVEL_UP_SHOW_HUD; - D_8029FB80 = D_8029FB7C->id; + case BTL_SUBSTATE_CELEBRATE_LEVEL_UP_BEGIN: + LevelUpScriptPtr = start_script(&EVS_ShowLevelUp, EVT_PRIORITY_A, 0); + LevelUpScriptID = LevelUpScriptPtr->id; + CelebrateSubstateTime = 25; + gBattleSubState = BTL_SUBSTATE_CELEBRATE_LEVEL_UP_CREATE_HUD; mdl_set_all_fog_mode(1); *gBgRenderTypePtr = BACKGROUND_RENDER_TYPE_1; set_background_color_blend(0, 0, 0, 0); break; - case BATTLE_SUB_STATE_LEVEL_UP_SHOW_HUD: - if (D_8029FB4C == 18) { + case BTL_SUBSTATE_CELEBRATE_LEVEL_UP_CREATE_HUD: + if (CelebrateSubstateTime == 18) { playerData->curHP = playerData->curMaxHP; playerData->curFP = playerData->curMaxFP; x = player->currentPos.x + 0.0f; @@ -618,133 +643,136 @@ void btl_state_update_celebration(void) { playerData->specialBarsFilled = playerData->maxStarPower * 256; } - if (D_8029FB4C != 0) { - D_8029FB4C--; - if (D_8029FB4C < 10) { - set_background_color_blend(0, 0, 0, ((10 - D_8029FB4C) * 0x10) & 0xF0); + if (CelebrateSubstateTime != 0) { + CelebrateSubstateTime--; + if (CelebrateSubstateTime < 10) { + set_background_color_blend(0, 0, 0, ((10 - CelebrateSubstateTime) * 16) & 0xF0); } } else { id = hud_element_create(&HES_level_up_heart); - D_8029FA80[0] = id; + LevelUpStatEmblemHEIDs[0] = id; hud_element_set_render_pos(id, 310, 140); hud_element_set_flags(id, HUD_ELEMENT_FLAGS_80); id = hud_element_create(&HES_level_up_flower); - D_8029FA80[1] = id; + LevelUpStatEmblemHEIDs[1] = id; hud_element_set_render_pos(id, 158, 340); hud_element_set_flags(id, HUD_ELEMENT_FLAGS_80); id = hud_element_create(&HES_level_up_leaves); - D_8029FA80[3] = id; + LevelUpStatEmblemHEIDs[3] = id; hud_element_set_render_pos(id, 158, 340); hud_element_set_flags(id, HUD_ELEMENT_FLAGS_80); id = hud_element_create(&HES_level_up_badge); - D_8029FA80[2] = id; + LevelUpStatEmblemHEIDs[2] = id; hud_element_set_render_pos(id, 6, 140); hud_element_set_flags(id, HUD_ELEMENT_FLAGS_80); id = hud_element_create(levelup_stat_scripts[0]); - D_8029FA90[0][0] = id; + LevelUpStatTextHEIDs[LVL_UP_FP][LVL_UP_TITLE] = id; hud_element_set_render_pos(id, 160, 317); hud_element_set_flags(id, HUD_ELEMENT_FLAGS_80); - for (i = 1; i < ARRAY_COUNT(D_8029FA90[0]); i++) { - id = hud_element_create(level_up_digit_scripts[0][0]); - D_8029FA90[0][i] = id; + for (i = 1; i < ARRAY_COUNT(LevelUpStatTextHEIDs[LVL_UP_FP]); i++) { + id = hud_element_create(level_up_digit_scripts[LVL_UP_FP][0]); + LevelUpStatTextHEIDs[LVL_UP_FP][i] = id; hud_element_set_render_pos(id, 160, 317); hud_element_set_flags(id, HUD_ELEMENT_FLAGS_80 | HUD_ELEMENT_FLAGS_DISABLED); } id = hud_element_create(levelup_stat_scripts[1]); - D_8029FA90[0][7] = id; + LevelUpStatTextHEIDs[LVL_UP_HP][LVL_UP_TITLE] = id; hud_element_set_render_pos(id, 312, 117); hud_element_set_flags(id, HUD_ELEMENT_FLAGS_80); - for (i = 1; i < ARRAY_COUNT(D_8029FA90[0]); i++) { - id = hud_element_create(level_up_digit_scripts[1][0]); - D_8029FA90[1][i] = id; + for (i = 1; i < ARRAY_COUNT(LevelUpStatTextHEIDs[LVL_UP_HP]); i++) { + id = hud_element_create(level_up_digit_scripts[LVL_UP_HP][0]); + LevelUpStatTextHEIDs[LVL_UP_HP][i] = id; hud_element_set_render_pos(id, 312, 117); hud_element_set_flags(id, HUD_ELEMENT_FLAGS_80 | HUD_ELEMENT_FLAGS_DISABLED); } id = hud_element_create(levelup_stat_scripts[2]); - D_8029FA90[2][0] = id; + LevelUpStatTextHEIDs[LVL_UP_BP][LVL_UP_TITLE] = id; hud_element_set_render_pos(id, 8, 117); hud_element_set_flags(id, HUD_ELEMENT_FLAGS_80); - for (i = 1; i < ARRAY_COUNT(D_8029FA90[20]); i++) { - id = hud_element_create(level_up_digit_scripts[2][0]); - D_8029FA90[2][i] = id; + for (i = 1; i < ARRAY_COUNT(LevelUpStatTextHEIDs[LVL_UP_BP]); i++) { + id = hud_element_create(level_up_digit_scripts[LVL_UP_BP][0]); + LevelUpStatTextHEIDs[LVL_UP_BP][i] = id; hud_element_set_render_pos(id, 8, 117); hud_element_set_flags(id, HUD_ELEMENT_FLAGS_80 | HUD_ELEMENT_FLAGS_DISABLED); } - D_8029FB60[0] = 0; - D_8029FB60[1] = 0; - D_8029FB60[2] = 0; + CantLevelUpStat[MENU_HP] = FALSE; + CantLevelUpStat[MENU_FP] = FALSE; + CantLevelUpStat[MENU_BP] = FALSE; if (playerData->hardMaxFP != 50) { - fpTens = playerData->curMaxFP / 10; - fpOnes = playerData->curMaxFP % 10; - id = D_8029FA90[0][1]; - hud_element_set_script(id, level_up_small_digit_scripts[0][fpTens]); - if (fpTens != 0) { + // current FP + tensDigit = playerData->curMaxFP / 10; + onesDigit = playerData->curMaxFP % 10; + id = LevelUpStatTextHEIDs[LVL_UP_FP][LVL_UP_CUR_TENS]; + hud_element_set_script(id, level_up_small_digit_scripts[LVL_UP_FP][tensDigit]); + if (tensDigit != 0) { hud_element_clear_flags(id, HUD_ELEMENT_FLAGS_DISABLED); } hud_element_get_render_pos(id, &x, &y); hud_element_set_render_pos(id, x - 14, y + 46); - id = D_8029FA90[0][2]; - hud_element_set_script(id, level_up_small_digit_scripts[0][fpOnes]); + id = LevelUpStatTextHEIDs[LVL_UP_FP][LVL_UP_CUR_ONES]; + hud_element_set_script(id, level_up_small_digit_scripts[LVL_UP_FP][onesDigit]); hud_element_clear_flags(id, HUD_ELEMENT_FLAGS_DISABLED); hud_element_get_render_pos(id, &x, &y); hud_element_set_render_pos(id, x - 8, y + 46); - id = D_8029FA90[0][3]; + id = LevelUpStatTextHEIDs[LVL_UP_FP][LVL_UP_ARROW]; hud_element_set_script(id, &HES_level_up_small_green_arrow); hud_element_clear_flags(id, HUD_ELEMENT_FLAGS_DISABLED); hud_element_get_render_pos(id, &x, &y); hud_element_set_render_pos(id, x - 3, y + 46); - - fpTens = (playerData->curMaxFP + 5) / 10; - fpOnes = (playerData->curMaxFP + 5) % 10; - id = D_8029FA90[0][4]; - hud_element_set_script(id, level_up_digit_scripts[0][fpTens]); - if (fpTens != 0) { + // upgraded FP + tensDigit = (playerData->curMaxFP + 5) / 10; + onesDigit = (playerData->curMaxFP + 5) % 10; + id = LevelUpStatTextHEIDs[LVL_UP_FP][LVL_UP_NEXT_TENS]; + hud_element_set_script(id, level_up_digit_scripts[LVL_UP_FP][tensDigit]); + if (tensDigit != 0) { hud_element_clear_flags(id, HUD_ELEMENT_FLAGS_DISABLED); } hud_element_get_render_pos(id, &x, &y); hud_element_set_render_pos(id, x + 3, y + 46); - id = D_8029FA90[0][5]; - hud_element_set_script(id, level_up_digit_scripts[0][fpOnes]); + id = LevelUpStatTextHEIDs[LVL_UP_FP][LVL_UP_NEXT_ONES]; + hud_element_set_script(id, level_up_digit_scripts[LVL_UP_FP][onesDigit]); hud_element_clear_flags(id, HUD_ELEMENT_FLAGS_DISABLED); hud_element_get_render_pos(id, &x, &y); hud_element_set_render_pos(id, x + 10, y + 46); } else { - id = D_8029FA90[0][4]; - fpTens = playerData->curMaxFP / 10; - fpOnes = playerData->curMaxFP % 10; - hud_element_set_script(id, level_up_digit_scripts[0][fpTens]); - if (fpTens != 0) { + // upgraded FP only + id = LevelUpStatTextHEIDs[LVL_UP_FP][LVL_UP_NEXT_TENS]; + tensDigit = playerData->curMaxFP / 10; + onesDigit = playerData->curMaxFP % 10; + hud_element_set_script(id, level_up_digit_scripts[LVL_UP_FP][tensDigit]); + if (tensDigit != 0) { hud_element_clear_flags(id, HUD_ELEMENT_FLAGS_DISABLED); } hud_element_get_render_pos(id, &x, &y); hud_element_set_render_pos(id, x - 6, y + 46); - id = D_8029FA90[0][5]; - hud_element_set_script(id, level_up_digit_scripts[0][fpOnes]); + id = LevelUpStatTextHEIDs[LVL_UP_FP][LVL_UP_NEXT_ONES]; + hud_element_set_script(id, level_up_digit_scripts[LVL_UP_FP][onesDigit]); hud_element_clear_flags(id, 2); hud_element_get_render_pos(id, &x, &y); hud_element_set_render_pos(id, x + 2, y + 46); - D_8029FB60[1] = 1; + CantLevelUpStat[MENU_FP] = TRUE; } if (is_ability_active(ABILITY_FP_PLUS)) { - id = D_8029FA90[0][6]; - hud_element_set_script(id, gItemHudScripts[gItemTable[248].hudElemID].enabled); + id = LevelUpStatTextHEIDs[LVL_UP_FP][LVL_UP_BONUS]; + itemHudElemID = gItemTable[ITEM_FP_PLUS_A].hudElemID; + hud_element_set_script(id, gItemHudScripts[itemHudElemID].enabled); hud_element_clear_flags(id, HUD_ELEMENT_FLAGS_DISABLED); hud_element_set_scale(id, 0.5f); hud_element_get_render_pos(id, &x, &y); @@ -752,68 +780,70 @@ void btl_state_update_celebration(void) { } if (playerData->hardMaxHP != 50) { - fpTens = playerData->curMaxHP / 10; - fpOnes = playerData->curMaxHP % 10; + // current HP + tensDigit = playerData->curMaxHP / 10; + onesDigit = playerData->curMaxHP % 10; - id = D_8029FA90[1][1]; - hud_element_set_script(id, level_up_small_digit_scripts[1][fpTens]); - if (fpTens != 0) { + id = LevelUpStatTextHEIDs[LVL_UP_HP][LVL_UP_CUR_TENS]; + hud_element_set_script(id, level_up_small_digit_scripts[LVL_UP_HP][tensDigit]); + if (tensDigit != 0) { hud_element_clear_flags(id, HUD_ELEMENT_FLAGS_DISABLED); } hud_element_get_render_pos(id, &x, &y); hud_element_set_render_pos(id, x - 14, y + 46); - id = D_8029FA90[1][2]; - hud_element_set_script(id, level_up_small_digit_scripts[1][fpOnes]); + id = LevelUpStatTextHEIDs[LVL_UP_HP][LVL_UP_CUR_ONES]; + hud_element_set_script(id, level_up_small_digit_scripts[LVL_UP_HP][onesDigit]); hud_element_clear_flags(id, HUD_ELEMENT_FLAGS_DISABLED); hud_element_get_render_pos(id, &x, &y); hud_element_set_render_pos(id, x - 8, y + 46); - id = D_8029FA90[1][3]; + id = LevelUpStatTextHEIDs[LVL_UP_HP][LVL_UP_ARROW]; hud_element_set_script(id, &HES_level_up_small_red_arrow); hud_element_clear_flags(id, HUD_ELEMENT_FLAGS_DISABLED); hud_element_get_render_pos(id, &x, &y); hud_element_set_render_pos(id, x - 3, y + 46); - fpTens = (playerData->curMaxHP + 5) / 10; - fpOnes = (playerData->curMaxHP + 5) % 10; + tensDigit = (playerData->curMaxHP + 5) / 10; + onesDigit = (playerData->curMaxHP + 5) % 10; - id = D_8029FA90[1][4]; - hud_element_set_script(id, level_up_digit_scripts[1][fpTens]); - if (fpTens != 0) { + id = LevelUpStatTextHEIDs[LVL_UP_HP][LVL_UP_NEXT_TENS]; + hud_element_set_script(id, level_up_digit_scripts[LVL_UP_HP][tensDigit]); + if (tensDigit != 0) { hud_element_clear_flags(id, HUD_ELEMENT_FLAGS_DISABLED); } hud_element_get_render_pos(id, &x, &y); hud_element_set_render_pos(id, x + 3, y + 46); - id = D_8029FA90[1][5]; - hud_element_set_script(id, level_up_digit_scripts[1][fpOnes]); + id = LevelUpStatTextHEIDs[LVL_UP_HP][LVL_UP_NEXT_ONES]; + hud_element_set_script(id, level_up_digit_scripts[LVL_UP_HP][onesDigit]); hud_element_clear_flags(id, HUD_ELEMENT_FLAGS_DISABLED); hud_element_get_render_pos(id, &x, &y); hud_element_set_render_pos(id, x + 10, y + 46); } else { - fpTens = playerData->curMaxHP / 10; - fpOnes = playerData->curMaxHP % 10; + tensDigit = playerData->curMaxHP / 10; + onesDigit = playerData->curMaxHP % 10; - id = D_8029FA90[1][4]; - hud_element_set_script(id, level_up_digit_scripts[1][fpTens]); - if (fpTens != 0) { + id = LevelUpStatTextHEIDs[LVL_UP_HP][LVL_UP_NEXT_TENS]; + hud_element_set_script(id, level_up_digit_scripts[LVL_UP_HP][tensDigit]); + if (tensDigit != 0) { hud_element_clear_flags(id, HUD_ELEMENT_FLAGS_DISABLED); } hud_element_get_render_pos(id, &x, &y); hud_element_set_render_pos(id, x - 6, y + 46); - id = D_8029FA90[1][5]; - hud_element_set_script(id, level_up_digit_scripts[1][fpOnes]); + id = LevelUpStatTextHEIDs[LVL_UP_HP][LVL_UP_NEXT_ONES]; + hud_element_set_script(id, level_up_digit_scripts[LVL_UP_HP][onesDigit]); hud_element_clear_flags(id, HUD_ELEMENT_FLAGS_DISABLED); hud_element_get_render_pos(id, &x, &y); hud_element_set_render_pos(id, x + 2, y + 46); - D_8029FB60[0] = 1; + CantLevelUpStat[MENU_HP] = TRUE; } if (is_ability_active(ABILITY_HP_PLUS)) { - id = D_8029FA90[1][6]; - hud_element_set_script(id, gItemHudScripts[gItemTable[231].hudElemID].enabled); + id = LevelUpStatTextHEIDs[LVL_UP_HP][LVL_UP_BONUS]; + itemHudElemID = gItemTable[ITEM_HP_PLUS_A].hudElemID; + hud_element_set_script(id, gItemHudScripts[itemHudElemID].enabled); hud_element_clear_flags(id, HUD_ELEMENT_FLAGS_DISABLED); hud_element_set_scale(id, 0.5f); hud_element_get_render_pos(id, &x, &y); @@ -821,61 +851,61 @@ void btl_state_update_celebration(void) { } if (playerData->maxBP != 30) { - fpTens = playerData->maxBP / 10; - fpOnes = playerData->maxBP % 10; + tensDigit = playerData->maxBP / 10; + onesDigit = playerData->maxBP % 10; - id = D_8029FA90[2][1]; - hud_element_set_script(id, level_up_small_digit_scripts[2][fpTens]); - if (fpTens != 0) { + id = LevelUpStatTextHEIDs[LVL_UP_BP][LVL_UP_CUR_TENS]; + hud_element_set_script(id, level_up_small_digit_scripts[LVL_UP_BP][tensDigit]); + if (tensDigit != 0) { hud_element_clear_flags(id, HUD_ELEMENT_FLAGS_DISABLED); } hud_element_get_render_pos(id, &x, &y); hud_element_set_render_pos(id, x - 14, y + 46); - id = D_8029FA90[2][2]; - hud_element_set_script(id, level_up_small_digit_scripts[2][fpOnes]); + id = LevelUpStatTextHEIDs[LVL_UP_BP][LVL_UP_CUR_ONES]; + hud_element_set_script(id, level_up_small_digit_scripts[LVL_UP_BP][onesDigit]); hud_element_clear_flags(id, HUD_ELEMENT_FLAGS_DISABLED); hud_element_get_render_pos(id, &x, &y); hud_element_set_render_pos(id, x - 8, y + 46); - id = D_8029FA90[2][3]; + id = LevelUpStatTextHEIDs[LVL_UP_BP][LVL_UP_ARROW]; hud_element_set_script(id, &HES_level_up_small_blue_arrow); hud_element_clear_flags(id, HUD_ELEMENT_FLAGS_DISABLED); hud_element_get_render_pos(id, &x, &y); hud_element_set_render_pos(id, x - 3, y + 46); - fpTens = (playerData->maxBP + 3) / 10; - fpOnes = (playerData->maxBP + 3) % 10; + tensDigit = (playerData->maxBP + 3) / 10; + onesDigit = (playerData->maxBP + 3) % 10; - id = D_8029FA90[2][4]; - hud_element_set_script(id, level_up_digit_scripts[2][fpTens]); - if (fpTens != 0) { + id = LevelUpStatTextHEIDs[LVL_UP_BP][LVL_UP_NEXT_TENS]; + hud_element_set_script(id, level_up_digit_scripts[LVL_UP_BP][tensDigit]); + if (tensDigit != 0) { hud_element_clear_flags(id, HUD_ELEMENT_FLAGS_DISABLED); } hud_element_get_render_pos(id, &x, &y); hud_element_set_render_pos(id, x + 3, y + 46); - id = D_8029FA90[2][5]; - hud_element_set_script(id, level_up_digit_scripts[2][fpOnes]); + id = LevelUpStatTextHEIDs[LVL_UP_BP][LVL_UP_NEXT_ONES]; + hud_element_set_script(id, level_up_digit_scripts[LVL_UP_BP][onesDigit]); hud_element_clear_flags(id, HUD_ELEMENT_FLAGS_DISABLED); hud_element_get_render_pos(id, &x, &y); hud_element_set_render_pos(id, x + 10, y + 46); } else { - id = D_8029FA90[2][4]; - hud_element_set_script(id, level_up_digit_scripts[2][3]); + id = LevelUpStatTextHEIDs[LVL_UP_BP][LVL_UP_NEXT_TENS]; + hud_element_set_script(id, level_up_digit_scripts[LVL_UP_BP][3]); hud_element_clear_flags(id, HUD_ELEMENT_FLAGS_DISABLED); hud_element_get_render_pos(id, &x, &y); hud_element_set_render_pos(id, x - 6, y + 46); - id = D_8029FA90[2][5]; - hud_element_set_script(id, level_up_digit_scripts[2][0]); + id = LevelUpStatTextHEIDs[LVL_UP_BP][LVL_UP_NEXT_ONES]; + hud_element_set_script(id, level_up_digit_scripts[LVL_UP_BP][0]); hud_element_clear_flags(id, HUD_ELEMENT_FLAGS_DISABLED); hud_element_get_render_pos(id, &x, &y); hud_element_set_render_pos(id, x + 2, y + 46); - D_8029FB60[2] = 1; + CantLevelUpStat[MENU_BP] = TRUE; } - D_8029FAE8 = id = hud_element_create(&HES_ProjectorBeam); + id = LevelUpSpotlightHEID = hud_element_create(&HES_ProjectorBeam); hud_element_create_transform_B(id); hud_element_set_render_pos(id, 156, 13); hud_element_set_tint(id, 255, 255, 255); @@ -885,75 +915,76 @@ void btl_state_update_celebration(void) { hud_element_set_alpha(id, 200); hud_element_set_flags(id, HUD_ELEMENT_FLAGS_FILTER_TEX | HUD_ELEMENT_FLAGS_80); - D_8029FB48 = id = hud_element_create(&HES_level_up_select_one_to_upgrade); + id = LevelUpSelectTextHEID = hud_element_create(&HES_level_up_select_one_to_upgrade); hud_element_set_render_pos(id, 0, 0); hud_element_set_flags(id, HUD_ELEMENT_FLAGS_80); battleStatus->currentSubmenu = 1; - D_8029FB4C = 10; - gBattleSubState = BATTLE_SUB_STATE_UNK_7; + + CelebrateSubstateTime = 10; + gBattleSubState = BTL_SUBSTATE_CELEBRATE_LEVEL_UP_SHOW_HUD; } break; - case BATTLE_SUB_STATE_UNK_7: - id = D_8029FA80[0]; + case BTL_SUBSTATE_CELEBRATE_LEVEL_UP_SHOW_HUD: + id = LevelUpStatEmblemHEIDs[0]; hud_element_get_render_pos(id, &x, &y); x -= 20; hud_element_set_render_pos(id, x, y); - for (i = 0; i < ARRAY_COUNT(D_8029FA90[1]); i++) { - id = D_8029FA90[1][i]; + for (i = 0; i < ARRAY_COUNT(LevelUpStatTextHEIDs[LVL_UP_HP]); i++) { + id = LevelUpStatTextHEIDs[LVL_UP_HP][i]; hud_element_get_render_pos(id, &x, &y); x -= 20; hud_element_set_render_pos(id, x, y); } - id = D_8029FA80[1]; + id = LevelUpStatEmblemHEIDs[1]; hud_element_get_render_pos(id, &x, &y); y -= 20; hud_element_set_render_pos(id, x, y); - id = D_8029FA80[3]; + id = LevelUpStatEmblemHEIDs[3]; hud_element_get_render_pos(id, &x, &y); y -= 20; hud_element_set_render_pos(id, x, y); - for (i = 0; i < ARRAY_COUNT(D_8029FA90[0]); i++) { - id = D_8029FA90[0][i]; + for (i = 0; i < ARRAY_COUNT(LevelUpStatTextHEIDs[LVL_UP_FP]); i++) { + id = LevelUpStatTextHEIDs[LVL_UP_FP][i]; hud_element_get_render_pos(id, &x, &y); y -= 20; hud_element_set_render_pos(id, x, y); } - id = D_8029FA80[2]; + id = LevelUpStatEmblemHEIDs[2]; hud_element_get_render_pos(id, &x, &y); x += 20; hud_element_set_render_pos(id, x, y); - for (i = 0; i < ARRAY_COUNT(D_8029FA90[2]); i++) { - id = D_8029FA90[2][i]; + for (i = 0; i < ARRAY_COUNT(LevelUpStatTextHEIDs[LVL_UP_BP]); i++) { + id = LevelUpStatTextHEIDs[LVL_UP_BP][i]; hud_element_get_render_pos(id, &x, &y); x += 20; hud_element_set_render_pos(id, x, y); } - D_8029FB4C--; - if (D_8029FB4C == 0) { + CelebrateSubstateTime--; + if (CelebrateSubstateTime == 0) { hud_element_set_tint(id, 128, 128, 128); x = 20; y = 186; - set_window_properties(WINDOW_ID_8, 20, 186, 280, 32, 20, func_80260948, NULL, -1); + set_window_properties(WINDOW_ID_8, 20, 186, 280, 32, 20, draw_content_level_up_textbox, NULL, -1); set_window_update(WINDOW_ID_8, WINDOW_UPDATE_SHOW); - gBattleSubState = BATTLE_SUB_STATE_UNK_8; + gBattleSubState = BTL_SUBSTATE_CELEBRATE_LEVEL_UP_CHOOSE; } break; - case BATTLE_SUB_STATE_UNK_8: + case BTL_SUBSTATE_CELEBRATE_LEVEL_UP_CHOOSE: if (battleStatus->currentButtonsPressed & BUTTON_A) { - if (D_8029FB60[battleStatus->currentSubmenu] == 0) { + if (!CantLevelUpStat[battleStatus->currentSubmenu]) { sfx_play_sound(SOUND_MENU_NEXT); sfx_play_sound(SOUND_749); - gBattleSubState = BATTLE_SUB_STATE_UNK_9; + gBattleSubState = BTL_SUBSTATE_CELEBRATE_LEVEL_UP_UPGRADE; } else { sfx_play_sound(SOUND_MENU_ERROR); - gBattleSubState = BATTLE_SUB_STATE_UNK_F; + gBattleSubState = BTL_SUBSTATE_CELEBRATE_LEVEL_UP_INVALID; } break; } @@ -976,14 +1007,14 @@ void btl_state_update_celebration(void) { battleStatus->currentSubmenu = newSubmenu; } - D_8029FB84++; - if (D_8029FB84 > 100) { - fx_confetti(3, 0.0f, 100.0f, 0.0f, 1.0f, 0x78); - D_8029FB84 = 0; + CelebrateStateTime++; + if (CelebrateStateTime > 100) { + fx_confetti(3, 0.0f, 100.0f, 0.0f, 1.0f, 120); + CelebrateStateTime = 0; } break; - case BATTLE_SUB_STATE_UNK_9: - hud_element_free(D_8029FAE8); + case BTL_SUBSTATE_CELEBRATE_LEVEL_UP_UPGRADE: + hud_element_free(LevelUpSpotlightHEID); set_window_update(WINDOW_ID_8, WINDOW_UPDATE_HIDE); switch (battleStatus->currentSubmenu) { @@ -1019,118 +1050,118 @@ void btl_state_update_celebration(void) { break; } - set_animation(0, 0, 0x30009); + set_animation(0, 0, ANIM_Mario_30009); if (partner != NULL) { - script = start_script(partner->takeTurnScriptSource, EVT_PRIORITY_A, 0); + script = start_script(partner->takeTurnSource, EVT_PRIORITY_A, 0); partner->takeTurnScript = script; - partner->takeTurnID = script->id; + partner->takeTurnScriptID = script->id; script->owner1.actorID = ACTOR_PARTNER; } if (!(gBattleStatus.flags2 & BS_FLAGS2_2000000)) { bgm_set_song(0, -1, 0, 2000, 8); } - D_80284150 = 0; - gBattleSubState = BATTLE_SUB_STATE_PLAYER_DEFEATED; + bFadeToBlackAmt = 0; + gBattleSubState = BTL_SUBSTATE_CELEBRATE_LEVEL_UP_FADE_OUT; break; - case BATTLE_SUB_STATE_PLAYER_DEFEATED: + case BTL_SUBSTATE_CELEBRATE_LEVEL_UP_FADE_OUT: if ((gGameStatusPtr->frameCounter % 2) != 0) { switch (battleStatus->currentSubmenu) { case 0: - hud_element_set_flags(D_8029FA80[0], HUD_ELEMENT_FLAGS_DISABLED); + hud_element_set_flags(LevelUpStatEmblemHEIDs[0], HUD_ELEMENT_FLAGS_DISABLED); break; case 1: - hud_element_set_flags(D_8029FA80[1], HUD_ELEMENT_FLAGS_DISABLED); - hud_element_set_flags(D_8029FA80[3], HUD_ELEMENT_FLAGS_DISABLED); + hud_element_set_flags(LevelUpStatEmblemHEIDs[1], HUD_ELEMENT_FLAGS_DISABLED); + hud_element_set_flags(LevelUpStatEmblemHEIDs[3], HUD_ELEMENT_FLAGS_DISABLED); break; case 2: - hud_element_set_flags(D_8029FA80[2], HUD_ELEMENT_FLAGS_DISABLED); + hud_element_set_flags(LevelUpStatEmblemHEIDs[2], HUD_ELEMENT_FLAGS_DISABLED); break; } } else { switch (battleStatus->currentSubmenu) { case 0: - hud_element_clear_flags(D_8029FA80[0], HUD_ELEMENT_FLAGS_DISABLED); + hud_element_clear_flags(LevelUpStatEmblemHEIDs[0], HUD_ELEMENT_FLAGS_DISABLED); break; case 1: - hud_element_clear_flags(D_8029FA80[1], HUD_ELEMENT_FLAGS_DISABLED); - hud_element_clear_flags(D_8029FA80[3], HUD_ELEMENT_FLAGS_DISABLED); + hud_element_clear_flags(LevelUpStatEmblemHEIDs[1], HUD_ELEMENT_FLAGS_DISABLED); + hud_element_clear_flags(LevelUpStatEmblemHEIDs[3], HUD_ELEMENT_FLAGS_DISABLED); break; case 2: - hud_element_clear_flags(D_8029FA80[2], HUD_ELEMENT_FLAGS_DISABLED); + hud_element_clear_flags(LevelUpStatEmblemHEIDs[2], HUD_ELEMENT_FLAGS_DISABLED); break; } } - if (D_80284150 == 255) { - gBattleSubState = BATTLE_SUB_STATE_UNK_B; + if (bFadeToBlackAmt == 255) { + gBattleSubState = BTL_SUBSTATE_CELEBRATE_LEVEL_UP_DESTROY_HUD; break; } - D_80284150 += 10; - if (D_80284150 > 255) { - D_80284150 = 255; + bFadeToBlackAmt += 10; + if (bFadeToBlackAmt > 255) { + bFadeToBlackAmt = 255; } break; - case BATTLE_SUB_STATE_UNK_B: - hud_element_free(D_8029FA80[0]); - hud_element_free(D_8029FA80[1]); - hud_element_free(D_8029FA80[3]); - hud_element_free(D_8029FA80[2]); + case BTL_SUBSTATE_CELEBRATE_LEVEL_UP_DESTROY_HUD: + hud_element_free(LevelUpStatEmblemHEIDs[0]); + hud_element_free(LevelUpStatEmblemHEIDs[1]); + hud_element_free(LevelUpStatEmblemHEIDs[3]); + hud_element_free(LevelUpStatEmblemHEIDs[2]); - for (i = 0; i < ARRAY_COUNT(D_8029FA90); i++) { - for (j = 0; j < ARRAY_COUNT(D_8029FA90[0]); j++) { - hud_element_free(D_8029FA90[i][j]); + for (i = 0; i < ARRAY_COUNT(LevelUpStatTextHEIDs); i++) { + for (j = 0; j < ARRAY_COUNT(LevelUpStatTextHEIDs[LVL_UP_FP]); j++) { + hud_element_free(LevelUpStatTextHEIDs[i][j]); } } - hud_element_free(D_8029FB48); + hud_element_free(LevelUpSelectTextHEID); set_background_color_blend(0, 0, 0, 0); btl_set_state(BATTLE_STATE_END_BATTLE); - gBattleSubState = BATTLE_SUB_STATE_UNK_2; + gBattleSubState = BTL_SUBSTATE_END_BATTLE_UNK_2; break; - case BATTLE_SUB_STATE_UNK_F: - width = get_msg_width(0x1D00AB, 0) + 31; + case BTL_SUBSTATE_CELEBRATE_LEVEL_UP_INVALID: + width = get_msg_width(MSG_Menus_CantIncrease, 0) + 31; x = 160 - (width / 2); y = 80; - set_window_properties(WINDOW_ID_9, x, y, width, 28, 10, func_80260A20, NULL, -1); + set_window_properties(WINDOW_ID_9, x, y, width, 28, 10, draw_content_cant_increase_popup, NULL, -1); set_window_update(WINDOW_ID_9, WINDOW_UPDATE_SHOW); - D_8029FB4C = 60; - gBattleSubState = BATTLE_SUB_STATE_UNK_10; + CelebrateSubstateTime = 60; + gBattleSubState = BTL_SUBSTATE_CELEBRATE_LEVEL_UP_INVALID_DELAY; break; - case BATTLE_SUB_STATE_UNK_10: + case BTL_SUBSTATE_CELEBRATE_LEVEL_UP_INVALID_DELAY: if (gGameStatusPtr->pressedButtons[0] & (BUTTON_A | BUTTON_B)) { - D_8029FB4C = 0; + CelebrateSubstateTime = 0; } - if (D_8029FB4C != 0) { - D_8029FB4C--; + if (CelebrateSubstateTime != 0) { + CelebrateSubstateTime--; break; } set_window_update(WINDOW_ID_9, WINDOW_UPDATE_HIDE); - gBattleSubState = BATTLE_SUB_STATE_UNK_8; + gBattleSubState = BTL_SUBSTATE_CELEBRATE_LEVEL_UP_CHOOSE; break; - case BATTLE_SUB_STATE_UNK_14: + case BTL_SUBSTATE_CELEBRATE_SKIPPABLE_END_DELAY: if (battleStatus->currentButtonsPressed & (BUTTON_A | BUTTON_B)) { - D_8029FB84 = 99; + CelebrateStateTime = 99; } - if (D_8029FB84 >= 99) { - if (!(gBattleStatus.flags2 & 0x02000000)) { + if (CelebrateStateTime >= 99) { + if (!(gBattleStatus.flags2 & BS_FLAGS2_2000000)) { bgm_set_song(0, -1, 0, 1500, 8); } - D_80284150 = 0; + bFadeToBlackAmt = 0; btl_cam_set_params(1, 270, 100, 8, 0, 0x2400, 0, 100); - set_animation(0, 0, 0x30009); + set_animation(0, 0, ANIM_Mario_30009); if (partner != NULL) { set_animation(ACTOR_PARTNER, 0, D_80284154[playerData->currentPartner]); } - D_8029FB4C = 6; - gBattleSubState = BATTLE_SUB_STATE_UNK_15; + CelebrateSubstateTime = 6; + gBattleSubState = BTL_SUBSTATE_CELEBRATE_WALK_AWAY; break; } break; - case BATTLE_SUB_STATE_UNK_15: - if (D_8029FB4C != 0) { - D_8029FB4C--; - if (D_8029FB4C == 0) { - set_animation(0, 0, 0x10004); + case BTL_SUBSTATE_CELEBRATE_WALK_AWAY: + if (CelebrateSubstateTime != 0) { + CelebrateSubstateTime--; + if (CelebrateSubstateTime == 0) { + set_animation(0, 0, ANIM_Mario_Walking); } } else { player->yaw = 0.0f; @@ -1143,30 +1174,30 @@ void btl_state_update_celebration(void) { partner->currentPos.x += 4.0f; } } - if (D_80284150 == 255) { - gBattleSubState = BATTLE_SUB_STATE_UNK_16; + if (bFadeToBlackAmt == 255) { + gBattleSubState = BTL_SUBSTATE_CELEBRATE_DONE; break; } - D_80284150 += 20; - if (D_80284150 > 255) { - D_80284150 = 255; + bFadeToBlackAmt += 20; + if (bFadeToBlackAmt > 255) { + bFadeToBlackAmt = 255; } break; - case BATTLE_SUB_STATE_UNK_16: - if (does_script_exist(player->takeTurnID)) { - kill_script_by_ID(player->takeTurnID); + case BTL_SUBSTATE_CELEBRATE_DONE: + if (does_script_exist(player->takeTurnScriptID)) { + kill_script_by_ID(player->takeTurnScriptID); } - if (partner != NULL && does_script_exist(partner->takeTurnID)) { - kill_script_by_ID(partner->takeTurnID); + if (partner != NULL && does_script_exist(partner->takeTurnScriptID)) { + kill_script_by_ID(partner->takeTurnScriptID); } btl_set_state(BATTLE_STATE_END_BATTLE); - gBattleSubState = BATTLE_SUB_STATE_UNK_2; + gBattleSubState = BTL_SUBSTATE_END_BATTLE_UNK_2; break; } - D_8029FB84 += 1; + CelebrateStateTime++; } -void btl_draw_upgrade_windows(s32 arg0) { +void btl_draw_upgrade_windows(s32 phase) { BattleStatus* battleStatus = &gBattleStatus; s32 x; s32 y; @@ -1174,20 +1205,20 @@ void btl_draw_upgrade_windows(s32 arg0) { s32 d2; s32 d3; - switch (arg0) { - case 0: + switch (phase) { + case 0: // before choice d1 = 100; d2 = 100; d3 = 100; break; - case 1: + case 1: // choosing switch (battleStatus->currentSubmenu) { - case 0: + case MENU_HP: d1 = 0; d2 = 100; d3 = 100; break; - case 1: + case MENU_FP: d1 = 100; d2 = 0; d3 = 100; @@ -1199,20 +1230,20 @@ void btl_draw_upgrade_windows(s32 arg0) { break; } break; - default: + default: // after choice d1 = 100; d2 = 100; d3 = 100; break; } - hud_element_get_render_pos(D_8029FA80[0], &x, &y); + hud_element_get_render_pos(LevelUpStatEmblemHEIDs[0], &x, &y); draw_box(0, WINDOW_STYLE_15, x - 22, y - 22, 0, 44, 44, 255, d1, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, NULL, NULL, NULL, SCREEN_WIDTH, SCREEN_HEIGHT, NULL); - hud_element_get_render_pos(D_8029FA80[3], &x, &y); + hud_element_get_render_pos(LevelUpStatEmblemHEIDs[3], &x, &y); draw_box(0, WINDOW_STYLE_15, x - 22, y - 22, 0, 44, 44, 255, d2, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, NULL, NULL, NULL, SCREEN_WIDTH, SCREEN_HEIGHT, NULL); - hud_element_get_render_pos(D_8029FA80[2], &x, &y); + hud_element_get_render_pos(LevelUpStatEmblemHEIDs[2], &x, &y); draw_box(0, WINDOW_STYLE_15, x - 22, y - 22, 0, 44, 44, 255, d3, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, NULL, NULL, NULL, SCREEN_WIDTH, SCREEN_HEIGHT, NULL); } @@ -1225,97 +1256,97 @@ void btl_state_draw_celebration(void) { s32 j; switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_7: + case BTL_SUBSTATE_CELEBRATE_LEVEL_UP_SHOW_HUD: btl_draw_upgrade_windows(0); - id = D_8029FA80[0]; + id = LevelUpStatEmblemHEIDs[0]; hud_element_set_tint(id, 128, 128, 128); hud_element_draw_clipped(id); - id = D_8029FA80[3]; + id = LevelUpStatEmblemHEIDs[3]; hud_element_set_tint(id, 128, 128, 128); hud_element_draw_clipped(id); - id = D_8029FA80[1]; + id = LevelUpStatEmblemHEIDs[1]; hud_element_set_tint(id, 128, 128, 128); hud_element_draw_clipped(id); - id = D_8029FA80[2]; + id = LevelUpStatEmblemHEIDs[2]; hud_element_set_tint(id, 128, 128, 128); hud_element_draw_clipped(id); - for (j = 0; j < ARRAY_COUNT(D_8029FA90); j++) { - for (i = 0; i < ARRAY_COUNT(D_8029FA90[0]); i++) { - id = D_8029FA90[j][i]; + for (j = 0; j < ARRAY_COUNT(LevelUpStatTextHEIDs); j++) { + for (i = 0; i < ARRAY_COUNT(LevelUpStatTextHEIDs[LVL_UP_FP]); i++) { + id = LevelUpStatTextHEIDs[j][i]; hud_element_set_tint(id, 128, 128, 128); hud_element_draw_clipped(id); } } break; - case BATTLE_SUB_STATE_UNK_8: - case BATTLE_SUB_STATE_UNK_F: - case BATTLE_SUB_STATE_UNK_10: + case BTL_SUBSTATE_CELEBRATE_LEVEL_UP_CHOOSE: + case BTL_SUBSTATE_CELEBRATE_LEVEL_UP_INVALID: + case BTL_SUBSTATE_CELEBRATE_LEVEL_UP_INVALID_DELAY: switch (battleStatus->currentSubmenu) { case 0: rotZ = 152; - hud_element_set_tint(D_8029FA80[0], 255, 255, 255); - hud_element_set_tint(D_8029FA80[3], 128, 128, 128); - hud_element_set_tint(D_8029FA80[1], 128, 128, 128); - hud_element_set_tint(D_8029FA80[2], 128, 128, 128); + hud_element_set_tint(LevelUpStatEmblemHEIDs[0], 255, 255, 255); + hud_element_set_tint(LevelUpStatEmblemHEIDs[3], 128, 128, 128); + hud_element_set_tint(LevelUpStatEmblemHEIDs[1], 128, 128, 128); + hud_element_set_tint(LevelUpStatEmblemHEIDs[2], 128, 128, 128); - for (i = 0; i < ARRAY_COUNT(D_8029FA90[0]); i++) { - id = D_8029FA90[0][i]; + for (i = 0; i < ARRAY_COUNT(LevelUpStatTextHEIDs[LVL_UP_FP]); i++) { + id = LevelUpStatTextHEIDs[LVL_UP_FP][i]; hud_element_set_tint(id, 128, 128, 128); } - for (i = 0; i < ARRAY_COUNT(D_8029FA90[1]); i++) { - id = D_8029FA90[1][i]; + for (i = 0; i < ARRAY_COUNT(LevelUpStatTextHEIDs[LVL_UP_HP]); i++) { + id = LevelUpStatTextHEIDs[LVL_UP_HP][i]; hud_element_set_tint(id, 255, 255, 255); } - for (i = 0; i < ARRAY_COUNT(D_8029FA90[2]); i++) { - id = D_8029FA90[2][i]; + for (i = 0; i < ARRAY_COUNT(LevelUpStatTextHEIDs[LVL_UP_BP]); i++) { + id = LevelUpStatTextHEIDs[LVL_UP_BP][i]; hud_element_set_tint(id, 128, 128, 128); } - id = D_8029FA80[0]; + id = LevelUpStatEmblemHEIDs[0]; if (hud_element_get_script(id) != &HES_level_up_heart_copy) { hud_element_set_script(id, &HES_level_up_heart_copy); } - id = D_8029FA80[3]; + id = LevelUpStatEmblemHEIDs[3]; if (hud_element_get_script(id) != &HES_level_up_leaves) { hud_element_set_script(id, &HES_level_up_leaves); } - id = D_8029FA80[1]; + id = LevelUpStatEmblemHEIDs[1]; if (hud_element_get_script(id) != &HES_level_up_flower) { hud_element_set_script(id, &HES_level_up_flower); } - id = D_8029FA80[2]; + id = LevelUpStatEmblemHEIDs[2]; if (hud_element_get_script(id) != &HES_level_up_badge) { hud_element_set_script(id, &HES_level_up_badge); } break; case 1: rotZ = 180; - hud_element_set_tint(D_8029FA80[0], 128, 128, 128); - hud_element_set_tint(D_8029FA80[3], 255, 255, 255); - hud_element_set_tint(D_8029FA80[1], 255, 255, 255); - hud_element_set_tint(D_8029FA80[2], 128, 128, 128); + hud_element_set_tint(LevelUpStatEmblemHEIDs[0], 128, 128, 128); + hud_element_set_tint(LevelUpStatEmblemHEIDs[3], 255, 255, 255); + hud_element_set_tint(LevelUpStatEmblemHEIDs[1], 255, 255, 255); + hud_element_set_tint(LevelUpStatEmblemHEIDs[2], 128, 128, 128); - for (i = 0; i < ARRAY_COUNT(D_8029FA90[0]); i++) { - id = D_8029FA90[0][i]; + for (i = 0; i < ARRAY_COUNT(LevelUpStatTextHEIDs[LVL_UP_FP]); i++) { + id = LevelUpStatTextHEIDs[LVL_UP_FP][i]; hud_element_set_tint(id, 255, 255, 255); } - for (i = 0; i < ARRAY_COUNT(D_8029FA90[1]); i++) { - id = D_8029FA90[1][i]; + for (i = 0; i < ARRAY_COUNT(LevelUpStatTextHEIDs[LVL_UP_HP]); i++) { + id = LevelUpStatTextHEIDs[LVL_UP_HP][i]; hud_element_set_tint(id, 128, 128, 128); } - for (i = 0; i < ARRAY_COUNT(D_8029FA90[2]); i++) { - id = D_8029FA90[2][i]; + for (i = 0; i < ARRAY_COUNT(LevelUpStatTextHEIDs[LVL_UP_BP]); i++) { + id = LevelUpStatTextHEIDs[LVL_UP_BP][i]; hud_element_set_tint(id, 128, 128, 128); } @@ -1323,25 +1354,25 @@ void btl_state_draw_celebration(void) { case 2: default: rotZ = 208; - hud_element_set_tint(D_8029FA80[0], 128, 128, 128); - hud_element_set_tint(D_8029FA80[3], 128, 128, 128); - hud_element_set_tint(D_8029FA80[1], 128, 128, 128); - hud_element_set_tint(D_8029FA80[2], 255, 255, 255); + hud_element_set_tint(LevelUpStatEmblemHEIDs[0], 128, 128, 128); + hud_element_set_tint(LevelUpStatEmblemHEIDs[3], 128, 128, 128); + hud_element_set_tint(LevelUpStatEmblemHEIDs[1], 128, 128, 128); + hud_element_set_tint(LevelUpStatEmblemHEIDs[2], 255, 255, 255); - for (i = 0; i < ARRAY_COUNT(D_8029FA90[0]); i++) { - id = D_8029FA90[0][i]; + for (i = 0; i < ARRAY_COUNT(LevelUpStatTextHEIDs[LVL_UP_FP]); i++) { + id = LevelUpStatTextHEIDs[LVL_UP_FP][i]; hud_element_set_tint(id, 128, 128, 128); } - for (i = 0; i < ARRAY_COUNT(D_8029FA90[1]); i++) { - id = D_8029FA90[1][i]; + for (i = 0; i < ARRAY_COUNT(LevelUpStatTextHEIDs[LVL_UP_HP]); i++) { + id = LevelUpStatTextHEIDs[LVL_UP_HP][i]; hud_element_set_tint(id, 128, 128, 128); } - for (i = 0; i < ARRAY_COUNT(D_8029FA90[2]); i++) { - id = D_8029FA90[2][i]; + for (i = 0; i < ARRAY_COUNT(LevelUpStatTextHEIDs[LVL_UP_BP]); i++) { + id = LevelUpStatTextHEIDs[LVL_UP_BP][i]; hud_element_set_tint(id, 255, 255, 255); } @@ -1349,116 +1380,115 @@ void btl_state_draw_celebration(void) { } btl_draw_upgrade_windows(1); - hud_element_draw_clipped(D_8029FA80[0]); - hud_element_draw_clipped(D_8029FA80[3]); - hud_element_draw_clipped(D_8029FA80[1]); - hud_element_draw_clipped(D_8029FA80[2]); + hud_element_draw_clipped(LevelUpStatEmblemHEIDs[0]); + hud_element_draw_clipped(LevelUpStatEmblemHEIDs[3]); + hud_element_draw_clipped(LevelUpStatEmblemHEIDs[1]); + hud_element_draw_clipped(LevelUpStatEmblemHEIDs[2]); - for (j = 0; j < ARRAY_COUNT(D_8029FA90); j++) { - for (i = 0; i < ARRAY_COUNT(D_8029FA90[0]); i++) { - hud_element_draw_clipped(D_8029FA90[j][i]); + for (j = 0; j < ARRAY_COUNT(LevelUpStatTextHEIDs); j++) { + for (i = 0; i < ARRAY_COUNT(LevelUpStatTextHEIDs[LVL_UP_FP]); i++) { + hud_element_draw_clipped(LevelUpStatTextHEIDs[j][i]); } } func_80144218(-1); - id = D_8029FAE8; + id = LevelUpSpotlightHEID; hud_element_set_transform_rotation(id, 0.0f, 0.0f, rotZ); func_80144238(id); break; - case BATTLE_SUB_STATE_UNK_9: - case BATTLE_SUB_STATE_PLAYER_DEFEATED: + case BTL_SUBSTATE_CELEBRATE_LEVEL_UP_UPGRADE: + case BTL_SUBSTATE_CELEBRATE_LEVEL_UP_FADE_OUT: btl_draw_upgrade_windows(1); - hud_element_draw_clipped(D_8029FA80[0]); - hud_element_draw_clipped(D_8029FA80[3]); - hud_element_draw_clipped(D_8029FA80[1]); - hud_element_draw_clipped(D_8029FA80[2]); + hud_element_draw_clipped(LevelUpStatEmblemHEIDs[0]); + hud_element_draw_clipped(LevelUpStatEmblemHEIDs[3]); + hud_element_draw_clipped(LevelUpStatEmblemHEIDs[1]); + hud_element_draw_clipped(LevelUpStatEmblemHEIDs[2]); - for (j = 0; j < ARRAY_COUNT(D_8029FA90); j++) { - for (i = 0; i < ARRAY_COUNT(D_8029FA90[0]); i++) { - hud_element_draw_clipped(D_8029FA90[j][i]); + for (j = 0; j < ARRAY_COUNT(LevelUpStatTextHEIDs); j++) { + for (i = 0; i < ARRAY_COUNT(LevelUpStatTextHEIDs[LVL_UP_FP]); i++) { + hud_element_draw_clipped(LevelUpStatTextHEIDs[j][i]); } } - set_screen_overlay_params_front(0, D_80284150); + set_screen_overlay_params_front(0, bFadeToBlackAmt); break; - case BATTLE_SUB_STATE_UNK_B: - set_screen_overlay_params_front(0, D_80284150); + case BTL_SUBSTATE_CELEBRATE_LEVEL_UP_DESTROY_HUD: + set_screen_overlay_params_front(0, bFadeToBlackAmt); break; - case BATTLE_SUB_STATE_UNK_15: - if (D_80284150 != 0) { - set_screen_overlay_params_front(0, D_80284150); + case BTL_SUBSTATE_CELEBRATE_WALK_AWAY: + if (bFadeToBlackAmt != 0) { + set_screen_overlay_params_front(0, bFadeToBlackAmt); } break; } switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_7: - case BATTLE_SUB_STATE_UNK_8: - case BATTLE_SUB_STATE_UNK_9: - D_8029FB8C += 2; - D_8029FB88 += D_8029FB8C; - if (D_8029FB88 > 200) { - D_8029FB88 = 200; - D_8029FB8C = -D_8029FB8C / 3; + case BTL_SUBSTATE_CELEBRATE_LEVEL_UP_SHOW_HUD: + case BTL_SUBSTATE_CELEBRATE_LEVEL_UP_CHOOSE: + case BTL_SUBSTATE_CELEBRATE_LEVEL_UP_UPGRADE: + LevelUpSelectTextVelX += 2; + LevelUpSelectTextOffsetX += LevelUpSelectTextVelX; + if (LevelUpSelectTextOffsetX > 200) { + LevelUpSelectTextOffsetX = 200; + LevelUpSelectTextVelX = -LevelUpSelectTextVelX / 3; // rebounding } - id = D_8029FB48; - hud_element_set_render_pos(id, D_8029FB88 - 43, 176); + id = LevelUpSelectTextHEID; + hud_element_set_render_pos(id, LevelUpSelectTextOffsetX - 43, 176); hud_element_draw_clipped(id); break; - case BATTLE_SUB_STATE_PLAYER_DEFEATED: - D_8029FB8C += 4; - D_8029FB88 += D_8029FB8C; - if (D_8029FB88 > 500) { - D_8029FB88 = 500; + case BTL_SUBSTATE_CELEBRATE_LEVEL_UP_FADE_OUT: + LevelUpSelectTextVelX += 4; + LevelUpSelectTextOffsetX += LevelUpSelectTextVelX; + if (LevelUpSelectTextOffsetX > 500) { + LevelUpSelectTextOffsetX = 500; } - id = D_8029FB48; - hud_element_set_render_pos(id, D_8029FB88 - 43, 176); + id = LevelUpSelectTextHEID; + hud_element_set_render_pos(id, LevelUpSelectTextOffsetX - 43, 176); hud_element_draw_clipped(id); break; } } -void func_80260948(s32 arg0, s32 posX, s32 posY) { +void draw_content_level_up_textbox(void* data, s32 posX, s32 posY) { BattleStatus* battleStatus = &gBattleStatus; s32 xOffset; s32 msgID; switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_8: - case BATTLE_SUB_STATE_UNK_F: - case BATTLE_SUB_STATE_UNK_10: + case BTL_SUBSTATE_CELEBRATE_LEVEL_UP_CHOOSE: + case BTL_SUBSTATE_CELEBRATE_LEVEL_UP_INVALID: + case BTL_SUBSTATE_CELEBRATE_LEVEL_UP_INVALID_DELAY: switch (battleStatus->currentSubmenu) { - case 0: - if (D_8029FB60[0] == 0) { - msgID = 0x1D00A5; + case MENU_HP: + if (!CantLevelUpStat[MENU_HP]) { + msgID = MSG_Menus_LevelUp_HP; } else { - msgID = 0x1D00A8; + msgID = MSG_Menus_LevelUp_MaxedHP; } xOffset = 9; break; - case 1: - if (D_8029FB60[1] == 0) { - msgID = 0x1D00A6; + case MENU_FP: + if (!CantLevelUpStat[MENU_FP]) { + msgID = MSG_Menus_LevelUp_FP; } else { - msgID = 0x1D00A9; + msgID = MSG_Menus_LevelUp_MaxedFP; } xOffset = 9; break; default: - if (D_8029FB60[2] == 0) { - msgID = 0x1D00A7; + if (!CantLevelUpStat[MENU_BP]) { + msgID = MSG_Menus_LevelUp_BP; } else { - msgID = 0x1D00AA; + msgID = MSG_Menus_LevelUp_MaxedBP; } xOffset = 9; break; } - draw_msg(msgID, posX + xOffset + 0x11, posY, 255, MSG_PAL_STANDARD, 0); + draw_msg(msgID, posX + xOffset + 17, posY, 255, MSG_PAL_STANDARD, 0); break; } } -// TODO type is almost definitely incorrect -void func_80260A20(s64 posX, s32 posY) { - draw_msg(0x1D00AB, posX + 11, posY + 6, 255, MSG_PAL_0F, 0); +void draw_content_cant_increase_popup(void* data, s32 posX, s32 posY) { + draw_msg(MSG_Menus_CantIncrease, posX + 11, posY + 6, 255, MSG_PAL_0F, 0); } diff --git a/src/18F340.c b/src/18F340.c index d06a5869d0..2ff4e7b4c2 100644 --- a/src/18F340.c +++ b/src/18F340.c @@ -30,7 +30,7 @@ void func_80260A60(void) { BattleStatus* battleStatus = &gBattleStatus; ActorPart* actorPart = &battleStatus->playerActor->partsTable[0]; - if (battleStatus->flags2 & BS_FLAGS2_40) { + if (battleStatus->flags2 & BS_FLAGS2_PEACH_BATTLE) { actorPart->idleAnimations = bPeachIdleAnims; set_animation(0, 0, 0xA0002); } else if (!battleStatus->outtaSightActive) { @@ -154,7 +154,7 @@ ApiStatus func_80260DD8(Evt* script, s32 isInitialCall) { } ApiStatus func_80260E38(Evt* script, s32 isInitialCall) { - btl_show_battle_message(0x31, 60); + btl_show_battle_message(BTL_MSG_31, 60); return ApiStatus_DONE2; } @@ -267,20 +267,20 @@ ApiStatus RestorePreDefeatState(Evt* script, s32 isInitialCall) { BattleStatus* battleStatus = &gBattleStatus; battleStatus->rushFlags = RUSH_FLAG_NONE; - gBattleState = D_800DC4E4; - gBattleSubState = D_800DC4D8; + gBattleState = gDefeatedBattleState; + gBattleSubState = gDefeatedBattleSubstate; battleStatus->flags1 |= BS_FLAGS1_8; - battleStatus->flags2 &= ~BS_FLAGS2_8000000; + battleStatus->flags2 &= ~BS_FLAGS2_HAS_RUSH; - if (!(battleStatus->flags2 & BS_FLAGS2_40)) { + if (!(battleStatus->flags2 & BS_FLAGS2_PEACH_BATTLE)) { if (playerData->curHP <= 1 && is_ability_active(ABILITY_MEGA_RUSH)) { - gBattleStatus.flags2 |= BS_FLAGS2_8000000; + gBattleStatus.flags2 |= BS_FLAGS2_HAS_RUSH; battleStatus->rushFlags |= RUSH_FLAG_MEGA; } if (playerData->curHP <= 5 && is_ability_active(ABILITY_POWER_RUSH) && !(battleStatus->rushFlags & RUSH_FLAG_MEGA)) { - gBattleStatus.flags2 |= BS_FLAGS2_8000000; + gBattleStatus.flags2 |= BS_FLAGS2_HAS_RUSH; battleStatus->rushFlags |= RUSH_FLAG_POWER; } } diff --git a/src/190B20.c b/src/190B20.c index 238999c361..7bd6c149a1 100644 --- a/src/190B20.c +++ b/src/190B20.c @@ -225,13 +225,11 @@ s32 btl_are_all_enemies_defeated(void) { s32 i; for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) { - s32 flagEnemyDefeated = ENEMY_FLAGS_400000 | ENEMY_FLAGS_4000; enemy = battleStatus->enemyActors[i]; - - // If currentEnemyFlags signify that the enemy isn't dead yet... - if (enemy != NULL && !(enemy->flags & flagEnemyDefeated)) { - // Countinue the battle - enemiesStillAlive = TRUE; + if (enemy != NULL) { + if(!(enemy->flags & (ACTOR_FLAG_NO_DMG_APPLY | ACTOR_FLAG_TARGET_ONLY))) { + enemiesStillAlive = TRUE; + } } } return !enemiesStillAlive; @@ -249,8 +247,8 @@ s32 btl_check_player_defeated(void) { if (gPlayerData.curHP > 0) { return FALSE; } - D_800DC4E4 = gBattleState; - D_800DC4D8 = gBattleSubState; + gDefeatedBattleState = gBattleState; + gDefeatedBattleSubstate = gBattleSubState; btl_set_state(BATTLE_STATE_DEFEAT); return TRUE; } @@ -819,7 +817,7 @@ void load_player_actor(void) { player->actorBlueprint = &bPlayerActorBlueprint; player->actorType = bPlayerActorBlueprint.type; - if ((gBattleStatus.flags2 & BS_FLAGS2_40) || (gGameStatusPtr->demoFlags & 2)) { + if ((gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) || (gGameStatusPtr->demoFlags & 2)) { player->homePos.x = player->currentPos.x = -130.0f; player->homePos.y = player->currentPos.y = 0.0f; player->homePos.z = player->currentPos.z = -10.0f; @@ -861,14 +859,14 @@ void load_player_actor(void) { player->unk_195 = 0; player->unk_196 = 0; player->unk_197 = 0; - player->idleScriptSource = NULL; - player->takeTurnScriptSource = NULL; - player->onHitScriptSource = NULL; - player->onTurnChanceScriptSource = NULL; + player->idleSource = NULL; + player->takeTurnSource = NULL; + player->handleEventSource = NULL; + player->handlePhaseSource = NULL; player->idleScript = NULL; player->takeTurnScript = NULL; - player->onHitScript = NULL; - player->onTurnChangeScript = NULL; + player->handleEventScript = NULL; + player->handlePhaseScript = NULL; player->turnPriority = 0; player->statusTable = bPlayerStatusTable; player->debuff = 0; @@ -932,7 +930,7 @@ void load_player_actor(void) { part->absolutePosition.z = 0.0f; part->defenseTable = bMarioDefenseTable; - if (gBattleStatus.flags2 & BS_FLAGS2_40) { + if (gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) { part->idleAnimations = bPeachIdleAnims; } else { part->idleAnimations = bMarioIdleAnims; @@ -1040,7 +1038,7 @@ void load_partner_actor(void) { ASSERT(ActorBlueprint != NULL); nuPiReadRom(partnerData->dmaStart, partnerData->dmaDest, partnerData->dmaEnd - partnerData->dmaStart); - if ((gBattleStatus.flags2 & BS_FLAGS2_40) || (gGameStatusPtr->demoFlags & 2)) { + if ((gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) || (gGameStatusPtr->demoFlags & 2)) { x = -95.0f; y = partnerData->y; z = 0.0f; @@ -1070,14 +1068,14 @@ void load_partner_actor(void) { partnerActor->headOffset.z = 0; partnerActor->currentHP = ActorBlueprint->maxHP; partnerActor->numParts = partCount; - partnerActor->idleScriptSource = NULL; - partnerActor->takeTurnScriptSource = ActorBlueprint->script; - partnerActor->onHitScriptSource = NULL; - partnerActor->onTurnChanceScriptSource = NULL; + partnerActor->idleSource = NULL; + partnerActor->takeTurnSource = ActorBlueprint->takeTurnScript; + partnerActor->handleEventSource = NULL; + partnerActor->handlePhaseSource = NULL; partnerActor->idleScript = NULL; partnerActor->takeTurnScript = NULL; - partnerActor->onHitScript = NULL; - partnerActor->onTurnChangeScript = NULL; + partnerActor->handleEventScript = NULL; + partnerActor->handlePhaseScript = NULL; partnerActor->turnPriority = 0; partnerActor->enemyIndex = 0; partnerActor->yaw = 0.0f; @@ -1262,8 +1260,8 @@ void load_partner_actor(void) { partnerActor->disableEffect = fx_disable_x(0, -142.0f, 34.0f, 1.0f, 0); partnerActor->icePillarEffect = NULL; - takeTurnScript = start_script(partnerActor->takeTurnScriptSource, EVT_PRIORITY_A, 0); - partnerActor->takeTurnID = takeTurnScript->id; + takeTurnScript = start_script(partnerActor->takeTurnSource, EVT_PRIORITY_A, 0); + partnerActor->takeTurnScriptID = takeTurnScript->id; takeTurnScript->owner1.actorID = ACTOR_PARTNER; } } @@ -1316,13 +1314,13 @@ Actor* create_actor(Formation formation) { actor->headOffset.z = 0; actor->maxHP = actor->currentHP = formationActor->maxHP; actor->numParts = partCount; - actor->idleScriptSource = NULL; - actor->takeTurnScriptSource = formationActor->script; - actor->onHitScriptSource = NULL; - actor->onTurnChanceScriptSource = NULL; + actor->idleSource = NULL; + actor->takeTurnSource = formationActor->takeTurnScript; + actor->handleEventSource = NULL; + actor->handlePhaseSource = NULL; actor->idleScript = NULL; actor->takeTurnScript = NULL; - actor->onHitScript = NULL; + actor->handleEventScript = NULL; actor->turnPriority = formation->priority; actor->enemyIndex = i; actor->yaw = 0.0f; @@ -1525,8 +1523,8 @@ Actor* create_actor(Formation formation) { actor->hpFraction = 25; actor->actorID = actor->enemyIndex | 0x200; - takeTurnScript = start_script(actor->takeTurnScriptSource, EVT_PRIORITY_A, 0); - actor->takeTurnID = takeTurnScript->id; + takeTurnScript = start_script(actor->takeTurnSource, EVT_PRIORITY_A, 0); + actor->takeTurnScriptID = takeTurnScript->id; takeTurnScript->owner1.enemyID = actor->enemyIndex | 0x200; actor->shadow.id = create_shadow_type(0, actor->currentPos.x, actor->currentPos.y, actor->currentPos.z); actor->shadowScale = actor->size.x / 24.0; @@ -1570,7 +1568,7 @@ s32 func_80265D44(s32 animID) { ret = 0; // TODO use animation id enum once it exists - if (!(battleStatus->flags2 & BS_FLAGS2_40)) { + if (!(battleStatus->flags2 & BS_FLAGS2_PEACH_BATTLE)) { if (playerData->curHP < 6) { if (animID == 1) { animID = 26; @@ -1695,7 +1693,7 @@ s32 inflict_status(Actor* target, s32 statusTypeKey, s32 duration) { if (target->debuff != statusTypeKey) { target->status = statusTypeKey; } - target->disableEffect->data.disableX->unk_3C = 0; + target->disableEffect->data.disableX->koDuration = 0; target->debuff = statusTypeKey; target->debuffDuration = duration; if ((s8)duration > 9) { @@ -2160,7 +2158,7 @@ void func_80266B14(void) { if (enemy->unk_206 > 0) { enemy->unk_206--; if (enemy->unk_206 == 0) { - enemy->flags &= ~ENEMY_FLAGS_80000; + enemy->flags &= ~ACTOR_FLAG_80000; } } } @@ -2434,7 +2432,7 @@ s32 player_team_is_ability_active(Actor* actor, s32 ability) { switch (actorClass) { case ACTOR_CLASS_PLAYER: - if (!(gBattleStatus.flags2 & BS_FLAGS2_40)) { + if (!(gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE)) { hasAbility = is_ability_active(ability); } break; @@ -2475,34 +2473,34 @@ void remove_player_buffs(s32 buffs) { Actor* partner = battleStatus->partnerActor; ActorPart* playerPartsTable = player->partsTable; - if (buffs & 1) { + if (buffs & PLAYER_BUFF_JUMP_CHARGE) { battleStatus->jumpCharge = 0; - battleStatus->flags1 &= ~BS_FLAGS1_20000000; + battleStatus->flags1 &= ~BS_FLAGS1_JUMP_CHARGED; } - if (buffs & 2) { + if (buffs & PLAYER_BUFF_HAMMER_CHARGE) { battleStatus->hammerCharge = 0; - battleStatus->flags1 &= ~BS_FLAGS1_10000000; + battleStatus->flags1 &= ~BS_FLAGS1_HAMMER_CHARGED; } - if (buffs & 8) { + if (buffs & PLAYER_BUFF_STONE) { player->stoneDuration = 0; player->stoneStatus = 0; } - if (buffs & 0x10) { + if (buffs & PLAYER_BUFF_HUSTLE) { battleStatus->hustleTurns = 0; - battleStatus->flags1 &= ~BS_FLAGS1_HUSTLE_DRINK_ON; + battleStatus->flags1 &= ~BS_FLAGS1_HUSTLED; } - if (buffs & 0x20 && (player->staticStatus != 0)) { + if (buffs & PLAYER_BUFF_STATIC && (player->staticStatus != 0)) { player->staticDuration = 0; player->staticStatus = 0; remove_status_static(player->hudElementDataIndex); } - if (buffs & 0x40 && (player->transparentStatus != 0)) { + if (buffs & PLAYER_BUFF_TRANSPARENT && (player->transparentStatus != 0)) { player->transparentDuration = 0; player->transparentStatus = 0; playerPartsTable->flags &= ~0x100; remove_status_transparent(player->hudElementDataIndex); } - if (buffs & 0x200 && (battleStatus->waterBlockTurnsLeft != 0)) { + if (buffs & PLAYER_BUFF_WATER_BLOCK && (battleStatus->waterBlockTurnsLeft != 0)) { battleStatus->waterBlockTurnsLeft = 0; battleStatus->buffEffect->data.partnerBuff->unk_0C[FX_BUFF_DATA_WATER_BLOCK].turnsLeft = 0; battleStatus->waterBlockEffect->flags |= 0x10; @@ -2515,18 +2513,18 @@ void remove_player_buffs(s32 buffs) { battleStatus->waterBlockEffect = NULL; sfx_play_sound(SOUND_299); } - if (buffs & 0x100 && (battleStatus->turboChargeTurnsLeft != 0)) { + if (buffs & PLAYER_BUFF_TURBO_CHARGE && (battleStatus->turboChargeTurnsLeft != 0)) { battleStatus->turboChargeTurnsLeft = 0; battleStatus->buffEffect->data.partnerBuff->unk_0C[FX_BUFF_DATA_TURBO_CHARGE].turnsLeft = 0; } - if (buffs & 0x80 && (battleStatus->cloudNineTurnsLeft != 0)) { + if (buffs & PLAYER_BUFF_CLOUD_NINE && (battleStatus->cloudNineTurnsLeft != 0)) { battleStatus->cloudNineTurnsLeft = 0; battleStatus->buffEffect->data.partnerBuff->unk_0C[FX_BUFF_DATA_CLOUD_NINE].turnsLeft = 0; remove_effect(battleStatus->cloudNineEffect); battleStatus->cloudNineEffect = NULL; } - if (partner != NULL && (buffs & 0x10000)) { + if (partner != NULL && (buffs & PLAYER_BUFF_PARTNER_GLOWING)) { partner->isGlowing = FALSE; gBattleStatus.flags1 &= ~BS_FLAGS1_40000000; } @@ -2542,7 +2540,7 @@ void btl_update_ko_status(void) { player->koDuration = player->debuffDuration; if (player->koDuration > 0) { player->koStatus = STATUS_DAZE; - player->disableEffect->data.disableX->unk_3C = player->koDuration; + player->disableEffect->data.disableX->koDuration = player->koDuration; if (koDuration == 0) { sfx_play_sound(SOUND_2107); @@ -2557,7 +2555,7 @@ void btl_update_ko_status(void) { if (partner->koDuration > 0) { partner->koStatus = STATUS_DAZE; - partner->disableEffect->data.disableX->unk_3C = partner->koDuration; + partner->disableEffect->data.disableX->koDuration = partner->koDuration; } } @@ -2568,7 +2566,7 @@ void btl_update_ko_status(void) { enemy->koDuration = enemy->debuffDuration; if (enemy->koDuration > 0) { enemy->koStatus = STATUS_DAZE; - enemy->disableEffect->data.disableX->unk_3C = enemy->koDuration; + enemy->disableEffect->data.disableX->koDuration = enemy->koDuration; } } } diff --git a/src/19FAF0.c b/src/19FAF0.c index 5f245bc3e8..e2a6fa20de 100644 --- a/src/19FAF0.c +++ b/src/19FAF0.c @@ -136,16 +136,16 @@ void dispatch_event_player(s32 eventType) { player->lastEventType = eventType; - oldOnHitScript = player->onHitScript; - oldOnHitID = player->onHitID; + oldOnHitScript = player->handleEventScript; + oldOnHitID = player->handleEventScriptID; eventScript = start_script(&HandleEvent_Player, EVT_PRIORITY_A, EVT_FLAG_RUN_IMMEDIATELY); - player->onHitScript = eventScript; - player->onHitID = eventScript->id; + player->handleEventScript = eventScript; + player->handleEventScriptID = eventScript->id; eventScript->owner1.actor = NULL; if (player->takeTurnScript != NULL) { - kill_script_by_ID(player->takeTurnID); + kill_script_by_ID(player->takeTurnScriptID); player->takeTurnScript = NULL; } @@ -162,12 +162,12 @@ void dispatch_event_player_continue_turn(s32 eventType) { player->lastEventType = eventType; - oldOnHitScript = player->onHitScript; - oldOnHitID = player->onHitID; + oldOnHitScript = player->handleEventScript; + oldOnHitID = player->handleEventScriptID; eventScript = start_script(&HandleEvent_Player, EVT_PRIORITY_A, EVT_FLAG_RUN_IMMEDIATELY); - player->onHitScript = eventScript; - player->onHitID = eventScript->id; + player->handleEventScript = eventScript; + player->handleEventScriptID = eventScript->id; eventScript->owner1.actor = NULL; if (oldOnHitScript != NULL) { @@ -423,12 +423,12 @@ s32 calc_player_damage_enemy(void) { if (battleStatus->jumpCharge && battleStatus->currentAttackElement & DAMAGE_TYPE_JUMP) { currentAttackDamage += battleStatus->jumpCharge; - gBattleStatus.flags1 &= ~BS_FLAGS1_20000000; + gBattleStatus.flags1 &= ~BS_FLAGS1_JUMP_CHARGED; } if (battleStatus->hammerCharge && battleStatus->currentAttackElement & (DAMAGE_TYPE_QUAKE_HAMMER | DAMAGE_TYPE_THROW | DAMAGE_TYPE_SMASH)) { currentAttackDamage += battleStatus->hammerCharge; - gBattleStatus.flags1 &= ~BS_FLAGS1_10000000; + gBattleStatus.flags1 &= ~BS_FLAGS1_HAMMER_CHARGED; } if (battleStatus->unk_98 != 0) { @@ -483,7 +483,7 @@ s32 calc_player_damage_enemy(void) { } } - if (gBattleStatus.flags2 & BS_FLAGS2_8000000 && (gBattleStatus.flags1 & BS_FLAGS1_10 || + if (gBattleStatus.flags2 & BS_FLAGS2_HAS_RUSH && (gBattleStatus.flags1 & BS_FLAGS1_10 || battleStatus->currentAttackElement & DAMAGE_TYPE_JUMP)) { if (battleStatus->rushFlags & RUSH_FLAG_POWER) { currentAttackDamage += 2; diff --git a/src/1A5830.c b/src/1A5830.c index 30fd345737..6e537d80cf 100644 --- a/src/1A5830.c +++ b/src/1A5830.c @@ -103,26 +103,26 @@ void play_hit_sound(Actor* actor, f32 x, f32 y, f32 z, u32 hitSound) { } void dispatch_event_actor(Actor* actor, s32 event) { - Evt* onHitScript = actor->onHitScript; - s32 onHitID = actor->onHitID; + Evt* handleEventScript = actor->handleEventScript; + s32 onHitID = actor->handleEventScriptID; - if (actor->onHitScriptSource != NULL) { + if (actor->handleEventSource != NULL) { Evt* newScript; actor->lastEventType = event; - newScript = start_script(actor->onHitScriptSource, EVT_PRIORITY_A, EVT_FLAG_RUN_IMMEDIATELY); - actor->onHitScript = newScript; - actor->onHitID = newScript->id; + newScript = start_script(actor->handleEventSource, EVT_PRIORITY_A, EVT_FLAG_RUN_IMMEDIATELY); + actor->handleEventScript = newScript; + actor->handleEventScriptID = newScript->id; newScript->owner1.actorID = actor->actorID; } if (actor->takeTurnScript != NULL) { - get_script_by_index(actor->takeTurnID); - kill_script_by_ID(actor->takeTurnID); + get_script_by_index(actor->takeTurnScriptID); + kill_script_by_ID(actor->takeTurnScriptID); actor->takeTurnScript = NULL; } - if (onHitScript != NULL) { + if (handleEventScript != NULL) { kill_script_by_ID(onHitID); } } @@ -885,7 +885,7 @@ ApiStatus BindTakeTurn(Evt* script, s32 isInitialCall) { } takeTurnScript = (EvtScript*) evt_get_variable(script, *args++); - get_actor(actorID)->takeTurnScriptSource = takeTurnScript; + get_actor(actorID)->takeTurnSource = takeTurnScript; return ApiStatus_DONE2; } @@ -898,7 +898,7 @@ ApiStatus PauseTakeTurn(Evt* script, s32 isInitialCall) { } evt_get_variable(script, *args++); - suspend_all_script(get_actor(actorID)->takeTurnID); + suspend_all_script(get_actor(actorID)->takeTurnScriptID); return ApiStatus_DONE2; } @@ -911,7 +911,7 @@ ApiStatus ResumeTakeTurn(Evt* script, s32 isInitialCall) { } evt_get_variable(script, *args++); - resume_all_script(get_actor(actorID)->takeTurnID); + resume_all_script(get_actor(actorID)->takeTurnScriptID); return ApiStatus_DONE2; } @@ -934,7 +934,7 @@ ApiStatus BindIdle(Evt* script, s32 isInitialCall) { actor->idleScript = 0; } - actor->idleScriptSource = idleCode; + actor->idleSource = idleCode; newScriptContext = start_script(idleCode, EVT_PRIORITY_A, 0); actor->idleScript = newScriptContext; actor->idleScriptID = newScriptContext->id; @@ -976,28 +976,28 @@ ApiStatus EnableIdleScript(Evt* script, s32 isInitialCall) { ApiStatus BindHandleEvent(Evt* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; s32 actorID = evt_get_variable(script, *args++); - EvtScript* var1; + EvtScript* src; if (actorID == ACTOR_SELF) { actorID = script->owner1.actorID; } - var1 = (EvtScript*) evt_get_variable(script, *args++); - get_actor(actorID)->onHitScriptSource = var1; + src = (EvtScript*) evt_get_variable(script, *args++); + get_actor(actorID)->handleEventSource = src; return ApiStatus_DONE2; } ApiStatus BindNextTurn(Evt* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; s32 actorID = evt_get_variable(script, *args++); - EvtScript* var1; + EvtScript* src; if (actorID == ACTOR_SELF) { actorID = script->owner1.actorID; } - var1 = (EvtScript*) evt_get_variable(script, *args++); - get_actor(actorID)->onTurnChanceScriptSource = var1; + src = (EvtScript*) evt_get_variable(script, *args++); + get_actor(actorID)->handlePhaseSource = src; return ApiStatus_DONE2; } @@ -3362,7 +3362,7 @@ ApiStatus ClearStatusEffects(Evt* script, s32 isInitialCall) { actor->koStatus = 0; actor->koDuration = 0; - actor->disableEffect->data.disableX->unk_3C = 0; + actor->disableEffect->data.disableX->koDuration = 0; actor->attackBoost = 0; actor->defenseBoost = 0; actor->isGlowing = 0; diff --git a/src/1AC760.c b/src/1AC760.c index 884076e325..33f8d2043d 100644 --- a/src/1AC760.c +++ b/src/1AC760.c @@ -9,22 +9,22 @@ s32 dispatch_damage_event_partner_1(s32, s32); void dispatch_event_partner(s32 lastEventType) { BattleStatus* battleStatus = &gBattleStatus; Actor* partnerActor = battleStatus->partnerActor; - Evt* onHitScript = partnerActor->onHitScript; - s32 onHitID = partnerActor->onHitID; + Evt* handleEventScript = partnerActor->handleEventScript; + s32 onHitID = partnerActor->handleEventScriptID; Evt* script; partnerActor->lastEventType = lastEventType; - script = start_script(partnerActor->onHitScriptSource, EVT_PRIORITY_A, EVT_FLAG_RUN_IMMEDIATELY); - partnerActor->onHitScript = script; - partnerActor->onHitID = script->id; + script = start_script(partnerActor->handleEventSource, EVT_PRIORITY_A, EVT_FLAG_RUN_IMMEDIATELY); + partnerActor->handleEventScript = script; + partnerActor->handleEventScriptID = script->id; script->owner1.actorID = ACTOR_PARTNER; if (partnerActor->takeTurnScript != NULL) { - kill_script_by_ID(partnerActor->takeTurnID); + kill_script_by_ID(partnerActor->takeTurnScriptID); partnerActor->takeTurnScript = NULL; } - if (onHitScript != NULL) { + if (handleEventScript != NULL) { kill_script_by_ID(onHitID); } } @@ -32,17 +32,17 @@ void dispatch_event_partner(s32 lastEventType) { void dispatch_event_partner_continue_turn(s8 lastEventType) { BattleStatus* battleStatus = &gBattleStatus; Actor* partnerActor = battleStatus->partnerActor; - Evt* onHitScript = partnerActor->onHitScript; - s32 onHitID = partnerActor->onHitID; + Evt* handleEventScript = partnerActor->handleEventScript; + s32 onHitID = partnerActor->handleEventScriptID; Evt* script; partnerActor->lastEventType = lastEventType; - script = start_script(partnerActor->onHitScriptSource, EVT_PRIORITY_A, EVT_FLAG_RUN_IMMEDIATELY); - partnerActor->onHitScript = script; - partnerActor->onHitID = script->id; + script = start_script(partnerActor->handleEventSource, EVT_PRIORITY_A, EVT_FLAG_RUN_IMMEDIATELY); + partnerActor->handleEventScript = script; + partnerActor->handleEventScriptID = script->id; script->owner1.actorID = ACTOR_PARTNER; - if (onHitScript != NULL) { + if (handleEventScript != NULL) { kill_script_by_ID(onHitID); } } diff --git a/src/415D90.c b/src/415D90.c index 2586c1ab22..27cae279f7 100644 --- a/src/415D90.c +++ b/src/415D90.c @@ -820,7 +820,7 @@ void btl_draw_menu_wheel(void) { draw_msg(battle_menu_messageIDs[D_802AD002 + D_802AD06B], l, t, opacity, MSG_PAL_35, 0); } - if ((gBattleStatus.flags1 & BS_FLAGS1_2000000) || (gBattleStatus.flags2 & BS_FLAGS2_40)) { + if ((gBattleStatus.flags1 & BS_FLAGS1_2000000) || (gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE)) { D_802AD104 = 0; } @@ -1343,18 +1343,18 @@ s32 func_802A2C84(void) { } set_window_update(8, 2); - msgID = 0x1D00C3; + msgID = MSG_Menus_00C3; if (D_802AD258 == 0) { if (!battle_menu_hasSpiritsMenu) { - msgID = 0x1D009F; + msgID = MSG_Menus_NotEnoughFP; } else { - msgID = 0x1D00A0; + msgID = MSG_Menus_NotEnoughStarPower; } } msgWidth = get_msg_width(msgID, 0) + 23; moveX = (SCREEN_WIDTH / 2) - (msgWidth / 2); - set_window_properties(9, moveX, 80, msgWidth, D_802AB340[get_msg_lines(msgID) - 1], 0x14, func_802A4534, NULL, -1); + set_window_properties(9, moveX, 80, msgWidth, D_802AB340[get_msg_lines(msgID) - 1], 20, func_802A4534, NULL, -1); set_window_update(9, 1); D_802AD10B = 60; battle_menu_moveState = 42; @@ -1367,16 +1367,16 @@ s32 func_802A2C84(void) { D_802AD10B--; return -1; } - set_window_update(9, 2); + set_window_update(WINDOW_ID_9, 2); set_window_update(1, 1); if (!battle_menu_hasSpiritsMenu) { - set_window_update(2, 1); - set_window_update(3, 1); + set_window_update(WINDOW_ID_2, 1); + set_window_update(WINDOW_ID_3, 1); } else { - set_window_update(4, 1); - set_window_update(5, 1); + set_window_update(WINDOW_ID_4, 1); + set_window_update(WINDOW_ID_5, 1); } - set_window_update(8, 1); + set_window_update(WINDOW_ID_8, 1); battle_menu_moveState = 1; break; } @@ -2165,7 +2165,7 @@ void btl_state_update_player_menu(void) { PartnerPopupProperties* prop; switch (gBattleSubState) { - case BATTLE_SUB_STATE_PLAYER_NONE: + case BTL_SUBSTATE_PLAYER_MENU_NONE: battleStatus->moveCategory = -1; battleStatus->selectedMoveID = 0; battleStatus->currentAttackElement = 0; @@ -2176,9 +2176,9 @@ void btl_state_update_player_menu(void) { btl_cam_use_preset(BTL_CAM_PRESET_C); btl_cam_move(10); if (!(battleStatus->flags1 & BS_FLAGS1_100000)) { - gBattleSubState = BATTLE_SUB_STATE_PLAYER_INIT_MENU; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_INIT_MENU; } else { - gBattleSubState = BATTLE_SUB_STATE_PLAYER_INIT_12C; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_INIT_12C; partnerActor->state.currentPos.x = partnerActor->homePos.x; partnerActor->state.currentPos.z = partnerActor->homePos.z; partnerActor->state.goalPos.x = playerActor->homePos.x; @@ -2187,7 +2187,7 @@ void btl_state_update_player_menu(void) { partnerActor->state.angle = 0.0f; } break; - case BATTLE_SUB_STATE_PLAYER_INIT_12C: + case BTL_SUBSTATE_PLAYER_MENU_INIT_12C: if (partnerActor->state.moveTime != 0) { partnerActor->currentPos.x += (partnerActor->state.goalPos.x - partnerActor->currentPos.x) / partnerActor->state.moveTime; partnerActor->currentPos.z += (partnerActor->state.goalPos.z - partnerActor->currentPos.z) / partnerActor->state.moveTime; @@ -2210,14 +2210,14 @@ void btl_state_update_player_menu(void) { partnerActor->homePos.z = partnerActor->currentPos.z; playerActor->homePos.x = playerActor->currentPos.x; playerActor->homePos.z = playerActor->currentPos.z; - gBattleSubState = BATTLE_SUB_STATE_PLAYER_INIT_MENU; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_INIT_MENU; battleStatus->flags1 &= ~BS_FLAGS1_100000; } break; } switch (gBattleSubState) { - case BATTLE_SUB_STATE_PLAYER_INIT_MENU: + case BTL_SUBSTATE_PLAYER_MENU_INIT_MENU: gBattleStatus.flags1 |= BS_FLAGS1_2; playerActor->flags &= ~ACTOR_FLAG_4000000; playerActor->flags |= ACTOR_FLAG_8000000; @@ -2230,7 +2230,7 @@ void btl_state_update_player_menu(void) { btl_init_menu_boots(); btl_init_menu_hammer(); if (player_team_is_ability_active(playerActor, ABILITY_BERSERKER)) { - gBattleSubState = BATTLE_SUB_STATE_PLAYER_BERSERKER_1; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_BERSERKER_1; break; } entryIdx = 0; @@ -2370,9 +2370,9 @@ void btl_state_update_player_menu(void) { func_802A1000(); D_802ACC60 = 8; D_802ACC6C = 0; - gBattleSubState = BATTLE_SUB_STATE_PLAYER_MAIN_MENU_1; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_1; break; - case BATTLE_SUB_STATE_PLAYER_MAIN_MENU_1: + case BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_1: if (battleStatus->hustleTurns != 0) { set_animation(ACTOR_PLAYER, 0, ANIM_Mario_RunThinking); } else { @@ -2389,7 +2389,7 @@ void btl_state_update_player_menu(void) { btl_set_state(BATTLE_STATE_SWITCH_TO_PARTNER); } else if (partnerActor != NULL && !(partnerActor->flags & BS_FLAGS1_200000) && battleStatus->hustleTurns != 1) { sfx_play_sound(SOUND_MENU_ERROR); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_MAIN_MENU_8; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_8; } break; } @@ -2541,13 +2541,13 @@ void btl_state_update_player_menu(void) { currentSubmenu = battleStatus->currentSubmenu; if (currentSubmenu == 8) { - gBattleSubState = BATTLE_SUB_STATE_PLAYER_STAR_SPIRITS_1; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_1; btl_state_update_player_menu(); btl_state_update_player_menu(); break; } else if (currentSubmenu == 7) { if (battleStatus->actionCommandMode != ACTION_COMMAND_MODE_TUTORIAL && !(gBattleStatus.flags1 & BS_FLAGS1_2000000)) { - gBattleSubState = BATTLE_SUB_STATE_PLAYER_STRATEGIES_1; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_BUILD_STRATEGIES; btl_state_update_player_menu(); btl_state_update_player_menu(); break; @@ -2562,10 +2562,10 @@ void btl_state_update_player_menu(void) { } else { if (battleStatus->submenuMoveCount == 0) { if (currentSubmenu != 2) { - gBattleSubState = BATTLE_SUB_STATE_PLAYER_MAIN_MENU_10; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_10; break; } else { - gBattleSubState = BATTLE_SUB_STATE_PLAYER_ITEMS_1; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_ITEMS_1; btl_state_update_player_menu(); btl_state_update_player_menu(); break; @@ -2643,21 +2643,21 @@ void btl_state_update_player_menu(void) { D_802AD4A8 = initialPos; battle_menu_moveOptionCount = battleStatus->submenuMoveCount; func_802A2684(); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_MAIN_MENU_2; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_2; break; } } break; - case BATTLE_SUB_STATE_PLAYER_MAIN_MENU_2: + case BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_2: submenuResult = func_802A2C84(); if (submenuResult == -1) { - gBattleSubState = BATTLE_SUB_STATE_PLAYER_MAIN_MENU_7; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_7; } else if (submenuResult == 0) { } else if (submenuResult == 255) { func_802A1050(); D_802ACC60 = 8; D_802ACC6C = 4; - gBattleSubState = BATTLE_SUB_STATE_PLAYER_MAIN_MENU_1; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_1; btl_state_update_player_menu(); btl_state_update_player_menu(); } else { @@ -2673,7 +2673,7 @@ void btl_state_update_player_menu(void) { if (battleStatus->currentSubmenu == 2) { battleStatus->unk_4C[3] = battle_menu_moveOptionActive; if (battleStatus->currentSubmenu == currentSubmenu2) { - gBattleSubState = BATTLE_SUB_STATE_PLAYER_UNKNOWN_1; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_UNKNOWN_1; btl_state_update_player_menu(); btl_state_update_player_menu(); break; @@ -2681,22 +2681,22 @@ void btl_state_update_player_menu(void) { } func_802A27D0(); func_802A1030(); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_MAIN_MENU_3; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_3; } break; - case BATTLE_SUB_STATE_PLAYER_MAIN_MENU_3: + case BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_3: submenuResult = func_802A2C84(); if ((battleStatus->currentButtonsPressed & BUTTON_B) && submenuResult == 0) { func_802A2AB8(); func_802A1098(); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_MAIN_MENU_4; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_4; break; } if (func_802A11B0() == 0) { break; } - battleStatus->unk_6C = BATTLE_SUB_STATE_PLAYER_MAIN_MENU_5; - battleStatus->unk_6E = BATTLE_SUB_STATE_PLAYER_MAIN_MENU_6; + battleStatus->unk_6C = BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_5; + battleStatus->unk_6E = BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_6; battleStatus->selectedMoveID = battleStatus->submenuMoves[battleStatus->unk_49]; battleStatus->currentTargetListFlags = gMoveTable[battleStatus->submenuMoves[battleStatus->unk_49]].flags; currentSubmenu = battleStatus->currentSubmenu; @@ -2719,55 +2719,55 @@ void btl_state_update_player_menu(void) { break; } break; - case BATTLE_SUB_STATE_PLAYER_MAIN_MENU_4: + case BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_4: func_802A2C84(); if (func_802A11B0() != 0) { - gBattleSubState = BATTLE_SUB_STATE_PLAYER_MAIN_MENU_2; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_2; } break; - case BATTLE_SUB_STATE_PLAYER_MAIN_MENU_5: + case BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_5: func_802A2AB8(); func_802A1098(); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_MAIN_MENU_4; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_4; break; - case BATTLE_SUB_STATE_PLAYER_MAIN_MENU_6: + case BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_6: func_802A27E4(); func_802A10B8(); break; - case BATTLE_SUB_STATE_PLAYER_MAIN_MENU_7: + case BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_7: if (func_802A2C84() != -1) { - gBattleSubState = BATTLE_SUB_STATE_PLAYER_MAIN_MENU_2; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_2; } break; - case BATTLE_SUB_STATE_PLAYER_MAIN_MENU_8: + case BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_8: if (gBattleStatus.flags2 & BS_FLAGS2_4) { - btl_show_variable_battle_message(0x50, 60, 0); + btl_show_variable_battle_message(BTL_MSG_50, 60, 0); } else { - btl_show_variable_battle_message(0x51, 60, playerData->currentPartner); + btl_show_variable_battle_message(BTL_MSG_51, 60, playerData->currentPartner); } D_802AD607 = 1; - gBattleSubState = 9; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_9; break; - case BATTLE_SUB_STATE_PLAYER_MAIN_MENU_9: + case BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_9: if (!btl_is_popup_displayed()) { D_802ACC6C = 4; D_802AD607 = 0; D_802ACC60 = 0; - gBattleSubState = BATTLE_SUB_STATE_PLAYER_MAIN_MENU_1; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_1; } break; - case BATTLE_SUB_STATE_PLAYER_MAIN_MENU_10: + case BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_10: func_802A1030(); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_MAIN_MENU_11; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_11; break; - case BATTLE_SUB_STATE_PLAYER_MAIN_MENU_11: + case BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_11: submenuResult = func_802A11B0(); if ((battleStatus->currentButtonsPressed & BUTTON_B) && submenuResult == 0) { func_802A1078(); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_MAIN_MENU_12; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_12; } else if (submenuResult != 0) { - battleStatus->unk_6C = BATTLE_SUB_STATE_PLAYER_MAIN_MENU_13; - battleStatus->unk_6E = BATTLE_SUB_STATE_PLAYER_MAIN_MENU_14; + battleStatus->unk_6C = BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_13; + battleStatus->unk_6E = BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_14; switch (battleStatus->currentSubmenu) { case 0: battleStatus->moveCategory = 0; @@ -2789,21 +2789,21 @@ void btl_state_update_player_menu(void) { } break; CASE_C: - case BATTLE_SUB_STATE_PLAYER_MAIN_MENU_12: + case BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_12: if (func_802A11B0() != 0) { D_802ACC60 = 8; D_802ACC6C = 4; - gBattleSubState = BATTLE_SUB_STATE_PLAYER_MAIN_MENU_1; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_1; } break; - case BATTLE_SUB_STATE_PLAYER_MAIN_MENU_13: + case BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_13: func_802A1078(); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_MAIN_MENU_12; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_12; break; - case BATTLE_SUB_STATE_PLAYER_MAIN_MENU_14: + case BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_14: func_802A10B8(); break; - case BATTLE_SUB_STATE_PLAYER_UNKNOWN_1: + case BTL_SUBSTATE_PLAYER_MENU_UNKNOWN_1: if (battleStatus->selectedMoveID == MOVE_DOUBLE_DIP) { battleStatus->itemUsesLeft = 2; } @@ -2854,20 +2854,20 @@ void btl_state_update_player_menu(void) { popup->initialPos = initialPos; func_800F513C(popup); func_800F52BC(); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_UNKNOWN_2; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_UNKNOWN_2; break; - case BATTLE_SUB_STATE_PLAYER_UNKNOWN_2: + case BTL_SUBSTATE_PLAYER_MENU_UNKNOWN_2: if (popup->result != 0) { if (popup->result == 0xff) { func_802A2910(); battleStatus->selectedMoveID = 0; battleStatus->itemUsesLeft = 0; - gBattleSubState = BATTLE_SUB_STATE_PLAYER_MAIN_MENU_2; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_2; btl_state_update_player_menu(); btl_state_update_player_menu(); } else { - battleStatus->unk_6C = BATTLE_SUB_STATE_PLAYER_UNKNOWN_5; - battleStatus->unk_6E = BATTLE_SUB_STATE_PLAYER_UNKNOWN_6; + battleStatus->unk_6C = BTL_SUBSTATE_PLAYER_MENU_UNKNOWN_5; + battleStatus->unk_6E = BTL_SUBSTATE_PLAYER_MENU_UNKNOWN_6; battleStatus->unk_1AA = popup->userIndex[popup->result - 1]; battleStatus->moveCategory = 2; battleStatus->selectedItemID = battleStatus->unk_1AA; @@ -2877,17 +2877,17 @@ void btl_state_update_player_menu(void) { hide_popup_menu(); func_802A27D0(); func_802A1030(); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_UNKNOWN_3; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_UNKNOWN_3; } } break; - case BATTLE_SUB_STATE_PLAYER_UNKNOWN_3: + case BTL_SUBSTATE_PLAYER_MENU_UNKNOWN_3: if ((battleStatus->currentButtonsPressed & BUTTON_B) && popup->result == 0) { func_800F16CC(); func_802A2C58(); func_802A1098(); battleStatus->selectedMoveID = 0; - gBattleSubState = BATTLE_SUB_STATE_PLAYER_UNKNOWN_4; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_UNKNOWN_4; } else { func_802A2C84(); if (func_802A11B0()) { @@ -2895,25 +2895,25 @@ void btl_state_update_player_menu(void) { } } break; - case BATTLE_SUB_STATE_PLAYER_UNKNOWN_4: + case BTL_SUBSTATE_PLAYER_MENU_UNKNOWN_4: func_802A2C84(); if (func_802A11B0() != 0) { - gBattleSubState = BATTLE_SUB_STATE_PLAYER_UNKNOWN_2; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_UNKNOWN_2; } break; - case BATTLE_SUB_STATE_PLAYER_UNKNOWN_5: + case BTL_SUBSTATE_PLAYER_MENU_UNKNOWN_5: func_800F16CC(); func_802A2C58(); func_802A1098(); func_802A2C84(); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_UNKNOWN_4; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_UNKNOWN_4; break; - case BATTLE_SUB_STATE_PLAYER_UNKNOWN_6: + case BTL_SUBSTATE_PLAYER_MENU_UNKNOWN_6: destroy_popup_menu(); func_802A27E4(); func_802A10B8(); break; - case BATTLE_SUB_STATE_PLAYER_ITEMS_1: + case BTL_SUBSTATE_PLAYER_MENU_ITEMS_1: entryIdx = 0; for (i = 0; i < ARRAY_COUNT(playerData->invItems); i++) { if (playerData->invItems[i] == 0) { @@ -2951,20 +2951,20 @@ void btl_state_update_player_menu(void) { popup->initialPos = initialPos; func_800F513C(popup); func_800F52BC(); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_ITEMS_2; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_ITEMS_2; break; - case BATTLE_SUB_STATE_PLAYER_ITEMS_2: + case BTL_SUBSTATE_PLAYER_MENU_ITEMS_2: if (popup->result != 0) { if (popup->result == 0xff) { func_802A1050(); D_802ACC60 = 8; D_802ACC6C = 4; - gBattleSubState = BATTLE_SUB_STATE_PLAYER_MAIN_MENU_1; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_1; btl_state_update_player_menu(); btl_state_update_player_menu(); } else { - battleStatus->unk_6C = 44; - battleStatus->unk_6E = 45; + battleStatus->unk_6C = BTL_SUBSTATE_PLAYER_MENU_ITEMS_5; + battleStatus->unk_6E = BTL_SUBSTATE_PLAYER_MENU_ITEMS_6; battleStatus->unk_1AA = popup->userIndex[popup->result - 1]; battleStatus->moveCategory = 2; battleStatus->selectedItemID = battleStatus->unk_1AA; @@ -2974,36 +2974,36 @@ void btl_state_update_player_menu(void) { battleStatus->unk_4C[4] = popup->result - 1; hide_popup_menu(); func_802A1030(); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_ITEMS_3; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_ITEMS_3; } } break; - case BATTLE_SUB_STATE_PLAYER_ITEMS_3: + case BTL_SUBSTATE_PLAYER_MENU_ITEMS_3: if ((battleStatus->currentButtonsPressed & BUTTON_B) && popup->result == 0) { func_800F16CC(); func_802A1098(); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_ITEMS_4; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_ITEMS_4; } else { if (func_802A11B0() != 0) { btl_set_state(BATTLE_STATE_SELECT_TARGET); } } break; - case BATTLE_SUB_STATE_PLAYER_ITEMS_4: + case BTL_SUBSTATE_PLAYER_MENU_ITEMS_4: if (func_802A11B0() != 0) { - gBattleSubState = BATTLE_SUB_STATE_PLAYER_ITEMS_2; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_ITEMS_2; } break; - case BATTLE_SUB_STATE_PLAYER_ITEMS_5: + case BTL_SUBSTATE_PLAYER_MENU_ITEMS_5: func_800F16CC(); func_802A1098(); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_ITEMS_4; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_ITEMS_4; break; - case BATTLE_SUB_STATE_PLAYER_ITEMS_6: + case BTL_SUBSTATE_PLAYER_MENU_ITEMS_6: destroy_popup_menu(); func_802A10B8(); break; - case BATTLE_SUB_STATE_PLAYER_STAR_SPIRITS_1: + case BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_1: for (i = 0; i < battleStatus->submenuMoveCount; i++) { moveData = &gMoveTable[battleStatus->submenuMoves[i]]; battle_menu_moveOptionCantUseTypes[i] = 0; @@ -3047,18 +3047,18 @@ void btl_state_update_player_menu(void) { D_802AD4A8 = initialPos; battle_menu_hasSpiritsMenu = 1; func_802A2684(); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_STAR_SPIRITS_2; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_2; break; - case BATTLE_SUB_STATE_PLAYER_STAR_SPIRITS_2: + case BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_2: submenuResult = func_802A2C84(); if (submenuResult == -1) { - gBattleSubState = BATTLE_SUB_STATE_PLAYER_STAR_SPIRITS_7; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_7; } else if (submenuResult == 0) { } else if (submenuResult == 0xff) { func_802A1050(); D_802ACC60 = 8; D_802ACC6C = 4; - gBattleSubState = BATTLE_SUB_STATE_PLAYER_MAIN_MENU_1; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_1; btl_state_update_player_menu(); btl_state_update_player_menu(); } else { @@ -3066,18 +3066,18 @@ void btl_state_update_player_menu(void) { battleStatus->unk_4C[6] = battle_menu_moveOptionActive; func_802A27D0(); func_802A1030(); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_STAR_SPIRITS_3; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_3; } break; - case BATTLE_SUB_STATE_PLAYER_STAR_SPIRITS_3: + case BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_3: submenuResult = func_802A2C84(); if ((battleStatus->currentButtonsPressed & BUTTON_B) && submenuResult == 0) { func_802A2AB8(); func_802A1098(); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_STAR_SPIRITS_4; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_4; } else if (func_802A11B0() != 0) { - battleStatus->unk_6C = BATTLE_SUB_STATE_PLAYER_STAR_SPIRITS_5; - battleStatus->unk_6E = BATTLE_SUB_STATE_PLAYER_STAR_SPIRITS_6; + battleStatus->unk_6C = BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_5; + battleStatus->unk_6E = BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_6; battleStatus->moveCategory = 8; battleStatus->selectedMoveID = battleStatus->submenuMoves[battleStatus->unk_49]; battleStatus->currentTargetListFlags = gMoveTable[battleStatus->submenuMoves[battleStatus->unk_49]].flags; @@ -3088,27 +3088,27 @@ void btl_state_update_player_menu(void) { btl_set_state(BATTLE_STATE_SELECT_TARGET); } break; - case BATTLE_SUB_STATE_PLAYER_STAR_SPIRITS_4: + case BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_4: func_802A2C84(); if (func_802A11B0() != 0) { - gBattleSubState = BATTLE_SUB_STATE_PLAYER_STAR_SPIRITS_2; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_2; } break; - case BATTLE_SUB_STATE_PLAYER_STAR_SPIRITS_5: + case BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_5: func_802A2AB8(); func_802A1098(); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_STAR_SPIRITS_4; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_4; break; - case BATTLE_SUB_STATE_PLAYER_STAR_SPIRITS_6: + case BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_6: func_802A27E4(); func_802A10B8(); break; - case BATTLE_SUB_STATE_PLAYER_STAR_SPIRITS_7: + case BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_7: if (func_802A2C84() != -1) { - gBattleSubState = BATTLE_SUB_STATE_PLAYER_STAR_SPIRITS_2; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_2; } break; - case BATTLE_SUB_STATE_PLAYER_UNUSED_1: + case BTL_SUBSTATE_PLAYER_MENU_UNUSED_1: if (!can_btl_state_update_switch_to_player()) { battleStatus->itemUsesLeft = 1; btl_set_state(BATTLE_STATE_END_PLAYER_TURN); @@ -3162,18 +3162,18 @@ void btl_state_update_player_menu(void) { popup->initialPos = initialPos; func_800F513C(popup); func_800F52BC(); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_UNUSED_2; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_UNUSED_2; } } break; - case BATTLE_SUB_STATE_PLAYER_UNUSED_2: + case BTL_SUBSTATE_PLAYER_MENU_UNUSED_2: if (popup->result != 0) { if (popup->result == 255) { battleStatus->itemUsesLeft = 1; btl_set_state(BATTLE_STATE_END_PLAYER_TURN); } else { - battleStatus->unk_6C = BATTLE_SUB_STATE_PLAYER_UNUSED_5; - battleStatus->unk_6E = BATTLE_SUB_STATE_PLAYER_UNUSED_6; + battleStatus->unk_6C = BTL_SUBSTATE_PLAYER_MENU_UNUSED_5; + battleStatus->unk_6E = BTL_SUBSTATE_PLAYER_MENU_UNUSED_6; battleStatus->unk_1AA = popup->userIndex[popup->result - 1]; battleStatus->moveCategory = 2; battleStatus->selectedItemID = battleStatus->unk_1AA; @@ -3182,33 +3182,33 @@ void btl_state_update_player_menu(void) { battleStatus->unk_4C[4] = popup->result - 1; hide_popup_menu(); D_802ACC60 = 5; - gBattleSubState = BATTLE_SUB_STATE_PLAYER_UNUSED_3; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_UNUSED_3; } } break; - case BATTLE_SUB_STATE_PLAYER_UNUSED_3: + case BTL_SUBSTATE_PLAYER_MENU_UNUSED_3: if (D_802ACC60 != 0) { D_802ACC60--; } else { btl_set_state(BATTLE_STATE_SELECT_TARGET); } break; - case BATTLE_SUB_STATE_PLAYER_UNUSED_4: + case BTL_SUBSTATE_PLAYER_MENU_UNUSED_4: if (D_802ACC60 != 0) { D_802ACC60--; } else { - gBattleSubState = BATTLE_SUB_STATE_PLAYER_UNUSED_2; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_UNUSED_2; } break; - case BATTLE_SUB_STATE_PLAYER_UNUSED_5: + case BTL_SUBSTATE_PLAYER_MENU_UNUSED_5: func_800F16CC(); D_802ACC60 = 5; - gBattleSubState = BATTLE_SUB_STATE_PLAYER_UNUSED_4; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_UNUSED_4; break; - case BATTLE_SUB_STATE_PLAYER_UNUSED_6: + case BTL_SUBSTATE_PLAYER_MENU_UNUSED_6: destroy_popup_menu(); break; - case BATTLE_SUB_STATE_PLAYER_BERSERKER_1: + case BTL_SUBSTATE_PLAYER_MENU_BERSERKER_1: if (playerData->bootsLevel >= 0) { battleStatus->currentTargetListFlags = gMoveTable[MOVE_UNUSED_JUMP5].flags; player_create_target_list(playerActor); @@ -3253,7 +3253,7 @@ void btl_state_update_player_menu(void) { btl_set_state(BATTLE_STATE_PLAYER_MOVE); } break; - case BATTLE_SUB_STATE_PLAYER_STRATEGIES_1: + case BTL_SUBSTATE_PLAYER_MENU_BUILD_STRATEGIES: entryIdx = 0; func_80263268(); if (battleStatus->changePartnerAllowed >= 0) { @@ -3282,7 +3282,7 @@ void btl_state_update_player_menu(void) { D_802AD690[entryIdx] = 1; D_802AD658[entryIdx] = battle_menu_leftJustfiedMessagesA[3]; D_802AD6C0[entryIdx] = MSG_Menus_Action_RunAway; - if (!(gBattleStatus.flags2 & BS_FLAGS2_20)) { + if (!(gBattleStatus.flags2 & BS_FLAGS2_CANT_FLEE)) { D_802AD640[entryIdx] = battle_menu_FleeHudScripts.disabled; D_802AD690[entryIdx] = 0; D_802AD6A8[entryIdx] = 1; @@ -3296,46 +3296,46 @@ void btl_state_update_player_menu(void) { D_802AD66C = entryIdx; D_802AD670 = initialPos; func_802A45D8(); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_STRATEGIES_2; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_2; break; - case BATTLE_SUB_STATE_PLAYER_STRATEGIES_2: + case BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_2: submenuResult = func_802A4A54(); if (submenuResult == -1) { - gBattleSubState = BATTLE_SUB_STATE_PLAYER_STRATEGIES_8; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_8; } else if (submenuResult == 0) { } else if (submenuResult == 255) { func_802A1050(); D_802ACC60 = 8; D_802ACC6C = 4; - gBattleSubState = BATTLE_SUB_STATE_PLAYER_MAIN_MENU_1; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_1; btl_state_update_player_menu(); btl_state_update_player_menu(); } else { battleStatus->currentSubmenu = D_802AD678[submenuResult - 1]; battleStatus->unk_4C[7] = submenuResult - 1; if (battleStatus->currentSubmenu == 5) { - gBattleSubState = BATTLE_SUB_STATE_PLAYER_CHANGE_MEMBER_1; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_1; btl_state_update_player_menu(); btl_state_update_player_menu(); } else { func_802A4718(); func_802A1030(); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_STRATEGIES_3; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_3; } } break; - case BATTLE_SUB_STATE_PLAYER_STRATEGIES_3: + case BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_3: submenuResult = func_802A4A54(); if ((battleStatus->currentButtonsPressed & BUTTON_B) && submenuResult == 0) { func_802A48FC(); func_802A1098(); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_STRATEGIES_4; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_4; } else if (func_802A11B0() != 0) { - battleStatus->unk_6C = BATTLE_SUB_STATE_PLAYER_STRATEGIES_5; - battleStatus->unk_6E = BATTLE_SUB_STATE_PLAYER_STRATEGIES_6; + battleStatus->unk_6C = BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_5; + battleStatus->unk_6E = BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_6; switch (battleStatus->currentSubmenu) { case 3: - gBattleSubState = BATTLE_SUB_STATE_PLAYER_STRATEGIES_6; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_6; btl_state_update_player_menu(); battleStatus->moveCategory = 3; battleStatus->selectedMoveID = MOVE_UNUSED_39; @@ -3343,49 +3343,49 @@ void btl_state_update_player_menu(void) { break; case 9: battleStatus->hustleTurns = 0; - gBattleStatus.flags1 &= ~BS_FLAGS1_HUSTLE_DRINK_ON; + gBattleStatus.flags1 &= ~BS_FLAGS1_HUSTLED; gBattleSubState = battleStatus->unk_6E; btl_state_update_player_menu(); btl_set_state(BATTLE_STATE_END_PLAYER_TURN); break; case 4: - gBattleSubState = BATTLE_SUB_STATE_PLAYER_STRATEGIES_6; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_6; btl_state_update_player_menu(); battleStatus->selectedMoveID = MOVE_UNUSED_DEFEND_PLUS; battleStatus->moveCategory = 4; btl_set_state(BATTLE_STATE_DEFEND); break; case 10: - gBattleSubState = BATTLE_SUB_STATE_PLAYER_STRATEGIES_6; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_6; btl_state_update_player_menu(); btl_set_state(BATTLE_STATE_SWITCH_TO_PARTNER); break; } } break; - case BATTLE_SUB_STATE_PLAYER_STRATEGIES_4: + case BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_4: func_802A4A54(); if (func_802A11B0() != 0) { D_802ACC60 = 8; D_802ACC6C = 4; - gBattleSubState = BATTLE_SUB_STATE_PLAYER_MAIN_MENU_1; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_1; } break; - case BATTLE_SUB_STATE_PLAYER_STRATEGIES_5: + case BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_5: func_802A48FC(); func_802A1098(); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_STRATEGIES_4; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_4; break; - case BATTLE_SUB_STATE_PLAYER_STRATEGIES_6: + case BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_6: func_802A472C(); func_802A10B8(); break; - case BATTLE_SUB_STATE_PLAYER_STRATEGIES_8: + case BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_8: if (func_802A4A54() != -1) { - gBattleSubState = BATTLE_SUB_STATE_PLAYER_STRATEGIES_2; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_2; } break; - case BATTLE_SUB_STATE_PLAYER_CHANGE_MEMBER_1: + case BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_1: entryIdx = 0; for (i = 1; i < ARRAY_COUNT(playerData->partners); i++) { s32 partnerId = D_8008EEC0[i]; @@ -3414,20 +3414,20 @@ void btl_state_update_player_menu(void) { popup->unk_320 = 0; func_800F513C(popup); func_800F52BC(); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_CHANGE_MEMBER_2; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_2; break; - case BATTLE_SUB_STATE_PLAYER_CHANGE_MEMBER_2: + case BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_2: if (popup->result == -1) { - gBattleSubState = BATTLE_SUB_STATE_PLAYER_CHANGE_MEMBER_7; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_7; } else if (popup->result != 0) { if (popup->result == 255) { func_802A47E0(); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_STRATEGIES_2; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_2; btl_state_update_player_menu(); btl_state_update_player_menu(); } else { - battleStatus->unk_6C = BATTLE_SUB_STATE_PLAYER_CHANGE_MEMBER_5; - battleStatus->unk_6E = BATTLE_SUB_STATE_PLAYER_CHANGE_MEMBER_6; + battleStatus->unk_6C = BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_5; + battleStatus->unk_6E = BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_6; battleStatus->unk_1AC = popup->userIndex[popup->result - 1]; battleStatus->moveCategory = 5; battleStatus->selectedMoveID = MOVE_UNUSED_37; @@ -3437,16 +3437,16 @@ void btl_state_update_player_menu(void) { hide_popup_menu(); func_802A4718(); func_802A1030(); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_CHANGE_MEMBER_3; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_3; } } break; - case BATTLE_SUB_STATE_PLAYER_CHANGE_MEMBER_3: + case BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_3: if ((battleStatus->currentButtonsPressed & BUTTON_B) && popup->result == 0) { func_800F16CC(); func_802A4A10(); func_802A1098(); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_CHANGE_MEMBER_4; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_4; } else { func_802A4A54(); if (func_802A11B0() != 0) { @@ -3456,30 +3456,30 @@ void btl_state_update_player_menu(void) { } } break; - case BATTLE_SUB_STATE_PLAYER_CHANGE_MEMBER_4: + case BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_4: func_802A4A54(); if (func_802A11B0() != 0) { - gBattleSubState = BATTLE_SUB_STATE_PLAYER_CHANGE_MEMBER_2; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_2; } break; - case BATTLE_SUB_STATE_PLAYER_CHANGE_MEMBER_5: + case BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_5: func_800F16CC(); func_802A4A10(); func_802A1098(); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_CHANGE_MEMBER_4; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_4; break; - case BATTLE_SUB_STATE_PLAYER_CHANGE_MEMBER_6: + case BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_6: destroy_popup_menu(); func_802A472C(); func_802A10B8(); break; - case BATTLE_SUB_STATE_PLAYER_CHANGE_MEMBER_7: + case BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_7: set_window_update(WINDOW_ID_6, WINDOW_UPDATE_HIDE); set_window_update(WINDOW_ID_7, WINDOW_UPDATE_HIDE); if (popup->result != -1) { set_window_update(WINDOW_ID_6, WINDOW_UPDATE_9); set_window_update(WINDOW_ID_7, WINDOW_UPDATE_9); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_CHANGE_MEMBER_2; + gBattleSubState = BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_2; } break; } @@ -3487,53 +3487,53 @@ void btl_state_update_player_menu(void) { void btl_state_draw_player_menu(void) { switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_1: + case BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_1: btl_draw_menu_wheel(); break; - case BATTLE_SUB_STATE_UNK_2: - case BATTLE_SUB_STATE_UNK_3: - case BATTLE_SUB_STATE_UNK_4: - case BATTLE_SUB_STATE_BEGIN_LEVEL_UP: - case BATTLE_SUB_STATE_PLAYER_DEFEATED: - case BATTLE_SUB_STATE_UNK_B: - case BATTLE_SUB_STATE_UNK_C: - case BATTLE_SUB_STATE_UNK_D: - case BATTLE_SUB_STATE_UNK_14: - case BATTLE_SUB_STATE_UNK_15: - case BATTLE_SUB_STATE_UNK_16: - case BATTLE_SUB_STATE_UNK_17: - case BATTLE_SUB_STATE_UNK_18: - case BATTLE_SUB_STATE_UNK_1E: - case BATTLE_SUB_STATE_UNK_1F: - case BATTLE_SUB_STATE_UNK_20: - case BATTLE_SUB_STATE_UNK_21: - case BATTLE_SUB_STATE_UNK_22: - case BATTLE_SUB_STATE_UNK_28: - case BATTLE_SUB_STATE_UNK_29: - case BATTLE_SUB_STATE_UNK_2A: - case BATTLE_SUB_STATE_UNK_2B: - case BATTLE_SUB_STATE_UNK_2C: - case BATTLE_SUB_STATE_UNK_3D: - case BATTLE_SUB_STATE_UNK_3E: - case BATTLE_SUB_STATE_UNK_3F: + case BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_2: + case BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_3: + case BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_4: + case BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_5: + case BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_10: + case BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_11: + case BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_12: + case BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_13: + case BTL_SUBSTATE_PLAYER_MENU_UNKNOWN_1: + case BTL_SUBSTATE_PLAYER_MENU_UNKNOWN_2: + case BTL_SUBSTATE_PLAYER_MENU_UNKNOWN_3: + case BTL_SUBSTATE_PLAYER_MENU_UNKNOWN_4: + case BTL_SUBSTATE_PLAYER_MENU_UNKNOWN_5: + case BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_1: + case BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_2: + case BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_3: + case BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_4: + case BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_5: + case BTL_SUBSTATE_PLAYER_MENU_ITEMS_1: + case BTL_SUBSTATE_PLAYER_MENU_ITEMS_2: + case BTL_SUBSTATE_PLAYER_MENU_ITEMS_3: + case BTL_SUBSTATE_PLAYER_MENU_ITEMS_4: + case BTL_SUBSTATE_PLAYER_MENU_ITEMS_5: + case BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_2: + case BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_3: + case BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_4: btl_draw_menu_wheel(); break; - case BATTLE_SUB_STATE_UNK_40: - case BATTLE_SUB_STATE_UNK_41: - case BATTLE_SUB_STATE_UNK_C8: - case BATTLE_SUB_STATE_UNK_C9: + case BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_5: + case BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_6: + case BTL_SUBSTATE_PLAYER_MENU_BUILD_STRATEGIES: + case BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_2: btl_draw_menu_wheel(); break; - case BATTLE_SUB_STATE_UNK_CA: + case BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_3: btl_draw_menu_wheel(); break; - case BATTLE_SUB_STATE_UNK_CB: + case BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_4: btl_draw_menu_wheel(); break; - case BATTLE_SUB_STATE_UNK_CC: + case BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_5: btl_draw_menu_wheel(); break; - case BATTLE_SUB_STATE_UNK_CD: + case BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_6: btl_draw_menu_wheel(); break; } @@ -3554,7 +3554,7 @@ void btl_state_update_partner_menu(void) { MoveData* moveData; PartnerPopupProperties* popupProps; - if (gBattleSubState == BATTLE_SUB_STATE_PARTNER_NONE) { + if (gBattleSubState == BTL_SUBSTATE_PARTNER_MENU_NONE) { battleStatus->moveCategory = -1; battleStatus->selectedMoveID = MOVE_NONE; battleStatus->currentAttackElement = 0; @@ -3566,9 +3566,9 @@ void btl_state_update_partner_menu(void) { playerActor->flags &= ~(ACTOR_FLAG_4000000 | ACTOR_FLAG_8000000); partnerActor->flags &= ~(ACTOR_FLAG_4000000 | ACTOR_FLAG_8000000); if (battleStatus->flags1 & BS_FLAGS1_100000) { - gBattleSubState = BATTLE_SUB_STATE_PARTNER_INIT_MENU; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_INIT_MENU; } else { - gBattleSubState = BATTLE_SUB_STATE_PARTNER_12D; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_12D; partnerActor->state.currentPos.x = partnerActor->homePos.x; partnerActor->state.currentPos.z = partnerActor->homePos.z; partnerActor->state.goalPos.x = playerActor->homePos.x; @@ -3578,7 +3578,7 @@ void btl_state_update_partner_menu(void) { } } } - if (gBattleSubState == BATTLE_SUB_STATE_PARTNER_12D) { + if (gBattleSubState == BTL_SUBSTATE_PARTNER_MENU_12D) { if (partnerActor->state.moveTime != 0) { partnerActor->currentPos.x += (partnerActor->state.goalPos.x - partnerActor->currentPos.x) / partnerActor->state.moveTime; partnerActor->currentPos.z += (partnerActor->state.goalPos.z - partnerActor->currentPos.z) / partnerActor->state.moveTime; @@ -3593,7 +3593,7 @@ void btl_state_update_partner_menu(void) { if (partnerActor->state.moveTime != 0) { partnerActor->state.moveTime--; } else { - gBattleSubState = BATTLE_SUB_STATE_UNK_12E; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_INIT_MENU; partnerActor->currentPos.x = partnerActor->state.goalPos.x; partnerActor->currentPos.z = partnerActor->state.goalPos.z; playerActor->currentPos.x = partnerActor->state.currentPos.x; @@ -3606,7 +3606,7 @@ void btl_state_update_partner_menu(void) { } } switch (gBattleSubState) { - case BATTLE_SUB_STATE_PARTNER_INIT_MENU: + case BTL_SUBSTATE_PARTNER_MENU_INIT_MENU: partnerActor->flags |= ACTOR_FLAG_8000000; partnerActor->flags &= ~ACTOR_FLAG_4000000; playerActor->flags |= ACTOR_FLAG_4000000; @@ -3686,12 +3686,12 @@ void btl_state_update_partner_menu(void) { func_802A1000(); D_802ACC60 = 8; D_802ACC6C = 0; - gBattleSubState = BATTLE_SUB_STATE_PARTNER_MAIN_MENU_1; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_1; return; - case BATTLE_SUB_STATE_PARTNER_MAIN_MENU_1: + case BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_1: set_animation(ACTOR_PARTNER, 0, battle_menu_partnerChooseMoveAnimations[playerData->currentPartner]); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_MAIN_MENU_2; - case BATTLE_SUB_STATE_PARTNER_MAIN_MENU_2: + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_2; + case BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_2: numOptions = func_802A11B0(); if (D_802ACC6C != 0) { D_802ACC6C -= 1; @@ -3703,7 +3703,7 @@ void btl_state_update_partner_menu(void) { btl_set_state(BATTLE_STATE_SWITCH_TO_PLAYER); } else { sfx_play_sound(SOUND_MENU_ERROR); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_MAIN_MENU_7; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_7; } break; } @@ -3713,38 +3713,38 @@ void btl_state_update_partner_menu(void) { set_animation(ACTOR_PARTNER, 0, D_802AB558[playerData->currentPartner]); battleStatus->unk_5C[0] = battleStatus->unk_4A = battle_menu_submenuIDs[numOptions - 1]; if (battleStatus->unk_4A == 7) { - gBattleSubState = BATTLE_SUB_STATE_PARTNER_STRATEGIES_1; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_1; btl_state_update_partner_menu(); btl_state_update_partner_menu(); } else if (battleStatus->unk_4A == 6) { - gBattleSubState = BATTLE_SUB_STATE_PARTNER_ABILITIES_1; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_ABILITIES_1; btl_state_update_partner_menu(); btl_state_update_partner_menu(); } else if (battleStatus->unk_4A == 8) { - gBattleSubState = BATTLE_SUB_STATE_PARTNER_FOCUS_1; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_FOCUS_1; btl_state_update_partner_menu(); btl_state_update_partner_menu(); } else if (battleStatus->unk_4A == 2) { - gBattleSubState = BATTLE_SUB_STATE_PARTNER_ITEMS_1; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_ITEMS_1; btl_state_update_partner_menu(); btl_state_update_partner_menu(); } else if (battleStatus->unk_4A == 5) { - gBattleSubState = BATTLE_SUB_STATE_PARTNER_UNUSED_CHANGE_PARTNER_1; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_1; btl_state_update_partner_menu(); btl_state_update_partner_menu(); } else { - battleStatus->unk_6C = BATTLE_SUB_STATE_PARTNER_MAIN_MENU_5; - battleStatus->unk_6E = BATTLE_SUB_STATE_PARTNER_MAIN_MENU_6; + battleStatus->unk_6C = BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_5; + battleStatus->unk_6E = BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_6; func_802A1030(); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_MAIN_MENU_3; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_3; } } break; - case BATTLE_SUB_STATE_PARTNER_MAIN_MENU_3: + case BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_3: numOptions = func_802A11B0(); if ((battleStatus->currentButtonsPressed & BUTTON_B) && numOptions == 0) { func_802A1078(); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_MAIN_MENU_4; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_4; return; } if (numOptions != 0) { @@ -3756,38 +3756,38 @@ void btl_state_update_partner_menu(void) { return; } break; - case BATTLE_SUB_STATE_PARTNER_MAIN_MENU_4: + case BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_4: if (func_802A11B0() != 0) { D_802ACC60 = 8; D_802ACC6C = 4; - gBattleSubState = BATTLE_SUB_STATE_PARTNER_MAIN_MENU_1; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_1; } break; - case BATTLE_SUB_STATE_PARTNER_MAIN_MENU_5: + case BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_5: func_802A1078(); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_MAIN_MENU_4; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_4; break; - case BATTLE_SUB_STATE_PARTNER_MAIN_MENU_6: + case BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_6: func_802A10B8(); break; - case BATTLE_SUB_STATE_PARTNER_MAIN_MENU_7: + case BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_7: if (can_btl_state_update_switch_to_player() == 0) { - btl_show_variable_battle_message(0x51, 60, 0); + btl_show_variable_battle_message(BTL_MSG_51, 60, 0); } else { - btl_show_variable_battle_message(0x50, 60, 0); + btl_show_variable_battle_message(BTL_MSG_50, 60, 0); } D_802AD607 = 1; - gBattleSubState = BATTLE_SUB_STATE_PARTNER_MAIN_MENU_8; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_8; break; - case BATTLE_SUB_STATE_PARTNER_MAIN_MENU_8: + case BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_8: if (btl_is_popup_displayed() == 0) { D_802ACC6C = 4; D_802ACC60 = 0; D_802AD607 = 0; - gBattleSubState = BATTLE_SUB_STATE_PARTNER_MAIN_MENU_1; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_1; } break; - case BATTLE_SUB_STATE_PARTNER_ABILITIES_1: + case BTL_SUBSTATE_PARTNER_MENU_ABILITIES_1: for (i = 0; i < battleStatus->submenuMoveCount; i++) { moveData = &gMoveTable[battleStatus->submenuMoves[i]]; @@ -3834,65 +3834,65 @@ void btl_state_update_partner_menu(void) { s1 = battleStatus->unk_5C[1]; D_802AD4A8 = s1; func_802A2684(); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_ABILITIES_2; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_ABILITIES_2; break; - case BATTLE_SUB_STATE_PARTNER_ABILITIES_2: + case BTL_SUBSTATE_PARTNER_MENU_ABILITIES_2: numOptions = func_802A2C84(); if (numOptions == -1) { - gBattleSubState = BATTLE_SUB_STATE_PARTNER_ABILITIES_7; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_ABILITIES_7; } else if (numOptions != 0) { if (numOptions == 255) { func_802A1050(); D_802ACC60 = 8; D_802ACC6C = 4; - gBattleSubState = BATTLE_SUB_STATE_PARTNER_MAIN_MENU_1; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_1; btl_state_update_partner_menu(); btl_state_update_partner_menu(); } else { battleStatus->unk_4B = numOptions - 1; func_802A27D0(); func_802A1030(); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_ABILITIES_3; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_ABILITIES_3; } } break; - case BATTLE_SUB_STATE_PARTNER_ABILITIES_3: + case BTL_SUBSTATE_PARTNER_MENU_ABILITIES_3: numOptions = func_802A2C84(); if ((battleStatus->currentButtonsPressed & BUTTON_B) && numOptions == 0) { func_802A2AB8(); func_802A1098(); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_ABILITIES_4; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_ABILITIES_4; } else if (func_802A11B0() != 0) { battleStatus->moveCategory = 6; battleStatus->selectedMoveID = battle_menu_moveIndices[battleStatus->unk_4B]; battleStatus->currentTargetListFlags = gMoveTable[battleStatus->selectedMoveID].flags; battleStatus->unk_5C[1] = battle_menu_moveOptionActive; - battleStatus->unk_6C = BATTLE_SUB_STATE_PARTNER_ABILITIES_5; - battleStatus->unk_6E = BATTLE_SUB_STATE_PARTNER_ABILITIES_6; + battleStatus->unk_6C = BTL_SUBSTATE_PARTNER_MENU_ABILITIES_5; + battleStatus->unk_6E = BTL_SUBSTATE_PARTNER_MENU_ABILITIES_6; btl_set_state(0x11); } break; - case BATTLE_SUB_STATE_PARTNER_ABILITIES_4: + case BTL_SUBSTATE_PARTNER_MENU_ABILITIES_4: func_802A2C84(); if (func_802A11B0() != 0) { - gBattleSubState = BATTLE_SUB_STATE_PARTNER_ABILITIES_2; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_ABILITIES_2; } break; - case BATTLE_SUB_STATE_PARTNER_ABILITIES_5: + case BTL_SUBSTATE_PARTNER_MENU_ABILITIES_5: func_802A2AB8(); func_802A1098(); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_ABILITIES_4; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_ABILITIES_4; break; - case BATTLE_SUB_STATE_PARTNER_ABILITIES_6: + case BTL_SUBSTATE_PARTNER_MENU_ABILITIES_6: func_802A27E4(); func_802A10B8(); break; - case BATTLE_SUB_STATE_PARTNER_ABILITIES_7: + case BTL_SUBSTATE_PARTNER_MENU_ABILITIES_7: if (func_802A2C84() != -1) { - gBattleSubState = BATTLE_SUB_STATE_PARTNER_ABILITIES_2; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_ABILITIES_2; } break; - case BATTLE_SUB_STATE_PARTNER_ITEMS_1: + case BTL_SUBSTATE_PARTNER_MENU_ITEMS_1: popupIndex = 0; for (i = 0; i < ARRAY_COUNT(playerData->invItems); i++) { ItemData* item; @@ -3924,20 +3924,20 @@ void btl_state_update_partner_menu(void) { popupMenu->initialPos = s1; func_800F513C(popupMenu); func_800F52BC(); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_ITEMS_2; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_ITEMS_2; break; - case BATTLE_SUB_STATE_PARTNER_ITEMS_2: + case BTL_SUBSTATE_PARTNER_MENU_ITEMS_2: if (popupMenu->result != 0) { if (popupMenu->result == 255) { func_802A1050(); D_802ACC60 = 8; D_802ACC6C = 4; - gBattleSubState = BATTLE_SUB_STATE_PARTNER_MAIN_MENU_1; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_1; btl_state_update_partner_menu(); btl_state_update_partner_menu(); } else { - battleStatus->unk_6C = BATTLE_SUB_STATE_PARTNER_ITEMS_5; - battleStatus->unk_6E = BATTLE_SUB_STATE_PARTNER_ITEMS_6; + battleStatus->unk_6C = BTL_SUBSTATE_PARTNER_MENU_ITEMS_5; + battleStatus->unk_6E = BTL_SUBSTATE_PARTNER_MENU_ITEMS_6; battleStatus->unk_1AA = popupMenu->userIndex[popupMenu->result - 1]; battleStatus->moveCategory = 2; battleStatus->selectedItemID = battleStatus->unk_1AA; @@ -3946,34 +3946,34 @@ void btl_state_update_partner_menu(void) { battleStatus->unk_5C[4] = popupMenu->result - 1; hide_popup_menu(); func_802A1030(); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_ITEMS_3; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_ITEMS_3; } } break; - case BATTLE_SUB_STATE_PARTNER_ITEMS_3: + case BTL_SUBSTATE_PARTNER_MENU_ITEMS_3: if ((battleStatus->currentButtonsPressed & BUTTON_B) && popupMenu->result == 0) { func_800F16CC(); func_802A1098(); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_ITEMS_4; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_ITEMS_4; } else if (func_802A11B0() != 0) { btl_set_state(BATTLE_STATE_SELECT_TARGET); } break; - case BATTLE_SUB_STATE_PARTNER_ITEMS_4: + case BTL_SUBSTATE_PARTNER_MENU_ITEMS_4: if (func_802A11B0() != 0) { - gBattleSubState = BATTLE_SUB_STATE_PARTNER_ITEMS_2; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_ITEMS_2; } break; - case BATTLE_SUB_STATE_PARTNER_ITEMS_5: + case BTL_SUBSTATE_PARTNER_MENU_ITEMS_5: func_800F16CC(); func_802A1098(); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_ITEMS_4; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_ITEMS_4; break; - case BATTLE_SUB_STATE_PARTNER_ITEMS_6: + case BTL_SUBSTATE_PARTNER_MENU_ITEMS_6: destroy_popup_menu(); func_802A10B8(); break; - case BATTLE_SUB_STATE_PARTNER_UNUSED_CHANGE_PARTNER_1: + case BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_1: popupIndex = 0; for (i = 1; i < ARRAY_COUNT(D_8008EEC0); i++) { s32 partnerId = D_8008EEC0[i]; @@ -4002,22 +4002,22 @@ void btl_state_update_partner_menu(void) { popupMenu->unk_320 = 0; func_800F513C(popupMenu); func_800F52BC(); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_UNUSED_CHANGE_PARTNER_2; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_2; break; - case BATTLE_SUB_STATE_PARTNER_UNUSED_CHANGE_PARTNER_2: + case BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_2: if (popupMenu->result == -1) { - gBattleSubState = BATTLE_SUB_STATE_PARTNER_UNUSED_CHANGE_PARTNER_7; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_7; } else if (popupMenu->result != 0) { if (popupMenu->result == 255) { func_802A1050(); D_802ACC60 = 8; D_802ACC6C = 4; - gBattleSubState = BATTLE_SUB_STATE_PARTNER_MAIN_MENU_1; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_1; btl_state_update_partner_menu(); btl_state_update_partner_menu(); } else { - battleStatus->unk_6C = BATTLE_SUB_STATE_PARTNER_UNUSED_CHANGE_PARTNER_5; - battleStatus->unk_6E = BATTLE_SUB_STATE_PARTNER_UNUSED_CHANGE_PARTNER_6; + battleStatus->unk_6C = BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_5; + battleStatus->unk_6E = BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_6; battleStatus->unk_1AC = popupMenu->userIndex[popupMenu->result - 1]; battleStatus->moveCategory = 5; battleStatus->selectedMoveID = MOVE_UNUSED_37; @@ -4026,41 +4026,41 @@ void btl_state_update_partner_menu(void) { battleStatus->unk_5C[5] = popupMenu->result - 1; hide_popup_menu(); func_802A1030(); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_UNUSED_CHANGE_PARTNER_3; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_3; } } break; - case BATTLE_SUB_STATE_PARTNER_UNUSED_CHANGE_PARTNER_3: + case BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_3: if ((battleStatus->currentButtonsPressed & BUTTON_B) && (popupMenu->result == 0)) { func_800F16CC(); func_802A1098(); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_UNUSED_CHANGE_PARTNER_4; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_4; } else if (func_802A11B0() != 0) { gBattleSubState = battleStatus->unk_6E; btl_state_update_partner_menu(); btl_set_state(BATTLE_STATE_CHANGE_PARTNER); } break; - case BATTLE_SUB_STATE_PARTNER_UNUSED_CHANGE_PARTNER_4: + case BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_4: if (func_802A11B0() != 0) { - gBattleSubState = BATTLE_SUB_STATE_PARTNER_UNUSED_CHANGE_PARTNER_2; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_2; } break; - case BATTLE_SUB_STATE_PARTNER_UNUSED_CHANGE_PARTNER_5: + case BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_5: func_800F16CC(); func_802A1098(); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_UNUSED_CHANGE_PARTNER_4; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_4; break; - case BATTLE_SUB_STATE_PARTNER_UNUSED_CHANGE_PARTNER_6: + case BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_6: destroy_popup_menu(); func_802A10B8(); break; - case BATTLE_SUB_STATE_PARTNER_UNUSED_CHANGE_PARTNER_7: + case BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_7: if (popupMenu->result != -1) { - gBattleSubState = BATTLE_SUB_STATE_PARTNER_UNUSED_CHANGE_PARTNER_2; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_2; } break; - case BATTLE_SUB_STATE_PARTNER_FOCUS_1: + case BTL_SUBSTATE_PARTNER_MENU_FOCUS_1: numOptions = 1; battleStatus->submenuMoves[0] = MOVE_FOCUS; battleStatus->submenuMoveCount = numOptions; @@ -4090,35 +4090,35 @@ void btl_state_update_partner_menu(void) { s1 = battleStatus->unk_5C[6]; D_802AD4A8 = s1; func_802A2684(); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_FOCUS_2; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_FOCUS_2; break; - case BATTLE_SUB_STATE_PARTNER_FOCUS_2: + case BTL_SUBSTATE_PARTNER_MENU_FOCUS_2: numOptions = func_802A2C84(); if (numOptions != 0) { if (numOptions == 255) { func_802A1050(); D_802ACC60 = 8; D_802ACC6C = 4; - gBattleSubState = BATTLE_SUB_STATE_PARTNER_MAIN_MENU_1; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_1; btl_state_update_partner_menu(); btl_state_update_partner_menu(); } else { battleStatus->unk_4B = battle_menu_moveIndices[numOptions - 1]; func_802A27D0(); func_802A1030(); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_FOCUS_3; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_FOCUS_3; } } break; - case BATTLE_SUB_STATE_PARTNER_FOCUS_3: + case BTL_SUBSTATE_PARTNER_MENU_FOCUS_3: numOptions = func_802A2C84(); if ((battleStatus->currentButtonsPressed & BUTTON_B) && (numOptions == 0)) { func_802A2AB8(); func_802A1098(); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_FOCUS_4; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_FOCUS_4; } else if (func_802A11B0() != 0) { - battleStatus->unk_6C = BATTLE_SUB_STATE_PARTNER_FOCUS_5; - battleStatus->unk_6E = BATTLE_SUB_STATE_PARTNER_FOCUS_6; + battleStatus->unk_6C = BTL_SUBSTATE_PARTNER_MENU_FOCUS_5; + battleStatus->unk_6E = BTL_SUBSTATE_PARTNER_MENU_FOCUS_6; battleStatus->moveCategory = 8; battleStatus->selectedMoveID = battleStatus->submenuMoves[battleStatus->unk_4B]; battleStatus->currentTargetListFlags = gMoveTable[battleStatus->submenuMoves[battleStatus->unk_4B]].flags; @@ -4127,22 +4127,22 @@ void btl_state_update_partner_menu(void) { btl_set_state(BATTLE_STATE_SELECT_TARGET); } break; - case BATTLE_SUB_STATE_PARTNER_FOCUS_4: + case BTL_SUBSTATE_PARTNER_MENU_FOCUS_4: func_802A2C84(); if (func_802A11B0() != 0) { - gBattleSubState = BATTLE_SUB_STATE_PARTNER_FOCUS_2; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_FOCUS_2; } break; - case BATTLE_SUB_STATE_PARTNER_FOCUS_5: + case BTL_SUBSTATE_PARTNER_MENU_FOCUS_5: func_802A2AB8(); func_802A1098(); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_FOCUS_4; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_FOCUS_4; break; - case BATTLE_SUB_STATE_PARTNER_FOCUS_6: + case BTL_SUBSTATE_PARTNER_MENU_FOCUS_6: func_802A27E4(); func_802A10B8(); break; - case BATTLE_SUB_STATE_PARTNER_STRATEGIES_1: + case BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_1: popupIndex = 0; func_80263268(); if (battleStatus->changePartnerAllowed >= 0) { @@ -4172,82 +4172,82 @@ void btl_state_update_partner_menu(void) { s1 = battleStatus->unk_5C[7]; D_802AD670 = s1; func_802A45D8(); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_STRATEGIES_2; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_2; break; - case BATTLE_SUB_STATE_PARTNER_STRATEGIES_2: + case BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_2: numOptions = func_802A4A54(); if (numOptions != 0) { if (numOptions == 255) { func_802A1050(); D_802ACC60 = 8; D_802ACC6C = 4; - gBattleSubState = BATTLE_SUB_STATE_PARTNER_MAIN_MENU_1; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_1; btl_state_update_partner_menu(); btl_state_update_partner_menu(); } else { battleStatus->unk_4A = D_802AD678[numOptions - 1]; battleStatus->unk_5C[7] = numOptions - 1; if (battleStatus->unk_4A == 5) { - gBattleSubState = BATTLE_SUB_STATE_PARTNER_CHANGE_PARTNER_1; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_1; btl_state_update_partner_menu(); btl_state_update_partner_menu(); } else { func_802A4718(); func_802A1030(); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_STRATEGIES_3; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_3; } } } break; - case BATTLE_SUB_STATE_PARTNER_STRATEGIES_3: + case BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_3: numOptions = func_802A4A54(); if ((battleStatus->currentButtonsPressed & BUTTON_B) && numOptions == 0) { func_802A48FC(); func_802A1098(); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_STRATEGIES_4; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_4; } else if (func_802A11B0() != 0) { - battleStatus->unk_6C = BATTLE_SUB_STATE_PARTNER_STRATEGIES_5; - battleStatus->unk_6E = BATTLE_SUB_STATE_PARTNER_STRATEGIES_6; + battleStatus->unk_6C = BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_5; + battleStatus->unk_6E = BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_6; numOptions = battleStatus->unk_4A; switch (numOptions) { case 9: - gBattleSubState = BATTLE_SUB_STATE_PARTNER_STRATEGIES_6; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_6; btl_state_update_partner_menu(); btl_set_state(BATTLE_STATE_END_PARTNER_TURN); break; case 3: - gBattleSubState = BATTLE_SUB_STATE_PARTNER_STRATEGIES_6; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_6; btl_state_update_partner_menu(); battleStatus->moveCategory = numOptions; battleStatus->selectedMoveID = MOVE_UNUSED_39; btl_set_state(BATTLE_STATE_RUN_AWAY); break; case 10: - gBattleSubState = BATTLE_SUB_STATE_PARTNER_STRATEGIES_6; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_6; btl_state_update_partner_menu(); btl_set_state(BATTLE_STATE_SWITCH_TO_PLAYER); break; } } break; - case BATTLE_SUB_STATE_PARTNER_STRATEGIES_4: + case BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_4: func_802A4A54(); if (func_802A11B0() != 0) { D_802ACC60 = 8; D_802ACC6C = 4; - gBattleSubState = BATTLE_SUB_STATE_PARTNER_MAIN_MENU_1; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_1; } break; - case BATTLE_SUB_STATE_PARTNER_STRATEGIES_5: + case BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_5: func_802A48FC(); func_802A1098(); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_STRATEGIES_4; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_4; break; - case BATTLE_SUB_STATE_PARTNER_STRATEGIES_6: + case BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_6: func_802A472C(); func_802A10B8(); break; - case BATTLE_SUB_STATE_PARTNER_CHANGE_PARTNER_1: + case BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_1: popupIndex = 0; for (i = 1; i < 12; i++) { s32 partnerId = D_8008EEC0[i]; @@ -4276,20 +4276,20 @@ void btl_state_update_partner_menu(void) { popupMenu->unk_320 = 0; func_800F513C(popupMenu); func_800F52BC(); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_CHANGE_PARTNER_2; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_2; break; - case BATTLE_SUB_STATE_PARTNER_CHANGE_PARTNER_2: + case BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_2: if (popupMenu->result == -1) { - gBattleSubState = BATTLE_SUB_STATE_PARTNER_CHANGE_PARTNER_7; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_7; } else if (popupMenu->result != 0) { if (popupMenu->result == 255) { func_802A47E0(); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_STRATEGIES_2; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_2; btl_state_update_partner_menu(); btl_state_update_partner_menu(); } else { - battleStatus->unk_6C = BATTLE_SUB_STATE_PARTNER_CHANGE_PARTNER_5; - battleStatus->unk_6E = BATTLE_SUB_STATE_PARTNER_CHANGE_PARTNER_6; + battleStatus->unk_6C = BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_5; + battleStatus->unk_6E = BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_6; battleStatus->unk_1AC = popupMenu->userIndex[popupMenu->result - 1]; battleStatus->moveCategory = 5; battleStatus->selectedMoveID = MOVE_UNUSED_37; @@ -4299,16 +4299,16 @@ void btl_state_update_partner_menu(void) { hide_popup_menu(); func_802A4718(); func_802A1030(); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_CHANGE_PARTNER_3; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_3; } } break; - case BATTLE_SUB_STATE_PARTNER_CHANGE_PARTNER_3: + case BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_3: if ((battleStatus->currentButtonsPressed & BUTTON_B) && popupMenu->result == 0) { func_800F16CC(); func_802A4A10(); func_802A1098(); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_CHANGE_PARTNER_4; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_4; } else { func_802A4A54(); if (func_802A11B0() != 0) { @@ -4318,30 +4318,30 @@ void btl_state_update_partner_menu(void) { } } break; - case BATTLE_SUB_STATE_PARTNER_CHANGE_PARTNER_4: + case BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_4: func_802A4A54(); if (func_802A11B0() != 0) { - gBattleSubState = BATTLE_SUB_STATE_PARTNER_CHANGE_PARTNER_2; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_2; } break; - case BATTLE_SUB_STATE_PARTNER_CHANGE_PARTNER_5: + case BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_5: func_800F16CC(); func_802A4A10(); func_802A1098(); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_CHANGE_PARTNER_4; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_4; break; - case BATTLE_SUB_STATE_PARTNER_CHANGE_PARTNER_6: + case BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_6: destroy_popup_menu(); func_802A472C(); func_802A10B8(); break; - case BATTLE_SUB_STATE_PARTNER_CHANGE_PARTNER_7: + case BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_7: set_window_update(WINDOW_ID_6, WINDOW_UPDATE_HIDE); set_window_update(WINDOW_ID_7, WINDOW_UPDATE_HIDE); if (popupMenu->result != -1) { set_window_update(WINDOW_ID_6, WINDOW_UPDATE_9); set_window_update(WINDOW_ID_7, WINDOW_UPDATE_9); - gBattleSubState = BATTLE_SUB_STATE_PARTNER_CHANGE_PARTNER_2; + gBattleSubState = BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_2; } break; } @@ -4349,56 +4349,56 @@ void btl_state_update_partner_menu(void) { void btl_state_draw_partner_menu(void) { switch (gBattleSubState) { - case BATTLE_SUB_STATE_PARTNER_MAIN_MENU_1: + case BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_1: btl_draw_menu_wheel(); break; - case BATTLE_SUB_STATE_PARTNER_MAIN_MENU_2: - case BATTLE_SUB_STATE_PARTNER_MAIN_MENU_3: - case BATTLE_SUB_STATE_PARTNER_MAIN_MENU_4: - case BATTLE_SUB_STATE_PARTNER_MAIN_MENU_5: - case BATTLE_SUB_STATE_PARTNER_ABILITIES_1: - case BATTLE_SUB_STATE_PARTNER_ABILITIES_2: - case BATTLE_SUB_STATE_PARTNER_ABILITIES_3: - case BATTLE_SUB_STATE_PARTNER_ABILITIES_4: - case BATTLE_SUB_STATE_PARTNER_ABILITIES_5: - case BATTLE_SUB_STATE_PARTNER_UNKNOWN_1: - case BATTLE_SUB_STATE_PARTNER_UNKNOWN_2: - case BATTLE_SUB_STATE_PARTNER_UNKNOWN_3: - case BATTLE_SUB_STATE_PARTNER_UNKNOWN_4: - case BATTLE_SUB_STATE_PARTNER_UNKNOWN_5: - case BATTLE_SUB_STATE_PARTNER_CHANGE_PARTNER_1: - case BATTLE_SUB_STATE_PARTNER_CHANGE_PARTNER_2: - case BATTLE_SUB_STATE_PARTNER_CHANGE_PARTNER_3: - case BATTLE_SUB_STATE_PARTNER_CHANGE_PARTNER_4: - case BATTLE_SUB_STATE_PARTNER_CHANGE_PARTNER_5: - case BATTLE_SUB_STATE_PARTNER_ITEMS_1: - case BATTLE_SUB_STATE_PARTNER_ITEMS_2: - case BATTLE_SUB_STATE_PARTNER_ITEMS_3: - case BATTLE_SUB_STATE_PARTNER_ITEMS_4: - case BATTLE_SUB_STATE_PARTNER_ITEMS_5: - case BATTLE_SUB_STATE_PARTNER_UNUSED_CHANGE_PARTNER_2: - case BATTLE_SUB_STATE_PARTNER_UNUSED_CHANGE_PARTNER_3: - case BATTLE_SUB_STATE_PARTNER_UNUSED_CHANGE_PARTNER_4: - case BATTLE_SUB_STATE_PARTNER_UNUSED_CHANGE_PARTNER_5: - case BATTLE_SUB_STATE_PARTNER_FOCUS_2: - case BATTLE_SUB_STATE_PARTNER_FOCUS_3: - case BATTLE_SUB_STATE_PARTNER_FOCUS_4: - case BATTLE_SUB_STATE_PARTNER_FOCUS_5: - case BATTLE_SUB_STATE_PARTNER_FOCUS_6: - case BATTLE_SUB_STATE_PARTNER_STRATEGIES_1: - case BATTLE_SUB_STATE_PARTNER_STRATEGIES_2: + case BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_2: + case BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_3: + case BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_4: + case BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_5: + case BTL_SUBSTATE_PARTNER_MENU_ABILITIES_1: + case BTL_SUBSTATE_PARTNER_MENU_ABILITIES_2: + case BTL_SUBSTATE_PARTNER_MENU_ABILITIES_3: + case BTL_SUBSTATE_PARTNER_MENU_ABILITIES_4: + case BTL_SUBSTATE_PARTNER_MENU_ABILITIES_5: + case BTL_SUBSTATE_PARTNER_MENU_UNKNOWN_1: + case BTL_SUBSTATE_PARTNER_MENU_UNKNOWN_2: + case BTL_SUBSTATE_PARTNER_MENU_UNKNOWN_3: + case BTL_SUBSTATE_PARTNER_MENU_UNKNOWN_4: + case BTL_SUBSTATE_PARTNER_MENU_UNKNOWN_5: + case BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_1: + case BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_2: + case BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_3: + case BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_4: + case BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_5: + case BTL_SUBSTATE_PARTNER_MENU_ITEMS_1: + case BTL_SUBSTATE_PARTNER_MENU_ITEMS_2: + case BTL_SUBSTATE_PARTNER_MENU_ITEMS_3: + case BTL_SUBSTATE_PARTNER_MENU_ITEMS_4: + case BTL_SUBSTATE_PARTNER_MENU_ITEMS_5: + case BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_2: + case BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_3: + case BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_4: + case BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_5: + case BTL_SUBSTATE_PARTNER_MENU_FOCUS_2: + case BTL_SUBSTATE_PARTNER_MENU_FOCUS_3: + case BTL_SUBSTATE_PARTNER_MENU_FOCUS_4: + case BTL_SUBSTATE_PARTNER_MENU_FOCUS_5: + case BTL_SUBSTATE_PARTNER_MENU_FOCUS_6: + case BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_1: + case BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_2: btl_draw_menu_wheel(); break; - case BATTLE_SUB_STATE_PARTNER_STRATEGIES_3: + case BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_3: btl_draw_menu_wheel(); break; - case BATTLE_SUB_STATE_PARTNER_STRATEGIES_4: + case BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_4: btl_draw_menu_wheel(); break; - case BATTLE_SUB_STATE_PARTNER_STRATEGIES_5: + case BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_5: btl_draw_menu_wheel(); break; - case BATTLE_SUB_STATE_PARTNER_STRATEGIES_6: + case BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_6: btl_draw_menu_wheel(); break; } @@ -4417,22 +4417,22 @@ void btl_state_update_peach_menu(void) { s32 s0; switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_0: + case BTL_SUBSTATE_PEACH_MENU_UNK_0: btl_cam_use_preset(BTL_CAM_PRESET_C); btl_cam_move(10); if (!(gBattleStatus.flags1 & BS_FLAGS1_100000)) { - gBattleSubState = BATTLE_SUB_STATE_UNK_B; + gBattleSubState = BTL_SUBSTATE_PEACH_MENU_UNK_B; break; } player->state.currentPos.x = player->homePos.x; player->state.currentPos.z = player->homePos.z; - gBattleSubState = BATTLE_SUB_STATE_PLAYER_DEFEATED; + gBattleSubState = BTL_SUBSTATE_PEACH_MENU_UNK_A; player->state.goalPos.x = partner->homePos.x; player->state.goalPos.z = partner->homePos.z; player->state.moveTime = 4; player->state.angle = 0.0f; break; - case BATTLE_SUB_STATE_PLAYER_DEFEATED: + case BTL_SUBSTATE_PEACH_MENU_UNK_A: if (player->state.moveTime != 0) { player->currentPos.x += (player->state.goalPos.x - player->currentPos.x) / player->state.moveTime; player->currentPos.z += (player->state.goalPos.z - player->currentPos.z) / player->state.moveTime; @@ -4460,7 +4460,7 @@ void btl_state_update_peach_menu(void) { partner->homePos.x = partner->currentPos.x; partner->homePos.z = partner->currentPos.z; gBattleStatus.flags1 &= ~BS_FLAGS1_100000; - case BATTLE_SUB_STATE_UNK_B: + case BTL_SUBSTATE_PEACH_MENU_UNK_B: gBattleStatus.flags1 |= BS_FLAGS1_2; player->flags &= ~ACTOR_FLAG_4000000; player->flags |= ACTOR_FLAG_8000000; @@ -4495,9 +4495,9 @@ void btl_state_update_peach_menu(void) { func_802A1000(); D_802ACC60 = 8; - gBattleSubState = BATTLE_SUB_STATE_UNK_1; + gBattleSubState = BTL_SUBSTATE_PEACH_MENU_UNK_1; break; - case BATTLE_SUB_STATE_UNK_1: + case BTL_SUBSTATE_PEACH_MENU_UNK_1: set_animation(ACTOR_PLAYER, 0, ANIM_Peach_C0009); temp_s0_2 = func_802A11B0(); if (D_802ACC60 != 0) { @@ -4510,13 +4510,13 @@ void btl_state_update_peach_menu(void) { func_802A1030(); D_802ACC60 = 8; D_802ACC6C = 4; - gBattleSubState = BATTLE_SUB_STATE_UNK_2; + gBattleSubState = BTL_SUBSTATE_PEACH_MENU_UNK_2; } break; - case BATTLE_SUB_STATE_UNK_2: + case BTL_SUBSTATE_PEACH_MENU_UNK_2: if (func_802A11B0() != 0) { - battleStatus->unk_6C = 4; - battleStatus->unk_6E = 5; + battleStatus->unk_6C = BTL_SUBSTATE_PEACH_MENU_UNK_4; + battleStatus->unk_6E = BTL_SUBSTATE_PEACH_MENU_UNK_5; battleStatus->moveCategory = 8; battleStatus->selectedMoveID = MOVE_PEACH_FOCUS; battleStatus->selectedItemID = ITEM_FIRST_DEGREE_CARD; @@ -4524,25 +4524,25 @@ void btl_state_update_peach_menu(void) { btl_set_state(BATTLE_STATE_SELECT_TARGET); } break; - case BATTLE_SUB_STATE_UNK_4: + case BTL_SUBSTATE_PEACH_MENU_UNK_4: func_802A1050(); - gBattleSubState = BATTLE_SUB_STATE_UNK_1; + gBattleSubState = BTL_SUBSTATE_PEACH_MENU_UNK_1; btl_state_update_peach_menu(); btl_state_update_peach_menu(); break; - case BATTLE_SUB_STATE_BEGIN_LEVEL_UP: + case BTL_SUBSTATE_PEACH_MENU_UNK_5: func_802A10B8(); break; - case BATTLE_SUB_STATE_UNK_8: - btl_show_variable_battle_message(0x50, 60, 0); + case BTL_SUBSTATE_PEACH_MENU_UNK_8: + btl_show_variable_battle_message(BTL_MSG_50, 60, 0); D_802AD607 = 1; - gBattleSubState = BATTLE_SUB_STATE_UNK_9; + gBattleSubState = BTL_SUBSTATE_PEACH_MENU_UNK_9; break; - case BATTLE_SUB_STATE_UNK_9: + case BTL_SUBSTATE_PEACH_MENU_UNK_9: if (!btl_is_popup_displayed()) { D_802AD607 = 0; D_802ACC60 = 0; - gBattleSubState = BATTLE_SUB_STATE_UNK_1; + gBattleSubState = BTL_SUBSTATE_PEACH_MENU_UNK_1; } break; } @@ -4550,25 +4550,25 @@ void btl_state_update_peach_menu(void) { void btl_state_draw_peach_menu(void) { switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_1: + case BTL_SUBSTATE_PEACH_MENU_UNK_1: btl_draw_menu_wheel(); break; - case BATTLE_SUB_STATE_UNK_2: + case BTL_SUBSTATE_PEACH_MENU_UNK_2: btl_draw_menu_wheel(); break; - case BATTLE_SUB_STATE_UNK_3: + case BTL_SUBSTATE_PEACH_MENU_UNK_3: btl_draw_menu_wheel(); break; - case BATTLE_SUB_STATE_UNK_4: + case BTL_SUBSTATE_PEACH_MENU_UNK_4: btl_draw_menu_wheel(); break; - case BATTLE_SUB_STATE_BEGIN_LEVEL_UP: + case BTL_SUBSTATE_PEACH_MENU_UNK_5: btl_draw_menu_wheel(); break; - case BATTLE_SUB_STATE_LEVEL_UP_SHOW_HUD: - case BATTLE_SUB_STATE_UNK_7: - case BATTLE_SUB_STATE_UNK_8: - case BATTLE_SUB_STATE_UNK_9: + case BTL_SUBSTATE_PEACH_MENU_UNK_6: + case BTL_SUBSTATE_PEACH_MENU_UNK_7: + case BTL_SUBSTATE_PEACH_MENU_UNK_8: + case BTL_SUBSTATE_PEACH_MENU_UNK_9: break; } } @@ -4586,39 +4586,39 @@ void btl_state_update_twink_menu(void) { s32 s1; s32 temp_s0_2; s32 var_v0_2; - s32 cond; + s32 shouldSkipTurn; s32 z; s32 s0; switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_0: - cond = FALSE; + case BTL_SUBSTATE_TWINK_MENU_INIT: + shouldSkipTurn = FALSE; if (player->debuff == STATUS_SLEEP) { - cond = TRUE; + shouldSkipTurn = TRUE; } if (player->debuff == STATUS_FEAR) { - cond = TRUE; + shouldSkipTurn = TRUE; } if (player->debuff == STATUS_DIZZY) { - cond = TRUE; + shouldSkipTurn = TRUE; } if (player->debuff == STATUS_PARALYZE) { - cond = TRUE; + shouldSkipTurn = TRUE; } if (player->debuff == STATUS_FROZEN) { - cond = TRUE; + shouldSkipTurn = TRUE; } if (player->debuff == STATUS_STOP) { - cond = TRUE; + shouldSkipTurn = TRUE; } if (player->stoneStatus == STATUS_STONE) { - cond = TRUE; + shouldSkipTurn = TRUE; } if (player->koStatus == STATUS_DAZE) { - cond = TRUE; + shouldSkipTurn = TRUE; } - if (cond) { + if (shouldSkipTurn) { btl_set_state(BATTLE_STATE_END_PLAYER_TURN); break; } @@ -4630,14 +4630,14 @@ void btl_state_update_twink_menu(void) { player->state.currentPos.z = player->homePos.z; player->state.goalPos.x = partner->homePos.x; player->state.goalPos.z = partner->homePos.z; - gBattleSubState = BATTLE_SUB_STATE_PLAYER_DEFEATED; + gBattleSubState = BTL_SUBSTATE_TWINK_MENU_PERFORM_SWAP; player->state.moveTime = 4; player->state.angle = 0.0f; break; } - gBattleSubState = BATTLE_SUB_STATE_UNK_B; + gBattleSubState = BTL_SUBSTATE_TWINK_MENU_UNK_B; break; - case BATTLE_SUB_STATE_PLAYER_DEFEATED: + case BTL_SUBSTATE_TWINK_MENU_PERFORM_SWAP: if (player->state.moveTime != 0) { player->currentPos.x += (player->state.goalPos.x - player->currentPos.x) / player->state.moveTime; player->currentPos.z += (player->state.goalPos.z - player->currentPos.z) / player->state.moveTime; @@ -4662,7 +4662,7 @@ void btl_state_update_twink_menu(void) { partner->homePos.x = partner->currentPos.x; partner->homePos.z = partner->currentPos.z; gBattleStatus.flags1 |= BS_FLAGS1_100000; - case BATTLE_SUB_STATE_UNK_B: + case BTL_SUBSTATE_TWINK_MENU_UNK_B: gBattleStatus.flags1 |= BS_FLAGS1_2; player->flags &= ~ACTOR_FLAG_4000000; player->flags |= ACTOR_FLAG_8000000; @@ -4680,7 +4680,7 @@ void btl_state_update_twink_menu(void) { if (!(battleStatus->menuDisableFlags & 0x100)) { battle_menu_isEnabled[0] = FALSE; - battle_menu_isMessageDisabled[0] = 0x48; + battle_menu_isMessageDisabled[0] = BTL_MSG_48; main_battle_menu_JumpHudScripts[0] = battle_menu_TwinkStarPowerHudScripts[1]; } z = 0; @@ -4698,9 +4698,9 @@ void btl_state_update_twink_menu(void) { func_802A1000(); D_802ACC60 = 8; - gBattleSubState = BATTLE_SUB_STATE_UNK_1; + gBattleSubState = BTL_SUBSTATE_TWINK_MENU_UNK_1; break; - case BATTLE_SUB_STATE_UNK_1: + case BTL_SUBSTATE_TWINK_MENU_UNK_1: set_animation(ACTOR_PARTNER, 0, ANIM_Twink_Idle); temp_s0_2 = func_802A11B0(); if (D_802ACC60 != 0) { @@ -4713,13 +4713,13 @@ void btl_state_update_twink_menu(void) { func_802A1030(); D_802ACC60 = 8; D_802ACC6C = 4; - gBattleSubState = BATTLE_SUB_STATE_UNK_2; + gBattleSubState = BTL_SUBSTATE_TWINK_MENU_UNK_2; } break; - case BATTLE_SUB_STATE_UNK_2: + case BTL_SUBSTATE_TWINK_MENU_UNK_2: if (func_802A11B0() != 0) { - battleStatus->unk_6C = 4; - battleStatus->unk_6E = 5; + battleStatus->unk_6C = BTL_SUBSTATE_TWINK_MENU_UNK_4; + battleStatus->unk_6E = BTL_SUBSTATE_TWINK_MENU_UNK_5; battleStatus->moveCategory = 8; battleStatus->selectedMoveID = MOVE_TWINK_DASH; battleStatus->selectedItemID = ITEM_NONE; @@ -4727,25 +4727,25 @@ void btl_state_update_twink_menu(void) { btl_set_state(BATTLE_STATE_SELECT_TARGET); } break; - case BATTLE_SUB_STATE_UNK_4: + case BTL_SUBSTATE_TWINK_MENU_UNK_4: func_802A1050(); - gBattleSubState = BATTLE_SUB_STATE_UNK_1; + gBattleSubState = BTL_SUBSTATE_TWINK_MENU_UNK_1; btl_state_update_twink_menu(); btl_state_update_twink_menu(); break; - case BATTLE_SUB_STATE_BEGIN_LEVEL_UP: + case BTL_SUBSTATE_TWINK_MENU_UNK_5: func_802A10B8(); break; - case BATTLE_SUB_STATE_UNK_8: - btl_show_variable_battle_message(0x50, 60, 0); + case BTL_SUBSTATE_TWINK_MENU_SHOW_CANT_SWITCH: + btl_show_variable_battle_message(BTL_MSG_50, 60, 0); D_802AD607 = 1; - gBattleSubState = BATTLE_SUB_STATE_UNK_9; + gBattleSubState = BTL_SUBSTATE_TWINK_MENU_AWAIT_CANT_SWITCH_POPUP; break; - case BATTLE_SUB_STATE_UNK_9: + case BTL_SUBSTATE_TWINK_MENU_AWAIT_CANT_SWITCH_POPUP: if (!btl_is_popup_displayed()) { D_802AD607 = 0; D_802ACC60 = 0; - gBattleSubState = BATTLE_SUB_STATE_UNK_1; + gBattleSubState = BTL_SUBSTATE_TWINK_MENU_UNK_1; } break; } @@ -4753,25 +4753,25 @@ void btl_state_update_twink_menu(void) { void btl_state_draw_twink_menu(void) { switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_1: + case BTL_SUBSTATE_TWINK_MENU_UNK_1: btl_draw_menu_wheel(); break; - case BATTLE_SUB_STATE_UNK_2: + case BTL_SUBSTATE_TWINK_MENU_UNK_2: btl_draw_menu_wheel(); break; - case BATTLE_SUB_STATE_UNK_3: + case BTL_SUBSTATE_TWINK_MENU_UNK_3: btl_draw_menu_wheel(); break; - case BATTLE_SUB_STATE_UNK_4: + case BTL_SUBSTATE_TWINK_MENU_UNK_4: btl_draw_menu_wheel(); break; - case BATTLE_SUB_STATE_BEGIN_LEVEL_UP: + case BTL_SUBSTATE_TWINK_MENU_UNK_5: btl_draw_menu_wheel(); break; - case BATTLE_SUB_STATE_LEVEL_UP_SHOW_HUD: - case BATTLE_SUB_STATE_UNK_7: - case BATTLE_SUB_STATE_UNK_8: - case BATTLE_SUB_STATE_UNK_9: + case BTL_SUBSTATE_TWINK_MENU_UNK_6: + case BTL_SUBSTATE_TWINK_MENU_UNK_7: + case BTL_SUBSTATE_TWINK_MENU_SHOW_CANT_SWITCH: + case BTL_SUBSTATE_TWINK_MENU_AWAIT_CANT_SWITCH_POPUP: break; } } @@ -4797,7 +4797,7 @@ void btl_state_update_select_target(void) { actor->flags &= ~ACTOR_FLAG_8000000; targetIndexList = actor->targetIndexList; switch (gBattleSubState) { - case BATTLE_SUB_STATE_UNK_0: + case BTL_SUBSTATE_SELECT_TARGET_INIT: D_802ACC64 = 0xFF; D_802ACC68 = -100; gBattleStatus.flags1 &= ~BS_FLAGS1_2; @@ -4806,7 +4806,7 @@ void btl_state_update_select_target(void) { s8 actionTip = gMoveTable[battleStatus->selectedMoveID].actionTip; if (actionTip >= 0) { - btl_show_battle_message(actionTip + 0x2E, 60); + btl_show_battle_message(BTL_MSG_2E + actionTip, 60); } } } @@ -4826,7 +4826,7 @@ void btl_state_update_select_target(void) { if (battleStatus->currentTargetListFlags & 0x80000000) { if (!(gBattleStatus.flags1 & BS_FLAGS1_80000)) { gBattleSubState = battleStatus->unk_6E; - if (gBattleStatus.flags2 & BS_FLAGS2_40) { + if (gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) { btl_state_update_player_menu(); } else { btl_state_update_player_menu(); @@ -4834,7 +4834,7 @@ void btl_state_update_select_target(void) { btl_set_state(BATTLE_STATE_PLAYER_MOVE); } else { gBattleSubState = battleStatus->unk_6E; - if (gBattleStatus.flags2 & BS_FLAGS2_40) { + if (gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) { btl_state_update_twink_menu(); } else { btl_state_update_partner_menu(); @@ -4847,7 +4847,7 @@ void btl_state_update_select_target(void) { if (targetListLength == 0) { if (!(gBattleStatus.flags1 & BS_FLAGS1_80000)) { gBattleSubState = battleStatus->unk_6E; - if (gBattleStatus.flags2 & BS_FLAGS2_40) { + if (gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) { btl_state_update_player_menu(); } else { btl_state_update_player_menu(); @@ -4855,7 +4855,7 @@ void btl_state_update_select_target(void) { btl_set_state(BATTLE_STATE_PLAYER_MOVE); } else { gBattleSubState = battleStatus->unk_6E; - if (gBattleStatus.flags2 & BS_FLAGS2_40) { + if (gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) { btl_state_update_twink_menu(); } else { btl_state_update_partner_menu(); @@ -4871,9 +4871,9 @@ void btl_state_update_select_target(void) { hud_element_set_render_depth(id, 0); hud_element_set_render_pos(id, 0, -100); } - gBattleSubState = BATTLE_SUB_STATE_UNK_1; + gBattleSubState = BTL_SUBSTATE_SELECT_TARGET_CHOOSE; break; - case BATTLE_SUB_STATE_UNK_1: + case BTL_SUBSTATE_SELECT_TARGET_CHOOSE: if (D_802ACC68 < 0) { D_802ACC68 += 20; if (D_802ACC68 > 0) { @@ -4883,7 +4883,7 @@ void btl_state_update_select_target(void) { if (battleStatus->currentButtonsPressed & BUTTON_B) { sfx_play_sound(SOUND_MENU_BACK); - gBattleSubState = BATTLE_SUB_STATE_PLAYER_DEFEATED; + gBattleSubState = BTL_SUBSTATE_SELECT_TARGET_CANCEL; break; } @@ -4891,7 +4891,7 @@ void btl_state_update_select_target(void) { sfx_play_sound(SOUND_MENU_NEXT); D_802ACC60 = 8; D_802ACC6C = 4; - gBattleSubState = BATTLE_SUB_STATE_UNK_2; + gBattleSubState = BTL_SUBSTATE_SELECT_TARGET_DONE; break; } @@ -4933,7 +4933,7 @@ void btl_state_update_select_target(void) { actor->selectedTargetIndex = selectedTargetIndex; } break; - case BATTLE_SUB_STATE_UNK_2: + case BTL_SUBSTATE_SELECT_TARGET_DONE: gBattleStatus.flags1 &= ~BS_FLAGS1_2; target = &actor->targetData[targetIndexList[actor->selectedTargetIndex]]; actor->targetActorID = target->actorID; @@ -4944,7 +4944,7 @@ void btl_state_update_select_target(void) { if (!(gBattleStatus.flags1 & BS_FLAGS1_80000)) { gBattleSubState = battleStatus->unk_6E; - if (gBattleStatus.flags2 & BS_FLAGS2_40) { + if (gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) { btl_state_update_peach_menu(); } else { btl_state_update_player_menu(); @@ -4952,7 +4952,7 @@ void btl_state_update_select_target(void) { btl_set_state(BATTLE_STATE_PLAYER_MOVE); } else { gBattleSubState = battleStatus->unk_6E; - if (gBattleStatus.flags2 & BS_FLAGS2_40) { + if (gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) { btl_state_update_twink_menu(); } else { btl_state_update_partner_menu(); @@ -4960,7 +4960,7 @@ void btl_state_update_select_target(void) { btl_set_state(BATTLE_STATE_PARTNER_MOVE); } break; - case BATTLE_SUB_STATE_PLAYER_DEFEATED: + case BTL_SUBSTATE_SELECT_TARGET_CANCEL: for (i = 0; i < targetListLength; i++) { hud_element_free(D_802ACC70[i]); } @@ -4970,7 +4970,7 @@ void btl_state_update_select_target(void) { if (battleStatus->itemUsesLeft != 0) { btl_set_state(BATTLE_STATE_PLAYER_MENU); gBattleSubState = battleStatus->unk_6C; - if (gBattleStatus.flags2 & BS_FLAGS2_40) { + if (gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) { btl_state_update_peach_menu(); } else { btl_state_update_player_menu(); @@ -4978,7 +4978,7 @@ void btl_state_update_select_target(void) { } else if (!(gBattleStatus.flags1 & BS_FLAGS1_80000)) { btl_set_state(BATTLE_STATE_PLAYER_MENU); gBattleSubState = battleStatus->unk_6C; - if (gBattleStatus.flags2 & BS_FLAGS2_40) { + if (gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) { btl_state_update_peach_menu(); } else { btl_state_update_player_menu(); @@ -4986,7 +4986,7 @@ void btl_state_update_select_target(void) { } else { btl_set_state(BATTLE_STATE_PARTNER_MENU); gBattleSubState = battleStatus->unk_6C; - if (gBattleStatus.flags2 & BS_FLAGS2_40) { + if (gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) { btl_state_update_twink_menu(); } else { btl_state_update_partner_menu(); @@ -5088,14 +5088,14 @@ void btl_state_draw_select_target(void) { currentPartner = playerData->currentPartner; screenX = 52; screenY = 64; - if (gBattleStatus.flags2 & BS_FLAGS2_40) { + if (gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) { currentPartner = PARTNER_TWINK; } if ((battleStatus->currentTargetListFlags & 1) || targetListLength == 1) { actorID = target->actorID; if (actorID == ACTOR_PLAYER) { - msgWidth = get_msg_width(0x1D00C4, 0) + 10; + msgWidth = get_msg_width(MSG_Menus_00C4, 0) + 10; } else if (actorID == ACTOR_PARTNER) { msgWidth = get_msg_width(D_802AB738[currentPartner], 0) + 10; } else { @@ -5111,11 +5111,11 @@ void btl_state_draw_select_target(void) { target = &actor->targetData[targetIndexList[selectedTargetIndex]]; actorID = target->actorID; if (actorID == ACTOR_PLAYER) { - msgWidth = get_msg_width(0x1D00C4, 0) + 10; + msgWidth = get_msg_width(MSG_Menus_00C4, 0) + 10; } else if (actorID == ACTOR_PARTNER) { msgWidth = get_msg_width(D_802AB738[currentPartner], 0) + 10; } else { - msgWidth = get_msg_width(0x1D00C5, 0) + 10; + msgWidth = get_msg_width(MSG_Menus_00C5, 0) + 10; } } @@ -5127,7 +5127,7 @@ void btl_state_draw_select_target(void) { if ((battleStatus->currentTargetListFlags & 1) || targetListLength == 1) { actorID = target->actorID; if (actorID == ACTOR_PLAYER) { - draw_msg(0x1D00C4, screenX + D_802ACC68, screenY, 255, MSG_PAL_36, 0); + draw_msg(MSG_Menus_00C4, screenX + D_802ACC68, screenY, 255, MSG_PAL_36, 0); } else if (actorID == ACTOR_PARTNER) { draw_msg(D_802AB738[currentPartner], screenX + D_802ACC68, screenY, 255, MSG_PAL_36, 0); } else { diff --git a/src/80850_len_3060.c b/src/80850_len_3060.c index 5dfdca20ab..769c21ac90 100644 --- a/src/80850_len_3060.c +++ b/src/80850_len_3060.c @@ -51,7 +51,7 @@ void clear_player_data(void) { playerData->starPoints = 0; playerData->unk_11 = 0; playerData->unk_288 = 0; - playerData->merleeSpellType = 0; + playerData->merleeSpellType = MERLEE_SPELL_0; playerData->merleeCastsLeft = 0; playerData->merleeTurnCount = -1; playerData->maxStarPower = 0; diff --git a/src/actor_api.c b/src/actor_api.c index b93cd973e4..c9fd1462a9 100644 --- a/src/actor_api.c +++ b/src/actor_api.c @@ -2038,7 +2038,7 @@ ApiStatus SummonEnemy(Evt* script, s32 isInitialCall) { break; case 1: actor2 = script->functionTempPtr[1]; - if (does_script_exist(actor2->takeTurnID) == FALSE) { + if (does_script_exist(actor2->takeTurnScriptID) == FALSE) { enemyIDs = battleStatus->enemyIDs; if (battleStatus->nextEnemyIndex == 0) { numEnemies = 0; @@ -3232,7 +3232,7 @@ ApiStatus BoostAttack(Evt* script, s32 isInitialCall) { break; case 3: if (script->functionTemp[3] == 0) { - btl_show_variable_battle_message(0x1D, 60, attackBoost); + btl_show_variable_battle_message(BTL_MSG_1D, 60, attackBoost); script->functionTemp[0] = 4; } else { script->functionTemp[3]--; @@ -3251,7 +3251,7 @@ ApiStatus BoostAttack(Evt* script, s32 isInitialCall) { script->functionTemp[3]--; break; } - if ((actor->onHitScript == NULL) || !does_script_exist(actor->onHitID)) { + if ((actor->handleEventScript == NULL) || !does_script_exist(actor->handleEventScriptID)) { D_8029FBD4 = 0; return ApiStatus_DONE2; } @@ -3356,7 +3356,7 @@ ApiStatus BoostDefense(Evt* script, s32 isInitialCall) { break; case 3: if (script->functionTemp[3] == 0) { - btl_show_variable_battle_message(0x1E, 60, defenseBoost); + btl_show_variable_battle_message(BTL_MSG_1E, 60, defenseBoost); script->functionTemp[0] = 4; } else { script->functionTemp[3]--; @@ -3375,7 +3375,7 @@ ApiStatus BoostDefense(Evt* script, s32 isInitialCall) { script->functionTemp[3]--; break; } - if ((actor->onHitScript == NULL) || !does_script_exist(actor->onHitID)) { + if ((actor->handleEventScript == NULL) || !does_script_exist(actor->handleEventScriptID)) { D_8029FBD4 = 0; return ApiStatus_DONE2; } @@ -3462,7 +3462,7 @@ ApiStatus VanishActor(Evt* script, s32 isInitialCall) { break; case 3: if (script->functionTemp[3] == 0) { - btl_show_variable_battle_message(0x21, 60, vanished); + btl_show_variable_battle_message(BTL_MSG_21, 60, vanished); script->functionTemp[0] = 4; } else { script->functionTemp[3]--; @@ -3481,7 +3481,7 @@ ApiStatus VanishActor(Evt* script, s32 isInitialCall) { script->functionTemp[3]--; break; } - if ((actor->onHitScript == NULL) || !does_script_exist(actor->onHitID)) { + if ((actor->handleEventScript == NULL) || !does_script_exist(actor->handleEventScriptID)) { D_8029FBD4 = 0; return ApiStatus_DONE2; } @@ -3568,7 +3568,7 @@ ApiStatus ElectrifyActor(Evt* script, s32 isInitialCall) { break; case 3: if (script->functionTemp[3] == 0) { - btl_show_variable_battle_message(0x22, 60, electrified); + btl_show_variable_battle_message(BTL_MSG_22, 60, electrified); script->functionTemp[0] = 4; } else { script->functionTemp[3]--; @@ -3587,7 +3587,7 @@ ApiStatus ElectrifyActor(Evt* script, s32 isInitialCall) { script->functionTemp[3]--; break; } - if ((actor->onHitScript == NULL) || !does_script_exist(actor->onHitID)) { + if ((actor->handleEventScript == NULL) || !does_script_exist(actor->handleEventScriptID)) { D_8029FBD4 = 0; return ApiStatus_DONE2; } @@ -3711,7 +3711,7 @@ ApiStatus HealActor(Evt* script, s32 isInitialCall) { script->functionTemp[3]--; break; } - if ((actor->onHitScript == NULL) || !does_script_exist(actor->onHitID)) { + if ((actor->handleEventScript == NULL) || !does_script_exist(actor->handleEventScriptID)) { D_8029FBD4 = 0; return ApiStatus_DONE2; } diff --git a/src/battle/action_cmd/break_free.c b/src/battle/action_cmd/break_free.c index 6e0373cabb..4f015c2826 100644 --- a/src/battle/action_cmd/break_free.c +++ b/src/battle/action_cmd/break_free.c @@ -82,7 +82,7 @@ ApiStatus N(start)(Evt* script, s32 isInitialCall) { actionCommandStatus->barFillWidth = 0; battleStatus->actionSuccess = 0; - battleStatus->unk_86 = 0x7F; + battleStatus->unk_86 = 127; battleStatus->unk_82 = actionCommandStatus->mashMeterCutoffs[actionCommandStatus->mashMeterIntervals - 1]; actionCommandStatus->thresholdLevel = rand_int(actionCommandStatus->unk_5A); diff --git a/src/battle/area_arn/actor/hyper_cleft.c b/src/battle/area_arn/actor/hyper_cleft.c index e0e16dd812..a87f2bce4b 100644 --- a/src/battle/area_arn/actor/hyper_cleft.c +++ b/src/battle/area_arn/actor/hyper_cleft.c @@ -75,7 +75,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 4, .partCount = ARRAY_COUNT(N(partsTable_80220C14)), .partsData = N(partsTable_80220C14), - .script = &N(init_80220CAC), + .takeTurnScript = &N(init_80220CAC), .statusTable = N(statusTable_80220B68), .escapeChance = 70, .airLiftChance = 30, diff --git a/src/battle/area_arn/actor/hyper_paragoomba.c b/src/battle/area_arn/actor/hyper_paragoomba.c index a0b6811390..42b802deae 100644 --- a/src/battle/area_arn/actor/hyper_paragoomba.c +++ b/src/battle/area_arn/actor/hyper_paragoomba.c @@ -144,7 +144,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 7, .partCount = ARRAY_COUNT(N(partsTable_8021B460)), .partsData = N(partsTable_8021B460), - .script = &N(init_8021B564), + .takeTurnScript = &N(init_8021B564), .statusTable = N(statusTable_8021B3B4), .escapeChance = 50, .airLiftChance = 95, diff --git a/src/battle/area_arn/actor/hypergoomba.c b/src/battle/area_arn/actor/hypergoomba.c index 7713299bcb..2e2917210a 100644 --- a/src/battle/area_arn/actor/hypergoomba.c +++ b/src/battle/area_arn/actor/hypergoomba.c @@ -66,7 +66,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 7, .partCount = ARRAY_COUNT(N(partsTable_80218828)), .partsData = N(partsTable_80218828), - .script = &N(init_802188C0), + .takeTurnScript = &N(init_802188C0), .statusTable = N(statusTable_8021877C), .escapeChance = 60, .airLiftChance = 90, diff --git a/src/battle/area_arn/actor/tubba_blubba.c b/src/battle/area_arn/actor/tubba_blubba.c index ea039abb57..a06d700924 100644 --- a/src/battle/area_arn/actor/tubba_blubba.c +++ b/src/battle/area_arn/actor/tubba_blubba.c @@ -81,7 +81,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 10, .partCount = ARRAY_COUNT(N(partsTable_80225D4C)), .partsData = N(partsTable_80225D4C), - .script = &N(init_80225D98), + .takeTurnScript = &N(init_80225D98), .statusTable = N(statusTable_80225CA0), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_arn/actor/tubbas_heart.c b/src/battle/area_arn/actor/tubbas_heart.c index b2451bf55a..bee034404d 100644 --- a/src/battle/area_arn/actor/tubbas_heart.c +++ b/src/battle/area_arn/actor/tubbas_heart.c @@ -111,7 +111,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 50, .partCount = ARRAY_COUNT(N(partsTable_80223D30)), .partsData = N(partsTable_80223D30), - .script = &N(init_80223DA0), + .takeTurnScript = &N(init_80223DA0), .statusTable = N(statusTable_80223C84), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_dgb/actor/tubba_blubba.c b/src/battle/area_dgb/actor/tubba_blubba.c index c2f4611a8e..326d73bc36 100644 --- a/src/battle/area_dgb/actor/tubba_blubba.c +++ b/src/battle/area_dgb/actor/tubba_blubba.c @@ -82,7 +82,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 10, .partCount = ARRAY_COUNT(N(partsTable_80218D24)), .partsData = N(partsTable_80218D24), - .script = &N(init_80218D70), + .takeTurnScript = &N(init_80218D70), .statusTable = N(statusTable_80218C78), .escapeChance = 15, .airLiftChance = 0, diff --git a/src/battle/area_dig/actor/tubba_blubba.c b/src/battle/area_dig/actor/tubba_blubba.c index f12bfa1a9d..22930cb8d6 100644 --- a/src/battle/area_dig/actor/tubba_blubba.c +++ b/src/battle/area_dig/actor/tubba_blubba.c @@ -82,7 +82,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 10, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_flo/actor/amazy_dayzee.c b/src/battle/area_flo/actor/amazy_dayzee.c index ca6fadcb10..6fdb3d1b41 100644 --- a/src/battle/area_flo/actor/amazy_dayzee.c +++ b/src/battle/area_flo/actor/amazy_dayzee.c @@ -65,7 +65,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 20, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 90, .airLiftChance = 85, diff --git a/src/battle/area_flo/actor/crazee_dayzee.c b/src/battle/area_flo/actor/crazee_dayzee.c index 90a378f35a..831797adbc 100644 --- a/src/battle/area_flo/actor/crazee_dayzee.c +++ b/src/battle/area_flo/actor/crazee_dayzee.c @@ -65,7 +65,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 8, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 50, .airLiftChance = 85, diff --git a/src/battle/area_flo/actor/lakitu.c b/src/battle/area_flo/actor/lakitu.c index 7d6d929825..650876cefd 100644 --- a/src/battle/area_flo/actor/lakitu.c +++ b/src/battle/area_flo/actor/lakitu.c @@ -117,7 +117,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 12, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 40, .airLiftChance = 90, diff --git a/src/battle/area_flo/actor/ruff_puff.c b/src/battle/area_flo/actor/ruff_puff.c index 7153d208d7..195c014174 100644 --- a/src/battle/area_flo/actor/ruff_puff.c +++ b/src/battle/area_flo/actor/ruff_puff.c @@ -76,7 +76,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 10, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 50, .airLiftChance = 90, diff --git a/src/battle/area_flo2/actor/huff_n_puff.c b/src/battle/area_flo2/actor/huff_n_puff.c index 82a2491cf4..c3c01a1797 100644 --- a/src/battle/area_flo2/actor/huff_n_puff.c +++ b/src/battle/area_flo2/actor/huff_n_puff.c @@ -404,7 +404,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 60, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_flo2/actor/monty_mole_boss.c b/src/battle/area_flo2/actor/monty_mole_boss.c index 70640dcf08..fdeb72bfd6 100644 --- a/src/battle/area_flo2/actor/monty_mole_boss.c +++ b/src/battle/area_flo2/actor/monty_mole_boss.c @@ -94,7 +94,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 12, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 50, .airLiftChance = 55, @@ -170,7 +170,7 @@ ActorBlueprint N(hole) = { .maxHP = 5, .partCount = ARRAY_COUNT(N(parts_hole)), .partsData = N(parts_hole), - .script = &N(init_hole), + .takeTurnScript = &N(init_hole), .statusTable = NULL, .escapeChance = 80, .airLiftChance = 0, diff --git a/src/battle/area_flo2/actor/spike.c b/src/battle/area_flo2/actor/spike.c index 148607d9eb..bfc2fd625d 100644 --- a/src/battle/area_flo2/actor/spike.c +++ b/src/battle/area_flo2/actor/spike.c @@ -95,7 +95,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 50, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_flo2/actor/tuff_puff.c b/src/battle/area_flo2/actor/tuff_puff.c index c8cc6f476f..4cfac84854 100644 --- a/src/battle/area_flo2/actor/tuff_puff.c +++ b/src/battle/area_flo2/actor/tuff_puff.c @@ -120,7 +120,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 1, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_hos/actor/goombario_tutor.c b/src/battle/area_hos/actor/goombario_tutor.c index 30b2d4c740..62731ff515 100644 --- a/src/battle/area_hos/actor/goombario_tutor.c +++ b/src/battle/area_hos/actor/goombario_tutor.c @@ -74,7 +74,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 99, .partCount = ARRAY_COUNT(N(partsTable_80219114)), .partsData = N(partsTable_80219114), - .script = &N(init_80219160), + .takeTurnScript = &N(init_80219160), .statusTable = N(statusTable_80219068), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_hos/actor/magikoopa.c b/src/battle/area_hos/actor/magikoopa.c index 577e79c12c..60913c055f 100644 --- a/src/battle/area_hos/actor/magikoopa.c +++ b/src/battle/area_hos/actor/magikoopa.c @@ -136,7 +136,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 8, .partCount = ARRAY_COUNT(N(partsTable_8021D5F0)), .partsData = N(partsTable_8021D5F0), - .script = &N(init_8021E100), + .takeTurnScript = &N(init_8021E100), .statusTable = N(statusTable_8021D498), .escapeChance = 0, .airLiftChance = 0, @@ -161,7 +161,7 @@ ActorBlueprint N(flying) = { .maxHP = 8, .partCount = ARRAY_COUNT(N(partsTable_8021D614)), .partsData = N(partsTable_8021D614), - .script = &N(init_8021E2C0), + .takeTurnScript = &N(init_8021E2C0), .statusTable = N(statusTable_8021D544), .escapeChance = 0, .airLiftChance = 0, @@ -1304,7 +1304,7 @@ ActorBlueprint N(clone) = { .maxHP = 11, .partCount = ARRAY_COUNT(N(partsTable_80221624)), .partsData = N(partsTable_80221624), - .script = &N(init_8022143C), + .takeTurnScript = &N(init_8022143C), .statusTable = N(statusTable_802214CC), .escapeChance = 40, .airLiftChance = 0, @@ -1327,7 +1327,7 @@ ActorBlueprint N(flying_clone) = { .maxHP = 11, .partCount = ARRAY_COUNT(N(partsTable_80221648)), .partsData = N(partsTable_80221648), - .script = &N(init_80221478), + .takeTurnScript = &N(init_80221478), .statusTable = N(statusTable_80221578), .escapeChance = 40, .airLiftChance = 0, diff --git a/src/battle/area_isk_part_1/actor/pokey_mummy.c b/src/battle/area_isk_part_1/actor/pokey_mummy.c index d12a75ba15..3815185d8b 100644 --- a/src/battle/area_isk_part_1/actor/pokey_mummy.c +++ b/src/battle/area_isk_part_1/actor/pokey_mummy.c @@ -131,7 +131,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 4, .partCount = ARRAY_COUNT(N(partsTable_80218CC8)), .partsData = N(partsTable_80218CC8), - .script = &N(init_80218EC4), + .takeTurnScript = &N(init_80218EC4), .statusTable = N(statusTable_80218C1C), .escapeChance = 60, .airLiftChance = 90, diff --git a/src/battle/area_isk_part_1/actor/stone_chomp.c b/src/battle/area_isk_part_1/actor/stone_chomp.c index f2432d774b..7af23a1e7f 100644 --- a/src/battle/area_isk_part_1/actor/stone_chomp.c +++ b/src/battle/area_isk_part_1/actor/stone_chomp.c @@ -221,7 +221,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 4, .partCount = ARRAY_COUNT(N(partsTable_80221604)), .partsData = N(partsTable_80221604), - .script = &N(init_80221ABC), + .takeTurnScript = &N(init_80221ABC), .statusTable = N(statusTable_80221558), .escapeChance = 0, .airLiftChance = 25, diff --git a/src/battle/area_isk_part_2/actor/chain_chomp.c b/src/battle/area_isk_part_2/actor/chain_chomp.c index a3a366bbab..8f9ef1dff0 100644 --- a/src/battle/area_isk_part_2/actor/chain_chomp.c +++ b/src/battle/area_isk_part_2/actor/chain_chomp.c @@ -232,7 +232,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 4, .partCount = ARRAY_COUNT(N(partsTable_80218D34)), .partsData = N(partsTable_80218D34), - .script = &N(init_80218EC4), + .takeTurnScript = &N(init_80218EC4), .statusTable = N(statusTable_80218C88), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_isk_part_2/actor/tutankoopa.c b/src/battle/area_isk_part_2/actor/tutankoopa.c index 5983e90bbe..0ca12a1dde 100644 --- a/src/battle/area_isk_part_2/actor/tutankoopa.c +++ b/src/battle/area_isk_part_2/actor/tutankoopa.c @@ -204,7 +204,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 30, .partCount = ARRAY_COUNT(N(partsTable_8021BAD4)), .partsData = N(partsTable_8021BAD4), - .script = &N(init_8021BC1C), + .takeTurnScript = &N(init_8021BC1C), .statusTable = N(statusTable_8021BA28), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_iwa/actor/buzzar.c b/src/battle/area_iwa/actor/buzzar.c index 46e5879f46..be9f127792 100644 --- a/src/battle/area_iwa/actor/buzzar.c +++ b/src/battle/area_iwa/actor/buzzar.c @@ -141,7 +141,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 40, .partCount = ARRAY_COUNT(N(partsTable_8021B708)), .partsData = N(partsTable_8021B708), - .script = &N(init_8021B7E4), + .takeTurnScript = &N(init_8021B7E4), .statusTable = N(statusTable_8021B65C), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_iwa/actor/cleft.c b/src/battle/area_iwa/actor/cleft.c index 1839380500..1866972874 100644 --- a/src/battle/area_iwa/actor/cleft.c +++ b/src/battle/area_iwa/actor/cleft.c @@ -72,7 +72,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 2, .partCount = ARRAY_COUNT(N(partsTable_802187EC)), .partsData = N(partsTable_802187EC), - .script = &N(init_802188D0), + .takeTurnScript = &N(init_802188D0), .statusTable = N(statusTable_80218740), .escapeChance = 80, .airLiftChance = 40, diff --git a/src/battle/area_jan/actor/hurt_plant.c b/src/battle/area_jan/actor/hurt_plant.c index 4b4f7992b0..67e03de9e6 100644 --- a/src/battle/area_jan/actor/hurt_plant.c +++ b/src/battle/area_jan/actor/hurt_plant.c @@ -77,7 +77,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 8, .partCount = ARRAY_COUNT(N(partsTable_8021DA4C)), .partsData = N(partsTable_8021DA4C), - .script = &N(init_8021DA98), + .takeTurnScript = &N(init_8021DA98), .statusTable = N(statusTable_8021D9A0), .escapeChance = 70, .airLiftChance = 20, diff --git a/src/battle/area_jan/actor/jungle_fuzzy.c b/src/battle/area_jan/actor/jungle_fuzzy.c index 879c9b5b13..30256741cf 100644 --- a/src/battle/area_jan/actor/jungle_fuzzy.c +++ b/src/battle/area_jan/actor/jungle_fuzzy.c @@ -67,7 +67,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 7, .partCount = ARRAY_COUNT(N(partsTable_8021EA90)), .partsData = N(partsTable_8021EA90), - .script = &N(init_8021EB28), + .takeTurnScript = &N(init_8021EB28), .statusTable = N(statusTable_8021E9E4), .escapeChance = 30, .airLiftChance = 85, diff --git a/src/battle/area_jan/actor/m_bush.c b/src/battle/area_jan/actor/m_bush.c index eb133a9817..4eda160036 100644 --- a/src/battle/area_jan/actor/m_bush.c +++ b/src/battle/area_jan/actor/m_bush.c @@ -76,7 +76,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 8, .partCount = ARRAY_COUNT(N(partsTable_8022193C)), .partsData = N(partsTable_8022193C), - .script = &N(init_80221988), + .takeTurnScript = &N(init_80221988), .statusTable = N(statusTable_80221890), .escapeChance = 70, .airLiftChance = 85, diff --git a/src/battle/area_jan/actor/spear_guy.c b/src/battle/area_jan/actor/spear_guy.c index 4283cb2c02..0b9bc5cf93 100644 --- a/src/battle/area_jan/actor/spear_guy.c +++ b/src/battle/area_jan/actor/spear_guy.c @@ -178,7 +178,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 7, .partCount = ARRAY_COUNT(N(partsTable_802187F0)), .partsData = N(partsTable_802187F0), - .script = &N(init_80218980), + .takeTurnScript = &N(init_80218980), .statusTable = N(statusTable_80218698), .escapeChance = 50, .airLiftChance = 85, diff --git a/src/battle/area_kgr/actor/fuzzipede.c b/src/battle/area_kgr/actor/fuzzipede.c index bd6ac22e49..c080bfec59 100644 --- a/src/battle/area_kgr/actor/fuzzipede.c +++ b/src/battle/area_kgr/actor/fuzzipede.c @@ -106,7 +106,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 20, .partCount = ARRAY_COUNT(N(partsTable_80218B00)), .partsData = N(partsTable_80218B00), - .script = &N(init_80218B70), + .takeTurnScript = &N(init_80218B70), .statusTable = N(statusTable_80218A54), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_kkj/actor/kammy_koopa.c b/src/battle/area_kkj/actor/kammy_koopa.c index 82e30b7f00..a3645dc939 100644 --- a/src/battle/area_kkj/actor/kammy_koopa.c +++ b/src/battle/area_kkj/actor/kammy_koopa.c @@ -93,7 +93,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 10, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_kmr_part_2/actor/blue_goomba.c b/src/battle/area_kmr_part_2/actor/blue_goomba.c index 79b0ead2f4..e57580349b 100644 --- a/src/battle/area_kmr_part_2/actor/blue_goomba.c +++ b/src/battle/area_kmr_part_2/actor/blue_goomba.c @@ -65,7 +65,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 6, .partCount = ARRAY_COUNT(N(partsTable_80219968)), .partsData = N(partsTable_80219968), - .script = &N(init_8021B268), + .takeTurnScript = &N(init_8021B268), .statusTable = N(statusTable_802198BC), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_kmr_part_2/actor/blue_goomba2.c b/src/battle/area_kmr_part_2/actor/blue_goomba2.c index 37f228b96a..5597e99ffb 100644 --- a/src/battle/area_kmr_part_2/actor/blue_goomba2.c +++ b/src/battle/area_kmr_part_2/actor/blue_goomba2.c @@ -63,7 +63,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 6, .partCount = ARRAY_COUNT(N(partsTable_8021D4B8)), .partsData = N(partsTable_8021D4B8), - .script = &N(init_8021EDB8), + .takeTurnScript = &N(init_8021EDB8), .statusTable = N(statusTable_8021D40C), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_kmr_part_2/actor/goomba_king.c b/src/battle/area_kmr_part_2/actor/goomba_king.c index 31555fc08f..4c4a7e694e 100644 --- a/src/battle/area_kmr_part_2/actor/goomba_king.c +++ b/src/battle/area_kmr_part_2/actor/goomba_king.c @@ -128,7 +128,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 10, .partCount = ARRAY_COUNT(N(partsTable_802209C8)), .partsData = N(partsTable_802209C8), - .script = &N(init_80220A38), + .takeTurnScript = &N(init_80220A38), .statusTable = N(statusTable_8022091C), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_kmr_part_2/actor/goomnut_tree.c b/src/battle/area_kmr_part_2/actor/goomnut_tree.c index f48bf082f0..5bb746eeb2 100644 --- a/src/battle/area_kmr_part_2/actor/goomnut_tree.c +++ b/src/battle/area_kmr_part_2/actor/goomnut_tree.c @@ -118,7 +118,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 255, .partCount = ARRAY_COUNT(N(partsTable_8022339C)), .partsData = N(partsTable_8022339C), - .script = &N(init_80223488), + .takeTurnScript = &N(init_80223488), .statusTable = N(statusTable_802232F0), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_kmr_part_2/actor/red_goomba.c b/src/battle/area_kmr_part_2/actor/red_goomba.c index 0468dc53c0..cbf5f09bd1 100644 --- a/src/battle/area_kmr_part_2/actor/red_goomba.c +++ b/src/battle/area_kmr_part_2/actor/red_goomba.c @@ -65,7 +65,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 7, .partCount = ARRAY_COUNT(N(partsTable_8021B778)), .partsData = N(partsTable_8021B778), - .script = &N(init_8021D078), + .takeTurnScript = &N(init_8021D078), .statusTable = N(statusTable_8021B6CC), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_kmr_part_2/actor/red_goomba2.c b/src/battle/area_kmr_part_2/actor/red_goomba2.c index cb63e003b8..597e3a8e40 100644 --- a/src/battle/area_kmr_part_2/actor/red_goomba2.c +++ b/src/battle/area_kmr_part_2/actor/red_goomba2.c @@ -63,7 +63,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 7, .partCount = ARRAY_COUNT(N(partsTable_8021EEB8)), .partsData = N(partsTable_8021EEB8), - .script = &N(init_802207B8), + .takeTurnScript = &N(init_802207B8), .statusTable = N(statusTable_8021EE0C), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_kmr_part_3/actor/egg_jr_troopa.c b/src/battle/area_kmr_part_3/actor/egg_jr_troopa.c index 302ff9abbb..0eea0dde9e 100644 --- a/src/battle/area_kmr_part_3/actor/egg_jr_troopa.c +++ b/src/battle/area_kmr_part_3/actor/egg_jr_troopa.c @@ -88,7 +88,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 15, .partCount = ARRAY_COUNT(N(partsTable_802244C4)), .partsData = N(partsTable_802244C4), - .script = &N(init_80224A94), + .takeTurnScript = &N(init_80224A94), .statusTable = N(statusTable_80224418), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_kmr_part_3/actor/final_jr_troopa.c b/src/battle/area_kmr_part_3/actor/final_jr_troopa.c index 93a6330006..c59e19ec17 100644 --- a/src/battle/area_kmr_part_3/actor/final_jr_troopa.c +++ b/src/battle/area_kmr_part_3/actor/final_jr_troopa.c @@ -184,7 +184,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 60, .partCount = ARRAY_COUNT(N(partsTable_8022C640)), .partsData = N(partsTable_8022C640), - .script = &N(init_8022CF80), + .takeTurnScript = &N(init_8022CF80), .statusTable = N(statusTable_8022C43C), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_kmr_part_3/actor/jr_troopa.c b/src/battle/area_kmr_part_3/actor/jr_troopa.c index 3ae6c71f14..5d2a776d18 100644 --- a/src/battle/area_kmr_part_3/actor/jr_troopa.c +++ b/src/battle/area_kmr_part_3/actor/jr_troopa.c @@ -71,7 +71,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 5, .partCount = ARRAY_COUNT(N(partsTable_80222AE4)), .partsData = N(partsTable_80222AE4), - .script = &N(init_80223180), + .takeTurnScript = &N(init_80223180), .statusTable = N(statusTable_80222A38), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_kmr_part_3/actor/mage_jr_troopa.c b/src/battle/area_kmr_part_3/actor/mage_jr_troopa.c index c04b585941..f6bdbec069 100644 --- a/src/battle/area_kmr_part_3/actor/mage_jr_troopa.c +++ b/src/battle/area_kmr_part_3/actor/mage_jr_troopa.c @@ -115,7 +115,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 50, .partCount = ARRAY_COUNT(N(partsTable_8022A6E0)), .partsData = N(partsTable_8022A6E0), - .script = &N(init_8022ACE4), + .takeTurnScript = &N(init_8022ACE4), .statusTable = N(statusTable_8022A634), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_kmr_part_3/actor/para_jr_troopa.c b/src/battle/area_kmr_part_3/actor/para_jr_troopa.c index b83d8d68da..005c483740 100644 --- a/src/battle/area_kmr_part_3/actor/para_jr_troopa.c +++ b/src/battle/area_kmr_part_3/actor/para_jr_troopa.c @@ -101,7 +101,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 40, .partCount = ARRAY_COUNT(N(partsTable_80225F0C)), .partsData = N(partsTable_80225F0C), - .script = &N(init_80226510), + .takeTurnScript = &N(init_80226510), .statusTable = N(statusTable_80225E60), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_kmr_part_3/actor/paragoomba.c b/src/battle/area_kmr_part_3/actor/paragoomba.c index 723a39b01a..4a74d768e9 100644 --- a/src/battle/area_kmr_part_3/actor/paragoomba.c +++ b/src/battle/area_kmr_part_3/actor/paragoomba.c @@ -133,7 +133,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 2, .partCount = ARRAY_COUNT(N(partsTable)), .partsData = N(partsTable), - .script = &N(init_8021F450), + .takeTurnScript = &N(init_8021F450), .statusTable = N(statusTable_8021C274), .escapeChance = 90, .airLiftChance = 100, diff --git a/src/battle/area_kmr_part_3/actor/spiked_goomba.c b/src/battle/area_kmr_part_3/actor/spiked_goomba.c index a309a0e43b..5786528eff 100644 --- a/src/battle/area_kmr_part_3/actor/spiked_goomba.c +++ b/src/battle/area_kmr_part_3/actor/spiked_goomba.c @@ -63,7 +63,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 2, .partCount = ARRAY_COUNT(N(partsTable_8021A448)), .partsData = N(partsTable_8021A448), - .script = &N(init_8021BEBC), + .takeTurnScript = &N(init_8021BEBC), .statusTable = N(statusTable_8021A39C), .escapeChance = 90, .airLiftChance = 95, diff --git a/src/battle/area_kmr_part_3/actor/spiked_para_jr_troopa.c b/src/battle/area_kmr_part_3/actor/spiked_para_jr_troopa.c index adb3b38dbf..c3c8e918bc 100644 --- a/src/battle/area_kmr_part_3/actor/spiked_para_jr_troopa.c +++ b/src/battle/area_kmr_part_3/actor/spiked_para_jr_troopa.c @@ -95,7 +95,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 40, .partCount = ARRAY_COUNT(N(partsTable_80228014)), .partsData = N(partsTable_80228014), - .script = &N(init_80228618), + .takeTurnScript = &N(init_80228618), .statusTable = N(statusTable_80227F68), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_kpa/actor/bony_beetle.c b/src/battle/area_kpa/actor/bony_beetle.c index 3574659741..fd4c9ca44d 100644 --- a/src/battle/area_kpa/actor/bony_beetle.c +++ b/src/battle/area_kpa/actor/bony_beetle.c @@ -143,7 +143,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 8, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 50, .airLiftChance = 70, diff --git a/src/battle/area_kpa/actor/dry_bones.c b/src/battle/area_kpa/actor/dry_bones.c index 5ac9b29585..edc62e0bbe 100644 --- a/src/battle/area_kpa/actor/dry_bones.c +++ b/src/battle/area_kpa/actor/dry_bones.c @@ -134,7 +134,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 8, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 50, .airLiftChance = 75, diff --git a/src/battle/area_kpa2/actor/bowser.c b/src/battle/area_kpa2/actor/bowser.c index ee36fdbc53..8d1c22a15c 100644 --- a/src/battle/area_kpa2/actor/bowser.c +++ b/src/battle/area_kpa2/actor/bowser.c @@ -93,7 +93,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 50, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_kpa2/actor/bowser_intro.c b/src/battle/area_kpa2/actor/bowser_intro.c index 395a218467..0bee0078c8 100644 --- a/src/battle/area_kpa2/actor/bowser_intro.c +++ b/src/battle/area_kpa2/actor/bowser_intro.c @@ -125,7 +125,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 10, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, @@ -165,7 +165,7 @@ EvtScript N(init) = { EVT_CALL(BindNextTurn, ACTOR_SELF, EVT_PTR(N(nextTurn))) EVT_CALL(ModifyActorDecoration, ACTOR_SELF, 1, 1, 100, 0, 0, 0) EVT_EXEC(N(unkDecorationScript)) - EVT_CALL(SetBattleFlagBits, BS_FLAGS1_800000, 1) + EVT_CALL(SetBattleFlagBits, BS_FLAGS1_NO_GAME_OVER, 1) EVT_CALL(SetBattleFlagBits2, BS_FLAGS2_2000000, 1) EVT_RETURN EVT_END diff --git a/src/battle/area_kpa2/actor/bowser_phase_1.c b/src/battle/area_kpa2/actor/bowser_phase_1.c index 4acd043ab3..2dcf3e45d0 100644 --- a/src/battle/area_kpa2/actor/bowser_phase_1.c +++ b/src/battle/area_kpa2/actor/bowser_phase_1.c @@ -139,7 +139,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 50, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_kpa2/actor/bowser_phase_2.c b/src/battle/area_kpa2/actor/bowser_phase_2.c index 7ac4b7824f..35bd1738f9 100644 --- a/src/battle/area_kpa2/actor/bowser_phase_2.c +++ b/src/battle/area_kpa2/actor/bowser_phase_2.c @@ -137,7 +137,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 99, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_kpa2/actor/bowser_phase_3.c b/src/battle/area_kpa2/actor/bowser_phase_3.c index 102b241b62..b2ade783f9 100644 --- a/src/battle/area_kpa2/actor/bowser_phase_3.c +++ b/src/battle/area_kpa2/actor/bowser_phase_3.c @@ -140,7 +140,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 99, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_kpa3/actor/anti_guy.c b/src/battle/area_kpa3/actor/anti_guy.c index cbd1a93582..b6093f6d56 100644 --- a/src/battle/area_kpa3/actor/anti_guy.c +++ b/src/battle/area_kpa3/actor/anti_guy.c @@ -64,7 +64,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 50, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_kpa4/actor/bombshell_bill.c b/src/battle/area_kpa4/actor/bombshell_bill.c index 5c8ea60471..ddbd96c8dd 100644 --- a/src/battle/area_kpa4/actor/bombshell_bill.c +++ b/src/battle/area_kpa4/actor/bombshell_bill.c @@ -67,7 +67,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 3, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 40, .airLiftChance = 100, diff --git a/src/battle/area_kpa4/actor/bombshell_bill_blaster.c b/src/battle/area_kpa4/actor/bombshell_bill_blaster.c index 50b920141b..0fe4796a78 100644 --- a/src/battle/area_kpa4/actor/bombshell_bill_blaster.c +++ b/src/battle/area_kpa4/actor/bombshell_bill_blaster.c @@ -70,7 +70,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 10, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 15, diff --git a/src/battle/area_kzn/actor/lava_bubble.c b/src/battle/area_kzn/actor/lava_bubble.c index e3e75c6786..273f1cae5b 100644 --- a/src/battle/area_kzn/actor/lava_bubble.c +++ b/src/battle/area_kzn/actor/lava_bubble.c @@ -121,7 +121,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 9, .partCount = ARRAY_COUNT(N(partsTable_80218EE8)), .partsData = N(partsTable_80218EE8), - .script = &N(init_8021901C), + .takeTurnScript = &N(init_8021901C), .statusTable = N(statusTable_80218E3C), .escapeChance = 50, .airLiftChance = 90, diff --git a/src/battle/area_kzn2/actor/lava_bud.c b/src/battle/area_kzn2/actor/lava_bud.c index 7ced171fc4..3ba4fe98a2 100644 --- a/src/battle/area_kzn2/actor/lava_bud.c +++ b/src/battle/area_kzn2/actor/lava_bud.c @@ -147,7 +147,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 8, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_kzn2/actor/lava_piranha.c b/src/battle/area_kzn2/actor/lava_piranha.c index 02708dddec..671a8a2fd6 100644 --- a/src/battle/area_kzn2/actor/lava_piranha.c +++ b/src/battle/area_kzn2/actor/lava_piranha.c @@ -251,7 +251,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 40, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_kzn2/actor/petit_piranha.c b/src/battle/area_kzn2/actor/petit_piranha.c index 81651a5878..71c2883717 100644 --- a/src/battle/area_kzn2/actor/petit_piranha.c +++ b/src/battle/area_kzn2/actor/petit_piranha.c @@ -83,7 +83,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 1, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_kzn2/actor/petit_piranha_bomb.c b/src/battle/area_kzn2/actor/petit_piranha_bomb.c index 37ded5db61..410d8ffca8 100644 --- a/src/battle/area_kzn2/actor/petit_piranha_bomb.c +++ b/src/battle/area_kzn2/actor/petit_piranha_bomb.c @@ -81,7 +81,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 1, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_mac/actor/chan.c b/src/battle/area_mac/actor/chan.c index 5f18076746..b6c4777a46 100644 --- a/src/battle/area_mac/actor/chan.c +++ b/src/battle/area_mac/actor/chan.c @@ -68,7 +68,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 15, .partCount = ARRAY_COUNT(N(partsTable_80219E24)), .partsData = N(partsTable_80219E24), - .script = &N(init_8021CCDC), + .takeTurnScript = &N(init_8021CCDC), .statusTable = N(statusTable_80219D78), .escapeChance = 100, .airLiftChance = 0, @@ -833,7 +833,7 @@ EvtScript N(init_8021CCDC) = { EVT_CALL(SetActorVar, -127, 0, 0) EVT_CALL(SetActorVar, -127, 1, 0) EVT_CALL(SetActorVar, -127, 2, 0) - EVT_CALL(SetBattleFlagBits, BS_FLAGS1_800000, 1) + EVT_CALL(SetBattleFlagBits, BS_FLAGS1_NO_GAME_OVER, 1) EVT_RETURN EVT_END }; diff --git a/src/battle/area_mac/actor/lee.c b/src/battle/area_mac/actor/lee.c index 31d4d41e86..671da50d24 100644 --- a/src/battle/area_mac/actor/lee.c +++ b/src/battle/area_mac/actor/lee.c @@ -90,7 +90,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 20, .partCount = ARRAY_COUNT(N(partsTable_8021D47C)), .partsData = N(partsTable_8021D47C), - .script = &N(init_8021D4C8), + .takeTurnScript = &N(init_8021D4C8), .statusTable = N(statusTable_8021D3D0), .escapeChance = 100, .airLiftChance = 0, @@ -138,7 +138,7 @@ EvtScript N(init_8021D4C8) = { EVT_CALL(func_8026BF48, 0) EVT_END_THREAD EVT_CALL(func_802180D0_464560) - EVT_CALL(SetBattleFlagBits, BS_FLAGS1_800000, 1) + EVT_CALL(SetBattleFlagBits, BS_FLAGS1_NO_GAME_OVER, 1) EVT_RETURN EVT_END }; @@ -518,7 +518,7 @@ ActorBlueprint N(goombario) = { .maxHP = 20, .partCount = ARRAY_COUNT(N(partsTable_8021EA50)), .partsData = N(partsTable_8021EA50), - .script = &N(init_Goombario), + .takeTurnScript = &N(init_Goombario), .statusTable = N(statusTable_8021E9A4), .escapeChance = 100, .airLiftChance = 0, @@ -1153,7 +1153,7 @@ ActorBlueprint N(kooper) = { .maxHP = 20, .partCount = ARRAY_COUNT(N(partsTable_8022069C)), .partsData = N(partsTable_8022069C), - .script = &N(init_Kooper), + .takeTurnScript = &N(init_Kooper), .statusTable = N(statusTable_802205F0), .escapeChance = 100, .airLiftChance = 0, @@ -1665,7 +1665,7 @@ ActorBlueprint N(bombette) = { .maxHP = 20, .partCount = ARRAY_COUNT(N(partsTable_80222394)), .partsData = N(partsTable_80222394), - .script = &N(init_LeeBombette), + .takeTurnScript = &N(init_LeeBombette), .statusTable = N(statusTable_802222E8), .escapeChance = 100, .airLiftChance = 0, @@ -2031,7 +2031,7 @@ ActorBlueprint N(parakarry) = { .maxHP = 20, .partCount = ARRAY_COUNT(N(partsTable_8022348C)), .partsData = N(partsTable_8022348C), - .script = &N(init_Parakarry), + .takeTurnScript = &N(init_Parakarry), .statusTable = N(statusTable_802233E0), .escapeChance = 100, .airLiftChance = 0, @@ -2393,7 +2393,7 @@ ActorBlueprint N(bow) = { .maxHP = 20, .partCount = ARRAY_COUNT(N(partsTable_80224514)), .partsData = N(partsTable_80224514), - .script = &N(init_Bow), + .takeTurnScript = &N(init_Bow), .statusTable = N(statusTable_80224468), .escapeChance = 100, .airLiftChance = 0, @@ -2845,7 +2845,7 @@ ActorBlueprint N(watt) = { .maxHP = 20, .partCount = ARRAY_COUNT(N(partsTable_80225A80)), .partsData = N(partsTable_80225A80), - .script = &N(init_Watt), + .takeTurnScript = &N(init_Watt), .statusTable = N(statusTable_802259D4), .escapeChance = 100, .airLiftChance = 0, @@ -3311,7 +3311,7 @@ ActorBlueprint N(sushie) = { .maxHP = 20, .partCount = ARRAY_COUNT(N(partsTable_80226A80)), .partsData = N(partsTable_80226A80), - .script = &N(init_Sushie), + .takeTurnScript = &N(init_Sushie), .statusTable = N(statusTable_802269D4), .escapeChance = 100, .airLiftChance = 0, @@ -3803,7 +3803,7 @@ ActorBlueprint N(lakilester) = { .maxHP = 20, .partCount = ARRAY_COUNT(N(partsTable_8022851C)), .partsData = N(partsTable_8022851C), - .script = &N(init_Lakilester), + .takeTurnScript = &N(init_Lakilester), .statusTable = N(statusTable_80228470), .escapeChance = 100, .airLiftChance = 0, diff --git a/src/battle/area_mac/actor/master1.c b/src/battle/area_mac/actor/master1.c index a85ef2d074..d041e873a2 100644 --- a/src/battle/area_mac/actor/master1.c +++ b/src/battle/area_mac/actor/master1.c @@ -73,7 +73,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 50, .partCount = ARRAY_COUNT(N(partsTable_8022A364)), .partsData = N(partsTable_8022A364), - .script = &N(init_8022A3B0), + .takeTurnScript = &N(init_8022A3B0), .statusTable = N(statusTable_8022A2B8), .escapeChance = 100, .airLiftChance = 0, @@ -104,7 +104,7 @@ EvtScript N(init_8022A3B0) = { EVT_CALL(SetActorVar, -127, 2, 0) EVT_CALL(SetActorVar, -127, 3, 2) EVT_SET(GF_FoughtTheMaster, 1) - EVT_CALL(SetBattleFlagBits, BS_FLAGS1_800000, 1) + EVT_CALL(SetBattleFlagBits, BS_FLAGS1_NO_GAME_OVER, 1) EVT_RETURN EVT_END }; diff --git a/src/battle/area_mac/actor/master2.c b/src/battle/area_mac/actor/master2.c index 3234b9b0f8..a117c68bc8 100644 --- a/src/battle/area_mac/actor/master2.c +++ b/src/battle/area_mac/actor/master2.c @@ -86,7 +86,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 75, .partCount = ARRAY_COUNT(N(partsTable_8022B790)), .partsData = N(partsTable_8022B790), - .script = &N(init_8022B7DC), + .takeTurnScript = &N(init_8022B7DC), .statusTable = N(statusTable_8022B6E4), .escapeChance = 100, .airLiftChance = 0, @@ -116,7 +116,7 @@ EvtScript N(init_8022B7DC) = { EVT_CALL(SetActorVar, -127, 1, 0) EVT_CALL(SetActorVar, -127, 2, 0) EVT_CALL(SetActorVar, -127, 3, 2) - EVT_CALL(SetBattleFlagBits, BS_FLAGS1_800000, 1) + EVT_CALL(SetBattleFlagBits, BS_FLAGS1_NO_GAME_OVER, 1) EVT_RETURN EVT_END }; diff --git a/src/battle/area_mac/actor/master3.c b/src/battle/area_mac/actor/master3.c index 0cb33cf262..3cc386a662 100644 --- a/src/battle/area_mac/actor/master3.c +++ b/src/battle/area_mac/actor/master3.c @@ -98,7 +98,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 99, .partCount = ARRAY_COUNT(N(partsTable_8022DAF0)), .partsData = N(partsTable_8022DAF0), - .script = &N(init_8022DB60), + .takeTurnScript = &N(init_8022DB60), .statusTable = N(statusTable_8022DA44), .escapeChance = 100, .airLiftChance = 0, @@ -128,7 +128,7 @@ EvtScript N(init_8022DB60) = { EVT_CALL(SetActorVar, -127, 1, 0) EVT_CALL(SetActorVar, -127, 2, 0) EVT_CALL(SetActorVar, -127, 3, 2) - EVT_CALL(SetBattleFlagBits, BS_FLAGS1_800000, 1) + EVT_CALL(SetBattleFlagBits, BS_FLAGS1_NO_GAME_OVER, 1) EVT_RETURN EVT_END }; diff --git a/src/battle/area_mim/actor/forest_fuzzy.c b/src/battle/area_mim/actor/forest_fuzzy.c index 1db27969e1..73e9e30b04 100644 --- a/src/battle/area_mim/actor/forest_fuzzy.c +++ b/src/battle/area_mim/actor/forest_fuzzy.c @@ -65,7 +65,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 6, .partCount = ARRAY_COUNT(N(partsTable_80218478)), .partsData = N(partsTable_80218478), - .script = &N(init_80218510), + .takeTurnScript = &N(init_80218510), .statusTable = N(statusTable_802183CC), .escapeChance = 40, .airLiftChance = 90, diff --git a/src/battle/area_mim/actor/piranha_plant.c b/src/battle/area_mim/actor/piranha_plant.c index c471db85d8..30450d6619 100644 --- a/src/battle/area_mim/actor/piranha_plant.c +++ b/src/battle/area_mim/actor/piranha_plant.c @@ -86,7 +86,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 5, .partCount = ARRAY_COUNT(N(partsTable_8021D44C)), .partsData = N(partsTable_8021D44C), - .script = &N(init_8021D498), + .takeTurnScript = &N(init_8021D498), .statusTable = N(statusTable_8021D3A0), .escapeChance = 70, .airLiftChance = 20, diff --git a/src/battle/area_nok/actor/kent_c_koopa.c b/src/battle/area_nok/actor/kent_c_koopa.c index 7c248948de..aa03a92e81 100644 --- a/src/battle/area_nok/actor/kent_c_koopa.c +++ b/src/battle/area_nok/actor/kent_c_koopa.c @@ -198,7 +198,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 70, .partCount = ARRAY_COUNT(N(partsTable_80227AB4)), .partsData = N(partsTable_80227AB4), - .script = &N(init_80227C20), + .takeTurnScript = &N(init_80227C20), .statusTable = N(statusTable_80227A08), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_omo/actor/anti_guy.c b/src/battle/area_omo/actor/anti_guy.c index bfafef2f22..f333b6069d 100644 --- a/src/battle/area_omo/actor/anti_guy.c +++ b/src/battle/area_omo/actor/anti_guy.c @@ -64,7 +64,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 50, .partCount = ARRAY_COUNT(N(partsTable_802219C8)), .partsData = N(partsTable_802219C8), - .script = &N(init_80221A60), + .takeTurnScript = &N(init_80221A60), .statusTable = N(statusTable_8022191C), .escapeChance = 50, .airLiftChance = 0, diff --git a/src/battle/area_omo/actor/blue_shy_guy.c b/src/battle/area_omo/actor/blue_shy_guy.c index 1321364504..ba30ffb6a4 100644 --- a/src/battle/area_omo/actor/blue_shy_guy.c +++ b/src/battle/area_omo/actor/blue_shy_guy.c @@ -65,7 +65,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 7, .partCount = ARRAY_COUNT(N(partsTable_8021ADD0)), .partsData = N(partsTable_8021ADD0), - .script = &N(init_8021AE68), + .takeTurnScript = &N(init_8021AE68), .statusTable = N(statusTable_8021AD24), .escapeChance = 60, .airLiftChance = 85, diff --git a/src/battle/area_omo/actor/green_shy_guy.c b/src/battle/area_omo/actor/green_shy_guy.c index f0cdfcc1d4..521237f7a6 100644 --- a/src/battle/area_omo/actor/green_shy_guy.c +++ b/src/battle/area_omo/actor/green_shy_guy.c @@ -65,7 +65,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 7, .partCount = ARRAY_COUNT(N(partsTable_8021FED0)), .partsData = N(partsTable_8021FED0), - .script = &N(init_8021FF68), + .takeTurnScript = &N(init_8021FF68), .statusTable = N(statusTable_8021FE24), .escapeChance = 60, .airLiftChance = 85, diff --git a/src/battle/area_omo/actor/groove_guy.c b/src/battle/area_omo/actor/groove_guy.c index 7fcdbe6b22..c06321f621 100644 --- a/src/battle/area_omo/actor/groove_guy.c +++ b/src/battle/area_omo/actor/groove_guy.c @@ -89,7 +89,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 7, .partCount = ARRAY_COUNT(N(partsTable_80224AEC)), .partsData = N(partsTable_80224AEC), - .script = &N(init_80224B38), + .takeTurnScript = &N(init_80224B38), .statusTable = N(statusTable_80224A40), .escapeChance = 50, .airLiftChance = 85, diff --git a/src/battle/area_omo/actor/pink_shy_guy.c b/src/battle/area_omo/actor/pink_shy_guy.c index 8e5c4ce8f2..f27ed782ad 100644 --- a/src/battle/area_omo/actor/pink_shy_guy.c +++ b/src/battle/area_omo/actor/pink_shy_guy.c @@ -65,7 +65,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 7, .partCount = ARRAY_COUNT(N(partsTable_8021E3D0)), .partsData = N(partsTable_8021E3D0), - .script = &N(init_8021E468), + .takeTurnScript = &N(init_8021E468), .statusTable = N(statusTable_8021E324), .escapeChance = 60, .airLiftChance = 85, diff --git a/src/battle/area_omo/actor/pyro_guy.c b/src/battle/area_omo/actor/pyro_guy.c index b1f5ea1224..483e3cb87d 100644 --- a/src/battle/area_omo/actor/pyro_guy.c +++ b/src/battle/area_omo/actor/pyro_guy.c @@ -83,7 +83,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 7, .partCount = ARRAY_COUNT(N(partsTable_8022CC34)), .partsData = N(partsTable_8022CC34), - .script = &N(init_8022CC80), + .takeTurnScript = &N(init_8022CC80), .statusTable = N(statusTable_8022CB88), .escapeChance = 60, .airLiftChance = 85, diff --git a/src/battle/area_omo/actor/sky_guy.c b/src/battle/area_omo/actor/sky_guy.c index dc5e84f28d..920e05d6ee 100644 --- a/src/battle/area_omo/actor/sky_guy.c +++ b/src/battle/area_omo/actor/sky_guy.c @@ -223,7 +223,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 7, .partCount = ARRAY_COUNT(N(partsTable_8022977C)), .partsData = N(partsTable_8022977C), - .script = &N(init_8022987C), + .takeTurnScript = &N(init_8022987C), .statusTable = N(statusTable_80229624), .escapeChance = 50, .airLiftChance = 90, diff --git a/src/battle/area_omo/actor/spy_guy.c b/src/battle/area_omo/actor/spy_guy.c index 7020255282..f8fb4c94a6 100644 --- a/src/battle/area_omo/actor/spy_guy.c +++ b/src/battle/area_omo/actor/spy_guy.c @@ -109,7 +109,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 7, .partCount = ARRAY_COUNT(N(partsTable_80227564)), .partsData = N(partsTable_80227564), - .script = &N(init_802275D4), + .takeTurnScript = &N(init_802275D4), .statusTable = N(statusTable_802274B8), .escapeChance = 50, .airLiftChance = 85, diff --git a/src/battle/area_omo/actor/yellow_shy_guy.c b/src/battle/area_omo/actor/yellow_shy_guy.c index 926b07df43..16224759f8 100644 --- a/src/battle/area_omo/actor/yellow_shy_guy.c +++ b/src/battle/area_omo/actor/yellow_shy_guy.c @@ -65,7 +65,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 7, .partCount = ARRAY_COUNT(N(partsTable_8021C8D0)), .partsData = N(partsTable_8021C8D0), - .script = &N(init_8021C968), + .takeTurnScript = &N(init_8021C968), .statusTable = N(statusTable_8021C824), .escapeChance = 60, .airLiftChance = 85, diff --git a/src/battle/area_omo2/actor/general_guy.c b/src/battle/area_omo2/actor/general_guy.c index d4c1139364..51c9f74694 100644 --- a/src/battle/area_omo2/actor/general_guy.c +++ b/src/battle/area_omo2/actor/general_guy.c @@ -92,7 +92,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 10, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_omo2/actor/light_bulb.c b/src/battle/area_omo2/actor/light_bulb.c index 09c05039ec..23aa3c703a 100644 --- a/src/battle/area_omo2/actor/light_bulb.c +++ b/src/battle/area_omo2/actor/light_bulb.c @@ -83,7 +83,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 8, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_omo2/actor/toy_tank.c b/src/battle/area_omo2/actor/toy_tank.c index bb0c877ac7..b2fcbbb72f 100644 --- a/src/battle/area_omo2/actor/toy_tank.c +++ b/src/battle/area_omo2/actor/toy_tank.c @@ -145,7 +145,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 30, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_omo2_1/actor/shy_squad.c b/src/battle/area_omo2_1/actor/shy_squad.c index 22e994a580..013d94b5cd 100644 --- a/src/battle/area_omo2_1/actor/shy_squad.c +++ b/src/battle/area_omo2_1/actor/shy_squad.c @@ -295,7 +295,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 15, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_omo2_2/actor/stilt_guy.c b/src/battle/area_omo2_2/actor/stilt_guy.c index d5d794cc95..de50784d10 100644 --- a/src/battle/area_omo2_2/actor/stilt_guy.c +++ b/src/battle/area_omo2_2/actor/stilt_guy.c @@ -227,7 +227,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 7, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_omo2_3/actor/shy_stack.c b/src/battle/area_omo2_3/actor/shy_stack.c index ecb5b45851..438f7295b2 100644 --- a/src/battle/area_omo2_3/actor/shy_stack.c +++ b/src/battle/area_omo2_3/actor/shy_stack.c @@ -256,7 +256,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 10, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_omo2_4/actor/signal_guy.c b/src/battle/area_omo2_4/actor/signal_guy.c index bdb7da066b..6b04bfa159 100644 --- a/src/battle/area_omo2_4/actor/signal_guy.c +++ b/src/battle/area_omo2_4/actor/signal_guy.c @@ -66,7 +66,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 8, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_omo2_5/actor/shy_squad_dup.c b/src/battle/area_omo2_5/actor/shy_squad_dup.c index 0c2ebcfb14..1de531bcfa 100644 --- a/src/battle/area_omo2_5/actor/shy_squad_dup.c +++ b/src/battle/area_omo2_5/actor/shy_squad_dup.c @@ -271,7 +271,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 15, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_omo2_6/actor/shy_guy_dup.c b/src/battle/area_omo2_6/actor/shy_guy_dup.c index a8c6efcec1..b91c87254a 100644 --- a/src/battle/area_omo2_6/actor/shy_guy_dup.c +++ b/src/battle/area_omo2_6/actor/shy_guy_dup.c @@ -169,7 +169,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 10, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_omo3/actor/big_lantern_ghost.c b/src/battle/area_omo3/actor/big_lantern_ghost.c index 6fd9435fce..46edce10de 100644 --- a/src/battle/area_omo3/actor/big_lantern_ghost.c +++ b/src/battle/area_omo3/actor/big_lantern_ghost.c @@ -114,7 +114,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 40, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_pra/actor/albino_dino.c b/src/battle/area_pra/actor/albino_dino.c index a969f92cac..d3cfd23b5e 100644 --- a/src/battle/area_pra/actor/albino_dino.c +++ b/src/battle/area_pra/actor/albino_dino.c @@ -78,7 +78,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 8, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 40, .airLiftChance = 15, diff --git a/src/battle/area_pra2/actor/crystal_bit.c b/src/battle/area_pra2/actor/crystal_bit.c index 5e79c2088a..d9c72a01ac 100644 --- a/src/battle/area_pra2/actor/crystal_bit.c +++ b/src/battle/area_pra2/actor/crystal_bit.c @@ -153,7 +153,7 @@ ActorBlueprint N(1) = { .maxHP = 1, .partCount = ARRAY_COUNT(N(parts_1)), .partsData = N(parts_1), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, @@ -176,7 +176,7 @@ ActorBlueprint N(2) = { .maxHP = 1, .partCount = ARRAY_COUNT(N(parts_2)), .partsData = N(parts_2), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, @@ -199,7 +199,7 @@ ActorBlueprint N(3) = { .maxHP = 1, .partCount = ARRAY_COUNT(N(parts_3)), .partsData = N(parts_3), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_pra2/actor/crystal_king.c b/src/battle/area_pra2/actor/crystal_king.c index 74b28aaf78..a7af2ff570 100644 --- a/src/battle/area_pra2/actor/crystal_king.c +++ b/src/battle/area_pra2/actor/crystal_king.c @@ -119,7 +119,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 70, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, @@ -1198,7 +1198,7 @@ ActorBlueprint N(clone) = { .maxHP = 70, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(clone_init), + .takeTurnScript = &N(clone_init), .statusTable = N(clone_statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_sam/actor/frost_piranha.c b/src/battle/area_sam/actor/frost_piranha.c index 8adb451fb8..3a4cc85013 100644 --- a/src/battle/area_sam/actor/frost_piranha.c +++ b/src/battle/area_sam/actor/frost_piranha.c @@ -81,7 +81,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 10, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 70, .airLiftChance = 20, diff --git a/src/battle/area_sam/actor/gulpit.c b/src/battle/area_sam/actor/gulpit.c index 4801ce958f..d29ba1ad17 100644 --- a/src/battle/area_sam/actor/gulpit.c +++ b/src/battle/area_sam/actor/gulpit.c @@ -113,7 +113,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 12, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 60, .airLiftChance = 50, diff --git a/src/battle/area_sam/actor/gulpit_rocks.c b/src/battle/area_sam/actor/gulpit_rocks.c index f75f25fbd9..2bf3ce2bb5 100644 --- a/src/battle/area_sam/actor/gulpit_rocks.c +++ b/src/battle/area_sam/actor/gulpit_rocks.c @@ -74,7 +74,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 1, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 100, diff --git a/src/battle/area_sam2/actor/monstar.c b/src/battle/area_sam2/actor/monstar.c index 369dfb2a52..6c0502a695 100644 --- a/src/battle/area_sam2/actor/monstar.c +++ b/src/battle/area_sam2/actor/monstar.c @@ -87,7 +87,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 20, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_tik/actor/dark_koopa.c b/src/battle/area_tik/actor/dark_koopa.c index 165198daab..df66c41497 100644 --- a/src/battle/area_tik/actor/dark_koopa.c +++ b/src/battle/area_tik/actor/dark_koopa.c @@ -75,7 +75,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 8, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 60, .airLiftChance = 85, diff --git a/src/battle/area_tik/actor/dark_paratroopa.c b/src/battle/area_tik/actor/dark_paratroopa.c index ab71c378ec..8026287e8b 100644 --- a/src/battle/area_tik/actor/dark_paratroopa.c +++ b/src/battle/area_tik/actor/dark_paratroopa.c @@ -140,7 +140,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 8, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 50, .airLiftChance = 90, diff --git a/src/battle/area_tik/actor/gloomba.c b/src/battle/area_tik/actor/gloomba.c index 627ad2c8b7..9636012288 100644 --- a/src/battle/area_tik/actor/gloomba.c +++ b/src/battle/area_tik/actor/gloomba.c @@ -65,7 +65,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 7, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 70, .airLiftChance = 90, diff --git a/src/battle/area_tik/actor/paragloomba.c b/src/battle/area_tik/actor/paragloomba.c index 1c86cd0ecc..a527a2e33b 100644 --- a/src/battle/area_tik/actor/paragloomba.c +++ b/src/battle/area_tik/actor/paragloomba.c @@ -144,7 +144,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 7, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 65, .airLiftChance = 95, diff --git a/src/battle/area_tik/actor/spiked_gloomba.c b/src/battle/area_tik/actor/spiked_gloomba.c index 3e598bce49..388904615b 100644 --- a/src/battle/area_tik/actor/spiked_gloomba.c +++ b/src/battle/area_tik/actor/spiked_gloomba.c @@ -66,7 +66,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 7, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 65, .airLiftChance = 90, diff --git a/src/battle/area_tik2/actor/blooper.c b/src/battle/area_tik2/actor/blooper.c index b78f47169a..f95c604456 100644 --- a/src/battle/area_tik2/actor/blooper.c +++ b/src/battle/area_tik2/actor/blooper.c @@ -188,7 +188,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 30, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_tik2/actor/blooper_baby.c b/src/battle/area_tik2/actor/blooper_baby.c index c706c9cb10..96257b88f3 100644 --- a/src/battle/area_tik2/actor/blooper_baby.c +++ b/src/battle/area_tik2/actor/blooper_baby.c @@ -188,7 +188,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 6, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_tik2/actor/electro_blooper.c b/src/battle/area_tik2/actor/electro_blooper.c index 51407beeb7..8999295673 100644 --- a/src/battle/area_tik2/actor/electro_blooper.c +++ b/src/battle/area_tik2/actor/electro_blooper.c @@ -219,7 +219,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 50, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_tik2/actor/super_blooper.c b/src/battle/area_tik2/actor/super_blooper.c index 60545e2d1e..e2c657f59d 100644 --- a/src/battle/area_tik2/actor/super_blooper.c +++ b/src/battle/area_tik2/actor/super_blooper.c @@ -223,7 +223,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 70, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_trd_part_1/actor/bill_blaster.c b/src/battle/area_trd_part_1/actor/bill_blaster.c index b403027071..a3d539dace 100644 --- a/src/battle/area_trd_part_1/actor/bill_blaster.c +++ b/src/battle/area_trd_part_1/actor/bill_blaster.c @@ -75,7 +75,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 4, .partCount = ARRAY_COUNT(N(partsTable_80219DD8)), .partsData = N(partsTable_80219DD8), - .script = &N(init_80219E6C), + .takeTurnScript = &N(init_80219E6C), .statusTable = N(statusTable_80219D2C), .escapeChance = 0, .airLiftChance = 20, diff --git a/src/battle/area_trd_part_1/actor/bob_omb.c b/src/battle/area_trd_part_1/actor/bob_omb.c index f2a97e6e1c..eb8389e80f 100644 --- a/src/battle/area_trd_part_1/actor/bob_omb.c +++ b/src/battle/area_trd_part_1/actor/bob_omb.c @@ -111,7 +111,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 3, .partCount = ARRAY_COUNT(N(partsTable_8021A70C)), .partsData = N(partsTable_8021A70C), - .script = &N(init_8021A758), + .takeTurnScript = &N(init_8021A758), .statusTable = N(statusTable_8021A5B4), .escapeChance = 70, .airLiftChance = 90, diff --git a/src/battle/area_trd_part_1/actor/bullet_bill.c b/src/battle/area_trd_part_1/actor/bullet_bill.c index 4432df2699..1991b17e97 100644 --- a/src/battle/area_trd_part_1/actor/bullet_bill.c +++ b/src/battle/area_trd_part_1/actor/bullet_bill.c @@ -61,7 +61,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 2, .partCount = ARRAY_COUNT(N(partsTable_80219018)), .partsData = N(partsTable_80219018), - .script = &N(init_80219088), + .takeTurnScript = &N(init_80219088), .statusTable = N(statusTable_80218F6C), .escapeChance = 50, .airLiftChance = 100, diff --git a/src/battle/area_trd_part_2/actor/blue_ninja_koopa.c b/src/battle/area_trd_part_2/actor/blue_ninja_koopa.c index 9cc059b1f0..f2d0e96e99 100644 --- a/src/battle/area_trd_part_2/actor/blue_ninja_koopa.c +++ b/src/battle/area_trd_part_2/actor/blue_ninja_koopa.c @@ -70,7 +70,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 5, .partCount = ARRAY_COUNT(N(partsTable_8022B564)), .partsData = N(partsTable_8022B564), - .script = &N(init_8022DC2C), + .takeTurnScript = &N(init_8022DC2C), .statusTable = N(statusTable_8022B4B8), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_trd_part_2/actor/fake_bowser.c b/src/battle/area_trd_part_2/actor/fake_bowser.c index e37cffedca..09560c0c8e 100644 --- a/src/battle/area_trd_part_2/actor/fake_bowser.c +++ b/src/battle/area_trd_part_2/actor/fake_bowser.c @@ -214,7 +214,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 10, .partCount = ARRAY_COUNT(N(partsTable_8021A748)), .partsData = N(partsTable_8021A748), - .script = &N(init_8021A968), + .takeTurnScript = &N(init_8021A968), .statusTable = N(statusTable_8021A690), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_trd_part_2/actor/green_ninja_koopa.c b/src/battle/area_trd_part_2/actor/green_ninja_koopa.c index c453420e34..30a947a5c1 100644 --- a/src/battle/area_trd_part_2/actor/green_ninja_koopa.c +++ b/src/battle/area_trd_part_2/actor/green_ninja_koopa.c @@ -70,7 +70,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 5, .partCount = ARRAY_COUNT(N(partsTable_80225624)), .partsData = N(partsTable_80225624), - .script = &N(init_80227CEC), + .takeTurnScript = &N(init_80227CEC), .statusTable = N(statusTable_80225578), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_trd_part_2/actor/red_ninja_koopa.c b/src/battle/area_trd_part_2/actor/red_ninja_koopa.c index e1bbeb4cd7..e98cb162c0 100644 --- a/src/battle/area_trd_part_2/actor/red_ninja_koopa.c +++ b/src/battle/area_trd_part_2/actor/red_ninja_koopa.c @@ -70,7 +70,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 5, .partCount = ARRAY_COUNT(N(partsTable_802285C4)), .partsData = N(partsTable_802285C4), - .script = &N(init_8022AC8C), + .takeTurnScript = &N(init_8022AC8C), .statusTable = N(statusTable_80228518), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_trd_part_2/actor/yellow_ninja_koopa.c b/src/battle/area_trd_part_2/actor/yellow_ninja_koopa.c index 61724b41f1..f12de232ad 100644 --- a/src/battle/area_trd_part_2/actor/yellow_ninja_koopa.c +++ b/src/battle/area_trd_part_2/actor/yellow_ninja_koopa.c @@ -70,7 +70,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 5, .partCount = ARRAY_COUNT(N(partsTable_8022E504)), .partsData = N(partsTable_8022E504), - .script = &N(init_80230BCC), + .takeTurnScript = &N(init_80230BCC), .statusTable = N(statusTable_8022E458), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/area_trd_part_3/actor/eldstar.c b/src/battle/area_trd_part_3/actor/eldstar.c index 3264287df6..cabdd2392d 100644 --- a/src/battle/area_trd_part_3/actor/eldstar.c +++ b/src/battle/area_trd_part_3/actor/eldstar.c @@ -71,7 +71,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 99, .partCount = ARRAY_COUNT(N(partsTable_80218344)), .partsData = N(partsTable_80218344), - .script = &N(init_80218390), + .takeTurnScript = &N(init_80218390), .statusTable = N(statusTable_80218298), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/battle.c b/src/battle/battle.c index 63ef600d62..078506f82f 100644 --- a/src/battle/battle.c +++ b/src/battle/battle.c @@ -280,8 +280,8 @@ void reset_battle_status(void) { gGameStatusPtr->demoFlags = 0; gBattleState = BATTLE_STATE_0; D_800DC4E0 = 1; - gBattleSubState = BATTLE_SUB_STATE_UNK_0; - D_800DC4D0 = 0; + gBattleSubState = BTL_SUBSTATE_INIT; + D_800DC4D0 = BATTLE_STATE_0; D_800DC4F0 = 0; D_800DC4D4 = 0; D_800DC4FC = NULL; @@ -316,15 +316,15 @@ void load_battle_section(void) { } btl_set_state(BATTLE_STATE_NORMAL_START); - D_800DC4D0 = 0; + D_800DC4D0 = BATTLE_STATE_0; } void load_battle(s32 battleID) { gCurrentBattleID = battleID; set_game_mode(GAME_MODE_BATTLE); - gBattleState = 0; - D_800DC4D0 = 0; - gBattleSubState = 0; + gBattleState = BATTLE_STATE_0; + D_800DC4D0 = BATTLE_STATE_0; + gBattleSubState = BTL_SUBSTATE_INIT; } void set_battle_stage(s32 arg0) { @@ -379,7 +379,7 @@ void setup_demo_player(void) { } playerData->unk_288 = 0; - playerData->merleeSpellType = 0; + playerData->merleeSpellType = MERLEE_SPELL_0; playerData->merleeCastsLeft = 0; playerData->merleeTurnCount = 0; playerData->maxStarPower = 0; @@ -462,7 +462,7 @@ void load_demo_battle(u32 index) { battleID = BTL_DIG_FORMATION_00; } - gGameStatusPtr->debugEnemyContact = 0; + gGameStatusPtr->debugEnemyContact = DEBUG_CONTACT_NONE; gGameStatusPtr->unk_7C = 1; switch (mode) { diff --git a/src/battle/battle.h b/src/battle/battle.h index fcd5e0fd4e..0bf54c1c82 100644 --- a/src/battle/battle.h +++ b/src/battle/battle.h @@ -292,7 +292,7 @@ typedef struct ActorBlueprint { /* 0x08 */ s16 partCount; /* 0x0A */ char unk_0A[2]; /* 0x0C */ struct ActorPartBlueprint* partsData; - /* 0x10 */ EvtScript* script; + /* 0x10 */ EvtScript* takeTurnScript; /* 0x14 */ s32* statusTable; /* 0x18 */ u8 escapeChance; /* 0x19 */ u8 airLiftChance; diff --git a/src/battle/common/actor/bandit.inc.c b/src/battle/common/actor/bandit.inc.c index c7f5f1fcd4..1ee4a670fd 100644 --- a/src/battle/common/actor/bandit.inc.c +++ b/src/battle/common/actor/bandit.inc.c @@ -123,7 +123,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 5, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 40, .airLiftChance = 90, @@ -146,7 +146,7 @@ ActorBlueprint N(coin) = { .maxHP = 5, .partCount = ARRAY_COUNT(N(parts_coin)), .partsData = N(parts_coin), - .script = &N(init_coin), + .takeTurnScript = &N(init_coin), .statusTable = N(statusTable), .escapeChance = 40, .airLiftChance = 90, diff --git a/src/battle/common/actor/buzzy_beetle.inc.c b/src/battle/common/actor/buzzy_beetle.inc.c index 2656cbd697..16780afcd3 100644 --- a/src/battle/common/actor/buzzy_beetle.inc.c +++ b/src/battle/common/actor/buzzy_beetle.inc.c @@ -72,7 +72,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 3, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 60, .airLiftChance = 75, diff --git a/src/battle/common/actor/bzzap.inc.c b/src/battle/common/actor/bzzap.inc.c index 44431f8526..e5ff270605 100644 --- a/src/battle/common/actor/bzzap.inc.c +++ b/src/battle/common/actor/bzzap.inc.c @@ -139,7 +139,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 3, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 40, .airLiftChance = 95, diff --git a/src/battle/common/actor/clubba.inc.c b/src/battle/common/actor/clubba.inc.c index 4ec8635561..6d0051d6a7 100644 --- a/src/battle/common/actor/clubba.inc.c +++ b/src/battle/common/actor/clubba.inc.c @@ -74,7 +74,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 8, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 60, .airLiftChance = 60, diff --git a/src/battle/common/actor/duplighost.inc.c b/src/battle/common/actor/duplighost.inc.c index 4c7d87755f..b4a3e4f363 100644 --- a/src/battle/common/actor/duplighost.inc.c +++ b/src/battle/common/actor/duplighost.inc.c @@ -86,7 +86,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 15, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 50, .airLiftChance = 80, diff --git a/src/battle/common/actor/ember.inc.c b/src/battle/common/actor/ember.inc.c index d92c6fca8f..b60a00909f 100644 --- a/src/battle/common/actor/ember.inc.c +++ b/src/battle/common/actor/ember.inc.c @@ -116,7 +116,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 10, .partCount = ARRAY_COUNT(N(partsTable_8021AD80)), .partsData = N(partsTable_8021AD80), - .script = &N(init_8021AEB4), + .takeTurnScript = &N(init_8021AEB4), .statusTable = N(statusTable_8021ACD4), .escapeChance = 60, .airLiftChance = 80, diff --git a/src/battle/common/actor/fuzzy.inc.c b/src/battle/common/actor/fuzzy.inc.c index 259a1fb413..8ee4a6d774 100644 --- a/src/battle/common/actor/fuzzy.inc.c +++ b/src/battle/common/actor/fuzzy.inc.c @@ -60,7 +60,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 3, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 50, .airLiftChance = 95, diff --git a/src/battle/common/actor/ghost_bombette.inc.c b/src/battle/common/actor/ghost_bombette.inc.c index 60ef2e20c2..b9d479f594 100644 --- a/src/battle/common/actor/ghost_bombette.inc.c +++ b/src/battle/common/actor/ghost_bombette.inc.c @@ -71,7 +71,7 @@ ActorBlueprint N(bombette) = { .maxHP = 15, .partCount = ARRAY_COUNT(N(bombette_parts)), .partsData = N(bombette_parts), - .script = &N(bombette_init), + .takeTurnScript = &N(bombette_init), .statusTable = N(bombette_statusTable), .escapeChance = 50, .airLiftChance = 80, diff --git a/src/battle/common/actor/ghost_bow.inc.c b/src/battle/common/actor/ghost_bow.inc.c index a4b717e397..688991fd1f 100644 --- a/src/battle/common/actor/ghost_bow.inc.c +++ b/src/battle/common/actor/ghost_bow.inc.c @@ -84,7 +84,7 @@ ActorBlueprint N(bow) = { .maxHP = 15, .partCount = ARRAY_COUNT(N(bow_parts)), .partsData = N(bow_parts), - .script = &N(bow_init), + .takeTurnScript = &N(bow_init), .statusTable = N(bow_statusTable), .escapeChance = 50, .airLiftChance = 80, diff --git a/src/battle/common/actor/ghost_goombario.inc.c b/src/battle/common/actor/ghost_goombario.inc.c index 88d9683e15..1b410e159c 100644 --- a/src/battle/common/actor/ghost_goombario.inc.c +++ b/src/battle/common/actor/ghost_goombario.inc.c @@ -93,7 +93,7 @@ ActorBlueprint N(goombario) = { .maxHP = 15, .partCount = ARRAY_COUNT(N(goombario_parts)), .partsData = N(goombario_parts), - .script = &N(goombario_init), + .takeTurnScript = &N(goombario_init), .statusTable = N(goombario_statusTable), .escapeChance = 50, .airLiftChance = 80, diff --git a/src/battle/common/actor/ghost_kooper.inc.c b/src/battle/common/actor/ghost_kooper.inc.c index 008298a87c..008202c64a 100644 --- a/src/battle/common/actor/ghost_kooper.inc.c +++ b/src/battle/common/actor/ghost_kooper.inc.c @@ -89,7 +89,7 @@ ActorBlueprint N(kooper) = { .maxHP = 15, .partCount = ARRAY_COUNT(N(kooper_parts)), .partsData = N(kooper_parts), - .script = &N(kooper_init), + .takeTurnScript = &N(kooper_init), .statusTable = N(kooper_statusTable), .escapeChance = 50, .airLiftChance = 80, diff --git a/src/battle/common/actor/ghost_lakilester.inc.c b/src/battle/common/actor/ghost_lakilester.inc.c index 47047fbaf0..54736432c5 100644 --- a/src/battle/common/actor/ghost_lakilester.inc.c +++ b/src/battle/common/actor/ghost_lakilester.inc.c @@ -89,7 +89,7 @@ ActorBlueprint N(lakilester) = { .maxHP = 15, .partCount = ARRAY_COUNT(N(lakilester_parts)), .partsData = N(lakilester_parts), - .script = &N(lakilester_init), + .takeTurnScript = &N(lakilester_init), .statusTable = N(lakilester_statusTable), .escapeChance = 50, .airLiftChance = 80, diff --git a/src/battle/common/actor/ghost_parakarry.inc.c b/src/battle/common/actor/ghost_parakarry.inc.c index 0dfd53b2e7..c6b31b69c2 100644 --- a/src/battle/common/actor/ghost_parakarry.inc.c +++ b/src/battle/common/actor/ghost_parakarry.inc.c @@ -84,7 +84,7 @@ ActorBlueprint N(parakarry) = { .maxHP = 15, .partCount = ARRAY_COUNT(N(parakarry_parts)), .partsData = N(parakarry_parts), - .script = &N(parakarry_init), + .takeTurnScript = &N(parakarry_init), .statusTable = N(parakarry_statusTable), .escapeChance = 50, .airLiftChance = 80, diff --git a/src/battle/common/actor/ghost_sushie.inc.c b/src/battle/common/actor/ghost_sushie.inc.c index 1686b45d68..bee33a26c5 100644 --- a/src/battle/common/actor/ghost_sushie.inc.c +++ b/src/battle/common/actor/ghost_sushie.inc.c @@ -71,7 +71,7 @@ ActorBlueprint N(sushie) = { .maxHP = 15, .partCount = ARRAY_COUNT(N(sushie_parts)), .partsData = N(sushie_parts), - .script = &N(sushie_init), + .takeTurnScript = &N(sushie_init), .statusTable = N(sushie_statusTable), .escapeChance = 50, .airLiftChance = 80, diff --git a/src/battle/common/actor/ghost_watt.inc.c b/src/battle/common/actor/ghost_watt.inc.c index f22c5339fe..37bc28a20e 100644 --- a/src/battle/common/actor/ghost_watt.inc.c +++ b/src/battle/common/actor/ghost_watt.inc.c @@ -220,7 +220,7 @@ ActorBlueprint N(watt) = { .maxHP = 15, .partCount = ARRAY_COUNT(N(watt_parts)), .partsData = N(watt_parts), - .script = &N(watt_init), + .takeTurnScript = &N(watt_init), .statusTable = N(watt_statusTable), .escapeChance = 50, .airLiftChance = 80, diff --git a/src/battle/common/actor/goomba.inc.c b/src/battle/common/actor/goomba.inc.c index 48b5c0c4c4..ac6b1cdcb9 100644 --- a/src/battle/common/actor/goomba.inc.c +++ b/src/battle/common/actor/goomba.inc.c @@ -58,7 +58,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 2, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 90, .airLiftChance = 100, diff --git a/src/battle/common/actor/gray_magikoopa.inc.c b/src/battle/common/actor/gray_magikoopa.inc.c index 071a6abc28..784330991a 100644 --- a/src/battle/common/actor/gray_magikoopa.inc.c +++ b/src/battle/common/actor/gray_magikoopa.inc.c @@ -140,7 +140,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 11, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 40, .airLiftChance = 80, @@ -163,7 +163,7 @@ ActorBlueprint N(flying) = { .maxHP = 11, .partCount = ARRAY_COUNT(N(parts_flying)), .partsData = N(parts_flying), - .script = &N(init_flying), + .takeTurnScript = &N(init_flying), .statusTable = N(statusTable_flying), .escapeChance = 40, .airLiftChance = 95, diff --git a/src/battle/common/actor/green_magikoopa.inc.c b/src/battle/common/actor/green_magikoopa.inc.c index 3ee4721e93..069f38400a 100644 --- a/src/battle/common/actor/green_magikoopa.inc.c +++ b/src/battle/common/actor/green_magikoopa.inc.c @@ -142,7 +142,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 11, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 40, .airLiftChance = 80, @@ -165,7 +165,7 @@ ActorBlueprint N(flying) = { .maxHP = 11, .partCount = ARRAY_COUNT(N(parts_flying)), .partsData = N(parts_flying), - .script = &N(init_flying), + .takeTurnScript = &N(init_flying), .statusTable = N(statusTable_flying), .escapeChance = 40, .airLiftChance = 95, diff --git a/src/battle/common/actor/hammer_bro.inc.c b/src/battle/common/actor/hammer_bro.inc.c index 1196530d01..d205b53d35 100644 --- a/src/battle/common/actor/hammer_bro.inc.c +++ b/src/battle/common/actor/hammer_bro.inc.c @@ -144,7 +144,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 12, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 30, .airLiftChance = 75, diff --git a/src/battle/common/actor/koopa_troopa.inc.c b/src/battle/common/actor/koopa_troopa.inc.c index 51689c4ef3..9ca4db7413 100644 --- a/src/battle/common/actor/koopa_troopa.inc.c +++ b/src/battle/common/actor/koopa_troopa.inc.c @@ -68,7 +68,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 4, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 70, .airLiftChance = 90, diff --git a/src/battle/common/actor/koopatrol.inc.c b/src/battle/common/actor/koopatrol.inc.c index b682987f95..8f5d4f029b 100644 --- a/src/battle/common/actor/koopatrol.inc.c +++ b/src/battle/common/actor/koopatrol.inc.c @@ -163,7 +163,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 8, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 50, .airLiftChance = 75, diff --git a/src/battle/common/actor/magikoopa.inc.c b/src/battle/common/actor/magikoopa.inc.c index 0003c7252e..e69f17b2be 100644 --- a/src/battle/common/actor/magikoopa.inc.c +++ b/src/battle/common/actor/magikoopa.inc.c @@ -168,7 +168,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 11, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 40, .airLiftChance = 80, @@ -191,7 +191,7 @@ ActorBlueprint N(flying) = { .maxHP = 11, .partCount = ARRAY_COUNT(N(parts_flying)), .partsData = N(parts_flying), - .script = &N(init_flying), + .takeTurnScript = &N(init_flying), .statusTable = N(statusTable_flying), .escapeChance = 40, .airLiftChance = 85, @@ -1355,7 +1355,7 @@ ActorBlueprint N(clone) = { .maxHP = 11, .partCount = ARRAY_COUNT(N(parts_clone)), .partsData = N(parts_clone), - .script = &N(init_clone), + .takeTurnScript = &N(init_clone), .statusTable = N(statusTable_clone), .escapeChance = 40, .airLiftChance = 0, @@ -1378,7 +1378,7 @@ ActorBlueprint N(clone_flying) = { .maxHP = 11, .partCount = ARRAY_COUNT(N(parts_clone_flying)), .partsData = N(parts_clone_flying), - .script = &N(init_clone_flying), + .takeTurnScript = &N(init_clone_flying), .statusTable = N(statusTable_clone_flying), .escapeChance = 40, .airLiftChance = 0, diff --git a/src/battle/common/actor/medi_guy.inc.c b/src/battle/common/actor/medi_guy.inc.c index c263899fde..bd70a0c8d3 100644 --- a/src/battle/common/actor/medi_guy.inc.c +++ b/src/battle/common/actor/medi_guy.inc.c @@ -80,7 +80,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 7, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 60, .airLiftChance = 90, diff --git a/src/battle/common/actor/monty_mole.inc.c b/src/battle/common/actor/monty_mole.inc.c index 8ed4f81daa..b01cc02e43 100644 --- a/src/battle/common/actor/monty_mole.inc.c +++ b/src/battle/common/actor/monty_mole.inc.c @@ -86,7 +86,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 3, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 80, .airLiftChance = 70, @@ -162,7 +162,7 @@ ActorBlueprint N(hole) = { .maxHP = 5, .partCount = ARRAY_COUNT(N(parts_hole)), .partsData = N(parts_hole), - .script = &N(init_hole), + .takeTurnScript = &N(init_hole), .statusTable = NULL, .escapeChance = 80, .airLiftChance = 0, diff --git a/src/battle/common/actor/paragoomba.inc.c b/src/battle/common/actor/paragoomba.inc.c index da50f94f6b..e009bad915 100644 --- a/src/battle/common/actor/paragoomba.inc.c +++ b/src/battle/common/actor/paragoomba.inc.c @@ -129,7 +129,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 2, .partCount = ARRAY_COUNT(N(partsTable_8021B280)), .partsData = N(partsTable_8021B280), - .script = &N(init_8021B3E8), + .takeTurnScript = &N(init_8021B3E8), .statusTable = N(statusTable_8021B1D4), .escapeChance = 90, .airLiftChance = 100, diff --git a/src/battle/common/actor/paratroopa.inc.c b/src/battle/common/actor/paratroopa.inc.c index b4ce107727..63ba1b4775 100644 --- a/src/battle/common/actor/paratroopa.inc.c +++ b/src/battle/common/actor/paratroopa.inc.c @@ -126,7 +126,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 4, .partCount = ARRAY_COUNT(N(partsTable_8021EC6C)), .partsData = N(partsTable_8021EC6C), - .script = &N(init_8021EE0C), + .takeTurnScript = &N(init_8021EE0C), .statusTable = N(statusTable_8021EBC0), .escapeChance = 60, .airLiftChance = 95, diff --git a/src/battle/common/actor/pokey.inc.c b/src/battle/common/actor/pokey.inc.c index c4ed7cb773..c1f233d7c4 100644 --- a/src/battle/common/actor/pokey.inc.c +++ b/src/battle/common/actor/pokey.inc.c @@ -144,7 +144,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 4, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 70, .airLiftChance = 90, diff --git a/src/battle/common/actor/putrid_piranha.inc.c b/src/battle/common/actor/putrid_piranha.inc.c index e75ab5df70..6a7f64121e 100644 --- a/src/battle/common/actor/putrid_piranha.inc.c +++ b/src/battle/common/actor/putrid_piranha.inc.c @@ -77,7 +77,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 12, .partCount = ARRAY_COUNT(N(partsTable_8021B1AC)), .partsData = N(partsTable_8021B1AC), - .script = &N(init_8021B1F8), + .takeTurnScript = &N(init_8021B1F8), .statusTable = N(statusTable_8021B100), .escapeChance = 60, .airLiftChance = 20, diff --git a/src/battle/common/actor/red_magikoopa.inc.c b/src/battle/common/actor/red_magikoopa.inc.c index 01f3e6c9a0..0b32f8247c 100644 --- a/src/battle/common/actor/red_magikoopa.inc.c +++ b/src/battle/common/actor/red_magikoopa.inc.c @@ -140,7 +140,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 11, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 40, .airLiftChance = 80, @@ -163,7 +163,7 @@ ActorBlueprint N(flying) = { .maxHP = 11, .partCount = ARRAY_COUNT(N(parts_flying)), .partsData = N(parts_flying), - .script = &N(init_flying), + .takeTurnScript = &N(init_flying), .statusTable = N(statusTable_flying), .escapeChance = 40, .airLiftChance = 95, diff --git a/src/battle/common/actor/red_shy_guy.inc.c b/src/battle/common/actor/red_shy_guy.inc.c index 9d4575fb04..f256a74ff1 100644 --- a/src/battle/common/actor/red_shy_guy.inc.c +++ b/src/battle/common/actor/red_shy_guy.inc.c @@ -63,7 +63,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 7, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 60, .airLiftChance = 85, diff --git a/src/battle/common/actor/slot_machine.inc.c b/src/battle/common/actor/slot_machine.inc.c index 0e630a52a9..f016d95cef 100644 --- a/src/battle/common/actor/slot_machine.inc.c +++ b/src/battle/common/actor/slot_machine.inc.c @@ -65,7 +65,7 @@ ActorBlueprint N(slot_machine_stop) = { .maxHP = 99, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, @@ -88,7 +88,7 @@ ActorBlueprint N(slot_machine_start) = { .maxHP = 99, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/common/actor/spike_top.inc.c b/src/battle/common/actor/spike_top.inc.c index cba35cf69f..580e08583e 100644 --- a/src/battle/common/actor/spike_top.inc.c +++ b/src/battle/common/actor/spike_top.inc.c @@ -71,7 +71,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 4, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 60, .airLiftChance = 70, diff --git a/src/battle/common/actor/spiked_goomba.inc.c b/src/battle/common/actor/spiked_goomba.inc.c index bcbd23bf44..59e7416193 100644 --- a/src/battle/common/actor/spiked_goomba.inc.c +++ b/src/battle/common/actor/spiked_goomba.inc.c @@ -59,7 +59,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 2, .partCount = ARRAY_COUNT(N(partsTable_8021E468)), .partsData = N(partsTable_8021E468), - .script = &N(init_8021E54C), + .takeTurnScript = &N(init_8021E54C), .statusTable = N(statusTable_8021E3BC), .escapeChance = 90, .airLiftChance = 95, diff --git a/src/battle/common/actor/spiny.inc.c b/src/battle/common/actor/spiny.inc.c index 4c4ec14ddf..dbabb8a5a0 100644 --- a/src/battle/common/actor/spiny.inc.c +++ b/src/battle/common/actor/spiny.inc.c @@ -112,7 +112,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 5, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 60, .airLiftChance = 75, diff --git a/src/battle/common/actor/swooper.inc.c b/src/battle/common/actor/swooper.inc.c index fd28dd01d6..418c25b7c5 100644 --- a/src/battle/common/actor/swooper.inc.c +++ b/src/battle/common/actor/swooper.inc.c @@ -62,7 +62,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 4, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 50, .airLiftChance = 100, diff --git a/src/battle/common/actor/swoopula.inc.c b/src/battle/common/actor/swoopula.inc.c index 3f5570d7ff..a3a9cb2f90 100644 --- a/src/battle/common/actor/swoopula.inc.c +++ b/src/battle/common/actor/swoopula.inc.c @@ -65,7 +65,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 8, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 30, .airLiftChance = 95, diff --git a/src/battle/common/actor/whacka.inc.c b/src/battle/common/actor/whacka.inc.c index 28570c6275..bd4f81fcf5 100644 --- a/src/battle/common/actor/whacka.inc.c +++ b/src/battle/common/actor/whacka.inc.c @@ -75,7 +75,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 99, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/common/actor/white_clubba.inc.c b/src/battle/common/actor/white_clubba.inc.c index 49407482b9..ab333070d9 100644 --- a/src/battle/common/actor/white_clubba.inc.c +++ b/src/battle/common/actor/white_clubba.inc.c @@ -76,7 +76,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 12, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 50, .airLiftChance = 50, diff --git a/src/battle/common/actor/white_magikoopa.inc.c b/src/battle/common/actor/white_magikoopa.inc.c index c0babd81b3..1524eb47fe 100644 --- a/src/battle/common/actor/white_magikoopa.inc.c +++ b/src/battle/common/actor/white_magikoopa.inc.c @@ -135,7 +135,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 11, .partCount = ARRAY_COUNT(N(partsTable_80223C90)), .partsData = N(partsTable_80223C90), - .script = &N(init_80225F58), + .takeTurnScript = &N(init_80225F58), .statusTable = N(statusTable_80223B38), .escapeChance = 40, .airLiftChance = 80, @@ -158,7 +158,7 @@ ActorBlueprint N(flying) = { .maxHP = 11, .partCount = ARRAY_COUNT(N(partsTable_80223CB4)), .partsData = N(partsTable_80223CB4), - .script = &N(init_80225FBC), + .takeTurnScript = &N(init_80225FBC), .statusTable = N(statusTable_80223BE4), .escapeChance = 40, .airLiftChance = 95, diff --git a/src/battle/common/actor/yellow_magikoopa.inc.c b/src/battle/common/actor/yellow_magikoopa.inc.c index e64bab8472..649d709f08 100644 --- a/src/battle/common/actor/yellow_magikoopa.inc.c +++ b/src/battle/common/actor/yellow_magikoopa.inc.c @@ -139,7 +139,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 11, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 40, .airLiftChance = 80, @@ -162,7 +162,7 @@ ActorBlueprint N(flying) = { .maxHP = 11, .partCount = ARRAY_COUNT(N(parts_flying)), .partsData = N(parts_flying), - .script = &N(init_flying), + .takeTurnScript = &N(init_flying), .statusTable = N(statusTable_flying), .escapeChance = 40, .airLiftChance = 95, diff --git a/src/battle/item/food.c b/src/battle/item/food.c index d578a1232b..12fdf9acdf 100644 --- a/src/battle/item/food.c +++ b/src/battle/item/food.c @@ -34,11 +34,11 @@ ApiStatus N(func_802A12EC_7333BC)(Evt* script, s32 isInitialCall) { partner->koDuration = 0; } if (partner->koDuration > 0) { - partner->disableEffect->data.disableX->unk_3C = partner->koDuration; + partner->disableEffect->data.disableX->koDuration = partner->koDuration; } else { partner->koStatus = 0; dispatch_event_partner(EVENT_RECOVER_PARTNER); - partner->disableEffect->data.disableX->unk_3C = 0; + partner->disableEffect->data.disableX->koDuration = 0; } return ApiStatus_DONE2; diff --git a/src/battle/item/life_shroom.c b/src/battle/item/life_shroom.c index 100fa80803..a7ec3d18fa 100644 --- a/src/battle/item/life_shroom.c +++ b/src/battle/item/life_shroom.c @@ -34,11 +34,11 @@ ApiStatus N(func_802A12EC_72E81C)(Evt* script, s32 isInitialCall) { partner->koDuration = 0; } if (partner->koDuration > 0) { - partner->disableEffect->data.disableX->unk_3C = partner->koDuration; + partner->disableEffect->data.disableX->koDuration = partner->koDuration; } else { partner->koStatus = 0; dispatch_event_partner(EVENT_RECOVER_PARTNER); - partner->disableEffect->data.disableX->unk_3C = 0; + partner->disableEffect->data.disableX->koDuration = 0; } return ApiStatus_DONE2; diff --git a/src/battle/item/mushroom.c b/src/battle/item/mushroom.c index 187ce7bd51..7445d5585c 100644 --- a/src/battle/item/mushroom.c +++ b/src/battle/item/mushroom.c @@ -34,11 +34,11 @@ ApiStatus N(func_802A12EC_715B3C)(Evt* script, s32 isInitialCall) { partner->koDuration = 0; } if (partner->koDuration > 0) { - partner->disableEffect->data.disableX->unk_3C = partner->koDuration; + partner->disableEffect->data.disableX->koDuration = partner->koDuration; } else { partner->koStatus = 0; dispatch_event_partner(EVENT_RECOVER_PARTNER); - partner->disableEffect->data.disableX->unk_3C = 0; + partner->disableEffect->data.disableX->koDuration = 0; } return ApiStatus_DONE2; diff --git a/src/battle/item/stone_cap.c b/src/battle/item/stone_cap.c index a7ac0aa1d9..1fb579ad4b 100644 --- a/src/battle/item/stone_cap.c +++ b/src/battle/item/stone_cap.c @@ -31,7 +31,7 @@ ApiStatus N(func_802A123C_7217DC)(Evt* script, s32 isInitialCall) { if (script->functionTemp[1] == 0) { BattleStatus* battleStatus2 = &gBattleStatus; - battleStatus2->flags1 &= ~BS_FLAGS1_HUSTLE_DRINK_ON; + battleStatus2->flags1 &= ~BS_FLAGS1_HUSTLED; battleStatus->hustleTurns = 0; battleStatus->itemUsesLeft = 0; diff --git a/src/battle/item/super_soda.c b/src/battle/item/super_soda.c index afeed4ee0e..78b4e048d6 100644 --- a/src/battle/item/super_soda.c +++ b/src/battle/item/super_soda.c @@ -34,11 +34,11 @@ ApiStatus N(func_802A12EC_724FCC)(Evt* script, s32 isInitialCall) { partner->koDuration = 0; } if (partner->koDuration > 0) { - partner->disableEffect->data.disableX->unk_3C = partner->koDuration; + partner->disableEffect->data.disableX->koDuration = partner->koDuration; } else { partner->koStatus = 0; dispatch_event_partner(EVENT_RECOVER_PARTNER); - partner->disableEffect->data.disableX->unk_3C = 0; + partner->disableEffect->data.disableX->koDuration = 0; } return ApiStatus_DONE2; @@ -67,7 +67,7 @@ ApiStatus N(func_802A1378_725058)(Evt* script, s32 isInitialCall) { break; } - actor->disableEffect->data.disableX->unk_3C = 0; + actor->disableEffect->data.disableX->koDuration = 0; } btl_update_ko_status(); diff --git a/src/battle/item/tasty_tonic.c b/src/battle/item/tasty_tonic.c index cf789024c8..779c889082 100644 --- a/src/battle/item/tasty_tonic.c +++ b/src/battle/item/tasty_tonic.c @@ -24,7 +24,7 @@ ApiStatus N(func_802A123C_72223C)(Evt* script, s32 isInitialCall) { case ACTOR_CLASS_PARTNER: dispatch_event_partner(EVENT_RECOVER_STATUS); } - actor->disableEffect->data.disableX->unk_3C = 0; + actor->disableEffect->data.disableX->koDuration = 0; } return ApiStatus_DONE2; diff --git a/src/battle/move/hammer_charge_0/74F130.c b/src/battle/move/hammer_charge_0/74F130.c index a31ea223ea..2112e4f377 100644 --- a/src/battle/move/hammer_charge_0/74F130.c +++ b/src/battle/move/hammer_charge_0/74F130.c @@ -24,8 +24,8 @@ ApiStatus func_802A10C8_74F1F8(Evt* script, s32 isInitialCall) { } battleStatus->jumpCharge = 0; - battleStatus->flags1 |= BS_FLAGS1_10000000; - battleStatus->flags1 &= ~BS_FLAGS1_20000000; + battleStatus->flags1 |= BS_FLAGS1_HAMMER_CHARGED; + battleStatus->flags1 &= ~BS_FLAGS1_JUMP_CHARGED; return ApiStatus_DONE2; } diff --git a/src/battle/move/hammer_charge_1/7595B0.c b/src/battle/move/hammer_charge_1/7595B0.c index 8dbd49e7fe..e6177431d1 100644 --- a/src/battle/move/hammer_charge_1/7595B0.c +++ b/src/battle/move/hammer_charge_1/7595B0.c @@ -33,8 +33,8 @@ ApiStatus func_802A10C8_759678(Evt* script, s32 isInitialCall) { } battleStatus->jumpCharge = 0; - battleStatus->flags1 |= BS_FLAGS1_10000000; - battleStatus->flags1 &= ~BS_FLAGS1_20000000; + battleStatus->flags1 |= BS_FLAGS1_HAMMER_CHARGED; + battleStatus->flags1 &= ~BS_FLAGS1_JUMP_CHARGED; return ApiStatus_DONE2; } diff --git a/src/battle/move/hammer_charge_2/75E5D0.c b/src/battle/move/hammer_charge_2/75E5D0.c index 6b1a1d513a..4244b90e22 100644 --- a/src/battle/move/hammer_charge_2/75E5D0.c +++ b/src/battle/move/hammer_charge_2/75E5D0.c @@ -33,8 +33,8 @@ ApiStatus func_802A10C8_75E698(Evt* script, s32 isInitialCall) { } battleStatus->jumpCharge = 0; - battleStatus->flags1 |= BS_FLAGS1_10000000; - battleStatus->flags1 &= ~BS_FLAGS1_20000000; + battleStatus->flags1 |= BS_FLAGS1_HAMMER_CHARGED; + battleStatus->flags1 &= ~BS_FLAGS1_JUMP_CHARGED; return ApiStatus_DONE2; } diff --git a/src/battle/move/jump_charge_0/74D570.c b/src/battle/move/jump_charge_0/74D570.c index 7f080cb1fd..348bbe585a 100644 --- a/src/battle/move/jump_charge_0/74D570.c +++ b/src/battle/move/jump_charge_0/74D570.c @@ -23,8 +23,8 @@ ApiStatus func_802A1108_74D678(Evt* script, s32 isInitialCall) { } battleStatus->hammerCharge = 0; - battleStatus->flags1 |= BS_FLAGS1_20000000; - battleStatus->flags1 &= ~BS_FLAGS1_10000000; + battleStatus->flags1 |= BS_FLAGS1_JUMP_CHARGED; + battleStatus->flags1 &= ~BS_FLAGS1_HAMMER_CHARGED; return ApiStatus_DONE2; } diff --git a/src/battle/move/jump_charge_1/75C980.c b/src/battle/move/jump_charge_1/75C980.c index 4546e61b5f..69d0d0a400 100644 --- a/src/battle/move/jump_charge_1/75C980.c +++ b/src/battle/move/jump_charge_1/75C980.c @@ -31,8 +31,8 @@ ApiStatus func_802A1108_75CA88(Evt* script, s32 isInitialCall) { } battleStatus->hammerCharge = 0; - battleStatus->flags1 |= BS_FLAGS1_20000000; - battleStatus->flags1 &= ~BS_FLAGS1_10000000; + battleStatus->flags1 |= BS_FLAGS1_JUMP_CHARGED; + battleStatus->flags1 &= ~BS_FLAGS1_HAMMER_CHARGED; return ApiStatus_DONE2; } diff --git a/src/battle/move/jump_charge_2/761920.c b/src/battle/move/jump_charge_2/761920.c index d8d45b9153..c281597c7c 100644 --- a/src/battle/move/jump_charge_2/761920.c +++ b/src/battle/move/jump_charge_2/761920.c @@ -31,8 +31,8 @@ ApiStatus func_802A1108_761A28(Evt* script, s32 isInitialCall) { } battleStatus->hammerCharge = 0; - battleStatus->flags1 |= BS_FLAGS1_20000000; - battleStatus->flags1 &= ~BS_FLAGS1_10000000; + battleStatus->flags1 |= BS_FLAGS1_JUMP_CHARGED; + battleStatus->flags1 &= ~BS_FLAGS1_HAMMER_CHARGED; return ApiStatus_DONE2; } diff --git a/src/battle/partner/bombette.c b/src/battle/partner/bombette.c index f29d6a4f96..c52db007c1 100644 --- a/src/battle/partner/bombette.c +++ b/src/battle/partner/bombette.c @@ -313,7 +313,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 99, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/partner/bow.c b/src/battle/partner/bow.c index 51da752434..bf54fd2af5 100644 --- a/src/battle/partner/bow.c +++ b/src/battle/partner/bow.c @@ -54,7 +54,7 @@ ApiStatus N(ApplyOuttaSight)(Evt* script, s32 isInitialCall) { playerActorPartTable->idleAnimations = bMarioHideAnims; gBattleStatus.hustleTurns = 0; - gBattleStatus.flags1 &= ~BS_FLAGS1_HUSTLE_DRINK_ON; + gBattleStatus.flags1 &= ~BS_FLAGS1_HUSTLED; return ApiStatus_DONE2; } @@ -208,7 +208,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 99, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/partner/goombario.c b/src/battle/partner/goombario.c index d6618bfd4d..f96d65a057 100644 --- a/src/battle/partner/goombario.c +++ b/src/battle/partner/goombario.c @@ -540,7 +540,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 99, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/partner/goompa.c b/src/battle/partner/goompa.c index 89cfaa8ac3..3ea7efa370 100644 --- a/src/battle/partner/goompa.c +++ b/src/battle/partner/goompa.c @@ -64,7 +64,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 99, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .spinSmashReq = 4, .powerBounceChance = 80, diff --git a/src/battle/partner/kooper.c b/src/battle/partner/kooper.c index 72e634660e..857005b1d7 100644 --- a/src/battle/partner/kooper.c +++ b/src/battle/partner/kooper.c @@ -240,7 +240,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 99, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/partner/lakilester.c b/src/battle/partner/lakilester.c index 2f72615b65..365a664e4c 100644 --- a/src/battle/partner/lakilester.c +++ b/src/battle/partner/lakilester.c @@ -165,7 +165,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 99, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/partner/parakarry.c b/src/battle/partner/parakarry.c index 565444e6bc..9554a47fd3 100644 --- a/src/battle/partner/parakarry.c +++ b/src/battle/partner/parakarry.c @@ -673,7 +673,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 99, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/partner/sushie.c b/src/battle/partner/sushie.c index 4f9ebf17ca..5b350f43dd 100644 --- a/src/battle/partner/sushie.c +++ b/src/battle/partner/sushie.c @@ -447,7 +447,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 99, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/partner/twink.c b/src/battle/partner/twink.c index 2ebcbf6dbb..b000469821 100644 --- a/src/battle/partner/twink.c +++ b/src/battle/partner/twink.c @@ -18,7 +18,7 @@ extern EvtScript N(runAwayFail); ApiStatus func_80238000_714CF0(Evt* script, s32 isInitialCall) { BattleStatus* battleStatus = &gBattleStatus; - if (battleStatus->flags2 & BS_FLAGS2_40) { + if (battleStatus->flags2 & BS_FLAGS2_PEACH_BATTLE) { script->varTable[0] = 1; } else { script->varTable[0] = 0; @@ -86,7 +86,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 99, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/partner/watt.c b/src/battle/partner/watt.c index 1f50ba3cf2..5c926e22e2 100644 --- a/src/battle/partner/watt.c +++ b/src/battle/partner/watt.c @@ -504,7 +504,7 @@ ActorBlueprint NAMESPACE = { .maxHP = 99, .partCount = ARRAY_COUNT(N(parts)), .partsData = N(parts), - .script = &N(init), + .takeTurnScript = &N(init), .statusTable = N(statusTable), .escapeChance = 0, .airLiftChance = 0, diff --git a/src/battle/star/refresh/78B600.c b/src/battle/star/refresh/78B600.c index 8cc09a4601..d9f55e7242 100644 --- a/src/battle/star/refresh/78B600.c +++ b/src/battle/star/refresh/78B600.c @@ -86,7 +86,7 @@ ApiStatus func_802A17D4_78BDD4(Evt* script, s32 isInitialCall) { if (actor->koStatus != 0) { actor->koDuration = 0; actor->koStatus = 0; - actor->disableEffect->data.disableX->unk_3C = 0; + actor->disableEffect->data.disableX->koDuration = 0; } btl_update_ko_status(); diff --git a/src/effects/disable_x.c b/src/effects/disable_x.c index 596ab5c7d8..37bc4574bb 100644 --- a/src/effects/disable_x.c +++ b/src/effects/disable_x.c @@ -57,10 +57,10 @@ EffectInstance* disable_x_main(s32 type, f32 x, f32 y, f32 z, s32 arg4) { data->scale = 1.0f; if (type == 1) { data->unk_38 = type; - data->unk_3C = 0; + data->koDuration = 0; } else { data->unk_38 = 0; - data->unk_3C = arg4; + data->koDuration = arg4; } data->pos.x = x; @@ -135,14 +135,14 @@ void disable_x_update(EffectInstance* effect) { unk_2C = data->unk_2C; unk_38 = data->unk_38; unk_34 = data->scale; - unk_3C = data->unk_3C; + unk_3C = data->koDuration; if (type == 0) { if (data->unk_44 > 0) { data->unk_44--; } else { - if (data->unk_3C != unk_38) { - if (data->unk_3C < 0) { + if (data->koDuration != unk_38) { + if (data->koDuration < 0) { unk_3C = 0; } if (unk_38 < unk_3C) { diff --git a/src/encounter.c b/src/encounter.c index ce8aa9aff6..da7f4f6537 100644 --- a/src/encounter.c +++ b/src/encounter.c @@ -650,7 +650,7 @@ void update_encounters_neutral(void) { } if (currentEncounter->battleTriggerCooldown != 0 || - gGameStatusPtr->debugEnemyContact == 1 || + gGameStatusPtr->debugEnemyContact == DEBUG_CONTACT_CANT_TOUCH || (playerStatus->flags & PS_FLAGS_ARMS_RAISED) || (gOverrideFlags & GLOBAL_OVERRIDES_40) || gPartnerActionStatus.actingPartner == PARTNER_BOW || @@ -1285,7 +1285,7 @@ void update_encounters_pre_battle(void) { return; } - if (gGameStatusPtr->debugEnemyContact == 2) { + if (gGameStatusPtr->debugEnemyContact == DEBUG_CONTACT_DIE_ON_TOUCH) { currentEncounter->unk_94 = 0; currentEncounter->battleStartCountdown = 10; partner_handle_before_battle(); diff --git a/src/fio.c b/src/fio.c index bbb3aeca3f..dac155862d 100644 --- a/src/fio.c +++ b/src/fio.c @@ -218,7 +218,7 @@ void fio_deserialize_state(void) { } - gGameStatusPtr->debugEnemyContact = 0; + gGameStatusPtr->debugEnemyContact = DEBUG_CONTACT_NONE; gGameStatusPtr->unk_76 = 0; gGameStatusPtr->unk_77 = 0; gGameStatusPtr->musicEnabled = TRUE; diff --git a/src/level_up.c b/src/level_up.c index b236523ebd..1281d4ff50 100644 --- a/src/level_up.c +++ b/src/level_up.c @@ -307,7 +307,7 @@ Gfx D_802A7A88_7A59C8[] = { #include "level_up/select_one_to_upgrade.png.inc.c" #include "level_up/select_one_to_upgrade.pal.inc.c" -EntityModelScript level_up_model_script = STANDARD_ENTITY_MODEL_SCRIPT(D_802A7A88_7A59C8, RENDER_MODE_2D); +EntityModelScript EMS_level_up = STANDARD_ENTITY_MODEL_SCRIPT(D_802A7A88_7A59C8, RENDER_MODE_2D); HudScript HES_level_up_heart = HES_TEMPLATE_CI_ENUM_SIZE(level_up_heart, 40, 40); HudScript HES_level_up_heart_copy = HES_TEMPLATE_CI_ENUM_SIZE(level_up_heart, 40, 40); diff --git a/src/move_script.c b/src/move_script.c index d549ea1fb4..5d509efe3e 100644 --- a/src/move_script.c +++ b/src/move_script.c @@ -116,7 +116,7 @@ ApiStatus LoadMoveScript(Evt* script, s32 isInitialCall) { deduct_current_move_fp(); - if (gBattleStatus.flags2 & BS_FLAGS2_8000000) { + if (gBattleStatus.flags2 & BS_FLAGS2_HAS_RUSH) { enable_player_blur(); } diff --git a/src/msg.c b/src/msg.c index 4d02d0e3c3..9685f9aa4c 100644 --- a/src/msg.c +++ b/src/msg.c @@ -283,7 +283,7 @@ s32 _update_message(MessagePrintState* printer) { s32 buttons; s16 endPosDist; s16 lineIncAmt; - s32 phi_a1_3; + s32 charsToPrint; s32 i; printer->effectFrameCounter++; @@ -316,10 +316,10 @@ s32 _update_message(MessagePrintState* printer) { if (gGameStatusPtr->pressedButtons[0] & (BUTTON_A | BUTTON_C_DOWN)) { cond = TRUE; sfx_play_sound_with_params(SOUND_MENU_NEXT, 0, 0, 0); - } else if (printer->srcBuffer[printer->srcBufferPos] != 0xFD) { - printer->stateFlags |= MSG_STATE_FLAG_100 | MSG_STATE_FLAG_4; + } else if (printer->srcBuffer[printer->srcBufferPos] != MSG_CHAR_READ_END) { + printer->stateFlags |= MSG_STATE_FLAG_PRINT_QUICKLY | MSG_STATE_FLAG_4; if (printer->fontVariant != 0 || printer->srcBuffer[printer->srcBufferPos] != 0xC3) { - printer->stateFlags |= MSG_STATE_FLAG_100 | MSG_STATE_FLAG_80 | MSG_STATE_FLAG_4; + printer->stateFlags |= MSG_STATE_FLAG_PRINT_QUICKLY | MSG_STATE_FLAG_80 | MSG_STATE_FLAG_4; } sfx_play_sound_with_params(SOUND_CC, 0, 0, 0); } else if (printer->style == MSG_STYLE_RIGHT || @@ -435,39 +435,39 @@ s32 _update_message(MessagePrintState* printer) { case MSG_WINDOW_STATE_PRINTING: if ((gGameStatusPtr->pressedButtons[0] & BUTTON_A) | (gGameStatusPtr->currentButtons[0] & BUTTON_B)) { if (!(printer->stateFlags & (MSG_STATE_FLAG_20 | MSG_STATE_FLAG_10)) && !cond) { - printer->stateFlags |= MSG_STATE_FLAG_100; + printer->stateFlags |= MSG_STATE_FLAG_PRINT_QUICKLY; } } // fallthrough case MSG_WINDOW_STATE_INIT: - phi_a1_3 = printer->charsPerChunk; + charsToPrint = printer->charsPerChunk; if (printer->windowState == MSG_WINDOW_STATE_INIT) { printer->windowState = MSG_WINDOW_STATE_PRINTING; printer->currentPrintDelay = 0; - } else if (printer->stateFlags & MSG_STATE_FLAG_100) { - phi_a1_3 = 12; + } else if (printer->stateFlags & MSG_STATE_FLAG_PRINT_QUICKLY) { + charsToPrint = 12; printer->currentPrintDelay = 0; } else if (!(printer->stateFlags & MSG_STATE_FLAG_4)) { if (!(printer->stateFlags & (MSG_STATE_FLAG_20 | MSG_STATE_FLAG_10)) && (gGameStatusPtr->currentButtons[0] & BUTTON_A)) { - phi_a1_3 = 6; + charsToPrint = 6; printer->currentPrintDelay = 0; } } if ((printer->currentPrintDelay == 0) || --printer->currentPrintDelay == 0) { - msg_copy_to_print_buffer(printer, phi_a1_3, 0); + msg_copy_to_print_buffer(printer, charsToPrint, 0); } break; case MSG_WINDOW_STATE_SCROLLING: if (gGameStatusPtr->pressedButtons[0] & (BUTTON_A | BUTTON_B)) { if (!(printer->stateFlags & (MSG_STATE_FLAG_20 | MSG_STATE_FLAG_10))) { - printer->stateFlags |= MSG_STATE_FLAG_100; + printer->stateFlags |= MSG_STATE_FLAG_PRINT_QUICKLY; } } printer->curLinePos += printer->unk_464; - if ((printer->stateFlags & MSG_STATE_FLAG_100) || + if ((printer->stateFlags & MSG_STATE_FLAG_PRINT_QUICKLY) || (!(printer->stateFlags & (MSG_STATE_FLAG_10 | MSG_STATE_FLAG_4)) && (gGameStatusPtr->currentButtons[0] & BUTTON_A))) { diff --git a/src/starpoint.c b/src/starpoint.c index 95a2ef38a4..1d26592a17 100644 --- a/src/starpoint.c +++ b/src/starpoint.c @@ -126,20 +126,20 @@ Gfx D_802A32D8_7AAC78[] = { #include "starpoint/_render_digit_9.gfx.inc.c" #include "starpoint/render_digit_9.gfx.inc.c" -EntityModelScript starpoint_model_script_starpoint = STANDARD_ENTITY_MODEL_SCRIPT(D_802A2158_7A9AF8, RENDER_MODE_2D); -EntityModelScript starpoint_model_script_starpoints = STANDARD_ENTITY_MODEL_SCRIPT(D_802A32D8_7AAC78, RENDER_MODE_2D); -EntityModelScript starpoint_model_script_digit_0 = STANDARD_ENTITY_MODEL_SCRIPT(D_802A4410_7ABDB0, RENDER_MODE_2D); -EntityModelScript starpoint_model_script_digit_1 = STANDARD_ENTITY_MODEL_SCRIPT(D_802A5530_7ACED0, RENDER_MODE_2D); -EntityModelScript starpoint_model_script_digit_2 = STANDARD_ENTITY_MODEL_SCRIPT(D_802A6650_7ADFF0, RENDER_MODE_2D); -EntityModelScript starpoint_model_script_digit_3 = STANDARD_ENTITY_MODEL_SCRIPT(D_802A7770_7AF110, RENDER_MODE_2D); -EntityModelScript starpoint_model_script_digit_4 = STANDARD_ENTITY_MODEL_SCRIPT(D_802A8890_7B0230, RENDER_MODE_2D); -EntityModelScript starpoint_model_script_digit_5 = STANDARD_ENTITY_MODEL_SCRIPT(D_802A99B0_7B1350, RENDER_MODE_2D); -EntityModelScript starpoint_model_script_digit_6 = STANDARD_ENTITY_MODEL_SCRIPT(D_802AAAD0_7B2470, RENDER_MODE_2D); -EntityModelScript starpoint_model_script_digit_7 = STANDARD_ENTITY_MODEL_SCRIPT(D_802ABBF0_7B3590, RENDER_MODE_2D); -EntityModelScript starpoint_model_script_digit_8 = STANDARD_ENTITY_MODEL_SCRIPT(D_802ACD10_7B46B0, RENDER_MODE_2D); -EntityModelScript starpoint_model_script_digit_9 = STANDARD_ENTITY_MODEL_SCRIPT(D_802ADE30_7B57D0, RENDER_MODE_2D); +EntityModelScript EMS_starpoint_starpoint = STANDARD_ENTITY_MODEL_SCRIPT(D_802A2158_7A9AF8, RENDER_MODE_2D); +EntityModelScript EMS_starpoint_starpoints = STANDARD_ENTITY_MODEL_SCRIPT(D_802A32D8_7AAC78, RENDER_MODE_2D); +EntityModelScript EMS_starpoint_digit_0 = STANDARD_ENTITY_MODEL_SCRIPT(D_802A4410_7ABDB0, RENDER_MODE_2D); +EntityModelScript EMS_starpoint_digit_1 = STANDARD_ENTITY_MODEL_SCRIPT(D_802A5530_7ACED0, RENDER_MODE_2D); +EntityModelScript EMS_starpoint_digit_2 = STANDARD_ENTITY_MODEL_SCRIPT(D_802A6650_7ADFF0, RENDER_MODE_2D); +EntityModelScript EMS_starpoint_digit_3 = STANDARD_ENTITY_MODEL_SCRIPT(D_802A7770_7AF110, RENDER_MODE_2D); +EntityModelScript EMS_starpoint_digit_4 = STANDARD_ENTITY_MODEL_SCRIPT(D_802A8890_7B0230, RENDER_MODE_2D); +EntityModelScript EMS_starpoint_digit_5 = STANDARD_ENTITY_MODEL_SCRIPT(D_802A99B0_7B1350, RENDER_MODE_2D); +EntityModelScript EMS_starpoint_digit_6 = STANDARD_ENTITY_MODEL_SCRIPT(D_802AAAD0_7B2470, RENDER_MODE_2D); +EntityModelScript EMS_starpoint_digit_7 = STANDARD_ENTITY_MODEL_SCRIPT(D_802ABBF0_7B3590, RENDER_MODE_2D); +EntityModelScript EMS_starpoint_digit_8 = STANDARD_ENTITY_MODEL_SCRIPT(D_802ACD10_7B46B0, RENDER_MODE_2D); +EntityModelScript EMS_starpoint_digit_9 = STANDARD_ENTITY_MODEL_SCRIPT(D_802ADE30_7B57D0, RENDER_MODE_2D); Gfx D_802ADF90_7B5930[] = { gsSPEndDisplayList(), }; -EntityModelScript starpoint_model_script_dummy = STANDARD_ENTITY_MODEL_SCRIPT(D_802ADF90_7B5930, RENDER_MODE_2D); +EntityModelScript EMS_starpoint_dummy = STANDARD_ENTITY_MODEL_SCRIPT(D_802ADF90_7B5930, RENDER_MODE_2D); diff --git a/src/world/area_jan/jan.h b/src/world/area_jan/jan.h index b2fb0af1e2..82aa114593 100644 --- a/src/world/area_jan/jan.h +++ b/src/world/area_jan/jan.h @@ -2,28 +2,50 @@ #define _WORLD_AREA_JAN_JAN_H_ enum { - AB_JAN_0 = AreaByte(0), - AB_JAN_1 = AreaByte(1), - AB_JAN_2 = AreaByte(2), - AB_JAN_3 = AreaByte(3), - AB_JAN_4 = AreaByte(4), - AB_JAN_5 = AreaByte(5), - AB_JAN_6 = AreaByte(6), - AB_JAN_7 = AreaByte(7), - AB_JAN_8 = AreaByte(8), - AB_JAN_9 = AreaByte(9), - AB_JAN_A = AreaByte(10), - AB_JAN_B = AreaByte(11), - AB_JAN_C = AreaByte(12), - AB_JAN_D = AreaByte(13), - AB_JAN_E = AreaByte(14), - AB_JAN_F = AreaByte(15), + AB_JAN_0 = AreaByte(0), + AB_JAN_1 = AreaByte(1), + AB_JAN_2 = AreaByte(2), + AB_JAN_3 = AreaByte(3), + AB_JAN_4 = AreaByte(4), + AB_JAN_5 = AreaByte(5), + AB_JAN_6 = AreaByte(6), + AB_JAN_7 = AreaByte(7), + AB_JAN_8 = AreaByte(8), + AB_JAN_9 = AreaByte(9), + AB_JAN_A = AreaByte(10), + AB_JAN_B = AreaByte(11), + AB_JAN_C = AreaByte(12), + AB_JAN_D = AreaByte(13), + AB_JAN_E = AreaByte(14), + AB_JAN_F = AreaByte(15), }; enum { - AF_JAN_0D = AreaFlag(0xD), + AF_JAN_03 = AreaFlag(3), + AF_JAN_0D = AreaFlag(13), }; -#define AF_JAN(index) AreaFlag(index) +extern MapSettings jan_00_settings; +extern MapSettings jan_01_settings; +extern MapSettings jan_02_settings; +extern MapSettings jan_03_settings; +extern MapSettings jan_04_settings; +extern MapSettings jan_05_settings; +extern MapSettings jan_06_settings; +extern MapSettings jan_07_settings; +extern MapSettings jan_08_settings; +extern MapSettings jan_09_settings; +extern MapSettings jan_10_settings; +extern MapSettings jan_11_settings; +extern MapSettings jan_12_settings; +extern MapSettings jan_13_settings; +extern MapSettings jan_14_settings; +extern MapSettings jan_15_settings; +extern MapSettings jan_16_settings; +extern MapSettings jan_17_settings; +extern MapSettings jan_18_settings; +extern MapSettings jan_19_settings; +extern MapSettings jan_22_settings; +extern MapSettings jan_23_settings; #endif diff --git a/src/world/area_jan/jan_17/B837C0.c b/src/world/area_jan/jan_17/B837C0.c deleted file mode 100644 index c81de50277..0000000000 --- a/src/world/area_jan/jan_17/B837C0.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "jan_17.h" - -static char* N(exit_str_0) = "jan_16"; -static char* N(exit_str_1) = "jan_18"; - -ApiStatus func_80240000_B837C0(Evt* script, s32 isInitialCall) { - enable_world_fog(); - return ApiStatus_DONE2; -} diff --git a/src/world/area_jan/jan_17/jan_17.h b/src/world/area_jan/jan_17/jan_17.h index 412a868ce4..76e55f7f1f 100644 --- a/src/world/area_jan/jan_17/jan_17.h +++ b/src/world/area_jan/jan_17/jan_17.h @@ -2,8 +2,15 @@ /// @brief Jade Jungle - Lower Great Tree Interior #include "common.h" -#include "../jan.h" #include "message_ids.h" #include "map.h" +#include "../jan.h" +#include "mapfs/jan_17_shape.h" +#include "mapfs/jan_17_hit.h" + #define NAMESPACE jan_17 + +extern EvtScript N(EVS_Main); +extern EvtScript N(EVS_SetupMusic); +extern EvtScript N(EVS_MakeEntities); diff --git a/src/world/area_jan/jan_17/jan_17_0_header.c b/src/world/area_jan/jan_17/jan_17_0_header.c new file mode 100644 index 0000000000..5652a646ec --- /dev/null +++ b/src/world/area_jan/jan_17/jan_17_0_header.c @@ -0,0 +1,13 @@ +#include "jan_17.h" + +EntryList N(Entrances) = { + [jan_17_ENTRY_0] { -220.0, 0.0, 10.0, 90.0 }, + [jan_17_ENTRY_1] { 190.0, 450.0, 110.0, 270.0 }, +}; + +MapSettings N(settings) = { + .main = &N(EVS_Main), + .entryList = &N(Entrances), + .entryCount = ENTRY_COUNT(N(Entrances)), + .tattle = { MSG_MapTattle_jan_17 }, +}; diff --git a/src/world/area_jan/jan_17/jan_17_1_music.c b/src/world/area_jan/jan_17/jan_17_1_music.c new file mode 100644 index 0000000000..dfa72b1ac9 --- /dev/null +++ b/src/world/area_jan/jan_17/jan_17_1_music.c @@ -0,0 +1,12 @@ +#include "jan_17.h" + +EvtScript N(EVS_SetupMusic) = { + EVT_CALL(GetLoadType, LVar1) + EVT_IF_EQ(LVar1, LOAD_FROM_FILE_SELECT) + EVT_CALL(SetMusicTrack, 0, SONG_RAPHAEL_RAVEN, 0, 8) + EVT_SET(AF_JAN_03, FALSE) + EVT_END_IF + EVT_CALL(ClearAmbientSounds, 250) + EVT_RETURN + EVT_END +}; diff --git a/src/world/area_jan/jan_17/jan_17_2_main.c b/src/world/area_jan/jan_17/jan_17_2_main.c new file mode 100644 index 0000000000..cfbc4f6fcd --- /dev/null +++ b/src/world/area_jan/jan_17/jan_17_2_main.c @@ -0,0 +1,39 @@ +#include "jan_17.h" + +API_CALLABLE(N(EnableFog)) { + enable_world_fog(); + return ApiStatus_DONE2; +} + +EvtScript N(EVS_ExitWalk_jan_16_2) = EVT_EXIT_WALK(60, jan_17_ENTRY_0, "jan_16", jan_16_ENTRY_2); +EvtScript N(EVS_ExitWalk_jan_18_0) = EVT_EXIT_WALK(60, jan_17_ENTRY_1, "jan_18", jan_18_ENTRY_0); + +EvtScript N(EVS_BindExitTriggers) = { + EVT_BIND_TRIGGER(EVT_PTR(N(EVS_ExitWalk_jan_16_2)), TRIGGER_FLOOR_ABOVE, COLLIDER_deiliw, 1, 0) + EVT_BIND_TRIGGER(EVT_PTR(N(EVS_ExitWalk_jan_18_0)), TRIGGER_FLOOR_ABOVE, COLLIDER_deilie, 1, 0) + EVT_RETURN + EVT_END +}; + +EvtScript N(EVS_Main) = { + EVT_SET(GB_WorldLocation, LOCATION_JADE_JUNGLE) + EVT_CALL(SetSpriteShading, SHADING_JAN_17) + EVT_CALL(SetCamLeadPlayer, CAM_DEFAULT, FALSE) + EVT_SETUP_CAMERA_DEFAULT() + EVT_EXEC_WAIT(N(EVS_MakeEntities)) + EVT_CALL(N(EnableFog)) + EVT_CALL(ModifyColliderFlags, MODIFY_COLLIDER_FLAGS_SET_BITS, COLLIDER_deilitw, COLLIDER_FLAGS_UPPER_MASK) + EVT_CALL(ModifyColliderFlags, MODIFY_COLLIDER_FLAGS_SET_BITS, COLLIDER_deilite, COLLIDER_FLAGS_UPPER_MASK) + EVT_CALL(GetLoadType, LVar1) + EVT_IF_EQ(LVar1, 1) + EVT_EXEC(EnterSavePoint) + EVT_EXEC(N(EVS_BindExitTriggers)) + EVT_ELSE + EVT_SET(LVar0, EVT_PTR(N(EVS_BindExitTriggers))) + EVT_EXEC(EnterWalk) + EVT_END_IF + EVT_WAIT(1) + EVT_EXEC_WAIT(N(EVS_SetupMusic)) + EVT_RETURN + EVT_END +}; diff --git a/src/world/area_jan/jan_17/jan_17_3_entity.c b/src/world/area_jan/jan_17/jan_17_3_entity.c new file mode 100644 index 0000000000..de699c32d7 --- /dev/null +++ b/src/world/area_jan/jan_17/jan_17_3_entity.c @@ -0,0 +1,9 @@ +#include "jan_17.h" +#include "entity.h" + +EvtScript N(EVS_MakeEntities) = { + EVT_CALL(MakeEntity, EVT_PTR(Entity_SavePoint), 0, 60, 0, 0, MAKE_ENTITY_END) + EVT_CALL(MakeEntity, EVT_PTR(Entity_PinkFlower), -61, 0, -7, 0, MAKE_ENTITY_END) + EVT_RETURN + EVT_END +}; diff --git a/src/world/area_jan/jan_18/B83B90.c b/src/world/area_jan/jan_18/B83B90.c deleted file mode 100644 index 69fc82a586..0000000000 --- a/src/world/area_jan/jan_18/B83B90.c +++ /dev/null @@ -1,4 +0,0 @@ -#include "jan_18.h" - -static char* N(exit_str_0) = "jan_17"; -static char* N(exit_str_1) = "jan_19"; diff --git a/src/world/area_jan/jan_18/jan_18.h b/src/world/area_jan/jan_18/jan_18.h index 061fdef6d7..29fe8893d9 100644 --- a/src/world/area_jan/jan_18/jan_18.h +++ b/src/world/area_jan/jan_18/jan_18.h @@ -2,8 +2,15 @@ /// @brief Jade Jungle - Great Tree Vine Ascent #include "common.h" -#include "../jan.h" #include "message_ids.h" #include "map.h" +#include "../jan.h" +#include "mapfs/jan_18_shape.h" +#include "mapfs/jan_18_hit.h" + #define NAMESPACE jan_18 + +extern EvtScript N(EVS_Main); +extern EvtScript N(EVS_SetupMusic); +extern EvtScript N(EVS_MakeEntities); diff --git a/src/world/area_jan/jan_18/jan_18_0_header.c b/src/world/area_jan/jan_18/jan_18_0_header.c new file mode 100644 index 0000000000..dec2d0a15c --- /dev/null +++ b/src/world/area_jan/jan_18/jan_18_0_header.c @@ -0,0 +1,14 @@ +#include "jan_18.h" + +EntryList N(Entrances) = { + [jan_18_ENTRY_0] { 25.0, 180.0, 205.0, 172.0 }, + [jan_18_ENTRY_1] { 20.0, 345.0, -210.0, 6.0 }, +}; + +MapSettings N(settings) = { + .main = &N(EVS_Main), + .entryList = &N(Entrances), + .entryCount = ENTRY_COUNT(N(Entrances)), + .background = &gBackgroundImage, + .tattle = { MSG_MapTattle_jan_18 }, +}; diff --git a/src/world/area_jan/jan_18/jan_18_1_music.c b/src/world/area_jan/jan_18/jan_18_1_music.c new file mode 100644 index 0000000000..d252064fe5 --- /dev/null +++ b/src/world/area_jan/jan_18/jan_18_1_music.c @@ -0,0 +1,7 @@ +#include "jan_18.h" + +EvtScript N(EVS_SetupMusic) = { + EVT_CALL(PlayAmbientSounds, AMBIENT_JUNGLE) + EVT_RETURN + EVT_END +}; diff --git a/src/world/area_jan/jan_18/jan_18_2_main.c b/src/world/area_jan/jan_18/jan_18_2_main.c new file mode 100644 index 0000000000..1af0863887 --- /dev/null +++ b/src/world/area_jan/jan_18/jan_18_2_main.c @@ -0,0 +1,26 @@ +#include "jan_18.h" + +EvtScript N(EVS_ExitWalk_jan_17_1) = EVT_EXIT_WALK(60, jan_18_ENTRY_0, "jan_17", jan_17_ENTRY_1); +EvtScript N(EVS_ExitWalk_jan_19_0) = EVT_EXIT_WALK(60, jan_18_ENTRY_1, "jan_19", jan_19_ENTRY_0); + +EvtScript N(EVS_BindExitTriggers) = { + EVT_BIND_TRIGGER(EVT_PTR(N(EVS_ExitWalk_jan_17_1)), TRIGGER_FLOOR_ABOVE, COLLIDER_deilis, 1, 0) + EVT_BIND_TRIGGER(EVT_PTR(N(EVS_ExitWalk_jan_19_0)), TRIGGER_FLOOR_ABOVE, COLLIDER_deilin, 1, 0) + EVT_RETURN + EVT_END +}; + +EvtScript N(EVS_Main) = { + EVT_SET(GB_WorldLocation, LOCATION_JADE_JUNGLE) + EVT_CALL(SetSpriteShading, SHADING_NONE) + EVT_CALL(SetCamLeadPlayer, CAM_DEFAULT, FALSE) + EVT_SETUP_CAMERA_DEFAULT() + EVT_EXEC_WAIT(N(EVS_MakeEntities)) + EVT_CALL(ModifyColliderFlags, MODIFY_COLLIDER_FLAGS_SET_BITS, COLLIDER_deilitse, COLLIDER_FLAGS_UPPER_MASK) + EVT_CALL(ModifyColliderFlags, MODIFY_COLLIDER_FLAGS_SET_BITS, COLLIDER_deilitn, COLLIDER_FLAGS_UPPER_MASK) + EVT_SET(LVar0, EVT_PTR(N(EVS_BindExitTriggers))) + EVT_EXEC(EnterWalk) + EVT_EXEC_WAIT(N(EVS_SetupMusic)) + EVT_RETURN + EVT_END +}; diff --git a/src/world/area_jan/jan_18/jan_18_3_entity.c b/src/world/area_jan/jan_18/jan_18_3_entity.c new file mode 100644 index 0000000000..26c925d202 --- /dev/null +++ b/src/world/area_jan/jan_18/jan_18_3_entity.c @@ -0,0 +1,8 @@ +#include "jan_18.h" +#include "entity.h" + +EvtScript N(EVS_MakeEntities) = { + EVT_CALL(MakeItemEntity, ITEM_HAPPY_HEART_B, -230, 460, 100, ITEM_SPAWN_MODE_FIXED_NEVER_VANISH, GF_JAN18_Item_HappyHeartB) + EVT_RETURN + EVT_END +}; diff --git a/src/world/area_jan/jan_19/B83E60.c b/src/world/area_jan/jan_19/B83E60.c deleted file mode 100644 index 2baaecee6d..0000000000 --- a/src/world/area_jan/jan_19/B83E60.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "jan_19.h" - -static char* N(exit_str_0) = "jan_18"; -static char* N(exit_str_1) = "jan_23"; - -ApiStatus func_80240000_B83E60(Evt* script, s32 isInitialCall) { - enable_world_fog(); - return ApiStatus_DONE2; -} diff --git a/src/world/area_jan/jan_19/jan_19.h b/src/world/area_jan/jan_19/jan_19.h index 9d0ac19037..b552b37458 100644 --- a/src/world/area_jan/jan_19/jan_19.h +++ b/src/world/area_jan/jan_19/jan_19.h @@ -2,8 +2,15 @@ /// @brief Jade Jungle - Upper Great Tree Interior #include "common.h" -#include "../jan.h" #include "message_ids.h" #include "map.h" +#include "../jan.h" +#include "mapfs/jan_19_shape.h" +#include "mapfs/jan_19_hit.h" + #define NAMESPACE jan_19 + +extern EvtScript N(EVS_Main); +extern EvtScript N(EVS_SetupMusic); +extern EvtScript N(EVS_MakeEntities); diff --git a/src/world/area_jan/jan_19/jan_19_0_header.c b/src/world/area_jan/jan_19/jan_19_0_header.c new file mode 100644 index 0000000000..20d97ba230 --- /dev/null +++ b/src/world/area_jan/jan_19/jan_19_0_header.c @@ -0,0 +1,13 @@ +#include "jan_19.h" + +EntryList N(Entrances) = { + [jan_19_ENTRY_0] { -220.0, 0.0, 10.0, 90.0 }, + [jan_19_ENTRY_1] { 190.0, 450.0, 110.0, 270.0 }, +}; + +MapSettings N(settings) = { + .main = &N(EVS_Main), + .entryList = &N(Entrances), + .entryCount = ENTRY_COUNT(N(Entrances)), + .tattle = { MSG_MapTattle_jan_19 }, +}; diff --git a/src/world/area_jan/jan_19/jan_19_1_music.c b/src/world/area_jan/jan_19/jan_19_1_music.c new file mode 100644 index 0000000000..7dfb202e3d --- /dev/null +++ b/src/world/area_jan/jan_19/jan_19_1_music.c @@ -0,0 +1,7 @@ +#include "jan_19.h" + +EvtScript N(EVS_SetupMusic) = { + EVT_CALL(ClearAmbientSounds, 250) + EVT_RETURN + EVT_END +}; diff --git a/src/world/area_jan/jan_19/jan_19_2_main.c b/src/world/area_jan/jan_19/jan_19_2_main.c new file mode 100644 index 0000000000..b0b61c9002 --- /dev/null +++ b/src/world/area_jan/jan_19/jan_19_2_main.c @@ -0,0 +1,32 @@ +#include "jan_19.h" + +API_CALLABLE(N(EnableFog)) { + enable_world_fog(); + return ApiStatus_DONE2; +} + +EvtScript N(EVS_ExitWalk_jan_18_1) = EVT_EXIT_WALK(60, jan_19_ENTRY_0, "jan_18", jan_18_ENTRY_1); +EvtScript N(EVS_ExitWalk_jan_23_0) = EVT_EXIT_WALK(60, jan_19_ENTRY_1, "jan_23", jan_23_ENTRY_0); + +EvtScript N(EVS_BindExitTriggers) = { + EVT_BIND_TRIGGER(EVT_PTR(N(EVS_ExitWalk_jan_18_1)), TRIGGER_FLOOR_ABOVE, COLLIDER_deiliw, 1, 0) + EVT_BIND_TRIGGER(EVT_PTR(N(EVS_ExitWalk_jan_23_0)), TRIGGER_FLOOR_ABOVE, COLLIDER_deilie, 1, 0) + EVT_RETURN + EVT_END +}; + +EvtScript N(EVS_Main) = { + EVT_SET(GB_WorldLocation, LOCATION_JADE_JUNGLE) + EVT_CALL(SetSpriteShading, SHADING_JAN_19) + EVT_CALL(SetCamLeadPlayer, CAM_DEFAULT, FALSE) + EVT_SETUP_CAMERA_DEFAULT() + EVT_EXEC_WAIT(N(EVS_MakeEntities)) + EVT_CALL(N(EnableFog)) + EVT_CALL(ModifyColliderFlags, MODIFY_COLLIDER_FLAGS_SET_BITS, COLLIDER_deilitw, COLLIDER_FLAGS_UPPER_MASK) + EVT_CALL(ModifyColliderFlags, MODIFY_COLLIDER_FLAGS_SET_BITS, COLLIDER_deilite, COLLIDER_FLAGS_UPPER_MASK) + EVT_SET(LVar0, EVT_PTR(N(EVS_BindExitTriggers))) + EVT_EXEC(EnterWalk) + EVT_EXEC_WAIT(N(EVS_SetupMusic)) + EVT_RETURN + EVT_END +}; diff --git a/src/world/area_jan/jan_19/jan_19_3_entity.c b/src/world/area_jan/jan_19/jan_19_3_entity.c new file mode 100644 index 0000000000..c824840b6e --- /dev/null +++ b/src/world/area_jan/jan_19/jan_19_3_entity.c @@ -0,0 +1,9 @@ +#include "jan_19.h" +#include "entity.h" + +EvtScript N(EVS_MakeEntities) = { + EVT_CALL(MakeEntity, EVT_PTR(Entity_PinkFlower), -154, 0, -20, 150, MAKE_ENTITY_END) + EVT_CALL(MakeEntity, EVT_PTR(Entity_PinkFlower), 145, 450, 50, 120, MAKE_ENTITY_END) + EVT_RETURN + EVT_END +}; diff --git a/src/world/world.c b/src/world/world.c index 4bccf97685..9c18564aa6 100644 --- a/src/world/world.c +++ b/src/world/world.c @@ -582,6 +582,7 @@ MapConfig kkj_maps[] = { }; /// Jade Jungle +#include "area_jan/jan.h" MapConfig jan_maps[] = { { MAP_UNSPLIT(jan_00, 0x80241BD0), .bgName = "yos_bg" }, { MAP_UNSPLIT(jan_01, 0x802413F0), .bgName = "yos_bg" }, @@ -600,9 +601,9 @@ MapConfig jan_maps[] = { { MAP_UNSPLIT(jan_14, 0x80241300), .bgName = "jan_bg", .songVariation = 1, .sfxReverb = 1 }, { MAP_UNSPLIT(jan_15, 0x80240320), .bgName = "jan_bg", .songVariation = 1, .sfxReverb = 1 }, { MAP_UNSPLIT(jan_16, 0x80240590), .bgName = "jan_bg", .songVariation = 1, .sfxReverb = 1 }, - { MAP_UNSPLIT(jan_17, 0x80240040), .bgName = "jan_bg", .songVariation = 1, .sfxReverb = 2 }, - { MAP_UNSPLIT(jan_18, 0x80240020), .bgName = "yos_bg" }, - { MAP_UNSPLIT(jan_19, 0x80240040), .bgName = "jan_bg", .songVariation = 1, .sfxReverb = 2 }, + { MAP(jan_17), .bgName = "jan_bg", .songVariation = 1, .sfxReverb = 2 }, + { MAP(jan_18), .bgName = "yos_bg" }, + { MAP(jan_19), .bgName = "jan_bg", .songVariation = 1, .sfxReverb = 2 }, { MAP_UNSPLIT(jan_22, 0x802419A0), .bgName = "jan_bg", .songVariation = 1, .sfxReverb = 1 }, { MAP_UNSPLIT(jan_23, 0x80240010), .bgName = "yos_bg" }, }; diff --git a/tools/splat_ext/msg.yaml b/tools/splat_ext/msg.yaml index a9e7d7f8ea..42f579e3a8 100644 --- a/tools/splat_ext/msg.yaml +++ b/tools/splat_ext/msg.yaml @@ -5477,7 +5477,7 @@ - [0x1D, 0x00C6, Menus_00C6] - [0x1D, 0x00C7, Menus_00C7] - [0x1D, 0x00C8, Menus_00C8] -- [0x1D, 0x00C9, Menus_00C9] +- [0x1D, 0x00C9, Menus_CantSwitch] - [0x1D, 0x00CA, Menus_00CA] - [0x1D, 0x00CB, Menus_00CB] - [0x1D, 0x00CC, Menus_00CC] diff --git a/tools/star_rod_idx_to_c.py b/tools/star_rod_idx_to_c.py index dbcd9886f9..980edad63b 100755 --- a/tools/star_rod_idx_to_c.py +++ b/tools/star_rod_idx_to_c.py @@ -874,7 +874,7 @@ def disassemble(bytes, midx, symbol_map={}, comments=True, romstart=0, namespace out += INDENT + f".maxHP = {d[3]},\n" out += INDENT + f".partCount = ARRAY_COUNT({read_ptr(d[5], symbol_map)}),\n" out += INDENT + f".partsData = {read_ptr(d[5], symbol_map)},\n" - out += INDENT + f".script = {read_ptr(d[6], symbol_map)},\n" + out += INDENT + f".takeTurnScript = {read_ptr(d[6], symbol_map)},\n" out += INDENT + f".statusTable = {read_ptr(d[7], symbol_map)},\n" out += INDENT + f".escapeChance = {d[8]},\n" out += INDENT + f".airLiftChance = {d[9]},\n" diff --git a/ver/us/asm/bss.s b/ver/us/asm/bss.s index 891707ac17..8a0fa70372 100644 --- a/ver/us/asm/bss.s +++ b/ver/us/asm/bss.s @@ -1063,7 +1063,7 @@ dlabel D_800DC4D0 dlabel D_800DC4D4 .space 4 -dlabel D_800DC4D8 +dlabel gDefeatedBattleSubstate .space 4 dlabel gBattleSubState @@ -1072,7 +1072,7 @@ dlabel gBattleSubState dlabel D_800DC4E0 .space 4 -dlabel D_800DC4E4 +dlabel gDefeatedBattleState .space 4 dlabel gCurrentBattleID diff --git a/ver/us/splat.yaml b/ver/us/splat.yaml index 398a8e2bc4..abb8ecccd1 100644 --- a/ver/us/splat.yaml +++ b/ver/us/splat.yaml @@ -12344,31 +12344,33 @@ segments: start: 0xB837C0 vram: 0x80240000 subsegments: - - [0xB837C0, c] - - [0xB837E0, data] - - [0xB838C0, data] - - [0xB83B20, data] - - [0xB83B80] + - [0xB837C0, c, jan_17_0_header] + - [0xB837C0, c, jan_17_1_music] + - [0xB837C0, c, jan_17_2_main] + - [0xB837E0, c, jan_17_3_entity] + - [0xB837E0] - name: jan_18 dir: world/area_jan/jan_18 type: code start: 0xB83B90 vram: 0x80240000 subsegments: - - [0xB83B90, c] - - [0xB83B90, data] - - [0xB83E10, data] - - [0xB83E50] + - [0xB83B90, c, jan_18_0_header] + - [0xB83B90, c, jan_18_1_music] + - [0xB83B90, c, jan_18_2_main] + - [0xB83B90, c, jan_18_3_entity] + - [0xB83B90] - name: jan_19 dir: world/area_jan/jan_19 type: code start: 0xB83E60 vram: 0x80240000 subsegments: - - [0xB83E60, c] - - [0xB83E80, data] - - [0xB84110, data] - - [0xB84170] + - [0xB83E60, c, jan_19_0_header] + - [0xB83E60, c, jan_19_1_music] + - [0xB83E60, c, jan_19_2_main] + - [0xB83E80, c, jan_19_3_entity] + - [0xB83E80] - name: jan_22 dir: world/area_jan/jan_22 type: code diff --git a/ver/us/symbol_addrs.txt b/ver/us/symbol_addrs.txt index f3d1d7f6dd..34abb764ee 100644 --- a/ver/us/symbol_addrs.txt +++ b/ver/us/symbol_addrs.txt @@ -4169,10 +4169,10 @@ make_entity_model_mtx_flipZ = 0x80121140; // type:func rom:0xB7840 appendGfx_entity_model = 0x80121184; // type:func rom:0xB7884 D_800DC4D0 = 0x800DC4D0; // type:data rom:0xB78D0 D_800DC4D4 = 0x800DC4D4; // type:data rom:0xB78D4 -D_800DC4D8 = 0x800DC4D8; // type:data rom:0xB78D8 +gDefeatedBattleSubstate = 0x800DC4D8; // type:data rom:0xB78D8 gBattleSubState = 0x800DC4DC; // type:data rom:0xB78DC D_800DC4E0 = 0x800DC4E0; // type:data rom:0xB78E0 -D_800DC4E4 = 0x800DC4E4; // type:data rom:0xB78E4 +gDefeatedBattleState = 0x800DC4E4; // type:data rom:0xB78E4 gCurrentBattleID = 0x800DC4E8; // type:data rom:0xB78E8 D_800DC4EC = 0x800DC4EC; // type:data rom:0xB78EC D_800DC4F0 = 0x800DC4F0; // type:data rom:0xB78F0 @@ -6538,7 +6538,7 @@ btl_state_update_begin_partner_turn = 0x80242BB0; // type:func rom:0x171490 btl_state_draw_begin_partner_turn = 0x80242EF8; // type:func rom:0x1717D8 btl_state_update_switch_to_partner = 0x80242F00; // type:func rom:0x1717E0 btl_state_draw_switch_to_partner = 0x80242FD8; // type:func rom:0x1718B8 -func_80242FE0 = 0x80242FE0; // type:func rom:0x1718C0 +btl_state_update_9 = 0x80242FE0; // type:func rom:0x1718C0 func_80243910 = 0x80243910; // type:func rom:0x1721F0 btl_state_update_prepare_menu = 0x80243918; // type:func rom:0x1721F8 btl_state_draw_prepare_menu = 0x802439D0; // type:func rom:0x1722B0 @@ -6650,7 +6650,7 @@ btl_set_popup_duration = 0x8024FAC4; // type:func rom:0x17E3A4 func_8024FAE8 = 0x8024FAE8; // type:func rom:0x17E3C8 func_8024FAFC = 0x8024FAFC; // type:func rom:0x17E3DC close_action_command_instruction_popup = 0x8024FB0C; // type:func rom:0x17E3EC -func_8024FB3C = 0x8024FB3C; // type:func rom:0x17E41C +btl_update_message_popup = 0x8024FB3C; // type:func rom:0x17E41C func_80250818 = 0x80250818; // type:func rom:0x17F0F8 btl_show_message_popup = 0x80250EA4; // type:func rom:0x17F784 ShowMessageBox = 0x802512B4; // type:func rom:0x17FB94 @@ -6781,17 +6781,17 @@ func_8025DBD0 = 0x8025DBD0; // type:func rom:0x18C4B0 func_8025DD40 = 0x8025DD40; // type:func rom:0x18C620 func_8025DD60 = 0x8025DD60; // type:func rom:0x18C640 func_8025DE88 = 0x8025DE88; // type:func rom:0x18C768 -func_8025DEB0 = 0x8025DEB0; // type:func rom:0x18C790 -func_8025DEC4 = 0x8025DEC4; // type:func rom:0x18C7A4 -func_8025E030 = 0x8025E030; // type:func rom:0x18C910 -func_8025E044 = 0x8025E044; // type:func rom:0x18C924 -func_8025E108 = 0x8025E108; // type:func rom:0x18C9E8 -func_8025E14C = 0x8025E14C; // type:func rom:0x18CA2C +GetRemainingStarPointsReward = 0x8025DEB0; // type:func rom:0x18C790 +GetStarPointDigitScripts = 0x8025DEC4; // type:func rom:0x18C7A4 +AwaitBattleRewardsDone = 0x8025E030; // type:func rom:0x18C910 +InitStarPointModelFlags = 0x8025E044; // type:func rom:0x18C924 +InitLevelUpModelFlags = 0x8025E108; // type:func rom:0x18C9E8 +MakeLevelUpConfetti = 0x8025E14C; // type:func rom:0x18CA2C btl_state_update_celebration = 0x8025E190; // type:func rom:0x18CA70 btl_draw_upgrade_windows = 0x8025FF8C; // type:func rom:0x18E86C btl_state_draw_celebration = 0x802601BC; // type:func rom:0x18EA9C -func_80260948 = 0x80260948; // type:func rom:0x18F228 -func_80260A20 = 0x80260A20; // type:func rom:0x18F300 +draw_content_level_up_textbox = 0x80260948; // type:func rom:0x18F228 +draw_content_cant_increase_popup = 0x80260A20; // type:func rom:0x18F300 func_80260A60 = 0x80260A60; // type:func rom:0x18F340 IsPartnerImmobile = 0x80260AD4; // type:func rom:0x18F3B4 activate_defend_command = 0x80260B04; // type:func rom:0x18F3E4 @@ -7291,7 +7291,7 @@ D_80283690 = 0x80283690; // type:data rom:0x1B1F70 D_80283744 = 0x80283744; // type:data rom:0x1B2024 bMessages = 0x80283770; // type:data rom:0x1B2050 bActorMessages = 0x802838C4; // type:data rom:0x1B21A4 -D_802838F8 = 0x802838F8; // type:data rom:0x1B21D8 +bPopupMessage = 0x802838F8; // type:data rom:0x1B21D8 D_80283D98 = 0x80283D98; // type:data rom:0x1B2678 gBattleDmaDest = 0x80284000; // rom:0x1B28E0 MarioEnterStage = 0x80284A40; // rom:0x1B3320 @@ -26849,23 +26849,23 @@ gSpeakingActorTalkAnim = 0x8029FA6C; // gSpeakingActorIdleAnim = 0x8029FA70; // gSpeakingActor = 0x8029FA74; // gSpeakingActorPart = 0x8029FA78; // -D_8029FA80 = 0x8029FA80; // type:data -D_8029FA90 = 0x8029FA90; // type:data +LevelUpStatEmblemHEIDs = 0x8029FA80; // type:data +LevelUpStatTextHEIDs = 0x8029FA90; // type:data D_8029FAE8 = 0x8029FAE8; // type:data -D_8029FB48 = 0x8029FB48; // type:data -D_8029FB4C = 0x8029FB4C; // type:data +LevelUpSelectTextHEID = 0x8029FB48; // type:data +CelebrateSubstateTime = 0x8029FB4C; // type:data D_8029FB50 = 0x8029FB50; // type:data -D_8029FB54 = 0x8029FB54; // type:data -D_8029FB60 = 0x8029FB60; // type:data -D_8029FB6C = 0x8029FB6C; // type:data -D_8029FB70 = 0x8029FB70; // type:data +EndBattleRewardStep = 0x8029FB54; // type:data +CantLevelUpStat = 0x8029FB60; // type:data +EndBattleRewardTotal = 0x8029FB6C; // type:data +EndBattleRewardIncrement = 0x8029FB70; // type:data D_8029FB74 = 0x8029FB74; // type:data -D_8029FB78 = 0x8029FB78; // type:data -D_8029FB7C = 0x8029FB7C; // type:data -D_8029FB80 = 0x8029FB80; // type:data -D_8029FB84 = 0x8029FB84; // type:data -D_8029FB88 = 0x8029FB88; // type:data -D_8029FB8C = 0x8029FB8C; // type:data +EndBattleRewardsDone = 0x8029FB78; // type:data +LevelUpScriptPtr = 0x8029FB7C; // type:data +LevelUpScriptID = 0x8029FB80; // type:data +CelebrateStateTime = 0x8029FB84; // type:data +LevelUpSelectTextOffsetX = 0x8029FB88; // type:data +LevelUpSelectTextVelX = 0x8029FB8C; // type:data D_8029FB90 = 0x8029FB90; // type:data D_8029FB94 = 0x8029FB94; // type:data BattleMerleeOrbEffect = 0x8029FB98; // type:data