- moved th player resurrection code into a player_t method.

This commit is contained in:
Christoph Oelckers 2017-03-28 21:29:14 +02:00
parent 71fe4a83c9
commit bdf761e457
5 changed files with 47 additions and 29 deletions

View File

@ -533,6 +533,7 @@ public:
// [Nash] set player FOV
void SetFOV(float fov);
bool HasWeaponsInSlot(int slot) const;
bool Resurrect();
};
// Bookkeeping on players - state.

View File

@ -339,35 +339,7 @@ void cht_DoCheat (player_t *player, int cheat)
}
else
{
player->mo->Revive();
player->playerstate = PST_LIVE;
player->health = player->mo->health = player->mo->GetDefault()->health;
player->viewheight = ((APlayerPawn *)player->mo->GetDefault())->ViewHeight;
player->mo->renderflags &= ~RF_INVISIBLE;
player->mo->Height = player->mo->GetDefault()->Height;
player->mo->radius = player->mo->GetDefault()->radius;
player->mo->special1 = 0; // required for the Hexen fighter's fist attack.
// This gets set by AActor::Die as flag for the wimpy death and must be reset here.
player->mo->SetState (player->mo->SpawnState);
if (!(player->mo->flags2 & MF2_DONTTRANSLATE))
{
player->mo->Translation = TRANSLATION(TRANSLATION_Players, uint8_t(player-players));
}
if (player->ReadyWeapon != nullptr)
{
P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->GetUpState());
}
if (player->morphTics)
{
P_UndoPlayerMorph(player, player);
}
// player is now alive.
// fire E_PlayerRespawned and start the ACS SCRIPT_Respawn.
E_PlayerRespawned(int(player - players));
//
FBehavior::StaticStartTypedScripts(SCRIPT_Respawn, player->mo, true);
player->Resurrect();
}
}

View File

@ -901,3 +901,4 @@ xx(Player5)
xx(Player6)
xx(Player7)
xx(Player8)
xx(PlayerChunk)

View File

@ -62,6 +62,8 @@
#include "g_levellocals.h"
#include "actorinlines.h"
#include "r_data/r_translate.h"
#include "p_acs.h"
#include "events.h"
static FRandom pr_skullpop ("SkullPop");
@ -725,6 +727,47 @@ DEFINE_ACTION_FUNCTION(_PlayerInfo, HasWeaponsInSlot)
}
bool player_t::Resurrect()
{
if (mo == nullptr || mo->IsKindOf(NAME_PlayerChunk)) return false;
mo->Revive();
playerstate = PST_LIVE;
health = mo->health = mo->GetDefault()->health;
viewheight = ((APlayerPawn *)mo->GetDefault())->ViewHeight;
mo->renderflags &= ~RF_INVISIBLE;
mo->Height = mo->GetDefault()->Height;
mo->radius = mo->GetDefault()->radius;
mo->special1 = 0; // required for the Hexen fighter's fist attack.
// This gets set by AActor::Die as flag for the wimpy death and must be reset here.
mo->SetState(mo->SpawnState);
if (!(mo->flags2 & MF2_DONTTRANSLATE))
{
mo->Translation = TRANSLATION(TRANSLATION_Players, uint8_t(this - players));
}
if (ReadyWeapon != nullptr)
{
P_SetPsprite(this, PSP_WEAPON, ReadyWeapon->GetUpState());
}
if (morphTics)
{
P_UndoPlayerMorph(this, this);
}
// player is now alive.
// fire E_PlayerRespawned and start the ACS SCRIPT_Respawn.
E_PlayerRespawned(int(this - players));
//
FBehavior::StaticStartTypedScripts(SCRIPT_Respawn, mo, true);
}
DEFINE_ACTION_FUNCTION(_PlayerInfo, Resurrect)
{
PARAM_SELF_STRUCT_PROLOGUE(player_t);
ACTION_RETURN_BOOL(self->Resurrect());
}
DEFINE_ACTION_FUNCTION(_PlayerInfo, GetUserName)
{
PARAM_SELF_STRUCT_PROLOGUE(player_t);

View File

@ -360,6 +360,7 @@ usercmd_t original_cmd;
native void SetLogText (String text);
native void DropWeapon();
native void BringUpWeapon();
native bool Resurrect();
native String GetUserName() const;
native Color GetColor() const;