- add 'playerrespawn' skill flag to allow gameplay mods to retroactively enable player respawns in single player on all maps

This commit is contained in:
Rachael Alexanderson 2017-12-28 00:53:30 -05:00
parent 10465c1d27
commit 45531090a7
5 changed files with 15 additions and 2 deletions

View file

@ -1743,7 +1743,8 @@ static void G_QueueBody (AActor *body)
EXTERN_CVAR(Bool, sv_singleplayerrespawn) EXTERN_CVAR(Bool, sv_singleplayerrespawn)
void G_DoReborn (int playernum, bool freshbot) void G_DoReborn (int playernum, bool freshbot)
{ {
if (!multiplayer && !(level.flags2 & LEVEL2_ALLOWRESPAWN) && !sv_singleplayerrespawn) if (!multiplayer && !(level.flags2 & LEVEL2_ALLOWRESPAWN) && !sv_singleplayerrespawn &&
!G_SkillProperty(SKILLP_PlayerRespawn))
{ {
if (BackupSaveName.Len() > 0 && FileExists (BackupSaveName.GetChars())) if (BackupSaveName.Len() > 0 && FileExists (BackupSaveName.GetChars()))
{ // Load game from the last point it was saved { // Load game from the last point it was saved

View file

@ -538,6 +538,7 @@ enum ESkillProperty
SKILLP_EasyKey, SKILLP_EasyKey,
SKILLP_SlowMonsters, SKILLP_SlowMonsters,
SKILLP_Infight, SKILLP_Infight,
SKILLP_PlayerRespawn,
}; };
enum EFSkillProperty // floating point properties enum EFSkillProperty // floating point properties
{ {
@ -595,6 +596,7 @@ struct FSkillInfo
double FriendlyHealth; double FriendlyHealth;
bool NoPain; bool NoPain;
int Infighting; int Infighting;
bool PlayerRespawn;
FSkillInfo() {} FSkillInfo() {}
FSkillInfo(const FSkillInfo &other) FSkillInfo(const FSkillInfo &other)

View file

@ -89,6 +89,7 @@ void FMapInfoParser::ParseSkill ()
skill.FriendlyHealth = 1.; skill.FriendlyHealth = 1.;
skill.NoPain = false; skill.NoPain = false;
skill.Infighting = 0; skill.Infighting = 0;
skill.PlayerRespawn = false;
sc.MustGetString(); sc.MustGetString();
skill.Name = sc.String; skill.Name = sc.String;
@ -155,6 +156,10 @@ void FMapInfoParser::ParseSkill ()
{ {
skill.NoMenu = true; skill.NoMenu = true;
} }
else if (sc.Compare ("playerrespawn"))
{
skill.PlayerRespawn = true;
}
else if (sc.Compare("respawntime")) else if (sc.Compare("respawntime"))
{ {
ParseAssign(); ParseAssign();
@ -397,6 +402,9 @@ int G_SkillProperty(ESkillProperty prop)
if (AllSkills[gameskill].Infighting == LEVEL2_TOTALINFIGHTING) return 1; if (AllSkills[gameskill].Infighting == LEVEL2_TOTALINFIGHTING) return 1;
if (AllSkills[gameskill].Infighting == LEVEL2_NOINFIGHTING) return -1; if (AllSkills[gameskill].Infighting == LEVEL2_NOINFIGHTING) return -1;
return infighting; return infighting;
case SKILLP_PlayerRespawn:
return AllSkills[gameskill].PlayerRespawn;
} }
} }
return 0; return 0;

View file

@ -5648,7 +5648,8 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags)
{ // Give all cards in death match mode. { // Give all cards in death match mode.
p->mo->GiveDeathmatchInventory (); p->mo->GiveDeathmatchInventory ();
} }
else if ((multiplayer || (level.flags2 & LEVEL2_ALLOWRESPAWN) || sv_singleplayerrespawn) && state == PST_REBORN && oldactor != NULL) else if ((multiplayer || (level.flags2 & LEVEL2_ALLOWRESPAWN) || sv_singleplayerrespawn ||
!!G_SkillProperty(SKILLP_PlayerRespawn)) && state == PST_REBORN && oldactor != NULL)
{ // Special inventory handling for respawning in coop { // Special inventory handling for respawning in coop
p->mo->FilterCoopRespawnInventory (oldactor); p->mo->FilterCoopRespawnInventory (oldactor);
} }

View file

@ -962,6 +962,7 @@ enum ESkillProperty
SKILLP_EasyKey, SKILLP_EasyKey,
SKILLP_SlowMonsters, SKILLP_SlowMonsters,
SKILLP_Infight, SKILLP_Infight,
SKILLP_PlayerRespawn,
}; };
enum EFSkillProperty // floating point properties enum EFSkillProperty // floating point properties
{ {