From 478672879e7c62bc3b9eab754378bfe98969dbcb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 23 Aug 2022 22:45:42 +0200 Subject: [PATCH] - partial HitScan parameter change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The really easy stuff… --- source/games/blood/src/actor.cpp | 2 +- source/games/blood/src/aibeast.cpp | 6 +++--- source/games/blood/src/aicaleb.cpp | 2 +- source/games/blood/src/aicerber.cpp | 2 +- source/games/blood/src/aicult.cpp | 20 ++++++++++---------- source/games/blood/src/aigarg.cpp | 8 ++++---- source/games/blood/src/aighost.cpp | 4 ++-- source/games/blood/src/aigilbst.cpp | 2 +- source/games/blood/src/aispid.cpp | 2 +- source/games/blood/src/aiunicult.cpp | 8 ++++---- source/games/blood/src/aizombf.cpp | 6 +++--- source/games/blood/src/gameutil.h | 4 ++++ source/games/blood/src/nnexts.cpp | 6 +++--- 13 files changed, 38 insertions(+), 34 deletions(-) diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index b0955cbea..52bf9a537 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -6819,7 +6819,7 @@ void actFireVector(DBloodActor* shooter, int a2, int a3, int a4, int a5, int a6, a4 += Random3(4000); a5 += Random3(4000); a6 += Random3(4000); - if (HitScan(actor, gHitInfo.int_hitpos().Z, a4, a5, a6, CLIPMASK1, tt) == 0) + if (HitScan(actor, gHitInfo.hitpos.Z, a4, a5, a6, CLIPMASK1, tt) == 0) { if (approxDist(gHitInfo.hitpos.XY() - actor->spr.pos.XY()) <= tt) { diff --git a/source/games/blood/src/aibeast.cpp b/source/games/blood/src/aibeast.cpp index 673992dac..5dff02595 100644 --- a/source/games/blood/src/aibeast.cpp +++ b/source/games/blood/src/aibeast.cpp @@ -89,7 +89,7 @@ void StompSeqCallback(int, DBloodActor* actor) int v10 = 25 + 30 * gGameOptions.nDifficulty; const bool newSectCheckMethod = !cl_bloodvanillaenemies && !VanillaMode(); // use new sector checking logic auto sectorMap = GetClosestSpriteSectors(pSector, actor->spr.pos.XY(), vc, nullptr, newSectCheckMethod); - int hit = HitScan(actor, actor->int_pos().Z, angx, angy, 0, CLIPMASK1, 0); + int hit = HitScan(actor, actor->spr.pos.Z, angx, angy, 0, CLIPMASK1, 0); DBloodActor* actorh = nullptr; actHitcodeToData(hit, &gHitInfo, &actorh); @@ -243,7 +243,7 @@ static void beastThinkChase(DBloodActor* actor) if (nDist < 0x1400 && nDist > 0xa00 && abs(nDeltaAngle) < 85 && (target->spr.flags & 2) && target->IsPlayerActor() && Chance(0x8000)) { - int hit = HitScan(actor, actor->int_pos().Z, dx, dy, 0, CLIPMASK1, 0); + int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0); if (target->xspr.health > (unsigned)gPlayerTemplate[0].startHealth / 2) { switch (hit) @@ -275,7 +275,7 @@ static void beastThinkChase(DBloodActor* actor) } if (nDist < 921 && abs(nDeltaAngle) < 28) { - int hit = HitScan(actor, actor->int_pos().Z, dx, dy, 0, CLIPMASK1, 0); + int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0); switch (hit) { case -1: diff --git a/source/games/blood/src/aicaleb.cpp b/source/games/blood/src/aicaleb.cpp index 984cb8966..033384862 100644 --- a/source/games/blood/src/aicaleb.cpp +++ b/source/games/blood/src/aicaleb.cpp @@ -163,7 +163,7 @@ static void calebThinkChase(DBloodActor* actor) { int dx = dvec.X * worldtoint; int dy = dvec.Y * worldtoint; - int hit = HitScan(actor, actor->int_pos().Z, dx, dy, 0, CLIPMASK1, 0); + int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0); switch (hit) { case -1: diff --git a/source/games/blood/src/aicerber.cpp b/source/games/blood/src/aicerber.cpp index 25f83a587..f6350d188 100644 --- a/source/games/blood/src/aicerber.cpp +++ b/source/games/blood/src/aicerber.cpp @@ -401,7 +401,7 @@ static void cerberusThinkChase(DBloodActor* actor) { int dx = dvec.X * worldtoint; int dy = dvec.Y * worldtoint; - int hit = HitScan(actor, actor->int_pos().Z, dx, dy, 0, CLIPMASK1, 0); + int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0); switch (actor->spr.type) { case kDudeCerberusTwoHead: switch (hit) { diff --git a/source/games/blood/src/aicult.cpp b/source/games/blood/src/aicult.cpp index e0daaa4ba..8aa496371 100644 --- a/source/games/blood/src/aicult.cpp +++ b/source/games/blood/src/aicult.cpp @@ -286,7 +286,7 @@ static void cultThinkChase(DBloodActor* actor) && (target->spr.flags & 2) && gGameOptions.nDifficulty > 2 && target->IsPlayerActor() && gPlayer[target->spr.type - kDudePlayer1].isRunning && Chance(0x8000)) { - int hit = HitScan(actor, actor->int_pos().Z, dx, dy, 0, CLIPMASK1, 0); + int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0); switch (hit) { case -1: @@ -307,7 +307,7 @@ static void cultThinkChase(DBloodActor* actor) } else if (nDist < 0x4600 && abs(nDeltaAngle) < 28) { - int hit = HitScan(actor, actor->int_pos().Z, dx, dy, 0, CLIPMASK1, 0); + int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0); switch (hit) { case -1: @@ -354,7 +354,7 @@ static void cultThinkChase(DBloodActor* actor) && (target->spr.flags & 2) && gGameOptions.nDifficulty >= 2 && target->IsPlayerActor() && !gPlayer[target->spr.type - kDudePlayer1].isRunning && Chance(0x8000)) { - int hit = HitScan(actor, actor->int_pos().Z, dx, dy, 0, CLIPMASK1, 0); + int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0); switch (hit) { case -1: @@ -375,7 +375,7 @@ static void cultThinkChase(DBloodActor* actor) } else if (nDist < 0x3200 && abs(nDeltaAngle) < 28) { - int hit = HitScan(actor, actor->int_pos().Z, dx, dy, 0, CLIPMASK1, 0); + int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0); switch (hit) { case -1: @@ -422,7 +422,7 @@ static void cultThinkChase(DBloodActor* actor) && (target->spr.flags & 2) && gGameOptions.nDifficulty > 2 && target->IsPlayerActor() && gPlayer[target->spr.type - kDudePlayer1].isRunning && Chance(0x8000)) { - int hit = HitScan(actor, actor->int_pos().Z, dx, dy, 0, CLIPMASK1, 0); + int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0); switch (hit) { case -1: @@ -444,7 +444,7 @@ static void cultThinkChase(DBloodActor* actor) else if (nDist < 0x3200 && abs(nDeltaAngle) < 28) { AISTATE *pCultistTsProneFire = !cl_bloodvanillaenemies && !VanillaMode() ? &cultistTsProneFireFixed : &cultistTsProneFire; - int hit = HitScan(actor, actor->int_pos().Z, dx, dy, 0, CLIPMASK1, 0); + int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0); switch (hit) { case -1: @@ -490,7 +490,7 @@ static void cultThinkChase(DBloodActor* actor) if (nDist < 0x2c00 && nDist > 0x1400 && abs(nDeltaAngle) < 85 && (target->spr.flags & 2) && target->IsPlayerActor()) { - int hit = HitScan(actor, actor->int_pos().Z, dx, dy, 0, CLIPMASK1, 0); + int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0); switch (hit) { case -1: @@ -511,7 +511,7 @@ static void cultThinkChase(DBloodActor* actor) else if (nDist < 0x1400 && abs(nDeltaAngle) < 85 && (target->spr.flags & 2) && target->IsPlayerActor()) { - int hit = HitScan(actor, actor->int_pos().Z, dx, dy, 0, CLIPMASK1, 0); + int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0); switch (hit) { case -1: @@ -535,7 +535,7 @@ static void cultThinkChase(DBloodActor* actor) && (target->spr.flags & 2) && gGameOptions.nDifficulty > 2 && target->IsPlayerActor() && gPlayer[target->spr.type - kDudePlayer1].isRunning && Chance(0x8000)) { - int hit = HitScan(actor, actor->int_pos().Z, dx, dy, 0, CLIPMASK1, 0); + int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0); switch (hit) { case -1: @@ -556,7 +556,7 @@ static void cultThinkChase(DBloodActor* actor) } else if (nDist < 0x3200 && abs(nDeltaAngle) < 28) { - int hit = HitScan(actor, actor->int_pos().Z, dx, dy, 0, CLIPMASK1, 0); + int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0); switch (hit) { case -1: diff --git a/source/games/blood/src/aigarg.cpp b/source/games/blood/src/aigarg.cpp index be2e94223..4751acd58 100644 --- a/source/games/blood/src/aigarg.cpp +++ b/source/games/blood/src/aigarg.cpp @@ -371,7 +371,7 @@ static void gargThinkChase(DBloodActor* actor) case kDudeGargoyleFlesh: if (nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85) { - int hit = HitScan(actor, actor->int_pos().Z, dx, dy, 0, CLIPMASK1, 0); + int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0); switch (hit) { case -1: @@ -396,7 +396,7 @@ static void gargThinkChase(DBloodActor* actor) } else if (nDist < 0x400 && abs(nDeltaAngle) < 85) { - int hit = HitScan(actor, actor->int_pos().Z, dx, dy, 0, CLIPMASK1, 0); + int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0); switch (hit) { case -1: @@ -430,7 +430,7 @@ static void gargThinkChase(DBloodActor* actor) case kDudeGargoyleStone: if (nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85) { - int hit = HitScan(actor, actor->int_pos().Z, dx, dy, 0, CLIPMASK1, 0); + int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0); switch (hit) { case -1: @@ -455,7 +455,7 @@ static void gargThinkChase(DBloodActor* actor) } else if (nDist < 0x400 && abs(nDeltaAngle) < 85) { - int hit = HitScan(actor, actor->int_pos().Z, dx, dy, 0, CLIPMASK1, 0); + int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0); switch (hit) { case -1: diff --git a/source/games/blood/src/aighost.cpp b/source/games/blood/src/aighost.cpp index 1c07a7642..4f46022dc 100644 --- a/source/games/blood/src/aighost.cpp +++ b/source/games/blood/src/aighost.cpp @@ -348,7 +348,7 @@ static void ghostThinkChase(DBloodActor* actor) switch (actor->spr.type) { case kDudePhantasm: if (nDist < 0x2000 && nDist > 0x1000 && abs(nDeltaAngle) < 85) { - int hit = HitScan(actor, actor->int_pos().Z, dx, dy, 0, CLIPMASK1, 0); + int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0); switch (hit) { case -1: @@ -368,7 +368,7 @@ static void ghostThinkChase(DBloodActor* actor) } else if (nDist < 0x400 && abs(nDeltaAngle) < 85) { - int hit = HitScan(actor, actor->int_pos().Z, dx, dy, 0, CLIPMASK1, 0); + int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0); switch (hit) { case -1: diff --git a/source/games/blood/src/aigilbst.cpp b/source/games/blood/src/aigilbst.cpp index 7a442ca17..cccc5a295 100644 --- a/source/games/blood/src/aigilbst.cpp +++ b/source/games/blood/src/aigilbst.cpp @@ -148,7 +148,7 @@ static void gillThinkChase(DBloodActor* actor) actor->dudeSlope = nDist == 0 ? 0 : DivScale(target->int_pos().Z - actor->int_pos().Z, nDist, 10); if (nDist < 921 && abs(nDeltaAngle) < 28) { - int hit = HitScan(actor, actor->int_pos().Z, dx, dy, 0, CLIPMASK1, 0); + int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0); switch (hit) { case -1: diff --git a/source/games/blood/src/aispid.cpp b/source/games/blood/src/aispid.cpp index 055dc2e94..ecf6209db 100644 --- a/source/games/blood/src/aispid.cpp +++ b/source/games/blood/src/aispid.cpp @@ -70,7 +70,7 @@ void SpidBiteSeqCallback(int, DBloodActor* actor) auto const target = actor->GetTarget(); if (target->IsPlayerActor()) { - int hit = HitScan(actor, actor->int_pos().Z, dx, dy, 0, CLIPMASK1, 0); + int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0); if (hit == 3 && gHitInfo.actor()->IsPlayerActor()) { dz += target->int_pos().Z - actor->int_pos().Z; diff --git a/source/games/blood/src/aiunicult.cpp b/source/games/blood/src/aiunicult.cpp index d73282f43..fad73cabe 100644 --- a/source/games/blood/src/aiunicult.cpp +++ b/source/games/blood/src/aiunicult.cpp @@ -139,7 +139,7 @@ static bool genDudeAdjustSlope(DBloodActor* actor, int dist, int weaponType, int for (int i = -8191; i < 8192; i += by) { - HitScan(actor, actor->int_pos().Z, bcos(actor->int_ang()), bsin(actor->int_ang()), i, clipMask, dist); + HitScan(actor, actor->spr.pos.Z, bcos(actor->int_ang()), bsin(actor->int_ang()), i, clipMask, dist); if (!fStart && actor->GetTarget() == gHitInfo.actor()) fStart = i; else if (fStart && actor->GetTarget() != gHitInfo.actor()) { @@ -555,7 +555,7 @@ static void unicultThinkChase(DBloodActor* actor) } else if (dist < 12264 && dist > 7680 && !spriteIsUnderwater(actor, false) && curWeapon != kModernThingEnemyLifeLeech) { - int pHit = HitScan(actor, actor->int_pos().Z, dx, dy, 0, 16777280, 0); + int pHit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, 16777280, 0); switch (pHit) { case 0: case 4: @@ -744,9 +744,9 @@ static void unicultThinkChase(DBloodActor* actor) { int objDist = -1; int targetDist = -1; int hit = -1; if (weaponType == kGenDudeWeaponHitscan) - hit = HitScan(actor, actor->int_pos().Z, bcos(actor->int_ang()), bsin(actor->int_ang()), actor->dudeSlope, CLIPMASK1, dist); + hit = HitScan(actor, actor->spr.pos.Z, bcos(actor->int_ang()), bsin(actor->int_ang()), actor->dudeSlope, CLIPMASK1, dist); else if (weaponType == kGenDudeWeaponMissile) - hit = HitScan(actor, actor->int_pos().Z, bcos(actor->int_ang()), bsin(actor->int_ang()), actor->dudeSlope, CLIPMASK0, dist); + hit = HitScan(actor, actor->spr.pos.Z, bcos(actor->int_ang()), bsin(actor->int_ang()), actor->dudeSlope, CLIPMASK0, dist); if (hit >= 0) { diff --git a/source/games/blood/src/aizombf.cpp b/source/games/blood/src/aizombf.cpp index bfb79b4f3..2c0c031c5 100644 --- a/source/games/blood/src/aizombf.cpp +++ b/source/games/blood/src/aizombf.cpp @@ -136,7 +136,7 @@ static void zombfThinkChase(DBloodActor* actor) aiSetTarget(actor, actor->GetTarget()); if (nDist < 0x1400 && nDist > 0xe00 && abs(nDeltaAngle) < 85) { - int hit = HitScan(actor, actor->int_pos().Z, dx, dy, 0, CLIPMASK1, 0); + int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0); switch (hit) { case -1: @@ -155,7 +155,7 @@ static void zombfThinkChase(DBloodActor* actor) } else if (nDist < 0x1400 && nDist > 0x600 && abs(nDeltaAngle) < 85) { - int hit = HitScan(actor, actor->int_pos().Z, dx, dy, 0, CLIPMASK1, 0); + int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0); switch (hit) { case -1: @@ -174,7 +174,7 @@ static void zombfThinkChase(DBloodActor* actor) } else if (nDist < 0x400 && abs(nDeltaAngle) < 85) { - int hit = HitScan(actor, actor->int_pos().Z, dx, dy, 0, CLIPMASK1, 0); + int hit = HitScan(actor, actor->spr.pos.Z, dx, dy, 0, CLIPMASK1, 0); switch (hit) { case -1: diff --git a/source/games/blood/src/gameutil.h b/source/games/blood/src/gameutil.h index 364e64b0b..891e5d51c 100644 --- a/source/games/blood/src/gameutil.h +++ b/source/games/blood/src/gameutil.h @@ -38,6 +38,10 @@ int GetWallAngle(walltype* pWall); void GetWallNormal(walltype* pWall, int* pX, int* pY); bool IntersectRay(int wx, int wy, int wdx, int wdy, int x1, int y1, int z1, int x2, int y2, int z2, int* ix, int* iy, int* iz); int HitScan(DBloodActor* pSprite, int z, int dx, int dy, int dz, unsigned int nMask, int a8); +inline int HitScan(DBloodActor* pSprite, double z, int dx, int dy, int dz, unsigned int nMask, int a8) +{ + return HitScan(pSprite, int(z * zworldtoint), dx, dy, dz, nMask, a8); +} int VectorScan(DBloodActor* pSprite, int nOffset, int nZOffset, int dx, int dy, int dz, int nRange, int ac); void GetZRange(DBloodActor* pSprite, int* ceilZ, Collision* ceilHit, int* floorZ, Collision* floorHit, int nDist, unsigned int nMask, unsigned int nClipParallax = 0); void GetZRangeAtXYZ(int x, int y, int z, sectortype* pSector, int* ceilZ, Collision* ceilHit, int* floorZ, Collision* floorHit, int nDist, unsigned int nMask, unsigned int nClipParallax = 0); diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index ff9432d8b..321f18f33 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -4653,15 +4653,15 @@ bool condCheckSprite(DBloodActor* aCond, int cmpOp, bool PUSH) if ((pPlayer = getPlayerById(objActor->spr.type)) != NULL) var = HitScan(objActor, pPlayer->zWeapon, pPlayer->aim.dx, pPlayer->aim.dy, pPlayer->aim.dz, arg1, arg3 << 1); else if (objActor->IsDudeActor()) - var = HitScan(objActor, objActor->int_pos().Z, bcos(objActor->int_ang()), bsin(objActor->int_ang()), (!objActor->hasX()) ? 0 : objActor->dudeSlope, arg1, arg3 << 1); + var = HitScan(objActor, objActor->spr.pos.Z, bcos(objActor->int_ang()), bsin(objActor->int_ang()), (!objActor->hasX()) ? 0 : objActor->dudeSlope, arg1, arg3 << 1); else if ((objActor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) == CSTAT_SPRITE_ALIGNMENT_FLOOR) { var3 = (objActor->spr.cstat & CSTAT_SPRITE_YFLIP) ? 0x10000 << 1 : -(0x10000 << 1); - var = HitScan(objActor, objActor->int_pos().Z, Cos(objActor->int_ang()) >> 16, Sin(objActor->int_ang()) >> 16, var3, arg1, arg3 << 1); + var = HitScan(objActor, objActor->spr.pos.Z, Cos(objActor->int_ang()) >> 16, Sin(objActor->int_ang()) >> 16, var3, arg1, arg3 << 1); } else { - var = HitScan(objActor, objActor->int_pos().Z, bcos(objActor->int_ang()), bsin(objActor->int_ang()), 0, arg1, arg3 << 1); + var = HitScan(objActor, objActor->spr.pos.Z, bcos(objActor->int_ang()), bsin(objActor->int_ang()), 0, arg1, arg3 << 1); } if (var < 0)