From 1c154a984d14b81eef1b286c01f40d0461cbe847 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 22 Aug 2022 18:31:45 +0200 Subject: [PATCH] - floatified XSPRITE::TargetPos --- source/games/blood/src/actor.cpp | 12 ++++++------ source/games/blood/src/ai.cpp | 13 ++++++------- source/games/blood/src/aizomba.cpp | 2 +- source/games/blood/src/db.cpp | 2 +- source/games/blood/src/mapstructs.h | 17 +++-------------- source/games/blood/src/nnexts.cpp | 6 +++--- 6 files changed, 20 insertions(+), 32 deletions(-) diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index 8a12bb9c6..5b2b67220 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -3965,7 +3965,7 @@ static void actImpactMissile(DBloodActor* missileActor, int hitCode) { missileActor->spr.picnum = 2123; missileActor->SetTarget(actorHit); - missileActor->xspr.set_int_TargetPos_Z(missileActor->int_pos().Z - actorHit->int_pos().Z); + missileActor->xspr.TargetPos.Z = (missileActor->spr.pos.Z - actorHit->spr.pos.Z); missileActor->xspr.goalAng = getangle(missileActor->spr.pos.XY() - actorHit->spr.pos.XY()) - actorHit->int_ang(); missileActor->xspr.state = 1; actPostSprite(missileActor, kStatFlare); @@ -5547,7 +5547,7 @@ static void actCheckProximity() case kThingBloodBits: case kThingBloodChunks: case kThingZombieHead: - if (actor->xspr.locked && PlayClock >= actor->xspr.NotReallyTargetPos.X) actor->xspr.locked = 0; + if (actor->xspr.locked && PlayClock >= actor->xspr.TargetPos.X) actor->xspr.locked = 0; break; } @@ -6349,7 +6349,7 @@ DBloodActor* actSpawnThing(sectortype* pSector, int x, int y, int z, int nThingT actor->xspr.data2 = 0; actor->xspr.data3 = 0; actor->xspr.data4 = 318; - actor->xspr.NotReallyTargetPos.X = PlayClock + 180; + actor->xspr.TargetPos.X = PlayClock + 180; actor->xspr.locked = 1; actor->xspr.state = 1; actor->xspr.triggerOnce = 0; @@ -6362,7 +6362,7 @@ DBloodActor* actSpawnThing(sectortype* pSector, int x, int y, int z, int nThingT actor->xspr.data2 = 0; actor->xspr.data3 = 0; actor->xspr.data4 = 319; - actor->xspr.NotReallyTargetPos.X = PlayClock + 180; + actor->xspr.TargetPos.X = PlayClock + 180; actor->xspr.locked = 1; actor->xspr.state = 1; actor->xspr.triggerOnce = 0; @@ -6994,7 +6994,7 @@ void DudeToGibCallback1(int, DBloodActor* actor) actor->xspr.triggerOnce = 0; actor->xspr.isTriggered = 0; actor->xspr.locked = 0; - actor->xspr.NotReallyTargetPos.X = PlayClock; + actor->xspr.TargetPos.X = PlayClock; actor->xspr.state = 1; } @@ -7009,7 +7009,7 @@ void DudeToGibCallback2(int, DBloodActor* actor) actor->xspr.triggerOnce = 0; actor->xspr.isTriggered = 0; actor->xspr.locked = 0; - actor->xspr.NotReallyTargetPos.X = PlayClock; + actor->xspr.TargetPos.X = PlayClock; actor->xspr.state = 1; } diff --git a/source/games/blood/src/ai.cpp b/source/games/blood/src/ai.cpp index 6000bbcdf..a037a46f8 100644 --- a/source/games/blood/src/ai.cpp +++ b/source/games/blood/src/ai.cpp @@ -916,7 +916,7 @@ void aiActivateDude(DBloodActor* actor) void aiSetTarget(DBloodActor* actor, int x, int y, int z) { actor->SetTarget(nullptr); - actor->xspr.set_int_TargetPos(x, y, z); + actor->xspr.TargetPos = {x * maptoworld, y * maptoworld, z * zmaptoworld }; } void aiSetTarget(DBloodActor* actor, DBloodActor* target) @@ -932,7 +932,8 @@ void aiSetTarget(DBloodActor* actor, DBloodActor* target) { actor->SetTarget(target); DUDEINFO* pDudeInfo = getDudeInfo(target->spr.type); - actor->xspr.set_int_TargetPos(target->int_pos().X, target->int_pos().Y, target->int_pos().Z - ((pDudeInfo->eyeHeight * target->spr.yrepeat) << 2)); + double eyeHeight = ((pDudeInfo->eyeHeight * target->spr.yrepeat) << 2) * inttoworld; + actor->xspr.TargetPos = target->spr.pos.plusZ(-eyeHeight); } } } @@ -1691,7 +1692,7 @@ void aiInitSprite(DBloodActor* actor) #ifdef NOONE_EXTENSIONS unsigned int stateTimer = 0; - int targetX = 0, targetY = 0, targetZ = 0; + DVector3 targetV(0,0,0); DBloodActor* pTargetMarker = nullptr; // dude patrol init @@ -1702,9 +1703,7 @@ void aiInitSprite(DBloodActor* actor) { stateTimer = actor->xspr.stateTimer; pTargetMarker = actor->GetTarget(); - targetX = actor->xspr.int_TargetPos().X; - targetY = actor->xspr.int_TargetPos().Y; - targetZ = actor->xspr.int_TargetPos().Z; + targetV = actor->xspr.TargetPos; } } #endif @@ -1923,7 +1922,7 @@ void aiInitSprite(DBloodActor* actor) if (pTargetMarker) { actor->SetTarget(pTargetMarker); - actor->xspr.set_int_TargetPos(targetX, targetY, targetZ); + actor->xspr.TargetPos = targetV; } // reset target spot progress diff --git a/source/games/blood/src/aizomba.cpp b/source/games/blood/src/aizomba.cpp index a12f8445c..cafc1478e 100644 --- a/source/games/blood/src/aizomba.cpp +++ b/source/games/blood/src/aizomba.cpp @@ -266,7 +266,7 @@ static void entryAIdle(DBloodActor* actor) static void entryEStand(DBloodActor* actor) { sfxPlay3DSound(actor, 1100, -1, 0); - actor->set_int_ang(getangle(actor->xspr.int_TargetPos().X - actor->int_pos().X, actor->xspr.int_TargetPos().Y - actor->int_pos().Y)); + actor->spr.angle = VecToAngle(actor->xspr.TargetPos - actor->spr.pos); } END_BLD_NS diff --git a/source/games/blood/src/db.cpp b/source/games/blood/src/db.cpp index a294b1d0d..cb115cd37 100644 --- a/source/games/blood/src/db.cpp +++ b/source/games/blood/src/db.cpp @@ -568,7 +568,7 @@ void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, int* int tx = bitReader.readSigned(32); int ty = bitReader.readSigned(32); int tz = bitReader.readSigned(32); - pXSprite->set_int_TargetPos(tx,ty,tz); + pXSprite->TargetPos = {tx * maptoworld, ty * maptoworld, tz * zmaptoworld }; pXSprite->burnTime = bitReader.readUnsigned(16); /*pXSprite->burnSource =*/ bitReader.readSigned(16); pXSprite->height = bitReader.readUnsigned(16); diff --git a/source/games/blood/src/mapstructs.h b/source/games/blood/src/mapstructs.h index 3f5f1080f..dd88d2b30 100644 --- a/source/games/blood/src/mapstructs.h +++ b/source/games/blood/src/mapstructs.h @@ -101,21 +101,10 @@ struct XSPRITE { TObjPtr target; // target sprite TObjPtr burnSource; - const vec3_t int_TargetPos() const { return TargetPos; } - void set_int_TargetPos(int x, int y, int z) - { - TargetPos = {x ,y ,z}; - } - void set_int_TargetPos_Z(int z) - { - TargetPos.Z = z; - } + const vec3_t int_TargetPos() const { return { int(TargetPos.X * worldtoint), int(TargetPos.Y * worldtoint), int(TargetPos.Z * worldtoint)}; } + + DVector3 TargetPos; - union - { - vec3_t TargetPos; - vec3_t NotReallyTargetPos; - }; int32_t sysData1; // used to keep here various system data, so user can't change it in map editor int32_t sysData2; // int32_t scale; // used for scaling SEQ size on sprites diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index b92741b8e..7a0a2e389 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -7216,7 +7216,7 @@ void useTargetChanger(DBloodActor* sourceactor, DBloodActor* actor) { actor->SetTarget(pMateTargetActor); auto pMate = pMateTargetActor->GetTarget(); - actor->xspr.set_int_TargetPos(pMate->int_pos().X, pMate->int_pos().Y, pMate->int_pos().Z); + actor->xspr.TargetPos = pMate->spr.pos; if (!isActive(actor)) aiActivateDude(actor); return; @@ -8030,7 +8030,7 @@ void aiPatrolSetMarker(DBloodActor* actor) while (auto nextactor = it.Next()) { if (nextactor == targetactor || !nextactor->hasX()) continue; - else if (actor->xspr.NotReallyTargetPos.X >= 0 && nextactor == prevactor && node) + else if (actor->xspr.TargetPos.X >= 0 && nextactor == prevactor && node) { if (targetactor->xspr.data2 == prevactor->xspr.data1) continue; @@ -8081,7 +8081,7 @@ void aiPatrolStop(DBloodActor* actor, DBloodActor* targetactor, bool alarm) actor->xspr.unused1 &= ~kDudeFlagCrouch; // reset the crouch status actor->xspr.unused2 = kPatrolMoveForward; // reset path direction actor->prevmarker = nullptr; - actor->xspr.NotReallyTargetPos.X = -1; // reset the previous marker index + actor->xspr.TargetPos.X = -1; // reset the previous marker index if (actor->xspr.health <= 0) return;