baryons_explode port

This commit is contained in:
laochailan 2021-09-23 14:34:51 +02:00 committed by Andrei Alexeyev
parent c589a79bbf
commit 0cb56aee4c
No known key found for this signature in database
GPG key ID: 72D26128040B9690
5 changed files with 161 additions and 119 deletions

View file

@ -10,6 +10,7 @@ stage6_src = files(
'nonspells/boss_nonspell_3.c',
'nonspells/boss_nonspell_4.c',
'nonspells/boss_nonspell_5.c',
'nonspells/boss_nonspell_6.c',
'spells/lhc.c',
'spells/toe.c',
'spells/ricci.c',

View file

@ -55,116 +55,3 @@ DEFINE_EXTERN_TASK(stage6_boss_nonspell_5) {
WAIT(interval);
}
}
static int baryon_explode(Enemy *e, int t) {
TIMER(&t);
AT(EVENT_DEATH) {
free_ref(e->args[1]);
petal_explosion(24, e->pos);
play_sfx("boom");
stage_shake_view(15);
for(uint i = 0; i < 3; ++i) {
PARTICLE(
.sprite = "smoke",
.pos = e->pos+10*frand()*cexp(2.0*I*M_PI*frand()),
.color = RGBA(0.2 * frand(), 0.5, 0.4 * frand(), 1.0),
.rule = asymptotic,
.draw_rule = ScaleFade,
.args = { cexp(I*2*M_PI*frand()) * 0.25, 2, (1 + 3*I) },
.timeout = 600 + 50 * nfrand(),
.layer = LAYER_PARTICLE_HIGH | 0x40,
);
}
PARTICLE(
.sprite = "blast_huge_halo",
.pos = e->pos + cexp(4*frand() + I*M_PI*frand()*2),
.color = RGBA(0.2 + frand() * 0.1, 0.6 + 0.4 * frand(), 0.5 + 0.5 * frand(), 0),
.timeout = 500 + 24 * frand() + 5,
.draw_rule = ScaleFade,
.args = { 0, 0, (0.25 + 2.5*I) * (1 + 0.2 * frand()) },
.layer = LAYER_PARTICLE_HIGH | 0x41,
.angle = frand() * 2 * M_PI,
.flags = PFLAG_REQUIREDPARTICLE,
);
PARTICLE(
.sprite = "blast_huge_rays",
.color = color_add(RGBA(0.2 + frand() * 0.3, 0.5 + 0.5 * frand(), frand(), 0.0), RGBA(1, 1, 1, 0)),
.pos = e->pos,
.timeout = 300 + 38 * frand(),
.draw_rule = ScaleFade,
.args = { 0, 0, (0 + 5*I) * (1 + 0.2 * frand()) },
.angle = frand() * 2 * M_PI,
.layer = LAYER_PARTICLE_HIGH | 0x42,
.flags = PFLAG_REQUIREDPARTICLE,
);
PARTICLE(
.sprite = "blast_huge_halo",
.pos = e->pos,
.color = RGBA(3.0, 1.0, 2.0, 1.0),
.timeout = 60 + 5 * nfrand(),
.draw_rule = ScaleFade,
.args = { 0, 0, (0.25 + 3.5*I) * (1 + 0.2 * frand()) },
.layer = LAYER_PARTICLE_HIGH | 0x41,
.angle = frand() * 2 * M_PI,
);
return 1;
}
GO_TO(e, global.boss->pos + (e->pos0-global.boss->pos)*(1.0+0.2*sin(t*0.1)) * cexp(I*t*t*0.0004), 0.05);
if(!(t % 6)) {
PARTICLE(
.sprite = "blast_huge_halo",
.pos = e->pos,
.color = RGBA(3.0, 1.0, 2.0, 1.0),
.timeout = 10,
.draw_rule = ScaleFade,
.args = { 0, 0, (t / 120.0 + 0*I) * (1 + 0.2 * frand()) },
.layer = LAYER_PARTICLE_HIGH | 0x41,
.angle = frand() * 2 * M_PI,
.flags = PFLAG_REQUIREDPARTICLE,
);
}
if(t > 120 && frand() < (t - 120) / 300.0) {
e->hp = 0;
return 1;
}
return 1;
}
void elly_baryon_explode(Boss *b, int t) {
TIMER(&t);
GO_TO(b, BOSS_DEFAULT_GO_POS, 0.05);
AT(20) {
set_baryon_rule(baryon_explode);
}
AT(42) {
audio_bgm_stop(1.0);
}
FROM_TO(0, 200, 1) {
stage_shake_view(_i / 200.0f);
if(_i > 30) {
play_sfx_loop("charge_generic");
}
}
AT(200) {
tsrand_fill(2);
stage_shake_view(40);
play_sfx("boom");
petal_explosion(100, b->pos + 100*afrand(0)*cexp(2.0*I*M_PI*afrand(1)));
enemy_kill_all(&global.enemies);
}
}

View file

@ -0,0 +1,157 @@
/*
* This software is licensed under the terms of the MIT License.
* See COPYING for further information.
* ---
* Copyright (c) 2011-2019, Lukas Weber <laochailan@web.de>.
* Copyright (c) 2012-2019, Andrei Alexeyev <akari@taisei-project.org>.
*/
#include "taisei.h"
#include "nonspells.h"
static void baryons_final_blast(cmplx pos) {
petal_explosion(24, pos);
play_sfx("boom");
stage_shake_view(15);
for(uint i = 0; i < 3; ++i) {
RNG_ARRAY(R, 6);
PARTICLE(
.sprite = "smoke",
.pos = pos+10*vrng_real(R[0]) * vrng_dir(R[1]),
.color = RGBA(0.2 * vrng_real(R[2]), 0.5, 0.4 * vrng_real(R[3]), 1.0),
.move = move_asymptotic_simple(0.25 * vrng_dir(R[4]), 2),
.draw_rule = pdraw_timeout_scalefade(1, 3, 1, 0),
.timeout = vrng_range(R[5], 550, 650),
.layer = LAYER_PARTICLE_HIGH | 0x40,
);
}
{
RNG_ARRAY(R, 8);
PARTICLE(
.sprite = "blast_huge_halo",
.pos = pos + exp(4*vrng_real(R[0])) * vrng_dir(R[1]),
.color = RGBA(vrng_range(R[2], 0.2, 0.3), vrng_range(R[3], 0.6, 1), vrng_range(R[4], 0.5, 1.0), 0),
.timeout = 505 + 24 * vrng_real(R[5]),
.draw_rule = pdraw_timeout_scalefade(0.25, 2.5 * vrng_range(R[6], 1.0, 1.2), 1, 0),
.layer = LAYER_PARTICLE_HIGH | 0x41,
.angle = vrng_angle(R[7]),
.flags = PFLAG_REQUIREDPARTICLE,
);
}
{
RNG_ARRAY(R, 6);
PARTICLE(
.sprite = "blast_huge_rays",
.color = color_add(RGBA(vrng_range(R[0], 0.2, 0.5), vrng_range(R[1], 0.5, 1.0), vrng_real(R[2]), 0.0), RGBA(1, 1, 1, 0)),
.pos = pos,
.timeout = 300 + 38 * vrng_real(R[3]),
.draw_rule = pdraw_timeout_scalefade(0, vrng_range(R[4], 5.0, 6.0), 1, 0),
.angle = vrng_angle(R[5]),
.layer = LAYER_PARTICLE_HIGH | 0x42,
.flags = PFLAG_REQUIREDPARTICLE,
);
}
{
RNG_ARRAY(R, 3);
PARTICLE(
.sprite = "blast_huge_halo",
.pos = pos,
.color = RGBA(3.0, 1.0, 2.0, 1.0),
.timeout = 60 + 5 * vrng_sreal(R[0]),
.draw_rule = pdraw_timeout_scalefade(0.25, vrng_range(R[1], 3.5, 4.2), 1, 0),
.layer = LAYER_PARTICLE_HIGH | 0x41,
.angle = vrng_angle(R[2]),
);
}
}
TASK(baryon_explode_movement, { BoxedEllyBaryons baryons; BoxedBoss boss; }) {
EllyBaryons *baryons = TASK_BIND(ARGS.baryons);
for(int t = 0;; t++) {
cmplx boss_pos = NOT_NULL(ENT_UNBOX(ARGS.boss))->pos;
baryons->center_pos = boss_pos;
for(int i = 0; i < NUM_BARYONS; i++) {
// TODO: define and replace by default position
baryons->target_poss[i] = boss_pos + 150 * cdir(M_TAU / NUM_BARYONS * i) * (1.0 + 0.2 * sin(t * 0.1)) * cdir(t * t * 0.0004);
}
YIELD;
}
}
TASK(baryons_explode, { BoxedEllyBaryons baryons; BoxedBoss boss; }) {
EllyBaryons *baryons = TASK_BIND(ARGS.baryons);
int lifetime = 120;
int interval = 6;
INVOKE_SUBTASK(baryon_explode_movement, ARGS.baryons, ARGS.boss);
bool dead[NUM_BARYONS];
memset(dead, 0, sizeof(dead));
for(int t = 0;; t += WAIT(interval)) {
for(int i = 0; i < NUM_BARYONS; i++) {
if(dead[i]) {
continue;
}
float angle = rng_angle();
PARTICLE(
.sprite = "blast_huge_halo",
.pos = baryons->poss[i],
.color = RGBA(3.0, 1.0, 2.0, 1.0),
.timeout = 10,
.draw_rule = pdraw_timeout_scalefade(t / 120.0 * rng_range(1.0, 1.2), 0, 1, 0),
.layer = LAYER_PARTICLE_HIGH | 0x41,
.angle = angle,
.flags = PFLAG_REQUIREDPARTICLE,
);
if(rng_chance((t - lifetime) / 300.0)) {
dead[i] = true;
baryons_final_blast(baryons->poss[i]);
}
}
}
}
DEFINE_EXTERN_TASK(stage6_boss_baryons_explode) {
STAGE_BOOKMARK(boss-baryons-explode);
Boss *boss = stage6_elly_init_baryons_attack(&ARGS);
BEGIN_BOSS_ATTACK(&ARGS.base);
INVOKE_SUBTASK_DELAYED(20, baryons_explode, ARGS.baryons, ENT_BOX(boss));
boss->move = move_towards(BOSS_DEFAULT_GO_POS, 0.04);
for(int t = 0; t < 200; t++) {
stage_shake_view(t / 200.0f);
if(t > 30) {
play_sfx_loop("charge_generic");
}
if(t == 42) {
audio_bgm_stop(1.0);
}
YIELD;
}
stage_shake_view(40);
play_sfx("boom");
real rad = 100 * rng_real();
petal_explosion(100, boss->pos + rad * rng_dir());
}

View file

@ -22,6 +22,4 @@ DECLARE_EXTERN_TASK_WITH_INTERFACE(stage6_boss_nonspell_2, ScytheAttack);
DECLARE_EXTERN_TASK(stage6_boss_paradigm_shift, { BossAttackTaskArgs base; BoxedEllyScythe scythe; BoxedEllyBaryons baryons; });
DECLARE_EXTERN_TASK_WITH_INTERFACE(stage6_boss_nonspell_4, BaryonsAttack);
DECLARE_EXTERN_TASK_WITH_INTERFACE(stage6_boss_nonspell_5, BaryonsAttack);
void elly_baryon_explode(Boss*, int);
DECLARE_EXTERN_TASK_WITH_INTERFACE(stage6_boss_baryons_explode, BaryonsAttack);

View file

@ -285,11 +285,10 @@ TASK(spawn_boss, NO_ARGS) {
boss_add_attack_from_info_with_args(boss, &stage6_spells.baryon.spacetime_curvature, baryons_args.base);
boss_add_attack_task_with_args(boss, AT_Normal, "Baryon2", 50, 55000, TASK_INDIRECT(BaryonsAttack, stage6_boss_nonspell_5).base, NULL, baryons_args.base);
boss_add_attack_from_info_with_args(boss, &stage6_spells.baryon.higgs_boson_uncovered, baryons_args.base);
//boss_add_attack_from_info(b, &stage6_spells.extra.curvature_domination, false);
boss_add_attack_task_with_args(boss, AT_Move, "Explode", 4, 0, TASK_INDIRECT(BaryonsAttack, stage6_boss_baryons_explode).base, NULL, baryons_args.base);
/*
boss_add_attack_from_info(b, &stage6_spells.extra.curvature_domination, false);
boss_add_attack(b, AT_Move, "Explode", 4, 0, elly_baryon_explode, NULL);
boss_add_attack(b, AT_Move, "Move to center", 4, 0, elly_goto_center, NULL);
boss_add_attack(b, AT_Immediate, "Final dialog", 0, 0, elly_insert_interboss_dialog, NULL);
boss_add_attack(b, AT_Move, "ToE transition", 7, 0, elly_begin_toe, NULL);