From: Lukas Krickl Date: Sat, 30 Aug 2025 03:27:13 +0000 (+0200) Subject: attack: replaced binary flag for ongoing attacks with a counter X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=bc282b9ff3585d96cface186b6ebb1270f6ce4f3;p=gbrg%2F.git attack: replaced binary flag for ongoing attacks with a counter --- diff --git a/src/action.s b/src/action.s index 3670d28..d8080b7 100644 --- a/src/action.s +++ b/src/action.s @@ -212,9 +212,9 @@ unit_action_attack: @done: ; unset flag - ld a, [gameplay_flags] - and a, ~GPF_ATTACK_ONGOING & 0xFF - ld [gameplay_flags], a + ld a, [gpf_attack_ongoing] + dec a + ld [gpf_attack_ongoing], a ; set animation timer and delay ld bc, st_unit_delay_to_active_template @@ -228,9 +228,9 @@ unit_action_attack: unit_action_attack_damage_calc: ; set flag - ld a, [gameplay_flags] - or a, GPF_ATTACK_ONGOING - ld [gameplay_flags], a + ld a, [gpf_attack_ongoing] + inc a + ld [gpf_attack_ongoing], a ; calculate damage push de diff --git a/src/defs.s b/src/defs.s index f31e402..9c47681 100644 --- a/src/defs.s +++ b/src/defs.s @@ -81,10 +81,6 @@ ; this will allow all other units to ; perform their update .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/map.s b/src/map.s index 903e464..045cb60 100644 --- a/src/map.s +++ b/src/map.s @@ -8,6 +8,9 @@ map_load_start: call disableinterrutpts call next_vblank_wait call lcd_off + + xor a, a + ld [gpf_attack_ongoing], a ret ; draws the map diff --git a/src/player.s b/src/player.s index 52b016a..5ca6c0b 100644 --- a/src/player.s +++ b/src/player.s @@ -23,6 +23,11 @@ unit_player_update: ld a, [gameplay_flags] and a, GPF_PLAYER_TURN_TAKEN ret nz + + ; check if an attack is ongoing + ld a, [gpf_attack_ongoing] + cp a, 0 + ret nz push de ld hl, act_oam_flags diff --git a/src/unit.s b/src/unit.s index 6202662..d1fb5f7 100644 --- a/src/unit.s +++ b/src/unit.s @@ -769,8 +769,8 @@ unit_delay_to_active: @not_player: ; do not proceed if an attack animation is ongoing - ld a, [gameplay_flags] - and a, GPF_ATTACK_ONGOING + ld a, [gpf_attack_ongoing] + cp a, 0 jr nz, @delay_again REL ldnull bc diff --git a/src/wram.s b/src/wram.s index 3537764..e506ce1 100644 --- a/src/wram.s +++ b/src/wram.s @@ -79,6 +79,10 @@ redraw_steps: .adv 1 ; dummy oam ; same memory as empty_unit empty_oam: .adv oamsize + + ; > 0 if an actor has an ongoing attack + ; used to delay other actors during the animation +gpf_attack_ongoing: .adv 0 ; can be used for custom state transtions