From: Lukas Krickl Date: Sat, 20 Dec 2025 18:07:02 +0000 (+0100) Subject: attr: added stub for attack damage calculation X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=a73b87abdb665257e1f829247b038202a0607b00;p=gbrg%2F.git attr: added stub for attack damage calculation --- diff --git a/src/attributes.s b/src/attributes.s index 2f84a9a..f21a301 100644 --- a/src/attributes.s +++ b/src/attributes.s @@ -10,3 +10,35 @@ attrdef 0, 0, 0, 0, 0, 0 attr_bat: attrdef 1, 0, 0, 1, 0, 0 + + ; gets strength attribute + ; of a given actor + ; inputs: + ; de: actor + ; returns: + ; a: attribute value + item bounus + buffs - debuffs +attr_get_str: + ret + + ; calculates the attack damage + ; of a given actor + ; inputs: + ; de: actor + ; returns: + ; a: damage value +attr_attack_damage: + ld hl, act_weapon + add hl, de + ld a, [hl] ; load weapon type + cp a, 0 ; if 0 -> unarmed + jp z, @unarmed + ret + +@unarmed: + ; unarmed is just strength / 2 + call attr_get_str + sla a ; divide by 2 + cp a, 0 ; damage should at least be 1! + ret nz + ld a, 1 ; ensure it is at least 1! + ret