From f88817d07bc6708a85e3dd1b3640541e42460dd3 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Fri, 15 Aug 2025 18:52:21 +0200 Subject: [PATCH] unit: removed dedicated attack state. Units now only have an active and idle state they can switch to --- src/battle.s | 32 +++----------------------------- src/defs.s | 2 -- src/macros.inc | 8 ++------ src/player.s | 2 +- src/unit.s | 27 --------------------------- src/unit_demo.s | 12 +++++------- 6 files changed, 11 insertions(+), 72 deletions(-) diff --git a/src/battle.s b/src/battle.s index baf55fe..4725d95 100644 --- a/src/battle.s +++ b/src/battle.s @@ -1,33 +1,7 @@ - ; transitions to battle view - ; redraws the tilemap to battle view - ; and sets up battle UI - ; *if* the player is being touched by - ; an enemy. All adjacent enemies to the player are - ; moved into combat. - ; the current map's state is preserved. - ; transitions game state to battle - ; switch all units to their attack state - ; and switch draw routines to battle routines ; inputs: - ; de: player actor -battle_enter: + ; de: source actor + ; bc: target coordinates +battle_attack: call unit_find_at ret - - - ; exits battle mode - ; and reloads the map - ; without re-generating it. - ; the map simply needs to be drawn again - ; switch all units back to their active states - ; and restore draw routines -battle_exit: - ret - -battle_update: - ldnull bc - ret - -st_update_battle: - st_def 0x00, battle_update, st_update_battle diff --git a/src/defs.s b/src/defs.s index 187baa1..e9a414b 100644 --- a/src/defs.s +++ b/src/defs.s @@ -216,8 +216,6 @@ ; actor states ; used for state switching ; set to 0000 to disable the state -.de act_st_attack, 2 -.de act_st_interact, 2 .de act_st_active, 2 .de act_st_idle, 2 diff --git a/src/macros.inc b/src/macros.inc index f2ca1a6..8cd0b60 100644 --- a/src/macros.inc +++ b/src/macros.inc @@ -219,15 +219,11 @@ ; defines actor state callbacks ; inputs: - ; $1: st_attack - ; $2: st_interact - ; $3: st_active - ; $4: st_idle + ; $1: st_active + ; $2: st_idle #macro act_st_def dw $1 dw $2 - dw $3 - dw $4 #endmacro ; defines an exit table entry diff --git a/src/player.s b/src/player.s index 1aa4bcc..a4616f5 100644 --- a/src/player.s +++ b/src/player.s @@ -288,7 +288,7 @@ unit_player: act_def ACT_T_DEMO_1, 0, 2, 2, 0 act_stat_def1 1, 1, 1, 1 act_stat_def2 1, 1, 90, 1 - act_st_def st_unit_player_attack, NULL, st_unit_player_update, st_unit_idle + act_st_def st_unit_player_update, st_unit_idle act_def_meta player_draw, 0x8C, OAM_FPRIO, NULL st_unit_player_update: diff --git a/src/unit.s b/src/unit.s index d5df12d..4920fb1 100644 --- a/src/unit.s +++ b/src/unit.s @@ -696,33 +696,6 @@ unit_switch_to_active: ret - ; switches a unit to attack state - ; inputs: - ; de: unit - ; returns: - ; bc: new state -unit_switch_to_attack: - ld hl, act_st_attack - add hl, de - ld a, [hl+] - ld c, a - ld a, [hl+] - ld b, a - ret - - ; forces the unit to enter attack state - ; inputs: - ; de: unit -unit_switch_to_attack_enter_combat: - push de - call unit_switch_to_attack - push bc ; de = new state - pop hl ; unit ptr (st header) - ld bc, st_size - call memcpy - - ret - ; forces a unit into an active state ; inputs: ; de: unit diff --git a/src/unit_demo.s b/src/unit_demo.s index 95c0678..7208621 100644 --- a/src/unit_demo.s +++ b/src/unit_demo.s @@ -20,7 +20,7 @@ unit_demo_2: act_def ACT_T_DEMO_1, 0, 3, 3, 0 act_stat_def1 1, 1, 1, 1 act_stat_def2 1, 1, 32, 1 - act_st_def st_unit_demo_1_cpu_update_attack, NULL, st_unit_demo_1_cpu_update_idle, st_unit_idle + act_st_def st_unit_demo_1_cpu_update_idle, st_unit_idle act_def_meta unit_draw, 0x88, OAM_FPRIO, NULL unit_demo_warrior: @@ -28,7 +28,7 @@ unit_demo_warrior: act_def ACT_T_DEMO_1, 0, 9, 9, 0 act_stat_def1 1, 1, 1, 1 act_stat_def2 1, 1, 32, 1 - act_st_def st_unit_demo_1_cpu_update_attack, NULL, st_unit_demo_1_cpu_update, st_unit_idle + act_st_def st_unit_demo_1_cpu_update, st_unit_idle act_def_meta unit_draw, 0x88, OAM_FPRIO, NULL unit_demo_mage: @@ -36,7 +36,7 @@ unit_demo_mage: act_def ACT_T_DEMO_1, 0, 9, 9, 0 act_stat_def1 1, 1, 1, 1 act_stat_def2 1, 1, 32, 1 - act_st_def st_unit_demo_1_cpu_update_attack, NULL, st_unit_demo_1_cpu_update, st_unit_idle + act_st_def st_unit_demo_1_cpu_update, st_unit_idle act_def_meta unit_draw, 0x8C, OAM_FPRIO, NULL unit_demo_thief: @@ -44,7 +44,7 @@ unit_demo_thief: act_def ACT_T_DEMO_1, 0, 9, 9, 0 act_stat_def1 1, 1, 1, 1 act_stat_def2 1, 1, 32, 1 - act_st_def st_unit_demo_1_cpu_update_attack, NULL, st_unit_demo_1_cpu_update, st_unit_idle + act_st_def st_unit_demo_1_cpu_update, st_unit_idle act_def_meta unit_draw, 0x90, OAM_FPRIO, NULL @@ -53,7 +53,7 @@ unit_demo_priest: act_def ACT_T_DEMO_1, 0, 9, 9, 0 act_stat_def1 1, 1, 1, 1 act_stat_def2 1, 1, 32, 1 - act_st_def st_unit_demo_1_cpu_update_attack, NULL, st_unit_demo_1_cpu_update, st_unit_idle + act_st_def st_unit_demo_1_cpu_update, st_unit_idle act_def_meta unit_draw, 0x94, OAM_FPRIO, NULL @@ -63,5 +63,3 @@ st_unit_demo_1_cpu_update: st_unit_demo_1_cpu_update_idle: st_def 0x00, unit_demo_1_cpu_update_idle, st_unit_demo_1_cpu_update_idle -st_unit_demo_1_cpu_update_attack: - st_def 0x00, unit_demo_1_cpu_update_attack, st_unit_demo_1_cpu_update_attack -- 2.30.2