From: Lukas Krickl Date: Wed, 27 Aug 2025 15:49:24 +0000 (+0200) Subject: unit: Added a simple delay flag for when an attack is ongoing X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=470aeae778bcf9d151bc67cf69cdce83855fd52f;p=gbrg%2F.git unit: Added a simple delay flag for when an attack is ongoing --- diff --git a/src/action.s b/src/action.s index 56ca42f..4e6cc7f 100644 --- a/src/action.s +++ b/src/action.s @@ -1,5 +1,5 @@ #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 @@ -211,6 +211,11 @@ unit_action_attack: 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 @@ -221,9 +226,12 @@ unit_action_attack: ; 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 diff --git a/src/defs.s b/src/defs.s index 8f78c52..f31e402 100644 --- a/src/defs.s +++ b/src/defs.s @@ -80,7 +80,11 @@ ; 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 diff --git a/src/unit.s b/src/unit.s index 6e36a23..5f27cb4 100644 --- a/src/unit.s +++ b/src/unit.s @@ -755,8 +755,16 @@ unit_sleep: ; 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