unit_cpu: Added stub for attack state
authorLukas Krickl <lukas@krickl.dev>
Tue, 26 Aug 2025 03:48:35 +0000 (05:48 +0200)
committerLukas Krickl <lukas@krickl.dev>
Tue, 26 Aug 2025 03:48:35 +0000 (05:48 +0200)
src/unit_cpu.s

index e6c2af40308ae55b74483463da7ad5f2dc9e3f43..8128f8543083c252fdaca88552636084fe62e171 100644 (file)
@@ -35,8 +35,10 @@ unit_handle_cpu_inputs:
        ; check if dead
        ; if so set type to 0
        call unit_cpu_check_dead
+       ldnull bc
        ret z
        
+       
        ; check if player has taken turn
        ; if not exit
        ldnull bc
@@ -44,6 +46,12 @@ unit_handle_cpu_inputs:
        and a, GPF_PLAYER_TURN_TAKEN
        ret z
        
+       ; attempt an attack
+       ; and jump to move made if attack was performed
+       call unit_cpu_attack_player
+       cp a, 0
+       jp nz, @move_made
+       
        ; clear move made buffer
        xor a, a
        ld [MOVE_MADE], a
@@ -127,6 +135,18 @@ unit_handle_cpu_inputs:
 #undefine MOVE_MADE
 
        
+       ; performs an attack
+       ; in the direction of the player
+       ; checks if player is on tile next to current unit
+       ; inputs:
+       ;               de: actors
+       ;       returns:
+       ;               a: 1 attack performed
+       ;               a: 0 no attack
+unit_cpu_attack_player:
+       ld a, 0 ; no attack
+       ret
+       
        ; moves actor into a random direction
        ; inputs:
        ;       de: actor