From 9a09fbd7edd92edb0e2e30f945fe308ea8e11acb Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Mon, 2 Mar 2015 12:01:40 -0600 Subject: [PATCH] Added MTHRUSPECIES support for rails and sprays. --- src/g_doom/a_doomweaps.cpp | 20 ++++++++++++++------ src/p_map.cpp | 17 ++++++++++++++--- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/g_doom/a_doomweaps.cpp b/src/g_doom/a_doomweaps.cpp index 898bf7c5b..05e1677c6 100644 --- a/src/g_doom/a_doomweaps.cpp +++ b/src/g_doom/a_doomweaps.cpp @@ -610,19 +610,27 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray) // offset angles from its attack angle for (i = 0; i < numrays; i++) { - an = self->angle - angle/2 + angle/numrays*i; + an = self->angle - angle / 2 + angle / numrays*i; // self->target is the originator (player) of the missile - P_AimLineAttack (self->target, an, distance, &linetarget, vrange); + P_AimLineAttack(self->target, an, distance, &linetarget, vrange); if (!linetarget) continue; - AActor *spray = Spawn (spraytype, linetarget->x, linetarget->y, - linetarget->z + (linetarget->height>>2), ALLOW_REPLACE); + AActor *spray = Spawn(spraytype, linetarget->x, linetarget->y, + linetarget->z + (linetarget->height >> 2), ALLOW_REPLACE); - if (spray && (spray->flags5 & MF5_PUFFGETSOWNER)) - spray->target = self->target; + if (spray) + { + if (spray->flags6 & MF6_MTHRUSPECIES && spray->GetSpecies() == linetarget->GetSpecies()) + { + spray->Destroy(); // [MC] Remove it because technically, the spray isn't trying to "hit" them. + continue; + } + if (spray->flags5 & MF5_PUFFGETSOWNER) + spray->target = self->target; + } if (defdamage == 0) { diff --git a/src/p_map.cpp b/src/p_map.cpp index 29d7a728f..013c647f0 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -4099,9 +4099,11 @@ struct SRailHit }; struct RailData { + AActor *Caller; TArray RailHits; bool StopAtOne; bool StopAtInvul; + bool ThruSpecies; }; static ETraceStatus ProcessRailHit(FTraceResults &res, void *userdata) @@ -4118,6 +4120,12 @@ static ETraceStatus ProcessRailHit(FTraceResults &res, void *userdata) return TRACE_Stop; } + // Skip actors with the same species if the puff has MTHRUSPECIES. + if (data->ThruSpecies && res.Actor->GetSpecies() == data->Caller->GetSpecies()) + { + return TRACE_Skip; + } + // Save this thing for damaging later, and continue the trace SRailHit newhit; newhit.HitActor = res.Actor; @@ -4172,7 +4180,8 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i y1 += offset_xy * finesine[angle]; RailData rail_data; - + rail_data.Caller = source; + rail_data.StopAtOne = !!(railflags & RAF_NOPIERCE); start.X = FIXED2FLOAT(x1); start.Y = FIXED2FLOAT(y1); @@ -4185,7 +4194,7 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i flags = (puffDefaults->flags6 & MF6_NOTRIGGER) ? 0 : TRACE_PCross | TRACE_Impact; rail_data.StopAtInvul = (puffDefaults->flags3 & MF3_FOILINVUL) ? false : true; - + rail_data.ThruSpecies = (puffDefaults->flags6 & MF6_MTHRUSPECIES) ? true : false; Trace(x1, y1, shootz, source->Sector, vx, vy, vz, distance, MF_SHOOTABLE, ML_BLOCKEVERYTHING, source, trace, flags, ProcessRailHit, &rail_data); @@ -4201,13 +4210,15 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i for (i = 0; i < rail_data.RailHits.Size(); i++) { + + fixed_t x, y, z; bool spawnpuff; bool bleed = false; int puffflags = PF_HITTHING; AActor *hitactor = rail_data.RailHits[i].HitActor; - fixed_t hitdist = rail_data.RailHits[i].Distance; + fixed_t hitdist = rail_data.RailHits[i].Distance; x = x1 + FixedMul(hitdist, vx); y = y1 + FixedMul(hitdist, vy);