- floatified several Distance calls

This commit is contained in:
Christoph Oelckers 2022-09-05 00:57:40 +02:00
parent 79100eeb08
commit 7b05beeb75
8 changed files with 35 additions and 43 deletions

View file

@ -598,7 +598,7 @@ int DoCoolieMove(DSWActor* actor)
return 0;
}
if (DistanceI(actor->spr.pos, actor->user.targetActor->spr.pos) < 1200)
if ((actor->spr.pos.XY() - actor->user.targetActor->spr.pos.XY()).Length() < 75)
{
UpdateSinglePlayKills(actor);
DoActorDie(actor, actor, 0);

View file

@ -1697,33 +1697,27 @@ void DoPlayerHorizon(PLAYER* pp, float const horz, double const scaleAdjust)
void DoPlayerBob(PLAYER* pp)
{
int dist;
int amt;
double amt;
dist = 0;
double dist = (pp->pos.XY() - pp->oldpos.XY()).Length();
dist = DistanceI(pp->pos, pp->oldpos);
if (dist > 512)
if (dist > 32)
dist = 0;
// if running make a longer stride
if (pp->input.actions & SB_RUN)
{
//amt = 10;
amt = 12;
amt = MulScale(amt, dist<<8, 16);
dist = MulScale(dist, 26000, 16);
amt = dist * (12. / 16.);
dist *= FixedToFloat(26000);
}
else
{
amt = 5;
amt = MulScale(amt, dist<<9, 16);
dist = MulScale(dist, 32000, 16);
amt = dist * (5. / 8.);
dist *= FixedToFloat(32000);
}
// controls how fast you move through the sin table
pp->bcnt += dist;
pp->bcnt += int(dist * 16);
// wrap bcnt
pp->bcnt &= 2047;
@ -1748,6 +1742,12 @@ void DoPlayerBeginRecoil(PLAYER* pp, short pix_amt)
pp->recoil_ohorizoff = pp->recoil_horizoff = 0;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void DoPlayerRecoil(PLAYER* pp)
{
// controls how fast you move through the sin table
@ -3481,7 +3481,9 @@ int DoPlayerWadeSuperJump(PLAYER* pp)
if (hit.hitSector != nullptr && abs(hit.hitSector->int_floorz() - pp->int_ppos().Z) < Z(50))
{
if (Distance(pp->int_ppos().X, pp->int_ppos().Y, hit.int_hitpos().X, hit.int_hitpos().Y) < ((((int)pp->actor->spr.clipdist)<<2) + 256))
double dist = (pp->pos.XY() - hit.hitpos.XY()).Length();
double comp = ((((int)pp->actor->spr.clipdist)<<2) + 256) * inttoworld;
if (dist < comp)
return true;
}
}
@ -3714,14 +3716,14 @@ void DoPlayerFly(PLAYER* pp)
DSWActor* FindNearSprite(DSWActor* actor, short stat)
{
int fs;
int dist, near_dist = 15000;
double dist, near_dist = 937.5;
DSWActor* near_fp = nullptr;
SWStatIterator it(stat);
while (auto itActor = it.Next())
{
dist = DistanceI(actor->spr.pos, itActor->spr.pos);
dist = (actor->spr.pos.XY() - itActor->spr.pos.XY()).Length();
if (dist < near_dist)
{

View file

@ -928,9 +928,9 @@ int InitRipperHang(DSWActor* actor)
if (hit.hitSector == nullptr)
continue;
int dist = DistanceI(actor->spr.pos, hit.hitpos);
double dist = (actor->spr.pos.XY() - hit.hitpos.XY()).Length();
if (hit.hitWall == nullptr || dist < 2000 || dist > 7000)
if (hit.hitWall == nullptr || dist < 125 || dist > 437.5)
{
continue;
}

View file

@ -941,9 +941,9 @@ int InitRipper2Hang(DSWActor* actor)
if (hit.hitSector == nullptr)
continue;
int dist = DistanceI(actor->spr.pos, hit.hitpos);
double dist = (actor->spr.pos.XY() - hit.hitpos.XY()).Length();
if (hit.hitWall == nullptr || dist < 2000 || dist > 7000)
if (hit.hitWall == nullptr || dist < 125 || dist > 437.5)
{
continue;
}

View file

@ -245,7 +245,6 @@ int DoRotator(DSWActor* actor)
short ndx,w,startwall,endwall;
DSWActor* pivot = nullptr;
vec2_t nxy;
int dist,closest;
bool kill = false;
r = actor->user.rotator.Data();
@ -320,13 +319,13 @@ int DoRotator(DSWActor* actor)
kill = true;
}
closest = 99999;
double closest = 99999;
SWStatIterator it(STAT_ROTATOR_PIVOT);
while (auto itActor = it.Next())
{
if (itActor->spr.lotag == actor->spr.lotag)
{
dist = DistanceI(actor->spr.pos, itActor->spr.pos);
double dist = (actor->spr.pos.XY() - itActor->spr.pos.XY()).Length();
if (dist < closest)
{
closest = dist;

View file

@ -1832,17 +1832,14 @@ void OperateTripTrigger(PLAYER* pp)
case TAG_TRIGGER_ACTORS:
{
int dist;
int i;
dist = sectp->hitag;
double dist = sectp->hitag * maptoworld;
SWStatIterator it(STAT_ENEMY);
while (auto actor = it.Next())
{
if (actor->user.Flags & (SPR_WAIT_FOR_TRIGGER))
{
if (Distance(actor->int_pos().X, actor->int_pos().Y, pp->int_ppos().X, pp->int_ppos().Y) < dist)
if ((actor->spr.pos.XY() - pp->pos.XY()).Length() < dist)
{
actor->user.targetActor = pp->actor;
actor->user.Flags &= ~(SPR_WAIT_FOR_TRIGGER);
@ -1982,7 +1979,7 @@ bool NearThings(PLAYER* pp)
if (hit.hitSector == nullptr)
return false;
if (Distance(hit.int_hitpos().X, hit.int_hitpos().Y, pp->int_ppos().X, pp->int_ppos().Y) > 1500)
if ((hit.hitpos.XY() - pp->pos.XY()).Length() > 93.75)
return false;
// hit a sprite?

View file

@ -4239,7 +4239,8 @@ int NewStateGroup(DSWActor* actor, STATE* StateGroup[])
bool SpriteOverlap(DSWActor* actor_a, DSWActor* actor_b)
{
if (!actor_a->hasU() || !actor_b->hasU()) return false;
if ((unsigned)DistanceI(actor_a->spr.pos, actor_b->spr.pos) > actor_a->user.Radius + actor_b->user.Radius)
double dist = (actor_a->spr.pos.XY() - actor_b->spr.pos.XY()).Length();
if (dist > (actor_a->user.Radius + actor_b->user.Radius) * inttoworld)
{
return false;
}

View file

@ -11621,7 +11621,7 @@ int InitSwordAttack(PLAYER* pp)
if (!(itActor->spr.extra & SPRX_PLAYER_OR_ENEMY))
continue;
dist = Distance(pp->int_ppos().X, pp->int_ppos().Y, itActor->int_pos().X, itActor->int_pos().Y);
dist = DistanceI(pp->pos, itActor->spr.pos);
reach = 1000; // !JIM! was 800
face = 200;
@ -11786,7 +11786,7 @@ int InitFistAttack(PLAYER* pp)
if (!(itActor->spr.extra & SPRX_PLAYER_OR_ENEMY))
continue;
dist = Distance(pp->int_ppos().X, pp->int_ppos().Y, itActor->int_pos().X, itActor->int_pos().Y);
dist = DistanceI(pp->pos, itActor->spr.pos);
if (pp->InventoryActive[2]) // Shadow Bombs give you demon fist
{
@ -12171,13 +12171,6 @@ int WeaponAutoAimZvel(DSWActor* actor, DSWActor* missileActor, int *zvel, short
{
int dist;
#if 0
//formula for leading a player
dist = Distance(actor->int_pos().X, actor->int_pos().Y, hp->pos.X, hp->pos.Y);
time_to_target = dist/missileActor->int_xvel();
lead_dist = time_to_target*hp->vel;
#endif
if (actor->hasU() && actor->user.PlayerP)
{
if (!Autoaim(actor->user.PlayerP->pnum))
@ -17124,8 +17117,8 @@ DSWActor* QueueWallBlood(DSWActor* actor, DAngle bang)
if (hit.hitSector == nullptr)
return nullptr;
const int WALLBLOOD_DIST_MAX = 2500;
if (DistanceI(hit.hitpos, actor->spr.pos) > WALLBLOOD_DIST_MAX)
const double WALLBLOOD_DIST_MAX = 156.25;
if ((hit.hitpos.XY(), actor->spr.pos.XY()).Length() > WALLBLOOD_DIST_MAX)
return nullptr;
// hit a sprite?