diff --git a/src/boss.c b/src/boss.c index bd694a11..aa830406 100644 --- a/src/boss.c +++ b/src/boss.c @@ -87,10 +87,6 @@ Color boss_healthbar_color(AttackType atype) { } static StageProgress* get_spellstage_progress(Attack *a, StageInfo **out_stginfo, bool write) { - if(out_stginfo) { - *out_stginfo = NULL; - } - if(!write || (global.replaymode == REPLAY_RECORD && global.stage->type == STAGE_STORY)) { StageInfo *i = stage_get_by_spellcard(a->info, global.diff); if(i) { @@ -311,6 +307,9 @@ void boss_finish_current_attack(Boss *boss) { if(p) { ++p->num_cleared; } + } else { + // see boss_death for explanation + boss->extraspell = NULL; } } } @@ -420,6 +419,27 @@ void boss_death(Boss **boss) { if((*boss)->acount && (*boss)->attacks[(*boss)->acount-1].type != AT_Move) petal_explosion(35, (*boss)->pos); + if((*boss)->extraspell && !global.continues) { + // unlock the relevant extra spell in spell practice mode if every spell of this boss has been cleared + // this is a temporary mechanic to make extra spells accessible until we integrate them into core game + + StageInfo *i; + AttackInfo *spell = (*boss)->extraspell; + + Attack dummy; + memset(&dummy, 0, sizeof(dummy)); + dummy.info = spell; + dummy.name = spell->name; + dummy.type = AT_ExtraSpell; + + StageProgress *p = get_spellstage_progress(&dummy, &i, true); + + if(p && !p->unlocked) { + log_info("Extra Spell unlocked! %s: %s", i->title, i->subtitle); + p->unlocked = true; + } + } + free_boss(*boss); *boss = NULL; stage_clear_hazards(true); @@ -495,6 +515,13 @@ Attack* boss_add_attack(Boss *boss, AttackType type, char *name, float timeout, return a; } +void boss_set_extra_spell(Boss *boss, AttackInfo *spell) { + assert(boss != NULL); + assert(spell != NULL); + assert(spell->type == AT_ExtraSpell); + boss->extraspell = spell; +} + void boss_generic_move(Boss *b, int time) { if(b->current->info->pos_dest != BOSS_NOMOVE) { GO_TO(b, b->current->info->pos_dest, 0.1) diff --git a/src/boss.h b/src/boss.h index bdca45c1..4c4fe6d3 100644 --- a/src/boss.h +++ b/src/boss.h @@ -94,6 +94,8 @@ typedef struct Boss { int dmg; Color zoomcolor; + + AttackInfo *extraspell; } Boss; Boss* create_boss(char *name, char *ani, char *dialog, complex pos); @@ -119,6 +121,8 @@ void boss_kill_projectiles(void); void boss_preload(void); +void boss_set_extra_spell(Boss *boss, AttackInfo *spellstage); + #define BOSS_DEFAULT_SPAWN_POS (VIEWPORT_W * 0.5 - I * VIEWPORT_H * 0.5) #define BOSS_DEFAULT_GO_POS (VIEWPORT_W * 0.5 + 200.0*I) #define BOSS_NOMOVE (-3142-39942.0*I) diff --git a/src/stages/stage1_events.c b/src/stages/stage1_events.c index 118fcc5b..77166799 100644 --- a/src/stages/stage1_events.c +++ b/src/stages/stage1_events.c @@ -382,6 +382,7 @@ Boss *create_cirno(void) { boss_add_attack_from_info(cirno, stage1_spells+1, false); boss_add_attack(cirno, AT_Normal, "Iceplosion 1", 20, 20000, cirno_iceplosion1, NULL); boss_add_attack_from_info(cirno, stage1_spells+2, false); + boss_set_extra_spell(cirno, stage1_spells+3); start_attack(cirno, cirno->attacks); return cirno; diff --git a/src/stages/stage2_events.c b/src/stages/stage2_events.c index 3c0ed1e2..46231c87 100644 --- a/src/stages/stage2_events.c +++ b/src/stages/stage2_events.c @@ -652,6 +652,7 @@ Boss *create_hina(void) { boss_add_attack(hina, AT_Normal, "Cards2", 17, 15000, hina_cards2, NULL); boss_add_attack_from_info(hina, stage2_spells+1, false); boss_add_attack_from_info(hina, stage2_spells+2 + (global.diff > D_Normal), false); + boss_set_extra_spell(hina, stage2_spells+4); start_attack(hina, hina->attacks); return hina; diff --git a/src/stages/stage3_events.c b/src/stages/stage3_events.c index 3d4fa02b..33fc9f16 100644 --- a/src/stages/stage3_events.c +++ b/src/stages/stage3_events.c @@ -958,6 +958,7 @@ Boss* stage3_create_boss(void) { boss_add_attack_from_info(wriggle, stage3_spells+3, false); boss_add_attack(wriggle, AT_Normal, "", 20, 20000, stage3_boss_prea3, NULL); boss_add_attack_from_info(wriggle, stage3_spells+4, false); + boss_set_extra_spell(wriggle, stage3_spells+5); start_attack(wriggle, wriggle->attacks); return wriggle; diff --git a/src/stages/stage4_events.c b/src/stages/stage4_events.c index 3d895598..ecfde987 100644 --- a/src/stages/stage4_events.c +++ b/src/stages/stage4_events.c @@ -1092,6 +1092,8 @@ Boss *create_kurumi(void) { if(global.diff > D_Normal) { boss_add_attack_from_info(b, stage4_spells+6, false); } + + boss_set_extra_spell(b, stage4_spells+7); start_attack(b, b->attacks); return b; diff --git a/src/stages/stage5_events.c b/src/stages/stage5_events.c index 910ff99b..f73b06f1 100644 --- a/src/stages/stage5_events.c +++ b/src/stages/stage5_events.c @@ -795,6 +795,7 @@ Boss *create_iku(void) { boss_add_attack(b, AT_Normal, "Bolts3", 20, 20000, iku_bolts3, NULL); boss_add_attack_from_info(b, stage5_spells+2, false); boss_add_attack_from_info(b, stage5_spells+(3 + (global.diff > D_Normal)), false); + boss_set_extra_spell(b, stage5_spells+5); return b; } diff --git a/src/stages/stage6_events.c b/src/stages/stage6_events.c index 2daefff3..04c7511b 100644 --- a/src/stages/stage6_events.c +++ b/src/stages/stage6_events.c @@ -1328,6 +1328,7 @@ Boss *create_elly(void) { boss_add_attack_from_info(b, stage6_spells+5, false); boss_add_attack(b, AT_Move, "Explode", 6, 10, elly_baryon_explode, NULL); boss_add_attack_from_info(b, stage6_spells+6, false); + boss_set_extra_spell(b, stage6_spells+7); start_attack(b, b->attacks); return b;