diff --git a/src/playsim/p_map.cpp b/src/playsim/p_map.cpp index c976792a8b6..359c91dce09 100644 --- a/src/playsim/p_map.cpp +++ b/src/playsim/p_map.cpp @@ -5393,16 +5393,30 @@ static ETraceStatus ProcessRailHit(FTraceResults &res, void *userdata) //========================================================================== void P_RailAttack(FRailParams *p) { - DVector3 start; - FTraceResults trace; + AActor *source = p->source; PClassActor *puffclass = p->puff; if (puffclass == NULL) { puffclass = PClass::FindActor(NAME_BulletPuff); } + assert(puffclass != NULL); // Because we set it to a default above + AActor *puffDefaults = GetDefaultByType(puffclass->GetReplacement(source->Level)); //Contains all the flags such as FOILINVUL, etc. + FName damagetype = (puffDefaults == NULL || puffDefaults->DamageType == NAME_None) ? FName(NAME_Railgun) : puffDefaults->DamageType; + + int flags; + + // disabled because not complete yet. + flags = (puffDefaults->flags6 & MF6_NOTRIGGER) ? TRACE_ReportPortals : TRACE_PCross | TRACE_Impact | TRACE_ReportPortals; + + if (source->Level->localEventManager->WorldHitscanPreFired(source, source->Angles.Yaw + p->angleoffset, p->distance, source->Angles.Pitch + p->pitchoffset, p->damage, damagetype, puffclass, flags, p->offset_z, 0, p->offset_xy)) + { + return; + } + + DVector3 start; + FTraceResults trace; - AActor *source = p->source; DAngle pitch = source->Angles.Pitch + p->pitchoffset; DAngle angle = source->Angles.Yaw + p->angleoffset; @@ -5431,13 +5445,6 @@ void P_RailAttack(FRailParams *p) start.Y = xy.Y; start.Z = shootz; - int flags; - - assert(puffclass != NULL); // Because we set it to a default above - AActor *puffDefaults = GetDefaultByType(puffclass->GetReplacement(source->Level)); //Contains all the flags such as FOILINVUL, etc. - - // disabled because not complete yet. - flags = (puffDefaults->flags6 & MF6_NOTRIGGER) ? TRACE_ReportPortals : TRACE_PCross | TRACE_Impact | TRACE_ReportPortals; rail_data.StopAtInvul = (puffDefaults->flags3 & MF3_FOILINVUL) ? false : true; rail_data.MThruSpecies = ((puffDefaults->flags6 & MF6_MTHRUSPECIES)) ? true : false; @@ -5474,8 +5481,7 @@ void P_RailAttack(FRailParams *p) // Hurt anything the trace hit unsigned int i; - FName damagetype = (puffDefaults == NULL || puffDefaults->DamageType == NAME_None) ? FName(NAME_Railgun) : puffDefaults->DamageType; - + for (i = 0; i < rail_data.RailHits.Size(); i++) { bool spawnpuff; @@ -5563,6 +5569,9 @@ void P_RailAttack(FRailParams *p) } } } + + source->Level->localEventManager->WorldHitscanFired(source, start, trace.HitPos, thepuff, flags); + if (thepuff != NULL) { if (trace.Crossed3DWater || trace.CrossedWater)