projectile: fix .prevpos being set incorrectly

This broke collision lerping, and automatic angle calculation in cases
where position is influenced by external tasks. A stage 2 pattern seems
to have relied on this broken behavior, and was also fixed.
This commit is contained in:
Andrei Alexeyev 2023-08-17 01:22:29 +02:00
parent 070768863f
commit bc1267f0e8
No known key found for this signature in database
GPG key ID: 72D26128040B9690
2 changed files with 9 additions and 2 deletions

View file

@ -549,7 +549,6 @@ void process_projectiles(ProjectileList *projlist, bool collision) {
for(Projectile *proj = projlist->first, *next; proj; proj = next) {
next = proj->next;
proj->prevpos = proj->pos;
if(proj->flags & PFLAG_INTERNAL_DEAD) {
delete_projectile(projlist, proj, NULL);
@ -588,6 +587,7 @@ void process_projectiles(ProjectileList *projlist, bool collision) {
}
}
proj->prevpos = proj->pos;
apply_projectile_collision(projlist, proj, &col);
}

View file

@ -46,6 +46,7 @@ TASK(spinshot_fairy_attack_spawn_projs, {
.pos = o,
.move = move_from_towards(o, o + ofs, 0.1),
.max_viewport_dist = 128,
.flags = PFLAG_MANUALANGLE,
));
ofs *= r;
@ -96,7 +97,12 @@ TASK(spinshot_fairy_attack, {
cmplx ofs = ref_pos - proj_origins[i];
proj_origins[i] += ofs;
p->pos += ofs;
p->move.attraction_point += ofs;
p->move.attraction_point += ofs;
if(p->move.velocity) {
p->angle = carg(p->move.velocity);
}
++live_count;
});
@ -116,6 +122,7 @@ TASK(spinshot_fairy_attack, {
cmplx dir = cdir(p->angle);
p->move = move_accelerated(dir * ARGS.activated_vel_multiplier, dir * ARGS.activated_accel_multiplier);
p->move.retention *= ARGS.activated_retention_multiplier;
p->flags &= ~PFLAG_MANUALANGLE;
++live_count;
});