; should contain next state
pop bc
ret
-
- ; performs an attack
- ; based on the units rt_action tmp value
- ; inputs:
- ; de: unit
+
+ ; get the attack location
+ ; input:
+ ; de: actor
; returns:
- ; bc: next action
-unit_action_attack:
- push de
+ ; bc: tile position
+unit_attack_get_attack_tile:
; get location
call unit_get_pos
-
+
ld hl, act_rt_action_dat1
add hl, de ; hl = dat1
jr nz, @not_right REL
inc c ; x++
@not_right:
+ ret
+
+ ; performs an attack
+ ; based on the units rt_action tmp value
+ ; inputs:
+ ; de: unit
+ ; returns:
+ ; bc: next action
+unit_action_attack:
+ push de
+
+ call unit_attack_get_attack_tile
; draw a slash animation at that location
@done:
; set animation timer and delay
- ld bc, st_unit_delay_to_active_template
+ ld bc, st_action_attack_damage_actor
ret
+
+ ; performs damage calculations based on the attacked location
+ ; inputs:
+ ; de: unit
+ ; returns:
+ ; bc: new state
+unit_action_attack_damage_calc:
+ ; TODO: do real damage calculation here
+ ; for now just delete the actor
+
+ call unit_attack_get_attack_tile
+ call unit_find_at
+
+ ; set type to NULL
+ ld de, act_type
+ add hl, de
+ ld a, ACT_T_NULL
+ ld [hl], a
+
+ ldnull bc
+ ret
+
; default attack state
st_action_attack_init:
st_def 0x00, unit_action_attack_pick_direction, st_action_attack_pick_direction
st_action_attack_direction_picked:
st_def 0x00, unit_action_attack, st_action_attack_direction_picked
+st_action_attack_damage_actor:
+ st_def 0x00, unit_action_attack_damage_calc, st_unit_delay_to_active_template