- handle most cansee calls.

This commit is contained in:
Christoph Oelckers 2021-11-24 00:35:46 +01:00
parent c8f4caf364
commit 9343e3f9c4
22 changed files with 68 additions and 70 deletions

View file

@ -148,12 +148,12 @@ bool CanMove(DBloodActor* actor, DBloodActor* target, int nAngle, int nRange)
}
x += MulScale(nRange, Cos(nAngle), 30);
y += MulScale(nRange, Sin(nAngle), 30);
int nSector = pSprite->sectnum;
assert(validSectorIndex(nSector));
if (!FindSector(x, y, z, &nSector))
auto pSector = pSprite->sector();
assert(pSector);
if (!FindSector(x, y, z, &pSector))
return false;
int floorZ = getflorzofslope(nSector, x, y);
auto pXSector = sector[nSector].hasX()? &sector[nSector].xs() : nullptr;
int floorZ = getflorzofslopeptr(pSector, x, y);
auto pXSector = pSector->hasX()? &pSector->xs() : nullptr;
bool Underwater = 0;
bool Water = 0;
bool Depth = 0;
@ -164,11 +164,11 @@ bool CanMove(DBloodActor* actor, DBloodActor* target, int nAngle, int nRange)
Underwater = 1;
if (pXSector->Depth)
Depth = 1;
if (sector[nSector].type == kSectorDamage || pXSector->damageType > 0)
if (pSector->type == kSectorDamage || pXSector->damageType > 0)
Crusher = 1;
}
auto Upper = getUpperLink(nSector);
auto Lower = getLowerLink(nSector);
auto Upper = pSector->upperLink;
auto Lower = pSector->lowerLink;
if (Upper != nullptr)
{
if (Upper->s().type == kMarkerUpWater || Upper->s().type == kMarkerUpGoo)
@ -1536,13 +1536,13 @@ void aiThinkTarget(DBloodActor* actor)
int x = pPlayer->pSprite->x;
int y = pPlayer->pSprite->y;
int z = pPlayer->pSprite->z;
int nSector = pPlayer->pSprite->sectnum;
auto pSector = pPlayer->pSprite->sector();
int dx = x - pSprite->x;
int dy = y - pSprite->y;
int nDist = approxDist(dx, dy);
if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist)
continue;
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sectnum))
if (!cansee(x, y, z, pSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sector()))
continue;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
@ -1584,13 +1584,13 @@ void aiLookForTarget(DBloodActor* actor)
int x = pPlayer->pSprite->x;
int y = pPlayer->pSprite->y;
int z = pPlayer->pSprite->z;
int nSector = pPlayer->pSprite->sectnum;
auto pSector = pPlayer->pSprite->sector();
int dx = x - pSprite->x;
int dy = y - pSprite->y;
int nDist = approxDist(dx, dy);
if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist)
continue;
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sectnum))
if (!cansee(x, y, z, pSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sector()))
continue;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)

View file

@ -104,13 +104,13 @@ static void batThinkTarget(DBloodActor* actor)
int x = pPlayer->pSprite->x;
int y = pPlayer->pSprite->y;
int z = pPlayer->pSprite->z;
int nSector = pPlayer->pSprite->sectnum;
auto pSector = pPlayer->pSprite->sector();
int dx = x - pSprite->x;
int dy = y - pSprite->y;
int nDist = approxDist(dx, dy);
if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist)
continue;
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sectnum))
if (!cansee(x, y, z, pSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sector()))
continue;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
@ -182,7 +182,7 @@ static void batThinkPonder(DBloodActor* actor)
int height2 = (getDudeInfo(pTarget->type)->eyeHeight * pTarget->yrepeat) << 2;
int top, bottom;
GetActorExtents(actor, &top, &bottom);
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector()))
{
aiSetTarget(actor, actor->GetTarget());
if (height2 - height < 0x3000 && nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85)
@ -295,7 +295,7 @@ static void batThinkChase(DBloodActor* actor)
int height2 = (pDudeInfo->eyeHeight * pTarget->yrepeat) << 2;
int top, bottom;
GetActorExtents(actor, &top, &bottom);
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector()))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{
@ -425,7 +425,6 @@ void batMoveToCeil(DBloodActor* actor)
int x = pSprite->x;
int y = pSprite->y;
int z = pSprite->z;
int nSector = pSprite->sectnum;
if (z - pXSprite->targetZ < 0x1000)
{
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
@ -434,7 +433,7 @@ void batMoveToCeil(DBloodActor* actor)
aiNewState(actor, &batIdle);
}
else
aiSetTarget(actor, x, y, sector[nSector].ceilingz);
aiSetTarget(actor, x, y, pSprite->sector()->ceilingz);
}
END_BLD_NS

View file

@ -88,7 +88,7 @@ void StompSeqCallback(int, DBloodActor* actor1)
int y = pSprite->y;
int z = pSprite->z;
int vc = 400;
int nSector = pSprite->sectnum;
auto nSector = pSprite->sectnum;
int v1c = 5 + 2 * gGameOptions.nDifficulty;
int v10 = 25 + 30 * gGameOptions.nDifficulty;
const bool newSectCheckMethod = !cl_bloodvanillaenemies && !VanillaMode(); // use new sector checking logic
@ -250,7 +250,7 @@ static void beastThinkChase(DBloodActor* actor)
{
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector()))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{
@ -385,7 +385,7 @@ static void beastThinkSwimChase(DBloodActor* actor)
int height = pDudeInfo->eyeHeight + pSprite->z;
int top, bottom;
GetActorExtents(actor, &top, &bottom);
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector()))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{

View file

@ -117,13 +117,13 @@ static void eelThinkTarget(DBloodActor* actor)
int x = pPlayer->pSprite->x;
int y = pPlayer->pSprite->y;
int z = pPlayer->pSprite->z;
int nSector = pPlayer->pSprite->sectnum;
auto pSector = pPlayer->pSprite->sector();
int dx = x - pSprite->x;
int dy = y - pSprite->y;
int nDist = approxDist(dx, dy);
if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist)
continue;
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sectnum))
if (!cansee(x, y, z, pSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sector()))
continue;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
@ -196,7 +196,7 @@ static void eelThinkPonder(DBloodActor* actor)
int height2 = (getDudeInfo(pTarget->type)->eyeHeight * pTarget->yrepeat) << 2;
int top, bottom;
GetActorExtents(actor, &top, &bottom);
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector()))
{
aiSetTarget(actor, actor->GetTarget());
if (height2 - height < -0x2000 && nDist < 0x1800 && nDist > 0xc00 && abs(nDeltaAngle) < 85)
@ -308,7 +308,7 @@ static void eelThinkChase(DBloodActor* actor)
GetActorExtents(actor, &top, &bottom);
int top2, bottom2;
GetSpriteExtents(pTarget, &top2, &bottom2);
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector()))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{
@ -428,7 +428,6 @@ void eelMoveToCeil(DBloodActor* actor)
int x = pSprite->x;
int y = pSprite->y;
int z = pSprite->z;
int nSector = pSprite->sectnum;
if (z - pXSprite->targetZ < 0x1000)
{
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
@ -437,7 +436,7 @@ void eelMoveToCeil(DBloodActor* actor)
aiNewState(actor, &eelIdle);
}
else
aiSetTarget(actor, x, y, sector[nSector].ceilingz);
aiSetTarget(actor, x, y, pSprite->sector()->ceilingz);
}
END_BLD_NS

View file

@ -199,7 +199,7 @@ static void burnThinkChase(DBloodActor* actor)
{
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector()))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{

View file

@ -158,7 +158,7 @@ static void calebThinkChase(DBloodActor* actor)
{
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector()))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{
@ -261,7 +261,7 @@ static void calebThinkSwimChase(DBloodActor* actor)
int height = pDudeInfo->eyeHeight + pSprite->z;
int top, bottom;
GetActorExtents(actor, &top, &bottom);
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector()))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{

View file

@ -127,7 +127,7 @@ void cerberusBurnSeqCallback(int, DBloodActor* actor)
if (abs(nDeltaAngle) <= tt1.at8)
{
int tz = pSprite2->z - pSprite->z;
if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum))
if (cansee(x, y, z, pSprite->sector(), x2, y2, z2, pSprite2->sector()))
{
nClosest = nDist2;
aim.dx = bcos(nAngle);
@ -208,7 +208,7 @@ void cerberusBurnSeqCallback2(int, DBloodActor* actor)
DUDEINFO* pDudeInfo2 = getDudeInfo(pSprite2->type);
int height = (pDudeInfo2->aimHeight * pSprite2->yrepeat) << 2;
int tz = (z2 - height) - z;
if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum))
if (cansee(x, y, z, pSprite->sector(), x2, y2, z2, pSprite2->sector()))
{
nClosest = nDist2;
aim.dx = bcos(nAngle);
@ -272,13 +272,13 @@ static void cerberusThinkTarget(DBloodActor* actor)
int x = pPlayer->pSprite->x;
int y = pPlayer->pSprite->y;
int z = pPlayer->pSprite->z;
int nSector = pPlayer->pSprite->sectnum;
auto pSector = pPlayer->pSprite->sector();
int dx = x - pSprite->x;
int dy = y - pSprite->y;
int nDist = approxDist(dx, dy);
if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist)
continue;
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sectnum))
if (!cansee(x, y, z, pSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sector()))
continue;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
@ -388,7 +388,7 @@ static void cerberusThinkChase(DBloodActor* actor)
{
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector()))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) {
aiSetTarget(actor, actor->GetTarget());

View file

@ -179,7 +179,7 @@ void sub_68230(int, DBloodActor* actor)
static bool TargetNearExplosion(spritetype* pSprite)
{
BloodSectIterator it(pSprite->sectnum);
BloodSectIterator it(pSprite->sector());
while (auto actor = it.Next())
{
if (actor->s().type == kThingArmedTNTStick || actor->s().statnum == kStatExplosion)
@ -284,7 +284,7 @@ static void cultThinkChase(DBloodActor* actor)
{
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector()))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{

View file

@ -156,7 +156,7 @@ void BlastSSeqCallback(int, DBloodActor* actor)
if (abs(nDeltaAngle) <= tt.at8)
{
int tz = pSprite2->z - pSprite->z;
if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum))
if (cansee(x, y, z, pSprite->sector(), x2, y2, z2, pSprite2->sector()))
{
nClosest = nDist2;
aim.dx = bcos(nAngle);
@ -229,13 +229,13 @@ static void gargThinkTarget(DBloodActor* actor)
int x = pPlayer->pSprite->x;
int y = pPlayer->pSprite->y;
int z = pPlayer->pSprite->z;
int nSector = pPlayer->pSprite->sectnum;
auto pSector = pPlayer->pSprite->sector();
int dx = x - pSprite->x;
int dy = y - pSprite->y;
int nDist = approxDist(dx, dy);
if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist)
continue;
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sectnum))
if (!cansee(x, y, z, pSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sector()))
continue;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
@ -382,7 +382,7 @@ static void gargThinkChase(DBloodActor* actor)
int height2 = (pDudeInfo->eyeHeight * pTarget->yrepeat) << 2;
int top, bottom;
GetActorExtents(actor, &top, &bottom);
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector()))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{

View file

@ -142,7 +142,7 @@ void ghostBlastSeqCallback(int, DBloodActor* actor)
if (abs(nDeltaAngle) <= tt.at8)
{
int tz = pSprite2->z - pSprite->z;
if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum))
if (cansee(x, y, z, pSprite->sector(), x2, y2, z2, pSprite2->sector()))
{
nClosest = nDist2;
aim.dx = bcos(nAngle);
@ -209,13 +209,13 @@ static void ghostThinkTarget(DBloodActor* actor)
int x = pPlayer->pSprite->x;
int y = pPlayer->pSprite->y;
int z = pPlayer->pSprite->z;
int nSector = pPlayer->pSprite->sectnum;
auto pSector = pPlayer->pSprite->sector();
int dx = x - pSprite->x;
int dy = y - pSprite->y;
int nDist = approxDist(dx, dy);
if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist)
continue;
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sectnum))
if (!cansee(x, y, z, pSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sector()))
continue;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
@ -362,7 +362,7 @@ static void ghostThinkChase(DBloodActor* actor)
int height2 = (pDudeInfo->eyeHeight * pTarget->yrepeat) << 2;
int top, bottom;
GetActorExtents(actor, &top, &bottom);
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector()))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{

View file

@ -147,7 +147,7 @@ static void gillThinkChase(DBloodActor* actor)
{
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector()))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{
@ -250,7 +250,7 @@ static void gillThinkSwimChase(DBloodActor* actor)
int height = pDudeInfo->eyeHeight + pSprite->z;
int top, bottom;
GetActorExtents(actor, &top, &bottom);
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector()))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{

View file

@ -110,7 +110,7 @@ static void handThinkChase(DBloodActor* actor)
{
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector()))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{

View file

@ -132,7 +132,7 @@ static void houndThinkChase(DBloodActor* actor)
{
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector()))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{

View file

@ -96,7 +96,7 @@ static void innocThinkChase(DBloodActor* actor)
{
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector()))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{

View file

@ -212,7 +212,7 @@ static void aiPodChase(DBloodActor* actor)
{
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector()))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{

View file

@ -106,7 +106,7 @@ static void ratThinkChase(DBloodActor* actor)
{
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector()))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{

View file

@ -220,7 +220,7 @@ static void spidThinkChase(DBloodActor* actor)
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum)) {
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector())) {
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery) {
aiSetTarget(actor, actor->GetTarget());

View file

@ -109,7 +109,7 @@ void sub_71BD4(int, DBloodActor* actor)
if (abs(nDeltaAngle) <= tt.at8)
{
int tz = pSprite2->z - pSprite->z;
if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum))
if (cansee(x, y, z, pSprite->sector(), x2, y2, z2, pSprite2->sector()))
{
nClosest = nDist2;
aim.dx = bcos(nAngle);
@ -183,7 +183,7 @@ void sub_720AC(int, DBloodActor* actor)
if (abs(nDeltaAngle) <= tt.at8)
{
int tz = pSprite2->z - pSprite->z;
if (cansee(x, y, z, pSprite->sectnum, x2, y2, z2, pSprite2->sectnum))
if (cansee(x, y, z, pSprite->sector(), x2, y2, z2, pSprite2->sector()))
{
nClosest = nDist2;
aim.dx = bcos(nAngle);
@ -237,13 +237,13 @@ static void sub_725A4(DBloodActor* actor)
int x = pPlayer->pSprite->x;
int y = pPlayer->pSprite->y;
int z = pPlayer->pSprite->z;
int nSector = pPlayer->pSprite->sectnum;
auto pSector = pPlayer->pSprite->sector();
int dx = x - pSprite->x;
int dy = y - pSprite->y;
int nDist = approxDist(dx, dy);
if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist)
continue;
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sectnum))
if (!cansee(x, y, z, pSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sector()))
continue;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
@ -320,7 +320,7 @@ static void sub_72934(DBloodActor* actor)
{
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector()))
{
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)
{

View file

@ -544,8 +544,8 @@ static void unicultThinkChase(DBloodActor* actor)
int losAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int eyeAboveZ = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (dist > pDudeInfo->seeDist || !cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum,
pSprite->x, pSprite->y, pSprite->z - eyeAboveZ, pSprite->sectnum))
if (dist > pDudeInfo->seeDist || !cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(),
pSprite->x, pSprite->y, pSprite->z - eyeAboveZ, pSprite->sector()))
{
if (spriteIsUnderwater(actor, false)) aiGenDudeNewState(actor, &genDudeSearchW);
else aiGenDudeNewState(actor, &genDudeSearchL);
@ -606,8 +606,8 @@ static void unicultThinkChase(DBloodActor* actor)
}
int ldist = aiFightGetTargetDist(targetactor, pDudeInfo, actLeech);
if (ldist > 3 || !cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum,
pLeech->x, pLeech->y, pLeech->z, pLeech->sectnum) || actLeech->GetTarget() == nullptr)
if (ldist > 3 || !cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(),
pLeech->x, pLeech->y, pLeech->z, pLeech->sector()) || actLeech->GetTarget() == nullptr)
{
aiGenDudeNewState(actor, &genDudeThrow2);
genDudeThrow2.nextState = &genDudeDodgeShortL;
@ -1845,7 +1845,7 @@ void dudeLeechOperate(DBloodActor* actor, const EVENT& event)
int x = pTarget->x; int y = pTarget->y; int z = pTarget->z;
int nDist = approxDist(x - pSprite->x, y - pSprite->y);
if (nDist != 0 && cansee(pSprite->x, pSprite->y, top, pSprite->sectnum, x, y, z, pTarget->sectnum))
if (nDist != 0 && cansee(pSprite->x, pSprite->y, top, pSprite->sector(), x, y, z, pTarget->sector()))
{
int t = DivScale(nDist, 0x1aaaaa, 12);
x += (actTarget->xvel * t) >> 12;

View file

@ -141,7 +141,7 @@ static void zombaThinkChase(DBloodActor* actor)
{
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector()))
{
if (abs(nDeltaAngle) <= pDudeInfo->periphery)
{
@ -188,7 +188,7 @@ static void zombaThinkPonder(DBloodActor* actor)
{
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector()))
{
if (abs(nDeltaAngle) <= pDudeInfo->periphery)
{
@ -223,13 +223,13 @@ static void myThinkTarget(DBloodActor* actor)
int x = pPlayer->pSprite->x;
int y = pPlayer->pSprite->y;
int z = pPlayer->pSprite->z;
int nSector = pPlayer->pSprite->sectnum;
auto pSector = pPlayer->pSprite->sector();
int dx = x - pSprite->x;
int dy = y - pSprite->y;
int nDist = approxDist(dx, dy);
if (nDist > pDudeInfo->seeDist && nDist > pDudeInfo->hearDist)
continue;
if (!cansee(x, y, z, nSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sectnum))
if (!cansee(x, y, z, pSector, pSprite->x, pSprite->y, pSprite->z - ((pDudeInfo->eyeHeight * pSprite->yrepeat) << 2), pSprite->sector()))
continue;
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
if (nDist < pDudeInfo->seeDist && abs(nDeltaAngle) <= pDudeInfo->periphery)

View file

@ -138,7 +138,7 @@ static void zombfThinkChase(DBloodActor* actor)
{
int nDeltaAngle = ((getangle(dx, dy) + 1024 - pSprite->ang) & 2047) - 1024;
int height = (pDudeInfo->eyeHeight * pSprite->yrepeat) << 2;
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pSprite->x, pSprite->y, pSprite->z - height, pSprite->sectnum))
if (cansee(pTarget->x, pTarget->y, pTarget->z, pTarget->sector(), pSprite->x, pSprite->y, pSprite->z - height, pSprite->sector()))
{
if (abs(nDeltaAngle) <= pDudeInfo->periphery)
{

View file

@ -8123,10 +8123,10 @@ void aiPatrolAlarmLite(DBloodActor* actor, DBloodActor* targetactor)
int eaz2 = (getDudeInfo(pTarget->type)->eyeHeight * pTarget->yrepeat) << 2;
int nDist = approxDist(pDude->x - pSprite->x, pDude->y - pSprite->y);
if (nDist >= kPatrolAlarmSeeDist || !cansee(pSprite->x, pSprite->y, zt1, pSprite->sectnum, pDude->x, pDude->y, pDude->z - eaz2, pDude->sectnum))
if (nDist >= kPatrolAlarmSeeDist || !cansee(pSprite->x, pSprite->y, zt1, pSprite->sector(), pDude->x, pDude->y, pDude->z - eaz2, pDude->sector()))
{
nDist = approxDist(pDude->x - pTarget->x, pDude->y - pTarget->y);
if (nDist >= kPatrolAlarmSeeDist || !cansee(pTarget->x, pTarget->y, zt2, pTarget->sectnum, pDude->x, pDude->y, pDude->z - eaz2, pDude->sectnum))
if (nDist >= kPatrolAlarmSeeDist || !cansee(pTarget->x, pTarget->y, zt2, pTarget->sector(), pDude->x, pDude->y, pDude->z - eaz2, pDude->sector()))
continue;
}