stage3: finish porting firefly storm

This commit is contained in:
Andrei Alexeyev 2021-02-27 04:26:26 +02:00
parent 0fb9733829
commit cb991be703
No known key found for this signature in database
GPG key ID: 72D26128040B9690

View file

@ -14,7 +14,6 @@
#include "common_tasks.h"
#include "global.h"
DEPRECATED_DRAW_RULE
static void wriggle_fstorm_proj_draw(Projectile *p, int time, ProjDrawRuleArgs args) {
float f = 1-fmin(time/60.0,1);
r_mat_mv_push();
@ -27,7 +26,7 @@ static void wriggle_fstorm_proj_draw(Projectile *p, int time, ProjDrawRuleArgs a
Sprite *s = p->sprite;
Color c = p->color;
c.a = 0;
p->sprite = get_sprite("proj/ball");
p->sprite = res_sprite("proj/ball");
r_mat_mv_scale(f,f,f);
ProjDrawCore(p, &c);
p->sprite = s;
@ -36,53 +35,51 @@ static void wriggle_fstorm_proj_draw(Projectile *p, int time, ProjDrawRuleArgs a
r_mat_mv_pop();
}
static int wriggle_fstorm_proj(Projectile *p, int time) {
if(time < 0) {
return ACTION_ACK;
}
TASK(fstorm_bullet, { BoxedBoss boss; ProjPrototype *proto; cmplx pos; cmplx vel; int convert_time; }) {
Projectile *p = TASK_BIND(PROJECTILE(
.proto = ARGS.proto,
.pos = ARGS.pos,
.color = RGB(0.2, 0.2, 0.6),
.move = move_linear(ARGS.vel),
));
if(cabs(global.plr.pos-p->pos) > 100) {
p->args[2]+=1;
} else {
p->args[2]-=1;
if(creal(p->args[2]) < 0)
p->args[2] = 0;
}
int t = 0;
int turntime = rint(creal(p->args[0]));
int t = rint(creal(p->args[2]));
if(t < turntime) {
float f = t/(float)turntime;
p->color = *RGB(0.3+0.7*(1 - pow(1 - f, 4)), 0.3+0.3*f*f, 0.7-0.7*f);
}
if(t == turntime && global.boss) {
p->args[1] = global.boss->pos-p->pos;
p->args[1] *= 2/cabs(p->args[1]);
p->angle = carg(p->args[1]);
p->birthtime = global.frames;
p->draw_rule = (ProjDrawRule) { wriggle_fstorm_proj_draw };
p->sprite = NULL;
projectile_set_prototype(p, pp_rice);
spawn_projectile_highlight_effect(p);
for(int i = 0; i < 3; ++i) {
tsrand_fill(2);
PARTICLE(
.sprite = "flare",
.pos = p->pos,
.rule = linear,
.timeout = 60,
.args = { (1+afrand(0))*cexp(I*tsrand_a(1)) },
.draw_rule = Shrink,
);
for(;;YIELD) {
if(cabs(global.plr.pos - p->pos) > 100) {
++t;
} else {
t = imax(0, t - 1);
}
play_sound_ex("redirect", 3, false);
if(t >= ARGS.convert_time) {
break;
}
real f = t / (real)ARGS.convert_time;
p->color = *RGB(0.3 + 0.7 * (1 - pow(1 - f, 4)), 0.3 + 0.3 * f * f, 0.7 - 0.7 * f);
}
p->pos += p->args[1];
return ACTION_NONE;
Boss *boss = NOT_NULL(ENT_UNBOX(ARGS.boss));
p->move.velocity = 2 * cnormalize(boss->pos - p->pos);
p->birthtime = global.frames;
p->draw_rule = (ProjDrawRule) { wriggle_fstorm_proj_draw };
p->sprite = NULL;
projectile_set_prototype(p, pp_rice);
spawn_projectile_highlight_effect(p);
for(int i = 0; i < 3; ++i) {
RNG_ARRAY(r, 2);
PARTICLE(
.sprite = "flare",
.pos = p->pos,
.timeout = 60,
.move = move_linear((1 + vrng_real(r[0])) * vrng_dir(r[1])),
.draw_rule = pdraw_timeout_scale(2, 0.01),
);
}
play_sfx_ex("redirect", 3, false);
}
DEFINE_EXTERN_TASK(stage3_spell_firefly_storm) {
@ -94,25 +91,23 @@ DEFINE_EXTERN_TASK(stage3_spell_firefly_storm) {
aniplayer_queue(&boss->ani, "fly", 0);
int convert_time = difficulty_value(40, 55, 75, 100);
cmplx bullet_rotation = cdir(difficulty_value(0.6, 0.6, 0.6, 0));
WAIT(30);
for(int cycle = 0;; ++cycle, WAIT(2)) {
int cnt = 2;
for(int i = 0; i < cnt; ++i) {
real r = tanh(sin(cycle / 200.0));
real r = fmax(0.05, tanh(sin(cycle / 200.0)));
real v = lun ? cos(cycle / 150.0) / pow(cosh(atanh(r)), 2) : 0.5;
cmplx pos = 230 * cdir(cycle * 0.301 + M_TAU / cnt * i) * r;
PROJECTILE(
INVOKE_SUBTASK(fstorm_bullet,
.boss = ENT_BOX(boss),
.proto = (global.diff >= D_Hard) && !(i%10) ? pp_bigball : pp_ball,
.pos = boss->pos+pos,
.color = RGB(0.2,0.2,0.6),
.rule = wriggle_fstorm_proj,
.args = {
convert_time,
cdir((!lun)*0.6) * cnormalize(pos) * (1 + v)
},
.pos = boss->pos + pos,
.vel = bullet_rotation * cnormalize(pos) * (1 + v),
.convert_time = convert_time
);
}
}