- floatification of p_enemy and p_interaction.cpp.

This commit is contained in:
Christoph Oelckers 2016-03-26 20:59:35 +01:00
commit 00ea8662b8
7 changed files with 143 additions and 156 deletions

View file

@ -85,11 +85,11 @@ FName MeansOfDeath;
//
void P_TouchSpecialThing (AActor *special, AActor *toucher)
{
fixed_t delta = special->_f_Z() - toucher->_f_Z();
double delta = special->Z() - toucher->Z();
// The pickup is at or above the toucher's feet OR
// The pickup is below the toucher.
if (delta > toucher->_f_height() || delta < MIN(-32*FRACUNIT, -special->_f_height()))
if (delta > toucher->Height || delta < MIN(-32., -special->Height))
{ // out of reach
return;
}
@ -931,7 +931,7 @@ int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage,
{
DAngle ang;
player_t *player = NULL;
fixed_t thrust;
double thrust;
int temp;
int painchance = 0;
FState * woundstate = NULL;
@ -1163,27 +1163,21 @@ int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage,
ang = origin->AngleTo(target);
}
// Calculate this as float to avoid overflows so that the
// clamping that had to be done here can be removed.
double fltthrust;
fltthrust = mod == NAME_MDK ? 10 : 32;
thrust = mod == NAME_MDK ? 10 : 32;
if (target->Mass > 0)
{
fltthrust = clamp((damage * 0.125 * kickback) / target->Mass, 0., fltthrust);
thrust = clamp((damage * 0.125 * kickback) / target->Mass, 0., thrust);
}
thrust = FLOAT2FIXED(fltthrust);
// Don't apply ultra-small damage thrust
if (thrust < FRACUNIT/100) thrust = 0;
if (thrust < 0.01) thrust = 0;
// make fall forwards sometimes
if ((damage < 40) && (damage > target->health)
&& (target->Z() - origin->Z() > 64)
&& (pr_damagemobj()&1)
// [RH] But only if not too fast and not flying
&& thrust < 10*FRACUNIT
&& thrust < 10
&& !(target->flags & MF_NOGRAVITY)
&& (inflictor == NULL || !(inflictor->flags5 & MF5_NOFORWARDFALL))
)
@ -1204,7 +1198,7 @@ int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage,
}
else
{
target->Thrust(ang, FIXED2DBL(thrust));
target->Thrust(ang, thrust);
}
}
}