action: Added basic attack effect
authorLukas Krickl <lukas@krickl.dev>
Thu, 21 Aug 2025 17:17:15 +0000 (19:17 +0200)
committerLukas Krickl <lukas@krickl.dev>
Thu, 21 Aug 2025 17:17:15 +0000 (19:17 +0200)
For now it simply deletes the hit actor

src/action.s

index 5634416fdc0a6ec5409bae6c4b7998f8e7359d01..d8a9c8c9cccee193be22e96844fd6b5a1f7c22a2 100644 (file)
@@ -120,18 +120,16 @@ unit_action_pick_direction:
        ; should contain next state
        pop bc
        ret
-
-       ; performs an attack
-       ; based on the units rt_action tmp value
-       ;       inputs:
-       ;               de: unit
+       
+       ; get the attack location
+       ; input:
+       ;               de: actor
        ;       returns:
-       ;               bc: next action
-unit_action_attack:    
-       push de
+       ;               bc: tile position
+unit_attack_get_attack_tile:
        ; get location
        call unit_get_pos
-       
+
        ld hl, act_rt_action_dat1
        add hl, de ; hl = dat1
 
@@ -156,6 +154,18 @@ unit_action_attack:
        jr nz, @not_right REL
                inc c ; x++
 @not_right:
+       ret
+
+       ; performs an attack
+       ; based on the units rt_action tmp value
+       ;       inputs:
+       ;               de: unit
+       ;       returns:
+       ;               bc: next action
+unit_action_attack:    
+       push de
+
+       call unit_attack_get_attack_tile
 
 
        ; draw a slash animation at that location
@@ -202,8 +212,30 @@ unit_action_attack:
 
 @done:
        ; set animation timer and delay
-       ld bc, st_unit_delay_to_active_template
+       ld bc, st_action_attack_damage_actor
        ret
+       
+       ; performs damage calculations based on the attacked location
+       ;       inputs:
+       ;               de: unit
+       ;       returns:
+       ;               bc: new state
+unit_action_attack_damage_calc:
+       ; TODO: do real damage calculation here
+       ; for now just delete the actor
+
+       call unit_attack_get_attack_tile
+       call unit_find_at
+
+       ; set type to NULL
+       ld de, act_type
+       add hl, de
+       ld a, ACT_T_NULL
+       ld [hl], a
+       
+       ldnull bc
+       ret
+
 
        ; default attack state
 st_action_attack_init:
@@ -212,3 +244,5 @@ st_action_attack_pick_direction:
        st_def 0x00, unit_action_attack_pick_direction, st_action_attack_pick_direction
 st_action_attack_direction_picked:
        st_def 0x00, unit_action_attack, st_action_attack_direction_picked
+st_action_attack_damage_actor:
+       st_def 0x00, unit_action_attack_damage_calc, st_unit_delay_to_active_template