diff --git a/EXILED/Exiled.Events/EventArgs/Scp106/StalkingEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Scp106/StalkingEventArgs.cs index 1ed03bc424..dcfac59afa 100644 --- a/EXILED/Exiled.Events/EventArgs/Scp106/StalkingEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Scp106/StalkingEventArgs.cs @@ -24,12 +24,11 @@ public class StalkingEventArgs : IScp106Event, IDeniableEvent /// Initializes a new instance of the class. /// /// - /// - public StalkingEventArgs(Player player, bool isAllowed = true) + public StalkingEventArgs(Player player) { Player = player; Scp106 = player.Role.As(); - IsAllowed = isAllowed; + IsAllowed = true; MinimumVigor = Scp106StalkAbility.MinVigorToSubmerge; } @@ -66,6 +65,7 @@ public float Vigor /// /// Gets or sets a value indicating whether SCP-106 can stalk. /// + /// IsAllowed doesn't indicate whether vigor is sufficient for Stalking. needs to be changed to override the base game check. public bool IsAllowed { get; set; } } } \ No newline at end of file diff --git a/EXILED/Exiled.Events/Patches/Events/Scp106/Stalking.cs b/EXILED/Exiled.Events/Patches/Events/Scp106/Stalking.cs index 977f8075c8..2ffad3da94 100644 --- a/EXILED/Exiled.Events/Patches/Events/Scp106/Stalking.cs +++ b/EXILED/Exiled.Events/Patches/Events/Scp106/Stalking.cs @@ -36,48 +36,19 @@ private static IEnumerable Transpiler(IEnumerable instruction.operand == (object)PropertyGetter(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.StalkActive))) + offset; + int offset = -1; + int index = newInstructions.FindIndex(instruction => instruction.Calls(PropertyGetter(typeof(Scp106VigorAbilityBase), nameof(Scp106VigorAbilityBase.VigorAmount)))) + offset; newInstructions.InsertRange( index, new CodeInstruction[] { + // Inserted before vigor amount check // 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 - 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.OnFinishingRecall(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), - }); - - newInstructions.InsertRange( - newInstructions.Count - 1, - 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) + // StalkingEventArgs ev = new(Player) new(OpCodes.Newobj, GetDeclaredConstructors(typeof(StalkingEventArgs))[0]), new(OpCodes.Dup), new(OpCodes.Dup), @@ -87,7 +58,7 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable