- beautification of A_BFGSpray.

Reordered checks so that only one 'spray != NULL' is needed, removed redundant thingToHit variable and reformatted slightly.
This commit is contained in:
Christoph Oelckers 2015-03-27 09:25:26 +01:00
parent 66c3c93529
commit c78fdae31d

View file

@ -584,7 +584,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray)
int j; int j;
int damage; int damage;
angle_t an; angle_t an;
AActor *thingToHit;
AActor *linetarget; AActor *linetarget;
ACTION_PARAM_START(7); ACTION_PARAM_START(7);
@ -615,21 +614,25 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray)
// self->target is the originator (player) of the missile // 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) if (linetarget != NULL)
continue; {
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) int dmgFlags = 0;
FName dmgType = NAME_BFGSplash;
if (spray != NULL)
{ {
if (spray->flags6 & MF6_MTHRUSPECIES && spray->GetSpecies() == linetarget->GetSpecies()) if (spray->flags6 & MF6_MTHRUSPECIES && spray->GetSpecies() == linetarget->GetSpecies())
{ {
spray->Destroy(); // [MC] Remove it because technically, the spray isn't trying to "hit" them. spray->Destroy(); // [MC] Remove it because technically, the spray isn't trying to "hit" them.
continue; continue;
} }
if (spray->flags5 & MF5_PUFFGETSOWNER) if (spray->flags5 & MF5_PUFFGETSOWNER) spray->target = self->target;
spray->target = self->target; if (spray->flags3 & MF3_FOILINVUL) dmgFlags |= DMG_FOILINVUL;
if (spray->flags7 & MF7_FOILBUDDHA) dmgFlags |= DMG_FOILBUDDHA;
dmgType = spray->DamageType;
} }
if (defdamage == 0) if (defdamage == 0)
@ -644,13 +647,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray)
damage = defdamage; damage = defdamage;
} }
int dmgFlagPass = 0; int newdam = P_DamageMobj(linetarget, self->target, self->target, damage, dmgType, dmgFlags);
dmgFlagPass += (spray != NULL && (spray->flags3 & MF3_FOILINVUL)) ? DMG_FOILINVUL : 0; //[MC]Because the original foilinvul wasn't working. P_TraceBleed(newdam > 0 ? newdam : damage, linetarget, self->target);
dmgFlagPass += (spray != NULL && (spray->flags7 & MF7_FOILBUDDHA)) ? DMG_FOILBUDDHA : 0; }
thingToHit = linetarget;
int newdam = P_DamageMobj (thingToHit, self->target, self->target, damage, spray != NULL? FName(spray->DamageType) : FName(NAME_BFGSplash),
dmgFlagPass);
P_TraceBleed (newdam > 0 ? newdam : damage, thingToHit, self->target);
} }
} }