- scriptified PlayerPawn.ResetAirSupply.

This commit is contained in:
Christoph Oelckers 2019-01-03 13:04:48 +01:00
parent badacbb968
commit 23146f1af2
4 changed files with 34 additions and 35 deletions

View File

@ -92,7 +92,6 @@ public:
virtual void BeginPlay () override;
virtual bool UpdateWaterLevel (bool splash) override;
bool ResetAirSupply (bool playgasp = true);
int GetMaxHealth(bool withupgrades = false) const;
void GiveDeathmatchInventory ();
@ -131,15 +130,18 @@ public:
FName MorphWeapon;
double AttackZOffset; // attack height, relative to player center
double UseRange; // [NS] Distance at which player can +use
double AirCapacity; // Multiplier for air supply underwater.
// Everything below this point is only used by scripted code or through the scripted variable interface.
int RunHealth;
TObjPtr<AActor*> InvFirst; // first inventory item displayed on inventory bar
// [GRB] Player class properties
double ForwardMove1, ForwardMove2;
double SideMove1, SideMove2;
double AirCapacity; // Multiplier for air supply underwater.
double HexenArmor[5];
// [CW] Fades for when you are being damaged.
PalEntry DamageFade;

View File

@ -5045,14 +5045,18 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags)
p->multicount = 0;
p->lastkilltime = 0;
p->BlendR = p->BlendG = p->BlendB = p->BlendA = 0.f;
p->mo->ResetAirSupply(false);
p->Uncrouch();
p->MinPitch = p->MaxPitch = 0.; // will be filled in by PostBeginPlay()/netcode
p->MUSINFOactor = NULL;
p->MUSINFOtics = -1;
p->Vel.Zero(); // killough 10/98: initialize bobbing to 0.
IFVIRTUALPTR(p->mo, APlayerPawn, ResetAirSupply)
{
VMValue params[] = { p->mo, false };
VMCall(func, params, 2, nullptr, 0);
}
for (int ii = 0; ii < MAXPLAYERS; ++ii)
{
if (playeringame[ii] && players[ii].camera == oldactor)

View File

@ -1017,36 +1017,6 @@ bool APlayerPawn::UpdateWaterLevel (bool splash)
return retval;
}
//===========================================================================
//
// APlayerPawn :: ResetAirSupply
//
// Gives the player a full "tank" of air. If they had previously completely
// run out of air, also plays the *gasp sound. Returns true if the player
// was drowning.
//
//===========================================================================
bool APlayerPawn::ResetAirSupply (bool playgasp)
{
bool wasdrowning = (player->air_finished < level.time);
if (playgasp && wasdrowning)
{
S_Sound (this, CHAN_VOICE, "*gasp", 1, ATTN_NORM);
}
if (level.airsupply> 0 && player->mo->AirCapacity > 0) player->air_finished = level.time + int(level.airsupply * player->mo->AirCapacity);
else player->air_finished = INT_MAX;
return wasdrowning;
}
DEFINE_ACTION_FUNCTION(APlayerPawn, ResetAirSupply)
{
PARAM_SELF_PROLOGUE(APlayerPawn);
PARAM_BOOL(playgasp);
ACTION_RETURN_BOOL(self->ResetAirSupply(playgasp));
}
//===========================================================================
//
// Animations

View File

@ -2317,6 +2317,30 @@ class PlayerPawn : Actor native
return painFlash;
}
//===========================================================================
//
// APlayerPawn :: ResetAirSupply
//
// Gives the player a full "tank" of air. If they had previously completely
// run out of air, also plays the *gasp sound. Returns true if the player
// was drowning.
//
//===========================================================================
virtual bool ResetAirSupply (bool playgasp = true)
{
let player = self.player;
bool wasdrowning = (player.air_finished < level.time);
if (playgasp && wasdrowning)
{
A_PlaySound("*gasp", CHAN_VOICE);
}
if (level.airsupply > 0 && AirCapacity > 0) player.air_finished = level.time + int(level.airsupply * AirCapacity);
else player.air_finished = int.max;
return wasdrowning;
}
//----------------------------------------------------------------------------
//
//
@ -2324,7 +2348,6 @@ class PlayerPawn : Actor native
//----------------------------------------------------------------------------
native clearscope int GetMaxHealth(bool withupgrades = false) const;
native bool ResetAirSupply (bool playgasp = true);
native clearscope static String GetPrintableDisplayName(Class<Actor> cls);
native void CheckMusicChange();
native void CheckEnvironment();