- move p->wackedbyactor chase-cam code into applylook() for increased smoothness.

This commit is contained in:
Mitchell Richters 2020-07-28 12:30:09 +10:00
parent baed75ff8a
commit ea98978ae7
3 changed files with 41 additions and 44 deletions

View file

@ -483,20 +483,11 @@ void moveplayers(void) //Players
}
else
{
p->posx = s->x;
p->posy = s->y;
p->posz = s->z - (20 << 8);
p->newowner = -1;
if (p->wackedbyactor >= 0 && sprite[p->wackedbyactor].statnum < MAXSTATUS)
{
int ang = p->getang();
ang += getincangle(ang, getangle(sprite[p->wackedbyactor].x - p->posx, sprite[p->wackedbyactor].y - p->posy)) >> 1;
p->setang(ang & 2047, true);
}
}
s->ang = p->getang();
}

View file

@ -1259,12 +1259,8 @@ void GetInput()
if (!synchronized_input)
{
if (sprite[p->i].extra > 0)
{
applylook(myconnectindex, scaleAdjust);
}
// Do these in the same order as the old code.
applylook(myconnectindex, scaleAdjust);
calcviewpitch(p, scaleAdjust);
sethorizon(myconnectindex, loc.bits, scaleAdjust, true);
}

View file

@ -800,42 +800,52 @@ void applylook(int snum, double factor)
{
auto p = &ps[snum];
p->addrotscrnang(factor * -0.5 * fix16_to_dbl(p->q16rotscrnang));
if (abs(p->q16rotscrnang) < FRACUNIT) p->q16rotscrnang = 0;
p->addlookang(factor * -0.25 * fix16_to_dbl(p->q16look_ang));
if (abs(p->q16look_ang) < FRACUNIT) p->q16look_ang = 0;
if (p->lookLeft)
if (sprite[p->i].extra > 0)
{
p->addlookang(factor * -152);
p->addrotscrnang(factor * 24);
}
p->addrotscrnang(factor * -0.5 * fix16_to_dbl(p->q16rotscrnang));
if (abs(p->q16rotscrnang) < FRACUNIT) p->q16rotscrnang = 0;
if (p->lookRight)
{
p->addlookang(factor * 152);
p->addrotscrnang(factor * -24);
}
p->addlookang(factor * -0.25 * fix16_to_dbl(p->q16look_ang));
if (abs(p->q16look_ang) < FRACUNIT) p->q16look_ang = 0;
if (p->actorsqu >= 0)
{
p->q16ang += fix16_from_dbl(factor * (getincangle(p->getang(), getangle(sprite[p->actorsqu].x - p->posx, sprite[p->actorsqu].y - p->posy)) >> 2));
}
if (p->one_eighty_count < 0 && p->on_crane < 0)
{
fixed_t add = fix16_from_dbl(factor * 128);
p->one_eighty_count += add;
if (p->one_eighty_count > 0)
if (p->lookLeft)
{
// Don't overshoot our target. With variable factor this is possible.
add -= p->one_eighty_count;
p->one_eighty_count = 0;
p->addlookang(factor * -152);
p->addrotscrnang(factor * 24);
}
if (p->lookRight)
{
p->addlookang(factor * 152);
p->addrotscrnang(factor * -24);
}
if (p->actorsqu >= 0)
{
p->q16ang += fix16_from_dbl(factor * (getincangle(p->getang(), getangle(sprite[p->actorsqu].x - p->posx, sprite[p->actorsqu].y - p->posy)) >> 2));
}
if (p->one_eighty_count < 0 && p->on_crane < 0)
{
fixed_t add = fix16_from_dbl(factor * 128);
p->one_eighty_count += add;
if (p->one_eighty_count > 0)
{
// Don't overshoot our target. With variable factor this is possible.
add -= p->one_eighty_count;
p->one_eighty_count = 0;
}
p->q16ang += add;
}
apply_seasick(p, factor);
}
else
{
if (p->wackedbyactor >= 0 && sprite[p->wackedbyactor].statnum < MAXSTATUS)
{
p->q16ang += fix16_from_dbl(factor * (getincangle(p->getang(), getangle(sprite[p->wackedbyactor].x - p->posx, sprite[p->wackedbyactor].y - p->posy)) >> 1));
}
p->q16ang += add;
}
apply_seasick(p, factor);
}
//---------------------------------------------------------------------------