- Exhumed: use DVector3 in BuildAnim and some related code

This commit is contained in:
Christoph Oelckers 2022-08-20 15:42:53 +02:00
parent 416be99967
commit 8ee10c5488
13 changed files with 48 additions and 48 deletions

View file

@ -29,7 +29,7 @@ BEGIN_PS_NS
void InitAnims(); void InitAnims();
void DestroyAnim(DExhumedActor* nAnim); void DestroyAnim(DExhumedActor* nAnim);
DExhumedActor* BuildAnim(DExhumedActor* actor, int val, int val2, int x, int y, int z, sectortype* pSector, int nRepeat, int nFlag); DExhumedActor* BuildAnim(DExhumedActor* actor, int val, int val2, const DVector3& pos, sectortype* pSector, int nRepeat, int nFlag);
void FuncAnim(int, int, int, int); void FuncAnim(int, int, int, int);
void BuildExplosion(DExhumedActor* actor); void BuildExplosion(DExhumedActor* actor);
@ -218,7 +218,7 @@ void Gravity(DExhumedActor* actor);
DExhumedActor* UpdateEnemy(DExhumedActor** ppEnemy); DExhumedActor* UpdateEnemy(DExhumedActor** ppEnemy);
Collision MoveCreature(DExhumedActor* nSprite); Collision MoveCreature(DExhumedActor* nSprite);
Collision MoveCreatureWithCaution(DExhumedActor* actor); Collision MoveCreatureWithCaution(DExhumedActor* actor);
void WheresMyMouth(int nPlayer, vec3_t* pos, sectortype** sectnum); DVector3 WheresMyMouth(int nPlayer, sectortype** sectnum);
int GetActorHeight(DExhumedActor* nSprite); int GetActorHeight(DExhumedActor* nSprite);
DExhumedActor* insertActor(sectortype* s, int st); DExhumedActor* insertActor(sectortype* s, int st);
DExhumedActor* GrabBody(); DExhumedActor* GrabBody();

View file

@ -60,12 +60,12 @@ void DestroyAnim(DExhumedActor* pActor)
} }
} }
DExhumedActor* BuildAnim(DExhumedActor* pActor, int val, int val2, int x, int y, int z, sectortype* pSector, int nRepeat, int nFlag) DExhumedActor* BuildAnim(DExhumedActor* pActor, int val, int val2, const DVector3& pos, sectortype* pSector, int nRepeat, int nFlag)
{ {
if (pActor == nullptr) { if (pActor == nullptr) {
pActor = insertActor(pSector, 500); pActor = insertActor(pSector, 500);
} }
pActor->set_int_pos({ x, y, z }); pActor->spr.pos = pos;
pActor->spr.cstat = 0; pActor->spr.cstat = 0;
if (nFlag & 4) if (nFlag & 4)
@ -239,7 +239,7 @@ void BuildExplosion(DExhumedActor* pActor)
edx = 34; edx = 34;
} }
BuildAnim(nullptr, edx, 0, pActor->int_pos().X, pActor->int_pos().Y, pActor->int_pos().Z, pActor->sector(), pActor->spr.xrepeat, 4); BuildAnim(nullptr, edx, 0, pActor->spr.pos, pActor->sector(), pActor->spr.xrepeat, 4);
} }
void BuildSplash(DExhumedActor* pActor, sectortype* pSector) void BuildSplash(DExhumedActor* pActor, sectortype* pSector)
@ -272,7 +272,7 @@ void BuildSplash(DExhumedActor* pActor, sectortype* pSector)
nFlag = 0; nFlag = 0;
} }
auto pSpawned = BuildAnim(nullptr, edx, 0, pActor->int_pos().X, pActor->int_pos().Y, pSector->int_floorz(), pSector, nRepeat, nFlag); auto pSpawned = BuildAnim(nullptr, edx, 0, DVector3(pActor->spr.pos.XY(), pSector->floorz), pSector, nRepeat, nFlag);
if (!bIsLava) if (!bIsLava)
{ {

View file

@ -33,7 +33,7 @@ void DestroyBubble(DExhumedActor* pActor)
DeleteActor(pActor); DeleteActor(pActor);
} }
DExhumedActor* BuildBubble(vec3_t pos, sectortype* pSector) DExhumedActor* BuildBubble(const DVector3& pos, sectortype* pSector)
{ {
int nSize = RandomSize(3); int nSize = RandomSize(3);
if (nSize > 4) { if (nSize > 4) {
@ -42,7 +42,7 @@ DExhumedActor* BuildBubble(vec3_t pos, sectortype* pSector)
auto pActor = insertActor(pSector, 402); auto pActor = insertActor(pSector, 402);
pActor->set_int_pos(pos); pActor->spr.pos = pos;
pActor->spr.cstat = 0; pActor->spr.cstat = 0;
pActor->spr.shade = -32; pActor->spr.shade = -32;
pActor->spr.pal = 0; pActor->spr.pal = 0;
@ -96,7 +96,7 @@ void AIBubble::Tick(RunListEvent* ev)
auto pSectAbove = pSector->pAbove; auto pSectAbove = pSector->pAbove;
if (pActor->spr.hitag > -1 && pSectAbove != nullptr) { if (pActor->spr.hitag > -1 && pSectAbove != nullptr) {
BuildAnim(nullptr, 70, 0, pActor->int_pos().X, pActor->int_pos().Y, pSectAbove->int_floorz(), pSectAbove, 64, 0); BuildAnim(nullptr, 70, 0, DVector3(pActor->spr.pos.XY(), pSectAbove->floorz), pSectAbove, 64, 0);
} }
DestroyBubble(pActor); DestroyBubble(pActor);
@ -124,7 +124,7 @@ void DoBubbleMachines()
{ {
pActor->nCount = (RandomWord() % pActor->nFrame) + 30; pActor->nCount = (RandomWord() % pActor->nFrame) + 30;
BuildBubble(pActor->int_pos(), pActor->sector()); BuildBubble(pActor->spr.pos, pActor->sector());
} }
} }
} }
@ -140,10 +140,9 @@ void BuildBubbleMachine(DExhumedActor* pActor)
void DoBubbles(int nPlayer) void DoBubbles(int nPlayer)
{ {
vec3_t pos;
sectortype* pSector; sectortype* pSector;
WheresMyMouth(nPlayer, &pos, &pSector); auto pos = WheresMyMouth(nPlayer, &pSector);
auto pActor = BuildBubble(pos, pSector); auto pActor = BuildBubble(pos, pSector);
pActor->spr.hitag = nPlayer; pActor->spr.hitag = nPlayer;

View file

@ -165,7 +165,7 @@ void IgniteSprite(DExhumedActor* pActor)
{ {
pActor->spr.hitag += 2; pActor->spr.hitag += 2;
auto pAnimActor = BuildAnim(nullptr, 38, 0, pActor->int_pos().X, pActor->int_pos().Y, pActor->int_pos().Z, pActor->sector(), 40, 20); auto pAnimActor = BuildAnim(nullptr, 38, 0, pActor->spr.pos, pActor->sector(), 40, 20);
if (pAnimActor) if (pAnimActor)
{ {
@ -175,7 +175,7 @@ void IgniteSprite(DExhumedActor* pActor)
} }
} }
void BulletHitsSprite(Bullet *pBullet, DExhumedActor* pBulletActor, DExhumedActor* pHitActor, int x, int y, int z, sectortype* pSector) void BulletHitsSprite(Bullet *pBullet, DExhumedActor* pBulletActor, DExhumedActor* pHitActor, const DVector3& pos, sectortype* pSector)
{ {
assert(pSector != nullptr); assert(pSector != nullptr);
@ -198,7 +198,7 @@ void BulletHitsSprite(Bullet *pBullet, DExhumedActor* pBulletActor, DExhumedActo
} }
if (!RandomSize(2)) { if (!RandomSize(2)) {
BuildAnim(nullptr, pBulletInfo->field_C, 0, x, y, z, pSector, 40, pBulletInfo->nFlags); BuildAnim(nullptr, pBulletInfo->field_C, 0, pos, pSector, 40, pBulletInfo->nFlags);
} }
return; return;
@ -267,7 +267,7 @@ void BulletHitsSprite(Bullet *pBullet, DExhumedActor* pBulletActor, DExhumedActo
if (nStat <= 90 || nStat >= 199) if (nStat <= 90 || nStat >= 199)
{ {
BuildAnim(nullptr, pBulletInfo->field_C, 0, x, y, z, pSector, 40, pBulletInfo->nFlags); BuildAnim(nullptr, pBulletInfo->field_C, 0, pos, pSector, 40, pBulletInfo->nFlags);
return; return;
} }
@ -279,13 +279,13 @@ void BulletHitsSprite(Bullet *pBullet, DExhumedActor* pBulletActor, DExhumedActo
case 102: case 102:
case kStatExplodeTrigger: case kStatExplodeTrigger:
case kStatExplodeTarget: case kStatExplodeTarget:
BuildAnim(nullptr, 12, 0, x, y, z, pSector, 40, 0); BuildAnim(nullptr, 12, 0, pos, pSector, 40, 0);
break; break;
default: default:
BuildAnim(nullptr, 39, 0, x, y, z, pSector, 40, 0); BuildAnim(nullptr, 39, 0, pos, pSector, 40, 0);
if (pBullet->nType > 2) if (pBullet->nType > 2)
{ {
BuildAnim(nullptr, pBulletInfo->field_C, 0, x, y, z, pSector, 40, pBulletInfo->nFlags); BuildAnim(nullptr, pBulletInfo->field_C, 0, pos, pSector, 40, pBulletInfo->nFlags);
} }
break; break;
} }
@ -300,6 +300,7 @@ void BackUpBullet(int *x, int *y, int nAngle)
int MoveBullet(int nBullet) int MoveBullet(int nBullet)
{ {
DExhumedActor* hitactor = nullptr; DExhumedActor* hitactor = nullptr;
sectortype* pHitSect = nullptr; sectortype* pHitSect = nullptr;
walltype* pHitWall = nullptr; walltype* pHitWall = nullptr;
@ -316,6 +317,7 @@ int MoveBullet(int nBullet)
int nSectFlag = pActor->sector()->Flag; int nSectFlag = pActor->sector()->Flag;
int x2, y2, z2; int x2, y2, z2;
DVector3 pos;
int nVal = 0; int nVal = 0;
Collision coll; Collision coll;
@ -372,6 +374,7 @@ MOVEEND:
x2 = pActor->int_pos().X; x2 = pActor->int_pos().X;
y2 = pActor->int_pos().Y; y2 = pActor->int_pos().Y;
z2 = pActor->int_pos().Z; z2 = pActor->int_pos().Z;
pos = pActor->spr.pos;
pHitSect = pActor->sector(); pHitSect = pActor->sector();
switch (coll.type) switch (coll.type)
@ -441,6 +444,7 @@ MOVEEND:
pHitSect = hit.hitSector; pHitSect = hit.hitSector;
pHitWall = hit.hitWall; pHitWall = hit.hitWall;
} }
pos = {x2 * inttoworld, y2 * inttoworld, z2 * zinttoworld};
lasthitx = x2; lasthitx = x2;
lasthity = y2; lasthity = y2;
@ -461,7 +465,7 @@ HITSPRITE:
} }
else else
{ {
BulletHitsSprite(pBullet, pActor->pTarget, hitactor, x2, y2, z2, pHitSect); BulletHitsSprite(pBullet, pActor->pTarget, hitactor, pos, pHitSect);
} }
} }
else if (pHitWall != nullptr) else if (pHitWall != nullptr)
@ -494,7 +498,7 @@ HITSPRITE:
} }
else else
{ {
BuildAnim(nullptr, pBulletInfo->field_C, 0, x2, y2, z2, pHitSect, 40, pBulletInfo->nFlags); BuildAnim(nullptr, pBulletInfo->field_C, 0, pos, pHitSect, 40, pBulletInfo->nFlags);
} }
} }
else else
@ -505,14 +509,14 @@ HITSPRITE:
if (nType != 3 || RandomSize(2) == 0) if (nType != 3 || RandomSize(2) == 0)
{ {
int zOffset = RandomSize(8) << 3; double zOffset = RandomSize(8) / 32.;
if (!RandomBit()) { if (!RandomBit()) {
zOffset = -zOffset; zOffset = -zOffset;
} }
// draws bullet puff on walls when they're shot // draws bullet puff on walls when they're shot
BuildAnim(nullptr, pBulletInfo->field_C, 0, x2, y2, z2 + zOffset + -4096, pHitSect, 40, pBulletInfo->nFlags); BuildAnim(nullptr, pBulletInfo->field_C, 0, pos.plusZ(zOffset - 16), pHitSect, 40, pBulletInfo->nFlags);
} }
} }
else else
@ -569,7 +573,7 @@ DExhumedActor* BuildBullet(DExhumedActor* pActor, int nType, int nZOffset, int n
assert(pTarget->sector()); assert(pTarget->sector());
BulletHitsSprite(&sBullet, pActor, pTarget, pTarget->int_pos().X, pTarget->int_pos().Y, pTarget->int_pos().Z - (nHeight >> 1), pTarget->sector()); BulletHitsSprite(&sBullet, pActor, pTarget, pTarget->spr.pos.plusZ(-(nHeight >> 1) * zinttoworld), pTarget->sector());
DeleteActor(sBullet.pActor); DeleteActor(sBullet.pActor);
return nullptr; return nullptr;
} }
@ -800,7 +804,7 @@ void AIBullet::Tick(RunListEvent* ev)
if (nFlag & 0x80) if (nFlag & 0x80)
{ {
BuildAnim(nullptr, 45, 0, pActor->int_pos().X, pActor->int_pos().Y, pActor->int_pos().Z, pActor->sector(), pActor->spr.xrepeat, 0); BuildAnim(nullptr, 45, 0, pActor->spr.pos, pActor->sector(), pActor->spr.xrepeat, 0);
} }
BulletList[nBullet].nFrame++; BulletList[nBullet].nFrame++;

View file

@ -72,9 +72,9 @@ void BuildFishLimb(DExhumedActor* pActor, int anim)
pChunkActor->spr.hitag = runlist_AddRunRec(NewRun, pChunkActor, 0x200000); pChunkActor->spr.hitag = runlist_AddRunRec(NewRun, pChunkActor, 0x200000);
} }
void BuildBlood(int x, int y, int z, sectortype* pSector) void BuildBlood(const DVector3& pos, sectortype* pSector)
{ {
BuildAnim(nullptr, kSeqFish, 36, x, y, z, pSector, 75, 128); BuildAnim(nullptr, kSeqFish, 36, pos, pSector, 75, 128);
} }
void AIFishLimb::Tick(RunListEvent* ev) void AIFishLimb::Tick(RunListEvent* ev)
@ -94,7 +94,7 @@ void AIFishLimb::Tick(RunListEvent* ev)
{ {
pActor->nFrame = 0; pActor->nFrame = 0;
if (RandomBit()) { if (RandomBit()) {
BuildBlood(pActor->int_pos().X, pActor->int_pos().Y, pActor->int_pos().Z, pActor->sector()); BuildBlood(pActor->spr.pos, pActor->sector());
} }
} }

View file

@ -190,7 +190,7 @@ void ExplodeGrenade(DExhumedActor* pActor)
runlist_RadialDamageEnemy(pActor, nDamage, BulletInfo[kWeaponGrenade].nRadius); runlist_RadialDamageEnemy(pActor, nDamage, BulletInfo[kWeaponGrenade].nRadius);
BuildAnim(nullptr, var_28, 0, pActor->int_pos().X, pActor->int_pos().Y, pActor->int_pos().Z, pActor->sector(), var_20, 4); BuildAnim(nullptr, var_28, 0, pActor->spr.pos, pActor->sector(), var_20, 4);
AddFlash(pActor->sector(), pActor->int_pos().X, pActor->int_pos().Y, pActor->int_pos().Z, 128); AddFlash(pActor->sector(), pActor->int_pos().X, pActor->int_pos().Y, pActor->int_pos().Z, 128);
DestroyGrenade(pActor); DestroyGrenade(pActor);

View file

@ -742,7 +742,7 @@ loc_flag:
else if (pActor2->spr.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, DVector3(theX * inttoworld, theY * inttoworld, theZ * zinttoworld), pSectorB, 30, 0);
} }
else if (pActor2->spr.statnum == kStatExplodeTrigger) { else if (pActor2->spr.statnum == kStatExplodeTrigger) {
var_28 += 2; var_28 += 2;
@ -754,7 +754,7 @@ loc_flag:
else else
{ {
// loc_27370: // loc_27370:
BuildAnim(nullptr, 12, 0, theX, theY, theZ, pSectorB, 30, 0); BuildAnim(nullptr, 12, 0, DVector3(theX * inttoworld, theY * inttoworld, theZ * zinttoworld), pSectorB, 30, 0);
} }
} }
} }

View file

@ -123,7 +123,7 @@ void BuildItemAnim(DExhumedActor* pActor)
if (nItemAnimInfo[nItem].a >= 0) if (nItemAnimInfo[nItem].a >= 0)
{ {
auto pAnimActor = BuildAnim(pActor, 41, nItemAnimInfo[nItem].a, pActor->int_pos().X, pActor->int_pos().Y, pActor->int_pos().Z, pActor->sector(), nItemAnimInfo[nItem].repeat, 20); auto pAnimActor = BuildAnim(pActor, 41, nItemAnimInfo[nItem].a, pActor->spr.pos, pActor->sector(), nItemAnimInfo[nItem].repeat, 20);
if (nItem == 44) { if (nItem == 44) {
pAnimActor->spr.cstat |= CSTAT_SPRITE_TRANSLUCENT; pAnimActor->spr.cstat |= CSTAT_SPRITE_TRANSLUCENT;
@ -338,9 +338,7 @@ void DropMagic(DExhumedActor* pActor)
nullptr, nullptr,
64, 64,
0, 0,
pActor->int_pos().X, pActor->spr.pos,
pActor->int_pos().Y,
pActor->int_pos().Z,
pActor->sector(), pActor->sector(),
48, 48,
4); 4);
@ -401,7 +399,7 @@ void DoRegenerates()
if (pActor->spr.extra <= 0) if (pActor->spr.extra <= 0)
{ {
BuildAnim(nullptr, 38, 0, pActor->int_pos().X, pActor->int_pos().Y, pActor->int_pos().Z, pActor->sector(), 64, 4); BuildAnim(nullptr, 38, 0, pActor->spr.pos, pActor->sector(), 64, 4);
D3PlayFX(StaticSound[kSoundTorchOn], pActor); D3PlayFX(StaticSound[kSoundTorchOn], pActor);
} }
else { else {

View file

@ -1230,20 +1230,20 @@ int GetWallNormal(walltype* pWall)
return (nAngle + 512) & kAngleMask; return (nAngle + 512) & kAngleMask;
} }
void WheresMyMouth(int nPlayer, vec3_t* pos, sectortype **sectnum) DVector3 WheresMyMouth(int nPlayer, sectortype **sectnum)
{ {
auto pActor = PlayerList[nPlayer].pActor; auto pActor = PlayerList[nPlayer].pActor;
int height = GetActorHeight(pActor) >> 1; int height = GetActorHeight(pActor) >> 1;
*sectnum = pActor->sector(); *sectnum = pActor->sector();
*pos = pActor->int_pos(); auto pos = pActor->spr.pos.plusZ(-height * zinttoworld);
pos->Z -= height;
Collision scratch; Collision scratch;
clipmove(*pos, sectnum, clipmove(pos, sectnum,
bcos(pActor->int_ang(), 7), bcos(pActor->int_ang(), 7),
bsin(pActor->int_ang(), 7), bsin(pActor->int_ang(), 7),
5120, 1280, 1280, CLIPMASK1, scratch); 5120, 1280, 1280, CLIPMASK1, scratch);
return pos;
} }
void InitChunks() void InitChunks()

View file

@ -1931,7 +1931,7 @@ void AIObject::Tick(RunListEvent* ev)
} }
AddFlash(pActor->sector(), pActor->int_pos().X, pActor->int_pos().Y, pActor->int_pos().Z, 128); AddFlash(pActor->sector(), pActor->int_pos().X, pActor->int_pos().Y, pActor->int_pos().Z, 128);
BuildAnim(nullptr, var_18, 0, pActor->int_pos().X, pActor->int_pos().Y, pActor->sector()->int_floorz(), pActor->sector(), 240, 4); BuildAnim(nullptr, var_18, 0, DVector3(pActor->spr.pos.XY(), pActor->sector()->floorz), pActor->sector(), 240, 4);
// int edi = nSprite | 0x4000; // int edi = nSprite | 0x4000;

View file

@ -2506,11 +2506,10 @@ sectdone:
if (!RandomSize(5)) if (!RandomSize(5))
{ {
vec3_t pos;
sectortype* mouthSect; sectortype* mouthSect;
WheresMyMouth(nPlayer, &pos, &mouthSect); auto pos = WheresMyMouth(nPlayer, &mouthSect);
BuildAnim(nullptr, 71, 0, pos.X, pos.Y, pPlayerActor->int_pos().Z + 3840, mouthSect, 75, 128); BuildAnim(nullptr, 71, 0, DVector3(pos.XY(), pPlayerActor->spr.pos.Z + 15), mouthSect, 75, 128);
} }
break; break;
case 17: case 17:

View file

@ -249,7 +249,7 @@ void DestroyEgg(int nEgg)
if (QueenEgg[nEgg].nAction != 4) if (QueenEgg[nEgg].nAction != 4)
{ {
BuildAnim(nullptr, 34, 0, pActor->int_pos().X, pActor->int_pos().Y, pActor->int_pos().Z, pActor->sector(), pActor->spr.xrepeat, 4); BuildAnim(nullptr, 34, 0, pActor->spr.pos, pActor->sector(), pActor->spr.xrepeat, 4);
} }
else else
{ {
@ -1461,7 +1461,7 @@ void AIQueen::Damage(RunListEvent* ev)
QueenList[nQueen].nHealth = 4000; QueenList[nQueen].nHealth = 4000;
QueenList[nQueen].nAction = 7; QueenList[nQueen].nAction = 7;
BuildAnim(nullptr, 36, 0, pActor->int_pos().X, pActor->int_pos().Y, pActor->int_pos().Z - 7680, pActor->sector(), pActor->spr.xrepeat, 4); BuildAnim(nullptr, 36, 0, pActor->spr.pos.plusZ(-30), pActor->sector(), pActor->spr.xrepeat, 4);
break; break;
case 2: case 2:
QueenList[nQueen].nHealth = 4000; QueenList[nQueen].nHealth = 4000;

View file

@ -117,7 +117,7 @@ void ExplodeSnakeSprite(DExhumedActor* pActor, int nPlayer)
pActor->pTarget = nOwner; pActor->pTarget = nOwner;
BuildAnim(nullptr, 23, 0, pActor->int_pos().X, pActor->int_pos().Y, pActor->int_pos().Z, pActor->sector(), 40, 4); BuildAnim(nullptr, 23, 0, pActor->spr.pos, pActor->sector(), 40, 4);
AddFlash(pActor->sector(), pActor->int_pos().X, pActor->int_pos().Y, pActor->int_pos().Z, 128); AddFlash(pActor->sector(), pActor->int_pos().X, pActor->int_pos().Y, pActor->int_pos().Z, 128);
@ -160,7 +160,7 @@ void BuildSnake(int nPlayer, int zVal)
BackUpBullet(&v.X, &v.Y, nAngle); BackUpBullet(&v.X, &v.Y, nAngle);
hit.set_int_hitpos_xy(v.X, v.Y); hit.set_int_hitpos_xy(v.X, v.Y);
auto pActor = insertActor(hit.hitSector, 202); auto pActor = insertActor(hit.hitSector, 202);
pActor->set_int_pos(hit.int_hitpos()); pActor->spr.pos = hit.hitpos;
ExplodeSnakeSprite(pActor, nPlayer); ExplodeSnakeSprite(pActor, nPlayer);
DeleteActor(pActor); DeleteActor(pActor);