combat: moved combat info to a struct
authorLukas Krickl <lukas@krickl.dev>
Mon, 22 Dec 2025 06:04:08 +0000 (07:04 +0100)
committerLukas Krickl <lukas@krickl.dev>
Mon, 22 Dec 2025 06:04:08 +0000 (07:04 +0100)
src/actor.s
src/defs.s
src/player.s
src/wram.s

index 8bf49f97125a38953b75de56925e44e51f3696e9..8238362667b15254b20e8cce317ea2a2d9bd1a69 100644 (file)
@@ -201,7 +201,7 @@ act_die_table:
        ; player
        dw act_r_nop
        ; bat
-       dw act_die_bat
+       dw act_die_clear_tact
        
        ; actor die table
        ; inputs:
@@ -220,10 +220,12 @@ act_die:
        ld l, a
        jp hl
        
-       ; bat dealloc
+       ; actor dealloc
+       ; sets type to 0
+       ; and clears tact
        ; inputs:
        ;               de: bat
-act_die_bat:
+act_die_clear_tact:
        xor a, a
        ld [de], a ; set type == 0
 
@@ -723,9 +725,12 @@ act_move_back:
        ; depends on the weapon equipped, 
        ; the current facing direction
        ; and the actor's stats
+       ; if dst_act is NULl this returns without effect
+       ; does not play animations or update text
        ; inputs:
-       ;               de: actor attacking
-act_attack:
+       ;               combat_src_act: ptr to source actor
+       ;               combat_dst_act: the target actor
+act_combat:
        ret
        
        ; loads attribute table of an actor 
index f6292d5fb085aeffff54c759a9d1342cb494d2c4..5ff9cd2b763ccfa3c5a5c057b59094a2a3236240 100644 (file)
        ; attr struct pointer
 .de item_attr, 2
 .de item_size, 0
+
+       ; combat struct
+.se 0
+       ; ptr sto source and dst actor
+       ; if dst is NULL the attack fails
+.de combat_src_act, 2
+.de combat_dst_act, 2
+       ; combat results
+
+       ; the damage done
+.de combat_res_damage, 1
+       ; the attack type (e.g. critical, dodge, miss)
+       ; if all flags are 0 == normal hit
+.de combat_res_flags, 1
+.de combat_size, 0
index 2db9143f24a5a27af79713d6ecf53ce16d53bfdb..074beecbad39c136c0564b9b3ce33300eef66fc1 100644 (file)
@@ -77,9 +77,9 @@ player_update:
 player_attack:
        ld de, player
        ld a, player HI
-       ld [combat_src_act], a
+       ld [combat+combat_src_act], a
        ld a, player LO
-       ld [combat_src_act+1], a
+       ld [combat+combat_src_act+1], a
        
        ; TODO: implement correctly
        ; for now just remove an actor if
@@ -93,14 +93,14 @@ player_attack:
        add hl, de
 
        ld a, [hl+]
-       ld [combat_dst_act], a
+       ld [combat+combat_dst_act], a
        ld a, [hl]
-       ld [combat_dst_act+1], a
+       ld [combat+combat_dst_act+1], a
        
        ; for now just die if actor != NULL
-       ld a, [combat_dst_act]
+       ld a, [combat+combat_dst_act]
        ld d, a
-       ld a, [combat_dst_act+1]
+       ld a, [combat+combat_dst_act+1]
        ld e, a
        or a, d
        ret z
index 5f457765630bea74fdb565e88f5ec34b7b32f68c..4bbb29e3a2158c49d0adc61fceb64a375f99e1d4 100644 (file)
@@ -125,7 +125,5 @@ tile_near: .adv 2
 tile_far: .adv 2
 tile_furthest: .adv 2
        
-       ; ptrs to source and dst actor
-       ; if dst is NULL the attack fails
-combat_src_act: .adv 2
-combat_dst_act: .adv 2
+       ; combat data
+combat: .adv combat_size