attack: Added player UI redraw to attack
authorLukas Krickl <lukas@krickl.dev>
Wed, 27 Aug 2025 16:31:57 +0000 (18:31 +0200)
committerLukas Krickl <lukas@krickl.dev>
Wed, 27 Aug 2025 16:31:57 +0000 (18:31 +0200)
src/action.s
src/ui.s
src/unit_cpu.s

index 4c3787a067073b192bca80d3e759c81f5c254dd5..3670d285996eec977b325129bd5553d526b5fc20 100644 (file)
@@ -226,6 +226,7 @@ unit_action_attack:
        ;       returns:
        ;               bc: new state
 unit_action_attack_damage_calc:
+
        ;  set flag
        ld a, [gameplay_flags]
        or a, GPF_ATTACK_ONGOING
@@ -240,6 +241,7 @@ unit_action_attack_damage_calc:
        or a, l
        pop de
        jp z, @miss ; no unit found
+       
 
        push hl
        pop bc
@@ -251,6 +253,7 @@ unit_action_attack_damage_calc:
 
        ld hl, STR_HIT_FOR
        call ui_draw_status_stat
+       call ui_redraw_player
        
        ldnull bc
        ret
@@ -258,7 +261,6 @@ unit_action_attack_damage_calc:
        ld hl, STR_MISS
        ld de, UI_STATUS_LINE
        call puts
-       call ui_redraw_hp
        call ui_request_redraw
        ldnull bc
        ret
index a95958a5e89e496017f60d1da5429586cd0e3f89..8b9e8b5df6b3e98d5a6997efd92365dac7c64b3b 100644 (file)
--- a/src/ui.s
+++ b/src/ui.s
@@ -18,7 +18,14 @@ ui_init:
 
   call ui_request_redraw
   ret
-
+       
+       ; redraws player stats
+       ; preserves all
+ui_redraw_player:
+       push_all
+       call ui_redraw_hp
+       pop_all
+       ret
   
   ; updates HP UI
 ui_redraw_hp:
index a3bb9e6818c260370cafbbca16ac3965f4d432fb..fa2c33b9cb7dfc2b1ac6f558cdb8c62bd734f024 100644 (file)
@@ -172,6 +172,14 @@ unit_cpu_attack_player:
        ; hl = rt action dat 1
        ld hl, act_rt_action_dat1
        add hl, de
+       
+       push af
+       inc hl ; rt action dat 2
+       ; clear attack frame timer
+       xor a, a
+       ld [hl], a
+       dec hl ; back to dat 1
+       pop af
 
        ; check y distance
        call distance