From 922fc3729e6ee3157d66ada774677d42a3956abd Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sun, 21 Dec 2025 12:00:44 +0100 Subject: [PATCH] actor: Attributes are now stored as a ptr in the actor struct --- src/actor.s | 11 +++-------- src/attributes.s | 12 +++--------- src/defs.s | 2 ++ src/levels.s | 4 ++-- src/macros.inc | 2 ++ 5 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/actor.s b/src/actor.s index bed61a2..1e994b3 100644 --- a/src/actor.s +++ b/src/actor.s @@ -696,18 +696,13 @@ act_attack: ; returns: ; bc: attribute table act_load_attr_table: - ld a, [hl] ; load type - add a, a - ld hl, act_attr_table - add a, a - ld b, 0 - ld c, a ; bc = offset into attr table - add hl, bc ; hl = attr ptr + ld hl, act_attr + add hl, de ; hl = attr table ptr ld a, [hl+] ld c, [hl] ld b, a - ; bc = attribute + ; bc = attribute table ret diff --git a/src/attributes.s b/src/attributes.s index 6504f85..e43e19e 100644 --- a/src/attributes.s +++ b/src/attributes.s @@ -1,23 +1,17 @@ - ; table of actor type -> attribute -act_attr_table: - dw attr_null - dw player_attr - dw attr_bat - attr_null: 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: +act_attr_get_str: call act_load_attr_table ; bc = attributes ld hl, attr_str @@ -41,7 +35,7 @@ attr_attack_damage: @unarmed: ; unarmed is just strength / 2 - call attr_get_str + call act_attr_get_str sla a ; divide by 2 cp a, 0 ; damage should at least be 1! ret nz diff --git a/src/defs.s b/src/defs.s index 3e5670d..a2c4051 100644 --- a/src/defs.s +++ b/src/defs.s @@ -76,6 +76,8 @@ .de act_armor, 1 .de act_ring, 1 .de act_weapon, 1 + ; ptr to attribute table +.de act_attr, 2 .de act_size, 0 diff --git a/src/levels.s b/src/levels.s index e65f1e7..cc723b4 100644 --- a/src/levels.s +++ b/src/levels.s @@ -14,8 +14,8 @@ l1: ; l1 actor table l1_acts: - actdef ACT_T_BAT, 0, 4, 6, 2, 1, ITEM_NONE, ITEM_NONE, ITEM_NONE - actdef ACT_T_BAT, 0, 0, 2, 2, 1, ITEM_NONE, ITEM_NONE, ITEM_NONE + actdef ACT_T_BAT, 0, 4, 6, 2, 1, ITEM_NONE, ITEM_NONE, ITEM_NONE, attr_bat + actdef ACT_T_BAT, 0, 0, 2, 2, 1, ITEM_NONE, ITEM_NONE, ITEM_NONE, attr_bat .db 0 ; terminate diff --git a/src/macros.inc b/src/macros.inc index 20b3177..6f71ef7 100644 --- a/src/macros.inc +++ b/src/macros.inc @@ -188,6 +188,7 @@ $1: ; $7: armor ; $8: ring ; $9: weapon + ; $10: attributes #macro actdef .db $1, $2, $3, $4 ; dir, p0 and state @@ -197,6 +198,7 @@ $1: ; buff/debuff .db 0, 0 .db $7, $8, $9 + dw $10 #endmacro ; defines an attribute list -- 2.30.2