- floatified XSPRITE::TargetPos

This commit is contained in:
Christoph Oelckers 2022-08-22 18:31:45 +02:00
parent d26a4e70c3
commit 1c154a984d
6 changed files with 20 additions and 32 deletions

View file

@ -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;
}

View file

@ -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

View file

@ -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

View file

@ -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);

View file

@ -101,21 +101,10 @@ 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;
}
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

View file

@ -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;