actor: Attributes are now stored as a ptr in the actor struct
authorLukas Krickl <lukas@krickl.dev>
Sun, 21 Dec 2025 11:00:44 +0000 (12:00 +0100)
committerLukas Krickl <lukas@krickl.dev>
Sun, 21 Dec 2025 11:00:44 +0000 (12:00 +0100)
src/actor.s
src/attributes.s
src/defs.s
src/levels.s
src/macros.inc

index bed61a2472f681d534acc755a7aa92c782be82ca..1e994b354d6eceaaa4385a904081abe8a70fef66 100644 (file)
@@ -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
index 6504f8537b2434ce5151d2ec18cd0764608ce918..e43e19edc2d32ecf3733d02cb02f57ad4521cf31 100644 (file)
@@ -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
index 3e5670d5eab789f029a9155f7d6389914a851c3c..a2c4051f4e71db1d504eb190f6f44760987bf208 100644 (file)
@@ -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
 
  
index e65f1e7b7b9f475fc9ca63168ce7bae8676fc412..cc723b4a8a432af6730b6af4831cf3716a025fbc 100644 (file)
@@ -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
        
 
index 20b317767632475685137150695e4bd17a8316d0..6f71ef7e2545e76a2ea1fef904ea196cfd3ffbea 100644 (file)
@@ -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