Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions EXILED/EXILED.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33205.214
# Visual Studio Version 18
VisualStudioVersion = 18.3.11512.155 d18.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Exiled.Events", "Exiled.Events\Exiled.Events.csproj", "{1E6C4350-5067-4CE7-91DB-6420D027A4FC}"
EndProject
Expand All @@ -23,6 +23,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Exiled.CustomRoles", "Exile
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "docs", "docs\docs.csproj", "{BE130A80-6819-44C6-AA1B-BF068DEA67FF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Exiled.Utility", "Exiled.Utility\Exiled.Utility.csproj", "{70A4E012-0DBB-18AA-A972-770281EEF726}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -82,6 +84,12 @@ Global
{BE130A80-6819-44C6-AA1B-BF068DEA67FF}.Installer|Any CPU.Build.0 = Installer|Any CPU
{BE130A80-6819-44C6-AA1B-BF068DEA67FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BE130A80-6819-44C6-AA1B-BF068DEA67FF}.Release|Any CPU.Build.0 = Release|Any CPU
{70A4E012-0DBB-18AA-A972-770281EEF726}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{70A4E012-0DBB-18AA-A972-770281EEF726}.Debug|Any CPU.Build.0 = Debug|Any CPU
{70A4E012-0DBB-18AA-A972-770281EEF726}.Installer|Any CPU.ActiveCfg = Installer|Any CPU
{70A4E012-0DBB-18AA-A972-770281EEF726}.Installer|Any CPU.Build.0 = Installer|Any CPU
{70A4E012-0DBB-18AA-A972-770281EEF726}.Release|Any CPU.ActiveCfg = Release|Any CPU
{70A4E012-0DBB-18AA-A972-770281EEF726}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
1 change: 1 addition & 0 deletions EXILED/Exiled.API/Enums/PrefabType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace Exiled.API.Enums
/// <summary>
/// Type of prefab.
/// </summary>
/// <seealso cref="Features.PrefabHelper"/>
public enum PrefabType
{
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
Expand Down
5 changes: 5 additions & 0 deletions EXILED/Exiled.API/Features/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,11 @@ public bool IsSpectatable
/// </summary>
public Footprint Footprint => new(ReferenceHub);

/// <summary>
/// Gets the player's UniqueLifeIdentifier.
/// </summary>
public int LifeIdentifier => ReferenceHub.roleManager.CurrentRole.UniqueLifeIdentifier;

/// <summary>
/// Gets or sets a value indicating whether the player is spawn protected.
/// </summary>
Expand Down
18 changes: 17 additions & 1 deletion EXILED/Exiled.API/Features/PrefabHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ namespace Exiled.API.Features

using Exiled.API.Enums;
using Exiled.API.Features.Attributes;

using MapGeneration.Distributors;
using MapGeneration.RoomConnectors;
using Mirror;
using UnityEngine;

Expand Down Expand Up @@ -57,6 +57,11 @@ public static PrefabAttribute GetPrefabAttribute(this PrefabType prefabType)
/// <returns>Returns the <see cref="GameObject"/>.</returns>
public static GameObject GetPrefab(PrefabType prefabType)
{
if (prefabType is PrefabType.HCZOneSided or PrefabType.HCZTwoSided)
{
prefabType = PrefabType.HCZBreakableDoor;
}

if (Prefabs.TryGetValue(prefabType, out (GameObject, Component) prefab))
return prefab.Item1;

Expand Down Expand Up @@ -112,6 +117,17 @@ public static GameObject Spawn(PrefabType prefabType, Vector3 position = default
positionSync.Network_rotationY = (sbyte)Mathf.RoundToInt(rotation.Value.eulerAngles.y / 5.625F);
}

if (prefabType is PrefabType.HCZOneSided or PrefabType.HCZTwoSided or PrefabType.HCZBreakableDoor)
{
newGameObject.GetComponent<WallableSmallNodeRoomConnector>().Network_syncBitmask = prefabType switch
{
PrefabType.HCZTwoSided => 0b00000000,
PrefabType.HCZOneSided => 0b00000001,
PrefabType.HCZBreakableDoor => 0b00000011,
_ => 0
};
}

NetworkServer.Spawn(newGameObject);

return newGameObject;
Expand Down
7 changes: 7 additions & 0 deletions EXILED/Exiled.API/Features/Roles/Scp0492Role.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace Exiled.API.Features.Roles
{
using System.Collections.Generic;

using PlayerRoles;
using PlayerRoles.PlayableScps.HumeShield;
using PlayerRoles.PlayableScps.Scp049;
Expand Down Expand Up @@ -45,6 +47,11 @@ internal Scp0492Role(ZombieRole baseRole)
ConsumeAbility = zombieConsumeAbility492;
}

/// <summary>
/// Gets a list of players who are turned away from SCP-049 Sense Ability.
/// </summary>
public static HashSet<Player> TurnedPlayers { get; } = new(20);

/// <inheritdoc/>
public override RoleTypeId Type { get; } = RoleTypeId.Scp0492;

Expand Down
49 changes: 0 additions & 49 deletions EXILED/Exiled.Events/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,67 +26,18 @@ public sealed class Config : IConfig
[Description("Indicates whether events are patched only if they have delegates subscribed to them")]
public bool UseDynamicPatching { get; set; } = true;

/// <summary>
/// Gets or sets a value indicating whether SCP-173 can be blocked by the tutorial.
/// </summary>
[Description("Indicates whether SCP-173 can be blocked by the tutorial")]
public bool CanTutorialBlockScp173 { get; set; } = true;

/// <summary>
/// Gets or sets a value indicating whether SCP-096 can be triggered by the tutorial.
/// </summary>
[Description("Indicates whether SCP-096 can be triggered by the tutorial")]
public bool CanTutorialTriggerScp096 { get; set; } = true;

/// <summary>
/// Gets or sets a value indicating whether SCP-049 can activate the sense ability on tutorials.
/// </summary>
[Description("Indicates whether SCP-049 can sense tutorial players")]
public bool CanScp049SenseTutorial { get; set; } = true;

/// <summary>
/// Gets or sets a value indicating whether tutorial is affected by SCP-079 scan.
/// </summary>
[Description("Indicates whether tutorial is affected by SCP-079 scan.")]
public bool TutorialNotAffectedByScp079Scan { get; set; } = false;

/// <summary>
/// Gets or sets a value indicating whether flashbangs flash original thrower.
/// </summary>
[Description("Indicates whether flashbangs flash original thrower.")]
public bool CanFlashbangsAffectThrower { get; set; } = false;

/// <summary>
/// Gets or sets a value indicating whether the name tracking (invisible EXILED version string added to the end of the server name) is enabled or not.
/// </summary>
[Description("Indicates whether the name tracking (invisible EXILED version string added to the end of the server name) is enabled or not")]
public bool IsNameTrackingEnabled { get; set; } = true;

/// <summary>
/// Gets or sets a value indicating whether the inventory should be dropped before being set as spectator, through commands or plugins.
/// </summary>
[Description("Indicates whether the inventory should be dropped before being set as spectator, through commands or plugins")]
public bool ShouldDropInventory { get; set; } = true;

/// <summary>
/// Gets or sets a value indicating whether the blood can be spawned.
/// </summary>
[Description("Indicates whether the blood can be spawned")]
public bool CanSpawnBlood { get; set; } = true;

/// <summary>
/// Gets or sets a value indicating whether keycard throw can affect basic doors.
/// </summary>
/// TODO: Make a poll about removing this config. (unimplemented since 9.6.0-beta7)
[Description("Indicates whether thrown keycards can affect doors that don't require any permissions")]
public bool CanKeycardThrowAffectDoors { get; set; } = false;

/// <summary>
/// Gets or sets a value indicating whether the SCP079 will recontained if there are no SCPs left.
/// </summary>
[Description("Indicates whether the SCP079 will recontained if there are no SCPs left.")]
public bool RecontainScp079IfNoScpsLeft { get; set; } = true;

/// <summary>
/// Gets or sets a value indicating whether configs has to be reloaded every time a round restarts.
/// </summary>
Expand Down
2 changes: 0 additions & 2 deletions EXILED/Exiled.Events/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public override void OnEnabled()
Handlers.Server.WaitingForPlayers += Handlers.Internal.Round.OnWaitingForPlayers;
Handlers.Server.RestartingRound += Handlers.Internal.Round.OnRestartingRound;
Handlers.Server.RoundStarted += Handlers.Internal.Round.OnRoundStarted;
Handlers.Player.ChangingRole += Handlers.Internal.Round.OnChangingRole;
Handlers.Player.SpawningRagdoll += Handlers.Internal.Round.OnSpawningRagdoll;
Handlers.Scp049.ActivatingSense += Handlers.Internal.Round.OnActivatingSense;
Handlers.Player.Verified += Handlers.Internal.Round.OnVerified;
Expand Down Expand Up @@ -113,7 +112,6 @@ public override void OnDisabled()
Handlers.Server.WaitingForPlayers -= Handlers.Internal.Round.OnWaitingForPlayers;
Handlers.Server.RestartingRound -= Handlers.Internal.Round.OnRestartingRound;
Handlers.Server.RoundStarted -= Handlers.Internal.Round.OnRoundStarted;
Handlers.Player.ChangingRole -= Handlers.Internal.Round.OnChangingRole;
Handlers.Player.SpawningRagdoll -= Handlers.Internal.Round.OnSpawningRagdoll;
Handlers.Scp049.ActivatingSense -= Handlers.Internal.Round.OnActivatingSense;
Handlers.Player.Verified -= Handlers.Internal.Round.OnVerified;
Expand Down
9 changes: 1 addition & 8 deletions EXILED/Exiled.Events/Handlers/Internal/Round.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,6 @@ public static void OnRestartingRound()
/// <inheritdoc cref="Handlers.Server.OnRoundStarted" />
public static void OnRoundStarted() => MultiAdminFeatures.CallEvent(MultiAdminFeatures.EventType.ROUND_START);

/// <inheritdoc cref="Handlers.Player.OnChangingRole(ChangingRoleEventArgs)" />
public static void OnChangingRole(ChangingRoleEventArgs ev)
{
if (!ev.Player.IsHost && ev.NewRole == RoleTypeId.Spectator && ev.Reason is not SpawnReason.Destroyed && Events.Instance.Config.ShouldDropInventory)
ev.Player.Inventory.ServerDropEverything();
}

/// <inheritdoc cref="Handlers.Player.OnSpawningRagdoll(SpawningRagdollEventArgs)" />
public static void OnSpawningRagdoll(SpawningRagdollEventArgs ev)
{
Expand All @@ -104,7 +97,7 @@ public static void OnActivatingSense(ActivatingSenseEventArgs ev)
{
if (ev.Target is null)
return;
if ((Events.Instance.Config.CanScp049SenseTutorial || ev.Target.Role.Type is not RoleTypeId.Tutorial) && !Scp049Role.TurnedPlayers.Contains(ev.Target))
if (!Scp049Role.TurnedPlayers.Contains(ev.Target))
return;
ev.Target = ev.Scp049.SenseAbility.CanFindTarget(out ReferenceHub hub) ? Player.Get(hub) : null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace Exiled.Events.Patches.Events.Map

/// <summary>
/// Patches <see cref="FlashbangGrenade.ServerFuseEnd()"/>.
/// Adds the <see cref="Handlers.Map.ExplodingGrenade"/> event and <see cref="Config.CanFlashbangsAffectThrower"/>.
/// Adds the <see cref="Handlers.Map.ExplodingGrenade"/> event"/>.
/// </summary>
[HarmonyPatch(typeof(FlashbangGrenade), nameof(FlashbangGrenade.ServerFuseEnd))]
internal static class ExplodingFlashGrenade
Expand Down Expand Up @@ -69,10 +69,8 @@ private static void ProcessEvent(FlashbangGrenade instance, float distance)
if ((instance.transform.position - player.Position).sqrMagnitude > distance)
continue;

if (!ExiledEvents.Instance.Config.CanFlashbangsAffectThrower && instance.PreviousOwner.CompareLife(player.ReferenceHub))
continue;

if (!IndividualFriendlyFire.CheckFriendlyFirePlayer(instance.PreviousOwner, player.ReferenceHub) && !instance.PreviousOwner.CompareLife(player.ReferenceHub))
// LifeIdentifier check is needed to fix NW Bug https://git.scpslgame.com/northwood-qa/scpsl-bug-reporting/-/issues/2811
if (!IndividualFriendlyFire.CheckFriendlyFirePlayer(instance.PreviousOwner, player.ReferenceHub) && instance.PreviousOwner.LifeIdentifier == player.Footprint.LifeIdentifier)
continue;

if (Physics.Linecast(instance.transform.position, player.CameraTransform.position, instance.BlindingMask))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace Exiled.Events.Patches.Events.Scp0492

using Exiled.API.Features;
using Exiled.API.Features.Pools;
using Exiled.API.Features.Roles;
using Exiled.Events.Attributes;
using Exiled.Events.EventArgs.Scp0492;

Expand All @@ -38,17 +39,31 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi

newInstructions.InsertRange(index, new CodeInstruction[]
{
// Player.Get(allHub) (allhub because NW name it like that it's should just be hub but whatever)
new(OpCodes.Ldloc_1),
new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })),

// Player.Get(owner)
new(OpCodes.Ldarg_1),
new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })),

// TriggeringBloodlustEventArgs ev = new(Target, Scp0492)
new(OpCodes.Newobj, GetDeclaredConstructors(typeof(TriggeringBloodlustEventArgs))[0]),
new(OpCodes.Dup),

// Handlers.Scp0492.OnTriggeringBloodlust(ev)
new(OpCodes.Call, Method(typeof(Handlers.Scp0492), nameof(Handlers.Scp0492.OnTriggeringBloodlust))),

// if (!ev.IsAllowed) continue;
new(OpCodes.Callvirt, PropertyGetter(typeof(TriggeringBloodlustEventArgs), nameof(TriggeringBloodlustEventArgs.IsAllowed))),
new(OpCodes.Brfalse_S, continueLabel),

// if (!Scp0492Role.TurnedPlayers.Contains(Player.Get(allHub))) continue;
new(OpCodes.Ldloc_1),
new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })),
new(OpCodes.Call, PropertyGetter(typeof(Scp0492Role), nameof(Scp0492Role.TurnedPlayers))),
new(OpCodes.Callvirt, Method(typeof(HashSet<Player>), nameof(HashSet<Player>.Contains))),
new(OpCodes.Brfalse_S, continueLabel),
});

for (int z = 0; z < newInstructions.Count; z++)
Expand Down
21 changes: 2 additions & 19 deletions EXILED/Exiled.Events/Patches/Generic/CanScp049SenseTutorial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ namespace Exiled.Events.Patches.Generic

using static HarmonyLib.AccessTools;

using ExiledEvents = Exiled.Events.Events;

/// <summary>
/// Patches <see cref="Scp049SenseAbility.CanFindTarget(out ReferenceHub)"/>.
/// <see cref="Config.CanScp049SenseTutorial"/>.
/// <see cref="API.Features.Roles.Scp049Role.TurnedPlayers"/>.
/// </summary>
[HarmonyPatch(typeof(Scp049SenseAbility), nameof(Scp049SenseAbility.CanFindTarget))]
internal static class CanScp049SenseTutorial
Expand All @@ -36,7 +34,6 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Brfalse);

Label continueLabel = (Label)newInstructions[index].operand;
Label skip = generator.DefineLabel();

index += 1;

Expand All @@ -46,22 +43,8 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
index,
new[]
{
// if (referenceHub.roleManager.CurrentRole.RoleTypeId == RoleTypeId.Tutorial)
new(OpCodes.Ldloc_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<Config>), nameof(Plugin<Config>.Config))),
new(OpCodes.Callvirt, PropertyGetter(typeof(Config), nameof(Config.CanScp049SenseTutorial))),
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 CodeInstruction(OpCodes.Call, PropertyGetter(typeof(API.Features.Roles.Scp049Role), nameof(API.Features.Roles.Scp049Role.TurnedPlayers))),
new(OpCodes.Ldloc_S, 6),
new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })),
new(OpCodes.Callvirt, Method(typeof(HashSet<Player>), nameof(HashSet<Player>.Contains))),
Expand Down
Loading
Loading