- wrapped XSPRITE::TargetPos

This commit is contained in:
Christoph Oelckers 2022-08-22 18:31:23 +02:00
parent 4888b363e8
commit d26a4e70c3
25 changed files with 151 additions and 147 deletions

View file

@ -2615,9 +2615,9 @@ int actFloorBounceVector(int* x, int* y, int* z, sectortype* pSector, int a5)
*z = -(*z - t2);
return t2;
}
walltype* pWall = pSector->firstWall();
walltype* pWall2 = pWall->point2Wall();
int angle = getangle(pWall2->wall_int_pos().X - pWall->wall_int_pos().X, pWall2->wall_int_pos().Y - pWall->wall_int_pos().Y) + 512;
int angle = getangle(pWall->fdelta()) + 512;
int t2 = pSector->floorheinum << 4;
int t3 = approxDist(-0x10000, t2);
int t4 = DivScale(-0x10000, t3, 16);
@ -3965,8 +3965,8 @@ static void actImpactMissile(DBloodActor* missileActor, int hitCode)
{
missileActor->spr.picnum = 2123;
missileActor->SetTarget(actorHit);
missileActor->xspr.TargetPos.Z = missileActor->int_pos().Z - actorHit->int_pos().Z;
missileActor->xspr.goalAng = getangle(missileActor->int_pos().X - actorHit->int_pos().X, missileActor->int_pos().Y - actorHit->int_pos().Y) - actorHit->int_ang();
missileActor->xspr.set_int_TargetPos_Z(missileActor->int_pos().Z - actorHit->int_pos().Z);
missileActor->xspr.goalAng = getangle(missileActor->spr.pos.XY() - actorHit->spr.pos.XY()) - actorHit->int_ang();
missileActor->xspr.state = 1;
actPostSprite(missileActor, kStatFlare);
missileActor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
@ -5226,7 +5226,7 @@ int MoveMissile(DBloodActor* actor)
if (target->spr.statnum == kStatDude && target->hasX() && target->xspr.health > 0)
{
int nTargetAngle = getangle(-(target->int_pos().Y - actor->int_pos().Y), target->int_pos().X - actor->int_pos().X);
int nTargetAngle = getangle(-(target->int_pos().Y - actor->int_pos().Y), target->int_pos().X - actor->int_pos().X); // X and Y are swapped here!
int vx = missileInfo[actor->spr.type - kMissileBase].velocity;
int vy = 0;
RotatePoint(&vx, &vy, (nTargetAngle + 1536) & 2047, 0, 0);
@ -5547,7 +5547,7 @@ static void actCheckProximity()
case kThingBloodBits:
case kThingBloodChunks:
case kThingZombieHead:
if (actor->xspr.locked && PlayClock >= actor->xspr.TargetPos.X) actor->xspr.locked = 0;
if (actor->xspr.locked && PlayClock >= actor->xspr.NotReallyTargetPos.X) actor->xspr.locked = 0;
break;
}
@ -6140,7 +6140,7 @@ void actCheckFlares()
{
int x = target->int_pos().X + mulscale30r(Cos(actor->xspr.goalAng + target->int_ang()), target->spr.clipdist * 2);
int y = target->int_pos().Y + mulscale30r(Sin(actor->xspr.goalAng + target->int_ang()), target->spr.clipdist * 2);
int z = target->int_pos().Z + actor->xspr.TargetPos.Z;
int z = target->int_pos().Z + actor->xspr.int_TargetPos().Z;
vec3_t pos = { x, y, z };
SetActor(actor, &pos);
actor->vel.X = target->vel.X;
@ -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.TargetPos.X = PlayClock + 180;
actor->xspr.NotReallyTargetPos.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.TargetPos.X = PlayClock + 180;
actor->xspr.NotReallyTargetPos.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.TargetPos.X = PlayClock;
actor->xspr.NotReallyTargetPos.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.TargetPos.X = PlayClock;
actor->xspr.NotReallyTargetPos.X = PlayClock;
actor->xspr.state = 1;
}

View file

@ -364,7 +364,7 @@ void aiActivateDude(DBloodActor* actor)
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
if (!actor->xspr.state)
{
aiChooseDirection(actor, getangle(actor->xspr.TargetPos.X - actor->int_pos().X, actor->xspr.TargetPos.Y - actor->int_pos().Y));
aiChooseDirection(actor, getangle(actor->xspr.int_TargetPos().X - actor->int_pos().X, actor->xspr.int_TargetPos().Y - actor->int_pos().Y));
actor->xspr.state = 1;
}
switch (actor->spr.type)
@ -916,9 +916,7 @@ void aiActivateDude(DBloodActor* actor)
void aiSetTarget(DBloodActor* actor, int x, int y, int z)
{
actor->SetTarget(nullptr);
actor->xspr.TargetPos.X = x;
actor->xspr.TargetPos.Y = y;
actor->xspr.TargetPos.Z = z;
actor->xspr.set_int_TargetPos(x, y, z);
}
void aiSetTarget(DBloodActor* actor, DBloodActor* target)
@ -934,9 +932,7 @@ void aiSetTarget(DBloodActor* actor, DBloodActor* target)
{
actor->SetTarget(target);
DUDEINFO* pDudeInfo = getDudeInfo(target->spr.type);
actor->xspr.TargetPos.X = target->int_pos().X;
actor->xspr.TargetPos.Y = target->int_pos().Y;
actor->xspr.TargetPos.Z = target->int_pos().Z - ((pDudeInfo->eyeHeight * target->spr.yrepeat) << 2);
actor->xspr.set_int_TargetPos(target->int_pos().X, target->int_pos().Y, target->int_pos().Z - ((pDudeInfo->eyeHeight * target->spr.yrepeat) << 2));
}
}
}
@ -1706,9 +1702,9 @@ void aiInitSprite(DBloodActor* actor)
{
stateTimer = actor->xspr.stateTimer;
pTargetMarker = actor->GetTarget();
targetX = actor->xspr.TargetPos.X;
targetY = actor->xspr.TargetPos.Y;
targetZ = actor->xspr.TargetPos.Z;
targetX = actor->xspr.int_TargetPos().X;
targetY = actor->xspr.int_TargetPos().Y;
targetZ = actor->xspr.int_TargetPos().Z;
}
}
#endif
@ -1927,9 +1923,7 @@ void aiInitSprite(DBloodActor* actor)
if (pTargetMarker)
{
actor->SetTarget(pTargetMarker);
actor->xspr.TargetPos.X = targetX;
actor->xspr.TargetPos.Y = targetY;
actor->xspr.TargetPos.Z = targetZ;
actor->xspr.set_int_TargetPos(targetX, targetY, targetZ);
}
// reset target spot progress

View file

@ -136,8 +136,8 @@ static void batThinkGoto(DBloodActor* actor)
{
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle);
@ -318,8 +318,8 @@ static void batMoveForward(DBloodActor* actor)
return;
if (actor->GetTarget() == nullptr)
actor->spr.angle += DAngle45;
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
if ((unsigned int)Random(64) < 32 && nDist <= 0x200)
return;
@ -350,8 +350,8 @@ static void batMoveSwoop(DBloodActor* actor)
actor->xspr.goalAng = (actor->int_ang() + 512) & 2047;
return;
}
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
if (Chance(0x600) && nDist <= 0x200)
return;
@ -380,8 +380,8 @@ static void batMoveFly(DBloodActor* actor)
actor->spr.angle += DAngle90;
return;
}
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
if (Chance(0x4000) && nDist <= 0x200)
return;
@ -402,7 +402,7 @@ void batMoveToCeil(DBloodActor* actor)
int x = actor->int_pos().X;
int y = actor->int_pos().Y;
int z = actor->int_pos().Z;
if (z - actor->xspr.TargetPos.Z < 0x1000)
if (z - actor->xspr.int_TargetPos().Z < 0x1000)
{
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
pDudeExtraE->thinkTime = 0;

View file

@ -174,8 +174,8 @@ static void beastThinkGoto(DBloodActor* actor)
auto pSector = actor->sector();
auto pXSector = pSector->hasX() ? &pSector->xs() : nullptr;
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle);
@ -325,8 +325,8 @@ static void beastThinkSwimGoto(DBloodActor* actor)
{
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle);
@ -398,8 +398,8 @@ static void beastMoveForward(DBloodActor* actor)
actor->set_int_ang((actor->int_ang() + ClipRange(nAng, -nTurnRange, nTurnRange)) & 2047);
if (abs(nAng) > 341)
return;
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
if (nDist <= 0x400 && Random(64) < 32)
return;
@ -419,8 +419,8 @@ static void sub_628A0(DBloodActor* actor)
return;
if (actor->GetTarget() == nullptr)
actor->spr.angle += DAngle45;
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
if (Random(64) < 32 && nDist <= 0x400)
return;
@ -455,8 +455,8 @@ static void sub_62AE0(DBloodActor* actor)
actor->xspr.goalAng = (actor->int_ang() + 512) & 2047;
return;
}
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int dz = z2 - z;
int nDist = approxDist(dx, dy);
if (Chance(0x600) && nDist <= 0x400)
@ -490,8 +490,8 @@ static void sub_62D7C(DBloodActor* actor)
actor->spr.angle += DAngle90;
return;
}
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int dz = (z2 - z) << 3;
int nDist = approxDist(dx, dy);
if (Chance(0x4000) && nDist <= 0x400)

View file

@ -150,8 +150,8 @@ static void eelThinkGoto(DBloodActor* actor)
{
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle);
@ -328,8 +328,8 @@ static void eelMoveForward(DBloodActor* actor)
return;
if (actor->GetTarget() == nullptr)
actor->spr.angle += DAngle45;
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
if (nDist <= 0x399)
return;
@ -357,8 +357,8 @@ static void eelMoveSwoop(DBloodActor* actor)
int nAccel = (pDudeInfo->frontSpeed - (((4 - gGameOptions.nDifficulty) << 26) / 120) / 120) << 2;
if (abs(nAng) > 341)
return;
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
if (Chance(0x8000) && nDist <= 0x399)
return;
@ -384,8 +384,8 @@ static void eelMoveAscend(DBloodActor* actor)
int nAccel = (pDudeInfo->frontSpeed - (((4 - gGameOptions.nDifficulty) << 26) / 120) / 120) << 2;
if (abs(nAng) > 341)
return;
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
if (Chance(0x4000) && nDist <= 0x399)
return;
@ -406,7 +406,7 @@ void eelMoveToCeil(DBloodActor* actor)
int x = actor->int_pos().X;
int y = actor->int_pos().Y;
int z = actor->int_pos().Z;
if (z - actor->xspr.TargetPos.Z < 0x1000)
if (z - actor->xspr.int_TargetPos().Z < 0x1000)
{
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
pDudeExtraE->active = 0;

View file

@ -84,8 +84,8 @@ static void burnThinkGoto(DBloodActor* actor)
{
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle);

View file

@ -94,8 +94,8 @@ static void calebThinkGoto(DBloodActor* actor)
auto pSector = actor->sector();
auto pXSector = pSector->hasX() ? &pSector->xs() : nullptr;
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle);
@ -212,8 +212,8 @@ static void calebThinkSwimGoto(DBloodActor* actor)
{
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle);
@ -284,8 +284,8 @@ static void sub_65D04(DBloodActor* actor)
return;
if (actor->GetTarget() == nullptr)
actor->spr.angle += DAngle45;
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
if (Random(64) < 32 && nDist <= 0x400)
return;
@ -321,8 +321,8 @@ static void sub_65F44(DBloodActor* actor)
actor->xspr.goalAng = (actor->int_ang() + 512) & 2047;
return;
}
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int dz = z2 - z;
int nDist = approxDist(dx, dy);
if (Chance(0x600) && nDist <= 0x400)
@ -357,8 +357,8 @@ static void sub_661E0(DBloodActor* actor)
actor->spr.angle += DAngle90;
return;
}
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int dz = (z2 - z) << 3;
int nDist = approxDist(dx, dy);
if (Chance(0x4000) && nDist <= 0x400)

View file

@ -296,8 +296,8 @@ static void cerberusThinkGoto(DBloodActor* actor)
return;
}
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle);

View file

@ -194,8 +194,8 @@ static void cultThinkGoto(DBloodActor* actor)
{
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle);

View file

@ -262,8 +262,8 @@ static void gargThinkGoto(DBloodActor* actor)
return;
}
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle);
@ -531,8 +531,8 @@ static void gargMoveForward(DBloodActor* actor)
return;
if (actor->GetTarget() == nullptr)
actor->spr.angle += DAngle45;
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
if ((unsigned int)Random(64) < 32 && nDist <= 0x400)
return;
@ -566,8 +566,8 @@ static void gargMoveSlow(DBloodActor* actor)
actor->xspr.goalAng = (actor->int_ang() + 512) & 2047;
return;
}
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
if (Chance(0x600) && nDist <= 0x400)
return;
@ -607,8 +607,8 @@ static void gargMoveSwoop(DBloodActor* actor)
actor->xspr.goalAng = (actor->int_ang() + 512) & 2047;
return;
}
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
if (Chance(0x600) && nDist <= 0x400)
return;
@ -647,8 +647,8 @@ static void gargMoveFly(DBloodActor* actor)
actor->spr.angle += DAngle90;
return;
}
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
if (Chance(0x4000) && nDist <= 0x400)
return;

View file

@ -241,8 +241,8 @@ static void ghostThinkGoto(DBloodActor* actor)
return;
}
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle);
@ -427,8 +427,8 @@ static void ghostMoveForward(DBloodActor* actor)
return;
if (actor->GetTarget() == nullptr)
actor->spr.angle += DAngle45;
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
if ((unsigned int)Random(64) < 32 && nDist <= 0x400)
return;
@ -462,8 +462,8 @@ static void ghostMoveSlow(DBloodActor* actor)
actor->xspr.goalAng = (actor->int_ang() + 512) & 2047;
return;
}
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
if (Chance(0x600) && nDist <= 0x400)
return;
@ -500,8 +500,8 @@ static void ghostMoveSwoop(DBloodActor* actor)
actor->xspr.goalAng = (actor->int_ang() + 512) & 2047;
return;
}
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
if (Chance(0x600) && nDist <= 0x400)
return;
@ -537,8 +537,8 @@ static void ghostMoveFly(DBloodActor* actor)
actor->spr.angle += DAngle90;
return;
}
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
if (Chance(0x4000) && nDist <= 0x400)
return;

View file

@ -85,8 +85,8 @@ static void gillThinkGoto(DBloodActor* actor)
auto pSector = actor->sector();
auto pXSector = pSector->hasX() ? &pSector->xs() : nullptr;
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle);
@ -199,8 +199,8 @@ static void gillThinkSwimGoto(DBloodActor* actor)
{
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle);
@ -274,8 +274,8 @@ static void sub_6CB00(DBloodActor* actor)
return;
if (actor->GetTarget() == nullptr)
actor->spr.angle += DAngle45;
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
if (Random(64) < 32 && nDist <= 0x400)
return;
@ -310,8 +310,8 @@ static void sub_6CD74(DBloodActor* actor)
actor->xspr.goalAng = (actor->int_ang() + 512) & 2047;
return;
}
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int dz = z2 - z;
int nDist = approxDist(dx, dy);
if (Chance(0x600) && nDist <= 0x400)
@ -345,8 +345,8 @@ static void sub_6D03C(DBloodActor* actor)
actor->spr.angle += DAngle90;
return;
}
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int dz = (z2 - z) << 3;
int nDist = approxDist(dx, dy);
if (Chance(0x4000) && nDist <= 0x400)

View file

@ -66,8 +66,8 @@ static void handThinkGoto(DBloodActor* actor)
{
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle);

View file

@ -81,8 +81,8 @@ static void houndThinkGoto(DBloodActor* actor)
}
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle);

View file

@ -50,8 +50,8 @@ static void innocThinkGoto(DBloodActor* actor)
{
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle);

View file

@ -139,8 +139,8 @@ static void aiPodMove(DBloodActor* actor)
}
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle);

View file

@ -62,8 +62,8 @@ static void ratThinkGoto(DBloodActor* actor)
{
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle);

View file

@ -136,8 +136,8 @@ void SpidBirthSeqCallback(int, DBloodActor* actor)
if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget();
DUDEEXTRA_STATS* pDudeExtraE = &actor->dudeExtra.stats;
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
@ -171,8 +171,8 @@ static void spidThinkGoto(DBloodActor* actor)
{
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle);

View file

@ -263,8 +263,8 @@ static void sub_72850(DBloodActor* actor)
return;
}
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle);

View file

@ -419,8 +419,8 @@ static void unicultThinkGoto(DBloodActor* actor)
return;
}
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
aiChooseDirection(actor, nAngle);
@ -1122,8 +1122,8 @@ void aiGenDudeMoveForward(DBloodActor* actor)
return;
if (actor->GetTarget() == nullptr)
actor->spr.angle += DAngle45;
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nDist = approxDist(dx, dy);
if ((unsigned int)Random(64) < 32 && nDist <= 0x400)
return;

View file

@ -64,8 +64,8 @@ void HackSeqCallback(int, DBloodActor* actor)
auto target = actor->GetTarget();
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
DUDEINFO* pDudeInfoT = getDudeInfo(target->spr.type);
int tx = actor->xspr.TargetPos.X - actor->int_pos().X;
int ty = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int tx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int ty = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(tx, ty);
int height = (actor->spr.yrepeat * pDudeInfo->eyeHeight) << 2;
int height2 = (target->spr.yrepeat * pDudeInfoT->eyeHeight) << 2;
@ -91,8 +91,8 @@ static void zombaThinkGoto(DBloodActor* actor)
{
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle);
@ -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.TargetPos.X - actor->int_pos().X, actor->xspr.TargetPos.Y - actor->int_pos().Y));
actor->set_int_ang(getangle(actor->xspr.int_TargetPos().X - actor->int_pos().X, actor->xspr.int_TargetPos().Y - actor->int_pos().Y));
}
END_BLD_NS

View file

@ -66,8 +66,8 @@ void PukeSeqCallback(int, DBloodActor* actor)
DUDEINFO* pDudeInfoT = getDudeInfo(target->spr.type);
int height = (pDudeInfo->eyeHeight * actor->spr.yrepeat);
int height2 = (pDudeInfoT->eyeHeight * target->spr.yrepeat);
int tx = actor->xspr.TargetPos.X - actor->int_pos().X;
int ty = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int tx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int ty = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(tx, ty);
int dx = bcos(nAngle);
int dy = bsin(nAngle);
@ -90,8 +90,8 @@ static void zombfThinkGoto(DBloodActor* actor)
{
assert(actor->spr.type >= kDudeBase && actor->spr.type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(actor->spr.type);
int dx = actor->xspr.TargetPos.X - actor->int_pos().X;
int dy = actor->xspr.TargetPos.Y - actor->int_pos().Y;
int dx = actor->xspr.int_TargetPos().X - actor->int_pos().X;
int dy = actor->xspr.int_TargetPos().Y - actor->int_pos().Y;
int nAngle = getangle(dx, dy);
int nDist = approxDist(dx, dy);
aiChooseDirection(actor, nAngle);

View file

@ -565,9 +565,10 @@ void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, int*
pXSprite->dudeGuard = bitReader.readUnsigned(1);
pXSprite->dudeFlag4 = bitReader.readUnsigned(1);
/*pXSprite->target_i = */ bitReader.readSigned(16);
pXSprite->TargetPos.X = bitReader.readSigned(32);
pXSprite->TargetPos.Y = bitReader.readSigned(32);
pXSprite->TargetPos.Z = bitReader.readSigned(32);
int tx = bitReader.readSigned(32);
int ty = bitReader.readSigned(32);
int tz = bitReader.readSigned(32);
pXSprite->set_int_TargetPos(tx,ty,tz);
pXSprite->burnTime = bitReader.readUnsigned(16);
/*pXSprite->burnSource =*/ bitReader.readSigned(16);
pXSprite->height = bitReader.readUnsigned(16);

View file

@ -100,8 +100,22 @@ struct XSPRITE {
TObjPtr<DBloodActor*> target; // target sprite
TObjPtr<DBloodActor*> 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;
}
vec3_t 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
@ -257,4 +271,4 @@ struct XWALL {
uint8_t key; // Key
};
END_BLD_NS
END_BLD_NS

View file

@ -719,8 +719,9 @@ void nnExtInitModernStuff(TArray<DBloodActor*>& actors)
actor->xspr.Sight = actor->xspr.Impact = actor->xspr.Touch = actor->xspr.triggerOff = false;
actor->xspr.Proximity = actor->xspr.Push = actor->xspr.Vector = actor->xspr.triggerOn = false;
actor->xspr.state = actor->xspr.restState = 0;
actor->xspr.TargetPos = {-1, -1, -1};
actor->xspr.TargetPos.X = actor->xspr.TargetPos.Y = actor->xspr.TargetPos.Z = actor->xspr.sysData2 = -1;
actor->xspr.sysData2 = -1;
actor->SetTarget(nullptr);
ChangeActorStat(actor, kStatModernCondition);
auto oldStat = actor->spr.cstat;
@ -3256,18 +3257,14 @@ void useTeleportTarget(DBloodActor* sourceactor, DBloodActor* actor)
if (actor->spr.statnum == kStatDude && actor->IsDudeActor() && !actor->IsPlayerActor())
{
int x = actor->xspr.TargetPos.X;
int y = actor->xspr.TargetPos.Y;
int z = actor->xspr.TargetPos.Z;
auto pos = actor->xspr.TargetPos;
auto target = actor->GetTarget();
aiInitSprite(actor);
if (target != nullptr && target->IsDudeActor())
{
actor->xspr.TargetPos.X = x;
actor->xspr.TargetPos.Y = y;
actor->xspr.TargetPos.Z = z;
actor->xspr.TargetPos = pos;
actor->SetTarget(target);
aiActivateDude(actor);
}
@ -7219,9 +7216,7 @@ void useTargetChanger(DBloodActor* sourceactor, DBloodActor* actor)
{
actor->SetTarget(pMateTargetActor);
auto pMate = pMateTargetActor->GetTarget();
actor->xspr.TargetPos.X = pMate->int_pos().X;
actor->xspr.TargetPos.Y = pMate->int_pos().Y;
actor->xspr.TargetPos.Z = pMate->int_pos().Z;
actor->xspr.set_int_TargetPos(pMate->int_pos().X, pMate->int_pos().Y, pMate->int_pos().Z);
if (!isActive(actor))
aiActivateDude(actor);
return;
@ -8035,7 +8030,7 @@ void aiPatrolSetMarker(DBloodActor* actor)
while (auto nextactor = it.Next())
{
if (nextactor == targetactor || !nextactor->hasX()) continue;
else if (actor->xspr.TargetPos.X >= 0 && nextactor == prevactor && node)
else if (actor->xspr.NotReallyTargetPos.X >= 0 && nextactor == prevactor && node)
{
if (targetactor->xspr.data2 == prevactor->xspr.data1)
continue;
@ -8086,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.TargetPos.X = -1; // reset the previous marker index
actor->xspr.NotReallyTargetPos.X = -1; // reset the previous marker index
if (actor->xspr.health <= 0)
return;
@ -8115,7 +8110,7 @@ void aiPatrolStop(DBloodActor* actor, DBloodActor* targetactor, bool alarm)
else
{
aiInitSprite(actor);
aiSetTarget(actor, actor->xspr.TargetPos.X, actor->xspr.TargetPos.Y, actor->xspr.TargetPos.Z);
aiSetTarget(actor, actor->xspr.int_TargetPos().X, actor->xspr.int_TargetPos().Y, actor->xspr.int_TargetPos().Z);
}
actor->xspr.dudeFlag4 = patrol; // this must be kept so enemy can patrol after respawn again