From: Lukas Krickl Date: Sat, 31 Jan 2026 06:08:41 +0000 (+0100) Subject: attributes: damage is now a 16 bit value X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=3bccdd9f8c1054098c5d1f9c758e4708c8b78deb;p=gbrg%2F.git attributes: damage is now a 16 bit value Added wepaon damage attack stub --- diff --git a/src/action.s b/src/action.s index 9474f7c..df485eb 100644 --- a/src/action.s +++ b/src/action.s @@ -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 diff --git a/src/attributes.s b/src/attributes.s index bf753fc..4266598 100644 --- a/src/attributes.s +++ b/src/attributes.s @@ -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