Updated explosion distances from int -> double

This commit is contained in:
Boondorl 2024-03-21 16:31:07 -04:00 committed by Rachael Alexanderson
parent 442ac3f78b
commit 96594e0f34
8 changed files with 42 additions and 42 deletions

View file

@ -448,11 +448,11 @@ static void PGRA_InsertIfCloser(TMap<int, pgra_data_t>& damageGroupPos, int grou
EXTERN_CVAR(Float, splashfactor);
void P_GeometryRadiusAttack(AActor* bombspot, AActor* bombsource, int bombdamage, int bombdistance, FName damagetype, int fulldamagedistance)
void P_GeometryRadiusAttack(AActor* bombspot, AActor* bombsource, int bombdamage, double bombdistance, FName damagetype, double fulldamagedistance)
{
TMap<int, pgra_data_t> damageGroupPos;
double bombdistancefloat = 1. / (double)(bombdistance - fulldamagedistance);
double bombdistancefloat = 1.0 / (bombdistance - fulldamagedistance);
// now, this is not entirely correct... but sector actions still _do_ require a valid source actor to trigger anything
if (!bombspot)
@ -588,8 +588,8 @@ void P_GeometryRadiusAttack(AActor* bombspot, AActor* bombsource, int bombdamage
int damage = 0;
if (dst < bombdistance)
{
dst = clamp<double>(dst - (double)fulldamagedistance, 0, dst);
damage = (int)((double)bombdamage * (1. - dst * bombdistancefloat));
dst = clamp<double>(dst - fulldamagedistance, 0.0, dst);
damage = (int)((double)bombdamage * (1.0 - dst * bombdistancefloat));
if (bombsource == bombspot)
damage = (int)(damage * splashfactor);
}
@ -661,8 +661,8 @@ void P_GeometryRadiusAttack(AActor* bombspot, AActor* bombsource, int bombdamage
int damage = 0;
if (dst < bombdistance)
{
dst = clamp<double>(dst - (double)fulldamagedistance, 0, dst);
damage = (int)((double)bombdamage * (1. - dst * bombdistancefloat));
dst = clamp<double>(dst - fulldamagedistance, 0.0, dst);
damage = (int)((double)bombdamage * (1.0 - dst * bombdistancefloat));
if (bombsource == bombspot)
damage = (int)(damage * splashfactor);
}
@ -950,9 +950,9 @@ DEFINE_ACTION_FUNCTION(FDestructible, GeometryRadiusAttack)
PARAM_OBJECT(bombspot, AActor);
PARAM_OBJECT(bombsource, AActor);
PARAM_INT(bombdamage);
PARAM_INT(bombdistance);
PARAM_FLOAT(bombdistance);
PARAM_NAME(damagetype);
PARAM_INT(fulldamagedistance);
PARAM_FLOAT(fulldamagedistance);
P_GeometryRadiusAttack(bombspot, bombsource, bombdamage, bombdistance, damagetype, fulldamagedistance);
return 0;
}

View file

@ -34,7 +34,7 @@ void P_DamageSector(sector_t* sector, AActor* source, int damage, FName damagety
void P_DamageLinedef(line_t* line, AActor* source, int damage, FName damagetype, int side, DVector3 position, bool isradius, bool dogroups);
void P_GeometryLineAttack(FTraceResults& trace, AActor* thing, int damage, FName damageType);
void P_GeometryRadiusAttack(AActor* bombspot, AActor* bombsource, int bombdamage, int bombdistance, FName damagetype, int fulldamagedistance);
void P_GeometryRadiusAttack(AActor* bombspot, AActor* bombsource, int bombdamage, double bombdistance, FName damagetype, double fulldamagedistance);
bool P_ProjectileHitLinedef(AActor* projectile, line_t* line);
bool P_ProjectileHitPlane(AActor* projectile, int part);

View file

@ -410,9 +410,9 @@ enum
RADF_NOALLIES = 128,
RADF_CIRCULAR = 256
};
int P_GetRadiusDamage(AActor *self, AActor *thing, int damage, int distance, int fulldmgdistance, bool oldradiusdmg, bool circular);
int P_RadiusAttack (AActor *spot, AActor *source, int damage, int distance,
FName damageType, int flags, int fulldamagedistance=0, FName species = NAME_None);
int P_GetRadiusDamage(AActor *self, AActor *thing, int damage, double distance, double fulldmgdistance, bool oldradiusdmg, bool circular);
int P_RadiusAttack (AActor *spot, AActor *source, int damage, double distance,
FName damageType, int flags, double fulldamagedistance=0.0, FName species = NAME_None);
void P_DelSeclist(msecnode_t *, msecnode_t *sector_t::*seclisthead);
void P_DelSeclist(portnode_t *, portnode_t *FLinePortal::*seclisthead);

View file

@ -5949,7 +5949,7 @@ CUSTOM_CVAR(Float, splashfactor, 1.f, CVAR_SERVERINFO)
// Used by anything without OLDRADIUSDMG flag
//==========================================================================
static double GetRadiusDamage(bool fromaction, AActor *bombspot, AActor *thing, int bombdamage, int bombdistance, int fulldamagedistance, bool thingbombsource, bool round)
static double GetRadiusDamage(bool fromaction, AActor *bombspot, AActor *thing, int bombdamage, double bombdistance, double fulldamagedistance, bool thingbombsource, bool round)
{
// [RH] New code. The bounding box only covers the
// height of the thing and not the height of the map.
@ -5958,7 +5958,7 @@ static double GetRadiusDamage(bool fromaction, AActor *bombspot, AActor *thing,
double dx, dy;
double boxradius;
double bombdistancefloat = 1. / (double)(bombdistance - fulldamagedistance);
double bombdistancefloat = 1.0 / (bombdistance - fulldamagedistance);
double bombdamagefloat = (double)bombdamage;
if (!round)
@ -6005,8 +6005,8 @@ static double GetRadiusDamage(bool fromaction, AActor *bombspot, AActor *thing,
{
len = bombspot->Distance3D (thing);
}
len = clamp<double>(len - (double)fulldamagedistance, 0, len);
points = bombdamagefloat * (1. - len * bombdistancefloat);
len = clamp<double>(len - fulldamagedistance, 0.0, len);
points = bombdamagefloat * (1.0 - len * bombdistancefloat);
// Calculate the splash and radius damage factor if called by P_RadiusAttack.
// Otherwise, just get the raw damage. This allows modders to manipulate it
@ -6034,7 +6034,7 @@ static double GetRadiusDamage(bool fromaction, AActor *bombspot, AActor *thing,
// based on XY distance.
//==========================================================================
static int GetOldRadiusDamage(bool fromaction, AActor *bombspot, AActor *thing, int bombdamage, int bombdistance, int fulldamagedistance)
static int GetOldRadiusDamage(bool fromaction, AActor *bombspot, AActor *thing, int bombdamage, double bombdistance, double fulldamagedistance)
{
const int ret = fromaction ? 0 : -1; // -1 is specifically for P_RadiusAttack; continue onto another actor.
double dx, dy, dist;
@ -6055,8 +6055,8 @@ static int GetOldRadiusDamage(bool fromaction, AActor *bombspot, AActor *thing,
// When called from the action function, ignore the sight check.
if (fromaction || P_CheckSight(thing, bombspot, SF_IGNOREVISIBILITY | SF_IGNOREWATERBOUNDARY))
{
dist = clamp<double>(dist - fulldamagedistance, 0, dist);
int damage = Scale(bombdamage, bombdistance - int(dist), bombdistance);
dist = clamp<double>(dist - fulldamagedistance, 0.0, dist);
int damage = (int)Scale((double)bombdamage, bombdistance - dist, bombdistance);
if (!fromaction)
{
@ -6078,7 +6078,7 @@ static int GetOldRadiusDamage(bool fromaction, AActor *bombspot, AActor *thing,
// damage and not taking into account any damage reduction.
//==========================================================================
int P_GetRadiusDamage(AActor *self, AActor *thing, int damage, int distance, int fulldmgdistance, bool oldradiusdmg, bool circular)
int P_GetRadiusDamage(AActor *self, AActor *thing, int damage, double distance, double fulldmgdistance, bool oldradiusdmg, bool circular)
{
if (!thing)
@ -6090,10 +6090,10 @@ int P_GetRadiusDamage(AActor *self, AActor *thing, int damage, int distance, int
return damage;
}
fulldmgdistance = clamp<int>(fulldmgdistance, 0, distance - 1);
fulldmgdistance = clamp<double>(fulldmgdistance, 0.0, distance - 1.0);
// Mirroring A_Explode's behavior.
if (distance <= 0)
if (distance <= 0.0)
distance = damage;
const int newdam = oldradiusdmg
@ -6110,15 +6110,15 @@ 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, FName species)
int P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, double bombdistance, FName bombmod,
int flags, double fulldamagedistance, FName species)
{
if (bombdistance <= 0)
if (bombdistance <= 0.0)
return 0;
fulldamagedistance = clamp<int>(fulldamagedistance, 0, bombdistance - 1);
fulldamagedistance = clamp<double>(fulldamagedistance, 0.0, bombdistance - 1.0);
FPortalGroupArray grouplist(FPortalGroupArray::PGA_Full3d);
FMultiBlockThingsIterator it(grouplist, bombspot->Level, bombspot->X(), bombspot->Y(), bombspot->Z() - bombdistance, bombspot->Height + bombdistance*2, bombdistance, false, bombspot->Sector);
FMultiBlockThingsIterator it(grouplist, bombspot->Level, bombspot->X(), bombspot->Y(), bombspot->Z() - bombdistance, bombspot->Height + bombdistance*2.0, bombdistance, false, bombspot->Sector);
FMultiBlockThingsIterator::CheckResult cres;
if (flags & RADF_SOURCEISSPOT)

View file

@ -1317,14 +1317,14 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetRadiusDamage, P_GetRadiusDamage)
PARAM_SELF_PROLOGUE(AActor);
PARAM_OBJECT(thing, AActor);
PARAM_INT(damage);
PARAM_INT(distance);
PARAM_INT(fulldmgdistance);
PARAM_FLOAT(distance);
PARAM_FLOAT(fulldmgdistance);
PARAM_BOOL(oldradiusdmg);
PARAM_BOOL(circular);
ACTION_RETURN_INT(P_GetRadiusDamage(self, thing, damage, distance, fulldmgdistance, oldradiusdmg, circular));
}
static int RadiusAttack(AActor *self, AActor *bombsource, int bombdamage, int bombdistance, int damagetype, int flags, int fulldamagedistance, int species)
static int RadiusAttack(AActor *self, AActor *bombsource, int bombdamage, double bombdistance, int damagetype, int flags, double fulldamagedistance, int species)
{
return P_RadiusAttack(self, bombsource, bombdamage, bombdistance, ENamedName(damagetype), flags, fulldamagedistance, ENamedName(species));
}
@ -1334,10 +1334,10 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, RadiusAttack, RadiusAttack)
PARAM_SELF_PROLOGUE(AActor);
PARAM_OBJECT(bombsource, AActor);
PARAM_INT(bombdamage);
PARAM_INT(bombdistance);
PARAM_FLOAT(bombdistance);
PARAM_INT(damagetype);
PARAM_INT(flags);
PARAM_INT(fulldamagedistance);
PARAM_FLOAT(fulldamagedistance);
PARAM_INT(species);
ACTION_RETURN_INT(RadiusAttack(self, bombsource, bombdamage, bombdistance, damagetype, flags, fulldamagedistance, species));
}

View file

@ -273,7 +273,7 @@ class Actor : Thinker native
meta Name BloodType2; // Bloopsplatter replacement type
meta Name BloodType3; // AxeBlood replacement type
meta bool DontHurtShooter;
meta int ExplosionRadius;
meta double ExplosionRadius;
meta int ExplosionDamage;
meta int MeleeDamage;
meta Sound MeleeSound;
@ -432,7 +432,7 @@ class Actor : Thinker native
DefThreshold 100;
BloodType "Blood", "BloodSplatter", "AxeBlood";
ExplosionDamage 128;
ExplosionRadius -1; // i.e. use ExplosionDamage value
ExplosionRadius -1.0; // i.e. use ExplosionDamage value
MissileHeight 32;
SpriteAngle 0;
SpriteRotation 0;
@ -1226,9 +1226,9 @@ class Actor : Thinker native
native void A_CustomMeleeAttack(int damage = 0, sound meleesound = "", sound misssound = "", name damagetype = "none", bool bleed = true);
native void A_CustomComboAttack(class<Actor> missiletype, double spawnheight, int damage, sound meleesound = "", name damagetype = "none", bool bleed = true);
native void A_Burst(class<Actor> chunktype);
native void A_RadiusDamageSelf(int damage = 128, double distance = 128, int flags = 0, class<Actor> flashtype = null);
native int GetRadiusDamage(Actor thing, int damage, int distance, int fulldmgdistance = 0, bool oldradiusdmg = false, bool circular = false);
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_RadiusDamageSelf(int damage = 128, double distance = 128.0, int flags = 0, class<Actor> flashtype = null);
native int GetRadiusDamage(Actor thing, int damage, double distance, double fulldmgdistance = 0.0, bool oldradiusdmg = false, bool circular = false);
native int RadiusAttack(Actor bombsource, int bombdamage, double bombdistance, Name bombmod = 'none', int flags = RADF_HURTSOURCE, double fulldamagedistance = 0.0, name species = "None");
native void A_Respawn(int flags = 1);
native void A_RestoreSpecialPosition();

View file

@ -569,7 +569,7 @@ extend class Actor
//
//==========================================================================
int A_Explode(int damage = -1, int distance = -1, int flags = XF_HURTSOURCE, bool alert = false, int fulldamagedistance = 0, int nails = 0, int naildamage = 10, class<Actor> pufftype = "BulletPuff", name damagetype = "none")
int A_Explode(int damage = -1, double distance = -1.0, int flags = XF_HURTSOURCE, bool alert = false, double fulldamagedistance = 0.0, int nails = 0, int naildamage = 10, class<Actor> pufftype = "BulletPuff", name damagetype = "none")
{
if (damage < 0) // get parameters from metadata
@ -626,7 +626,7 @@ extend class Actor
}
deprecated("2.3", "For Dehacked use only")
void A_RadiusDamage(int dam, int dist)
void A_RadiusDamage(int dam, double dist)
{
A_Explode(dam, dist);
}
@ -637,10 +637,10 @@ extend class Actor
//
//==========================================================================
void A_RadiusThrust(int force = 128, int distance = -1, int flags = RTF_AFFECTSOURCE, int fullthrustdistance = 0, name species = "None")
void A_RadiusThrust(int force = 128, double distance = -1.0, int flags = RTF_AFFECTSOURCE, double fullthrustdistance = 0.0, name species = "None")
{
if (force == 0) force = 128;
if (distance <= 0) distance = abs(force);
if (distance <= 0.0) distance = abs(force);
bool nothrust = false;
if (target)

View file

@ -28,7 +28,7 @@ struct Destructible native play
static native void DamageLinedef(Line def, Actor source, int damage, Name damagetype, int side, vector3 position, bool isradius);
static native void GeometryLineAttack(TraceResults trace, Actor thing, int damage, Name damagetype);
static native void GeometryRadiusAttack(Actor bombspot, Actor bombsource, int bombdamage, int bombdistance, Name damagetype, int fulldamagedistance);
static native void GeometryRadiusAttack(Actor bombspot, Actor bombsource, int bombdamage, double bombdistance, Name damagetype, double fulldamagedistance);
static native bool ProjectileHitLinedef(Actor projectile, Line def);
static native bool ProjectileHitPlane(Actor projectile, SectorPart part);