From 45531090a7f2754acfc0ba46e5624c261621d2dd Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 28 Dec 2017 00:53:30 -0500 Subject: [PATCH] - add 'playerrespawn' skill flag to allow gameplay mods to retroactively enable player respawns in single player on all maps --- src/g_game.cpp | 3 ++- src/g_level.h | 2 ++ src/g_skill.cpp | 8 ++++++++ src/p_mobj.cpp | 3 ++- wadsrc/static/zscript/constants.txt | 1 + 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/g_game.cpp b/src/g_game.cpp index 4044846728..82bff3f736 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1743,7 +1743,8 @@ static void G_QueueBody (AActor *body) EXTERN_CVAR(Bool, sv_singleplayerrespawn) 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())) { // Load game from the last point it was saved diff --git a/src/g_level.h b/src/g_level.h index 7fb38a046c..78dcd55b11 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -538,6 +538,7 @@ enum ESkillProperty SKILLP_EasyKey, SKILLP_SlowMonsters, SKILLP_Infight, + SKILLP_PlayerRespawn, }; enum EFSkillProperty // floating point properties { @@ -595,6 +596,7 @@ struct FSkillInfo double FriendlyHealth; bool NoPain; int Infighting; + bool PlayerRespawn; FSkillInfo() {} FSkillInfo(const FSkillInfo &other) diff --git a/src/g_skill.cpp b/src/g_skill.cpp index 6e23c9523a..5c252274fb 100644 --- a/src/g_skill.cpp +++ b/src/g_skill.cpp @@ -89,6 +89,7 @@ void FMapInfoParser::ParseSkill () skill.FriendlyHealth = 1.; skill.NoPain = false; skill.Infighting = 0; + skill.PlayerRespawn = false; sc.MustGetString(); skill.Name = sc.String; @@ -155,6 +156,10 @@ void FMapInfoParser::ParseSkill () { skill.NoMenu = true; } + else if (sc.Compare ("playerrespawn")) + { + skill.PlayerRespawn = true; + } else if (sc.Compare("respawntime")) { ParseAssign(); @@ -397,6 +402,9 @@ int G_SkillProperty(ESkillProperty prop) if (AllSkills[gameskill].Infighting == LEVEL2_TOTALINFIGHTING) return 1; if (AllSkills[gameskill].Infighting == LEVEL2_NOINFIGHTING) return -1; return infighting; + + case SKILLP_PlayerRespawn: + return AllSkills[gameskill].PlayerRespawn; } } return 0; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 561334a52d..dc0e76ad1f 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -5648,7 +5648,8 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags) { // Give all cards in death match mode. 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 p->mo->FilterCoopRespawnInventory (oldactor); } diff --git a/wadsrc/static/zscript/constants.txt b/wadsrc/static/zscript/constants.txt index dc44832534..e35af3a80f 100644 --- a/wadsrc/static/zscript/constants.txt +++ b/wadsrc/static/zscript/constants.txt @@ -962,6 +962,7 @@ enum ESkillProperty SKILLP_EasyKey, SKILLP_SlowMonsters, SKILLP_Infight, + SKILLP_PlayerRespawn, }; enum EFSkillProperty // floating point properties {