From 0b61ec9641252e36adea13e00bc7898672ffd7a1 Mon Sep 17 00:00:00 2001 From: Jonaeru Date: Wed, 20 Mar 2024 01:53:50 +0900 Subject: [PATCH 1/2] port: add friendly fire mp option --- src/game/chraction.c | 12 ++++++++++++ src/game/mplayer/mplayer.c | 4 ++++ 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/include/constants.h | 1 + 9 files changed, 65 insertions(+) diff --git a/src/game/chraction.c b/src/game/chraction.c index a770ee77c..8ff7b6502 100644 --- a/src/game/chraction.c +++ b/src/game/chraction.c @@ -4339,6 +4339,18 @@ void chrDamage(struct chrdata *chr, f32 damage, struct coord *vector, struct gse return; } +#ifndef PLATFORM_N64 + // Don't damage if multiplayer and friendly fire is off + if (g_Vars.mplayerisrunning + && !(g_MpSetup.options & MPOPTION_FRIENDLYFIRE) + && aprop + && aprop != vprop + && (aprop->type == PROPTYPE_PLAYER || aprop->type == PROPTYPE_CHR) + && chr->team == aprop->chr->team) { + return; + } +#endif + if (gset == NULL) { gset = &gset2; } diff --git a/src/game/mplayer/mplayer.c b/src/game/mplayer/mplayer.c index a5756ab8e..e74e8fc49 100644 --- a/src/game/mplayer/mplayer.c +++ b/src/game/mplayer/mplayer.c @@ -524,6 +524,10 @@ void mpInit(void) | MPOPTION_PAC_HIGHLIGHTTARGET | MPOPTION_PAC_SHOWONRADAR; +#ifndef PLATFORM_N64 + g_MpSetup.options |= MPOPTION_FRIENDLYFIRE; +#endif + g_Vars.mphilltime = 10; func0f187fec(); diff --git a/src/game/mplayer/scenarios/capturethecase.inc b/src/game/mplayer/scenarios/capturethecase.inc index 0e82d542a..920715fdb 100644 --- a/src/game/mplayer/scenarios/capturethecase.inc +++ b/src/game/mplayer/scenarios/capturethecase.inc @@ -69,6 +69,14 @@ struct menuitem g_CtcOptionsMenuItems[] = { MPOPTION_SPAWNWITHWEAPON, menuhandlerMpCheckboxOption, }, + { + MENUITEMTYPE_CHECKBOX, + 0, + MENUITEMFLAG_LOCKABLEMINOR | MENUITEMFLAG_LITERAL_TEXT, + (uintptr_t)"Friendly Fire", + MPOPTION_FRIENDLYFIRE, + menuhandlerMpDisplayTeam, + }, #endif { MENUITEMTYPE_CHECKBOX, diff --git a/src/game/mplayer/scenarios/combat.inc b/src/game/mplayer/scenarios/combat.inc index 7d096a55c..cc35e2207 100644 --- a/src/game/mplayer/scenarios/combat.inc +++ b/src/game/mplayer/scenarios/combat.inc @@ -64,6 +64,14 @@ struct menuitem g_MpCombatOptionsMenuItems[] = { MPOPTION_SPAWNWITHWEAPON, menuhandlerMpCheckboxOption, }, + { + MENUITEMTYPE_CHECKBOX, + 0, + MENUITEMFLAG_LOCKABLEMINOR | MENUITEMFLAG_LITERAL_TEXT, + (uintptr_t)"Friendly Fire", + MPOPTION_FRIENDLYFIRE, + menuhandlerMpDisplayTeam, + }, #endif { MENUITEMTYPE_SEPARATOR, diff --git a/src/game/mplayer/scenarios/hackthatmac.inc b/src/game/mplayer/scenarios/hackthatmac.inc index 1ca58458a..696182857 100644 --- a/src/game/mplayer/scenarios/hackthatmac.inc +++ b/src/game/mplayer/scenarios/hackthatmac.inc @@ -67,6 +67,14 @@ struct menuitem g_HtmOptionsMenuItems[] = { MPOPTION_SPAWNWITHWEAPON, menuhandlerMpCheckboxOption, }, + { + MENUITEMTYPE_CHECKBOX, + 0, + MENUITEMFLAG_LOCKABLEMINOR | MENUITEMFLAG_LITERAL_TEXT, + (uintptr_t)"Friendly Fire", + MPOPTION_FRIENDLYFIRE, + menuhandlerMpDisplayTeam, + }, #endif { MENUITEMTYPE_CHECKBOX, diff --git a/src/game/mplayer/scenarios/holdthebriefcase.inc b/src/game/mplayer/scenarios/holdthebriefcase.inc index fe9cc0bd6..021eedb79 100644 --- a/src/game/mplayer/scenarios/holdthebriefcase.inc +++ b/src/game/mplayer/scenarios/holdthebriefcase.inc @@ -67,6 +67,14 @@ struct menuitem g_HtbOptionsMenuItems[] = { MPOPTION_SPAWNWITHWEAPON, menuhandlerMpCheckboxOption, }, + { + MENUITEMTYPE_CHECKBOX, + 0, + MENUITEMFLAG_LOCKABLEMINOR | MENUITEMFLAG_LITERAL_TEXT, + (uintptr_t)"Friendly Fire", + MPOPTION_FRIENDLYFIRE, + menuhandlerMpDisplayTeam, + }, #endif { MENUITEMTYPE_CHECKBOX, diff --git a/src/game/mplayer/scenarios/kingofthehill.inc b/src/game/mplayer/scenarios/kingofthehill.inc index 120024f19..6beb27a3c 100644 --- a/src/game/mplayer/scenarios/kingofthehill.inc +++ b/src/game/mplayer/scenarios/kingofthehill.inc @@ -88,6 +88,14 @@ struct menuitem g_KohOptionsMenuItems[] = { MPOPTION_SPAWNWITHWEAPON, menuhandlerMpCheckboxOption, }, + { + MENUITEMTYPE_CHECKBOX, + 0, + MENUITEMFLAG_LOCKABLEMINOR | MENUITEMFLAG_LITERAL_TEXT, + (uintptr_t)"Friendly Fire", + MPOPTION_FRIENDLYFIRE, + menuhandlerMpDisplayTeam, + }, #endif { MENUITEMTYPE_CHECKBOX, diff --git a/src/game/mplayer/scenarios/popacap.inc b/src/game/mplayer/scenarios/popacap.inc index 7da8ed521..6d6ea5e75 100644 --- a/src/game/mplayer/scenarios/popacap.inc +++ b/src/game/mplayer/scenarios/popacap.inc @@ -65,6 +65,14 @@ struct menuitem g_PacOptionsMenuItems[] = { MPOPTION_SPAWNWITHWEAPON, menuhandlerMpCheckboxOption, }, + { + MENUITEMTYPE_CHECKBOX, + 0, + MENUITEMFLAG_LOCKABLEMINOR | MENUITEMFLAG_LITERAL_TEXT, + (uintptr_t)"Friendly Fire", + MPOPTION_FRIENDLYFIRE, + menuhandlerMpDisplayTeam, + }, #endif { MENUITEMTYPE_CHECKBOX, diff --git a/src/include/constants.h b/src/include/constants.h index e51ec894a..ac39e4c60 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -2890,6 +2890,7 @@ #define MPOPTION_PAC_HIGHLIGHTTARGET 0x00080000 #define MPOPTION_PAC_SHOWONRADAR 0x00100000 #define MPOPTION_SPAWNWITHWEAPON 0x00200000 +#define MPOPTION_FRIENDLYFIRE 0x00400000 #define MPPAUSEMODE_UNPAUSED 0 #define MPPAUSEMODE_PAUSED 1 From 501ab95b00c7835c72f2cb67a2f43ab7ea4889a6 Mon Sep 17 00:00:00 2001 From: Jonaeru Date: Wed, 20 Mar 2024 11:19:06 +0900 Subject: [PATCH 2/2] port: fix texts --- src/game/mplayer/scenarios/capturethecase.inc | 4 ++-- src/game/mplayer/scenarios/combat.inc | 4 ++-- src/game/mplayer/scenarios/hackthatmac.inc | 4 ++-- src/game/mplayer/scenarios/holdthebriefcase.inc | 4 ++-- src/game/mplayer/scenarios/kingofthehill.inc | 4 ++-- src/game/mplayer/scenarios/popacap.inc | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/game/mplayer/scenarios/capturethecase.inc b/src/game/mplayer/scenarios/capturethecase.inc index 920715fdb..e940390e7 100644 --- a/src/game/mplayer/scenarios/capturethecase.inc +++ b/src/game/mplayer/scenarios/capturethecase.inc @@ -72,8 +72,8 @@ struct menuitem g_CtcOptionsMenuItems[] = { { MENUITEMTYPE_CHECKBOX, 0, - MENUITEMFLAG_LOCKABLEMINOR | MENUITEMFLAG_LITERAL_TEXT, - (uintptr_t)"Friendly Fire", + MENUITEMFLAG_LOCKABLEMINOR, + L_OPTIONS_257, // "Friendly Fire" MPOPTION_FRIENDLYFIRE, menuhandlerMpDisplayTeam, }, diff --git a/src/game/mplayer/scenarios/combat.inc b/src/game/mplayer/scenarios/combat.inc index cc35e2207..03834861f 100644 --- a/src/game/mplayer/scenarios/combat.inc +++ b/src/game/mplayer/scenarios/combat.inc @@ -67,8 +67,8 @@ struct menuitem g_MpCombatOptionsMenuItems[] = { { MENUITEMTYPE_CHECKBOX, 0, - MENUITEMFLAG_LOCKABLEMINOR | MENUITEMFLAG_LITERAL_TEXT, - (uintptr_t)"Friendly Fire", + MENUITEMFLAG_LOCKABLEMINOR, + L_OPTIONS_257, // "Friendly Fire" MPOPTION_FRIENDLYFIRE, menuhandlerMpDisplayTeam, }, diff --git a/src/game/mplayer/scenarios/hackthatmac.inc b/src/game/mplayer/scenarios/hackthatmac.inc index 696182857..2ab930965 100644 --- a/src/game/mplayer/scenarios/hackthatmac.inc +++ b/src/game/mplayer/scenarios/hackthatmac.inc @@ -70,8 +70,8 @@ struct menuitem g_HtmOptionsMenuItems[] = { { MENUITEMTYPE_CHECKBOX, 0, - MENUITEMFLAG_LOCKABLEMINOR | MENUITEMFLAG_LITERAL_TEXT, - (uintptr_t)"Friendly Fire", + MENUITEMFLAG_LOCKABLEMINOR, + L_OPTIONS_257, // "Friendly Fire" MPOPTION_FRIENDLYFIRE, menuhandlerMpDisplayTeam, }, diff --git a/src/game/mplayer/scenarios/holdthebriefcase.inc b/src/game/mplayer/scenarios/holdthebriefcase.inc index 021eedb79..f08a33f3c 100644 --- a/src/game/mplayer/scenarios/holdthebriefcase.inc +++ b/src/game/mplayer/scenarios/holdthebriefcase.inc @@ -70,8 +70,8 @@ struct menuitem g_HtbOptionsMenuItems[] = { { MENUITEMTYPE_CHECKBOX, 0, - MENUITEMFLAG_LOCKABLEMINOR | MENUITEMFLAG_LITERAL_TEXT, - (uintptr_t)"Friendly Fire", + MENUITEMFLAG_LOCKABLEMINOR, + L_OPTIONS_257, // "Friendly Fire" MPOPTION_FRIENDLYFIRE, menuhandlerMpDisplayTeam, }, diff --git a/src/game/mplayer/scenarios/kingofthehill.inc b/src/game/mplayer/scenarios/kingofthehill.inc index 6beb27a3c..45684ff4b 100644 --- a/src/game/mplayer/scenarios/kingofthehill.inc +++ b/src/game/mplayer/scenarios/kingofthehill.inc @@ -91,8 +91,8 @@ struct menuitem g_KohOptionsMenuItems[] = { { MENUITEMTYPE_CHECKBOX, 0, - MENUITEMFLAG_LOCKABLEMINOR | MENUITEMFLAG_LITERAL_TEXT, - (uintptr_t)"Friendly Fire", + MENUITEMFLAG_LOCKABLEMINOR, + L_OPTIONS_257, // "Friendly Fire" MPOPTION_FRIENDLYFIRE, menuhandlerMpDisplayTeam, }, diff --git a/src/game/mplayer/scenarios/popacap.inc b/src/game/mplayer/scenarios/popacap.inc index 6d6ea5e75..fa58c551f 100644 --- a/src/game/mplayer/scenarios/popacap.inc +++ b/src/game/mplayer/scenarios/popacap.inc @@ -68,8 +68,8 @@ struct menuitem g_PacOptionsMenuItems[] = { { MENUITEMTYPE_CHECKBOX, 0, - MENUITEMFLAG_LOCKABLEMINOR | MENUITEMFLAG_LITERAL_TEXT, - (uintptr_t)"Friendly Fire", + MENUITEMFLAG_LOCKABLEMINOR, + L_OPTIONS_257, // "Friendly Fire" MPOPTION_FRIENDLYFIRE, menuhandlerMpDisplayTeam, },