- remaining s() in bullet.cpp, grenade.cpp and gun.cpp.

This commit is contained in:
Christoph Oelckers 2021-12-23 18:11:53 +01:00
parent cd6bb5305e
commit 7eaf669295
3 changed files with 114 additions and 130 deletions

View file

@ -186,8 +186,7 @@ void BulletHitsSprite(Bullet *pBullet, DExhumedActor* pBulletActor, DExhumedActo
bulletInfo *pBulletInfo = &BulletInfo[pBullet->nType]; bulletInfo *pBulletInfo = &BulletInfo[pBullet->nType];
auto pHitSprite = &pHitActor->s(); int nStat = pHitActor->spr.statnum;
int nStat = pHitSprite->statnum;
switch (pBullet->nType) switch (pBullet->nType)
{ {
@ -197,9 +196,9 @@ void BulletHitsSprite(Bullet *pBullet, DExhumedActor* pBulletActor, DExhumedActo
return; return;
} }
pHitSprite->hitag++; pHitActor->spr.hitag++;
if (pHitSprite->hitag == 15) { if (pHitActor->spr.hitag == 15) {
IgniteSprite(pHitActor); IgniteSprite(pHitActor);
} }
@ -237,22 +236,22 @@ void BulletHitsSprite(Bullet *pBullet, DExhumedActor* pBulletActor, DExhumedActo
{ {
int nAngle = (pActor->spr.ang + 256) - RandomSize(9); int nAngle = (pActor->spr.ang + 256) - RandomSize(9);
pHitSprite->xvel = bcos(nAngle, 1); pHitActor->spr.xvel = bcos(nAngle, 1);
pHitSprite->yvel = bsin(nAngle, 1); pHitActor->spr.yvel = bsin(nAngle, 1);
pHitSprite->zvel = (-(RandomSize(3) + 1)) << 8; pHitActor->spr.zvel = (-(RandomSize(3) + 1)) << 8;
} }
else else
{ {
int xVel = pHitSprite->xvel; int xVel = pHitActor->spr.xvel;
int yVel = pHitSprite->yvel; int yVel = pHitActor->spr.yvel;
pHitSprite->xvel = bcos(pActor->spr.ang, -2); pHitActor->spr.xvel = bcos(pActor->spr.ang, -2);
pHitSprite->yvel = bsin(pActor->spr.ang, -2); pHitActor->spr.yvel = bsin(pActor->spr.ang, -2);
MoveCreature(pHitActor); MoveCreature(pHitActor);
pHitSprite->xvel = xVel; pHitActor->spr.xvel = xVel;
pHitSprite->yvel = yVel; pHitActor->spr.yvel = yVel;
} }
break; break;
@ -441,11 +440,10 @@ MOVEEND:
if (BulletList[nBullet].pEnemy) if (BulletList[nBullet].pEnemy)
{ {
hitactor = BulletList[nBullet].pEnemy; hitactor = BulletList[nBullet].pEnemy;
auto hitsprite = &hitactor->s(); x2 = hitactor->spr.pos.X;
x2 = hitsprite->pos.X; y2 = hitactor->spr.pos.Y;
y2 = hitsprite->pos.Y; z2 = hitactor->spr.pos.Z - (GetActorHeight(hitactor) >> 1);
z2 = hitsprite->pos.Z - (GetActorHeight(hitactor) >> 1); pHitSect = hitactor->spr.sector();
pHitSect = hitsprite->sector();
} }
else else
{ {
@ -473,8 +471,7 @@ MOVEEND:
if (hitactor) if (hitactor)
{ {
HITSPRITE: HITSPRITE:
auto hitsprite = &hitactor->s(); if (pActor->spr.pal == 5 && hitactor->spr.statnum == 100)
if (pActor->spr.pal == 5 && hitsprite->statnum == 100)
{ {
int nPlayer = GetPlayerFromActor(hitactor); int nPlayer = GetPlayerFromActor(hitactor);
if (!PlayerList[nPlayer].bIsMummified) if (!PlayerList[nPlayer].bIsMummified)
@ -585,9 +582,7 @@ DExhumedActor* BuildBullet(DExhumedActor* pActor, int nType, int nZOffset, int n
{ {
if (pTarget) if (pTarget)
{ {
spritetype *pTargetSprite = &pTarget->s(); if (pTarget->spr.cstat & CSTAT_SPRITE_BLOCK_ALL)
if (pTargetSprite->cstat & CSTAT_SPRITE_BLOCK_ALL)
{ {
sBullet.nType = nType; sBullet.nType = nType;
sBullet.nDoubleDamage = nDoubleDamage; sBullet.nDoubleDamage = nDoubleDamage;
@ -597,9 +592,9 @@ DExhumedActor* BuildBullet(DExhumedActor* pActor, int nType, int nZOffset, int n
int nHeight = GetActorHeight(pTarget); int nHeight = GetActorHeight(pTarget);
assert(pTargetSprite->sector()); assert(pTarget->spr.sector());
BulletHitsSprite(&sBullet, pActor, pTarget, pTargetSprite->pos.X, pTargetSprite->pos.Y, pTargetSprite->pos.Z - (nHeight >> 1), pTargetSprite->sector()); BulletHitsSprite(&sBullet, pActor, pTarget, pTarget->spr.pos.X, pTarget->spr.pos.Y, pTarget->spr.pos.Z - (nHeight >> 1), pTarget->spr.sector());
DeleteActor(sBullet.pActor); DeleteActor(sBullet.pActor);
return nullptr; return nullptr;
} }
@ -627,50 +622,49 @@ DExhumedActor* BuildBullet(DExhumedActor* pActor, int nType, int nZOffset, int n
} }
auto pBulletActor = insertActor(pSector, 200); auto pBulletActor = insertActor(pSector, 200);
auto pBulletSprite = &pBulletActor->s(); int nHeight = GetActorHeight(pActor);
int nHeight = GetActorHeight(pActor);
nHeight = nHeight - (nHeight >> 2); nHeight = nHeight - (nHeight >> 2);
if (nZOffset == -1) { if (nZOffset == -1) {
nZOffset = -nHeight; nZOffset = -nHeight;
} }
pBulletSprite->pos.X = pActor->spr.pos.X; pBulletActor->spr.pos.X = pActor->spr.pos.X;
pBulletSprite->pos.Y = pActor->spr.pos.Y; pBulletActor->spr.pos.Y = pActor->spr.pos.Y;
pBulletSprite->pos.Z = pActor->spr.pos.Z; pBulletActor->spr.pos.Z = pActor->spr.pos.Z;
Bullet *pBullet = &BulletList[nBullet]; Bullet *pBullet = &BulletList[nBullet];
pBullet->pEnemy = nullptr; pBullet->pEnemy = nullptr;
pBulletSprite->cstat = 0; pBulletActor->spr.cstat = 0;
pBulletSprite->shade = -64; pBulletActor->spr.shade = -64;
if (pBulletInfo->nFlags & 4) { if (pBulletInfo->nFlags & 4) {
pBulletSprite->pal = 4; pBulletActor->spr.pal = 4;
} }
else { else {
pBulletSprite->pal = 0; pBulletActor->spr.pal = 0;
} }
pBulletSprite->clipdist = 25; pBulletActor->spr.clipdist = 25;
int nRepeat = pBulletInfo->xyRepeat; int nRepeat = pBulletInfo->xyRepeat;
if (nRepeat < 0) { if (nRepeat < 0) {
nRepeat = 30; nRepeat = 30;
} }
pBulletSprite->xrepeat = (uint8_t)nRepeat; pBulletActor->spr.xrepeat = (uint8_t)nRepeat;
pBulletSprite->yrepeat = (uint8_t)nRepeat; pBulletActor->spr.yrepeat = (uint8_t)nRepeat;
pBulletSprite->xoffset = 0; pBulletActor->spr.xoffset = 0;
pBulletSprite->yoffset = 0; pBulletActor->spr.yoffset = 0;
pBulletSprite->ang = nAngle; pBulletActor->spr.ang = nAngle;
pBulletSprite->xvel = 0; pBulletActor->spr.xvel = 0;
pBulletSprite->yvel = 0; pBulletActor->spr.yvel = 0;
pBulletSprite->zvel = 0; pBulletActor->spr.zvel = 0;
pBulletSprite->lotag = runlist_HeadRun() + 1; pBulletActor->spr.lotag = runlist_HeadRun() + 1;
pBulletSprite->extra = -1; pBulletActor->spr.extra = -1;
pBulletSprite->hitag = 0; pBulletActor->spr.hitag = 0;
pBulletActor->pTarget = pActor; pBulletActor->pTarget = pActor;
pBulletActor->nPhase = nBullet; pBulletActor->nPhase = nBullet;
@ -695,30 +689,30 @@ DExhumedActor* BuildBullet(DExhumedActor* pActor, int nType, int nZOffset, int n
pBullet->nSeq = nSeq; pBullet->nSeq = nSeq;
pBulletSprite->picnum = seq_GetSeqPicnum(nSeq, 0, 0); pBulletActor->spr.picnum = seq_GetSeqPicnum(nSeq, 0, 0);
if (nSeq == kSeqBullet) { if (nSeq == kSeqBullet) {
pBulletSprite->cstat |= CSTAT_SPRITE_INVISIBLE; pBulletActor->spr.cstat |= CSTAT_SPRITE_INVISIBLE;
} }
pBullet->nPitch = nPitch; pBullet->nPitch = nPitch;
pBullet->nType = nType; pBullet->nType = nType;
pBullet->pActor = pBulletActor; pBullet->pActor = pBulletActor;
pBullet->nRunRec = runlist_AddRunRec(pBulletSprite->lotag - 1, nBullet, 0xB0000); pBullet->nRunRec = runlist_AddRunRec(pBulletActor->spr.lotag - 1, nBullet, 0xB0000);
pBullet->nRunRec2 = runlist_AddRunRec(NewRun, nBullet, 0xB0000); pBullet->nRunRec2 = runlist_AddRunRec(NewRun, nBullet, 0xB0000);
pBullet->nDoubleDamage = nDoubleDamage; pBullet->nDoubleDamage = nDoubleDamage;
pBulletSprite->pos.Z += nZOffset; pBulletActor->spr.pos.Z += nZOffset;
pBulletSprite->backuppos(); pBulletActor->spr.backuppos();
int var_18 = 0; int var_18 = 0;
pSector = pBulletSprite->sector(); pSector = pBulletActor->spr.sector();
while (pBulletSprite->pos.Z < pSector->ceilingz) while (pBulletActor->spr.pos.Z < pSector->ceilingz)
{ {
if (pSector->pAbove == nullptr) if (pSector->pAbove == nullptr)
{ {
pBulletSprite->pos.Z = pSector->ceilingz; pBulletActor->spr.pos.Z = pSector->ceilingz;
break; break;
} }
@ -732,8 +726,6 @@ DExhumedActor* BuildBullet(DExhumedActor* pActor, int nType, int nZOffset, int n
} }
else else
{ {
auto pTargetSprite = &pTarget->s();
if ((unsigned int)pBulletInfo->field_4 > 30000) if ((unsigned int)pBulletInfo->field_4 > 30000)
{ {
BulletList[nBullet].pEnemy = pTarget; BulletList[nBullet].pEnemy = pTarget;
@ -742,7 +734,7 @@ DExhumedActor* BuildBullet(DExhumedActor* pActor, int nType, int nZOffset, int n
{ {
nHeight = GetActorHeight(pTarget); nHeight = GetActorHeight(pTarget);
if (pTargetSprite->statnum == 100) if (pTarget->spr.statnum == 100)
{ {
nHeight -= nHeight >> 2; nHeight -= nHeight >> 2;
} }
@ -751,19 +743,19 @@ DExhumedActor* BuildBullet(DExhumedActor* pActor, int nType, int nZOffset, int n
nHeight -= nHeight >> 1; nHeight -= nHeight >> 1;
} }
int var_20 = pTargetSprite->pos.Z - nHeight; int var_20 = pTarget->spr.pos.Z - nHeight;
int x, y; int x, y;
if (pActor != nullptr && pActor->spr.statnum != 100) if (pActor != nullptr && pActor->spr.statnum != 100)
{ {
x = pTargetSprite->pos.X; x = pTarget->spr.pos.X;
y = pTargetSprite->pos.Y; y = pTarget->spr.pos.Y;
if (pTargetSprite->statnum != 100) if (pTarget->spr.statnum != 100)
{ {
x += (pTargetSprite->xvel * 20) >> 6; x += (pTarget->spr.xvel * 20) >> 6;
y += (pTargetSprite->yvel * 20) >> 6; y += (pTarget->spr.yvel * 20) >> 6;
} }
else else
{ {
@ -775,8 +767,8 @@ DExhumedActor* BuildBullet(DExhumedActor* pActor, int nType, int nZOffset, int n
} }
} }
x -= pBulletSprite->pos.X; x -= pBulletActor->spr.pos.X;
y -= pBulletSprite->pos.Y; y -= pBulletActor->spr.pos.Y;
nAngle = GetMyAngle(x, y); nAngle = GetMyAngle(x, y);
pActor->spr.ang = nAngle; pActor->spr.ang = nAngle;
@ -784,14 +776,14 @@ DExhumedActor* BuildBullet(DExhumedActor* pActor, int nType, int nZOffset, int n
else else
{ {
// loc_2ABA3: // loc_2ABA3:
x = pTargetSprite->pos.X - pBulletSprite->pos.X; x = pTarget->spr.pos.X - pBulletActor->spr.pos.X;
y = pTargetSprite->pos.Y - pBulletSprite->pos.Y; y = pTarget->spr.pos.Y - pBulletActor->spr.pos.Y;
} }
int nSqrt = lsqrt(y*y + x*x); int nSqrt = lsqrt(y*y + x*x);
if ((unsigned int)nSqrt > 0) if ((unsigned int)nSqrt > 0)
{ {
var_18 = ((var_20 - pBulletSprite->pos.Z) * pBulletInfo->field_4) / nSqrt; var_18 = ((var_20 - pBulletActor->spr.pos.Z) * pBulletInfo->field_4) / nSqrt;
} }
else else
{ {

View file

@ -53,33 +53,31 @@ void ThrowGrenade(int nPlayer, int, int, int ecx, int push1)
return; return;
DExhumedActor* pActor = PlayerList[nPlayer].pPlayerGrenade; DExhumedActor* pActor = PlayerList[nPlayer].pPlayerGrenade;
auto pGrenadeSprite = &pActor->s();
auto pPlayerActor = PlayerList[nPlayer].Actor(); auto pPlayerActor = PlayerList[nPlayer].Actor();
auto pPlayerSprite = &pPlayerActor->s();
int nAngle = pPlayerSprite->ang; int nAngle = pPlayerActor->spr.ang;
ChangeActorSect(pActor, PlayerList[nPlayer].pPlayerViewSect); ChangeActorSect(pActor, PlayerList[nPlayer].pPlayerViewSect);
pGrenadeSprite->pos.X = pPlayerSprite->pos.X; pActor->spr.pos.X = pPlayerActor->spr.pos.X;
pGrenadeSprite->pos.Y = pPlayerSprite->pos.Y; pActor->spr.pos.Y = pPlayerActor->spr.pos.Y;
pGrenadeSprite->pos.Z = pPlayerSprite->pos.Z; pActor->spr.pos.Z = pPlayerActor->spr.pos.Z;
if (nAngle < 0) { if (nAngle < 0) {
nAngle = pPlayerSprite->ang; nAngle = pPlayerActor->spr.ang;
} }
pGrenadeSprite->cstat &= ~CSTAT_SPRITE_BLOCK; pActor->spr.cstat &= ~CSTAT_SPRITE_BLOCK;
pGrenadeSprite->ang = nAngle; pActor->spr.ang = 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;
pGrenadeSprite->zvel = (-64 * push1) - 4352; pActor->spr.zvel = (-64 * push1) - 4352;
auto nMov = movesprite(pActor, bcos(nAngle) * (pPlayerSprite->clipdist << 3), bsin(nAngle) * (pPlayerSprite->clipdist << 3), ecx, 0, 0, CLIPMASK1); auto nMov = movesprite(pActor, bcos(nAngle) * (pPlayerActor->spr.clipdist << 3), bsin(nAngle) * (pPlayerActor->spr.clipdist << 3), ecx, 0, 0, CLIPMASK1);
if (nMov.type == kHitWall) if (nMov.type == kHitWall)
{ {
nAngle = GetWallNormal(nMov.hitWall); nAngle = GetWallNormal(nMov.hitWall);
@ -89,7 +87,7 @@ void ThrowGrenade(int nPlayer, int, int, int ecx, int push1)
else else
{ {
pActor->nTurn = 0; pActor->nTurn = 0;
pGrenadeSprite->zvel = pPlayerSprite->zvel; pActor->spr.zvel = pPlayerActor->spr.zvel;
} }
pActor->x = bcos(nAngle, -4) * pActor->nTurn; pActor->x = bcos(nAngle, -4) * pActor->nTurn;
@ -104,11 +102,11 @@ void BuildGrenade(int nPlayer)
{ {
auto pActor = insertActor(PlayerList[nPlayer].pPlayerViewSect, 201); auto pActor = insertActor(PlayerList[nPlayer].pPlayerViewSect, 201);
auto pPlayerSprite = &PlayerList[nPlayer].Actor()->s(); auto pPlayerActor = PlayerList[nPlayer].Actor();
pActor->spr.pos.X = pPlayerSprite->pos.X; pActor->spr.pos.X = pPlayerActor->spr.pos.X;
pActor->spr.pos.Y = pPlayerSprite->pos.Y; pActor->spr.pos.Y = pPlayerActor->spr.pos.Y;
pActor->spr.pos.Z = pPlayerSprite->pos.Z - 3840; pActor->spr.pos.Z = pPlayerActor->spr.pos.Z - 3840;
pActor->spr.shade = -64; pActor->spr.shade = -64;
pActor->spr.xrepeat = 20; pActor->spr.xrepeat = 20;
pActor->spr.yrepeat = 20; pActor->spr.yrepeat = 20;
@ -118,7 +116,7 @@ void BuildGrenade(int nPlayer)
pActor->spr.clipdist = 30; pActor->spr.clipdist = 30;
pActor->spr.xoffset = 0; pActor->spr.xoffset = 0;
pActor->spr.yoffset = 0; pActor->spr.yoffset = 0;
pActor->spr.ang = pPlayerSprite->ang; pActor->spr.ang = pPlayerActor->spr.ang;
pActor->spr.owner = nPlayer; pActor->spr.owner = nPlayer;
pActor->spr.xvel = 0; pActor->spr.xvel = 0;
pActor->spr.yvel = 0; pActor->spr.yvel = 0;
@ -146,9 +144,8 @@ void ExplodeGrenade(DExhumedActor* pActor)
{ {
int var_28, var_20; int var_28, var_20;
auto pGrenadeSprite = &pActor->s(); int nPlayer = pActor->spr.owner;
int nPlayer = pGrenadeSprite->owner; auto pGrenadeSect = pActor->spr.sector();
auto pGrenadeSect = pGrenadeSprite->sector();
pActor->nFrame = 1; pActor->nFrame = 1;
@ -159,7 +156,7 @@ void ExplodeGrenade(DExhumedActor* pActor)
} }
else else
{ {
if (pGrenadeSprite->pos.Z < pGrenadeSect->floorz) if (pActor->spr.pos.Z < pGrenadeSect->floorz)
{ {
var_20 = 200; var_20 = 200;
var_28 = 36; var_28 = 36;
@ -178,14 +175,13 @@ void ExplodeGrenade(DExhumedActor* pActor)
if (pActor->nTurn < 0) if (pActor->nTurn < 0)
{ {
auto pPlayerActor = PlayerList[nPlayer].Actor(); auto pPlayerActor = PlayerList[nPlayer].Actor();
auto pPlayerSprite = &pPlayerActor->s(); int nAngle = pPlayerActor->spr.ang;
int nAngle = pPlayerSprite->ang;
pGrenadeSprite->pos.Z = pPlayerSprite->pos.Z; pActor->spr.pos.Z = pPlayerActor->spr.pos.Z;
pGrenadeSprite->pos.X = bcos(nAngle, -5) + pPlayerSprite->pos.X; pActor->spr.pos.X = bcos(nAngle, -5) + pPlayerActor->spr.pos.X;
pGrenadeSprite->pos.Y = bsin(nAngle, -5) + pPlayerSprite->pos.Y; pActor->spr.pos.Y = bsin(nAngle, -5) + pPlayerActor->spr.pos.Y;
ChangeActorSect(pActor, pPlayerSprite->sector()); ChangeActorSect(pActor, pPlayerActor->spr.sector());
if (!PlayerList[nPlayer].invincibility) { if (!PlayerList[nPlayer].invincibility) {
PlayerList[nPlayer].nHealth = 1; PlayerList[nPlayer].nHealth = 1;
@ -200,8 +196,8 @@ void ExplodeGrenade(DExhumedActor* pActor)
runlist_RadialDamageEnemy(pActor, nDamage, BulletInfo[kWeaponGrenade].nRadius); runlist_RadialDamageEnemy(pActor, nDamage, BulletInfo[kWeaponGrenade].nRadius);
BuildAnim(nullptr, var_28, 0, pGrenadeSprite->pos.X, pGrenadeSprite->pos.Y, pGrenadeSprite->pos.Z, pGrenadeSprite->sector(), var_20, 4); BuildAnim(nullptr, var_28, 0, pActor->spr.pos.X, pActor->spr.pos.Y, pActor->spr.pos.Z, pActor->spr.sector(), var_20, 4);
AddFlash(pGrenadeSprite->sector(), pGrenadeSprite->pos.X, pGrenadeSprite->pos.Y, pGrenadeSprite->pos.Z, 128); AddFlash(pActor->spr.sector(), pActor->spr.pos.X, pActor->spr.pos.Y, pActor->spr.pos.Z, 128);
DestroyGrenade(pActor); DestroyGrenade(pActor);
} }
@ -221,16 +217,15 @@ void AIGrenade::Tick(RunListEvent* ev)
auto pActor = ev->pObjActor; auto pActor = ev->pObjActor;
if (!pActor) return; if (!pActor) return;
auto pGrenadeSprite = &pActor->s();
int nSeq = pActor->nFrame ? SeqOffsets[kSeqGrenBoom] : SeqOffsets[kSeqGrenRoll] + pActor->nIndex; int nSeq = pActor->nFrame ? SeqOffsets[kSeqGrenBoom] : SeqOffsets[kSeqGrenRoll] + pActor->nIndex;
seq_MoveSequence(pActor, nSeq, pActor->nHealth >> 8); seq_MoveSequence(pActor, nSeq, pActor->nHealth >> 8);
pGrenadeSprite->picnum = seq_GetSeqPicnum2(nSeq, pActor->nHealth >> 8); pActor->spr.picnum = seq_GetSeqPicnum2(nSeq, pActor->nHealth >> 8);
pActor->nIndex2--; pActor->nIndex2--;
if (!pActor->nIndex2) if (!pActor->nIndex2)
{ {
int nPlayer = pGrenadeSprite->owner; int nPlayer = pActor->spr.owner;
if (pActor->nTurn < 0) if (pActor->nTurn < 0)
{ {
@ -287,10 +282,10 @@ void AIGrenade::Tick(RunListEvent* ev)
return; return;
} }
int zVel = pGrenadeSprite->zvel; int zVel = pActor->spr.zvel;
Gravity(pActor); Gravity(pActor);
auto nMov = movesprite(pActor, pActor->x, pActor->y, pGrenadeSprite->zvel, pGrenadeSprite->clipdist >> 1, pGrenadeSprite->clipdist >> 1, CLIPMASK1); auto nMov = movesprite(pActor, pActor->x, pActor->y, pActor->spr.zvel, pActor->spr.clipdist >> 1, pActor->spr.clipdist >> 1, CLIPMASK1);
if (!nMov.type && !nMov.exbits) if (!nMov.type && !nMov.exbits)
return; return;
@ -299,7 +294,7 @@ void AIGrenade::Tick(RunListEvent* ev)
{ {
if (zVel) if (zVel)
{ {
if (pGrenadeSprite->sector()->Damage > 0) if (pActor->spr.sector()->Damage > 0)
{ {
ExplodeGrenade(pActor); ExplodeGrenade(pActor);
return; return;
@ -309,14 +304,14 @@ void AIGrenade::Tick(RunListEvent* ev)
D3PlayFX(StaticSound[kSound3], pActor); D3PlayFX(StaticSound[kSound3], pActor);
pGrenadeSprite->zvel = -(zVel >> 1); pActor->spr.zvel = -(zVel >> 1);
if (pGrenadeSprite->zvel > -1280) if (pActor->spr.zvel > -1280)
{ {
D3PlayFX(StaticSound[kSound5], pActor); D3PlayFX(StaticSound[kSound5], pActor);
pActor->nCount = 0; pActor->nCount = 0;
pActor->nHealth = 0; pActor->nHealth = 0;
pGrenadeSprite->zvel = 0; pActor->spr.zvel = 0;
pActor->nIndex = 1; pActor->nIndex = 1;
} }
} }

View file

@ -319,7 +319,6 @@ void MoveWeapons(int nPlayer)
nTemperature[nPlayer] = 0; nTemperature[nPlayer] = 0;
auto pPlayerActor = PlayerList[nPlayer].Actor(); auto pPlayerActor = PlayerList[nPlayer].Actor();
auto pPlayerSprite = &pPlayerActor->s();
int nWeapon = PlayerList[nPlayer].nCurrentWeapon; int nWeapon = PlayerList[nPlayer].nCurrentWeapon;
if (nWeapon < -1) if (nWeapon < -1)
@ -614,10 +613,10 @@ loc_flag:
{ {
BuildFlash(nPlayer, 512); BuildFlash(nPlayer, 512);
AddFlash( AddFlash(
pPlayerSprite->sector(), pPlayerActor->spr.sector(),
pPlayerSprite->pos.X, pPlayerActor->spr.pos.X,
pPlayerSprite->pos.Y, pPlayerActor->spr.pos.Y,
pPlayerSprite->pos.Z, pPlayerActor->spr.pos.Z,
0); 0);
} }
@ -648,13 +647,13 @@ loc_flag:
} }
int nAmmoType = WeaponInfo[nWeapon].nAmmoType; int nAmmoType = WeaponInfo[nWeapon].nAmmoType;
int nAngle = pPlayerSprite->ang; int nAngle = pPlayerActor->spr.ang;
int theX = pPlayerSprite->pos.X; int theX = pPlayerActor->spr.pos.X;
int theY = pPlayerSprite->pos.Y; int theY = pPlayerActor->spr.pos.Y;
int theZ = pPlayerSprite->pos.Z; int theZ = pPlayerActor->spr.pos.Z;
int ebp = bcos(nAngle) * (pPlayerSprite->clipdist << 3); int ebp = bcos(nAngle) * (pPlayerActor->spr.clipdist << 3);
int ebx = bsin(nAngle) * (pPlayerSprite->clipdist << 3); int ebx = bsin(nAngle) * (pPlayerActor->spr.clipdist << 3);
if (WeaponInfo[nWeapon].c) if (WeaponInfo[nWeapon].c)
{ {
@ -688,7 +687,7 @@ loc_flag:
} }
} }
auto pSectorB = pPlayerSprite->sector(); auto pSectorB = pPlayerActor->spr.sector();
switch (nWeapon) switch (nWeapon)
{ {
@ -728,25 +727,24 @@ loc_flag:
else if (cRange.type == kHitSprite) else if (cRange.type == kHitSprite)
{ {
auto pActor2 = cRange.actor(); auto pActor2 = cRange.actor();
auto pSprite2 = &pActor2->s();
if (pSprite2->cstat & (CSTAT_SPRITE_ALIGNMENT_WALL | CSTAT_SPRITE_ONE_SIDE)) if (pActor2->spr.cstat & (CSTAT_SPRITE_ALIGNMENT_WALL | CSTAT_SPRITE_ONE_SIDE))
{ {
var_28 += 2; var_28 += 2;
} }
else if (pSprite2->statnum > 90 && pSprite2->statnum <= 199) else if (pActor2->spr.statnum > 90 && pActor2->spr.statnum <= 199)
{ {
runlist_DamageEnemy(pActor2, pPlayerActor, nDamage); runlist_DamageEnemy(pActor2, pPlayerActor, nDamage);
if (pSprite2->statnum < 102) { if (pActor2->spr.statnum < 102) {
var_28++; var_28++;
} }
else if (pSprite2->statnum == 102) else if (pActor2->spr.statnum == 102)
{ {
// loc_27370: // loc_27370:
BuildAnim(nullptr, 12, 0, theX, theY, theZ, pSectorB, 30, 0); BuildAnim(nullptr, 12, 0, theX, theY, theZ, pSectorB, 30, 0);
} }
else if (pSprite2->statnum == kStatExplodeTrigger) { else if (pActor2->spr.statnum == kStatExplodeTrigger) {
var_28 += 2; var_28 += 2;
} }
else { else {
@ -809,10 +807,9 @@ loc_flag:
{ {
DExhumedActor* t = sPlayerInput[nPlayer].pTarget; DExhumedActor* t = sPlayerInput[nPlayer].pTarget;
// only autoaim if target is in front of the player. // only autoaim if target is in front of the player.
auto pTargetSprite = &t->s(); assert(t->spr.sector());
assert(pTargetSprite->sector()); int angletotarget = bvectangbam(t->spr.pos.X - pPlayerActor->spr.pos.X, t->spr.pos.Y - pPlayerActor->spr.pos.Y).asbuild();
int angletotarget = bvectangbam(pTargetSprite->pos.X - pPlayerSprite->pos.X, pTargetSprite->pos.Y - pPlayerSprite->pos.Y).asbuild(); int anglediff = (pPlayerActor->spr.ang - angletotarget) & 2047;
int anglediff = (pPlayerSprite->ang - angletotarget) & 2047;
if (anglediff < 512 || anglediff > 1536) if (anglediff < 512 || anglediff > 1536)
{ {
target = t; target = t;
@ -833,8 +830,8 @@ loc_flag:
BuildSnake(nPlayer, nHeight); BuildSnake(nPlayer, nHeight);
nQuake[nPlayer] = 512; nQuake[nPlayer] = 512;
PlayerList[nPlayer].nXDamage -= bcos(pPlayerSprite->ang, 9); PlayerList[nPlayer].nXDamage -= bcos(pPlayerActor->spr.ang, 9);
PlayerList[nPlayer].nYDamage -= bsin(pPlayerSprite->ang, 9); PlayerList[nPlayer].nYDamage -= bsin(pPlayerActor->spr.ang, 9);
break; break;
} }
case kWeaponRing: case kWeaponRing: