- floatified BlastSSeqCallback

This commit is contained in:
Christoph Oelckers 2022-09-27 19:40:32 +02:00
parent 8b2ddfadf6
commit a7b23fe9ea
2 changed files with 41 additions and 60 deletions

View file

@ -166,11 +166,13 @@ void cerberusBurnSeqCallback2(int, DBloodActor* actor)
DVector3 tvec = pos; DVector3 tvec = pos;
tvec.XY() += actor->spr.angle.ToVector() * nDist; tvec.XY() += actor->spr.angle.ToVector() * nDist;
tvec.Z += actor->dudeSlope / 16384. * nDist; tvec.Z += actor->dudeSlope / 16384. * nDist;
double tsr = nDist * 9.23828125; double tsr = nDist * 9.23828125;
double top, bottom; double top, bottom;
GetActorExtents(actor2, &top, &bottom); GetActorExtents(actor2, &top, &bottom);
if (tvec.Z - tsr > bottom || tvec.Z + tsr < top) if (tvec.Z - tsr > bottom || tvec.Z + tsr < top)
continue; continue;
double nDist2 = (tvec - pos2).Length(); double nDist2 = (tvec - pos2).Length();
if (nDist2 < nClosest) if (nDist2 < nClosest)
{ {

View file

@ -105,87 +105,66 @@ void BlastSSeqCallback(int, DBloodActor* actor)
wrand(); // ??? wrand(); // ???
if (!actor->ValidateTarget(__FUNCTION__)) return; if (!actor->ValidateTarget(__FUNCTION__)) return;
auto target = actor->GetTarget(); auto target = actor->GetTarget();
int height = (actor->spr.yrepeat * getDudeInfo(actor->spr.type)->eyeHeight) << 2; double height = (actor->spr.yrepeat * getDudeInfo(actor->spr.type)->eyeHeight) * REPEAT_SCALE;
int x = actor->int_pos().X; DVector3 pos(actor->spr.pos.XY(), height);
int y = actor->int_pos().Y;
int z = height; DVector3 Aim(actor->spr.angle.ToVector(), actor->dudeSlope / 16384.);
TARGETTRACK tt = { 0x10000, 0x10000, 0x100, 0x55, 0x1aaaaa }; double nClosest = 0x7fffffff;
Aim aim;
aim.dx = bcos(actor->int_ang());
aim.dy = bsin(actor->int_ang());
aim.dz = actor->dudeSlope;
int nClosest = 0x7fffffff;
BloodStatIterator it(kStatDude); BloodStatIterator it(kStatDude);
while (auto actor2 = it.Next()) while (auto actor2 = it.Next())
{ {
if (actor == actor2 || !(actor2->spr.flags & 8)) if (actor == actor2 || !(actor2->spr.flags & 8))
continue; continue;
int x2 = actor2->int_pos().X;
int y2 = actor2->int_pos().Y; auto pos2 = actor2->spr.pos;
int z2 = actor2->int_pos().Z; double nDist = (pos2 - pos).Length();
int nDist = approxDist(x2 - x, y2 - y); if (nDist == 0 || nDist > 0x280)
if (nDist == 0 || nDist > 0x2800)
continue; continue;
if (tt.at10)
{ pos += actor2->vel * nDist * (65536. / 0x1aaaaa);
int t = DivScale(nDist, tt.at10, 12);
x2 += (actor->int_vel().X * t) >> 12; DVector3 tvec = pos;
y2 += (actor->int_vel().Y * t) >> 12; tvec.XY() += actor->spr.angle.ToVector() * nDist;
z2 += (actor->int_vel().Z * t) >> 8; tvec.Z += actor->dudeSlope / 16384. * nDist;
}
int tx = x + MulScale(Cos(actor->int_ang()), nDist, 30); double tsr = nDist * 9.23828125;
int ty = y + MulScale(Sin(actor->int_ang()), nDist, 30); double top, bottom;
int tz = z + MulScale(actor->dudeSlope, nDist, 10);
int tsr = MulScale(9460, nDist, 10);
int top, bottom;
GetActorExtents(actor2, &top, &bottom); GetActorExtents(actor2, &top, &bottom);
if (tz - tsr > bottom || tz + tsr < top) if (tvec.Z - tsr > bottom || tvec.Z + tsr < top)
continue; continue;
int dx = (tx - x2) >> 4;
int dy = (ty - y2) >> 4; double nDist2 = (tvec - pos2).Length();
int dz = (tz - z2) >> 8;
int nDist2 = ksqrt(dx * dx + dy * dy + dz * dz);
if (nDist2 < nClosest) if (nDist2 < nClosest)
{ {
int nAngle = getangle(x2 - x, y2 - y); DAngle nAngle = VecToAngle(pos2.XY() - pos.XY());
int nDeltaAngle = ((nAngle - actor->int_ang() + 1024) & 2047) - 1024; DAngle nDeltaAngle = absangle(nAngle, actor->spr.angle);
if (abs(nDeltaAngle) <= tt.at8) if (nDeltaAngle <= DAngle45)
{ {
int tz1 = actor2->int_pos().Z - actor->int_pos().Z; double tz1 = actor2->spr.pos.Z - actor->spr.pos.Z;
if (cansee(x, y, z, actor->sector(), x2, y2, z2, actor2->sector()))
if (cansee(pos, actor->sector(), pos2, actor2->sector()))
{ {
nClosest = nDist2; nClosest = nDist2;
aim.dx = bcos(nAngle); Aim.XY() = nAngle.ToVector();
aim.dy = bsin(nAngle); Aim.Z = tz1 / nDist;
aim.dz = DivScale(tz1, nDist, 10);
if (tz1 > -0x333) // This does not make any sense...
aim.dz = DivScale(tz1, nDist, 10); if (tz1 < -3.2 && tz1 > -48)
else if (tz1 < -0x333 && tz1 > -0xb33) Aim.Z += 0.5774;
aim.dz = DivScale(tz1, nDist, 10) + 9460; else if (tz1 <= -48)
else if (tz1 < -0xb33 && tz1 > -0x3000) Aim.Z -= 0.45776;
aim.dz = DivScale(tz1, nDist, 10) + 9460;
else if (tz1 < -0x3000)
aim.dz = DivScale(tz1, nDist, 10) - 7500;
else
aim.dz = DivScale(tz1, nDist, 10);
} }
else else
aim.dz = DivScale(tz1, nDist, 10); Aim.Z = tz1 / nDist;
} }
} }
} }
#ifdef NOONE_EXTENSIONS
// allow to fire missile in non-player targets // allow to fire missile in non-player targets
if (target->IsPlayerActor() || gModernMap) { if (target->IsPlayerActor() || gModernMap) {
actFireMissile(actor, -120, 0, aim.dx, aim.dy, aim.dz, kMissileArcGargoyle); actFireMissile(actor, -7.5, 0, Aim, kMissileArcGargoyle);
actFireMissile(actor, 120, 0, aim.dx, aim.dy, aim.dz, kMissileArcGargoyle); actFireMissile(actor, 7.5, 0, Aim, kMissileArcGargoyle);
} }
#else
if (target->IsPlayerActor()) {
actFireMissile(actor, -120, 0, aim.dx, aim.dy, aim.dz, kMissileArcGargoyle);
actFireMissile(actor, 120, 0, aim.dx, aim.dy, aim.dz, kMissileArcGargoyle);
}
#endif
} }