ret z ; no actor here...
push hl
- ; hl = actor
- call act_attr_get_attack_damage
- ; a = attack damage (source)
- ld b, a ; b = damage
+ ; hl = target actor
+ ; de = still source actor
+ call act_attr_get_weapon_damage
+ ; bc = damage of source
; TODO: for now just kill the actor
; later we need actual damage calculations
pop de
- call act_die
+ call act_attr_take_weapon_damage
ret
; generall attributes are either returned
; in a (8 bit stats) or bc (16 bit stats)
+ ; values:
+ ; primary stats (e.g. str) are 8 bit values
+ ; they are usually returned in a.
+ ; derived stats are 16 bit values usually returned in bc
+
attr_null:
attrdef 0, 0, 0, 0, 0
; inputs:
; de: actor
; returns:
- ; a: damage value
-act_attr_get_attack_damage:
+ ; bc: damage value
+act_attr_get_weapon_damage:
; if not player do not use weapon
ld a, [hl]
cp a, ACT_T_PLAYER
call act_attr_get_str
sra a ; divide by 2
cp a, 0 ; damage should at least be 1!
- ret nz
+ jr nz, @not_zero REL
ld a, 1 ; ensure it is at least 1!
+@not_zero:
+ ld b, 0
+ ld c, a
+ ; bc = damage
+ ret
+
+ ; takes weapon type damage
+ ; inputs:
+ ; de: actor to take damage
+ ; bc: damage value
+act_attr_take_weapon_damage:
+ call act_die
ret