# HG changeset patch # User Adam Kaminski # Date 1631117891 14400 # Wed Sep 08 12:18:11 2021 -0400 # Node ID cea1464c98f9881ce3569eacf34238339b06362e # Parent 7f56c18c02804dafd290b3e5f4310884e6c8a8e6 Added DMFlags: "sv_shootthroughallies" and "sv_dontpushallies", so a player's attacks can pass through and not push their allies. diff -r 7f56c18c0280 -r cea1464c98f9 docs/zandronum-history.txt --- a/docs/zandronum-history.txt Mon Sep 06 10:41:14 2021 -0400 +++ b/docs/zandronum-history.txt Wed Sep 08 12:18:11 2021 -0400 @@ -56,6 +56,7 @@ + - Added CVars that customize how the weapon bobs, sways, and offsets based on the player's pitch, or whether or not to bob the screen itself while leaving the weapon bob unaffected. [Kaminsky] + - Added the GAMEMODE flag DONTPRINTPLAYERSLEFT to prevent printing the "waiting for players" or "x allies/opponents left" message at the bottom of the screen. [Kaminsky] + - Added all of the text colors from "New Text Colors", originally made by FuzzballFox. [Kaminsky] ++ - Added DMFlags: "sv_shootthroughallies" and "sv_dontpushallies", so a player's attacks can pass through and not push their allies. [Kaminsky] - - Fixed: Bots tries to jump to reach item when sv_nojump is true. [sleep] - - Fixed: ACS function SetSkyScrollSpeed didn't work online. [Edward-san] - - Fixed: color codes in callvote reasons weren't terminated properly. [Dusk] diff -r 7f56c18c0280 -r cea1464c98f9 src/d_main.cpp --- a/src/d_main.cpp Mon Sep 06 10:41:14 2021 -0400 +++ b/src/d_main.cpp Wed Sep 08 12:18:11 2021 -0400 @@ -632,6 +632,8 @@ CVAR (Flag, sv_nodoorclose, zadmflags, ZADF_NODOORCLOSE); CVAR (Flag, sv_forcesoftwarepitchlimits, zadmflags, ZADF_FORCE_SOFTWARE_PITCH_LIMITS); CVAR (Flag, sv_noprivatechat, zadmflags, ZADF_NO_PRIVATE_CHAT); +CVAR (Flag, sv_shootthroughallies, zadmflags, ZADF_SHOOT_THROUGH_ALLIES); +CVAR (Flag, sv_dontpushallies, zadmflags, ZADF_DONT_PUSH_ALLIES); // Old name kept for compatibility CVAR (Flag, sv_forcegldefaults, zadmflags, ZADF_FORCE_VIDEO_DEFAULTS); diff -r 7f56c18c0280 -r cea1464c98f9 src/d_player.h --- a/src/d_player.h Mon Sep 06 10:41:14 2021 -0400 +++ b/src/d_player.h Wed Sep 08 12:18:11 2021 -0400 @@ -800,6 +800,7 @@ bool PLAYER_NameUsed( const FString &Name, const ULONG ulIgnorePlayer = MAXPLAYERS ); FString PLAYER_GenerateUniqueName( void ); bool PLAYER_CanRespawnWhereDied( player_t *pPlayer ); +bool PLAYER_CannotShootOrPushAlly( AActor *pActor1, AActor *pActor2, bool bCheckPush ); void P_CheckPlayerSprite(AActor *mo, int &spritenum, fixed_t &scalex, fixed_t &scaley); diff -r 7f56c18c0280 -r cea1464c98f9 src/doomdef.h --- a/src/doomdef.h Mon Sep 06 10:41:14 2021 -0400 +++ b/src/doomdef.h Wed Sep 08 12:18:11 2021 -0400 @@ -386,6 +386,12 @@ // [AK] No private messaging allowed on the server. ZADF_NO_PRIVATE_CHAT = 1 << 21, + + // [AK] Allows players to fire hitscans and projectiles through teammates. + ZADF_SHOOT_THROUGH_ALLIES = 1 << 22, + + // [AK] Players aren't pushed by attacks caused by their teammates (e.g. BFG tracers). + ZADF_DONT_PUSH_ALLIES = 1 << 23, }; // [RH] Compatibility flags. diff -r 7f56c18c0280 -r cea1464c98f9 src/p_interaction.cpp --- a/src/p_interaction.cpp Mon Sep 06 10:41:14 2021 -0400 +++ b/src/p_interaction.cpp Wed Sep 08 12:18:11 2021 -0400 @@ -1392,11 +1392,13 @@ // Push the target unless the source's weapon's kickback is 0. // (i.e. Gauntlets/Chainsaw) // [BB] The server handles this. + // [AK] Don't push teammates if ZADF_DONT_PUSH_ALLIES is enabled. if (inflictor && inflictor != target // [RH] Not if hurting own self && !(target->flags & MF_NOCLIP) && !(inflictor->flags2 & MF2_NODMGTHRUST) && !(flags & DMG_THRUSTLESS) && (source == NULL || source->player == NULL || !(source->flags2 & MF2_NODMGTHRUST)) + && ( PLAYER_CannotShootOrPushAlly( source, target, true ) == false ) && ( NETWORK_InClientMode() == false ) ) { int kickback; @@ -3401,6 +3403,26 @@ return true; } +//***************************************************************************** +// +bool PLAYER_CannotShootOrPushAlly( AActor *pActor1, AActor *pActor2, bool bCheckPush ) +{ + // [AK] Check if we have the corresponding zadmflag enabled. + if (( zadmflags & ( !bCheckPush ? ZADF_SHOOT_THROUGH_ALLIES : ZADF_DONT_PUSH_ALLIES )) == false ) + return false; + + // [AK] If the first actor isn't a player, return false. + if (( pActor1 == NULL ) || ( pActor1->player == NULL )) + return false; + + // [AK] Make sure the other actor is another player and a teammate of the first actor. Otherwise, + // their attacks should still hit and push each other. + if (( pActor1 != pActor2 ) && ( pActor1->IsTeammate( pActor2 )) && ( pActor2->player )) + return true; + + return false; +} + CCMD (kill) { // Only allow it in a level. diff -r 7f56c18c0280 -r cea1464c98f9 src/p_map.cpp --- a/src/p_map.cpp Mon Sep 06 10:41:14 2021 -0400 +++ b/src/p_map.cpp Wed Sep 08 12:18:11 2021 -0400 @@ -1084,6 +1084,11 @@ && (tm.thing->target->GetSpecies() == thing->GetSpecies())) return true; + // [AK] Check if this projectile was shot by a player and can pass through their + // teammates if ZADF_SHOOT_THROUGH_ALLIES is enabled. + if ( PLAYER_CannotShootOrPushAlly( tm.thing->target, thing, false )) + return true; + // Check for rippers passing through corpses if ((thing->flags & MF_CORPSE) && (tm.thing->flags2 & MF2_RIP) && !(thing->flags & MF_SHOOTABLE)) { @@ -4133,6 +4138,12 @@ return TRACE_Skip; } + // [AK] Check if this player can shoot through their teammates if ZADF_SHOOT_THROUGH_ALLIES is enabled. + if ( PLAYER_CannotShootOrPushAlly( data->Caller, res.Actor, false )) + { + return TRACE_Skip; + } + return TRACE_Stop; } @@ -5613,6 +5624,11 @@ ) ) continue; + // [AK] Don't push this player if ZADF_DONT_PUSH_ALLIES is enabled and the + // other player who caused the explosion is their teammate. + if ( PLAYER_CannotShootOrPushAlly( bombsource, thing, true )) + continue; + // Barrels always use the original code, since this makes // them far too "active." BossBrains also use the old code // because some user levels require they have a height of 16, diff -r 7f56c18c0280 -r cea1464c98f9 wadsrc/static/menudef.txt --- a/wadsrc/static/menudef.txt Mon Sep 06 10:41:14 2021 -0400 +++ b/wadsrc/static/menudef.txt Wed Sep 08 12:18:11 2021 -0400 @@ -1313,6 +1313,8 @@ Option "Full blood brightness", "sv_maxbloodscalar", "YesNo" Option "Force software pitch limits", "sv_forcesoftwarepitchlimits", "YesNo" Option "Allow private chat", "sv_noprivatechat", "NoYes" + Option "Shoot through allies", "sv_shootthroughallies", "YesNo" + Option "Attacks push allies", "sv_dontpushallies", "NoYes" // [TP] -- StaticText " "