- floatified the return data from Trace().
This commit is contained in:
parent
70d87f94f2
commit
2dbd79cc8d
17 changed files with 105 additions and 108 deletions
|
|
@ -4219,7 +4219,7 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance,
|
|||
}
|
||||
if (puffDefaults != NULL && puffDefaults->flags3 & MF3_ALWAYSPUFF)
|
||||
{ // Spawn the puff anyway
|
||||
puff = P_SpawnPuff(t1, pufftype, trace.HitPos, trace.SrcAngleToTarget, trace.SrcAngleToTarget, 2, puffFlags);
|
||||
puff = P_SpawnPuff(t1, pufftype, trace.HitPos, trace.SrcAngleFromTarget, trace.SrcAngleFromTarget, 2, puffFlags);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -4233,9 +4233,9 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance,
|
|||
// position a bit closer for puffs
|
||||
if (trace.HitType != TRACE_HitWall || trace.Line->special != Line_Horizon)
|
||||
{
|
||||
fixedvec2 pos = P_GetOffsetPosition(trace.HitPos.x, trace.HitPos.y, -trace.HitVector.x * 4, -trace.HitVector.y * 4);
|
||||
puff = P_SpawnPuff(t1, pufftype, { pos.x, pos.y, trace.HitPos.z - trace.HitVector.z * 4 }, trace.SrcAngleToTarget,
|
||||
trace.SrcAngleToTarget - ANGLE_90, 0, puffFlags);
|
||||
DVector2 pos = P_GetOffsetPosition(trace.HitPos.X, trace.HitPos.Y, -trace.HitVector.X * 4, -trace.HitVector.Y * 4);
|
||||
puff = P_SpawnPuff(t1, pufftype, DVector3(pos, trace.HitPos.Z - trace.HitVector.Z * 4), trace.SrcAngleFromTarget,
|
||||
trace.SrcAngleFromTarget - 90, 0, puffFlags);
|
||||
puff->radius = 1/65536.;
|
||||
}
|
||||
|
||||
|
|
@ -4283,16 +4283,15 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance,
|
|||
(t1->player->ReadyWeapon->WeaponFlags & WIF_AXEBLOOD));
|
||||
|
||||
// Hit a thing, so it could be either a puff or blood
|
||||
fixedvec3 bleedpos = trace.HitPos;
|
||||
DVector3 bleedpos = trace.HitPos;
|
||||
// position a bit closer for puffs/blood if using compatibility mode.
|
||||
if (i_compatflags & COMPATF_HITSCAN)
|
||||
{
|
||||
fixedvec2 ofs = P_GetOffsetPosition(bleedpos.x, bleedpos.y, -10 * trace.HitVector.x, -10 * trace.HitVector.y);
|
||||
bleedpos.x = ofs.x;
|
||||
bleedpos.y = ofs.y;
|
||||
bleedpos.z -= -10 * trace.HitVector.z;
|
||||
DVector2 ofs = P_GetOffsetPosition(bleedpos.X, bleedpos.Y, -10 * trace.HitVector.X, -10 * trace.HitVector.Y);
|
||||
bleedpos.X = ofs.X;
|
||||
bleedpos.Y = ofs.Y;
|
||||
bleedpos.Z -= -10 * trace.HitVector.Z;
|
||||
}
|
||||
DVector3 bleedposf(FIXED2DBL(bleedpos.x), FIXED2DBL(bleedpos.y), FIXED2DBL(bleedpos.z));
|
||||
|
||||
// Spawn bullet puffs or blood spots, depending on target type.
|
||||
if ((puffDefaults != NULL && puffDefaults->flags3 & MF3_PUFFONACTORS) ||
|
||||
|
|
@ -4303,7 +4302,7 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance,
|
|||
puffFlags |= PF_HITTHINGBLEED;
|
||||
|
||||
// We must pass the unreplaced puff type here
|
||||
puff = P_SpawnPuff(t1, pufftype, bleedpos, trace.SrcAngleToTarget, trace.SrcAngleToTarget - ANGLE_90, 2, puffFlags | PF_HITTHING, trace.Actor);
|
||||
puff = P_SpawnPuff(t1, pufftype, bleedpos, trace.SrcAngleFromTarget, trace.SrcAngleFromTarget - 90, 2, puffFlags | PF_HITTHING, trace.Actor);
|
||||
}
|
||||
|
||||
// Allow puffs to inflict poison damage, so that hitscans can poison, too.
|
||||
|
|
@ -4329,10 +4328,10 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance,
|
|||
{
|
||||
// Since the puff is the damage inflictor we need it here
|
||||
// regardless of whether it is displayed or not.
|
||||
puff = P_SpawnPuff(t1, pufftype, bleedpos, 0, 0, 2, puffFlags | PF_HITTHING | PF_TEMPORARY);
|
||||
puff = P_SpawnPuff(t1, pufftype, bleedpos, 0., 0., 2, puffFlags | PF_HITTHING | PF_TEMPORARY);
|
||||
killPuff = true;
|
||||
}
|
||||
newdam = P_DamageMobj(trace.Actor, puff ? puff : t1, t1, damage, damageType, dmgflags|DMG_USEANGLE, ANGLE2DBL(trace.SrcAngleToTarget));
|
||||
newdam = P_DamageMobj(trace.Actor, puff ? puff : t1, t1, damage, damageType, dmgflags|DMG_USEANGLE, trace.SrcAngleFromTarget);
|
||||
if (actualdamage != NULL)
|
||||
{
|
||||
*actualdamage = newdam;
|
||||
|
|
@ -4344,7 +4343,7 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance,
|
|||
!(trace.Actor->flags & MF_NOBLOOD) &&
|
||||
!(trace.Actor->flags2 & (MF2_INVULNERABLE | MF2_DORMANT)))
|
||||
{
|
||||
P_SpawnBlood(bleedposf, ANGLE2DBL(trace.SrcAngleToTarget), newdam > 0 ? newdam : damage, trace.Actor);
|
||||
P_SpawnBlood(bleedpos, trace.SrcAngleFromTarget, newdam > 0 ? newdam : damage, trace.Actor);
|
||||
}
|
||||
|
||||
if (damage)
|
||||
|
|
@ -4356,23 +4355,22 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance,
|
|||
{
|
||||
if (axeBlood)
|
||||
{
|
||||
P_BloodSplatter2(bleedposf, trace.Actor, ANGLE2DBL(trace.SrcAngleToTarget));
|
||||
P_BloodSplatter2(bleedpos, trace.Actor, trace.SrcAngleFromTarget);
|
||||
}
|
||||
if (pr_lineattack() < 192)
|
||||
{
|
||||
P_BloodSplatter(bleedposf, trace.Actor, ANGLE2DBL(trace.SrcAngleToTarget));
|
||||
P_BloodSplatter(bleedpos, trace.Actor, trace.SrcAngleFromTarget);
|
||||
}
|
||||
}
|
||||
}
|
||||
// [RH] Stick blood to walls
|
||||
P_TraceBleed(newdam > 0 ? newdam : damage, trace.HitPos,
|
||||
trace.Actor, trace.SrcAngleToTarget, srcpitch);
|
||||
P_TraceBleed(newdam > 0 ? newdam : damage, trace.HitPos, trace.Actor, trace.SrcAngleFromTarget, ANGLE2DBL(srcpitch));
|
||||
}
|
||||
}
|
||||
if (victim != NULL)
|
||||
{
|
||||
victim->linetarget = trace.Actor;
|
||||
victim->angleFromSource = ANGLE2DBL(trace.SrcAngleToTarget);
|
||||
victim->angleFromSource = trace.SrcAngleFromTarget;
|
||||
victim->unlinked = trace.unlinked;
|
||||
}
|
||||
}
|
||||
|
|
@ -4380,7 +4378,7 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance,
|
|||
{
|
||||
if (puff == NULL)
|
||||
{ // Spawn puff just to get a mass for the splash
|
||||
puff = P_SpawnPuff(t1, pufftype, trace.HitPos, 0, 0, 2, puffFlags | PF_HITTHING | PF_TEMPORARY);
|
||||
puff = P_SpawnPuff(t1, pufftype, trace.HitPos, 0., 0., 2, puffFlags | PF_HITTHING | PF_TEMPORARY);
|
||||
killPuff = true;
|
||||
}
|
||||
SpawnDeepSplash(t1, trace, puff);
|
||||
|
|
@ -4539,8 +4537,7 @@ void P_TraceBleed(int damage, fixed_t x, fixed_t y, fixed_t z, AActor *actor, an
|
|||
bloodcolor.a = 1;
|
||||
}
|
||||
|
||||
DVector3 hp(FIXED2DBL(bleedtrace.HitPos.x), FIXED2DBL(bleedtrace.HitPos.y), FIXED2DBL(bleedtrace.HitPos.z));
|
||||
DImpactDecal::StaticCreate(bloodType, hp,
|
||||
DImpactDecal::StaticCreate(bloodType, bleedtrace.HitPos,
|
||||
bleedtrace.Line->sidedef[bleedtrace.Side], bleedtrace.ffloor, bloodcolor);
|
||||
}
|
||||
}
|
||||
|
|
@ -4629,8 +4626,8 @@ void P_TraceBleed(int damage, AActor *target)
|
|||
struct SRailHit
|
||||
{
|
||||
AActor *HitActor;
|
||||
fixedvec3 HitPos;
|
||||
angle_t HitAngle;
|
||||
DVector3 HitPos;
|
||||
DAngle HitAngle;
|
||||
};
|
||||
struct RailData
|
||||
{
|
||||
|
|
@ -4665,13 +4662,13 @@ static ETraceStatus ProcessRailHit(FTraceResults &res, void *userdata)
|
|||
SRailHit newhit;
|
||||
newhit.HitActor = res.Actor;
|
||||
newhit.HitPos = res.HitPos;
|
||||
newhit.HitAngle = res.SrcAngleToTarget;
|
||||
newhit.HitAngle = res.SrcAngleFromTarget;
|
||||
if (i_compatflags & COMPATF_HITSCAN)
|
||||
{
|
||||
fixedvec2 ofs = P_GetOffsetPosition(newhit.HitPos.x, newhit.HitPos.y, -10 * res.HitVector.x, -10 * res.HitVector.y);
|
||||
newhit.HitPos.x = ofs.x;
|
||||
newhit.HitPos.y = ofs.y;
|
||||
newhit.HitPos.z -= -10 * res.HitVector.z;
|
||||
DVector2 ofs = P_GetOffsetPosition(newhit.HitPos.X, newhit.HitPos.Y, -10 * res.HitVector.X, -10 * res.HitVector.Y);
|
||||
newhit.HitPos.X = ofs.X;
|
||||
newhit.HitPos.Y = ofs.Y;
|
||||
newhit.HitPos.Z -= -10 * res.HitVector.Z;
|
||||
}
|
||||
data->RailHits.Push(newhit);
|
||||
|
||||
|
|
@ -4759,8 +4756,8 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i
|
|||
|
||||
int puffflags = PF_HITTHING;
|
||||
AActor *hitactor = rail_data.RailHits[i].HitActor;
|
||||
fixedvec3 &hitpos = rail_data.RailHits[i].HitPos;
|
||||
angle_t hitangle = rail_data.RailHits[i].HitAngle;
|
||||
DVector3 &hitpos = rail_data.RailHits[i].HitPos;
|
||||
DAngle hitangle = rail_data.RailHits[i].HitAngle;
|
||||
|
||||
if ((hitactor->flags & MF_NOBLOOD) ||
|
||||
(hitactor->flags2 & MF2_DORMANT || ((hitactor->flags2 & MF2_INVULNERABLE) && !(puffDefaults->flags3 & MF3_FOILINVUL))))
|
||||
|
|
@ -4778,7 +4775,7 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i
|
|||
}
|
||||
if (spawnpuff)
|
||||
{
|
||||
P_SpawnPuff(source, puffclass, hitpos, trace.SrcAngleToTarget, trace.SrcAngleToTarget - ANGLE_90, 1, puffflags, hitactor);
|
||||
P_SpawnPuff(source, puffclass, hitpos, hitangle, hitangle - 90, 1, puffflags, hitactor);
|
||||
}
|
||||
|
||||
int dmgFlagPass = DMG_INFLICTOR_IS_PUFF;
|
||||
|
|
@ -4791,13 +4788,12 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i
|
|||
if (puffDefaults->flags3 & MF3_FOILINVUL) dmgFlagPass |= DMG_FOILINVUL;
|
||||
if (puffDefaults->flags7 & MF7_FOILBUDDHA) dmgFlagPass |= DMG_FOILBUDDHA;
|
||||
}
|
||||
int newdam = P_DamageMobj(hitactor, thepuff ? thepuff : source, source, damage, damagetype, dmgFlagPass|DMG_USEANGLE, ANGLE2DBL(hitangle));
|
||||
int newdam = P_DamageMobj(hitactor, thepuff ? thepuff : source, source, damage, damagetype, dmgFlagPass|DMG_USEANGLE, hitangle);
|
||||
|
||||
if (bleed)
|
||||
{
|
||||
DVector3 h(FIXED2DBL(hitpos.x), FIXED2DBL(hitpos.y), FIXED2DBL(hitpos.z));
|
||||
P_SpawnBlood(h, ANGLE2DBL(hitangle), newdam > 0 ? newdam : damage, hitactor);
|
||||
P_TraceBleed(newdam > 0 ? newdam : damage, hitpos, hitactor, source->_f_angle(), pitch);
|
||||
P_SpawnBlood(hitpos, hitangle, newdam > 0 ? newdam : damage, hitactor);
|
||||
P_TraceBleed(newdam > 0 ? newdam : damage, hitpos, hitactor, hitangle, ANGLE2DBL(pitch));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4808,7 +4804,7 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i
|
|||
|
||||
if (puffclass != NULL && puffDefaults->flags3 & MF3_ALWAYSPUFF)
|
||||
{
|
||||
puff = P_SpawnPuff(source, puffclass, trace.HitPos, trace.SrcAngleToTarget, trace.SrcAngleToTarget - ANGLE_90, 1, 0);
|
||||
puff = P_SpawnPuff(source, puffclass, trace.HitPos, trace.SrcAngleFromTarget, trace.SrcAngleFromTarget - 90, 1, 0);
|
||||
if (puff && (trace.Line != NULL) && (trace.Line->special == Line_Horizon) && !(puff->flags3 & MF3_SKYEXPLODE))
|
||||
puff->Destroy();
|
||||
}
|
||||
|
|
@ -4823,7 +4819,7 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i
|
|||
AActor* puff = NULL;
|
||||
if (puffclass != NULL && puffDefaults->flags3 & MF3_ALWAYSPUFF)
|
||||
{
|
||||
puff = P_SpawnPuff(source, puffclass, trace.HitPos, trace.SrcAngleToTarget, trace.SrcAngleToTarget - ANGLE_90, 1, 0);
|
||||
puff = P_SpawnPuff(source, puffclass, trace.HitPos, trace.SrcAngleFromTarget, trace.SrcAngleFromTarget - 90, 1, 0);
|
||||
if (puff && !(puff->flags3 & MF3_SKYEXPLODE) &&
|
||||
(((trace.HitType == TRACE_HitFloor) && (puff->floorpic == skyflatnum)) ||
|
||||
((trace.HitType == TRACE_HitCeiling) && (puff->ceilingpic == skyflatnum))))
|
||||
|
|
@ -4846,9 +4842,7 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i
|
|||
}
|
||||
|
||||
// Draw the slug's trail.
|
||||
end.X = FIXED2DBL(trace.HitPos.x);
|
||||
end.Y = FIXED2DBL(trace.HitPos.y);
|
||||
end.Z = FIXED2DBL(trace.HitPos.z);
|
||||
end = trace.HitPos;
|
||||
P_DrawRailTrail(source, start, end, color1, color2, maxdiff, railflags, spawnclass, source->_f_angle() + angleoffset, duration, sparsity, drift, SpiralOffset);
|
||||
}
|
||||
|
||||
|
|
@ -4861,7 +4855,7 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i
|
|||
CVAR(Float, chase_height, -8.f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
CVAR(Float, chase_dist, 90.f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
|
||||
void P_AimCamera(AActor *t1, fixed_t &CameraX, fixed_t &CameraY, fixed_t &CameraZ, sector_t *&CameraSector, bool &unlinked)
|
||||
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;
|
||||
|
|
@ -4873,23 +4867,21 @@ void P_AimCamera(AActor *t1, fixed_t &CameraX, fixed_t &CameraY, fixed_t &Camera
|
|||
vy = FixedMul(finecosine[pitch], finesine[angle]);
|
||||
vz = finesine[pitch];
|
||||
|
||||
DVector3 vvec(vx, vy, vz);
|
||||
vvec.MakeUnit();
|
||||
|
||||
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) &&
|
||||
trace.Distance > 10 * FRACUNIT)
|
||||
trace.Distance > 10)
|
||||
{
|
||||
// Position camera slightly in front of hit thing
|
||||
fixed_t dist = trace.Distance - 5 * FRACUNIT;
|
||||
CameraX = t1->_f_X() + FixedMul(vx, dist);
|
||||
CameraY = t1->_f_Y() + FixedMul(vy, dist);
|
||||
CameraZ = sz + FixedMul(vz, dist);
|
||||
campos = t1->PosAtZ(FIXED2DBL(sz)) + vvec *(trace.Distance - 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
CameraX = trace.HitPos.x;
|
||||
CameraY = trace.HitPos.y;
|
||||
CameraZ = trace.HitPos.z;
|
||||
campos = trace.HitPos;
|
||||
}
|
||||
CameraSector = trace.Sector;
|
||||
unlinked = trace.unlinked;
|
||||
|
|
@ -6418,9 +6410,8 @@ void SpawnShootDecal(AActor *t1, const FTraceResults &trace)
|
|||
}
|
||||
if (decalbase != NULL)
|
||||
{
|
||||
DVector3 hp(FIXED2DBL(trace.HitPos.x), FIXED2DBL(trace.HitPos.y), FIXED2DBL(trace.HitPos.z));
|
||||
DImpactDecal::StaticCreate(decalbase->GetDecal(),
|
||||
hp, trace.Line->sidedef[trace.Side], trace.ffloor);
|
||||
trace.HitPos, trace.Line->sidedef[trace.Side], trace.ffloor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -6432,7 +6423,7 @@ void SpawnShootDecal(AActor *t1, const FTraceResults &trace)
|
|||
|
||||
static void SpawnDeepSplash(AActor *t1, const FTraceResults &trace, AActor *puff)
|
||||
{
|
||||
const fixedvec3 *hitpos;
|
||||
const DVector3 *hitpos;
|
||||
if (trace.Crossed3DWater)
|
||||
{
|
||||
hitpos = &trace.Crossed3DWaterPos;
|
||||
|
|
@ -6443,7 +6434,7 @@ static void SpawnDeepSplash(AActor *t1, const FTraceResults &trace, AActor *puff
|
|||
}
|
||||
else return;
|
||||
|
||||
P_HitWater(puff != NULL ? puff : t1, P_PointInSector(hitpos->x, hitpos->y), *hitpos);
|
||||
P_HitWater(puff != NULL ? puff : t1, P_PointInSector(*hitpos), *hitpos);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue