From 481ef7a5b588ce90d7454f6ec57bd021372ef8a6 Mon Sep 17 00:00:00 2001 From: Xaser Acheron Date: Fri, 10 Jun 2016 21:38:55 -0500 Subject: [PATCH] added SMMU-BFG11k-style 'damrad' property to A_BFGSpray --- src/g_doom/a_doomweaps.cpp | 35 +++++++++++++++++++++++++++++++++- wadsrc/static/actors/actor.txt | 2 +- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/g_doom/a_doomweaps.cpp b/src/g_doom/a_doomweaps.cpp index 95ce63342..f985e6ed5 100644 --- a/src/g_doom/a_doomweaps.cpp +++ b/src/g_doom/a_doomweaps.cpp @@ -653,6 +653,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray) PARAM_ANGLE_OPT (vrange) { vrange = 0.; } PARAM_INT_OPT (defdamage) { defdamage = 0; } PARAM_INT_OPT (flags) { flags = 0; } + PARAM_FLOAT_OPT (damrad) { damrad = 0; } int i; int j; @@ -660,6 +661,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray) DAngle an; FTranslatedLineTarget t; AActor *originator; + double origdist; if (spraytype == NULL) spraytype = PClass::FindActor("BFGExtra"); if (numrays <= 0) numrays = 40; @@ -672,7 +674,38 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray) if (!self->target) return 0; - // [XA] Set the originator of the attack to the projectile (self) if + // [XA] If damrad is set, check the originator and hurt them if too close. + // adapted from SMMU's BFG11K code with fraggle's blessing. + origdist = self->Distance2D(self->target); + if (origdist < damrad) + { + // [XA] Decrease damage with distance. This uses SMMU's formula + // and is included mainly for emulation's sake. For more + // customization, seek out A_Explode rather than this. + damage = 0; + for (j = 0; j < (damrad / 2) - (origdist / 2); ++j) + damage += (pr_bfgspray() & 7) + 1; + + // [XA] flash n' damage -- some slight copypasta here, but it works. + AActor *spray = Spawn(spraytype, self->target->PosPlusZ(self->target->Height / 4), ALLOW_REPLACE); + + int dmgFlags = 0; + FName dmgType = NAME_BFGSplash; + + if (spray != NULL) + { + // [XA] skip the species check since we've already decided to damage oneself. + if (spray->flags5 & MF5_PUFFGETSOWNER) spray->target = self->target; + if (spray->flags3 & MF3_FOILINVUL) dmgFlags |= DMG_FOILINVUL; + if (spray->flags7 & MF7_FOILBUDDHA) dmgFlags |= DMG_FOILBUDDHA; + dmgType = spray->DamageType; + } + + int selfdam = P_DamageMobj(self->target, self, self->target, damage, dmgType, dmgFlags); + P_TraceBleed(selfdam > 0 ? selfdam : damage, self->target, self); + } + + // [XA] Set the originator of the rays to the projectile (self) if // the new flag is set, else set it to the player (self->target) originator = (flags & BFGF_MISSILEORIGIN) ? self : self->target; diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 7e4319690..103d8be5b 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -56,7 +56,7 @@ ACTOR Actor native //: Thinker // End of MBF redundant functions. action native A_MonsterRail(); - action native A_BFGSpray(class spraytype = "BFGExtra", int numrays = 40, int damagecount = 15, float/*angle*/ angle = 90, float distance = 16*64, float/*angle*/ vrange = 32, int damage = 0, int flags = 0); + action native A_BFGSpray(class spraytype = "BFGExtra", int numrays = 40, int damagecount = 15, float/*angle*/ angle = 90, float distance = 16*64, float/*angle*/ vrange = 32, int damage = 0, int flags = 0, float damrad = 0); action native A_Pain(); action native A_NoBlocking(); action native A_XScream();