NSTraceAttack: save traceline endpos and plane_normal in case it gets set elsewhere

This commit is contained in:
Marco Cawthorne 2024-02-23 13:21:44 -08:00
parent 7d58b4a96a
commit e2ee6987de
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
1 changed files with 17 additions and 12 deletions

View File

@ -140,6 +140,8 @@ void
NSTraceAttack::_FireSingle(vector vecPos, vector vecAngles, float flDamage, float flRange) NSTraceAttack::_FireSingle(vector vecPos, vector vecAngles, float flDamage, float flRange)
{ {
vector range; vector range;
vector planeNormal;
vector endPos;
if (flRange <= 0) if (flRange <= 0)
return; return;
@ -157,6 +159,8 @@ NSTraceAttack::_FireSingle(vector vecPos, vector vecAngles, float flDamage, floa
m_eOwner.hitcontentsmaski = CONTENTBITS_POINTSOLID | CONTENTBIT_CORPSE | CONTENTBIT_WATER | CONTENTBIT_SLIME | CONTENTBIT_LAVA | CONTENTBIT_PROJECTILE; m_eOwner.hitcontentsmaski = CONTENTBITS_POINTSOLID | CONTENTBIT_CORPSE | CONTENTBIT_WATER | CONTENTBIT_SLIME | CONTENTBIT_LAVA | CONTENTBIT_PROJECTILE;
traceline(vecPos, vecPos + range, MOVE_LAGGED | MOVE_HITMODEL, m_eOwner); traceline(vecPos, vecPos + range, MOVE_LAGGED | MOVE_HITMODEL, m_eOwner);
m_eOwner.hitcontentsmaski = oldhitcontents; m_eOwner.hitcontentsmaski = oldhitcontents;
planeNormal = trace_plane_normal;
endPos = trace_endpos;
flRange -= trace_plane_dist; flRange -= trace_plane_dist;
@ -170,14 +174,14 @@ NSTraceAttack::_FireSingle(vector vecPos, vector vecAngles, float flDamage, floa
/* water impact */ /* water impact */
if (trace_endcontentsi & CONTENTBIT_WATER) { if (trace_endcontentsi & CONTENTBIT_WATER) {
SurfData_ImpactOfNamedType("water", trace_endpos, trace_plane_normal); SurfData_ImpactOfNamedType("water", endPos, planeNormal);
_FireSingle(trace_endpos + (v_forward * 2), vecAngles, flDamage / 2, flRange); _FireSingle(endPos + (v_forward * 2), vecAngles, flDamage / 2, flRange);
} else if (trace_endcontentsi & CONTENTBIT_SLIME) { } else if (trace_endcontentsi & CONTENTBIT_SLIME) {
SurfData_ImpactOfNamedType("slime", trace_endpos, trace_plane_normal); SurfData_ImpactOfNamedType("slime", endPos, planeNormal);
_FireSingle(trace_endpos + (v_forward * 2), vecAngles, flDamage / 2, flRange); _FireSingle(endPos + (v_forward * 2), vecAngles, flDamage / 2, flRange);
} else if (trace_endcontentsi & CONTENTBIT_LAVA) { } else if (trace_endcontentsi & CONTENTBIT_LAVA) {
SurfData_ImpactOfNamedType("lama", trace_endpos, trace_plane_normal); SurfData_ImpactOfNamedType("lama", endPos, planeNormal);
_FireSingle(trace_endpos + (v_forward * 2), vecAngles, flDamage / 2, flRange); _FireSingle(endPos + (v_forward * 2), vecAngles, flDamage / 2, flRange);
} }
if (trace_ent.takedamage != DAMAGE_NO && trace_ent.iBleeds) { if (trace_ent.takedamage != DAMAGE_NO && trace_ent.iBleeds) {
@ -219,21 +223,22 @@ NSTraceAttack::_FireSingle(vector vecPos, vector vecAngles, float flDamage, floa
#ifdef WASTES #ifdef WASTES
player pl1 = (player)self; player pl1 = (player)self;
if (pl1.m_iWillpowerValue > 0) { if (pl1.m_iWillpowerValue > 0) {
FX_Crit(trace_endpos, vectoangles(trace_endpos - pl1.origin), 0); FX_Crit(endPos, vectoangles(endPos - pl1.origin), 0);
} }
#endif #endif
/* impact per bullet */ /* impact per bullet */
if (trace_ent.iBleeds == 0) { if (trace_ent.iBleeds == 0) {
if (m_strDecalGroup) if (m_strDecalGroup)
DecalGroups_Place(m_strDecalGroup, trace_endpos + (v_forward * -2)); DecalGroups_Place(m_strDecalGroup, endPos + (v_forward * -2));
SurfData_Impact(trace_ent, trace_endpos, trace_plane_normal); SurfData_Impact(trace_ent, endPos, planeNormal);
} }
/* combine them into one single Damage_Apply call later */ /* combine them into one single Damage_Apply call later */
if (trace_ent.takedamage != DAMAGE_NO) { if (trace_ent.takedamage != DAMAGE_NO) {
if (trace_ent != m_eMultiTarget) { if (trace_ent != m_eMultiTarget) {
trace_endpos = endPos;
_ApplyDamage(); _ApplyDamage();
m_eMultiTarget = (NSSurfacePropEntity)trace_ent; m_eMultiTarget = (NSSurfacePropEntity)trace_ent;
m_iMultiValue = flDamage; m_iMultiValue = flDamage;
@ -251,16 +256,16 @@ NSTraceAttack::_FireSingle(vector vecPos, vector vecAngles, float flDamage, floa
/* check if this wall is 6 units thick... */ /* check if this wall is 6 units thick... */
if (m_iTotalPenetrations > 0) { if (m_iTotalPenetrations > 0) {
cont = pointcontents(trace_endpos + v_forward * 5); cont = pointcontents(endPos + v_forward * 5);
if (cont == CONTENT_SOLID) if (cont == CONTENT_SOLID)
m_iTotalPenetrations -= 1; /* deduct 1 penetration power */ m_iTotalPenetrations -= 1; /* deduct 1 penetration power */
} }
cont = pointcontents(trace_endpos + v_forward * m_flMaxThickness); cont = pointcontents(endPos + v_forward * m_flMaxThickness);
if (cont == CONTENT_EMPTY) if (cont == CONTENT_EMPTY)
_FireSingle(trace_endpos + (v_forward * 2), vecAngles, flDamage / 2, flRange); _FireSingle(endPos + (v_forward * 2), vecAngles, flDamage / 2, flRange);
} }
#endif #endif
} }