# HG changeset patch # User Adam Kaminski # Date 1636900350 18000 # Sun Nov 14 09:32:30 2021 -0500 # Node ID 38d8f420ad6bf7101bfedbe658e082b50c7d2af6 # Parent bf5db36a26bc40caa9097681700d1a5b65b43e23 P_AimLineAttack now ignores allies if sv_shootthroughallies is enabled, unless forced in certain cases. This particularly fixes the BFG's tracers still hitting a shooter's teammates even when the flag was enabled. diff -r bf5db36a26bc -r 38d8f420ad6b src/c_cmds.cpp --- a/src/c_cmds.cpp Sun Nov 14 00:42:32 2021 -0500 +++ b/src/c_cmds.cpp Sun Nov 14 09:32:30 2021 -0500 @@ -1257,7 +1257,8 @@ AActor *linetarget; if (CheckCheatmode () || players[consoleplayer].mo == NULL) return; - P_AimLineAttack(players[consoleplayer].mo,players[consoleplayer].mo->angle,MISSILERANGE, &linetarget, 0); + // [AK] Added the ALF_FORCEALLYCHECK flag, as "linetarget" should always check for allies. + P_AimLineAttack(players[consoleplayer].mo,players[consoleplayer].mo->angle,MISSILERANGE, &linetarget, 0, ALF_FORCEALLYCHECK); if (linetarget) { // [TP] If we're the client, ask the server for information about the linetarget. @@ -1281,8 +1282,9 @@ AActor *linetarget; if (CheckCheatmode () || players[consoleplayer].mo == NULL) return; + // [AK] Added the ALF_FORCEALLYCHECK flag, as "info" should always check for allies. P_AimLineAttack(players[consoleplayer].mo,players[consoleplayer].mo->angle,MISSILERANGE, - &linetarget, 0, ALF_CHECKNONSHOOTABLE|ALF_FORCENOSMART); + &linetarget, 0, ALF_CHECKNONSHOOTABLE|ALF_FORCENOSMART|ALF_FORCEALLYCHECK); if (linetarget) { // [TP] If we're the client, ask the server for information about the linetarget. diff -r bf5db36a26bc -r 38d8f420ad6b src/g_doom/a_doomweaps.cpp --- a/src/g_doom/a_doomweaps.cpp Sun Nov 14 00:42:32 2021 -0500 +++ b/src/g_doom/a_doomweaps.cpp Sun Nov 14 09:32:30 2021 -0500 @@ -1016,14 +1016,20 @@ if (!self->target) return; + // [Proteh] Skip backwards reconciliation if the zadmflag is set + int lineAttackFlags = ((zadmflags & ZADF_NOUNLAGGED_BFG_TRACERS) ? ALF_NOUNLAGGED : 0); + + // [AK] Check if the spray type forces collision with allies, in case sv_shootthroughallies is enabled. + if (GetDefaultByType(spraytype)->STFlags & STFL_FORCEALLYCOLLISION) + lineAttackFlags |= ALF_FORCEALLYCHECK; + // offset angles from its attack angle for (i = 0; i < numrays; i++) { an = self->angle - ANG90/2 + ANG90/numrays*i; // self->target is the originator (player) of the missile - // [Proteh] Skip backwards reconciliation if the zadmflag is set - P_AimLineAttack (self->target, an, 16*64*FRACUNIT, &linetarget, ANGLE_1*32, ((zadmflags & ZADF_NOUNLAGGED_BFG_TRACERS) ? ALF_NOUNLAGGED : 0)); + P_AimLineAttack (self->target, an, 16*64*FRACUNIT, &linetarget, ANGLE_1*32, lineAttackFlags); if (!linetarget) continue; diff -r bf5db36a26bc -r 38d8f420ad6b src/p_local.h --- a/src/p_local.h Sun Nov 14 00:42:32 2021 -0500 +++ b/src/p_local.h Sun Nov 14 09:32:30 2021 -0500 @@ -490,7 +490,9 @@ ALF_NOFRIENDS = 16, // [Proteh] Don't use backwards reconciliation - ALF_NOUNLAGGED = 32 + ALF_NOUNLAGGED = 32, + // [AK] Forces allies to be checked, even when sv_shootthroughallies is enabled. + ALF_FORCEALLYCHECK = 64, }; enum // P_LineAttack flags diff -r bf5db36a26bc -r 38d8f420ad6b src/p_map.cpp --- a/src/p_map.cpp Sun Nov 14 00:42:32 2021 -0500 +++ b/src/p_map.cpp Sun Nov 14 09:32:30 2021 -0500 @@ -3933,6 +3933,11 @@ } } + // [AK] Unless we forced the aim to check for allies, we also need to check if the + // shooter shouldn't pick the target, in case sv_shootthroughallies is enabled. + if (!( flags & ALF_FORCEALLYCHECK ) && ( PLAYER_CannotAffectAllyWith( shootthing, th, NULL, ZADF_SHOOT_THROUGH_ALLIES ))) + continue; + if ((flags & ALF_NOFRIENDS) && th->IsFriend(friender)) { continue;