From 8acb89a1697527e34fec49d8a1818fc2685aaf2c Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sat, 20 Dec 2025 18:51:43 +0100 Subject: [PATCH] actor: it is now possible for the player to remove actor This will eventually be turned into an attack system. --- src/actor.s | 11 +++++++++-- src/defs.s | 7 +++++++ src/item.s | 2 +- src/macros.inc | 11 ++++++----- src/player.s | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 57 insertions(+), 8 deletions(-) diff --git a/src/actor.s b/src/actor.s index fef3651..291fbe1 100644 --- a/src/actor.s +++ b/src/actor.s @@ -680,5 +680,12 @@ act_move_back: call act_set_tact ret - - + + ; performs an attack + ; depends on the weapon equipped, + ; the current facing direction + ; and the actor's stats + ; inputs: + ; de: actor attacking +actor_attack: + ret diff --git a/src/defs.s b/src/defs.s index 0b7037a..3e5670d 100644 --- a/src/defs.s +++ b/src/defs.s @@ -211,9 +211,16 @@ ; ring type .se 0 + ; item flags +.se 0 + ; if F_RANGE is set the item can reach the furthest tile + ; e.g. weapon attacks with bow +.de ITEM_F_RANGE, 1 + ; item struct .se 0 .de item_type, 1 +.de item_flags, 1 ; used for weapon damage .de item_damage, 1 ; proficiency mask needed to use the item diff --git a/src/item.s b/src/item.s index b3d1b31..70c10bf 100644 --- a/src/item.s +++ b/src/item.s @@ -8,4 +8,4 @@ items_ring: dw null_item null_item: - itemdef 0, 0, 0, 0 + itemdef 0, 0, 0, 0, 0 diff --git a/src/macros.inc b/src/macros.inc index 9450519..20b3177 100644 --- a/src/macros.inc +++ b/src/macros.inc @@ -214,10 +214,11 @@ $1: ; defines an item ; inputs: ; $1: type - ; $2: damage - ; $3: prof mask - ; $4: attribute ptr (may be NULL) + ; $2: flags + ; $3: damage + ; $4: prof mask + ; $5: attribute ptr (may be NULL) #macro itemdef - .db $1, $2, $3 - dw $4 + .db $1, $2, $3, $4 + dw $5 #endmacro diff --git a/src/player.s b/src/player.s index 1a36568..b1b945e 100644 --- a/src/player.s +++ b/src/player.s @@ -61,10 +61,44 @@ player_update: ret + ; player attack call +player_attack: + ; TODO: implement correctly + ; for now just remove an actor if + ; they are near + ld a, [tile_far] + ld b, a + ld a, [tile_far+1] + ld c, a + call map_get_tile + ld de, t_act + add hl, de + + ld a, [hl+] + ld e, [hl] + ld d, a + or a, e + ret z + + xor a, a + dec hl + ld [de], a ; set type to 0 + ld [hl+], a ; clear ptr + ld [hl], a + + ret + ; moves the player ; does not move out of bounds ; based on the last queued input player_handle_move: + ld b, BTNA + input_just + jr z, @not_attack REL + ld de, player + call player_attack +@not_attack: + ld b, DIRLEFT input_just jr z, @not_left REL -- 2.30.2