mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-06 16:31:47 +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)
|
static void Polyobj_slideThing(mobj_t *mo, fixed_t dx, fixed_t dy)
|
||||||
{
|
{
|
||||||
if (mo->player) { // Do something similar to conveyor movement. -Red
|
if (mo->player) { // Finally this doesn't suck eggs -fickle
|
||||||
mo->player->cmomx += dx;
|
fixed_t cdx, cdy;
|
||||||
mo->player->cmomy += dy;
|
|
||||||
|
|
||||||
dx = FixedMul(dx, CARRYFACTOR);
|
cdx = FixedMul(dx, FRACUNIT-CARRYFACTOR);
|
||||||
dy = FixedMul(dy, CARRYFACTOR);
|
cdy = FixedMul(dy, FRACUNIT-CARRYFACTOR);
|
||||||
|
|
||||||
mo->player->cmomx -= dx;
|
if (mo->player->onconveyor == 1)
|
||||||
mo->player->cmomy -= dy;
|
{
|
||||||
|
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)) {
|
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
|
#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;
|
static INT32 pomovecount = 10000;
|
||||||
INT32 x, y;
|
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++;
|
pomovecount++;
|
||||||
|
|
||||||
|
@ -1334,19 +1355,10 @@ static void Polyobj_rotateThings(polyobj_t *po, vertex_t origin, angle_t delta,
|
||||||
oldxoff = mo->x-origin.x;
|
oldxoff = mo->x-origin.x;
|
||||||
oldyoff = mo->y-origin.y;
|
oldyoff = mo->y-origin.y;
|
||||||
|
|
||||||
if (mo->player) // Hack to fix players sliding off of spinning polys -Red
|
newxoff = FixedMul(oldxoff, c)-FixedMul(oldyoff, s) - oldxoff;
|
||||||
{
|
newyoff = FixedMul(oldyoff, c)+FixedMul(oldxoff, s) - oldyoff;
|
||||||
fixed_t temp;
|
|
||||||
|
|
||||||
temp = FixedMul(oldxoff, c)-FixedMul(oldyoff, s);
|
Polyobj_slideThing(mo, newxoff, newyoff);
|
||||||
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);
|
|
||||||
|
|
||||||
if (turnthings == 2 || (turnthings == 1 && !mo->player)) {
|
if (turnthings == 2 || (turnthings == 1 && !mo->player)) {
|
||||||
mo->angle += delta;
|
mo->angle += delta;
|
||||||
|
|
|
@ -12174,7 +12174,9 @@ void P_PlayerThink(player_t *player)
|
||||||
|
|
||||||
#ifdef POLYOBJECTS
|
#ifdef POLYOBJECTS
|
||||||
if (player->onconveyor == 1)
|
if (player->onconveyor == 1)
|
||||||
player->cmomy = player->cmomx = 0;
|
player->onconveyor = 3;
|
||||||
|
else if (player->onconveyor == 3)
|
||||||
|
player->cmomy = player->cmomx = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
P_DoSuperStuff(player);
|
P_DoSuperStuff(player);
|
||||||
|
|
Loading…
Reference in a new issue