This will eventually be turned into an attack system.
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
; 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
dw null_item
null_item:
- itemdef 0, 0, 0, 0
+ itemdef 0, 0, 0, 0, 0
; 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
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