mirror of
https://github.com/ZDoom/Raze.git
synced 2025-02-20 18:42:26 +00:00
- floatified movesprite and the thrust vector.
This commit is contained in:
parent
5365066c05
commit
559fe495fb
7 changed files with 28 additions and 43 deletions
|
@ -575,7 +575,7 @@ inline int clipmove(DVector3& pos, sectortype** const sect, const DVector2& mvec
|
|||
double const walldist, double const ceildist, double const flordist, unsigned const cliptype, CollisionBase& result, int clipmoveboxtracenum = 3)
|
||||
{
|
||||
auto vect = vec3_t(pos.X * worldtoint, pos.Y * worldtoint, pos.Z * zworldtoint);
|
||||
int res = clipmove(vect, sect, int(mvec.X * worldtoint), int(mvec.Y * worldtoint), int(walldist * worldtoint), int(ceildist * zworldtoint), int(flordist * zworldtoint), cliptype, result, clipmoveboxtracenum);
|
||||
int res = clipmove(vect, sect, FloatToFixed<18>(mvec.X), FloatToFixed<18>(mvec.Y), int(walldist * worldtoint), int(ceildist * zworldtoint), int(flordist * zworldtoint), cliptype, result, clipmoveboxtracenum);
|
||||
pos = { vect.X * inttoworld, vect.Y * inttoworld, vect.Z * zinttoworld };
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -228,7 +228,7 @@ DExhumedActor* FindPlayer(DExhumedActor* nSprite, int nDistance, bool dontengage
|
|||
|
||||
DExhumedActor* BuildCreatureChunk(DExhumedActor* pSrc, int nPic, bool bSpecial = false);
|
||||
int PlotCourseToSprite(DExhumedActor* nSprite1, DExhumedActor* nSprite2);
|
||||
void CheckSectorFloor(sectortype* pSector, int z, int *x, int *y);
|
||||
void CheckSectorFloor(sectortype* pSector, double z, DVector2& xy);
|
||||
int GetAngleToSprite(DExhumedActor* nSprite1, DExhumedActor* nSprite2);
|
||||
int GetWallNormal(walltype* nWall);
|
||||
void MoveSector(sectortype* pSector, int nAngle, int *nXVel, int *nYVel);
|
||||
|
|
|
@ -814,8 +814,7 @@ loc_flag:
|
|||
BuildSnake(nPlayer, nHeight);
|
||||
nQuake[nPlayer] = 2.;
|
||||
|
||||
PlayerList[nPlayer].nThrust.X -= bcos(pPlayerActor->int_ang(), 9);
|
||||
PlayerList[nPlayer].nThrust.Y -= bsin(pPlayerActor->int_ang(), 9);
|
||||
PlayerList[nPlayer].nThrust -= pPlayerActor->spr.angle.ToVector() * 2;
|
||||
break;
|
||||
}
|
||||
case kWeaponRing:
|
||||
|
|
|
@ -396,14 +396,13 @@ DExhumedActor* insertActor(sectortype* s, int st)
|
|||
|
||||
Collision movesprite(DExhumedActor* pActor, int dx, int dy, int dz, int ceildist, int flordist, unsigned int clipmask)
|
||||
{
|
||||
DVector2 vect(FixedToFloat<18>(dx), FixedToFloat<18>(dy));
|
||||
|
||||
bTouchFloor = false;
|
||||
|
||||
auto spos = pActor->spr.pos;
|
||||
|
||||
int nSpriteHeight = GetActorHeight(pActor);
|
||||
|
||||
double nSpriteHeight = GetActorHeightF(pActor);
|
||||
int nClipDist = pActor->int_clipdist();
|
||||
|
||||
auto pSector = pActor->sector();
|
||||
assert(pSector);
|
||||
|
||||
|
@ -411,39 +410,33 @@ Collision movesprite(DExhumedActor* pActor, int dx, int dy, int dz, int ceildist
|
|||
|
||||
if ((pSector->Flag & kSectUnderwater) || (floorZ < spos.Z))
|
||||
{
|
||||
dx >>= 1;
|
||||
dy >>= 1;
|
||||
vect *= 0.5;
|
||||
}
|
||||
|
||||
Collision nRet = movespritez(pActor, dz * zinttoworld, nSpriteHeight * zinttoworld, nClipDist);
|
||||
Collision nRet = movespritez(pActor, dz * zinttoworld, nSpriteHeight, nClipDist);
|
||||
|
||||
pSector = pActor->sector(); // modified in movespritez so re-grab this variable
|
||||
|
||||
if (pActor->spr.statnum == 100)
|
||||
{
|
||||
int nPlayer = GetPlayerFromActor(pActor);
|
||||
DVector2 thrust(0, 0);
|
||||
|
||||
int varA = 0;
|
||||
int varB = 0;
|
||||
|
||||
CheckSectorFloor(overridesect, pActor->int_pos().Z, &varB, &varA);
|
||||
|
||||
if (varB || varA)
|
||||
CheckSectorFloor(overridesect, pActor->spr.pos.Z, thrust);
|
||||
if (!thrust.isZero())
|
||||
{
|
||||
PlayerList[nPlayer].nThrust.X = varB;
|
||||
PlayerList[nPlayer].nThrust.Y = varA;
|
||||
PlayerList[nPlayer].nThrust = thrust;
|
||||
}
|
||||
|
||||
dx += PlayerList[nPlayer].nThrust.X;
|
||||
dy += PlayerList[nPlayer].nThrust.Y;
|
||||
vect += PlayerList[nPlayer].nThrust;
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckSectorFloor(overridesect, pActor->int_pos().Z, &dx, &dy);
|
||||
CheckSectorFloor(overridesect, pActor->spr.pos.Z, vect);
|
||||
}
|
||||
|
||||
Collision coll;
|
||||
clipmove(pActor->spr.pos, &pSector, dx, dy, nClipDist, nSpriteHeight, flordist, clipmask, coll);
|
||||
clipmove(pActor->spr.pos, &pSector, FloatToFixed<18>(vect.X), FloatToFixed<18>(vect.Y), nClipDist, int(nSpriteHeight * zworldtoint), flordist, clipmask, coll);
|
||||
if (coll.type != kHitNone) // originally this or'ed the two values which can create unpredictable bad values in some edge cases.
|
||||
{
|
||||
coll.exbits = nRet.exbits;
|
||||
|
@ -620,7 +613,7 @@ DExhumedActor* FindPlayer(DExhumedActor* pActor, int nDistance, bool dontengage)
|
|||
return pPlayerActor;
|
||||
}
|
||||
|
||||
void CheckSectorFloor(sectortype* pSector, int z, int *x, int *y)
|
||||
void CheckSectorFloor(sectortype* pSector, double z, DVector2& xy)
|
||||
{
|
||||
int nSpeed = pSector->Speed;
|
||||
|
||||
|
@ -628,18 +621,15 @@ void CheckSectorFloor(sectortype* pSector, int z, int *x, int *y)
|
|||
return;
|
||||
}
|
||||
|
||||
int nFlag = pSector->Flag;
|
||||
int nAng = nFlag & kAngleMask;
|
||||
DAngle nAng = DAngle::fromBuild(pSector->Flag & kAngleMask);
|
||||
|
||||
if (z >= pSector->int_floorz())
|
||||
if (z >= pSector->floorz)
|
||||
{
|
||||
*x += bcos(nAng, 3) * nSpeed;
|
||||
*y += bsin(nAng, 3) * nSpeed;
|
||||
xy += nAng.ToVector() * nSpeed * 0.5;
|
||||
}
|
||||
else if (nFlag & 0x800)
|
||||
else if (pSector->Flag & 0x800)
|
||||
{
|
||||
*x += bcos(nAng, 4) * nSpeed;
|
||||
*y += bsin(nAng, 4) * nSpeed;
|
||||
xy += nAng.ToVector() * nSpeed;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -369,8 +369,7 @@ void RestartPlayer(int nPlayer)
|
|||
|
||||
nTemperature[nPlayer] = 0;
|
||||
|
||||
plr->nThrust.Y = 0;
|
||||
plr->nThrust.X = 0;
|
||||
plr->nThrust.Zero();
|
||||
|
||||
plr->nDestVertPan = plr->horizon.ohoriz = plr->horizon.horiz = q16horiz(0);
|
||||
plr->nBreathTimer = 90;
|
||||
|
@ -895,8 +894,7 @@ void AIPlayer::Tick(RunListEvent* ev)
|
|||
|
||||
if (bUnderwater)
|
||||
{
|
||||
PlayerList[nPlayer].nThrust.X /= 2;
|
||||
PlayerList[nPlayer].nThrust.Y /= 2;
|
||||
PlayerList[nPlayer].nThrust /= 2;
|
||||
}
|
||||
|
||||
// Trigger Ramses?
|
||||
|
@ -941,8 +939,7 @@ void AIPlayer::Tick(RunListEvent* ev)
|
|||
if (bTouchFloor)
|
||||
{
|
||||
// Damage stuff..
|
||||
PlayerList[nPlayer].nThrust.X /= 2;
|
||||
PlayerList[nPlayer].nThrust.Y /= 2;
|
||||
PlayerList[nPlayer].nThrust /= 2;
|
||||
|
||||
if (nPlayer == nLocalPlayer)
|
||||
{
|
||||
|
@ -2510,8 +2507,7 @@ sectdone:
|
|||
|
||||
if (!PlayerList[nPlayer].nHealth)
|
||||
{
|
||||
PlayerList[nPlayer].nThrust.Y = 0;
|
||||
PlayerList[nPlayer].nThrust.X = 0;
|
||||
PlayerList[nPlayer].nThrust.Zero();
|
||||
|
||||
if (PlayerList[nPlayer].eyelevel >= -11)
|
||||
{
|
||||
|
|
|
@ -92,7 +92,8 @@ struct Player
|
|||
int16_t nPlayerScore;
|
||||
int16_t nPlayerColor;
|
||||
int16_t nPistolClip;
|
||||
vec2_t nPlayerD, nThrust;
|
||||
vec2_t nPlayerD;
|
||||
DVector2 nThrust;
|
||||
int16_t nPlayerOldWeapon;
|
||||
int16_t nPlayerClip;
|
||||
int16_t nPlayerPushSound;
|
||||
|
|
|
@ -336,8 +336,7 @@ void AIRex::Tick(RunListEvent* ev)
|
|||
if (pHitActor->spr.statnum == 100)
|
||||
{
|
||||
auto nPlayer = GetPlayerFromActor(nMov.actor());
|
||||
PlayerList[nPlayer].nThrust.X += (int(vel.X * worldtoint) << 4);
|
||||
PlayerList[nPlayer].nThrust.Y += (int(vel.Y * worldtoint) << 4);
|
||||
PlayerList[nPlayer].nThrust += vel / 4096;
|
||||
pHitActor->vel.Z = -14;
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue