diff --git a/Exiled.Events/EventArgs/Map/PlacingBulletHoleEventArgs.cs b/Exiled.Events/EventArgs/Map/PlacingBulletHoleEventArgs.cs
index 8e237af27e..b6e5254630 100644
--- a/Exiled.Events/EventArgs/Map/PlacingBulletHoleEventArgs.cs
+++ b/Exiled.Events/EventArgs/Map/PlacingBulletHoleEventArgs.cs
@@ -8,9 +8,8 @@
namespace Exiled.Events.EventArgs.Map
{
using API.Features;
-
+ using Exiled.API.Features.Items;
using Interfaces;
-
using UnityEngine;
///
@@ -27,11 +26,15 @@ public class PlacingBulletHoleEventArgs : IPlayerEvent, IDeniableEvent
///
///
///
- public PlacingBulletHoleEventArgs(Player owner, RaycastHit hit)
+ ///
+ ///
+ ///
+ public PlacingBulletHoleEventArgs(Player owner, RaycastHit hit, InventorySystem.Items.Firearms.Firearm firearm)
{
Player = owner;
Position = hit.point;
Rotation = Quaternion.LookRotation(hit.normal);
+ Firearm = Item.Get(firearm).As();
}
///
@@ -53,5 +56,10 @@ public PlacingBulletHoleEventArgs(Player owner, RaycastHit hit)
/// Gets the decal owner.
///
public Player Player { get; }
+
+ ///
+ /// Gets the firearm that triggered the event.
+ ///
+ public Firearm Firearm { get; }
}
}
\ No newline at end of file
diff --git a/Exiled.Events/Patches/Events/Map/ExplodingFragGrenade.cs b/Exiled.Events/Patches/Events/Map/ExplodingFragGrenade.cs
index 2ef6e17001..cbd59e6733 100644
--- a/Exiled.Events/Patches/Events/Map/ExplodingFragGrenade.cs
+++ b/Exiled.Events/Patches/Events/Map/ExplodingFragGrenade.cs
@@ -26,7 +26,7 @@ namespace Exiled.Events.Patches.Events.Map
using static HarmonyLib.AccessTools;
///
- /// Patches .
+ /// Patches .
/// Adds the event.
///
[EventPatch(typeof(Handlers.Map), nameof(Handlers.Map.ExplodingGrenade))]
diff --git a/Exiled.Events/Patches/Events/Map/PlacingBulletHole.cs b/Exiled.Events/Patches/Events/Map/PlacingBulletHole.cs
index 772916b751..29160cd165 100644
--- a/Exiled.Events/Patches/Events/Map/PlacingBulletHole.cs
+++ b/Exiled.Events/Patches/Events/Map/PlacingBulletHole.cs
@@ -11,16 +11,12 @@ namespace Exiled.Events.Patches.Events.Map
using System.Reflection.Emit;
using API.Features.Core.Generic.Pools;
-
using Exiled.Events.Attributes;
using Exiled.Events.EventArgs.Map;
-
using Handlers;
-
using HarmonyLib;
-
+ using InventorySystem.Items.Firearms;
using InventorySystem.Items.Firearms.Modules;
-
using UnityEngine;
using static HarmonyLib.AccessTools;
@@ -28,11 +24,11 @@ namespace Exiled.Events.Patches.Events.Map
using Player = API.Features.Player;
///
- /// Patches .
+ /// Patches .
/// Adds the event.
///
[EventPatch(typeof(Map), nameof(Map.PlacingBulletHole))]
- [HarmonyPatch(typeof(StandardHitregBase), nameof(StandardHitregBase.PlaceBulletholeDecal))]
+ [HarmonyPatch(typeof(ImpactEffectsModule), nameof(ImpactEffectsModule.ServerSendImpactDecal))]
internal static class PlacingBulletHole
{
private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator)
@@ -50,11 +46,16 @@ private static IEnumerable Transpiler(IEnumerable
- /// Patches .
+ /// Patches .
/// To add the event.
///
[EventPatch(typeof(Handlers.Scp106), nameof(Handlers.Scp106.ExitStalking))]
- [HarmonyPatch(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.IsActive), MethodType.Setter)]
+ [HarmonyPatch(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.UpdateServerside))]
public class ExitStalking
{
private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator)
@@ -34,22 +34,17 @@ private static IEnumerable Transpiler(IEnumerable instruction.opcode == OpCodes.Newobj) + offset;
+
+ const int offset = -2;
+ int index = newInstructions.FindIndex(instruction => instruction.OperandIs(Method(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.ServerSetStalk), new[] { typeof(bool) }))) + offset;
newInstructions.InsertRange(
index,
- new CodeInstruction[]
+ new[]
{
- // if (value is false) continue;
- new CodeInstruction(OpCodes.Ldarg_1).MoveLabelsFrom(newInstructions[index]),
- new(OpCodes.Ldc_I4_0),
- new(OpCodes.Beq_S, continueLabel),
-
// Player.Get(this.Owner);
- new(OpCodes.Ldarg_0),
- new(OpCodes.Callvirt, PropertyGetter(typeof(Scp106HuntersAtlasAbility), nameof(Scp106HuntersAtlasAbility.Owner))),
+ new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]),
+ new(OpCodes.Callvirt, PropertyGetter(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.Owner))),
new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })),
// true
@@ -70,14 +65,10 @@ private static IEnumerable Transpiler(IEnumerable instruction.opcode == OpCodes.Newobj) + offset;
- newInstructions[index].labels.Add(continueLabel);
-
newInstructions[newInstructions.Count - 1].labels.Add(returnLabel);
- for (int z = 0; z < newInstructions.Count; z++)
- yield return newInstructions[z];
+ foreach (CodeInstruction instruction in newInstructions)
+ yield return instruction;
ListPool.Pool.Return(newInstructions);
}
diff --git a/Exiled.Events/Patches/Events/Scp106/Stalking.cs b/Exiled.Events/Patches/Events/Scp106/Stalking.cs
index 9098fd65e3..63bdc1c90b 100644
--- a/Exiled.Events/Patches/Events/Scp106/Stalking.cs
+++ b/Exiled.Events/Patches/Events/Scp106/Stalking.cs
@@ -35,15 +35,15 @@ private static IEnumerable Transpiler(IEnumerable instruction.operand == (object)PropertyGetter(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.IsActive))) + offset;
+ const int offset = -1;
+ int index = newInstructions.FindIndex(instruction => instruction.Calls(PropertyGetter(typeof(Scp106VigorAbilityBase), nameof(Scp106VigorAbilityBase.VigorAmount)))) + offset;
newInstructions.InsertRange(
index,
- new CodeInstruction[]
+ new[]
{
// Player.Get(this.Owner);
new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]),
- new(OpCodes.Callvirt, PropertyGetter(typeof(Scp106HuntersAtlasAbility), nameof(Scp106HuntersAtlasAbility.Owner))),
+ new(OpCodes.Callvirt, PropertyGetter(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.Owner))),
new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })),
// true
@@ -64,38 +64,8 @@ private static IEnumerable Transpiler(IEnumerable instruction.operand == (object)PropertySetter(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.IsActive))) + offset;
- newInstructions.InsertRange(
- index,
- new CodeInstruction[]
- {
- // Player.Get(this.Owner);
- new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]),
- new(OpCodes.Callvirt, PropertyGetter(typeof(Scp106HuntersAtlasAbility), nameof(Scp106HuntersAtlasAbility.Owner))),
- new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })),
-
- // true
- new(OpCodes.Ldc_I4_1),
-
- // StalkingEventArgs ev = new(Player, isAllowed)
- new(OpCodes.Newobj, GetDeclaredConstructors(typeof(StalkingEventArgs))[0]),
- new(OpCodes.Dup),
- new(OpCodes.Dup),
- new(OpCodes.Stloc_S, ev.LocalIndex),
-
- // Handlers.Scp106.OnStalking(ev)
- new(OpCodes.Call, Method(typeof(Handlers.Scp106), nameof(Handlers.Scp106.OnStalking))),
-
- // if (!ev.IsAllowed)
- // return;
- new(OpCodes.Callvirt, PropertyGetter(typeof(StalkingEventArgs), nameof(StalkingEventArgs.IsAllowed))),
- new(OpCodes.Brfalse_S, returnLabel),
- });
-
// replace "base.Vigor.VigorAmount < 0.25f" with "base.Vigor.VigorAmount < ev.MinimumVigor"
- offset = 0;
- index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Ldc_R4) + offset;
+ index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Ldc_R4);
newInstructions.RemoveAt(index);
newInstructions.InsertRange(
@@ -109,8 +79,8 @@ private static IEnumerable Transpiler(IEnumerable.Pool.Return(newInstructions);
}