mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-30 05:00:46 +00:00
Improvements to polyobjects carrying things:
- Fixed loss of precision in rotate carry causing objects to slide off - Adjusted player carrying logic to make platforms less slippery - Finally obsoleted the player-specific rotate hack now that I found the actual problem :]
This commit is contained in:
parent
1d2f6c9581
commit
a63e9fe002
2 changed files with 35 additions and 21 deletions
|
@ -1001,15 +1001,35 @@ static void Polyobj_pushThing(polyobj_t *po, line_t *line, mobj_t *mo)
|
|||
//
|
||||
static void Polyobj_slideThing(mobj_t *mo, fixed_t dx, fixed_t dy)
|
||||
{
|
||||
if (mo->player) { // Do something similar to conveyor movement. -Red
|
||||
mo->player->cmomx += dx;
|
||||
mo->player->cmomy += dy;
|
||||
if (mo->player) { // Finally this doesn't suck eggs -fickle
|
||||
fixed_t cdx, cdy;
|
||||
|
||||
dx = FixedMul(dx, CARRYFACTOR);
|
||||
dy = FixedMul(dy, CARRYFACTOR);
|
||||
cdx = FixedMul(dx, FRACUNIT-CARRYFACTOR);
|
||||
cdy = FixedMul(dy, FRACUNIT-CARRYFACTOR);
|
||||
|
||||
mo->player->cmomx -= dx;
|
||||
mo->player->cmomy -= dy;
|
||||
if (mo->player->onconveyor == 1)
|
||||
{
|
||||
mo->momx += cdx;
|
||||
mo->momy += cdy;
|
||||
|
||||
// Multiple slides in the same tic, somehow
|
||||
mo->player->cmomx += cdx;
|
||||
mo->player->cmomy += cdy;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mo->player->onconveyor == 3)
|
||||
{
|
||||
mo->momx += cdx - mo->player->cmomx;
|
||||
mo->momy += cdy - mo->player->cmomy;
|
||||
}
|
||||
|
||||
mo->player->cmomx = cdx;
|
||||
mo->player->cmomy = cdy;
|
||||
}
|
||||
|
||||
dx = FixedMul(dx, FRACUNIT - mo->friction);
|
||||
dy = FixedMul(dy, FRACUNIT - mo->friction);
|
||||
|
||||
if (mo->player->pflags & PF_SPINNING && (mo->player->rmomx || mo->player->rmomy) && !(mo->player->pflags & PF_STARTDASH)) {
|
||||
#define SPINMULT 5184 // Consider this a substitute for properly calculating FRACUNIT-friction. I'm tired. -Red
|
||||
|
@ -1282,7 +1302,8 @@ static void Polyobj_rotateThings(polyobj_t *po, vertex_t origin, angle_t delta,
|
|||
{
|
||||
static INT32 pomovecount = 10000;
|
||||
INT32 x, y;
|
||||
angle_t deltafine = delta >> ANGLETOFINESHIFT;
|
||||
angle_t deltafine = (((po->angle + delta) >> ANGLETOFINESHIFT) - (po->angle >> ANGLETOFINESHIFT)) & FINEMASK;
|
||||
// This fineshift trickery replaces the old delta>>ANGLETOFINESHIFT; doing it this way avoids loss of precision causing objects to slide off -fickle
|
||||
|
||||
pomovecount++;
|
||||
|
||||
|
@ -1334,19 +1355,10 @@ static void Polyobj_rotateThings(polyobj_t *po, vertex_t origin, angle_t delta,
|
|||
oldxoff = mo->x-origin.x;
|
||||
oldyoff = mo->y-origin.y;
|
||||
|
||||
if (mo->player) // Hack to fix players sliding off of spinning polys -Red
|
||||
{
|
||||
fixed_t temp;
|
||||
newxoff = FixedMul(oldxoff, c)-FixedMul(oldyoff, s) - oldxoff;
|
||||
newyoff = FixedMul(oldyoff, c)+FixedMul(oldxoff, s) - oldyoff;
|
||||
|
||||
temp = FixedMul(oldxoff, c)-FixedMul(oldyoff, s);
|
||||
oldyoff = FixedMul(oldyoff, c)+FixedMul(oldxoff, s);
|
||||
oldxoff = temp;
|
||||
}
|
||||
|
||||
newxoff = FixedMul(oldxoff, c)-FixedMul(oldyoff, s);
|
||||
newyoff = FixedMul(oldyoff, c)+FixedMul(oldxoff, s);
|
||||
|
||||
Polyobj_slideThing(mo, newxoff-oldxoff, newyoff-oldyoff);
|
||||
Polyobj_slideThing(mo, newxoff, newyoff);
|
||||
|
||||
if (turnthings == 2 || (turnthings == 1 && !mo->player)) {
|
||||
mo->angle += delta;
|
||||
|
|
|
@ -12174,7 +12174,9 @@ void P_PlayerThink(player_t *player)
|
|||
|
||||
#ifdef POLYOBJECTS
|
||||
if (player->onconveyor == 1)
|
||||
player->cmomy = player->cmomx = 0;
|
||||
player->onconveyor = 3;
|
||||
else if (player->onconveyor == 3)
|
||||
player->cmomy = player->cmomx = 0;
|
||||
#endif
|
||||
|
||||
P_DoSuperStuff(player);
|
||||
|
|
Loading…
Reference in a new issue