mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-22 20:11:17 +00:00
- backported Zandronum's MaxHealth base class for the MaxHealthBonus item.
This commit is contained in:
parent
00dc59ebdc
commit
b194ba205a
6 changed files with 39 additions and 6 deletions
|
@ -125,6 +125,8 @@ public:
|
|||
|
||||
int crouchsprite;
|
||||
int MaxHealth;
|
||||
int BonusHealth;
|
||||
|
||||
int MugShotMaxHealth;
|
||||
int RunHealth;
|
||||
int PlayerFlags;
|
||||
|
|
|
@ -1330,7 +1330,7 @@ static int CheckInventory (AActor *activator, const char *type, bool max)
|
|||
if (max)
|
||||
{
|
||||
if (activator->IsKindOf (RUNTIME_CLASS (APlayerPawn)))
|
||||
return static_cast<APlayerPawn *>(activator)->MaxHealth;
|
||||
return static_cast<APlayerPawn *>(activator)->GetMaxHealth();
|
||||
else
|
||||
return activator->SpawnHealth();
|
||||
}
|
||||
|
@ -3939,7 +3939,7 @@ int DLevelScript::GetActorProperty (int tid, int property)
|
|||
case APROP_Dormant: return !!(actor->flags2 & MF2_DORMANT);
|
||||
case APROP_SpawnHealth: if (actor->IsKindOf (RUNTIME_CLASS (APlayerPawn)))
|
||||
{
|
||||
return static_cast<APlayerPawn *>(actor)->MaxHealth;
|
||||
return static_cast<APlayerPawn *>(actor)->GetMaxHealth();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1340,7 +1340,7 @@ bool P_GiveBody(AActor *actor, int num, int max)
|
|||
{
|
||||
if (!(player->MorphStyle & MORPH_ADDSTAMINA))
|
||||
{
|
||||
max -= player->mo->stamina;
|
||||
max -= player->mo->stamina + player->mo->BonusHealth;
|
||||
}
|
||||
}
|
||||
else // old health behaviour
|
||||
|
@ -1348,7 +1348,7 @@ bool P_GiveBody(AActor *actor, int num, int max)
|
|||
max = MAXMORPHHEALTH;
|
||||
if (player->MorphStyle & MORPH_ADDSTAMINA)
|
||||
{
|
||||
max += player->mo->stamina;
|
||||
max += player->mo->stamina + player->mo->BonusHealth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -781,6 +781,7 @@ void APlayerPawn::Serialize(FSerializer &arc)
|
|||
|
||||
arc("jumpz", JumpZ, def->JumpZ)
|
||||
("maxhealth", MaxHealth, def->MaxHealth)
|
||||
("bonushealth", BonusHealth, def->BonusHealth)
|
||||
("runhealth", RunHealth, def->RunHealth)
|
||||
("spawnmask", SpawnMask, def->SpawnMask)
|
||||
("forwardmove1", ForwardMove1, def->ForwardMove1)
|
||||
|
@ -1353,7 +1354,7 @@ const char *APlayerPawn::GetSoundClass() const
|
|||
int APlayerPawn::GetMaxHealth(bool withupgrades) const
|
||||
{
|
||||
int ret = MaxHealth > 0? MaxHealth : ((i_compatflags&COMPATF_DEHHEALTH)? 100 : deh.MaxHealth);
|
||||
if (withupgrades) ret += stamina;
|
||||
if (withupgrades) ret += stamina + BonusHealth;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -3345,6 +3346,7 @@ bool P_IsPlayerTotallyFrozen(const player_t *player)
|
|||
|
||||
DEFINE_FIELD(APlayerPawn, crouchsprite)
|
||||
DEFINE_FIELD(APlayerPawn, MaxHealth)
|
||||
DEFINE_FIELD(APlayerPawn, BonusHealth)
|
||||
DEFINE_FIELD(APlayerPawn, MugShotMaxHealth)
|
||||
DEFINE_FIELD(APlayerPawn, RunHealth)
|
||||
DEFINE_FIELD(APlayerPawn, PlayerFlags)
|
||||
|
|
|
@ -86,8 +86,36 @@ class Health : Inventory
|
|||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class MaxHealth : Health
|
||||
{
|
||||
//===========================================================================
|
||||
//
|
||||
// TryPickup
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
override bool TryPickup (in out Actor other)
|
||||
{
|
||||
bool success = false;
|
||||
int savedAmount = MaxAmount;
|
||||
let player = PlayerPawn(other);
|
||||
MaxAmount = Health;
|
||||
if (player)
|
||||
{
|
||||
if (player.BonusHealth < savedAmount)
|
||||
{
|
||||
player.BonusHealth = min(player.BonusHealth + Amount, savedAmount);
|
||||
success = true;
|
||||
}
|
||||
MaxAmount += player.BonusHealth;
|
||||
}
|
||||
success |= Super.TryPickup(other);
|
||||
MaxAmount = saved;
|
||||
if (success) GoAwayAndDie();
|
||||
return success;
|
||||
}
|
||||
}
|
||||
|
||||
class HealthPickup : Inventory
|
||||
|
|
|
@ -3,6 +3,7 @@ class PlayerPawn : Actor native
|
|||
|
||||
native int crouchsprite;
|
||||
native int MaxHealth;
|
||||
native int BonusHealth;
|
||||
native int MugShotMaxHealth;
|
||||
native int RunHealth;
|
||||
native int PlayerFlags;
|
||||
|
|
Loading…
Reference in a new issue