actor: it is now possible for the player to remove actor
authorLukas Krickl <lukas@krickl.dev>
Sat, 20 Dec 2025 17:51:43 +0000 (18:51 +0100)
committerLukas Krickl <lukas@krickl.dev>
Sat, 20 Dec 2025 17:51:43 +0000 (18:51 +0100)
This will eventually be turned into an attack system.

src/actor.s
src/defs.s
src/item.s
src/macros.inc
src/player.s

index fef365143ce070804d6043c95ae552520b987d09..291fbe19d9753ecd1c163be5ee5d0cd409978300 100644 (file)
@@ -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
index 0b7037ac099f18084ab12131b0f86524019871cd..3e5670d5eab789f029a9155f7d6389914a851c3c 100644 (file)
        ; 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
index b3d1b31e61349cd41e100a28833878122f9b4bbf..70c10bfbbc6f6ee7b7cc19b75f5a0008693ea7df 100644 (file)
@@ -8,4 +8,4 @@ items_ring:
        dw null_item
 
 null_item:
-       itemdef 0, 0, 0, 0
+       itemdef 0, 0, 0, 0, 0
index 9450519be0c7622599d8862dd9abee7b2cc1aa32..20b317767632475685137150695e4bd17a8316d0 100644 (file)
@@ -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
index 1a365680367085cc89cdab947d489d10fba3150f..b1b945eb77ac5f3f688eab21713fc7ce191da72a 100644 (file)
@@ -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