From 6fd2568e2a8fbe25039bc665e5daf9d3bff137ab Mon Sep 17 00:00:00 2001
From: Yamato <66829532+louis1706@users.noreply.github.com>
Date: Mon, 27 Oct 2025 16:47:56 +0100
Subject: [PATCH 1/6] InfluenceEventArgs
---
.../Map/ModifyingFactionInfluenceEventArgs.cs | 70 +++++++++++++++
EXILED/Exiled.Events/Handlers/Map.cs | 11 +++
.../Events/Map/ModifyingFactionInfluence.cs | 86 +++++++++++++++++++
3 files changed, 167 insertions(+)
create mode 100644 EXILED/Exiled.Events/EventArgs/Map/ModifyingFactionInfluenceEventArgs.cs
create mode 100644 EXILED/Exiled.Events/Patches/Events/Map/ModifyingFactionInfluence.cs
diff --git a/EXILED/Exiled.Events/EventArgs/Map/ModifyingFactionInfluenceEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Map/ModifyingFactionInfluenceEventArgs.cs
new file mode 100644
index 0000000000..d789fdc920
--- /dev/null
+++ b/EXILED/Exiled.Events/EventArgs/Map/ModifyingFactionInfluenceEventArgs.cs
@@ -0,0 +1,70 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (c) ExMod Team. All rights reserved.
+// Licensed under the CC BY-SA 3.0 license.
+//
+// -----------------------------------------------------------------------
+
+namespace Exiled.Events.EventArgs.Map
+{
+ using System.Diagnostics;
+
+ using API.Features;
+
+ using Interfaces;
+
+ using PlayerRoles;
+
+ ///
+ /// Contains all information after activating a generator.
+ ///
+ public class ModifyingFactionInfluenceEventArgs : IDeniableEvent
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public ModifyingFactionInfluenceEventArgs(Team team, float influence, bool isAllowed = true)
+ {
+ Team = team;
+ Influence = influence;
+ IsAllowed = isAllowed;
+ _ = new StackFrame(4)?.GetMethod()?.Name;
+ /*
+ OnServerRoleSet (Escaping)
+ OnPlayerDamaged
+ OnKill
+ OnGeneratorEngaged
+ OnItemAdded
+ */
+ }
+
+ ///
+ /// Gets a value indicating where the Modification has been taken from.
+ ///
+ public string StackFrame { get; private set; }
+
+ ///
+ /// Gets or sets a value indicating whether team will get this influence.
+ ///
+ public Team Team { get; set; }
+
+ ///
+ /// Gets or sets a value indicating how much Influence will be changed.
+ ///
+ public float Influence { get; set; }
+
+ ///
+ /// Gets or sets a value indicating whether the generator can be activated.
+ ///
+ public bool IsAllowed { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/EXILED/Exiled.Events/Handlers/Map.cs b/EXILED/Exiled.Events/Handlers/Map.cs
index 4db303b36d..7707ebb9f2 100644
--- a/EXILED/Exiled.Events/Handlers/Map.cs
+++ b/EXILED/Exiled.Events/Handlers/Map.cs
@@ -50,6 +50,11 @@ public static class Map
///
public static Event GeneratorActivating { get; set; } = new();
+ ///
+ /// Invoked before influence got changed.
+ ///
+ public static Event ModifyingFactionInfluence { get; set; } = new();
+
///
/// Invoked before decontaminating the light containment zone.
///
@@ -161,6 +166,12 @@ public static class Map
/// The instance.
public static void OnGeneratorActivating(GeneratorActivatingEventArgs ev) => GeneratorActivating.InvokeSafely(ev);
+ ///
+ /// Called before influence got modified.
+ ///
+ /// The instance.
+ public static void OnModifyingFactionInfluence(ModifyingFactionInfluenceEventArgs ev) => ModifyingFactionInfluence.InvokeSafely(ev);
+
///
/// Called before decontaminating the light containment zone.
///
diff --git a/EXILED/Exiled.Events/Patches/Events/Map/ModifyingFactionInfluence.cs b/EXILED/Exiled.Events/Patches/Events/Map/ModifyingFactionInfluence.cs
new file mode 100644
index 0000000000..f6fccb741e
--- /dev/null
+++ b/EXILED/Exiled.Events/Patches/Events/Map/ModifyingFactionInfluence.cs
@@ -0,0 +1,86 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (c) ExMod Team. All rights reserved.
+// Licensed under the CC BY-SA 3.0 license.
+//
+// -----------------------------------------------------------------------
+
+namespace Exiled.Events.Patches.Events.Map
+{
+ using System.Collections.Generic;
+ using System.Diagnostics;
+ using System.Reflection.Emit;
+
+ using API.Features.Pools;
+ using Exiled.Events.Attributes;
+ using Exiled.Events.EventArgs.Map;
+
+ using Handlers;
+
+ using HarmonyLib;
+
+ using MapGeneration.Distributors;
+ using Respawning;
+
+ using static HarmonyLib.AccessTools;
+
+ ///
+ /// Patches .
+ /// Adds the event.
+ ///
+ [EventPatch(typeof(Map), nameof(Map.ModifyingFactionInfluence))]
+ [HarmonyPatch(typeof(FactionInfluenceManager), nameof(FactionInfluenceManager.Set))]
+ internal static class ModifyingFactionInfluence
+ {
+ private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator)
+ {
+ List newInstructions = ListPool.Pool.Get(instructions);
+
+ Label retModLabel = generator.DefineLabel();
+ Label returnLabel = generator.DefineLabel();
+
+ LocalBuilder ev = generator.DeclareLocal(typeof(ModifyingFactionInfluenceEventArgs));
+
+ // ModifyingFactionInfluenceEventArgs ev = new(this, true);
+ //
+ // Map.OnGeneratorActivated(ev);
+ //
+ // if (!ev.IsAllowed)
+ // return;
+ newInstructions.InsertRange(
+ 0,
+ new CodeInstruction[]
+ {
+ // faction
+ new(OpCodes.Ldarg_0),
+
+ // influence
+ new(OpCodes.Ldarg_1),
+
+ // true
+ new(OpCodes.Ldc_I4_1),
+
+ // ModifyingFactionInfluenceEventArgs ev = new(Team, float, bool)
+ new(OpCodes.Newobj, GetDeclaredConstructors(typeof(ModifyingFactionInfluenceEventArgs))[0]),
+ new(OpCodes.Dup),
+ new(OpCodes.Dup),
+ new(OpCodes.Stloc, ev.LocalIndex),
+
+ // Map.OnGeneratorActivated(ev)
+ new(OpCodes.Call, Method(typeof(Map), nameof(Map.OnModifyingFactionInfluence))),
+
+ // if (!ev.IsAllowed)
+ // return;
+ new(OpCodes.Callvirt, PropertyGetter(typeof(ModifyingFactionInfluenceEventArgs), nameof(ModifyingFactionInfluenceEventArgs.IsAllowed))),
+ new(OpCodes.Brfalse_S, returnLabel),
+ });
+
+ newInstructions[newInstructions.Count - 1].labels.Add(returnLabel);
+
+ for (int z = 0; z < newInstructions.Count; z++)
+ yield return newInstructions[z];
+
+ ListPool.Pool.Return(newInstructions);
+ }
+ }
+}
\ No newline at end of file
From 33f19bae42340a937628a71cc393ce187a67238e Mon Sep 17 00:00:00 2001
From: Yamato <66829532+louis1706@users.noreply.github.com>
Date: Mon, 27 Oct 2025 16:56:52 +0100
Subject: [PATCH 2/6] ObjectiveCompleting
---
...rgs.cs => ObjectiveCompletingEventArgs.cs} | 16 ++++----------
EXILED/Exiled.Events/Handlers/Map.cs | 6 +++---
...ionInfluence.cs => ObjectiveCompleting.cs} | 21 +++++++++----------
3 files changed, 17 insertions(+), 26 deletions(-)
rename EXILED/Exiled.Events/EventArgs/Map/{ModifyingFactionInfluenceEventArgs.cs => ObjectiveCompletingEventArgs.cs} (74%)
rename EXILED/Exiled.Events/Patches/Events/Map/{ModifyingFactionInfluence.cs => ObjectiveCompleting.cs} (77%)
diff --git a/EXILED/Exiled.Events/EventArgs/Map/ModifyingFactionInfluenceEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Map/ObjectiveCompletingEventArgs.cs
similarity index 74%
rename from EXILED/Exiled.Events/EventArgs/Map/ModifyingFactionInfluenceEventArgs.cs
rename to EXILED/Exiled.Events/EventArgs/Map/ObjectiveCompletingEventArgs.cs
index d789fdc920..8563cda3dc 100644
--- a/EXILED/Exiled.Events/EventArgs/Map/ModifyingFactionInfluenceEventArgs.cs
+++ b/EXILED/Exiled.Events/EventArgs/Map/ObjectiveCompletingEventArgs.cs
@@ -1,5 +1,5 @@
// -----------------------------------------------------------------------
-//
+//
// Copyright (c) ExMod Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
//
@@ -18,10 +18,10 @@ namespace Exiled.Events.EventArgs.Map
///
/// Contains all information after activating a generator.
///
- public class ModifyingFactionInfluenceEventArgs : IDeniableEvent
+ public class ObjectiveCompletingEventArgs : IDeniableEvent
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
///
///
@@ -32,19 +32,11 @@ public class ModifyingFactionInfluenceEventArgs : IDeniableEvent
///
///
///
- public ModifyingFactionInfluenceEventArgs(Team team, float influence, bool isAllowed = true)
+ public ObjectiveCompletingEventArgs(Team team, float influence, bool isAllowed = true)
{
Team = team;
Influence = influence;
IsAllowed = isAllowed;
- _ = new StackFrame(4)?.GetMethod()?.Name;
- /*
- OnServerRoleSet (Escaping)
- OnPlayerDamaged
- OnKill
- OnGeneratorEngaged
- OnItemAdded
- */
}
///
diff --git a/EXILED/Exiled.Events/Handlers/Map.cs b/EXILED/Exiled.Events/Handlers/Map.cs
index 7707ebb9f2..9096a3764e 100644
--- a/EXILED/Exiled.Events/Handlers/Map.cs
+++ b/EXILED/Exiled.Events/Handlers/Map.cs
@@ -53,7 +53,7 @@ public static class Map
///
/// Invoked before influence got changed.
///
- public static Event ModifyingFactionInfluence { get; set; } = new();
+ public static Event ObjectiveCompleting { get; set; } = new();
///
/// Invoked before decontaminating the light containment zone.
@@ -169,8 +169,8 @@ public static class Map
///
/// Called before influence got modified.
///
- /// The instance.
- public static void OnModifyingFactionInfluence(ModifyingFactionInfluenceEventArgs ev) => ModifyingFactionInfluence.InvokeSafely(ev);
+ /// The instance.
+ public static void OnObjectiveCompleting(ObjectiveCompletingEventArgs ev) => ObjectiveCompleting.InvokeSafely(ev);
///
/// Called before decontaminating the light containment zone.
diff --git a/EXILED/Exiled.Events/Patches/Events/Map/ModifyingFactionInfluence.cs b/EXILED/Exiled.Events/Patches/Events/Map/ObjectiveCompleting.cs
similarity index 77%
rename from EXILED/Exiled.Events/Patches/Events/Map/ModifyingFactionInfluence.cs
rename to EXILED/Exiled.Events/Patches/Events/Map/ObjectiveCompleting.cs
index f6fccb741e..f65d2877e5 100644
--- a/EXILED/Exiled.Events/Patches/Events/Map/ModifyingFactionInfluence.cs
+++ b/EXILED/Exiled.Events/Patches/Events/Map/ObjectiveCompleting.cs
@@ -1,5 +1,5 @@
// -----------------------------------------------------------------------
-//
+//
// Copyright (c) ExMod Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
//
@@ -19,18 +19,17 @@ namespace Exiled.Events.Patches.Events.Map
using HarmonyLib;
- using MapGeneration.Distributors;
using Respawning;
using static HarmonyLib.AccessTools;
///
/// Patches .
- /// Adds the event.
+ /// Adds the event.
///
- [EventPatch(typeof(Map), nameof(Map.ModifyingFactionInfluence))]
+ [EventPatch(typeof(Map), nameof(Map.ObjectiveCompleting))]
[HarmonyPatch(typeof(FactionInfluenceManager), nameof(FactionInfluenceManager.Set))]
- internal static class ModifyingFactionInfluence
+ internal static class ObjectiveCompleting
{
private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator)
{
@@ -39,9 +38,9 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable
Date: Mon, 27 Oct 2025 18:16:54 +0100
Subject: [PATCH 3/6] FixGeneratorActivatedObjective
---
.../Fixes/FixGeneratorActivatedObjective.cs | 58 +++++++++++++++++++
1 file changed, 58 insertions(+)
create mode 100644 EXILED/Exiled.Events/Patches/Fixes/FixGeneratorActivatedObjective.cs
diff --git a/EXILED/Exiled.Events/Patches/Fixes/FixGeneratorActivatedObjective.cs b/EXILED/Exiled.Events/Patches/Fixes/FixGeneratorActivatedObjective.cs
new file mode 100644
index 0000000000..ca481137ed
--- /dev/null
+++ b/EXILED/Exiled.Events/Patches/Fixes/FixGeneratorActivatedObjective.cs
@@ -0,0 +1,58 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (c) ExMod Team. All rights reserved.
+// Licensed under the CC BY-SA 3.0 license.
+//
+// -----------------------------------------------------------------------
+
+namespace Exiled.Events.Patches.Fixes
+{
+ using System.Collections.Generic;
+ using System.Reflection.Emit;
+
+ using API.Features.Pools;
+ using Footprinting;
+ using HarmonyLib;
+ using InventorySystem;
+ using InventorySystem.Items.Firearms.Ammo;
+ using InventorySystem.Items.Pickups;
+ using Respawning.Objectives;
+
+ using static HarmonyLib.AccessTools;
+
+ ///
+ /// Patches delegate.
+ /// Fix than LabAPI get an incorect value for when Scp079 is not prevent and than any change on timer for LabAPI will not be affected.
+ /// Reported at NW (https://git.scpslgame.com/northwood-qa/scpsl-bug-reporting/-/issues/2184).
+ ///
+ [HarmonyPatch(typeof(GeneratorActivatedObjective), nameof(GeneratorActivatedObjective.OnGeneratorEngaged))]
+ internal class FixGeneratorActivatedObjective
+ {
+ private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator)
+ {
+ List newInstructions = ListPool.Pool.Get(instructions);
+ Label jump = generator.DefineLabel();
+ int offset = 1;
+ int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Stloc_2) + offset;
+
+ newInstructions[index].labels.Add(jump);
+
+ newInstructions.InsertRange(index, new CodeInstruction[]
+ {
+ new(OpCodes.Ldloc_0),
+ new(OpCodes.Brtrue_S, jump),
+ new(OpCodes.Ldc_R4, 0f),
+ new(OpCodes.Stloc_2),
+ });
+
+ offset = 0;
+ index = newInstructions.FindLastIndex(instruction => instruction.opcode == OpCodes.Ldloc_0) + offset;
+ newInstructions.RemoveRange(index, 2);
+
+ for (int z = 0; z < newInstructions.Count; z++)
+ yield return newInstructions[z];
+
+ ListPool.Pool.Return(newInstructions);
+ }
+ }
+}
From d732e608f9e4f9fb191cf5eb094cf009002ffab3 Mon Sep 17 00:00:00 2001
From: Yamato <66829532+louis1706@users.noreply.github.com>
Date: Mon, 27 Oct 2025 18:17:09 +0100
Subject: [PATCH 4/6] better placement for the event
---
.../Map/ObjectiveCompletingEventArgs.cs | 31 ++-----
.../Patches/Events/Map/ObjectiveCompleting.cs | 87 +++++++++++--------
2 files changed, 58 insertions(+), 60 deletions(-)
diff --git a/EXILED/Exiled.Events/EventArgs/Map/ObjectiveCompletingEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Map/ObjectiveCompletingEventArgs.cs
index 8563cda3dc..926044b137 100644
--- a/EXILED/Exiled.Events/EventArgs/Map/ObjectiveCompletingEventArgs.cs
+++ b/EXILED/Exiled.Events/EventArgs/Map/ObjectiveCompletingEventArgs.cs
@@ -7,13 +7,10 @@
namespace Exiled.Events.EventArgs.Map
{
- using System.Diagnostics;
-
- using API.Features;
-
+ using Exiled.API.Features.Objectives;
using Interfaces;
-
using PlayerRoles;
+ using Respawning.Objectives;
///
/// Contains all information after activating a generator.
@@ -23,36 +20,22 @@ public class ObjectiveCompletingEventArgs : IDeniableEvent
///
/// Initializes a new instance of the class.
///
- ///
- ///
- ///
- ///
- ///
+ ///
+ ///
///
///
///
///
- public ObjectiveCompletingEventArgs(Team team, float influence, bool isAllowed = true)
+ public ObjectiveCompletingEventArgs(FactionObjectiveBase factionObjectiveBase, bool isAllowed = true)
{
- Team = team;
- Influence = influence;
+ Objective = Objective.Get(factionObjectiveBase);
IsAllowed = isAllowed;
}
///
/// Gets a value indicating where the Modification has been taken from.
///
- public string StackFrame { get; private set; }
-
- ///
- /// Gets or sets a value indicating whether team will get this influence.
- ///
- public Team Team { get; set; }
-
- ///
- /// Gets or sets a value indicating how much Influence will be changed.
- ///
- public float Influence { get; set; }
+ public Objective Objective { get; }
///
/// Gets or sets a value indicating whether the generator can be activated.
diff --git a/EXILED/Exiled.Events/Patches/Events/Map/ObjectiveCompleting.cs b/EXILED/Exiled.Events/Patches/Events/Map/ObjectiveCompleting.cs
index f65d2877e5..4ea880af13 100644
--- a/EXILED/Exiled.Events/Patches/Events/Map/ObjectiveCompleting.cs
+++ b/EXILED/Exiled.Events/Patches/Events/Map/ObjectiveCompleting.cs
@@ -8,18 +8,19 @@
namespace Exiled.Events.Patches.Events.Map
{
using System.Collections.Generic;
- using System.Diagnostics;
+ using System.Linq;
using System.Reflection.Emit;
using API.Features.Pools;
+ using Exiled.API.Extensions;
using Exiled.Events.Attributes;
using Exiled.Events.EventArgs.Map;
-
using Handlers;
-
using HarmonyLib;
-
+ using PlayerRoles;
using Respawning;
+ using Respawning.Objectives;
+ using Respawning.Waves;
using static HarmonyLib.AccessTools;
@@ -28,7 +29,7 @@ namespace Exiled.Events.Patches.Events.Map
/// Adds the event.
///
[EventPatch(typeof(Map), nameof(Map.ObjectiveCompleting))]
- [HarmonyPatch(typeof(FactionInfluenceManager), nameof(FactionInfluenceManager.Set))]
+ [HarmonyPatch(typeof(FactionObjectiveBase), nameof(FactionObjectiveBase.ServerSendUpdate))]
internal static class ObjectiveCompleting
{
private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator)
@@ -36,50 +37,64 @@ private static IEnumerable Transpiler(IEnumerable newInstructions = ListPool.Pool.Get(instructions);
Label retModLabel = generator.DefineLabel();
- Label returnLabel = generator.DefineLabel();
LocalBuilder ev = generator.DeclareLocal(typeof(ObjectiveCompletingEventArgs));
// ObjectiveCompletingEventArgs ev = new(this, true);
//
- // Map.OnGeneratorActivated(ev);
+ // Map.OnObjectiveCompleting(ev);
//
// if (!ev.IsAllowed)
// return;
- newInstructions.InsertRange(
- 0,
- new CodeInstruction[]
- {
- // faction
- new(OpCodes.Ldarg_0),
-
- // influence
- new(OpCodes.Ldarg_1),
-
- // true
- new(OpCodes.Ldc_I4_1),
-
- // ObjectiveCompletingEventArgs ev = new(Team, float, bool)
- new(OpCodes.Newobj, GetDeclaredConstructors(typeof(ObjectiveCompletingEventArgs))[0]),
- new(OpCodes.Dup),
- new(OpCodes.Dup),
- new(OpCodes.Stloc, ev.LocalIndex),
-
- // Map.OnGeneratorActivated(ev)
- new(OpCodes.Call, Method(typeof(Map), nameof(Map.OnObjectiveCompleting))),
-
- // if (!ev.IsAllowed)
- // return;
- new(OpCodes.Callvirt, PropertyGetter(typeof(ObjectiveCompletingEventArgs), nameof(ObjectiveCompletingEventArgs.IsAllowed))),
- new(OpCodes.Brfalse_S, returnLabel),
- });
-
- newInstructions[newInstructions.Count - 1].labels.Add(returnLabel);
+ newInstructions.InsertRange(0, new CodeInstruction[]
+ {
+ // this
+ new(OpCodes.Ldarg_0),
+
+ // true
+ new(OpCodes.Ldc_I4_1),
+
+ // ObjectiveCompletingEventArgs ev = new(FactionObjectiveBase, bool)
+ new(OpCodes.Newobj, GetDeclaredConstructors(typeof(ObjectiveCompletingEventArgs))[0]),
+ new(OpCodes.Dup),
+ new(OpCodes.Dup),
+ new(OpCodes.Stloc, ev.LocalIndex),
+
+ // Map.OnObjectiveCompleting(ev)
+ new(OpCodes.Call, Method(typeof(Map), nameof(Map.OnObjectiveCompleting))),
+
+ // if (!ev.IsAllowed)
+ // return;
+ new(OpCodes.Callvirt, PropertyGetter(typeof(ObjectiveCompletingEventArgs), nameof(ObjectiveCompletingEventArgs.IsAllowed))),
+ new(OpCodes.Brfalse_S, retModLabel),
+ });
+
+ newInstructions.InsertRange(newInstructions.Count, new CodeInstruction[]
+ {
+ // faction
+ new CodeInstruction(OpCodes.Ldarg_0).WithLabels(retModLabel),
+ new (OpCodes.Call, Method(typeof(ObjectiveCompleting), nameof(ObjectiveCompleting.RevertAllValue))),
+ });
for (int z = 0; z < newInstructions.Count; z++)
yield return newInstructions[z];
ListPool.Pool.Return(newInstructions);
}
+
+ private static void RevertAllValue(FactionObjectiveBase factionObjectiveBase)
+ {
+ if (factionObjectiveBase is IFootprintObjective footprintObjective)
+ {
+ FactionInfluenceManager.Remove(footprintObjective.ObjectiveFootprint.AchievingPlayer.RoleType.GetFaction(), -footprintObjective.ObjectiveFootprint.InfluenceReward);
+ foreach (TimeBasedWave wave in WaveManager.Waves.Cast())
+ {
+ if (wave.TargetFaction == footprintObjective.ObjectiveFootprint.AchievingPlayer.RoleType.GetFaction() && wave.ReceiveObjectiveRewards)
+ {
+ wave.Timer.AddTime(-footprintObjective.ObjectiveFootprint.TimeReward);
+ }
+ }
+ }
+ }
}
}
\ No newline at end of file
From 4ed9ef13fdbe8975780ec3c75aeb1f389a99c08d Mon Sep 17 00:00:00 2001
From: Yamato <66829532+louis1706@users.noreply.github.com>
Date: Mon, 27 Oct 2025 18:26:32 +0100
Subject: [PATCH 5/6] CompletingObjective update
---
.../Events/Server/CompletingObjective.cs | 38 ++++++++++++++++---
1 file changed, 32 insertions(+), 6 deletions(-)
diff --git a/EXILED/Exiled.Events/Patches/Events/Server/CompletingObjective.cs b/EXILED/Exiled.Events/Patches/Events/Server/CompletingObjective.cs
index cf9f9aacbe..e89320ea83 100644
--- a/EXILED/Exiled.Events/Patches/Events/Server/CompletingObjective.cs
+++ b/EXILED/Exiled.Events/Patches/Events/Server/CompletingObjective.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------
+// -----------------------------------------------------------------------
//
// Copyright (c) ExMod Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
@@ -8,13 +8,19 @@
namespace Exiled.Events.Patches.Events.Server
{
using System.Collections.Generic;
+ using System.Linq;
using System.Reflection.Emit;
using Exiled.API.Features.Pools;
using Exiled.Events.Attributes;
+ using Exiled.Events.EventArgs.Map;
using Exiled.Events.EventArgs.Server;
+ using Exiled.Events.Patches.Events.Map;
using HarmonyLib;
+ using PlayerRoles;
+ using Respawning;
using Respawning.Objectives;
+ using Respawning.Waves;
using static HarmonyLib.AccessTools;
@@ -30,7 +36,7 @@ private static IEnumerable Transpiler(IEnumerable newInstructions = ListPool.Pool.Get(instructions);
- Label returnLabel = generator.DefineLabel();
+ Label retModLabel = generator.DefineLabel();
newInstructions.InsertRange(0, new CodeInstruction[]
{
@@ -48,17 +54,37 @@ private static IEnumerable Transpiler(IEnumerable.Pool.Return(newInstructions);
}
+
+ private static void RevertAllValue(FactionObjectiveBase factionObjectiveBase)
+ {
+ if (factionObjectiveBase is IFootprintObjective footprintObjective)
+ {
+ FactionInfluenceManager.Remove(footprintObjective.ObjectiveFootprint.AchievingPlayer.RoleType.GetFaction(), -footprintObjective.ObjectiveFootprint.InfluenceReward);
+ foreach (TimeBasedWave wave in WaveManager.Waves.Cast())
+ {
+ if (wave.TargetFaction == footprintObjective.ObjectiveFootprint.AchievingPlayer.RoleType.GetFaction() && wave.ReceiveObjectiveRewards)
+ {
+ wave.Timer.AddTime(-footprintObjective.ObjectiveFootprint.TimeReward);
+ }
+ }
+ }
+ }
}
}
\ No newline at end of file
From 9dc2b1d7e7d885624cc94ee303c196ebdbc7fe53 Mon Sep 17 00:00:00 2001
From: Yamato <66829532+louis1706@users.noreply.github.com>
Date: Mon, 27 Oct 2025 18:28:22 +0100
Subject: [PATCH 6/6] Oups duplicate
---
.../Map/ObjectiveCompletingEventArgs.cs | 45 --------
EXILED/Exiled.Events/Handlers/Map.cs | 11 --
.../Patches/Events/Map/ObjectiveCompleting.cs | 100 ------------------
.../Events/Server/CompletingObjective.cs | 2 +-
4 files changed, 1 insertion(+), 157 deletions(-)
delete mode 100644 EXILED/Exiled.Events/EventArgs/Map/ObjectiveCompletingEventArgs.cs
delete mode 100644 EXILED/Exiled.Events/Patches/Events/Map/ObjectiveCompleting.cs
diff --git a/EXILED/Exiled.Events/EventArgs/Map/ObjectiveCompletingEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Map/ObjectiveCompletingEventArgs.cs
deleted file mode 100644
index 926044b137..0000000000
--- a/EXILED/Exiled.Events/EventArgs/Map/ObjectiveCompletingEventArgs.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-// -----------------------------------------------------------------------
-//
-// Copyright (c) ExMod Team. All rights reserved.
-// Licensed under the CC BY-SA 3.0 license.
-//
-// -----------------------------------------------------------------------
-
-namespace Exiled.Events.EventArgs.Map
-{
- using Exiled.API.Features.Objectives;
- using Interfaces;
- using PlayerRoles;
- using Respawning.Objectives;
-
- ///
- /// Contains all information after activating a generator.
- ///
- public class ObjectiveCompletingEventArgs : IDeniableEvent
- {
- ///
- /// Initializes a new instance of the class.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public ObjectiveCompletingEventArgs(FactionObjectiveBase factionObjectiveBase, bool isAllowed = true)
- {
- Objective = Objective.Get(factionObjectiveBase);
- IsAllowed = isAllowed;
- }
-
- ///
- /// Gets a value indicating where the Modification has been taken from.
- ///
- public Objective Objective { get; }
-
- ///
- /// Gets or sets a value indicating whether the generator can be activated.
- ///
- public bool IsAllowed { get; set; }
- }
-}
\ No newline at end of file
diff --git a/EXILED/Exiled.Events/Handlers/Map.cs b/EXILED/Exiled.Events/Handlers/Map.cs
index 9096a3764e..4db303b36d 100644
--- a/EXILED/Exiled.Events/Handlers/Map.cs
+++ b/EXILED/Exiled.Events/Handlers/Map.cs
@@ -50,11 +50,6 @@ public static class Map
///
public static Event GeneratorActivating { get; set; } = new();
- ///
- /// Invoked before influence got changed.
- ///
- public static Event ObjectiveCompleting { get; set; } = new();
-
///
/// Invoked before decontaminating the light containment zone.
///
@@ -166,12 +161,6 @@ public static class Map
/// The instance.
public static void OnGeneratorActivating(GeneratorActivatingEventArgs ev) => GeneratorActivating.InvokeSafely(ev);
- ///
- /// Called before influence got modified.
- ///
- /// The instance.
- public static void OnObjectiveCompleting(ObjectiveCompletingEventArgs ev) => ObjectiveCompleting.InvokeSafely(ev);
-
///
/// Called before decontaminating the light containment zone.
///
diff --git a/EXILED/Exiled.Events/Patches/Events/Map/ObjectiveCompleting.cs b/EXILED/Exiled.Events/Patches/Events/Map/ObjectiveCompleting.cs
deleted file mode 100644
index 4ea880af13..0000000000
--- a/EXILED/Exiled.Events/Patches/Events/Map/ObjectiveCompleting.cs
+++ /dev/null
@@ -1,100 +0,0 @@
-// -----------------------------------------------------------------------
-//
-// Copyright (c) ExMod Team. All rights reserved.
-// Licensed under the CC BY-SA 3.0 license.
-//
-// -----------------------------------------------------------------------
-
-namespace Exiled.Events.Patches.Events.Map
-{
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection.Emit;
-
- using API.Features.Pools;
- using Exiled.API.Extensions;
- using Exiled.Events.Attributes;
- using Exiled.Events.EventArgs.Map;
- using Handlers;
- using HarmonyLib;
- using PlayerRoles;
- using Respawning;
- using Respawning.Objectives;
- using Respawning.Waves;
-
- using static HarmonyLib.AccessTools;
-
- ///
- /// Patches .
- /// Adds the event.
- ///
- [EventPatch(typeof(Map), nameof(Map.ObjectiveCompleting))]
- [HarmonyPatch(typeof(FactionObjectiveBase), nameof(FactionObjectiveBase.ServerSendUpdate))]
- internal static class ObjectiveCompleting
- {
- private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator)
- {
- List newInstructions = ListPool.Pool.Get(instructions);
-
- Label retModLabel = generator.DefineLabel();
-
- LocalBuilder ev = generator.DeclareLocal(typeof(ObjectiveCompletingEventArgs));
-
- // ObjectiveCompletingEventArgs ev = new(this, true);
- //
- // Map.OnObjectiveCompleting(ev);
- //
- // if (!ev.IsAllowed)
- // return;
- newInstructions.InsertRange(0, new CodeInstruction[]
- {
- // this
- new(OpCodes.Ldarg_0),
-
- // true
- new(OpCodes.Ldc_I4_1),
-
- // ObjectiveCompletingEventArgs ev = new(FactionObjectiveBase, bool)
- new(OpCodes.Newobj, GetDeclaredConstructors(typeof(ObjectiveCompletingEventArgs))[0]),
- new(OpCodes.Dup),
- new(OpCodes.Dup),
- new(OpCodes.Stloc, ev.LocalIndex),
-
- // Map.OnObjectiveCompleting(ev)
- new(OpCodes.Call, Method(typeof(Map), nameof(Map.OnObjectiveCompleting))),
-
- // if (!ev.IsAllowed)
- // return;
- new(OpCodes.Callvirt, PropertyGetter(typeof(ObjectiveCompletingEventArgs), nameof(ObjectiveCompletingEventArgs.IsAllowed))),
- new(OpCodes.Brfalse_S, retModLabel),
- });
-
- newInstructions.InsertRange(newInstructions.Count, new CodeInstruction[]
- {
- // faction
- new CodeInstruction(OpCodes.Ldarg_0).WithLabels(retModLabel),
- new (OpCodes.Call, Method(typeof(ObjectiveCompleting), nameof(ObjectiveCompleting.RevertAllValue))),
- });
-
- for (int z = 0; z < newInstructions.Count; z++)
- yield return newInstructions[z];
-
- ListPool.Pool.Return(newInstructions);
- }
-
- private static void RevertAllValue(FactionObjectiveBase factionObjectiveBase)
- {
- if (factionObjectiveBase is IFootprintObjective footprintObjective)
- {
- FactionInfluenceManager.Remove(footprintObjective.ObjectiveFootprint.AchievingPlayer.RoleType.GetFaction(), -footprintObjective.ObjectiveFootprint.InfluenceReward);
- foreach (TimeBasedWave wave in WaveManager.Waves.Cast())
- {
- if (wave.TargetFaction == footprintObjective.ObjectiveFootprint.AchievingPlayer.RoleType.GetFaction() && wave.ReceiveObjectiveRewards)
- {
- wave.Timer.AddTime(-footprintObjective.ObjectiveFootprint.TimeReward);
- }
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/EXILED/Exiled.Events/Patches/Events/Server/CompletingObjective.cs b/EXILED/Exiled.Events/Patches/Events/Server/CompletingObjective.cs
index e89320ea83..7da7da50e1 100644
--- a/EXILED/Exiled.Events/Patches/Events/Server/CompletingObjective.cs
+++ b/EXILED/Exiled.Events/Patches/Events/Server/CompletingObjective.cs
@@ -55,7 +55,7 @@ private static IEnumerable Transpiler(IEnumerable