- floatified P_RadiusAttack.

This commit is contained in:
Christoph Oelckers 2016-03-27 21:11:17 +02:00
parent 0baaa3cf63
commit fe744a589c

View file

@ -5043,13 +5043,12 @@ void P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bo
if (bombdistance <= 0) if (bombdistance <= 0)
return; return;
fulldamagedistance = clamp<int>(fulldamagedistance, 0, bombdistance - 1); fulldamagedistance = clamp<int>(fulldamagedistance, 0, bombdistance - 1);
fixed_t bombdistfix = bombdistance << FRACBITS;
double bombdistancefloat = 1.f / (double)(bombdistance - fulldamagedistance); double bombdistancefloat = 1. / (double)(bombdistance - fulldamagedistance);
double bombdamagefloat = (double)bombdamage; double bombdamagefloat = (double)bombdamage;
FPortalGroupArray grouplist(FPortalGroupArray::PGA_Full3d); FPortalGroupArray grouplist(FPortalGroupArray::PGA_Full3d);
FMultiBlockThingsIterator it(grouplist, bombspot->_f_X(), bombspot->_f_Y(), bombspot->_f_Z() - bombdistfix, bombspot->_f_height() + bombdistfix*2, bombdistfix, false, bombspot->Sector); FMultiBlockThingsIterator it(grouplist, bombspot->X(), bombspot->Y(), bombspot->Z() - bombdistance, bombspot->Height + bombdistance*2, bombdistancefloat, false, bombspot->Sector);
FMultiBlockThingsIterator::CheckResult cres; FMultiBlockThingsIterator::CheckResult cres;
if (flags & RADF_SOURCEISSPOT) if (flags & RADF_SOURCEISSPOT)
@ -5096,28 +5095,28 @@ void P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bo
// height of the thing and not the height of the map. // height of the thing and not the height of the map.
double points; double points;
double len; double len;
fixed_t dx, dy; double dx, dy;
double boxradius; double boxradius;
fixedvec2 vec = bombspot->_f_Vec2To(thing); DVector2 vec = bombspot->Vec2To(thing);
dx = abs(vec.x); dx = fabs(vec.X);
dy = abs(vec.y); dy = fabs(vec.Y);
boxradius = double(thing->_f_radius()); boxradius = thing->radius;
// The damage pattern is square, not circular. // The damage pattern is square, not circular.
len = double(dx > dy ? dx : dy); len = double(dx > dy ? dx : dy);
if (bombspot->_f_Z() < thing->_f_Z() || bombspot->_f_Z() >= thing->_f_Top()) if (bombspot->Z() < thing->Z() || bombspot->Z() >= thing->Top())
{ {
double dz; double dz;
if (bombspot->_f_Z() > thing->_f_Z()) if (bombspot->Z() > thing->Z())
{ {
dz = double(bombspot->_f_Z() - thing->_f_Top()); dz = double(bombspot->Z() - thing->Top());
} }
else else
{ {
dz = double(thing->_f_Z() - bombspot->_f_Z()); dz = double(thing->Z() - bombspot->Z());
} }
if (len <= boxradius) if (len <= boxradius)
{ {
@ -5135,9 +5134,8 @@ void P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bo
if (len < 0.f) if (len < 0.f)
len = 0.f; len = 0.f;
} }
len /= FRACUNIT;
len = clamp<double>(len - (double)fulldamagedistance, 0, len); len = clamp<double>(len - (double)fulldamagedistance, 0, len);
points = bombdamagefloat * (1.f - len * bombdistancefloat); points = bombdamagefloat * (1. - len * bombdistancefloat);
if (thing == bombsource) if (thing == bombsource)
{ {
points = points * splashfactor; points = points * splashfactor;
@ -5195,14 +5193,14 @@ void P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bo
else else
{ {
// [RH] Old code just for barrels // [RH] Old code just for barrels
fixed_t dx, dy, dist; double dx, dy, dist;
fixedvec2 vec = bombspot->_f_Vec2To(thing); DVector2 vec = bombspot->Vec2To(thing);
dx = abs(vec.x); dx = fabs(vec.X);
dy = abs(vec.y); dy = fabs(vec.Y);
dist = dx>dy ? dx : dy; dist = dx>dy ? dx : dy;
dist = (dist - thing->_f_radius()) >> FRACBITS; dist -= thing->radius;
if (dist < 0) if (dist < 0)
dist = 0; dist = 0;
@ -5212,8 +5210,8 @@ void P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bo
if (P_CheckSight(thing, bombspot, SF_IGNOREVISIBILITY | SF_IGNOREWATERBOUNDARY)) if (P_CheckSight(thing, bombspot, SF_IGNOREVISIBILITY | SF_IGNOREWATERBOUNDARY))
{ // OK to damage; target is in direct path { // OK to damage; target is in direct path
dist = clamp<int>(dist - fulldamagedistance, 0, dist); dist = clamp<double>(dist - fulldamagedistance, 0, dist);
int damage = Scale(bombdamage, bombdistance - dist, bombdistance); int damage = Scale(bombdamage, bombdistance - int(dist), bombdistance);
double factor = splashfactor * thing->GetClass()->RDFactor; double factor = splashfactor * thing->GetClass()->RDFactor;
damage = int(damage * factor); damage = int(damage * factor);