; returns:
; bc: next action
unit_action_attack_pick_direction:
+ ld bc, st_action_attack_direction_picked
+ jp unit_action_pick_direction
+
+ ; generic direction picker
+ ; press B to abort
+ ; press keyopad to pick direction
+ ; inputs:
+ ; de: unit
+ ; bc: next success state
+ ; returns:
+ ; bc: null if no press
+ ; bc: unit_switch_to_active -> B pressed
+ ; bc: bc input -> direction pressed
+ ; act_rt_action_tmp: writes pressed bit BTNUP, BTNDOWN, BTNLEFT, BTNRIGHT
+unit_action_pick_direction:
+ ld hl, act_rt_action_tmp
+ add hl, de ; hl = act_rt_action
+
+ ; save next state
+ push bc
+
; b to abort
ld b, BTNB
input_just
+ pop bc ; need to pop in case of jp
jp nz, unit_switch_to_active
+ push bc ; save again..
+
+
+ ld b, BTNUP
+ input_just
+ jr nz, @direction_pressed REL
+
+ ld b, BTNDOWN
+ input_just
+ jr nz, @direction_pressed REL
+
+ ld b, BTNLEFT
+ input_just
+ jr nz, @direction_pressed REL
+
+ ld b, BTNRIGHT
+ input_just
+ jr nz, @direction_pressed REL
+
+ pop bc ; remove from stack
+
ldnull bc
ret
+@direction_pressed:
+ ld a, b
+ ld [hl], a ; write pressed button to action tmp
+ ; should contain next state
+ pop bc
+ ret
+
+
+ ; performs an attack
+ ; based on the units rt_action tmp value
+ ; inputs:
+ ; de: unit
+ ; returns:
+ ; bc: next action
+unit_action_attack:
+ jp unit_switch_to_active
+ ret
; default attack state
st_action_attack_init:
st_def 0x00, unit_action_attack_pick_direction_init, st_action_attack_pick_direction
st_action_attack_pick_direction:
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
; last collision with actor
; set during unit_collision_woth_any_other
.de act_rt_collided_with, 2
+ ; temporary buffer for any action picked
+.de act_rt_action_tmp, 1
; sub-tile drawing vars
; during this animation the actor is already technically in its new
#define DISTANCE_BGTA 1
#define DISTANCE_AGTB 0
+