Special stages for DPS testing

This commit is contained in:
Andrei Alexeyev 2018-08-14 01:48:18 +03:00
parent 3f79af227c
commit c43f4d8032
No known key found for this signature in database
GPG key ID: 363707CD4C7FE8A4
7 changed files with 142 additions and 33 deletions

View file

@ -134,7 +134,7 @@ static StageProgress* get_spellstage_progress(Attack *a, StageInfo **out_stginfo
}
}
#if DEBUG
else if(a->type == AT_Spellcard || a->type == AT_ExtraSpell) {
else if((a->type == AT_Spellcard || a->type == AT_ExtraSpell) && global.stage->type != STAGE_SPECIAL) {
log_warn("FIXME: spellcard '%s' is not available in spell practice mode!", a->name);
}
#endif
@ -297,14 +297,14 @@ static void ent_draw_boss(EntityInterface *ent) {
draw_sprite_batched_p(creal(boss->pos), cimag(boss->pos) + 6*sin(global.frames/25.0), aniplayer_get_frame(&boss->ani));
r_color4(1, 1, 1, 1);
if(!boss->current)
return;
if(boss->current->type == AT_Move && global.frames - boss->current->starttime > 0 && boss_attack_is_final(boss, boss->current))
return;
draw_boss_text(ALIGN_LEFT, 10, 20, boss->name, "standard", RGB(1, 1, 1));
if(!boss->current)
return;
if(ATTACK_IS_SPELL(boss->current->type))
spell_opening(boss, global.frames - boss->current->starttime);
@ -341,6 +341,9 @@ static void ent_draw_boss(EntityInterface *ent) {
int maxhpspan = 0;
int hpspan = 0;
int nextspell, prevspell;
// FIXME: this does not work when the boss has just one attack!
for(nextspell = 0; nextspell < boss->acount - 1; nextspell++) {
if(boss_should_skip_attack(boss,&boss->attacks[nextspell]))
continue;
@ -349,7 +352,6 @@ static void ent_draw_boss(EntityInterface *ent) {
break;
}
for(prevspell = nextspell; prevspell > 0; prevspell--) {
if(boss_should_skip_attack(boss,&boss->attacks[prevspell]))
continue;

View file

@ -26,6 +26,11 @@
#include "stagedraw.h"
#include "stageobjects.h"
#ifdef DEBUG
#define DPSTEST
#include "stages/dpstest.h"
#endif
static size_t numstages = 0;
StageInfo *stages = NULL;
@ -64,7 +69,7 @@ static void add_spellpractice_stages(int *spellnum, bool (*filter)(AttackInfo*),
for(int i = 0 ;; ++i) {
StageInfo *s = stages + i;
if(s->type == STAGE_SPELL) {
if(s->type == STAGE_SPELL || !s->spell) {
break;
}
@ -102,6 +107,12 @@ void stage_init_array(void) {
add_stage(5, &stage5_procs, STAGE_STORY, "Stage 5", "Climbing the Tower of Babel", (AttackInfo*)&stage5_spells, D_Any);
add_stage(6, &stage6_procs, STAGE_STORY, "Stage 6", "Roof of the World", (AttackInfo*)&stage6_spells, D_Any);
#ifdef DPSTEST
add_stage(0x40|0, &stage_dpstest_single_procs, STAGE_SPECIAL, "DPS Test", "Single target", NULL, D_Normal);
add_stage(0x40|1, &stage_dpstest_multi_procs, STAGE_SPECIAL, "DPS Test", "Multiple targets", NULL, D_Normal);
add_stage(0x40|2, &stage_dpstest_boss_procs, STAGE_SPECIAL, "DPS Test", "Boss", NULL, D_Normal);
#endif
// generate spellpractice stages
add_spellpractice_stages(&spellnum, spellfilter_normal, STAGE_SPELL_BIT);
add_spellpractice_stages(&spellnum, spellfilter_extra, STAGE_SPELL_BIT | STAGE_EXTRASPELL_BIT);

View file

@ -66,6 +66,7 @@ typedef enum StageType {
STAGE_STORY = 1,
STAGE_EXTRA,
STAGE_SPELL,
STAGE_SPECIAL,
} StageType;
typedef struct StageProcs StageProcs;

100
src/stages/dpstest.c Normal file
View file

@ -0,0 +1,100 @@
/*
* This software is licensed under the terms of the MIT-License
* See COPYING for further information.
* ---
* Copyright (c) 2011-2018, Lukas Weber <laochailan@web.de>.
* Copyright (c) 2012-2018, Andrei Alexeyev <akari@alienslab.net>.
*/
#include "taisei.h"
#include "dpstest.h"
#include "global.h"
#include "enemy.h"
#define DPSTEST_HP 90000
static void dpstest_stub_proc(void) { }
static int dpstest_dummy(Enemy *e, int t) {
e->hp = DPSTEST_HP;
if(t > 0) {
e->pos += e->args[0];
}
return ACTION_NONE;
}
static void stage_dpstest_single_events(void) {
TIMER(&global.timer);
AT(0) {
create_enemy1c(VIEWPORT_W/2 + VIEWPORT_H/3*I, DPSTEST_HP, BigFairy, dpstest_dummy, 0);
}
}
static void stage_dpstest_multi_events(void) {
TIMER(&global.timer);
AT(0) {
create_enemy1c(VIEWPORT_W/2 + VIEWPORT_H/3*I, DPSTEST_HP, BigFairy, dpstest_dummy, 0);
create_enemy1c(-64 + VIEWPORT_W/2 + VIEWPORT_H/3*I, DPSTEST_HP, Fairy, dpstest_dummy, 0);
create_enemy1c(+64 + VIEWPORT_W/2 + VIEWPORT_H/3*I, DPSTEST_HP, Fairy, dpstest_dummy, 0);
}
if(!(global.timer % 16)) {
create_enemy1c(-16 + VIEWPORT_H/5*I, DPSTEST_HP, Swirl, dpstest_dummy, 4);
}
if(!((global.timer + 8) % 16)) {
create_enemy1c(VIEWPORT_W+16 + (VIEWPORT_H/5 - 32)*I, DPSTEST_HP, Swirl, dpstest_dummy, -4);
}
}
static void stage_dpstest_boss_rule(Boss *b, int t) {
if(t >= 0) {
double x = pow((b->current->maxhp - b->current->hp) / b->current->maxhp, 0.75) * b->current->maxhp;
b->current->hp = clamp(b->current->hp + x * 0.0025, b->current->maxhp * 0.05, b->current->maxhp);
}
}
static void stage_dpstest_boss_events(void) {
TIMER(&global.timer);
AT(0) {
global.boss = create_boss("Baka", "cirno", NULL, BOSS_DEFAULT_GO_POS);
boss_add_attack(global.boss, AT_Move, "", 1, DPSTEST_HP, stage_dpstest_boss_rule, NULL);
boss_add_attack(global.boss, AT_Spellcard, "Masochism ~ Eternal Torment", 5184000, DPSTEST_HP, stage_dpstest_boss_rule, NULL);
}
}
StageProcs stage_dpstest_single_procs = {
.begin = dpstest_stub_proc,
.preload = dpstest_stub_proc,
.end = dpstest_stub_proc,
.draw = dpstest_stub_proc,
.update = dpstest_stub_proc,
.event = stage_dpstest_single_events,
.shader_rules = (ShaderRule[]) { NULL },
};
StageProcs stage_dpstest_multi_procs = {
.begin = dpstest_stub_proc,
.preload = dpstest_stub_proc,
.end = dpstest_stub_proc,
.draw = dpstest_stub_proc,
.update = dpstest_stub_proc,
.event = stage_dpstest_multi_events,
.shader_rules = (ShaderRule[]) { NULL },
};
StageProcs stage_dpstest_boss_procs = {
.begin = dpstest_stub_proc,
.preload = dpstest_stub_proc,
.end = dpstest_stub_proc,
.draw = dpstest_stub_proc,
.update = dpstest_stub_proc,
.event = stage_dpstest_boss_events,
.shader_rules = (ShaderRule[]) { NULL },
};

16
src/stages/dpstest.h Normal file
View file

@ -0,0 +1,16 @@
/*
* This software is licensed under the terms of the MIT-License
* See COPYING for further information.
* ---
* Copyright (c) 2011-2018, Lukas Weber <laochailan@web.de>.
* Copyright (c) 2012-2018, Andrei Alexeyev <akari@alienslab.net>.
*/
#pragma once
#include "taisei.h"
#include "stage.h"
extern StageProcs stage_dpstest_single_procs;
extern StageProcs stage_dpstest_multi_procs;
extern StageProcs stage_dpstest_boss_procs;

View file

@ -13,3 +13,9 @@ stages_src = files(
'stage6.c',
'stage6_events.c',
)
if is_debug_build
stages_src += files(
'dpstest.c',
)
endif

View file

@ -1107,7 +1107,6 @@ int stage1_tritoss(Enemy *e, int t) {
return 1;
}
// #define DPSTEST
// #define BULLET_TEST
#ifdef BULLET_TEST
@ -1122,18 +1121,6 @@ static int proj_rotate(Projectile *p, int t) {
}
#endif
#ifdef DPSTEST
static int dpsdummy(Enemy *e, int t) {
e->hp = 9000;
if(t > 0) {
e->pos += e->args[0];
}
return ACTION_NONE;
}
#endif
void stage1_events(void) {
TIMER(&global.timer);
@ -1141,20 +1128,6 @@ void stage1_events(void) {
stage_start_bgm("stage1");
}
#ifdef DPSTEST
AT(0) {
create_enemy1c(VIEWPORT_W/2 + VIEWPORT_H/3*I, 9000, BigFairy, dpsdummy, 0);
create_enemy1c(-64 + VIEWPORT_W/2 + VIEWPORT_H/3*I, 9000, BigFairy, dpsdummy, 0);
create_enemy1c(+64 + VIEWPORT_W/2 + VIEWPORT_H/3*I, 9000, BigFairy, dpsdummy, 0);
}
if(!(global.timer % 16)) {
create_enemy1c(-16 + VIEWPORT_H/5*I, 9000, Swirl, dpsdummy, 2);
}
return;
#endif
#ifdef BULLET_TEST
if(!global.projs) {
PROJECTILE(