Skip to content

Commit

Permalink
Fix DryFiring fired constantly
Browse files Browse the repository at this point in the history
  • Loading branch information
scp252arc committed Jan 5, 2025
1 parent be5fb53 commit 3d6b0f5
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions EXILED/Exiled.Events/Patches/Events/Player/DryFire.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@ namespace Exiled.Events.Patches.Events.Player
#pragma warning disable SA1649
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;

using Exiled.API.Extensions;
using Exiled.API.Features.Pools;
using Attributes;

using Exiled.Events.Attributes;
using Exiled.API.Features.Pools;

using Exiled.Events.EventArgs.Player;

using Exiled.Events.Handlers;
using Handlers;

using HarmonyLib;

Expand Down Expand Up @@ -67,7 +65,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
Label ret = newInstructions[newInstructions.Count - 1 + offset].labels[0];

offset = -2;
int index = newInstructions.FindLastIndex(x => x.Calls(PropertyGetter(typeof(AutomaticActionModule), nameof(AutomaticActionModule.Cocked)))) + offset;
int index = newInstructions.FindLastIndex(x => x.Calls(PropertySetter(typeof(AutomaticActionModule), nameof(AutomaticActionModule.Cocked)))) + offset;

newInstructions.InsertRange(index, GetInstructions(newInstructions[index], ret));

Expand All @@ -78,6 +76,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
}
}

/* ------------> Commented out, because it is never called (nw moment). Calls 2 PumpActionModule.ShootOneBarrel(bool) instead.
/// <summary>
/// Patches <see cref="DoubleActionModule.FireDry()"/>
/// to add <see cref="Player.DryfiringWeapon"/> event for double shots.
Expand All @@ -102,10 +101,11 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
ListPool<CodeInstruction>.Pool.Return(newInstructions);
}
}
*/

/// <summary>
/// Patches <see cref="DoubleActionModule.FireDry()"/>
/// to add <see cref="Player.DryfiringWeapon"/> event for double shots.
/// Patches <see cref="PumpActionModule.ShootOneBarrel(bool)"/>
/// to add <see cref="Player.DryfiringWeapon"/> event for pump shots.
/// </summary>
[EventPatch(typeof(Player), nameof(Player.DryfiringWeapon))]
[HarmonyPatch(typeof(PumpActionModule), nameof(PumpActionModule.ShootOneBarrel))]
Expand Down

0 comments on commit 3d6b0f5

Please sign in to comment.