make extra spells unlockable for practice

This commit is contained in:
Andrei "Akari" Alexeyev 2017-09-11 08:39:58 +03:00
parent ae4eb3746f
commit 779d5ac1f7
No known key found for this signature in database
GPG key ID: 048C3D2A5648B785
8 changed files with 42 additions and 4 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;
}

View file

@ -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;