#define ACTION_ATTACK_SPRITE1 0xA0
-#define UNIT_ACTION_ATTACK_ANIM_LEN 1
+#define UNIT_ACTION_ATTACK_ANIM_LEN 16
; sets up default actions for a new game
; for button A and button B
ret
@done:
+ ; unset flag
+ ld a, [gameplay_flags]
+ and a, ~GPF_ATTACK_ONGOING & 0xFF
+ ld [gameplay_flags], a
+
; set animation timer and delay
ld bc, st_unit_delay_to_active
ret
; returns:
; bc: new state
unit_action_attack_damage_calc:
- ; TODO: do real damage calculation here
- ; for now just delete the actor
+ ; set flag
+ ld a, [gameplay_flags]
+ or a, GPF_ATTACK_ONGOING
+ ld [gameplay_flags], a
+ ; calculate damage
push de
call unit_attack_get_attack_tile
call unit_find_at
; set if the player has taken their turn
; this will allow all other units to
; perform their update
-.de GPF_PLAYER_TURN_TAKEN, 1
+.de GPF_PLAYER_TURN_TAKEN, 2
+ ; set while an attack animation is playing
+ ; delay to active actor stats should wait until this
+ ; is cleared
+.de GPF_ATTACK_ONGOING, 4
; cell flags
.se 1
; inputs:
; de: unit
unit_delay_to_active:
+ ; do not proceed if an attack animation is ongoing
+ ld a, [gameplay_flags]
+ and a, GPF_ATTACK_ONGOING
+ jr nz, @delay_again REL
+
ldnull bc
ret
+@delay_again:
+ ld bc, st_unit_delay_to_active
+ ret
; inputs
; de: actor