Skip to content

Commit

Permalink
IndividualFriendlyFire adjustments (Exiled-Team#2404)
Browse files Browse the repository at this point in the history
* IndividualFriendlyFire RequiredTesting

* .
  • Loading branch information
louis1706 authored Apr 6, 2024
1 parent 1a61285 commit 5a37020
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,6 @@ public static bool CheckFriendlyFirePlayerRules(Footprint attackerFootprint, Ref
if (attackerFootprint.Hub == Server.Host.ReferenceHub)
return true;

// Only check friendlyFire if the FootPrint hasn't changed (Fix for Grenade not dealing damage because it's from a dead player)
// TODO rework FriendlyFireRule to make it compatible with Footprint
if (!attackerFootprint.SameLife(new(attackerFootprint.Hub)))
return HitboxIdentity.IsEnemy(attackerFootprint.Role, victimHub.roleManager.CurrentRole.RoleTypeId);

if (attackerFootprint.Hub is null || victimHub is null)
{
Log.Debug($"CheckFriendlyFirePlayerRules, Attacker hub null: {attackerFootprint.Hub is null}, Victim hub null: {victimHub is null}");
Expand All @@ -110,7 +105,7 @@ public static bool CheckFriendlyFirePlayerRules(Footprint attackerFootprint, Ref
{
Player attacker = Player.Get(attackerFootprint.Hub);
Player victim = Player.Get(victimHub);
if (attacker is null || victim is null)
if (victim is null)
{
Log.Debug($"CheckFriendlyFirePlayerRules, Attacker null: {attacker is null}, Victim null: {victim is null}");
return true;
Expand All @@ -122,7 +117,7 @@ public static bool CheckFriendlyFirePlayerRules(Footprint attackerFootprint, Ref
return true;
}

Log.Debug($"CheckFriendlyFirePlayerRules, Attacker role {attacker.Role} and Victim {victim.Role}");
Log.Debug($"CheckFriendlyFirePlayerRules, Attacker role {attackerFootprint.Role} and Victim {victim.Role}");

if (!string.IsNullOrEmpty(victim.UniqueRole))
{
Expand All @@ -131,15 +126,15 @@ public static bool CheckFriendlyFirePlayerRules(Footprint attackerFootprint, Ref
{
if (victim.CustomRoleFriendlyFireMultiplier.TryGetValue(victim.UniqueRole, out Dictionary<RoleTypeId, float> pairedData))
{
if (pairedData.ContainsKey(attacker.Role))
if (pairedData.ContainsKey(attackerFootprint.Role))
{
ffMultiplier = pairedData[attacker.Role];
ffMultiplier = pairedData[attackerFootprint.Role];
return true;
}
}
}
}
else if (!string.IsNullOrEmpty(attacker.UniqueRole))
else if (!string.IsNullOrEmpty(attacker?.UniqueRole))
{
// If 035 is attacking, whether to allow or disallow based on victim role.
if (attacker.CustomRoleFriendlyFireMultiplier.Count > 0)
Expand All @@ -156,7 +151,7 @@ public static bool CheckFriendlyFirePlayerRules(Footprint attackerFootprint, Ref
}

// If we're SCP then we need to check if we can attack other SCP, or D-Class, etc. This is default FF logic without unique roles.
if (attacker.FriendlyFireMultiplier.Count > 0)
if ((attacker?.FriendlyFireMultiplier.Count ?? 0) > 0)
{
if (attacker.FriendlyFireMultiplier.TryGetValue(victim.Role, out float ffMulti))
{
Expand Down

0 comments on commit 5a37020

Please sign in to comment.