attributes: damage is now a 16 bit value
authorLukas Krickl <lukas@krickl.dev>
Sat, 31 Jan 2026 06:08:41 +0000 (07:08 +0100)
committerLukas Krickl <lukas@krickl.dev>
Sat, 31 Jan 2026 06:08:41 +0000 (07:08 +0100)
Added wepaon damage attack stub

src/action.s
src/attributes.s

index 9474f7cef794c1efe295ab356478e8fe67dc387a..df485eb61cf4cf79435bf4cbd7035ce1ad94c339 100644 (file)
@@ -38,14 +38,14 @@ action_attack:
        ret z ; no actor here...
 
        push hl
-       ; hl = actor
-       call act_attr_get_attack_damage
-       ; a = attack damage (source)
-       ld b, a ; b = damage
+       ; hl = target actor
+       ; de = still source actor
+       call act_attr_get_weapon_damage
+       ; bc = damage of source
 
        ; TODO: for now just kill the actor
        ; later we need actual damage calculations
        pop de
-       call act_die
+       call act_attr_take_weapon_damage
 
        ret
index bf753fc94e8aab6037d39de8fcd5117129398308..4266598548804142914d688fc7d764c05c108a18 100644 (file)
@@ -2,6 +2,11 @@
        ; generall attributes are either returned
        ; in a (8 bit stats) or bc (16 bit stats)
 
+       ; values:
+       ;               primary stats (e.g. str) are 8 bit values
+       ;               they are usually returned in a.
+       ;   derived stats are 16 bit values usually returned in bc
+
 attr_null:
 attrdef 0, 0, 0, 0, 0
 
@@ -72,8 +77,8 @@ act_attr_get_str:
        ; inputs:
        ;               de: actor
        ;       returns:
-       ;               a: damage value
-act_attr_get_attack_damage:
+       ;               bc: damage value
+act_attr_get_weapon_damage:
        ; if not player do not use weapon
        ld a, [hl]
        cp a, ACT_T_PLAYER
@@ -92,6 +97,18 @@ act_attr_get_attack_damage:
        call act_attr_get_str
        sra a ; divide by 2
        cp a, 0 ; damage should at least be 1!
-       ret nz
+       jr nz, @not_zero REL
        ld a, 1 ; ensure it is at least 1!
+@not_zero:
+       ld b, 0
+       ld c, a
+       ; bc = damage
+       ret
+
+       ; takes weapon type damage
+       ; inputs:
+       ;               de: actor to take damage
+       ;               bc: damage value
+act_attr_take_weapon_damage:
+       call act_die
        ret