- floatified P_LineAttack, P_TraceBleed and P_UseLines.

This commit is contained in:
Christoph Oelckers 2016-03-27 20:58:01 +02:00
parent eae6f7e9ea
commit 0baaa3cf63
14 changed files with 118 additions and 157 deletions

View File

@ -1679,13 +1679,8 @@ inline fixedvec2 Vec2Angle(fixed_t length, angle_t angle)
return ret;
}
inline fixedvec2 Vec2Angle(fixed_t length, DAngle angle)
{
return { xs_CRoundToInt(length * angle.Cos()), xs_CRoundToInt(length * angle.Sin()) };
}
void PrintMiscActorInfo(AActor * query);
AActor *P_LinePickActor(AActor *t1, angle_t angle, fixed_t distance, int pitch, ActorFlags actorMask, DWORD wallMask);
AActor *P_LinePickActor(AActor *t1, DAngle angle, double distance, DAngle pitch, ActorFlags actorMask, DWORD wallMask);
// If we want to make P_AimLineAttack capable of handling arbitrary portals, it needs to pass a lot more info than just the linetarget actor.
struct FTranslatedLineTarget

View File

@ -5885,7 +5885,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
flags = args[7];
}
AActor* pickedActor = P_LinePickActor(actor, args[1] << 16, args[3], args[2] << 16, actorMask, wallMask);
AActor* pickedActor = P_LinePickActor(actor, ACSToAngle(args[1]), ACSToDouble(args[3]), ACSToAngle(args[2]), actorMask, wallMask);
if (pickedActor == NULL) {
return 0;
}

View File

@ -637,7 +637,7 @@ void P_DrawSplash2 (int count, const DVector3 &pos, DAngle angle, int updown, in
}
}
void P_DrawRailTrail(AActor *source, const DVector3 &start, const DVector3 &end, int color1, int color2, double maxdiff_d, int flags, PClassActor *spawnclass, angle_t angle, int duration, double sparsity, double drift, int SpiralOffset)
void P_DrawRailTrail(AActor *source, const DVector3 &start, const DVector3 &end, int color1, int color2, double maxdiff_d, int flags, PClassActor *spawnclass, DAngle angle, int duration, double sparsity, double drift, int SpiralOffset)
{
double length, lengthsquared;
int steps, i;
@ -646,6 +646,7 @@ void P_DrawRailTrail(AActor *source, const DVector3 &start, const DVector3 &end,
bool fullbright;
float maxdiff = (float)maxdiff_d;
dir = end - start;
lengthsquared = dir | dir;
length = g_sqrt(lengthsquared);
@ -862,7 +863,7 @@ void P_DrawRailTrail(AActor *source, const DVector3 &start, const DVector3 &end,
}
AActor *thing = Spawn (spawnclass, pos + diff, ALLOW_REPLACE);
if (thing)
thing->Angles.Yaw = ANGLE2DBL(angle);
thing->Angles.Yaw = angle;
pos += trail_step;
}
}

View File

@ -89,7 +89,7 @@ void P_RunEffects (void);
void P_RunEffect (AActor *actor, int effects);
void P_DrawRailTrail(AActor *source, const DVector3 &start, const DVector3 &end, int color1, int color2, double maxdiff = 0, int flags = 0, PClassActor *spawnclass = NULL, angle_t angle = 0, int duration = 35, double sparsity = 1.0, double drift = 1.0, int SpiralOffset = 270);
void P_DrawRailTrail(AActor *source, const DVector3 &start, const DVector3 &end, int color1, int color2, double maxdiff = 0, int flags = 0, PClassActor *spawnclass = NULL, DAngle angle = 0., int duration = 35, double sparsity = 1.0, double drift = 1.0, int SpiralOffset = 270);
void P_DrawSplash (int count, const DVector3 &pos, DAngle angle, int kind);
void P_DrawSplash2 (int count, const DVector3 &pos, DAngle angle, int updown, int kind);
void P_DisconnectEffect (AActor *actor);

View File

@ -2605,7 +2605,7 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates)
FState *raisestate = corpsehit->GetRaiseState();
if (raisestate != NULL)
{
// use the current actor's _f_radius() instead of the Arch Vile's default.
// use the current actor's radius instead of the Arch Vile's default.
double maxdist = corpsehit->GetDefault()->radius + self->radius;
if (fabs(corpsehit->X() - cres.Position.X) > maxdist ||
@ -2640,7 +2640,7 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates)
}
corpsehit->Vel.X = corpsehit->Vel.Y = 0;
// [RH] Check against real height and _f_radius()
// [RH] Check against real height and radius
double oldheight = corpsehit->Height;
double oldradius = corpsehit->radius;

View File

@ -88,7 +88,7 @@ inline int GetSafeBlockY(long long blocky)
#define MAXMOVE (30.)
#define TALKRANGE (128.)
#define USERANGE (64*FRACUNIT)
#define USERANGE (64.)
#define MELEERANGE (64.)
#define SAWRANGE (64.+(1./65536.)) // use meleerange + 1 so the puff doesn't skip the flash (i.e. plays all states)
@ -360,20 +360,9 @@ enum // P_LineAttack flags
AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, DAngle pitch, int damage, FName damageType, PClassActor *pufftype, int flags = 0, FTranslatedLineTarget *victim = NULL, int *actualdamage = NULL);
AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, DAngle pitch, int damage, FName damageType, FName pufftype, int flags = 0, FTranslatedLineTarget *victim = NULL, int *actualdamage = NULL);
void P_TraceBleed (int damage, fixed_t x, fixed_t y, fixed_t z, AActor *target, angle_t angle, int pitch);
inline void P_TraceBleed(int damage, const fixedvec3 &pos, AActor *target, angle_t angle, int pitch)
{
P_TraceBleed(damage, pos.x, pos.y, pos.z, target, angle, pitch);
}
inline void P_TraceBleed(int damage, const DVector3 &pos, AActor *target, DAngle angle, DAngle pitch)
{
P_TraceBleed(damage, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), FLOAT2FIXED(pos.Z), target,angle.BAMs(), pitch.BAMs());
}
void P_TraceBleed (int damage, AActor *target, angle_t angle, int pitch);
inline void P_TraceBleed(int damage, AActor *target, DAngle angle, DAngle pitch)
{
P_TraceBleed(damage, target, angle.BAMs(), pitch.BAMs());
}
void P_TraceBleed(int damage, const DVector3 &pos, AActor *target, DAngle angle, DAngle pitch);
void P_TraceBleed(int damage, AActor *target, DAngle angle, DAngle pitch);
void P_TraceBleed (int damage, AActor *target, AActor *missile); // missile version
void P_TraceBleed(int damage, FTranslatedLineTarget *t, AActor *puff); // hitscan version
void P_TraceBleed (int damage, AActor *target); // random direction version

View File

@ -3535,7 +3535,6 @@ struct aim_t
//============================================================================
//
// traverses a line portal
// simply calling PortalRelocate does not work here because more needs to be set up
//
//============================================================================
@ -3993,12 +3992,11 @@ static ETraceStatus CheckForActor(FTraceResults &res, void *userdata)
AActor *P_LineAttack(AActor *t1, DAngle angle, double distance,
DAngle pitch, int damage, FName damageType, PClassActor *pufftype, int flags, FTranslatedLineTarget*victim, int *actualdamage)
{
fixed_t vx, vy, vz, shootz;
DVector3 direction;
double shootz;
FTraceResults trace;
Origin TData;
TData.Caller = t1;
angle_t srcangle = angle.BAMs();
int srcpitch = pitch.BAMs();
bool killPuff = false;
AActor *puff = NULL;
int pflag = 0;
@ -4017,14 +4015,12 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance,
double pc = pitch.Cos();
vx = FLOAT2FIXED(pc * angle.Cos());
vy = FLOAT2FIXED(pc * angle.Sin());
vz = FLOAT2FIXED(-pitch.Sin());
direction = { pc * angle.Cos(), pc * angle.Sin(), -pitch.Sin() };
shootz = t1->Center() - t1->Floorclip;
shootz = t1->_f_Z() - t1->_f_floorclip() + (t1->_f_height() >> 1);
if (t1->player != NULL)
{
shootz += FLOAT2FIXED(t1->player->mo->AttackZOffset * t1->player->crouchfactor);
shootz += t1->player->mo->AttackZOffset * t1->player->crouchfactor;
if (damageType == NAME_Melee || damageType == NAME_Hitscan)
{
// this is coming from a weapon attack function which needs to transfer information to the obituary code,
@ -4034,7 +4030,7 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance,
}
else
{
shootz += 8 * FRACUNIT;
shootz += 8;
}
// We need to check the defaults of the replacement here
@ -4059,9 +4055,8 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance,
if (puffDefaults != NULL && puffDefaults->flags6 & MF6_NOTRIGGER) tflags = TRACE_NoSky;
else tflags = TRACE_NoSky | TRACE_Impact;
if (!Trace(t1->_f_X(), t1->_f_Y(), shootz, t1->Sector, vx, vy, vz, FLOAT2FIXED(distance),
MF_SHOOTABLE, ML_BLOCKEVERYTHING | ML_BLOCKHITSCAN, t1, trace,
tflags, CheckForActor, &TData))
if (!Trace(t1->PosAtZ(shootz), t1->Sector, direction, distance, MF_SHOOTABLE,
ML_BLOCKEVERYTHING | ML_BLOCKHITSCAN, t1, trace, tflags, CheckForActor, &TData))
{ // hit nothing
if (puffDefaults == NULL)
{
@ -4217,7 +4212,7 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance,
}
}
// [RH] Stick blood to walls
P_TraceBleed(newdam > 0 ? newdam : damage, trace.HitPos, trace.Actor, trace.SrcAngleFromTarget, ANGLE2DBL(srcpitch));
P_TraceBleed(newdam > 0 ? newdam : damage, trace.HitPos, trace.Actor, trace.SrcAngleFromTarget, pitch);
}
}
if (victim != NULL)
@ -4270,26 +4265,22 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance,
//
//==========================================================================
AActor *P_LinePickActor(AActor *t1, angle_t angle, fixed_t distance, int pitch,
ActorFlags actorMask, DWORD wallMask)
AActor *P_LinePickActor(AActor *t1, DAngle angle, double distance, DAngle pitch, ActorFlags actorMask, DWORD wallMask)
{
fixed_t vx, vy, vz, shootz;
angle >>= ANGLETOFINESHIFT;
pitch = (angle_t)(pitch) >> ANGLETOFINESHIFT;
DVector3 direction;
double shootz;
vx = FixedMul(finecosine[pitch], finecosine[angle]);
vy = FixedMul(finecosine[pitch], finesine[angle]);
vz = -finesine[pitch];
double pc = pitch.Cos();
direction = { pc * angle.Cos(), pc * angle.Sin(), -pitch.Sin() };
shootz = t1->Center() - t1->Floorclip;
shootz = t1->_f_Z() - t1->_f_floorclip() + (t1->_f_height() >> 1);
if (t1->player != NULL)
{
shootz += FLOAT2FIXED(t1->player->mo->AttackZOffset * t1->player->crouchfactor);
shootz += t1->player->mo->AttackZOffset * t1->player->crouchfactor;
}
else
{
shootz += 8 * FRACUNIT;
shootz += 8;
}
FTraceResults trace;
@ -4298,7 +4289,7 @@ AActor *P_LinePickActor(AActor *t1, angle_t angle, fixed_t distance, int pitch,
TData.Caller = t1;
TData.hitGhosts = true;
if (Trace(t1->_f_X(), t1->_f_Y(), shootz, t1->Sector, vx, vy, vz, distance,
if (Trace(t1->PosAtZ(shootz), t1->Sector, direction, distance,
actorMask, wallMask, t1, trace, TRACE_NoSky | TRACE_PortalRestrict, CheckForActor, &TData))
{
if (trace.HitType == TRACE_HitActor)
@ -4316,14 +4307,14 @@ AActor *P_LinePickActor(AActor *t1, angle_t angle, fixed_t distance, int pitch,
//
//==========================================================================
void P_TraceBleed(int damage, fixed_t x, fixed_t y, fixed_t z, AActor *actor, angle_t angle, int pitch)
void P_TraceBleed(int damage, const DVector3 &pos, AActor *actor, DAngle angle, DAngle pitch)
{
if (!cl_bloodsplats)
return;
const char *bloodType = "BloodSplat";
int count;
int noise;
double noise;
if ((actor->flags & MF_NOBLOOD) ||
@ -4333,6 +4324,7 @@ void P_TraceBleed(int damage, fixed_t x, fixed_t y, fixed_t z, AActor *actor, an
{
return;
}
if (damage < 15)
{ // For low damages, there is a chance to not spray blood at all
if (damage <= 10)
@ -4343,12 +4335,12 @@ void P_TraceBleed(int damage, fixed_t x, fixed_t y, fixed_t z, AActor *actor, an
}
}
count = 1;
noise = 18;
noise = 11.25 / 256.;
}
else if (damage < 25)
{
count = 2;
noise = 19;
noise = 22.5 / 256.;
}
else
{ // For high damages, there is a chance to spray just one big glob of blood
@ -4356,12 +4348,12 @@ void P_TraceBleed(int damage, fixed_t x, fixed_t y, fixed_t z, AActor *actor, an
{
bloodType = "BloodSmear";
count = 1;
noise = 20;
noise = 45. / 256.;
}
else
{
count = 3;
noise = 20;
noise = 45. / 256.;
}
}
@ -4369,15 +4361,12 @@ void P_TraceBleed(int damage, fixed_t x, fixed_t y, fixed_t z, AActor *actor, an
{
FTraceResults bleedtrace;
angle_t bleedang = (angle + ((pr_tracebleed() - 128) << noise)) >> ANGLETOFINESHIFT;
angle_t bleedpitch = (angle_t)(pitch + ((pr_tracebleed() - 128) << noise)) >> ANGLETOFINESHIFT;
fixed_t vx = FixedMul(finecosine[bleedpitch], finecosine[bleedang]);
fixed_t vy = FixedMul(finecosine[bleedpitch], finesine[bleedang]);
fixed_t vz = -finesine[bleedpitch];
DAngle bleedang = angle + (pr_tracebleed() - 128) * noise;
DAngle bleedpitch = pitch + (pr_tracebleed() - 128) * noise;
double cosp = bleedpitch.Cos();
DVector3 vdir = DVector3(cosp * bleedang.Cos(), cosp * bleedang.Sin(), -bleedpitch.Sin());
if (Trace(x, y, z, actor->Sector,
vx, vy, vz, 172 * FRACUNIT, 0, ML_BLOCKEVERYTHING, actor,
bleedtrace, TRACE_NoSky))
if (Trace(pos, actor->Sector, vdir, 172 * FRACUNIT, 0, ML_BLOCKEVERYTHING, actor, bleedtrace, TRACE_NoSky))
{
if (bleedtrace.HitType == TRACE_HitWall)
{
@ -4397,10 +4386,9 @@ void P_TraceBleed(int damage, fixed_t x, fixed_t y, fixed_t z, AActor *actor, an
}
}
void P_TraceBleed(int damage, AActor *target, angle_t angle, int pitch)
void P_TraceBleed(int damage, AActor *target, DAngle angle, DAngle pitch)
{
P_TraceBleed(damage, target->_f_X(), target->_f_Y(), target->_f_Z() + target->_f_height() / 2,
target, angle, pitch);
P_TraceBleed(damage, target->PosPlusZ(target->Height/2), target, angle, pitch);
}
//==========================================================================
@ -4422,7 +4410,7 @@ void P_TraceBleed(int damage, AActor *target, AActor *missile)
{
double aim;
aim = g_atan((double)missile->_f_velz() / (double)target->AproxDistance(missile));
aim = g_atan(missile->Vel.Z / target->Distance2D(missile));
pitch = -ToDegrees(aim);
}
else
@ -4445,9 +4433,8 @@ void P_TraceBleed(int damage, FTranslatedLineTarget *t, AActor *puff)
return;
}
fixed_t randpitch = (pr_tracebleed() - 128) << 16;
P_TraceBleed(damage, t->linetarget->_f_X(), t->linetarget->_f_Y(), t->linetarget->_f_Z() + t->linetarget->_f_height() / 2,
t->linetarget, FLOAT2ANGLE(t->angleFromSource.Degrees), 0);
DAngle pitch = (pr_tracebleed() - 128) * (360 / 65536.);
P_TraceBleed(damage, t->linetarget->PosPlusZ(t->linetarget->Height/2), t->linetarget, t->angleFromSource, pitch);
}
//==========================================================================
@ -4460,11 +4447,9 @@ void P_TraceBleed(int damage, AActor *target)
{
if (target != NULL)
{
fixed_t one = pr_tracebleed() << 24;
fixed_t two = (pr_tracebleed() - 128) << 16;
P_TraceBleed(damage, target->_f_X(), target->_f_Y(), target->_f_Z() + target->_f_height() / 2,
target, one, two);
DAngle angle = pr_tracebleed() * (360 / 256.);
DAngle pitch = (pr_tracebleed() - 128) * (360 / 65536.);
P_TraceBleed(damage, target->PosPlusZ(target->Height / 2), target, angle, pitch);
}
}
@ -4683,7 +4668,7 @@ void P_RailAttack(FRailParams *p)
}
// Draw the slug's trail.
P_DrawRailTrail(source, start, trace.HitPos, p->color1, p->color2, p->maxdiff, p->flags, p->spawnclass, angle.BAMs(), p->duration, p->sparsity, p->drift, p->SpiralOffset);
P_DrawRailTrail(source, start, trace.HitPos, p->color1, p->color2, p->maxdiff, p->flags, p->spawnclass, angle, p->duration, p->sparsity, p->drift, p->SpiralOffset);
}
//==========================================================================
@ -4697,27 +4682,23 @@ CVAR(Float, chase_dist, 90.f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
void P_AimCamera(AActor *t1, DVector3 &campos, sector_t *&CameraSector, bool &unlinked)
{
fixed_t distance = (fixed_t)(clamp<double>(chase_dist, 0, 30000) * FRACUNIT);
angle_t angle = (t1->_f_angle() - ANG180) >> ANGLETOFINESHIFT;
angle_t pitch = (angle_t)(t1->_f_pitch()) >> ANGLETOFINESHIFT;
double distance = clamp<double>(chase_dist, 0, 30000);
DAngle angle = t1->Angles.Yaw - 180;
DAngle pitch = t1->Angles.Pitch;
FTraceResults trace;
fixed_t vx, vy, vz, sz;
DVector3 vvec;
double sz;
vx = FixedMul(finecosine[pitch], finecosine[angle]);
vy = FixedMul(finecosine[pitch], finesine[angle]);
vz = finesine[pitch];
double pc = pitch.Cos();
DVector3 vvec(vx, vy, vz);
vvec.MakeUnit();
vvec = { pc * angle.Cos(), pc * angle.Sin(), -pitch.Sin() };
sz = t1->Top() - t1->Floorclip + clamp<double>(chase_height, -1000, 1000);
sz = t1->_f_Z() - t1->_f_floorclip() + t1->_f_height() + (fixed_t)(clamp<double>(chase_height, -1000, 1000) * FRACUNIT);
if (Trace(t1->_f_X(), t1->_f_Y(), sz, t1->Sector,
vx, vy, vz, distance, 0, 0, NULL, trace) &&
if (Trace(t1->PosAtZ(sz), t1->Sector, vvec, distance, 0, 0, NULL, trace) &&
trace.Distance > 10)
{
// Position camera slightly in front of hit thing
campos = t1->PosAtZ(FIXED2DBL(sz)) + vvec *(trace.Distance - 5);
campos = t1->PosAtZ(sz) + vvec *(trace.Distance - 5);
}
else
{
@ -4768,11 +4749,11 @@ bool P_TalkFacing(AActor *player)
//
//==========================================================================
bool P_UseTraverse(AActor *usething, fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy, bool &foundline)
bool P_UseTraverse(AActor *usething, const DVector2 &start, const DVector2 &end, bool &foundline)
{
FPathTraverse it(startx, starty, endx, endy, PT_ADDLINES | PT_ADDTHINGS);
FPathTraverse it(start.X, start.Y, end.X, end.Y, PT_ADDLINES | PT_ADDTHINGS);
intercept_t *in;
fixedvec3 xpos = { startx, starty, usething->_f_Z() };
DVector3 xpos = { start.X, start.Y, usething->Z() };
while ((in = it.Next()))
{
@ -4792,6 +4773,7 @@ bool P_UseTraverse(AActor *usething, fixed_t startx, fixed_t starty, fixed_t end
}
continue;
}
if (it.PortalRelocate(in, PT_ADDLINES | PT_ADDTHINGS, &xpos))
{
continue;
@ -4807,7 +4789,7 @@ bool P_UseTraverse(AActor *usething, fixed_t startx, fixed_t starty, fixed_t end
}
else
{
P_LineOpening(open, NULL, in->d.line, it._f_InterceptPoint(in));
P_LineOpening(open, NULL, in->d.line, it.InterceptPoint(in));
}
if (open.range <= 0 ||
(in->d.line->special != 0 && (i_compatflags & COMPATF_USEBLOCKING)))
@ -4823,7 +4805,7 @@ bool P_UseTraverse(AActor *usething, fixed_t startx, fixed_t starty, fixed_t end
return true;
}
sec = P_PointOnLineSide(xpos.x, xpos.y, in->d.line) == 0 ?
sec = P_PointOnLineSide(xpos, in->d.line) == 0 ?
in->d.line->frontsector : in->d.line->backsector;
if (sec != NULL && sec->SecActTarget &&
@ -4842,7 +4824,7 @@ bool P_UseTraverse(AActor *usething, fixed_t startx, fixed_t starty, fixed_t end
continue; // not a special line, but keep checking
}
if (P_PointOnLineSide(xpos.x, xpos.y, in->d.line) == 1)
if (P_PointOnLineSide(xpos, in->d.line) == 1)
{
if (!(in->d.line->activation & SPAC_UseBack))
{
@ -4900,9 +4882,9 @@ bool P_UseTraverse(AActor *usething, fixed_t startx, fixed_t starty, fixed_t end
//
//==========================================================================
bool P_NoWayTraverse(AActor *usething, fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy)
bool P_NoWayTraverse(AActor *usething, const DVector2 &start, const DVector2 &end)
{
FPathTraverse it(startx, starty, endx, endy, PT_ADDLINES);
FPathTraverse it(start.X, start.Y, end.X, end.Y, PT_ADDLINES);
intercept_t *in;
while ((in = it.Next()))
@ -4915,7 +4897,7 @@ bool P_NoWayTraverse(AActor *usething, fixed_t startx, fixed_t starty, fixed_t e
if (ld->special) continue;
if (ld->isLinePortal()) return false;
if (ld->flags&(ML_BLOCKING | ML_BLOCKEVERYTHING | ML_BLOCK_PLAYERS)) return true;
P_LineOpening(open, NULL, ld, it._f_InterceptPoint(in));
P_LineOpening(open, NULL, ld, it.InterceptPoint(in));
if (open.range <= 0 ||
open.bottom > usething->Z() + usething->MaxStepHeight ||
open.top < usething->Top()) return true;
@ -4936,23 +4918,20 @@ void P_UseLines(player_t *player)
bool foundline = false;
// If the player is transitioning a portal, use the group that is at its vertical center.
fixedvec2 start = player->mo->_f_GetPortalTransition(player->mo->_f_height() / 2);
DVector2 start = player->mo->GetPortalTransition(player->mo->Height / 2);
// [NS] Now queries the Player's UseRange.
fixedvec2 end = start + Vec2Angle(FLOAT2FIXED(player->mo->UseRange), player->mo->_f_angle());
DVector2 end = start + player->mo->Angles.Yaw.ToVector(player->mo->UseRange);
// old code:
//
// P_PathTraverse ( x1, y1, x2, y2, PT_ADDLINES, PTR_UseTraverse );
//
// This added test makes the "oof" sound work on 2s lines -- killough:
if (!P_UseTraverse(player->mo, start.x, start.y, end.x, end.y, foundline))
if (!P_UseTraverse(player->mo, start, end, foundline))
{ // [RH] Give sector a chance to eat the use
sector_t *sec = player->mo->Sector;
int spac = SECSPAC_Use;
if (foundline) spac |= SECSPAC_UseWall;
if ((!sec->SecActTarget || !sec->SecActTarget->TriggerAction(player->mo, spac)) &&
P_NoWayTraverse(player->mo, start.x, start.y, end.x, end.y))
P_NoWayTraverse(player->mo, start, end))
{
S_Sound(player->mo, CHAN_VOICE, "*usefail", 1, ATTN_IDLE);
}
@ -4969,23 +4948,20 @@ void P_UseLines(player_t *player)
bool P_UsePuzzleItem(AActor *PuzzleItemUser, int PuzzleItemType)
{
int angle;
fixed_t x1, y1, x2, y2, usedist;
angle = PuzzleItemUser->_f_angle() >> ANGLETOFINESHIFT;
x1 = PuzzleItemUser->_f_X();
y1 = PuzzleItemUser->_f_Y();
DVector2 start;
DVector2 end;
double usedist;
// [NS] If it's a Player, get their UseRange.
if (PuzzleItemUser->player)
usedist = FLOAT2FIXED(PuzzleItemUser->player->mo->UseRange);
usedist = PuzzleItemUser->player->mo->UseRange;
else
usedist = USERANGE;
x2 = x1 + FixedMul(usedist, finecosine[angle]);
y2 = y1 + FixedMul(usedist, finesine[angle]);
start = PuzzleItemUser->GetPortalTransition(PuzzleItemUser->Height / 2);
end = PuzzleItemUser->Angles.Yaw.ToVector(usedist);
FPathTraverse it(x1, y1, x2, y2, PT_ADDLINES | PT_ADDTHINGS);
FPathTraverse it(start.X, start.Y, end.X, end.Y, PT_ADDLINES | PT_ADDTHINGS);
intercept_t *in;
while ((in = it.Next()))
@ -4997,14 +4973,14 @@ bool P_UsePuzzleItem(AActor *PuzzleItemUser, int PuzzleItemType)
{ // Check line
if (in->d.line->special != UsePuzzleItem)
{
P_LineOpening(open, NULL, in->d.line, it._f_InterceptPoint(in));
P_LineOpening(open, NULL, in->d.line, it.InterceptPoint(in));
if (open.range <= 0)
{
return false; // can't use through a wall
}
continue;
}
if (P_PointOnLineSide(PuzzleItemUser->_f_X(), PuzzleItemUser->_f_Y(), in->d.line) == 1)
if (P_PointOnLineSide(PuzzleItemUser->Pos(), in->d.line) == 1)
{ // Don't use back sides
return false;
}

View File

@ -1697,7 +1697,7 @@ void FPathTraverse::init (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, int fl
//
//===========================================================================
int FPathTraverse::PortalRelocate(intercept_t *in, int flags, fixedvec3 *optpos)
int FPathTraverse::PortalRelocate(intercept_t *in, int flags, DVector3 *optpos)
{
if (!in->isaline || !in->d.line->isLinePortal()) return false;
if (P_PointOnLineSidePrecise(trace.x, trace.y, in->d.line) == 1) return false;
@ -1711,8 +1711,8 @@ int FPathTraverse::PortalRelocate(intercept_t *in, int flags, fixedvec3 *optpos)
P_TranslatePortalXY(in->d.line, endx, endy);
if (optpos != NULL)
{
P_TranslatePortalXY(in->d.line, optpos->x, optpos->y);
P_TranslatePortalZ(in->d.line, optpos->z);
P_TranslatePortalXY(in->d.line, optpos->X, optpos->Y);
P_TranslatePortalZ(in->d.line, optpos->Z);
}
line_t *saved = in->d.line; // this gets overwriitten by the init call.
intercepts.Resize(intercept_index);

View File

@ -432,7 +432,7 @@ public:
init(FLOAT2FIXED(x1), FLOAT2FIXED(y1), FLOAT2FIXED(x2), FLOAT2FIXED(y2), flags, FLOAT2FIXED(startfrac));
}
void init(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, int flags, fixed_t startfrac = 0);
int PortalRelocate(intercept_t *in, int flags, fixedvec3 *optpos = NULL);
int PortalRelocate(intercept_t *in, int flags, DVector3 *optpos = NULL);
virtual ~FPathTraverse();
const fdivline_t &_f_Trace() const { return trace; }
const divline_t &Trace() const { return ftrace; }

View File

@ -198,7 +198,7 @@ bool CheckIfExitIsGood (AActor *self, level_info_t *info)
//
//============================================================================
bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType, fixedvec3 *optpos)
bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType, DVector3 *optpos)
{
int lineActivation;
INTBOOL repeat;
@ -259,7 +259,7 @@ bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType, fix
//
//============================================================================
bool P_TestActivateLine (line_t *line, AActor *mo, int side, int activationType, fixedvec3 *optpos)
bool P_TestActivateLine (line_t *line, AActor *mo, int side, int activationType, DVector3 *optpos)
{
int lineActivation = line->activation;

View File

@ -162,8 +162,8 @@ void P_SpawnSpecials (void);
void P_UpdateSpecials (void);
// when needed
bool P_ActivateLine (line_t *ld, AActor *mo, int side, int activationType, fixedvec3 *optpos = NULL);
bool P_TestActivateLine (line_t *ld, AActor *mo, int side, int activationType, fixedvec3 *optpos = NULL);
bool P_ActivateLine (line_t *ld, AActor *mo, int side, int activationType, DVector3 *optpos = NULL);
bool P_TestActivateLine (line_t *ld, AActor *mo, int side, int activationType, DVector3 *optpos = NULL);
bool P_PredictLine (line_t *ld, AActor *mo, int side, int activationType);
void P_PlayerInSpecialSector (player_t *player, sector_t * sector=NULL);
@ -382,7 +382,7 @@ void EV_StartLightFading (int tag, int value, int tics);
#define BUTTONTIME TICRATE // 1 second, in ticks.
bool P_ChangeSwitchTexture (side_t *side, int useAgain, BYTE special, bool *quest=NULL);
bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpos = NULL);
bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, const DVector3 *optpos = NULL);
//
// P_PLATS

View File

@ -112,7 +112,7 @@ static bool P_StartButton (side_t *side, int Where, FSwitchDef *Switch, fixed_t
//
//==========================================================================
bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpos)
bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, const DVector3 *optpos)
{
// Activated from an empty side -> always succeed
side_t *side = line->sidedef[sideno];
@ -135,16 +135,17 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpo
return true;
// calculate the point where the user would touch the wall.
fdivline_t dll, dlu;
fixed_t inter, checkx, checky;
divline_t dll, dlu;
double inter;
DVector2 check;
P_MakeDivline (line, &dll);
fixedvec3 pos = optpos? *optpos : user->_f_PosRelative(line);
dlu.x = pos.x;
dlu.y = pos.y;
dlu.dx = finecosine[user->_f_angle() >> ANGLETOFINESHIFT];
dlu.dy = finesine[user->_f_angle() >> ANGLETOFINESHIFT];
DVector3 pos = optpos? *optpos : user->PosRelative(line);
dlu.x = pos.X;
dlu.y = pos.Y;
dlu.dx = user->Angles.Yaw.Cos();
dlu.dy = user->Angles.Yaw.Sin();
inter = P_InterceptVector(&dll, &dlu);
@ -153,14 +154,14 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpo
{
// Get a check point slightly inside the polyobject so that this still works
// if the polyobject lies directly on a sector boundary
checkx = dll.x + FixedMul(dll.dx, inter + (FRACUNIT/100));
checky = dll.y + FixedMul(dll.dy, inter + (FRACUNIT/100));
front = P_PointInSector(checkx, checky);
check.X = dll.x + dll.dx * (inter + 0.01);
check.Y = dll.y + dll.dy * (inter + 0.01);
front = P_PointInSector(check);
}
else
{
checkx = dll.x + FixedMul(dll.dx, inter);
checky = dll.y + FixedMul(dll.dy, inter);
check.X = dll.x + dll.dx * inter;
check.Y = dll.y + dll.dy * inter;
}
@ -168,13 +169,13 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpo
if (line->sidedef[1] == NULL || (line->sidedef[0]->Flags & WALLF_POLYOBJ))
{
onesided:
fixed_t sectorc = front->ceilingplane.ZatPoint(checkx, checky);
fixed_t sectorf = front->floorplane.ZatPoint(checkx, checky);
return (user->_f_Top() >= sectorf && user->_f_Z() <= sectorc);
double sectorc = front->ceilingplane.ZatPoint(check);
double sectorf = front->floorplane.ZatPoint(check);
return (user->Top() >= sectorf && user->Z() <= sectorc);
}
// Now get the information from the line.
P_LineOpening(open, NULL, line, checkx, checky, pos.x, pos.y);
P_LineOpening(open, NULL, line, check, &pos);
if (open.range <= 0)
goto onesided;
@ -190,8 +191,8 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpo
if (!(rover->flags & FF_EXISTS)) continue;
if (!(rover->flags & FF_UPPERTEXTURE)) continue;
if (user->_f_Z() > rover->top.plane->ZatPoint(checkx, checky) ||
user->_f_Top() < rover->bottom.plane->ZatPoint(checkx, checky))
if (user->Z() > rover->top.plane->ZatPoint(check) ||
user->Top() < rover->bottom.plane->ZatPoint(check))
continue;
// This 3D floor depicts a switch texture in front of the player's eyes
@ -212,8 +213,8 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpo
if (!(rover->flags & FF_EXISTS)) continue;
if (!(rover->flags & FF_LOWERTEXTURE)) continue;
if (user->_f_Z() > rover->top.plane->ZatPoint(checkx, checky) ||
user->_f_Top() < rover->bottom.plane->ZatPoint(checkx, checky))
if (user->Z() > rover->top.plane->ZatPoint(check) ||
user->Top() < rover->bottom.plane->ZatPoint(check))
continue;
// This 3D floor depicts a switch texture in front of the player's eyes

View File

@ -355,7 +355,7 @@ bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int f
// Rotate 90 degrees, so that walking perpendicularly across
// teleporter linedef causes thing to exit in the direction
// indicated by the exit thing.
angle = VecToAngle(line->dx, line->dy) - searcher->Angles.Yaw + 90;
angle = line->Delta().Angle() - searcher->Angles.Yaw + 90.;
// Sine, cosine of angle adjustment
s = angle.Sin();
@ -457,7 +457,7 @@ bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBO
// Get the angle between the two linedefs, for rotating
// orientation and velocity. Rotate 180 degrees, and flip
// the position across the exit linedef, if reversed.
DAngle angle = VecToAngle(l->Delta()) - VecToAngle(line->Delta());
DAngle angle = l->Delta().Angle() - line->Delta().Angle();
if (!reverse)
{

View File

@ -96,7 +96,7 @@ struct FTraceInfo
{
Results->SrcFromTarget = { FIXED2DBL(StartX), FIXED2DBL(StartY), FIXED2DBL(StartZ) };
Results->HitVector = { FIXED2DBL(Vx), FIXED2DBL(Vy), FIXED2DBL(Vz) };
Results->SrcAngleFromTarget = VecToAngle(Results->HitVector);
Results->SrcAngleFromTarget = Results->HitVector.Angle();
}
@ -241,7 +241,6 @@ void FTraceInfo::EnterSectorPortal(int position, fixed_t frac, sector_t *enterse
//============================================================================
//
// traverses a line portal
// simply calling PortalRelocate does not work here because more needs to be set up
//
//============================================================================