Skip to content

Commit 84f251e

Browse files
committed
idek what's in here
1 parent 9d761f7 commit 84f251e

6 files changed

Lines changed: 39 additions & 24 deletions

File tree

Config.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ public class Config : IConfig
1313

1414
[Description("Weather the Tranq is effective on Tutorials")]
1515
public bool EffectiveOnTutorials { get; set; } = false;
16-
16+
17+
[Description("Weather the Tranq is still useable when Nuke is on")]
18+
public bool NukeTranq { get; set; } = true;
19+
1720
[Description("The Distance from Larry a player can be before they can no longer use SCP-1499")]
1821
public float LarryDistance { get; set; } = 1f;
1922

ExtendedItems.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</PropertyGroup>
1414

1515
<ItemGroup>
16-
<PackageReference Include="ExMod.Exiled" Version="9.8.1"/>
16+
<PackageReference Include="ExMod.Exiled" Version="9.8.1" />
1717
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3">
1818
<PrivateAssets>all</PrivateAssets>
1919
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

Items/Sniper.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@ namespace ExtendedItems.Items
1414
public class Sniper : CustomWeapon
1515
{
1616
public override uint Id { get; set; } = 2;
17-
public ItemCategory Category { get; set; } = ItemCategory.SpecialWeapon;
18-
1917
public override string Name { get; set; } = "SR-118";
2018

2119
public override string Description { get; set; } =
2220
"A modified E-11 that fires 5.56 at supersonic velocity that deals significantly more damage";
2321

24-
public override float Weight { get; set; } = 5f;
25-
public override float Damage { get; set; } = 112f;
22+
public override float Weight { get; set; } = 4f;
23+
public override float Damage { get; set; } = 125f;
2624
public override byte ClipSize { get; set; } = 1;
2725

2826
[YamlIgnore]
@@ -58,10 +56,19 @@ protected override void UnsubscribeEvents()
5856
private void OnChangingAttachments(ChangingAttachmentsEventArgs ev)
5957
{
6058
if (!Check(ev.Item)) return;
61-
59+
6260
Log.Debug($"Player {ev.Player.Nickname} tried to change attachments for {Name}");
63-
ev.IsAllowed = false;
64-
ev.Player.ShowHint("You are not allowed to change the attachment for this weapon.");
61+
try
62+
{
63+
ev.IsAllowed = false;
64+
ev.Player.ShowHint("You are not allowed to change the attachment for this weapon.");
65+
}
66+
catch (Exception ex) {
67+
Log.Error($"{ex.GetType().Name}: {ex.Message}\n{ex.StackTrace}");
68+
ev.Player.CurrentItem.Destroy();
69+
ev.Player.CurrentItem = null;
70+
ev.Player.ShowHint("An error has occured and the Sniper has been removed");
71+
}
6572
}
6673
}
6774
}

Items/Tranquilizer.cs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ public class Tranquilizer : CustomWeapon
4545

4646
[Description("Resistance to remove from the chance after being shot.")]
4747
private float Resistance { get; } = 0.05f;
48-
49-
[Description("Whether tranquilizer should not effect those with Adrenaline.")]
50-
private bool AdrenalineBuff { get; } = true;
51-
52-
private bool Affected { get; set; } = true;
48+
5349

5450
public override SpawnProperties? SpawnProperties { get; set; } = new()
5551
{
@@ -82,15 +78,14 @@ private void OnChangingRole(ChangingRoleEventArgs ev)
8278

8379
protected override void OnShot(ShotEventArgs ev)
8480
{
85-
Affected = true;
86-
8781
if (ev.Target == null || Plugin.Instance == null) return;
8882
if (ev.Target.IsTutorial && !Plugin.Instance.Config.EffectiveOnTutorials) return;
8983

90-
foreach (var targetActiveEffect in ev.Target.ActiveEffects)
91-
if (AdrenalineBuff && targetActiveEffect.name == "Invigorated")
92-
Affected = false;
93-
if (!Affected) return;
84+
if (!Utils.HasEffect(ev.Target, EffectType.Invigorated))
85+
{
86+
return;
87+
}
88+
9489

9590
var rand = _rng.NextDouble();
9691
_resistances.TryGetValue(ev.Target.NetId, out var tResistance);

Plugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace ExtendedItems
88
{
9+
// ReSharper disable once ClassNeverInstantiated.Global
910
public class Plugin : Plugin<Config>
1011
{
1112
public static Plugin? Instance;
@@ -45,7 +46,6 @@ public override void OnDisabled()
4546
Ssss.Unregister();
4647

4748
_settings = null;
48-
4949
Instance = null;
5050

5151
base.OnDisabled();

Utils.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Exiled.API.Enums;
1+
using System.ComponentModel;
2+
using Exiled.API.Enums;
23
using Exiled.API.Features;
34
using Exiled.API.Features.Items;
45
using PlayerRoles;
@@ -10,7 +11,7 @@ namespace ExtendedItems
1011
public static class Utils
1112
{
1213
/// <summary>
13-
/// Calculates the global coords of a point inside a room based on the room type and the location
14+
/// Calculates the global coords of a point inside a room based on the room type and the location
1415
/// </summary>
1516
/// <param name="roomType"></param>
1617
/// <param name="localPos"></param>
@@ -57,7 +58,11 @@ public static ushort Subtract(ushort input, int mask = 1)
5758
// ReSharper disable once InconsistentNaming
5859
public static bool PDWarning(EP player)
5960
{
60-
return (from actEffects in player.ActiveEffects let Larry = EP.List.First(L => L.Role == RoleTypeId.Scp106).Position select actEffects.name == "Corroding" && Plugin.Instance != null && Vector3.Distance(player.Position, Larry) < Plugin.Instance.Config.LarryDistance).FirstOrDefault();
61+
return (from actEffects in player.ActiveEffects
62+
let Larry = EP.List.First(L => L.Role == RoleTypeId.Scp106).Position
63+
select actEffects.name == "Corroding" && Plugin.Instance != null &&
64+
Vector3.Distance(player.Position, Larry) < Plugin.Instance.Config.LarryDistance)
65+
.FirstOrDefault();
6166
}
6267

6368
public static void Exploding(EP player)
@@ -66,5 +71,10 @@ public static void Exploding(EP player)
6671
grenade.FuseTime = 0.1f;
6772
grenade.SpawnActive(player.Position + new Vector3(0, 1, 0), player);
6873
}
74+
75+
public static bool HasEffect(EP player, EffectType effect)
76+
{
77+
return !Enum.IsDefined(typeof(EffectType), effect) ? throw new InvalidEnumArgumentException(nameof(effect), (int)effect, typeof(EffectType)) : player.ActiveEffects.Any(targetActiveEffect => targetActiveEffect.name == nameof(effect));
78+
}
6979
}
7080
}

0 commit comments

Comments
 (0)