#define ACTION_ATTACK_SPRITE1 0xA0
-#define UNIT_ACTION_ATTACK_ANIM_LEN 16
+#define UNIT_ACTION_ATTACK_ANIM_LEN 1
; sets up default actions for a new game
; for button A and button B
; returns:
; bc: next action
unit_action_attack_pick_direction:
- ld bc, st_action_attack_direction_picked
+ ld bc, st_action_attack_damage_actor
jp unit_action_pick_direction
; generic direction picker
@done:
; set animation timer and delay
- ld bc, st_action_attack_damage_actor
+ ld bc, st_unit_delay_to_active
ret
; performs damage calculations based on the attacked location
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
+ st_def 0x00, unit_action_attack_damage_calc, st_action_attack_direction_picked
ld bc, st_unit_delay_to_active
ret
@attack_started:
- ld bc, st_action_attack_direction_picked
+ ld bc, st_action_attack_damage_actor
ret
#undefine MOVE_MADE
; a: 1 attack performed
; a: 0 no attack
unit_cpu_attack_player:
+ ; first check if x == x player
+ ld hl, act_pos_x
+ add hl, de
+ ld a, [hl]
+ ld b, a ; b = act x
+
+ ld hl, player_unit+act_pos_x
+ ld a, [hl]
+
+ ; they need to be equal to be in range
+ cp a, b
+ jr nz, @not_in_y_range REL
+
ld hl, act_pos_y
add hl, de
ld a, c ; find out which direction
cp a, DISTANCE_AGTB
; jump up or down
- jp z, @attack_up
+ jp nz, @attack_up
jp @attack_down
@not_in_y_range: