mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-06-04 19:10:59 +00:00
- scriptified the health items.
This commit is contained in:
parent
917b36c6ae
commit
9f9cea4b4a
9 changed files with 471 additions and 215 deletions
110
src/p_mobj.cpp
110
src/p_mobj.cpp
|
@ -73,6 +73,7 @@
|
|||
#include "a_ammo.h"
|
||||
#include "a_health.h"
|
||||
#include "g_levellocals.h"
|
||||
#include "a_morph.h"
|
||||
|
||||
// MACROS ------------------------------------------------------------------
|
||||
|
||||
|
@ -1318,6 +1319,115 @@ DEFINE_ACTION_FUNCTION(AActor, ObtainInventory)
|
|||
self->ObtainInventory(other);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// FUNC P_GiveBody
|
||||
//
|
||||
// Returns false if the body isn't needed at all.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool P_GiveBody(AActor *actor, int num, 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 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)
|
||||
{
|
||||
if (!(player->MorphStyle & MORPH_ADDSTAMINA))
|
||||
{
|
||||
max -= player->mo->stamina;
|
||||
}
|
||||
}
|
||||
else // old health behaviour
|
||||
{
|
||||
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)
|
||||
{
|
||||
num = max * -num / 100;
|
||||
if (player->health < num)
|
||||
{
|
||||
player->health = num;
|
||||
actor->health = num;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (num > 0)
|
||||
{
|
||||
if (player->health < max)
|
||||
{
|
||||
num = int(num * G_SkillProperty(SKILLP_HealthFactor));
|
||||
if (num < 1) num = 1;
|
||||
player->health += num;
|
||||
if (player->health > max)
|
||||
{
|
||||
player->health = max;
|
||||
}
|
||||
actor->health = player->health;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
num = max * -num / 100;
|
||||
if (actor->health < num)
|
||||
{
|
||||
actor->health = num;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (actor->health < max)
|
||||
{
|
||||
actor->health += num;
|
||||
if (actor->health > max)
|
||||
{
|
||||
actor->health = max;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(AActor, GiveBody)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
PARAM_INT(num);
|
||||
PARAM_INT_DEF(max);
|
||||
ACTION_RETURN_BOOL(P_GiveBody(self, num, max));
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// AActor :: CheckLocalView
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue