From a98a248a8e3972e42c1032275939272a230c0bb7 Mon Sep 17 00:00:00 2001 From: Albert Pulchny Date: Sun, 2 Nov 2025 14:54:31 +0100 Subject: [PATCH] 4 new methods --- .../Exceptions/KrzysiuFuckedUpException.cs | 13 + .../ItemMethods/FirearmItemInfoMethod.cs | 39 ++ .../ItemMethods/UsableItemInfoMethod.cs | 37 ++ .../Methods/RoleMethods/RoleInfoMethod.cs | 4 - .../RoleMethods/Set079AuxPowerMethod.cs | 34 ++ .../WarheadMethods/DetonateWarheadMethod.cs | 17 - .../WarheadMethods/WarheadInfoMethod.cs | 39 ++ .../Methods/WarheadMethods/WarheadMethod.cs | 76 ++++ SER.csproj | 403 +----------------- .../ExpressionTokens/PlayerExpressionToken.cs | 18 + 10 files changed, 270 insertions(+), 410 deletions(-) create mode 100644 Helpers/Exceptions/KrzysiuFuckedUpException.cs create mode 100644 MethodSystem/Methods/ItemMethods/FirearmItemInfoMethod.cs create mode 100644 MethodSystem/Methods/ItemMethods/UsableItemInfoMethod.cs create mode 100644 MethodSystem/Methods/RoleMethods/Set079AuxPowerMethod.cs delete mode 100644 MethodSystem/Methods/WarheadMethods/DetonateWarheadMethod.cs create mode 100644 MethodSystem/Methods/WarheadMethods/WarheadInfoMethod.cs create mode 100644 MethodSystem/Methods/WarheadMethods/WarheadMethod.cs diff --git a/Helpers/Exceptions/KrzysiuFuckedUpException.cs b/Helpers/Exceptions/KrzysiuFuckedUpException.cs new file mode 100644 index 0000000..d4b6a41 --- /dev/null +++ b/Helpers/Exceptions/KrzysiuFuckedUpException.cs @@ -0,0 +1,13 @@ +using System; + +namespace SER.Helpers.Exceptions; +public class KrzysiuFuckedUpException : SystemException +{ + public KrzysiuFuckedUpException() + { + } + + public KrzysiuFuckedUpException(string msg) : base(msg) + { + } +} diff --git a/MethodSystem/Methods/ItemMethods/FirearmItemInfoMethod.cs b/MethodSystem/Methods/ItemMethods/FirearmItemInfoMethod.cs new file mode 100644 index 0000000..d9f51dd --- /dev/null +++ b/MethodSystem/Methods/ItemMethods/FirearmItemInfoMethod.cs @@ -0,0 +1,39 @@ +using LabApi.Features.Wrappers; +using SER.ArgumentSystem.Arguments; +using SER.ArgumentSystem.BaseArguments; +using SER.Helpers.Exceptions; +using SER.MethodSystem.BaseMethods; +using SER.ValueSystem; +using System; + +namespace SER.MethodSystem.Methods.ItemMethods; +internal class FirearmItemInfoMethod : ReturningMethod +{ + public override string Description => "Returns info about provided firearm"; + + public override Type[] ReturnTypes => [typeof(BoolValue), typeof(NumberValue)]; + + public override Argument[] ExpectedArguments => + [ + new ReferenceArgument("firearm"), + new OptionsArgument("property", + "ammo", + "maxAmmo", + "isCocked", + "isMagazineInserted" + ) + ]; + + public override void Execute() + { + FirearmItem f = Args.GetReference("firearm"); + ReturnValue = Args.GetOption("property") switch + { + "ammo" => new NumberValue(f.StoredAmmo), + "maxammo" => new NumberValue(f.MaxAmmo), + "iscocked" => new BoolValue(f.Cocked), + "ismagazineinserted" => new BoolValue(f.MagazineInserted), + _ => throw new KrzysiuFuckedUpException("out of range") + }; + } +} diff --git a/MethodSystem/Methods/ItemMethods/UsableItemInfoMethod.cs b/MethodSystem/Methods/ItemMethods/UsableItemInfoMethod.cs new file mode 100644 index 0000000..93c21ab --- /dev/null +++ b/MethodSystem/Methods/ItemMethods/UsableItemInfoMethod.cs @@ -0,0 +1,37 @@ +using LabApi.Features.Wrappers; +using SER.ArgumentSystem.Arguments; +using SER.ArgumentSystem.BaseArguments; +using SER.Helpers.Exceptions; +using SER.MethodSystem.BaseMethods; +using SER.ValueSystem; +using System; + +namespace SER.MethodSystem.Methods.ItemMethods; +internal class UsableItemInfoMethod : ReturningMethod +{ + public override string Description => "Returns information about provided usable item, like Painkillers, Medkit, etc."; + + public override Type[] ReturnTypes => [typeof(NumberValue), typeof(BoolValue)]; + + public override Argument[] ExpectedArguments => + [ + new ReferenceArgument("usable"), + new OptionsArgument("property", + "useTime", + "canUse", + "isUsing" + ) + ]; + + public override void Execute() + { + UsableItem u = Args.GetReference("usable"); + ReturnValue = Args.GetOption("property") switch + { + "usetime" => new NumberValue((decimal)u.UseDuration), + "canuse" => new BoolValue(u.CanClientStartUsing), + "isusing" => new BoolValue(u.IsUsing), + _ => throw new KrzysiuFuckedUpException("out of range") + }; + } +} diff --git a/MethodSystem/Methods/RoleMethods/RoleInfoMethod.cs b/MethodSystem/Methods/RoleMethods/RoleInfoMethod.cs index 22c572f..8f03215 100644 --- a/MethodSystem/Methods/RoleMethods/RoleInfoMethod.cs +++ b/MethodSystem/Methods/RoleMethods/RoleInfoMethod.cs @@ -22,8 +22,6 @@ public class RoleInfoMethod : ReturningMethod, IReferenceResolvingMet new OptionsArgument("property", Option.Enum("type"), Option.Enum("team"), - Option.Enum("spawnFlags"), - Option.Enum("spawnReason"), "name" ) ]; @@ -35,8 +33,6 @@ public override void Execute() { "type" => new TextValue(role.RoleTypeId.ToString()), "team" => new TextValue(role.Team.ToString()), - "spawnflags" => new TextValue(role.ServerSpawnFlags.ToString()), - "spawnreason" => new TextValue(role.ServerSpawnReason.ToString()), "name" => new TextValue(role.RoleName), _ => throw new AndrzejFuckedUpException("out of range") }; diff --git a/MethodSystem/Methods/RoleMethods/Set079AuxPowerMethod.cs b/MethodSystem/Methods/RoleMethods/Set079AuxPowerMethod.cs new file mode 100644 index 0000000..57afc79 --- /dev/null +++ b/MethodSystem/Methods/RoleMethods/Set079AuxPowerMethod.cs @@ -0,0 +1,34 @@ +using LabApi.Features.Wrappers; +using PlayerRoles.PlayableScps.Scp079; +using SER.ArgumentSystem.Arguments; +using SER.ArgumentSystem.BaseArguments; +using SER.MethodSystem.BaseMethods; +using System.Collections.Generic; + +namespace SER.MethodSystem.Methods.RoleMethods; +public class Set079AuxPowerMethod : SynchronousMethod +{ + public override string Description => "Sets players EXP if he is SCP-079"; + + public override Argument[] ExpectedArguments => + [ + new PlayersArgument("players"), + new IntArgument("exp") + ]; + + public override void Execute() + { + List pls = Args.GetPlayers("players"); + int exp = Args.GetInt("exp"); + foreach(Player p in pls) + { + if(p.RoleBase is Scp079Role scp) + { + if(scp.SubroutineModule.TryGetSubroutine(out Scp079TierManager tier)) + { + tier.TotalExp = exp; + } + } + } + } +} diff --git a/MethodSystem/Methods/WarheadMethods/DetonateWarheadMethod.cs b/MethodSystem/Methods/WarheadMethods/DetonateWarheadMethod.cs deleted file mode 100644 index 779638b..0000000 --- a/MethodSystem/Methods/WarheadMethods/DetonateWarheadMethod.cs +++ /dev/null @@ -1,17 +0,0 @@ -using LabApi.Features.Wrappers; -using SER.ArgumentSystem.BaseArguments; -using SER.MethodSystem.BaseMethods; - -namespace SER.MethodSystem.Methods.WarheadMethods; - -public class DetonateWarheadMethod : SynchronousMethod -{ - public override string Description => "Detonates the alpha warhead."; - - public override Argument[] ExpectedArguments { get; } = []; - - public override void Execute() - { - Warhead.Detonate(); - } -} \ No newline at end of file diff --git a/MethodSystem/Methods/WarheadMethods/WarheadInfoMethod.cs b/MethodSystem/Methods/WarheadMethods/WarheadInfoMethod.cs new file mode 100644 index 0000000..c5cbff1 --- /dev/null +++ b/MethodSystem/Methods/WarheadMethods/WarheadInfoMethod.cs @@ -0,0 +1,39 @@ +using LabApi.Features.Wrappers; +using SER.ArgumentSystem.Arguments; +using SER.ArgumentSystem.BaseArguments; +using SER.Helpers.Exceptions; +using SER.MethodSystem.BaseMethods; +using SER.ValueSystem; +using System; + +namespace SER.MethodSystem.Methods.WarheadMethods; +public class WarheadInfoMethod : ReturningMethod +{ + public override string Description => "returns information about alpha warhead"; + + public override Type[] ReturnTypes => [typeof(BoolValue), typeof(NumberValue)]; + + public override Argument[] ExpectedArguments => + [ + new OptionsArgument("property", + "isOpen", + "isArmed", + "isStarted", + "isDetonated", + "duration" + ) + ]; + + public override void Execute() + { + ReturnValue = Args.GetOption("property") switch + { + "isarmed" => new BoolValue(Warhead.IsAuthorized), + "isopen" => new BoolValue(Warhead.IsLocked), + "isstarted" => new BoolValue(Warhead.IsDetonationInProgress), + "isdetonated" => new BoolValue(Warhead.IsDetonated), + "duration" => new NumberValue((decimal)AlphaWarheadController.TimeUntilDetonation), + _ => throw new KrzysiuFuckedUpException() + }; + } +} diff --git a/MethodSystem/Methods/WarheadMethods/WarheadMethod.cs b/MethodSystem/Methods/WarheadMethods/WarheadMethod.cs new file mode 100644 index 0000000..68b6f6b --- /dev/null +++ b/MethodSystem/Methods/WarheadMethods/WarheadMethod.cs @@ -0,0 +1,76 @@ +using LabApi.Features.Wrappers; +using SER.ArgumentSystem.Arguments; +using SER.ArgumentSystem.BaseArguments; +using SER.MethodSystem.BaseMethods; +using SER.Helpers.Exceptions; + +namespace SER.MethodSystem.Methods.WarheadMethods; + +public class WarheadMethod : SynchronousMethod +{ + public override string Description => "Manages alpha warhead."; + + public override Argument[] ExpectedArguments => + [ + new OptionsArgument("action", + "Open", + "Close", + "Arm", + "Disarm", + "Lock", + "Unlock", + "Start", + "Stop", + "Detonate", + "Shake" + ) + ]; + + public override void Execute() + { + switch (Args.GetOption("action")) + { + case "open": + Warhead.IsAuthorized = true; + break; + + case "close": + Warhead.IsAuthorized = false; + break; + + case "lock": + Warhead.IsLocked = true; + break; + + case "unlock": + Warhead.IsLocked = false; + break; + + case "arm": + Warhead.BaseNukesitePanel.Networkenabled = true; + break; + + case "disarm": + Warhead.BaseNukesitePanel.Networkenabled = false; + break; + + case "start": + Warhead.Start(); + break; + + case "stop": + Warhead.Stop(); + break; + + case "detonate": + Warhead.Detonate(); + break; + + case "shake": + Warhead.Shake(); + break; + + default: throw new KrzysiuFuckedUpException("out of range"); + } + } +} \ No newline at end of file diff --git a/SER.csproj b/SER.csproj index 788ca23..99fa9a9 100644 --- a/SER.csproj +++ b/SER.csproj @@ -1,400 +1,25 @@  + + + + + + + - Debug - x64 - {FA94121F-C3B2-462E-A741-9D90790DE268} - Library - Properties - SER - SER - v4.8.1 - 512 - enable - true - true + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}. - - - - - - preview - x64 - true - embedded - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - preview - x64 - embedded - true - bin\Release\ - TRACE - prompt - 4 - true - - - - $(SL_DEV_REFERENCES)\0Harmony.dll - - - $(SL_DEV_REFERENCES)\Assembly-CSharp-Publicized.dll - - - $(SL_DEV_REFERENCES)\Assembly-CSharp-firstpass.dll - - - $(SL_DEV_REFERENCES)\CommandSystem.Core.dll - true - - - $(SL_DEV_REFERENCES)\LabApi.dll - - - $(SL_DEV_REFERENCES)\Mirror.dll - - - $(SL_DEV_REFERENCES)\NCalc.dll - - - $(SL_DEV_REFERENCES)\NorthwoodLib.dll - - - $(SL_DEV_REFERENCES)\Pooling.dll - - - - $(SL_DEV_REFERENCES)\UnityEngine.dll - - - $(SL_DEV_REFERENCES)\UnityEngine.CoreModule.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}. - - - - - - - - + \ No newline at end of file diff --git a/TokenSystem/Tokens/ExpressionTokens/PlayerExpressionToken.cs b/TokenSystem/Tokens/ExpressionTokens/PlayerExpressionToken.cs index 2d8ce74..71b2eac 100644 --- a/TokenSystem/Tokens/ExpressionTokens/PlayerExpressionToken.cs +++ b/TokenSystem/Tokens/ExpressionTokens/PlayerExpressionToken.cs @@ -4,6 +4,7 @@ using InventorySystem.Items; using LabApi.Features.Wrappers; using PlayerRoles; +using PlayerRoles.PlayableScps.Scp079; using SER.ArgumentSystem.Arguments; using SER.Helpers.Extensions; using SER.Helpers.ResultSystem; @@ -52,6 +53,9 @@ public enum PlayerProperty IsBypassEnabled, IsGodModeEnabled, IsNoclipEnabled, + RoleChangeReason, + RoleSpawnFlags, + AuxiliaryPower } public abstract class Info @@ -103,6 +107,20 @@ public class Info(Func handler, string? description) : Info [PlayerProperty.IsBypassEnabled] = new Info(plr => plr.IsBypassEnabled, null), [PlayerProperty.IsGodModeEnabled] = new Info(plr => plr.IsGodModeEnabled, null), [PlayerProperty.IsNoclipEnabled] = new Info(plr => plr.IsNoclipEnabled, null), + [PlayerProperty.RoleChangeReason] = new Info(plr => plr.RoleBase._spawnReason.ToString(), null), + [PlayerProperty.RoleSpawnFlags] = new Info(plr => plr.RoleBase._spawnFlags.ToString(), null), + [PlayerProperty.AuxiliaryPower] = new Info(plr => + { + if (plr.RoleBase is Scp079Role scp) + { + if (scp.SubroutineModule.TryGetSubroutine(out Scp079TierManager tier)) + { + return tier.TotalExp; + } + else return -1; + } + else return -1; + }, "Returns player EXP if he is SCP-079, otherwise returns -1"), }; protected override IParseResult InternalParse(BaseToken[] tokens)