- Exhumed: Give runlist_CheckRadialDamage() a bit of a tidy.

This commit is contained in:
Mitchell Richters 2023-04-25 19:44:15 +10:00
parent ece41ac84c
commit 0a6ff79f4f

View file

@ -1747,8 +1747,7 @@ int runlist_CheckRadialDamage(DExhumedActor* pActor)
return 0;
}
auto pos = (pActor->spr.pos - pRadialActor->spr.pos) / 16.;
const auto pos = (pActor->spr.pos - pRadialActor->spr.pos) * (1. / 16.);
if (abs(pos.X) > nDamageRadius) {
return 0;
@ -1763,27 +1762,19 @@ int runlist_CheckRadialDamage(DExhumedActor* pActor)
}
double nDist = pos.XY().Length();
double nPush = 0;
int edi = 0;
if (nDist < nDamageRadius)
{
auto nCStat = pActor->spr.cstat;
pActor->spr.cstat = CSTAT_SPRITE_BLOCK_ALL;
if (((kStatExplodeTarget - pActor->spr.statnum) <= 1) ||
cansee(pRadialActor->spr.pos.plusZ(-2),
pRadialActor->sector(),
pActor->spr.pos.plusZ(-32),
pActor->sector()))
cansee(pRadialActor->spr.pos.plusZ(-2), pRadialActor->sector(), pActor->spr.pos.plusZ(-32), pActor->sector()))
{
edi = int((nRadialDamage * (nDamageRadius - nDist)) / nDamageRadius);
if (edi < 0) {
edi = 0;
}
else if (edi > 20)
if ((nPush = max((nRadialDamage * (nDamageRadius - nDist)) / nDamageRadius, 0.)) > 20)
{
const auto nVel = DVector3(pos.Angle().ToVector() * 128., -24 * (1. / 256.)) * edi;
const auto nVel = DVector3(pos.Angle().ToVector() * 128., -24 * (1. / 256.)) * nPush;
pActor->vel.Z += nVel.Z;
if (pActor->vel.Z < -14)
@ -1803,11 +1794,7 @@ int runlist_CheckRadialDamage(DExhumedActor* pActor)
pActor->spr.cstat = nCStat;
}
if (edi > 0x7FFF) {
edi = 0x7FFF;
}
return edi;
return min((int)nPush, 0x7FFF);
}
//---------------------------------------------------------------------------