mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 22:11:43 +00:00
- added parameter to PLayerPawn::GetMaxHealth to return the real maximum health, including stamina upgrades.
This commit is contained in:
parent
12915b5f6e
commit
cb295e0441
7 changed files with 14 additions and 11 deletions
|
@ -358,7 +358,7 @@ void DBot::WhatToGet (AActor *item)
|
|||
}
|
||||
else if ((typeis (Megasphere) || typeis (Soulsphere) || typeis (HealthBonus)) && player->mo->health >= deh.MaxSoulsphere)
|
||||
return;
|
||||
else if (item->IsKindOf (PClass::FindActor(NAME_Health)) && player->mo->health >= player->mo->GetMaxHealth() + player->mo->stamina)
|
||||
else if (item->IsKindOf (PClass::FindActor(NAME_Health)) && player->mo->health >= player->mo->GetMaxHealth(true))
|
||||
return;
|
||||
|
||||
if ((dest == NULL ||
|
||||
|
|
|
@ -93,7 +93,7 @@ public:
|
|||
virtual bool UpdateWaterLevel (bool splash) override;
|
||||
|
||||
bool ResetAirSupply (bool playgasp = true);
|
||||
int GetMaxHealth() const;
|
||||
int GetMaxHealth(bool withupgrades = false) const;
|
||||
void TweakSpeeds (double &forwardmove, double &sidemove);
|
||||
void MorphPlayerThink ();
|
||||
void ActivateMorphWeapon ();
|
||||
|
|
|
@ -2744,7 +2744,7 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
max = 0;
|
||||
}
|
||||
else //default to the class's health
|
||||
max = statusBar->CPlayer->mo->GetMaxHealth() + statusBar->CPlayer->mo->stamina;
|
||||
max = statusBar->CPlayer->mo->GetMaxHealth(true);
|
||||
break;
|
||||
case ARMOR:
|
||||
value = statusBar->armor != NULL ? statusBar->armor->Amount : 0;
|
||||
|
@ -3251,7 +3251,7 @@ class CommandDrawGem : public SBarInfoCommand
|
|||
void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged)
|
||||
{
|
||||
goalValue = armor ? (statusBar->armor ? statusBar->armor->Amount : 0) : statusBar->CPlayer->mo->health;
|
||||
int max = armor ? 100 : statusBar->CPlayer->mo->GetMaxHealth() + statusBar->CPlayer->mo->stamina;
|
||||
int max = armor ? 100 : statusBar->CPlayer->mo->GetMaxHealth(true);
|
||||
if(max != 0 && goalValue > 0)
|
||||
{
|
||||
goalValue = (goalValue*100)/max;
|
||||
|
|
|
@ -1330,7 +1330,7 @@ bool P_GiveBody(AActor *actor, int num, int max)
|
|||
// calls while supporting health pickups.
|
||||
if (max <= 0)
|
||||
{
|
||||
max = static_cast<APlayerPawn*>(actor)->GetMaxHealth() + player->mo->stamina;
|
||||
max = static_cast<APlayerPawn*>(actor)->GetMaxHealth(true);
|
||||
// [MH] First step in predictable generic morph effects
|
||||
if (player->morphTics)
|
||||
{
|
||||
|
|
|
@ -1350,15 +1350,18 @@ const char *APlayerPawn::GetSoundClass() const
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
int APlayerPawn::GetMaxHealth() const
|
||||
int APlayerPawn::GetMaxHealth(bool withupgrades) const
|
||||
{
|
||||
return MaxHealth > 0? MaxHealth : ((i_compatflags&COMPATF_DEHHEALTH)? 100 : deh.MaxHealth);
|
||||
int ret = MaxHealth > 0? MaxHealth : ((i_compatflags&COMPATF_DEHHEALTH)? 100 : deh.MaxHealth);
|
||||
if (withupgrades) ret += stamina;
|
||||
return ret;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(APlayerPawn, GetMaxHealth)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(APlayerPawn);
|
||||
ACTION_RETURN_INT(self->GetMaxHealth());
|
||||
PARAM_BOOL_DEF(withupgrades);
|
||||
ACTION_RETURN_INT(self->GetMaxHealth(withupgrades));
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
@ -2869,7 +2872,7 @@ void P_PlayerThink (player_t *player)
|
|||
// Apply degeneration.
|
||||
if (dmflags2 & DF2_YES_DEGENERATION)
|
||||
{
|
||||
int maxhealth = player->mo->GetMaxHealth() + player->mo->stamina;
|
||||
int maxhealth = player->mo->GetMaxHealth(true);
|
||||
if ((level.time % TICRATE) == 0 && player->health > maxhealth)
|
||||
{
|
||||
if (player->health - 5 < maxhealth)
|
||||
|
|
|
@ -166,7 +166,7 @@ class PlayerPawn : Actor native
|
|||
return -1, -1;
|
||||
}
|
||||
|
||||
native int GetMaxHealth();
|
||||
native int GetMaxHealth(bool withupgrades = false);
|
||||
native bool ResetAirSupply (bool playgasp = false);
|
||||
native void CheckWeaponSwitch(class<Inventory> item);
|
||||
native static String GetPrintableDisplayName(Class<Actor> cls);
|
||||
|
|
|
@ -76,7 +76,7 @@ extend class PlayerPawn
|
|||
}
|
||||
else
|
||||
{
|
||||
player.health = health = GetMaxHealth();
|
||||
player.health = health = GetMaxHealth(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue