Skip to content

Commit

Permalink
boss: make extra spell trigger condition more robust
Browse files Browse the repository at this point in the history
Fixes #377
  • Loading branch information
Akaricchi committed Feb 29, 2024
1 parent 2ed26a9 commit e3d8cec
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/boss.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,10 @@ static StageProgress *get_spellstage_progress(Attack *a, StageInfo **out_stginfo
}

static bool boss_should_skip_attack(Boss *boss, Attack *a) {
if(a->type == AT_ExtraSpell || (a->info != NULL && a->info->type == AT_ExtraSpell)) {
if(global.plr.voltage < global.voltage_threshold) {
return true;
}
}

// Skip zero-length spells. Zero-length AT_Move and AT_Normal attacks are ok.
// FIXME: I'm really not sure what was the purpose of this, but for now I'm abusing this to
// conditionally flag the extra spell as skipped. Investigate whether we can remove simplify
// things a bit and remove this function.
if(ATTACK_IS_SPELL(a->type) && a->timeout <= 0) {
return true;
}
Expand Down Expand Up @@ -1068,6 +1065,17 @@ void boss_finish_current_attack(Boss *boss) {
);
}

if(boss->current < boss->attacks + boss->acount - 1) {
// If the next attack is an extra spell, determine whether we have enough voltage now, and
// if not, skip it. This can't be done any later, because we have to know whether to start
// the death sequence this frame (since the extra spell is usually the final one).
Attack *next = boss->current + 1;
if(next->type == AT_ExtraSpell && global.plr.voltage < global.voltage_threshold) {
// see boss_should_skip_attack()
next->timeout = 0;
}
}

boss->current->endtime = global.frames + attack_end_delay(boss);
boss->current->endtime_undelayed = global.frames;

Expand Down Expand Up @@ -1267,7 +1275,6 @@ void process_boss(Boss **pboss) {
}

boss->current++;
assert(boss->current != NULL);

if(boss_should_skip_attack(boss, boss->current)) {
COEVENT_CANCEL_ARRAY(boss->current->events);
Expand Down

0 comments on commit e3d8cec

Please sign in to comment.