diff --git a/source/games/exhumed/src/aistuff.h b/source/games/exhumed/src/aistuff.h index 47eae2316..c5dead0c1 100644 --- a/source/games/exhumed/src/aistuff.h +++ b/source/games/exhumed/src/aistuff.h @@ -29,7 +29,7 @@ BEGIN_PS_NS void InitAnims(); 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 BuildExplosion(DExhumedActor* actor); @@ -218,7 +218,7 @@ void Gravity(DExhumedActor* actor); DExhumedActor* UpdateEnemy(DExhumedActor** ppEnemy); Collision MoveCreature(DExhumedActor* nSprite); Collision MoveCreatureWithCaution(DExhumedActor* actor); -void WheresMyMouth(int nPlayer, vec3_t* pos, sectortype** sectnum); +DVector3 WheresMyMouth(int nPlayer, sectortype** sectnum); int GetActorHeight(DExhumedActor* nSprite); DExhumedActor* insertActor(sectortype* s, int st); DExhumedActor* GrabBody(); diff --git a/source/games/exhumed/src/anims.cpp b/source/games/exhumed/src/anims.cpp index 94fd379cd..a79d157b7 100644 --- a/source/games/exhumed/src/anims.cpp +++ b/source/games/exhumed/src/anims.cpp @@ -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) { pActor = insertActor(pSector, 500); } - pActor->set_int_pos({ x, y, z }); + pActor->spr.pos = pos; pActor->spr.cstat = 0; if (nFlag & 4) @@ -239,7 +239,7 @@ void BuildExplosion(DExhumedActor* pActor) 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) @@ -272,7 +272,7 @@ void BuildSplash(DExhumedActor* pActor, sectortype* pSector) 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) { diff --git a/source/games/exhumed/src/bubbles.cpp b/source/games/exhumed/src/bubbles.cpp index 8f7163e8f..913fa7e6c 100644 --- a/source/games/exhumed/src/bubbles.cpp +++ b/source/games/exhumed/src/bubbles.cpp @@ -33,7 +33,7 @@ void DestroyBubble(DExhumedActor* pActor) DeleteActor(pActor); } -DExhumedActor* BuildBubble(vec3_t pos, sectortype* pSector) +DExhumedActor* BuildBubble(const DVector3& pos, sectortype* pSector) { int nSize = RandomSize(3); if (nSize > 4) { @@ -42,7 +42,7 @@ DExhumedActor* BuildBubble(vec3_t pos, sectortype* pSector) auto pActor = insertActor(pSector, 402); - pActor->set_int_pos(pos); + pActor->spr.pos = pos; pActor->spr.cstat = 0; pActor->spr.shade = -32; pActor->spr.pal = 0; @@ -96,7 +96,7 @@ void AIBubble::Tick(RunListEvent* ev) auto pSectAbove = pSector->pAbove; 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); @@ -124,7 +124,7 @@ void DoBubbleMachines() { 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) { - vec3_t pos; sectortype* pSector; - WheresMyMouth(nPlayer, &pos, &pSector); + auto pos = WheresMyMouth(nPlayer, &pSector); auto pActor = BuildBubble(pos, pSector); pActor->spr.hitag = nPlayer; diff --git a/source/games/exhumed/src/bullet.cpp b/source/games/exhumed/src/bullet.cpp index 96d77b221..f52d7af94 100644 --- a/source/games/exhumed/src/bullet.cpp +++ b/source/games/exhumed/src/bullet.cpp @@ -165,7 +165,7 @@ void IgniteSprite(DExhumedActor* pActor) { 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) { @@ -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); @@ -198,7 +198,7 @@ void BulletHitsSprite(Bullet *pBullet, DExhumedActor* pBulletActor, DExhumedActo } 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; @@ -267,7 +267,7 @@ void BulletHitsSprite(Bullet *pBullet, DExhumedActor* pBulletActor, DExhumedActo 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; } @@ -279,13 +279,13 @@ void BulletHitsSprite(Bullet *pBullet, DExhumedActor* pBulletActor, DExhumedActo case 102: case kStatExplodeTrigger: case kStatExplodeTarget: - BuildAnim(nullptr, 12, 0, x, y, z, pSector, 40, 0); + BuildAnim(nullptr, 12, 0, pos, pSector, 40, 0); break; default: - BuildAnim(nullptr, 39, 0, x, y, z, pSector, 40, 0); + BuildAnim(nullptr, 39, 0, pos, pSector, 40, 0); 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; } @@ -300,6 +300,7 @@ void BackUpBullet(int *x, int *y, int nAngle) int MoveBullet(int nBullet) { + DExhumedActor* hitactor = nullptr; sectortype* pHitSect = nullptr; walltype* pHitWall = nullptr; @@ -316,6 +317,7 @@ int MoveBullet(int nBullet) int nSectFlag = pActor->sector()->Flag; int x2, y2, z2; + DVector3 pos; int nVal = 0; Collision coll; @@ -372,6 +374,7 @@ MOVEEND: x2 = pActor->int_pos().X; y2 = pActor->int_pos().Y; z2 = pActor->int_pos().Z; + pos = pActor->spr.pos; pHitSect = pActor->sector(); switch (coll.type) @@ -441,6 +444,7 @@ MOVEEND: pHitSect = hit.hitSector; pHitWall = hit.hitWall; } + pos = {x2 * inttoworld, y2 * inttoworld, z2 * zinttoworld}; lasthitx = x2; lasthity = y2; @@ -461,7 +465,7 @@ HITSPRITE: } else { - BulletHitsSprite(pBullet, pActor->pTarget, hitactor, x2, y2, z2, pHitSect); + BulletHitsSprite(pBullet, pActor->pTarget, hitactor, pos, pHitSect); } } else if (pHitWall != nullptr) @@ -494,7 +498,7 @@ HITSPRITE: } 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 @@ -505,14 +509,14 @@ HITSPRITE: if (nType != 3 || RandomSize(2) == 0) { - int zOffset = RandomSize(8) << 3; + double zOffset = RandomSize(8) / 32.; if (!RandomBit()) { zOffset = -zOffset; } // 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 @@ -569,7 +573,7 @@ DExhumedActor* BuildBullet(DExhumedActor* pActor, int nType, int nZOffset, int n 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); return nullptr; } @@ -800,7 +804,7 @@ void AIBullet::Tick(RunListEvent* ev) 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++; diff --git a/source/games/exhumed/src/fish.cpp b/source/games/exhumed/src/fish.cpp index 662500b76..e2f75c394 100644 --- a/source/games/exhumed/src/fish.cpp +++ b/source/games/exhumed/src/fish.cpp @@ -72,9 +72,9 @@ void BuildFishLimb(DExhumedActor* pActor, int anim) 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) @@ -94,7 +94,7 @@ void AIFishLimb::Tick(RunListEvent* ev) { pActor->nFrame = 0; if (RandomBit()) { - BuildBlood(pActor->int_pos().X, pActor->int_pos().Y, pActor->int_pos().Z, pActor->sector()); + BuildBlood(pActor->spr.pos, pActor->sector()); } } diff --git a/source/games/exhumed/src/grenade.cpp b/source/games/exhumed/src/grenade.cpp index cc0f4c313..61194f690 100644 --- a/source/games/exhumed/src/grenade.cpp +++ b/source/games/exhumed/src/grenade.cpp @@ -190,7 +190,7 @@ void ExplodeGrenade(DExhumedActor* pActor) 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); DestroyGrenade(pActor); diff --git a/source/games/exhumed/src/gun.cpp b/source/games/exhumed/src/gun.cpp index cc6704d53..e99e51e6e 100644 --- a/source/games/exhumed/src/gun.cpp +++ b/source/games/exhumed/src/gun.cpp @@ -742,7 +742,7 @@ loc_flag: else if (pActor2->spr.statnum == 102) { // 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) { var_28 += 2; @@ -754,7 +754,7 @@ loc_flag: else { // 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); } } } diff --git a/source/games/exhumed/src/items.cpp b/source/games/exhumed/src/items.cpp index 4a9f929e6..b23d8770e 100644 --- a/source/games/exhumed/src/items.cpp +++ b/source/games/exhumed/src/items.cpp @@ -123,7 +123,7 @@ void BuildItemAnim(DExhumedActor* pActor) 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) { pAnimActor->spr.cstat |= CSTAT_SPRITE_TRANSLUCENT; @@ -338,9 +338,7 @@ void DropMagic(DExhumedActor* pActor) nullptr, 64, 0, - pActor->int_pos().X, - pActor->int_pos().Y, - pActor->int_pos().Z, + pActor->spr.pos, pActor->sector(), 48, 4); @@ -401,7 +399,7 @@ void DoRegenerates() 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); } else { diff --git a/source/games/exhumed/src/move.cpp b/source/games/exhumed/src/move.cpp index ab5566091..4ce1c077c 100644 --- a/source/games/exhumed/src/move.cpp +++ b/source/games/exhumed/src/move.cpp @@ -1230,20 +1230,20 @@ int GetWallNormal(walltype* pWall) return (nAngle + 512) & kAngleMask; } -void WheresMyMouth(int nPlayer, vec3_t* pos, sectortype **sectnum) +DVector3 WheresMyMouth(int nPlayer, sectortype **sectnum) { auto pActor = PlayerList[nPlayer].pActor; int height = GetActorHeight(pActor) >> 1; *sectnum = pActor->sector(); - *pos = pActor->int_pos(); - pos->Z -= height; + auto pos = pActor->spr.pos.plusZ(-height * zinttoworld); Collision scratch; - clipmove(*pos, sectnum, + clipmove(pos, sectnum, bcos(pActor->int_ang(), 7), bsin(pActor->int_ang(), 7), 5120, 1280, 1280, CLIPMASK1, scratch); + return pos; } void InitChunks() diff --git a/source/games/exhumed/src/object.cpp b/source/games/exhumed/src/object.cpp index 77200691c..4433f0c34 100644 --- a/source/games/exhumed/src/object.cpp +++ b/source/games/exhumed/src/object.cpp @@ -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); - 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; diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index 4a7839ab1..57c7cc9ea 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -2506,11 +2506,10 @@ sectdone: if (!RandomSize(5)) { - vec3_t pos; 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; case 17: diff --git a/source/games/exhumed/src/queen.cpp b/source/games/exhumed/src/queen.cpp index 1545bf8d0..eb6b2c531 100644 --- a/source/games/exhumed/src/queen.cpp +++ b/source/games/exhumed/src/queen.cpp @@ -249,7 +249,7 @@ void DestroyEgg(int nEgg) 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 { @@ -1461,7 +1461,7 @@ void AIQueen::Damage(RunListEvent* ev) QueenList[nQueen].nHealth = 4000; 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; case 2: QueenList[nQueen].nHealth = 4000; diff --git a/source/games/exhumed/src/snake.cpp b/source/games/exhumed/src/snake.cpp index b3b3012ff..56d0877f9 100644 --- a/source/games/exhumed/src/snake.cpp +++ b/source/games/exhumed/src/snake.cpp @@ -117,7 +117,7 @@ void ExplodeSnakeSprite(DExhumedActor* pActor, int nPlayer) 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); @@ -160,7 +160,7 @@ void BuildSnake(int nPlayer, int zVal) BackUpBullet(&v.X, &v.Y, nAngle); hit.set_int_hitpos_xy(v.X, v.Y); auto pActor = insertActor(hit.hitSector, 202); - pActor->set_int_pos(hit.int_hitpos()); + pActor->spr.pos = hit.hitpos; ExplodeSnakeSprite(pActor, nPlayer); DeleteActor(pActor);