From 3181fbbc846192eb2bed8ebcfd98e11837afb6b4 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sat, 17 Jan 2026 11:17:13 +0100 Subject: [PATCH] player: reworked equipment Equipment is now a separate struct and not part of regular actors. Only the player has equipment. --- src/attributes.s | 8 +++++++- src/defs.s | 18 ++++++++++++------ src/levels.s | 4 ++-- src/macros.inc | 10 +++------- src/wram.s | 2 ++ 5 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/attributes.s b/src/attributes.s index d813a33..335e788 100644 --- a/src/attributes.s +++ b/src/attributes.s @@ -26,7 +26,13 @@ act_attr_get_str: ; returns: ; a: damage value act_attr_get_attack_damage: - ld hl, act_weapon + ; if not player do not use weapon + ld a, [hl] + cp a, ACT_T_PLAYER + jp nz, @unarmed + + ; if player use right hand weapon + ld hl, player_eq+eq_handr add hl, de ld a, [hl] ; load weapon type cp a, 0 ; if 0 -> unarmed diff --git a/src/defs.s b/src/defs.s index c203e6b..61ae288 100644 --- a/src/defs.s +++ b/src/defs.s @@ -74,17 +74,23 @@ ; NNNN0000: debuff status ; 0000NNNN: debuff type .de act_debuff, 1 - ; item ids for each slot - ; each slot type has its own table - ; of items -.de act_armor, 1 -.de act_ring, 1 -.de act_weapon, 1 ; ptr to attribute table .de act_attr, 2 .de act_size, 0 + ; equipment struct + ; list of ptrs to items +.se 0 +.de eq_head, 2 +.de eq_armor, 2 +.de eq_neck, 2 +.de eq_ringl, 2 +.de eq_ringr, 2 +.de eq_handl, 2 +.de eq_handr, 2 +.de eq_size, 0 + ; map flags .se 1 .de MAP_F_DO_FULL_REDRAW, 1 diff --git a/src/levels.s b/src/levels.s index 603f35f..407756a 100644 --- a/src/levels.s +++ b/src/levels.s @@ -14,8 +14,8 @@ l1: ; l1 actor table l1_acts: - actdef ACT_T_BAT, 0, 9, 10, 2, 1, ITEM_NONE, ITEM_NONE, ITEM_NONE, attr_bat - actdef ACT_T_BAT, 0, 1, 2, 2, 1, ITEM_NONE, ITEM_NONE, ITEM_NONE, attr_bat + actdef ACT_T_BAT, 0, 9, 10, 2, 1, attr_bat + actdef ACT_T_BAT, 0, 1, 2, 2, 1, attr_bat .db 0 ; terminate tile_banks_default: diff --git a/src/macros.inc b/src/macros.inc index 0b0e075..ba38410 100644 --- a/src/macros.inc +++ b/src/macros.inc @@ -196,20 +196,16 @@ $1: ; $4: x ; $5: hp ; $6: mp - ; $7: armor - ; $8: ring - ; $9: weapon - ; $10: attributes + ; $7: attributes #macro actdef .db $1, $2, $3, $4 - ; dir, p0 and state + ; p0 and state .db 0, 0 dw $5 dw $6 ; buff/debuff .db 0, 0 - .db $7, $8, $9 - dw $10 + dw $7 #endmacro ; defines an attribute list diff --git a/src/wram.s b/src/wram.s index 0c5372f..465408e 100644 --- a/src/wram.s +++ b/src/wram.s @@ -87,6 +87,8 @@ srand: .adv 2 player_attr: .adv attr_size player_exp: .adv 2 player_level: .adv 1 + ; player equipment +player_eq: .adv eq_size ; player view distance radius player_viewradius: .adv 1 -- 2.30.2