From 9e28aeac1455a1405e0083af9d6af46c1943cc51 Mon Sep 17 00:00:00 2001 From: makise-homura Date: Thu, 20 Aug 2020 23:55:00 +0300 Subject: [PATCH] Add species parameter to A_RadiusThrust This is the last parameter for A_RadiusThrust() DECORATE function. If it is omitted or none, then A_RadiusThrust will behave as usual. If it is set for some species name, it witt thrust only that species. Of course, these species should be +VULNERABLE to be thrustable. --- src/p_local.h | 2 +- src/p_map.cpp | 7 ++++++- src/scripting/vmthunks_actors.cpp | 7 ++++--- wadsrc/static/zscript/actors/actor.zs | 2 +- wadsrc/static/zscript/actors/attacks.zs | 4 ++-- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index 39903c94c..16ba40d39 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -420,7 +420,7 @@ enum }; int P_GetRadiusDamage(AActor *self, AActor *thing, int damage, int distance, int fulldmgdistance, bool oldradiusdmg); int P_RadiusAttack (AActor *spot, AActor *source, int damage, int distance, - FName damageType, int flags, int fulldamagedistance=0); + FName damageType, int flags, int fulldamagedistance=0, FName species = NAME_None); void P_DelSeclist(msecnode_t *, msecnode_t *sector_t::*seclisthead); void P_DelSeclist(portnode_t *, portnode_t *FLinePortal::*seclisthead); diff --git a/src/p_map.cpp b/src/p_map.cpp index dd0a755cd..5292348d8 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -5890,7 +5890,7 @@ int P_GetRadiusDamage(AActor *self, AActor *thing, int damage, int distance, int //========================================================================== int P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bombdistance, FName bombmod, - int flags, int fulldamagedistance) + int flags, int fulldamagedistance, FName species) { if (bombdistance <= 0) return 0; @@ -5938,6 +5938,11 @@ int P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bom ) ) continue; + if((species != NAME_None) && (thing->Species != species)) + { + continue; + } + targets.Push(thing); } diff --git a/src/scripting/vmthunks_actors.cpp b/src/scripting/vmthunks_actors.cpp index 5f175d4ee..76861fe93 100644 --- a/src/scripting/vmthunks_actors.cpp +++ b/src/scripting/vmthunks_actors.cpp @@ -1238,9 +1238,9 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetRadiusDamage, P_GetRadiusDamage) ACTION_RETURN_INT(P_GetRadiusDamage(self, thing, damage, distance, fulldmgdistance, oldradiusdmg)); } -static int RadiusAttack(AActor *self, AActor *bombsource, int bombdamage, int bombdistance, int damagetype, int flags, int fulldamagedistance) +static int RadiusAttack(AActor *self, AActor *bombsource, int bombdamage, int bombdistance, int damagetype, int flags, int fulldamagedistance, int species) { - return P_RadiusAttack(self, bombsource, bombdamage, bombdistance, ENamedName(damagetype), flags, fulldamagedistance); + return P_RadiusAttack(self, bombsource, bombdamage, bombdistance, ENamedName(damagetype), flags, fulldamagedistance, ENamedName(species)); } DEFINE_ACTION_FUNCTION_NATIVE(AActor, RadiusAttack, RadiusAttack) @@ -1252,7 +1252,8 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, RadiusAttack, RadiusAttack) PARAM_INT(damagetype); PARAM_INT(flags); PARAM_INT(fulldamagedistance); - ACTION_RETURN_INT(RadiusAttack(self, bombsource, bombdamage, bombdistance, damagetype, flags, fulldamagedistance)); + PARAM_INT(species); + ACTION_RETURN_INT(RadiusAttack(self, bombsource, bombdamage, bombdistance, damagetype, flags, fulldamagedistance, species)); } static int ZS_GetSpriteIndex(int sprt) diff --git a/wadsrc/static/zscript/actors/actor.zs b/wadsrc/static/zscript/actors/actor.zs index c36f19046..48859454a 100644 --- a/wadsrc/static/zscript/actors/actor.zs +++ b/wadsrc/static/zscript/actors/actor.zs @@ -1110,7 +1110,7 @@ class Actor : Thinker native native void A_Burst(class chunktype); native void A_RadiusDamageSelf(int damage = 128, double distance = 128, int flags = 0, class flashtype = null); native int GetRadiusDamage(Actor thing, int damage, int distance, int fulldmgdistance = 0, bool oldradiusdmg = false); - native int RadiusAttack(Actor bombsource, int bombdamage, int bombdistance, Name bombmod = 'none', int flags = RADF_HURTSOURCE, int fulldamagedistance = 0); + native int RadiusAttack(Actor bombsource, int bombdamage, int bombdistance, Name bombmod = 'none', int flags = RADF_HURTSOURCE, int fulldamagedistance = 0, name species = "None"); native void A_Respawn(int flags = 1); native void A_RestoreSpecialPosition(); diff --git a/wadsrc/static/zscript/actors/attacks.zs b/wadsrc/static/zscript/actors/attacks.zs index bb2cdeec4..86bd07279 100644 --- a/wadsrc/static/zscript/actors/attacks.zs +++ b/wadsrc/static/zscript/actors/attacks.zs @@ -613,7 +613,7 @@ extend class Actor // //========================================================================== - void A_RadiusThrust(int force = 128, int distance = -1, int flags = RTF_AFFECTSOURCE, int fullthrustdistance = 0) + void A_RadiusThrust(int force = 128, int distance = -1, int flags = RTF_AFFECTSOURCE, int fullthrustdistance = 0, name species = "None") { if (force == 0) force = 128; if (distance <= 0) distance = abs(force); @@ -628,7 +628,7 @@ extend class Actor target.bNoDamageThrust = false; } } - RadiusAttack (target, force, distance, DamageType, flags | RADF_NODAMAGE, fullthrustdistance); + RadiusAttack (target, force, distance, DamageType, flags | RADF_NODAMAGE, fullthrustdistance, species); CheckSplash(distance); if (target) target.bNoDamageThrust = nothrust; }