From 3681c7d75fb1127a0a26dfe5ddfbe67fa972687a Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Wed, 7 Dec 2022 23:23:22 +1000 Subject: [PATCH] Introduce option to spawn with weapon --- src/assets/ntsc-final/lang/mpmenu.json | 2 +- src/game/bot.c | 9 +++++++++ src/game/mplayer/scenarios/capturethecase.inc | 8 ++++++++ src/game/mplayer/scenarios/combat.inc | 8 ++++++++ src/game/mplayer/scenarios/hackthatmac.inc | 8 ++++++++ src/game/mplayer/scenarios/holdthebriefcase.inc | 8 ++++++++ src/game/mplayer/scenarios/kingofthehill.inc | 8 ++++++++ src/game/mplayer/scenarios/popacap.inc | 8 ++++++++ src/game/player.c | 14 ++++++++++++-- src/include/constants.h | 1 + 10 files changed, 71 insertions(+), 3 deletions(-) diff --git a/src/assets/ntsc-final/lang/mpmenu.json b/src/assets/ntsc-final/lang/mpmenu.json index 1bc947505..201c84c1b 100644 --- a/src/assets/ntsc-final/lang/mpmenu.json +++ b/src/assets/ntsc-final/lang/mpmenu.json @@ -2521,7 +2521,7 @@ }, { "id": "L_MPMENU_252", - "en": "Touch That Box", + "en": "Spawn With Weapon", "gb": "Touch That Box", "jp": "Touch That Box", "it": "Touch That Box", diff --git a/src/game/bot.c b/src/game/bot.c index eb063bac1..8e6d882a4 100644 --- a/src/game/bot.c +++ b/src/game/bot.c @@ -252,6 +252,15 @@ void botSpawn(struct chrdata *chr, u8 respawning) chr->aibot->unk0b4 = 0; chr->aibot->unk0b8 = 0; func0f02e9a0(chr, 0); + + if ((g_MpSetup.options & MPOPTION_SPAWNWITHWEAPON) + && g_MpSetup.weapons[0] != MPWEAPON_NONE + && g_MpSetup.weapons[0] != MPWEAPON_DISABLED) { + struct mpweapon *mpweapon = &g_MpWeapons[g_MpSetup.weapons[0]]; + botinvGiveSingleWeapon(chr, mpweapon->weaponnum); + botactGiveAmmoByType(aibot, mpweapon->weapon1ammotypeminusone, mpweapon->weapon1ammoqty); + botinvSwitchToWeapon(chr, mpweapon->weaponnum, FUNC_PRIMARY); + } } chr->maxdamage = 8; diff --git a/src/game/mplayer/scenarios/capturethecase.inc b/src/game/mplayer/scenarios/capturethecase.inc index 789927941..ddd02ad5d 100644 --- a/src/game/mplayer/scenarios/capturethecase.inc +++ b/src/game/mplayer/scenarios/capturethecase.inc @@ -60,6 +60,14 @@ struct menuitem g_CtcOptionsMenuItems[] = { MPOPTION_NOAUTOAIM, menuhandlerMpCheckboxOption, }, + { + MENUITEMTYPE_CHECKBOX, + 0, + MENUITEMFLAG_LOCKABLEMINOR, + L_MPMENU_252, // "Spawn With Weapon" + MPOPTION_SPAWNWITHWEAPON, + menuhandlerMpCheckboxOption, + }, { MENUITEMTYPE_CHECKBOX, 0, diff --git a/src/game/mplayer/scenarios/combat.inc b/src/game/mplayer/scenarios/combat.inc index 74f4c6ad3..a4694a604 100644 --- a/src/game/mplayer/scenarios/combat.inc +++ b/src/game/mplayer/scenarios/combat.inc @@ -55,6 +55,14 @@ struct menuitem g_MpCombatOptionsMenuItems[] = { MPOPTION_NOAUTOAIM, menuhandlerMpCheckboxOption, }, + { + MENUITEMTYPE_CHECKBOX, + 0, + MENUITEMFLAG_LOCKABLEMINOR, + L_MPMENU_252, // "Spawn With Weapon" + MPOPTION_SPAWNWITHWEAPON, + menuhandlerMpCheckboxOption, + }, { MENUITEMTYPE_SEPARATOR, 0, diff --git a/src/game/mplayer/scenarios/hackthatmac.inc b/src/game/mplayer/scenarios/hackthatmac.inc index 111c65623..6e3b6251e 100644 --- a/src/game/mplayer/scenarios/hackthatmac.inc +++ b/src/game/mplayer/scenarios/hackthatmac.inc @@ -58,6 +58,14 @@ struct menuitem g_HtmOptionsMenuItems[] = { MPOPTION_NOAUTOAIM, menuhandlerMpCheckboxOption, }, + { + MENUITEMTYPE_CHECKBOX, + 0, + MENUITEMFLAG_LOCKABLEMINOR, + L_MPMENU_252, // "Spawn With Weapon" + MPOPTION_SPAWNWITHWEAPON, + menuhandlerMpCheckboxOption, + }, { MENUITEMTYPE_CHECKBOX, 0, diff --git a/src/game/mplayer/scenarios/holdthebriefcase.inc b/src/game/mplayer/scenarios/holdthebriefcase.inc index cf964567e..219113ce7 100644 --- a/src/game/mplayer/scenarios/holdthebriefcase.inc +++ b/src/game/mplayer/scenarios/holdthebriefcase.inc @@ -58,6 +58,14 @@ struct menuitem g_HtbOptionsMenuItems[] = { MPOPTION_NOAUTOAIM, menuhandlerMpCheckboxOption, }, + { + MENUITEMTYPE_CHECKBOX, + 0, + MENUITEMFLAG_LOCKABLEMINOR, + L_MPMENU_252, // "Spawn With Weapon" + MPOPTION_SPAWNWITHWEAPON, + menuhandlerMpCheckboxOption, + }, { MENUITEMTYPE_CHECKBOX, 0, diff --git a/src/game/mplayer/scenarios/kingofthehill.inc b/src/game/mplayer/scenarios/kingofthehill.inc index acedb2166..3a4d6b20e 100644 --- a/src/game/mplayer/scenarios/kingofthehill.inc +++ b/src/game/mplayer/scenarios/kingofthehill.inc @@ -79,6 +79,14 @@ struct menuitem g_KohOptionsMenuItems[] = { MPOPTION_NOAUTOAIM, menuhandlerMpCheckboxOption, }, + { + MENUITEMTYPE_CHECKBOX, + 0, + MENUITEMFLAG_LOCKABLEMINOR, + L_MPMENU_252, // "Spawn With Weapon" + MPOPTION_SPAWNWITHWEAPON, + menuhandlerMpCheckboxOption, + }, { MENUITEMTYPE_CHECKBOX, 0, diff --git a/src/game/mplayer/scenarios/popacap.inc b/src/game/mplayer/scenarios/popacap.inc index 3455c4292..017c4641a 100644 --- a/src/game/mplayer/scenarios/popacap.inc +++ b/src/game/mplayer/scenarios/popacap.inc @@ -56,6 +56,14 @@ struct menuitem g_PacOptionsMenuItems[] = { MPOPTION_NOAUTOAIM, menuhandlerMpCheckboxOption, }, + { + MENUITEMTYPE_CHECKBOX, + 0, + MENUITEMFLAG_LOCKABLEMINOR, + L_MPMENU_252, // "Spawn With Weapon" + MPOPTION_SPAWNWITHWEAPON, + menuhandlerMpCheckboxOption, + }, { MENUITEMTYPE_CHECKBOX, 0, diff --git a/src/game/player.c b/src/game/player.c index b7115779f..5405d28c9 100644 --- a/src/game/player.c +++ b/src/game/player.c @@ -794,8 +794,18 @@ void playerSpawn(void) invGiveSingleWeapon(WEAPON_UNARMED); playerSetShieldFrac(0); - bgunEquipWeapon2(HAND_LEFT, g_DefaultWeapons[HAND_LEFT]); - bgunEquipWeapon2(HAND_RIGHT, g_DefaultWeapons[HAND_RIGHT]); + if ((g_MpSetup.options & MPOPTION_SPAWNWITHWEAPON) + && g_MpSetup.weapons[0] != MPWEAPON_NONE + && g_MpSetup.weapons[0] != MPWEAPON_DISABLED) { + struct mpweapon *mpweapon = &g_MpWeapons[g_MpSetup.weapons[0]]; + invGiveSingleWeapon(mpweapon->weaponnum); + bgunEquipWeapon2(HAND_LEFT, WEAPON_NONE); + bgunEquipWeapon2(HAND_RIGHT, mpweapon->weaponnum); + bgunSetAmmoQuantity(mpweapon->weapon1ammotypeminusone, mpweapon->weapon1ammoqty); + } else { + bgunEquipWeapon2(HAND_LEFT, g_DefaultWeapons[HAND_LEFT]); + bgunEquipWeapon2(HAND_RIGHT, g_DefaultWeapons[HAND_RIGHT]); + } if (g_Vars.currentplayer->model00d4 == NULL) { playerTickChrBody(); diff --git a/src/include/constants.h b/src/include/constants.h index 027f77efc..61faefe37 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -2900,6 +2900,7 @@ #define MPOPTION_HTM_SHOWONRADAR 0x00040000 #define MPOPTION_PAC_HIGHLIGHTTARGET 0x00080000 #define MPOPTION_PAC_SHOWONRADAR 0x00100000 +#define MPOPTION_SPAWNWITHWEAPON 0x00200000 #define MPPAUSEMODE_UNPAUSED 0 #define MPPAUSEMODE_PAUSED 1