Skip to content

Commit

Permalink
Added WorldHitscan to P_RailAttack
Browse files Browse the repository at this point in the history
  • Loading branch information
jekyllgrim committed Oct 28, 2024
1 parent 29a85ab commit d1ef5da
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions src/playsim/p_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d1ef5da

Please sign in to comment.