Added MTHRUSPECIES support for rails and sprays.

This commit is contained in:
MajorCooke 2015-03-02 12:01:40 -06:00 committed by Christoph Oelckers
parent b6ca1947ff
commit 9a09fbd7ed
2 changed files with 28 additions and 9 deletions

View file

@ -621,8 +621,16 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray)
AActor *spray = Spawn(spraytype, linetarget->x, linetarget->y, AActor *spray = Spawn(spraytype, linetarget->x, linetarget->y,
linetarget->z + (linetarget->height >> 2), ALLOW_REPLACE); linetarget->z + (linetarget->height >> 2), ALLOW_REPLACE);
if (spray && (spray->flags5 & MF5_PUFFGETSOWNER)) 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; spray->target = self->target;
}
if (defdamage == 0) if (defdamage == 0)
{ {

View file

@ -4099,9 +4099,11 @@ struct SRailHit
}; };
struct RailData struct RailData
{ {
AActor *Caller;
TArray<SRailHit> RailHits; TArray<SRailHit> RailHits;
bool StopAtOne; bool StopAtOne;
bool StopAtInvul; bool StopAtInvul;
bool ThruSpecies;
}; };
static ETraceStatus ProcessRailHit(FTraceResults &res, void *userdata) static ETraceStatus ProcessRailHit(FTraceResults &res, void *userdata)
@ -4118,6 +4120,12 @@ static ETraceStatus ProcessRailHit(FTraceResults &res, void *userdata)
return TRACE_Stop; 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 // Save this thing for damaging later, and continue the trace
SRailHit newhit; SRailHit newhit;
newhit.HitActor = res.Actor; newhit.HitActor = res.Actor;
@ -4172,6 +4180,7 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i
y1 += offset_xy * finesine[angle]; y1 += offset_xy * finesine[angle];
RailData rail_data; RailData rail_data;
rail_data.Caller = source;
rail_data.StopAtOne = !!(railflags & RAF_NOPIERCE); rail_data.StopAtOne = !!(railflags & RAF_NOPIERCE);
start.X = FIXED2FLOAT(x1); start.X = FIXED2FLOAT(x1);
@ -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; flags = (puffDefaults->flags6 & MF6_NOTRIGGER) ? 0 : TRACE_PCross | TRACE_Impact;
rail_data.StopAtInvul = (puffDefaults->flags3 & MF3_FOILINVUL) ? false : true; 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, Trace(x1, y1, shootz, source->Sector, vx, vy, vz,
distance, MF_SHOOTABLE, ML_BLOCKEVERYTHING, source, trace, distance, MF_SHOOTABLE, ML_BLOCKEVERYTHING, source, trace,
flags, ProcessRailHit, &rail_data); flags, ProcessRailHit, &rail_data);
@ -4201,6 +4210,8 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i
for (i = 0; i < rail_data.RailHits.Size(); i++) for (i = 0; i < rail_data.RailHits.Size(); i++)
{ {
fixed_t x, y, z; fixed_t x, y, z;
bool spawnpuff; bool spawnpuff;
bool bleed = false; bool bleed = false;