From 61201beb865aa285cdd6c6992b87194b19d11647 Mon Sep 17 00:00:00 2001 From: Dasperal Date: Sun, 12 May 2024 21:01:56 +0300 Subject: [PATCH] Hexen: Implement "Wand start" game mode --- src/hexen/g_game.c | 48 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/src/hexen/g_game.c b/src/hexen/g_game.c index d7cb9c10c..5a1686120 100644 --- a/src/hexen/g_game.c +++ b/src/hexen/g_game.c @@ -1219,17 +1219,53 @@ void G_PlayerExitMap(int playerNumber) } else { - if (P_GetMapCluster(gamemap) != P_GetMapCluster(LeaveMap)) - { // Entering new cluster + // Entering new cluster + if(P_GetMapCluster(gamemap) != P_GetMapCluster(LeaveMap)) + { // Strip all keys player->keys = 0; - // Strip flight artifact - for (i = 0; i < 25; i++) + // Reset player in wandstart mode + if(singleplayer && !vanillaparm && pistol_start) { - player->powers[pw_flight] = 0; - P_PlayerUseArtifact(player, arti_fly); + memset(player->armorpoints, 0, sizeof(player->armorpoints)); + memset(player->weaponowned, 0, sizeof(player->weaponowned)); + memset(player->mana, 0, sizeof(player->mana)); + player->health = player->mo->health = MAXHEALTH; + player->pieces = 0; + player->readyweapon = player->pendingweapon = player->mo->special1.i = WP_FIRST; + player->weaponowned[WP_FIRST] = true; + + // Remove all non-puzzle items + // Keep puzzle items for wad compatibility + for(i = 0; i < player->inventorySlotNum; i++) + { + if(player->inventory[i].type < arti_firstpuzzitem) + { + // Set count to 1 because P_PlayerRemoveArtifact removes only 1 artifact + player->inventory[i].count = 1; + P_PlayerRemoveArtifact(player, i); + // inventory array is shifted when artifact is removed, so stay on the same slot + i--; + } + } } + else + { + // Remove flight artifact + for(i = 0; i < player->inventorySlotNum; i++) + { + if(player->inventory[i].type == arti_fly) + { + // Set count to 1 because P_PlayerRemoveArtifact removes only 1 artifact + player->inventory[i].count = 1; + P_PlayerRemoveArtifact(player, i); + break; + } + } + } + + // Strip flight powerup player->powers[pw_flight] = 0; } }