From b68b70a5622344de62fc5c2f779f6602b3333270 Mon Sep 17 00:00:00 2001 From: "Andrei \"Akari\" Alexeyev" Date: Sat, 11 Feb 2017 00:34:48 +0200 Subject: [PATCH] Add stage_get_by_spellcard() --- src/boss.c | 6 ++++++ src/stage.c | 11 +++++++++++ src/stage.h | 1 + 3 files changed, 18 insertions(+) diff --git a/src/boss.c b/src/boss.c index a2c3ec94..472ec50d 100644 --- a/src/boss.c +++ b/src/boss.c @@ -176,7 +176,13 @@ void free_attack(Attack *a) { } void start_attack(Boss *b, Attack *a) { +#if DEBUG printf("BOSS start_attack(): %s\n", a->name); + StageInfo *i = stage_get_by_spellcard(a->info, global.diff); + if(i) { + printf("This attack has a spell stage: %u\n", i->id); + } +#endif a->starttime = global.frames + ATTACK_START_DELAY; a->rule(b, EVENT_BIRTH); diff --git a/src/stage.c b/src/stage.c index 48862d55..62515e43 100644 --- a/src/stage.c +++ b/src/stage.c @@ -241,6 +241,17 @@ StageInfo* stage_get(uint16_t n) { return NULL; } +StageInfo* stage_get_by_spellcard(AttackInfo *spell, Difficulty diff) { + if(!spell) + return NULL; + + for(StageInfo *stg = stages; stg->loop; ++stg) + if(stg->spell == spell && stg->difficulty == diff) + return stg; + + return NULL; +} + void stage_start(void) { global.timer = 0; global.frames = 0; diff --git a/src/stage.h b/src/stage.h index 061b1bc3..a56c477d 100644 --- a/src/stage.h +++ b/src/stage.h @@ -68,6 +68,7 @@ typedef struct StageInfo { extern StageInfo stages[]; StageInfo* stage_get(uint16_t); +StageInfo* stage_get_by_spellcard(AttackInfo *spell, Difficulty diff); void stage_init_array(void); void stage_loop(StageRule start, StageRule end, StageRule draw, StageRule event, ShaderRule *shaderrules, int endtime);