From becc70ab2ee1bac8afbd85156538e051414aa864 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Mon, 31 Jul 2023 18:10:09 +0200 Subject: [PATCH 001/207] Rework Scp049 Event --- .../Scp049/ActivatingSenseEventArgs.cs | 10 +- .../Scp049/ConsumingCorpseEventArgs.cs | 15 +- .../EventArgs/Scp049/SendingCallEventArgs.cs | 8 +- .../Patches/Events/Scp049/ActivatingSense.cs | 143 ++++++++++-------- .../Patches/Events/Scp049/Consuming.cs | 103 ++++++------- .../Patches/Events/Scp049/SendingCall.cs | 79 ++++++---- 6 files changed, 195 insertions(+), 163 deletions(-) diff --git a/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs b/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs index 91a695915f..036b42f2ae 100644 --- a/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- // // Copyright (c) Exiled Team. All rights reserved. // Licensed under the CC BY-SA 3.0 license. @@ -10,7 +10,7 @@ namespace Exiled.Events.EventArgs.Scp049 using API.Features; using Interfaces; - + using PlayerRoles; using PlayerRoles.PlayableScps.Scp049; /// @@ -29,7 +29,7 @@ public ActivatingSenseEventArgs(Player player, Player target, bool isAllowed = t Player = player; Target = target; IsAllowed = isAllowed; - Cooldown = Scp049SenseAbility.AttemptFailCooldown; + FailedCooldown = Scp049SenseAbility.AttemptFailCooldown; Duration = Scp049SenseAbility.EffectDuration; } @@ -46,10 +46,10 @@ public ActivatingSenseEventArgs(Player player, Player target, bool isAllowed = t /// /// Gets or sets the cooldown of the ability. /// - public float Cooldown { get; set; } + public float FailedCooldown { get; set; } /// - /// Gets or sets the duration of the ability. + /// Gets or sets the duration of the Effect. /// public float Duration { get; set; } diff --git a/Exiled.Events/EventArgs/Scp049/ConsumingCorpseEventArgs.cs b/Exiled.Events/EventArgs/Scp049/ConsumingCorpseEventArgs.cs index 3d0ffe3a3e..9c228482da 100644 --- a/Exiled.Events/EventArgs/Scp049/ConsumingCorpseEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp049/ConsumingCorpseEventArgs.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- // // Copyright (c) Exiled Team. All rights reserved. // Licensed under the CC BY-SA 3.0 license. @@ -7,6 +7,8 @@ namespace Exiled.Events.EventArgs.Scp049 { + using System; + using API.Features; using Interfaces; @@ -23,14 +25,13 @@ public class ConsumingCorpseEventArgs : IPlayerEvent, IRagdollEvent, IDeniableEv /// /// /// - /// /// /// See for all RagDolls consumed. - public ConsumingCorpseEventArgs(Player player, Ragdoll ragDoll, ZombieConsumeAbility.ConsumeError error, bool isAllowed = true) + public ConsumingCorpseEventArgs(Player player, Ragdoll ragDoll, bool isAllowed = true) { Player = player; Ragdoll = ragDoll; - ErrorCode = error; + ConsumeHeal = ZombieConsumeAbility.ConsumeHeal; IsAllowed = isAllowed; } @@ -44,9 +45,15 @@ public ConsumingCorpseEventArgs(Player player, Ragdoll ragDoll, ZombieConsumeAbi /// public Ragdoll Ragdoll { get; } + /// + /// Gets or sets a value indicating whether 049-2 can consume a corpse. + /// + public float ConsumeHeal { get; set; } + /// /// Gets or sets error code to send back to client. /// + [Obsolete("Removed", true)] public ZombieConsumeAbility.ConsumeError ErrorCode { get; set; } /// diff --git a/Exiled.Events/EventArgs/Scp049/SendingCallEventArgs.cs b/Exiled.Events/EventArgs/Scp049/SendingCallEventArgs.cs index 49699f6d5b..90ab3e03e8 100644 --- a/Exiled.Events/EventArgs/Scp049/SendingCallEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp049/SendingCallEventArgs.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- // // Copyright (c) Exiled Team. All rights reserved. // Licensed under the CC BY-SA 3.0 license. @@ -10,6 +10,7 @@ namespace Exiled.Events.EventArgs.Scp049 using API.Features; using Interfaces; + using PlayerRoles.PlayableScps.Scp049; /// /// Contains all information before SCP-049 Call is activated. @@ -20,12 +21,11 @@ public class SendingCallEventArgs : IPlayerEvent, IDeniableEvent /// Initializes a new instance of the class. /// /// - /// /// - public SendingCallEventArgs(Player player, float duration, bool isAllowed = true) + public SendingCallEventArgs(Player player, bool isAllowed = true) { Player = player; - Duration = duration; + Duration = Scp049CallAbility.EffectDuration; IsAllowed = isAllowed; } diff --git a/Exiled.Events/Patches/Events/Scp049/ActivatingSense.cs b/Exiled.Events/Patches/Events/Scp049/ActivatingSense.cs index 4b7a1808ea..ca467bf3c9 100644 --- a/Exiled.Events/Patches/Events/Scp049/ActivatingSense.cs +++ b/Exiled.Events/Patches/Events/Scp049/ActivatingSense.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- // // Copyright (c) Exiled Team. All rights reserved. // Licensed under the CC BY-SA 3.0 license. @@ -14,15 +14,13 @@ namespace Exiled.Events.Patches.Events.Scp049 using Exiled.API.Features.Pools; using Exiled.Events.EventArgs.Scp049; - using HarmonyLib; - using Mirror; using PlayerRoles; using PlayerRoles.PlayableScps; using PlayerRoles.PlayableScps.Scp049; - + using PlayerRoles.PlayableScps.Subroutines; using Utils.Networking; using static HarmonyLib.AccessTools; @@ -31,24 +29,86 @@ namespace Exiled.Events.Patches.Events.Scp049 /// Patches . /// Adds the event. /// - // TODO: REWORK TRANSPILER - [HarmonyPatch] + [HarmonyPatch(typeof(Scp049SenseAbility), nameof(Scp049SenseAbility.ServerProcessCmd))] public class ActivatingSense { - [HarmonyTranspiler] - [HarmonyPatch(typeof(Scp049SenseAbility), nameof(Scp049SenseAbility.ServerProcessCmd))] - private static IEnumerable OnSendingSense(IEnumerable instructions, ILGenerator generator) + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) { List newInstructions = ListPool.Pool.Get(instructions); + + int offset = 1; + int index = newInstructions.FindIndex(instruction => instruction.operand == (object)PropertySetter(typeof(Scp049SenseAbility), nameof(Scp049SenseAbility.Target))) + offset; + + LocalBuilder ev = generator.DeclareLocal(typeof(FinishingRecallEventArgs)); + Label returnLabel = generator.DefineLabel(); - newInstructions.InsertRange(0, new CodeInstruction[] - { - new(OpCodes.Ldarg_0), - new(OpCodes.Ldarg_1), - new(OpCodes.Call, Method(typeof(ActivatingSense), nameof(ProcessSense))), - new(OpCodes.Br, returnLabel), - }); + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // Player.Get(base.Owner) + new(OpCodes.Ldarg_0), + new(OpCodes.Call, PropertyGetter(typeof(ScpStandardSubroutine), nameof(ScpStandardSubroutine.Owner))), + new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), + + // Player.Get(this.Target) + new(OpCodes.Ldarg_0), + new(OpCodes.Call, PropertyGetter(typeof(Scp049SenseAbility), nameof(Scp049SenseAbility.Target))), + new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), + + // true + new(OpCodes.Ldc_I4_1), + + // ActivatingSenseEventArgs ev = new(player, target, isAllowed) + new(OpCodes.Newobj, GetDeclaredConstructors(typeof(ActivatingSenseEventArgs))[0]), + new(OpCodes.Dup), + new(OpCodes.Dup), + new(OpCodes.Stloc_S, ev.LocalIndex), + + // Handlers.Scp049.OnFinishingRecall(ev) + new(OpCodes.Call, Method(typeof(Handlers.Scp049), nameof(Handlers.Scp049.OnActivatingSense))), + + // if (!ev.IsAllowed) + // return; + new(OpCodes.Callvirt, PropertyGetter(typeof(ActivatingSenseEventArgs), nameof(ActivatingSenseEventArgs.IsAllowed))), + new(OpCodes.Brfalse_S, returnLabel), + + // this.Target = ev.Target + new(OpCodes.Ldarg_0), + new(OpCodes.Ldloc_S, ev.LocalIndex), + new(OpCodes.Callvirt, PropertyGetter(typeof(ActivatingSenseEventArgs), nameof(ActivatingSenseEventArgs.Target))), + new(OpCodes.Callvirt, PropertyGetter(typeof(Player), nameof(Player.ReferenceHub))), + new(OpCodes.Call, PropertySetter(typeof(Scp049SenseAbility), nameof(Scp049SenseAbility.Target))), + }); + + // replace "this.Cooldown.Trigger(2.5)" with "this.Cooldown.Trigger(ev.FailedCooldown)" + offset = -1; + index = newInstructions.FindIndex(instruction => instruction.operand == (object)PropertySetter(typeof(AbilityCooldown), nameof(AbilityCooldown.Trigger))) + offset; + newInstructions.RemoveAt(index); + + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // ev.FailedCooldown + new(OpCodes.Ldloc_S, ev.LocalIndex), + new(OpCodes.Callvirt, PropertyGetter(typeof(ActivatingSenseEventArgs), nameof(ActivatingSenseEventArgs.FailedCooldown))), + }); + + // replace "this.Duration.Trigger(20.0)" with "this.Duration.Trigger(ev.Duration)" + offset = -1; + index = newInstructions.FindLastIndex(instruction => instruction.operand == (object)PropertySetter(typeof(AbilityCooldown), nameof(AbilityCooldown.Trigger))) + offset; + newInstructions.RemoveAt(index); + + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // ev.Duration + new(OpCodes.Ldloc_S, ev.LocalIndex), + new(OpCodes.Callvirt, PropertyGetter(typeof(ActivatingSenseEventArgs), nameof(ActivatingSenseEventArgs.Duration))), + }); newInstructions[newInstructions.Count - 1].WithLabels(returnLabel); @@ -57,56 +117,5 @@ private static IEnumerable OnSendingSense(IEnumerable.Pool.Return(newInstructions); } - - /// - /// Process the Sense Ability for the Event. - /// - /// 049's ability. - /// to get from network data. - private static void ProcessSense(Scp049SenseAbility senseAbility, NetworkReader reader) - { - if (!senseAbility.Cooldown.IsReady || !senseAbility.Duration.IsReady) - return; - - Player scp049 = Player.Get(senseAbility.Owner); - var target = Player.Get(reader.ReadReferenceHub()); - - if ((target is not null && target.RoleManager.CurrentRole.RoleTypeId == RoleTypeId.Tutorial && !Exiled.Events.Events.Instance.Config.CanScp049SenseTutorial) || API.Features.Roles.Scp049Role.TurnedPlayers.Contains(target)) - { - senseAbility.Cooldown.Trigger(Scp049SenseAbility.AttemptFailCooldown); - senseAbility.HasTarget = false; - senseAbility.ServerSendRpc(true); - return; - } - - var ev = new ActivatingSenseEventArgs(scp049, target); - Handlers.Scp049.OnActivatingSense(ev); - - if (!ev.IsAllowed) - return; - - senseAbility._distanceThreshold = 100f; - senseAbility.HasTarget = false; - senseAbility.Target = ev.Target?.ReferenceHub; - - if (senseAbility.Target == null) - { - senseAbility.Cooldown.Trigger(ev.Cooldown); - senseAbility.ServerSendRpc(true); - return; - } - - HumanRole humanRole; - if ((humanRole = target?.RoleManager.CurrentRole as HumanRole) == null) - return; - - senseAbility._distanceThreshold = 100f; - if (!VisionInformation.GetVisionInformation(senseAbility.Owner, senseAbility.Owner.PlayerCameraReference, humanRole.CameraPosition, humanRole.FpcModule.CharController.radius, senseAbility._distanceThreshold, true, true, 0).IsLooking) - return; - - senseAbility.Duration.Trigger(ev.Duration); - senseAbility.HasTarget = true; - senseAbility.ServerSendRpc(true); - } } } \ No newline at end of file diff --git a/Exiled.Events/Patches/Events/Scp049/Consuming.cs b/Exiled.Events/Patches/Events/Scp049/Consuming.cs index a11cdaa876..69c024b761 100644 --- a/Exiled.Events/Patches/Events/Scp049/Consuming.cs +++ b/Exiled.Events/Patches/Events/Scp049/Consuming.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- // // Copyright (c) Exiled Team. All rights reserved. // Licensed under the CC BY-SA 3.0 license. @@ -20,83 +20,80 @@ namespace Exiled.Events.Patches.Events.Scp049 using PlayerRoles; using PlayerRoles.PlayableScps.Scp049; using PlayerRoles.PlayableScps.Scp049.Zombies; - + using PlayerRoles.PlayableScps.Subroutines; + using PlayerStatsSystem; using UnityEngine; using static HarmonyLib.AccessTools; /// - /// Patches - /// RagdollAbilityBase{T}.ServerProcessCmd - /// - /// . /// Adds the event. /// - // TODO: REWORK TRANSPILER - [HarmonyPatch] + [HarmonyPatch(typeof(ZombieConsumeAbility), nameof(ZombieConsumeAbility.ServerProcessCmd))] public class Consuming { - [HarmonyTranspiler] - [HarmonyPatch(typeof(RagdollAbilityBase), nameof(RagdollAbilityBase.ServerProcessCmd))] - private static IEnumerable OnConsumingCorpse(IEnumerable instructions, ILGenerator generator) + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) { List newInstructions = ListPool.Pool.Get(instructions); - int offset = -1; - int index = newInstructions.FindLastIndex(instrc => instrc.LoadsField(Field(typeof(RagdollAbilityBase), nameof(RagdollAbilityBase._errorCode)))) + offset; - Label retLabel = generator.DefineLabel(); - newInstructions.InsertRange(index, new CodeInstruction[] - { - new (OpCodes.Ldarg_0), - new (OpCodes.Call, Method(typeof(Consuming), nameof(Consuming.ServerProcessConsume))), - new (OpCodes.Br, retLabel), - }); + LocalBuilder ev = generator.DeclareLocal(typeof(ConsumingCorpseEventArgs)); - newInstructions[newInstructions.Count - 1].WithLabels(retLabel); + int offset = 1; + int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Ret) + offset; - for (int z = 0; z < newInstructions.Count; z++) - yield return newInstructions[z]; + Label returnLabel = generator.DefineLabel(); - ListPool.Pool.Return(newInstructions); - } + newInstructions.InsertRange( + index, + new[] + { + // Player.Get(base.Owner) + new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]), + new(OpCodes.Call, PropertyGetter(typeof(ScpStandardSubroutine), nameof(ScpStandardSubroutine.Owner))), + new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), - /// - /// Processes RagDoll ability for the Zombie interaction. - /// - /// parameterized . - private static void ServerProcessConsume(RagdollAbilityBase zombieAbility) - { - Transform transform = zombieAbility._ragdollTransform; + // base.CurRagdoll + new CodeInstruction(OpCodes.Ldarg_0), + new(OpCodes.Call, PropertyGetter(typeof(RagdollAbilityBase), nameof(RagdollAbilityBase.CurRagdoll))), - Ragdoll currentRagDoll = Ragdoll.Get(zombieAbility.CurRagdoll); + // true + new(OpCodes.Ldc_I4_1), - Player zombiePlayer = Player.Get(zombieAbility.Owner); + // ConsumingCorpseEventArgs ev = new(Player, Ragdoll, bool) + new(OpCodes.Newobj, GetDeclaredConstructors(typeof(ConsumingCorpseEventArgs))[0]), + new(OpCodes.Dup), + new(OpCodes.Dup), + new(OpCodes.Stloc_S, ev.LocalIndex), - ZombieConsumeAbility.ConsumeError errorCode = (ZombieConsumeAbility.ConsumeError)zombieAbility._errorCode; + // Handlers.Scp049.OnSendingCall(ev) + new(OpCodes.Call, Method(typeof(Handlers.Scp049), nameof(Handlers.Scp049.OnConsumingCorpse))), - if (zombiePlayer.Role.Type != RoleTypeId.Scp049) - { - ConsumingCorpseEventArgs ev = new(zombiePlayer, currentRagDoll, errorCode); - Handlers.Scp049.OnConsumingCorpse(ev); + // if (!ev.IsAllowed) + // return; + new(OpCodes.Callvirt, PropertyGetter(typeof(ConsumingCorpseEventArgs), nameof(ConsumingCorpseEventArgs.IsAllowed))), + new(OpCodes.Brfalse_S, returnLabel), + }); - if (!ev.IsAllowed) - return; + // replace "base.Owner.playerStats.GetModule().ServerHeal(100f)" with "base.Owner.playerStats.GetModule().ServerHeal(ev.ConsumeHeal)" + offset = -1; + index = newInstructions.FindIndex(instruction => instruction.operand == (object)Method(typeof(HealthStat), nameof(HealthStat.ServerHeal))) + offset; + newInstructions.RemoveAt(index); - currentRagDoll = ev.Ragdoll; - errorCode = ev.ErrorCode; - } + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // ev.ConsumeHeal + new(OpCodes.Ldloc_S, ev.LocalIndex), + new(OpCodes.Callvirt, PropertyGetter(typeof(ConsumingCorpseEventArgs), nameof(ConsumingCorpseEventArgs.ConsumeHeal))), + }); - bool errorCodeFlag = errorCode != ZombieConsumeAbility.ConsumeError.None; + newInstructions[newInstructions.Count - 1].WithLabels(returnLabel); - if (errorCodeFlag) - { - zombieAbility._ragdollTransform = transform; - zombieAbility.CurRagdoll = currentRagDoll.Base; - zombieAbility.ServerSendRpc(true); - return; - } + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; - zombieAbility.IsInProgress = true; + ListPool.Pool.Return(newInstructions); } } } \ No newline at end of file diff --git a/Exiled.Events/Patches/Events/Scp049/SendingCall.cs b/Exiled.Events/Patches/Events/Scp049/SendingCall.cs index c23fc49e06..a46ce16e94 100644 --- a/Exiled.Events/Patches/Events/Scp049/SendingCall.cs +++ b/Exiled.Events/Patches/Events/Scp049/SendingCall.cs @@ -17,6 +17,7 @@ namespace Exiled.Events.Patches.Events.Scp049 using HarmonyLib; using PlayerRoles.PlayableScps.Scp049; + using PlayerRoles.PlayableScps.Subroutines; using static HarmonyLib.AccessTools; @@ -24,23 +25,60 @@ namespace Exiled.Events.Patches.Events.Scp049 /// Patches . /// Adds the event. /// - // TODO: REWORK TRANSPILER - [HarmonyPatch] + [HarmonyPatch(typeof(Scp049CallAbility), nameof(Scp049CallAbility.ServerProcessCmd))] public class SendingCall { - [HarmonyTranspiler] - [HarmonyPatch(typeof(Scp049CallAbility), nameof(Scp049CallAbility.ServerProcessCmd))] - private static IEnumerable OnSendingCall(IEnumerable instructions, ILGenerator generator) + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) { List newInstructions = ListPool.Pool.Get(instructions); + + LocalBuilder ev = generator.DeclareLocal(typeof(SendingCallEventArgs)); + + int offset = 1; + int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Ret) + offset; + Label returnLabel = generator.DefineLabel(); - newInstructions.InsertRange(0, new CodeInstruction[] - { - new(OpCodes.Ldarg_0), - new(OpCodes.Call, Method(typeof(SendingCall), nameof(SendingCall.ProcessCall))), - new(OpCodes.Br, returnLabel), - }); + newInstructions.InsertRange( + index, + new[] + { + // Player.Get(ownerHub) + new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]), + new(OpCodes.Call, PropertyGetter(typeof(ScpStandardSubroutine), nameof(ScpStandardSubroutine.Owner))), + new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), + + // true + new(OpCodes.Ldc_I4_1), + + // SendingCallEventArgs ev = new(Player, float, bool) + new(OpCodes.Newobj, GetDeclaredConstructors(typeof(SendingCallEventArgs))[0]), + new(OpCodes.Dup), + new(OpCodes.Dup), + new(OpCodes.Stloc_S, ev.LocalIndex), + + // Handlers.Scp049.OnSendingCall(ev) + new(OpCodes.Call, Method(typeof(Handlers.Scp049), nameof(Handlers.Scp049.OnSendingCall))), + + // if (!ev.IsAllowed) + // return; + new(OpCodes.Callvirt, PropertyGetter(typeof(SendingCallEventArgs), nameof(SendingCallEventArgs.IsAllowed))), + new(OpCodes.Brfalse_S, returnLabel), + }); + + // replace "this.Duration.Trigger(20.0)" with "this.Duration.Trigger(ev.Duration)" + offset = -1; + index = newInstructions.FindIndex(instruction => instruction.operand == (object)PropertySetter(typeof(AbilityCooldown), nameof(AbilityCooldown.Trigger))) + offset; + newInstructions.RemoveAt(index); + + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // ev.Duration + new(OpCodes.Ldloc_S, ev.LocalIndex), + new(OpCodes.Callvirt, PropertyGetter(typeof(SendingCallEventArgs), nameof(SendingCallEventArgs.Duration))), + }); newInstructions[newInstructions.Count - 1].WithLabels(returnLabel); @@ -49,24 +87,5 @@ private static IEnumerable OnSendingCall(IEnumerable.Pool.Return(newInstructions); } - - /// - /// Process's Scp049 call ability. - /// - /// . - private static void ProcessCall(Scp049CallAbility callAbility) - { - Player currentScp = Player.Get(callAbility.Owner); - float duration = Scp049CallAbility.EffectDuration; - - var ev = new SendingCallEventArgs(currentScp, duration, !callAbility._serverTriggered && callAbility.Cooldown.IsReady); - Handlers.Scp049.OnSendingCall(ev); - - if (!ev.IsAllowed) - return; - callAbility.Duration.Trigger(ev.Duration); - callAbility._serverTriggered = true; - callAbility.ServerSendRpc(true); - } } } \ No newline at end of file From de7a5f6686505d6a9812a564ffec15b1b9d33404 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Mon, 31 Jul 2023 20:42:31 +0200 Subject: [PATCH 002/207] IScp049Event --- Exiled.API/Features/Roles/Scp049Role.cs | 25 +++++++++++++++++++ .../EventArgs/Interfaces/IScp049Event.cs | 22 ++++++++++++++++ .../Scp049/ActivatingSenseEventArgs.cs | 14 ++++++----- .../EventArgs/Scp049/AttackingEventArgs.cs | 9 +++++-- .../Scp049/ConsumingCorpseEventArgs.cs | 2 +- .../Scp049/FinishingRecallEventArgs.cs | 10 +++++--- .../EventArgs/Scp049/SendingCallEventArgs.cs | 11 +++++--- .../Scp049/StartingRecallEventArgs.cs | 8 ++++-- 8 files changed, 83 insertions(+), 18 deletions(-) create mode 100644 Exiled.Events/EventArgs/Interfaces/IScp049Event.cs diff --git a/Exiled.API/Features/Roles/Scp049Role.cs b/Exiled.API/Features/Roles/Scp049Role.cs index 640bfed577..c20e413df3 100644 --- a/Exiled.API/Features/Roles/Scp049Role.cs +++ b/Exiled.API/Features/Roles/Scp049Role.cs @@ -118,6 +118,31 @@ internal Scp049Role(Scp049GameRole baseRole) /// public HashSet DeadZombies => Scp049ResurrectAbility.DeadZombies; + /// + /// Gets or sets . + /// + public double CallAbilityDuration { get; set; } = Scp049CallAbility.EffectDuration; + + /// + /// Gets or sets . + /// + public double CallAbilityBaseCooldown { get; set; } = Scp049CallAbility.BaseCooldown; + + /// + /// Gets or sets . + /// + public double SenseAbilityBaseCooldown { get; set; } = Scp049SenseAbility.BaseCooldown; + + /// + /// Gets or sets . + /// + public double SenseAbilityDuration { get; set; } = Scp049SenseAbility.EffectDuration; + + /// + /// Gets or sets . + /// + public double SenseAbilityFailCooldown { get; set; } = Scp049SenseAbility.AttemptFailCooldown; + /// /// Gets all the resurrected players. /// diff --git a/Exiled.Events/EventArgs/Interfaces/IScp049Event.cs b/Exiled.Events/EventArgs/Interfaces/IScp049Event.cs new file mode 100644 index 0000000000..fa4008f5b7 --- /dev/null +++ b/Exiled.Events/EventArgs/Interfaces/IScp049Event.cs @@ -0,0 +1,22 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Interfaces +{ + using Exiled.API.Features.Roles; + + /// + /// Event args used for all related events. + /// + public interface IScp049Event : IExiledEvent + { + /// + /// Gets the triggering the event. + /// + public Scp049Role Scp049 { get; } + } +} \ No newline at end of file diff --git a/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs b/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs index 036b42f2ae..6034c49aa0 100644 --- a/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs @@ -8,15 +8,13 @@ namespace Exiled.Events.EventArgs.Scp049 { using API.Features; - + using Exiled.API.Features.Roles; using Interfaces; - using PlayerRoles; - using PlayerRoles.PlayableScps.Scp049; /// /// Contains all information before SCP-049 sense is activated. /// - public class ActivatingSenseEventArgs : IPlayerEvent, IDeniableEvent + public class ActivatingSenseEventArgs : IScp049Event, IPlayerEvent, IDeniableEvent { /// /// Initializes a new instance of the class with information before SCP-049 sense is activated. @@ -27,12 +25,16 @@ public class ActivatingSenseEventArgs : IPlayerEvent, IDeniableEvent public ActivatingSenseEventArgs(Player player, Player target, bool isAllowed = true) { Player = player; + Scp049 = player.Role.As(); Target = target; IsAllowed = isAllowed; - FailedCooldown = Scp049SenseAbility.AttemptFailCooldown; - Duration = Scp049SenseAbility.EffectDuration; + FailedCooldown = (float)Scp049.SenseAbilityFailCooldown; + Duration = (float)Scp049.SenseAbilityDuration; } + /// + public Scp049Role Scp049 { get; } + /// /// Gets the Player who is playing as SCP-049. /// diff --git a/Exiled.Events/EventArgs/Scp049/AttackingEventArgs.cs b/Exiled.Events/EventArgs/Scp049/AttackingEventArgs.cs index 0bd18c33fa..35d9196057 100644 --- a/Exiled.Events/EventArgs/Scp049/AttackingEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp049/AttackingEventArgs.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- // // Copyright (c) Exiled Team. All rights reserved. // Licensed under the CC BY-SA 3.0 license. @@ -8,12 +8,13 @@ namespace Exiled.Events.EventArgs.Scp049 { using Exiled.API.Features; + using Exiled.API.Features.Roles; using Exiled.Events.EventArgs.Interfaces; /// /// Contains all information before SCP-049 attacks player. /// - public class AttackingEventArgs : IPlayerEvent, IDeniableEvent + public class AttackingEventArgs : IScp049Event, IPlayerEvent, IDeniableEvent { /// /// Initializes a new instance of the class. @@ -24,10 +25,14 @@ public class AttackingEventArgs : IPlayerEvent, IDeniableEvent public AttackingEventArgs(Player player, Player target, bool isAllowed = true) { Player = player; + Scp049 = player.Role.As(); Target = target; IsAllowed = isAllowed; } + /// + public Scp049Role Scp049 { get; } + /// /// Gets the player controlling SCP-049. /// diff --git a/Exiled.Events/EventArgs/Scp049/ConsumingCorpseEventArgs.cs b/Exiled.Events/EventArgs/Scp049/ConsumingCorpseEventArgs.cs index 9c228482da..6b86990e6c 100644 --- a/Exiled.Events/EventArgs/Scp049/ConsumingCorpseEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp049/ConsumingCorpseEventArgs.cs @@ -46,7 +46,7 @@ public ConsumingCorpseEventArgs(Player player, Ragdoll ragDoll, bool isAllowed = public Ragdoll Ragdoll { get; } /// - /// Gets or sets a value indicating whether 049-2 can consume a corpse. + /// Gets or sets a value about how mush heath the Zombie will get. /// public float ConsumeHeal { get; set; } diff --git a/Exiled.Events/EventArgs/Scp049/FinishingRecallEventArgs.cs b/Exiled.Events/EventArgs/Scp049/FinishingRecallEventArgs.cs index d175d63d4f..8ba0875c5a 100644 --- a/Exiled.Events/EventArgs/Scp049/FinishingRecallEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp049/FinishingRecallEventArgs.cs @@ -8,13 +8,13 @@ namespace Exiled.Events.EventArgs.Scp049 { using API.Features; - + using Exiled.API.Features.Roles; using Interfaces; /// /// Contains all information before SCP-049 finishes recalling a player. /// - public class FinishingRecallEventArgs : IPlayerEvent, IDeniableEvent + public class FinishingRecallEventArgs : IScp049Event, IPlayerEvent, IDeniableEvent { /// /// Initializes a new instance of the class. @@ -33,12 +33,16 @@ public class FinishingRecallEventArgs : IPlayerEvent, IDeniableEvent /// public FinishingRecallEventArgs(Player target, Player scp049, BasicRagdoll ragdoll, bool isAllowed = true) { - Target = target; Player = scp049; + Scp049 = Player.Role.As(); + Target = target; Ragdoll = Ragdoll.Get(ragdoll); IsAllowed = isAllowed; } + /// + public Scp049Role Scp049 { get; } + /// /// Gets the player who is controlling SCP-049. /// diff --git a/Exiled.Events/EventArgs/Scp049/SendingCallEventArgs.cs b/Exiled.Events/EventArgs/Scp049/SendingCallEventArgs.cs index 90ab3e03e8..ddcffc74fb 100644 --- a/Exiled.Events/EventArgs/Scp049/SendingCallEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp049/SendingCallEventArgs.cs @@ -8,14 +8,13 @@ namespace Exiled.Events.EventArgs.Scp049 { using API.Features; - + using Exiled.API.Features.Roles; using Interfaces; - using PlayerRoles.PlayableScps.Scp049; /// /// Contains all information before SCP-049 Call is activated. /// - public class SendingCallEventArgs : IPlayerEvent, IDeniableEvent + public class SendingCallEventArgs : IScp049Event, IPlayerEvent, IDeniableEvent { /// /// Initializes a new instance of the class. @@ -25,10 +24,14 @@ public class SendingCallEventArgs : IPlayerEvent, IDeniableEvent public SendingCallEventArgs(Player player, bool isAllowed = true) { Player = player; - Duration = Scp049CallAbility.EffectDuration; + Scp049 = Player.Role.As(); + Duration = (float)Scp049.CallAbilityBaseCooldown; IsAllowed = isAllowed; } + /// + public Scp049Role Scp049 { get; } + /// /// Gets the player who is controlling SCP-049. /// diff --git a/Exiled.Events/EventArgs/Scp049/StartingRecallEventArgs.cs b/Exiled.Events/EventArgs/Scp049/StartingRecallEventArgs.cs index a0c03f5027..b7b86470b9 100644 --- a/Exiled.Events/EventArgs/Scp049/StartingRecallEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp049/StartingRecallEventArgs.cs @@ -8,13 +8,13 @@ namespace Exiled.Events.EventArgs.Scp049 { using API.Features; - + using Exiled.API.Features.Roles; using Interfaces; /// /// Contains all information before SCP-049 begins recalling a player. /// - public class StartingRecallEventArgs : IPlayerEvent, IRagdollEvent, IDeniableEvent + public class StartingRecallEventArgs : IScp049Event, IPlayerEvent, IRagdollEvent, IDeniableEvent { /// /// Initializes a new instance of the class. @@ -35,10 +35,14 @@ public StartingRecallEventArgs(Player target, Player scp049, Ragdoll ragdoll, bo { Target = target; Player = scp049; + Scp049 = Player.Role.As(); Ragdoll = ragdoll; IsAllowed = isAllowed; } + /// + public Scp049Role Scp049 { get; } + /// /// Gets the player who's getting recalled. /// From 7acf7b3bd9730c2ddd62e3e7630b694d4f36b348 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Mon, 31 Jul 2023 21:07:21 +0200 Subject: [PATCH 003/207] Adding Patch for Scp079Role Property --- .../Generic/Scp079API/CallAbilityDuration.cs | 63 ++++++++++++++++++ .../Scp079API/SenseAbilityBaseCooldown.cs | 64 +++++++++++++++++++ 2 files changed, 127 insertions(+) create mode 100644 Exiled.Events/Patches/Generic/Scp079API/CallAbilityDuration.cs create mode 100644 Exiled.Events/Patches/Generic/Scp079API/SenseAbilityBaseCooldown.cs diff --git a/Exiled.Events/Patches/Generic/Scp079API/CallAbilityDuration.cs b/Exiled.Events/Patches/Generic/Scp079API/CallAbilityDuration.cs new file mode 100644 index 0000000000..a06395c78a --- /dev/null +++ b/Exiled.Events/Patches/Generic/Scp079API/CallAbilityDuration.cs @@ -0,0 +1,63 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Generic.Scp079API +{ + using System.Collections.Generic; + using System.Reflection.Emit; + + using API.Features.Pools; + using Exiled.API.Features; + using HarmonyLib; + using PlayerRoles.PlayableScps.Scp049; + using PlayerRoles.PlayableScps.Subroutines; + + using static HarmonyLib.AccessTools; + + using BaseScp049Role = PlayerRoles.PlayableScps.Scp049.Scp049Role; + using Scp049Role = API.Features.Roles.Scp049Role; + + /// + /// Patches . + /// Adds the property. + /// + [HarmonyPatch(typeof(Scp049CallAbility), nameof(Scp049CallAbility.ServerProcessCmd))] + internal class CallAbilityDuration + { + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) + { + List newInstructions = ListPool.Pool.Get(instructions); + + LocalBuilder scp049Role = generator.DeclareLocal(typeof(Scp049Role)); + + // replace "this.Duration.Trigger(20.0)" with "this.Duration.Trigger((Player.Get(base.Owner).Role as Scp049Role).CallAbilityDuration)" + int offset = -1; + int index = newInstructions.FindIndex(instruction => instruction.operand == (object)Method(typeof(AbilityCooldown), nameof(AbilityCooldown.Trigger))) + offset; + newInstructions.RemoveAt(index); + + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // Player.Get(base.Owner).Role + new(OpCodes.Ldarg_0), + new(OpCodes.Call, PropertyGetter(typeof(ScpStandardSubroutine), nameof(ScpStandardSubroutine.Owner))), + new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), + new(OpCodes.Callvirt, PropertyGetter(typeof(Player), nameof(Player.Role))), + + // (Player.Get(base.Owner).Role as Scp049Role).CallAbilityDuration + new(OpCodes.Isinst, typeof(Scp049Role)), + new(OpCodes.Callvirt, PropertyGetter(typeof(Scp049Role), nameof(Scp049Role.CallAbilityDuration))), + }); + + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; + + ListPool.Pool.Return(newInstructions); + } + } +} \ No newline at end of file diff --git a/Exiled.Events/Patches/Generic/Scp079API/SenseAbilityBaseCooldown.cs b/Exiled.Events/Patches/Generic/Scp079API/SenseAbilityBaseCooldown.cs new file mode 100644 index 0000000000..ba615bf087 --- /dev/null +++ b/Exiled.Events/Patches/Generic/Scp079API/SenseAbilityBaseCooldown.cs @@ -0,0 +1,64 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Generic.Scp079API +{ + using System.Collections.Generic; + using System.Reflection.Emit; + + using API.Features.Pools; + using Exiled.API.Features; + + using HarmonyLib; + using PlayerRoles.PlayableScps.Scp049; + using PlayerRoles.PlayableScps.Subroutines; + + using static HarmonyLib.AccessTools; + + using BaseScp049Role = PlayerRoles.PlayableScps.Scp049.Scp049Role; + using Scp049Role = API.Features.Roles.Scp049Role; + + /// + /// Patches . + /// Adds the property. + /// + [HarmonyPatch(typeof(Scp049SenseAbility), nameof(Scp049SenseAbility.ServerProcessKilledPlayer))] + internal class SenseAbilityBaseCooldown + { + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) + { + List newInstructions = ListPool.Pool.Get(instructions); + + LocalBuilder scp049Role = generator.DeclareLocal(typeof(Scp049Role)); + + // replace "this.Duration.Trigger(40.0)" with "this.Duration.Trigger((Player.Get(base.Owner).Role as Scp049Role).SenseAbilityBaseCooldown)" + int offset = -1; + int index = newInstructions.FindIndex(instruction => instruction.operand == (object)Method(typeof(AbilityCooldown), nameof(AbilityCooldown.Trigger))) + offset; + newInstructions.RemoveAt(index); + + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // Player.Get(base.Owner).Role + new(OpCodes.Ldarg_0), + new(OpCodes.Call, PropertyGetter(typeof(ScpStandardSubroutine), nameof(ScpStandardSubroutine.Owner))), + new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), + new(OpCodes.Callvirt, PropertyGetter(typeof(Player), nameof(Player.Role))), + + // (Player.Get(base.Owner).Role as Scp049Role).SenseAbilityBaseCooldown + new(OpCodes.Isinst, typeof(Scp049Role)), + new(OpCodes.Callvirt, PropertyGetter(typeof(Scp049Role), nameof(Scp049Role.SenseAbilityBaseCooldown))), + }); + + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; + + ListPool.Pool.Return(newInstructions); + } + } +} \ No newline at end of file From 3f03db3df24bbd296346871f3222e0317c9fe9b0 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Mon, 31 Jul 2023 21:39:15 +0200 Subject: [PATCH 004/207] Doc + Miss SenseAbilityReducedCooldown --- Exiled.API/Features/Roles/Scp049Role.cs | 15 +++-- .../Scp079API/SenseAbilityReducedCooldown.cs | 64 +++++++++++++++++++ 2 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 Exiled.Events/Patches/Generic/Scp079API/SenseAbilityReducedCooldown.cs diff --git a/Exiled.API/Features/Roles/Scp049Role.cs b/Exiled.API/Features/Roles/Scp049Role.cs index c20e413df3..2f84fb6a95 100644 --- a/Exiled.API/Features/Roles/Scp049Role.cs +++ b/Exiled.API/Features/Roles/Scp049Role.cs @@ -119,27 +119,32 @@ internal Scp049Role(Scp049GameRole baseRole) public HashSet DeadZombies => Scp049ResurrectAbility.DeadZombies; /// - /// Gets or sets . + /// Gets or sets how mush time the Call Ability will be effective. /// public double CallAbilityDuration { get; set; } = Scp049CallAbility.EffectDuration; /// - /// Gets or sets . + /// Gets or sets the Cooldown of the Call Ability. /// public double CallAbilityBaseCooldown { get; set; } = Scp049CallAbility.BaseCooldown; /// - /// Gets or sets . + /// Gets or sets the Cooldown of the Sense Ability. /// public double SenseAbilityBaseCooldown { get; set; } = Scp049SenseAbility.BaseCooldown; /// - /// Gets or sets . + /// Gets or sets the Cooldown of the Sense Ability when you lost your target. + /// + public double SenseAbilityReducedCooldown { get; set; } = Scp049SenseAbility.ReducedCooldown; + + /// + /// Gets or sets the Cooldown of the Sense Ability when it's failed. /// public double SenseAbilityDuration { get; set; } = Scp049SenseAbility.EffectDuration; /// - /// Gets or sets . + /// Gets or sets how mush time the Sense Ability will be effective. /// public double SenseAbilityFailCooldown { get; set; } = Scp049SenseAbility.AttemptFailCooldown; diff --git a/Exiled.Events/Patches/Generic/Scp079API/SenseAbilityReducedCooldown.cs b/Exiled.Events/Patches/Generic/Scp079API/SenseAbilityReducedCooldown.cs new file mode 100644 index 0000000000..a8526a996c --- /dev/null +++ b/Exiled.Events/Patches/Generic/Scp079API/SenseAbilityReducedCooldown.cs @@ -0,0 +1,64 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Generic.Scp079API +{ + using System.Collections.Generic; + using System.Reflection.Emit; + + using API.Features.Pools; + using Exiled.API.Features; + + using HarmonyLib; + using PlayerRoles.PlayableScps.Scp049; + using PlayerRoles.PlayableScps.Subroutines; + + using static HarmonyLib.AccessTools; + + using BaseScp049Role = PlayerRoles.PlayableScps.Scp049.Scp049Role; + using Scp049Role = API.Features.Roles.Scp049Role; + + /// + /// Patches . + /// Adds the property. + /// + [HarmonyPatch(typeof(Scp049SenseAbility), nameof(Scp049SenseAbility.ServerLoseTarget))] + internal class SenseAbilityReducedCooldown + { + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) + { + List newInstructions = ListPool.Pool.Get(instructions); + + LocalBuilder scp049Role = generator.DeclareLocal(typeof(Scp049Role)); + + // replace "this.Duration.Trigger(40.0)" with "this.Duration.Trigger((Player.Get(base.Owner).Role as Scp049Role).SenseAbilityReducedCooldown)" + int offset = -1; + int index = newInstructions.FindIndex(instruction => instruction.operand == (object)Method(typeof(AbilityCooldown), nameof(AbilityCooldown.Trigger))) + offset; + newInstructions.RemoveAt(index); + + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // Player.Get(base.Owner).Role + new(OpCodes.Ldarg_0), + new(OpCodes.Call, PropertyGetter(typeof(ScpStandardSubroutine), nameof(ScpStandardSubroutine.Owner))), + new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), + new(OpCodes.Callvirt, PropertyGetter(typeof(Player), nameof(Player.Role))), + + // (Player.Get(base.Owner).Role as Scp049Role).SenseAbilityReducedCooldown + new(OpCodes.Isinst, typeof(Scp049Role)), + new(OpCodes.Callvirt, PropertyGetter(typeof(Scp049Role), nameof(Scp049Role.SenseAbilityReducedCooldown))), + }); + + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; + + ListPool.Pool.Return(newInstructions); + } + } +} \ No newline at end of file From 3e7005d71e726a01675846add06855e9b15dcd9a Mon Sep 17 00:00:00 2001 From: louis1706 Date: Mon, 31 Jul 2023 21:42:32 +0200 Subject: [PATCH 005/207] Update API + oups --- Exiled.API/Features/Roles/Scp049Role.cs | 6 +++--- .../Generic/Scp079API/SenseAbilityReducedCooldown.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Exiled.API/Features/Roles/Scp049Role.cs b/Exiled.API/Features/Roles/Scp049Role.cs index 2f84fb6a95..9817838226 100644 --- a/Exiled.API/Features/Roles/Scp049Role.cs +++ b/Exiled.API/Features/Roles/Scp049Role.cs @@ -296,7 +296,7 @@ public void Attack(Player player) } SenseAbility.HasTarget = false; - SenseAbility.Cooldown.Trigger(Scp049SenseAbility.ReducedCooldown); + SenseAbility.Cooldown.Trigger(SenseAbilityBaseCooldown); SenseAbility.ServerSendRpc(true); AttackAbility.ServerSendRpc(true); @@ -317,7 +317,7 @@ public void Sense(Player player) if (SenseAbility.Target is null) { - SenseAbility.Cooldown.Trigger(Scp049SenseAbility.AttemptFailCooldown); + SenseAbility.Cooldown.Trigger(SenseAbilityFailCooldown); SenseAbility.ServerSendRpc(true); return; } @@ -330,7 +330,7 @@ public void Sense(Player player) if (!VisionInformation.GetVisionInformation(SenseAbility.Owner, SenseAbility.Owner.PlayerCameraReference, humanRole.CameraPosition, radius, SenseAbility._distanceThreshold).IsLooking) return; - SenseAbility.Duration.Trigger(Scp049SenseAbility.ReducedCooldown); + SenseAbility.Duration.Trigger(SenseAbilityDuration); SenseAbility.HasTarget = true; SenseAbility.ServerSendRpc(true); } diff --git a/Exiled.Events/Patches/Generic/Scp079API/SenseAbilityReducedCooldown.cs b/Exiled.Events/Patches/Generic/Scp079API/SenseAbilityReducedCooldown.cs index a8526a996c..b4c351abda 100644 --- a/Exiled.Events/Patches/Generic/Scp079API/SenseAbilityReducedCooldown.cs +++ b/Exiled.Events/Patches/Generic/Scp079API/SenseAbilityReducedCooldown.cs @@ -1,5 +1,5 @@ // ----------------------------------------------------------------------- -// +// // Copyright (c) Exiled Team. All rights reserved. // Licensed under the CC BY-SA 3.0 license. // From 2ac085cf003352d0c57b3eb1f3414dabe8dd5f97 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Tue, 1 Aug 2023 18:48:54 +0200 Subject: [PATCH 006/207] OUPS --- .../Generic/{Scp079API => Scp049API}/CallAbilityDuration.cs | 0 .../Generic/{Scp079API => Scp049API}/SenseAbilityBaseCooldown.cs | 0 .../{Scp079API => Scp049API}/SenseAbilityReducedCooldown.cs | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename Exiled.Events/Patches/Generic/{Scp079API => Scp049API}/CallAbilityDuration.cs (100%) rename Exiled.Events/Patches/Generic/{Scp079API => Scp049API}/SenseAbilityBaseCooldown.cs (100%) rename Exiled.Events/Patches/Generic/{Scp079API => Scp049API}/SenseAbilityReducedCooldown.cs (100%) diff --git a/Exiled.Events/Patches/Generic/Scp079API/CallAbilityDuration.cs b/Exiled.Events/Patches/Generic/Scp049API/CallAbilityDuration.cs similarity index 100% rename from Exiled.Events/Patches/Generic/Scp079API/CallAbilityDuration.cs rename to Exiled.Events/Patches/Generic/Scp049API/CallAbilityDuration.cs diff --git a/Exiled.Events/Patches/Generic/Scp079API/SenseAbilityBaseCooldown.cs b/Exiled.Events/Patches/Generic/Scp049API/SenseAbilityBaseCooldown.cs similarity index 100% rename from Exiled.Events/Patches/Generic/Scp079API/SenseAbilityBaseCooldown.cs rename to Exiled.Events/Patches/Generic/Scp049API/SenseAbilityBaseCooldown.cs diff --git a/Exiled.Events/Patches/Generic/Scp079API/SenseAbilityReducedCooldown.cs b/Exiled.Events/Patches/Generic/Scp049API/SenseAbilityReducedCooldown.cs similarity index 100% rename from Exiled.Events/Patches/Generic/Scp079API/SenseAbilityReducedCooldown.cs rename to Exiled.Events/Patches/Generic/Scp049API/SenseAbilityReducedCooldown.cs From 94eb4e76e90648911792fa4b4ebec0c06381994f Mon Sep 17 00:00:00 2001 From: louis1706 Date: Mon, 7 Aug 2023 11:12:56 +0200 Subject: [PATCH 007/207] Fix BreakingChange --- .../EventArgs/Scp049/ActivatingSenseEventArgs.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs b/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs index 6034c49aa0..720a086a26 100644 --- a/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs @@ -7,6 +7,8 @@ namespace Exiled.Events.EventArgs.Scp049 { + using System; + using API.Features; using Exiled.API.Features.Roles; using Interfaces; @@ -50,6 +52,12 @@ public ActivatingSenseEventArgs(Player player, Player target, bool isAllowed = t /// public float FailedCooldown { get; set; } + /// + /// Gets or sets the cooldown of the ability. + /// + [Obsolete("Use FailedCooldown instead of this")] + public float Cooldown { get => FailedCooldown; set => FailedCooldown = value; } + /// /// Gets or sets the duration of the Effect. /// From fac0f3748f2aec8abc51ed71a703c24eb16c1bcf Mon Sep 17 00:00:00 2001 From: louis1706 Date: Mon, 7 Aug 2023 20:30:28 +0200 Subject: [PATCH 008/207] Few fix --- Exiled.API/Features/Roles/Scp079Role.cs | 38 ++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/Exiled.API/Features/Roles/Scp079Role.cs b/Exiled.API/Features/Roles/Scp079Role.cs index e3b0ed5483..abf1fa1c57 100644 --- a/Exiled.API/Features/Roles/Scp079Role.cs +++ b/Exiled.API/Features/Roles/Scp079Role.cs @@ -388,13 +388,44 @@ public bool LockDoor(Door door) if (door is not null) { DoorLockChanger.LockedDoor = door.Base; - door.Lock((float)DoorLockChanger._lockTime, DoorLockType.Regular079); + DoorLockChanger._lockTime = NetworkTime.time; + DoorLockChanger.LockedDoor.ServerChangeLock(DoorLockReason.Regular079, true); + if (door.Room is not null) + MarkRoom(door.Room); + AuxManager.CurrentAux -= DoorLockChanger.GetCostForDoor(DoorAction.Locked, DoorLockChanger.LockedDoor); return true; } return false; } + /// + /// Locks the provided . + /// + /// The door to lock. + /// if the door has been lock; otherwise, . + /// Indicates if the energy cost should be consumed or not. + public bool LockDoor(Door door, bool consumeEnergy = true) + { + if (door is not null) + { + DoorLockChanger.LockedDoor = door.Base; + DoorLockChanger._lockTime = NetworkTime.time; + DoorLockChanger.LockedDoor.ServerChangeLock(DoorLockReason.Regular079, true); + MarkRoom(door.Room); + if (consumeEnergy) + AuxManager.CurrentAux -= GetCost(door, DoorAction.Locked); + return true; + } + + return false; + } + + /// + /// Unlocks the . + /// + public void UnlockDoor() => LockedDoor?.Unlock(); + /// /// Unlocks the provided . /// @@ -500,10 +531,9 @@ public void BlackoutZone(bool consumeEnergy = true) /// Indicates if the energy cost should be consumed or not. public void Ping(Vector3 position, PingType pingType = PingType.Default, bool consumeEnergy = true) { - var relativePosition = new RelativePosition(position); - PingAbility._syncPos = relativePosition; + PingAbility._syncPos = new(position); PingAbility._syncNormal = position; - pingType = (PingType)PingAbility._syncProcessorIndex; + PingAbility._syncProcessorIndex = (byte)pingType; PingAbility.ServerSendRpc(x => PingAbility.ServerCheckReceiver(x, PingAbility._syncPos.Position, (int)pingType)); From b425c241829b3997b332e039e0ed974f04246822 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Mon, 7 Aug 2023 20:33:23 +0200 Subject: [PATCH 009/207] BRUH --- Exiled.API/Features/Roles/Scp079Role.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.API/Features/Roles/Scp079Role.cs b/Exiled.API/Features/Roles/Scp079Role.cs index abf1fa1c57..735ac146e1 100644 --- a/Exiled.API/Features/Roles/Scp079Role.cs +++ b/Exiled.API/Features/Roles/Scp079Role.cs @@ -474,7 +474,7 @@ public void UnmarkRoom(Room room) /// /// The camera to get the cost to switch to. /// The cost to switch from the current camera to the new camera. - public int GetSwitchCost(Camera camera) => camera is null ? CurrentCameraSync.GetSwitchCost(camera.Base) : 0; + public int GetSwitchCost(Camera camera) => camera is null ? 0 : CurrentCameraSync.GetSwitchCost(camera.Base); /// /// Gets the cost to modify a door. From 624ab0589308d2ee916bc65350a71617beb3dd90 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Wed, 9 Aug 2023 16:00:19 +0200 Subject: [PATCH 010/207] Scp106ReworkTranspiller --- .../EventArgs/Scp106/ExitStalkingEventArgs.cs | 50 +++++++ .../EventArgs/Scp106/StalkingEventArgs.cs | 30 +++-- Exiled.Events/Handlers/Scp106.cs | 11 ++ .../Patches/Events/Scp106/ExitStalking.cs | 83 ++++++++++++ .../Patches/Events/Scp106/Stalking.cs | 125 +++++++++++------- .../Patches/Events/Scp106/Teleporting.cs | 2 +- 6 files changed, 243 insertions(+), 58 deletions(-) create mode 100644 Exiled.Events/EventArgs/Scp106/ExitStalkingEventArgs.cs create mode 100644 Exiled.Events/Patches/Events/Scp106/ExitStalking.cs diff --git a/Exiled.Events/EventArgs/Scp106/ExitStalkingEventArgs.cs b/Exiled.Events/EventArgs/Scp106/ExitStalkingEventArgs.cs new file mode 100644 index 0000000000..cc8416bd97 --- /dev/null +++ b/Exiled.Events/EventArgs/Scp106/ExitStalkingEventArgs.cs @@ -0,0 +1,50 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Scp106 +{ + using System; + + using API.Features; + using Interfaces; + using PlayerRoles.PlayableScps.Scp106; + + using Scp106Role = API.Features.Roles.Scp106Role; + + /// + /// Contains all information before SCP-106 use the stalk ability. + /// + public class ExitStalkingEventArgs : IPlayerEvent, IDeniableEvent + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + public ExitStalkingEventArgs(Player player, bool isAllowed = true) + { + Player = player; + Scp106 = player.Role.As(); + IsAllowed = isAllowed; + } + + /// + /// Gets the player who's controlling SCP-106. + /// + public Player Player { get; } + + /// + /// Gets the player who's controlling SCP-106. + /// + public Scp106Role Scp106 { get; } + + /// + /// Gets or sets a value indicating whether or not SCP-106 can stalk. + /// + public bool IsAllowed { get; set; } + } +} \ No newline at end of file diff --git a/Exiled.Events/EventArgs/Scp106/StalkingEventArgs.cs b/Exiled.Events/EventArgs/Scp106/StalkingEventArgs.cs index 534a297bdc..8e9784fdde 100644 --- a/Exiled.Events/EventArgs/Scp106/StalkingEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp106/StalkingEventArgs.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- // // Copyright (c) Exiled Team. All rights reserved. // Licensed under the CC BY-SA 3.0 license. @@ -7,12 +7,14 @@ namespace Exiled.Events.EventArgs.Scp106 { - using API.Features; + using System; + using API.Features; using Interfaces; - using PlayerRoles.PlayableScps.Scp106; + using Scp106Role = API.Features.Roles.Scp106Role; + /// /// Contains all information before SCP-106 use the stalk ability. /// @@ -22,26 +24,31 @@ public class StalkingEventArgs : IPlayerEvent, IDeniableEvent /// Initializes a new instance of the class. /// /// - /// /// - public StalkingEventArgs(Player player, Scp106StalkAbility scp106StalkAbility, bool isAllowed = true) + public StalkingEventArgs(Player player, bool isAllowed = true) { Player = player; - Scp106StalkAbility = scp106StalkAbility; + Scp106 = player.Role.As(); IsAllowed = isAllowed; - Vigor = scp106StalkAbility.Vigor.VigorAmount; MinimumVigor = Scp106StalkAbility.MinVigorToSubmerge; } /// /// Gets the . /// - public Scp106StalkAbility Scp106StalkAbility { get; } + [Obsolete("Use Scp106.StalkAbility instead of this")] + public Scp106StalkAbility Scp106StalkAbility => Scp106.StalkAbility; /// /// Gets or sets the current vigor when SCP-106 starts to stalk. /// - public float Vigor { get; set; } + public float Vigor + { + [Obsolete("Use Scp106.Vigor instead of this")] + get => Scp106StalkAbility.Vigor.VigorAmount; + [Obsolete("Use Scp106.Vigor instead of this")] + set => Scp106StalkAbility.Vigor.VigorAmount = value; + } /// /// Gets or sets the required minimum vigor to stalk. @@ -53,6 +60,11 @@ public StalkingEventArgs(Player player, Scp106StalkAbility scp106StalkAbility, b /// public Player Player { get; } + /// + /// Gets the player who's controlling SCP-106. + /// + public Scp106Role Scp106 { get; } + /// /// Gets or sets a value indicating whether or not SCP-106 can stalk. /// diff --git a/Exiled.Events/Handlers/Scp106.cs b/Exiled.Events/Handlers/Scp106.cs index 0426daea07..b6470b3e52 100644 --- a/Exiled.Events/Handlers/Scp106.cs +++ b/Exiled.Events/Handlers/Scp106.cs @@ -33,6 +33,11 @@ public static class Scp106 /// public static event CustomEventHandler Stalking; + /// + /// Invoked before SCP-106 exit the stalk ability. + /// + public static event CustomEventHandler ExitStalking; + /// /// Called before SCP-106 attacks player. /// @@ -50,5 +55,11 @@ public static class Scp106 /// /// The instance. public static void OnStalking(StalkingEventArgs ev) => Stalking.InvokeSafely(ev); + + /// + /// Called before SCP-106 exit the stalk ability. + /// + /// The instance. + public static void OnExitStalking(ExitStalkingEventArgs ev) => ExitStalking.InvokeSafely(ev); } } \ No newline at end of file diff --git a/Exiled.Events/Patches/Events/Scp106/ExitStalking.cs b/Exiled.Events/Patches/Events/Scp106/ExitStalking.cs new file mode 100644 index 0000000000..4b3b8e50e5 --- /dev/null +++ b/Exiled.Events/Patches/Events/Scp106/ExitStalking.cs @@ -0,0 +1,83 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Events.Scp106 +{ + using System.Collections.Generic; + using System.Reflection; + using System.Reflection.Emit; + + using API.Features; + using API.Features.Pools; + + using Exiled.Events.EventArgs.Scp106; + using HarmonyLib; + + using PlayerRoles.PlayableScps.Scp106; + + using static HarmonyLib.AccessTools; + + /// + /// Patches . + /// To add the event. + /// + [HarmonyPatch(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.IsActive), MethodType.Setter)] + public class ExitStalking + { + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) + { + List newInstructions = ListPool.Pool.Get(instructions); + + LocalBuilder ev = generator.DeclareLocal(typeof(StalkingEventArgs)); + + Label continueLabel = generator.DefineLabel(); + Label returnLabel = generator.DefineLabel(); + int offset = -3; + int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Newobj) + offset; + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // if (value is true) continue; + new CodeInstruction(OpCodes.Ldarg_1).MoveLabelsFrom(newInstructions[index]), + new(OpCodes.Ldc_I4_1), + new(OpCodes.Beq_S, continueLabel), + + // Player.Get(this.Owner); + new(OpCodes.Ldarg_0), + 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), + + // ExitStalking ev = new(Player, isAllowed) + new(OpCodes.Newobj, GetDeclaredConstructors(typeof(ExitStalkingEventArgs))[0]), + new(OpCodes.Dup), + new(OpCodes.Dup), + new(OpCodes.Stloc_S, ev.LocalIndex), + + // Handlers.Scp106.OnExitStalking(ev) + new(OpCodes.Call, Method(typeof(Handlers.Scp106), nameof(Handlers.Scp106.OnExitStalking))), + + // if (!ev.IsAllowed) + // return; + new(OpCodes.Callvirt, PropertyGetter(typeof(StalkingEventArgs), nameof(StalkingEventArgs.IsAllowed))), + new(OpCodes.Brfalse_S, returnLabel), + }); + + offset = -3; + index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Newobj) + offset; + newInstructions[index].labels.Add(continueLabel); + + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; + + ListPool.Pool.Return(newInstructions); + } + } +} \ No newline at end of file diff --git a/Exiled.Events/Patches/Events/Scp106/Stalking.cs b/Exiled.Events/Patches/Events/Scp106/Stalking.cs index 3c9b0590cc..c2ae277a92 100644 --- a/Exiled.Events/Patches/Events/Scp106/Stalking.cs +++ b/Exiled.Events/Patches/Events/Scp106/Stalking.cs @@ -8,13 +8,13 @@ namespace Exiled.Events.Patches.Events.Scp106 { using System.Collections.Generic; + using System.Reflection; using System.Reflection.Emit; using API.Features; using API.Features.Pools; using Exiled.Events.EventArgs.Scp106; - using HarmonyLib; using PlayerRoles.PlayableScps.Scp106; @@ -25,23 +25,87 @@ namespace Exiled.Events.Patches.Events.Scp106 /// Patches . /// To add the event. /// - // TODO: REWORK TRANSPILER - [HarmonyPatch] + [HarmonyPatch(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.ServerProcessCmd))] public class Stalking { - [HarmonyTranspiler] - [HarmonyPatch(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.ServerProcessCmd))] - private static IEnumerable OnStalking(IEnumerable instructions, ILGenerator generator) + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) { List newInstructions = ListPool.Pool.Get(instructions); - Label returnLabel = generator.DefineLabel(); - newInstructions.InsertRange(0, new CodeInstruction[] - { - new(OpCodes.Ldarg_0), - new(OpCodes.Call, Method(typeof(Stalking), nameof(ServerProcessStalk))), - new(OpCodes.Br, returnLabel), - }); + LocalBuilder ev = generator.DeclareLocal(typeof(StalkingEventArgs)); + + Label returnLabel = generator.DefineLabel(); + int offset = 2; + int index = newInstructions.FindIndex(instruction => instruction.operand == (object)PropertyGetter(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.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), + }); + + offset = 2; + index = newInstructions.FindIndex(instruction => 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; + newInstructions.RemoveAt(index); + + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // ev.MinimumVigor + new(OpCodes.Ldloc_S, ev.LocalIndex), + new(OpCodes.Callvirt, PropertyGetter(typeof(StalkingEventArgs), nameof(StalkingEventArgs.MinimumVigor))), + }); newInstructions[newInstructions.Count - 1].WithLabels(returnLabel); @@ -50,40 +114,5 @@ private static IEnumerable OnStalking(IEnumerable.Pool.Return(newInstructions); } - - /// - /// Process the stalk ability and call the event. - /// - /// 106's ability. - private static void ServerProcessStalk(Scp106StalkAbility stalkAbility) - { - if (stalkAbility._sinkhole.IsDuringAnimation || !stalkAbility._sinkhole.Cooldown.IsReady || - !stalkAbility.ScpRole.FpcModule.IsGrounded) - return; - - Player scp106 = Player.Get(stalkAbility.Owner); - StalkingEventArgs ev = new(scp106, stalkAbility); - Handlers.Scp106.OnStalking(ev); - - bool flag = ev.Vigor < ev.MinimumVigor; - - if (!ev.IsAllowed) - return; - - if (stalkAbility.IsActive) - { - stalkAbility.IsActive = false; - } - else if (flag) - { - if (stalkAbility.Role.IsLocalPlayer) - Scp106Hud.PlayFlash(true); - stalkAbility.ServerSendRpc(false); - } - else - { - stalkAbility.IsActive = true; - } - } } } \ No newline at end of file diff --git a/Exiled.Events/Patches/Events/Scp106/Teleporting.cs b/Exiled.Events/Patches/Events/Scp106/Teleporting.cs index 85e55abef0..99446ab41b 100644 --- a/Exiled.Events/Patches/Events/Scp106/Teleporting.cs +++ b/Exiled.Events/Patches/Events/Scp106/Teleporting.cs @@ -42,7 +42,7 @@ private static IEnumerable Transpiler(IEnumerable Date: Wed, 9 Aug 2023 16:04:17 +0200 Subject: [PATCH 011/207] better --- Exiled.Events/EventArgs/Scp106/StalkingEventArgs.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Exiled.Events/EventArgs/Scp106/StalkingEventArgs.cs b/Exiled.Events/EventArgs/Scp106/StalkingEventArgs.cs index 8e9784fdde..b2211b2c82 100644 --- a/Exiled.Events/EventArgs/Scp106/StalkingEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp106/StalkingEventArgs.cs @@ -45,9 +45,9 @@ public StalkingEventArgs(Player player, bool isAllowed = true) public float Vigor { [Obsolete("Use Scp106.Vigor instead of this")] - get => Scp106StalkAbility.Vigor.VigorAmount; + get => Scp106.Vigor; [Obsolete("Use Scp106.Vigor instead of this")] - set => Scp106StalkAbility.Vigor.VigorAmount = value; + set => Scp106.Vigor = value; } /// From 13edad645ed90c29d06907362dc8f482a65c60b4 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Wed, 9 Aug 2023 16:22:10 +0200 Subject: [PATCH 012/207] StalkVigorUse --- Exiled.API/Features/Roles/Scp106Role.cs | 11 +++ .../Patches/Events/Scp106/ExitStalking.cs | 1 - .../Generic/Scp106API/StalkVigorUse.cs | 84 +++++++++++++++++++ 3 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 Exiled.Events/Patches/Generic/Scp106API/StalkVigorUse.cs diff --git a/Exiled.API/Features/Roles/Scp106Role.cs b/Exiled.API/Features/Roles/Scp106Role.cs index 1682b81121..9589098cfb 100644 --- a/Exiled.API/Features/Roles/Scp106Role.cs +++ b/Exiled.API/Features/Roles/Scp106Role.cs @@ -12,6 +12,7 @@ namespace Exiled.API.Features.Roles using Exiled.API.Enums; using PlayerRoles; using PlayerRoles.PlayableScps.HumeShield; + using PlayerRoles.PlayableScps.Scp049; using PlayerRoles.PlayableScps.Scp106; using PlayerRoles.PlayableScps.Subroutines; using PlayerStatsSystem; @@ -176,6 +177,16 @@ public bool SinkholeState /// public float SinkholeSpeedMultiplier => SinkholeController.SpeedMultiplier; + /// + /// Gets or sets how mush cost the Ability Stalk will cost per tick when being stationary. + /// + public double VigorStalkCostStationary { get; set; } = Scp106StalkAbility.VigorStalkCostStationary; + + /// + /// Gets or sets how mush cost the Ability Stalk will cost per tick when moving. + /// + public double VigorStalkCostMoving { get; set; } = Scp106StalkAbility.VigorStalkCostMoving; + /// /// Gets or sets the amount of time in between player captures. /// diff --git a/Exiled.Events/Patches/Events/Scp106/ExitStalking.cs b/Exiled.Events/Patches/Events/Scp106/ExitStalking.cs index 4b3b8e50e5..5cc545db9b 100644 --- a/Exiled.Events/Patches/Events/Scp106/ExitStalking.cs +++ b/Exiled.Events/Patches/Events/Scp106/ExitStalking.cs @@ -8,7 +8,6 @@ namespace Exiled.Events.Patches.Events.Scp106 { using System.Collections.Generic; - using System.Reflection; using System.Reflection.Emit; using API.Features; diff --git a/Exiled.Events/Patches/Generic/Scp106API/StalkVigorUse.cs b/Exiled.Events/Patches/Generic/Scp106API/StalkVigorUse.cs new file mode 100644 index 0000000000..e0e06446ac --- /dev/null +++ b/Exiled.Events/Patches/Generic/Scp106API/StalkVigorUse.cs @@ -0,0 +1,84 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Generic.Scp106API +{ + using System.Collections.Generic; + using System.Reflection.Emit; + + using API.Features.Pools; + using Exiled.API.Features; + using HarmonyLib; + using PlayerRoles.PlayableScps.Scp106; + using PlayerRoles.PlayableScps.Subroutines; + + using static HarmonyLib.AccessTools; + + using BaseScp106Role = PlayerRoles.PlayableScps.Scp106.Scp106Role; + using Scp106Role = API.Features.Roles.Scp106Role; + + /// + /// Patches . + /// Adds the and property. + /// + [HarmonyPatch(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.UpdateServerside))] + internal class StalkVigorUse + { + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) + { + List newInstructions = ListPool.Pool.Get(instructions); + + LocalBuilder scp049Role = generator.DeclareLocal(typeof(Scp106Role)); + + // replace "float num = base.ScpRole.FpcModule.Motor.MovementDetected ? 0.09f : 0.06f;" + // with + // Scp106Role = Player.Get(this.Owner).Role.As() + // "float num = base.ScpRole.FpcModule.Motor.MovementDetected ? Scp106Role.VigorStalkCostMoving : Scp106Role.VigorStalkCostStationary;" + int offset = 0; + int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Ldc_R4) + offset; + newInstructions.RemoveAt(index); + + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // Player.Get(base.Owner).Role + new(OpCodes.Ldarg_0), + new(OpCodes.Call, PropertyGetter(typeof(ScpStandardSubroutine), nameof(ScpStandardSubroutine.Owner))), + new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), + new(OpCodes.Callvirt, PropertyGetter(typeof(Player), nameof(Player.Role))), + + // (Player.Get(base.Owner).Role as Scp106Role).VigorStalkCostMoving + new(OpCodes.Isinst, typeof(Scp106Role)), + new(OpCodes.Callvirt, PropertyGetter(typeof(Scp106Role), nameof(Scp106Role.VigorStalkCostMoving))), + }); + + offset = 0; + index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Ldc_R4) + offset; + newInstructions.RemoveAt(index); + + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // Player.Get(base.Owner).Role + new(OpCodes.Ldarg_0), + new(OpCodes.Call, PropertyGetter(typeof(ScpStandardSubroutine), nameof(ScpStandardSubroutine.Owner))), + new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), + new(OpCodes.Callvirt, PropertyGetter(typeof(Player), nameof(Player.Role))), + + // (Player.Get(base.Owner).Role as Scp106Role).VigorStalkCostStationary + new(OpCodes.Isinst, typeof(Scp106Role)), + new(OpCodes.Callvirt, PropertyGetter(typeof(Scp106Role), nameof(Scp106Role.VigorStalkCostStationary))), + }); + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; + + ListPool.Pool.Return(newInstructions); + } + } +} From f83bdbcc1b07d7e0dc8e27340bf6033c2eaffdb2 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Wed, 9 Aug 2023 16:36:26 +0200 Subject: [PATCH 013/207] VigorRegeneration --- Exiled.API/Features/Roles/Scp106Role.cs | 9 ++- .../Generic/Scp106API/StalkVigorUse.cs | 4 +- .../Generic/Scp106API/VigorRegeneration.cs | 66 +++++++++++++++++++ 3 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 Exiled.Events/Patches/Generic/Scp106API/VigorRegeneration.cs diff --git a/Exiled.API/Features/Roles/Scp106Role.cs b/Exiled.API/Features/Roles/Scp106Role.cs index 9589098cfb..8af1be951d 100644 --- a/Exiled.API/Features/Roles/Scp106Role.cs +++ b/Exiled.API/Features/Roles/Scp106Role.cs @@ -180,12 +180,17 @@ public bool SinkholeState /// /// Gets or sets how mush cost the Ability Stalk will cost per tick when being stationary. /// - public double VigorStalkCostStationary { get; set; } = Scp106StalkAbility.VigorStalkCostStationary; + public float VigorStalkCostStationary { get; set; } = Scp106StalkAbility.VigorStalkCostStationary; /// /// Gets or sets how mush cost the Ability Stalk will cost per tick when moving. /// - public double VigorStalkCostMoving { get; set; } = Scp106StalkAbility.VigorStalkCostMoving; + public float VigorStalkCostMoving { get; set; } = Scp106StalkAbility.VigorStalkCostMoving; + + /// + /// Gets or sets how mush vigor will be regenerate while moving per tick. + /// + public float VigorRegeneration { get; set; } = Scp106StalkAbility.VigorRegeneration; /// /// Gets or sets the amount of time in between player captures. diff --git a/Exiled.Events/Patches/Generic/Scp106API/StalkVigorUse.cs b/Exiled.Events/Patches/Generic/Scp106API/StalkVigorUse.cs index e0e06446ac..8cdd360b27 100644 --- a/Exiled.Events/Patches/Generic/Scp106API/StalkVigorUse.cs +++ b/Exiled.Events/Patches/Generic/Scp106API/StalkVigorUse.cs @@ -36,8 +36,8 @@ private static IEnumerable Transpiler(IEnumerable() - // "float num = base.ScpRole.FpcModule.Motor.MovementDetected ? Scp106Role.VigorStalkCostMoving : Scp106Role.VigorStalkCostStationary;" + // Scp106Role scp106Role = Player.Get(this.Owner).Role.As() + // "float num = base.ScpRole.FpcModule.Motor.MovementDetected ? scp106Role.VigorStalkCostMoving : scp106Role.VigorStalkCostStationary;" int offset = 0; int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Ldc_R4) + offset; newInstructions.RemoveAt(index); diff --git a/Exiled.Events/Patches/Generic/Scp106API/VigorRegeneration.cs b/Exiled.Events/Patches/Generic/Scp106API/VigorRegeneration.cs new file mode 100644 index 0000000000..09ab86cd8f --- /dev/null +++ b/Exiled.Events/Patches/Generic/Scp106API/VigorRegeneration.cs @@ -0,0 +1,66 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Generic.Scp106API +{ + using System.Collections.Generic; + using System.Reflection.Emit; + + using API.Features.Pools; + using Exiled.API.Features; + using HarmonyLib; + using PlayerRoles.PlayableScps.Scp106; + using PlayerRoles.PlayableScps.Subroutines; + + using static HarmonyLib.AccessTools; + + using BaseScp106Role = PlayerRoles.PlayableScps.Scp106.Scp106Role; + using Scp106Role = API.Features.Roles.Scp106Role; + + /// + /// Patches . + /// Adds the property. + /// + [HarmonyPatch(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.UpdateMovementState))] + internal class VigorRegeneration + { + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) + { + List newInstructions = ListPool.Pool.Get(instructions); + + LocalBuilder scp049Role = generator.DeclareLocal(typeof(Scp106Role)); + + // replace "base.Vigor.VigorAmount += 0.03f * Time.deltaTime;" + // with + // Scp106Role scp106Role = Player.Get(this.Owner).Role.As() + // "base.Vigor.VigorAmount += scp106Role.VigorRegeneration * Time.deltaTime;" + int offset = -4; + int index = newInstructions.FindIndex(instruction => instruction.operand == (object)PropertySetter(typeof(Scp106Vigor), nameof(Scp106Vigor.VigorAmount))) + offset; + newInstructions.RemoveAt(index); + + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // Player.Get(base.Owner).Role + new(OpCodes.Ldarg_0), + new(OpCodes.Call, PropertyGetter(typeof(ScpStandardSubroutine), nameof(ScpStandardSubroutine.Owner))), + new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), + new(OpCodes.Callvirt, PropertyGetter(typeof(Player), nameof(Player.Role))), + + // (Player.Get(base.Owner).Role as Scp106Role).VigorRegeneration + new(OpCodes.Isinst, typeof(Scp106Role)), + new(OpCodes.Callvirt, PropertyGetter(typeof(Scp106Role), nameof(Scp106Role.VigorRegeneration))), + }); + + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; + + ListPool.Pool.Return(newInstructions); + } + } +} From d80462773864ec95cbec2772194403dbcf595b3d Mon Sep 17 00:00:00 2001 From: louis1706 Date: Wed, 9 Aug 2023 16:41:37 +0200 Subject: [PATCH 014/207] fix doc --- Exiled.API/Features/Roles/Scp106Role.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.API/Features/Roles/Scp106Role.cs b/Exiled.API/Features/Roles/Scp106Role.cs index 8af1be951d..f743e101e8 100644 --- a/Exiled.API/Features/Roles/Scp106Role.cs +++ b/Exiled.API/Features/Roles/Scp106Role.cs @@ -188,7 +188,7 @@ public bool SinkholeState public float VigorStalkCostMoving { get; set; } = Scp106StalkAbility.VigorStalkCostMoving; /// - /// Gets or sets how mush vigor will be regenerate while moving per tick. + /// Gets or sets how mush vigor will be regenerate while moving per seconds. /// public float VigorRegeneration { get; set; } = Scp106StalkAbility.VigorRegeneration; From 483cdc23a4c0aef8122b54ffc60f287fc36dca65 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Wed, 9 Aug 2023 16:52:30 +0200 Subject: [PATCH 015/207] Not finish (i will done all of them this night normally) --- Exiled.API/Features/Roles/Scp106Role.cs | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Exiled.API/Features/Roles/Scp106Role.cs b/Exiled.API/Features/Roles/Scp106Role.cs index f743e101e8..8eaac65cd4 100644 --- a/Exiled.API/Features/Roles/Scp106Role.cs +++ b/Exiled.API/Features/Roles/Scp106Role.cs @@ -192,6 +192,36 @@ public bool SinkholeState /// public float VigorRegeneration { get; set; } = Scp106StalkAbility.VigorRegeneration; + /// + /// Gets or sets how mush vigor will be regenerate while moving per seconds. + /// + public float AttackDamage { get; set; } = Scp106Attack.AttackDamage; + + /// + /// Gets or sets how mush vigor will be regenerate while moving per seconds. + /// + public float CorrodingTime { get; set; } = Scp106Attack.CorrodingTime; + + /// + /// Gets or sets how mush vigor will be regenerate while moving per seconds. + /// + public float VigorCaptureReward { get; set; } = Scp106Attack.VigorCaptureReward; + + /// + /// Gets or sets how mush vigor will be regenerate while moving per seconds. + /// + public float CooldownReductionReward { get; set; } = Scp106Attack.CooldownReductionReward; + + /// + /// Gets or sets how mush vigor will be regenerate while moving per seconds. + /// + public float SinkholeCooldownDuration { get; set; } = Scp106SinkholeController.CooldownDuration; + + /// + /// Gets or sets how mush vigor will be regenerate while moving per seconds. + /// + public float HuntersAtlasCostPerMeter { get; set; } = Scp106HuntersAtlasAbility.CostPerMeter; + /// /// Gets or sets the amount of time in between player captures. /// From 5383873cbc11e667c4b2a260ea90cfc97307f582 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 11 Aug 2023 01:21:16 +0200 Subject: [PATCH 016/207] DroppingScp330Event Fix Candy --- .../Patches/Events/Scp330/DroppingCandy.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Exiled.Events/Patches/Events/Scp330/DroppingCandy.cs b/Exiled.Events/Patches/Events/Scp330/DroppingCandy.cs index 7519585410..0648636bc7 100644 --- a/Exiled.Events/Patches/Events/Scp330/DroppingCandy.cs +++ b/Exiled.Events/Patches/Events/Scp330/DroppingCandy.cs @@ -22,7 +22,7 @@ namespace Exiled.Events.Patches.Events.Scp330 using InventorySystem.Items.Usables.Scp330; using Mirror; - + using Utils.Networking; using static HarmonyLib.AccessTools; using Player = API.Features.Player; @@ -42,7 +42,7 @@ private static IEnumerable Transpiler(IEnumerable instruction.LoadsField(Field(typeof(ReferenceHub), nameof(ReferenceHub.inventory)))) + offset; newInstructions.InsertRange( @@ -78,17 +78,17 @@ private static IEnumerable Transpiler(IEnumerable instruction.StoresField(Field(typeof(ItemPickupBase), nameof(ItemPickupBase.PreviousOwner)))) + jumpOverOffset; + offset = 1; + index = newInstructions.FindLastIndex( + instruction => instruction.StoresField(Field(typeof(ItemPickupBase), nameof(ItemPickupBase.PreviousOwner)))) + offset; // Remove TryRemove candy logic since we did it earlier from current location - newInstructions.RemoveRange(jumpOverIndex, 6); + newInstructions.RemoveRange(index, 6); int candyKindIdIndex = 4; newInstructions.InsertRange( - jumpOverIndex, + index, new[] { // candyKindID = ev.Candy @@ -100,7 +100,10 @@ private static IEnumerable Transpiler(IEnumerable instruction.operand == (object)Method(typeof(NetworkUtils), nameof(NetworkUtils.SendToAuthenticated))) + offset; + + newInstructions[index].labels.Add(returnLabel); for (int z = 0; z < newInstructions.Count; z++) yield return newInstructions[z]; From 8e2a9055f3888b057856382064f21ca9414be567 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 11 Aug 2023 01:33:38 +0200 Subject: [PATCH 017/207] Fix using --- Exiled.Events/Patches/Events/Scp330/DroppingCandy.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Exiled.Events/Patches/Events/Scp330/DroppingCandy.cs b/Exiled.Events/Patches/Events/Scp330/DroppingCandy.cs index 0648636bc7..418377cc41 100644 --- a/Exiled.Events/Patches/Events/Scp330/DroppingCandy.cs +++ b/Exiled.Events/Patches/Events/Scp330/DroppingCandy.cs @@ -23,6 +23,7 @@ namespace Exiled.Events.Patches.Events.Scp330 using Mirror; using Utils.Networking; + using static HarmonyLib.AccessTools; using Player = API.Features.Player; From 7ee5da5f8365273a4d83d4a3d558ba528911ecab Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sun, 27 Aug 2023 16:06:02 +0200 Subject: [PATCH 018/207] Stupid Transpiller --- .../Patches/Generic/Scp106API/CustomAttack.cs | 134 ++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 Exiled.Events/Patches/Generic/Scp106API/CustomAttack.cs diff --git a/Exiled.Events/Patches/Generic/Scp106API/CustomAttack.cs b/Exiled.Events/Patches/Generic/Scp106API/CustomAttack.cs new file mode 100644 index 0000000000..54fccd372b --- /dev/null +++ b/Exiled.Events/Patches/Generic/Scp106API/CustomAttack.cs @@ -0,0 +1,134 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Generic.Scp106API +{ + using System.Collections.Generic; + using System.Reflection.Emit; + + using API.Features.Pools; + using Exiled.API.Features; + using HarmonyLib; + using PlayerRoles.PlayableScps.Scp106; + using PlayerRoles.PlayableScps.Subroutines; + + using static HarmonyLib.AccessTools; + + using BaseScp106Role = PlayerRoles.PlayableScps.Scp106.Scp106Role; + using Scp106Role = API.Features.Roles.Scp106Role; + + /// + /// Patches . + /// Adds the , , property. + /// + [HarmonyPatch(typeof(Scp106Attack), nameof(Scp106Attack.ServerShoot))] + internal class CustomAttack + { + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) + { + List newInstructions = ListPool.Pool.Get(instructions); + + LocalBuilder scp049Role = generator.DeclareLocal(typeof(Scp106Role)); + + // replace "new ScpDamageHandler(base.Owner, 30f, DeathTranslations.PocketDecay);" + // with + // Scp106Role scp106Role = Player.Get(this.Owner).Role.As() + // "new ScpDamageHandler(base.Owner, scp106Role.AttackDamage, DeathTranslations.PocketDecay);" + int offset = 0; + int index = newInstructions.FindIndex(instruction => instruction.operand == (object)Scp106Attack.AttackDamage) + offset; + newInstructions.RemoveAt(index); + + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // Player.Get(base.Owner).Role + new(OpCodes.Ldarg_0), + new(OpCodes.Call, PropertyGetter(typeof(ScpStandardSubroutine), nameof(ScpStandardSubroutine.Owner))), + new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), + new(OpCodes.Callvirt, PropertyGetter(typeof(Player), nameof(Player.Role))), + + // (Player.Get(base.Owner).Role as Scp106Role).AttackDamage + new(OpCodes.Isinst, typeof(Scp106Role)), + new(OpCodes.Callvirt, PropertyGetter(typeof(Scp106Role), nameof(Scp106Role.AttackDamage))), + }); + + // replace "base.Vigor.VigorAmount += 0.3f;" + // with + // Scp106Role scp106Role = Player.Get(this.Owner).Role.As() + // "base.Vigor.VigorAmount += scp106Role.VigorCaptureReward;" + offset = 0; + index = newInstructions.FindIndex(instruction => instruction.operand == (object)Scp106Attack.VigorCaptureReward) + offset; + newInstructions.RemoveAt(index); + + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // Player.Get(base.Owner).Role + new(OpCodes.Ldarg_0), + new(OpCodes.Call, PropertyGetter(typeof(ScpStandardSubroutine), nameof(ScpStandardSubroutine.Owner))), + new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), + new(OpCodes.Callvirt, PropertyGetter(typeof(Player), nameof(Player.Role))), + + // (Player.Get(base.Owner).Role as Scp106Role).AttackDamage + new(OpCodes.Isinst, typeof(Scp106Role)), + new(OpCodes.Callvirt, PropertyGetter(typeof(Scp106Role), nameof(Scp106Role.VigorCaptureReward))), + }); + + // replace "base.Vigor.VigorAmount += 0.3f;" + // with + // Scp106Role scp106Role = Player.Get(this.Owner).Role.As() + // "base.Vigor.VigorAmount += scp106Role.VigorCaptureReward;" + offset = 0; + index = newInstructions.FindIndex(instruction => instruction.operand == (object)Scp106Attack.VigorCaptureReward) + offset; + newInstructions.RemoveAt(index); + + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // Player.Get(base.Owner).Role + new(OpCodes.Ldarg_0), + new(OpCodes.Call, PropertyGetter(typeof(ScpStandardSubroutine), nameof(ScpStandardSubroutine.Owner))), + new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), + new(OpCodes.Callvirt, PropertyGetter(typeof(Player), nameof(Player.Role))), + + // (Player.Get(base.Owner).Role as Scp106Role).AttackDamage + new(OpCodes.Isinst, typeof(Scp106Role)), + new(OpCodes.Callvirt, PropertyGetter(typeof(Scp106Role), nameof(Scp106Role.VigorCaptureReward))), + }); + + // replace "playerEffectsController.EnableEffect(20f, false);" + // with + // Scp106Role scp106Role = Player.Get(this.Owner).Role.As() + // "playerEffectsController.EnableEffect(scp106Role.CorrodingTime, false);" + offset = 0; + index = newInstructions.FindLastIndex(instruction => instruction.opcode == OpCodes.Ldc_R4) + offset; + newInstructions.RemoveAt(index); + + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // Player.Get(base.Owner).Role + new(OpCodes.Ldarg_0), + new(OpCodes.Call, PropertyGetter(typeof(ScpStandardSubroutine), nameof(ScpStandardSubroutine.Owner))), + new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), + new(OpCodes.Callvirt, PropertyGetter(typeof(Player), nameof(Player.Role))), + + // (Player.Get(base.Owner).Role as Scp106Role).CorrodingTime + new(OpCodes.Isinst, typeof(Scp106Role)), + new(OpCodes.Callvirt, PropertyGetter(typeof(Scp106Role), nameof(Scp106Role.CorrodingTime))), + }); + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; + + ListPool.Pool.Return(newInstructions); + } + } +} From 56096319945b992c212be443ad3c5b7b1073f02e Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sun, 27 Aug 2023 16:10:48 +0200 Subject: [PATCH 019/207] Scp106Attack.ReduceSinkholeCooldown --- .../Scp106API/CooldownReductionReward.cs | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 Exiled.Events/Patches/Generic/Scp106API/CooldownReductionReward.cs diff --git a/Exiled.Events/Patches/Generic/Scp106API/CooldownReductionReward.cs b/Exiled.Events/Patches/Generic/Scp106API/CooldownReductionReward.cs new file mode 100644 index 0000000000..dd0e539450 --- /dev/null +++ b/Exiled.Events/Patches/Generic/Scp106API/CooldownReductionReward.cs @@ -0,0 +1,67 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Generic.Scp106API +{ + using System.Collections.Generic; + using System.Reflection; + using System.Reflection.Emit; + + using API.Features.Pools; + using Exiled.API.Features; + using HarmonyLib; + using PlayerRoles.PlayableScps.Scp106; + using PlayerRoles.PlayableScps.Subroutines; + + using static HarmonyLib.AccessTools; + + using BaseScp106Role = PlayerRoles.PlayableScps.Scp106.Scp106Role; + using Scp106Role = API.Features.Roles.Scp106Role; + + /// + /// Patches . + /// Adds the property. + /// + [HarmonyPatch(typeof(Scp106Attack), nameof(Scp106Attack.ReduceSinkholeCooldown))] + internal class CooldownReductionReward + { + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) + { + List newInstructions = ListPool.Pool.Get(instructions); + + LocalBuilder scp049Role = generator.DeclareLocal(typeof(Scp106Role)); + + // replace "base.ScpRole.Sinkhole.Cooldown.NextUse -= 5.0; + // with + // Scp106Role scp106Role = Player.Get(this.Owner).Role.As() + // replace "base.ScpRole.Sinkhole.Cooldown.NextUse -= scp106Role.CooldownReductionReward; + int offset = 0; + int index = newInstructions.FindLastIndex(instruction => instruction.opcode == OpCodes.Ldc_R4) + offset; + newInstructions.RemoveAt(index); + + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // Player.Get(base.Owner).Role + new(OpCodes.Ldarg_0), + new(OpCodes.Call, PropertyGetter(typeof(ScpStandardSubroutine), nameof(ScpStandardSubroutine.Owner))), + new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), + new(OpCodes.Callvirt, PropertyGetter(typeof(Player), nameof(Player.Role))), + + // (Player.Get(base.Owner).Role as Scp106Role).CooldownReductionReward + new(OpCodes.Isinst, typeof(Scp106Role)), + new(OpCodes.Callvirt, PropertyGetter(typeof(Scp106Role), nameof(Scp106Role.CooldownReductionReward))), + }); + + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; + + ListPool.Pool.Return(newInstructions); + } + } +} From a8078cf91dbf6538a59503253c7a3b5202091195 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sun, 27 Aug 2023 16:17:36 +0200 Subject: [PATCH 020/207] SinkholeAbilityCooldown --- .../Scp106API/SinkholeAbilityCooldown.cs | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 Exiled.Events/Patches/Generic/Scp106API/SinkholeAbilityCooldown.cs diff --git a/Exiled.Events/Patches/Generic/Scp106API/SinkholeAbilityCooldown.cs b/Exiled.Events/Patches/Generic/Scp106API/SinkholeAbilityCooldown.cs new file mode 100644 index 0000000000..120441459f --- /dev/null +++ b/Exiled.Events/Patches/Generic/Scp106API/SinkholeAbilityCooldown.cs @@ -0,0 +1,67 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Generic.Scp106API +{ + using System.Collections.Generic; + using System.Reflection; + using System.Reflection.Emit; + + using API.Features.Pools; + using Exiled.API.Features; + using HarmonyLib; + using PlayerRoles.PlayableScps.Scp106; + using PlayerRoles.PlayableScps.Subroutines; + + using static HarmonyLib.AccessTools; + + using BaseScp106Role = PlayerRoles.PlayableScps.Scp106.Scp106Role; + using Scp106Role = API.Features.Roles.Scp106Role; + + /// + /// Patches . + /// Adds the property. + /// + [HarmonyPatch(typeof(Scp106Attack), nameof(Scp106Attack.ReduceSinkholeCooldown))] + internal class SinkholeAbilityCooldown + { + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) + { + List newInstructions = ListPool.Pool.Get(instructions); + + LocalBuilder scp049Role = generator.DeclareLocal(typeof(Scp106Role)); + + // replace "this.Cooldown.Trigger(20.0);" + // with + // Scp106Role scp106Role = Player.Get(this.Owner).Role.As() + // replace "this.Cooldown.Trigger(scp106Role.SinkholeCooldownDuration);" + int offset = 0; + int index = newInstructions.FindLastIndex(instruction => instruction.opcode == OpCodes.Ldc_R4) + offset; + newInstructions.RemoveAt(index); + + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // Player.Get(base.Owner).Role + new(OpCodes.Ldarg_0), + new(OpCodes.Call, PropertyGetter(typeof(ScpStandardSubroutine), nameof(ScpStandardSubroutine.Owner))), + new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), + new(OpCodes.Callvirt, PropertyGetter(typeof(Player), nameof(Player.Role))), + + // (Player.Get(base.Owner).Role as Scp106Role).SinkholeCooldownDuration + new(OpCodes.Isinst, typeof(Scp106Role)), + new(OpCodes.Callvirt, PropertyGetter(typeof(Scp106Role), nameof(Scp106Role.SinkholeCooldownDuration))), + }); + + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; + + ListPool.Pool.Return(newInstructions); + } + } +} From ab6dca0716708bfb9cd3e95aba4964d3577ac734 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sun, 27 Aug 2023 16:21:15 +0200 Subject: [PATCH 021/207] HuntersAtlasCostPerMeter --- .../Scp106API/HunterAtlastCostPerMetter.cs | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 Exiled.Events/Patches/Generic/Scp106API/HunterAtlastCostPerMetter.cs diff --git a/Exiled.Events/Patches/Generic/Scp106API/HunterAtlastCostPerMetter.cs b/Exiled.Events/Patches/Generic/Scp106API/HunterAtlastCostPerMetter.cs new file mode 100644 index 0000000000..0fdc57feb8 --- /dev/null +++ b/Exiled.Events/Patches/Generic/Scp106API/HunterAtlastCostPerMetter.cs @@ -0,0 +1,67 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Generic.Scp106API +{ + using System.Collections.Generic; + using System.Reflection; + using System.Reflection.Emit; + + using API.Features.Pools; + using Exiled.API.Features; + using HarmonyLib; + using PlayerRoles.PlayableScps.Scp106; + using PlayerRoles.PlayableScps.Subroutines; + + using static HarmonyLib.AccessTools; + + using BaseScp106Role = PlayerRoles.PlayableScps.Scp106.Scp106Role; + using Scp106Role = API.Features.Roles.Scp106Role; + + /// + /// Patches . + /// Adds the property. + /// + [HarmonyPatch(typeof(Scp106HuntersAtlasAbility), nameof(Scp106HuntersAtlasAbility.ServerProcessCmd))] + internal class HunterAtlastCostPerMetter + { + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) + { + List newInstructions = ListPool.Pool.Get(instructions); + + LocalBuilder scp049Role = generator.DeclareLocal(typeof(Scp106Role)); + + // replace "num = (position2 - this._syncPos).MagnitudeIgnoreY() * 0.019f;" + // with + // Scp106Role scp106Role = Player.Get(this.Owner).Role.As() + // replace "num = (position2 - this._syncPos).MagnitudeIgnoreY() * scp106Role.HuntersAtlasCostPerMeter;" + int offset = 0; + int index = newInstructions.FindLastIndex(instruction => instruction.opcode == OpCodes.Ldc_R4) + offset; + newInstructions.RemoveAt(index); + + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // Player.Get(base.Owner).Role + new(OpCodes.Ldarg_0), + new(OpCodes.Call, PropertyGetter(typeof(ScpStandardSubroutine), nameof(ScpStandardSubroutine.Owner))), + new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), + new(OpCodes.Callvirt, PropertyGetter(typeof(Player), nameof(Player.Role))), + + // (Player.Get(base.Owner).Role as Scp106Role).HuntersAtlasCostPerMeter + new(OpCodes.Isinst, typeof(Scp106Role)), + new(OpCodes.Callvirt, PropertyGetter(typeof(Scp106Role), nameof(Scp106Role.HuntersAtlasCostPerMeter))), + }); + + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; + + ListPool.Pool.Return(newInstructions); + } + } +} From af3891e8bf7d26d8171b228feaa16860ffcaf5f2 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sun, 27 Aug 2023 16:28:33 +0200 Subject: [PATCH 022/207] Documentation --- Exiled.API/Features/Roles/Scp106Role.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Exiled.API/Features/Roles/Scp106Role.cs b/Exiled.API/Features/Roles/Scp106Role.cs index 8eaac65cd4..07c89eb54e 100644 --- a/Exiled.API/Features/Roles/Scp106Role.cs +++ b/Exiled.API/Features/Roles/Scp106Role.cs @@ -193,32 +193,32 @@ public bool SinkholeState public float VigorRegeneration { get; set; } = Scp106StalkAbility.VigorRegeneration; /// - /// Gets or sets how mush vigor will be regenerate while moving per seconds. + /// Gets or sets how mush damage Scp106 will dealt when attacking a player. /// public float AttackDamage { get; set; } = Scp106Attack.AttackDamage; /// - /// Gets or sets how mush vigor will be regenerate while moving per seconds. + /// Gets or sets the duration of Corroding effect. /// public float CorrodingTime { get; set; } = Scp106Attack.CorrodingTime; /// - /// Gets or sets how mush vigor will be regenerate while moving per seconds. + /// Gets or sets how mush vigor Scp106 will gain when being reward for having caught a player. /// public float VigorCaptureReward { get; set; } = Scp106Attack.VigorCaptureReward; /// - /// Gets or sets how mush vigor will be regenerate while moving per seconds. + /// Gets or sets how mush reduction cooldown Scp106 will gain when being reward for having caught a player. /// public float CooldownReductionReward { get; set; } = Scp106Attack.CooldownReductionReward; /// - /// Gets or sets how mush vigor will be regenerate while moving per seconds. + /// Gets or sets the cooldown duration of it's Sinkhole ability's. /// public float SinkholeCooldownDuration { get; set; } = Scp106SinkholeController.CooldownDuration; /// - /// Gets or sets how mush vigor will be regenerate while moving per seconds. + /// Gets or sets how mush vigor it's ability Hunter Atlas will cost per meter. /// public float HuntersAtlasCostPerMeter { get; set; } = Scp106HuntersAtlasAbility.CostPerMeter; From 26b359d69c6e1c621cba53f59a65fb021e30b6c7 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sun, 27 Aug 2023 16:35:01 +0200 Subject: [PATCH 023/207] IScp106Event --- .../EventArgs/Interfaces/IScp106Event.cs | 22 +++++++++++++++++++ .../EventArgs/Scp106/AttackingEventArgs.cs | 7 +++++- .../EventArgs/Scp106/ExitStalkingEventArgs.cs | 6 ++--- .../EventArgs/Scp106/StalkingEventArgs.cs | 6 ++--- .../EventArgs/Scp106/TeleportingEventArgs.cs | 8 +++++-- 5 files changed, 38 insertions(+), 11 deletions(-) create mode 100644 Exiled.Events/EventArgs/Interfaces/IScp106Event.cs diff --git a/Exiled.Events/EventArgs/Interfaces/IScp106Event.cs b/Exiled.Events/EventArgs/Interfaces/IScp106Event.cs new file mode 100644 index 0000000000..32d3971b6c --- /dev/null +++ b/Exiled.Events/EventArgs/Interfaces/IScp106Event.cs @@ -0,0 +1,22 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Interfaces +{ + using Exiled.API.Features.Roles; + + /// + /// Event args used for all related events. + /// + public interface IScp106Event : IPlayerEvent + { + /// + /// Gets the triggering the event. + /// + public Scp106Role Scp106 { get; } + } +} \ No newline at end of file diff --git a/Exiled.Events/EventArgs/Scp106/AttackingEventArgs.cs b/Exiled.Events/EventArgs/Scp106/AttackingEventArgs.cs index d2131ead6d..6c8bf215d1 100644 --- a/Exiled.Events/EventArgs/Scp106/AttackingEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp106/AttackingEventArgs.cs @@ -8,12 +8,13 @@ namespace Exiled.Events.EventArgs.Scp106 { using Exiled.API.Features; + using Exiled.API.Features.Roles; using Exiled.Events.EventArgs.Interfaces; /// /// Contains all information before SCP-106 attacks player. /// - public class AttackingEventArgs : IPlayerEvent, IDeniableEvent + public class AttackingEventArgs : IScp106Event, IDeniableEvent { /// /// Initializes a new instance of the class. @@ -24,6 +25,7 @@ public class AttackingEventArgs : IPlayerEvent, IDeniableEvent public AttackingEventArgs(Player player, Player target, bool isAllowed = true) { Player = player; + Scp106 = player.Role.As(); Target = target; IsAllowed = isAllowed; } @@ -33,6 +35,9 @@ public AttackingEventArgs(Player player, Player target, bool isAllowed = true) /// public Player Player { get; } + /// + public Scp106Role Scp106 { get; } + /// /// Gets the target of attack. /// diff --git a/Exiled.Events/EventArgs/Scp106/ExitStalkingEventArgs.cs b/Exiled.Events/EventArgs/Scp106/ExitStalkingEventArgs.cs index cc8416bd97..9e04b8656e 100644 --- a/Exiled.Events/EventArgs/Scp106/ExitStalkingEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp106/ExitStalkingEventArgs.cs @@ -18,7 +18,7 @@ namespace Exiled.Events.EventArgs.Scp106 /// /// Contains all information before SCP-106 use the stalk ability. /// - public class ExitStalkingEventArgs : IPlayerEvent, IDeniableEvent + public class ExitStalkingEventArgs : IScp106Event, IDeniableEvent { /// /// Initializes a new instance of the class. @@ -37,9 +37,7 @@ public ExitStalkingEventArgs(Player player, bool isAllowed = true) /// public Player Player { get; } - /// - /// Gets the player who's controlling SCP-106. - /// + /// public Scp106Role Scp106 { get; } /// diff --git a/Exiled.Events/EventArgs/Scp106/StalkingEventArgs.cs b/Exiled.Events/EventArgs/Scp106/StalkingEventArgs.cs index b2211b2c82..47f6ff7cb1 100644 --- a/Exiled.Events/EventArgs/Scp106/StalkingEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp106/StalkingEventArgs.cs @@ -18,7 +18,7 @@ namespace Exiled.Events.EventArgs.Scp106 /// /// Contains all information before SCP-106 use the stalk ability. /// - public class StalkingEventArgs : IPlayerEvent, IDeniableEvent + public class StalkingEventArgs : IScp106Event, IDeniableEvent { /// /// Initializes a new instance of the class. @@ -60,9 +60,7 @@ public float Vigor /// public Player Player { get; } - /// - /// Gets the player who's controlling SCP-106. - /// + /// public Scp106Role Scp106 { get; } /// diff --git a/Exiled.Events/EventArgs/Scp106/TeleportingEventArgs.cs b/Exiled.Events/EventArgs/Scp106/TeleportingEventArgs.cs index f0b20503ca..e87b88bf79 100644 --- a/Exiled.Events/EventArgs/Scp106/TeleportingEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp106/TeleportingEventArgs.cs @@ -8,7 +8,7 @@ namespace Exiled.Events.EventArgs.Scp106 { using API.Features; - + using Exiled.API.Features.Roles; using Interfaces; using UnityEngine; @@ -16,7 +16,7 @@ namespace Exiled.Events.EventArgs.Scp106 /// /// Contains all information before SCP-106 teleports using the hunter atlas. /// - public class TeleportingEventArgs : IPlayerEvent, IDeniableEvent + public class TeleportingEventArgs : IScp106Event, IDeniableEvent { /// /// Initializes a new instance of the class. @@ -33,6 +33,7 @@ public class TeleportingEventArgs : IPlayerEvent, IDeniableEvent public TeleportingEventArgs(Player player, Vector3 position, bool isAllowed = true) { Player = player; + Scp106 = player.Role.As(); Position = position; IsAllowed = isAllowed; } @@ -51,5 +52,8 @@ public TeleportingEventArgs(Player player, Vector3 position, bool isAllowed = tr /// Gets the player who's controlling SCP-106. /// public Player Player { get; } + + /// + public Scp106Role Scp106 { get; } } } \ No newline at end of file From fc569d118d613796582385eaeb4b6de4556b0a98 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sun, 27 Aug 2023 16:39:11 +0200 Subject: [PATCH 024/207] IScp0492Event & IScp049Event is inherited by IPlayerEvent --- .../EventArgs/Interfaces/IScp0492Event.cs | 22 +++++++++++++++++++ .../EventArgs/Interfaces/IScp049Event.cs | 2 +- .../Scp049/ActivatingSenseEventArgs.cs | 2 +- .../EventArgs/Scp049/AttackingEventArgs.cs | 2 +- .../Scp049/ConsumingCorpseEventArgs.cs | 8 +++++-- .../Scp049/FinishingRecallEventArgs.cs | 2 +- .../EventArgs/Scp049/SendingCallEventArgs.cs | 2 +- .../Scp049/StartingRecallEventArgs.cs | 2 +- .../EventArgs/Scp106/StalkingEventArgs.cs | 2 +- 9 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 Exiled.Events/EventArgs/Interfaces/IScp0492Event.cs diff --git a/Exiled.Events/EventArgs/Interfaces/IScp0492Event.cs b/Exiled.Events/EventArgs/Interfaces/IScp0492Event.cs new file mode 100644 index 0000000000..3a01e27306 --- /dev/null +++ b/Exiled.Events/EventArgs/Interfaces/IScp0492Event.cs @@ -0,0 +1,22 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Interfaces +{ + using Exiled.API.Features.Roles; + + /// + /// Event args used for all related events. + /// + public interface IScp0492Event : IPlayerEvent + { + /// + /// Gets the triggering the event. + /// + public Scp0492Role Scp0492 { get; } + } +} \ No newline at end of file diff --git a/Exiled.Events/EventArgs/Interfaces/IScp049Event.cs b/Exiled.Events/EventArgs/Interfaces/IScp049Event.cs index fa4008f5b7..b397c05e83 100644 --- a/Exiled.Events/EventArgs/Interfaces/IScp049Event.cs +++ b/Exiled.Events/EventArgs/Interfaces/IScp049Event.cs @@ -12,7 +12,7 @@ namespace Exiled.Events.EventArgs.Interfaces /// /// Event args used for all related events. /// - public interface IScp049Event : IExiledEvent + public interface IScp049Event : IPlayerEvent { /// /// Gets the triggering the event. diff --git a/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs b/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs index 720a086a26..9233d5d936 100644 --- a/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs @@ -16,7 +16,7 @@ namespace Exiled.Events.EventArgs.Scp049 /// /// Contains all information before SCP-049 sense is activated. /// - public class ActivatingSenseEventArgs : IScp049Event, IPlayerEvent, IDeniableEvent + public class ActivatingSenseEventArgs : IScp049Event, IDeniableEvent { /// /// Initializes a new instance of the class with information before SCP-049 sense is activated. diff --git a/Exiled.Events/EventArgs/Scp049/AttackingEventArgs.cs b/Exiled.Events/EventArgs/Scp049/AttackingEventArgs.cs index 35d9196057..8371c1fa73 100644 --- a/Exiled.Events/EventArgs/Scp049/AttackingEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp049/AttackingEventArgs.cs @@ -14,7 +14,7 @@ namespace Exiled.Events.EventArgs.Scp049 /// /// Contains all information before SCP-049 attacks player. /// - public class AttackingEventArgs : IScp049Event, IPlayerEvent, IDeniableEvent + public class AttackingEventArgs : IScp049Event, IDeniableEvent { /// /// Initializes a new instance of the class. diff --git a/Exiled.Events/EventArgs/Scp049/ConsumingCorpseEventArgs.cs b/Exiled.Events/EventArgs/Scp049/ConsumingCorpseEventArgs.cs index 6b86990e6c..dd0befdd45 100644 --- a/Exiled.Events/EventArgs/Scp049/ConsumingCorpseEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp049/ConsumingCorpseEventArgs.cs @@ -10,7 +10,7 @@ namespace Exiled.Events.EventArgs.Scp049 using System; using API.Features; - + using Exiled.API.Features.Roles; using Interfaces; using PlayerRoles.PlayableScps.Scp049.Zombies; @@ -18,7 +18,7 @@ namespace Exiled.Events.EventArgs.Scp049 /// /// Contains all information before zombie consumes RagDolls. /// - public class ConsumingCorpseEventArgs : IPlayerEvent, IRagdollEvent, IDeniableEvent + public class ConsumingCorpseEventArgs : IScp0492Event, IRagdollEvent, IDeniableEvent { /// /// Initializes a new instance of the class. @@ -30,6 +30,7 @@ public class ConsumingCorpseEventArgs : IPlayerEvent, IRagdollEvent, IDeniableEv public ConsumingCorpseEventArgs(Player player, Ragdoll ragDoll, bool isAllowed = true) { Player = player; + Scp0492 = player.Role.As(); Ragdoll = ragDoll; ConsumeHeal = ZombieConsumeAbility.ConsumeHeal; IsAllowed = isAllowed; @@ -40,6 +41,9 @@ public ConsumingCorpseEventArgs(Player player, Ragdoll ragDoll, bool isAllowed = /// public Player Player { get; } + /// + public Scp0492Role Scp0492 { get; } + /// /// Gets the RagDoll to be consumed. /// diff --git a/Exiled.Events/EventArgs/Scp049/FinishingRecallEventArgs.cs b/Exiled.Events/EventArgs/Scp049/FinishingRecallEventArgs.cs index 8ba0875c5a..7748318aa9 100644 --- a/Exiled.Events/EventArgs/Scp049/FinishingRecallEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp049/FinishingRecallEventArgs.cs @@ -14,7 +14,7 @@ namespace Exiled.Events.EventArgs.Scp049 /// /// Contains all information before SCP-049 finishes recalling a player. /// - public class FinishingRecallEventArgs : IScp049Event, IPlayerEvent, IDeniableEvent + public class FinishingRecallEventArgs : IScp049Event, IDeniableEvent { /// /// Initializes a new instance of the class. diff --git a/Exiled.Events/EventArgs/Scp049/SendingCallEventArgs.cs b/Exiled.Events/EventArgs/Scp049/SendingCallEventArgs.cs index ddcffc74fb..cd882d151d 100644 --- a/Exiled.Events/EventArgs/Scp049/SendingCallEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp049/SendingCallEventArgs.cs @@ -14,7 +14,7 @@ namespace Exiled.Events.EventArgs.Scp049 /// /// Contains all information before SCP-049 Call is activated. /// - public class SendingCallEventArgs : IScp049Event, IPlayerEvent, IDeniableEvent + public class SendingCallEventArgs : IScp049Event, IDeniableEvent { /// /// Initializes a new instance of the class. diff --git a/Exiled.Events/EventArgs/Scp049/StartingRecallEventArgs.cs b/Exiled.Events/EventArgs/Scp049/StartingRecallEventArgs.cs index b7b86470b9..a0c5f0a6a6 100644 --- a/Exiled.Events/EventArgs/Scp049/StartingRecallEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp049/StartingRecallEventArgs.cs @@ -14,7 +14,7 @@ namespace Exiled.Events.EventArgs.Scp049 /// /// Contains all information before SCP-049 begins recalling a player. /// - public class StartingRecallEventArgs : IScp049Event, IPlayerEvent, IRagdollEvent, IDeniableEvent + public class StartingRecallEventArgs : IScp049Event, IRagdollEvent, IDeniableEvent { /// /// Initializes a new instance of the class. diff --git a/Exiled.Events/EventArgs/Scp106/StalkingEventArgs.cs b/Exiled.Events/EventArgs/Scp106/StalkingEventArgs.cs index 534a297bdc..f15b7a22e7 100644 --- a/Exiled.Events/EventArgs/Scp106/StalkingEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp106/StalkingEventArgs.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- // // Copyright (c) Exiled Team. All rights reserved. // Licensed under the CC BY-SA 3.0 license. From 8a42a4f6b75650153951d5d816ec25126c797b4b Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sun, 27 Aug 2023 16:44:56 +0200 Subject: [PATCH 025/207] WTF ? --- Exiled.API/Features/Roles/Scp106Role.cs | 7 +++---- Exiled.Events/EventArgs/Scp049/AttackingEventArgs.cs | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Exiled.API/Features/Roles/Scp106Role.cs b/Exiled.API/Features/Roles/Scp106Role.cs index 07c89eb54e..12dc20dfd1 100644 --- a/Exiled.API/Features/Roles/Scp106Role.cs +++ b/Exiled.API/Features/Roles/Scp106Role.cs @@ -294,18 +294,17 @@ public void CapturePlayer(Player player) // Convert to bool. if (player is null) return; Attack._targetHub = player.ReferenceHub; - DamageHandlerBase handler = new ScpDamageHandler(Attack.Owner, Attack._damage, DeathTranslations.PocketDecay); + DamageHandlerBase handler = new ScpDamageHandler(Attack.Owner, AttackDamage, DeathTranslations.PocketDecay); if (!Attack._targetHub.playerStats.DealDamage(handler)) return; Attack.SendCooldown(Attack._hitCooldown); - Attack.Vigor.VigorAmount += Scp106Attack.VigorCaptureReward; + Attack.Vigor.VigorAmount += VigorCaptureReward; Attack.ReduceSinkholeCooldown(); Hitmarker.SendHitmarker(Attack.Owner, 1f); - player.EnableEffect(EffectType.Corroding); - player.EnableEffect(EffectType.SinkHole); + player.EnableEffect(EffectType.PocketCorroding); } /// diff --git a/Exiled.Events/EventArgs/Scp049/AttackingEventArgs.cs b/Exiled.Events/EventArgs/Scp049/AttackingEventArgs.cs index 0bd18c33fa..cba5d9f00b 100644 --- a/Exiled.Events/EventArgs/Scp049/AttackingEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp049/AttackingEventArgs.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- // // Copyright (c) Exiled Team. All rights reserved. // Licensed under the CC BY-SA 3.0 license. From d8c0590544fd5968222684bbd8626f5f54d0c9aa Mon Sep 17 00:00:00 2001 From: louis1706 Date: Tue, 29 Aug 2023 01:36:43 +0200 Subject: [PATCH 026/207] Reworking Transpiller --- .../EventArgs/Interfaces/IScp079Event.cs | 22 +++ .../Scp079/ChangingCameraEventArgs.cs | 8 +- .../Scp079/ChangingSpeakerStatusEventArgs.cs | 8 +- .../Scp079/ElevatorTeleportingEventArgs.cs | 8 +- .../Scp079/GainingExperienceEventArgs.cs | 6 +- .../EventArgs/Scp079/GainingLevelEventArgs.cs | 8 +- .../Scp079/InteractingTeslaEventArgs.cs | 8 +- .../EventArgs/Scp079/LockingDownEventArgs.cs | 8 +- .../EventArgs/Scp079/PingingEventArgs.cs | 8 +- .../EventArgs/Scp079/RecontainedEventArgs.cs | 14 +- .../EventArgs/Scp079/RoomBlackoutEventArgs.cs | 6 +- .../Scp079/StartingSpeakerEventArgs.cs | 7 +- .../Scp079/StoppingSpeakerEventArgs.cs | 7 +- .../Scp079/TriggeringDoorEventArgs.cs | 27 +++- .../EventArgs/Scp079/ZoneBlackoutEventArgs.cs | 6 +- .../Patches/Events/Scp079/ChangingCamera.cs | 76 ++++++----- .../Patches/Events/Scp079/Pinging.cs | 104 ++++++++++---- .../Patches/Events/Scp079/RoomBlackout.cs | 127 ++++++++++++++---- .../Patches/Events/Scp079/ZoneBlackout.cs | 126 +++++++++++++---- 19 files changed, 447 insertions(+), 137 deletions(-) create mode 100644 Exiled.Events/EventArgs/Interfaces/IScp079Event.cs diff --git a/Exiled.Events/EventArgs/Interfaces/IScp079Event.cs b/Exiled.Events/EventArgs/Interfaces/IScp079Event.cs new file mode 100644 index 0000000000..df91d55e54 --- /dev/null +++ b/Exiled.Events/EventArgs/Interfaces/IScp079Event.cs @@ -0,0 +1,22 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Interfaces +{ + using Exiled.API.Features.Roles; + + /// + /// Event args used for all related events. + /// + public interface IScp079Event : IPlayerEvent + { + /// + /// Gets the triggering the event. + /// + public Scp079Role Scp079 { get; } + } +} \ No newline at end of file diff --git a/Exiled.Events/EventArgs/Scp079/ChangingCameraEventArgs.cs b/Exiled.Events/EventArgs/Scp079/ChangingCameraEventArgs.cs index 943b944ca2..496feac804 100644 --- a/Exiled.Events/EventArgs/Scp079/ChangingCameraEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp079/ChangingCameraEventArgs.cs @@ -16,7 +16,7 @@ namespace Exiled.Events.EventArgs.Scp079 /// /// Contains all information before a SCP-079 changes the current camera. /// - public class ChangingCameraEventArgs : IPlayerEvent, ICameraEvent, IDeniableEvent + public class ChangingCameraEventArgs : IScp079Event, ICameraEvent, IDeniableEvent { /// /// Initializes a new instance of the class. @@ -33,9 +33,10 @@ public class ChangingCameraEventArgs : IPlayerEvent, ICameraEvent, IDeniableEven public ChangingCameraEventArgs(Player player, Scp079Camera camera, float auxiliaryPowerCost) { Player = player; + Scp079 = player.Role.As(); Camera = Camera.Get(camera); AuxiliaryPowerCost = auxiliaryPowerCost; - IsAllowed = auxiliaryPowerCost <= player.Role.As().Energy; + IsAllowed = auxiliaryPowerCost <= Scp079.Energy; } /// @@ -43,6 +44,9 @@ public ChangingCameraEventArgs(Player player, Scp079Camera camera, float auxilia /// public Player Player { get; } + /// + public Scp079Role Scp079 { get; } + /// /// Gets or sets the amount of auxiliary power that will be required to switch cameras. /// diff --git a/Exiled.Events/EventArgs/Scp079/ChangingSpeakerStatusEventArgs.cs b/Exiled.Events/EventArgs/Scp079/ChangingSpeakerStatusEventArgs.cs index e790de1fb1..97d78a73e2 100644 --- a/Exiled.Events/EventArgs/Scp079/ChangingSpeakerStatusEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp079/ChangingSpeakerStatusEventArgs.cs @@ -16,7 +16,7 @@ namespace Exiled.Events.EventArgs.Scp079 /// /// Contains all information before SCP-079 uses a speaker. /// - public class ChangingSpeakerStatusEventArgs : IPlayerEvent, IRoomEvent, IDeniableEvent + public class ChangingSpeakerStatusEventArgs : IScp079Event, IRoomEvent, IDeniableEvent { /// /// Initializes a new instance of the class. @@ -30,7 +30,8 @@ public class ChangingSpeakerStatusEventArgs : IPlayerEvent, IRoomEvent, IDeniabl public ChangingSpeakerStatusEventArgs(Player player, bool isAllowed) { Player = player; - Room = Room.Get(player.Role.As().Speaker.Room); + Scp079 = player.Role.As(); + Room = Room.Get(Scp079.Speaker.Room); IsAllowed = isAllowed; } @@ -39,6 +40,9 @@ public ChangingSpeakerStatusEventArgs(Player player, bool isAllowed) /// public Player Player { get; } + /// + public Scp079Role Scp079 { get; } + /// /// Gets the room that the speaker is located in. /// diff --git a/Exiled.Events/EventArgs/Scp079/ElevatorTeleportingEventArgs.cs b/Exiled.Events/EventArgs/Scp079/ElevatorTeleportingEventArgs.cs index 5326e0163a..35374315df 100644 --- a/Exiled.Events/EventArgs/Scp079/ElevatorTeleportingEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp079/ElevatorTeleportingEventArgs.cs @@ -18,7 +18,7 @@ namespace Exiled.Events.EventArgs.Scp079 /// /// Contains all information before SCP-079 changes rooms via elevator. /// - public class ElevatorTeleportingEventArgs : IPlayerEvent, IRoomEvent, IDeniableEvent + public class ElevatorTeleportingEventArgs : IScp079Event, IRoomEvent, IDeniableEvent { /// /// Initializes a new instance of the class. @@ -38,10 +38,11 @@ public class ElevatorTeleportingEventArgs : IPlayerEvent, IRoomEvent, IDeniableE public ElevatorTeleportingEventArgs(Player player, RoomIdentifier room, ElevatorDoor elevatorDoor, float auxiliaryPowerCost) { Player = player; + Scp079 = player.Role.As(); Room = Room.Get(room); Lift = Lift.Get(elevatorDoor.TargetPanel.AssignedChamber); AuxiliaryPowerCost = auxiliaryPowerCost; - IsAllowed = auxiliaryPowerCost <= player.Role.As().Energy; + IsAllowed = auxiliaryPowerCost <= Scp079.Energy; } /// @@ -49,6 +50,9 @@ public ElevatorTeleportingEventArgs(Player player, RoomIdentifier room, Elevator /// public Player Player { get; } + /// + public Scp079Role Scp079 { get; } + /// /// Gets or sets the amount of auxiliary power required to teleport to an elevator camera. /// diff --git a/Exiled.Events/EventArgs/Scp079/GainingExperienceEventArgs.cs b/Exiled.Events/EventArgs/Scp079/GainingExperienceEventArgs.cs index 4d29e2fd5f..0ff1b621b6 100644 --- a/Exiled.Events/EventArgs/Scp079/GainingExperienceEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp079/GainingExperienceEventArgs.cs @@ -15,7 +15,7 @@ namespace Exiled.Events.EventArgs.Scp079 /// /// Contains all information before SCP-079 gains experience. /// - public class GainingExperienceEventArgs : IPlayerEvent, IDeniableEvent + public class GainingExperienceEventArgs : IScp079Event, IDeniableEvent { /// /// Initializes a new instance of the class. @@ -38,6 +38,7 @@ public class GainingExperienceEventArgs : IPlayerEvent, IDeniableEvent public GainingExperienceEventArgs(Player player, Scp079HudTranslation gainType, int amount, RoleTypeId roleType, bool isAllowed = true) { Player = player; + Scp079 = player.Role.As(); GainType = gainType; RoleType = roleType; Amount = amount; @@ -69,5 +70,8 @@ public GainingExperienceEventArgs(Player player, Scp079HudTranslation gainType, /// Gets the player who's controlling SCP-079. /// public Player Player { get; } + + /// + public API.Features.Roles.Scp079Role Scp079 { get; } } } \ No newline at end of file diff --git a/Exiled.Events/EventArgs/Scp079/GainingLevelEventArgs.cs b/Exiled.Events/EventArgs/Scp079/GainingLevelEventArgs.cs index d4a7b5ea7f..03e5458dc0 100644 --- a/Exiled.Events/EventArgs/Scp079/GainingLevelEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp079/GainingLevelEventArgs.cs @@ -8,13 +8,13 @@ namespace Exiled.Events.EventArgs.Scp079 { using API.Features; - + using Exiled.API.Features.Roles; using Interfaces; /// /// Contains all information before SCP-079 gains a level. /// - public class GainingLevelEventArgs : IPlayerEvent, IDeniableEvent + public class GainingLevelEventArgs : IScp079Event, IDeniableEvent { /// /// Initializes a new instance of the class. @@ -31,6 +31,7 @@ public class GainingLevelEventArgs : IPlayerEvent, IDeniableEvent public GainingLevelEventArgs(Player player, int newLevel, bool isAllowed = true) { Player = player; + Scp079 = player.Role.As(); NewLevel = newLevel; IsAllowed = isAllowed; } @@ -49,5 +50,8 @@ public GainingLevelEventArgs(Player player, int newLevel, bool isAllowed = true) /// Gets the player who's controlling SCP-079. /// public Player Player { get; } + + /// + public Scp079Role Scp079 { get; } } } \ No newline at end of file diff --git a/Exiled.Events/EventArgs/Scp079/InteractingTeslaEventArgs.cs b/Exiled.Events/EventArgs/Scp079/InteractingTeslaEventArgs.cs index 3db01d3e00..588f4cb0b8 100644 --- a/Exiled.Events/EventArgs/Scp079/InteractingTeslaEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp079/InteractingTeslaEventArgs.cs @@ -16,7 +16,7 @@ namespace Exiled.Events.EventArgs.Scp079 /// /// Contains all information before SCP-079 triggers a tesla gate. /// - public class InteractingTeslaEventArgs : IPlayerEvent, ITeslaEvent, IDeniableEvent + public class InteractingTeslaEventArgs : IScp079Event, ITeslaEvent, IDeniableEvent { /// /// Initializes a new instance of the class. @@ -33,9 +33,10 @@ public class InteractingTeslaEventArgs : IPlayerEvent, ITeslaEvent, IDeniableEve public InteractingTeslaEventArgs(Player player, TeslaGate teslaGate, float auxiliaryPowerCost) { Player = player; + Scp079 = player.Role.As(); Tesla = API.Features.TeslaGate.Get(teslaGate); AuxiliaryPowerCost = auxiliaryPowerCost; - IsAllowed = auxiliaryPowerCost <= player.Role.As().Energy; + IsAllowed = auxiliaryPowerCost <= Scp079.Energy; } /// @@ -43,6 +44,9 @@ public InteractingTeslaEventArgs(Player player, TeslaGate teslaGate, float auxil /// public Player Player { get; } + /// + public Scp079Role Scp079 { get; } + /// /// Gets the that SCP-079 is triggering. /// diff --git a/Exiled.Events/EventArgs/Scp079/LockingDownEventArgs.cs b/Exiled.Events/EventArgs/Scp079/LockingDownEventArgs.cs index fb45fba9bd..3f1bd09e4f 100644 --- a/Exiled.Events/EventArgs/Scp079/LockingDownEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp079/LockingDownEventArgs.cs @@ -16,7 +16,7 @@ namespace Exiled.Events.EventArgs.Scp079 /// /// Contains all information before SCP-079 lockdowns a room. /// - public class LockingDownEventArgs : IPlayerEvent, IRoomEvent, IDeniableEvent + public class LockingDownEventArgs : IScp079Event, IRoomEvent, IDeniableEvent { /// /// Initializes a new instance of the class. @@ -33,9 +33,10 @@ public class LockingDownEventArgs : IPlayerEvent, IRoomEvent, IDeniableEvent public LockingDownEventArgs(Player player, RoomIdentifier roomIdentifier, float auxiliaryPowerCost) { Player = player; + Scp079 = player.Role.As(); Room = Room.Get(roomIdentifier); AuxiliaryPowerCost = auxiliaryPowerCost; - IsAllowed = auxiliaryPowerCost <= player.Role.As().Energy; + IsAllowed = auxiliaryPowerCost <= Scp079.Energy; } /// @@ -43,6 +44,9 @@ public LockingDownEventArgs(Player player, RoomIdentifier roomIdentifier, float /// public Player Player { get; } + /// + public Scp079Role Scp079 { get; } + /// /// Gets the of the room that will be locked down. /// diff --git a/Exiled.Events/EventArgs/Scp079/PingingEventArgs.cs b/Exiled.Events/EventArgs/Scp079/PingingEventArgs.cs index a0d57407db..4ea0b75cc9 100644 --- a/Exiled.Events/EventArgs/Scp079/PingingEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp079/PingingEventArgs.cs @@ -10,7 +10,7 @@ namespace Exiled.Events.EventArgs.Scp079 using API.Features; using Exiled.API.Enums; - + using Exiled.API.Features.Roles; using Interfaces; using RelativePositioning; @@ -20,7 +20,7 @@ namespace Exiled.Events.EventArgs.Scp079 /// /// Contains all information before SCP-079 pings a location. /// - public class PingingEventArgs : IPlayerEvent, IRoomEvent, IDeniableEvent + public class PingingEventArgs : IScp079Event, IRoomEvent, IDeniableEvent { /// /// Initializes a new instance of the class. @@ -46,6 +46,7 @@ public class PingingEventArgs : IPlayerEvent, IRoomEvent, IDeniableEvent public PingingEventArgs(ReferenceHub hub, RelativePosition position, int powerCost, byte proccesorindex, Vector3 syncNormal, bool isAllowed = true) { Player = Player.Get(hub); + Scp079 = Player.Role.As(); Position = position.Position; Room = Room.Get(Position); AuxiliaryPowerCost = powerCost; @@ -88,5 +89,8 @@ public PingingEventArgs(ReferenceHub hub, RelativePosition position, int powerCo /// Gets the player who's controlling SCP-079. /// public Player Player { get; } + + /// + public Scp079Role Scp079 { get; } } } \ No newline at end of file diff --git a/Exiled.Events/EventArgs/Scp079/RecontainedEventArgs.cs b/Exiled.Events/EventArgs/Scp079/RecontainedEventArgs.cs index 60decba4fc..90523da600 100644 --- a/Exiled.Events/EventArgs/Scp079/RecontainedEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp079/RecontainedEventArgs.cs @@ -8,28 +8,32 @@ namespace Exiled.Events.EventArgs.Scp079 { using API.Features; - + using Exiled.API.Features.Roles; using Interfaces; /// /// Contains information after SCP-079 recontainment. /// - public class RecontainedEventArgs : IPlayerEvent + public class RecontainedEventArgs : IScp079Event { /// /// Initializes a new instance of the class. /// - /// + /// /// /// - public RecontainedEventArgs(Player target) + public RecontainedEventArgs(Player player) { - Player = target; + Player = player; + Scp079 = player.Role.As(); } /// /// Gets the player that previously controlled SCP-079. /// public Player Player { get; } + + /// + public Scp079Role Scp079 { get; } } } \ No newline at end of file diff --git a/Exiled.Events/EventArgs/Scp079/RoomBlackoutEventArgs.cs b/Exiled.Events/EventArgs/Scp079/RoomBlackoutEventArgs.cs index 24ea62074c..7ba103fdc0 100644 --- a/Exiled.Events/EventArgs/Scp079/RoomBlackoutEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp079/RoomBlackoutEventArgs.cs @@ -15,7 +15,7 @@ namespace Exiled.Events.EventArgs.Scp079 /// /// Contains all information before SCP-079 turns off the lights in a room. /// - public class RoomBlackoutEventArgs : IPlayerEvent, IRoomEvent, IDeniableEvent + public class RoomBlackoutEventArgs : IScp079Event, IRoomEvent, IDeniableEvent { /// /// Initializes a new instance of the class. @@ -41,6 +41,7 @@ public class RoomBlackoutEventArgs : IPlayerEvent, IRoomEvent, IDeniableEvent public RoomBlackoutEventArgs(ReferenceHub player, RoomIdentifier roomIdentifier, float auxiliaryPowerCost, float blackoutduration, float cooldown, bool isAllowed) { Player = Player.Get(player); + Scp079 = Player.Role.As(); Room = Room.Get(roomIdentifier); AuxiliaryPowerCost = auxiliaryPowerCost; BlackoutDuration = blackoutduration; @@ -53,6 +54,9 @@ public RoomBlackoutEventArgs(ReferenceHub player, RoomIdentifier roomIdentifier, /// public Player Player { get; } + /// + public API.Features.Roles.Scp079Role Scp079 { get; } + /// /// Gets the room that will be locked down. /// diff --git a/Exiled.Events/EventArgs/Scp079/StartingSpeakerEventArgs.cs b/Exiled.Events/EventArgs/Scp079/StartingSpeakerEventArgs.cs index 2a22421e4a..8c2430a59d 100644 --- a/Exiled.Events/EventArgs/Scp079/StartingSpeakerEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp079/StartingSpeakerEventArgs.cs @@ -8,12 +8,13 @@ namespace Exiled.Events.EventArgs.Scp079 { using Exiled.API.Features; + using Exiled.API.Features.Roles; using Exiled.Events.EventArgs.Interfaces; /// /// Contains all information before SCP-079 uses a speaker. /// - public class StartingSpeakerEventArgs : IPlayerEvent, IDeniableEvent + public class StartingSpeakerEventArgs : IScp079Event, IDeniableEvent { /// /// Initializes a new instance of the class. @@ -33,6 +34,7 @@ public class StartingSpeakerEventArgs : IPlayerEvent, IDeniableEvent public StartingSpeakerEventArgs(Player player, Room room, float auxiliaryPowerCost, bool isAllowed = true) { Player = player; + Scp079 = player.Role.As(); Room = room; AuxiliaryPowerCost = auxiliaryPowerCost; IsAllowed = isAllowed; @@ -43,6 +45,9 @@ public StartingSpeakerEventArgs(Player player, Room room, float auxiliaryPowerCo /// public Player Player { get; } + /// + public Scp079Role Scp079 { get; } + /// /// Gets the room that the speaker is located in. /// diff --git a/Exiled.Events/EventArgs/Scp079/StoppingSpeakerEventArgs.cs b/Exiled.Events/EventArgs/Scp079/StoppingSpeakerEventArgs.cs index 2ab3b9e886..c52fcde3a8 100644 --- a/Exiled.Events/EventArgs/Scp079/StoppingSpeakerEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp079/StoppingSpeakerEventArgs.cs @@ -8,12 +8,13 @@ namespace Exiled.Events.EventArgs.Scp079 { using Exiled.API.Features; + using Exiled.API.Features.Roles; using Exiled.Events.EventArgs.Interfaces; /// /// Contains all information before SCP-079 finishes using a speaker. /// - public class StoppingSpeakerEventArgs : IPlayerEvent, IDeniableEvent + public class StoppingSpeakerEventArgs : IScp079Event, IDeniableEvent { /// /// Initializes a new instance of the class. @@ -30,6 +31,7 @@ public class StoppingSpeakerEventArgs : IPlayerEvent, IDeniableEvent public StoppingSpeakerEventArgs(Player player, Room room, bool isAllowed = true) { Player = player; + Scp079 = player.Role.As(); Room = room; IsAllowed = isAllowed; } @@ -39,6 +41,9 @@ public StoppingSpeakerEventArgs(Player player, Room room, bool isAllowed = true) /// public Player Player { get; } + /// + public Scp079Role Scp079 { get; } + /// /// Gets the room that the speaker is located in. /// diff --git a/Exiled.Events/EventArgs/Scp079/TriggeringDoorEventArgs.cs b/Exiled.Events/EventArgs/Scp079/TriggeringDoorEventArgs.cs index 0440bfe4da..8548c9bdb9 100644 --- a/Exiled.Events/EventArgs/Scp079/TriggeringDoorEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp079/TriggeringDoorEventArgs.cs @@ -10,7 +10,7 @@ namespace Exiled.Events.EventArgs.Scp079 using API.Features; using Exiled.API.Features.Roles; - + using Exiled.Events.EventArgs.Interfaces; using Interactables.Interobjects.DoorUtils; using Player; @@ -18,7 +18,7 @@ namespace Exiled.Events.EventArgs.Scp079 /// /// Contains all information before SCP-079 interacts with a door. /// - public class TriggeringDoorEventArgs : InteractingDoorEventArgs + public class TriggeringDoorEventArgs : IScp079Event, IDoorEvent, IDeniableEvent { /// /// Initializes a new instance of the class. @@ -33,11 +33,30 @@ public class TriggeringDoorEventArgs : InteractingDoorEventArgs /// /// public TriggeringDoorEventArgs(Player player, DoorVariant door, float auxiliaryPowerCost) - : base(player, door, auxiliaryPowerCost <= player.Role.As().Energy) { - AuxiliaryPowerCost = auxiliaryPowerCost; + Player = player; + Scp079 = player.Role.As(); + Door = Door.Get(door); } + /// + /// Gets or sets a value indicating whether or not the player can interact with the door. + /// + public bool IsAllowed { get; set; } = true; + + /// + /// Gets or sets the instance. + /// + public Door Door { get; set; } + + /// + /// Gets the player who's interacting with the door. + /// + public Player Player { get; } + + /// + public Scp079Role Scp079 { get; } + /// /// Gets or sets the amount of auxiliary power required to trigger a door through SCP-079. /// diff --git a/Exiled.Events/EventArgs/Scp079/ZoneBlackoutEventArgs.cs b/Exiled.Events/EventArgs/Scp079/ZoneBlackoutEventArgs.cs index 51f80118e6..4e74b8654a 100644 --- a/Exiled.Events/EventArgs/Scp079/ZoneBlackoutEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp079/ZoneBlackoutEventArgs.cs @@ -20,7 +20,7 @@ namespace Exiled.Events.EventArgs.Scp079 /// /// Contains all information before SCP-079 lockdowns a room. /// - public class ZoneBlackoutEventArgs : IPlayerEvent, IDeniableEvent + public class ZoneBlackoutEventArgs : IScp079Event, IDeniableEvent { /// /// Initializes a new instance of the class. @@ -46,6 +46,7 @@ public class ZoneBlackoutEventArgs : IPlayerEvent, IDeniableEvent public ZoneBlackoutEventArgs(ReferenceHub player, FacilityZone zone, float auxiliaryPowerCost, float blackoutduration, float cooldown, Scp079HudTranslation scp079HudTranslation) { Player = Player.Get(player); + Scp079 = Player.Role.As(); Zone = zone.GetZone(); AuxiliaryPowerCost = auxiliaryPowerCost; BlackoutDuration = blackoutduration; @@ -88,5 +89,8 @@ public ZoneBlackoutEventArgs(ReferenceHub player, FacilityZone zone, float auxil /// Gets or sets a value indicating whether or not SCP-079 can lockdown a room. /// public bool IsAllowed { get; set; } + + /// + public API.Features.Roles.Scp079Role Scp079 { get; } } } \ No newline at end of file diff --git a/Exiled.Events/Patches/Events/Scp079/ChangingCamera.cs b/Exiled.Events/Patches/Events/Scp079/ChangingCamera.cs index 9c327139ff..81d438e9cb 100644 --- a/Exiled.Events/Patches/Events/Scp079/ChangingCamera.cs +++ b/Exiled.Events/Patches/Events/Scp079/ChangingCamera.cs @@ -18,7 +18,10 @@ namespace Exiled.Events.Patches.Events.Scp079 using HarmonyLib; using Mirror; + using PlayerRoles.PlayableScps.Scp079; using PlayerRoles.PlayableScps.Scp079.Cameras; + using PlayerRoles.PlayableScps.Subroutines; + using PluginAPI.Events; using static HarmonyLib.AccessTools; @@ -35,57 +38,64 @@ private static IEnumerable Transpiler(IEnumerable newInstructions = ListPool.Pool.Get(instructions); - const int offset = 2; - int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Conv_R4) + offset; + int offset = -2; + int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Ldloca_S) + offset; - // Define the first label of the last "ret" and retrieve it. - Label returnLabel = newInstructions[newInstructions.Count - 1].WithLabels(generator.DefineLabel()).labels[0]; + Label returnLabel = generator.DefineLabel(); LocalBuilder ev = generator.DeclareLocal(typeof(ChangingCameraEventArgs)); - // ChangingCameraEventArgs ev = new(Player.Get(this.gameObject), camera, num) - // - // Handlers.Scp079.OnChangingCamera(ev) - // - // if (!ev.IsAllowed) - // return; - // - // num = ev.AuxiliaryPowerCost newInstructions.InsertRange( index, new CodeInstruction[] { - // this - new(OpCodes.Ldarg_0), + // Player.Get(base.Owner) + new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]), + new(OpCodes.Call, PropertyGetter(typeof(ScpStandardSubroutine), nameof(ScpStandardSubroutine.Owner))), + new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), - // num (auxiliary power cost) - new(OpCodes.Ldloca_S, 0), + // this._switchTarget + new CodeInstruction(OpCodes.Ldarg_0), + new(OpCodes.Call, PropertyGetter(typeof(Scp079CurrentCameraSync), nameof(Scp079CurrentCameraSync._switchTarget))), - new(OpCodes.Call, Method(typeof(ChangingCamera), nameof(ChangingCamera.ChangingCameraEvent))), + // num (cost) + new(OpCodes.Ldloc_0), - // if (!ev.IsAllowed) - // return; - new(OpCodes.Brfalse_S, returnLabel), - }); + // ChangingCameraEventArgs ev = new(Player, Scp079Camera, float) + new CodeInstruction(OpCodes.Newobj, GetDeclaredConstructors(typeof(ChangingCameraEventArgs))[0]), + new(OpCodes.Dup), + new(OpCodes.Dup), + new(OpCodes.Stloc_S, ev.LocalIndex), - for (int z = 0; z < newInstructions.Count; z++) - yield return newInstructions[z]; + // Scp079.OnChangingCamera(ev) + new(OpCodes.Call, Method(typeof(Scp079), nameof(Scp079.OnChangingCamera))), - ListPool.Pool.Return(newInstructions); - } + // if (ev.IsAllowed) return; + new(OpCodes.Callvirt, PropertyGetter(typeof(ChangingCameraEventArgs), nameof(ChangingCameraEventArgs.IsAllowed))), + new(OpCodes.Brfalse, returnLabel), - private static bool ChangingCameraEvent(Scp079CurrentCameraSync instance, ref float cost) - { - ChangingCameraEventArgs ev = new ChangingCameraEventArgs(Player.Get(instance.Owner), instance._switchTarget, cost); + // num = ev.AuxiliaryPowerCost + new(OpCodes.Ldloc_S, ev.LocalIndex), + new(OpCodes.Callvirt, PropertyGetter(typeof(ChangingCameraEventArgs), nameof(ChangingCameraEventArgs.AuxiliaryPowerCost))), + new(OpCodes.Stloc_0), - Scp079.OnChangingCamera(ev); + // this._switchTarget = ev.Camera.Base + new(OpCodes.Ldarg_0), + new(OpCodes.Ldloc_S, ev.LocalIndex), + new(OpCodes.Callvirt, PropertyGetter(typeof(ChangingCameraEventArgs), nameof(ChangingCameraEventArgs.Camera))), + new(OpCodes.Callvirt, PropertyGetter(typeof(API.Features.Camera), nameof(API.Features.Camera.Base))), + new(OpCodes.Stfld, Field(typeof(Scp079CurrentCameraSync), nameof(Scp079CurrentCameraSync._switchTarget))), + }); - instance.ServerSendRpc(true); + // return as the same way than NW does + offset = 2; + index = newInstructions.FindIndex(instruction => instruction.operand == (object)Method(typeof(EventManager), nameof(EventManager.ExecuteEvent))) + offset; + newInstructions[index].labels.Add(returnLabel); - if (ev.IsAllowed) - cost = ev.AuxiliaryPowerCost; + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; - return ev.IsAllowed; + ListPool.Pool.Return(newInstructions); } } } \ No newline at end of file diff --git a/Exiled.Events/Patches/Events/Scp079/Pinging.cs b/Exiled.Events/Patches/Events/Scp079/Pinging.cs index 2e31d06d36..f11a3b95e9 100644 --- a/Exiled.Events/Patches/Events/Scp079/Pinging.cs +++ b/Exiled.Events/Patches/Events/Scp079/Pinging.cs @@ -8,13 +8,16 @@ namespace Exiled.Events.Patches.Events.Scp079 { using System.Collections.Generic; + using System.Reflection; using System.Reflection.Emit; using API.Features.Pools; using Exiled.Events.EventArgs.Scp079; using HarmonyLib; using Mirror; + using PlayerRoles.PlayableScps.Scp079; using PlayerRoles.PlayableScps.Scp079.Pinging; + using PlayerRoles.PlayableScps.Subroutines; using RelativePositioning; using UnityEngine; @@ -30,42 +33,91 @@ internal static class Pinging private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) { List newInstructions = ListPool.Pool.Get(instructions); - int offset = -2; - int index = newInstructions.FindIndex( - instruction => instruction.Calls(Method(typeof(RelativePositionSerialization), nameof(RelativePositionSerialization.ReadRelativePosition)))) + offset; + + Label returnLabel = generator.DefineLabel(); + + LocalBuilder ev = generator.DeclareLocal(typeof(PingingEventArgs)); + + int offset = 1; + int index = newInstructions.FindLastIndex(instruction => instruction.opcode == OpCodes.Stfld) + offset; + + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // this.Owner + new(OpCodes.Ldarg_0), + new(OpCodes.Call, PropertyGetter(typeof(ScpStandardSubroutine), nameof(ScpStandardSubroutine.Owner))), + + // this._syncPos + new(OpCodes.Ldarg_0), + new(OpCodes.Ldfld, Field(typeof(Scp079PingAbility), nameof(Scp079PingAbility._syncPos))), + + // this._cost + new(OpCodes.Ldarg_0), + new(OpCodes.Ldfld, Field(typeof(Scp079PingAbility), nameof(Scp079PingAbility._cost))), + + // this._syncProcessorIndex + new(OpCodes.Ldarg_0), + new(OpCodes.Ldfld, Field(typeof(Scp079PingAbility), nameof(Scp079PingAbility._syncProcessorIndex))), + + // this._syncNormal + new(OpCodes.Ldarg_0), + new(OpCodes.Ldfld, Field(typeof(Scp079PingAbility), nameof(Scp079PingAbility._syncNormal))), + + // true + new(OpCodes.Ldc_I4_1), + + // PingingEventArgs ev = new(ReferenceHub, RelativePosition, int, byte, Vector3, bool) + new CodeInstruction(OpCodes.Newobj, GetDeclaredConstructors(typeof(PingingEventArgs))[0]), + new(OpCodes.Dup), + new(OpCodes.Dup), + new(OpCodes.Stloc_S, ev.LocalIndex), + + // Scp079.OnPinging(ev) + new(OpCodes.Call, Method(typeof(Handlers.Scp079), nameof(Handlers.Scp079.OnPinging))), + + // if (ev.IsAllowed) return; + new(OpCodes.Callvirt, PropertyGetter(typeof(PingingEventArgs), nameof(PingingEventArgs.IsAllowed))), + new(OpCodes.Brfalse, returnLabel), + + // this._syncPos = new RelativePosition(ev.Position) + new(OpCodes.Ldarg_0), + new(OpCodes.Ldloc_S, ev.LocalIndex), + new(OpCodes.Callvirt, PropertyGetter(typeof(PingingEventArgs), nameof(PingingEventArgs.Position))), + new(OpCodes.Newobj, DeclaredConstructor(typeof(RelativePosition), new[] { typeof(Vector3), })), + new(OpCodes.Stfld, Field(typeof(Scp079PingAbility), nameof(Scp079PingAbility._syncPos))), + + // this._syncProcessorIndex = ev.Type + new(OpCodes.Ldarg_0), + new(OpCodes.Ldloc_S, ev.LocalIndex), + new(OpCodes.Callvirt, PropertyGetter(typeof(PingingEventArgs), nameof(PingingEventArgs.Type))), + new(OpCodes.Stfld, Field(typeof(Scp079PingAbility), nameof(Scp079PingAbility._syncProcessorIndex))), + }); + + // replace "base.AuxManager.CurrentAux -= (float)this._cost;" + // with + // "base.AuxManager.CurrentAux -= ev.AuxiliaryPowerCost;" + offset = -1; + index = newInstructions.FindLastIndex(instruction => instruction.operand == (object)Field(typeof(Scp079PingAbility), nameof(Scp079PingAbility._cost))) + offset; + + newInstructions.RemoveRange(index, 3); newInstructions.InsertRange( index, new CodeInstruction[] { - // Load Scp079PingAbility , NetworkReader into ProcessPinging - new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]), - new(OpCodes.Ldarg_1), - new(OpCodes.Call, Method(typeof(Pinging), nameof(Pinging.ProcessPinging))), - new(OpCodes.Ret), + // ev.AuxiliaryPowerCost + new(OpCodes.Ldloc_S, ev.LocalIndex), + new(OpCodes.Callvirt, PropertyGetter(typeof(PingingEventArgs), nameof(PingingEventArgs.AuxiliaryPowerCost))), }); + newInstructions[newInstructions.Count - 1].WithLabels(returnLabel); + for (int z = 0; z < newInstructions.Count; z++) yield return newInstructions[z]; - ListPool.Pool.Return(newInstructions); - } - private static void ProcessPinging(Scp079PingAbility instance, NetworkReader reader) - { - RelativePosition curRelativePos = reader.ReadRelativePosition(); - Vector3 syncNormal = reader.ReadVector3(); - PingingEventArgs ev = new PingingEventArgs(instance.Owner, curRelativePos, instance._cost, instance._syncProcessorIndex, syncNormal); - - Handlers.Scp079.OnPinging(ev); - - if (ev.IsAllowed) - { - instance._syncNormal = ev.SyncNormal; - instance._syncPos = curRelativePos; - instance.ServerSendRpc(hub => instance.ServerCheckReceiver(hub, ev.Position, (int)ev.Type)); - instance.AuxManager.CurrentAux -= ev.AuxiliaryPowerCost; - instance._rateLimiter.RegisterInput(); - } + ListPool.Pool.Return(newInstructions); } } } \ No newline at end of file diff --git a/Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs b/Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs index dd74f67933..1e2c660a93 100644 --- a/Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs +++ b/Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs @@ -11,12 +11,10 @@ namespace Exiled.Events.Patches.Events.Scp079 using System.Reflection.Emit; using API.Features.Pools; - using Exiled.Events.EventArgs.Scp079; - using HarmonyLib; - using PlayerRoles.PlayableScps.Scp079; + using PlayerRoles.PlayableScps.Subroutines; using static HarmonyLib.AccessTools; @@ -31,14 +29,18 @@ private static IEnumerable Transpiler(IEnumerable newInstructions = ListPool.Pool.Get(instructions); - Label returnLabel = generator.DefineLabel(); + Label returnLabel; + Label allowedJump = generator.DefineLabel(); + Label jump = generator.DefineLabel(); LocalBuilder ev = generator.DeclareLocal(typeof(RoomBlackoutEventArgs)); - int offset = -1; - int index = newInstructions.FindIndex( - instruction => instruction.Calls(PropertyGetter(typeof(Scp079AbilityBase), nameof(Scp079AbilityBase.LostSignalHandler)))) + offset; - newInstructions.RemoveRange(index, 4); + int index = newInstructions.FindIndex(x => x.opcode == OpCodes.Brfalse); + + returnLabel = (Label)newInstructions[index].operand; + + int offset = -2; + index += offset; newInstructions.InsertRange( index, @@ -46,34 +48,107 @@ private static IEnumerable Transpiler(IEnumerable), nameof(ScpStandardSubroutine.Owner))), + + // this._roomController.Room + new(OpCodes.Ldarg_0), + new(OpCodes.Ldfld, Field(typeof(Scp079BlackoutRoomAbility), nameof(Scp079BlackoutRoomAbility._roomController))), + new(OpCodes.Callvirt, PropertyGetter(typeof(RoomLightController), nameof(RoomLightController.Room))), + + // this._cost + new(OpCodes.Ldarg_0), + new(OpCodes.Ldfld, Field(typeof(Scp079BlackoutRoomAbility), nameof(Scp079BlackoutRoomAbility._cost))), + + // this._duration + new(OpCodes.Ldarg_0), + new(OpCodes.Ldfld, Field(typeof(Scp079BlackoutRoomAbility), nameof(Scp079BlackoutRoomAbility._blackoutDuration))), + + // this._cooldown + new(OpCodes.Ldarg_0), + new(OpCodes.Ldfld, Field(typeof(Scp079BlackoutRoomAbility), nameof(Scp079BlackoutRoomAbility._cooldown))), + + // (!this.IsReady || !base.LostSignalHandler.Lost) + new(OpCodes.Ldarg_0), + new(OpCodes.Ldfld, PropertyGetter(typeof(Scp079BlackoutRoomAbility), nameof(Scp079BlackoutRoomAbility.IsReady))), + new(OpCodes.Brfalse_S, allowedJump), + + new(OpCodes.Ldarg_0), + new(OpCodes.Ldfld, PropertyGetter(typeof(Scp079BlackoutRoomAbility), nameof(Scp079BlackoutRoomAbility.LostSignalHandler))), + new(OpCodes.Callvirt, PropertyGetter(typeof(Scp079LostSignalHandler), nameof(Scp079LostSignalHandler.Lost))), + new(OpCodes.Ldc_I4_0), + new(OpCodes.Ceq), + new(OpCodes.Br, jump), + new CodeInstruction(OpCodes.Ldc_I4_1).WithLabels(allowedJump), + + // RoomBlackoutEventArgs ev = new(ReferenceHub, RoomIdentifier, float, float, float, bool) + new CodeInstruction(OpCodes.Newobj, GetDeclaredConstructors(typeof(RoomBlackoutEventArgs))[0]).WithLabels(jump), + new(OpCodes.Dup), + new(OpCodes.Dup), + new(OpCodes.Stloc_S, ev.LocalIndex), + + // Scp079.OnRoomBlackout(ev) + new(OpCodes.Call, Method(typeof(Handlers.Scp079), nameof(Handlers.Scp079.OnRoomBlackout))), + + // if (ev.IsAllowed) return; + new(OpCodes.Callvirt, PropertyGetter(typeof(ZoneBlackoutEventArgs), nameof(ZoneBlackoutEventArgs.IsAllowed))), new(OpCodes.Brfalse, returnLabel), }); - newInstructions[newInstructions.Count - 1].WithLabels(returnLabel); + // replace "base.AuxManager.CurrentAux -= (float)this._cost;" + // with + // "base.AuxManager.CurrentAux -= ev.AuxiliaryPowerCost;" + offset = -1; + index = newInstructions.FindLastIndex(instruction => instruction.operand == (object)Field(typeof(Scp079BlackoutRoomAbility), nameof(Scp079BlackoutRoomAbility._cost))) + offset; - for (int z = 0; z < newInstructions.Count; z++) - yield return newInstructions[z]; + newInstructions.RemoveRange(index, 3); - ListPool.Pool.Return(newInstructions); - } + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // ev.AuxiliaryPowerCost + new(OpCodes.Ldloc_S, ev.LocalIndex), + new(OpCodes.Callvirt, PropertyGetter(typeof(RoomBlackoutEventArgs), nameof(RoomBlackoutEventArgs.AuxiliaryPowerCost))), + }); - private static bool ProcessRoomBlackout(Scp079BlackoutRoomAbility instance) - { - RoomBlackoutEventArgs ev = new(instance.Owner, instance._roomController.Room, instance._cost, instance._blackoutDuration, instance._cooldown, !instance.LostSignalHandler.Lost); + // replace "this._blackoutCooldowns[this._roomController.netId] = NetworkTime.time + (double)this._cooldown;" + // with + // "this._blackoutCooldowns[this._roomController.netId] = NetworkTime.time + ev.Cooldown;" + offset = -1; + index = newInstructions.FindLastIndex(instruction => instruction.operand == (object)Field(typeof(Scp079BlackoutRoomAbility), nameof(Scp079BlackoutRoomAbility._cooldown))) + offset; + + newInstructions.RemoveRange(index, 3); - Handlers.Scp079.OnRoomBlackout(ev); + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // ev.Cooldown + new(OpCodes.Ldloc_S, ev.LocalIndex), + new(OpCodes.Callvirt, PropertyGetter(typeof(RoomBlackoutEventArgs), nameof(RoomBlackoutEventArgs.Cooldown))), + }); - if (ev.IsAllowed) - { - instance._blackoutDuration = ev.BlackoutDuration; - instance._cooldown = (float)ev.Cooldown; + // replace "this._blackoutCooldowns[this._roomController.netId] = NetworkTime.time + (double)this._cooldown;" + // with + // "this._blackoutCooldowns[this._roomController.netId] = NetworkTime.time + ev.Cooldown;" + offset = -1; + index = newInstructions.FindLastIndex(instruction => instruction.operand == (object)Field(typeof(Scp079BlackoutRoomAbility), nameof(Scp079BlackoutRoomAbility._blackoutDuration))) + offset; - // Gets casted to float above, even though it is an int, joy. - instance._cost = (int)ev.AuxiliaryPowerCost; - } + newInstructions.RemoveRange(index, 2); - return ev.IsAllowed; + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // ev.BlackoutDuration + new(OpCodes.Ldloc_S, ev.LocalIndex), + new(OpCodes.Callvirt, PropertyGetter(typeof(RoomBlackoutEventArgs), nameof(RoomBlackoutEventArgs.BlackoutDuration))), + }); + + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; + + ListPool.Pool.Return(newInstructions); } } } \ No newline at end of file diff --git a/Exiled.Events/Patches/Events/Scp079/ZoneBlackout.cs b/Exiled.Events/Patches/Events/Scp079/ZoneBlackout.cs index 33ac522de4..49b59d4cab 100644 --- a/Exiled.Events/Patches/Events/Scp079/ZoneBlackout.cs +++ b/Exiled.Events/Patches/Events/Scp079/ZoneBlackout.cs @@ -11,12 +11,13 @@ namespace Exiled.Events.Patches.Events.Scp079 using System.Reflection.Emit; using API.Features.Pools; - + using Exiled.API.Extensions; using Exiled.Events.EventArgs.Scp079; using HarmonyLib; using PlayerRoles.PlayableScps.Scp079; + using PlayerRoles.PlayableScps.Subroutines; using static HarmonyLib.AccessTools; @@ -31,44 +32,121 @@ private static IEnumerable Transpiler(IEnumerable newInstructions = ListPool.Pool.Get(instructions); - int offset = 3; - int index = newInstructions.FindIndex( - instruction => instruction.LoadsField(Field(typeof(Scp079BlackoutZoneAbility), nameof(Scp079BlackoutZoneAbility._syncZone)))) + offset; + LocalBuilder ev = generator.DeclareLocal(typeof(ZoneBlackoutEventArgs)); + + int offset = 0; + int index = newInstructions.FindIndex(x => x.opcode == OpCodes.Brfalse) + offset; newInstructions.InsertRange( index, new CodeInstruction[] { - // Remove NW answer - new(OpCodes.Pop), + // this.Owner + new(OpCodes.Ldarg_0), + new(OpCodes.Call, PropertyGetter(typeof(ScpStandardSubroutine), nameof(ScpStandardSubroutine.Owner))), + + // this._syncZone + new(OpCodes.Ldarg_0), + new(OpCodes.Ldfld, Field(typeof(Scp079BlackoutZoneAbility), nameof(Scp079BlackoutZoneAbility._syncZone))), + + // this._cost + new(OpCodes.Ldarg_0), + new(OpCodes.Ldfld, Field(typeof(Scp079BlackoutZoneAbility), nameof(Scp079BlackoutZoneAbility._cost))), + + // this._duration + new(OpCodes.Ldarg_0), + new(OpCodes.Ldfld, Field(typeof(Scp079BlackoutZoneAbility), nameof(Scp079BlackoutZoneAbility._duration))), - // Pass Scp079BlackoutZoneAbility instance + // this._cooldown new(OpCodes.Ldarg_0), - new(OpCodes.Call, Method(typeof(ZoneBlackout), nameof(ProcessZoneBlackout))), + new(OpCodes.Ldfld, Field(typeof(Scp079BlackoutZoneAbility), nameof(Scp079BlackoutZoneAbility._cooldown))), + + // this.ErrorCode + new(OpCodes.Ldarg_0), + new(OpCodes.Ldfld, PropertyGetter(typeof(Scp079BlackoutZoneAbility), nameof(Scp079BlackoutZoneAbility.ErrorCode))), + + // ZoneBlackoutEventArgs ev = new(ReferenceHub, FacilityZone, float, float, float, Scp079HudTranslation) + new(OpCodes.Newobj, GetDeclaredConstructors(typeof(ZoneBlackoutEventArgs))[0]), + new(OpCodes.Dup), + new(OpCodes.Dup), + new(OpCodes.Stloc_S, ev.LocalIndex), + + // Scp079.OnZoneBlackout(ev) + new(OpCodes.Call, Method(typeof(Handlers.Scp079), nameof(Handlers.Scp079.OnZoneBlackout))), + + // ev.IsAllowed + new(OpCodes.Callvirt, PropertyGetter(typeof(ZoneBlackoutEventArgs), nameof(ZoneBlackoutEventArgs.IsAllowed))), + + // if (ev.IsAllowed) return; }); - for (int z = 0; z < newInstructions.Count; z++) - yield return newInstructions[z]; + offset = 1; + index = newInstructions.FindIndex(x => x.opcode == OpCodes.Ret) + offset; - ListPool.Pool.Return(newInstructions); - } + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // this._syncZone = ev.Zone.GetZone() + new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]), + new(OpCodes.Ldloc_S, ev.LocalIndex), + new(OpCodes.Callvirt, PropertyGetter(typeof(ZoneBlackoutEventArgs), nameof(ZoneBlackoutEventArgs.Zone))), + new(OpCodes.Call, Method(typeof(RoomExtensions), nameof(RoomExtensions.GetZone), new[] { typeof(API.Enums.ZoneType), })), + new(OpCodes.Callvirt, PropertySetter(typeof(Scp079BlackoutZoneAbility), nameof(Scp079BlackoutZoneAbility._syncZone))), + }); - private static bool ProcessZoneBlackout(Scp079BlackoutZoneAbility instance) - { - ZoneBlackoutEventArgs ev = new(instance.Owner, instance._syncZone, instance._cost, instance._duration, instance._cooldown, instance.ErrorCode); + // replace "roomLightController.ServerFlickerLights(this._duration);" + // with + // "roomLightController.ServerFlickerLights(ev.Duration);" + offset = -1; + index = newInstructions.FindLastIndex(instruction => instruction.operand == (object)Field(typeof(Scp079BlackoutZoneAbility), nameof(Scp079BlackoutZoneAbility._duration))) + offset; + newInstructions.RemoveRange(index, 2); - Handlers.Scp079.OnZoneBlackout(ev); + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // ev.BlackoutDuration + new(OpCodes.Ldloc_S, ev.LocalIndex), + new(OpCodes.Callvirt, PropertyGetter(typeof(ZoneBlackoutEventArgs), nameof(ZoneBlackoutEventArgs.BlackoutDuration))), + }); - if (ev.IsAllowed) - { - instance._duration = ev.BlackoutDuration; - instance._cooldown = ev.Cooldown; + // replace "this._cooldownTimer.Trigger((double)this._cooldown);" + // with + // "this._cooldownTimer.Trigger((double)ev._cooldown);" + offset = -1; + index = newInstructions.FindLastIndex(instruction => instruction.operand == (object)Field(typeof(Scp079BlackoutZoneAbility), nameof(Scp079BlackoutZoneAbility._cooldown))) + offset; + newInstructions.RemoveRange(index, 3); - // Gets casted to float above, even though it is an int, joy. - instance._cost = (int)ev.AuxiliaryPowerCost; - } + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // ev.Cooldown + new(OpCodes.Ldloc_S, ev.LocalIndex), + new(OpCodes.Callvirt, PropertyGetter(typeof(ZoneBlackoutEventArgs), nameof(ZoneBlackoutEventArgs.Cooldown))), + }); - return ev.IsAllowed; + // replace "base.AuxManager.CurrentAux -= (float)this._cost;" + // with + // "base.AuxManager.CurrentAux -= (float)ev.AuxiliaryPowerCost;" + offset = -1; + index = newInstructions.FindLastIndex(instruction => instruction.operand == (object)Field(typeof(Scp079BlackoutZoneAbility), nameof(Scp079BlackoutZoneAbility._cost))) + offset; + newInstructions.RemoveRange(index, 3); + + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // ev.AuxiliaryPowerCost + new(OpCodes.Ldloc_S, ev.LocalIndex), + new(OpCodes.Callvirt, PropertyGetter(typeof(ZoneBlackoutEventArgs), nameof(ZoneBlackoutEventArgs.AuxiliaryPowerCost))), + }); + + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; + + ListPool.Pool.Return(newInstructions); } } } \ No newline at end of file From 3a1f50b6e106d815ac996cde862b9ad365320e40 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Tue, 29 Aug 2023 15:10:15 +0200 Subject: [PATCH 027/207] Testing --- .../Patches/Events/Scp079/RoomBlackout.cs | 11 +++++--- .../Patches/Events/Scp079/ZoneBlackout.cs | 26 ++++++++++++++----- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs b/Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs index 1e2c660a93..c25171cafc 100644 --- a/Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs +++ b/Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs @@ -11,6 +11,7 @@ namespace Exiled.Events.Patches.Events.Scp079 using System.Reflection.Emit; using API.Features.Pools; + using Exiled.API.Features; using Exiled.Events.EventArgs.Scp079; using HarmonyLib; using PlayerRoles.PlayableScps.Scp079; @@ -55,9 +56,10 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable instruction.operand == (object)Field(typeof(Scp079BlackoutRoomAbility), nameof(Scp079BlackoutRoomAbility._blackoutDuration))) + offset; @@ -145,6 +147,9 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable x.opcode == OpCodes.Brfalse) + offset; + int offset = -2; + int index = newInstructions.FindIndex(x => x.opcode == OpCodes.Brfalse_S) + offset; + Log.Info($"ZoneBlackout {index}"); + + // remove "this.ErrorCode" + newInstructions.RemoveRange(index, 2); newInstructions.InsertRange( index, @@ -49,9 +54,10 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable x.opcode == OpCodes.Ret) + offset; + Log.Info($"ZoneBlackout {index}"); newInstructions.InsertRange( index, @@ -92,7 +99,7 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable instruction.operand == (object)Field(typeof(Scp079BlackoutZoneAbility), nameof(Scp079BlackoutZoneAbility._duration))) + offset; + Log.Info($"ZoneBlackout {index}"); + newInstructions.RemoveRange(index, 2); newInstructions.InsertRange( @@ -116,7 +125,8 @@ private static IEnumerable Transpiler(IEnumerable instruction.operand == (object)Field(typeof(Scp079BlackoutZoneAbility), nameof(Scp079BlackoutZoneAbility._cooldown))) + offset; - newInstructions.RemoveRange(index, 3); + Log.Info($"ZoneBlackout {index}"); + newInstructions.RemoveRange(index, 2); newInstructions.InsertRange( index, @@ -129,9 +139,10 @@ private static IEnumerable Transpiler(IEnumerable instruction.operand == (object)Field(typeof(Scp079BlackoutZoneAbility), nameof(Scp079BlackoutZoneAbility._cost))) + offset; + Log.Info($"ZoneBlackout {index}"); newInstructions.RemoveRange(index, 3); newInstructions.InsertRange( @@ -143,6 +154,9 @@ private static IEnumerable Transpiler(IEnumerable Date: Tue, 29 Aug 2023 17:34:09 +0200 Subject: [PATCH 028/207] Fix ChangingCamera --- Exiled.Events/Patches/Events/Scp079/ChangingCamera.cs | 6 +++--- Exiled.Events/Patches/Events/Scp079/Pinging.cs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Exiled.Events/Patches/Events/Scp079/ChangingCamera.cs b/Exiled.Events/Patches/Events/Scp079/ChangingCamera.cs index 81d438e9cb..2597b1da8e 100644 --- a/Exiled.Events/Patches/Events/Scp079/ChangingCamera.cs +++ b/Exiled.Events/Patches/Events/Scp079/ChangingCamera.cs @@ -56,7 +56,7 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable instruction.operand == (object)Method(typeof(EventManager), nameof(EventManager.ExecuteEvent))) + offset; + offset = 1; + index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Brtrue_S) + offset; newInstructions[index].labels.Add(returnLabel); for (int z = 0; z < newInstructions.Count; z++) diff --git a/Exiled.Events/Patches/Events/Scp079/Pinging.cs b/Exiled.Events/Patches/Events/Scp079/Pinging.cs index f11a3b95e9..7548234656 100644 --- a/Exiled.Events/Patches/Events/Scp079/Pinging.cs +++ b/Exiled.Events/Patches/Events/Scp079/Pinging.cs @@ -39,7 +39,7 @@ private static IEnumerable Transpiler(IEnumerable instruction.opcode == OpCodes.Stfld) + offset; + int index = newInstructions.FindLastIndex(x => x.opcode == OpCodes.Stfld) + offset; newInstructions.InsertRange( index, @@ -99,7 +99,7 @@ private static IEnumerable Transpiler(IEnumerable instruction.operand == (object)Field(typeof(Scp079PingAbility), nameof(Scp079PingAbility._cost))) + offset; + index = newInstructions.FindLastIndex(x => x.operand == (object)Field(typeof(Scp079PingAbility), nameof(Scp079PingAbility._cost))) + offset; newInstructions.RemoveRange(index, 3); From 8437ef651026d4f59cb57900b41f8172bd32ef9a Mon Sep 17 00:00:00 2001 From: louis1706 Date: Wed, 6 Sep 2023 11:07:22 +0200 Subject: [PATCH 029/207] Fix changed file --- .../Patches/Events/Scp0492/Consuming.cs | 114 ++++++++++-------- 1 file changed, 62 insertions(+), 52 deletions(-) diff --git a/Exiled.Events/Patches/Events/Scp0492/Consuming.cs b/Exiled.Events/Patches/Events/Scp0492/Consuming.cs index 6cfe439772..78de4de588 100644 --- a/Exiled.Events/Patches/Events/Scp0492/Consuming.cs +++ b/Exiled.Events/Patches/Events/Scp0492/Consuming.cs @@ -5,83 +5,93 @@ // // ----------------------------------------------------------------------- -namespace Exiled.Events.Patches.Events.Scp0492 +namespace Exiled.Events.Patches.Events.Scp049 { using System.Collections.Generic; using System.Reflection.Emit; - using API.Features.Pools; + using Exiled.API.Features; + using Exiled.API.Features.Pools; using Exiled.Events.Attributes; using Exiled.Events.EventArgs.Scp0492; using HarmonyLib; + using PlayerRoles.PlayableScps.Scp049; using PlayerRoles.PlayableScps.Scp049.Zombies; using PlayerRoles.PlayableScps.Subroutines; + using PlayerStatsSystem; using static HarmonyLib.AccessTools; /// - /// Patches - /// to add event. + /// Adds the event. /// [EventPatch(typeof(Handlers.Scp0492), nameof(Handlers.Scp0492.ConsumingCorpse))] - [HarmonyPatch(typeof(RagdollAbilityBase), nameof(RagdollAbilityBase.ServerProcessCmd))] + [HarmonyPatch(typeof(ZombieConsumeAbility), nameof(ZombieConsumeAbility.ServerProcessCmd))] public class Consuming { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) { List newInstructions = ListPool.Pool.Get(instructions); - int offset = 2; - int index = newInstructions.FindIndex(instrc => instrc.Calls(Method(typeof(RagdollAbilityBase), nameof(RagdollAbilityBase.ServerValidateBegin)))) + offset; - - Label retLabel = generator.DefineLabel(); LocalBuilder ev = generator.DeclareLocal(typeof(ConsumingCorpseEventArgs)); - newInstructions.InsertRange(index, new CodeInstruction[] - { - // this.Owner - new (OpCodes.Ldarg_0), - new (OpCodes.Callvirt, PropertyGetter(typeof(ScpStandardSubroutine), nameof(ScpStandardSubroutine.Owner))), - - // this.CurRagdoll - new(OpCodes.Ldarg_0), - new(OpCodes.Callvirt, PropertyGetter(typeof(RagdollAbilityBase), nameof(RagdollAbilityBase.CurRagdoll))), - - // this._errorCode - new(OpCodes.Ldarg_0), - new(OpCodes.Ldfld, Field(typeof(RagdollAbilityBase), nameof(RagdollAbilityBase._errorCode))), - - // true - new(OpCodes.Ldc_I4_1), - - // ConsumingCorpseEventArgs = new(this.Owner, this.Ragdoll, this._errorCode, true) - new(OpCodes.Newobj, GetDeclaredConstructors(typeof(ConsumingCorpseEventArgs))[0]), - new(OpCodes.Dup), - new(OpCodes.Dup), - new(OpCodes.Stloc, ev.LocalIndex), - - // Handlers.Scp0492.OnConsumingCorpse(ev) - new(OpCodes.Call, Method(typeof(Handlers.Scp0492), nameof(Handlers.Scp0492.OnConsumingCorpse))), - - // if (!ev.IsAllowed) - // return - new(OpCodes.Callvirt, PropertyGetter(typeof(ConsumingCorpseEventArgs), nameof(ConsumingCorpseEventArgs.IsAllowed))), - new(OpCodes.Brtrue_S, retLabel), - - new(OpCodes.Ret), - - // this._errorCode = ev.ErrorCode - new CodeInstruction(OpCodes.Ldloc, ev.LocalIndex).WithLabels(retLabel), - new(OpCodes.Ldarg_0), - new(OpCodes.Callvirt, PropertyGetter(typeof(ConsumingCorpseEventArgs), nameof(ConsumingCorpseEventArgs.ErrorCode))), - new(OpCodes.Stfld, Field(typeof(RagdollAbilityBase), nameof(RagdollAbilityBase._errorCode))), - }); - - foreach (var instruction in newInstructions) - yield return instruction; + int offset = 1; + int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Ret) + offset; + + Label returnLabel = generator.DefineLabel(); + + newInstructions.InsertRange( + index, + new[] + { + // Player.Get(base.Owner) + new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]), + new(OpCodes.Call, PropertyGetter(typeof(ScpStandardSubroutine), nameof(ScpStandardSubroutine.Owner))), + new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), + + // base.CurRagdoll + new CodeInstruction(OpCodes.Ldarg_0), + new(OpCodes.Call, PropertyGetter(typeof(RagdollAbilityBase), nameof(RagdollAbilityBase.CurRagdoll))), + + // true + new(OpCodes.Ldc_I4_1), + + // ConsumingCorpseEventArgs ev = new(Player, Ragdoll, bool) + new(OpCodes.Newobj, GetDeclaredConstructors(typeof(ConsumingCorpseEventArgs))[0]), + new(OpCodes.Dup), + new(OpCodes.Dup), + new(OpCodes.Stloc_S, ev.LocalIndex), + + // Handlers.Scp0492.OnSendingCall(ev) + new(OpCodes.Call, Method(typeof(Handlers.Scp0492), nameof(Handlers.Scp0492.OnConsumingCorpse))), + + // if (!ev.IsAllowed) + // return; + new(OpCodes.Callvirt, PropertyGetter(typeof(ConsumingCorpseEventArgs), nameof(ConsumingCorpseEventArgs.IsAllowed))), + new(OpCodes.Brfalse_S, returnLabel), + }); + + // replace "base.Owner.playerStats.GetModule().ServerHeal(100f)" with "base.Owner.playerStats.GetModule().ServerHeal(ev.ConsumeHeal)" + offset = -1; + index = newInstructions.FindIndex(instruction => instruction.operand == (object)Method(typeof(HealthStat), nameof(HealthStat.ServerHeal))) + offset; + newInstructions.RemoveAt(index); + + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // ev.ConsumeHeal + new(OpCodes.Ldloc_S, ev.LocalIndex), + new(OpCodes.Callvirt, PropertyGetter(typeof(ConsumingCorpseEventArgs), nameof(ConsumingCorpseEventArgs.ConsumeHeal))), + }); + + newInstructions[newInstructions.Count - 1].WithLabels(returnLabel); + + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; ListPool.Pool.Return(newInstructions); } } -} +} \ No newline at end of file From 70ac128c1381641aa6acfd08aeaca3a830c51fef Mon Sep 17 00:00:00 2001 From: IRacle Date: Sun, 10 Sep 2023 19:03:47 +0300 Subject: [PATCH 030/207] role isValid --- Exiled.API/Features/Roles/Role.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.API/Features/Roles/Role.cs b/Exiled.API/Features/Roles/Role.cs index ca6a3f823c..d65084c4c4 100644 --- a/Exiled.API/Features/Roles/Role.cs +++ b/Exiled.API/Features/Roles/Role.cs @@ -112,7 +112,7 @@ protected Role(PlayerRoleBase baseRole) /// /// Gets a value indicating whether or not this role is still valid. This will only ever be if the Role is stored and accessed at a later date. /// - public bool IsValid => Owner == null || Type == Owner.RoleManager.CurrentRole.RoleTypeId; + public bool IsValid => Owner != null && Owner.IsConnected && Base == Owner.RoleManager.CurrentRole; /// /// Gets a random spawn position of this role. From 264f0d1a7e4dd366fbf24ed1f3e014979a849243 Mon Sep 17 00:00:00 2001 From: IRacle Date: Sun, 10 Sep 2023 20:37:56 +0300 Subject: [PATCH 031/207] first changes --- Exiled.API/Features/Items/Armor.cs | 19 ++++++++++ Exiled.API/Features/Items/ExplosiveGrenade.cs | 15 ++++++++ Exiled.API/Features/Items/FlashGrenade.cs | 13 +++++++ Exiled.API/Features/Items/Item.cs | 14 ++++++++ Exiled.API/Features/Items/Jailbird.cs | 16 +++++++++ Exiled.API/Features/Items/Keycard.cs | 13 +++++++ Exiled.API/Features/Items/Scp330.cs | 12 ++++--- Exiled.API/Features/Items/Usable.cs | 22 ++++++++++-- .../Features/Pickups/BodyArmorPickup.cs | 24 ++----------- .../Pickups/ExplosiveGrenadePickup.cs | 23 ++---------- .../Features/Pickups/FlashGrenadePickup.cs | 21 ++--------- Exiled.API/Features/Pickups/JailbirdPickup.cs | 21 ++--------- Exiled.API/Features/Pickups/KeycardPickup.cs | 18 ++-------- Exiled.API/Features/Pickups/Pickup.cs | 35 +++---------------- .../Pickups/Projectiles/Projectile.cs | 4 +-- Exiled.API/Features/Pickups/UsablePickup.cs | 19 ++-------- 16 files changed, 135 insertions(+), 154 deletions(-) diff --git a/Exiled.API/Features/Items/Armor.cs b/Exiled.API/Features/Items/Armor.cs index 170f0602be..fadef406f1 100644 --- a/Exiled.API/Features/Items/Armor.cs +++ b/Exiled.API/Features/Items/Armor.cs @@ -11,6 +11,7 @@ namespace Exiled.API.Features.Items using System.Collections.Generic; using System.Linq; + using Exiled.API.Features.Pickups; using Exiled.API.Interfaces; using InventorySystem.Items.Armor; @@ -20,6 +21,8 @@ namespace Exiled.API.Features.Items using Structs; using UnityEngine; + using BodyArmorPickup = Pickups.BodyArmorPickup; + /// /// A wrapper class for . /// @@ -176,5 +179,21 @@ public IEnumerable CategoryLimits VestEfficacy = VestEfficacy, HelmetEfficacy = HelmetEfficacy, }; + + /// + internal override void ReadPickupInfo(Pickup pickup) + { + base.ReadPickupInfo(pickup); + if (pickup is BodyArmorPickup armorPickup) + { + HelmetEfficacy = armorPickup.HelmetEfficacy; + VestEfficacy = armorPickup.VestEfficacy; + RemoveExcessOnDrop = armorPickup.RemoveExcessOnDrop; + StaminaUseMultiplier = armorPickup.StaminaUseMultiplier; + MovementSpeedMultiplier = armorPickup.MovementSpeedMultiplier; + AmmoLimits = armorPickup.AmmoLimits; + CategoryLimits = armorPickup.CategoryLimits; + } + } } } \ No newline at end of file diff --git a/Exiled.API/Features/Items/ExplosiveGrenade.cs b/Exiled.API/Features/Items/ExplosiveGrenade.cs index 0a93ea93f0..cb97efa089 100644 --- a/Exiled.API/Features/Items/ExplosiveGrenade.cs +++ b/Exiled.API/Features/Items/ExplosiveGrenade.cs @@ -161,5 +161,20 @@ public ExplosionGrenadeProjectile SpawnActive(Vector3 position, Player owner = n PinPullTime = PinPullTime, Repickable = Repickable, }; + + /// + internal override void ReadPickupInfo(Pickup pickup) + { + base.ReadPickupInfo(pickup); + if (pickup is ExplosiveGrenadePickup explosiveGrenadePickup) + { + MaxRadius = explosiveGrenadePickup.MaxRadius; + ScpDamageMultiplier = explosiveGrenadePickup.ScpDamageMultiplier; + BurnDuration = explosiveGrenadePickup.BurnDuration; + DeafenDuration = explosiveGrenadePickup.DeafenDuration; + ConcussDuration = explosiveGrenadePickup.ConcussDuration; + FuseTime = explosiveGrenadePickup.FuseTime; + } + } } } \ No newline at end of file diff --git a/Exiled.API/Features/Items/FlashGrenade.cs b/Exiled.API/Features/Items/FlashGrenade.cs index 9638c9eade..e2d009ac7a 100644 --- a/Exiled.API/Features/Items/FlashGrenade.cs +++ b/Exiled.API/Features/Items/FlashGrenade.cs @@ -137,5 +137,18 @@ public FlashbangProjectile SpawnActive(Vector3 position, Player owner = null) /// /// A string containing FlashGrenade-related data. public override string ToString() => $"{Type} ({Serial}) [{Weight}] *{Scale}* |{FuseTime}|"; + + /// + internal override void ReadPickupInfo(Pickup pickup) + { + base.ReadPickupInfo(pickup); + if (pickup is FlashGrenadePickup flashGrenadePickup) + { + MinimalDurationEffect = flashGrenadePickup.MinimalDurationEffect; + AdditionalBlindedEffect = flashGrenadePickup.AdditionalBlindedEffect; + SurfaceDistanceIntensifier = flashGrenadePickup.SurfaceDistanceIntensifier; + FuseTime = flashGrenadePickup.FuseTime; + } + } } } \ No newline at end of file diff --git a/Exiled.API/Features/Items/Item.cs b/Exiled.API/Features/Items/Item.cs index 4f847af765..4ef1e05248 100644 --- a/Exiled.API/Features/Items/Item.cs +++ b/Exiled.API/Features/Items/Item.cs @@ -293,6 +293,8 @@ public virtual Pickup CreatePickup(Vector3 position, Quaternion rotation = defau ipb.Info = new(Type, Weight, ItemSerialGenerator.GenerateNext()); ipb.gameObject.transform.localScale = Scale; + Base.OnRemoved(ipb); + Pickup pickup = Pickup.Get(ipb); if (spawn) @@ -326,5 +328,17 @@ internal virtual void ChangeOwner(Player oldOwner, Player newOwner) Base.OnAdded(null); } + + /// + /// Helper method for saving data between items and pickups. + /// + /// -related data to give to the . + internal virtual void ReadPickupInfo(Pickup pickup) + { + if (pickup is not null) + { + Scale = pickup.Scale; + } + } } } \ No newline at end of file diff --git a/Exiled.API/Features/Items/Jailbird.cs b/Exiled.API/Features/Items/Jailbird.cs index 2f1d5ef3ea..66d8548166 100644 --- a/Exiled.API/Features/Items/Jailbird.cs +++ b/Exiled.API/Features/Items/Jailbird.cs @@ -7,11 +7,14 @@ namespace Exiled.API.Features.Items { + using Exiled.API.Features.Pickups; using Exiled.API.Interfaces; using InventorySystem.Items.Autosync; using InventorySystem.Items.Jailbird; using Mirror; + using JailbirdPickup = Pickups.JailbirdPickup; + /// /// A wrapped class for . /// @@ -143,5 +146,18 @@ public void Break() /// /// A string containing JailBird-related data. public override string ToString() => $"{Type} ({Serial}) [{Weight}] *{Scale}*"; + + /// + internal override void ReadPickupInfo(Pickup pickup) + { + base.ReadPickupInfo(pickup); + if (pickup is JailbirdPickup jailbirdPickup) + { + MeleeDamage = jailbirdPickup.MeleeDamage; + ChargeDamage = jailbirdPickup.ChargeDamage; + FlashDuration = jailbirdPickup.FlashDuration; + Radius = jailbirdPickup.Radius; + } + } } } \ No newline at end of file diff --git a/Exiled.API/Features/Items/Keycard.cs b/Exiled.API/Features/Items/Keycard.cs index 98a4328918..08d11db561 100644 --- a/Exiled.API/Features/Items/Keycard.cs +++ b/Exiled.API/Features/Items/Keycard.cs @@ -8,10 +8,13 @@ namespace Exiled.API.Features.Items { using Exiled.API.Enums; + using Exiled.API.Features.Pickups; using Exiled.API.Interfaces; using InventorySystem.Items.Keycards; + using KeycardPickup = Pickups.KeycardPickup; + /// /// A wrapper class for . /// @@ -64,5 +67,15 @@ public KeycardPermissions Permissions /// /// A string containing Keycard-related data. public override string ToString() => $"{Type} ({Serial}) [{Weight}] *{Scale}* |{Permissions}|"; + + /// + internal override void ReadPickupInfo(Pickup pickup) + { + base.ReadPickupInfo(pickup); + if (pickup is KeycardPickup keycardPickup) + { + Permissions = keycardPickup.Permissions; + } + } } } \ No newline at end of file diff --git a/Exiled.API/Features/Items/Scp330.cs b/Exiled.API/Features/Items/Scp330.cs index 0dae05ad71..69259cce95 100644 --- a/Exiled.API/Features/Items/Scp330.cs +++ b/Exiled.API/Features/Items/Scp330.cs @@ -235,12 +235,14 @@ public IEnumerable DropCandy(CandyKindID type, bool dropAll = fals /// The created . public override Pickup CreatePickup(Vector3 position, Quaternion rotation = default, bool spawn = true) { - Scp330Pickup pickup = (Scp330Pickup)Pickup.Get(Object.Instantiate(Base.PickupDropModel, position, rotation)); + InventorySystem.Items.Usables.Scp330.Scp330Pickup ipb = (InventorySystem.Items.Usables.Scp330.Scp330Pickup)Object.Instantiate(Base.PickupDropModel, position, rotation); - pickup.Info = new(Type, Weight, ItemSerialGenerator.GenerateNext()); - pickup.Candies = new(Base.Candies); - pickup.ExposedCandy = ExposedType; - pickup.Scale = Scale; + ipb.Info = new(Type, Weight, ItemSerialGenerator.GenerateNext()); + ipb.gameObject.transform.localScale = Scale; + + Base.OnRemoved(ipb); + + Pickup pickup = Pickup.Get(ipb); if (spawn) pickup.Spawn(); diff --git a/Exiled.API/Features/Items/Usable.cs b/Exiled.API/Features/Items/Usable.cs index 406cedb9dc..28c6eda819 100644 --- a/Exiled.API/Features/Items/Usable.cs +++ b/Exiled.API/Features/Items/Usable.cs @@ -11,6 +11,7 @@ namespace Exiled.API.Features.Items using Exiled.API.Interfaces; using InventorySystem.Items; + using InventorySystem.Items.Pickups; using InventorySystem.Items.Usables; using UnityEngine; @@ -109,10 +110,14 @@ public float RemainingCooldown /// The created . public override Pickup CreatePickup(Vector3 position, Quaternion rotation = default, bool spawn = true) { - Pickup pickup = Pickup.Get(Object.Instantiate(Base.PickupDropModel, position, rotation)); + ItemPickupBase ipb = Object.Instantiate(Base.PickupDropModel, position, rotation); - pickup.Info = new(Type, Weight, ItemSerialGenerator.GenerateNext()); - pickup.Scale = Scale; + ipb.Info = new(Type, Weight, ItemSerialGenerator.GenerateNext()); + ipb.gameObject.transform.localScale = Scale; + + Base.OnRemoved(ipb); + + Pickup pickup = Pickup.Get(ipb); if (spawn) pickup.Spawn(); @@ -131,5 +136,16 @@ public virtual void Use() Owner.UseItem(this); } + + /// + internal override void ReadPickupInfo(Pickup pickup) + { + base.ReadPickupInfo(pickup); + if (pickup is UsablePickup usablePickup) + { + UseTime = usablePickup.UseTime; + MaxCancellableTime = usablePickup.MaxCancellableTime; + } + } } } \ No newline at end of file diff --git a/Exiled.API/Features/Pickups/BodyArmorPickup.cs b/Exiled.API/Features/Pickups/BodyArmorPickup.cs index 6f0171a6b3..9d9d9aff1c 100644 --- a/Exiled.API/Features/Pickups/BodyArmorPickup.cs +++ b/Exiled.API/Features/Pickups/BodyArmorPickup.cs @@ -136,9 +136,9 @@ public int VestEfficacy public override string ToString() => $"{Type} ({Serial}) [{Weight}] *{Scale}*"; /// - internal override Pickup GetItemInfo(Item item) + internal override void ReadItemInfo(Item item) { - base.GetItemInfo(item); + base.ReadItemInfo(item); if (item is Armor armoritem) { helmetEfficacy = armoritem.HelmetEfficacy; @@ -149,26 +149,6 @@ internal override Pickup GetItemInfo(Item item) AmmoLimits = armoritem.AmmoLimits; CategoryLimits = armoritem.CategoryLimits; } - - return this; - } - - /// - internal override Item GetPickupInfo(Item item) - { - base.GetPickupInfo(item); - if (item is Armor armoritem) - { - armoritem.HelmetEfficacy = helmetEfficacy; - armoritem.VestEfficacy = vestEfficacy; - armoritem.RemoveExcessOnDrop = RemoveExcessOnDrop; - armoritem.StaminaUseMultiplier = StaminaUseMultiplier; - armoritem.MovementSpeedMultiplier = MovementSpeedMultiplier; - armoritem.AmmoLimits = AmmoLimits; - armoritem.CategoryLimits = CategoryLimits; - } - - return item; } } } diff --git a/Exiled.API/Features/Pickups/ExplosiveGrenadePickup.cs b/Exiled.API/Features/Pickups/ExplosiveGrenadePickup.cs index 2fdbe16277..b0b25cac83 100644 --- a/Exiled.API/Features/Pickups/ExplosiveGrenadePickup.cs +++ b/Exiled.API/Features/Pickups/ExplosiveGrenadePickup.cs @@ -60,9 +60,9 @@ internal ExplosiveGrenadePickup() public float ConcussDuration { get; set; } /// - internal override Pickup GetItemInfo(Item item) + internal override void ReadItemInfo(Item item) { - base.GetItemInfo(item); + base.ReadItemInfo(item); if (item is ExplosiveGrenade explosiveGrenadeitem) { MaxRadius = explosiveGrenadeitem.MaxRadius; @@ -72,25 +72,6 @@ internal override Pickup GetItemInfo(Item item) ConcussDuration = explosiveGrenadeitem.ConcussDuration; FuseTime = explosiveGrenadeitem.FuseTime; } - - return this; - } - - /// - internal override Item GetPickupInfo(Item item) - { - base.GetPickupInfo(item); - if (item is ExplosiveGrenade explosiveGrenadeitem) - { - explosiveGrenadeitem.MaxRadius = MaxRadius; - explosiveGrenadeitem.ScpDamageMultiplier = ScpDamageMultiplier; - explosiveGrenadeitem.BurnDuration = BurnDuration; - explosiveGrenadeitem.DeafenDuration = DeafenDuration; - explosiveGrenadeitem.ConcussDuration = ConcussDuration; - explosiveGrenadeitem.FuseTime = FuseTime; - } - - return item; } /// diff --git a/Exiled.API/Features/Pickups/FlashGrenadePickup.cs b/Exiled.API/Features/Pickups/FlashGrenadePickup.cs index f8dccbf981..96ea9a5f0b 100644 --- a/Exiled.API/Features/Pickups/FlashGrenadePickup.cs +++ b/Exiled.API/Features/Pickups/FlashGrenadePickup.cs @@ -50,9 +50,9 @@ internal FlashGrenadePickup() public float SurfaceDistanceIntensifier { get; set; } /// - internal override Pickup GetItemInfo(Item item) + internal override void ReadItemInfo(Item item) { - base.GetItemInfo(item); + base.ReadItemInfo(item); if (item is FlashGrenade flashGrenadeitem) { MinimalDurationEffect = flashGrenadeitem.MinimalDurationEffect; @@ -60,23 +60,6 @@ internal override Pickup GetItemInfo(Item item) SurfaceDistanceIntensifier = flashGrenadeitem.SurfaceDistanceIntensifier; FuseTime = flashGrenadeitem.FuseTime; } - - return this; - } - - /// - internal override Item GetPickupInfo(Item item) - { - base.GetPickupInfo(item); - if (item is FlashGrenade flashGrenadeitem) - { - flashGrenadeitem.MinimalDurationEffect = MinimalDurationEffect; - flashGrenadeitem.AdditionalBlindedEffect = AdditionalBlindedEffect; - flashGrenadeitem.SurfaceDistanceIntensifier = SurfaceDistanceIntensifier; - flashGrenadeitem.FuseTime = FuseTime; - } - - return item; } /// diff --git a/Exiled.API/Features/Pickups/JailbirdPickup.cs b/Exiled.API/Features/Pickups/JailbirdPickup.cs index aa32d75fb0..82a71b6b72 100644 --- a/Exiled.API/Features/Pickups/JailbirdPickup.cs +++ b/Exiled.API/Features/Pickups/JailbirdPickup.cs @@ -97,9 +97,9 @@ public JailbirdWearState WearState public override string ToString() => $"{Type} ({Serial}) [{Weight}] *{Scale}*"; /// - internal override Pickup GetItemInfo(Item item) + internal override void ReadItemInfo(Item item) { - base.GetItemInfo(item); + base.ReadItemInfo(item); if (item is Jailbird jailBirditem) { MeleeDamage = jailBirditem.MeleeDamage; @@ -107,23 +107,6 @@ internal override Pickup GetItemInfo(Item item) FlashDuration = jailBirditem.FlashDuration; Radius = jailBirditem.Radius; } - - return this; - } - - /// - internal override Item GetPickupInfo(Item item) - { - base.GetPickupInfo(item); - if (item is Jailbird jailBirditem) - { - jailBirditem.MeleeDamage = MeleeDamage; - jailBirditem.ChargeDamage = ChargeDamage; - jailBirditem.FlashDuration = FlashDuration; - jailBirditem.Radius = Radius; - } - - return item; } } } diff --git a/Exiled.API/Features/Pickups/KeycardPickup.cs b/Exiled.API/Features/Pickups/KeycardPickup.cs index ff6729e1ef..7af429d32d 100644 --- a/Exiled.API/Features/Pickups/KeycardPickup.cs +++ b/Exiled.API/Features/Pickups/KeycardPickup.cs @@ -49,27 +49,13 @@ internal KeycardPickup(ItemType type) public new BaseKeycard Base { get; } /// - internal override Pickup GetItemInfo(Item item) + internal override void ReadItemInfo(Item item) { - base.GetItemInfo(item); + base.ReadItemInfo(item); if (item is Keycard keycarditem) { Permissions = keycarditem.Permissions; } - - return this; - } - - /// - internal override Item GetPickupInfo(Item item) - { - base.GetPickupInfo(item); - if (item is Keycard keycarditem) - { - keycarditem.Permissions = Permissions; - } - - return item; } } } diff --git a/Exiled.API/Features/Pickups/Pickup.cs b/Exiled.API/Features/Pickups/Pickup.cs index 4cd013489b..ce142ce044 100644 --- a/Exiled.API/Features/Pickups/Pickup.cs +++ b/Exiled.API/Features/Pickups/Pickup.cs @@ -79,8 +79,6 @@ internal Pickup(ItemType type) if (!InventoryItemLoader.AvailableItems.TryGetValue(type, out ItemBase itemBase)) return; - Base = Object.Instantiate(itemBase.PickupDropModel); - PickupSyncInfo psi = new() { ItemId = type, @@ -88,6 +86,8 @@ internal Pickup(ItemType type) WeightKg = itemBase.Weight, }; + Base = InventoryExtensions.ServerCreatePickup(itemBase, psi, itemBase.PickupDropModel.transform.position, itemBase.PickupDropModel.transform.rotation, false); + Info = psi; BaseToPickup.Add(Base, this); @@ -285,11 +285,6 @@ public Quaternion Rotation /// public bool IsSpawned { get; internal set; } - /// - /// Gets a value indicating whether or not this is a worn item. - /// - public bool IsLoaded { get; internal set; } - /// /// Gets an existing or creates a new instance of one. /// @@ -585,35 +580,15 @@ public void UnSpawn() public override string ToString() => $"{Type} ({Serial}) [{Weight}] *{Scale}* |{Position}| -{IsLocked}- ={InUse}="; /// - /// Returns the Pickup with the according property from the Item. + /// Helper method for saving data between items and pickups. /// - /// Item-related data to give to the Pickup. - /// A Pickup containing the Item-related data. - internal virtual Pickup GetItemInfo(Items.Item item) + /// -related data to give to the . + internal virtual void ReadItemInfo(Items.Item item) { - IsLoaded = true; - if (item is not null) { Scale = item.Scale; } - - return this; - } - - /// - /// Returns the Item with the according property from the Pickup. - /// - /// Pickup-related data to give to the Item. - /// A Item containing the Pickup-related data. - internal virtual Items.Item GetPickupInfo(Items.Item item) - { - if (item is not null) - { - item.Scale = Scale; - } - - return item; } } } diff --git a/Exiled.API/Features/Pickups/Projectiles/Projectile.cs b/Exiled.API/Features/Pickups/Projectiles/Projectile.cs index fc25c68d14..7edebfdb53 100644 --- a/Exiled.API/Features/Pickups/Projectiles/Projectile.cs +++ b/Exiled.API/Features/Pickups/Projectiles/Projectile.cs @@ -120,7 +120,7 @@ public static Projectile Spawn(Projectile pickup, Vector3 position, Quaternion r pickup.Spawn(); if (shouldBeActive) - pickup.Active(); + pickup.Activate(); return pickup; } @@ -128,7 +128,7 @@ public static Projectile Spawn(Projectile pickup, Vector3 position, Quaternion r /// /// Activates the current . /// - public void Active() => Base.ServerActivate(); + public void Activate() => Base.ServerActivate(); /// /// Returns the ProjectilePickup in a human readable format. diff --git a/Exiled.API/Features/Pickups/UsablePickup.cs b/Exiled.API/Features/Pickups/UsablePickup.cs index bf16a134bb..1102842e05 100644 --- a/Exiled.API/Features/Pickups/UsablePickup.cs +++ b/Exiled.API/Features/Pickups/UsablePickup.cs @@ -44,29 +44,14 @@ internal UsablePickup(ItemType type) public float MaxCancellableTime { get; set; } /// - internal override Pickup GetItemInfo(Item item) + internal override void ReadItemInfo(Item item) { - base.GetItemInfo(item); + base.ReadItemInfo(item); if (item is Usable usableitem) { UseTime = usableitem.UseTime; MaxCancellableTime = usableitem.MaxCancellableTime; } - - return this; - } - - /// - internal override Item GetPickupInfo(Item item) - { - base.GetPickupInfo(item); - if (item is Usable usableitem) - { - usableitem.UseTime = UseTime; - usableitem.MaxCancellableTime = MaxCancellableTime; - } - - return item; } } } From c99957d180434571075d69a74e73f6b0236be1a3 Mon Sep 17 00:00:00 2001 From: IRacle Date: Tue, 12 Sep 2023 14:41:55 +0300 Subject: [PATCH 032/207] lol --- Exiled.API/Features/Player.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 40b193e53d..428210c581 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -1803,7 +1803,7 @@ public Pickup DropHeldItem() /// public int CountItem(ItemCategory category) => category switch { - ItemCategory.Ammo => Inventory.UserInventory.ReserveAmmo.Where(ammo => ammo.Value > 0).Count(), + ItemCategory.Ammo => Inventory.UserInventory.ReserveAmmo.Count(ammo => ammo.Value > 0), _ => Inventory.UserInventory.Items.Count(tempItem => tempItem.Value.Category == category), }; From ce8f1b2e92eea99a3a777d0e84cb04628796712b Mon Sep 17 00:00:00 2001 From: IRacle Date: Tue, 12 Sep 2023 15:56:31 +0300 Subject: [PATCH 033/207] testt --- Exiled.API/Features/Items/Armor.cs | 10 ++------ Exiled.API/Features/Items/ExplosiveGrenade.cs | 4 +++- .../Features/Pickups/BodyArmorPickup.cs | 23 ++++++++++++++++--- .../Pickups/ExplosiveGrenadePickup.cs | 17 ++++++++++++++ .../Features/Pickups/FlashGrenadePickup.cs | 15 ++++++++++++ Exiled.API/Features/Pickups/JailbirdPickup.cs | 14 +++++++++++ Exiled.API/Features/Pickups/KeycardPickup.cs | 13 +++++++++++ Exiled.API/Features/Pickups/Pickup.cs | 12 ++++++++++ Exiled.API/Features/Pickups/UsablePickup.cs | 14 +++++++++++ Exiled.API/Features/Player.cs | 2 +- .../Patches/Generic/InventoryControlPatch.cs | 7 +++--- .../Patches/Generic/PickupControlPatch.cs | 8 ++++--- 12 files changed, 119 insertions(+), 20 deletions(-) diff --git a/Exiled.API/Features/Items/Armor.cs b/Exiled.API/Features/Items/Armor.cs index fadef406f1..f2d38add0c 100644 --- a/Exiled.API/Features/Items/Armor.cs +++ b/Exiled.API/Features/Items/Armor.cs @@ -132,14 +132,9 @@ public float StaminaUseMultiplier } /// - /// Gets or sets how much the users movement speed should be affected when wearing this armor. (higher values = slower movement). + /// Gets how much the users movement speed should be affected when wearing this armor. (higher values = slower movement). /// - /// When attempting to set the value below 0 or above 1. - public float MovementSpeedMultiplier - { - get => Base.MovementSpeedMultiplier; - set => Base._movementSpeedMultiplier = value; - } + public float MovementSpeedMultiplier { get; } /// /// Gets how much worse and s are affected by wearing this armor. @@ -190,7 +185,6 @@ internal override void ReadPickupInfo(Pickup pickup) VestEfficacy = armorPickup.VestEfficacy; RemoveExcessOnDrop = armorPickup.RemoveExcessOnDrop; StaminaUseMultiplier = armorPickup.StaminaUseMultiplier; - MovementSpeedMultiplier = armorPickup.MovementSpeedMultiplier; AmmoLimits = armorPickup.AmmoLimits; CategoryLimits = armorPickup.CategoryLimits; } diff --git a/Exiled.API/Features/Items/ExplosiveGrenade.cs b/Exiled.API/Features/Items/ExplosiveGrenade.cs index cb97efa089..c01796cb4d 100644 --- a/Exiled.API/Features/Items/ExplosiveGrenade.cs +++ b/Exiled.API/Features/Items/ExplosiveGrenade.cs @@ -13,11 +13,13 @@ namespace Exiled.API.Features.Items using Exiled.API.Features.Pickups.Projectiles; using InventorySystem.Items; + using InventorySystem.Items.Armor; using InventorySystem.Items.Pickups; using InventorySystem.Items.ThrowableProjectiles; - using UnityEngine; + using static ServerConfigSynchronizer; + using Object = UnityEngine.Object; /// diff --git a/Exiled.API/Features/Pickups/BodyArmorPickup.cs b/Exiled.API/Features/Pickups/BodyArmorPickup.cs index 9d9d9aff1c..8e3c50cc85 100644 --- a/Exiled.API/Features/Pickups/BodyArmorPickup.cs +++ b/Exiled.API/Features/Pickups/BodyArmorPickup.cs @@ -9,11 +9,15 @@ namespace Exiled.API.Features.Pickups { using System; using System.Collections.Generic; + using System.Linq; using Exiled.API.Features.Items; using Exiled.API.Interfaces; using Exiled.API.Structs; + + using InventorySystem.Items; using InventorySystem.Items.Armor; + using UnityEngine; using BaseBodyArmor = InventorySystem.Items.Armor.BodyArmorPickup; @@ -114,10 +118,10 @@ public int VestEfficacy public float StaminaUseMultiplier { get; set; } /// - /// Gets or sets how much the users movement speed should be affected when wearing this armor. (higher values = slower movement). + /// Gets how much the users movement speed should be affected when wearing this armor. (higher values = slower movement). /// /// When attempting to set the value below 0 or above 1. - public float MovementSpeedMultiplier { get; set; } + public float MovementSpeedMultiplier { get; } /// /// Gets or sets the ammo limit of the wearer when using this armor. @@ -145,10 +149,23 @@ internal override void ReadItemInfo(Item item) vestEfficacy = armoritem.VestEfficacy; RemoveExcessOnDrop = armoritem.RemoveExcessOnDrop; StaminaUseMultiplier = armoritem.StaminaUseMultiplier; - MovementSpeedMultiplier = armoritem.MovementSpeedMultiplier; AmmoLimits = armoritem.AmmoLimits; CategoryLimits = armoritem.CategoryLimits; } } + + /// + protected override void InitializeProperties(ItemBase itemBase) + { + base.InitializeProperties(itemBase); + if (itemBase is BodyArmor armoritem) + { + helmetEfficacy = armoritem.HelmetEfficacy; + vestEfficacy = armoritem.VestEfficacy; + RemoveExcessOnDrop = !armoritem.DontRemoveExcessOnDrop; + AmmoLimits = armoritem.AmmoLimits.Select(limit => (ArmorAmmoLimit)limit); + CategoryLimits = armoritem.CategoryLimits; + } + } } } diff --git a/Exiled.API/Features/Pickups/ExplosiveGrenadePickup.cs b/Exiled.API/Features/Pickups/ExplosiveGrenadePickup.cs index b0b25cac83..6123799870 100644 --- a/Exiled.API/Features/Pickups/ExplosiveGrenadePickup.cs +++ b/Exiled.API/Features/Pickups/ExplosiveGrenadePickup.cs @@ -10,6 +10,8 @@ namespace Exiled.API.Features.Pickups using Exiled.API.Enums; using Exiled.API.Features.Items; using Exiled.API.Features.Pickups.Projectiles; + + using InventorySystem.Items; using InventorySystem.Items.ThrowableProjectiles; /// @@ -89,5 +91,20 @@ internal override Pickup GetPickupInfo(Projectile projectile) return projectile; } + + /// + protected override void InitializeProperties(ItemBase itemBase) + { + base.InitializeProperties(itemBase); + if (itemBase is ThrowableItem throwable && throwable.Projectile is ExplosionGrenade explosiveGrenade) + { + MaxRadius = explosiveGrenade._maxRadius; + ScpDamageMultiplier = explosiveGrenade._scpDamageMultiplier; + BurnDuration = explosiveGrenade._burnedDuration; + DeafenDuration = explosiveGrenade._deafenedDuration; + ConcussDuration = explosiveGrenade._concussedDuration; + FuseTime = explosiveGrenade._fuseTime; + } + } } } \ No newline at end of file diff --git a/Exiled.API/Features/Pickups/FlashGrenadePickup.cs b/Exiled.API/Features/Pickups/FlashGrenadePickup.cs index 96ea9a5f0b..5c22733a4d 100644 --- a/Exiled.API/Features/Pickups/FlashGrenadePickup.cs +++ b/Exiled.API/Features/Pickups/FlashGrenadePickup.cs @@ -10,6 +10,8 @@ namespace Exiled.API.Features.Pickups using Exiled.API.Enums; using Exiled.API.Features.Items; using Exiled.API.Features.Pickups.Projectiles; + + using InventorySystem.Items; using InventorySystem.Items.ThrowableProjectiles; /// @@ -75,5 +77,18 @@ internal override Pickup GetPickupInfo(Projectile projectile) return projectile; } + + /// + protected override void InitializeProperties(ItemBase itemBase) + { + base.InitializeProperties(itemBase); + if (itemBase is ThrowableItem throwable && throwable.Projectile is FlashbangGrenade flashGrenade) + { + MinimalDurationEffect = flashGrenade._minimalEffectDuration; + AdditionalBlindedEffect = flashGrenade._additionalBlurDuration; + SurfaceDistanceIntensifier = flashGrenade._surfaceZoneDistanceIntensifier; + FuseTime = flashGrenade._fuseTime; + } + } } } diff --git a/Exiled.API/Features/Pickups/JailbirdPickup.cs b/Exiled.API/Features/Pickups/JailbirdPickup.cs index 82a71b6b72..aa5fa2bf62 100644 --- a/Exiled.API/Features/Pickups/JailbirdPickup.cs +++ b/Exiled.API/Features/Pickups/JailbirdPickup.cs @@ -10,6 +10,7 @@ namespace Exiled.API.Features.Pickups using Exiled.API.Features.Items; using Exiled.API.Interfaces; + using InventorySystem.Items; using InventorySystem.Items.Jailbird; using BaseJailbirdPickup = InventorySystem.Items.Jailbird.JailbirdPickup; @@ -108,5 +109,18 @@ internal override void ReadItemInfo(Item item) Radius = jailBirditem.Radius; } } + + /// + protected override void InitializeProperties(ItemBase itemBase) + { + base.InitializeProperties(itemBase); + if (itemBase is JailbirdItem jailbirdItem) + { + MeleeDamage = jailbirdItem._hitreg._damageMelee; + ChargeDamage = jailbirdItem._hitreg._damageCharge; + FlashDuration = jailbirdItem._hitreg._flashDuration; + Radius = jailbirdItem._hitreg._hitregRadius; + } + } } } diff --git a/Exiled.API/Features/Pickups/KeycardPickup.cs b/Exiled.API/Features/Pickups/KeycardPickup.cs index 7af429d32d..9267e0591e 100644 --- a/Exiled.API/Features/Pickups/KeycardPickup.cs +++ b/Exiled.API/Features/Pickups/KeycardPickup.cs @@ -11,6 +11,9 @@ namespace Exiled.API.Features.Pickups using Exiled.API.Features.Items; using Exiled.API.Interfaces; + using InventorySystem.Items; + using InventorySystem.Items.Keycards; + using BaseKeycard = InventorySystem.Items.Keycards.KeycardPickup; /// @@ -57,5 +60,15 @@ internal override void ReadItemInfo(Item item) Permissions = keycarditem.Permissions; } } + + /// + protected override void InitializeProperties(ItemBase itemBase) + { + base.InitializeProperties(itemBase); + if (itemBase is KeycardItem keycardItem) + { + Permissions = (KeycardPermissions)keycardItem.Permissions; + } + } } } diff --git a/Exiled.API/Features/Pickups/Pickup.cs b/Exiled.API/Features/Pickups/Pickup.cs index ce142ce044..4bdd74fd59 100644 --- a/Exiled.API/Features/Pickups/Pickup.cs +++ b/Exiled.API/Features/Pickups/Pickup.cs @@ -68,6 +68,8 @@ internal Pickup(ItemPickupBase pickupBase) return; BaseToPickup.Add(pickupBase, this); + + InitializeProperties(InventoryItemLoader.AvailableItems[pickupBase.Info.ItemId]); } /// @@ -91,6 +93,8 @@ internal Pickup(ItemType type) Info = psi; BaseToPickup.Add(Base, this); + + InitializeProperties(itemBase); } /// @@ -590,5 +594,13 @@ internal virtual void ReadItemInfo(Items.Item item) Scale = item.Scale; } } + + /// + /// eeee. + /// + /// target item. + protected virtual void InitializeProperties(ItemBase itemBase) + { + } } } diff --git a/Exiled.API/Features/Pickups/UsablePickup.cs b/Exiled.API/Features/Pickups/UsablePickup.cs index 1102842e05..e05a20eea2 100644 --- a/Exiled.API/Features/Pickups/UsablePickup.cs +++ b/Exiled.API/Features/Pickups/UsablePickup.cs @@ -8,7 +8,10 @@ namespace Exiled.API.Features.Pickups { using Exiled.API.Features.Items; + + using InventorySystem.Items; using InventorySystem.Items.Pickups; + using InventorySystem.Items.Usables; /// /// A wrapper class for dropped Usable Pickup. @@ -53,5 +56,16 @@ internal override void ReadItemInfo(Item item) MaxCancellableTime = usableitem.MaxCancellableTime; } } + + /// + protected override void InitializeProperties(ItemBase itemBase) + { + base.InitializeProperties(itemBase); + if (itemBase is UsableItem usableitem) + { + UseTime = usableitem.UseTime; + MaxCancellableTime = usableitem.MaxCancellableTime; + } + } } } diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 428210c581..1fb9218ca5 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -2371,7 +2371,7 @@ public Item AddItem(ItemBase itemBase, Item item = null) item.ChangeOwner(item.Owner, this); - if (Inventory.isLocalPlayer && itemBase is IAcquisitionConfirmationTrigger acquisitionConfirmationTrigger) + if (itemBase is IAcquisitionConfirmationTrigger acquisitionConfirmationTrigger) { acquisitionConfirmationTrigger.ServerConfirmAcqusition(); acquisitionConfirmationTrigger.AcquisitionAlreadyReceived = true; diff --git a/Exiled.Events/Patches/Generic/InventoryControlPatch.cs b/Exiled.Events/Patches/Generic/InventoryControlPatch.cs index 08cdb27273..6651d46dd4 100644 --- a/Exiled.Events/Patches/Generic/InventoryControlPatch.cs +++ b/Exiled.Events/Patches/Generic/InventoryControlPatch.cs @@ -77,10 +77,9 @@ private static void AddItem(Player player, ItemBase itemBase, ItemPickupBase ite { Item item = Item.Get(itemBase); Pickup pickup = Pickup.Get(itemPickupBase); - /* - if (pickup?.IsLoaded ?? false) - pickup.GetPickupInfo(item); - */ + + item.ReadPickupInfo(pickup); + player?.ItemsValue.Add(item); } } diff --git a/Exiled.Events/Patches/Generic/PickupControlPatch.cs b/Exiled.Events/Patches/Generic/PickupControlPatch.cs index ef2a4edf29..8f874a8d63 100644 --- a/Exiled.Events/Patches/Generic/PickupControlPatch.cs +++ b/Exiled.Events/Patches/Generic/PickupControlPatch.cs @@ -14,6 +14,8 @@ namespace Exiled.Events.Patches.Generic using API.Features.Pickups; using API.Features.Pools; + using Exiled.API.Features.Items; + using HarmonyLib; using InventorySystem; @@ -47,14 +49,14 @@ private static IEnumerable Transpiler( // pickup = Pickup.Get(pickupBase); new(OpCodes.Ldloc_0), new(OpCodes.Call, Method(typeof(Pickup), nameof(Pickup.Get), new[] { typeof(ItemPickupBase) })), + new(OpCodes.Dup), - /* // Item.Get(itemBase); new(OpCodes.Ldarg_0), new(OpCodes.Call, Method(typeof(Item), nameof(Item.Get), new[] { typeof(ItemBase) })), - // pickup.GetItemInfo(item); - new(OpCodes.Callvirt, Method(typeof(Pickup), nameof(Pickup.GetItemInfo))),*/ + // pickup.ReadItemInfo(item); + new(OpCodes.Callvirt, Method(typeof(Pickup), nameof(Pickup.ReadItemInfo))), // pickup.IsSpawned = spawn new(OpCodes.Ldarg_S, 4), From adc2726c8d89ea167e9c241429c30e929f8c7314 Mon Sep 17 00:00:00 2001 From: IRacle Date: Tue, 12 Sep 2023 19:04:15 +0300 Subject: [PATCH 034/207] items changes --- Exiled.API/Features/Player.cs | 66 +++++++++++------------------------ 1 file changed, 21 insertions(+), 45 deletions(-) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 1fb9218ca5..614ccd52a8 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -2194,17 +2194,27 @@ public int GetCategoryLimit(ItemCategory category) => /// Adds an item of the specified type with default durability(ammo/charge) and no mods to the player's inventory. /// /// The item to be added. + /// The given to the player. + public Item AddItem(ItemType itemType) + { + return Item.Get(Inventory.ServerAddItem(itemType)); + } + + /// + /// Adds an firearm of the specified type with default durability(ammo/charge) and no mods to the player's inventory. + /// + /// The firearm to be added. /// The attachments to be added to the item. /// The given to the player. - public Item AddItem(ItemType itemType, IEnumerable identifiers = null) + public Item AddItem(FirearmType firearmType, IEnumerable identifiers) { - Item item = Item.Get(Inventory.ServerAddItem(itemType)); + Item item = Item.Get(Inventory.ServerAddItem(firearmType.GetItemType())); if (item is Firearm firearm) { if (identifiers is not null) firearm.AddAttachment(identifiers); - else if (Preferences is not null && Preferences.TryGetValue(itemType.GetFirearmType(), out AttachmentIdentifier[] attachments)) + else if (Preferences is not null && Preferences.TryGetValue(firearmType, out AttachmentIdentifier[] attachments)) firearm.Base.ApplyAttachmentsCode(attachments.GetAttachmentsCode(), true); FirearmStatusFlags flags = FirearmStatusFlags.MagazineInserted; @@ -2237,13 +2247,13 @@ public IEnumerable AddItem(ItemType itemType, int amount) } /// - /// Adds the amount of items of the specified type with default durability(ammo/charge) and no mods to the player's inventory. + /// Adds the amount of firearms of the specified type with default durability(ammo/charge) and no mods to the player's inventory. /// - /// The item to be added. + /// The item to be added. /// The amount of items to be added. /// The attachments to be added to the item. /// An containing the items given. - public IEnumerable AddItem(ItemType itemType, int amount, IEnumerable identifiers) + public IEnumerable AddItem(FirearmType firearmType, int amount, IEnumerable identifiers) { List items = new(amount > 0 ? amount : 0); @@ -2252,7 +2262,7 @@ public IEnumerable AddItem(ItemType itemType, int amount, IEnumerable attachmentIdentifiers = identifiers.ToList(); for (int i = 0; i < amount; i++) - items.Add(AddItem(itemType, attachmentIdentifiers)); + items.Add(AddItem(firearmType, attachmentIdentifiers)); } return items; @@ -2280,11 +2290,11 @@ public IEnumerable AddItem(IEnumerable items) /// /// The of and of to be added. /// An containing the items given. - public IEnumerable AddItem(Dictionary> items) + public IEnumerable AddItem(Dictionary> items) { List returnedItems = new(items.Count); - foreach (KeyValuePair> item in items) + foreach (KeyValuePair> item in items) returnedItems.Add(AddItem(item.Key, item.Value)); return returnedItems; @@ -2298,9 +2308,6 @@ public void AddItem(Item item) { try { - if (item.Base is null) - item = Item.Create(item.Type); - AddItem(item.Base, item); } catch (Exception e) @@ -2318,9 +2325,6 @@ public void AddItem(Firearm item, IEnumerable identifiers) { try { - if (item.Base is null) - item = new Firearm(item.Type); - if (identifiers is not null) item.AddAttachment(identifiers); @@ -2378,6 +2382,7 @@ public Item AddItem(ItemBase itemBase, Item item = null) } // Dont care, didnt ask, ratio + // UPD 12.09.23 - maybe some changes will fix candies desync, and that legacy code can be deleted Timing.CallDelayed(0.02f, () => { if (item.Type is ItemType.SCP330 && item.Base != null) @@ -2397,35 +2402,6 @@ public Item AddItem(ItemBase itemBase, Item item = null) return null; } - /// - /// Adds the of items to the player's inventory. - /// - /// The item to be added. - /// The amount of items to be added. - public void AddItem(Item item, int amount) - { - if (amount > 0) - { - for (int i = 0; i < amount; i++) - AddItem(item); - } - } - - /// - /// Adds the of items to the player's inventory. - /// - /// The firearm to be added. - /// The amount of items to be added. - /// The attachments to be added to the item. - public void AddItem(Firearm firearm, int amount, IEnumerable identifiers) - { - if (amount > 0) - { - for (int i = 0; i < amount; i++) - AddItem(firearm, identifiers); - } - } - /// /// Adds the list of items to the player's inventory. /// @@ -2501,7 +2477,7 @@ public void ResetInventory(IEnumerable newItems) ClearInventory(); foreach (Item item in newItems) - AddItem(item.Base is null ? new Item(item.Type) : item); + AddItem(item); } /// From 30f2a7250d73c5a26e8de9a5020575dad60b60c2 Mon Sep 17 00:00:00 2001 From: IRacle Date: Tue, 12 Sep 2023 19:33:58 +0300 Subject: [PATCH 035/207] e --- Exiled.API/Features/Pickups/ExplosiveGrenadePickup.cs | 4 +--- Exiled.API/Features/Pickups/FlashGrenadePickup.cs | 4 +--- Exiled.API/Features/Pickups/GrenadePickup.cs | 9 +++------ Exiled.Events/Handlers/Internal/ExplodingGrenade.cs | 2 +- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/Exiled.API/Features/Pickups/ExplosiveGrenadePickup.cs b/Exiled.API/Features/Pickups/ExplosiveGrenadePickup.cs index 6123799870..c47d8f133c 100644 --- a/Exiled.API/Features/Pickups/ExplosiveGrenadePickup.cs +++ b/Exiled.API/Features/Pickups/ExplosiveGrenadePickup.cs @@ -77,7 +77,7 @@ internal override void ReadItemInfo(Item item) } /// - internal override Pickup GetPickupInfo(Projectile projectile) + internal override void WriteProjectileInfo(Projectile projectile) { if (projectile is ExplosionGrenadeProjectile explosionGrenadeProjectile) { @@ -88,8 +88,6 @@ internal override Pickup GetPickupInfo(Projectile projectile) explosionGrenadeProjectile.ConcussDuration = ConcussDuration; explosionGrenadeProjectile.FuseTime = FuseTime; } - - return projectile; } /// diff --git a/Exiled.API/Features/Pickups/FlashGrenadePickup.cs b/Exiled.API/Features/Pickups/FlashGrenadePickup.cs index 5c22733a4d..8e2a70a793 100644 --- a/Exiled.API/Features/Pickups/FlashGrenadePickup.cs +++ b/Exiled.API/Features/Pickups/FlashGrenadePickup.cs @@ -65,7 +65,7 @@ internal override void ReadItemInfo(Item item) } /// - internal override Pickup GetPickupInfo(Projectile projectile) + internal override void WriteProjectileInfo(Projectile projectile) { if (projectile is FlashbangProjectile flashbangProjectile) { @@ -74,8 +74,6 @@ internal override Pickup GetPickupInfo(Projectile projectile) flashbangProjectile.SurfaceDistanceIntensifier = SurfaceDistanceIntensifier; flashbangProjectile.FuseTime = FuseTime; } - - return projectile; } /// diff --git a/Exiled.API/Features/Pickups/GrenadePickup.cs b/Exiled.API/Features/Pickups/GrenadePickup.cs index f9b29a6ac7..fddde2c7d0 100644 --- a/Exiled.API/Features/Pickups/GrenadePickup.cs +++ b/Exiled.API/Features/Pickups/GrenadePickup.cs @@ -72,18 +72,15 @@ public void Explode(Footprint attacker) } /// - /// Returns the Projectile with the according property from the Pickup. + /// Helper method for saving data between projectiles and pickups. /// - /// Pickup-related data to give to the Projectile. - /// A Projectile containing the Pickup-related data. - internal virtual Pickup GetPickupInfo(Projectile projectile) + /// -related data to write to. + internal virtual void WriteProjectileInfo(Projectile projectile) { if (projectile is TimeGrenadeProjectile timeGrenadeProjectile) { timeGrenadeProjectile.FuseTime = FuseTime; } - - return projectile; } } } diff --git a/Exiled.Events/Handlers/Internal/ExplodingGrenade.cs b/Exiled.Events/Handlers/Internal/ExplodingGrenade.cs index 88a779a6f9..21f6f5635c 100644 --- a/Exiled.Events/Handlers/Internal/ExplodingGrenade.cs +++ b/Exiled.Events/Handlers/Internal/ExplodingGrenade.cs @@ -19,7 +19,7 @@ internal static class ExplodingGrenade public static void OnChangedIntoGrenade(ChangedIntoGrenadeEventArgs ev) { if (ev.Pickup is GrenadePickup grenadePickup) - grenadePickup.GetPickupInfo(ev.Projectile); + grenadePickup.WriteProjectileInfo(ev.Projectile); } } } From 6fca47abcd297607366583a6f5f8d8c9e6d76432 Mon Sep 17 00:00:00 2001 From: IRacle Date: Tue, 12 Sep 2023 19:39:22 +0300 Subject: [PATCH 036/207] lul --- Exiled.Events/Handlers/Internal/ExplodingGrenade.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Exiled.Events/Handlers/Internal/ExplodingGrenade.cs b/Exiled.Events/Handlers/Internal/ExplodingGrenade.cs index 21f6f5635c..02eb4e1ce5 100644 --- a/Exiled.Events/Handlers/Internal/ExplodingGrenade.cs +++ b/Exiled.Events/Handlers/Internal/ExplodingGrenade.cs @@ -18,8 +18,7 @@ internal static class ExplodingGrenade /// public static void OnChangedIntoGrenade(ChangedIntoGrenadeEventArgs ev) { - if (ev.Pickup is GrenadePickup grenadePickup) - grenadePickup.WriteProjectileInfo(ev.Projectile); + ev.Pickup.WriteProjectileInfo(ev.Projectile); } } } From 0b4262bdc7d90844eeaec970396ee958e6b625fd Mon Sep 17 00:00:00 2001 From: IRacle Date: Tue, 12 Sep 2023 19:44:58 +0300 Subject: [PATCH 037/207] fusetime can access differently --- .../EventArgs/Map/ChangedIntoGrenadeEventArgs.cs | 7 ------- .../Patches/Events/Map/ChangingIntoGrenade.cs | 16 ---------------- 2 files changed, 23 deletions(-) diff --git a/Exiled.Events/EventArgs/Map/ChangedIntoGrenadeEventArgs.cs b/Exiled.Events/EventArgs/Map/ChangedIntoGrenadeEventArgs.cs index 3ba4b9f116..ab9b83c521 100644 --- a/Exiled.Events/EventArgs/Map/ChangedIntoGrenadeEventArgs.cs +++ b/Exiled.Events/EventArgs/Map/ChangedIntoGrenadeEventArgs.cs @@ -31,7 +31,6 @@ public ChangedIntoGrenadeEventArgs(TimedGrenadePickup pickup, ThrownProjectile p Pickup = (GrenadePickup)API.Features.Pickups.Pickup.Get(pickup); Projectile = (Projectile)API.Features.Pickups.Pickup.Get(projectile); - FuseTime = (Projectile as TimeGrenadeProjectile)?.FuseTime ?? float.NaN; } /// @@ -43,11 +42,5 @@ public ChangedIntoGrenadeEventArgs(TimedGrenadePickup pickup, ThrownProjectile p /// Gets a value indicating the projectile that spawned. /// public Projectile Projectile { get; } - - /// - /// Gets or sets a value indicating how long the fuse of the changed grenade will be. - /// - // TODO: float - public double FuseTime { get; set; } } } diff --git a/Exiled.Events/Patches/Events/Map/ChangingIntoGrenade.cs b/Exiled.Events/Patches/Events/Map/ChangingIntoGrenade.cs index adf30cc981..8f5d30e3d5 100644 --- a/Exiled.Events/Patches/Events/Map/ChangingIntoGrenade.cs +++ b/Exiled.Events/Patches/Events/Map/ChangingIntoGrenade.cs @@ -43,12 +43,10 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Date: Tue, 12 Sep 2023 19:45:56 +0300 Subject: [PATCH 038/207] why --- Exiled.Events/EventArgs/Map/ChangedIntoGrenadeEventArgs.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/Exiled.Events/EventArgs/Map/ChangedIntoGrenadeEventArgs.cs b/Exiled.Events/EventArgs/Map/ChangedIntoGrenadeEventArgs.cs index ab9b83c521..525234f2a9 100644 --- a/Exiled.Events/EventArgs/Map/ChangedIntoGrenadeEventArgs.cs +++ b/Exiled.Events/EventArgs/Map/ChangedIntoGrenadeEventArgs.cs @@ -26,9 +26,6 @@ public class ChangedIntoGrenadeEventArgs : IExiledEvent /// The . public ChangedIntoGrenadeEventArgs(TimedGrenadePickup pickup, ThrownProjectile projectile) { - if (pickup is not TimedGrenadePickup) - Log.Error($"{nameof(ChangedIntoGrenadeEventArgs)}: Pickup is not TimedGrenadePickup!"); - Pickup = (GrenadePickup)API.Features.Pickups.Pickup.Get(pickup); Projectile = (Projectile)API.Features.Pickups.Pickup.Get(projectile); } From e3c3eaeee300c5ced116f1e5be45a9e4919c0a3b Mon Sep 17 00:00:00 2001 From: IRacle Date: Tue, 12 Sep 2023 20:00:22 +0300 Subject: [PATCH 039/207] yes --- Exiled.CustomItems/API/Features/CustomGrenade.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Exiled.CustomItems/API/Features/CustomGrenade.cs b/Exiled.CustomItems/API/Features/CustomGrenade.cs index d488d10c6e..5b0d958e7f 100644 --- a/Exiled.CustomItems/API/Features/CustomGrenade.cs +++ b/Exiled.CustomItems/API/Features/CustomGrenade.cs @@ -200,7 +200,8 @@ private void OnInternalChangedIntoGrenade(ChangedIntoGrenadeEventArgs ev) if (!Check(ev.Pickup)) return; - ev.FuseTime = FuseTime; + if (ev.Projectile is TimeGrenadeProjectile timedGrenade) + timedGrenade.FuseTime = FuseTime; OnChangedIntoGrenade(ev); From c74bca9217b1cb67c4ed6cce1dcb083dcb60ec8d Mon Sep 17 00:00:00 2001 From: IRacle Date: Sun, 17 Sep 2023 16:10:00 +0300 Subject: [PATCH 040/207] better method --- Exiled.API/Features/Player.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 614ccd52a8..209342f9c7 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -1849,7 +1849,12 @@ public bool RemoveItem(Item item, bool destroy = true) /// The serial to remove. /// Whether or not to destroy the item. /// A value indicating whether or not the was removed. - public bool RemoveItem(ushort serial, bool destroy = true) => RemoveItem(Item.Get(serial), destroy); + public bool RemoveItem(ushort serial, bool destroy = true) + { + if (Items.SingleOrDefault(item => item.Serial == serial) is not Item item) + return false; + return RemoveItem(item, destroy); + } /// /// Removes all 's that satisfy the condition from the player's inventory. From f991b2a5d281832d327b6e86e0346c0ce91e8dcf Mon Sep 17 00:00:00 2001 From: IRacle Date: Sun, 17 Sep 2023 15:43:56 +0300 Subject: [PATCH 041/207] maybe fix --- Exiled.API/Features/Player.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 209342f9c7..ccb69f3362 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -1832,7 +1832,12 @@ public bool RemoveItem(Item item, bool destroy = true) { item.ChangeOwner(this, Server.Host); - if (CurrentItem is not null && CurrentItem.Serial == item.Serial) + if (CurrentItem == item) + { + Inventory.CurInstance = null; + } + + if (item.Serial == Inventory.CurItem.SerialNumber) Inventory.NetworkCurItem = ItemIdentifier.None; Inventory.UserInventory.Items.Remove(item.Serial); From 1fc966a8c5b8c4abcb88ebda7008c2c5cced2657 Mon Sep 17 00:00:00 2001 From: IRacle Date: Sun, 17 Sep 2023 17:53:18 +0300 Subject: [PATCH 042/207] better method --- .../Features/Pickups/Projectiles/Projectile.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Exiled.API/Features/Pickups/Projectiles/Projectile.cs b/Exiled.API/Features/Pickups/Projectiles/Projectile.cs index 7edebfdb53..199f02fe38 100644 --- a/Exiled.API/Features/Pickups/Projectiles/Projectile.cs +++ b/Exiled.API/Features/Pickups/Projectiles/Projectile.cs @@ -130,6 +130,18 @@ public static Projectile Spawn(Projectile pickup, Vector3 position, Quaternion r /// public void Activate() => Base.ServerActivate(); + /// + /// Spawns a . + /// + /// Whether the should be in active state after spawn. + public void Spawn(bool shouldBeActive = true) + { + Spawn(); + + if (shouldBeActive) + Active(); + } + /// /// Returns the ProjectilePickup in a human readable format. /// From 9df5efcb6d79475fd359dc63325e34170cadf7c5 Mon Sep 17 00:00:00 2001 From: IRacle Date: Sun, 17 Sep 2023 17:54:36 +0300 Subject: [PATCH 043/207] bro --- Exiled.API/Features/Pickups/Projectiles/Projectile.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.API/Features/Pickups/Projectiles/Projectile.cs b/Exiled.API/Features/Pickups/Projectiles/Projectile.cs index 199f02fe38..ebe40ee5c5 100644 --- a/Exiled.API/Features/Pickups/Projectiles/Projectile.cs +++ b/Exiled.API/Features/Pickups/Projectiles/Projectile.cs @@ -139,7 +139,7 @@ public void Spawn(bool shouldBeActive = true) Spawn(); if (shouldBeActive) - Active(); + Activate(); } /// From ab4b0bdde305d34d08e7b7ebccbf96c92002069d Mon Sep 17 00:00:00 2001 From: IRacle Date: Sun, 17 Sep 2023 18:04:38 +0300 Subject: [PATCH 044/207] better logic --- Exiled.API/Features/Pickups/Pickup.cs | 41 +++++++++---------- .../Pickups/Projectiles/Projectile.cs | 35 +++++----------- 2 files changed, 31 insertions(+), 45 deletions(-) diff --git a/Exiled.API/Features/Pickups/Pickup.cs b/Exiled.API/Features/Pickups/Pickup.cs index 4bdd74fd59..071cb48d2b 100644 --- a/Exiled.API/Features/Pickups/Pickup.cs +++ b/Exiled.API/Features/Pickups/Pickup.cs @@ -491,26 +491,7 @@ public static IEnumerable Get(IEnumerable gameObjects) /// An optional previous owner of the item. /// The . See documentation of for more information on casting. /// - public static Pickup CreateAndSpawn(ItemType type, Vector3 position, Quaternion rotation, Player previousOwner = null) => Spawn(Create(type), position, rotation, previousOwner); - - /// - /// Spawns a . - /// - /// The too spawn. - /// The position to spawn the at. - /// The rotation to spawn the . - /// An optional previous owner of the item. - /// The Spawn. - /// - public static Pickup Spawn(Pickup pickup, Vector3 position, Quaternion rotation, Player previousOwner = null) - { - pickup.Position = position; - pickup.Rotation = rotation; - pickup.PreviousOwner = previousOwner; - pickup.Spawn(); - - return pickup; - } + public static Pickup CreateAndSpawn(ItemType type, Vector3 position, Quaternion rotation, Player previousOwner = null) => Create(type).Spawn(position, rotation, previousOwner); /// /// Returns the amount of time it will take for the provided to pick up this item, based on and active status effects. @@ -528,7 +509,7 @@ public float PickupTimeForPlayer(Player player) } /// - /// Spawns pickup on server. + /// Spawns pickup on a server. /// /// public void Spawn() @@ -546,6 +527,24 @@ public void Spawn() } } + /// + /// Spawns pickup on a server. + /// + /// The position to spawn the at. + /// The rotation to spawn the . + /// An optional previous owner of the item. + /// The spawned . + /// + public Pickup Spawn(Vector3 position, Quaternion rotation, Player previousOwner = null) + { + Position = position; + Rotation = rotation; + PreviousOwner = previousOwner; + Spawn(); + + return this; + } + /// /// Unspawns pickup on server. /// diff --git a/Exiled.API/Features/Pickups/Projectiles/Projectile.cs b/Exiled.API/Features/Pickups/Projectiles/Projectile.cs index ebe40ee5c5..be9480fa3b 100644 --- a/Exiled.API/Features/Pickups/Projectiles/Projectile.cs +++ b/Exiled.API/Features/Pickups/Projectiles/Projectile.cs @@ -101,29 +101,7 @@ internal Projectile(ItemType type) /// Whether the should be in active state after spawn. /// An optional previous owner of the item. /// The . See documentation of for more information on casting. - public static Projectile CreateAndSpawn(ProjectileType type, Vector3 position, Quaternion rotation, bool shouldBeActive = true, Player previousOwner = null) => Spawn(Create(type), position, rotation, shouldBeActive, previousOwner); - - /// - /// Spawns a . - /// - /// The too spawn. - /// The position to spawn the at. - /// The rotation to spawn the . - /// Whether the should be in active state after spawn. - /// An optional previous owner of the item. - /// The Spawn. - public static Projectile Spawn(Projectile pickup, Vector3 position, Quaternion rotation, bool shouldBeActive = true, Player previousOwner = null) - { - pickup.Position = position; - pickup.Rotation = rotation; - pickup.PreviousOwner = previousOwner; - pickup.Spawn(); - - if (shouldBeActive) - pickup.Activate(); - - return pickup; - } + public static Projectile CreateAndSpawn(ProjectileType type, Vector3 position, Quaternion rotation, bool shouldBeActive = true, Player previousOwner = null) => Create(type).Spawn(position, rotation, shouldBeActive, previousOwner); /// /// Activates the current . @@ -133,13 +111,22 @@ public static Projectile Spawn(Projectile pickup, Vector3 position, Quaternion r /// /// Spawns a . /// + /// The position to spawn the at. + /// The rotation to spawn the . /// Whether the should be in active state after spawn. - public void Spawn(bool shouldBeActive = true) + /// An optional previous owner of the item. + /// The spawned . + public Projectile Spawn(Vector3 position, Quaternion rotation, bool shouldBeActive = true, Player previousOwner = null) { + Position = position; + Rotation = rotation; + PreviousOwner = previousOwner; Spawn(); if (shouldBeActive) Activate(); + + return this; } /// From 0fc5824c7b06988d546225e1609ace97b27c2388 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sun, 24 Sep 2023 13:28:02 +0200 Subject: [PATCH 045/207] Fix Bug than Grenade do not make damage correctly --- .../Map/ExplodingGrenadeEventArgs.cs | 2 +- .../Patches/Generic/IndividualFriendlyFire.cs | 37 +++++++++++++++++-- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/Exiled.Events/EventArgs/Map/ExplodingGrenadeEventArgs.cs b/Exiled.Events/EventArgs/Map/ExplodingGrenadeEventArgs.cs index da80b0aa10..9c6b570de7 100644 --- a/Exiled.Events/EventArgs/Map/ExplodingGrenadeEventArgs.cs +++ b/Exiled.Events/EventArgs/Map/ExplodingGrenadeEventArgs.cs @@ -57,7 +57,7 @@ public ExplodingGrenadeEventArgs(Footprint thrower, Vector3 position, ExplosionG { case false: { - if (Server.FriendlyFire || IndividualFriendlyFire.CheckFriendlyFirePlayer(player.ReferenceHub, hub)) + if (Server.FriendlyFire || IndividualFriendlyFire.CheckFriendlyFirePlayer(thrower, hub)) { if (!TargetsToAffect.Contains(player)) TargetsToAffect.Add(player); diff --git a/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs b/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs index c00608f4b0..455fcd066b 100644 --- a/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs +++ b/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs @@ -24,6 +24,7 @@ namespace Exiled.Events.Patches.Generic using PlayerStatsSystem; using static HarmonyLib.AccessTools; + using static HarmonyLib.Code; /// /// Checks friendly fire rules. @@ -36,32 +37,60 @@ public static class IndividualFriendlyFire /// The person attacking. /// The person being attacked. /// True if the attacker can damage the victim. - public static bool CheckFriendlyFirePlayer(ReferenceHub attackerHub, ReferenceHub victimHub) => CheckFriendlyFirePlayerRules(attackerHub, victimHub, out _); + [Obsolete("Use CheckFriendlyFirePlayer(Footprint, ReferenceHub) instead of this", true)] + public static bool CheckFriendlyFirePlayer(ReferenceHub attackerHub, ReferenceHub victimHub) => CheckFriendlyFirePlayer(new Footprint(attackerHub), victimHub); /// /// Checks if there can be damage between two players, according to the FF rules. /// - /// The person attacking. + /// The person attacking. /// The person being attacked. /// True if the attacker can damage the victim. - public static bool CheckFriendlyFirePlayerHitbox(ReferenceHub attackerHub, ReferenceHub victimHub) => Server.FriendlyFire || CheckFriendlyFirePlayerRules(attackerHub, victimHub, out _); + public static bool CheckFriendlyFirePlayer(Footprint attackerFootprint, ReferenceHub victimHub) => CheckFriendlyFirePlayerRules(attackerFootprint, victimHub, out _); /// /// Checks if there can be damage between two players, according to the FF rules. /// /// The person attacking. /// The person being attacked. + /// True if the attacker can damage the victim. + [Obsolete("Use CheckFriendlyFirePlayerHitbox(Footprint, ReferenceHub) instead of this", true)] + public static bool CheckFriendlyFirePlayerHitbox(ReferenceHub attackerHub, ReferenceHub victimHub) => CheckFriendlyFirePlayerHitbox(new Footprint(attackerHub), victimHub); + + /// + /// Checks if there can be damage between two players, according to the FF rules. + /// + /// The person attacking. + /// The person being attacked. + /// True if the attacker can damage the victim. + public static bool CheckFriendlyFirePlayerHitbox(Footprint attackerFootprint, ReferenceHub victimHub) => Server.FriendlyFire || CheckFriendlyFirePlayerRules(attackerFootprint, victimHub, out _); + + /// + /// Checks if there can be damage between two players, according to the FF rules. + /// + /// The person attacking. + /// The person being attacked. /// FF multiplier. /// True if the attacker can damage the victim. /// Friendly fire multiplier is also provided back if needed. - public static bool CheckFriendlyFirePlayerRules(ReferenceHub attackerHub, ReferenceHub victimHub, out float ffMultiplier) + public static bool CheckFriendlyFirePlayerRules(Footprint attackerFootprint, ReferenceHub victimHub, out float ffMultiplier) { ffMultiplier = 1f; + ReferenceHub attackerHub = attackerFootprint.Hub; // Return false, no custom friendly fire allowed, default to NW logic for FF. No point in processing if FF is enabled across the board. if (Server.FriendlyFire) return false; + // always allow damage from Server.Host + 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.CheckFriendlyFire(attackerFootprint.Role, victimHub.roleManager.CurrentRole.RoleTypeId); + if (attackerHub is null || victimHub is null) { Log.Debug($"CheckFriendlyFirePlayerRules, Attacker hub null: {attackerHub is null}, Victim hub null: {victimHub is null}"); From 7d76eae6e4d6d90625989799f255a006b3ac4209 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sun, 24 Sep 2023 13:36:16 +0200 Subject: [PATCH 046/207] Remove BreakingChange --- .../Patches/Generic/IndividualFriendlyFire.cs | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs b/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs index 455fcd066b..21f99e079b 100644 --- a/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs +++ b/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs @@ -24,7 +24,6 @@ namespace Exiled.Events.Patches.Generic using PlayerStatsSystem; using static HarmonyLib.AccessTools; - using static HarmonyLib.Code; /// /// Checks friendly fire rules. @@ -37,7 +36,7 @@ public static class IndividualFriendlyFire /// The person attacking. /// The person being attacked. /// True if the attacker can damage the victim. - [Obsolete("Use CheckFriendlyFirePlayer(Footprint, ReferenceHub) instead of this", true)] + /// Use instead of this if the damage is not done instantly. public static bool CheckFriendlyFirePlayer(ReferenceHub attackerHub, ReferenceHub victimHub) => CheckFriendlyFirePlayer(new Footprint(attackerHub), victimHub); /// @@ -54,7 +53,7 @@ public static class IndividualFriendlyFire /// The person attacking. /// The person being attacked. /// True if the attacker can damage the victim. - [Obsolete("Use CheckFriendlyFirePlayerHitbox(Footprint, ReferenceHub) instead of this", true)] + /// Use instead of this if the damage is not done instantly. public static bool CheckFriendlyFirePlayerHitbox(ReferenceHub attackerHub, ReferenceHub victimHub) => CheckFriendlyFirePlayerHitbox(new Footprint(attackerHub), victimHub); /// @@ -65,6 +64,16 @@ public static class IndividualFriendlyFire /// True if the attacker can damage the victim. public static bool CheckFriendlyFirePlayerHitbox(Footprint attackerFootprint, ReferenceHub victimHub) => Server.FriendlyFire || CheckFriendlyFirePlayerRules(attackerFootprint, victimHub, out _); + /// + /// Checks if there can be damage between two players, according to the FF rules. + /// + /// The person attacking. + /// The person being attacked. + /// FF multiplier. + /// True if the attacker can damage the victim. + /// Friendly fire multiplier is also provided back if needed. + public static bool CheckFriendlyFirePlayerRules(ReferenceHub attackerHub, ReferenceHub victimHub, out float ffMultiplier) => CheckFriendlyFirePlayerRules(new Footprint(attackerHub), victimHub, out ffMultiplier); + /// /// Checks if there can be damage between two players, according to the FF rules. /// @@ -185,7 +194,7 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Date: Sun, 24 Sep 2023 13:38:03 +0200 Subject: [PATCH 047/207] useless change --- Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs b/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs index 21f99e079b..e1ca59e2f3 100644 --- a/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs +++ b/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs @@ -85,7 +85,6 @@ public static class IndividualFriendlyFire public static bool CheckFriendlyFirePlayerRules(Footprint attackerFootprint, ReferenceHub victimHub, out float ffMultiplier) { ffMultiplier = 1f; - ReferenceHub attackerHub = attackerFootprint.Hub; // Return false, no custom friendly fire allowed, default to NW logic for FF. No point in processing if FF is enabled across the board. if (Server.FriendlyFire) @@ -100,15 +99,15 @@ public static bool CheckFriendlyFirePlayerRules(Footprint attackerFootprint, Ref if (!attackerFootprint.SameLife(new(attackerFootprint.Hub))) return HitboxIdentity.CheckFriendlyFire(attackerFootprint.Role, victimHub.roleManager.CurrentRole.RoleTypeId); - if (attackerHub is null || victimHub is null) + if (attackerFootprint.Hub is null || victimHub is null) { - Log.Debug($"CheckFriendlyFirePlayerRules, Attacker hub null: {attackerHub is null}, Victim hub null: {victimHub is null}"); + Log.Debug($"CheckFriendlyFirePlayerRules, Attacker hub null: {attackerFootprint.Hub is null}, Victim hub null: {victimHub is null}"); return true; } try { - Player attacker = Player.Get(attackerHub); + Player attacker = Player.Get(attackerFootprint.Hub); Player victim = Player.Get(victimHub); if (attacker is null || victim is null) { From 6799584fd3405b5b50a7ec9b02581a9b9d7ef8ab Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sun, 24 Sep 2023 13:46:28 +0200 Subject: [PATCH 048/207] fix doc --- Exiled.Events/Patches/Events/Map/ExplodingFragGrenade.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.Events/Patches/Events/Map/ExplodingFragGrenade.cs b/Exiled.Events/Patches/Events/Map/ExplodingFragGrenade.cs index 1808ec2fb3..c4df40bc27 100644 --- a/Exiled.Events/Patches/Events/Map/ExplodingFragGrenade.cs +++ b/Exiled.Events/Patches/Events/Map/ExplodingFragGrenade.cs @@ -72,7 +72,7 @@ private static IEnumerable Transpiler(IEnumerable Date: Sun, 24 Sep 2023 14:49:08 +0200 Subject: [PATCH 049/207] Fix doc --- Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs b/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs index e1ca59e2f3..0465d86b57 100644 --- a/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs +++ b/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs @@ -53,7 +53,7 @@ public static class IndividualFriendlyFire /// The person attacking. /// The person being attacked. /// True if the attacker can damage the victim. - /// Use instead of this if the damage is not done instantly. + /// Use instead of this if the damage is not done instantly. public static bool CheckFriendlyFirePlayerHitbox(ReferenceHub attackerHub, ReferenceHub victimHub) => CheckFriendlyFirePlayerHitbox(new Footprint(attackerHub), victimHub); /// @@ -72,6 +72,7 @@ public static class IndividualFriendlyFire /// FF multiplier. /// True if the attacker can damage the victim. /// Friendly fire multiplier is also provided back if needed. + /// Use instead of this if the damage is not done instantly. public static bool CheckFriendlyFirePlayerRules(ReferenceHub attackerHub, ReferenceHub victimHub, out float ffMultiplier) => CheckFriendlyFirePlayerRules(new Footprint(attackerHub), victimHub, out ffMultiplier); /// From 9bcf023c3088b0c73c4d3d506f05f28b22ddeceb Mon Sep 17 00:00:00 2001 From: louis1706 Date: Tue, 26 Sep 2023 17:39:39 +0200 Subject: [PATCH 050/207] Grenade Fix --- Exiled.Events/Patches/Events/Map/ExplodingFlashGrenade.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Exiled.Events/Patches/Events/Map/ExplodingFlashGrenade.cs b/Exiled.Events/Patches/Events/Map/ExplodingFlashGrenade.cs index b5cbc6ab8a..f74a0950fd 100644 --- a/Exiled.Events/Patches/Events/Map/ExplodingFlashGrenade.cs +++ b/Exiled.Events/Patches/Events/Map/ExplodingFlashGrenade.cs @@ -15,6 +15,7 @@ namespace Exiled.Events.Patches.Events.Map using API.Features.Pools; using Exiled.Events.Attributes; using Exiled.Events.EventArgs.Map; + using Exiled.Events.Patches.Generic; using HarmonyLib; using InventorySystem.Items.ThrowableProjectiles; using UnityEngine; @@ -78,7 +79,7 @@ private static int ProcessEvent(FlashbangGrenade instance) if (!ExiledEvents.Instance.Config.CanFlashbangsAffectThrower && explodingGrenadeEvent.Player == player) continue; - if (HitboxIdentity.CheckFriendlyFire(explodingGrenadeEvent.Player.ReferenceHub, player.ReferenceHub)) + if (IndividualFriendlyFire.CheckFriendlyFirePlayer(instance.PreviousOwner, player.ReferenceHub)) { instance.ProcessPlayer(player.ReferenceHub); size++; From 4df362a2cb6e8663957640195dcd334f4cb6e3d0 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Tue, 26 Sep 2023 18:37:45 +0200 Subject: [PATCH 051/207] Oups Fix Config CanFlashbangsAffectThrower --- Exiled.Events/Patches/Events/Map/ExplodingFlashGrenade.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Exiled.Events/Patches/Events/Map/ExplodingFlashGrenade.cs b/Exiled.Events/Patches/Events/Map/ExplodingFlashGrenade.cs index f74a0950fd..c621901aa7 100644 --- a/Exiled.Events/Patches/Events/Map/ExplodingFlashGrenade.cs +++ b/Exiled.Events/Patches/Events/Map/ExplodingFlashGrenade.cs @@ -28,7 +28,6 @@ namespace Exiled.Events.Patches.Events.Map /// Patches . /// Adds the event. /// - [EventPatch(typeof(Handlers.Map), nameof(Handlers.Map.ExplodingGrenade))] [HarmonyPatch(typeof(FlashbangGrenade), nameof(FlashbangGrenade.ServerFuseEnd))] internal static class ExplodingFlashGrenade { From 7b824307c91f03b164716923c17b23a2d5238ed3 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Tue, 26 Sep 2023 18:38:45 +0200 Subject: [PATCH 052/207] better doc --- Exiled.Events/Patches/Events/Map/ExplodingFlashGrenade.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.Events/Patches/Events/Map/ExplodingFlashGrenade.cs b/Exiled.Events/Patches/Events/Map/ExplodingFlashGrenade.cs index c621901aa7..7320ef208b 100644 --- a/Exiled.Events/Patches/Events/Map/ExplodingFlashGrenade.cs +++ b/Exiled.Events/Patches/Events/Map/ExplodingFlashGrenade.cs @@ -26,7 +26,7 @@ namespace Exiled.Events.Patches.Events.Map /// /// Patches . - /// Adds the event. + /// Adds the event and . /// [HarmonyPatch(typeof(FlashbangGrenade), nameof(FlashbangGrenade.ServerFuseEnd))] internal static class ExplodingFlashGrenade From b869ac4244180467009d6cb09596b6aa094a68e5 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 29 Sep 2023 19:42:40 +0200 Subject: [PATCH 053/207] ExitStalking --- Exiled.Events/Handlers/Scp106.cs | 2 +- Exiled.Events/Patches/Events/Scp106/ExitStalking.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Exiled.Events/Handlers/Scp106.cs b/Exiled.Events/Handlers/Scp106.cs index b0bb9035de..0ed5972db9 100644 --- a/Exiled.Events/Handlers/Scp106.cs +++ b/Exiled.Events/Handlers/Scp106.cs @@ -35,7 +35,7 @@ public static class Scp106 /// /// Invoked before SCP-106 exit the stalk ability. /// - public static event CustomEventHandler ExitStalking; + public static Event ExitStalking { get; set; } = new(); /// /// Called before SCP-106 attacks player. diff --git a/Exiled.Events/Patches/Events/Scp106/ExitStalking.cs b/Exiled.Events/Patches/Events/Scp106/ExitStalking.cs index 5cc545db9b..9bd2c48dec 100644 --- a/Exiled.Events/Patches/Events/Scp106/ExitStalking.cs +++ b/Exiled.Events/Patches/Events/Scp106/ExitStalking.cs @@ -12,7 +12,7 @@ namespace Exiled.Events.Patches.Events.Scp106 using API.Features; using API.Features.Pools; - + using Exiled.Events.Attributes; using Exiled.Events.EventArgs.Scp106; using HarmonyLib; @@ -24,6 +24,7 @@ namespace Exiled.Events.Patches.Events.Scp106 /// Patches . /// To add the event. /// + [EventPatch(typeof(Handlers.Scp106), nameof(Handlers.Scp106.ExitStalking))] [HarmonyPatch(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.IsActive), MethodType.Setter)] public class ExitStalking { From 6ad479a5c3d02cfca16aa29a1cc88aa80fbe7cd5 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 29 Sep 2023 19:43:48 +0200 Subject: [PATCH 054/207] Fix Error --- Exiled.API/Features/Roles/Scp106Role.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.API/Features/Roles/Scp106Role.cs b/Exiled.API/Features/Roles/Scp106Role.cs index c6dd75beec..3881b94456 100644 --- a/Exiled.API/Features/Roles/Scp106Role.cs +++ b/Exiled.API/Features/Roles/Scp106Role.cs @@ -305,7 +305,7 @@ public void CapturePlayer(Player player) // Convert to bool. return; Attack.SendCooldown(Attack._hitCooldown); - Attack.Vigor.VigorAmount += VigorCaptureReward; + Vigor += VigorCaptureReward; Attack.ReduceSinkholeCooldown(); Hitmarker.SendHitmarker(Attack.Owner, 1f); From e36721dd028ff330c6e827c6bf7295a2c34abd64 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 29 Sep 2023 19:45:54 +0200 Subject: [PATCH 055/207] Fix event --- Exiled.Events/Patches/Generic/Scp106API/VigorRegeneration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.Events/Patches/Generic/Scp106API/VigorRegeneration.cs b/Exiled.Events/Patches/Generic/Scp106API/VigorRegeneration.cs index 09ab86cd8f..3bbe601d94 100644 --- a/Exiled.Events/Patches/Generic/Scp106API/VigorRegeneration.cs +++ b/Exiled.Events/Patches/Generic/Scp106API/VigorRegeneration.cs @@ -39,7 +39,7 @@ private static IEnumerable Transpiler(IEnumerable() // "base.Vigor.VigorAmount += scp106Role.VigorRegeneration * Time.deltaTime;" int offset = -4; - int index = newInstructions.FindIndex(instruction => instruction.operand == (object)PropertySetter(typeof(Scp106Vigor), nameof(Scp106Vigor.VigorAmount))) + offset; + int index = newInstructions.FindIndex(instruction => instruction.operand == (object)PropertySetter(typeof(Scp106VigorAbilityBase), nameof(Scp106VigorAbilityBase.VigorAmount))) + offset; newInstructions.RemoveAt(index); newInstructions.InsertRange( From 522b587116b850ef741aeeed2bd9f403d7051fd1 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 29 Sep 2023 22:54:58 +0200 Subject: [PATCH 056/207] NetherCode --- .../Features/DynamicPatch/Property{T}.cs | 94 +++++++++++++++++++ Exiled.API/Features/Roles/Scp106Role.cs | 21 ++--- Exiled.API/Interfaces/IProperty.cs | 16 ++++ .../Scp106API/CooldownReductionReward.cs | 2 + .../Patches/Generic/Scp106API/CustomAttack.cs | 5 + .../Scp106API/HunterAtlastCostPerMetter.cs | 2 + .../Scp106API/SinkholeAbilityCooldown.cs | 2 + .../Generic/Scp106API/StalkVigorUse.cs | 3 + .../Generic/Scp106API/VigorRegeneration.cs | 2 + 9 files changed, 136 insertions(+), 11 deletions(-) create mode 100644 Exiled.API/Features/DynamicPatch/Property{T}.cs create mode 100644 Exiled.API/Interfaces/IProperty.cs diff --git a/Exiled.API/Features/DynamicPatch/Property{T}.cs b/Exiled.API/Features/DynamicPatch/Property{T}.cs new file mode 100644 index 0000000000..0d451fd1d5 --- /dev/null +++ b/Exiled.API/Features/DynamicPatch/Property{T}.cs @@ -0,0 +1,94 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.API.Features.DynamicPatch +{ + using System; +#pragma warning disable SA1611 // Element parameters should be documented + + using System.Collections.Generic; + using System.Reflection; + + using Exiled.API.Interfaces; + + /// + /// An implementation of the interface that encapsulates a property with arguments. + /// + /// The type of the property value. + public class Property : IProperty + { + private static bool? useDynamicPatching; + + private static MethodInfo patchMethod; + + private static object patcherInstance; + private bool patched; + private T propertyValue; + + /// + /// Initializes a new instance of the class. + /// + /// + public Property(T value) => propertyValue = value; + + /// + /// Gets or sets the property value. + /// + public T Value + { + get => propertyValue; + set + { + if (!EqualityComparer.Default.Equals(propertyValue, value)) + { + if (useDynamicPatching is null) + AccessPatcherUsingReflection(); + + if (useDynamicPatching is true && !patched) + { + patchMethod.Invoke(patcherInstance, new object[] { this }); + patched = true; + } + + propertyValue = value; + } + } + } + + /// + /// Implicitly converts the Property to its value type. + /// + /// The Property to convert. + public static implicit operator T(Property property) => property.Value; + + private static void AccessPatcherUsingReflection() + { + if (patchMethod == null || patcherInstance == null) + { + foreach (Type type in Assembly.Load("Exiled.Events").GetTypes()) + { + if (type.Name == "Patcher") + { + // Access the Patcher instance property using reflection + patcherInstance = type.GetField("Instance", BindingFlags.Public | BindingFlags.Static)?.GetValue(null); + + if (patcherInstance != null) + { + // Call the Patch method on the patcherInstance + patchMethod = type.GetMethod("Patch"); + + // Instance.Config.UseDynamicPatching + // Call the config + useDynamicPatching = (bool?)type.GetProperty("Config", BindingFlags.Public | BindingFlags.Static)?.GetValue(null)? + .GetType()?.GetProperty("UseDynamicPatching", BindingFlags.Public | BindingFlags.Static)?.GetValue(null); + } + } + } + } + } + } +} diff --git a/Exiled.API/Features/Roles/Scp106Role.cs b/Exiled.API/Features/Roles/Scp106Role.cs index 3881b94456..23bc026c2c 100644 --- a/Exiled.API/Features/Roles/Scp106Role.cs +++ b/Exiled.API/Features/Roles/Scp106Role.cs @@ -10,13 +10,12 @@ namespace Exiled.API.Features.Roles using System.Collections.Generic; using Exiled.API.Enums; + using Exiled.API.Features.DynamicPatch; using PlayerRoles; using PlayerRoles.PlayableScps.HumeShield; - using PlayerRoles.PlayableScps.Scp049; using PlayerRoles.PlayableScps.Scp106; using PlayerRoles.PlayableScps.Subroutines; using PlayerStatsSystem; - using UnityEngine; using Scp106GameRole = PlayerRoles.PlayableScps.Scp106.Scp106Role; @@ -185,47 +184,47 @@ public bool SinkholeState /// /// Gets or sets how mush cost the Ability Stalk will cost per tick when being stationary. /// - public float VigorStalkCostStationary { get; set; } = Scp106StalkAbility.VigorStalkCostStationary; + public Property VigorStalkCostStationary { get; set; } = new(Scp106StalkAbility.VigorStalkCostStationary); /// /// Gets or sets how mush cost the Ability Stalk will cost per tick when moving. /// - public float VigorStalkCostMoving { get; set; } = Scp106StalkAbility.VigorStalkCostMoving; + public Property VigorStalkCostMoving { get; set; } = new(Scp106StalkAbility.VigorStalkCostMoving); /// /// Gets or sets how mush vigor will be regenerate while moving per seconds. /// - public float VigorRegeneration { get; set; } = Scp106StalkAbility.VigorRegeneration; + public Property VigorRegeneration { get; set; } = new(Scp106StalkAbility.VigorRegeneration); /// /// Gets or sets how mush damage Scp106 will dealt when attacking a player. /// - public float AttackDamage { get; set; } = Scp106Attack.AttackDamage; + public Property AttackDamage { get; set; } = new(Scp106Attack.AttackDamage); /// /// Gets or sets the duration of Corroding effect. /// - public float CorrodingTime { get; set; } = Scp106Attack.CorrodingTime; + public Property CorrodingTime { get; set; } = new(Scp106Attack.CorrodingTime); /// /// Gets or sets how mush vigor Scp106 will gain when being reward for having caught a player. /// - public float VigorCaptureReward { get; set; } = Scp106Attack.VigorCaptureReward; + public Property VigorCaptureReward { get; set; } = new(Scp106Attack.VigorCaptureReward); /// /// Gets or sets how mush reduction cooldown Scp106 will gain when being reward for having caught a player. /// - public float CooldownReductionReward { get; set; } = Scp106Attack.CooldownReductionReward; + public Property CooldownReductionReward { get; set; } = new(Scp106Attack.CooldownReductionReward); /// /// Gets or sets the cooldown duration of it's Sinkhole ability's. /// - public float SinkholeCooldownDuration { get; set; } = Scp106SinkholeController.CooldownDuration; + public Property SinkholeCooldownDuration { get; set; } = new(Scp106SinkholeController.CooldownDuration); /// /// Gets or sets how mush vigor it's ability Hunter Atlas will cost per meter. /// - public float HuntersAtlasCostPerMeter { get; set; } = Scp106HuntersAtlasAbility.CostPerMeter; + public Property HuntersAtlasCostPerMeter { get; set; } = new(Scp106HuntersAtlasAbility.CostPerMeter); /// /// Gets or sets the amount of time in between player captures. diff --git a/Exiled.API/Interfaces/IProperty.cs b/Exiled.API/Interfaces/IProperty.cs new file mode 100644 index 0000000000..390cccb13c --- /dev/null +++ b/Exiled.API/Interfaces/IProperty.cs @@ -0,0 +1,16 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.API.Interfaces +{ + /// + /// The base Exiled Event Args interface to be used by all other event arg interfaces/classes. + /// + public interface IProperty + { + } +} \ No newline at end of file diff --git a/Exiled.Events/Patches/Generic/Scp106API/CooldownReductionReward.cs b/Exiled.Events/Patches/Generic/Scp106API/CooldownReductionReward.cs index dd0e539450..02f7e7c3c7 100644 --- a/Exiled.Events/Patches/Generic/Scp106API/CooldownReductionReward.cs +++ b/Exiled.Events/Patches/Generic/Scp106API/CooldownReductionReward.cs @@ -13,6 +13,7 @@ namespace Exiled.Events.Patches.Generic.Scp106API using API.Features.Pools; using Exiled.API.Features; + using Exiled.API.Features.DynamicPatch; using HarmonyLib; using PlayerRoles.PlayableScps.Scp106; using PlayerRoles.PlayableScps.Subroutines; @@ -56,6 +57,7 @@ private static IEnumerable Transpiler(IEnumerable), "op_implicit")), }); for (int z = 0; z < newInstructions.Count; z++) diff --git a/Exiled.Events/Patches/Generic/Scp106API/CustomAttack.cs b/Exiled.Events/Patches/Generic/Scp106API/CustomAttack.cs index 54fccd372b..d5d7a5bcd8 100644 --- a/Exiled.Events/Patches/Generic/Scp106API/CustomAttack.cs +++ b/Exiled.Events/Patches/Generic/Scp106API/CustomAttack.cs @@ -12,6 +12,7 @@ namespace Exiled.Events.Patches.Generic.Scp106API using API.Features.Pools; using Exiled.API.Features; + using Exiled.API.Features.DynamicPatch; using HarmonyLib; using PlayerRoles.PlayableScps.Scp106; using PlayerRoles.PlayableScps.Subroutines; @@ -55,6 +56,7 @@ private static IEnumerable Transpiler(IEnumerable), "op_implicit")), }); // replace "base.Vigor.VigorAmount += 0.3f;" @@ -78,6 +80,7 @@ private static IEnumerable Transpiler(IEnumerable), "op_implicit")), }); // replace "base.Vigor.VigorAmount += 0.3f;" @@ -101,6 +104,7 @@ private static IEnumerable Transpiler(IEnumerable), "op_implicit")), }); // replace "playerEffectsController.EnableEffect(20f, false);" @@ -124,6 +128,7 @@ private static IEnumerable Transpiler(IEnumerable), "op_implicit")), }); for (int z = 0; z < newInstructions.Count; z++) yield return newInstructions[z]; diff --git a/Exiled.Events/Patches/Generic/Scp106API/HunterAtlastCostPerMetter.cs b/Exiled.Events/Patches/Generic/Scp106API/HunterAtlastCostPerMetter.cs index 0fdc57feb8..ad6e5e999c 100644 --- a/Exiled.Events/Patches/Generic/Scp106API/HunterAtlastCostPerMetter.cs +++ b/Exiled.Events/Patches/Generic/Scp106API/HunterAtlastCostPerMetter.cs @@ -13,6 +13,7 @@ namespace Exiled.Events.Patches.Generic.Scp106API using API.Features.Pools; using Exiled.API.Features; + using Exiled.API.Features.DynamicPatch; using HarmonyLib; using PlayerRoles.PlayableScps.Scp106; using PlayerRoles.PlayableScps.Subroutines; @@ -56,6 +57,7 @@ private static IEnumerable Transpiler(IEnumerable), "op_implicit")), }); for (int z = 0; z < newInstructions.Count; z++) diff --git a/Exiled.Events/Patches/Generic/Scp106API/SinkholeAbilityCooldown.cs b/Exiled.Events/Patches/Generic/Scp106API/SinkholeAbilityCooldown.cs index 120441459f..aa3f526d69 100644 --- a/Exiled.Events/Patches/Generic/Scp106API/SinkholeAbilityCooldown.cs +++ b/Exiled.Events/Patches/Generic/Scp106API/SinkholeAbilityCooldown.cs @@ -13,6 +13,7 @@ namespace Exiled.Events.Patches.Generic.Scp106API using API.Features.Pools; using Exiled.API.Features; + using Exiled.API.Features.DynamicPatch; using HarmonyLib; using PlayerRoles.PlayableScps.Scp106; using PlayerRoles.PlayableScps.Subroutines; @@ -56,6 +57,7 @@ private static IEnumerable Transpiler(IEnumerable), "op_implicit")), }); for (int z = 0; z < newInstructions.Count; z++) diff --git a/Exiled.Events/Patches/Generic/Scp106API/StalkVigorUse.cs b/Exiled.Events/Patches/Generic/Scp106API/StalkVigorUse.cs index 8cdd360b27..1f677ea541 100644 --- a/Exiled.Events/Patches/Generic/Scp106API/StalkVigorUse.cs +++ b/Exiled.Events/Patches/Generic/Scp106API/StalkVigorUse.cs @@ -12,6 +12,7 @@ namespace Exiled.Events.Patches.Generic.Scp106API using API.Features.Pools; using Exiled.API.Features; + using Exiled.API.Features.DynamicPatch; using HarmonyLib; using PlayerRoles.PlayableScps.Scp106; using PlayerRoles.PlayableScps.Subroutines; @@ -55,6 +56,7 @@ private static IEnumerable Transpiler(IEnumerable), "op_implicit")), }); offset = 0; @@ -74,6 +76,7 @@ private static IEnumerable Transpiler(IEnumerable), "op_implicit")), }); for (int z = 0; z < newInstructions.Count; z++) yield return newInstructions[z]; diff --git a/Exiled.Events/Patches/Generic/Scp106API/VigorRegeneration.cs b/Exiled.Events/Patches/Generic/Scp106API/VigorRegeneration.cs index 3bbe601d94..365e313315 100644 --- a/Exiled.Events/Patches/Generic/Scp106API/VigorRegeneration.cs +++ b/Exiled.Events/Patches/Generic/Scp106API/VigorRegeneration.cs @@ -12,6 +12,7 @@ namespace Exiled.Events.Patches.Generic.Scp106API using API.Features.Pools; using Exiled.API.Features; + using Exiled.API.Features.DynamicPatch; using HarmonyLib; using PlayerRoles.PlayableScps.Scp106; using PlayerRoles.PlayableScps.Subroutines; @@ -55,6 +56,7 @@ private static IEnumerable Transpiler(IEnumerable), "op_implicit")), }); for (int z = 0; z < newInstructions.Count; z++) From fcfad21ebd9f92915541edbec2005a9b35a16cd8 Mon Sep 17 00:00:00 2001 From: IRacle Date: Sat, 7 Oct 2023 21:41:03 +0300 Subject: [PATCH 057/207] fix cringe logic --- Exiled.API/Features/Items/Firearm.cs | 2 +- Exiled.API/Features/Items/Item.cs | 2 +- Exiled.API/Features/Items/Scp330.cs | 2 +- Exiled.API/Features/Items/Usable.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Exiled.API/Features/Items/Firearm.cs b/Exiled.API/Features/Items/Firearm.cs index b11488cbbc..34e7e2ed39 100644 --- a/Exiled.API/Features/Items/Firearm.cs +++ b/Exiled.API/Features/Items/Firearm.cs @@ -570,7 +570,7 @@ public override Pickup CreatePickup(Vector3 position, Quaternion rotation = defa { ItemPickupBase ipb = Object.Instantiate(Base.PickupDropModel, position, rotation); - ipb.Info = new(Type, Weight, ItemSerialGenerator.GenerateNext()); + ipb.Info = new(Type, Weight, Serial); ipb.gameObject.transform.localScale = Scale; FirearmPickup pickup = Pickup.Get(ipb).As(); diff --git a/Exiled.API/Features/Items/Item.cs b/Exiled.API/Features/Items/Item.cs index 4ef1e05248..465725c529 100644 --- a/Exiled.API/Features/Items/Item.cs +++ b/Exiled.API/Features/Items/Item.cs @@ -290,7 +290,7 @@ public virtual Pickup CreatePickup(Vector3 position, Quaternion rotation = defau { ItemPickupBase ipb = Object.Instantiate(Base.PickupDropModel, position, rotation); - ipb.Info = new(Type, Weight, ItemSerialGenerator.GenerateNext()); + ipb.Info = new(Type, Weight, Serial); ipb.gameObject.transform.localScale = Scale; Base.OnRemoved(ipb); diff --git a/Exiled.API/Features/Items/Scp330.cs b/Exiled.API/Features/Items/Scp330.cs index 69259cce95..3f4734d53b 100644 --- a/Exiled.API/Features/Items/Scp330.cs +++ b/Exiled.API/Features/Items/Scp330.cs @@ -237,7 +237,7 @@ public override Pickup CreatePickup(Vector3 position, Quaternion rotation = defa { InventorySystem.Items.Usables.Scp330.Scp330Pickup ipb = (InventorySystem.Items.Usables.Scp330.Scp330Pickup)Object.Instantiate(Base.PickupDropModel, position, rotation); - ipb.Info = new(Type, Weight, ItemSerialGenerator.GenerateNext()); + ipb.Info = new(Type, Weight, Serial); ipb.gameObject.transform.localScale = Scale; Base.OnRemoved(ipb); diff --git a/Exiled.API/Features/Items/Usable.cs b/Exiled.API/Features/Items/Usable.cs index 28c6eda819..963d0077d9 100644 --- a/Exiled.API/Features/Items/Usable.cs +++ b/Exiled.API/Features/Items/Usable.cs @@ -112,7 +112,7 @@ public override Pickup CreatePickup(Vector3 position, Quaternion rotation = defa { ItemPickupBase ipb = Object.Instantiate(Base.PickupDropModel, position, rotation); - ipb.Info = new(Type, Weight, ItemSerialGenerator.GenerateNext()); + ipb.Info = new(Type, Weight, Serial); ipb.gameObject.transform.localScale = Scale; Base.OnRemoved(ipb); From b3a5dee85cd24c1976d718bc2a3af77dcb177de0 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sun, 8 Oct 2023 16:09:53 +0200 Subject: [PATCH 058/207] EnableEffect should have intensity argument --- Exiled.API/Features/Player.cs | 51 +++++++++++++++++-- .../Events/Scp330/InteractingScp330.cs | 5 +- 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index e095fd45db..65d90f8f1e 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -2691,7 +2691,18 @@ public void DisableEffects(IEnumerable effects) /// If the effect is already active, setting to will add this duration onto the effect. /// A bool indicating whether or not the effect was valid and successfully enabled. public bool EnableEffect(float duration = 0f, bool addDurationIfActive = false) - where T : StatusEffectBase => ReferenceHub.playerEffectsController.EnableEffect(duration, addDurationIfActive); + where T : StatusEffectBase => EnableEffect(duration, 1, addDurationIfActive); + + /// + /// Enables a status effect on the player. + /// + /// The to enable. + /// The intensity of the effect will be active for. + /// The amount of time the effect will be active for. + /// If the effect is already active, setting to will add this duration onto the effect. + /// A bool indicating whether or not the effect was valid and successfully enabled. + public bool EnableEffect(byte intensity = 1, float duration = 0f, bool addDurationIfActive = false) + where T : StatusEffectBase => ReferenceHub.playerEffectsController.ChangeState(intensity, duration, addDurationIfActive); /// /// Enables a status effect on the player. @@ -2701,11 +2712,22 @@ public bool EnableEffect(float duration = 0f, bool addDurationIfActive = fals /// If the effect is already active, setting to will add this duration onto the effect. /// A bool indicating whether or not the effect was valid and successfully enabled. public bool EnableEffect(StatusEffectBase statusEffect, float duration = 0f, bool addDurationIfActive = false) + => EnableEffect(statusEffect, 1, duration, addDurationIfActive); + + /// + /// Enables a status effect on the player. + /// + /// The name of the to enable. + /// The intensity of the effect will be active for. + /// The amount of time the effect will be active for. + /// If the effect is already active, setting to will add this duration onto the effect. + /// A bool indicating whether or not the effect was valid and successfully enabled. + public bool EnableEffect(StatusEffectBase statusEffect, byte intensity = 1, float duration = 0f, bool addDurationIfActive = false) { if (statusEffect is null) return false; - StatusEffectBase effect = EnableEffect(statusEffect.GetType().Name, duration, addDurationIfActive); + StatusEffectBase effect = EnableEffect(statusEffect.GetType().Name, intensity, duration, addDurationIfActive); return effect is not null && effect.IsEnabled; } @@ -2717,7 +2739,18 @@ public bool EnableEffect(StatusEffectBase statusEffect, float duration = 0f, boo /// If the effect is already active, setting to will add this duration onto the effect. /// The instance of the activated effect. public StatusEffectBase EnableEffect(string effectName, float duration = 0f, bool addDurationIfActive = false) - => ReferenceHub.playerEffectsController.ChangeState(effectName, 1, duration, addDurationIfActive); + => EnableEffect(effectName, 1, duration, addDurationIfActive); + + /// + /// Enables a status effect on the player. + /// + /// The name of the to enable. + /// The intensity of the effect will be active for. + /// The amount of time the effect will be active for. + /// If the effect is already active, setting to will add this duration onto the effect. + /// The instance of the activated effect. + public StatusEffectBase EnableEffect(string effectName, byte intensity = 1, float duration = 0f, bool addDurationIfActive = false) + => ReferenceHub.playerEffectsController.ChangeState(effectName, intensity, duration, addDurationIfActive); /// /// Enables a status effect on the player. @@ -2726,6 +2759,16 @@ public StatusEffectBase EnableEffect(string effectName, float duration = 0f, boo /// The amount of time the effect will be active for. /// If the effect is already active, setting to will add this duration onto the effect. public void EnableEffect(EffectType type, float duration = 0f, bool addDurationIfActive = false) + => EnableEffect(type, 1, duration, addDurationIfActive); + + /// + /// Enables a status effect on the player. + /// + /// The to enable. + /// The intensity of the effect will be active for. + /// The amount of time the effect will be active for. + /// If the effect is already active, setting to will add this duration onto the effect. + public void EnableEffect(EffectType type, byte intensity = 1, float duration = 0f, bool addDurationIfActive = false) { switch (type) { @@ -2740,7 +2783,7 @@ public void EnableEffect(EffectType type, float duration = 0f, bool addDurationI break; default: if (TryGetEffect(type, out StatusEffectBase statusEffect)) - EnableEffect(statusEffect, duration, addDurationIfActive); + EnableEffect(statusEffect, intensity, duration, addDurationIfActive); break; } diff --git a/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs b/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs index 92025db533..017e7b1eb8 100644 --- a/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs +++ b/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs @@ -130,13 +130,14 @@ private static IEnumerable Transpiler(IEnumerable Date: Sun, 8 Oct 2023 16:32:18 +0200 Subject: [PATCH 059/207] Preventing Error + add a new ctor for Effect class --- Exiled.API/Features/Effect.cs | 19 ++++++++++++-- Exiled.API/Features/Player.cs | 49 ++++++++++++++++++++++++++--------- 2 files changed, 54 insertions(+), 14 deletions(-) diff --git a/Exiled.API/Features/Effect.cs b/Exiled.API/Features/Effect.cs index 1f1de3ad55..8123f94e40 100644 --- a/Exiled.API/Features/Effect.cs +++ b/Exiled.API/Features/Effect.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- // // Copyright (c) Exiled Team. All rights reserved. // Licensed under the CC BY-SA 3.0 license. @@ -9,10 +9,13 @@ namespace Exiled.API.Features { using System.ComponentModel; + using CustomPlayerEffects; + using Exiled.API.Enums; + using Exiled.API.Extensions; /// - /// Useful class to save hint configs in a cleaner way. + /// Useful class to save effect configs in a cleaner way. /// public class Effect { @@ -23,6 +26,18 @@ public Effect() { } + /// + /// Initializes a new instance of the class. + /// + /// Get all the information of the effect>. + public Effect(StatusEffectBase statusEffectBase) + { + Type = statusEffectBase.GetEffectType(); + Duration = statusEffectBase.Duration; + Intensity = statusEffectBase.Intensity; + IsEnabled = statusEffectBase.IsEnabled; + } + /// /// Initializes a new instance of the class. /// diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 65d90f8f1e..0e59c94628 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -2691,7 +2691,7 @@ public void DisableEffects(IEnumerable effects) /// If the effect is already active, setting to will add this duration onto the effect. /// A bool indicating whether or not the effect was valid and successfully enabled. public bool EnableEffect(float duration = 0f, bool addDurationIfActive = false) - where T : StatusEffectBase => EnableEffect(duration, 1, addDurationIfActive); + where T : StatusEffectBase => EnableEffect(1, duration, addDurationIfActive); /// /// Enables a status effect on the player. @@ -2701,7 +2701,7 @@ public bool EnableEffect(float duration = 0f, bool addDurationIfActive = fals /// The amount of time the effect will be active for. /// If the effect is already active, setting to will add this duration onto the effect. /// A bool indicating whether or not the effect was valid and successfully enabled. - public bool EnableEffect(byte intensity = 1, float duration = 0f, bool addDurationIfActive = false) + public bool EnableEffect(byte intensity, float duration = 0f, bool addDurationIfActive = false) where T : StatusEffectBase => ReferenceHub.playerEffectsController.ChangeState(intensity, duration, addDurationIfActive); /// @@ -2722,7 +2722,7 @@ public bool EnableEffect(StatusEffectBase statusEffect, float duration = 0f, boo /// The amount of time the effect will be active for. /// If the effect is already active, setting to will add this duration onto the effect. /// A bool indicating whether or not the effect was valid and successfully enabled. - public bool EnableEffect(StatusEffectBase statusEffect, byte intensity = 1, float duration = 0f, bool addDurationIfActive = false) + public bool EnableEffect(StatusEffectBase statusEffect, byte intensity, float duration = 0f, bool addDurationIfActive = false) { if (statusEffect is null) return false; @@ -2749,7 +2749,7 @@ public StatusEffectBase EnableEffect(string effectName, float duration = 0f, boo /// The amount of time the effect will be active for. /// If the effect is already active, setting to will add this duration onto the effect. /// The instance of the activated effect. - public StatusEffectBase EnableEffect(string effectName, byte intensity = 1, float duration = 0f, bool addDurationIfActive = false) + public StatusEffectBase EnableEffect(string effectName, byte intensity, float duration = 0f, bool addDurationIfActive = false) => ReferenceHub.playerEffectsController.ChangeState(effectName, intensity, duration, addDurationIfActive); /// @@ -2768,18 +2768,18 @@ public void EnableEffect(EffectType type, float duration = 0f, bool addDurationI /// The intensity of the effect will be active for. /// The amount of time the effect will be active for. /// If the effect is already active, setting to will add this duration onto the effect. - public void EnableEffect(EffectType type, byte intensity = 1, float duration = 0f, bool addDurationIfActive = false) + public void EnableEffect(EffectType type, byte intensity, float duration = 0f, bool addDurationIfActive = false) { switch (type) { case EffectType.AmnesiaItems: - EnableEffect(duration, addDurationIfActive); + EnableEffect(intensity, duration, addDurationIfActive); break; case EffectType.AmnesiaVision: - EnableEffect(duration, addDurationIfActive); + EnableEffect(intensity, duration, addDurationIfActive); break; case EffectType.SoundtrackMute: - EnableEffect(duration, addDurationIfActive); + EnableEffect(intensity, duration, addDurationIfActive); break; default: if (TryGetEffect(type, out StatusEffectBase statusEffect)) @@ -2793,7 +2793,14 @@ public void EnableEffect(EffectType type, byte intensity = 1, float duration = 0 /// Enables a status effect on the player. /// /// The to enable. - public void EnableEffect(Effect effect) + [Obsolete("Use SyncEffect(Effect) instead of this")] + public void EnableEffect(Effect effect) => SyncEffect(effect); + + /// + /// Sync the status effect on the player. + /// + /// The to sync. + public void SyncEffect(Effect effect) { if (effect.IsEnabled) { @@ -2812,12 +2819,23 @@ public void EnableEffect(Effect effect) /// If the effect is already active, setting to will add this duration onto the effect. /// A that was given to the player. public EffectType ApplyRandomEffect(EffectCategory category = EffectCategory.None, float duration = 0f, bool addDurationIfActive = false) + => ApplyRandomEffect(category, 1, duration, addDurationIfActive); + + /// + /// Enables a random on the player. + /// + /// An optional category to filter the applied effect. Set to for any effect. + /// The intensity of the effect will be active for. + /// The amount of time the effect will be active for. + /// If the effect is already active, setting to will add this duration onto the effect. + /// A that was given to the player. + public EffectType ApplyRandomEffect(EffectCategory category, byte intensity, float duration = 0f, bool addDurationIfActive = false) { Array effectTypes = Enum.GetValues(typeof(EffectType)); IEnumerable validEffects = effectTypes.ToArray().Where(effect => effect.GetCategories().HasFlag(category)); EffectType effectType = validEffects.GetRandomValue(); - EnableEffect(effectType, duration, addDurationIfActive); + EnableEffect(effectType, intensity, duration, addDurationIfActive); return effectType; } @@ -2841,10 +2859,17 @@ public void EnableEffects(IEnumerable types, float duration = 0f, bo /// Enables a of on the player. /// /// The of to enable. - public void EnableEffects(IEnumerable effects) + [Obsolete("Use SyncEffects(IEnumerable) instead of this")] + public void EnableEffects(IEnumerable effects) => SyncEffects(effects); + + /// + /// Sync a of on the player. + /// + /// The of to enable. + public void SyncEffects(IEnumerable effects) { foreach (Effect effect in effects) - EnableEffect(effect); + SyncEffect(effect); } /// From a87cf97815b4135cf72c60f6964c7462f4f453c6 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sun, 8 Oct 2023 17:30:23 +0200 Subject: [PATCH 060/207] Fix NW --- Exiled.API/Features/Player.cs | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 0e59c94628..ce389cb241 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -2727,8 +2727,13 @@ public bool EnableEffect(StatusEffectBase statusEffect, byte intensity, float du if (statusEffect is null) return false; - StatusEffectBase effect = EnableEffect(statusEffect.GetType().Name, intensity, duration, addDurationIfActive); - return effect is not null && effect.IsEnabled; + Type effectType = statusEffect.GetType(); + if (ReferenceHub.playerEffectsController._effectsByType.TryGetValue(effectType, out statusEffect)) + { + ReferenceHub.playerEffectsController._effectsByType[effectType].ServerSetState(intensity, duration, addDurationIfActive); + } + + return statusEffect is not null && statusEffect.IsEnabled; } /// @@ -2768,26 +2773,9 @@ public void EnableEffect(EffectType type, float duration = 0f, bool addDurationI /// The intensity of the effect will be active for. /// The amount of time the effect will be active for. /// If the effect is already active, setting to will add this duration onto the effect. - public void EnableEffect(EffectType type, byte intensity, float duration = 0f, bool addDurationIfActive = false) - { - switch (type) - { - case EffectType.AmnesiaItems: - EnableEffect(intensity, duration, addDurationIfActive); - break; - case EffectType.AmnesiaVision: - EnableEffect(intensity, duration, addDurationIfActive); - break; - case EffectType.SoundtrackMute: - EnableEffect(intensity, duration, addDurationIfActive); - break; - default: - if (TryGetEffect(type, out StatusEffectBase statusEffect)) - EnableEffect(statusEffect, intensity, duration, addDurationIfActive); - - break; - } - } + /// return if the effect has been Enable. + public bool EnableEffect(EffectType type, byte intensity, float duration = 0f, bool addDurationIfActive = false) + => TryGetEffect(type, out StatusEffectBase statusEffect) && EnableEffect(statusEffect, intensity, duration, addDurationIfActive); /// /// Enables a status effect on the player. From 99bfa796dc339c4a9d0812115dba7e44d396e9d0 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sun, 8 Oct 2023 17:32:36 +0200 Subject: [PATCH 061/207] FUCK that so dumb --- Exiled.API/Features/Player.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index ce389cb241..8e7dc70356 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -2727,11 +2727,7 @@ public bool EnableEffect(StatusEffectBase statusEffect, byte intensity, float du if (statusEffect is null) return false; - Type effectType = statusEffect.GetType(); - if (ReferenceHub.playerEffectsController._effectsByType.TryGetValue(effectType, out statusEffect)) - { - ReferenceHub.playerEffectsController._effectsByType[effectType].ServerSetState(intensity, duration, addDurationIfActive); - } + statusEffect.ServerSetState(intensity, duration, addDurationIfActive); return statusEffect is not null && statusEffect.IsEnabled; } From 90bcaffc00b7e54907986bfb4d7e4a26df8c6c16 Mon Sep 17 00:00:00 2001 From: IRacle Date: Sun, 8 Oct 2023 19:40:38 +0300 Subject: [PATCH 062/207] nah, cringe logic --- Exiled.API/Features/Pickups/Pickup.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Exiled.API/Features/Pickups/Pickup.cs b/Exiled.API/Features/Pickups/Pickup.cs index 071cb48d2b..ccf255fe36 100644 --- a/Exiled.API/Features/Pickups/Pickup.cs +++ b/Exiled.API/Features/Pickups/Pickup.cs @@ -81,6 +81,8 @@ internal Pickup(ItemType type) if (!InventoryItemLoader.AvailableItems.TryGetValue(type, out ItemBase itemBase)) return; + Base = Object.Instantiate(itemBase.PickupDropModel); + PickupSyncInfo psi = new() { ItemId = type, @@ -88,8 +90,6 @@ internal Pickup(ItemType type) WeightKg = itemBase.Weight, }; - Base = InventoryExtensions.ServerCreatePickup(itemBase, psi, itemBase.PickupDropModel.transform.position, itemBase.PickupDropModel.transform.rotation, false); - Info = psi; BaseToPickup.Add(Base, this); From 73d622fefafdc968bd599b7e18b2beab3a15857e Mon Sep 17 00:00:00 2001 From: IRacle Date: Sun, 8 Oct 2023 19:47:00 +0300 Subject: [PATCH 063/207] :) --- Exiled.API/Features/Pickups/ExplosiveGrenadePickup.cs | 1 - Exiled.API/Features/Pickups/FlashGrenadePickup.cs | 1 - Exiled.API/Features/Pickups/GrenadePickup.cs | 11 +++++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Exiled.API/Features/Pickups/ExplosiveGrenadePickup.cs b/Exiled.API/Features/Pickups/ExplosiveGrenadePickup.cs index c47d8f133c..dcfdee8ecc 100644 --- a/Exiled.API/Features/Pickups/ExplosiveGrenadePickup.cs +++ b/Exiled.API/Features/Pickups/ExplosiveGrenadePickup.cs @@ -101,7 +101,6 @@ protected override void InitializeProperties(ItemBase itemBase) BurnDuration = explosiveGrenade._burnedDuration; DeafenDuration = explosiveGrenade._deafenedDuration; ConcussDuration = explosiveGrenade._concussedDuration; - FuseTime = explosiveGrenade._fuseTime; } } } diff --git a/Exiled.API/Features/Pickups/FlashGrenadePickup.cs b/Exiled.API/Features/Pickups/FlashGrenadePickup.cs index 8e2a70a793..1d178dfb74 100644 --- a/Exiled.API/Features/Pickups/FlashGrenadePickup.cs +++ b/Exiled.API/Features/Pickups/FlashGrenadePickup.cs @@ -85,7 +85,6 @@ protected override void InitializeProperties(ItemBase itemBase) MinimalDurationEffect = flashGrenade._minimalEffectDuration; AdditionalBlindedEffect = flashGrenade._additionalBlurDuration; SurfaceDistanceIntensifier = flashGrenade._surfaceZoneDistanceIntensifier; - FuseTime = flashGrenade._fuseTime; } } } diff --git a/Exiled.API/Features/Pickups/GrenadePickup.cs b/Exiled.API/Features/Pickups/GrenadePickup.cs index fddde2c7d0..7f4314995e 100644 --- a/Exiled.API/Features/Pickups/GrenadePickup.cs +++ b/Exiled.API/Features/Pickups/GrenadePickup.cs @@ -14,6 +14,7 @@ namespace Exiled.API.Features.Pickups using Footprinting; + using InventorySystem.Items; using InventorySystem.Items.ThrowableProjectiles; /// @@ -82,5 +83,15 @@ internal virtual void WriteProjectileInfo(Projectile projectile) timeGrenadeProjectile.FuseTime = FuseTime; } } + + /// + protected override void InitializeProperties(ItemBase itemBase) + { + base.InitializeProperties(itemBase); + if (itemBase is ThrowableItem throwable && throwable.Projectile is TimeGrenade timeGrenade) + { + FuseTime = timeGrenade._fuseTime; + } + } } } From c5b7d1aebc8053807487865ff1b4cdceb402bff8 Mon Sep 17 00:00:00 2001 From: Yamato <66829532+louis1706@users.noreply.github.com> Date: Mon, 9 Oct 2023 13:43:39 +0200 Subject: [PATCH 064/207] Update Consuming.cs --- Exiled.Events/Patches/Events/Scp0492/Consuming.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Exiled.Events/Patches/Events/Scp0492/Consuming.cs b/Exiled.Events/Patches/Events/Scp0492/Consuming.cs index 78de4de588..c364da72f1 100644 --- a/Exiled.Events/Patches/Events/Scp0492/Consuming.cs +++ b/Exiled.Events/Patches/Events/Scp0492/Consuming.cs @@ -5,7 +5,7 @@ // // ----------------------------------------------------------------------- -namespace Exiled.Events.Patches.Events.Scp049 +namespace Exiled.Events.Patches.Events.Scp0492 { using System.Collections.Generic; using System.Reflection.Emit; @@ -94,4 +94,4 @@ private static IEnumerable Transpiler(IEnumerable.Pool.Return(newInstructions); } } -} \ No newline at end of file +} From b7cafa746f9db4945cabac0e01c7cc6600004b59 Mon Sep 17 00:00:00 2001 From: NotIntense Date: Mon, 9 Oct 2023 15:45:00 -0400 Subject: [PATCH 065/207] fix --- .../Patches/Fixes/NpcServerCountFix.cs | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Exiled.Events/Patches/Fixes/NpcServerCountFix.cs diff --git a/Exiled.Events/Patches/Fixes/NpcServerCountFix.cs b/Exiled.Events/Patches/Fixes/NpcServerCountFix.cs new file mode 100644 index 0000000000..005997943e --- /dev/null +++ b/Exiled.Events/Patches/Fixes/NpcServerCountFix.cs @@ -0,0 +1,48 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled 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 Exiled.API.Features; + using Exiled.API.Features.Pools; + using HarmonyLib; + + using static HarmonyLib.AccessTools; + + /// + /// Patches to prevent NPC's from appearing as real players in the server list count. + /// + [HarmonyPatch(typeof(ServerConsole), nameof(ServerConsole.RefreshOnlinePlayers))] + internal static class NpcServerCountFix + { + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) + { + List newInstructions = ListPool.Pool.Get(instructions); + + int offset = 0; + int index = newInstructions.FindIndex(i => i.opcode == OpCodes.Ldsflda) + offset; + + Label labelcontinue = (Label)newInstructions[index - 1].operand; + + newInstructions.InsertRange(index, new[] + { + new CodeInstruction(OpCodes.Ldloc_1), + new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), + new(OpCodes.Callvirt, PropertyGetter(typeof(Player), nameof(Player.IsNPC))), + new(OpCodes.Brtrue_S, labelcontinue), + }); + + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; + + ListPool.Pool.Return(newInstructions); + } + } +} \ No newline at end of file From 80d4a788bbff9610d8607e1ab228790f611e45dc Mon Sep 17 00:00:00 2001 From: NotIntense Date: Mon, 9 Oct 2023 15:46:01 -0400 Subject: [PATCH 066/207] Update --- Exiled.API/Features/Npc.cs | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/Exiled.API/Features/Npc.cs b/Exiled.API/Features/Npc.cs index 8a57379d04..1bcc8dc382 100644 --- a/Exiled.API/Features/Npc.cs +++ b/Exiled.API/Features/Npc.cs @@ -10,6 +10,7 @@ namespace Exiled.API.Features { using System; using System.Collections.Generic; + using System.Linq; using CommandSystem; @@ -49,20 +50,7 @@ public Npc(GameObject gameObject) /// /// Gets a list of Npcs. /// - public new List List - { - get - { - List npcS = new(); - foreach (Player player in Player.List) - { - if (player is Npc npc) - npcS.Add(npc); - } - - return npcS; - } - } + public static new List List => Player.List.OfType().ToList(); /// /// Retrieves the NPC associated with the specified ReferenceHub. @@ -139,7 +127,7 @@ public Npc(GameObject gameObject) /// /// The name of the NPC. /// The RoleTypeId of the NPC. - /// The player ID of the NPC. + /// The Network ID of the NPC. If 0, one is made. /// The userID of the NPC. /// The position to spawn the NPC. /// The spawned. @@ -160,20 +148,13 @@ public static Npc Spawn(string name, RoleTypeId role, int id = 0, string userId Log.Debug($"Ignore: {e}"); } - if (RecyclablePlayerId.FreeIds.Contains(id)) - { - RecyclablePlayerId.FreeIds.RemoveFromQueue(id); - } - else if (RecyclablePlayerId._autoIncrement >= id) - { - RecyclablePlayerId._autoIncrement = id = RecyclablePlayerId._autoIncrement + 1; - } + int conId = id == 0 ? ReferenceHub.AllHubs.Count + 1 : id; + + NetworkServer.AddPlayerForConnection(new(conId), newObject); - FakeConnection fakeConnection = new(id); - NetworkServer.AddPlayerForConnection(fakeConnection, newObject); try { - npc.ReferenceHub.characterClassManager.UserId = string.IsNullOrEmpty(userId) ? $"Dummy@localhost" : userId; + npc.ReferenceHub.characterClassManager.UserId = string.IsNullOrEmpty(userId) ? $"Dummy{ReferenceHub.AllHubs.Count}@localhost" : userId; } catch (Exception e) { @@ -209,4 +190,4 @@ public void Destroy() Object.Destroy(GameObject); } } -} +} \ No newline at end of file From 564b6a40ff83368207c883da2ef1dff1c172d267 Mon Sep 17 00:00:00 2001 From: IRacle Date: Tue, 10 Oct 2023 15:50:18 +0300 Subject: [PATCH 067/207] u --- Exiled.API/Features/Items/ExplosiveGrenade.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/Exiled.API/Features/Items/ExplosiveGrenade.cs b/Exiled.API/Features/Items/ExplosiveGrenade.cs index c01796cb4d..8f9aa165c3 100644 --- a/Exiled.API/Features/Items/ExplosiveGrenade.cs +++ b/Exiled.API/Features/Items/ExplosiveGrenade.cs @@ -13,13 +13,10 @@ namespace Exiled.API.Features.Items using Exiled.API.Features.Pickups.Projectiles; using InventorySystem.Items; - using InventorySystem.Items.Armor; using InventorySystem.Items.Pickups; using InventorySystem.Items.ThrowableProjectiles; using UnityEngine; - using static ServerConfigSynchronizer; - using Object = UnityEngine.Object; /// From 73141ac290d6e1d210a88004abf81b9aa2756854 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Wed, 11 Oct 2023 16:00:19 +0200 Subject: [PATCH 068/207] Fix --- Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs | 7 +------ Exiled.Events/EventArgs/Scp049/AttackingEventArgs.cs | 3 --- Exiled.Events/EventArgs/Scp049/FinishingRecallEventArgs.cs | 3 --- Exiled.Events/EventArgs/Scp049/SendingCallEventArgs.cs | 3 --- Exiled.Events/EventArgs/Scp049/StartingRecallEventArgs.cs | 3 --- 5 files changed, 1 insertion(+), 18 deletions(-) diff --git a/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs b/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs index 9f9f78b51e..9c38f0a70c 100644 --- a/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs @@ -10,9 +10,7 @@ namespace Exiled.Events.EventArgs.Scp049 using System; using API.Features; - using API.Features.Roles; - - using PlayerRoles.PlayableScps.Scp049; + using Exiled.Events.EventArgs.Interfaces; using Scp049Role = API.Features.Roles.Scp049Role; @@ -45,9 +43,6 @@ public ActivatingSenseEventArgs(Player player, Player target, bool isAllowed = t /// public Player Player { get; } - /// - public Scp049Role Scp049 { get; } - /// /// Gets the Player who the sense ability is affecting. /// diff --git a/Exiled.Events/EventArgs/Scp049/AttackingEventArgs.cs b/Exiled.Events/EventArgs/Scp049/AttackingEventArgs.cs index 870794f6ec..8371c1fa73 100644 --- a/Exiled.Events/EventArgs/Scp049/AttackingEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp049/AttackingEventArgs.cs @@ -38,9 +38,6 @@ public AttackingEventArgs(Player player, Player target, bool isAllowed = true) /// public Player Player { get; } - /// - public Scp049Role Scp049 { get; } - /// /// Gets the target of attack. /// diff --git a/Exiled.Events/EventArgs/Scp049/FinishingRecallEventArgs.cs b/Exiled.Events/EventArgs/Scp049/FinishingRecallEventArgs.cs index 34b6d636b7..7748318aa9 100644 --- a/Exiled.Events/EventArgs/Scp049/FinishingRecallEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp049/FinishingRecallEventArgs.cs @@ -48,9 +48,6 @@ public FinishingRecallEventArgs(Player target, Player scp049, BasicRagdoll ragdo /// public Player Player { get; } - /// - public Scp049Role Scp049 { get; } - /// /// Gets the player who's getting recalled. /// diff --git a/Exiled.Events/EventArgs/Scp049/SendingCallEventArgs.cs b/Exiled.Events/EventArgs/Scp049/SendingCallEventArgs.cs index 96b7194b6e..cd882d151d 100644 --- a/Exiled.Events/EventArgs/Scp049/SendingCallEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp049/SendingCallEventArgs.cs @@ -37,9 +37,6 @@ public SendingCallEventArgs(Player player, bool isAllowed = true) /// public Player Player { get; } - /// - public Scp049Role Scp049 { get; } - /// /// Gets or sets the duration of the Call Ability. /// diff --git a/Exiled.Events/EventArgs/Scp049/StartingRecallEventArgs.cs b/Exiled.Events/EventArgs/Scp049/StartingRecallEventArgs.cs index 29f7460a6d..a0c5f0a6a6 100644 --- a/Exiled.Events/EventArgs/Scp049/StartingRecallEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp049/StartingRecallEventArgs.cs @@ -58,9 +58,6 @@ public StartingRecallEventArgs(Player target, Player scp049, Ragdoll ragdoll, bo /// public Player Player { get; } - /// - public Scp049Role Scp049 { get; } - /// /// Gets the Ragdoll who's getting recalled. /// From 3ffbd5346bad92bc4898aa2bedf24d2df96fdb2d Mon Sep 17 00:00:00 2001 From: louis1706 Date: Wed, 11 Oct 2023 16:08:09 +0200 Subject: [PATCH 069/207] I will re add setter later when i found a good way to do them --- Exiled.API/Features/Roles/Scp049Role.cs | 16 ++++++++++------ .../Generic/Scp049API/CallAbilityDuration.cs | 2 +- .../Scp049API/SenseAbilityBaseCooldown.cs | 2 +- .../Scp049API/SenseAbilityReducedCooldown.cs | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Exiled.API/Features/Roles/Scp049Role.cs b/Exiled.API/Features/Roles/Scp049Role.cs index 87958c9a6a..1f7a8a1e07 100644 --- a/Exiled.API/Features/Roles/Scp049Role.cs +++ b/Exiled.API/Features/Roles/Scp049Role.cs @@ -119,35 +119,39 @@ internal Scp049Role(Scp049GameRole baseRole) /// public IEnumerable DeadZombies => Scp049ResurrectAbility.DeadZombies.Select(x => Player.Get(x)); + // TODO: ReAdd Setter but before making an propper way to overwrite NW constant only when the propperty has been used +#pragma warning disable SA1623 // Property summary documentation should match accessors + /// /// Gets or sets how mush time the Call Ability will be effective. /// - public double CallAbilityDuration { get; set; } = Scp049CallAbility.EffectDuration; + internal double CallAbilityDuration { get; } = Scp049CallAbility.EffectDuration; /// /// Gets or sets the Cooldown of the Call Ability. /// - public double CallAbilityBaseCooldown { get; set; } = Scp049CallAbility.BaseCooldown; + internal double CallAbilityBaseCooldown { get; } = Scp049CallAbility.BaseCooldown; /// /// Gets or sets the Cooldown of the Sense Ability. /// - public double SenseAbilityBaseCooldown { get; set; } = Scp049SenseAbility.BaseCooldown; + internal double SenseAbilityBaseCooldown { get; } = Scp049SenseAbility.BaseCooldown; /// /// Gets or sets the Cooldown of the Sense Ability when you lost your target. /// - public double SenseAbilityReducedCooldown { get; set; } = Scp049SenseAbility.ReducedCooldown; + internal double SenseAbilityReducedCooldown { get; } = Scp049SenseAbility.ReducedCooldown; /// /// Gets or sets the Cooldown of the Sense Ability when it's failed. /// - public double SenseAbilityDuration { get; set; } = Scp049SenseAbility.EffectDuration; + internal double SenseAbilityDuration { get; } = Scp049SenseAbility.EffectDuration; /// /// Gets or sets how mush time the Sense Ability will be effective. /// - public double SenseAbilityFailCooldown { get; set; } = Scp049SenseAbility.AttemptFailCooldown; + internal double SenseAbilityFailCooldown { get; } = Scp049SenseAbility.AttemptFailCooldown; +#pragma warning restore SA1623 // Property summary documentation should match accessors /// /// Gets all the resurrected players. diff --git a/Exiled.Events/Patches/Generic/Scp049API/CallAbilityDuration.cs b/Exiled.Events/Patches/Generic/Scp049API/CallAbilityDuration.cs index a06395c78a..e9cb219aab 100644 --- a/Exiled.Events/Patches/Generic/Scp049API/CallAbilityDuration.cs +++ b/Exiled.Events/Patches/Generic/Scp049API/CallAbilityDuration.cs @@ -25,7 +25,7 @@ namespace Exiled.Events.Patches.Generic.Scp079API /// Patches . /// Adds the property. /// - [HarmonyPatch(typeof(Scp049CallAbility), nameof(Scp049CallAbility.ServerProcessCmd))] + // [HarmonyPatch(typeof(Scp049CallAbility), nameof(Scp049CallAbility.ServerProcessCmd))] internal class CallAbilityDuration { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) diff --git a/Exiled.Events/Patches/Generic/Scp049API/SenseAbilityBaseCooldown.cs b/Exiled.Events/Patches/Generic/Scp049API/SenseAbilityBaseCooldown.cs index ba615bf087..db27de6c41 100644 --- a/Exiled.Events/Patches/Generic/Scp049API/SenseAbilityBaseCooldown.cs +++ b/Exiled.Events/Patches/Generic/Scp049API/SenseAbilityBaseCooldown.cs @@ -26,7 +26,7 @@ namespace Exiled.Events.Patches.Generic.Scp079API /// Patches . /// Adds the property. /// - [HarmonyPatch(typeof(Scp049SenseAbility), nameof(Scp049SenseAbility.ServerProcessKilledPlayer))] + // [HarmonyPatch(typeof(Scp049SenseAbility), nameof(Scp049SenseAbility.ServerProcessKilledPlayer))] internal class SenseAbilityBaseCooldown { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) diff --git a/Exiled.Events/Patches/Generic/Scp049API/SenseAbilityReducedCooldown.cs b/Exiled.Events/Patches/Generic/Scp049API/SenseAbilityReducedCooldown.cs index b4c351abda..ae789da37f 100644 --- a/Exiled.Events/Patches/Generic/Scp049API/SenseAbilityReducedCooldown.cs +++ b/Exiled.Events/Patches/Generic/Scp049API/SenseAbilityReducedCooldown.cs @@ -26,7 +26,7 @@ namespace Exiled.Events.Patches.Generic.Scp079API /// Patches . /// Adds the property. /// - [HarmonyPatch(typeof(Scp049SenseAbility), nameof(Scp049SenseAbility.ServerLoseTarget))] + // [HarmonyPatch(typeof(Scp049SenseAbility), nameof(Scp049SenseAbility.ServerLoseTarget))] internal class SenseAbilityReducedCooldown { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) From dd3d535dc0f261974a0af81539b759ba5e67efd1 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Wed, 11 Oct 2023 16:14:58 +0200 Subject: [PATCH 070/207] Revert "NetherCode" This reverts commit 522b587116b850ef741aeeed2bd9f403d7051fd1. --- .../Features/DynamicPatch/Property{T}.cs | 94 ------------------- Exiled.API/Features/Roles/Scp106Role.cs | 21 +++-- Exiled.API/Interfaces/IProperty.cs | 16 ---- .../Scp106API/CooldownReductionReward.cs | 2 - .../Patches/Generic/Scp106API/CustomAttack.cs | 5 - .../Scp106API/HunterAtlastCostPerMetter.cs | 2 - .../Scp106API/SinkholeAbilityCooldown.cs | 2 - .../Generic/Scp106API/StalkVigorUse.cs | 3 - .../Generic/Scp106API/VigorRegeneration.cs | 2 - 9 files changed, 11 insertions(+), 136 deletions(-) delete mode 100644 Exiled.API/Features/DynamicPatch/Property{T}.cs delete mode 100644 Exiled.API/Interfaces/IProperty.cs diff --git a/Exiled.API/Features/DynamicPatch/Property{T}.cs b/Exiled.API/Features/DynamicPatch/Property{T}.cs deleted file mode 100644 index 0d451fd1d5..0000000000 --- a/Exiled.API/Features/DynamicPatch/Property{T}.cs +++ /dev/null @@ -1,94 +0,0 @@ -// ----------------------------------------------------------------------- -// -// Copyright (c) Exiled Team. All rights reserved. -// Licensed under the CC BY-SA 3.0 license. -// -// ----------------------------------------------------------------------- - -namespace Exiled.API.Features.DynamicPatch -{ - using System; -#pragma warning disable SA1611 // Element parameters should be documented - - using System.Collections.Generic; - using System.Reflection; - - using Exiled.API.Interfaces; - - /// - /// An implementation of the interface that encapsulates a property with arguments. - /// - /// The type of the property value. - public class Property : IProperty - { - private static bool? useDynamicPatching; - - private static MethodInfo patchMethod; - - private static object patcherInstance; - private bool patched; - private T propertyValue; - - /// - /// Initializes a new instance of the class. - /// - /// - public Property(T value) => propertyValue = value; - - /// - /// Gets or sets the property value. - /// - public T Value - { - get => propertyValue; - set - { - if (!EqualityComparer.Default.Equals(propertyValue, value)) - { - if (useDynamicPatching is null) - AccessPatcherUsingReflection(); - - if (useDynamicPatching is true && !patched) - { - patchMethod.Invoke(patcherInstance, new object[] { this }); - patched = true; - } - - propertyValue = value; - } - } - } - - /// - /// Implicitly converts the Property to its value type. - /// - /// The Property to convert. - public static implicit operator T(Property property) => property.Value; - - private static void AccessPatcherUsingReflection() - { - if (patchMethod == null || patcherInstance == null) - { - foreach (Type type in Assembly.Load("Exiled.Events").GetTypes()) - { - if (type.Name == "Patcher") - { - // Access the Patcher instance property using reflection - patcherInstance = type.GetField("Instance", BindingFlags.Public | BindingFlags.Static)?.GetValue(null); - - if (patcherInstance != null) - { - // Call the Patch method on the patcherInstance - patchMethod = type.GetMethod("Patch"); - - // Instance.Config.UseDynamicPatching - // Call the config - useDynamicPatching = (bool?)type.GetProperty("Config", BindingFlags.Public | BindingFlags.Static)?.GetValue(null)? - .GetType()?.GetProperty("UseDynamicPatching", BindingFlags.Public | BindingFlags.Static)?.GetValue(null); - } - } - } - } - } - } -} diff --git a/Exiled.API/Features/Roles/Scp106Role.cs b/Exiled.API/Features/Roles/Scp106Role.cs index 23bc026c2c..3881b94456 100644 --- a/Exiled.API/Features/Roles/Scp106Role.cs +++ b/Exiled.API/Features/Roles/Scp106Role.cs @@ -10,12 +10,13 @@ namespace Exiled.API.Features.Roles using System.Collections.Generic; using Exiled.API.Enums; - using Exiled.API.Features.DynamicPatch; using PlayerRoles; using PlayerRoles.PlayableScps.HumeShield; + using PlayerRoles.PlayableScps.Scp049; using PlayerRoles.PlayableScps.Scp106; using PlayerRoles.PlayableScps.Subroutines; using PlayerStatsSystem; + using UnityEngine; using Scp106GameRole = PlayerRoles.PlayableScps.Scp106.Scp106Role; @@ -184,47 +185,47 @@ public bool SinkholeState /// /// Gets or sets how mush cost the Ability Stalk will cost per tick when being stationary. /// - public Property VigorStalkCostStationary { get; set; } = new(Scp106StalkAbility.VigorStalkCostStationary); + public float VigorStalkCostStationary { get; set; } = Scp106StalkAbility.VigorStalkCostStationary; /// /// Gets or sets how mush cost the Ability Stalk will cost per tick when moving. /// - public Property VigorStalkCostMoving { get; set; } = new(Scp106StalkAbility.VigorStalkCostMoving); + public float VigorStalkCostMoving { get; set; } = Scp106StalkAbility.VigorStalkCostMoving; /// /// Gets or sets how mush vigor will be regenerate while moving per seconds. /// - public Property VigorRegeneration { get; set; } = new(Scp106StalkAbility.VigorRegeneration); + public float VigorRegeneration { get; set; } = Scp106StalkAbility.VigorRegeneration; /// /// Gets or sets how mush damage Scp106 will dealt when attacking a player. /// - public Property AttackDamage { get; set; } = new(Scp106Attack.AttackDamage); + public float AttackDamage { get; set; } = Scp106Attack.AttackDamage; /// /// Gets or sets the duration of Corroding effect. /// - public Property CorrodingTime { get; set; } = new(Scp106Attack.CorrodingTime); + public float CorrodingTime { get; set; } = Scp106Attack.CorrodingTime; /// /// Gets or sets how mush vigor Scp106 will gain when being reward for having caught a player. /// - public Property VigorCaptureReward { get; set; } = new(Scp106Attack.VigorCaptureReward); + public float VigorCaptureReward { get; set; } = Scp106Attack.VigorCaptureReward; /// /// Gets or sets how mush reduction cooldown Scp106 will gain when being reward for having caught a player. /// - public Property CooldownReductionReward { get; set; } = new(Scp106Attack.CooldownReductionReward); + public float CooldownReductionReward { get; set; } = Scp106Attack.CooldownReductionReward; /// /// Gets or sets the cooldown duration of it's Sinkhole ability's. /// - public Property SinkholeCooldownDuration { get; set; } = new(Scp106SinkholeController.CooldownDuration); + public float SinkholeCooldownDuration { get; set; } = Scp106SinkholeController.CooldownDuration; /// /// Gets or sets how mush vigor it's ability Hunter Atlas will cost per meter. /// - public Property HuntersAtlasCostPerMeter { get; set; } = new(Scp106HuntersAtlasAbility.CostPerMeter); + public float HuntersAtlasCostPerMeter { get; set; } = Scp106HuntersAtlasAbility.CostPerMeter; /// /// Gets or sets the amount of time in between player captures. diff --git a/Exiled.API/Interfaces/IProperty.cs b/Exiled.API/Interfaces/IProperty.cs deleted file mode 100644 index 390cccb13c..0000000000 --- a/Exiled.API/Interfaces/IProperty.cs +++ /dev/null @@ -1,16 +0,0 @@ -// ----------------------------------------------------------------------- -// -// Copyright (c) Exiled Team. All rights reserved. -// Licensed under the CC BY-SA 3.0 license. -// -// ----------------------------------------------------------------------- - -namespace Exiled.API.Interfaces -{ - /// - /// The base Exiled Event Args interface to be used by all other event arg interfaces/classes. - /// - public interface IProperty - { - } -} \ No newline at end of file diff --git a/Exiled.Events/Patches/Generic/Scp106API/CooldownReductionReward.cs b/Exiled.Events/Patches/Generic/Scp106API/CooldownReductionReward.cs index 02f7e7c3c7..dd0e539450 100644 --- a/Exiled.Events/Patches/Generic/Scp106API/CooldownReductionReward.cs +++ b/Exiled.Events/Patches/Generic/Scp106API/CooldownReductionReward.cs @@ -13,7 +13,6 @@ namespace Exiled.Events.Patches.Generic.Scp106API using API.Features.Pools; using Exiled.API.Features; - using Exiled.API.Features.DynamicPatch; using HarmonyLib; using PlayerRoles.PlayableScps.Scp106; using PlayerRoles.PlayableScps.Subroutines; @@ -57,7 +56,6 @@ private static IEnumerable Transpiler(IEnumerable), "op_implicit")), }); for (int z = 0; z < newInstructions.Count; z++) diff --git a/Exiled.Events/Patches/Generic/Scp106API/CustomAttack.cs b/Exiled.Events/Patches/Generic/Scp106API/CustomAttack.cs index d5d7a5bcd8..54fccd372b 100644 --- a/Exiled.Events/Patches/Generic/Scp106API/CustomAttack.cs +++ b/Exiled.Events/Patches/Generic/Scp106API/CustomAttack.cs @@ -12,7 +12,6 @@ namespace Exiled.Events.Patches.Generic.Scp106API using API.Features.Pools; using Exiled.API.Features; - using Exiled.API.Features.DynamicPatch; using HarmonyLib; using PlayerRoles.PlayableScps.Scp106; using PlayerRoles.PlayableScps.Subroutines; @@ -56,7 +55,6 @@ private static IEnumerable Transpiler(IEnumerable), "op_implicit")), }); // replace "base.Vigor.VigorAmount += 0.3f;" @@ -80,7 +78,6 @@ private static IEnumerable Transpiler(IEnumerable), "op_implicit")), }); // replace "base.Vigor.VigorAmount += 0.3f;" @@ -104,7 +101,6 @@ private static IEnumerable Transpiler(IEnumerable), "op_implicit")), }); // replace "playerEffectsController.EnableEffect(20f, false);" @@ -128,7 +124,6 @@ private static IEnumerable Transpiler(IEnumerable), "op_implicit")), }); for (int z = 0; z < newInstructions.Count; z++) yield return newInstructions[z]; diff --git a/Exiled.Events/Patches/Generic/Scp106API/HunterAtlastCostPerMetter.cs b/Exiled.Events/Patches/Generic/Scp106API/HunterAtlastCostPerMetter.cs index ad6e5e999c..0fdc57feb8 100644 --- a/Exiled.Events/Patches/Generic/Scp106API/HunterAtlastCostPerMetter.cs +++ b/Exiled.Events/Patches/Generic/Scp106API/HunterAtlastCostPerMetter.cs @@ -13,7 +13,6 @@ namespace Exiled.Events.Patches.Generic.Scp106API using API.Features.Pools; using Exiled.API.Features; - using Exiled.API.Features.DynamicPatch; using HarmonyLib; using PlayerRoles.PlayableScps.Scp106; using PlayerRoles.PlayableScps.Subroutines; @@ -57,7 +56,6 @@ private static IEnumerable Transpiler(IEnumerable), "op_implicit")), }); for (int z = 0; z < newInstructions.Count; z++) diff --git a/Exiled.Events/Patches/Generic/Scp106API/SinkholeAbilityCooldown.cs b/Exiled.Events/Patches/Generic/Scp106API/SinkholeAbilityCooldown.cs index aa3f526d69..120441459f 100644 --- a/Exiled.Events/Patches/Generic/Scp106API/SinkholeAbilityCooldown.cs +++ b/Exiled.Events/Patches/Generic/Scp106API/SinkholeAbilityCooldown.cs @@ -13,7 +13,6 @@ namespace Exiled.Events.Patches.Generic.Scp106API using API.Features.Pools; using Exiled.API.Features; - using Exiled.API.Features.DynamicPatch; using HarmonyLib; using PlayerRoles.PlayableScps.Scp106; using PlayerRoles.PlayableScps.Subroutines; @@ -57,7 +56,6 @@ private static IEnumerable Transpiler(IEnumerable), "op_implicit")), }); for (int z = 0; z < newInstructions.Count; z++) diff --git a/Exiled.Events/Patches/Generic/Scp106API/StalkVigorUse.cs b/Exiled.Events/Patches/Generic/Scp106API/StalkVigorUse.cs index 1f677ea541..8cdd360b27 100644 --- a/Exiled.Events/Patches/Generic/Scp106API/StalkVigorUse.cs +++ b/Exiled.Events/Patches/Generic/Scp106API/StalkVigorUse.cs @@ -12,7 +12,6 @@ namespace Exiled.Events.Patches.Generic.Scp106API using API.Features.Pools; using Exiled.API.Features; - using Exiled.API.Features.DynamicPatch; using HarmonyLib; using PlayerRoles.PlayableScps.Scp106; using PlayerRoles.PlayableScps.Subroutines; @@ -56,7 +55,6 @@ private static IEnumerable Transpiler(IEnumerable), "op_implicit")), }); offset = 0; @@ -76,7 +74,6 @@ private static IEnumerable Transpiler(IEnumerable), "op_implicit")), }); for (int z = 0; z < newInstructions.Count; z++) yield return newInstructions[z]; diff --git a/Exiled.Events/Patches/Generic/Scp106API/VigorRegeneration.cs b/Exiled.Events/Patches/Generic/Scp106API/VigorRegeneration.cs index 365e313315..3bbe601d94 100644 --- a/Exiled.Events/Patches/Generic/Scp106API/VigorRegeneration.cs +++ b/Exiled.Events/Patches/Generic/Scp106API/VigorRegeneration.cs @@ -12,7 +12,6 @@ namespace Exiled.Events.Patches.Generic.Scp106API using API.Features.Pools; using Exiled.API.Features; - using Exiled.API.Features.DynamicPatch; using HarmonyLib; using PlayerRoles.PlayableScps.Scp106; using PlayerRoles.PlayableScps.Subroutines; @@ -56,7 +55,6 @@ private static IEnumerable Transpiler(IEnumerable), "op_implicit")), }); for (int z = 0; z < newInstructions.Count; z++) From 0cd64fe7ad5eaf628254095291c2408b6ac22a23 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Wed, 11 Oct 2023 16:17:59 +0200 Subject: [PATCH 071/207] will add this later --- Exiled.API/Features/Roles/Scp106Role.cs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Exiled.API/Features/Roles/Scp106Role.cs b/Exiled.API/Features/Roles/Scp106Role.cs index 3881b94456..de2e95b986 100644 --- a/Exiled.API/Features/Roles/Scp106Role.cs +++ b/Exiled.API/Features/Roles/Scp106Role.cs @@ -182,50 +182,53 @@ public bool SinkholeState /// public float SinkholeSpeedMultiplier => SinkholeController.SpeedMultiplier; + // TODO: ReAdd Setter but before making an propper way to overwrite NW constant only when the propperty has been used +#pragma warning disable SA1623 // Property summary documentation should match accessors /// /// Gets or sets how mush cost the Ability Stalk will cost per tick when being stationary. /// - public float VigorStalkCostStationary { get; set; } = Scp106StalkAbility.VigorStalkCostStationary; + internal float VigorStalkCostStationary { get; } = Scp106StalkAbility.VigorStalkCostStationary; /// /// Gets or sets how mush cost the Ability Stalk will cost per tick when moving. /// - public float VigorStalkCostMoving { get; set; } = Scp106StalkAbility.VigorStalkCostMoving; + internal float VigorStalkCostMoving { get; } = Scp106StalkAbility.VigorStalkCostMoving; /// /// Gets or sets how mush vigor will be regenerate while moving per seconds. /// - public float VigorRegeneration { get; set; } = Scp106StalkAbility.VigorRegeneration; + internal float VigorRegeneration { get; } = Scp106StalkAbility.VigorRegeneration; /// /// Gets or sets how mush damage Scp106 will dealt when attacking a player. /// - public float AttackDamage { get; set; } = Scp106Attack.AttackDamage; + internal float AttackDamage { get; } = Scp106Attack.AttackDamage; /// /// Gets or sets the duration of Corroding effect. /// - public float CorrodingTime { get; set; } = Scp106Attack.CorrodingTime; + internal float CorrodingTime { get; } = Scp106Attack.CorrodingTime; /// /// Gets or sets how mush vigor Scp106 will gain when being reward for having caught a player. /// - public float VigorCaptureReward { get; set; } = Scp106Attack.VigorCaptureReward; + internal float VigorCaptureReward { get; } = Scp106Attack.VigorCaptureReward; /// /// Gets or sets how mush reduction cooldown Scp106 will gain when being reward for having caught a player. /// - public float CooldownReductionReward { get; set; } = Scp106Attack.CooldownReductionReward; + internal float CooldownReductionReward { get; } = Scp106Attack.CooldownReductionReward; /// /// Gets or sets the cooldown duration of it's Sinkhole ability's. /// - public float SinkholeCooldownDuration { get; set; } = Scp106SinkholeController.CooldownDuration; + internal float SinkholeCooldownDuration { get; } = Scp106SinkholeController.CooldownDuration; /// /// Gets or sets how mush vigor it's ability Hunter Atlas will cost per meter. /// - public float HuntersAtlasCostPerMeter { get; set; } = Scp106HuntersAtlasAbility.CostPerMeter; + internal float HuntersAtlasCostPerMeter { get; } = Scp106HuntersAtlasAbility.CostPerMeter; +#pragma warning restore SA1623 // Property summary documentation should match accessors /// /// Gets or sets the amount of time in between player captures. From e427dece88791f6b3afd514d68f96fcbb9997d99 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Wed, 11 Oct 2023 16:19:27 +0200 Subject: [PATCH 072/207] RemoveError --- Exiled.API/Features/Roles/Scp106Role.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Exiled.API/Features/Roles/Scp106Role.cs b/Exiled.API/Features/Roles/Scp106Role.cs index de2e95b986..f81b3c14a3 100644 --- a/Exiled.API/Features/Roles/Scp106Role.cs +++ b/Exiled.API/Features/Roles/Scp106Role.cs @@ -184,6 +184,7 @@ public bool SinkholeState // TODO: ReAdd Setter but before making an propper way to overwrite NW constant only when the propperty has been used #pragma warning disable SA1623 // Property summary documentation should match accessors +#pragma warning disable SA1202 /// /// Gets or sets how mush cost the Ability Stalk will cost per tick when being stationary. /// From d4cfa93b7c23c5b43713cf76cb04206d0b235fb9 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Wed, 11 Oct 2023 16:20:24 +0200 Subject: [PATCH 073/207] Remove Error --- Exiled.API/Features/Roles/Scp049Role.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.API/Features/Roles/Scp049Role.cs b/Exiled.API/Features/Roles/Scp049Role.cs index 1f7a8a1e07..3e6999f977 100644 --- a/Exiled.API/Features/Roles/Scp049Role.cs +++ b/Exiled.API/Features/Roles/Scp049Role.cs @@ -121,7 +121,7 @@ internal Scp049Role(Scp049GameRole baseRole) // TODO: ReAdd Setter but before making an propper way to overwrite NW constant only when the propperty has been used #pragma warning disable SA1623 // Property summary documentation should match accessors - +#pragma warning disable SA1202 /// /// Gets or sets how mush time the Call Ability will be effective. /// From 2042b374daba59dc8f4fc31bf8b3c3685bf018fc Mon Sep 17 00:00:00 2001 From: Yamato <66829532+louis1706@users.noreply.github.com> Date: Wed, 11 Oct 2023 20:13:38 +0200 Subject: [PATCH 074/207] Update ZoneBlackoutEventArgs.cs --- Exiled.Events/EventArgs/Scp079/ZoneBlackoutEventArgs.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Exiled.Events/EventArgs/Scp079/ZoneBlackoutEventArgs.cs b/Exiled.Events/EventArgs/Scp079/ZoneBlackoutEventArgs.cs index 2a6c76b86c..e6f7bf3f0d 100644 --- a/Exiled.Events/EventArgs/Scp079/ZoneBlackoutEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp079/ZoneBlackoutEventArgs.cs @@ -59,9 +59,6 @@ public ZoneBlackoutEventArgs(ReferenceHub player, FacilityZone zone, float auxil /// public Player Player { get; } - /// - public Scp079Role Scp079 { get; } - /// /// Gets the of the room that will be locked down. /// @@ -95,4 +92,4 @@ public ZoneBlackoutEventArgs(ReferenceHub player, FacilityZone zone, float auxil /// public API.Features.Roles.Scp079Role Scp079 { get; } } -} \ No newline at end of file +} From d2908b4e930c1bf91ef0119a9711b374d46ac4d1 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Wed, 11 Oct 2023 20:15:43 +0200 Subject: [PATCH 075/207] Fix error --- Exiled.Events/Patches/Events/Scp049/Consuming.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Exiled.Events/Patches/Events/Scp049/Consuming.cs b/Exiled.Events/Patches/Events/Scp049/Consuming.cs index 69c024b761..da254bfcb4 100644 --- a/Exiled.Events/Patches/Events/Scp049/Consuming.cs +++ b/Exiled.Events/Patches/Events/Scp049/Consuming.cs @@ -12,23 +12,20 @@ namespace Exiled.Events.Patches.Events.Scp049 using Exiled.API.Features; using Exiled.API.Features.Pools; - - using Exiled.Events.EventArgs.Scp049; - + using Exiled.Events.Attributes; + using Exiled.Events.EventArgs.Scp0492; using HarmonyLib; - - using PlayerRoles; using PlayerRoles.PlayableScps.Scp049; using PlayerRoles.PlayableScps.Scp049.Zombies; using PlayerRoles.PlayableScps.Subroutines; using PlayerStatsSystem; - using UnityEngine; using static HarmonyLib.AccessTools; /// - /// Adds the event. + /// Adds the event. /// + [EventPatch(typeof(Handlers.Scp0492), nameof(Handlers.Scp0492.ConsumingCorpse))] [HarmonyPatch(typeof(ZombieConsumeAbility), nameof(ZombieConsumeAbility.ServerProcessCmd))] public class Consuming { @@ -66,7 +63,7 @@ private static IEnumerable Transpiler(IEnumerable Date: Wed, 11 Oct 2023 22:44:32 +0200 Subject: [PATCH 076/207] Space --- Exiled.Events/Patches/Events/Scp079/Pinging.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.Events/Patches/Events/Scp079/Pinging.cs b/Exiled.Events/Patches/Events/Scp079/Pinging.cs index 5f1d646db9..42212febba 100644 --- a/Exiled.Events/Patches/Events/Scp079/Pinging.cs +++ b/Exiled.Events/Patches/Events/Scp079/Pinging.cs @@ -119,7 +119,7 @@ private static IEnumerable Transpiler(IEnumerable.Pool.Return(newInstructions); + ListPool.Pool.Return(newInstructions); } } } \ No newline at end of file From d5a6008ed8f67ea0636e6d243d5f55c63f3d75d5 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Wed, 11 Oct 2023 22:50:23 +0200 Subject: [PATCH 077/207] Bruh --- Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs | 2 +- Exiled.Events/Patches/Events/Scp079/TriggeringDoor.cs | 2 +- Exiled.Events/Patches/Events/Scp079/ZoneBlackout.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs b/Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs index b343328897..41942e2d83 100644 --- a/Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs +++ b/Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs @@ -24,7 +24,7 @@ namespace Exiled.Events.Patches.Events.Scp079 /// Patches . /// Adds the event for SCP-079. /// - [EventPatch(typeof(Handlers.Scp079), nameof(Handlers.Scp079.Pinging))] + [EventPatch(typeof(Handlers.Scp079), nameof(Handlers.Scp079.RoomBlackout))] [HarmonyPatch(typeof(Scp079BlackoutRoomAbility), nameof(Scp079BlackoutRoomAbility.ServerProcessCmd))] internal static class RoomBlackout { diff --git a/Exiled.Events/Patches/Events/Scp079/TriggeringDoor.cs b/Exiled.Events/Patches/Events/Scp079/TriggeringDoor.cs index 973d0b765e..4daed3bc5c 100644 --- a/Exiled.Events/Patches/Events/Scp079/TriggeringDoor.cs +++ b/Exiled.Events/Patches/Events/Scp079/TriggeringDoor.cs @@ -29,7 +29,7 @@ namespace Exiled.Events.Patches.Events.Scp079 /// Patches . /// Adds the event for SCP-079. /// - [EventPatch(typeof(Scp079), nameof(Scp079.Pinging))] + [EventPatch(typeof(Scp079), nameof(Scp079.TriggeringDoor))] [HarmonyPatch(typeof(Scp079DoorStateChanger), nameof(Scp079DoorStateChanger.ServerProcessCmd))] internal static class TriggeringDoor { diff --git a/Exiled.Events/Patches/Events/Scp079/ZoneBlackout.cs b/Exiled.Events/Patches/Events/Scp079/ZoneBlackout.cs index aff15d424b..f2efc4af60 100644 --- a/Exiled.Events/Patches/Events/Scp079/ZoneBlackout.cs +++ b/Exiled.Events/Patches/Events/Scp079/ZoneBlackout.cs @@ -27,7 +27,7 @@ namespace Exiled.Events.Patches.Events.Scp079 /// Patches . /// Adds the event for SCP-079. /// - [EventPatch(typeof(Handlers.Scp079), nameof(Handlers.Scp079.Pinging))] + [EventPatch(typeof(Handlers.Scp079), nameof(Handlers.Scp079.ZoneBlackout))] [HarmonyPatch(typeof(Scp079BlackoutZoneAbility), nameof(Scp079BlackoutZoneAbility.ServerProcessCmd))] internal static class ZoneBlackout { From 7116059f6e6dd8d41c5ca1dca236dd09273d8608 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Wed, 11 Oct 2023 23:09:47 +0200 Subject: [PATCH 078/207] No Fix --- Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs | 5 ++++- Exiled.Events/Patches/Events/Scp079/ZoneBlackout.cs | 7 ++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs b/Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs index 41942e2d83..388ab83a54 100644 --- a/Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs +++ b/Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs @@ -94,7 +94,7 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable x.opcode == OpCodes.Brfalse_S) + offset; - Log.Info($"ZoneBlackout {index}"); // remove "this.ErrorCode" newInstructions.RemoveRange(index, 2); @@ -90,7 +89,6 @@ private static IEnumerable Transpiler(IEnumerable x.opcode == OpCodes.Ret) + offset; - Log.Info($"ZoneBlackout {index}"); newInstructions.InsertRange( index, @@ -109,7 +107,6 @@ private static IEnumerable Transpiler(IEnumerable instruction.operand == (object)Field(typeof(Scp079BlackoutZoneAbility), nameof(Scp079BlackoutZoneAbility._duration))) + offset; - Log.Info($"ZoneBlackout {index}"); newInstructions.RemoveRange(index, 2); @@ -127,7 +124,7 @@ private static IEnumerable Transpiler(IEnumerable instruction.operand == (object)Field(typeof(Scp079BlackoutZoneAbility), nameof(Scp079BlackoutZoneAbility._cooldown))) + offset; - Log.Info($"ZoneBlackout {index}"); + newInstructions.RemoveRange(index, 2); newInstructions.InsertRange( @@ -144,7 +141,7 @@ private static IEnumerable Transpiler(IEnumerable instruction.operand == (object)Field(typeof(Scp079BlackoutZoneAbility), nameof(Scp079BlackoutZoneAbility._cost))) + offset; - Log.Info($"ZoneBlackout {index}"); + newInstructions.RemoveRange(index, 3); newInstructions.InsertRange( From 800277dcd0fd0073efea64dc62a50167b1e87d88 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Wed, 11 Oct 2023 23:27:23 +0200 Subject: [PATCH 079/207] Fix ILCode Error --- Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs | 7 ++----- Exiled.Events/Patches/Events/Scp079/ZoneBlackout.cs | 5 +---- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs b/Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs index 388ab83a54..691e965581 100644 --- a/Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs +++ b/Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs @@ -73,11 +73,11 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Date: Wed, 11 Oct 2023 23:29:11 +0200 Subject: [PATCH 080/207] Callvirt --- Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs b/Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs index 691e965581..0f5ea3e37e 100644 --- a/Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs +++ b/Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs @@ -77,7 +77,7 @@ private static IEnumerable Transpiler(IEnumerable Date: Thu, 12 Oct 2023 00:06:23 +0200 Subject: [PATCH 081/207] No needed it's not bool Prefix --- Exiled.Events/Patches/Fixes/KillPlayer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.Events/Patches/Fixes/KillPlayer.cs b/Exiled.Events/Patches/Fixes/KillPlayer.cs index 9772b85b60..cded0dee06 100644 --- a/Exiled.Events/Patches/Fixes/KillPlayer.cs +++ b/Exiled.Events/Patches/Fixes/KillPlayer.cs @@ -28,7 +28,7 @@ namespace Exiled.Events.Patches.Fixes [HarmonyPatch(typeof(PlayerStats), nameof(PlayerStats.KillPlayer))] internal class KillPlayer { - private static void Prefix(PlayerStats __instance, ref DamageHandlerBase handler) // TODO: Transpiler + private static void Prefix(PlayerStats __instance, ref DamageHandlerBase handler) { if (!DamageHandlers.IdsByTypeHash.ContainsKey(handler.GetType().FullName.GetStableHashCode())) { From 3ec3d38cab71a3c437f64819a13afe2fe0e9918e Mon Sep 17 00:00:00 2001 From: louis1706 Date: Thu, 12 Oct 2023 15:18:12 +0200 Subject: [PATCH 082/207] Failed instead of return --- .../EventArgs/Scp049/ActivatingSenseEventArgs.cs | 4 ++-- Exiled.Events/Handlers/Internal/Round.cs | 12 ++++++++++++ .../Patches/Events/Scp049/ActivatingSense.cs | 14 ++++++-------- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs b/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs index 9c38f0a70c..af082d17ce 100644 --- a/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs @@ -44,9 +44,9 @@ public ActivatingSenseEventArgs(Player player, Player target, bool isAllowed = t public Player Player { get; } /// - /// Gets the Player who the sense ability is affecting. + /// Gets or sets the Player who the sense ability is affecting. /// - public Player Target { get; } + public Player Target { get; set; } /// /// Gets or sets the cooldown of the ability. diff --git a/Exiled.Events/Handlers/Internal/Round.cs b/Exiled.Events/Handlers/Internal/Round.cs index 29ca9dd6f4..bf2cd3fcbf 100644 --- a/Exiled.Events/Handlers/Internal/Round.cs +++ b/Exiled.Events/Handlers/Internal/Round.cs @@ -10,6 +10,7 @@ namespace Exiled.Events.Handlers.Internal using Exiled.API.Features; using Exiled.API.Features.Roles; using Exiled.Events.EventArgs.Player; + using Exiled.Events.EventArgs.Scp049; using Exiled.Loader; using Exiled.Loader.Features; @@ -64,6 +65,17 @@ public static void OnChangingRole(ChangingRoleEventArgs ev) ev.Player.Inventory.ServerDropEverything(); } + /// + public static void OnActivatingSense(ActivatingSenseEventArgs ev) + { + if (!Events.Instance.Config.CanScp049SenseTutorial || ev.Target.Role.Type is not RoleTypeId.Tutorial) + return; + if (ev.Player.Role.As().SenseAbility.CanFindTarget(out ReferenceHub hub)) + ev.Target = Player.Get(hub); + else + ev.Target = null; + } + /// public static void OnVerified(VerifiedEventArgs ev) { diff --git a/Exiled.Events/Patches/Events/Scp049/ActivatingSense.cs b/Exiled.Events/Patches/Events/Scp049/ActivatingSense.cs index 0bf2739c1b..71b70670ba 100644 --- a/Exiled.Events/Patches/Events/Scp049/ActivatingSense.cs +++ b/Exiled.Events/Patches/Events/Scp049/ActivatingSense.cs @@ -29,21 +29,21 @@ namespace Exiled.Events.Patches.Events.Scp049 /// Patches . /// Adds the event. /// - [EventPatch(typeof(Handlers.Scp049), nameof(Handlers.Scp049.ActivatingSense))] [HarmonyPatch(typeof(Scp049SenseAbility), nameof(Scp049SenseAbility.ServerProcessCmd))] public class ActivatingSense { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) { List newInstructions = ListPool.Pool.Get(instructions); + int offset = 2; + int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Ldnull) + offset; + Label failedLabel = (Label)newInstructions[index].operand; - int offset = 1; - int index = newInstructions.FindIndex(instruction => instruction.operand == (object)PropertySetter(typeof(Scp049SenseAbility), nameof(Scp049SenseAbility.Target))) + offset; + offset = 1; + index = newInstructions.FindIndex(instruction => instruction.operand == (object)PropertySetter(typeof(Scp049SenseAbility), nameof(Scp049SenseAbility.Target))) + offset; LocalBuilder ev = generator.DeclareLocal(typeof(FinishingRecallEventArgs)); - Label returnLabel = generator.DefineLabel(); - newInstructions.InsertRange( index, new CodeInstruction[] @@ -73,7 +73,7 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Date: Thu, 12 Oct 2023 15:58:19 +0200 Subject: [PATCH 083/207] CanScp049SenseTutorial Patch --- .../Patches/Generic/CanScp049SenseTutorial.cs | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 Exiled.Events/Patches/Generic/CanScp049SenseTutorial.cs diff --git a/Exiled.Events/Patches/Generic/CanScp049SenseTutorial.cs b/Exiled.Events/Patches/Generic/CanScp049SenseTutorial.cs new file mode 100644 index 0000000000..cc9d847968 --- /dev/null +++ b/Exiled.Events/Patches/Generic/CanScp049SenseTutorial.cs @@ -0,0 +1,82 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Generic +{ + using System.Collections.Generic; + using System.Reflection.Emit; + + using API.Features; + using API.Features.Pools; + + using HarmonyLib; + + using PlayerRoles; + using PlayerRoles.PlayableScps.Scp049; + + using static HarmonyLib.AccessTools; + + using ExiledEvents = Exiled.Events.Events; + + /// + /// Patches . + /// . + /// + [HarmonyPatch(typeof(Scp049SenseAbility), nameof(Scp049SenseAbility.CanFindTarget))] + internal static class CanScp049SenseTutorial + { + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) + { + List newInstructions = ListPool.Pool.Get(instructions); + + int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Brfalse); + + Label returnLabel = (Label)newInstructions[index].operand; + Label skip = generator.DefineLabel(); + Label continueLabel = generator.DefineLabel(); + + index += 1; + + newInstructions[index].labels.Add(continueLabel); + + // if ((referenceHub.roleManager.CurrentRole.RoleTypeId == RoleTypeId.Tutorial && ExiledEvents.Instance.Config.CanScp049SenseTutorial) || Scp049Role.TurnedPlayers.Contains(Player.Get(referenceHub))) + // return; + newInstructions.InsertRange( + index, + new[] + { + // if (referenceHub.roleManager.CurrentRole.RoleTypeId == RoleTypeId.Tutorial) + new(OpCodes.Ldloca_S, 6), + new(OpCodes.Ldfld, Field(typeof(ReferenceHub), nameof(ReferenceHub.roleManager))), + new(OpCodes.Callvirt, PropertyGetter(typeof(PlayerRoleManager), nameof(PlayerRoleManager.CurrentRole))), + new(OpCodes.Callvirt, PropertyGetter(typeof(PlayerRoleBase), nameof(PlayerRoleBase.RoleTypeId))), + new(OpCodes.Ldc_I4_S, (sbyte)RoleTypeId.Tutorial), + new(OpCodes.Bne_Un_S, skip), + + // if (!ExiledEvents.Instance.Config.CanScp049SenseTutorial) + new(OpCodes.Call, PropertyGetter(typeof(ExiledEvents), nameof(ExiledEvents.Instance))), + new(OpCodes.Callvirt, PropertyGetter(typeof(Plugin), nameof(Plugin.Config))), + new(OpCodes.Callvirt, PropertyGetter(typeof(Config), nameof(Config.CanScp049SenseTutorial))), + new(OpCodes.Brfalse_S, returnLabel), + + // if (Scp049Role.TurnedPlayers.Contains(Player.Get(referenceHub))) + new CodeInstruction(OpCodes.Call, PropertyGetter(typeof(API.Features.Roles.Scp049Role), nameof(API.Features.Roles.Scp049Role.TurnedPlayers))).WithLabels(skip), + new(OpCodes.Ldloca_S, 6), + new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), + new(OpCodes.Callvirt, Method(typeof(HashSet), nameof(HashSet.Contains))), + new(OpCodes.Brtrue_S, returnLabel), + }); + + newInstructions[newInstructions.Count - 1].WithLabels(returnLabel); + + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; + + ListPool.Pool.Return(newInstructions); + } + } +} \ No newline at end of file From f558661b26075c583d8f9f161de84c2f5f4f876e Mon Sep 17 00:00:00 2001 From: louis1706 Date: Thu, 12 Oct 2023 16:00:28 +0200 Subject: [PATCH 084/207] miss register event --- Exiled.Events/Events.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Exiled.Events/Events.cs b/Exiled.Events/Events.cs index 707d55beac..70fffe8bde 100644 --- a/Exiled.Events/Events.cs +++ b/Exiled.Events/Events.cs @@ -64,6 +64,7 @@ public override void OnEnabled() Handlers.Server.RestartingRound += Handlers.Internal.Round.OnRestartingRound; Handlers.Server.RoundStarted += Handlers.Internal.Round.OnRoundStarted; Handlers.Player.ChangingRole += Handlers.Internal.Round.OnChangingRole; + Handlers.Scp049.ActivatingSense += Handlers.Internal.Round.OnActivatingSense; Handlers.Player.Verified += Handlers.Internal.Round.OnVerified; Handlers.Map.ChangedIntoGrenade += Handlers.Internal.ExplodingGrenade.OnChangedIntoGrenade; @@ -94,6 +95,7 @@ public override void OnDisabled() Handlers.Server.RestartingRound -= Handlers.Internal.Round.OnRestartingRound; Handlers.Server.RoundStarted -= Handlers.Internal.Round.OnRoundStarted; Handlers.Player.ChangingRole -= Handlers.Internal.Round.OnChangingRole; + Handlers.Scp049.ActivatingSense -= Handlers.Internal.Round.OnActivatingSense; Handlers.Player.Verified -= Handlers.Internal.Round.OnVerified; Handlers.Map.ChangedIntoGrenade -= Handlers.Internal.ExplodingGrenade.OnChangedIntoGrenade; From fecc67807479dd154346f67957dbe675e92f9e19 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Thu, 12 Oct 2023 16:01:51 +0200 Subject: [PATCH 085/207] . --- Exiled.Events/Handlers/Internal/Round.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.Events/Handlers/Internal/Round.cs b/Exiled.Events/Handlers/Internal/Round.cs index bf2cd3fcbf..ded2dfd2f9 100644 --- a/Exiled.Events/Handlers/Internal/Round.cs +++ b/Exiled.Events/Handlers/Internal/Round.cs @@ -70,7 +70,7 @@ public static void OnActivatingSense(ActivatingSenseEventArgs ev) { if (!Events.Instance.Config.CanScp049SenseTutorial || ev.Target.Role.Type is not RoleTypeId.Tutorial) return; - if (ev.Player.Role.As().SenseAbility.CanFindTarget(out ReferenceHub hub)) + if (ev.Scp049.SenseAbility.CanFindTarget(out ReferenceHub hub)) ev.Target = Player.Get(hub); else ev.Target = null; From d5bd9e312458c254bb07e1277916aa6c18ee4768 Mon Sep 17 00:00:00 2001 From: Nao <60253860+NaoUnderscore@users.noreply.github.com> Date: Fri, 13 Oct 2023 15:31:16 +0200 Subject: [PATCH 086/207] Fix typos --- Exiled.API/Features/Player.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 9651025fd1..b6c4175ec5 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -2785,7 +2785,7 @@ public bool EnableEffect(EffectType type, byte intensity, float duration = 0f, b public void EnableEffect(Effect effect) => SyncEffect(effect); /// - /// Sync the status effect on the player. + /// Syncs the status effect on the player. /// /// The to sync. public void SyncEffect(Effect effect) @@ -2851,7 +2851,7 @@ public void EnableEffects(IEnumerable types, float duration = 0f, bo public void EnableEffects(IEnumerable effects) => SyncEffects(effects); /// - /// Sync a of on the player. + /// Syncs a of on the player. /// /// The of to enable. public void SyncEffects(IEnumerable effects) From 98c4b3527c6988ba2290552340de2b388dda3a8f Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sat, 14 Oct 2023 02:05:07 +0200 Subject: [PATCH 087/207] DecontaminationFeatures --- Exiled.API/Enums/DecontaminationState.cs | 61 +++++++++++++++++++ Exiled.API/Features/Map.cs | 5 ++ .../Map/AnnouncingDecontaminationEventArgs.cs | 22 +++++-- .../Events/Map/AnnouncingDecontamination.cs | 5 +- 4 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 Exiled.API/Enums/DecontaminationState.cs diff --git a/Exiled.API/Enums/DecontaminationState.cs b/Exiled.API/Enums/DecontaminationState.cs new file mode 100644 index 0000000000..f4e28531be --- /dev/null +++ b/Exiled.API/Enums/DecontaminationState.cs @@ -0,0 +1,61 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.API.Enums +{ + using System; + + using Features; + + /// + /// Represents the state of a . + /// + /// + [Flags] + public enum DecontaminationState + { + /// + /// Decontamination is disable. + /// + Disabled = -1, + + /// + /// Decontamination has started. + /// + Start, + + /// + /// It's remain 10 minutes. + /// + Remain10Minutes, + + /// + /// It's remain 5 minutes. + /// + Remain5Minutes, + + /// + /// It's remain 1 minutes. + /// + Remain1Minute, + + /// + /// It's remain 30 seconds. + /// + Countdown, + + /// + /// All doors is closed lock. + /// + Lockdown, + + /// + /// The decontamination has been done. + /// + Finish, + } +} \ No newline at end of file diff --git a/Exiled.API/Features/Map.cs b/Exiled.API/Features/Map.cs index cfa1562e91..5837e70409 100644 --- a/Exiled.API/Features/Map.cs +++ b/Exiled.API/Features/Map.cs @@ -108,6 +108,11 @@ public static Scp939AmnesticCloudInstance AmnesticCloudPrefab /// public static bool IsLczDecontaminated => DecontaminationController.Singleton.IsDecontaminating; + /// + /// Gets a value indicating whether decontamination phase is in the light containment zone. + /// + public static DecontaminationState DecontaminationState => (DecontaminationState)DecontaminationController.Singleton._nextPhase; + /// /// Gets all objects. /// diff --git a/Exiled.Events/EventArgs/Map/AnnouncingDecontaminationEventArgs.cs b/Exiled.Events/EventArgs/Map/AnnouncingDecontaminationEventArgs.cs index ff3b9d6c76..363a9229e9 100644 --- a/Exiled.Events/EventArgs/Map/AnnouncingDecontaminationEventArgs.cs +++ b/Exiled.Events/EventArgs/Map/AnnouncingDecontaminationEventArgs.cs @@ -7,8 +7,11 @@ namespace Exiled.Events.EventArgs.Map { + using Exiled.API.Enums; using Exiled.Events.EventArgs.Interfaces; + using static LightContainmentZoneDecontamination.DecontaminationController.DecontaminationPhase; + /// /// Contains all information before C.A.S.S.I.E announces light containment zone decontamination. /// @@ -20,13 +23,14 @@ public class AnnouncingDecontaminationEventArgs : IExiledEvent /// /// /// - /// - /// + /// + /// /// - public AnnouncingDecontaminationEventArgs(int announcementId, bool isGlobal) + public AnnouncingDecontaminationEventArgs(int announcementId, PhaseFunction phaseFunction) { Id = announcementId; - IsGlobal = isGlobal; + PhaseFunction = phaseFunction; + IsGlobal = PhaseFunction is PhaseFunction.GloballyAudible; } /// @@ -34,6 +38,16 @@ public AnnouncingDecontaminationEventArgs(int announcementId, bool isGlobal) /// public int Id { get; } + /// + /// Gets the announcement id, from 0 to 6. + /// + public DecontaminationState State => (DecontaminationState)Id; + + /// + /// Gets a value indicating whether the action will be. + /// + public PhaseFunction PhaseFunction { get; } + /// /// Gets a value indicating whether the announcement is going to be global or not. /// diff --git a/Exiled.Events/Patches/Events/Map/AnnouncingDecontamination.cs b/Exiled.Events/Patches/Events/Map/AnnouncingDecontamination.cs index b25fafcd75..556d8e7151 100644 --- a/Exiled.Events/Patches/Events/Map/AnnouncingDecontamination.cs +++ b/Exiled.Events/Patches/Events/Map/AnnouncingDecontamination.cs @@ -42,8 +42,9 @@ private static IEnumerable Transpiler(IEnumerable Date: Sat, 14 Oct 2023 02:08:24 +0200 Subject: [PATCH 088/207] it's also global when final --- .../EventArgs/Map/AnnouncingDecontaminationEventArgs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.Events/EventArgs/Map/AnnouncingDecontaminationEventArgs.cs b/Exiled.Events/EventArgs/Map/AnnouncingDecontaminationEventArgs.cs index 363a9229e9..56949b40d2 100644 --- a/Exiled.Events/EventArgs/Map/AnnouncingDecontaminationEventArgs.cs +++ b/Exiled.Events/EventArgs/Map/AnnouncingDecontaminationEventArgs.cs @@ -30,7 +30,7 @@ public AnnouncingDecontaminationEventArgs(int announcementId, PhaseFunction phas { Id = announcementId; PhaseFunction = phaseFunction; - IsGlobal = PhaseFunction is PhaseFunction.GloballyAudible; + IsGlobal = PhaseFunction is PhaseFunction.GloballyAudible or PhaseFunction.Final; } /// From 0a5b883e34ea949e1d733b55314aacc1e777b912 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sat, 14 Oct 2023 02:14:44 +0200 Subject: [PATCH 089/207] Fix --- Exiled.API/Features/Map.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Exiled.API/Features/Map.cs b/Exiled.API/Features/Map.cs index 5837e70409..142c4f88be 100644 --- a/Exiled.API/Features/Map.cs +++ b/Exiled.API/Features/Map.cs @@ -111,7 +111,9 @@ public static Scp939AmnesticCloudInstance AmnesticCloudPrefab /// /// Gets a value indicating whether decontamination phase is in the light containment zone. /// - public static DecontaminationState DecontaminationState => (DecontaminationState)DecontaminationController.Singleton._nextPhase; + public static DecontaminationState DecontaminationState => + DecontaminationController.Singleton.NetworkDecontaminationOverride is DecontaminationController.DecontaminationStatus.Disabled ? + DecontaminationState.Disabled : (DecontaminationState)DecontaminationController.Singleton._nextPhase; /// /// Gets all objects. From 19d03bc45cb6895bed63b11db55f1737a1d7f61c Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sat, 14 Oct 2023 11:31:52 +0200 Subject: [PATCH 090/207] LazyFix --- Exiled.Events/Patches/Events/Item/JailbirdPatch.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Exiled.Events/Patches/Events/Item/JailbirdPatch.cs b/Exiled.Events/Patches/Events/Item/JailbirdPatch.cs index 1f342866a1..15f8a0980b 100644 --- a/Exiled.Events/Patches/Events/Item/JailbirdPatch.cs +++ b/Exiled.Events/Patches/Events/Item/JailbirdPatch.cs @@ -88,8 +88,13 @@ private static bool HandleJailbird(JailbirdItem instance, JailbirdMessageType me ChargingJailbirdEventArgs ev = new(instance.Owner, instance); Item.OnChargingJailbird(ev); - - return ev.IsAllowed; + if (ev.IsAllowed) + return true; + instance.SendRpc(JailbirdMessageType.ChargeStarted, wr => + { + wr.WriteDouble(instance._chargeResetTime); + }); + return false; } default: From ad7e5a5f7938fd5e88d67a53737a9f7616553ef6 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sat, 14 Oct 2023 11:32:36 +0200 Subject: [PATCH 091/207] 0 --- Exiled.Events/Patches/Events/Item/JailbirdPatch.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.Events/Patches/Events/Item/JailbirdPatch.cs b/Exiled.Events/Patches/Events/Item/JailbirdPatch.cs index 15f8a0980b..da7b221f1c 100644 --- a/Exiled.Events/Patches/Events/Item/JailbirdPatch.cs +++ b/Exiled.Events/Patches/Events/Item/JailbirdPatch.cs @@ -92,7 +92,7 @@ private static bool HandleJailbird(JailbirdItem instance, JailbirdMessageType me return true; instance.SendRpc(JailbirdMessageType.ChargeStarted, wr => { - wr.WriteDouble(instance._chargeResetTime); + wr.WriteDouble(0); }); return false; } From 6d4431e1fdba12eccb219f14ed719604a276ff5b Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sat, 14 Oct 2023 11:44:26 +0200 Subject: [PATCH 092/207] Obsolete --- Exiled.API/Extensions/MirrorExtensions.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Exiled.API/Extensions/MirrorExtensions.cs b/Exiled.API/Extensions/MirrorExtensions.cs index 0691414c42..909fa802b2 100644 --- a/Exiled.API/Extensions/MirrorExtensions.cs +++ b/Exiled.API/Extensions/MirrorExtensions.cs @@ -216,6 +216,7 @@ public static void SetName(this Player target, Player player, string name) /// Room to modify. /// Only this player can see room color. /// Light intensity multiplier to set. + [Obsolete("This features has been removed by NW", true)] public static void SetRoomLightIntensityForTargetOnly(this Room room, Player target, float multiplier) { } From 453834308e2a8059476e4193e2a8f4c83a09a449 Mon Sep 17 00:00:00 2001 From: IRacle Date: Sun, 15 Oct 2023 14:07:46 +0300 Subject: [PATCH 093/207] better --- Exiled.API/Features/Items/Firearm.cs | 25 +------------------------ Exiled.API/Features/Items/Item.cs | 6 +++--- Exiled.API/Features/Items/Scp244.cs | 14 ++++++++++---- Exiled.API/Features/Items/Scp330.cs | 8 +++++--- Exiled.API/Features/Items/Usable.cs | 6 +++--- 5 files changed, 22 insertions(+), 37 deletions(-) diff --git a/Exiled.API/Features/Items/Firearm.cs b/Exiled.API/Features/Items/Firearm.cs index 34e7e2ed39..f15aa027ef 100644 --- a/Exiled.API/Features/Items/Firearm.cs +++ b/Exiled.API/Features/Items/Firearm.cs @@ -21,6 +21,7 @@ namespace Exiled.API.Features.Items using Extensions; + using InventorySystem; using InventorySystem.Items; using InventorySystem.Items.Firearms; using InventorySystem.Items.Firearms.Attachments; @@ -559,30 +560,6 @@ public void ClearPreferences() ClearPreferences(player); } - /// - /// Creates the that based on this . - /// - /// The location to spawn the item. - /// The rotation of the item. - /// Whether the should be initially spawned. - /// The created . - public override Pickup CreatePickup(Vector3 position, Quaternion rotation = default, bool spawn = true) - { - ItemPickupBase ipb = Object.Instantiate(Base.PickupDropModel, position, rotation); - - ipb.Info = new(Type, Weight, Serial); - ipb.gameObject.transform.localScale = Scale; - - FirearmPickup pickup = Pickup.Get(ipb).As(); - - pickup.Status = Base.Status; - - if (spawn) - pickup.Spawn(); - - return pickup; - } - /// /// Clones current object. /// diff --git a/Exiled.API/Features/Items/Item.cs b/Exiled.API/Features/Items/Item.cs index 465725c529..2911a1071c 100644 --- a/Exiled.API/Features/Items/Item.cs +++ b/Exiled.API/Features/Items/Item.cs @@ -14,6 +14,7 @@ namespace Exiled.API.Features.Items using Exiled.API.Features.Pickups; using Exiled.API.Interfaces; + using InventorySystem; using InventorySystem.Items; using InventorySystem.Items.Armor; using InventorySystem.Items.Firearms.Ammo; @@ -288,10 +289,9 @@ ItemType.KeycardGuard or ItemType.KeycardJanitor or ItemType.KeycardO5 or ItemTy /// The created . public virtual Pickup CreatePickup(Vector3 position, Quaternion rotation = default, bool spawn = true) { - ItemPickupBase ipb = Object.Instantiate(Base.PickupDropModel, position, rotation); + PickupSyncInfo info = new(Type, Weight, Serial); - ipb.Info = new(Type, Weight, Serial); - ipb.gameObject.transform.localScale = Scale; + ItemPickupBase ipb = InventoryExtensions.ServerCreatePickup(Base, info, position, rotation); Base.OnRemoved(ipb); diff --git a/Exiled.API/Features/Items/Scp244.cs b/Exiled.API/Features/Items/Scp244.cs index 1aa6598353..2d41dce073 100644 --- a/Exiled.API/Features/Items/Scp244.cs +++ b/Exiled.API/Features/Items/Scp244.cs @@ -10,6 +10,8 @@ namespace Exiled.API.Features.Items using Exiled.API.Features.Pickups; using Exiled.API.Interfaces; + using InventorySystem; + using InventorySystem.Items.Pickups; using InventorySystem.Items.Usables.Scp244; using UnityEngine; @@ -61,11 +63,15 @@ public bool Primed /// The created . public override Pickup CreatePickup(Vector3 position, Quaternion rotation = default, bool spawn = true) { - Scp244Pickup pickup = (Scp244Pickup)Pickup.Get(Object.Instantiate(Base.PickupDropModel, position, rotation)); + PickupSyncInfo info = new(Type, Weight, Serial); - pickup.Info = new(Type, pickup.Weight, Serial); - pickup.State = Base._primed ? Scp244State.Active : Scp244State.Idle; - pickup.Scale = Scale; + Scp244DeployablePickup ipb = (Scp244DeployablePickup)InventoryExtensions.ServerCreatePickup(Base, info, position, rotation); + + Base.OnRemoved(ipb); + + ipb.State = Base._primed ? Scp244State.Active : Scp244State.Idle; + + Pickup pickup = Pickup.Get(ipb); if (spawn) pickup.Spawn(); diff --git a/Exiled.API/Features/Items/Scp330.cs b/Exiled.API/Features/Items/Scp330.cs index 3f4734d53b..68818f6101 100644 --- a/Exiled.API/Features/Items/Scp330.cs +++ b/Exiled.API/Features/Items/Scp330.cs @@ -12,6 +12,7 @@ namespace Exiled.API.Features.Items using Exiled.API.Features.Pickups; using Exiled.API.Interfaces; + using InventorySystem; using InventorySystem.Items; using InventorySystem.Items.Pickups; using InventorySystem.Items.Usables.Scp330; @@ -235,13 +236,14 @@ public IEnumerable DropCandy(CandyKindID type, bool dropAll = fals /// The created . public override Pickup CreatePickup(Vector3 position, Quaternion rotation = default, bool spawn = true) { - InventorySystem.Items.Usables.Scp330.Scp330Pickup ipb = (InventorySystem.Items.Usables.Scp330.Scp330Pickup)Object.Instantiate(Base.PickupDropModel, position, rotation); + PickupSyncInfo info = new(Type, Weight, Serial); - ipb.Info = new(Type, Weight, Serial); - ipb.gameObject.transform.localScale = Scale; + InventorySystem.Items.Usables.Scp330.Scp330Pickup ipb = (InventorySystem.Items.Usables.Scp330.Scp330Pickup)InventoryExtensions.ServerCreatePickup(Base, info, position, rotation); Base.OnRemoved(ipb); + ipb.NetworkExposedCandy = ExposedType; + Pickup pickup = Pickup.Get(ipb); if (spawn) diff --git a/Exiled.API/Features/Items/Usable.cs b/Exiled.API/Features/Items/Usable.cs index 963d0077d9..c6c7f1b334 100644 --- a/Exiled.API/Features/Items/Usable.cs +++ b/Exiled.API/Features/Items/Usable.cs @@ -10,6 +10,7 @@ namespace Exiled.API.Features.Items using Exiled.API.Features.Pickups; using Exiled.API.Interfaces; + using InventorySystem; using InventorySystem.Items; using InventorySystem.Items.Pickups; using InventorySystem.Items.Usables; @@ -110,10 +111,9 @@ public float RemainingCooldown /// The created . public override Pickup CreatePickup(Vector3 position, Quaternion rotation = default, bool spawn = true) { - ItemPickupBase ipb = Object.Instantiate(Base.PickupDropModel, position, rotation); + PickupSyncInfo info = new(Type, Weight, Serial); - ipb.Info = new(Type, Weight, Serial); - ipb.gameObject.transform.localScale = Scale; + ItemPickupBase ipb = InventoryExtensions.ServerCreatePickup(Base, info, position, rotation); Base.OnRemoved(ipb); From 3caacc9ae3c40c54f3d5a5a4ff25fc902684b26c Mon Sep 17 00:00:00 2001 From: Yamato <66829532+louis1706@users.noreply.github.com> Date: Sun, 15 Oct 2023 18:20:11 +0200 Subject: [PATCH 094/207] Update DecontaminationState.cs --- Exiled.API/Enums/DecontaminationState.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Exiled.API/Enums/DecontaminationState.cs b/Exiled.API/Enums/DecontaminationState.cs index f4e28531be..865a9734a4 100644 --- a/Exiled.API/Enums/DecontaminationState.cs +++ b/Exiled.API/Enums/DecontaminationState.cs @@ -15,7 +15,6 @@ namespace Exiled.API.Enums /// Represents the state of a . /// /// - [Flags] public enum DecontaminationState { /// @@ -58,4 +57,4 @@ public enum DecontaminationState /// Finish, } -} \ No newline at end of file +} From b27326f9bd366da7ca7936ba186c925fd71fc010 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Thu, 19 Oct 2023 00:54:24 +0200 Subject: [PATCH 095/207] SendStaffMessage --- Exiled.API/Features/Player.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 8d24bc3027..28d0ffc8c2 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -2112,6 +2112,28 @@ public void RemoteAdminMessage(string message, bool success = true, string plugi Sender.RaReply((pluginName ?? Assembly.GetCallingAssembly().GetName().Name) + "#" + message, success, true, string.Empty); } + /// + /// Sends a message to the player's Remote Admin Chat. + /// + /// The message to be sent. + /// Indicates whether or not the message should be highlighted as success. + /// if message was send; otherwise, . + public bool SendStaffMessage(string message, EncryptedChannelManager.EncryptedChannel channel = EncryptedChannelManager.EncryptedChannel.AdminChat) + { + return ReferenceHub.encryptedChannelManager.TrySendMessageToClient(message, channel); + } + + /// + /// Sends a message to the player's Remote Admin Chat. + /// + /// The message to be sent. + /// Indicates whether or not the message should be highlighted as success. + /// if message was send; otherwise, . + public bool SendStaffPing(string message, EncryptedChannelManager.EncryptedChannel channel = EncryptedChannelManager.EncryptedChannel.AdminChat) + { + return ReferenceHub.encryptedChannelManager.TrySendMessageToClient("!0" + message, channel); + } + /// /// Shows a broadcast to the player. Doesn't get logged to the console and can be monospaced. /// From b237a596a013652a406f0015119c134399e43348 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Thu, 19 Oct 2023 00:57:38 +0200 Subject: [PATCH 096/207] Idk if this is needed --- Exiled.API/Features/Player.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 28d0ffc8c2..adaa70cfa4 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -2120,7 +2120,7 @@ public void RemoteAdminMessage(string message, bool success = true, string plugi /// if message was send; otherwise, . public bool SendStaffMessage(string message, EncryptedChannelManager.EncryptedChannel channel = EncryptedChannelManager.EncryptedChannel.AdminChat) { - return ReferenceHub.encryptedChannelManager.TrySendMessageToClient(message, channel); + return ReferenceHub.encryptedChannelManager.TrySendMessageToClient("!0" + message, channel); } /// From fa9f1256a1557629906192059ea4ac709f3f9db9 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Thu, 19 Oct 2023 18:52:34 +0200 Subject: [PATCH 097/207] autommatically find exiled version --- Exiled.Loader/Loader.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Exiled.Loader/Loader.cs b/Exiled.Loader/Loader.cs index 5ac5099853..62436b7ced 100644 --- a/Exiled.Loader/Loader.cs +++ b/Exiled.Loader/Loader.cs @@ -225,7 +225,7 @@ public static IPlugin CreatePlugin(Assembly assembly) Log.Debug($"Instantiated type {type.FullName}"); - if (CheckPluginRequiredExiledVersion(plugin)) + if (CheckPluginRequiredExiledVersion(plugin, assembly.GetReferencedAssemblies()?.FirstOrDefault(x => x?.Name is "Exiled.Loader")?.Version ?? new())) continue; return plugin; @@ -439,12 +439,12 @@ private static bool IsDerivedFromPlugin(Type type) return false; } - private static bool CheckPluginRequiredExiledVersion(IPlugin plugin) + private static bool CheckPluginRequiredExiledVersion(IPlugin plugin, Version pluginVersion) { if (plugin.IgnoreRequiredVersionCheck) return false; - Version requiredVersion = plugin.RequiredExiledVersion; + Version requiredVersion = plugin.RequiredExiledVersion == default ? pluginVersion : pluginVersion; Version actualVersion = Version; // Check Major version From f0ba2944ad4a7205a47e0d30957ff8eca62f8323 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sat, 21 Oct 2023 21:27:35 +0200 Subject: [PATCH 098/207] Fix Crash null string --- Exiled.API/Features/Player.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 7c12d70585..518c99557d 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -2561,6 +2561,7 @@ public void ThrowItem(Throwable throwable, bool fullForce = true) /// The duration the text will be on screen. public void ShowHint(string message, float duration = 3f) { + message ??= string.Empty; HintDisplay.Show(new TextHint(message, new HintParameter[] { new StringHintParameter(message) }, null, duration)); } From 3dce27e6aa8176c93e9c8f20c8685f43530735f6 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Mon, 23 Oct 2023 00:16:03 +0200 Subject: [PATCH 099/207] Fix ILError --- Exiled.Events/Patches/Events/Player/Kicking.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Exiled.Events/Patches/Events/Player/Kicking.cs b/Exiled.Events/Patches/Events/Player/Kicking.cs index 95d1723150..070314e0ad 100644 --- a/Exiled.Events/Patches/Events/Player/Kicking.cs +++ b/Exiled.Events/Patches/Events/Player/Kicking.cs @@ -47,7 +47,7 @@ private static IEnumerable Transpiler(IEnumerable x.opcode == OpCodes.Ldstr).operand), @@ -71,7 +71,7 @@ private static IEnumerable Transpiler(IEnumerable Date: Mon, 23 Oct 2023 01:13:29 +0200 Subject: [PATCH 100/207] Fix Skill Issue from someone else - /* */ will need to be removed when the other method will be deleted --- Exiled.API/Features/Toys/Primitive.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Exiled.API/Features/Toys/Primitive.cs b/Exiled.API/Features/Toys/Primitive.cs index be024200d3..b27db955da 100644 --- a/Exiled.API/Features/Toys/Primitive.cs +++ b/Exiled.API/Features/Toys/Primitive.cs @@ -107,7 +107,7 @@ public static Primitive Create(PrimitiveType primitiveType = PrimitiveType.Spher /// Whether or not the should be initially spawned. /// The color of the . /// The new . - public static Primitive Create(Vector3? position = null, Vector3? rotation = null, Vector3? scale = null, bool spawn = true, Color? color = null) + public static Primitive Create(Vector3? position /*= null*/, Vector3? rotation /*= null*/, Vector3? scale /*= null*/, bool spawn /*= true*/, Color? color /*= null*/) { Primitive primitive = new(Object.Instantiate(ToysHelper.PrimitiveBaseObject)); @@ -134,7 +134,7 @@ public static Primitive Create(Vector3? position = null, Vector3? rotation = nul /// Whether or not the should be initially spawned. /// The color of the . /// The new . - public static Primitive Create(PrimitiveType primitiveType = PrimitiveType.Sphere, Vector3? position = null, Vector3? rotation = null, Vector3? scale = null, bool spawn = true, Color? color = null) + public static Primitive Create(PrimitiveType primitiveType /*= PrimitiveType.Sphere*/, Vector3? position /*= null*/, Vector3? rotation /*= null*/, Vector3? scale /*= null*/, bool spawn /*= true*/, Color? color /*= null*/) { Primitive primitive = new(Object.Instantiate(ToysHelper.PrimitiveBaseObject)); From 53da1939ef99368ce840210204f3d42acc5a838f Mon Sep 17 00:00:00 2001 From: louis1706 Date: Mon, 23 Oct 2023 20:36:55 +0200 Subject: [PATCH 101/207] Obsolete value instead of deleting them --- Exiled.API/Features/Items/Armor.cs | 9 +++- Exiled.API/Features/Items/Firearm.cs | 10 ++++ Exiled.API/Features/Pickups/Pickup.cs | 15 ++++++ .../Pickups/Projectiles/Projectile.cs | 19 ++++++- Exiled.API/Features/Player.cs | 54 +++++++++++++++++++ .../Map/ChangedIntoGrenadeEventArgs.cs | 10 +++- 6 files changed, 111 insertions(+), 6 deletions(-) diff --git a/Exiled.API/Features/Items/Armor.cs b/Exiled.API/Features/Items/Armor.cs index f2d38add0c..450baa3849 100644 --- a/Exiled.API/Features/Items/Armor.cs +++ b/Exiled.API/Features/Items/Armor.cs @@ -132,9 +132,14 @@ public float StaminaUseMultiplier } /// - /// Gets how much the users movement speed should be affected when wearing this armor. (higher values = slower movement). + /// Gets or sets how much the users movement speed should be affected when wearing this armor. (higher values = slower movement). /// - public float MovementSpeedMultiplier { get; } + public float MovementSpeedMultiplier + { + get => Base.MovementSpeedMultiplier; + [Obsolete("This Setter was causing desync to client", true)] + set => _ = value; + } /// /// Gets how much worse and s are affected by wearing this armor. diff --git a/Exiled.API/Features/Items/Firearm.cs b/Exiled.API/Features/Items/Firearm.cs index f15aa027ef..5f9857a3f1 100644 --- a/Exiled.API/Features/Items/Firearm.cs +++ b/Exiled.API/Features/Items/Firearm.cs @@ -365,6 +365,16 @@ public void RemoveAttachment(IEnumerable attachmentSlots) /// public void ClearAttachments() => Base.ApplyAttachmentsCode(BaseCode, true); + /// + /// Creates the that based on this . + /// + /// The location to spawn the item. + /// The rotation of the item. + /// Whether the should be initially spawned. + /// The created . + public override Pickup CreatePickup(Vector3 position, Quaternion rotation = default, bool spawn = true) + => base.CreatePickup(position, rotation, spawn); // TODO: Deleted this overide + /// /// Gets a of the specified . /// diff --git a/Exiled.API/Features/Pickups/Pickup.cs b/Exiled.API/Features/Pickups/Pickup.cs index 1d255fe9cd..37308ff80e 100644 --- a/Exiled.API/Features/Pickups/Pickup.cs +++ b/Exiled.API/Features/Pickups/Pickup.cs @@ -7,6 +7,7 @@ namespace Exiled.API.Features.Pickups { + using System; using System.Collections.Generic; using System.Linq; @@ -34,6 +35,7 @@ namespace Exiled.API.Features.Pickups using BaseScp1576Pickup = InventorySystem.Items.Usables.Scp1576.Scp1576Pickup; using BaseScp2176Projectile = InventorySystem.Items.ThrowableProjectiles.Scp2176Projectile; using BaseScp330Pickup = InventorySystem.Items.Usables.Scp330.Scp330Pickup; + using Object = UnityEngine.Object; /// /// A wrapper class for . @@ -493,6 +495,19 @@ public static IEnumerable Get(IEnumerable gameObjects) /// public static Pickup CreateAndSpawn(ItemType type, Vector3 position, Quaternion rotation, Player previousOwner = null) => Create(type).Spawn(position, rotation, previousOwner); + /// + /// Spawns a . + /// + /// The too spawn. + /// The position to spawn the at. + /// The rotation to spawn the . + /// An optional previous owner of the item. + /// The Spawn. + /// + [Obsolete("Use pickup.Spawn(Vector3, Quaternion, Player) instead of this", true)] + public static Pickup Spawn(Pickup pickup, Vector3 position, Quaternion rotation, Player previousOwner = null) + => pickup.Spawn(position, rotation, previousOwner); + /// /// Returns the amount of time it will take for the provided to pick up this item, based on and active status effects. /// diff --git a/Exiled.API/Features/Pickups/Projectiles/Projectile.cs b/Exiled.API/Features/Pickups/Projectiles/Projectile.cs index be9480fa3b..cd18059bc7 100644 --- a/Exiled.API/Features/Pickups/Projectiles/Projectile.cs +++ b/Exiled.API/Features/Pickups/Projectiles/Projectile.cs @@ -7,17 +7,19 @@ namespace Exiled.API.Features.Pickups.Projectiles { + using System; + using Exiled.API.Enums; using Exiled.API.Extensions; using Exiled.API.Interfaces; - using InventorySystem; using InventorySystem.Items; using InventorySystem.Items.Pickups; using InventorySystem.Items.ThrowableProjectiles; - using UnityEngine; + using Object = UnityEngine.Object; + /// /// A wrapper class for Projectile. /// @@ -92,6 +94,19 @@ internal Projectile(ItemType type) _ => throw new System.Exception($"ProjectileType does not contain a valid value : {projectiletype}"), }; + /// + /// Spawns a . + /// + /// The too spawn. + /// The position to spawn the at. + /// The rotation to spawn the . + /// Whether the should be in active state after spawn. + /// An optional previous owner of the item. + /// The Spawn. + [Obsolete("Use pickup.Spawn(Vector3, Quaternion, Player) instead of this", true)] + public static Projectile Spawn(Projectile pickup, Vector3 position, Quaternion rotation, bool shouldBeActive = true, Player previousOwner = null) + => pickup.Spawn(position, rotation, shouldBeActive, previousOwner); + /// /// Creates and spawns a . /// diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 0ed978a28d..b8920e0033 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -2211,6 +2211,16 @@ public Item AddItem(ItemType itemType) return Item.Get(Inventory.ServerAddItem(itemType)); } + /// + /// Adds an item of the specified type with default durability(ammo/charge) and no mods to the player's inventory. + /// + /// The item to be added. + /// The attachments to be added to the item. + /// The given to the player. + [Obsolete("Use AddItem(ItemType) or AddItem(FirearmType, IEnumerable)", true)] + public Item AddItem(ItemType itemType, IEnumerable identifiers = null) + => itemType.GetFirearmType() is FirearmType.None ? AddItem(itemType) : AddItem(itemType.GetFirearmType(), identifiers); + /// /// Adds an firearm of the specified type with default durability(ammo/charge) and no mods to the player's inventory. /// @@ -2257,6 +2267,17 @@ public IEnumerable AddItem(ItemType itemType, int amount) return items; } + /// + /// Adds the amount of items of the specified type with default durability(ammo/charge) and no mods to the player's inventory. + /// + /// The item to be added. + /// The amount of items to be added. + /// The attachments to be added to the item. + /// An containing the items given. + [Obsolete("Use AddItem(ItemType, int) or AddItem(FirearmType, int, IEnumerable)", true)] + public IEnumerable AddItem(ItemType itemType, int amount, IEnumerable identifiers) + => itemType.GetFirearmType() is FirearmType.None ? AddItem(itemType, amount) : AddItem(itemType.GetFirearmType(), amount, identifiers); + /// /// Adds the amount of firearms of the specified type with default durability(ammo/charge) and no mods to the player's inventory. /// @@ -2296,6 +2317,22 @@ public IEnumerable AddItem(IEnumerable items) return returnedItems; } + /// + /// Adds the list of items of the specified type with default durability(ammo/charge) and no mods to the player's inventory. + /// + /// The of and of to be added. + /// An containing the items given. + [Obsolete("Use AddItem(Dictionary>) instead of this", true)] + public IEnumerable AddItem(Dictionary> items) + { + List returnedItems = new(items.Count); + + foreach (KeyValuePair> item in items) + returnedItems.Add(AddItem(item.Key, item.Value)); + + return returnedItems; + } + /// /// Adds the list of items of the specified type with default durability(ammo/charge) and no mods to the player's inventory. /// @@ -2413,6 +2450,23 @@ public Item AddItem(ItemBase itemBase, Item item = null) return null; } + /// + /// Adds the of items to the player's inventory. + /// + /// The item to be added. + /// The amount of items to be added. + [Obsolete("Removed this method can't be functional")] + public void AddItem(Item item, int amount) => _ = item; + + /// + /// Adds the of items to the player's inventory. + /// + /// The firearm to be added. + /// The amount of items to be added. + /// The attachments to be added to the item. + [Obsolete("Removed this method can't be functional")] + public void AddItem(Firearm firearm, int amount, IEnumerable identifiers) => _ = firearm; + /// /// Adds the list of items to the player's inventory. /// diff --git a/Exiled.Events/EventArgs/Map/ChangedIntoGrenadeEventArgs.cs b/Exiled.Events/EventArgs/Map/ChangedIntoGrenadeEventArgs.cs index 525234f2a9..1de263928a 100644 --- a/Exiled.Events/EventArgs/Map/ChangedIntoGrenadeEventArgs.cs +++ b/Exiled.Events/EventArgs/Map/ChangedIntoGrenadeEventArgs.cs @@ -7,11 +7,11 @@ namespace Exiled.Events.EventArgs.Map { - using Exiled.API.Features; + using System; + using Exiled.API.Features.Pickups; using Exiled.API.Features.Pickups.Projectiles; using Exiled.Events.EventArgs.Interfaces; - using InventorySystem.Items.ThrowableProjectiles; /// @@ -39,5 +39,11 @@ public ChangedIntoGrenadeEventArgs(TimedGrenadePickup pickup, ThrownProjectile p /// Gets a value indicating the projectile that spawned. /// public Projectile Projectile { get; } + + /// + /// Gets or sets a value indicating how long the fuse of the changed grenade will be. + /// + [Obsolete("Use Projectile.Is(Projectile, out TimeGrenadeProjectile timeGrenadeProjectile) ? timeGrenadeProjectile.FuseTime : 0 instead of this", true)] + public double FuseTime { get; set; } } } From 7e9cbd6fcba98114c586d9a7b969ac89784ece81 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Mon, 23 Oct 2023 20:45:39 +0200 Subject: [PATCH 102/207] doc --- Exiled.API/Features/Pickups/Pickup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.API/Features/Pickups/Pickup.cs b/Exiled.API/Features/Pickups/Pickup.cs index 37308ff80e..d5b41bbe47 100644 --- a/Exiled.API/Features/Pickups/Pickup.cs +++ b/Exiled.API/Features/Pickups/Pickup.cs @@ -610,7 +610,7 @@ internal virtual void ReadItemInfo(Items.Item item) } /// - /// eeee. + /// initialize item properties. /// /// target item. protected virtual void InitializeProperties(ItemBase itemBase) From 7548440b96e61f9d38a4971d35fd5c90085701b7 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Tue, 24 Oct 2023 12:50:29 +0200 Subject: [PATCH 103/207] . --- EXILED.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED.props b/EXILED.props index 71ba9648bb..cffe478ed5 100644 --- a/EXILED.props +++ b/EXILED.props @@ -15,7 +15,7 @@ - 8.2.1 + 8.3.0 false From 1a6249ec0f3d296bd53070ac6eaa40403b215ae6 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Tue, 24 Oct 2023 12:51:12 +0200 Subject: [PATCH 104/207] DisableCustomConst --- .../Patches/Generic/Scp106API/CooldownReductionReward.cs | 2 +- Exiled.Events/Patches/Generic/Scp106API/CustomAttack.cs | 2 +- .../Patches/Generic/Scp106API/HunterAtlastCostPerMetter.cs | 2 +- .../Patches/Generic/Scp106API/SinkholeAbilityCooldown.cs | 2 +- Exiled.Events/Patches/Generic/Scp106API/StalkVigorUse.cs | 2 +- Exiled.Events/Patches/Generic/Scp106API/VigorRegeneration.cs | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Exiled.Events/Patches/Generic/Scp106API/CooldownReductionReward.cs b/Exiled.Events/Patches/Generic/Scp106API/CooldownReductionReward.cs index dd0e539450..28c0e36100 100644 --- a/Exiled.Events/Patches/Generic/Scp106API/CooldownReductionReward.cs +++ b/Exiled.Events/Patches/Generic/Scp106API/CooldownReductionReward.cs @@ -26,7 +26,7 @@ namespace Exiled.Events.Patches.Generic.Scp106API /// Patches . /// Adds the property. /// - [HarmonyPatch(typeof(Scp106Attack), nameof(Scp106Attack.ReduceSinkholeCooldown))] + // [HarmonyPatch(typeof(Scp106Attack), nameof(Scp106Attack.ReduceSinkholeCooldown))] internal class CooldownReductionReward { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) diff --git a/Exiled.Events/Patches/Generic/Scp106API/CustomAttack.cs b/Exiled.Events/Patches/Generic/Scp106API/CustomAttack.cs index 54fccd372b..28703e7309 100644 --- a/Exiled.Events/Patches/Generic/Scp106API/CustomAttack.cs +++ b/Exiled.Events/Patches/Generic/Scp106API/CustomAttack.cs @@ -25,7 +25,7 @@ namespace Exiled.Events.Patches.Generic.Scp106API /// Patches . /// Adds the , , property. /// - [HarmonyPatch(typeof(Scp106Attack), nameof(Scp106Attack.ServerShoot))] + // [HarmonyPatch(typeof(Scp106Attack), nameof(Scp106Attack.ServerShoot))] internal class CustomAttack { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) diff --git a/Exiled.Events/Patches/Generic/Scp106API/HunterAtlastCostPerMetter.cs b/Exiled.Events/Patches/Generic/Scp106API/HunterAtlastCostPerMetter.cs index 0fdc57feb8..1bc2c8fc1e 100644 --- a/Exiled.Events/Patches/Generic/Scp106API/HunterAtlastCostPerMetter.cs +++ b/Exiled.Events/Patches/Generic/Scp106API/HunterAtlastCostPerMetter.cs @@ -26,7 +26,7 @@ namespace Exiled.Events.Patches.Generic.Scp106API /// Patches . /// Adds the property. /// - [HarmonyPatch(typeof(Scp106HuntersAtlasAbility), nameof(Scp106HuntersAtlasAbility.ServerProcessCmd))] + // [HarmonyPatch(typeof(Scp106HuntersAtlasAbility), nameof(Scp106HuntersAtlasAbility.ServerProcessCmd))] internal class HunterAtlastCostPerMetter { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) diff --git a/Exiled.Events/Patches/Generic/Scp106API/SinkholeAbilityCooldown.cs b/Exiled.Events/Patches/Generic/Scp106API/SinkholeAbilityCooldown.cs index 120441459f..8e44ecc46e 100644 --- a/Exiled.Events/Patches/Generic/Scp106API/SinkholeAbilityCooldown.cs +++ b/Exiled.Events/Patches/Generic/Scp106API/SinkholeAbilityCooldown.cs @@ -26,7 +26,7 @@ namespace Exiled.Events.Patches.Generic.Scp106API /// Patches . /// Adds the property. /// - [HarmonyPatch(typeof(Scp106Attack), nameof(Scp106Attack.ReduceSinkholeCooldown))] + // [HarmonyPatch(typeof(Scp106Attack), nameof(Scp106Attack.ReduceSinkholeCooldown))] internal class SinkholeAbilityCooldown { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) diff --git a/Exiled.Events/Patches/Generic/Scp106API/StalkVigorUse.cs b/Exiled.Events/Patches/Generic/Scp106API/StalkVigorUse.cs index 8cdd360b27..d3334dbe2e 100644 --- a/Exiled.Events/Patches/Generic/Scp106API/StalkVigorUse.cs +++ b/Exiled.Events/Patches/Generic/Scp106API/StalkVigorUse.cs @@ -25,7 +25,7 @@ namespace Exiled.Events.Patches.Generic.Scp106API /// Patches . /// Adds the and property. /// - [HarmonyPatch(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.UpdateServerside))] + // [HarmonyPatch(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.UpdateServerside))] internal class StalkVigorUse { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) diff --git a/Exiled.Events/Patches/Generic/Scp106API/VigorRegeneration.cs b/Exiled.Events/Patches/Generic/Scp106API/VigorRegeneration.cs index 3bbe601d94..6a5eb2aa31 100644 --- a/Exiled.Events/Patches/Generic/Scp106API/VigorRegeneration.cs +++ b/Exiled.Events/Patches/Generic/Scp106API/VigorRegeneration.cs @@ -25,7 +25,7 @@ namespace Exiled.Events.Patches.Generic.Scp106API /// Patches . /// Adds the property. /// - [HarmonyPatch(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.UpdateMovementState))] + // [HarmonyPatch(typeof(Scp106StalkAbility), nameof(Scp106StalkAbility.UpdateMovementState))] internal class VigorRegeneration { private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) From 2b1ab058242b730a7660485fa6b3d386002fea9a Mon Sep 17 00:00:00 2001 From: louis1706 Date: Tue, 24 Oct 2023 13:22:49 +0200 Subject: [PATCH 105/207] . --- Exiled.Events/Patches/Events/Map/AnnouncingDecontamination.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.Events/Patches/Events/Map/AnnouncingDecontamination.cs b/Exiled.Events/Patches/Events/Map/AnnouncingDecontamination.cs index 556d8e7151..7ee1b2d1fc 100644 --- a/Exiled.Events/Patches/Events/Map/AnnouncingDecontamination.cs +++ b/Exiled.Events/Patches/Events/Map/AnnouncingDecontamination.cs @@ -46,7 +46,7 @@ private static IEnumerable Transpiler(IEnumerable Date: Tue, 24 Oct 2023 13:28:15 +0200 Subject: [PATCH 106/207] . --- Exiled.API/Features/Respawn.cs | 4 ++-- .../Patches/Events/Player/SendingAdminChatMessage.cs | 5 ++++- Exiled.Events/Patches/Events/Player/UsedItemFixNotCall.cs | 6 ------ 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Exiled.API/Features/Respawn.cs b/Exiled.API/Features/Respawn.cs index 7a2dd39b98..3367de9c3b 100644 --- a/Exiled.API/Features/Respawn.cs +++ b/Exiled.API/Features/Respawn.cs @@ -195,14 +195,14 @@ public static void SummonChaosInsurgencyVan(bool playMusic = true) /// /// The to grant tickets to. /// The amount of tickets to grant. - public static void GrantTickets(SpawnableTeamType team, float amount) => RespawnTokensManager.ModifyTokens(team, Math.Max(0, amount)); + public static void GrantTickets(SpawnableTeamType team, float amount) => RespawnTokensManager.GrantTokens(team, Math.Max(0, amount)); /// /// Removes tickets from a . /// /// The to remove tickets from. /// The amount of tickets to remove. - public static void RemoveTickets(SpawnableTeamType team, float amount) => RespawnTokensManager.ModifyTokens(team, Math.Min(0, amount)); + public static void RemoveTickets(SpawnableTeamType team, float amount) => RespawnTokensManager.RemoveTokens(team, Math.Max(0, amount)); /// /// Modify tickets from a . diff --git a/Exiled.Events/Patches/Events/Player/SendingAdminChatMessage.cs b/Exiled.Events/Patches/Events/Player/SendingAdminChatMessage.cs index cc803e23ba..6368994da4 100644 --- a/Exiled.Events/Patches/Events/Player/SendingAdminChatMessage.cs +++ b/Exiled.Events/Patches/Events/Player/SendingAdminChatMessage.cs @@ -54,7 +54,10 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Date: Tue, 24 Oct 2023 13:31:42 +0200 Subject: [PATCH 107/207] Fix --- Exiled.Events/Patches/Events/Scp106/ExitStalking.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Exiled.Events/Patches/Events/Scp106/ExitStalking.cs b/Exiled.Events/Patches/Events/Scp106/ExitStalking.cs index 9bd2c48dec..ac93ec10f4 100644 --- a/Exiled.Events/Patches/Events/Scp106/ExitStalking.cs +++ b/Exiled.Events/Patches/Events/Scp106/ExitStalking.cs @@ -74,6 +74,8 @@ 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]; From 4423850c872b78df197ab98ad9023bd6f6193e55 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Tue, 24 Oct 2023 13:33:13 +0200 Subject: [PATCH 108/207] Fix doc --- Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs b/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs index 017e7b1eb8..64e296d3cd 100644 --- a/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs +++ b/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs @@ -130,7 +130,7 @@ private static IEnumerable Transpiler(IEnumerable Date: Tue, 24 Oct 2023 19:17:35 +0200 Subject: [PATCH 109/207] not needed --- Exiled.API/Features/Npc.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Exiled.API/Features/Npc.cs b/Exiled.API/Features/Npc.cs index 58fec52709..ba6c57a284 100644 --- a/Exiled.API/Features/Npc.cs +++ b/Exiled.API/Features/Npc.cs @@ -182,8 +182,6 @@ public static Npc Spawn(string name, RoleTypeId role, int id = 0, string userId public void Destroy() { NetworkConnectionToClient conn = ReferenceHub.connectionToClient; - if (ReferenceHub._playerId.Value <= RecyclablePlayerId._autoIncrement) - ReferenceHub._playerId.Destroy(); ReferenceHub.OnDestroy(); CustomNetworkManager.TypedSingleton.OnServerDisconnect(conn); Dictionary.Remove(GameObject); From 9632cd799f9c5d80f3236807689025c6e1b364cf Mon Sep 17 00:00:00 2001 From: Yamato <66829532+louis1706@users.noreply.github.com> Date: Tue, 24 Oct 2023 22:45:52 +0200 Subject: [PATCH 110/207] Revert "Fix UsedItem event not being called (#2163)" This reverts commit 58007bc4a737a0c68ec7bef31387b5c7d354dfd3. --- .../Events/Player/UsedItemFixNotCall.cs | 115 ------------------ 1 file changed, 115 deletions(-) delete mode 100644 Exiled.Events/Patches/Events/Player/UsedItemFixNotCall.cs diff --git a/Exiled.Events/Patches/Events/Player/UsedItemFixNotCall.cs b/Exiled.Events/Patches/Events/Player/UsedItemFixNotCall.cs deleted file mode 100644 index 62f9b15b7b..0000000000 --- a/Exiled.Events/Patches/Events/Player/UsedItemFixNotCall.cs +++ /dev/null @@ -1,115 +0,0 @@ -// ----------------------------------------------------------------------- -// -// Copyright (c) Exiled Team. All rights reserved. -// Licensed under the CC BY-SA 3.0 license. -// -// ----------------------------------------------------------------------- - -namespace Exiled.Events.Patches.Events.Player -{ -#pragma warning disable SA1402 // File may only contain a single type - - using System.Collections.Generic; - using System.Reflection.Emit; - - using Exiled.API.Features; - using Exiled.API.Features.Pools; - using Exiled.Events.Attributes; - using Exiled.Events.EventArgs.Player; - using HarmonyLib; - using InventorySystem.Items.Usables; - - using static HarmonyLib.AccessTools; - - /// - /// Patches . - /// Adds the event in case of missing call. - /// - [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.UsedItem))] - [HarmonyPatch(typeof(Consumable), nameof(Consumable.EquipUpdate))] - internal class UsedItemFixNotCall - { - private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) - { - List newInstructions = ListPool.Pool.Get(instructions); - - LocalBuilder ev = generator.DeclareLocal(typeof(UsedItemEventArgs)); - - const int offset = -1; - int index = newInstructions.FindIndex(instruction => instruction.Calls(Method(typeof(Consumable), nameof(Consumable.ActivateEffects)))) + offset; - - newInstructions.InsertRange( - index, - new CodeInstruction[] - { - // Player.Get(base.Owner) - new(OpCodes.Ldarg_0), - new(OpCodes.Callvirt, PropertyGetter(typeof(Consumable), nameof(Consumable.Owner))), - new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), - - // this - new(OpCodes.Ldarg_0), - - // UsedItemEventArgs ev = new(ReferenceHub, UsableItem) - new(OpCodes.Newobj, GetDeclaredConstructors(typeof(UsedItemEventArgs))[0]), - new(OpCodes.Dup), - new(OpCodes.Dup), - new(OpCodes.Stloc_S, ev.LocalIndex), - - // Handlers.Player.OnUsedItem(ev) - new(OpCodes.Call, Method(typeof(Handlers.Player), nameof(Handlers.Player.OnUsedItem))), - }); - - for (int z = 0; z < newInstructions.Count; z++) - yield return newInstructions[z]; - - ListPool.Pool.Return(newInstructions); - } - } - - /// - /// Patches . - /// Adds the event in case of missing call. - /// - [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.UsedItem))] - [HarmonyPatch(typeof(Consumable), nameof(Consumable.OnRemoved))] - internal class UsedItem2 - { - private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) - { - List newInstructions = ListPool.Pool.Get(instructions); - - LocalBuilder ev = generator.DeclareLocal(typeof(UsedItemEventArgs)); - - const int offset = -1; - int index = newInstructions.FindIndex(instruction => instruction.Calls(Method(typeof(Consumable), nameof(Consumable.ActivateEffects)))) + offset; - - newInstructions.InsertRange( - index, - new CodeInstruction[] - { - // Player.Get(base.Owner) - new(OpCodes.Ldarg_0), - new(OpCodes.Callvirt, PropertyGetter(typeof(Consumable), nameof(Consumable.Owner))), - new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), - - // this - new(OpCodes.Ldarg_0), - - // UsedItemEventArgs ev = new(ReferenceHub, UsableItem) - new(OpCodes.Newobj, GetDeclaredConstructors(typeof(UsedItemEventArgs))[0]), - new(OpCodes.Dup), - new(OpCodes.Dup), - new(OpCodes.Stloc_S, ev.LocalIndex), - - // Handlers.Player.OnUsedItem(ev) - new(OpCodes.Call, Method(typeof(Handlers.Player), nameof(Handlers.Player.OnUsedItem))), - }); - - for (int z = 0; z < newInstructions.Count; z++) - yield return newInstructions[z]; - - ListPool.Pool.Return(newInstructions); - } - } -} From f840f1395212212d21657781a3348482916bd440 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Tue, 24 Oct 2023 23:04:41 +0200 Subject: [PATCH 111/207] Fix --- Exiled.Events/Patches/Events/Scp330/DroppingCandy.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Exiled.Events/Patches/Events/Scp330/DroppingCandy.cs b/Exiled.Events/Patches/Events/Scp330/DroppingCandy.cs index 8d10909fa5..c486982cba 100644 --- a/Exiled.Events/Patches/Events/Scp330/DroppingCandy.cs +++ b/Exiled.Events/Patches/Events/Scp330/DroppingCandy.cs @@ -102,10 +102,8 @@ private static IEnumerable Transpiler(IEnumerable instruction.operand == (object)Method(typeof(NetworkUtils), nameof(NetworkUtils.SendToAuthenticated))) + offset; - - newInstructions[index].labels.Add(returnLabel); + // before msg.SendToAuthenticated(0); + newInstructions[newInstructions.Count - 5].labels.Add(returnLabel); for (int z = 0; z < newInstructions.Count; z++) yield return newInstructions[z]; From 10d0f5f04d64d6066aa5d3c9cb8a237c60f38119 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Tue, 24 Oct 2023 23:09:28 +0200 Subject: [PATCH 112/207] . --- .../Patches/Events/Scp049/Consuming.cs | 96 ------------------- 1 file changed, 96 deletions(-) delete mode 100644 Exiled.Events/Patches/Events/Scp049/Consuming.cs diff --git a/Exiled.Events/Patches/Events/Scp049/Consuming.cs b/Exiled.Events/Patches/Events/Scp049/Consuming.cs deleted file mode 100644 index da254bfcb4..0000000000 --- a/Exiled.Events/Patches/Events/Scp049/Consuming.cs +++ /dev/null @@ -1,96 +0,0 @@ -// ----------------------------------------------------------------------- -// -// Copyright (c) Exiled Team. All rights reserved. -// Licensed under the CC BY-SA 3.0 license. -// -// ----------------------------------------------------------------------- - -namespace Exiled.Events.Patches.Events.Scp049 -{ - using System.Collections.Generic; - using System.Reflection.Emit; - - using Exiled.API.Features; - using Exiled.API.Features.Pools; - using Exiled.Events.Attributes; - using Exiled.Events.EventArgs.Scp0492; - using HarmonyLib; - using PlayerRoles.PlayableScps.Scp049; - using PlayerRoles.PlayableScps.Scp049.Zombies; - using PlayerRoles.PlayableScps.Subroutines; - using PlayerStatsSystem; - - using static HarmonyLib.AccessTools; - - /// - /// Adds the event. - /// - [EventPatch(typeof(Handlers.Scp0492), nameof(Handlers.Scp0492.ConsumingCorpse))] - [HarmonyPatch(typeof(ZombieConsumeAbility), nameof(ZombieConsumeAbility.ServerProcessCmd))] - public class Consuming - { - private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) - { - List newInstructions = ListPool.Pool.Get(instructions); - - LocalBuilder ev = generator.DeclareLocal(typeof(ConsumingCorpseEventArgs)); - - int offset = 1; - int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Ret) + offset; - - Label returnLabel = generator.DefineLabel(); - - newInstructions.InsertRange( - index, - new[] - { - // Player.Get(base.Owner) - new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]), - new(OpCodes.Call, PropertyGetter(typeof(ScpStandardSubroutine), nameof(ScpStandardSubroutine.Owner))), - new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), - - // base.CurRagdoll - new CodeInstruction(OpCodes.Ldarg_0), - new(OpCodes.Call, PropertyGetter(typeof(RagdollAbilityBase), nameof(RagdollAbilityBase.CurRagdoll))), - - // true - new(OpCodes.Ldc_I4_1), - - // ConsumingCorpseEventArgs ev = new(Player, Ragdoll, bool) - new(OpCodes.Newobj, GetDeclaredConstructors(typeof(ConsumingCorpseEventArgs))[0]), - new(OpCodes.Dup), - new(OpCodes.Dup), - new(OpCodes.Stloc_S, ev.LocalIndex), - - // Handlers.Scp049.OnSendingCall(ev) - new(OpCodes.Call, Method(typeof(Handlers.Scp0492), nameof(Handlers.Scp0492.OnConsumingCorpse))), - - // if (!ev.IsAllowed) - // return; - new(OpCodes.Callvirt, PropertyGetter(typeof(ConsumingCorpseEventArgs), nameof(ConsumingCorpseEventArgs.IsAllowed))), - new(OpCodes.Brfalse_S, returnLabel), - }); - - // replace "base.Owner.playerStats.GetModule().ServerHeal(100f)" with "base.Owner.playerStats.GetModule().ServerHeal(ev.ConsumeHeal)" - offset = -1; - index = newInstructions.FindIndex(instruction => instruction.operand == (object)Method(typeof(HealthStat), nameof(HealthStat.ServerHeal))) + offset; - newInstructions.RemoveAt(index); - - newInstructions.InsertRange( - index, - new CodeInstruction[] - { - // ev.ConsumeHeal - new(OpCodes.Ldloc_S, ev.LocalIndex), - new(OpCodes.Callvirt, PropertyGetter(typeof(ConsumingCorpseEventArgs), nameof(ConsumingCorpseEventArgs.ConsumeHeal))), - }); - - newInstructions[newInstructions.Count - 1].WithLabels(returnLabel); - - for (int z = 0; z < newInstructions.Count; z++) - yield return newInstructions[z]; - - ListPool.Pool.Return(newInstructions); - } - } -} \ No newline at end of file From 5e0dd78502db336ff07971af786dc8853ad927e7 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Tue, 24 Oct 2023 23:30:45 +0200 Subject: [PATCH 113/207] Implement Scp0492.Conssumed --- .../Scp0492/ConsumedCorpseEventArgs.cs | 54 +++++++++++ .../Scp0492/ConsumingCorpseEventArgs.cs | 13 +-- Exiled.Events/Handlers/Scp0492.cs | 11 +++ .../Patches/Events/Scp0492/Consumed.cs | 94 +++++++++++++++++++ .../Patches/Events/Scp0492/Consuming.cs | 2 +- 5 files changed, 163 insertions(+), 11 deletions(-) create mode 100644 Exiled.Events/EventArgs/Scp0492/ConsumedCorpseEventArgs.cs create mode 100644 Exiled.Events/Patches/Events/Scp0492/Consumed.cs diff --git a/Exiled.Events/EventArgs/Scp0492/ConsumedCorpseEventArgs.cs b/Exiled.Events/EventArgs/Scp0492/ConsumedCorpseEventArgs.cs new file mode 100644 index 0000000000..44a0c52bda --- /dev/null +++ b/Exiled.Events/EventArgs/Scp0492/ConsumedCorpseEventArgs.cs @@ -0,0 +1,54 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Scp0492 +{ + using System; + + using API.Features; + using Exiled.API.Features.Roles; + using Interfaces; + + using PlayerRoles.PlayableScps.Scp049.Zombies; + + /// + /// Contains all information after zombie consumes RagDolls. + /// + public class ConsumedCorpseEventArgs : IScp0492Event, IRagdollEvent + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// See for all RagDolls consumed. + public ConsumedCorpseEventArgs(ReferenceHub player, BasicRagdoll ragDoll) + { + Player = Player.Get(player); + Scp0492 = Player.Role.As(); + Ragdoll = Ragdoll.Get(ragDoll); + } + + /// + /// Gets the player who is controlling SCP-049-2. + /// + public Player Player { get; } + + /// + public Scp0492Role Scp0492 { get; } + + /// + /// Gets the RagDoll to be consumed. + /// + public Ragdoll Ragdoll { get; } + + /// + /// Gets or sets a value about how mush heath the Zombie will get. + /// + public float ConsumeHeal { get; set; } = ZombieConsumeAbility.ConsumeHeal; + } +} diff --git a/Exiled.Events/EventArgs/Scp0492/ConsumingCorpseEventArgs.cs b/Exiled.Events/EventArgs/Scp0492/ConsumingCorpseEventArgs.cs index 0c3c93053f..6f69ea4d0f 100644 --- a/Exiled.Events/EventArgs/Scp0492/ConsumingCorpseEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp0492/ConsumingCorpseEventArgs.cs @@ -7,8 +7,6 @@ namespace Exiled.Events.EventArgs.Scp0492 { - using System; - using API.Features; using Exiled.API.Features.Roles; using Interfaces; @@ -25,6 +23,7 @@ public class ConsumingCorpseEventArgs : IScp0492Event, IRagdollEvent, IDeniableE /// /// /// + /// /// /// See for all RagDolls consumed. // TODO: remove isAllowed argument @@ -41,7 +40,7 @@ public ConsumingCorpseEventArgs(ReferenceHub player, BasicRagdoll ragDoll, Zombi /// public Player Player { get; } - /// + /// public Scp0492Role Scp0492 { get; } /// @@ -49,15 +48,9 @@ public ConsumingCorpseEventArgs(ReferenceHub player, BasicRagdoll ragDoll, Zombi /// public Ragdoll Ragdoll { get; } - /// - /// Gets or sets a value about how mush heath the Zombie will get. - /// - public float ConsumeHeal { get; set; } - /// /// Gets or sets error code to send back to client. /// - [Obsolete("Removed", true)] public ZombieConsumeAbility.ConsumeError ErrorCode { get; set; } /// @@ -69,4 +62,4 @@ public bool IsAllowed set => ErrorCode = value ? ZombieConsumeAbility.ConsumeError.None : ZombieConsumeAbility.ConsumeError.TargetNotValid; } } -} +} \ No newline at end of file diff --git a/Exiled.Events/Handlers/Scp0492.cs b/Exiled.Events/Handlers/Scp0492.cs index 0509a9cab2..82ee09d8de 100644 --- a/Exiled.Events/Handlers/Scp0492.cs +++ b/Exiled.Events/Handlers/Scp0492.cs @@ -22,6 +22,11 @@ public class Scp0492 /// public static Event TriggeringBloodlust { get; set; } = new (); + /// + /// Called after 049-2 gets his benefits from consumed ability. + /// + public static Event ConsumedCorpse { get; set; } = new(); + /// /// Called before 049-2 gets his benefits from consuming ability. /// @@ -33,6 +38,12 @@ public class Scp0492 /// The instance. public static void OnTriggeringBloodlust(TriggeringBloodlustEventArgs ev) => TriggeringBloodlust.InvokeSafely(ev); + /// + /// Invokes after 049-2 gets his benefits from consumed ability. + /// + /// instance. + public static void OnConsumedCorpse(ConsumedCorpseEventArgs ev) => ConsumedCorpse.InvokeSafely(ev); + /// /// Invokes before 049-2 gets his benefits from consuming ability. /// diff --git a/Exiled.Events/Patches/Events/Scp0492/Consumed.cs b/Exiled.Events/Patches/Events/Scp0492/Consumed.cs new file mode 100644 index 0000000000..bbafe1fc35 --- /dev/null +++ b/Exiled.Events/Patches/Events/Scp0492/Consumed.cs @@ -0,0 +1,94 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Events.Scp0492 +{ + using System.Collections.Generic; + using System.Reflection.Emit; + + using API.Features.Pools; + + using Exiled.API.Extensions; + using Exiled.API.Features; + using Exiled.Events.Attributes; + using Exiled.Events.EventArgs.Scp0492; + using HarmonyLib; + using PlayerRoles.PlayableScps.Scp049; + using PlayerRoles.PlayableScps.Scp049.Zombies; + using PlayerRoles.PlayableScps.Subroutines; + using PlayerStatsSystem; + + using static HarmonyLib.AccessTools; + + /// + /// Patches + /// to add event. + /// + [EventPatch(typeof(Handlers.Scp0492), nameof(Handlers.Scp0492.ConsumedCorpse))] + [HarmonyPatch(typeof(ZombieConsumeAbility), nameof(ZombieConsumeAbility.ServerComplete))] + public class Consumed + { + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) + { + List newInstructions = ListPool.Pool.Get(instructions); + + LocalBuilder ev = generator.DeclareLocal(typeof(ConsumedCorpseEventArgs)); + + int offset = 1; + int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Ret) + offset; + + Label returnLabel = generator.DefineLabel(); + + newInstructions.InsertRange( + index, + new[] + { + // Player.Get(base.Owner) + new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]), + new(OpCodes.Call, PropertyGetter(typeof(ScpStandardSubroutine), nameof(ScpStandardSubroutine.Owner))), + new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), + + // base.CurRagdoll + new CodeInstruction(OpCodes.Ldarg_0), + new(OpCodes.Call, PropertyGetter(typeof(RagdollAbilityBase), nameof(RagdollAbilityBase.CurRagdoll))), + + // true + new(OpCodes.Ldc_I4_1), + + // ConsumingCorpseEventArgs ev = new(Player, Ragdoll, bool) + new(OpCodes.Newobj, GetDeclaredConstructors(typeof(ConsumedCorpseEventArgs))[0]), + new(OpCodes.Dup), + new(OpCodes.Dup), + new(OpCodes.Stloc_S, ev.LocalIndex), + + // Handlers.Scp049.OnSendingCall(ev) + new(OpCodes.Call, Method(typeof(Handlers.Scp0492), nameof(Handlers.Scp0492.OnConsumedCorpse))), + }); + + // replace "base.Owner.playerStats.GetModule().ServerHeal(100f)" with "base.Owner.playerStats.GetModule().ServerHeal(ev.ConsumeHeal)" + offset = -1; + index = newInstructions.FindIndex(instruction => instruction.operand == (object)Method(typeof(HealthStat), nameof(HealthStat.ServerHeal))) + offset; + newInstructions.RemoveAt(index); + + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // ev.ConsumeHeal + new(OpCodes.Ldloc_S, ev.LocalIndex), + new(OpCodes.Callvirt, PropertyGetter(typeof(ConsumedCorpseEventArgs), nameof(ConsumedCorpseEventArgs.ConsumeHeal))), + }); + + newInstructions[newInstructions.Count - 1].WithLabels(returnLabel); + + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; + + ListPool.Pool.Return(newInstructions); + } + } +} diff --git a/Exiled.Events/Patches/Events/Scp0492/Consuming.cs b/Exiled.Events/Patches/Events/Scp0492/Consuming.cs index a742a978f2..2d3320a29f 100644 --- a/Exiled.Events/Patches/Events/Scp0492/Consuming.cs +++ b/Exiled.Events/Patches/Events/Scp0492/Consuming.cs @@ -71,4 +71,4 @@ private static IEnumerable Transpiler(IEnumerable.Pool.Return(newInstructions); } } -} +} \ No newline at end of file From 497d1fd42d422bd2f32b8988c73b4c58a04db143 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Tue, 24 Oct 2023 23:31:13 +0200 Subject: [PATCH 114/207] Implement Scp0492.Conssumed --- .../Scp0492/ConsumedCorpseEventArgs.cs | 54 +++++++++++ .../Scp0492/ConsumingCorpseEventArgs.cs | 13 +-- Exiled.Events/Handlers/Scp0492.cs | 11 +++ .../Patches/Events/Scp0492/Consumed.cs | 94 +++++++++++++++++++ .../Patches/Events/Scp0492/Consuming.cs | 2 +- 5 files changed, 163 insertions(+), 11 deletions(-) create mode 100644 Exiled.Events/EventArgs/Scp0492/ConsumedCorpseEventArgs.cs create mode 100644 Exiled.Events/Patches/Events/Scp0492/Consumed.cs diff --git a/Exiled.Events/EventArgs/Scp0492/ConsumedCorpseEventArgs.cs b/Exiled.Events/EventArgs/Scp0492/ConsumedCorpseEventArgs.cs new file mode 100644 index 0000000000..44a0c52bda --- /dev/null +++ b/Exiled.Events/EventArgs/Scp0492/ConsumedCorpseEventArgs.cs @@ -0,0 +1,54 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Scp0492 +{ + using System; + + using API.Features; + using Exiled.API.Features.Roles; + using Interfaces; + + using PlayerRoles.PlayableScps.Scp049.Zombies; + + /// + /// Contains all information after zombie consumes RagDolls. + /// + public class ConsumedCorpseEventArgs : IScp0492Event, IRagdollEvent + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// See for all RagDolls consumed. + public ConsumedCorpseEventArgs(ReferenceHub player, BasicRagdoll ragDoll) + { + Player = Player.Get(player); + Scp0492 = Player.Role.As(); + Ragdoll = Ragdoll.Get(ragDoll); + } + + /// + /// Gets the player who is controlling SCP-049-2. + /// + public Player Player { get; } + + /// + public Scp0492Role Scp0492 { get; } + + /// + /// Gets the RagDoll to be consumed. + /// + public Ragdoll Ragdoll { get; } + + /// + /// Gets or sets a value about how mush heath the Zombie will get. + /// + public float ConsumeHeal { get; set; } = ZombieConsumeAbility.ConsumeHeal; + } +} diff --git a/Exiled.Events/EventArgs/Scp0492/ConsumingCorpseEventArgs.cs b/Exiled.Events/EventArgs/Scp0492/ConsumingCorpseEventArgs.cs index 0c3c93053f..6f69ea4d0f 100644 --- a/Exiled.Events/EventArgs/Scp0492/ConsumingCorpseEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp0492/ConsumingCorpseEventArgs.cs @@ -7,8 +7,6 @@ namespace Exiled.Events.EventArgs.Scp0492 { - using System; - using API.Features; using Exiled.API.Features.Roles; using Interfaces; @@ -25,6 +23,7 @@ public class ConsumingCorpseEventArgs : IScp0492Event, IRagdollEvent, IDeniableE /// /// /// + /// /// /// See for all RagDolls consumed. // TODO: remove isAllowed argument @@ -41,7 +40,7 @@ public ConsumingCorpseEventArgs(ReferenceHub player, BasicRagdoll ragDoll, Zombi /// public Player Player { get; } - /// + /// public Scp0492Role Scp0492 { get; } /// @@ -49,15 +48,9 @@ public ConsumingCorpseEventArgs(ReferenceHub player, BasicRagdoll ragDoll, Zombi /// public Ragdoll Ragdoll { get; } - /// - /// Gets or sets a value about how mush heath the Zombie will get. - /// - public float ConsumeHeal { get; set; } - /// /// Gets or sets error code to send back to client. /// - [Obsolete("Removed", true)] public ZombieConsumeAbility.ConsumeError ErrorCode { get; set; } /// @@ -69,4 +62,4 @@ public bool IsAllowed set => ErrorCode = value ? ZombieConsumeAbility.ConsumeError.None : ZombieConsumeAbility.ConsumeError.TargetNotValid; } } -} +} \ No newline at end of file diff --git a/Exiled.Events/Handlers/Scp0492.cs b/Exiled.Events/Handlers/Scp0492.cs index 0509a9cab2..82ee09d8de 100644 --- a/Exiled.Events/Handlers/Scp0492.cs +++ b/Exiled.Events/Handlers/Scp0492.cs @@ -22,6 +22,11 @@ public class Scp0492 /// public static Event TriggeringBloodlust { get; set; } = new (); + /// + /// Called after 049-2 gets his benefits from consumed ability. + /// + public static Event ConsumedCorpse { get; set; } = new(); + /// /// Called before 049-2 gets his benefits from consuming ability. /// @@ -33,6 +38,12 @@ public class Scp0492 /// The instance. public static void OnTriggeringBloodlust(TriggeringBloodlustEventArgs ev) => TriggeringBloodlust.InvokeSafely(ev); + /// + /// Invokes after 049-2 gets his benefits from consumed ability. + /// + /// instance. + public static void OnConsumedCorpse(ConsumedCorpseEventArgs ev) => ConsumedCorpse.InvokeSafely(ev); + /// /// Invokes before 049-2 gets his benefits from consuming ability. /// diff --git a/Exiled.Events/Patches/Events/Scp0492/Consumed.cs b/Exiled.Events/Patches/Events/Scp0492/Consumed.cs new file mode 100644 index 0000000000..bbafe1fc35 --- /dev/null +++ b/Exiled.Events/Patches/Events/Scp0492/Consumed.cs @@ -0,0 +1,94 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Events.Scp0492 +{ + using System.Collections.Generic; + using System.Reflection.Emit; + + using API.Features.Pools; + + using Exiled.API.Extensions; + using Exiled.API.Features; + using Exiled.Events.Attributes; + using Exiled.Events.EventArgs.Scp0492; + using HarmonyLib; + using PlayerRoles.PlayableScps.Scp049; + using PlayerRoles.PlayableScps.Scp049.Zombies; + using PlayerRoles.PlayableScps.Subroutines; + using PlayerStatsSystem; + + using static HarmonyLib.AccessTools; + + /// + /// Patches + /// to add event. + /// + [EventPatch(typeof(Handlers.Scp0492), nameof(Handlers.Scp0492.ConsumedCorpse))] + [HarmonyPatch(typeof(ZombieConsumeAbility), nameof(ZombieConsumeAbility.ServerComplete))] + public class Consumed + { + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) + { + List newInstructions = ListPool.Pool.Get(instructions); + + LocalBuilder ev = generator.DeclareLocal(typeof(ConsumedCorpseEventArgs)); + + int offset = 1; + int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Ret) + offset; + + Label returnLabel = generator.DefineLabel(); + + newInstructions.InsertRange( + index, + new[] + { + // Player.Get(base.Owner) + new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]), + new(OpCodes.Call, PropertyGetter(typeof(ScpStandardSubroutine), nameof(ScpStandardSubroutine.Owner))), + new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), + + // base.CurRagdoll + new CodeInstruction(OpCodes.Ldarg_0), + new(OpCodes.Call, PropertyGetter(typeof(RagdollAbilityBase), nameof(RagdollAbilityBase.CurRagdoll))), + + // true + new(OpCodes.Ldc_I4_1), + + // ConsumingCorpseEventArgs ev = new(Player, Ragdoll, bool) + new(OpCodes.Newobj, GetDeclaredConstructors(typeof(ConsumedCorpseEventArgs))[0]), + new(OpCodes.Dup), + new(OpCodes.Dup), + new(OpCodes.Stloc_S, ev.LocalIndex), + + // Handlers.Scp049.OnSendingCall(ev) + new(OpCodes.Call, Method(typeof(Handlers.Scp0492), nameof(Handlers.Scp0492.OnConsumedCorpse))), + }); + + // replace "base.Owner.playerStats.GetModule().ServerHeal(100f)" with "base.Owner.playerStats.GetModule().ServerHeal(ev.ConsumeHeal)" + offset = -1; + index = newInstructions.FindIndex(instruction => instruction.operand == (object)Method(typeof(HealthStat), nameof(HealthStat.ServerHeal))) + offset; + newInstructions.RemoveAt(index); + + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // ev.ConsumeHeal + new(OpCodes.Ldloc_S, ev.LocalIndex), + new(OpCodes.Callvirt, PropertyGetter(typeof(ConsumedCorpseEventArgs), nameof(ConsumedCorpseEventArgs.ConsumeHeal))), + }); + + newInstructions[newInstructions.Count - 1].WithLabels(returnLabel); + + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; + + ListPool.Pool.Return(newInstructions); + } + } +} diff --git a/Exiled.Events/Patches/Events/Scp0492/Consuming.cs b/Exiled.Events/Patches/Events/Scp0492/Consuming.cs index a742a978f2..2d3320a29f 100644 --- a/Exiled.Events/Patches/Events/Scp0492/Consuming.cs +++ b/Exiled.Events/Patches/Events/Scp0492/Consuming.cs @@ -71,4 +71,4 @@ private static IEnumerable Transpiler(IEnumerable.Pool.Return(newInstructions); } } -} +} \ No newline at end of file From 9b690c9d8560bd7b00c84e76bdee164980b55f9e Mon Sep 17 00:00:00 2001 From: louis1706 Date: Tue, 24 Oct 2023 23:56:02 +0200 Subject: [PATCH 115/207] Few Fix --- Exiled.Events/Patches/Events/Scp049/ActivatingSense.cs | 4 ++-- Exiled.Events/Patches/Events/Scp049/SendingCall.cs | 2 +- Exiled.Events/Patches/Events/Scp0492/Consumed.cs | 5 ----- Exiled.Events/Patches/Generic/CanScp049SenseTutorial.cs | 5 ----- 4 files changed, 3 insertions(+), 13 deletions(-) diff --git a/Exiled.Events/Patches/Events/Scp049/ActivatingSense.cs b/Exiled.Events/Patches/Events/Scp049/ActivatingSense.cs index 71b70670ba..e66d2cda4c 100644 --- a/Exiled.Events/Patches/Events/Scp049/ActivatingSense.cs +++ b/Exiled.Events/Patches/Events/Scp049/ActivatingSense.cs @@ -85,7 +85,7 @@ private static IEnumerable Transpiler(IEnumerable instruction.operand == (object)PropertySetter(typeof(AbilityCooldown), nameof(AbilityCooldown.Trigger))) + offset; + index = newInstructions.FindIndex(instruction => instruction.operand == (object)Method(typeof(AbilityCooldown), nameof(AbilityCooldown.Trigger))) + offset; newInstructions.RemoveAt(index); newInstructions.InsertRange( @@ -99,7 +99,7 @@ private static IEnumerable Transpiler(IEnumerable instruction.operand == (object)PropertySetter(typeof(AbilityCooldown), nameof(AbilityCooldown.Trigger))) + offset; + index = newInstructions.FindLastIndex(instruction => instruction.operand == (object)Method(typeof(AbilityCooldown), nameof(AbilityCooldown.Trigger))) + offset; newInstructions.RemoveAt(index); newInstructions.InsertRange( diff --git a/Exiled.Events/Patches/Events/Scp049/SendingCall.cs b/Exiled.Events/Patches/Events/Scp049/SendingCall.cs index 1464bffabf..cb942613be 100644 --- a/Exiled.Events/Patches/Events/Scp049/SendingCall.cs +++ b/Exiled.Events/Patches/Events/Scp049/SendingCall.cs @@ -69,7 +69,7 @@ private static IEnumerable Transpiler(IEnumerable instruction.operand == (object)PropertySetter(typeof(AbilityCooldown), nameof(AbilityCooldown.Trigger))) + offset; + index = newInstructions.FindIndex(instruction => instruction.operand == (object)Method(typeof(AbilityCooldown), nameof(AbilityCooldown.Trigger))) + offset; newInstructions.RemoveAt(index); newInstructions.InsertRange( diff --git a/Exiled.Events/Patches/Events/Scp0492/Consumed.cs b/Exiled.Events/Patches/Events/Scp0492/Consumed.cs index bbafe1fc35..600efbf7e0 100644 --- a/Exiled.Events/Patches/Events/Scp0492/Consumed.cs +++ b/Exiled.Events/Patches/Events/Scp0492/Consumed.cs @@ -50,19 +50,14 @@ private static IEnumerable Transpiler(IEnumerable), nameof(ScpStandardSubroutine.Owner))), - new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), // base.CurRagdoll new CodeInstruction(OpCodes.Ldarg_0), new(OpCodes.Call, PropertyGetter(typeof(RagdollAbilityBase), nameof(RagdollAbilityBase.CurRagdoll))), - // true - new(OpCodes.Ldc_I4_1), - // ConsumingCorpseEventArgs ev = new(Player, Ragdoll, bool) new(OpCodes.Newobj, GetDeclaredConstructors(typeof(ConsumedCorpseEventArgs))[0]), new(OpCodes.Dup), - new(OpCodes.Dup), new(OpCodes.Stloc_S, ev.LocalIndex), // Handlers.Scp049.OnSendingCall(ev) diff --git a/Exiled.Events/Patches/Generic/CanScp049SenseTutorial.cs b/Exiled.Events/Patches/Generic/CanScp049SenseTutorial.cs index cc9d847968..16e9eb3e0f 100644 --- a/Exiled.Events/Patches/Generic/CanScp049SenseTutorial.cs +++ b/Exiled.Events/Patches/Generic/CanScp049SenseTutorial.cs @@ -37,12 +37,9 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Date: Wed, 25 Oct 2023 13:06:41 +0200 Subject: [PATCH 116/207] Fix Item always being null --- .../Events/Player/UsingAndCancellingItemUse.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Exiled.Events/Patches/Events/Player/UsingAndCancellingItemUse.cs b/Exiled.Events/Patches/Events/Player/UsingAndCancellingItemUse.cs index f8e373c702..8881a934fe 100644 --- a/Exiled.Events/Patches/Events/Player/UsingAndCancellingItemUse.cs +++ b/Exiled.Events/Patches/Events/Player/UsingAndCancellingItemUse.cs @@ -42,7 +42,8 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Date: Wed, 25 Oct 2023 13:19:30 +0200 Subject: [PATCH 117/207] . --- Exiled.Events/Patches/Events/Player/UsingAndCancellingItemUse.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Exiled.Events/Patches/Events/Player/UsingAndCancellingItemUse.cs b/Exiled.Events/Patches/Events/Player/UsingAndCancellingItemUse.cs index 8881a934fe..af583cde3b 100644 --- a/Exiled.Events/Patches/Events/Player/UsingAndCancellingItemUse.cs +++ b/Exiled.Events/Patches/Events/Player/UsingAndCancellingItemUse.cs @@ -102,6 +102,7 @@ private static IEnumerable Transpiler(IEnumerable Date: Wed, 25 Oct 2023 17:46:05 +0200 Subject: [PATCH 118/207] FixCanScp049SenseTutorial --- .../Patches/Generic/CanScp049SenseTutorial.cs | 10 +++++----- Exiled.Events/Patches/Generic/Scp079Scan.cs | 7 ++----- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Exiled.Events/Patches/Generic/CanScp049SenseTutorial.cs b/Exiled.Events/Patches/Generic/CanScp049SenseTutorial.cs index 16e9eb3e0f..8f0f815ac0 100644 --- a/Exiled.Events/Patches/Generic/CanScp049SenseTutorial.cs +++ b/Exiled.Events/Patches/Generic/CanScp049SenseTutorial.cs @@ -35,7 +35,7 @@ private static IEnumerable Transpiler(IEnumerable instruction.opcode == OpCodes.Brfalse); - Label returnLabel = (Label)newInstructions[index].operand; + Label continueLabel = (Label)newInstructions[index].operand; Label skip = generator.DefineLabel(); index += 1; @@ -47,7 +47,7 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable), nameof(Plugin.Config))), new(OpCodes.Callvirt, PropertyGetter(typeof(Config), nameof(Config.CanScp049SenseTutorial))), - new(OpCodes.Brfalse_S, returnLabel), + new(OpCodes.Brfalse_S, continueLabel), // if (Scp049Role.TurnedPlayers.Contains(Player.Get(referenceHub))) new CodeInstruction(OpCodes.Call, PropertyGetter(typeof(API.Features.Roles.Scp049Role), nameof(API.Features.Roles.Scp049Role.TurnedPlayers))).WithLabels(skip), - new(OpCodes.Ldloca_S, 6), + new(OpCodes.Ldloc_S, 6), new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), new(OpCodes.Callvirt, Method(typeof(HashSet), nameof(HashSet.Contains))), - new(OpCodes.Brtrue_S, returnLabel), + new(OpCodes.Brtrue_S, continueLabel), }); for (int z = 0; z < newInstructions.Count; z++) diff --git a/Exiled.Events/Patches/Generic/Scp079Scan.cs b/Exiled.Events/Patches/Generic/Scp079Scan.cs index 760a695c1c..4660d1923c 100644 --- a/Exiled.Events/Patches/Generic/Scp079Scan.cs +++ b/Exiled.Events/Patches/Generic/Scp079Scan.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- // // Copyright (c) Exiled Team. All rights reserved. // Licensed under the CC BY-SA 3.0 license. @@ -34,9 +34,6 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable), nameof(HashSet.Contains))), new(OpCodes.Brtrue_S, returnLabel), From 5eb154b1fb53327846b43c3c3e8784799e6e40a8 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 27 Oct 2023 00:05:15 +0200 Subject: [PATCH 119/207] Hurt --- .../EventArgs/Player/HurtingEventArgs.cs | 16 ++--- Exiled.Events/Handlers/Player.cs | 11 ++++ .../Patches/Events/Player/HurtEventArgs.cs | 62 +++++++++++++++++++ .../Patches/Events/Player/Hurting.cs | 26 +++++++- 4 files changed, 101 insertions(+), 14 deletions(-) create mode 100644 Exiled.Events/Patches/Events/Player/HurtEventArgs.cs diff --git a/Exiled.Events/EventArgs/Player/HurtingEventArgs.cs b/Exiled.Events/EventArgs/Player/HurtingEventArgs.cs index 085598ad49..326d1ad09e 100644 --- a/Exiled.Events/EventArgs/Player/HurtingEventArgs.cs +++ b/Exiled.Events/EventArgs/Player/HurtingEventArgs.cs @@ -37,14 +37,10 @@ public HurtingEventArgs(Player target, DamageHandlerBase damageHandler) Player = target; } - /// - /// Gets the target player, who is going to be hurt. - /// + /// public Player Player { get; } - /// - /// Gets the attacker player. - /// + /// public Player Attacker { get; } /// @@ -56,14 +52,10 @@ public float Amount set => DamageHandler.Damage = value; } - /// - /// Gets or sets the for the event. - /// + /// public CustomDamageHandler DamageHandler { get; set; } - /// - /// Gets or sets a value indicating whether or not the player will be dealt damage. - /// + /// public bool IsAllowed { get; set; } = true; } } \ No newline at end of file diff --git a/Exiled.Events/Handlers/Player.cs b/Exiled.Events/Handlers/Player.cs index 14e491c9e3..0a1d5520a6 100644 --- a/Exiled.Events/Handlers/Player.cs +++ b/Exiled.Events/Handlers/Player.cs @@ -146,6 +146,11 @@ public class Player /// public static Event Hurting { get; set; } = new(); + /// + /// Invoked after hurting a . + /// + public static Event Hurt { get; set; } = new(); + /// /// Invoked before a dies. /// @@ -1024,6 +1029,12 @@ public static void OnItemAdded(ReferenceHub referenceHub, InventorySystem.Items. /// The instance. public static void OnHurting(HurtingEventArgs ev) => Hurting.InvokeSafely(ev); + /// + /// Called ater a being hurt. + /// + /// The instance. + public static void OnHurt(HurtEventArgs ev) => Hurt.InvokeSafely(ev); + /// /// Called before a dies. /// diff --git a/Exiled.Events/Patches/Events/Player/HurtEventArgs.cs b/Exiled.Events/Patches/Events/Player/HurtEventArgs.cs new file mode 100644 index 0000000000..b1abacd681 --- /dev/null +++ b/Exiled.Events/Patches/Events/Player/HurtEventArgs.cs @@ -0,0 +1,62 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Player +{ + using API.Features; + using API.Features.DamageHandlers; + + using Interfaces; + + using CustomAttackerHandler = API.Features.DamageHandlers.AttackerDamageHandler; + using DamageHandlerBase = PlayerStatsSystem.DamageHandlerBase; + + /// + /// Contains all information before a player gets damaged. + /// + public class HurtEventArgs : IAttackerEvent + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public HurtEventArgs(Player target, DamageHandlerBase damageHandler, DamageHandlerBase.HandlerOutput handlerOutput) + { + DamageHandler = new CustomDamageHandler(target, damageHandler); + Attacker = DamageHandler.BaseIs(out CustomAttackerHandler attackerDamageHandler) ? attackerDamageHandler.Attacker : null; + Player = target; + HandlerOutput = handlerOutput; + } + + /// + public Player Player { get; } + + /// + public Player Attacker { get; } + + /// + /// Gets the amount of inflicted damage. + /// + public float Amount { get; } + + /// + /// Gets or sets the action than will be made on the player. + /// + public DamageHandlerBase.HandlerOutput HandlerOutput { get; set; } + + /// + public CustomDamageHandler DamageHandler { get; set; } + } +} \ No newline at end of file diff --git a/Exiled.Events/Patches/Events/Player/Hurting.cs b/Exiled.Events/Patches/Events/Player/Hurting.cs index 3afc266e8f..1cf3d3a15d 100644 --- a/Exiled.Events/Patches/Events/Player/Hurting.cs +++ b/Exiled.Events/Patches/Events/Player/Hurting.cs @@ -27,9 +27,10 @@ namespace Exiled.Events.Patches.Events.Player /// /// Patches . - /// Adds the event. + /// Adds the event and event. /// [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.Hurting))] + [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.Hurt))] [HarmonyPatch(typeof(PlayerStats), nameof(PlayerStats.DealDamage))] internal static class Hurting { @@ -43,7 +44,7 @@ private static IEnumerable Transpiler(IEnumerable instruction.opcode == OpCodes.Ret) + offset; newInstructions.InsertRange( @@ -96,6 +97,27 @@ private static IEnumerable Transpiler(IEnumerable instruction.operand == (object)Method(typeof(DamageHandlerBase), nameof(DamageHandlerBase.ApplyDamage))) + offset; + + newInstructions.InsertRange( + index, + new[] + { + // HurtingEventArgs ev = new(player, handler, handleroutput) + new CodeInstruction(OpCodes.Ldloc, player.LocalIndex), + new(OpCodes.Ldarg_1), + new(OpCodes.Ldloc_1), + new(OpCodes.Newobj, GetDeclaredConstructors(typeof(HurtEventArgs))[0]), + new(OpCodes.Dup), + + // Handlers.Player.OnHurting(ev); + new(OpCodes.Call, Method(typeof(Handlers.Player), nameof(Handlers.Player.OnHurt))), + + // handlerOutput = ev.HandlerOutput; + new(OpCodes.Callvirt, PropertyGetter(typeof(HurtEventArgs), nameof(HurtEventArgs.HandlerOutput))), + new(OpCodes.Stloc_1), + }); newInstructions[newInstructions.Count - 1].WithLabels(ret); for (int z = 0; z < newInstructions.Count; z++) From 79f730533c237d3c80a14142c4b7e929184b9799 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 27 Oct 2023 09:46:00 +0200 Subject: [PATCH 120/207] SCP:SL 13.3 --- Exiled.API/Features/Items/Flashlight.cs | 5 ++--- Exiled.API/Features/Items/Item.cs | 2 +- Exiled.API/Features/Map.cs | 1 + Exiled.API/Features/Player.cs | 14 ++++++++++++-- Exiled.API/Features/Roles/HumanRole.cs | 5 +++-- Exiled.API/Features/Roles/Scp0492Role.cs | 1 + Exiled.API/Features/Roles/Scp049Role.cs | 3 ++- Exiled.API/Features/Roles/Scp106Role.cs | 2 +- .../EventArgs/Player/SpawnedRagdollEventArgs.cs | 2 +- .../EventArgs/Player/SpawningRagdollEventArgs.cs | 2 +- .../Player/TogglingFlashlightEventArgs.cs | 2 +- .../EventArgs/Scp049/FinishingRecallEventArgs.cs | 1 + .../EventArgs/Scp0492/ConsumingCorpseEventArgs.cs | 1 + .../Patches/Events/Player/TogglingFlashlight.cs | 2 +- .../Patches/Events/Scp049/StartingRecall.cs | 1 + 15 files changed, 30 insertions(+), 14 deletions(-) diff --git a/Exiled.API/Features/Items/Flashlight.cs b/Exiled.API/Features/Items/Flashlight.cs index 6b95414d24..1f60699547 100644 --- a/Exiled.API/Features/Items/Flashlight.cs +++ b/Exiled.API/Features/Items/Flashlight.cs @@ -8,9 +8,8 @@ namespace Exiled.API.Features.Items { using Exiled.API.Interfaces; - - using InventorySystem.Items.Flashlight; - + using InventorySystem.Items.SwitchableLightSources; + using InventorySystem.Items.SwitchableLightSources.Flashlight; using Utils.Networking; /// diff --git a/Exiled.API/Features/Items/Item.cs b/Exiled.API/Features/Items/Item.cs index 4f847af765..631637ea13 100644 --- a/Exiled.API/Features/Items/Item.cs +++ b/Exiled.API/Features/Items/Item.cs @@ -17,12 +17,12 @@ namespace Exiled.API.Features.Items using InventorySystem.Items; using InventorySystem.Items.Armor; using InventorySystem.Items.Firearms.Ammo; - using InventorySystem.Items.Flashlight; using InventorySystem.Items.Jailbird; using InventorySystem.Items.Keycards; using InventorySystem.Items.MicroHID; using InventorySystem.Items.Pickups; using InventorySystem.Items.Radio; + using InventorySystem.Items.SwitchableLightSources.Flashlight; using InventorySystem.Items.ThrowableProjectiles; using InventorySystem.Items.Usables; using InventorySystem.Items.Usables.Scp1576; diff --git a/Exiled.API/Features/Map.cs b/Exiled.API/Features/Map.cs index cfa1562e91..18d8898ae6 100644 --- a/Exiled.API/Features/Map.cs +++ b/Exiled.API/Features/Map.cs @@ -31,6 +31,7 @@ namespace Exiled.API.Features using PlayerRoles; using PlayerRoles.PlayableScps.Scp173; using PlayerRoles.PlayableScps.Scp939; + using PlayerRoles.Ragdolls; using RelativePositioning; using UnityEngine; using Utils; diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index a06e24e414..8931f36149 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -54,6 +54,7 @@ namespace Exiled.API.Features using PluginAPI.Core; using RelativePositioning; using RemoteAdmin; + using Respawning.NamingRules; using RoundRestarting; using UnityEngine; using Utils; @@ -817,7 +818,16 @@ public bool IsGodModeEnabled /// /// Gets the player's unit name. /// - public string UnitName => Role.Base is PlayerRoles.HumanRole humanRole ? humanRole.UnitName : string.Empty; + public string UnitName => Role.Base is PlayerRoles.HumanRole humanRole ? UnitNameMessageHandler.GetReceived(humanRole.AssignedSpawnableTeam, humanRole.UnitNameId) : string.Empty; + + /// + /// Gets or sets the player's unit id. + /// + public byte UnitId + { + get => Role.Base is PlayerRoles.HumanRole humanRole ? humanRole.UnitNameId : byte.MinValue; + set => _ = Role.Base is PlayerRoles.HumanRole humanRole ? humanRole.UnitNameId = value : _ = value; + } /// /// Gets or sets the player's health. @@ -2684,7 +2694,7 @@ public void ShowHint(Hint hint) /// /// The size of the hitmarker, ranging from 0 to ). public void ShowHitMarker(float size = 1f) => - Hitmarker.SendHitmarker(ReferenceHub, size); + Hitmarker.SendHitmarkerDirectly(ReferenceHub, size); /// /// Safely gets an from , then casts it to . diff --git a/Exiled.API/Features/Roles/HumanRole.cs b/Exiled.API/Features/Roles/HumanRole.cs index 4d9888723f..ff58745bed 100644 --- a/Exiled.API/Features/Roles/HumanRole.cs +++ b/Exiled.API/Features/Roles/HumanRole.cs @@ -10,6 +10,7 @@ namespace Exiled.API.Features.Roles using PlayerRoles; using Respawning; + using Respawning.NamingRules; using HumanGameRole = PlayerRoles.HumanRole; @@ -41,9 +42,9 @@ public SpawnableTeamType SpawnableTeamType } /// - /// Gets the . + /// Gets the player's unit name. /// - public string UnitName => Base.UnitName; + public string UnitName => UnitNameMessageHandler.GetReceived(Base.AssignedSpawnableTeam, Base.UnitNameId); /// /// Gets or sets the . diff --git a/Exiled.API/Features/Roles/Scp0492Role.cs b/Exiled.API/Features/Roles/Scp0492Role.cs index 2ffb064c30..83cfa29095 100644 --- a/Exiled.API/Features/Roles/Scp0492Role.cs +++ b/Exiled.API/Features/Roles/Scp0492Role.cs @@ -12,6 +12,7 @@ namespace Exiled.API.Features.Roles using PlayerRoles.PlayableScps.Scp049; using PlayerRoles.PlayableScps.Scp049.Zombies; using PlayerRoles.PlayableScps.Subroutines; + using PlayerRoles.Ragdolls; /// /// Defines a role that represents SCP-049-2. diff --git a/Exiled.API/Features/Roles/Scp049Role.cs b/Exiled.API/Features/Roles/Scp049Role.cs index bc4f7e0c87..cfc6df64b1 100644 --- a/Exiled.API/Features/Roles/Scp049Role.cs +++ b/Exiled.API/Features/Roles/Scp049Role.cs @@ -17,6 +17,7 @@ namespace Exiled.API.Features.Roles using PlayerRoles.PlayableScps.HumeShield; using PlayerRoles.PlayableScps.Scp049; using PlayerRoles.PlayableScps.Subroutines; + using PlayerRoles.Ragdolls; using PlayerStatsSystem; using UnityEngine; @@ -269,7 +270,7 @@ public void Attack(Player player) SenseAbility.OnServerHit(AttackAbility._target); AttackAbility.ServerSendRpc(true); - Hitmarker.SendHitmarker(AttackAbility.Owner, 1f); + Hitmarker.SendHitmarkerDirectly(AttackAbility.Owner, 1f); } /// diff --git a/Exiled.API/Features/Roles/Scp106Role.cs b/Exiled.API/Features/Roles/Scp106Role.cs index cb0b9354f1..54aa9346ad 100644 --- a/Exiled.API/Features/Roles/Scp106Role.cs +++ b/Exiled.API/Features/Roles/Scp106Role.cs @@ -261,7 +261,7 @@ public void CapturePlayer(Player player) // Convert to bool. Attack.SendCooldown(Attack._hitCooldown); VigorAbility.VigorAmount += Scp106Attack.VigorCaptureReward; Attack.ReduceSinkholeCooldown(); - Hitmarker.SendHitmarker(Attack.Owner, 1f); + Hitmarker.SendHitmarkerDirectly(Attack.Owner, 1f); player.EnableEffect(EffectType.Corroding); player.EnableEffect(EffectType.SinkHole); diff --git a/Exiled.Events/EventArgs/Player/SpawnedRagdollEventArgs.cs b/Exiled.Events/EventArgs/Player/SpawnedRagdollEventArgs.cs index 40b491bac0..768cd868e3 100644 --- a/Exiled.Events/EventArgs/Player/SpawnedRagdollEventArgs.cs +++ b/Exiled.Events/EventArgs/Player/SpawnedRagdollEventArgs.cs @@ -12,7 +12,7 @@ namespace Exiled.Events.EventArgs.Player using Interfaces; using PlayerRoles; - + using PlayerRoles.Ragdolls; using PlayerStatsSystem; using UnityEngine; diff --git a/Exiled.Events/EventArgs/Player/SpawningRagdollEventArgs.cs b/Exiled.Events/EventArgs/Player/SpawningRagdollEventArgs.cs index 8d02d074dc..59a60fda54 100644 --- a/Exiled.Events/EventArgs/Player/SpawningRagdollEventArgs.cs +++ b/Exiled.Events/EventArgs/Player/SpawningRagdollEventArgs.cs @@ -12,7 +12,7 @@ namespace Exiled.Events.EventArgs.Player using Interfaces; using PlayerRoles; - + using PlayerRoles.Ragdolls; using PlayerStatsSystem; using UnityEngine; diff --git a/Exiled.Events/EventArgs/Player/TogglingFlashlightEventArgs.cs b/Exiled.Events/EventArgs/Player/TogglingFlashlightEventArgs.cs index 892b9ec1c5..66323f8d99 100644 --- a/Exiled.Events/EventArgs/Player/TogglingFlashlightEventArgs.cs +++ b/Exiled.Events/EventArgs/Player/TogglingFlashlightEventArgs.cs @@ -12,7 +12,7 @@ namespace Exiled.Events.EventArgs.Player using Interfaces; - using InventorySystem.Items.Flashlight; + using InventorySystem.Items.SwitchableLightSources.Flashlight; /// /// Contains all information before a player toggles the flashlight. diff --git a/Exiled.Events/EventArgs/Scp049/FinishingRecallEventArgs.cs b/Exiled.Events/EventArgs/Scp049/FinishingRecallEventArgs.cs index edb604dcd9..3ab6dee651 100644 --- a/Exiled.Events/EventArgs/Scp049/FinishingRecallEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp049/FinishingRecallEventArgs.cs @@ -10,6 +10,7 @@ namespace Exiled.Events.EventArgs.Scp049 using API.Features; using Exiled.API.Features.Roles; using Interfaces; + using PlayerRoles.Ragdolls; /// /// Contains all information before SCP-049 finishes recalling a player. diff --git a/Exiled.Events/EventArgs/Scp0492/ConsumingCorpseEventArgs.cs b/Exiled.Events/EventArgs/Scp0492/ConsumingCorpseEventArgs.cs index 7093d6a867..d68d174497 100644 --- a/Exiled.Events/EventArgs/Scp0492/ConsumingCorpseEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp0492/ConsumingCorpseEventArgs.cs @@ -12,6 +12,7 @@ namespace Exiled.Events.EventArgs.Scp0492 using Interfaces; using PlayerRoles.PlayableScps.Scp049.Zombies; + using PlayerRoles.Ragdolls; /// /// Contains all information before zombie consumes RagDolls. diff --git a/Exiled.Events/Patches/Events/Player/TogglingFlashlight.cs b/Exiled.Events/Patches/Events/Player/TogglingFlashlight.cs index 0f0c2470fd..f919d934f4 100644 --- a/Exiled.Events/Patches/Events/Player/TogglingFlashlight.cs +++ b/Exiled.Events/Patches/Events/Player/TogglingFlashlight.cs @@ -16,7 +16,7 @@ namespace Exiled.Events.Patches.Events.Player using HarmonyLib; - using InventorySystem.Items.Flashlight; + using InventorySystem.Items.SwitchableLightSources; using static HarmonyLib.AccessTools; diff --git a/Exiled.Events/Patches/Events/Scp049/StartingRecall.cs b/Exiled.Events/Patches/Events/Scp049/StartingRecall.cs index 6126a90b4b..fd781c5712 100644 --- a/Exiled.Events/Patches/Events/Scp049/StartingRecall.cs +++ b/Exiled.Events/Patches/Events/Scp049/StartingRecall.cs @@ -18,6 +18,7 @@ namespace Exiled.Events.Patches.Events.Scp049 using HarmonyLib; using PlayerRoles.PlayableScps.Scp049; + using PlayerRoles.Ragdolls; using static HarmonyLib.AccessTools; From 317a62da631ddbbc09fff892f2c7076e446f79f1 Mon Sep 17 00:00:00 2001 From: Yamato <66829532+louis1706@users.noreply.github.com> Date: Fri, 27 Oct 2023 09:50:12 +0200 Subject: [PATCH 121/207] Doc (#2177) --- docs/docs/Resources/Intro.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/docs/docs/Resources/Intro.md b/docs/docs/Resources/Intro.md index bc425f7099..ebe64b9b89 100644 --- a/docs/docs/Resources/Intro.md +++ b/docs/docs/Resources/Intro.md @@ -34,7 +34,7 @@ sidebar_position: 1
Roles -```md title="Latest Updated: 13.2.0.0" +```md title="Latest Updated: 13.2.0.2" | Id | RoleTypeId | Team | Side | LeadingTeam | |-----|----------------|------------------|------------------|-----------------| | -1 | None | Dead | None | Draw | @@ -69,7 +69,7 @@ sidebar_position: 1
Items -```md title="Latest Updated: 13.2.0.0" +```md title="Latest Updated: 13.2.0.2" [-1] None [0] KeycardJanitor [1] KeycardScientist @@ -134,7 +134,7 @@ sidebar_position: 1
Ammo -```md title="Latest Updated: 8.2.1.0" +```md title="Latest Updated: 8.3.0.0" [0] None [1] Nato556 [2] Nato762 @@ -149,7 +149,7 @@ sidebar_position: 1
Doors -```md title="Latest Updated: 8.2.1.0" +```md title="Latest Updated: 8.3.0.0" [0] UnknownDoor [1] Scp914Door [2] GR18Inner @@ -218,7 +218,7 @@ sidebar_position: 1
Rooms -```md title="Latest Updated: 8.2.1.0" +```md title="Latest Updated: 8.3.0.0" [0] Unknown [1] LczArmory [2] LczCurve @@ -281,7 +281,7 @@ sidebar_position: 1
Elevators -```md title="Latest Updated: 8.2.1.0" +```md title="Latest Updated: 8.3.0.0" [0] Unknown [1] GateA [2] GateB @@ -297,7 +297,7 @@ sidebar_position: 1
DamageType -```md title="Latest Updated: 8.2.1.0" +```md title="Latest Updated: 8.3.0.0" [0] Unknown [1] Falldown [2] Warhead @@ -376,7 +376,7 @@ PlayerStatsSystem::Scp018DamageHandler : AttackerDamageHandler
Effects -```md title="Latest Updated: 8.2.1.0" +```md title="Latest Updated: 8.3.0.0" [0] AmnesiaItems [1] AmnesiaVision [2] Asphyxiated @@ -422,7 +422,7 @@ PlayerStatsSystem::Scp018DamageHandler : AttackerDamageHandler
Keycard Perms -```md title="Latest Updated: 8.2.1.0" +```md title="Latest Updated: 8.3.0.0" [0] None [1] Checkpoints [2] ExitGates @@ -443,7 +443,7 @@ PlayerStatsSystem::Scp018DamageHandler : AttackerDamageHandler
Lock Type -```md title="Latest Updated: 8.2.1.0" +```md title="Latest Updated: 8.3.0.0" [0] None [1] Regular079 [2] Lockdown079 @@ -463,7 +463,7 @@ PlayerStatsSystem::Scp018DamageHandler : AttackerDamageHandler
Structures -```md title="Latest Updated: 13.2.0.0" +```md title="Latest Updated: 13.2.0.2" [0] StandardLocker [1] LargeGunLocker [2] ScpPedestal @@ -478,7 +478,7 @@ PlayerStatsSystem::Scp018DamageHandler : AttackerDamageHandler
Blood -```md title="Latest Updated: 8.2.1.0" +```md title="Latest Updated: 8.3.0.0" [0] Default [1] Scp106 [2] Spreaded @@ -491,7 +491,7 @@ PlayerStatsSystem::Scp018DamageHandler : AttackerDamageHandler
GeneratorState -```md title="Latest Updated: 8.2.1.0" +```md title="Latest Updated: 8.3.0.0" [1] None [2] Unlocked [4] Open @@ -505,7 +505,7 @@ PlayerStatsSystem::Scp018DamageHandler : AttackerDamageHandler
Intercom States -```md title="Latest Updated: 13.2.0.0" +```md title="Latest Updated: 13.2.0.2" [0] Ready [1] Starting [2] InUse @@ -519,7 +519,7 @@ PlayerStatsSystem::Scp018DamageHandler : AttackerDamageHandler
BroadcastFlags -```md title="Latest Updated: 13.2.0.0" +```md title="Latest Updated: 13.2.0.2" [0] Normal [1] Truncated [2] AdminChat @@ -533,7 +533,7 @@ PlayerStatsSystem::Scp018DamageHandler : AttackerDamageHandler
Attachment Names -```md title="Latest Updated: 8.2.1.0" +```md title="Latest Updated: 8.3.0.0" [0] None [1] IronSights [2] DotSight @@ -588,7 +588,7 @@ PlayerStatsSystem::Scp018DamageHandler : AttackerDamageHandler
Spawn Reasons -```md title="Latest Updated: 8.2.1.0" +```md title="Latest Updated: 8.3.0.0" [0] None [1] RoundStart [2] LateJoin From 067db4ea86076cb62d91c245c2700e1f611b4186 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 27 Oct 2023 09:54:41 +0200 Subject: [PATCH 122/207] SCP:SL 13.3 --- Exiled.Events/EventArgs/Scp0492/ConsumedCorpseEventArgs.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Exiled.Events/EventArgs/Scp0492/ConsumedCorpseEventArgs.cs b/Exiled.Events/EventArgs/Scp0492/ConsumedCorpseEventArgs.cs index 44a0c52bda..ce45ceff26 100644 --- a/Exiled.Events/EventArgs/Scp0492/ConsumedCorpseEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp0492/ConsumedCorpseEventArgs.cs @@ -14,6 +14,7 @@ namespace Exiled.Events.EventArgs.Scp0492 using Interfaces; using PlayerRoles.PlayableScps.Scp049.Zombies; + using PlayerRoles.Ragdolls; /// /// Contains all information after zombie consumes RagDolls. From 1efab6dc526d6f3a401744b8bdec539129fa8f62 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 27 Oct 2023 10:40:56 +0200 Subject: [PATCH 123/207] Fix DisruptorHitreg.ServerPerformShot Transpiler --- Exiled.Events/Patches/Events/Player/Shot.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.Events/Patches/Events/Player/Shot.cs b/Exiled.Events/Patches/Events/Player/Shot.cs index 4933783166..293ef72357 100644 --- a/Exiled.Events/Patches/Events/Player/Shot.cs +++ b/Exiled.Events/Patches/Events/Player/Shot.cs @@ -276,7 +276,7 @@ private static IEnumerable Transpiler(IEnumerable instruction.Calls(Method(typeof(IDestructible), nameof(IDestructible.Damage)))) + offset; newInstructions.InsertRange( From 169ee7127f7273f5316e051e88e5ec5ce558db73 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 27 Oct 2023 10:52:37 +0200 Subject: [PATCH 124/207] Fix Scp330Interobject transpiler --- Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs b/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs index 92025db533..3c40ae3e07 100644 --- a/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs +++ b/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs @@ -46,7 +46,7 @@ private static IEnumerable Transpiler(IEnumerable Date: Fri, 27 Oct 2023 11:04:45 +0200 Subject: [PATCH 125/207] Fix FirearmRequest Received - Transpiler --- Exiled.Events/Patches/Events/Player/FirearmRequestReceived.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.Events/Patches/Events/Player/FirearmRequestReceived.cs b/Exiled.Events/Patches/Events/Player/FirearmRequestReceived.cs index 464cda34ac..d763be3d41 100644 --- a/Exiled.Events/Patches/Events/Player/FirearmRequestReceived.cs +++ b/Exiled.Events/Patches/Events/Player/FirearmRequestReceived.cs @@ -234,7 +234,7 @@ private static IEnumerable Transpiler(IEnumerable Date: Fri, 27 Oct 2023 11:47:08 +0200 Subject: [PATCH 126/207] New API for SCP Halloween --- Exiled.API/Enums/DamageType.cs | 18 ++++++ Exiled.API/Enums/EffectType.cs | 21 +++++++ Exiled.API/Extensions/DamageTypeExtensions.cs | 17 +++++- Exiled.API/Extensions/EffectTypeExtension.cs | 21 ++++++- .../DamageHandlers/ScpDamageHandler.cs | 10 ++- Exiled.API/Features/Roles/Role.cs | 2 + Exiled.API/Features/Roles/Scp3114Role.cs | 61 +++++++++++++++++++ 7 files changed, 146 insertions(+), 4 deletions(-) create mode 100644 Exiled.API/Features/Roles/Scp3114Role.cs diff --git a/Exiled.API/Enums/DamageType.cs b/Exiled.API/Enums/DamageType.cs index 226697b6ea..9a5347f061 100644 --- a/Exiled.API/Enums/DamageType.cs +++ b/Exiled.API/Enums/DamageType.cs @@ -234,5 +234,23 @@ public enum DamageType /// Damage caused by . /// A7, + + /// + /// Damage caused by . + /// + Scp3114, + + /// + /// . + /// + Strangled, + +#pragma warning disable CS1591 // Commentaire XML manquant pour le type ou le membre visible publiquement +#pragma warning disable SA1602 // Enumeration items should be documented + MarshmallowMan, + Silent, + MetalPipe, +#pragma warning restore SA1602 // Enumeration items should be documented +#pragma warning restore CS1591 // Commentaire XML manquant pour le type ou le membre visible publiquement } } diff --git a/Exiled.API/Enums/EffectType.cs b/Exiled.API/Enums/EffectType.cs index 1142907162..7338477290 100644 --- a/Exiled.API/Enums/EffectType.cs +++ b/Exiled.API/Enums/EffectType.cs @@ -199,5 +199,26 @@ public enum EffectType /// Teleports the player to the pocket dimension and drains health until the player escapes or is killed. ///
PocketCorroding, + + /// + /// The effect permit player to go trough door like Scp-106. + /// + Ghostly, + + /// + /// Effect given to player when being strangled by SCP-3114. + /// + Strangled, +#pragma warning disable CS1591 // Commentaire XML manquant pour le type ou le membre visible publiquement +#pragma warning disable SA1602 // Enumeration items should be documented + OrangeCandy, + Spicy, + SugarCrave, + SugarHigh, + SugarRush, + TraumatizedByEvil, + Metal, +#pragma warning restore SA1602 // Enumeration items should be documented +#pragma warning restore CS1591 // Commentaire XML manquant pour le type ou le membre visible publiquement } } diff --git a/Exiled.API/Extensions/DamageTypeExtensions.cs b/Exiled.API/Extensions/DamageTypeExtensions.cs index 5f4d834628..daf4f35aad 100644 --- a/Exiled.API/Extensions/DamageTypeExtensions.cs +++ b/Exiled.API/Extensions/DamageTypeExtensions.cs @@ -12,7 +12,8 @@ namespace Exiled.API.Extensions using Enums; using Features; - + using PlayerRoles.PlayableScps.Scp3114; + using PlayerRoles.PlayableScps.Scp939; using PlayerStatsSystem; /// @@ -47,6 +48,7 @@ public static class DamageTypeExtensions { DeathTranslations.UsedAs106Bait.Id, DamageType.FemurBreaker }, { DeathTranslations.MicroHID.Id, DamageType.MicroHid }, { DeathTranslations.Hypothermia.Id, DamageType.Hypothermia }, + { DeathTranslations.MarshmallowMan.Id, DamageType.MarshmallowMan }, }; private static readonly Dictionary TranslationConversionInternal = new() @@ -76,6 +78,7 @@ public static class DamageTypeExtensions { DeathTranslations.UsedAs106Bait, DamageType.FemurBreaker }, { DeathTranslations.MicroHID, DamageType.MicroHid }, { DeathTranslations.Hypothermia, DamageType.Hypothermia }, + { DeathTranslations.MarshmallowMan, DamageType.MarshmallowMan }, }; private static readonly Dictionary ItemConversionInternal = new() @@ -160,6 +163,10 @@ public static DamageType GetDamageType(DamageHandlerBase damageHandlerBase) { case CustomReasonDamageHandler: return DamageType.Custom; + case SilentDamageHandler: + return DamageType.Silent; + case MetalPipeDamageHandler: + return DamageType.MetalPipe; case WarheadDamageHandler: return DamageType.Warhead; case ExplosionDamageHandler: @@ -170,6 +177,14 @@ public static DamageType GetDamageType(DamageHandlerBase damageHandlerBase) return DamageType.Recontainment; case Scp096DamageHandler: return DamageType.Scp096; + case Scp3114DamageHandler scp3114DamageHandler: + return scp3114DamageHandler.Subtype switch + { + Scp3114DamageHandler.HandlerType.Strangulation => DamageType.Strangled, + Scp3114DamageHandler.HandlerType.SkinSteal => DamageType.Scp3114, + Scp3114DamageHandler.HandlerType.Slap => DamageType.Scp3114, + _ => DamageType.Unknown, + }; case MicroHidDamageHandler: return DamageType.MicroHid; case DisruptorDamageHandler: diff --git a/Exiled.API/Extensions/EffectTypeExtension.cs b/Exiled.API/Extensions/EffectTypeExtension.cs index b083f8042a..e984b9c9d3 100644 --- a/Exiled.API/Extensions/EffectTypeExtension.cs +++ b/Exiled.API/Extensions/EffectTypeExtension.cs @@ -66,6 +66,15 @@ public static class EffectTypeExtension EffectType.Traumatized => typeof(Traumatized), EffectType.AntiScp207 => typeof(AntiScp207), EffectType.Scanned => typeof(Scanned), + EffectType.Ghostly => typeof(Ghostly), + EffectType.Strangled => typeof(Strangled), + EffectType.OrangeCandy => typeof(OrangeCandy), + EffectType.Spicy => typeof(Spicy), + EffectType.SugarCrave => typeof(SugarCrave), + EffectType.SugarHigh => typeof(SugarHigh), + EffectType.SugarRush => typeof(SugarRush), + EffectType.TraumatizedByEvil => typeof(TraumatizedByEvil), + EffectType.Metal => typeof(Metal), // This should never happen _ => throw new InvalidOperationException("Invalid effect enum provided"), @@ -115,6 +124,14 @@ public static class EffectTypeExtension Traumatized => EffectType.Traumatized, AntiScp207 => EffectType.AntiScp207, Scanned => EffectType.Scanned, + Ghostly => EffectType.Ghostly, + Strangled => EffectType.Strangled, + OrangeCandy => EffectType.OrangeCandy, + Spicy => EffectType.Spicy, + SugarCrave => EffectType.SugarCrave, + SugarHigh => EffectType.SugarHigh, + SugarRush => EffectType.SugarRush, + TraumatizedByEvil => EffectType.TraumatizedByEvil, // This should never happen _ => throw new InvalidOperationException("Invalid effect status base provided"), @@ -128,7 +145,7 @@ public static class EffectTypeExtension /// public static bool IsHarmful(this EffectType effect) => effect is EffectType.Asphyxiated or EffectType.Bleeding or EffectType.Corroding or EffectType.Decontaminating or EffectType.Hemorrhage or EffectType.Hypothermia - or EffectType.Poisoned or EffectType.Scp207 or EffectType.SeveredHands; + or EffectType.Poisoned or EffectType.Scp207 or EffectType.SeveredHands or EffectType.Strangled; /// /// Returns whether or not the provided heals a player. @@ -157,7 +174,7 @@ or EffectType.Disabled or EffectType.Ensnared or EffectType.Exhausted or EffectT /// public static bool IsPositive(this EffectType effect) => effect is EffectType.BodyshotReduction or EffectType.DamageReduction or EffectType.Invigorated or EffectType.Invisible or EffectType.MovementBoost or EffectType.RainbowTaste - or EffectType.Scp207 or EffectType.Scp1853 or EffectType.Vitality or EffectType.AntiScp207; + or EffectType.Scp207 or EffectType.Scp1853 or EffectType.Vitality or EffectType.AntiScp207 or EffectType.Ghostly; /// /// Returns whether or not the provided affects the player's movement speed. diff --git a/Exiled.API/Features/DamageHandlers/ScpDamageHandler.cs b/Exiled.API/Features/DamageHandlers/ScpDamageHandler.cs index ebeeedf616..309aca1c6a 100644 --- a/Exiled.API/Features/DamageHandlers/ScpDamageHandler.cs +++ b/Exiled.API/Features/DamageHandlers/ScpDamageHandler.cs @@ -10,7 +10,7 @@ namespace Exiled.API.Features.DamageHandlers using Enums; using Extensions; - + using PlayerRoles.PlayableScps.Scp3114; using PlayerStatsSystem; using BaseHandler = PlayerStatsSystem.DamageHandlerBase; @@ -40,6 +40,14 @@ public override DamageType Type { case Scp096DamageHandler: return DamageType.Scp096; + case Scp3114DamageHandler scp3114DamageHandler: + return scp3114DamageHandler.Subtype switch + { + Scp3114DamageHandler.HandlerType.Strangulation => DamageType.Strangled, + Scp3114DamageHandler.HandlerType.SkinSteal => DamageType.Scp3114, + Scp3114DamageHandler.HandlerType.Slap => DamageType.Scp3114, + _ => DamageType.Unknown, + }; case Scp049DamageHandler scp049DamageHandler: return scp049DamageHandler.DamageSubType switch { diff --git a/Exiled.API/Features/Roles/Role.cs b/Exiled.API/Features/Roles/Role.cs index d65084c4c4..095f36ca04 100644 --- a/Exiled.API/Features/Roles/Role.cs +++ b/Exiled.API/Features/Roles/Role.cs @@ -29,6 +29,7 @@ namespace Exiled.API.Features.Roles using Scp096GameRole = PlayerRoles.PlayableScps.Scp096.Scp096Role; using Scp106GameRole = PlayerRoles.PlayableScps.Scp106.Scp106Role; using Scp173GameRole = PlayerRoles.PlayableScps.Scp173.Scp173Role; + using Scp3114GameRole = PlayerRoles.PlayableScps.Scp3114.Scp3114Role; using Scp939GameRole = PlayerRoles.PlayableScps.Scp939.Scp939Role; using SpectatorGameRole = PlayerRoles.Spectating.SpectatorRole; @@ -223,6 +224,7 @@ public virtual void Set(RoleTypeId newRole, SpawnReason reason, RoleSpawnFlags s Scp106GameRole scp106Role => new Scp106Role(scp106Role), Scp173GameRole scp173Role => new Scp173Role(scp173Role), Scp939GameRole scp939Role => new Scp939Role(scp939Role), + Scp3114GameRole scp3114Role => new Scp3114Role(scp3114Role), OverwatchGameRole overwatchRole => new OverwatchRole(overwatchRole), SpectatorGameRole spectatorRole => new SpectatorRole(spectatorRole), HumanGameRole humanRole => new HumanRole(humanRole), diff --git a/Exiled.API/Features/Roles/Scp3114Role.cs b/Exiled.API/Features/Roles/Scp3114Role.cs new file mode 100644 index 0000000000..20e7e449b1 --- /dev/null +++ b/Exiled.API/Features/Roles/Scp3114Role.cs @@ -0,0 +1,61 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.API.Features.Roles +{ + using System.Collections.Generic; + using System.Linq; + + using Exiled.API.Features.Hazards; + using Mirror; + using PlayerRoles; + using PlayerRoles.PlayableScps.HumeShield; + using PlayerRoles.PlayableScps.Scp3114; + using PlayerRoles.PlayableScps.Subroutines; + using UnityEngine; + + using Scp3114GameRole = PlayerRoles.PlayableScps.Scp3114.Scp3114Role; + + /// + /// Defines a role that represents SCP-173. + /// + public class Scp3114Role : FpcRole, ISubroutinedScpRole, IHumeShieldRole + { + /// + /// Initializes a new instance of the class. + /// + /// the base . + internal Scp3114Role(Scp3114GameRole baseRole) + : base(baseRole) + { + Base = baseRole; + SubroutineModule = baseRole.SubroutineModule; + HumeShieldModule = baseRole.HumeShieldModule; + } + + /// + public override RoleTypeId Type { get; } = RoleTypeId.Scp3114; + + /// + public SubroutineManagerModule SubroutineModule { get; } + + /// + public HumeShieldModuleBase HumeShieldModule { get; } + + /// + /// Gets the instance. + /// + public new Scp3114GameRole Base { get; } + + /// + /// Gets the Spawn Chance of SCP-173. + /// + /// The List of Roles already spawned. + /// The Spawn Chance. + public float GetSpawnChance(List alreadySpawned) => 0; + } +} \ No newline at end of file From f7587cf2f84e2e12192477887ba8ff8ebf16d88a Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 27 Oct 2023 14:48:53 +0200 Subject: [PATCH 127/207] Updating Documentation Again --- Exiled.Loader/AutoUpdateFiles.cs | 2 +- docs/docs/Resources/Intro.md | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Exiled.Loader/AutoUpdateFiles.cs b/Exiled.Loader/AutoUpdateFiles.cs index bda484a30a..01059af55a 100644 --- a/Exiled.Loader/AutoUpdateFiles.cs +++ b/Exiled.Loader/AutoUpdateFiles.cs @@ -17,6 +17,6 @@ public static class AutoUpdateFiles /// /// Gets which SCP: SL version generated Exiled. /// - public static readonly Version RequiredSCPSLVersion = new(13, 2, 0, 2); + public static readonly Version RequiredSCPSLVersion = new(13, 3, 0, 0); } } \ No newline at end of file diff --git a/docs/docs/Resources/Intro.md b/docs/docs/Resources/Intro.md index ebe64b9b89..415eb9e22b 100644 --- a/docs/docs/Resources/Intro.md +++ b/docs/docs/Resources/Intro.md @@ -61,6 +61,7 @@ sidebar_position: 1 | 20 | ChaosRepressor | ChaosInsurgency | ChaosInsurgency | ChaosInsurgency | | 21 | Overwatch | Dead | None | Draw | | 22 | Filmmaker | Dead | None | Draw | +| 23 | Scp3114 | Dead | None | Draw | ``` @@ -125,6 +126,8 @@ sidebar_position: 1 [51] AntiSCP207 [52] GunFRMG0 [53] GunA7 +[54] Lantern +[55] Marshmallow ``` @@ -341,6 +344,11 @@ sidebar_position: 1 [40] Jailbird [41] Frmg0 [42] A7 +[43] Scp3114 +[44] Strangled +[45] MarshmallowMan +[46] Silent +[47] MetalPipe ``` @@ -414,6 +422,15 @@ PlayerStatsSystem::Scp018DamageHandler : AttackerDamageHandler [34] AntiScp207 [35] Scanned [36] PocketCorroding +[37] Ghostly +[38] Strangled +[39] OrangeCandy +[40] Spicy +[41] SugarCrave +[42] SugarHigh +[43] SugarRush +[44] TraumatizedByEvil +[45] Metal ``` From 9f904df5e9859f08c43d8d0c1825116cca532cd7 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 27 Oct 2023 17:00:05 +0200 Subject: [PATCH 128/207] Fixing some part of the code --- .../Scp049/ActivatingSenseEventArgs.cs | 9 ++++++++- .../Patches/Events/Scp049/ActivatingSense.cs | 19 ++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs b/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs index af082d17ce..b2809da66c 100644 --- a/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs @@ -10,6 +10,7 @@ namespace Exiled.Events.EventArgs.Scp049 using System; using API.Features; + using Exiled.API.Features.Roles; using Exiled.Events.EventArgs.Interfaces; using Scp049Role = API.Features.Roles.Scp049Role; @@ -19,6 +20,8 @@ namespace Exiled.Events.EventArgs.Scp049 /// public class ActivatingSenseEventArgs : IScp049Event, IDeniableEvent { + private Player target; + /// /// Initializes a new instance of the class with information before SCP-049 sense is activated. /// @@ -46,7 +49,11 @@ public ActivatingSenseEventArgs(Player player, Player target, bool isAllowed = t /// /// Gets or sets the Player who the sense ability is affecting. /// - public Player Target { get; set; } + public Player Target + { + get => target; + set => _ = value.Role.Is(out HumanRole _) ? target = value : target = null; + } /// /// Gets or sets the cooldown of the ability. diff --git a/Exiled.Events/Patches/Events/Scp049/ActivatingSense.cs b/Exiled.Events/Patches/Events/Scp049/ActivatingSense.cs index e66d2cda4c..d4746118de 100644 --- a/Exiled.Events/Patches/Events/Scp049/ActivatingSense.cs +++ b/Exiled.Events/Patches/Events/Scp049/ActivatingSense.cs @@ -35,9 +35,12 @@ public class ActivatingSense private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) { List newInstructions = ListPool.Pool.Get(instructions); - int offset = 2; + + // Label than return in the this.Cooldown.Trigger((double)ev.FailedCooldown) + int offset = 3; int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Ldnull) + offset; - Label failedLabel = (Label)newInstructions[index].operand; + Label failedLabel = generator.DefineLabel(); + newInstructions[index].labels.Add(failedLabel); offset = 1; index = newInstructions.FindIndex(instruction => instruction.operand == (object)PropertySetter(typeof(Scp049SenseAbility), nameof(Scp049SenseAbility.Target))) + offset; @@ -80,10 +83,10 @@ private static IEnumerable Transpiler(IEnumerable instruction.operand == (object)Method(typeof(AbilityCooldown), nameof(AbilityCooldown.Trigger))) + offset; newInstructions.RemoveAt(index); @@ -92,12 +95,13 @@ private static IEnumerable Transpiler(IEnumerable instruction.operand == (object)Method(typeof(AbilityCooldown), nameof(AbilityCooldown.Trigger))) + offset; newInstructions.RemoveAt(index); @@ -106,9 +110,10 @@ private static IEnumerable Transpiler(IEnumerable Date: Fri, 27 Oct 2023 17:01:12 +0200 Subject: [PATCH 129/207] Update Exiled.Events/Patches/Events/Player/Hurting.cs Co-authored-by: IRacle <79921583+IRacle1@users.noreply.github.com> --- Exiled.Events/Patches/Events/Player/Hurting.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.Events/Patches/Events/Player/Hurting.cs b/Exiled.Events/Patches/Events/Player/Hurting.cs index 1cf3d3a15d..f84b022471 100644 --- a/Exiled.Events/Patches/Events/Player/Hurting.cs +++ b/Exiled.Events/Patches/Events/Player/Hurting.cs @@ -111,7 +111,7 @@ private static IEnumerable Transpiler(IEnumerable Date: Fri, 27 Oct 2023 17:03:40 +0200 Subject: [PATCH 130/207] Bruh --- .../{Patches/Events => EventArgs}/Player/HurtEventArgs.cs | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Exiled.Events/{Patches/Events => EventArgs}/Player/HurtEventArgs.cs (100%) diff --git a/Exiled.Events/Patches/Events/Player/HurtEventArgs.cs b/Exiled.Events/EventArgs/Player/HurtEventArgs.cs similarity index 100% rename from Exiled.Events/Patches/Events/Player/HurtEventArgs.cs rename to Exiled.Events/EventArgs/Player/HurtEventArgs.cs From 90a7dbbc0465e8235b41354b515145666e73e2f5 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 27 Oct 2023 17:39:44 +0200 Subject: [PATCH 131/207] Fix --- Exiled.Events/EventArgs/Player/HurtEventArgs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.Events/EventArgs/Player/HurtEventArgs.cs b/Exiled.Events/EventArgs/Player/HurtEventArgs.cs index b1abacd681..951254ea64 100644 --- a/Exiled.Events/EventArgs/Player/HurtEventArgs.cs +++ b/Exiled.Events/EventArgs/Player/HurtEventArgs.cs @@ -49,7 +49,7 @@ public HurtEventArgs(Player target, DamageHandlerBase damageHandler, DamageHandl /// /// Gets the amount of inflicted damage. /// - public float Amount { get; } + public float Amount => DamageHandler.Damage; /// /// Gets or sets the action than will be made on the player. From 480b40939ddba6ff01350bdf21fb56b59c945ce8 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 27 Oct 2023 18:47:24 +0200 Subject: [PATCH 132/207] 1st try --- Exiled.API/Features/Items/Item.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Exiled.API/Features/Items/Item.cs b/Exiled.API/Features/Items/Item.cs index 2911a1071c..c00805aaa7 100644 --- a/Exiled.API/Features/Items/Item.cs +++ b/Exiled.API/Features/Items/Item.cs @@ -13,7 +13,7 @@ namespace Exiled.API.Features.Items using Exiled.API.Features.Core; using Exiled.API.Features.Pickups; using Exiled.API.Interfaces; - + using Footprinting; using InventorySystem; using InventorySystem.Items; using InventorySystem.Items.Armor; @@ -335,6 +335,9 @@ internal virtual void ChangeOwner(Player oldOwner, Player newOwner) /// -related data to give to the . internal virtual void ReadPickupInfo(Pickup pickup) { + if (!pickup.Base.PreviousOwner.IsSet) + pickup.Base.PreviousOwner = new Footprint(Server.Host.ReferenceHub); + if (pickup is not null) { Scale = pickup.Scale; From b8a600869e4c0838ce3bee05edfc69b15d70b28a Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 27 Oct 2023 21:10:14 +0200 Subject: [PATCH 133/207] Fixed crash --- .../EventArgs/Scp049/ActivatingSenseEventArgs.cs | 6 +----- .../Patches/Events/Scp049/ActivatingSense.cs | 13 ++++++++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs b/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs index b2809da66c..eb26a7d2ed 100644 --- a/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs @@ -49,11 +49,7 @@ public ActivatingSenseEventArgs(Player player, Player target, bool isAllowed = t /// /// Gets or sets the Player who the sense ability is affecting. /// - public Player Target - { - get => target; - set => _ = value.Role.Is(out HumanRole _) ? target = value : target = null; - } + public Player Target { get; set; } /// /// Gets or sets the cooldown of the ability. diff --git a/Exiled.Events/Patches/Events/Scp049/ActivatingSense.cs b/Exiled.Events/Patches/Events/Scp049/ActivatingSense.cs index d4746118de..4ec79ca1fd 100644 --- a/Exiled.Events/Patches/Events/Scp049/ActivatingSense.cs +++ b/Exiled.Events/Patches/Events/Scp049/ActivatingSense.cs @@ -53,12 +53,12 @@ private static IEnumerable Transpiler(IEnumerable), nameof(ScpStandardSubroutine.Owner))), + new(OpCodes.Callvirt, PropertyGetter(typeof(ScpStandardSubroutine), nameof(ScpStandardSubroutine.Owner))), new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), // Player.Get(this.Target) new(OpCodes.Ldarg_0), - new(OpCodes.Call, PropertyGetter(typeof(Scp049SenseAbility), nameof(Scp049SenseAbility.Target))), + new(OpCodes.Callvirt, PropertyGetter(typeof(Scp049SenseAbility), nameof(Scp049SenseAbility.Target))), new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), // true @@ -78,7 +78,14 @@ private static IEnumerable Transpiler(IEnumerable Date: Fri, 27 Oct 2023 21:10:59 +0200 Subject: [PATCH 134/207] Callvirt & Fix yamato moment --- Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs | 2 +- Exiled.Events/Patches/Events/Scp079/ZoneBlackout.cs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs b/Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs index 0f5ea3e37e..79fef9197b 100644 --- a/Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs +++ b/Exiled.Events/Patches/Events/Scp079/RoomBlackout.cs @@ -51,7 +51,7 @@ private static IEnumerable Transpiler(IEnumerable), nameof(ScpStandardSubroutine.Owner))), + new(OpCodes.Callvirt, PropertyGetter(typeof(ScpStandardSubroutine), nameof(ScpStandardSubroutine.Owner))), // this._roomController.Room new(OpCodes.Ldarg_0), diff --git a/Exiled.Events/Patches/Events/Scp079/ZoneBlackout.cs b/Exiled.Events/Patches/Events/Scp079/ZoneBlackout.cs index 286ad51b08..adf07eb341 100644 --- a/Exiled.Events/Patches/Events/Scp079/ZoneBlackout.cs +++ b/Exiled.Events/Patches/Events/Scp079/ZoneBlackout.cs @@ -49,7 +49,7 @@ private static IEnumerable Transpiler(IEnumerable), nameof(ScpStandardSubroutine.Owner))), + new(OpCodes.Callvirt, PropertyGetter(typeof(ScpStandardSubroutine), nameof(ScpStandardSubroutine.Owner))), // this._syncZone new(OpCodes.Ldarg_0), @@ -81,10 +81,12 @@ private static IEnumerable Transpiler(IEnumerable Date: Fri, 27 Oct 2023 21:13:52 +0200 Subject: [PATCH 135/207] oups --- Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs b/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs index eb26a7d2ed..d0689d9d70 100644 --- a/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs +++ b/Exiled.Events/EventArgs/Scp049/ActivatingSenseEventArgs.cs @@ -20,8 +20,6 @@ namespace Exiled.Events.EventArgs.Scp049 /// public class ActivatingSenseEventArgs : IScp049Event, IDeniableEvent { - private Player target; - /// /// Initializes a new instance of the class with information before SCP-049 sense is activated. /// From 3815b1e939bcff749be1e32056d7d7733c47e165 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 27 Oct 2023 21:18:56 +0200 Subject: [PATCH 136/207] . --- Exiled.Events/Patches/Events/Scp049/ActivatingSense.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Exiled.Events/Patches/Events/Scp049/ActivatingSense.cs b/Exiled.Events/Patches/Events/Scp049/ActivatingSense.cs index 4ec79ca1fd..e8a4115133 100644 --- a/Exiled.Events/Patches/Events/Scp049/ActivatingSense.cs +++ b/Exiled.Events/Patches/Events/Scp049/ActivatingSense.cs @@ -80,7 +80,6 @@ private static IEnumerable Transpiler(IEnumerable Date: Fri, 27 Oct 2023 21:29:42 +0200 Subject: [PATCH 137/207] Fuck --- Exiled.API/Features/Items/Item.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/Exiled.API/Features/Items/Item.cs b/Exiled.API/Features/Items/Item.cs index c00805aaa7..038c7e460e 100644 --- a/Exiled.API/Features/Items/Item.cs +++ b/Exiled.API/Features/Items/Item.cs @@ -335,9 +335,6 @@ internal virtual void ChangeOwner(Player oldOwner, Player newOwner) /// -related data to give to the . internal virtual void ReadPickupInfo(Pickup pickup) { - if (!pickup.Base.PreviousOwner.IsSet) - pickup.Base.PreviousOwner = new Footprint(Server.Host.ReferenceHub); - if (pickup is not null) { Scale = pickup.Scale; From 96a4680d9137b8b9c2c030ff6b6d10c35e0bf011 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 27 Oct 2023 22:17:44 +0200 Subject: [PATCH 138/207] Fix --- Exiled.API/Features/Items/Armor.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Exiled.API/Features/Items/Armor.cs b/Exiled.API/Features/Items/Armor.cs index 450baa3849..45a0d2c6a7 100644 --- a/Exiled.API/Features/Items/Armor.cs +++ b/Exiled.API/Features/Items/Armor.cs @@ -11,7 +11,6 @@ namespace Exiled.API.Features.Items using System.Collections.Generic; using System.Linq; - using Exiled.API.Features.Pickups; using Exiled.API.Interfaces; using InventorySystem.Items.Armor; @@ -21,8 +20,6 @@ namespace Exiled.API.Features.Items using Structs; using UnityEngine; - using BodyArmorPickup = Pickups.BodyArmorPickup; - /// /// A wrapper class for . /// @@ -127,16 +124,17 @@ public int VestEfficacy /// When attempting to set the value below 1 or above 2. public float StaminaUseMultiplier { - get => Base.StaminaUsageMultiplier; + get => Base._staminaUseMultiplier; set => Base._staminaUseMultiplier = value; } /// /// Gets or sets how much the users movement speed should be affected when wearing this armor. (higher values = slower movement). /// + /// When attempting to set the value below 0 or above 1. public float MovementSpeedMultiplier { - get => Base.MovementSpeedMultiplier; + get => Base._movementSpeedMultiplier; [Obsolete("This Setter was causing desync to client", true)] set => _ = value; } @@ -161,7 +159,6 @@ public IEnumerable AmmoLimits public IEnumerable CategoryLimits { get => Base.CategoryLimits; - set => Base.CategoryLimits = value.ToArray(); } From 14149ceda1adc9f39efd6e2bc29432bbfbfc3bda Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 27 Oct 2023 23:28:58 +0200 Subject: [PATCH 139/207] Adding Scp3114 Subroutine --- Exiled.API/Features/Roles/Scp3114Role.cs | 70 ++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/Exiled.API/Features/Roles/Scp3114Role.cs b/Exiled.API/Features/Roles/Scp3114Role.cs index 20e7e449b1..dc492df72d 100644 --- a/Exiled.API/Features/Roles/Scp3114Role.cs +++ b/Exiled.API/Features/Roles/Scp3114Role.cs @@ -35,6 +35,41 @@ internal Scp3114Role(Scp3114GameRole baseRole) Base = baseRole; SubroutineModule = baseRole.SubroutineModule; HumeShieldModule = baseRole.HumeShieldModule; + + if (!SubroutineModule.TryGetSubroutine(out Scp3114Slap scp3114Slap)) + Log.Error("Scp3114Slap not found in Scp3114Role::ctor"); + + Slap = scp3114Slap; + + if (!SubroutineModule.TryGetSubroutine(out Scp3114Dance scp3114Dance)) + Log.Error("Scp3114Dance not found in Scp3114Role::ctor"); + + Dance = scp3114Dance; + + if (!SubroutineModule.TryGetSubroutine(out Scp3114Reveal scp3114Reveal)) + Log.Error("Scp3114Reveal not found in Scp3114Role::ctor"); + + Reveal = scp3114Reveal; + + if (!SubroutineModule.TryGetSubroutine(out Scp3114Identity scp3114Identity)) + Log.Error("Scp3114Identity not found in Scp3114Role::ctor"); + + Identity = scp3114Identity; + + if (!SubroutineModule.TryGetSubroutine(out Scp3114History scp3114History)) + Log.Error("Scp3114History not found in Scp3114Role::ctor"); + + History = scp3114History; + + if (!SubroutineModule.TryGetSubroutine(out Scp3114FakeModelManager scp3114FakeModelManager)) + Log.Error("Scp3114FakeModelManager not found in Scp3114Role::ctor"); + + FakeModelManager = scp3114FakeModelManager; + + if (!SubroutineModule.TryGetSubroutine(out Scp3114Disguise scp3114Disguise)) + Log.Error("Scp3114Disguise not found in Scp3114Role::ctor"); + + Disguise = scp3114Disguise; } /// @@ -46,6 +81,41 @@ internal Scp3114Role(Scp3114GameRole baseRole) /// public HumeShieldModuleBase HumeShieldModule { get; } + /// + /// Gets SCP-173's movement module. + /// + public Scp3114Slap Slap { get; } + + /// + /// Gets SCP-173's movement module. + /// + public Scp3114Dance Dance { get; } + + /// + /// Gets SCP-173's movement module. + /// + public Scp3114Reveal Reveal { get; } + + /// + /// Gets SCP-173's movement module. + /// + public Scp3114Identity Identity { get; } + + /// + /// Gets SCP-173's movement module. + /// + public Scp3114History History { get; } + + /// + /// Gets SCP-173's movement module. + /// + public Scp3114FakeModelManager FakeModelManager { get; } + + /// + /// Gets SCP-173's movement module. + /// + public Scp3114Disguise Disguise { get; } + /// /// Gets the instance. /// From d43ada70b572f0a0f9b66d45267d7cc39b4cff77 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 27 Oct 2023 23:29:16 +0200 Subject: [PATCH 140/207] . --- Exiled.API/Features/Items/Armor.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Exiled.API/Features/Items/Armor.cs b/Exiled.API/Features/Items/Armor.cs index 45a0d2c6a7..78815b5d76 100644 --- a/Exiled.API/Features/Items/Armor.cs +++ b/Exiled.API/Features/Items/Armor.cs @@ -11,6 +11,7 @@ namespace Exiled.API.Features.Items using System.Collections.Generic; using System.Linq; + using Exiled.API.Features.Pickups; using Exiled.API.Interfaces; using InventorySystem.Items.Armor; From 531a919ef68ae06638577a674c587e13b76b1740 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 27 Oct 2023 23:31:09 +0200 Subject: [PATCH 141/207] . --- Exiled.API/Features/Items/Armor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.API/Features/Items/Armor.cs b/Exiled.API/Features/Items/Armor.cs index 78815b5d76..bd7358c677 100644 --- a/Exiled.API/Features/Items/Armor.cs +++ b/Exiled.API/Features/Items/Armor.cs @@ -182,7 +182,7 @@ public IEnumerable CategoryLimits internal override void ReadPickupInfo(Pickup pickup) { base.ReadPickupInfo(pickup); - if (pickup is BodyArmorPickup armorPickup) + if (pickup is Pickups.BodyArmorPickup armorPickup) { HelmetEfficacy = armorPickup.HelmetEfficacy; VestEfficacy = armorPickup.VestEfficacy; From 661820625c8b02ac637aedc53555a41e9e33fb49 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sat, 28 Oct 2023 00:28:53 +0200 Subject: [PATCH 142/207] Missing features for halloween --- Exiled.API/Enums/EffectType.cs | 2 + Exiled.API/Extensions/EffectTypeExtension.cs | 4 ++ Exiled.API/Features/Hazards/PrismaticCloud.cs | 46 +++++++++++++++++++ Exiled.API/Features/Hazards/TantrumHazard.cs | 12 ++++- 4 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 Exiled.API/Features/Hazards/PrismaticCloud.cs diff --git a/Exiled.API/Enums/EffectType.cs b/Exiled.API/Enums/EffectType.cs index 7338477290..fe16077b6f 100644 --- a/Exiled.API/Enums/EffectType.cs +++ b/Exiled.API/Enums/EffectType.cs @@ -218,6 +218,8 @@ public enum EffectType SugarRush, TraumatizedByEvil, Metal, + Prismatic, + SlowMetabolism, #pragma warning restore SA1602 // Enumeration items should be documented #pragma warning restore CS1591 // Commentaire XML manquant pour le type ou le membre visible publiquement } diff --git a/Exiled.API/Extensions/EffectTypeExtension.cs b/Exiled.API/Extensions/EffectTypeExtension.cs index e984b9c9d3..0c8811e3b7 100644 --- a/Exiled.API/Extensions/EffectTypeExtension.cs +++ b/Exiled.API/Extensions/EffectTypeExtension.cs @@ -75,6 +75,8 @@ public static class EffectTypeExtension EffectType.SugarRush => typeof(SugarRush), EffectType.TraumatizedByEvil => typeof(TraumatizedByEvil), EffectType.Metal => typeof(Metal), + EffectType.Prismatic => typeof(Prismatic), + EffectType.SlowMetabolism => typeof(SlowMetabolism), // This should never happen _ => throw new InvalidOperationException("Invalid effect enum provided"), @@ -132,6 +134,8 @@ public static class EffectTypeExtension SugarHigh => EffectType.SugarHigh, SugarRush => EffectType.SugarRush, TraumatizedByEvil => EffectType.TraumatizedByEvil, + Prismatic => EffectType.Prismatic, + SlowMetabolism => EffectType.SlowMetabolism, // This should never happen _ => throw new InvalidOperationException("Invalid effect status base provided"), diff --git a/Exiled.API/Features/Hazards/PrismaticCloud.cs b/Exiled.API/Features/Hazards/PrismaticCloud.cs new file mode 100644 index 0000000000..df5fcc625e --- /dev/null +++ b/Exiled.API/Features/Hazards/PrismaticCloud.cs @@ -0,0 +1,46 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.API.Features.Hazards +{ + using global::Hazards; + using PlayerRoles; + using RelativePositioning; + using UnityEngine; + + using PrismaticCloudHazard = global::Hazards.PrismaticCloud; + + /// + /// A wrapper for . + /// + public class PrismaticCloud : TemporaryHazard + { + /// + /// Initializes a new instance of the class. + /// + /// The instance. + public PrismaticCloud(PrismaticCloudHazard hazard) + : base(hazard) + { + Base = hazard; + } + + /// + /// Gets the . + /// + public new PrismaticCloudHazard Base { get; } + + /// + /// Gets or sets the synced position. + /// + public RelativePosition SynchronisedPosition + { + get => Base.SynchronizedPosition; + set => Base.SynchronizedPosition = value; + } + } +} diff --git a/Exiled.API/Features/Hazards/TantrumHazard.cs b/Exiled.API/Features/Hazards/TantrumHazard.cs index 15f54b5ac0..025047aaea 100644 --- a/Exiled.API/Features/Hazards/TantrumHazard.cs +++ b/Exiled.API/Features/Hazards/TantrumHazard.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- // // Copyright (c) Exiled Team. All rights reserved. // Licensed under the CC BY-SA 3.0 license. @@ -8,6 +8,7 @@ namespace Exiled.API.Features.Hazards { using global::Hazards; + using PlayerRoles; using RelativePositioning; using UnityEngine; @@ -57,5 +58,14 @@ public Transform CorrectPosition get => Base._correctPosition; set => Base._correctPosition = value; } + + /// + /// Gets or sets the teams that will be affected by this Tantrum. + /// + public Team[] TargetedTeams + { + get => Base._targetedTeams; + set => Base._targetedTeams = value; + } } } \ No newline at end of file From 7838133e24ad48350cc2ba3649d5d04d0d807bf3 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sat, 28 Oct 2023 09:32:50 +0200 Subject: [PATCH 143/207] Update Version --- EXILED.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED.props b/EXILED.props index cffe478ed5..2d8567007d 100644 --- a/EXILED.props +++ b/EXILED.props @@ -15,7 +15,7 @@ - 8.3.0 + 8.3.1 false From 2484381ed578d14f4e92659b03fdd050c88a9708 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sat, 28 Oct 2023 12:57:16 +0200 Subject: [PATCH 144/207] Flashlight can now contain Lantern --- Exiled.API/Features/Items/Flashlight.cs | 17 +++++++++-------- Exiled.API/Features/Items/Item.cs | 5 +++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Exiled.API/Features/Items/Flashlight.cs b/Exiled.API/Features/Items/Flashlight.cs index 1f60699547..716fd0afb6 100644 --- a/Exiled.API/Features/Items/Flashlight.cs +++ b/Exiled.API/Features/Items/Flashlight.cs @@ -13,15 +13,15 @@ namespace Exiled.API.Features.Items using Utils.Networking; /// - /// A wrapped class for . + /// A wrapped class for . /// - public class Flashlight : Item, IWrapper + public class Flashlight : Item, IWrapper { /// /// Initializes a new instance of the class. /// - /// The base class. - public Flashlight(FlashlightItem itemBase) + /// The base class. + public Flashlight(SwitchableLightSourceItemBase itemBase) : base(itemBase) { Base = itemBase; @@ -30,15 +30,16 @@ public Flashlight(FlashlightItem itemBase) /// /// Initializes a new instance of the class, as well as a new Flashlight item. /// - internal Flashlight() - : this((FlashlightItem)Server.Host.Inventory.CreateItemInstance(new(ItemType.Flashlight, 0), false)) + /// The of the flashlight. + internal Flashlight(ItemType type) + : this((SwitchableLightSourceItemBase)Server.Host.Inventory.CreateItemInstance(new(type, 0), false)) { } /// /// Gets the that this class is encapsulating. /// - public new FlashlightItem Base { get; } + public new SwitchableLightSourceItemBase Base { get; } /// /// Gets or sets a value indicating whether the flashlight is turned on. @@ -57,7 +58,7 @@ public bool Active /// Clones current object. /// /// New object. - public override Item Clone() => new Flashlight() + public override Item Clone() => new Flashlight(Type) { Active = Active, }; diff --git a/Exiled.API/Features/Items/Item.cs b/Exiled.API/Features/Items/Item.cs index 8766717ea5..423bcd280b 100644 --- a/Exiled.API/Features/Items/Item.cs +++ b/Exiled.API/Features/Items/Item.cs @@ -23,6 +23,7 @@ namespace Exiled.API.Features.Items using InventorySystem.Items.MicroHID; using InventorySystem.Items.Pickups; using InventorySystem.Items.Radio; + using InventorySystem.Items.SwitchableLightSources; using InventorySystem.Items.SwitchableLightSources.Flashlight; using InventorySystem.Items.ThrowableProjectiles; using InventorySystem.Items.Usables; @@ -195,7 +196,7 @@ public static Item Get(ItemBase itemBase) MicroHIDItem micro => new MicroHid(micro), BodyArmor armor => new Armor(armor), AmmoItem ammo => new Ammo(ammo), - FlashlightItem flashlight => new Flashlight(flashlight), + SwitchableLightSourceItemBase flashlight => new Flashlight(flashlight), JailbirdItem jailbird => new Jailbird(jailbird), ThrowableItem throwable => throwable.Projectile switch { @@ -252,7 +253,7 @@ public static Item Get(ItemBase itemBase) ItemType.Adrenaline or ItemType.Medkit or ItemType.Painkillers or ItemType.SCP500 or ItemType.SCP207 or ItemType.SCP1853 => new Consumable(type), ItemType.SCP244a or ItemType.SCP244b => new Scp244(type), ItemType.Ammo9x19 or ItemType.Ammo12gauge or ItemType.Ammo44cal or ItemType.Ammo556x45 or ItemType.Ammo762x39 => new Ammo(type), - ItemType.Flashlight => new Flashlight(), + ItemType.Flashlight or ItemType.Lantern => new Flashlight(type), ItemType.Radio => new Radio(), ItemType.MicroHID => new MicroHid(), ItemType.GrenadeFlash => new FlashGrenade(owner), From 6d2f45db5fa98ed030b3c5dedcebe0a028de9e9c Mon Sep 17 00:00:00 2001 From: Nameless <85962933+Misfiy@users.noreply.github.com> Date: Sat, 28 Oct 2023 13:29:40 +0200 Subject: [PATCH 145/207] ChaosTargetCounter --- Exiled.API/Features/Round.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Exiled.API/Features/Round.cs b/Exiled.API/Features/Round.cs index 11e44049a9..1ffd6ef6a9 100644 --- a/Exiled.API/Features/Round.cs +++ b/Exiled.API/Features/Round.cs @@ -61,6 +61,15 @@ public static class Round /// public static bool IsLobby => !(IsEnded || IsStarted); + /// + /// Gets or sets a value indicating the amount of Chaos Targets remaining. + /// + public static int ChaosTargetCount + { + get => RoundSummary.singleton.ChaosTargetCount; + set => RoundSummary.singleton.ChaosTargetCount = value; + } + /// /// Gets or sets a value indicating whether the round is locked or not. /// @@ -240,4 +249,4 @@ public static bool EndRound(bool forceEnd = false) /// public static void Start() => CharacterClassManager.ForceRoundStart(); } -} \ No newline at end of file +} From 7fe79e350c0c10636185bcf9a7350ad7668a7906 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sat, 28 Oct 2023 15:36:59 +0200 Subject: [PATCH 146/207] Map::PrismaticCloud --- Exiled.API/Features/Map.cs | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/Exiled.API/Features/Map.cs b/Exiled.API/Features/Map.cs index 96ce18c60f..1c17f3dd88 100644 --- a/Exiled.API/Features/Map.cs +++ b/Exiled.API/Features/Map.cs @@ -28,6 +28,7 @@ namespace Exiled.API.Features using MapGeneration; using MapGeneration.Distributors; using Mirror; + using Mirror.LiteNetLib4Mirror; using PlayerRoles; using PlayerRoles.PlayableScps.Scp173; using PlayerRoles.PlayableScps.Scp939; @@ -63,9 +64,33 @@ public static class Map private static TantrumEnvironmentalHazard tantrumPrefab; private static Scp939AmnesticCloudInstance amnesticCloudPrefab; + private static global::Hazards.PrismaticCloud prismaticCloudPrefab; private static AmbientSoundPlayer ambientSoundPlayer; + /// + /// Gets the tantrum prefab. + /// + public static global::Hazards.PrismaticCloud PrismaticCloud + { + get + { + if (prismaticCloudPrefab == null) + { + foreach (GameObject prefab in LiteNetLib4MirrorNetworkManager.singleton.spawnPrefabs) + { + if (prefab.TryGetComponent(out global::Hazards.PrismaticCloud prismaticCloud)) + { + prismaticCloudPrefab = prismaticCloud; + break; + } + } + } + + return prismaticCloudPrefab; + } + } + /// /// Gets the tantrum prefab. /// @@ -86,7 +111,7 @@ public static TantrumEnvironmentalHazard TantrumPrefab } /// - /// Gets the amnestic cloud prefab. + /// Gets the prismatic cloud prefab. /// public static Scp939AmnesticCloudInstance AmnesticCloudPrefab { From 9fc5eb372220083e6ece12abc11881853f357095 Mon Sep 17 00:00:00 2001 From: Nameless <85962933+Misfiy@users.noreply.github.com> Date: Sat, 28 Oct 2023 15:50:05 +0200 Subject: [PATCH 147/207] Network_chaosTargetCount --- Exiled.API/Features/Round.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Exiled.API/Features/Round.cs b/Exiled.API/Features/Round.cs index 1ffd6ef6a9..f7ea6e8e9b 100644 --- a/Exiled.API/Features/Round.cs +++ b/Exiled.API/Features/Round.cs @@ -66,8 +66,8 @@ public static class Round /// public static int ChaosTargetCount { - get => RoundSummary.singleton.ChaosTargetCount; - set => RoundSummary.singleton.ChaosTargetCount = value; + get => RoundSummary.singleton.Network_chaosTargetCount; + set => RoundSummary.singleton.Network_chaosTargetCount = value; } /// From 7745b36e488067ca0cd207af398b8b420edcdc9b Mon Sep 17 00:00:00 2001 From: Thunder Date: Sat, 28 Oct 2023 09:57:36 -0400 Subject: [PATCH 148/207] Add Scp3114 to RoleExtensions --- Exiled.API/Enums/Side.cs | 2 +- Exiled.API/Extensions/RoleExtensions.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Exiled.API/Enums/Side.cs b/Exiled.API/Enums/Side.cs index 3a8b1346d6..fdc329c90c 100644 --- a/Exiled.API/Enums/Side.cs +++ b/Exiled.API/Enums/Side.cs @@ -26,7 +26,7 @@ public enum Side /// /// SCP team. Same as . /// Contains all SCP-related roles: , , , , - /// , , and . + /// , , , and . /// Scp, diff --git a/Exiled.API/Extensions/RoleExtensions.cs b/Exiled.API/Extensions/RoleExtensions.cs index 60bc7e0065..76be3ff7f6 100644 --- a/Exiled.API/Extensions/RoleExtensions.cs +++ b/Exiled.API/Extensions/RoleExtensions.cs @@ -65,7 +65,7 @@ public static class RoleExtensions RoleTypeId.ChaosConscript or RoleTypeId.ChaosMarauder or RoleTypeId.ChaosRepressor or RoleTypeId.ChaosRifleman => Team.ChaosInsurgency, RoleTypeId.Scientist => Team.Scientists, RoleTypeId.ClassD => Team.ClassD, - RoleTypeId.Scp049 or RoleTypeId.Scp939 or RoleTypeId.Scp0492 or RoleTypeId.Scp079 or RoleTypeId.Scp096 or RoleTypeId.Scp106 or RoleTypeId.Scp173 => Team.SCPs, + RoleTypeId.Scp049 or RoleTypeId.Scp939 or RoleTypeId.Scp0492 or RoleTypeId.Scp079 or RoleTypeId.Scp096 or RoleTypeId.Scp106 or RoleTypeId.Scp173 or RoleTypeId.Scp3114 => Team.SCPs, RoleTypeId.FacilityGuard or RoleTypeId.NtfCaptain or RoleTypeId.NtfPrivate or RoleTypeId.NtfSergeant or RoleTypeId.NtfSpecialist => Team.FoundationForces, RoleTypeId.Tutorial => Team.OtherAlive, _ => Team.Dead, From ce7742f2a7f8f0a96552b6e50ce51c3cbb4d1a7a Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sat, 28 Oct 2023 20:21:57 +0200 Subject: [PATCH 149/207] i fix this little doc --- Exiled.API/Features/Map.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Exiled.API/Features/Map.cs b/Exiled.API/Features/Map.cs index 1c17f3dd88..4342640c3d 100644 --- a/Exiled.API/Features/Map.cs +++ b/Exiled.API/Features/Map.cs @@ -69,7 +69,7 @@ public static class Map private static AmbientSoundPlayer ambientSoundPlayer; /// - /// Gets the tantrum prefab. + /// Gets the prismatic prefab. /// public static global::Hazards.PrismaticCloud PrismaticCloud { @@ -111,7 +111,7 @@ public static TantrumEnvironmentalHazard TantrumPrefab } /// - /// Gets the prismatic cloud prefab. + /// Gets the amnestic cloud prefab. /// public static Scp939AmnesticCloudInstance AmnesticCloudPrefab { From 8cc368ce6023a06ac15f2c64a2c3e4cb8fe6398d Mon Sep 17 00:00:00 2001 From: Yamato <66829532+louis1706@users.noreply.github.com> Date: Sat, 28 Oct 2023 20:25:42 +0200 Subject: [PATCH 150/207] DON'T MERGE it's not FINISH (#2180) * MethodPatched are clearly wrong * Disguise * revealing * e * fix * e * yes * fix --------- Co-authored-by: IRacle --- Exiled.API/Features/Roles/Scp3114Role.cs | 95 +++++++++++++++++-- .../EventArgs/Interfaces/IScp3114Event.cs | 22 +++++ .../EventArgs/Scp3114/DisguisedEventArgs.cs | 46 +++++++++ .../EventArgs/Scp3114/DisguisingEventArgs.cs | 49 ++++++++++ .../EventArgs/Scp3114/RevealedEventArgs.cs | 37 ++++++++ .../EventArgs/Scp3114/RevealingEventArgs.cs | 44 +++++++++ .../EventArgs/Scp3114/TryUseBodyEventArgs.cs | 52 ++++++++++ Exiled.Events/Handlers/Scp3114.cs | 76 +++++++++++++++ .../Patches/Events/Scp3114/Disguising.cs | 51 ++++++++++ .../Patches/Events/Scp3114/Revealing.cs | 86 +++++++++++++++++ .../Patches/Events/Scp3114/TryUseBody.cs | 54 +++++++++++ 11 files changed, 603 insertions(+), 9 deletions(-) create mode 100644 Exiled.Events/EventArgs/Interfaces/IScp3114Event.cs create mode 100644 Exiled.Events/EventArgs/Scp3114/DisguisedEventArgs.cs create mode 100644 Exiled.Events/EventArgs/Scp3114/DisguisingEventArgs.cs create mode 100644 Exiled.Events/EventArgs/Scp3114/RevealedEventArgs.cs create mode 100644 Exiled.Events/EventArgs/Scp3114/RevealingEventArgs.cs create mode 100644 Exiled.Events/EventArgs/Scp3114/TryUseBodyEventArgs.cs create mode 100644 Exiled.Events/Handlers/Scp3114.cs create mode 100644 Exiled.Events/Patches/Events/Scp3114/Disguising.cs create mode 100644 Exiled.Events/Patches/Events/Scp3114/Revealing.cs create mode 100644 Exiled.Events/Patches/Events/Scp3114/TryUseBody.cs diff --git a/Exiled.API/Features/Roles/Scp3114Role.cs b/Exiled.API/Features/Roles/Scp3114Role.cs index dc492df72d..87293dc0d3 100644 --- a/Exiled.API/Features/Roles/Scp3114Role.cs +++ b/Exiled.API/Features/Roles/Scp3114Role.cs @@ -11,17 +11,21 @@ namespace Exiled.API.Features.Roles using System.Linq; using Exiled.API.Features.Hazards; + using Exiled.API.Interfaces; using Mirror; using PlayerRoles; using PlayerRoles.PlayableScps.HumeShield; using PlayerRoles.PlayableScps.Scp3114; using PlayerRoles.PlayableScps.Subroutines; + using PlayerRoles.Ragdolls; using UnityEngine; + using static PlayerRoles.PlayableScps.Scp3114.Scp3114Identity; + using Scp3114GameRole = PlayerRoles.PlayableScps.Scp3114.Scp3114Role; /// - /// Defines a role that represents SCP-173. + /// Defines a role that represents SCP-3114. /// public class Scp3114Role : FpcRole, ISubroutinedScpRole, IHumeShieldRole { @@ -82,37 +86,37 @@ internal Scp3114Role(Scp3114GameRole baseRole) public HumeShieldModuleBase HumeShieldModule { get; } /// - /// Gets SCP-173's movement module. + /// Gets Scp3114's . /// public Scp3114Slap Slap { get; } /// - /// Gets SCP-173's movement module. + /// Gets Scp3114's . /// public Scp3114Dance Dance { get; } /// - /// Gets SCP-173's movement module. + /// Gets Scp3114's . /// public Scp3114Reveal Reveal { get; } /// - /// Gets SCP-173's movement module. + /// Gets Scp3114's . /// public Scp3114Identity Identity { get; } /// - /// Gets SCP-173's movement module. + /// Gets Scp3114's . /// public Scp3114History History { get; } /// - /// Gets SCP-173's movement module. + /// Gets Scp3114's . /// public Scp3114FakeModelManager FakeModelManager { get; } /// - /// Gets SCP-173's movement module. + /// Gets Scp3114's . /// public Scp3114Disguise Disguise { get; } @@ -122,7 +126,80 @@ internal Scp3114Role(Scp3114GameRole baseRole) public new Scp3114GameRole Base { get; } /// - /// Gets the Spawn Chance of SCP-173. + /// Gets or sets the SCP-3114's Stolen Role. + /// + public RoleTypeId StolenRole + { + get => Identity.CurIdentity.StolenRole; + set + { + if (Ragdoll is null) + return; + + Ragdoll.Role = value; + Identity.ServerResendIdentity(); + } + } + + /// + /// Gets or sets the SCP-3114's Ragdoll used for it's FakeIdentity. + /// + public Ragdoll Ragdoll + { + get => Ragdoll.Get(Identity.CurIdentity.Ragdoll); + set + { + Identity.CurIdentity.Ragdoll = value?.Base; + Identity.ServerResendIdentity(); + } + } + + /// + /// Gets or sets the SCP-3114's UnitId used for it's FakeIdentity. + /// + public byte UnitId + { + get => Identity.CurIdentity.UnitNameId; + set + { + Identity.CurIdentity.UnitNameId = value; + Identity.ServerResendIdentity(); + } + } + + /// + /// Gets or sets the SCP-3114's UnitId used for it's FakeIdentity. + /// + public DisguiseStatus DisguiseStatus + { + get => Identity.CurIdentity.Status; + set + { + Identity.CurIdentity.Status = value; + Identity.ServerResendIdentity(); + } + } + + /// + /// Gets or sets the SCP-3114's Disguise duration. + /// + public float DisguiseDuration + { + get => Identity._disguiseDurationSeconds; + set => Identity._disguiseDurationSeconds = value; + } + + /// + /// Reset Scp3114 FakeIdentity. + /// + public void ResetIdentity() + { + Identity.CurIdentity.Reset(); + Identity.ServerResendIdentity(); + } + + /// + /// Gets the Spawn Chance of SCP-3114. /// /// The List of Roles already spawned. /// The Spawn Chance. diff --git a/Exiled.Events/EventArgs/Interfaces/IScp3114Event.cs b/Exiled.Events/EventArgs/Interfaces/IScp3114Event.cs new file mode 100644 index 0000000000..b9ce041be5 --- /dev/null +++ b/Exiled.Events/EventArgs/Interfaces/IScp3114Event.cs @@ -0,0 +1,22 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Interfaces +{ + using Exiled.API.Features.Roles; + + /// + /// Event args used for all related events. + /// + public interface IScp3114Event : IPlayerEvent + { + /// + /// Gets the triggering the event. + /// + public Scp3114Role Scp3114 { get; } + } +} \ No newline at end of file diff --git a/Exiled.Events/EventArgs/Scp3114/DisguisedEventArgs.cs b/Exiled.Events/EventArgs/Scp3114/DisguisedEventArgs.cs new file mode 100644 index 0000000000..2e9a10487a --- /dev/null +++ b/Exiled.Events/EventArgs/Scp3114/DisguisedEventArgs.cs @@ -0,0 +1,46 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Scp3114 +{ + using API.Features; + using Exiled.API.Features.Roles; + using Interfaces; + + using PlayerRoles.Ragdolls; + + /// + /// Contains all information before SCP-3114 changes its target focus. + /// + public class DisguisedEventArgs : IScp3114Event, IRagdollEvent + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// + /// + /// + /// + public DisguisedEventArgs(ReferenceHub player, DynamicRagdoll ragdoll) + { + Player = Player.Get(player); + Scp3114 = Player.Role.As(); + Ragdoll = Ragdoll.Get(ragdoll); + } + + /// + public Player Player { get; } + + /// + public Scp3114Role Scp3114 { get; } + + /// + public Ragdoll Ragdoll { get; } + } +} \ No newline at end of file diff --git a/Exiled.Events/EventArgs/Scp3114/DisguisingEventArgs.cs b/Exiled.Events/EventArgs/Scp3114/DisguisingEventArgs.cs new file mode 100644 index 0000000000..198d9d8c3c --- /dev/null +++ b/Exiled.Events/EventArgs/Scp3114/DisguisingEventArgs.cs @@ -0,0 +1,49 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Scp3114 +{ + using API.Features; + using Exiled.API.Features.Roles; + using Interfaces; + + using PlayerRoles.Ragdolls; + + /// + /// Contains all information before SCP-3114 it's diguised to a new role. + /// + public class DisguisingEventArgs : IScp3114Event, IDeniableEvent, IRagdollEvent + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// + /// + /// + /// + public DisguisingEventArgs(ReferenceHub player, DynamicRagdoll ragdoll) + { + Player = Player.Get(player); + Scp3114 = Player.Role.As(); + Ragdoll = Ragdoll.Get(ragdoll); + } + + /// + public bool IsAllowed { get; set; } = true; + + /// + public Player Player { get; } + + /// + public Scp3114Role Scp3114 { get; } + + /// + public Ragdoll Ragdoll { get; } + } +} \ No newline at end of file diff --git a/Exiled.Events/EventArgs/Scp3114/RevealedEventArgs.cs b/Exiled.Events/EventArgs/Scp3114/RevealedEventArgs.cs new file mode 100644 index 0000000000..8f88be803f --- /dev/null +++ b/Exiled.Events/EventArgs/Scp3114/RevealedEventArgs.cs @@ -0,0 +1,37 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Scp3114 +{ + using API.Features; + using Exiled.API.Features.Roles; + using Interfaces; + + /// + /// Contains all information before SCP-3114 changes its target focus. + /// + public class RevealedEventArgs : IScp3114Event + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// + public RevealedEventArgs(ReferenceHub player) + { + Player = Player.Get(player); + Scp3114 = Player.Role.As(); + } + + /// + public Player Player { get; } + + /// + public Scp3114Role Scp3114 { get; } + } +} \ No newline at end of file diff --git a/Exiled.Events/EventArgs/Scp3114/RevealingEventArgs.cs b/Exiled.Events/EventArgs/Scp3114/RevealingEventArgs.cs new file mode 100644 index 0000000000..f9efca5b5e --- /dev/null +++ b/Exiled.Events/EventArgs/Scp3114/RevealingEventArgs.cs @@ -0,0 +1,44 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Scp3114 +{ + using API.Features; + using Exiled.API.Features.Roles; + using Interfaces; + + /// + /// Contains all information before SCP-3114 changes its target focus. + /// + public class RevealingEventArgs : IScp3114Event, IDeniableEvent + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// + /// + /// + /// + public RevealingEventArgs(ReferenceHub player, bool isAllowed = true) + { + Player = Player.Get(player); + Scp3114 = Player.Role.As(); + IsAllowed = isAllowed; + } + + /// + public bool IsAllowed { get; set; } + + /// + public Player Player { get; } + + /// + public Scp3114Role Scp3114 { get; } + } +} \ No newline at end of file diff --git a/Exiled.Events/EventArgs/Scp3114/TryUseBodyEventArgs.cs b/Exiled.Events/EventArgs/Scp3114/TryUseBodyEventArgs.cs new file mode 100644 index 0000000000..7cd8b99bec --- /dev/null +++ b/Exiled.Events/EventArgs/Scp3114/TryUseBodyEventArgs.cs @@ -0,0 +1,52 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Scp3114 +{ + using API.Features; + using Exiled.API.Features.Roles; + using Interfaces; + using PlayerRoles.Ragdolls; + + /// + /// Contains all information before SCP-3114 changes its target focus. + /// + public class TryUseBodyEventArgs : IScp3114Event, IDeniableEvent, IRagdollEvent + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public TryUseBodyEventArgs(ReferenceHub player, BasicRagdoll ragdoll, bool isAllowed = true) + { + Player = Player.Get(player); + Scp3114 = Player.Role.As(); + Ragdoll = Ragdoll.Get(ragdoll); + IsAllowed = isAllowed; + } + + /// + public bool IsAllowed { get; set; } + + /// + public Player Player { get; } + + /// + public Ragdoll Ragdoll { get; } + + /// + public Scp3114Role Scp3114 { get; } + } +} \ No newline at end of file diff --git a/Exiled.Events/Handlers/Scp3114.cs b/Exiled.Events/Handlers/Scp3114.cs new file mode 100644 index 0000000000..1e85bf7ad5 --- /dev/null +++ b/Exiled.Events/Handlers/Scp3114.cs @@ -0,0 +1,76 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Handlers +{ +#pragma warning disable SA1623 // Property summary documentation should match accessors + + using Exiled.Events.EventArgs.Scp244; + using Exiled.Events.EventArgs.Scp3114; + using Exiled.Events.Features; + + /// + /// Scp3114 related events. + /// + public static class Scp3114 + { + /// + /// Invoked before Disguising. + /// + public static Event Disguising { get; set; } = new(); + + /// + /// Invoked before Disguising. + /// + public static Event Disguised { get; set; } = new(); + + /// + /// Invoked before Disguising. + /// + public static Event TryUseBody { get; set; } = new(); + + /// + /// Invoked before Disguising. + /// + public static Event Revealed { get; set; } = new(); + + /// + /// Invoked before Disguising. + /// + public static Event Revealing { get; set; } = new(); + + /// + /// Called before diguising to a new Roles. + /// + /// The instance. + public static void OnDisguising(DisguisingEventArgs ev) => Disguising.InvokeSafely(ev); + + /// + /// Called before diguising to a new Roles. + /// + /// The instance. + public static void OnDisguised(DisguisedEventArgs ev) => Disguised.InvokeSafely(ev); + + /// + /// Called before diguising to a new Roles. + /// + /// The instance. + public static void OnTryUseBody(TryUseBodyEventArgs ev) => TryUseBody.InvokeSafely(ev); + + /// + /// Called before diguising to a new Roles. + /// + /// The instance. + public static void OnRevealed(RevealedEventArgs ev) => Revealed.InvokeSafely(ev); + + /// + /// Called before diguising to a new Roles. + /// + /// The instance. + public static void OnRevealing(RevealingEventArgs ev) => Revealing.InvokeSafely(ev); + } +} \ No newline at end of file diff --git a/Exiled.Events/Patches/Events/Scp3114/Disguising.cs b/Exiled.Events/Patches/Events/Scp3114/Disguising.cs new file mode 100644 index 0000000000..863aaf5298 --- /dev/null +++ b/Exiled.Events/Patches/Events/Scp3114/Disguising.cs @@ -0,0 +1,51 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Events.Scp3114 +{ + using Exiled.Events.Attributes; + using Exiled.Events.EventArgs.Scp3114; + using Exiled.Events.Handlers; + +#pragma warning disable SA1313 // Parameter names should begin with lower-case letter + + using HarmonyLib; + using Mirror; + using PlayerRoles.PlayableScps.Scp3114; + using PlayerRoles.PlayableScps.Subroutines; + using PlayerRoles.Ragdolls; + + /// + /// Patches . + /// Adds the and events. + /// + [EventPatch(typeof(Scp3114), nameof(Scp3114.Disguising))] + [EventPatch(typeof(Scp3114), nameof(Scp3114.Disguised))] + [HarmonyPatch(typeof(Scp3114Disguise), nameof(Scp3114Disguise.ServerComplete))] + internal class Disguising + { + private static bool Prefix(Scp3114Disguise __instance) + { + if (__instance.CurRagdoll != null && __instance.CurRagdoll is DynamicRagdoll ragdoll) + { + DisguisingEventArgs disguising = new(__instance.Owner, ragdoll); + Scp3114.OnDisguising(disguising); + + if (!disguising.IsAllowed) + return false; + + __instance.ScpRole.Disguised = true; + Scp3114RagdollToBonesConverter.ServerConvertNew(__instance.ScpRole, ragdoll); + + DisguisedEventArgs disguised = new(__instance.Owner, ragdoll); + Scp3114.OnDisguised(disguised); + } + + return false; + } + } +} diff --git a/Exiled.Events/Patches/Events/Scp3114/Revealing.cs b/Exiled.Events/Patches/Events/Scp3114/Revealing.cs new file mode 100644 index 0000000000..9c0d6fe54a --- /dev/null +++ b/Exiled.Events/Patches/Events/Scp3114/Revealing.cs @@ -0,0 +1,86 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Events.Scp3114 +{ + using Exiled.Events.Attributes; +#pragma warning disable SA1313 // Parameter names should begin with lower-case letter +#pragma warning disable SA1402 // File may only contain a single type + using Exiled.Events.EventArgs.Scp3114; + using Exiled.Events.Handlers; + + using HarmonyLib; + + using Mirror; + + using PlayerRoles.PlayableScps.Scp3114; + + using static PlayerRoles.PlayableScps.Scp3114.Scp3114Identity; + + /// + /// Patches setter. + /// Adds the and event. + /// + [EventPatch(typeof(Scp3114), nameof(Scp3114.Revealed))] + [EventPatch(typeof(Scp3114), nameof(Scp3114.Revealing))] + [HarmonyPatch(typeof(Scp3114Identity), nameof(Scp3114Identity.Update))] + internal class Revealing + { + private static bool Prefix(Scp3114Identity __instance) + { + __instance.UpdateWarningAudio(); + if (NetworkServer.active && __instance.CurIdentity.Status == DisguiseStatus.Active && __instance.RemainingDuration.IsReady) + { + RevealingEventArgs revealing = new(__instance.Owner); + Handlers.Scp3114.OnRevealing(revealing); + if (!revealing.IsAllowed) + { + __instance.RemainingDuration.Trigger(__instance._disguiseDurationSeconds); + __instance.ServerResendIdentity(); + return false; + } + + __instance.CurIdentity.Status = DisguiseStatus.None; + __instance.ServerResendIdentity(); + + RevealedEventArgs revealed = new(__instance.Owner); + Handlers.Scp3114.OnRevealed(revealed); + } + + return false; + } + } + + /// + /// Patches . + /// Adds the and event. + /// + [EventPatch(typeof(Scp3114), nameof(Scp3114.Revealed))] + [EventPatch(typeof(Scp3114), nameof(Scp3114.Revealing))] + [HarmonyPatch(typeof(Scp3114Reveal), nameof(Scp3114Reveal.ServerProcessCmd))] + internal class RevealingKey + { + private static bool Prefix(Scp3114Reveal __instance, NetworkReader reader) + { + RevealingEventArgs revealing = new(__instance.Owner); + Handlers.Scp3114.OnRevealing(revealing); + + if (!revealing.IsAllowed) + { + return false; + } + + __instance.ServerProcessCmd(reader); + __instance.ScpRole.Disguised = false; + + RevealedEventArgs revealed = new(__instance.Owner); + Handlers.Scp3114.OnRevealed(revealed); + + return false; + } + } +} diff --git a/Exiled.Events/Patches/Events/Scp3114/TryUseBody.cs b/Exiled.Events/Patches/Events/Scp3114/TryUseBody.cs new file mode 100644 index 0000000000..6315783243 --- /dev/null +++ b/Exiled.Events/Patches/Events/Scp3114/TryUseBody.cs @@ -0,0 +1,54 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Events.Scp3114 +{ + using Exiled.Events.Attributes; + using Exiled.Events.EventArgs.Scp3114; + using Exiled.Events.Handlers; +#pragma warning disable SA1313 // Parameter names should begin with lower-case letter + using HarmonyLib; + using PlayerRoles.PlayableScps.Scp3114; + + /// + /// Patches . + /// Adds the event. + /// + [EventPatch(typeof(Scp3114), nameof(Scp3114.TryUseBody))] + [HarmonyPatch(typeof(Scp3114Disguise), nameof(Scp3114Disguise.OnProgressSet))] + internal class TryUseBody + { + private static bool Prefix(Scp3114Disguise __instance) + { + __instance.OnProgressSet(); + Scp3114Identity.StolenIdentity curIdentity = __instance.ScpRole.CurIdentity; + if (__instance.IsInProgress) + { + TryUseBodyEventArgs ev = new(__instance.Owner, __instance.CurRagdoll, true); + Handlers.Scp3114.OnTryUseBody(ev); + + if (!ev.IsAllowed) + return false; + + __instance._equipSkinSound.Play(); + curIdentity.Ragdoll = __instance.CurRagdoll; + curIdentity.UnitNameId = __instance._prevUnitIds.TryGetValue(__instance.CurRagdoll, out byte b) ? b : byte.MinValue; + curIdentity.Status = Scp3114Identity.DisguiseStatus.Equipping; + return false; + } + + if (curIdentity.Status == Scp3114Identity.DisguiseStatus.Equipping) + { + __instance._equipSkinSound.Stop(); + curIdentity.Status = Scp3114Identity.DisguiseStatus.None; + __instance.Cooldown.Trigger((double)__instance.Duration); + } + + return false; + } + } +} From 900902d32be5a3e146c60a584c8275c490c94dfe Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sat, 28 Oct 2023 20:41:26 +0200 Subject: [PATCH 151/207] Fast fix light --- Exiled.API/Features/Toys/Light.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.API/Features/Toys/Light.cs b/Exiled.API/Features/Toys/Light.cs index 105e41eede..34b0de2e03 100644 --- a/Exiled.API/Features/Toys/Light.cs +++ b/Exiled.API/Features/Toys/Light.cs @@ -93,7 +93,7 @@ public static Light Create(Vector3? position = null, Vector3? rotation = null, V /// Whether the should be initially spawned. /// The color of the . /// The new . - public static Light Create(Vector3? position = null, Vector3? rotation = null, Vector3? scale = null, bool spawn = true, Color? color = null) + public static Light Create(Vector3? position /*= null*/, Vector3? rotation /*= null*/, Vector3? scale /*= null*/, bool spawn /*= true*/, Color? color /*= null*/) { Light light = new(UnityEngine.Object.Instantiate(ToysHelper.LightBaseObject)); From c65ca6176454a63ff7caa2e0fc8e7e5bd9654804 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sat, 28 Oct 2023 20:42:39 +0200 Subject: [PATCH 152/207] Bump Version --- EXILED.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED.props b/EXILED.props index 2d8567007d..fe3c710cb0 100644 --- a/EXILED.props +++ b/EXILED.props @@ -15,7 +15,7 @@ - 8.3.1 + 8.3.2 false From 9f4482adebafbecd921990d9bd7c126bc97e8ff6 Mon Sep 17 00:00:00 2001 From: Ika <36999341+SiphoxR@users.noreply.github.com> Date: Sat, 28 Oct 2023 22:34:45 +0200 Subject: [PATCH 153/207] fix playerstat (#2181) --- Exiled.API/Features/Player.cs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 1a6f87f444..1d4dd36fc3 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -84,7 +84,6 @@ public class Player : TypeCastObject, IEntity, IWorldSpace private readonly HashSet componentsInChildren = new(); private ReferenceHub referenceHub; - private CustomHealthStat healthStat; private Role role; /// @@ -164,8 +163,6 @@ private set HintDisplay = value.hints; Inventory = value.inventory; CameraTransform = value.PlayerCameraReference; - - value.playerStats._dictionarizedTypes[typeof(HealthStat)] = value.playerStats.StatModules[0] = healthStat = new CustomHealthStat { Hub = value }; } } @@ -835,10 +832,10 @@ public byte UnitId /// public float Health { - get => healthStat.CurValue; + get => ReferenceHub.playerStats.StatModules[1].CurValue; set { - healthStat.CurValue = value; + ReferenceHub.playerStats.StatModules[1].CurValue = value; if (value > MaxHealth) MaxHealth = value; @@ -850,8 +847,8 @@ public float Health /// public float MaxHealth { - get => healthStat.MaxValue; - set => healthStat.CustomMaxValue = value; + get => ReferenceHub.playerStats.StatModules[0].CurValue; + set => ReferenceHub.playerStats.StatModules[0].CurValue = value; } /// @@ -904,12 +901,12 @@ public float HumeShield /// /// Gets a of all active Artificial Health processes on the player. /// - public IEnumerable ActiveArtificialHealthProcesses => ((AhpStat)ReferenceHub.playerStats.StatModules[1])._activeProcesses; + public IEnumerable ActiveArtificialHealthProcesses => ((AhpStat)ReferenceHub.playerStats.StatModules[2])._activeProcesses; /// /// Gets the player's . /// - public HumeShieldStat HumeShieldStat => (HumeShieldStat)ReferenceHub.playerStats.StatModules[4]; + public HumeShieldStat HumeShieldStat => (HumeShieldStat)ReferenceHub.playerStats.StatModules[5]; /// /// Gets or sets the item in the player's hand. Value will be if the player is not holding anything. @@ -941,7 +938,7 @@ public Item CurrentItem /// /// Gets the class. /// - public StaminaStat StaminaStat => (StaminaStat)ReferenceHub.playerStats.StatModules[2]; + public StaminaStat StaminaStat => (StaminaStat)ReferenceHub.playerStats.StatModules[3]; /// /// Gets or sets the amount of stamina the player has. @@ -2070,7 +2067,7 @@ public void Hurt(float damage, string damageReason, string cassieAnnouncement = public void Heal(float amount, bool overrideMaxHealth = false) { if (!overrideMaxHealth) - healthStat.ServerHeal(amount); + ((HealthStat)ReferenceHub.playerStats.StatModules[1]).ServerHeal(amount); else Health += amount; } From 87271cd0856a898d5a667a66e811df93a40a34a3 Mon Sep 17 00:00:00 2001 From: Misaka_ZeroTwo <45165615+Misaka-ZeroTwo@users.noreply.github.com> Date: Sat, 28 Oct 2023 20:06:23 -0400 Subject: [PATCH 154/207] Update RoundEnd.cs --- Exiled.Events/Patches/Events/Server/RoundEnd.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.Events/Patches/Events/Server/RoundEnd.cs b/Exiled.Events/Patches/Events/Server/RoundEnd.cs index 21ff8a28e4..3fa1c437ef 100644 --- a/Exiled.Events/Patches/Events/Server/RoundEnd.cs +++ b/Exiled.Events/Patches/Events/Server/RoundEnd.cs @@ -78,7 +78,7 @@ private static IEnumerable Transpiler(IEnumerable Date: Sat, 28 Oct 2023 20:41:24 -0400 Subject: [PATCH 155/207] Update EXILED.props --- EXILED.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED.props b/EXILED.props index fe3c710cb0..4ed5882f99 100644 --- a/EXILED.props +++ b/EXILED.props @@ -15,7 +15,7 @@ - 8.3.2 + 8.3.3 false From 11e1a29009f0bd9896c3587db0fd5a633f558341 Mon Sep 17 00:00:00 2001 From: Misaka_ZeroTwo <45165615+Misaka-ZeroTwo@users.noreply.github.com> Date: Sun, 29 Oct 2023 00:31:20 -0400 Subject: [PATCH 156/207] Update RoundEnd.cs --- Exiled.Events/Patches/Events/Server/RoundEnd.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.Events/Patches/Events/Server/RoundEnd.cs b/Exiled.Events/Patches/Events/Server/RoundEnd.cs index 3fa1c437ef..dbdaae6327 100644 --- a/Exiled.Events/Patches/Events/Server/RoundEnd.cs +++ b/Exiled.Events/Patches/Events/Server/RoundEnd.cs @@ -57,7 +57,7 @@ private static IEnumerable Transpiler(IEnumerable Date: Sun, 29 Oct 2023 00:36:50 -0400 Subject: [PATCH 157/207] Update EXILED.props --- EXILED.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED.props b/EXILED.props index 4ed5882f99..e4c19b9169 100644 --- a/EXILED.props +++ b/EXILED.props @@ -15,7 +15,7 @@ - 8.3.3 + 8.3.4 false From 3459d3284d59e459852fb3933eb953e8f9df9454 Mon Sep 17 00:00:00 2001 From: IRacle Date: Sun, 29 Oct 2023 12:10:52 +0300 Subject: [PATCH 158/207] fix --- Exiled.Events/Patches/Events/Player/SendingAdminChatMessage.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.Events/Patches/Events/Player/SendingAdminChatMessage.cs b/Exiled.Events/Patches/Events/Player/SendingAdminChatMessage.cs index 6368994da4..08ff5f76b8 100644 --- a/Exiled.Events/Patches/Events/Player/SendingAdminChatMessage.cs +++ b/Exiled.Events/Patches/Events/Player/SendingAdminChatMessage.cs @@ -69,7 +69,7 @@ private static IEnumerable Transpiler(IEnumerable Date: Sun, 29 Oct 2023 13:20:29 +0300 Subject: [PATCH 159/207] Fixes (#2184) * fix * 3114 fix * stats fix * verifed * yea --- Exiled.API/Features/Player.cs | 35 ++++++++++++------ .../Patches/Events/Player/Verified.cs | 37 ++++++++++++++++--- .../Patches/Events/Scp3114/Revealing.cs | 1 - .../Patches/Events/Scp3114/TryUseBody.cs | 1 - 4 files changed, 55 insertions(+), 19 deletions(-) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 1d4dd36fc3..9f5def7eb0 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -52,6 +52,7 @@ namespace Exiled.API.Features using PlayerRoles.Voice; using PlayerStatsSystem; using PluginAPI.Core; + using RelativePositioning; using RemoteAdmin; using Respawning.NamingRules; @@ -832,13 +833,13 @@ public byte UnitId /// public float Health { - get => ReferenceHub.playerStats.StatModules[1].CurValue; + get => ReferenceHub.playerStats.GetModule().CurValue; set { - ReferenceHub.playerStats.StatModules[1].CurValue = value; - if (value > MaxHealth) MaxHealth = value; + + ReferenceHub.playerStats.GetModule().CurValue = value; } } @@ -847,8 +848,14 @@ public float Health /// public float MaxHealth { - get => ReferenceHub.playerStats.StatModules[0].CurValue; - set => ReferenceHub.playerStats.StatModules[0].CurValue = value; + get + { + MaxHealthStat maxHealthStat = ReferenceHub.playerStats.GetModule(); + HealthStat healthStat = ReferenceHub.playerStats.GetModule(); + + return maxHealthStat.CurValue == 0.0f ? healthStat.MaxValue : maxHealthStat.CurValue; + } + set => ReferenceHub.playerStats.GetModule().CurValue = value; } /// @@ -901,12 +908,12 @@ public float HumeShield /// /// Gets a of all active Artificial Health processes on the player. /// - public IEnumerable ActiveArtificialHealthProcesses => ((AhpStat)ReferenceHub.playerStats.StatModules[2])._activeProcesses; + public IEnumerable ActiveArtificialHealthProcesses => ReferenceHub.playerStats.GetModule()._activeProcesses; /// /// Gets the player's . /// - public HumeShieldStat HumeShieldStat => (HumeShieldStat)ReferenceHub.playerStats.StatModules[5]; + public HumeShieldStat HumeShieldStat => ReferenceHub.playerStats.GetModule(); /// /// Gets or sets the item in the player's hand. Value will be if the player is not holding anything. @@ -938,7 +945,7 @@ public Item CurrentItem /// /// Gets the class. /// - public StaminaStat StaminaStat => (StaminaStat)ReferenceHub.playerStats.StatModules[3]; + public StaminaStat StaminaStat => ReferenceHub.playerStats.GetModule(); /// /// Gets or sets the amount of stamina the player has. @@ -2067,7 +2074,7 @@ public void Hurt(float damage, string damageReason, string cassieAnnouncement = public void Heal(float amount, bool overrideMaxHealth = false) { if (!overrideMaxHealth) - ((HealthStat)ReferenceHub.playerStats.StatModules[1]).ServerHeal(amount); + ReferenceHub.playerStats.GetModule().ServerHeal(amount); else Health += amount; } @@ -2316,7 +2323,11 @@ public int GetCategoryLimit(ItemCategory category) => /// The given to the player. public Item AddItem(ItemType itemType) { - return Item.Get(Inventory.ServerAddItem(itemType)); + Item item = Item.Create(itemType); + + AddItem(item); + + return item; } /// @@ -2337,7 +2348,7 @@ public Item AddItem(ItemType itemType, IEnumerable identif /// The given to the player. public Item AddItem(FirearmType firearmType, IEnumerable identifiers) { - Item item = Item.Get(Inventory.ServerAddItem(firearmType.GetItemType())); + Item item = Item.Create(firearmType.GetItemType()); if (item is Firearm firearm) { @@ -2354,6 +2365,8 @@ public Item AddItem(FirearmType firearmType, IEnumerable i firearm.Base.Status = new FirearmStatus(firearm.MaxAmmo, flags, firearm.Base.GetCurrentAttachmentsCode()); } + AddItem(item); + return item; } diff --git a/Exiled.Events/Patches/Events/Player/Verified.cs b/Exiled.Events/Patches/Events/Player/Verified.cs index e1e5acbc35..b63ac96a60 100644 --- a/Exiled.Events/Patches/Events/Player/Verified.cs +++ b/Exiled.Events/Patches/Events/Player/Verified.cs @@ -8,15 +8,18 @@ namespace Exiled.Events.Patches.Events.Player { using System; + using System.Collections.Generic; + using System.Reflection.Emit; using API.Features; using CentralAuth; using Exiled.API.Extensions; + using Exiled.API.Features.Pools; using Exiled.Events.EventArgs.Player; using HarmonyLib; -#pragma warning disable SA1313 // Parameter names should begin with lower-case letter + using static HarmonyLib.AccessTools; /// /// Patches . @@ -25,12 +28,34 @@ namespace Exiled.Events.Patches.Events.Player [HarmonyPatch(typeof(PlayerAuthenticationManager), nameof(PlayerAuthenticationManager.FinalizeAuthentication))] internal static class Verified { - private static void Postfix(PlayerAuthenticationManager __instance) + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) { - if (!Player.UnverifiedPlayers.TryGetValue(__instance._hub.gameObject, out Player player)) - Joined.CallEvent(__instance._hub, out player); + List newInstructions = ListPool.Pool.Get(instructions); - Player.Dictionary.Add(__instance._hub.gameObject, player); + const int offset = -4; + int index = newInstructions.FindIndex(instruction => instruction.Calls(Method(typeof(ServerRoles), nameof(ServerRoles.RefreshPermissions)))) + offset; + + newInstructions.InsertRange( + index, + new CodeInstruction[] + { + // Helper(authenticationManager); + new(OpCodes.Ldarg_0), + new(OpCodes.Call, Method(typeof(Verified), nameof(Helper))), + }); + + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; + + ListPool.Pool.Return(newInstructions); + } + + private static void Helper(PlayerAuthenticationManager auth) + { + if (!Player.UnverifiedPlayers.TryGetValue(auth._hub.gameObject, out Player player)) + Joined.CallEvent(auth._hub, out player); + + Player.Dictionary.Add(auth._hub.gameObject, player); player.IsVerified = true; player.RawUserId = player.UserId.GetRawUserId(); @@ -40,4 +65,4 @@ private static void Postfix(PlayerAuthenticationManager __instance) Handlers.Player.OnVerified(new VerifiedEventArgs(player)); } } -} \ No newline at end of file +} diff --git a/Exiled.Events/Patches/Events/Scp3114/Revealing.cs b/Exiled.Events/Patches/Events/Scp3114/Revealing.cs index 9c0d6fe54a..4e6e74ca07 100644 --- a/Exiled.Events/Patches/Events/Scp3114/Revealing.cs +++ b/Exiled.Events/Patches/Events/Scp3114/Revealing.cs @@ -74,7 +74,6 @@ private static bool Prefix(Scp3114Reveal __instance, NetworkReader reader) return false; } - __instance.ServerProcessCmd(reader); __instance.ScpRole.Disguised = false; RevealedEventArgs revealed = new(__instance.Owner); diff --git a/Exiled.Events/Patches/Events/Scp3114/TryUseBody.cs b/Exiled.Events/Patches/Events/Scp3114/TryUseBody.cs index 6315783243..235f72975b 100644 --- a/Exiled.Events/Patches/Events/Scp3114/TryUseBody.cs +++ b/Exiled.Events/Patches/Events/Scp3114/TryUseBody.cs @@ -24,7 +24,6 @@ internal class TryUseBody { private static bool Prefix(Scp3114Disguise __instance) { - __instance.OnProgressSet(); Scp3114Identity.StolenIdentity curIdentity = __instance.ScpRole.CurIdentity; if (__instance.IsInProgress) { From 2ca9c4ab2f784a6ad52277558ad3028c561e06b9 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sun, 29 Oct 2023 11:25:29 +0100 Subject: [PATCH 160/207] Bump Version --- EXILED.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED.props b/EXILED.props index e4c19b9169..60ac0c9c17 100644 --- a/EXILED.props +++ b/EXILED.props @@ -15,7 +15,7 @@ - 8.3.4 + 8.3.5 false From 8fc82311e2f1d4c0b6bcbfb579f6162bc72d4551 Mon Sep 17 00:00:00 2001 From: IRacle <79921583+IRacle1@users.noreply.github.com> Date: Sun, 29 Oct 2023 15:07:41 +0300 Subject: [PATCH 161/207] `MaxHealth` fix (#2185) * test * fix * bruh --- Exiled.API/Features/Player.cs | 14 +- Exiled.Events/Patches/Fixes/MaxHealthFix.cs | 207 ++++++++++++++++++++ 2 files changed, 217 insertions(+), 4 deletions(-) create mode 100644 Exiled.Events/Patches/Fixes/MaxHealthFix.cs diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 9f5def7eb0..823694e225 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -80,6 +80,11 @@ public class Player : TypeCastObject, IEntity, IWorldSpace /// A list of the player's items. /// internal readonly List ItemsValue = new(8); + + /// + /// A overriden value. + /// + internal float OverrideMaxHealth; #pragma warning restore SA1401 private readonly HashSet componentsInChildren = new(); @@ -850,12 +855,13 @@ public float MaxHealth { get { - MaxHealthStat maxHealthStat = ReferenceHub.playerStats.GetModule(); - HealthStat healthStat = ReferenceHub.playerStats.GetModule(); + return ReferenceHub.playerStats.GetModule().MaxValue; + } - return maxHealthStat.CurValue == 0.0f ? healthStat.MaxValue : maxHealthStat.CurValue; + set + { + OverrideMaxHealth = value; } - set => ReferenceHub.playerStats.GetModule().CurValue = value; } /// diff --git a/Exiled.Events/Patches/Fixes/MaxHealthFix.cs b/Exiled.Events/Patches/Fixes/MaxHealthFix.cs new file mode 100644 index 0000000000..8c956c94ff --- /dev/null +++ b/Exiled.Events/Patches/Fixes/MaxHealthFix.cs @@ -0,0 +1,207 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Fixes +{ +#pragma warning disable SA1649 // File name should match first type name +#pragma warning disable SA1402 // File may only contain a single type + using System.Collections.Generic; + using System.Reflection.Emit; + + using Exiled.API.Features; + using Exiled.API.Features.Pools; + + using HarmonyLib; + + using MapGeneration.Distributors; + + using PlayerRoles; + using PlayerRoles.PlayableScps; + using PlayerRoles.PlayableScps.Scp049.Zombies; + + using PlayerStatsSystem; + + using static HarmonyLib.AccessTools; + + /// + /// Fix for for . + /// + [HarmonyPatch(typeof(HumanRole), nameof(HumanRole.MaxHealth), MethodType.Getter)] + internal class MaxHealthFixHuman + { + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) + { + List newInstructions = ListPool.Pool.Get(instructions); + + LocalBuilder player = generator.DeclareLocal(typeof(Player)); + LocalBuilder value = generator.DeclareLocal(typeof(float)); + + Label @default = generator.DefineLabel(); + Label end = generator.DefineLabel(); + + int offset = 0; + int index = newInstructions.FindIndex(i => i.opcode == OpCodes.Ldc_R4) + offset; + + newInstructions.RemoveAt(index); + + newInstructions.InsertRange(index, new[] + { + new CodeInstruction(OpCodes.Ldarg_0), + new(OpCodes.Ldfld, Field(typeof(HumanRole), nameof(HumanRole._lastOwner))), + new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), + new(OpCodes.Dup), + new(OpCodes.Stloc_S, player.LocalIndex), + new(OpCodes.Brfalse_S, @default), + + new(OpCodes.Ldloc_S, player), + new(OpCodes.Ldfld, Field(typeof(Player), nameof(Player.OverrideMaxHealth))), + new(OpCodes.Dup), + new(OpCodes.Stloc_S, value.LocalIndex), + new(OpCodes.Ldc_R4, 0.0f), + new(OpCodes.Beq_S, @default), + + new(OpCodes.Ldloc_S, value.LocalIndex), + new(OpCodes.Br_S, end), + + new CodeInstruction(OpCodes.Ldc_R4, 100f).WithLabels(@default), + + new CodeInstruction(OpCodes.Nop).WithLabels(end), + }); + + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; + + ListPool.Pool.Return(newInstructions); + } + } + + /// + /// Fix for for . + /// + [HarmonyPatch(typeof(FpcStandardScp), nameof(FpcStandardScp.MaxHealth), MethodType.Getter)] + internal class MaxHealthFixScp + { + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) + { + List newInstructions = ListPool.Pool.Get(instructions); + + LocalBuilder player = generator.DeclareLocal(typeof(Player)); + LocalBuilder value = generator.DeclareLocal(typeof(float)); + + Label end = generator.DefineLabel(); + + newInstructions.InsertRange(0, new[] + { + new CodeInstruction(OpCodes.Ldarg_0), + new(OpCodes.Ldfld, Field(typeof(FpcStandardScp), nameof(FpcStandardScp._lastOwner))), + new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), + new(OpCodes.Dup), + new(OpCodes.Stloc_S, player.LocalIndex), + new(OpCodes.Brfalse_S, end), + + new(OpCodes.Ldloc_S, player), + new(OpCodes.Ldfld, Field(typeof(Player), nameof(Player.OverrideMaxHealth))), + new(OpCodes.Dup), + new(OpCodes.Stloc_S, value.LocalIndex), + new(OpCodes.Ldc_R4, 0.0f), + new(OpCodes.Beq_S, end), + + new(OpCodes.Ldloc_S, value.LocalIndex), + new(OpCodes.Ret), + + new CodeInstruction(OpCodes.Nop).WithLabels(end), + }); + + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; + + ListPool.Pool.Return(newInstructions); + } + } + + /// + /// Fix for for . + /// + [HarmonyPatch(typeof(ZombieRole), nameof(ZombieRole.MaxHealth), MethodType.Getter)] + internal class MaxHealthFixZombie + { + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) + { + List newInstructions = ListPool.Pool.Get(instructions); + + LocalBuilder player = generator.DeclareLocal(typeof(Player)); + LocalBuilder value = generator.DeclareLocal(typeof(float)); + + Label end = generator.DefineLabel(); + + newInstructions.InsertRange(0, new[] + { + new CodeInstruction(OpCodes.Ldarg_0), + new(OpCodes.Ldfld, Field(typeof(ZombieRole), nameof(ZombieRole._lastOwner))), + new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), + new(OpCodes.Dup), + new(OpCodes.Stloc_S, player.LocalIndex), + new(OpCodes.Brfalse_S, end), + + new(OpCodes.Ldloc_S, player), + new(OpCodes.Ldfld, Field(typeof(Player), nameof(Player.OverrideMaxHealth))), + new(OpCodes.Dup), + new(OpCodes.Stloc_S, value.LocalIndex), + new(OpCodes.Ldc_R4, 0.0f), + new(OpCodes.Beq_S, end), + + new(OpCodes.Ldloc_S, value.LocalIndex), + new(OpCodes.Ret), + + new CodeInstruction(OpCodes.Nop).WithLabels(end), + }); + + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; + + ListPool.Pool.Return(newInstructions); + } + } + + /// + /// Fix reseting. + /// + [HarmonyPatch(typeof(HealthStat), nameof(HealthStat.ClassChanged))] + internal class MaxHealthFixReset + { + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) + { + List newInstructions = ListPool.Pool.Get(instructions); + + LocalBuilder player = generator.DeclareLocal(typeof(Player)); + LocalBuilder value = generator.DeclareLocal(typeof(float)); + + Label end = generator.DefineLabel(); + + newInstructions.InsertRange(0, new[] + { + new CodeInstruction(OpCodes.Ldarg_0), + new(OpCodes.Callvirt, PropertyGetter(typeof(HealthStat), nameof(HealthStat.Hub))), + new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })), + new(OpCodes.Dup), + new(OpCodes.Stloc_S, player.LocalIndex), + new(OpCodes.Brfalse_S, end), + + new(OpCodes.Ldloc_S, player), + new(OpCodes.Ldc_R4, 0.0f), + new(OpCodes.Stfld, Field(typeof(Player), nameof(Player.OverrideMaxHealth))), + + new CodeInstruction(OpCodes.Nop).WithLabels(end), + }); + + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; + + ListPool.Pool.Return(newInstructions); + } + } +} \ No newline at end of file From bf67f0f7ecd504500ed3ab436079399a08e7de14 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sun, 29 Oct 2023 20:52:54 +0100 Subject: [PATCH 162/207] WTF How that fix duration effect ??!!?? --- Exiled.API/Features/Player.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 823694e225..6881b571d0 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -2921,8 +2921,8 @@ public bool EnableEffect(StatusEffectBase statusEffect, byte intensity, float du if (statusEffect is null) return false; - statusEffect.ServerSetState(intensity, duration, addDurationIfActive); - + statusEffect.ServerSetState(intensity); + statusEffect.ServerChangeDuration(duration, addDurationIfActive); return statusEffect is not null && statusEffect.IsEnabled; } From 8ed48045e8325d64ce3a44a6258fb6b341a3d987 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sun, 29 Oct 2023 22:23:37 +0100 Subject: [PATCH 163/207] Fix KickingEvent idk why it's could be null --- Exiled.Events/Patches/Events/Player/Kicking.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Exiled.Events/Patches/Events/Player/Kicking.cs b/Exiled.Events/Patches/Events/Player/Kicking.cs index 070314e0ad..ff6fe2762d 100644 --- a/Exiled.Events/Patches/Events/Player/Kicking.cs +++ b/Exiled.Events/Patches/Events/Player/Kicking.cs @@ -35,6 +35,9 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Date: Sun, 29 Oct 2023 22:26:15 +0100 Subject: [PATCH 164/207] Scp3114DamageHandler is not ScpDamage ???!!!?? --- .../Features/DamageHandlers/DamageHandlerBase.cs | 10 +++++++++- Exiled.API/Features/DamageHandlers/ScpDamageHandler.cs | 8 -------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Exiled.API/Features/DamageHandlers/DamageHandlerBase.cs b/Exiled.API/Features/DamageHandlers/DamageHandlerBase.cs index a11b26f0ce..c4eed3f055 100644 --- a/Exiled.API/Features/DamageHandlers/DamageHandlerBase.cs +++ b/Exiled.API/Features/DamageHandlers/DamageHandlerBase.cs @@ -15,7 +15,7 @@ namespace Exiled.API.Features.DamageHandlers using Enums; using Extensions; - + using PlayerRoles.PlayableScps.Scp3114; using PlayerRoles.PlayableScps.Scp939; using PlayerStatsSystem; @@ -116,6 +116,14 @@ public virtual DamageType Type return DamageType.Scp939; case JailbirdDamageHandler: return DamageType.Jailbird; + case Scp3114DamageHandler scp3114DamageHandler: + return scp3114DamageHandler.Subtype switch + { + Scp3114DamageHandler.HandlerType.Strangulation => DamageType.Strangled, + Scp3114DamageHandler.HandlerType.SkinSteal => DamageType.Scp3114, + Scp3114DamageHandler.HandlerType.Slap => DamageType.Scp3114, + _ => DamageType.Unknown, + }; case Scp049DamageHandler scp049DamageHandler: return scp049DamageHandler.DamageSubType switch { diff --git a/Exiled.API/Features/DamageHandlers/ScpDamageHandler.cs b/Exiled.API/Features/DamageHandlers/ScpDamageHandler.cs index 309aca1c6a..a1102d6dc3 100644 --- a/Exiled.API/Features/DamageHandlers/ScpDamageHandler.cs +++ b/Exiled.API/Features/DamageHandlers/ScpDamageHandler.cs @@ -40,14 +40,6 @@ public override DamageType Type { case Scp096DamageHandler: return DamageType.Scp096; - case Scp3114DamageHandler scp3114DamageHandler: - return scp3114DamageHandler.Subtype switch - { - Scp3114DamageHandler.HandlerType.Strangulation => DamageType.Strangled, - Scp3114DamageHandler.HandlerType.SkinSteal => DamageType.Scp3114, - Scp3114DamageHandler.HandlerType.Slap => DamageType.Scp3114, - _ => DamageType.Unknown, - }; case Scp049DamageHandler scp049DamageHandler: return scp049DamageHandler.DamageSubType switch { From b087428c517c9a657c40b3580d63f222538072bf Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sun, 29 Oct 2023 22:32:01 +0100 Subject: [PATCH 165/207] Bump Version 8.3.6 --- EXILED.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED.props b/EXILED.props index 60ac0c9c17..6fbf3088f6 100644 --- a/EXILED.props +++ b/EXILED.props @@ -15,7 +15,7 @@ - 8.3.5 + 8.3.6 false From 37f39665dd3003168d9531745eb38c64f7401053 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Mon, 30 Oct 2023 00:24:06 +0100 Subject: [PATCH 166/207] Update doc --- docs/docs/Resources/Intro.md | 38 +++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/docs/docs/Resources/Intro.md b/docs/docs/Resources/Intro.md index 415eb9e22b..261f14a320 100644 --- a/docs/docs/Resources/Intro.md +++ b/docs/docs/Resources/Intro.md @@ -34,7 +34,7 @@ sidebar_position: 1
Roles -```md title="Latest Updated: 13.2.0.2" +```md title="Latest Updated: 13.3.0.0" | Id | RoleTypeId | Team | Side | LeadingTeam | |-----|----------------|------------------|------------------|-----------------| | -1 | None | Dead | None | Draw | @@ -61,7 +61,7 @@ sidebar_position: 1 | 20 | ChaosRepressor | ChaosInsurgency | ChaosInsurgency | ChaosInsurgency | | 21 | Overwatch | Dead | None | Draw | | 22 | Filmmaker | Dead | None | Draw | -| 23 | Scp3114 | Dead | None | Draw | +| 23 | Scp3114 | SCPs | Scp | Anomalies | ```
@@ -70,7 +70,7 @@ sidebar_position: 1
Items -```md title="Latest Updated: 13.2.0.2" +```md title="Latest Updated: 13.3.0.0" [-1] None [0] KeycardJanitor [1] KeycardScientist @@ -137,7 +137,7 @@ sidebar_position: 1
Ammo -```md title="Latest Updated: 8.3.0.0" +```md title="Latest Updated: 8.3.6.0" [0] None [1] Nato556 [2] Nato762 @@ -152,7 +152,7 @@ sidebar_position: 1
Doors -```md title="Latest Updated: 8.3.0.0" +```md title="Latest Updated: 8.3.6.0" [0] UnknownDoor [1] Scp914Door [2] GR18Inner @@ -221,7 +221,7 @@ sidebar_position: 1
Rooms -```md title="Latest Updated: 8.3.0.0" +```md title="Latest Updated: 8.3.6.0" [0] Unknown [1] LczArmory [2] LczCurve @@ -284,7 +284,7 @@ sidebar_position: 1
Elevators -```md title="Latest Updated: 8.3.0.0" +```md title="Latest Updated: 8.3.6.0" [0] Unknown [1] GateA [2] GateB @@ -300,7 +300,7 @@ sidebar_position: 1
DamageType -```md title="Latest Updated: 8.3.0.0" +```md title="Latest Updated: 8.3.6.0" [0] Unknown [1] Falldown [2] Warhead @@ -384,7 +384,7 @@ PlayerStatsSystem::Scp018DamageHandler : AttackerDamageHandler
Effects -```md title="Latest Updated: 8.3.0.0" +```md title="Latest Updated: 8.3.6.0" [0] AmnesiaItems [1] AmnesiaVision [2] Asphyxiated @@ -431,6 +431,8 @@ PlayerStatsSystem::Scp018DamageHandler : AttackerDamageHandler [43] SugarRush [44] TraumatizedByEvil [45] Metal +[46] Prismatic +[47] SlowMetabolism ```
@@ -439,7 +441,7 @@ PlayerStatsSystem::Scp018DamageHandler : AttackerDamageHandler
Keycard Perms -```md title="Latest Updated: 8.3.0.0" +```md title="Latest Updated: 8.3.6.0" [0] None [1] Checkpoints [2] ExitGates @@ -460,7 +462,7 @@ PlayerStatsSystem::Scp018DamageHandler : AttackerDamageHandler
Lock Type -```md title="Latest Updated: 8.3.0.0" +```md title="Latest Updated: 8.3.6.0" [0] None [1] Regular079 [2] Lockdown079 @@ -480,7 +482,7 @@ PlayerStatsSystem::Scp018DamageHandler : AttackerDamageHandler
Structures -```md title="Latest Updated: 13.2.0.2" +```md title="Latest Updated: 13.3.0.0" [0] StandardLocker [1] LargeGunLocker [2] ScpPedestal @@ -495,7 +497,7 @@ PlayerStatsSystem::Scp018DamageHandler : AttackerDamageHandler
Blood -```md title="Latest Updated: 8.3.0.0" +```md title="Latest Updated: 8.3.6.0" [0] Default [1] Scp106 [2] Spreaded @@ -508,7 +510,7 @@ PlayerStatsSystem::Scp018DamageHandler : AttackerDamageHandler
GeneratorState -```md title="Latest Updated: 8.3.0.0" +```md title="Latest Updated: 8.3.6.0" [1] None [2] Unlocked [4] Open @@ -522,7 +524,7 @@ PlayerStatsSystem::Scp018DamageHandler : AttackerDamageHandler
Intercom States -```md title="Latest Updated: 13.2.0.2" +```md title="Latest Updated: 13.3.0.0" [0] Ready [1] Starting [2] InUse @@ -536,7 +538,7 @@ PlayerStatsSystem::Scp018DamageHandler : AttackerDamageHandler
BroadcastFlags -```md title="Latest Updated: 13.2.0.2" +```md title="Latest Updated: 13.3.0.0" [0] Normal [1] Truncated [2] AdminChat @@ -550,7 +552,7 @@ PlayerStatsSystem::Scp018DamageHandler : AttackerDamageHandler
Attachment Names -```md title="Latest Updated: 8.3.0.0" +```md title="Latest Updated: 8.3.6.0" [0] None [1] IronSights [2] DotSight @@ -605,7 +607,7 @@ PlayerStatsSystem::Scp018DamageHandler : AttackerDamageHandler
Spawn Reasons -```md title="Latest Updated: 8.3.0.0" +```md title="Latest Updated: 8.3.6.0" [0] None [1] RoundStart [2] LateJoin From 136788a82ab6760cdd33a62edf5e1dded0a7489b Mon Sep 17 00:00:00 2001 From: Nameless <85962933+Misfiy@users.noreply.github.com> Date: Mon, 30 Oct 2023 12:16:36 +0100 Subject: [PATCH 167/207] Someone forgot about the marshmallows >:( (#2189) --- Exiled.API/Enums/EffectType.cs | 1 + Exiled.API/Extensions/EffectTypeExtension.cs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Exiled.API/Enums/EffectType.cs b/Exiled.API/Enums/EffectType.cs index fe16077b6f..4d3bc57d72 100644 --- a/Exiled.API/Enums/EffectType.cs +++ b/Exiled.API/Enums/EffectType.cs @@ -220,6 +220,7 @@ public enum EffectType Metal, Prismatic, SlowMetabolism, + Marshmallow, #pragma warning restore SA1602 // Enumeration items should be documented #pragma warning restore CS1591 // Commentaire XML manquant pour le type ou le membre visible publiquement } diff --git a/Exiled.API/Extensions/EffectTypeExtension.cs b/Exiled.API/Extensions/EffectTypeExtension.cs index 0c8811e3b7..1c3243eed4 100644 --- a/Exiled.API/Extensions/EffectTypeExtension.cs +++ b/Exiled.API/Extensions/EffectTypeExtension.cs @@ -13,6 +13,8 @@ namespace Exiled.API.Extensions using Enums; + using InventorySystem.Items.MarshmallowMan; + using InventorySystem.Items.Usables.Scp244.Hypothermia; using PlayerRoles.FirstPersonControl; @@ -136,6 +138,7 @@ public static class EffectTypeExtension TraumatizedByEvil => EffectType.TraumatizedByEvil, Prismatic => EffectType.Prismatic, SlowMetabolism => EffectType.SlowMetabolism, + MarshmallowEffect => EffectType.Marshmallow, // This should never happen _ => throw new InvalidOperationException("Invalid effect status base provided"), From 2801667f89900dc75f008806876b8f1262a98ac5 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Mon, 30 Oct 2023 12:22:17 +0100 Subject: [PATCH 168/207] Fix Marshmallow --- Exiled.API/Extensions/EffectTypeExtension.cs | 1 + docs/docs/Resources/Intro.md | 1 + 2 files changed, 2 insertions(+) diff --git a/Exiled.API/Extensions/EffectTypeExtension.cs b/Exiled.API/Extensions/EffectTypeExtension.cs index 1c3243eed4..c2ae09a0bf 100644 --- a/Exiled.API/Extensions/EffectTypeExtension.cs +++ b/Exiled.API/Extensions/EffectTypeExtension.cs @@ -79,6 +79,7 @@ public static class EffectTypeExtension EffectType.Metal => typeof(Metal), EffectType.Prismatic => typeof(Prismatic), EffectType.SlowMetabolism => typeof(SlowMetabolism), + EffectType.Marshmallow => typeof(MarshmallowEffect), // This should never happen _ => throw new InvalidOperationException("Invalid effect enum provided"), diff --git a/docs/docs/Resources/Intro.md b/docs/docs/Resources/Intro.md index 261f14a320..f990e74655 100644 --- a/docs/docs/Resources/Intro.md +++ b/docs/docs/Resources/Intro.md @@ -433,6 +433,7 @@ PlayerStatsSystem::Scp018DamageHandler : AttackerDamageHandler [45] Metal [46] Prismatic [47] SlowMetabolism +[48] Marshmallow ```
From 39a5f2f83dadd16819401ed5983d9b9ca3908e31 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Mon, 30 Oct 2023 18:19:59 +0100 Subject: [PATCH 169/207] Fix NRE --- Exiled.Events/Handlers/Internal/Round.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.Events/Handlers/Internal/Round.cs b/Exiled.Events/Handlers/Internal/Round.cs index 84c7aa6fe3..7554669fc5 100644 --- a/Exiled.Events/Handlers/Internal/Round.cs +++ b/Exiled.Events/Handlers/Internal/Round.cs @@ -69,7 +69,7 @@ public static void OnChangingRole(ChangingRoleEventArgs ev) /// public static void OnActivatingSense(ActivatingSenseEventArgs ev) { - if (!Events.Instance.Config.CanScp049SenseTutorial || ev.Target.Role.Type is not RoleTypeId.Tutorial) + if (!Events.Instance.Config.CanScp049SenseTutorial || ev.Target is null || ev.Target.Role.Type is not RoleTypeId.Tutorial) return; if (ev.Scp049.SenseAbility.CanFindTarget(out ReferenceHub hub)) ev.Target = Player.Get(hub); From 9c1f6fdf02a83a1641f04f060b45b504eb2cf4dc Mon Sep 17 00:00:00 2001 From: Thunder Date: Mon, 30 Oct 2023 15:16:39 -0400 Subject: [PATCH 170/207] Add SCP-3114 properties, fix documentation --- Exiled.API/Features/Roles/Scp3114Role.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Exiled.API/Features/Roles/Scp3114Role.cs b/Exiled.API/Features/Roles/Scp3114Role.cs index 87293dc0d3..31056abde3 100644 --- a/Exiled.API/Features/Roles/Scp3114Role.cs +++ b/Exiled.API/Features/Roles/Scp3114Role.cs @@ -125,6 +125,16 @@ internal Scp3114Role(Scp3114GameRole baseRole) ///
public new Scp3114GameRole Base { get; } + /// + /// Gets the damage amount of SCP-3114's slap ability. + /// + public float SlapDamage => Slap.DamageAmount; + + /// + /// Gets the current target of SCP-3114's strangle ability. Can be . + /// + public Player StrangleTarget => Player.Get(Slap._strangle.SyncTarget?.Target); + /// /// Gets or sets the SCP-3114's Stolen Role. /// @@ -168,7 +178,7 @@ public byte UnitId } /// - /// Gets or sets the SCP-3114's UnitId used for it's FakeIdentity. + /// Gets or sets current state of SCP-3114's disguise ability. /// public DisguiseStatus DisguiseStatus { From 37fe47b16dca580054a75606401a076f2c286059 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Tue, 31 Oct 2023 00:16:40 +0100 Subject: [PATCH 171/207] Missing SilentDamage --- Exiled.API/Features/DamageHandlers/DamageHandlerBase.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Exiled.API/Features/DamageHandlers/DamageHandlerBase.cs b/Exiled.API/Features/DamageHandlers/DamageHandlerBase.cs index c4eed3f055..83d929e1db 100644 --- a/Exiled.API/Features/DamageHandlers/DamageHandlerBase.cs +++ b/Exiled.API/Features/DamageHandlers/DamageHandlerBase.cs @@ -100,6 +100,8 @@ public virtual DamageType Type { case CustomReasonDamageHandler: return DamageType.Custom; + case SilentDamageHandler: + return DamageType.Silent; case WarheadDamageHandler: return DamageType.Warhead; case ExplosionDamageHandler: From e95cbf862d7fe005c046815db55e6c834fcc7115 Mon Sep 17 00:00:00 2001 From: Misaka_ZeroTwo <45165615+Misaka-ZeroTwo@users.noreply.github.com> Date: Tue, 31 Oct 2023 17:23:20 -0400 Subject: [PATCH 172/207] Fix kicking event --- Exiled.Events/Patches/Events/Player/Kicking.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Exiled.Events/Patches/Events/Player/Kicking.cs b/Exiled.Events/Patches/Events/Player/Kicking.cs index 070314e0ad..9f73c6b912 100644 --- a/Exiled.Events/Patches/Events/Player/Kicking.cs +++ b/Exiled.Events/Patches/Events/Player/Kicking.cs @@ -38,14 +38,14 @@ private static IEnumerable Transpiler(IEnumerable Date: Tue, 31 Oct 2023 17:25:10 -0400 Subject: [PATCH 173/207] Version Bump --- EXILED.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED.props b/EXILED.props index 6fbf3088f6..f09d262c21 100644 --- a/EXILED.props +++ b/EXILED.props @@ -15,7 +15,7 @@ - 8.3.6 + 8.3.7 false From 146b0d50322fdbe26999e6ca482fc27570315474 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Tue, 31 Oct 2023 22:48:12 +0100 Subject: [PATCH 174/207] Fix thanks IRacle Co-Authored-By: IRacle <79921583+IRacle1@users.noreply.github.com> --- .../EventArgs/Player/CancelledItemUseEventArgs.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Exiled.Events/EventArgs/Player/CancelledItemUseEventArgs.cs b/Exiled.Events/EventArgs/Player/CancelledItemUseEventArgs.cs index e15164a717..a393d2dbe1 100644 --- a/Exiled.Events/EventArgs/Player/CancelledItemUseEventArgs.cs +++ b/Exiled.Events/EventArgs/Player/CancelledItemUseEventArgs.cs @@ -10,7 +10,6 @@ namespace Exiled.Events.EventArgs.Player using API.Features; using Exiled.API.Features.Items; using Exiled.Events.EventArgs.Interfaces; - using InventorySystem.Items.Usables; /// /// Contains all information before a player cancels usage of an item. @@ -22,12 +21,12 @@ public class CancelledItemUseEventArgs : IPlayerEvent, IUsableEvent /// /// The player who's stopping the use of an item. /// - /// + /// /// - public CancelledItemUseEventArgs(Player player, UsableItem item) + public CancelledItemUseEventArgs(Player player, Item item) { Player = player; - Usable = Item.Get(item) is Usable usable ? usable : null; + Usable = item is Usable usable ? usable : null; } /// From 81aeb5b6d336d885b996bb38099df5e9e115068d Mon Sep 17 00:00:00 2001 From: louis1706 Date: Tue, 31 Oct 2023 22:58:46 +0100 Subject: [PATCH 175/207] Fix documentation --- .../Patches/Events/Player/UsingAndCancellingItemUse.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Exiled.Events/Patches/Events/Player/UsingAndCancellingItemUse.cs b/Exiled.Events/Patches/Events/Player/UsingAndCancellingItemUse.cs index af583cde3b..8040f64cf9 100644 --- a/Exiled.Events/Patches/Events/Player/UsingAndCancellingItemUse.cs +++ b/Exiled.Events/Patches/Events/Player/UsingAndCancellingItemUse.cs @@ -125,11 +125,11 @@ private static IEnumerable Transpiler(IEnumerable Date: Tue, 31 Oct 2023 19:03:24 -0400 Subject: [PATCH 176/207] Fix ChangingGroupEventArgs.NewGroup having no effect. --- Exiled.Events/Patches/Events/Player/ChangingGroup.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Exiled.Events/Patches/Events/Player/ChangingGroup.cs b/Exiled.Events/Patches/Events/Player/ChangingGroup.cs index 640af3a71b..1ffb9e3f3a 100644 --- a/Exiled.Events/Patches/Events/Player/ChangingGroup.cs +++ b/Exiled.Events/Patches/Events/Player/ChangingGroup.cs @@ -41,6 +41,9 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Date: Tue, 31 Oct 2023 22:03:43 -0400 Subject: [PATCH 177/207] Add Get & Sets for the warningTimeSeconds method & adding more proper grammar for the readme (#2191) * Add Get & Sets for the warningTimeSeconds method --- Exiled.API/Features/Roles/Scp3114Role.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Exiled.API/Features/Roles/Scp3114Role.cs b/Exiled.API/Features/Roles/Scp3114Role.cs index 31056abde3..36e23b11d1 100644 --- a/Exiled.API/Features/Roles/Scp3114Role.cs +++ b/Exiled.API/Features/Roles/Scp3114Role.cs @@ -214,5 +214,14 @@ public void ResetIdentity() /// The List of Roles already spawned. /// The Spawn Chance. public float GetSpawnChance(List alreadySpawned) => 0; + + /// + /// Gets or sets the warning time seconds + /// + public float WarningTime + { + get => Identity._warningTimeSeconds; + set => Identity._warningTimeSeconds = value; + } } } \ No newline at end of file From c5041e85fb63c80ca3c67f7b695fecd49d854b49 Mon Sep 17 00:00:00 2001 From: sanyae2439 <30918724+sanyae2439@users.noreply.github.com> Date: Wed, 1 Nov 2023 15:16:11 +0900 Subject: [PATCH 178/207] Fix Rpc and WriteExtensions dictionary (#2199) --- Exiled.API/Extensions/MirrorExtensions.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Exiled.API/Extensions/MirrorExtensions.cs b/Exiled.API/Extensions/MirrorExtensions.cs index 909fa802b2..5fc259583b 100644 --- a/Exiled.API/Extensions/MirrorExtensions.cs +++ b/Exiled.API/Extensions/MirrorExtensions.cs @@ -44,7 +44,6 @@ public static class MirrorExtensions private static readonly ReadOnlyDictionary ReadOnlyRpcFullNamesValue = new(RpcFullNamesValue); private static MethodInfo setDirtyBitsMethodInfoValue; private static MethodInfo sendSpawnMessageMethodInfoValue; - private static MethodInfo bufferRpcMethodInfoValue; /// /// Gets corresponding to . @@ -55,7 +54,7 @@ public static ReadOnlyDictionary WriterExtensions { if (WriterExtensionsValue.Count == 0) { - foreach (MethodInfo method in typeof(NetworkWriterExtensions).GetMethods().Where(x => !x.IsGenericMethod && (x.GetParameters()?.Length == 2))) + foreach (MethodInfo method in typeof(NetworkWriterExtensions).GetMethods().Where(x => !x.IsGenericMethod && x.GetCustomAttribute(typeof(ObsoleteAttribute)) == null && (x.GetParameters()?.Length == 2))) WriterExtensionsValue.Add(method.GetParameters().First(x => x.ParameterType != typeof(NetworkWriter)).ParameterType, method); Type fuckNorthwood = Assembly.GetAssembly(typeof(RoleTypeId)).GetType("Mirror.GeneratedNetworkCode"); @@ -146,11 +145,6 @@ public static ReadOnlyDictionary RpcFullNames /// public static MethodInfo SendSpawnMessageMethodInfo => sendSpawnMessageMethodInfoValue ??= typeof(NetworkServer).GetMethod("SendSpawnMessage", BindingFlags.NonPublic | BindingFlags.Static); - /// - /// Gets a NetworkConnectionToClient.BufferRpc's . - /// - public static MethodInfo BufferRpcMethodInfo => bufferRpcMethodInfoValue ??= typeof(NetworkConnectionToClient).GetMethod("BufferRpc", BindingFlags.NonPublic | BindingFlags.Instance, null, CallingConventions.HasThis, new Type[] { typeof(RpcMessage), typeof(int) }, null); - /// /// Plays a beep sound that only the target can hear. /// @@ -402,7 +396,7 @@ public static void SendFakeTargetRpc(Player target, NetworkIdentity behaviorOwne payload = writer.ToArraySegment(), }; - BufferRpcMethodInfo.Invoke(target.Connection, new object[] { msg, 0 }); + target.Connection.Send(msg); NetworkWriterPool.Return(writer); } From f21540ed69d4456324dace5a19fba398309104a3 Mon Sep 17 00:00:00 2001 From: Misaka_ZeroTwo <45165615+Misaka-ZeroTwo@users.noreply.github.com> Date: Wed, 1 Nov 2023 03:23:10 -0400 Subject: [PATCH 179/207] code style --- Exiled.API/Features/Roles/Scp3114Role.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Exiled.API/Features/Roles/Scp3114Role.cs b/Exiled.API/Features/Roles/Scp3114Role.cs index 36e23b11d1..fc987353ea 100644 --- a/Exiled.API/Features/Roles/Scp3114Role.cs +++ b/Exiled.API/Features/Roles/Scp3114Role.cs @@ -199,6 +199,15 @@ public float DisguiseDuration set => Identity._disguiseDurationSeconds = value; } + /// + /// Gets or sets the warning time seconds. + /// + public float WarningTime + { + get => Identity._warningTimeSeconds; + set => Identity._warningTimeSeconds = value; + } + /// /// Reset Scp3114 FakeIdentity. /// @@ -214,14 +223,5 @@ public void ResetIdentity() /// The List of Roles already spawned. /// The Spawn Chance. public float GetSpawnChance(List alreadySpawned) => 0; - - /// - /// Gets or sets the warning time seconds - /// - public float WarningTime - { - get => Identity._warningTimeSeconds; - set => Identity._warningTimeSeconds = value; - } } } \ No newline at end of file From c0689f0ccef9b9637d6ea3cc9c166f5f74dffe6a Mon Sep 17 00:00:00 2001 From: louis1706 Date: Wed, 1 Nov 2023 17:02:50 +0100 Subject: [PATCH 180/207] whut --- Exiled.Events/Events.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Exiled.Events/Events.cs b/Exiled.Events/Events.cs index 151ccc3b79..3db2af8221 100644 --- a/Exiled.Events/Events.cs +++ b/Exiled.Events/Events.cs @@ -106,6 +106,8 @@ public override void OnDisabled() RagdollManager.OnRagdollSpawned -= Handlers.Internal.RagdollList.OnSpawnedRagdoll; RagdollManager.OnRagdollRemoved -= Handlers.Internal.RagdollList.OnRemovedRagdoll; + ItemPickupBase.OnPickupAdded -= Handlers.Internal.PickupEvent.OnSpawnedPickup; + ItemPickupBase.OnPickupDestroyed -= Handlers.Internal.PickupEvent.OnRemovedPickup; EventManager.UnregisterEvents(this); } From 2df7739a22c73c100683861cb0065818e697cf5a Mon Sep 17 00:00:00 2001 From: louis1706 Date: Wed, 1 Nov 2023 17:04:26 +0100 Subject: [PATCH 181/207] Fix stamina bug --- Exiled.API/Features/Pickups/BodyArmorPickup.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Exiled.API/Features/Pickups/BodyArmorPickup.cs b/Exiled.API/Features/Pickups/BodyArmorPickup.cs index 8e3c50cc85..430e758df2 100644 --- a/Exiled.API/Features/Pickups/BodyArmorPickup.cs +++ b/Exiled.API/Features/Pickups/BodyArmorPickup.cs @@ -163,6 +163,7 @@ protected override void InitializeProperties(ItemBase itemBase) helmetEfficacy = armoritem.HelmetEfficacy; vestEfficacy = armoritem.VestEfficacy; RemoveExcessOnDrop = !armoritem.DontRemoveExcessOnDrop; + StaminaUseMultiplier = armoritem._staminaUseMultiplier; AmmoLimits = armoritem.AmmoLimits.Select(limit => (ArmorAmmoLimit)limit); CategoryLimits = armoritem.CategoryLimits; } From a31d69d3927651c329340c0ae3676441c59cbfaf Mon Sep 17 00:00:00 2001 From: louis1706 Date: Wed, 1 Nov 2023 17:06:53 +0100 Subject: [PATCH 182/207] No ArgumentOutOfRangeException for this --- Exiled.API/Features/Items/Armor.cs | 1 - Exiled.API/Features/Pickups/BodyArmorPickup.cs | 2 -- 2 files changed, 3 deletions(-) diff --git a/Exiled.API/Features/Items/Armor.cs b/Exiled.API/Features/Items/Armor.cs index bd7358c677..fb8ad0ef42 100644 --- a/Exiled.API/Features/Items/Armor.cs +++ b/Exiled.API/Features/Items/Armor.cs @@ -122,7 +122,6 @@ public int VestEfficacy /// /// Gets or sets how much faster stamina will drain when wearing this armor. /// - /// When attempting to set the value below 1 or above 2. public float StaminaUseMultiplier { get => Base._staminaUseMultiplier; diff --git a/Exiled.API/Features/Pickups/BodyArmorPickup.cs b/Exiled.API/Features/Pickups/BodyArmorPickup.cs index 430e758df2..04df55b21e 100644 --- a/Exiled.API/Features/Pickups/BodyArmorPickup.cs +++ b/Exiled.API/Features/Pickups/BodyArmorPickup.cs @@ -114,13 +114,11 @@ public int VestEfficacy /// /// Gets or sets how much faster stamina will drain when wearing this armor. /// - /// When attempting to set the value below 1 or above 2. public float StaminaUseMultiplier { get; set; } /// /// Gets how much the users movement speed should be affected when wearing this armor. (higher values = slower movement). /// - /// When attempting to set the value below 0 or above 1. public float MovementSpeedMultiplier { get; } /// From d32fc8955d531c07bb5df590fabf891bacc8a1b9 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Wed, 1 Nov 2023 18:52:56 +0100 Subject: [PATCH 183/207] fix Metal --- Exiled.API/Extensions/EffectTypeExtension.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Exiled.API/Extensions/EffectTypeExtension.cs b/Exiled.API/Extensions/EffectTypeExtension.cs index c2ae09a0bf..685655f289 100644 --- a/Exiled.API/Extensions/EffectTypeExtension.cs +++ b/Exiled.API/Extensions/EffectTypeExtension.cs @@ -137,6 +137,7 @@ public static class EffectTypeExtension SugarHigh => EffectType.SugarHigh, SugarRush => EffectType.SugarRush, TraumatizedByEvil => EffectType.TraumatizedByEvil, + Metal => EffectType.Metal, Prismatic => EffectType.Prismatic, SlowMetabolism => EffectType.SlowMetabolism, MarshmallowEffect => EffectType.Marshmallow, From e01ff0b65a0b8a75f45d2e0626c6ba188f6cc59d Mon Sep 17 00:00:00 2001 From: IRacle <79921583+IRacle1@users.noreply.github.com> Date: Wed, 1 Nov 2023 22:02:29 +0300 Subject: [PATCH 184/207] Jailbird/firearm fix (#2187) * jailbird fix * firearm fix --- Exiled.API/Features/Pickups/JailbirdPickup.cs | 1 + Exiled.API/Features/Pickups/Pickup.cs | 3 +++ Exiled.API/Features/Player.cs | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/Exiled.API/Features/Pickups/JailbirdPickup.cs b/Exiled.API/Features/Pickups/JailbirdPickup.cs index aa5fa2bf62..7af31e6ae9 100644 --- a/Exiled.API/Features/Pickups/JailbirdPickup.cs +++ b/Exiled.API/Features/Pickups/JailbirdPickup.cs @@ -101,6 +101,7 @@ public JailbirdWearState WearState internal override void ReadItemInfo(Item item) { base.ReadItemInfo(item); + if (item is Jailbird jailBirditem) { MeleeDamage = jailBirditem.MeleeDamage; diff --git a/Exiled.API/Features/Pickups/Pickup.cs b/Exiled.API/Features/Pickups/Pickup.cs index d5b41bbe47..0706f5d5d2 100644 --- a/Exiled.API/Features/Pickups/Pickup.cs +++ b/Exiled.API/Features/Pickups/Pickup.cs @@ -28,6 +28,7 @@ namespace Exiled.API.Features.Pickups using BaseAmmoPickup = InventorySystem.Items.Firearms.Ammo.AmmoPickup; using BaseBodyArmorPickup = InventorySystem.Items.Armor.BodyArmorPickup; using BaseFirearmPickup = InventorySystem.Items.Firearms.FirearmPickup; + using BaseJailbirdPickup = InventorySystem.Items.Jailbird.JailbirdPickup; using BaseKeycardPickup = InventorySystem.Items.Keycards.KeycardPickup; using BaseMicroHIDPickup = InventorySystem.Items.MicroHID.MicroHIDPickup; using BaseRadioPickup = InventorySystem.Items.Radio.RadioPickup; @@ -35,6 +36,7 @@ namespace Exiled.API.Features.Pickups using BaseScp1576Pickup = InventorySystem.Items.Usables.Scp1576.Scp1576Pickup; using BaseScp2176Projectile = InventorySystem.Items.ThrowableProjectiles.Scp2176Projectile; using BaseScp330Pickup = InventorySystem.Items.Usables.Scp330.Scp330Pickup; + using Object = UnityEngine.Object; /// @@ -321,6 +323,7 @@ public static Pickup Get(ItemPickupBase pickupBase) BaseBodyArmorPickup bodyArmorPickup => new BodyArmorPickup(bodyArmorPickup), BaseScp330Pickup scp330Pickup => new Scp330Pickup(scp330Pickup), BaseScp1576Pickup scp1576Pickup => new Scp1576Pickup(scp1576Pickup), + BaseJailbirdPickup jailbirdPickup => new JailbirdPickup(jailbirdPickup), ThrownProjectile thrownProjectile => thrownProjectile switch { BaseScp018Projectile scp018 => new Projectiles.Scp018Projectile(scp018), diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 6881b571d0..0949e362c1 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -2329,6 +2329,11 @@ public int GetCategoryLimit(ItemCategory category) => /// The given to the player. public Item AddItem(ItemType itemType) { + if (itemType.GetFirearmType() is not FirearmType.None) + { + return AddItem(itemType.GetFirearmType(), null); + } + Item item = Item.Create(itemType); AddItem(item); From 78a3c2e650fd30422064c1015481bdf94d7ddaaa Mon Sep 17 00:00:00 2001 From: Yamato <66829532+louis1706@users.noreply.github.com> Date: Wed, 1 Nov 2023 23:42:08 +0100 Subject: [PATCH 185/207] Nw skill issue fixed jailbird crash (#2200) * NWFix * . --- .../Fixes/FixJailbirdHitWindowsCrash.cs | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 Exiled.Events/Patches/Fixes/FixJailbirdHitWindowsCrash.cs diff --git a/Exiled.Events/Patches/Fixes/FixJailbirdHitWindowsCrash.cs b/Exiled.Events/Patches/Fixes/FixJailbirdHitWindowsCrash.cs new file mode 100644 index 0000000000..ea45731a2b --- /dev/null +++ b/Exiled.Events/Patches/Fixes/FixJailbirdHitWindowsCrash.cs @@ -0,0 +1,94 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Fixes +{ +#pragma warning disable SA1313 // Parameter names should begin with lower-case letter +#pragma warning disable CS1591 // Commentaire XML manquant pour le type ou le membre visible publiquement +#pragma warning disable SA1600 // Elements should be documented + + using CustomPlayerEffects; + using HarmonyLib; + using InventorySystem.Items.Jailbird; + using Mirror; + using PlayerRoles.FirstPersonControl; + using PlayerStatsSystem; + using RelativePositioning; + using UnityEngine; + using Utils.Networking; + using Utils.NonAllocLINQ; + + /// + /// Patches delegate. + /// Fix than NW don't send the a null referenceHub in client NetwordReader causing crash when player hit windows. + /// Prefix taken from https://github.com/GraczBezNicku/Jailbird-Glass-Fix. + /// + [HarmonyPatch(typeof(JailbirdHitreg), nameof(JailbirdHitreg.ServerAttack))] + public static class FixJailbirdHitWindowsCrash + { + public static bool Prefix(ref bool __result, JailbirdHitreg __instance, bool isCharging, NetworkReader reader) + { + ReferenceHub owner = __instance._item.Owner; + bool result = false; + if (reader != null) + { + RelativePosition relativePosition = reader.ReadRelativePosition(); + Quaternion claimedRot = reader.ReadQuaternion(); + JailbirdHitreg.BacktrackedPlayers.Add(new FpcBacktracker(owner, relativePosition.Position, claimedRot, 0.1f, 0.15f)); + byte b = reader.ReadByte(); + for (int i = 0; i < b; i++) + { + try + { + bool flag = reader.TryReadReferenceHub(out ReferenceHub target); + RelativePosition relativePosition2 = reader.ReadRelativePosition(); + if (flag) + { + JailbirdHitreg.BacktrackedPlayers.Add(new FpcBacktracker(target, relativePosition2.Position, 0.4f)); + } + } + catch + { + // Ignore. + } + } + } + + __instance.DetectDestructibles(); + Vector3 forward = __instance._item.Owner.PlayerCameraReference.forward; + float num = isCharging ? __instance._damageCharge : __instance._damageMelee; + for (int j = 0; j < JailbirdHitreg._detectionsLen; j++) + { + IDestructible destructible = JailbirdHitreg.DetectedDestructibles[j]; + if (destructible.Damage(num, new JailbirdDamageHandler(owner, num, forward), destructible.CenterOfMass)) + { + result = true; + if (!isCharging) + { + __instance.TotalMeleeDamageDealt += num; + } + else + { + if (destructible is HitboxIdentity hitboxIdentity) + { + hitboxIdentity.TargetHub.playerEffectsController.EnableEffect(__instance._flashDuration, true); + } + } + } + } + + JailbirdHitreg.BacktrackedPlayers.ForEach(x => + { + x.RestorePosition(); + }); + JailbirdHitreg.BacktrackedPlayers.Clear(); + __result = result; + + return false; + } + } +} \ No newline at end of file From 9acfb82821c75d2d3fdbf9eb1706574651cc045f Mon Sep 17 00:00:00 2001 From: Thunder Date: Wed, 1 Nov 2023 20:32:32 -0400 Subject: [PATCH 186/207] Documentation fix --- Exiled.CustomItems/API/Features/CustomGrenade.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.CustomItems/API/Features/CustomGrenade.cs b/Exiled.CustomItems/API/Features/CustomGrenade.cs index a263e2ab3c..aece379e6b 100644 --- a/Exiled.CustomItems/API/Features/CustomGrenade.cs +++ b/Exiled.CustomItems/API/Features/CustomGrenade.cs @@ -49,7 +49,7 @@ public override ItemType Type } /// - /// Gets or sets a value indicating whether gets or sets a value that determines if the grenade should explode immediately when contacting any surface. + /// Gets or sets a value indicating whether or not the grenade should explode immediately when contacting any surface. /// public abstract bool ExplodeOnCollision { get; set; } From 2451f1ffd4010769f5d7026a2cb29be783501b33 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Thu, 2 Nov 2023 09:48:23 +0100 Subject: [PATCH 187/207] Bump Version --- EXILED.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED.props b/EXILED.props index f09d262c21..ae3bf52373 100644 --- a/EXILED.props +++ b/EXILED.props @@ -15,7 +15,7 @@ - 8.3.7 + 8.3.8 false From b5b3888ba595224928307e3fb600e69af090b627 Mon Sep 17 00:00:00 2001 From: Zereth <70236765+o5zereth@users.noreply.github.com> Date: Thu, 2 Nov 2023 10:57:50 -0400 Subject: [PATCH 188/207] ok, lets save 3 opcodes worth of perfomance as if it actually matters. like seriously? --- .../Patches/Events/Player/ChangingGroup.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Exiled.Events/Patches/Events/Player/ChangingGroup.cs b/Exiled.Events/Patches/Events/Player/ChangingGroup.cs index 1ffb9e3f3a..695883a4e6 100644 --- a/Exiled.Events/Patches/Events/Player/ChangingGroup.cs +++ b/Exiled.Events/Patches/Events/Player/ChangingGroup.cs @@ -33,6 +33,8 @@ private static IEnumerable Transpiler(IEnumerable newInstructions = ListPool.Pool.Get(instructions); + LocalBuilder ev = generator.DeclareLocal(typeof(ChangingGroupEventArgs)); + Label returnLabel = generator.DefineLabel(); int offset = 1; @@ -42,10 +44,11 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable Date: Fri, 3 Nov 2023 10:53:10 +0100 Subject: [PATCH 189/207] Fix Server.Host not being able to deal Damage with Grenade --- Exiled.Events/EventArgs/Map/ExplodingGrenadeEventArgs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.Events/EventArgs/Map/ExplodingGrenadeEventArgs.cs b/Exiled.Events/EventArgs/Map/ExplodingGrenadeEventArgs.cs index 9c6b570de7..292f34596c 100644 --- a/Exiled.Events/EventArgs/Map/ExplodingGrenadeEventArgs.cs +++ b/Exiled.Events/EventArgs/Map/ExplodingGrenadeEventArgs.cs @@ -67,7 +67,7 @@ public ExplodingGrenadeEventArgs(Footprint thrower, Vector3 position, ExplosionG break; case true: { - if (Server.FriendlyFire || HitboxIdentity.CheckFriendlyFire(thrower.Role, hub.roleManager.CurrentRole.RoleTypeId)) + if (Server.FriendlyFire || thrower.Hub == Server.Host.ReferenceHub || HitboxIdentity.CheckFriendlyFire(thrower.Role, hub.roleManager.CurrentRole.RoleTypeId)) { if (!TargetsToAffect.Contains(player)) TargetsToAffect.Add(player); From b31589072feca05872c2dccea1becbdd62d1549c Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 3 Nov 2023 10:53:34 +0100 Subject: [PATCH 190/207] (there no change but it's will make it work when NW will make it correctly) --- Exiled.API/Features/Roles/Scp3114Role.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Exiled.API/Features/Roles/Scp3114Role.cs b/Exiled.API/Features/Roles/Scp3114Role.cs index fc987353ea..b52e16c0ac 100644 --- a/Exiled.API/Features/Roles/Scp3114Role.cs +++ b/Exiled.API/Features/Roles/Scp3114Role.cs @@ -14,6 +14,7 @@ namespace Exiled.API.Features.Roles using Exiled.API.Interfaces; using Mirror; using PlayerRoles; + using PlayerRoles.PlayableScps; using PlayerRoles.PlayableScps.HumeShield; using PlayerRoles.PlayableScps.Scp3114; using PlayerRoles.PlayableScps.Subroutines; @@ -222,6 +223,6 @@ public void ResetIdentity() /// /// The List of Roles already spawned. /// The Spawn Chance. - public float GetSpawnChance(List alreadySpawned) => 0; + public float GetSpawnChance(List alreadySpawned) => Base is ISpawnableScp spawnableScp ? spawnableScp.GetSpawnChance(alreadySpawned) : 0; } } \ No newline at end of file From b03bbc479330ec5e742ba81dfc5b148fe5ece143 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 3 Nov 2023 11:34:39 +0100 Subject: [PATCH 191/207] Fix TryAddCandy --- Exiled.API/Features/Player.cs | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 0949e362c1..e44499bb13 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -2629,26 +2629,29 @@ public void AddItem(Dictionary> firea /// if a candy was given. public bool TryAddCandy(CandyKindID candyType) { - if (Scp330Bag.TryGetBag(ReferenceHub, out Scp330Bag bag)) + bool flag = false; + if (!Scp330Bag.TryGetBag(referenceHub, out Scp330Bag scp330Bag)) { - bool flag = bag.TryAddSpecific(candyType); - - if (flag) - bag.ServerRefreshBag(); + flag = true; + if (Items.Count > 7) + return false; - return flag; + scp330Bag = AddItem(ItemType.SCP330).As().Base; } - if (Items.Count > 7) - return false; - - Scp330 scp330 = (Scp330)AddItem(ItemType.SCP330); - - Timing.CallDelayed(0.02f, () => + if (flag) + { + scp330Bag.Candies = new List { candyType }; + scp330Bag.ServerRefreshBag(); + } + else if (scp330Bag.TryAddSpecific(candyType)) + { + scp330Bag.ServerRefreshBag(); + } + else { - scp330.Base.Candies.Clear(); - scp330.AddCandy(candyType); - }); + return false; + } return true; } From c404084aaf0f00c42437d93bdc83883e3905926d Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 3 Nov 2023 14:58:50 +0100 Subject: [PATCH 192/207] Fix than ConfirmAcqusition need to be done after some tick --- Exiled.API/Features/Player.cs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index e44499bb13..7cbf36c67a 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -2555,18 +2555,13 @@ public Item AddItem(ItemBase itemBase, Item item = null) item.ChangeOwner(item.Owner, this); - if (itemBase is IAcquisitionConfirmationTrigger acquisitionConfirmationTrigger) - { - acquisitionConfirmationTrigger.ServerConfirmAcqusition(); - acquisitionConfirmationTrigger.AcquisitionAlreadyReceived = true; - } - - // Dont care, didnt ask, ratio - // UPD 12.09.23 - maybe some changes will fix candies desync, and that legacy code can be deleted Timing.CallDelayed(0.02f, () => { - if (item.Type is ItemType.SCP330 && item.Base != null) - ((Scp330)item).Base.ServerRefreshBag(); + if (itemBase is IAcquisitionConfirmationTrigger acquisitionConfirmationTrigger) + { + acquisitionConfirmationTrigger.ServerConfirmAcqusition(); + acquisitionConfirmationTrigger.AcquisitionAlreadyReceived = true; + } }); ItemsValue.Add(item); From b58705a8a0ec6ee4ddf06908983064b50e5ff822 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 3 Nov 2023 15:00:09 +0100 Subject: [PATCH 193/207] Bump Version --- EXILED.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED.props b/EXILED.props index ae3bf52373..92ae4029c1 100644 --- a/EXILED.props +++ b/EXILED.props @@ -15,7 +15,7 @@ - 8.3.8 + 8.3.9 false From 476baa5d393b372ae19e770880d97f288a9ffad8 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 3 Nov 2023 16:24:40 +0100 Subject: [PATCH 194/207] Map.IsHubertSky HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT --- Exiled.API/Features/Map.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Exiled.API/Features/Map.cs b/Exiled.API/Features/Map.cs index 4342640c3d..53acc7dcb6 100644 --- a/Exiled.API/Features/Map.cs +++ b/Exiled.API/Features/Map.cs @@ -67,6 +67,7 @@ public static class Map private static global::Hazards.PrismaticCloud prismaticCloudPrefab; private static AmbientSoundPlayer ambientSoundPlayer; + private static SkyboxHubert skyboxHubert; /// /// Gets the prismatic prefab. @@ -129,6 +130,19 @@ public static Scp939AmnesticCloudInstance AmnesticCloudPrefab } } + public static SkyboxHubert SkyboxHubert + { + get + { + if (skyboxHubert == null) + { + skyboxHubert = Object.FindObjectOfType(); + } + + return skyboxHubert; + } + } + /// /// Gets a value indicating whether decontamination has begun in the light containment zone. /// @@ -174,6 +188,16 @@ public static int Seed /// public static AmbientSoundPlayer AmbientSoundPlayer => ambientSoundPlayer != null ? ambientSoundPlayer : (ambientSoundPlayer = ReferenceHub.HostHub.GetComponent()); + /// + /// Gets or sets a value indicating whether HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT. + /// HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT HUBERT. + /// + public static bool IsHubertSky + { + get => SkyboxHubert.NetworkHubert; + set => SkyboxHubert.NetworkHubert = value; + } + /// /// Broadcasts a message to all players. /// From 019760a5803617c938461f403f87c4a9aeeba9a7 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 3 Nov 2023 16:30:48 +0100 Subject: [PATCH 195/207] missing doc --- Exiled.API/Features/Map.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Exiled.API/Features/Map.cs b/Exiled.API/Features/Map.cs index 53acc7dcb6..ffa6934014 100644 --- a/Exiled.API/Features/Map.cs +++ b/Exiled.API/Features/Map.cs @@ -130,6 +130,9 @@ public static Scp939AmnesticCloudInstance AmnesticCloudPrefab } } + /// + /// Gets the Hubert Sky prefab. + /// public static SkyboxHubert SkyboxHubert { get From da065406f080f1aa91feca51bef79f94a5d59511 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 3 Nov 2023 18:40:49 +0100 Subject: [PATCH 196/207] ItemType.AntiSCP207 was missing for Usable object --- Exiled.API/Features/Items/Item.cs | 2 +- Exiled.API/Features/Pickups/Pickup.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Exiled.API/Features/Items/Item.cs b/Exiled.API/Features/Items/Item.cs index 423bcd280b..682053850e 100644 --- a/Exiled.API/Features/Items/Item.cs +++ b/Exiled.API/Features/Items/Item.cs @@ -250,7 +250,7 @@ public static Item Get(ItemBase itemBase) public static Item Create(ItemType type, Player owner = null) => type switch { ItemType.SCP268 => new Usable(type), - ItemType.Adrenaline or ItemType.Medkit or ItemType.Painkillers or ItemType.SCP500 or ItemType.SCP207 or ItemType.SCP1853 => new Consumable(type), + ItemType.Adrenaline or ItemType.Medkit or ItemType.Painkillers or ItemType.SCP500 or ItemType.SCP207 or ItemType.SCP1853 or ItemType.AntiSCP207 => new Consumable(type), ItemType.SCP244a or ItemType.SCP244b => new Scp244(type), ItemType.Ammo9x19 or ItemType.Ammo12gauge or ItemType.Ammo44cal or ItemType.Ammo556x45 or ItemType.Ammo762x39 => new Ammo(type), ItemType.Flashlight or ItemType.Lantern => new Flashlight(type), diff --git a/Exiled.API/Features/Pickups/Pickup.cs b/Exiled.API/Features/Pickups/Pickup.cs index 0706f5d5d2..b56057a6ea 100644 --- a/Exiled.API/Features/Pickups/Pickup.cs +++ b/Exiled.API/Features/Pickups/Pickup.cs @@ -479,7 +479,7 @@ public static IEnumerable Get(IEnumerable gameObjects) ItemType.KeycardGuard or ItemType.KeycardJanitor or ItemType.KeycardO5 or ItemType.KeycardScientist or ItemType.KeycardContainmentEngineer or ItemType.KeycardFacilityManager or ItemType.KeycardResearchCoordinator or ItemType.KeycardZoneManager or ItemType.KeycardMTFCaptain or ItemType.KeycardMTFOperative or ItemType.KeycardMTFPrivate => new KeycardPickup(type), ItemType.ArmorLight or ItemType.ArmorCombat or ItemType.ArmorHeavy => new BodyArmorPickup(type), ItemType.SCP330 => new Scp330Pickup(), - ItemType.SCP500 or ItemType.SCP268 or ItemType.SCP207 or ItemType.SCP1853 or ItemType.Painkillers or ItemType.Medkit or ItemType.Adrenaline => new UsablePickup(type), + ItemType.SCP500 or ItemType.SCP268 or ItemType.SCP207 or ItemType.SCP1853 or ItemType.Painkillers or ItemType.Medkit or ItemType.Adrenaline or ItemType.AntiSCP207 => new UsablePickup(type), ItemType.Jailbird => new JailbirdPickup(), ItemType.SCP1576 => new Scp1576Pickup(), ItemType.SCP2176 => new Projectiles.Scp2176Projectile(), From 006b1c8ec2268fbb2c0ba143b58ad13606d8e331 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 3 Nov 2023 19:59:51 +0100 Subject: [PATCH 197/207] Checking if player is connected --- Exiled.API/Extensions/MirrorExtensions.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Exiled.API/Extensions/MirrorExtensions.cs b/Exiled.API/Extensions/MirrorExtensions.cs index 5fc259583b..9b0b1fa424 100644 --- a/Exiled.API/Extensions/MirrorExtensions.cs +++ b/Exiled.API/Extensions/MirrorExtensions.cs @@ -383,6 +383,8 @@ void CustomSyncVarGenerator(NetworkWriter targetWriter) /// Values of send to target. public static void SendFakeTargetRpc(Player target, NetworkIdentity behaviorOwner, Type targetType, string rpcName, params object[] values) { + if (!target.IsConnected) + return; NetworkWriterPooled writer = NetworkWriterPool.Get(); foreach (object value in values) From 11552a86c6f33e493dd34f155a1bbbef6c3e2b93 Mon Sep 17 00:00:00 2001 From: louis1706 Date: Sun, 5 Nov 2023 22:58:38 +0100 Subject: [PATCH 198/207] Fix TogglingFlashlight to work with Lantern --- Exiled.Events/EventArgs/Player/TogglingFlashlightEventArgs.cs | 4 ++-- Exiled.Events/Patches/Events/Player/TogglingFlashlight.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Exiled.Events/EventArgs/Player/TogglingFlashlightEventArgs.cs b/Exiled.Events/EventArgs/Player/TogglingFlashlightEventArgs.cs index 66323f8d99..7db34c3ac5 100644 --- a/Exiled.Events/EventArgs/Player/TogglingFlashlightEventArgs.cs +++ b/Exiled.Events/EventArgs/Player/TogglingFlashlightEventArgs.cs @@ -12,7 +12,7 @@ namespace Exiled.Events.EventArgs.Player using Interfaces; - using InventorySystem.Items.SwitchableLightSources.Flashlight; + using InventorySystem.Items.SwitchableLightSources; /// /// Contains all information before a player toggles the flashlight. @@ -33,7 +33,7 @@ public class TogglingFlashlightEventArgs : IPlayerEvent, IDeniableEvent, IItemEv /// /// /// - public TogglingFlashlightEventArgs(ReferenceHub hub, FlashlightItem flashlight, bool newState) + public TogglingFlashlightEventArgs(ReferenceHub hub, SwitchableLightSourceItemBase flashlight, bool newState) { Player = Player.Get(hub); Flashlight = (Flashlight)Item.Get(flashlight); diff --git a/Exiled.Events/Patches/Events/Player/TogglingFlashlight.cs b/Exiled.Events/Patches/Events/Player/TogglingFlashlight.cs index f919d934f4..b4800a2f0c 100644 --- a/Exiled.Events/Patches/Events/Player/TogglingFlashlight.cs +++ b/Exiled.Events/Patches/Events/Player/TogglingFlashlight.cs @@ -51,7 +51,7 @@ private static IEnumerable Transpiler(IEnumerable Date: Wed, 8 Nov 2023 11:46:32 +0300 Subject: [PATCH 199/207] Fixes (#2205) * npcs fix * fix `IAcquisitionConfirmationTrigger` logic * final 330 fix --- Exiled.API/Features/Items/Scp330.cs | 2 +- Exiled.API/Features/Npc.cs | 2 +- Exiled.API/Features/Player.cs | 10 +++------- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Exiled.API/Features/Items/Scp330.cs b/Exiled.API/Features/Items/Scp330.cs index 68818f6101..da46ec3ad4 100644 --- a/Exiled.API/Features/Items/Scp330.cs +++ b/Exiled.API/Features/Items/Scp330.cs @@ -64,6 +64,7 @@ public Scp330(Scp330Bag itemBase) internal Scp330() : this((Scp330Bag)Server.Host.Inventory.CreateItemInstance(new(ItemType.SCP330, 0), false)) { + Base.Candies.Add(Scp330Candies.GetRandom()); } /// @@ -282,7 +283,6 @@ public override Item Clone() internal override void ChangeOwner(Player oldOwner, Player newOwner) { Base.Owner = newOwner.ReferenceHub; - Base.ServerRefreshBag(); } } } diff --git a/Exiled.API/Features/Npc.cs b/Exiled.API/Features/Npc.cs index ba6c57a284..d1abbc9095 100644 --- a/Exiled.API/Features/Npc.cs +++ b/Exiled.API/Features/Npc.cs @@ -150,7 +150,7 @@ public static Npc Spawn(string name, RoleTypeId role, int id = 0, string userId int conId = id == 0 ? ReferenceHub.AllHubs.Count + 1 : id; - NetworkServer.AddPlayerForConnection(new(conId), newObject); + NetworkServer.AddPlayerForConnection(new FakeConnection(conId), newObject); try { diff --git a/Exiled.API/Features/Player.cs b/Exiled.API/Features/Player.cs index 7cbf36c67a..b73505a1c5 100644 --- a/Exiled.API/Features/Player.cs +++ b/Exiled.API/Features/Player.cs @@ -2555,14 +2555,10 @@ public Item AddItem(ItemBase itemBase, Item item = null) item.ChangeOwner(item.Owner, this); - Timing.CallDelayed(0.02f, () => + if (itemBase is IAcquisitionConfirmationTrigger acquisitionConfirmationTrigger) { - if (itemBase is IAcquisitionConfirmationTrigger acquisitionConfirmationTrigger) - { - acquisitionConfirmationTrigger.ServerConfirmAcqusition(); - acquisitionConfirmationTrigger.AcquisitionAlreadyReceived = true; - } - }); + acquisitionConfirmationTrigger.AcquisitionAlreadyReceived = false; + } ItemsValue.Add(item); From 156b4d5c0d612d9c803370773f813f9ea751a986 Mon Sep 17 00:00:00 2001 From: Thunder Date: Wed, 8 Nov 2023 21:25:15 -0500 Subject: [PATCH 200/207] Add Scp3114Role.VoiceLines and Scp3114Role.PlaySound() --- Exiled.API/Features/Roles/Scp3114Role.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Exiled.API/Features/Roles/Scp3114Role.cs b/Exiled.API/Features/Roles/Scp3114Role.cs index b52e16c0ac..bdec6315a2 100644 --- a/Exiled.API/Features/Roles/Scp3114Role.cs +++ b/Exiled.API/Features/Roles/Scp3114Role.cs @@ -75,6 +75,11 @@ internal Scp3114Role(Scp3114GameRole baseRole) Log.Error("Scp3114Disguise not found in Scp3114Role::ctor"); Disguise = scp3114Disguise; + + if (!SubroutineModule.TryGetSubroutine(out Scp3114VoiceLines scp3114VoiceLines)) + Log.Error("Scp3114VoiceLines not found in Scp3114Role::ctor"); + + VoiceLines = scp3114VoiceLines; } /// @@ -121,6 +126,11 @@ internal Scp3114Role(Scp3114GameRole baseRole) /// public Scp3114Disguise Disguise { get; } + /// + /// Gets Scp3114's . + /// + public Scp3114VoiceLines VoiceLines { get; } + /// /// Gets the instance. /// @@ -218,6 +228,13 @@ public void ResetIdentity() Identity.ServerResendIdentity(); } + /// + /// Plays a random Scp3114 voice line. + /// + /// The type of voice line to play. + public void PlaySound(Scp3114VoiceLines.VoiceLinesName voiceLine = Scp3114VoiceLines.VoiceLinesName.RandomIdle) + => VoiceLines.ServerPlayConditionally(voiceLine); + /// /// Gets the Spawn Chance of SCP-3114. /// From cdb2f26db58a9817fcd6d4c072afa800fa571d7a Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 10 Nov 2023 19:06:55 +0100 Subject: [PATCH 201/207] Fix IndividualFriendlyFire --- .../Patches/Generic/IndividualFriendlyFire.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs b/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs index 0465d86b57..060421f45b 100644 --- a/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs +++ b/Exiled.Events/Patches/Generic/IndividualFriendlyFire.cs @@ -89,7 +89,7 @@ public static bool CheckFriendlyFirePlayerRules(Footprint attackerFootprint, Ref // Return false, no custom friendly fire allowed, default to NW logic for FF. No point in processing if FF is enabled across the board. if (Server.FriendlyFire) - return false; + return HitboxIdentity.CheckFriendlyFire(attackerFootprint.Role, victimHub.roleManager.CurrentRole.RoleTypeId); // always allow damage from Server.Host if (attackerFootprint.Hub == Server.Host.ReferenceHub) @@ -134,7 +134,7 @@ public static bool CheckFriendlyFirePlayerRules(Footprint attackerFootprint, Ref if (pairedData.ContainsKey(attacker.Role)) { ffMultiplier = pairedData[attacker.Role]; - return true; + return ffMultiplier != 0; } } } @@ -149,7 +149,7 @@ public static bool CheckFriendlyFirePlayerRules(Footprint attackerFootprint, Ref if (pairedData.ContainsKey(victim.Role)) { ffMultiplier = pairedData[victim.Role]; - return true; + return ffMultiplier != 0; } } } @@ -161,16 +161,16 @@ public static bool CheckFriendlyFirePlayerRules(Footprint attackerFootprint, Ref if (attacker.FriendlyFireMultiplier.TryGetValue(victim.Role, out float ffMulti)) { ffMultiplier = ffMulti; - return true; + return ffMultiplier != 0; } } } catch (Exception ex) { - Log.Debug($"CheckFriendlyFirePlayerRules failed to handle friendly fire because: {ex}"); + Log.Error($"CheckFriendlyFirePlayerRules failed to handle friendly fire because: {ex}"); } - return false; + return HitboxIdentity.CheckFriendlyFire(attackerFootprint.Role, victimHub.roleManager.CurrentRole.RoleTypeId); } } From 28cd8725e2acb1c4079192e88ab893878f3988ff Mon Sep 17 00:00:00 2001 From: louis1706 Date: Fri, 10 Nov 2023 19:08:25 +0100 Subject: [PATCH 202/207] Bump Version --- EXILED.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED.props b/EXILED.props index 92ae4029c1..39d21c8802 100644 --- a/EXILED.props +++ b/EXILED.props @@ -15,7 +15,7 @@ - 8.3.9 + 8.3.10 false From 36952ac52b89e3c403b85fcb87dbcb30e3338f1b Mon Sep 17 00:00:00 2001 From: Bolton <48883340+BoltonDev@users.noreply.github.com> Date: Fri, 10 Nov 2023 20:07:58 +0100 Subject: [PATCH 203/207] Fix Patch errors (#2218) --- Exiled.Events/Patches/Fixes/GrenadePropertiesFix.cs | 5 ----- Exiled.Events/Patches/Generic/PickupControlPatch.cs | 9 ++------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/Exiled.Events/Patches/Fixes/GrenadePropertiesFix.cs b/Exiled.Events/Patches/Fixes/GrenadePropertiesFix.cs index f9fd0835d0..bb42e350a2 100644 --- a/Exiled.Events/Patches/Fixes/GrenadePropertiesFix.cs +++ b/Exiled.Events/Patches/Fixes/GrenadePropertiesFix.cs @@ -103,11 +103,6 @@ private static IEnumerable Transpiler(IEnumerable Transpiler( // pickup.ReadItemInfo(item); new(OpCodes.Callvirt, Method(typeof(Pickup), nameof(Pickup.ReadItemInfo))), - - // pickup.IsSpawned = spawn - new(OpCodes.Ldarg_S, 4), - new(OpCodes.Callvirt, PropertySetter(typeof(Pickup), nameof(Pickup.IsSpawned))), }); for (int z = 0; z < newInstructions.Count; z++) @@ -82,11 +78,10 @@ private static IEnumerable Transpiler(IEnumerable Date: Fri, 10 Nov 2023 20:08:55 +0100 Subject: [PATCH 204/207] 8.3.11 --- EXILED.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED.props b/EXILED.props index 39d21c8802..2c7eeed24c 100644 --- a/EXILED.props +++ b/EXILED.props @@ -15,7 +15,7 @@ - 8.3.10 + 8.3.11 false From 7fe62a6530a7b0993456e3b5126f343e70140307 Mon Sep 17 00:00:00 2001 From: Misaka-ZeroTwo <45165615+Misaka-ZeroTwo@users.noreply.github.com> Date: Fri, 10 Nov 2023 15:02:02 -0500 Subject: [PATCH 205/207] Trigger gh action From cc989f42a15853d563fe019a19bb663232ea4b6e Mon Sep 17 00:00:00 2001 From: NotIntense Date: Fri, 10 Nov 2023 15:05:24 -0500 Subject: [PATCH 206/207] Fix IL error (#2221) --- Exiled.Events/Patches/Generic/PickupControlPatch.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Exiled.Events/Patches/Generic/PickupControlPatch.cs b/Exiled.Events/Patches/Generic/PickupControlPatch.cs index 3fe328ac85..c76a8f2474 100644 --- a/Exiled.Events/Patches/Generic/PickupControlPatch.cs +++ b/Exiled.Events/Patches/Generic/PickupControlPatch.cs @@ -49,7 +49,6 @@ private static IEnumerable Transpiler( // pickup = Pickup.Get(pickupBase); new(OpCodes.Ldloc_0), new(OpCodes.Call, Method(typeof(Pickup), nameof(Pickup.Get), new[] { typeof(ItemPickupBase) })), - new(OpCodes.Dup), // Item.Get(itemBase); new(OpCodes.Ldarg_0), From 842f9d731e67166c8ecef660302c009c14e52996 Mon Sep 17 00:00:00 2001 From: Misaka-ZeroTwo <45165615+Misaka-ZeroTwo@users.noreply.github.com> Date: Fri, 10 Nov 2023 15:28:42 -0500 Subject: [PATCH 207/207] Create halloween.yml --- .github/workflows/halloween.yml | 53 +++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/halloween.yml diff --git a/.github/workflows/halloween.yml b/.github/workflows/halloween.yml new file mode 100644 index 0000000000..55a42098f0 --- /dev/null +++ b/.github/workflows/halloween.yml @@ -0,0 +1,53 @@ +name: Exiled Halloween CI + +on: + push: + branches: + - 'halloween-2023' + pull_request: + branches: + - 'halloween-2023' + workflow_dispatch: + +env: + EXILED_REFERENCES_URL: https://exiled.host/build_deps/Dev.zip + EXILED_REFERENCES_PATH: ${{ github.workspace }}/References + +jobs: + + build: + + runs-on: windows-latest + # Prevent double running for push & pull_request events from the main repo + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'Exiled-Team/Exiled' + + steps: + + - name: Setup .NET Core SDK + uses: actions/setup-dotnet@v1.7.2 + + - name: Setup Nuget + uses: iRebbok/setup-nuget@master + + - uses: actions/checkout@v2.3.4 + + - name: Get references + shell: pwsh + run: | + Invoke-WebRequest -Uri ${{ env.EXILED_REFERENCES_URL }} -OutFile ${{ github.workspace }}/References.zip + Expand-Archive -Path References.zip -DestinationPath ${{ env.EXILED_REFERENCES_PATH }} + + - name: Build + env: + EXILED_REFERENCES: ${{ env.EXILED_REFERENCES_PATH }} + shell: pwsh + run: | + ./build.ps1 -BuildNuGet + $File = (Get-ChildItem -Path . -Include 'EXILED.*.nupkg' -Recurse).Name + Out-File -FilePath ${{ github.env }} -InputObject "PackageFile=$File" -Encoding utf-8 -Append + + - name: Upload artifacts + uses: actions/upload-artifact@v2 + with: + name: Build Results + path: bin/Release