- floatified dudeSlope.

This commit is contained in:
Christoph Oelckers 2022-09-28 18:20:26 +02:00
parent 27c0a00df6
commit b2dc69ad5d
12 changed files with 42 additions and 43 deletions

View file

@ -239,7 +239,7 @@ static void beastThinkChase(DBloodActor* actor)
if (nDist < pDudeInfo->SeeDist() && nDeltaAngle <= pDudeInfo->Periphery())
{
aiSetTarget(actor, actor->GetTarget());
actor->_dudeSlope = nDist == 0 ? 0 : int(target->spr.pos.Z - actor->spr.pos.Z / nDist) * 16384;
actor->dudeSlope = nDist == 0 ? 0 : int(target->spr.pos.Z - actor->spr.pos.Z / nDist);
if (nDist < 0x140 && nDist > 0xa0 && nDeltaAngle < DAngle15 && (target->spr.flags & 2)
&& target->IsPlayerActor() && Chance(0x8000))
{

View file

@ -59,7 +59,7 @@ AISTATE tinycaleb139698 = { kAiStateOther, 8, -1, 120, NULL, aiMoveTurn, NULL, &
void SeqAttackCallback(int, DBloodActor* actor)
{
DVector3 vect(actor->spr.angle.ToVector(), actor->flt_dudeSlope());
DVector3 vect(actor->spr.angle.ToVector(), actor->dudeSlope);
vect.X += Random2F(1500, 4);
vect.Y += Random2F(1500, 4);
vect.Z += Random2F(1500, 8);
@ -158,7 +158,7 @@ static void calebThinkChase(DBloodActor* actor)
if (nDist < pDudeInfo->SeeDist() && nDeltaAngle <= pDudeInfo->Periphery())
{
aiSetTarget(actor, actor->GetTarget());
actor->_dudeSlope = nDist == 0 ? 0 : target->spr.pos.Z - actor->spr.pos.Z / nDist * 16384;
actor->dudeSlope = nDist == 0 ? 0 : target->spr.pos.Z - actor->spr.pos.Z / nDist;
if (nDist < 89.5625 && abs(nDeltaAngle) < DAngle1 * 5)
{
int hit = HitScan(actor, actor->spr.pos.Z, DVector3(dvec, 0), CLIPMASK1, 0);

View file

@ -84,7 +84,7 @@ void cerberusBurnSeqCallback(int, DBloodActor* actor)
DVector3 pos(actor->spr.pos.XY(), height);
//auto pos = actor->spr.pos.plusZ(height); // what it probably should be
DVector3 Aim(actor->spr.angle.ToVector(), actor->flt_dudeSlope());
DVector3 Aim(actor->spr.angle.ToVector(), actor->dudeSlope);
double nClosest = 0x7fffffff;
BloodStatIterator it(kStatDude);
while (auto actor2 = it.Next())
@ -100,7 +100,7 @@ void cerberusBurnSeqCallback(int, DBloodActor* actor)
DVector3 tvec = pos;
tvec.XY() += actor->spr.angle.ToVector() * nDist;
tvec.Z += actor->flt_dudeSlope() * nDist;
tvec.Z += actor->dudeSlope * nDist;
double tsr = nDist * 9.23828125;
double top, bottom;
GetActorExtents(actor2, &top, &bottom);
@ -145,7 +145,7 @@ void cerberusBurnSeqCallback2(int, DBloodActor* actor)
DVector3 pos(actor->spr.pos.XY(), height);
//auto pos = actor->spr.pos.plusZ(height); // what it probably should be
DVector3 Aim(actor->spr.angle.ToVector(), actor->flt_dudeSlope());
DVector3 Aim(actor->spr.angle.ToVector(), actor->dudeSlope);
DVector3 Aim2(Aim.XY(), 0);
double nClosest = 0x7fffffff;
@ -165,7 +165,7 @@ void cerberusBurnSeqCallback2(int, DBloodActor* actor)
DVector3 tvec = pos;
tvec.XY() += actor->spr.angle.ToVector() * nDist;
tvec.Z += actor->flt_dudeSlope() * nDist;
tvec.Z += actor->dudeSlope * nDist;
double tsr = nDist * 9.23828125;
double top, bottom;

View file

@ -75,7 +75,7 @@ AISTATE cultistSwimRecoil = { kAiStateRecoil, 5, -1, 0, NULL, NULL, NULL, &culti
void TommySeqCallback(int, DBloodActor* actor)
{
DVector3 vect(actor->spr.angle.ToVector(), actor->flt_dudeSlope());
DVector3 vect(actor->spr.angle.ToVector(), actor->dudeSlope);
vect.X += Random3F((5 - gGameOptions.nDifficulty) * 1000, 14);
vect.Y += Random3F((5 - gGameOptions.nDifficulty) * 1000, 14);
vect.Z += Random3F((5 - gGameOptions.nDifficulty) * 500, 14);
@ -87,7 +87,7 @@ void TeslaSeqCallback(int, DBloodActor* actor)
{
if (Chance(gCultTeslaFireChance[gGameOptions.nDifficulty]))
{
DVector3 vect(actor->spr.angle.ToVector(), actor->flt_dudeSlope());
DVector3 vect(actor->spr.angle.ToVector(), actor->dudeSlope);
vect.X += Random3F((5 - gGameOptions.nDifficulty) * 1000, 14);
vect.Y += Random3F((5 - gGameOptions.nDifficulty) * 1000, 14);
vect.Z += Random3F((5 - gGameOptions.nDifficulty) * 500, 14);
@ -98,7 +98,7 @@ void TeslaSeqCallback(int, DBloodActor* actor)
void ShotSeqCallback(int, DBloodActor* actor)
{
DVector3 vect(actor->spr.angle.ToVector(), actor->flt_dudeSlope());
DVector3 vect(actor->spr.angle.ToVector(), actor->dudeSlope);
vect.X += Random3F((5 - gGameOptions.nDifficulty) * 1000, 14);
vect.Y += Random3F((5 - gGameOptions.nDifficulty) * 1000, 14);
vect.Z += Random3F((5 - gGameOptions.nDifficulty) * 500, 14);
@ -143,7 +143,7 @@ void cultThrowSeqCallback2(int, DBloodActor* actor)
if (gGameOptions.nDifficulty > 2)
nMissile = kThingArmedTNTBundle;
sfxPlay3DSound(actor, 455, -1, 0);
auto pMissile = actFireThing(actor, 0, 0, actor->int_dudeSlope() - 9460, nMissile, 0x133333);
auto pMissile = actFireThing(actor, 0., 0., actor->dudeSlope * 0.25 - 0.14435, nMissile, 0x133333 / 65536.);
evPostActor(pMissile, 120 * (2 + Random(2)), kCmdOn, actor);
}
@ -270,7 +270,7 @@ static void cultThinkChase(DBloodActor* actor)
if (nDist < pDudeInfo->SeeDist() && nDeltaAngle <= pDudeInfo->Periphery())
{
aiSetTarget(actor, actor->GetTarget());
actor->_dudeSlope = nDist == 0 ? 0 : (target->spr.pos.Z - actor->spr.pos.Z) / nDist * 16384;
actor->dudeSlope = nDist == 0 ? 0 : (target->spr.pos.Z - actor->spr.pos.Z) / nDist;
switch (actor->spr.type)
{
case kDudeCultistTommy:

View file

@ -96,7 +96,7 @@ void SlashFSeqCallback(int, DBloodActor* actor)
void ThrowFSeqCallback(int, DBloodActor* actor)
{
actFireThing(actor, 0, 0, actor->int_dudeSlope() - 7500, kThingBone, 0xeeeee);
actFireThing(actor, 0., 0., actor->dudeSlope * 0.25 - 0.11444, kThingBone, 0xeeeee / 65536.);
}
void BlastSSeqCallback(int, DBloodActor* actor)
@ -107,7 +107,7 @@ void BlastSSeqCallback(int, DBloodActor* actor)
double height = (actor->spr.yrepeat * getDudeInfo(actor->spr.type)->eyeHeight) * REPEAT_SCALE;
DVector3 pos(actor->spr.pos.XY(), height);
DVector3 Aim(actor->spr.angle.ToVector(), actor->flt_dudeSlope());
DVector3 Aim(actor->spr.angle.ToVector(), actor->dudeSlope);
double nClosest = 0x7fffffff;
BloodStatIterator it(kStatDude);
@ -125,7 +125,7 @@ void BlastSSeqCallback(int, DBloodActor* actor)
DVector3 tvec = pos;
tvec.XY() += actor->spr.angle.ToVector() * nDist;
tvec.Z += actor->flt_dudeSlope() * nDist;
tvec.Z += actor->dudeSlope * nDist;
double tsr = nDist * 9.23828125;
double top, bottom;
@ -169,7 +169,7 @@ void BlastSSeqCallback(int, DBloodActor* actor)
void ThrowSSeqCallback(int, DBloodActor* actor)
{
actFireThing(actor, 0., 0., actor->flt_dudeSlope() * 0.25 - 0.11444, kThingBone, Chance(0x6000) ? 19.2 : 17.066666);
actFireThing(actor, 0., 0., actor->dudeSlope * 0.25 - 0.11444, kThingBone, Chance(0x6000) ? 19.2 : 17.066666);
}
static void gargThinkTarget(DBloodActor* actor)

View file

@ -82,7 +82,7 @@ void ghostSlashSeqCallback(int, DBloodActor* actor)
void ghostThrowSeqCallback(int, DBloodActor* actor)
{
actFireThing(actor, 0., 0., actor->flt_dudeSlope() * 0.25 - 0.11444, kThingBone, 14.93333);
actFireThing(actor, 0., 0., actor->dudeSlope * 0.25 - 0.11444, kThingBone, 14.93333);
}
// This functions seems to be identical with BlastSSeqCallback except for the spawn calls at the end.
@ -94,7 +94,7 @@ void ghostBlastSeqCallback(int, DBloodActor* actor)
double height = (actor->spr.yrepeat * getDudeInfo(actor->spr.type)->eyeHeight) * REPEAT_SCALE;
DVector3 pos(actor->spr.pos.XY(), height);
DVector3 Aim(actor->spr.angle.ToVector(), actor->flt_dudeSlope());
DVector3 Aim(actor->spr.angle.ToVector(), actor->dudeSlope);
double nClosest = 0x7fffffff;
BloodStatIterator it(kStatDude);
@ -112,7 +112,7 @@ void ghostBlastSeqCallback(int, DBloodActor* actor)
DVector3 tvec = pos;
tvec.XY() += actor->spr.angle.ToVector() * nDist;
tvec.Z += actor->flt_dudeSlope() * nDist;
tvec.Z += actor->dudeSlope * nDist;
double tsr = nDist * 9.23828125;
double top, bottom;

View file

@ -143,7 +143,7 @@ static void gillThinkChase(DBloodActor* actor)
if (nDist < pDudeInfo->SeeDist() && nDeltaAngle <= pDudeInfo->Periphery())
{
aiSetTarget(actor, actor->GetTarget());
actor->_dudeSlope = nDist == 0 ? 0 : (target->spr.pos.Z - actor->spr.pos.Z) / nDist * 16384;
actor->dudeSlope = nDist == 0 ? 0 : (target->spr.pos.Z - actor->spr.pos.Z) / nDist;
if (nDist < 57.5625 && abs(nDeltaAngle) < DAngle1 * 5)
{
int hit = HitScan(actor, actor->spr.pos.Z, DVector3(dv, 0), CLIPMASK1, 0);

View file

@ -65,7 +65,7 @@ void tchernobogBurnSeqCallback(int, DBloodActor* actor)
if (!actor->ValidateTarget(__FUNCTION__)) return;
DVector3 pos(actor->spr.pos.XY(), height);
DVector3 Aim(actor->spr.angle.ToVector(), actor->flt_dudeSlope());
DVector3 Aim(actor->spr.angle.ToVector(), actor->dudeSlope);
double nClosest = 0x7fffffff;
BloodStatIterator it(kStatDude);
@ -83,7 +83,7 @@ void tchernobogBurnSeqCallback(int, DBloodActor* actor)
DVector3 tvec = pos;
tvec.XY() += actor->spr.angle.ToVector() * nDist;
tvec.Z += actor->flt_dudeSlope() * nDist;
tvec.Z += actor->dudeSlope * nDist;
double tsr = nDist * 9.23828125;
double top, bottom;
@ -123,7 +123,7 @@ void tchernobogBurnSeqCallback2(int, DBloodActor* actor)
double height = actor->spr.yrepeat * pDudeInfo->eyeHeight * REPEAT_SCALE * 0.25;
DVector3 pos(actor->spr.pos.XY(), height);
DVector3 Aim(actor->spr.angle.ToVector(), -actor->flt_dudeSlope());
DVector3 Aim(actor->spr.angle.ToVector(), -actor->dudeSlope);
DVector3 Aim2(Aim.XY(), 0);
double nClosest = 0x7fffffff;
@ -139,7 +139,7 @@ void tchernobogBurnSeqCallback2(int, DBloodActor* actor)
DVector3 tvec = pos;
tvec.XY() += actor->spr.angle.ToVector() * nDist;
tvec.Z += actor->flt_dudeSlope() * nDist;
tvec.Z += actor->dudeSlope * nDist;
double tsr = nDist * 9.23828125;
double top, bottom;

View file

@ -132,18 +132,19 @@ static bool genDudeAdjustSlope(DBloodActor* actor, int dist, int weaponType, int
{
if (actor->GetTarget() != nullptr)
{
int fStart = 0;
int fEnd = 0;
double fStart = 0;
double fEnd = 0;
GENDUDEEXTRA* pExtra = &actor->genDudeExtra;
unsigned int clipMask = (weaponType == kGenDudeWeaponMissile) ? CLIPMASK0 : CLIPMASK1;
for (int i = -8191; i < 8192; i += by)
{
HitScan(actor, actor->spr.pos.Z, DVector3(actor->spr.angle.ToVector() * 1024, i / 16.), clipMask, dist);
if (!fStart && actor->GetTarget() == gHitInfo.actor()) fStart = i;
double ii = i / 16384.;
HitScan(actor, actor->spr.pos.Z, DVector3(actor->spr.angle.ToVector(), ii), clipMask, dist);
if (!fStart && actor->GetTarget() == gHitInfo.actor()) fStart = ii;
else if (fStart && actor->GetTarget() != gHitInfo.actor())
{
fEnd = i;
fEnd = ii;
break;
}
}
@ -152,12 +153,12 @@ static bool genDudeAdjustSlope(DBloodActor* actor, int dist, int weaponType, int
{
if (weaponType == kGenDudeWeaponHitscan)
{
actor->_dudeSlope = fStart - ((fStart - fEnd) >> 2);
actor->dudeSlope = fStart - ((fStart - fEnd) * 0.25);
}
else if (weaponType == kGenDudeWeaponMissile)
{
const MissileType* pMissile = &missileInfo[pExtra->curWeapon - kMissileBase];
actor->_dudeSlope = (fStart - ((fStart - fEnd) >> 2)) - (pMissile->clipDist << 1);
actor->dudeSlope = (fStart - ((fStart - fEnd) * 0.25)) - (pMissile->fClipDist()) / 2048;
}
return true;
}
@ -225,7 +226,7 @@ void genDudeAttack1(int, DBloodActor* actor)
if (pExtra->weaponType == kGenDudeWeaponHitscan)
{
dv = DVector3(actor->spr.angle.ToVector(), actor->flt_dudeSlope());
dv = DVector3(actor->spr.angle.ToVector(), actor->dudeSlope);
// dispersal modifiers here in case if non-melee enemy
if (!dudeIsMelee(actor))
{
@ -264,7 +265,7 @@ void genDudeAttack1(int, DBloodActor* actor)
}
else if (pExtra->weaponType == kGenDudeWeaponMissile)
{
dv = DVector3(actor->spr.angle.ToVector(), actor->flt_dudeSlope());
dv = DVector3(actor->spr.angle.ToVector(), actor->dudeSlope);
// dispersal modifiers here
dv.X += Random3F(dispersion, 14);
@ -529,7 +530,7 @@ static void unicultThinkChase(DBloodActor* actor)
if ((PlayClock & 64) == 0 && Chance(0x3000) && !spriteIsUnderwater(actor, false))
playGenDudeSound(actor, kGenDudeSndChasing);
actor->_dudeSlope = dist == 0 ? 0 : target->spr.pos.Z - actor->spr.pos.Z / dist * 16384;
actor->dudeSlope = dist == 0 ? 0 : target->spr.pos.Z - actor->spr.pos.Z / dist;
int curWeapon = actor->genDudeExtra.curWeapon;
int weaponType = actor->genDudeExtra.weaponType;
@ -746,9 +747,9 @@ static void unicultThinkChase(DBloodActor* actor)
double targetDist = -1;
int hit = -1;
if (weaponType == kGenDudeWeaponHitscan)
hit = HitScan(actor, actor->spr.pos.Z, DVector3(actor->spr.angle.ToVector(), actor->flt_dudeSlope()), CLIPMASK1, dist);
hit = HitScan(actor, actor->spr.pos.Z, DVector3(actor->spr.angle.ToVector(), actor->dudeSlope), CLIPMASK1, dist);
else if (weaponType == kGenDudeWeaponMissile)
hit = HitScan(actor, actor->spr.pos.Z, DVector3(actor->spr.angle.ToVector(), actor->flt_dudeSlope()), CLIPMASK0, dist);
hit = HitScan(actor, actor->spr.pos.Z, DVector3(actor->spr.angle.ToVector(), actor->dudeSlope), CLIPMASK0, dist);
if (hit >= 0)
{
@ -861,7 +862,7 @@ static void unicultThinkChase(DBloodActor* actor)
else if (weaponType == kGenDudeWeaponHitscan && hscn)
{
if (genDudeAdjustSlope(actor, dist * worldtoint, weaponType)) break;
VectorScan(actor, 0, 0, DVector3(actor->spr.angle.ToVector(), actor->flt_dudeSlope()), dist, 1);
VectorScan(actor, 0, 0, DVector3(actor->spr.angle.ToVector(), actor->dudeSlope), dist, 1);
if (actor == gHitInfo.actor()) break;
bool immune = nnExtIsImmune(hitactor, gVectorData[curWeapon].dmgType);
@ -922,7 +923,7 @@ static void unicultThinkChase(DBloodActor* actor)
if (hit == 4 && weaponType == kGenDudeWeaponHitscan && hscn)
{
bool masked = (pHWall->cstat & CSTAT_WALL_MASKED);
if (masked) VectorScan(actor, 0, 0, DVector3(actor->spr.angle.ToVector(), actor->flt_dudeSlope()), dist, 1);
if (masked) VectorScan(actor, 0, 0, DVector3(actor->spr.angle.ToVector(), actor->dudeSlope), dist, 1);
if ((actor != gHitInfo.actor()) && (pHWall->type != kWallGib || !masked || pXHWall == NULL || !pXHWall->triggerVector || pXHWall->locked))
{

View file

@ -18,9 +18,7 @@ class DBloodActor : public DCoreActor
HAS_OBJECT_POINTERS
public:
int _dudeSlope; // Q18.14 format
[[deprecated]] int int_dudeSlope() const { return _dudeSlope; }
[[deprecated]] double flt_dudeSlope() const { return _dudeSlope / 16384.; }
double dudeSlope; // Q18.14 format
bool hasx;
XSPRITE xspr;
SPRITEHIT hit;

View file

@ -479,7 +479,7 @@ void DBloodActor::Serialize(FSerializer& arc)
if (hasX())
{
arc("xsprite", xspr)
("dudeslope", _dudeSlope)
("dudeslope", dudeSlope)
("dudeextra", dudeExtra)
("explosionflag", explosionhackflag)
("spritehit", hit)

View file

@ -4646,7 +4646,7 @@ 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->spr.pos.Z, DVector3(objActor->spr.angle.ToVector(), (!objActor->hasX()) ? 0 : objActor->flt_dudeSlope()), arg1, range);
var = HitScan(objActor, objActor->spr.pos.Z, DVector3(objActor->spr.angle.ToVector(), (!objActor->hasX()) ? 0 : objActor->dudeSlope), arg1, range);
else if ((objActor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) == CSTAT_SPRITE_ALIGNMENT_FLOOR)
{
var3 = (objActor->spr.cstat & CSTAT_SPRITE_YFLIP) ? 8 : -8; // was 0x20000 - HitScan uses Q28.4 for dz!