Skip to content

Commit

Permalink
Merge pull request #412 from jonaeru/port-autorandom
Browse files Browse the repository at this point in the history
port: add auto random mp weapon option
  • Loading branch information
fgsfdsfgs authored May 14, 2024
2 parents 70b02da + 4e7e61c commit 51d842f
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/game/mplayer/mplayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,15 @@ void mpStartMatch(void)
s32 numplayers = 0;
s32 stagenum;

#ifndef PLATFORM_N64
if (g_MpSetup.options & MPOPTION_AUTORANDOMWEAPON_START) {
if (g_MpWeaponSetNum == WEAPONSET_RANDOM
|| g_MpWeaponSetNum == WEAPONSET_RANDOMFIVE) {
mpApplyWeaponSet();
}
}
#endif

mpConfigureQuickTeamSimulants();

if (!challengeIsFeatureUnlocked(MPFEATURE_ONEHITKILLS)) {
Expand Down Expand Up @@ -2458,6 +2467,15 @@ void mpEndMatch(void)
challengeConsiderMarkingComplete();
}

#ifndef PLATFORM_N64
if (g_MpSetup.options & MPOPTION_AUTORANDOMWEAPON_END) {
if (g_MpWeaponSetNum == WEAPONSET_RANDOM
|| g_MpWeaponSetNum == WEAPONSET_RANDOMFIVE) {
mpApplyWeaponSet();
}
}
#endif

func0f0f820c(NULL, -6);
}

Expand Down
60 changes: 60 additions & 0 deletions src/game/mplayer/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ struct menudialogdef g_MpChangeTeamNameMenuDialog;
struct menudialogdef g_MpEditSimulantMenuDialog;
struct menudialogdef g_MpSaveSetupNameMenuDialog;

#ifndef PLATFORM_N64
extern s32 g_MpWeaponSetNum;
#endif

MenuItemHandlerResult menuhandlerMpDropOut(s32 operation, struct menuitem *item, union handlerdata *data)
{
if (operation == MENUOP_SET) {
Expand Down Expand Up @@ -1160,6 +1164,52 @@ struct menudialogdef g_MpSaveSetupExistsMenuDialog = {
NULL,
};

#ifndef PLATFORM_N64
MenuItemHandlerResult menuhandlerMpAutoRandomWeapon(s32 operation, struct menuitem *item, union handlerdata *data)
{
static const char *labels[] = {
"Off",
"Start",
"End",
};

switch (operation) {
case MENUOP_CHECKDISABLED:
case MENUOP_CHECKHIDDEN:
if (g_MpWeaponSetNum == WEAPONSET_RANDOM
|| g_MpWeaponSetNum == WEAPONSET_RANDOMFIVE) {
return false;
}
return true;
case MENUOP_GETOPTIONCOUNT:
data->dropdown.value = ARRAYCOUNT(labels);
break;
case MENUOP_GETOPTIONTEXT:
return (intptr_t)labels[data->dropdown.value];
case MENUOP_SET:
g_MpSetup.options &= ~(MPOPTION_AUTORANDOMWEAPON_START | MPOPTION_AUTORANDOMWEAPON_END);

if (data->dropdown.value == AUTORANDOMWEAPON_START) {
g_MpSetup.options |= MPOPTION_AUTORANDOMWEAPON_START;
} else if (data->dropdown.value == AUTORANDOMWEAPON_END) {
g_MpSetup.options |= MPOPTION_AUTORANDOMWEAPON_END;
}
break;
case MENUOP_GETSELECTEDINDEX:
if (g_MpSetup.options & MPOPTION_AUTORANDOMWEAPON_END) {
data->dropdown.value = AUTORANDOMWEAPON_END;
} else if (g_MpSetup.options & MPOPTION_AUTORANDOMWEAPON_START) {
data->dropdown.value = AUTORANDOMWEAPON_START;
} else {
data->dropdown.value = AUTORANDOMWEAPON_OFF;
}
break;
}

return 0;
}
#endif

struct menuitem g_MpWeaponsMenuItems[] = {
{
MENUITEMTYPE_DROPDOWN,
Expand All @@ -1169,6 +1219,16 @@ struct menuitem g_MpWeaponsMenuItems[] = {
0,
menuhandlerMpWeaponSetDropdown,
},
#ifndef PLATFORM_N64
{
MENUITEMTYPE_DROPDOWN,
0,
MENUITEMFLAG_LITERAL_TEXT,
(uintptr_t)"Auto Random\n",
0,
menuhandlerMpAutoRandomWeapon,
},
#endif
{
MENUITEMTYPE_SEPARATOR,
0,
Expand Down
6 changes: 6 additions & 0 deletions src/include/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -2892,6 +2892,8 @@
#define MPOPTION_PAC_SHOWONRADAR 0x00100000
#define MPOPTION_SPAWNWITHWEAPON 0x00200000
#define MPOPTION_NODRUGBLUR 0x00400000
#define MPOPTION_AUTORANDOMWEAPON_START 0x00800000
#define MPOPTION_AUTORANDOMWEAPON_END 0x01000000

#define MPPAUSEMODE_UNPAUSED 0
#define MPPAUSEMODE_PAUSED 1
Expand Down Expand Up @@ -3804,6 +3806,10 @@
#define SLOWMOTION_ON 1
#define SLOWMOTION_SMART 2

#define AUTORANDOMWEAPON_OFF 0
#define AUTORANDOMWEAPON_START 1
#define AUTORANDOMWEAPON_END 2

#define SMOKETYPE_NONE 0
#define SMOKETYPE_ELECTRICAL 1 // Dr Caroll, mainframes in Infiltration bunker
#define SMOKETYPE_MINI 2 // Phoenix, Laptop sentry
Expand Down

0 comments on commit 51d842f

Please sign in to comment.