action: Added miss text
authorLukas Krickl <lukas@krickl.dev>
Sun, 24 Aug 2025 06:33:02 +0000 (08:33 +0200)
committerLukas Krickl <lukas@krickl.dev>
Sun, 24 Aug 2025 06:33:02 +0000 (08:33 +0200)
Fixed actor lookup returning actors of type NULL

src/action.s
src/strings.s
src/unit.s

index d121c6b7f9b70d34c4f2671b223e99e6ab7ad14d..b9785a5219e77d56e5e9b6b93e3f8cbaa1c64d7c 100644 (file)
@@ -228,11 +228,10 @@ unit_action_attack_damage_calc:
        call unit_attack_get_attack_tile
        call unit_find_at
 
-       ldnull bc
        ld a, h
        or a, l
        pop de
-       ret z ; no unit found
+       jp z, @miss ; no unit found
 
        push hl
        pop bc
@@ -247,6 +246,13 @@ unit_action_attack_damage_calc:
        
        ldnull bc
        ret
+@miss:
+       ld hl, STR_MISS
+       ld de, UI_STATUS_LINE
+       call puts
+       call ui_request_redraw
+       ldnull bc
+       ret
 
 
        ; default attack state
index 8731dae13153afe798255155e02b9b30774be32a..d3b6f656aa4303d2089f60a80789f5e2fe07a6cf 100644 (file)
@@ -71,6 +71,10 @@ STR_HIT_FOR:
 .str "hit for "
 .db 0
 
+STR_MISS:
+.str "miss"
+.db 0
+
 STR_SLASH:
 .str "/"
 .db 0
index 11971a4b617117557c6f799f49a520955ec22916..6e36a2359f7b2bdfbecb2268b159780397727958 100644 (file)
@@ -837,6 +837,15 @@ unit_find_at:
                push af
                push hl
 
+               push hl
+               ; do not find type null
+               ld de, act_type
+               add hl, de
+               ld a, [hl]
+               pop hl 
+               cp a, 0
+               jr z, @no_match REL
+
                ld de, act_pos_y
                add hl, de 
                ; hl = y pos