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

@ -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)
{

View file

@ -4099,9 +4099,11 @@ struct SRailHit
};
struct RailData
{
AActor *Caller;
TArray<SRailHit> 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);