unit: removed dedicated attack state.
authorLukas Krickl <lukas@krickl.dev>
Fri, 15 Aug 2025 16:52:21 +0000 (18:52 +0200)
committerLukas Krickl <lukas@krickl.dev>
Fri, 15 Aug 2025 16:52:21 +0000 (18:52 +0200)
Units now only have an active and idle state they can switch to

src/battle.s
src/defs.s
src/macros.inc
src/player.s
src/unit.s
src/unit_demo.s

index baf55fe626d529455a01aa81fde7f86f0ab7044f..4725d95336f69f5d06a68d50b0c780f32246bf82 100644 (file)
@@ -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
index 187baa10a3a20db1d73c9ec5faf7e2e20ca20bd0..e9a414b419e77b3ec282b1d18a46a2fdb0a6cc7c 100644 (file)
   ; 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
 
index f2ca1a60e8773816e8eacae77d88f0ce9f102979..8cd0b609404da6a21d197956fae7461366b2de26 100644 (file)
 
   ; 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
index 1aa4bcc477da59ad4d22f1696d292b24fafcac60..a4616f5383d12da335f828ca506e6a9c62a2c4b4 100644 (file)
@@ -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:
index d5df12d3e6951c1efd2727fa8e3fc0ca59591631..4920fb149f6d38033cf9a824ee2aefaba0ea4f5b 100644 (file)
@@ -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
index 95c06783ece14b3e43d10ef18f35711095b27e2c..72086216ef7b43547936427cb90883b09324a70a 100644 (file)
@@ -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