taisei/src/stages/dpstest.c

96 lines
2.2 KiB
C
Raw Normal View History

2018-08-14 00:48:18 +02:00
/*
* This software is licensed under the terms of the MIT License.
2018-08-14 00:48:18 +02:00
* See COPYING for further information.
* ---
2024-05-16 23:30:41 +02:00
* Copyright (c) 2011-2024, Lukas Weber <laochailan@web.de>.
* Copyright (c) 2012-2024, Andrei Alexeyev <akari@taisei-project.org>.
2018-08-14 00:48:18 +02:00
*/
#include "dpstest.h"
2020-10-10 04:55:42 +02:00
#include "enemy_classes.h"
#include "enemy.h"
#include "global.h"
2018-08-14 00:48:18 +02:00
2021-08-12 22:31:06 +02:00
TASK(single_fairy) {
2020-10-10 04:55:42 +02:00
for(;;) {
Enemy *e = espawn_super_fairy(VIEWPORT_W/2, ITEMS(.points = 10));
e->move = move_from_towards(e->pos, BOSS_DEFAULT_GO_POS, 0.025);
2020-10-10 04:55:42 +02:00
WAIT_EVENT(&e->events.killed);
2018-08-14 00:48:18 +02:00
}
2020-10-10 04:55:42 +02:00
}
2018-08-14 00:48:18 +02:00
2020-10-10 04:55:42 +02:00
static void dpstest_single(void) {
INVOKE_TASK(single_fairy);
2018-08-14 00:48:18 +02:00
}
2020-10-10 04:55:42 +02:00
TASK(circling_fairy, { EnemySpawner spawner; cmplx circle_orig; cmplx circle_ofs; }) {
WAIT(20);
2018-08-14 00:48:18 +02:00
2020-10-10 04:55:42 +02:00
Enemy *e = TASK_BIND(ARGS.spawner(VIEWPORT_W/2, NULL));
2018-08-14 00:48:18 +02:00
2020-10-10 04:55:42 +02:00
cmplx org = ARGS.circle_orig;
cmplx ofs = ARGS.circle_ofs;
2018-08-14 00:48:18 +02:00
e->move = move_towards(0, 0, 0.025);
2018-08-14 00:48:18 +02:00
2020-10-10 04:55:42 +02:00
INVOKE_TASK_AFTER(&e->events.killed, circling_fairy, ARGS.spawner, org, ofs);
2018-08-14 00:48:18 +02:00
2020-10-10 04:55:42 +02:00
for(;;YIELD) {
e->move.attraction_point = org + ofs * cdir(global.frames * 0.02);
2018-08-14 00:48:18 +02:00
}
}
2020-10-10 04:55:42 +02:00
static void dpstest_multi(void) {
EnemySpawner spawners[] = {
espawn_fairy_blue,
espawn_fairy_red,
espawn_big_fairy,
espawn_huge_fairy,
espawn_super_fairy,
};
for(int i = 0; i < ARRAY_SIZE(spawners); ++i) {
INVOKE_TASK(circling_fairy,
spawners[i], VIEWPORT_W/2 + I*VIEWPORT_H/3,
128 * cdir(i * M_TAU / ARRAY_SIZE(spawners))
);
}
2018-08-14 00:48:18 +02:00
}
2020-10-10 04:55:42 +02:00
TASK_WITH_INTERFACE(boss_regen, BossAttack) {
INIT_BOSS_ATTACK(&ARGS);
BEGIN_BOSS_ATTACK(&ARGS);
2018-08-14 00:48:18 +02:00
2020-10-10 04:55:42 +02:00
Attack *a = ARGS.attack;
for(;;YIELD) {
real x = pow((a->maxhp - a->hp) / a->maxhp, 0.75) * a->maxhp;
a->hp = clamp(a->hp + x * 0.0025, a->maxhp * 0.05, a->maxhp);
2018-08-14 00:48:18 +02:00
}
}
2020-10-10 04:55:42 +02:00
static void dpstest_boss(void) {
global.boss = create_boss("Baka", "cirno", BOSS_DEFAULT_GO_POS);
boss_add_attack_task(
global.boss, AT_Spellcard, "Masochism “Eternal Torment”",
5184000, 90000, TASK_INDIRECT(BossAttack, boss_regen), NULL
);
boss_engage(global.boss);
2020-10-10 04:55:42 +02:00
}
2018-08-14 00:48:18 +02:00
StageProcs stage_dpstest_single_procs = {
2020-10-10 04:55:42 +02:00
.begin = dpstest_single,
2018-08-14 00:48:18 +02:00
.shader_rules = (ShaderRule[]) { NULL },
};
StageProcs stage_dpstest_multi_procs = {
2020-10-10 04:55:42 +02:00
.begin = dpstest_multi,
2018-08-14 00:48:18 +02:00
.shader_rules = (ShaderRule[]) { NULL },
};
StageProcs stage_dpstest_boss_procs = {
2020-10-10 04:55:42 +02:00
.begin = dpstest_boss,
2018-08-14 00:48:18 +02:00
.shader_rules = (ShaderRule[]) { NULL },
};