mirror of
https://github.com/DrBeef/Raze.git
synced 2025-01-20 08:00:56 +00:00
- floatified most of the grenade code and GetWallNormal
This commit is contained in:
parent
54a55b3d09
commit
029e0f6fa4
7 changed files with 28 additions and 27 deletions
|
@ -229,7 +229,7 @@ DExhumedActor* BuildCreatureChunk(DExhumedActor* pSrc, int nPic, bool bSpecial =
|
||||||
int PlotCourseToSprite(DExhumedActor* nSprite1, DExhumedActor* nSprite2);
|
int PlotCourseToSprite(DExhumedActor* nSprite1, DExhumedActor* nSprite2);
|
||||||
void CheckSectorFloor(sectortype* pSector, double z, DVector2& xy);
|
void CheckSectorFloor(sectortype* pSector, double z, DVector2& xy);
|
||||||
int GetAngleToSprite(DExhumedActor* nSprite1, DExhumedActor* nSprite2);
|
int GetAngleToSprite(DExhumedActor* nSprite1, DExhumedActor* nSprite2);
|
||||||
int GetWallNormal(walltype* nWall);
|
DAngle GetWallNormal(walltype* nWall);
|
||||||
void MoveSector(sectortype* pSector, DAngle nAngle, DVector2& vel);
|
void MoveSector(sectortype* pSector, DAngle nAngle, DVector2& vel);
|
||||||
Collision AngleChase(DExhumedActor* nSprite, DExhumedActor* nSprite2, int ebx, int ecx, DAngle push1);
|
Collision AngleChase(DExhumedActor* nSprite, DExhumedActor* nSprite2, int ebx, int ecx, DAngle push1);
|
||||||
void SetQuake(DExhumedActor* nSprite, int nVal);
|
void SetQuake(DExhumedActor* nSprite, int nVal);
|
||||||
|
|
|
@ -37,12 +37,12 @@ void DestroyGrenade(DExhumedActor* pActor)
|
||||||
DeleteActor(pActor);
|
DeleteActor(pActor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BounceGrenade(DExhumedActor* pActor, int nAngle)
|
void BounceGrenade(DExhumedActor* pActor, DAngle nAngle)
|
||||||
{
|
{
|
||||||
pActor->nTurn >>= 1;
|
pActor->nTurn >>= 1;
|
||||||
|
|
||||||
pActor->x = bcos(nAngle, -5) * pActor->nTurn;
|
pActor->x = bcos(nAngle.Buildang(), -5) * pActor->nTurn;
|
||||||
pActor->y = bsin(nAngle, -5) * pActor->nTurn;
|
pActor->y = bsin(nAngle.Buildang(), -5) * pActor->nTurn;
|
||||||
|
|
||||||
D3PlayFX(StaticSound[kSound3], pActor);
|
D3PlayFX(StaticSound[kSound3], pActor);
|
||||||
}
|
}
|
||||||
|
@ -55,27 +55,29 @@ void ThrowGrenade(int nPlayer, int, int, int ecx, int push1)
|
||||||
DExhumedActor* pActor = PlayerList[nPlayer].pPlayerGrenade;
|
DExhumedActor* pActor = PlayerList[nPlayer].pPlayerGrenade;
|
||||||
auto pPlayerActor = PlayerList[nPlayer].pActor;
|
auto pPlayerActor = PlayerList[nPlayer].pActor;
|
||||||
|
|
||||||
int nAngle = pPlayerActor->int_ang();
|
DAngle nAngle = pPlayerActor->spr.angle;
|
||||||
|
|
||||||
ChangeActorSect(pActor, PlayerList[nPlayer].pPlayerViewSect);
|
ChangeActorSect(pActor, PlayerList[nPlayer].pPlayerViewSect);
|
||||||
|
|
||||||
pActor->spr.pos = pPlayerActor->spr.pos;
|
pActor->spr.pos = pPlayerActor->spr.pos;
|
||||||
|
|
||||||
if (nAngle < 0) {
|
if (nAngle < nullAngle) {
|
||||||
nAngle = pPlayerActor->int_ang();
|
nAngle = pPlayerActor->spr.angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
pActor->spr.cstat &= ~CSTAT_SPRITE_INVISIBLE;
|
pActor->spr.cstat &= ~CSTAT_SPRITE_INVISIBLE;
|
||||||
pActor->set_int_ang(nAngle);
|
pActor->spr.angle = nAngle;
|
||||||
|
|
||||||
if (push1 >= -3000)
|
if (push1 >= -3000)
|
||||||
{
|
{
|
||||||
int nVel = PlayerList[nPlayer].totalvel << 5;
|
int nVel = PlayerList[nPlayer].totalvel << 5;
|
||||||
|
|
||||||
pActor->nTurn = ((90 - pActor->nIndex2) * (90 - pActor->nIndex2)) + nVel;
|
pActor->nTurn = ((90 - pActor->nIndex2) * (90 - pActor->nIndex2)) + nVel;
|
||||||
pActor->set_int_zvel((-64 * push1) - 4352);
|
pActor->vel.Z = ((-0.25 * push1) - 17);
|
||||||
|
|
||||||
auto nMov = movesprite(pActor, bcos(nAngle) * (pPlayerActor->native_clipdist() << 3), bsin(nAngle) * (pPlayerActor->native_clipdist() << 3), ecx, 0, 0, CLIPMASK1);
|
|
||||||
|
DVector2 vec = nAngle.ToVector() * pPlayerActor->fClipdist() *2; // == << 14 + 3 + 2 - 18
|
||||||
|
auto nMov = movesprite(pActor, FloatToFixed<18>(vec.X), FloatToFixed<18>(vec.Y), ecx, 0, 0, CLIPMASK1);
|
||||||
if (nMov.type == kHitWall)
|
if (nMov.type == kHitWall)
|
||||||
{
|
{
|
||||||
nAngle = GetWallNormal(nMov.hitWall);
|
nAngle = GetWallNormal(nMov.hitWall);
|
||||||
|
@ -88,8 +90,8 @@ void ThrowGrenade(int nPlayer, int, int, int ecx, int push1)
|
||||||
pActor->vel.Z = pPlayerActor->vel.Z;
|
pActor->vel.Z = pPlayerActor->vel.Z;
|
||||||
}
|
}
|
||||||
|
|
||||||
pActor->x = bcos(nAngle, -4) * pActor->nTurn;
|
pActor->x = bcos(nAngle.Buildang(), -4) * pActor->nTurn;
|
||||||
pActor->y = bsin(nAngle, -4) * pActor->nTurn;
|
pActor->y = bsin(nAngle.Buildang(), -4) * pActor->nTurn;
|
||||||
|
|
||||||
PlayerList[nPlayer].pPlayerGrenade = nullptr;
|
PlayerList[nPlayer].pPlayerGrenade = nullptr;
|
||||||
|
|
||||||
|
@ -323,7 +325,7 @@ void AIGrenade::Tick(RunListEvent* ev)
|
||||||
}
|
}
|
||||||
else if (nMov.type == kHitSprite)
|
else if (nMov.type == kHitSprite)
|
||||||
{
|
{
|
||||||
BounceGrenade(pActor, nMov.actor()->int_ang());
|
BounceGrenade(pActor, nMov.actor()->spr.angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
pActor->nHealth = 0;
|
pActor->nHealth = 0;
|
||||||
|
|
|
@ -421,7 +421,7 @@ void AILion::Tick(RunListEvent* ev)
|
||||||
if (nMov.type == kHitWall)
|
if (nMov.type == kHitWall)
|
||||||
{
|
{
|
||||||
pActor->nAction = 7;
|
pActor->nAction = 7;
|
||||||
pActor->set_int_ang((GetWallNormal(nMov.hitWall) + 1024) & kAngleMask);
|
pActor->spr.angle = (GetWallNormal(nMov.hitWall) + DAngle180).Normalized360();
|
||||||
pActor->nCount = RandomSize(4);
|
pActor->nCount = RandomSize(4);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -966,10 +966,9 @@ Collision AngleChase(DExhumedActor* pActor, DExhumedActor* pActor2, int threshol
|
||||||
return movesprite(pActor, FloatToFixed<18>(vec.X), FloatToFixed<18>(vec.Y), zz * 4096 + BobVal(zbob) * 512, 0, 0, nClipType);
|
return movesprite(pActor, FloatToFixed<18>(vec.X), FloatToFixed<18>(vec.Y), zz * 4096 + BobVal(zbob) * 512, 0, 0, nClipType);
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetWallNormal(walltype* pWall)
|
DAngle GetWallNormal(walltype* pWall)
|
||||||
{
|
{
|
||||||
int nAngle = getangle(pWall->delta());
|
return (VecToAngle(pWall->delta()) + DAngle90).Normalized360();
|
||||||
return (nAngle + 512) & kAngleMask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector3 WheresMyMouth(int nPlayer, sectortype **sectnum)
|
DVector3 WheresMyMouth(int nPlayer, sectortype **sectnum)
|
||||||
|
@ -1178,7 +1177,7 @@ void AICreatureChunk::Tick(RunListEvent* ev)
|
||||||
}
|
}
|
||||||
else if (nVal.type == kHitWall)
|
else if (nVal.type == kHitWall)
|
||||||
{
|
{
|
||||||
nAngle = DAngle::fromBuild(GetWallNormal(nVal.hitWall));
|
nAngle = GetWallNormal(nVal.hitWall);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -720,7 +720,7 @@ bool CheckMovingBlocks(int nPlayer, Collision& nMove, DVector3& spr_pos, sectort
|
||||||
if (nMove.type == kHitSector || nMove.type == kHitWall)
|
if (nMove.type == kHitSector || nMove.type == kHitWall)
|
||||||
{
|
{
|
||||||
sectortype* sect;
|
sectortype* sect;
|
||||||
int nNormal = 0;
|
DAngle nNormal = nullAngle;
|
||||||
|
|
||||||
if (nMove.type == kHitSector)
|
if (nMove.type == kHitSector)
|
||||||
{
|
{
|
||||||
|
@ -738,7 +738,7 @@ bool CheckMovingBlocks(int nPlayer, Collision& nMove, DVector3& spr_pos, sectort
|
||||||
{
|
{
|
||||||
if ((sect->hitag == 45) && bTouchFloor)
|
if ((sect->hitag == 45) && bTouchFloor)
|
||||||
{
|
{
|
||||||
int nDiff = AngleDiff(DAngle::fromBuild(nNormal), DAngle::fromBuild((pPlayerActor->int_ang() + 1024) & kAngleMask));
|
int nDiff = AngleDiff(nNormal, pPlayerActor->spr.angle + DAngle180);
|
||||||
|
|
||||||
if (nDiff < 0) {
|
if (nDiff < 0) {
|
||||||
nDiff = -nDiff;
|
nDiff = -nDiff;
|
||||||
|
|
|
@ -537,7 +537,7 @@ void AIQueenEgg::Tick(RunListEvent* ev)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int nAngle;
|
DAngle nAngle;
|
||||||
|
|
||||||
switch (nMov.type)
|
switch (nMov.type)
|
||||||
{
|
{
|
||||||
|
@ -547,11 +547,11 @@ void AIQueenEgg::Tick(RunListEvent* ev)
|
||||||
nAngle = GetWallNormal(nMov.hitWall);
|
nAngle = GetWallNormal(nMov.hitWall);
|
||||||
break;
|
break;
|
||||||
case kHitSprite:
|
case kHitSprite:
|
||||||
nAngle = nMov.actor()->int_ang();
|
nAngle = nMov.actor()->spr.angle;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
pActor->set_int_ang(nAngle);
|
pActor->spr.angle = nAngle;
|
||||||
pActor->vel.XY() = pActor->spr.angle.ToVector() * 512;
|
pActor->vel.XY() = pActor->spr.angle.ToVector() * 512;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -766,11 +766,11 @@ void AIQueenHead::Tick(RunListEvent* ev)
|
||||||
auto nMov = MoveCreature(pActor);
|
auto nMov = MoveCreature(pActor);
|
||||||
|
|
||||||
// original BUG - this line doesn't exist in original code?
|
// original BUG - this line doesn't exist in original code?
|
||||||
int nNewAng = pActor->int_ang();
|
DAngle nNewAng = pActor->spr.angle;
|
||||||
|
|
||||||
if (nMov.exbits == 0)
|
if (nMov.exbits == 0)
|
||||||
{
|
{
|
||||||
if (nMov.type == kHitSprite) nNewAng = nMov.actor()->int_ang();
|
if (nMov.type == kHitSprite) nNewAng = nMov.actor()->spr.angle;
|
||||||
else if (nMov.type == kHitWall) nNewAng = GetWallNormal(nMov.hitWall);
|
else if (nMov.type == kHitWall) nNewAng = GetWallNormal(nMov.hitWall);
|
||||||
}
|
}
|
||||||
else if (nMov.exbits == kHitAux2)
|
else if (nMov.exbits == kHitAux2)
|
||||||
|
@ -785,7 +785,7 @@ void AIQueenHead::Tick(RunListEvent* ev)
|
||||||
}
|
}
|
||||||
|
|
||||||
// original BUG - var_18 isn't being set if the check above == 0x20000 ?
|
// original BUG - var_18 isn't being set if the check above == 0x20000 ?
|
||||||
pActor->set_int_ang(nNewAng);
|
pActor->spr.angle = nNewAng;
|
||||||
nVelShift++;
|
nVelShift++;
|
||||||
|
|
||||||
if (nVelShift < 5)
|
if (nVelShift < 5)
|
||||||
|
|
|
@ -29,7 +29,7 @@ BEGIN_PS_NS
|
||||||
// 100% done
|
// 100% done
|
||||||
int AngleDiff(DAngle a, DAngle b)
|
int AngleDiff(DAngle a, DAngle b)
|
||||||
{
|
{
|
||||||
int diff = (b - a).Buildang();
|
int diff = (b - a).Normalized360().Buildang();
|
||||||
|
|
||||||
if (diff > 1024) {
|
if (diff > 1024) {
|
||||||
diff = 2048 - diff;
|
diff = 2048 - diff;
|
||||||
|
|
Loading…
Reference in a new issue