From 7a23b19be800faeecbf86bb0acd35d87f571af2f Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sun, 23 Jun 2019 18:15:40 -0400 Subject: [PATCH 1/3] Add startrings level header option --- src/dehacked.c | 2 ++ src/doomstat.h | 1 + src/g_game.c | 2 ++ 3 files changed, 5 insertions(+) diff --git a/src/dehacked.c b/src/dehacked.c index f70615af6..259542957 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1323,6 +1323,8 @@ static void readlevelheader(MYFILE *f, INT32 num) else mapheaderinfo[num-1]->menuflags &= ~LF2_WIDEICON; } + else if (fastcmp(word, "STARTRINGS")) + mapheaderinfo[num-1]->startrings = (UINT16)i; else deh_warning("Level header %d: unknown word '%s'", num, word); } diff --git a/src/doomstat.h b/src/doomstat.h index efd347dbe..06dfcca0b 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -313,6 +313,7 @@ typedef struct UINT8 menuflags; ///< LF2_flags: options that affect record attack / nights mode menus char selectheading[22]; ///< Level select heading. Allows for controllable grouping. + UINT16 startrings; ///< Number of rings players start with. // Freed animals stuff. UINT8 numFlickies; ///< Internal. For freed flicky support. diff --git a/src/g_game.c b/src/g_game.c index af17b2b28..5a11b237f 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2449,6 +2449,8 @@ void G_SpawnPlayer(INT32 playernum, boolean starpost) } P_MovePlayerToSpawn(playernum, spawnpoint); + players[playernum].rings = mapheaderinfo[gamemap-1]->startrings; + #ifdef HAVE_BLUA LUAh_PlayerSpawn(&players[playernum]); // Lua hook for player spawning :) #endif From a801efa946b76df8d3f52a2a2eb229e68487fa1f Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sun, 23 Jun 2019 18:51:42 -0400 Subject: [PATCH 2/3] Forgot to do this. --- src/lua_maplib.c | 2 ++ src/p_setup.c | 1 + 2 files changed, 3 insertions(+) diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 27b97204f..c5555009f 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -2080,6 +2080,8 @@ static int mapheaderinfo_get(lua_State *L) lua_pushinteger(L, header->levelflags); else if (fastcmp(field,"menuflags")) lua_pushinteger(L, header->menuflags); + else if (fastcmp(field,"startrings")) + lua_pushinteger(L, header->startrings); // TODO add support for reading numGradedMares and grades else { // Read custom vars now diff --git a/src/p_setup.c b/src/p_setup.c index af4f1f9dd..259cbfea3 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -209,6 +209,7 @@ static void P_ClearSingleMapHeaderInfo(INT16 i) mapheaderinfo[num]->actnum = 0; mapheaderinfo[num]->typeoflevel = 0; mapheaderinfo[num]->nextlevel = (INT16)(i + 1); + mapheaderinfo[num]->startrings = 0; snprintf(mapheaderinfo[num]->musname, 7, "%sM", G_BuildMapName(i)); mapheaderinfo[num]->musname[6] = 0; mapheaderinfo[num]->mustrack = 0; From 8026fe0d4b4c0ead0fde3f9118a1856dec91f288 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Mon, 24 Jun 2019 16:21:03 -0400 Subject: [PATCH 3/3] Some few changes. The amount of rings you start with also applies when you respawn from a starpost. Startrings counts the ring total requirement for a perfect bonus. --- src/g_game.c | 4 ++-- src/p_setup.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 65d199350..632e33009 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2397,6 +2397,8 @@ void G_SpawnPlayer(INT32 playernum, boolean starpost) P_SpawnPlayer(playernum); + players[playernum].rings = mapheaderinfo[gamemap-1]->startrings; + if (starpost) //Don't even bother with looking for a place to spawn. { P_MovePlayerToStarpost(playernum); @@ -2452,8 +2454,6 @@ void G_SpawnPlayer(INT32 playernum, boolean starpost) } P_MovePlayerToSpawn(playernum, spawnpoint); - players[playernum].rings = mapheaderinfo[gamemap-1]->startrings; - #ifdef HAVE_BLUA LUAh_PlayerSpawn(&players[playernum]); // Lua hook for player spawning :) #endif diff --git a/src/p_setup.c b/src/p_setup.c index 259cbfea3..585da2149 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2176,7 +2176,7 @@ static void P_LevelInitStuff(void) tokenbits = 0; runemeraldmanager = false; emeraldspawndelay = 60*TICRATE; - nummaprings = 0; + nummaprings = mapheaderinfo[gamemap-1]->startrings; // emerald hunt hunt1 = hunt2 = hunt3 = NULL;