- Applied a modified version of FDARI's patch to prevent giving health to dead things:
* P_GiveBody() now takes a max parameter so that it can also do the bulk of the work
AHealth::TryPickup() previously did.
* Setting an actor's health to 0 or below with SetActorProperty will now kill the actor
properly.
SVN r3438 (trunk)
This commit is contained in:
parent
6290ea4fcb
commit
977b2caa30
3 changed files with 48 additions and 69 deletions
|
|
@ -180,34 +180,43 @@ AInventory *AAmmo::CreateTossable()
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool P_GiveBody (AActor *actor, int num)
|
||||
bool P_GiveBody (AActor *actor, int num, int max)
|
||||
{
|
||||
int max;
|
||||
if (actor->health <= 0 || (actor->player != NULL && actor->player->playerstate == PST_DEAD))
|
||||
{ // Do not heal dead things.
|
||||
return false;
|
||||
}
|
||||
|
||||
player_t *player = actor->player;
|
||||
|
||||
num = clamp(num, -65536, 65536); // prevent overflows for bad values
|
||||
if (player != NULL)
|
||||
{
|
||||
max = static_cast<APlayerPawn*>(actor)->GetMaxHealth() + player->mo->stamina;
|
||||
// [MH] First step in predictable generic morph effects
|
||||
if (player->morphTics)
|
||||
{
|
||||
if (player->MorphStyle & MORPH_FULLHEALTH)
|
||||
{
|
||||
if (!(player->MorphStyle & MORPH_ADDSTAMINA))
|
||||
// Max is 0 by default, preserving default behavior for P_GiveBody()
|
||||
// calls while supporting AHealth.
|
||||
if (max <= 0)
|
||||
{
|
||||
max = static_cast<APlayerPawn*>(actor)->GetMaxHealth() + player->mo->stamina;
|
||||
// [MH] First step in predictable generic morph effects
|
||||
if (player->morphTics)
|
||||
{
|
||||
if (player->MorphStyle & MORPH_FULLHEALTH)
|
||||
{
|
||||
max -= player->mo->stamina;
|
||||
if (!(player->MorphStyle & MORPH_ADDSTAMINA))
|
||||
{
|
||||
max -= player->mo->stamina;
|
||||
}
|
||||
}
|
||||
}
|
||||
else // old health behaviour
|
||||
{
|
||||
max = MAXMORPHHEALTH;
|
||||
if (player->MorphStyle & MORPH_ADDSTAMINA)
|
||||
else // old health behaviour
|
||||
{
|
||||
max += player->mo->stamina;
|
||||
max = MAXMORPHHEALTH;
|
||||
if (player->MorphStyle & MORPH_ADDSTAMINA)
|
||||
{
|
||||
max += player->mo->stamina;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// [RH] For Strife: A negative body sets you up with a percentage
|
||||
// of your full health.
|
||||
if (num < 0)
|
||||
|
|
@ -236,6 +245,8 @@ bool P_GiveBody (AActor *actor, int num)
|
|||
}
|
||||
else
|
||||
{
|
||||
// Parameter value for max is ignored on monsters, preserving original
|
||||
// behaviour on AHealth as well as on existing calls to P_GiveBody().
|
||||
max = actor->SpawnHealth();
|
||||
if (num < 0)
|
||||
{
|
||||
|
|
@ -1475,58 +1486,16 @@ const char *AHealth::PickupMessage ()
|
|||
|
||||
bool AHealth::TryPickup (AActor *&other)
|
||||
{
|
||||
player_t *player = other->player;
|
||||
int max = MaxAmount;
|
||||
|
||||
if (player != NULL)
|
||||
PrevHealth = other->player != NULL ? other->player->health : other->health;
|
||||
|
||||
// P_GiveBody adds one new feature, applied only if it is possible to pick up negative health:
|
||||
// Negative values are treated as positive percentages, ie Amount -100 means 100% health, ignoring max amount.
|
||||
if (P_GiveBody(other, Amount, MaxAmount))
|
||||
{
|
||||
PrevHealth = other->player->health;
|
||||
if (max == 0)
|
||||
{
|
||||
max = static_cast<APlayerPawn*>(other)->GetMaxHealth() + player->mo->stamina;
|
||||
// [MH] First step in predictable generic morph effects
|
||||
if (player->morphTics)
|
||||
{
|
||||
if (player->MorphStyle & MORPH_FULLHEALTH)
|
||||
{
|
||||
if (!(player->MorphStyle & MORPH_ADDSTAMINA))
|
||||
{
|
||||
max -= player->mo->stamina;
|
||||
}
|
||||
}
|
||||
else // old health behaviour
|
||||
{
|
||||
max = MAXMORPHHEALTH;
|
||||
if (player->MorphStyle & MORPH_ADDSTAMINA)
|
||||
{
|
||||
max += player->mo->stamina;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (player->health >= max)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
player->health += Amount;
|
||||
if (player->health > max)
|
||||
{
|
||||
player->health = max;
|
||||
}
|
||||
player->mo->health = player->health;
|
||||
GoAwayAndDie();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrevHealth = INT_MAX;
|
||||
if (P_GiveBody(other, Amount))
|
||||
{
|
||||
GoAwayAndDie ();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
GoAwayAndDie ();
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
IMPLEMENT_CLASS (AHealthPickup)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue