Skip to content

Commit

Permalink
lol updates added spawnchance
Browse files Browse the repository at this point in the history
  • Loading branch information
Logic-Gun committed Nov 12, 2024
1 parent c5d3835 commit 2424935
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 1 deletion.
1 change: 0 additions & 1 deletion Components/Scp507Component.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Exiled.API.Features;
using Exiled.CustomRoles.API.Features;
using UnityEngine;

namespace Scp_507.Components
Expand Down
3 changes: 3 additions & 0 deletions Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ public class Config : IConfig
public bool IsEnabled { get; set; } = true;
public bool Debug { get; set; } = false;

[Description("Scp507: Spawn chance")]
public byte Scp507SpawnChance { get; set; } = 75;

[Description("Scp507 Teleporter: Minimum time (seconds)")]
public uint Scp507TeleporterMin { get; set; } = 2;

Expand Down
1 change: 1 addition & 0 deletions CustomRoles/Scp507.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ private IEnumerator<float> Teleporter(Player pl)
{
players.Add(pl);
}

Room room = Room.List.Where(r => !Plugin.StupidRooms.Contains(r.Type)).GetRandomValue();
newPosition = room.Position + new Vector3(0, 1.2f);

Expand Down
22 changes: 22 additions & 0 deletions Events/PlayerHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Exiled.API.Features;
using Exiled.Events.EventArgs.Player;
using PlayerRoles;
using System.Linq;
using UnityEngine;

namespace Scp_507.Events
{
public static class PlayerHandler
{
public static void OnChangingRole(ChangingRoleEventArgs ev)
{
if (ev.Player.IsNPC || ev.Player.IsHost) return;
if (ev.Reason != Exiled.API.Enums.SpawnReason.RoundStart) return;
if (ev.Player.Role.Type != RoleTypeId.Scientist) return;
if (Player.List.Where(r => !r.IsNPC && !r.IsHost).Any(Plugin.Instance.Config.Scp507.Check)) return;
if (Random.Range(0, 100) <= Plugin.Instance.Config.Scp507SpawnChance) return;

Plugin.Instance.Config.Scp507.AddRole(ev.Player);
}
}
}
15 changes: 15 additions & 0 deletions Plugin.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Exiled.API.Enums;
using Exiled.API.Features;
using Exiled.CustomRoles.API;
using Scp_507.Events;
using System;
using System.Collections.Generic;

Expand All @@ -22,16 +23,30 @@ public override void OnEnabled()

Instance.Config.Scp507.Register();

SubscribeEvents();

base.OnEnabled();
}

public override void OnDisabled()
{
UnsubscribeEvents();

Instance.Config.Scp507.Unregister();

Instance = null;

base.OnDisabled();
}

private void SubscribeEvents()
{
Exiled.Events.Handlers.Player.ChangingRole += PlayerHandler.OnChangingRole;
}

private void UnsubscribeEvents()
{
Exiled.Events.Handlers.Player.ChangingRole -= PlayerHandler.OnChangingRole;
}
}
}
1 change: 1 addition & 0 deletions Scp-507.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
<Compile Include="Components\Scp507Component.cs" />
<Compile Include="Config.cs" />
<Compile Include="CustomRoles\Scp507.cs" />
<Compile Include="Events\PlayerHandler.cs" />
<Compile Include="Plugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Translation.cs" />
Expand Down

0 comments on commit 2424935

Please sign in to comment.