Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
1ffc6d5
reorder VaildScps to be nicer to read
blankochan Mar 16, 2025
3b42c71
fix: stop tracking .user files because they can sometimes cause unexp…
blankochan Mar 17, 2025
a62700f
fix: IndexOutOfRangeException if no scps were alive at the end of the…
blankochan Mar 17, 2025
60cae97
remove the arrow because the different font sizes make the alignment …
blankochan Mar 16, 2025
e77a49b
feat: zombies can now use .h to form a request
blankochan Mar 17, 2025
dfebdf4
fix: race condition if you died while trying to be replaced
blankochan Mar 17, 2025
ef4731f
fix: you could run .human as the server
blankochan Mar 17, 2025
df979d3
rider will not shut up about this typo
blankochan Mar 17, 2025
d376469
fix: remove redundant IsDead check
blankochan Mar 17, 2025
b04815c
fix: use [CanBeNull] instead of nullable for simplicity
blankochan Mar 17, 2025
4a74c7a
fix: IsDead instead of !IsAlive (I didnt think to check if that was t…
blankochan Mar 17, 2025
ceaddfa
fix: disable nullable to avoid warnings for possibility's that cannot be
blankochan Mar 17, 2025
529fb4a
fix: remove .human's ability to make request volunteer's and point th…
blankochan Mar 17, 2025
93639a9
fix: volunteer request wouldn't set max health and max hume (GOD I NE…
blankochan Mar 17, 2025
76c5dbe
fix: make volunteer request a separate command
blankochan Mar 17, 2025
1356e03
fix: make volunteer request a separate command
blankochan Mar 17, 2025
169f1e5
fix: this using statement didnt get commited for some reason
blankochan Mar 17, 2025
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
obj/
bin/
packages/*/
packages/*/
*.user
23 changes: 0 additions & 23 deletions SillySCP.sln.DotSettings.user

This file was deleted.

46 changes: 33 additions & 13 deletions SillySCP/API/Features/VolunteerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,50 @@ public static class VolunteerSystem

public static Dictionary<string, RoleTypeId> VaildScps { get; set; } = new ()
{
{ "173", RoleTypeId.Scp173 },
{ "peanut", RoleTypeId.Scp173 },
{ "173", RoleTypeId.Scp173 },

{ "dog", RoleTypeId.Scp173 },
{ "939", RoleTypeId.Scp939 },

{ "computer", RoleTypeId.Scp079 },
{ "pc", RoleTypeId.Scp079 },
{ "079", RoleTypeId.Scp079 },
{ "79", RoleTypeId.Scp079 },
{ "computer", RoleTypeId.Scp079 },
{ "106", RoleTypeId.Scp106 },

{ "larry", RoleTypeId.Scp106 },
{ "106", RoleTypeId.Scp106 },

{ "shyguy", RoleTypeId.Scp096 },
{ "096", RoleTypeId.Scp096 },
{ "96", RoleTypeId.Scp096 },
{ "shyguy", RoleTypeId.Scp096 },

{ "doctor", RoleTypeId.Scp049 },
{ "049", RoleTypeId.Scp049 },
{ "49", RoleTypeId.Scp049 },
{ "doctor", RoleTypeId.Scp049 },

{ "zombie", RoleTypeId.Scp0492 },
{ "0492", RoleTypeId.Scp0492 },
{ "049-2", RoleTypeId.Scp0492 },
{ "492", RoleTypeId.Scp0492 },
{ "zombie", RoleTypeId.Scp0492 },
};

public static void NewVolunteer(RoleTypeId role)
/// <summary>
/// if supplied with an original player the <see cref="SillySCP.Handlers.VolunteerHandler"/> will treat this as a replacement
/// </summary>
#nullable enable
public static void NewVolunteer(RoleTypeId role, Player? original=null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public static void NewVolunteer(RoleTypeId role, Player? original=null)
public static void NewVolunteer(RoleTypeId role, Player? original = null)

The lack of space is really irritating me 😭

{
Volunteers volunteer = new ()
{
Replacement = role,
Players = new()
Players = new(),
OriginalPlayer = original,
};
Volunteers ??= new();
Volunteers.Add(volunteer);
Timing.RunCoroutine(ChooseVolunteers(volunteer));

string annoucement = // if we add support for other roles this will need to be changed
string announcement = // TODO if we add support for other roles this will need to be changed to use something else
$"{role.GetFullName()} has left the game\nPlease run .volunteer {role.GetFullName().Substring(4)} to volunteer to be the SCP";

if (role == RoleTypeId.Scp0492)
Expand All @@ -60,14 +72,15 @@ public static void NewVolunteer(RoleTypeId role)
{
if (player.IsAlive) continue;

player.Broadcast(10, annoucement);
player.Broadcast(10, announcement);
}
return;
}
Map.Broadcast(10, annoucement);
Map.Broadcast(10, announcement);

VolunteerCreated.InvokeSafely(new (volunteer));
}
#nullable disable
public static IEnumerator<float> DisableVolunteers()
{
yield return Timing.WaitForSeconds(120);
Expand All @@ -86,9 +99,16 @@ public static IEnumerator<float> ChooseVolunteers(Volunteers volunteer)
Volunteers volunteerClone = new ()
{
Replacement = volunteer.Replacement,
Players = volunteer.Players
Players = volunteer.Players,
OriginalPlayer = volunteer.OriginalPlayer,
};
Volunteers.Remove(volunteer);

if (volunteerClone.OriginalPlayer != null)
{
if (volunteerClone.OriginalPlayer.IsDead) yield break; // you get inconsistent and weird behavior if they're dead (like teleporting into the void and then landing on top of chaos spawn over and over)
}

if (volunteerClone.Players.Count == 0) yield break;
Player replacementPlayer = volunteerClone.Players.GetRandomValue();
replacementPlayer.Role.Set(volunteerClone.Replacement);
Expand Down
2 changes: 2 additions & 0 deletions SillySCP/API/Features/Volunteers.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using Exiled.API.Features;
using JetBrains.Annotations;
using PlayerRoles;

namespace SillySCP.API.Features
{
public class Volunteers
{
public RoleTypeId Replacement;
[CanBeNull] public Player OriginalPlayer;
public List<Player> Players;
}
}
21 changes: 13 additions & 8 deletions SillySCP/Commands/Human.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Human : ICommand
{
public string Command { get; } = "human";

public string[] Aliases { get; } = new [] { "h" };
public string[] Aliases { get; } = { "h" };

public string Description { get; } = "Change into a human, if you're an SCP.";

Expand All @@ -23,25 +23,30 @@ public bool Execute(
out string response
)
{
if (!Player.TryGet(sender, out Player player))
{
response = "Only Players can use this command.";
return false;
}

if (player.Role == RoleTypeId.Scp0492)
{
response = "You cannot change into a human as SCP-049-2!, try .r or .requestVolunteer to request a spectator to take your place";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
response = "You cannot change into a human as SCP-049-2!, try .r or .requestVolunteer to request a spectator to take your place";
response = "You cannot change into a human as SCP-049-2!, try .r or .requestvolunteer to request a spectator to take your place";

Sorry, looks ugly asf

return false;
}

if (!VolunteerSystem.ReadyVolunteers)
{
response = "You can not change into a human after the volunteer period is over!";
return false;
}

Player.TryGet(sender, out Player player);

if (!player.IsScp)
{
response = "Only SCPs can use this command!";
return false;
}

if (player.Role.Type == RoleTypeId.Scp0492)
{
response = "You can not change into a human as SCP-049-2!";
return false;
}

RoleTypeId role = HumanSpawner.NextHumanRoleToSpawn;
VolunteerSystem.NewVolunteer(player.Role);
Expand Down
47 changes: 47 additions & 0 deletions SillySCP/Commands/RequestHuman.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using CommandSystem;
using Exiled.API.Features;
using PlayerRoles;
using SillySCP.API.Features;


namespace SillySCP.Commands
{
[CommandHandler(typeof(ClientCommandHandler))]
public class RequestHuman : ICommand
{
public string Command { get; } = "RequestHuman";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please lowercase for my sanity

Suggested change
public string Command { get; } = "RequestHuman";
public string Command { get; } = "requesthuman";


public string[] Aliases { get; } = ["r","rh","request"];

public string Description { get; } = "request to change into a human, if you're an SCP."; // no clue what the description for this should actually be tbh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public string Description { get; } = "request to change into a human, if you're an SCP."; // no clue what the description for this should actually be tbh
public string Description { get; } = "Request to change into a human, if you're an SCP."; // no clue what the description for this should actually be tbh


public bool Execute(
ArraySegment<string> arguments,
ICommandSender sender,
out string response
)
{
if (!Player.TryGet(sender, out Player player))
{
response = "Only Players can use this command.";
return false;
}

if (!player.IsScp)
{
response = "Only SCP's can use this command.";
return false;
}

if (player.Role != RoleTypeId.Scp0492) // change if we allow other SCPs to request volunteer swap thingy (i should really figure out that terminology I hate how inconsistent i am)
{
response = "Only Zombies can use this command.";
return false;
}

response = "Opening a volunteer request."; // I really do not know what terminology should be used, always sounds so weird
VolunteerSystem.NewVolunteer(player.Role,original:player);
return true;
}
}
}
18 changes: 10 additions & 8 deletions SillySCP/Commands/Volunteer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,29 @@ out string response
response = "Only players can use this command!";
return false;
}

if (player.IsScp && player.Role != RoleTypeId.Scp0492) // zombies should beable to volunteer for regular scp's
{
response = "You are already an SCP! If they get replaced, you can swap with the person if they wish!";
return false;
}


if(arguments.Count != 1)
{
response = "Usage: .volunteer <role>";
return false;
}



RoleTypeId role;

if (!VolunteerSystem.VaildScps.TryGetValue(arguments.At(0), out role) && !Enum.TryParse(arguments.At(0), true, out role))
{
response = "Error parsing the RoleTypeId.";
return false;
}

if (player.IsScp && player.Role != RoleTypeId.Scp0492 && role is not RoleTypeId.Scp0492) // zombies should beable to volunteer for regular scp's
{
response = "You are already an SCP! If they get replaced, you can swap with the person if they wish!";
return false;
}

if (player.IsAlive && role == RoleTypeId.Scp0492)
{
response = "Alive Players cannot volunteer as a zombie";
Expand All @@ -67,7 +69,7 @@ out string response
return false;
}

volunteer.Players ??= new ();


if (volunteer.Players.Contains(player))
{
Expand Down
21 changes: 21 additions & 0 deletions SillySCP/Handlers/VolunteerHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Exiled.Events.EventArgs.Player;
using MEC;
using PlayerRoles;
using SillySCP.API.EventArgs;
using SillySCP.API.Features;
using SillySCP.API.Interfaces;
using SillySCP.API.Modules;
Expand All @@ -19,6 +20,7 @@ public void Init()
Exiled.Events.Handlers.Player.ChangingRole += OnChangingRole;

VolunteerSystem.VolunteerPeriodEnd += OnVolunteerPeriodEnd;
VolunteerSystem.VolunteerChosen += OnChosenVolunteer;
}

public void Unregister()
Expand All @@ -27,6 +29,7 @@ public void Unregister()
Exiled.Events.Handlers.Server.RoundStarted -= OnRoundStarted;
Exiled.Events.Handlers.Player.Died -= OnDead;
Exiled.Events.Handlers.Player.ChangingRole -= OnChangingRole;
VolunteerSystem.VolunteerChosen -= OnChosenVolunteer;
}

private void OnChangingRole(ChangingRoleEventArgs ev)
Expand All @@ -38,6 +41,23 @@ private void OnChangingRole(ChangingRoleEventArgs ev)
}
}

private void OnChosenVolunteer(VolunteerChosenEventArgs ev)
{
if (ev.Volunteer.OriginalPlayer != null) // If a Volunteer specified a player, for sake of sanity and simplicity, its treated as a replacement
{
// lumi before you chop my balls off, I elected to handle canceling the volunteer entirely if the player is dead in the VolunteerSystem
Exiled.API.Features.Player originalPlayer = ev.Volunteer.OriginalPlayer;
ev.Player.MaxHealth = originalPlayer.MaxHealth;
ev.Player.Health = originalPlayer.Health;

ev.Player.Position = originalPlayer.Position;

ev.Player.MaxHumeShield = originalPlayer.MaxHumeShield;
ev.Player.HumeShield = originalPlayer.HumeShield;
originalPlayer.Role.Set(RoleTypeId.Spectator,SpawnReason.None);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

??????????????????? the player should become a human once they do .h, not spectator???????????

Copy link
Collaborator Author

@blankochan blankochan Mar 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I elected in order to avoid having to duplicate stuff, or make a weird abstraction that'd only ever be used to handle the possibility of like spectator swap or whatever.
(I genuinely do not know what terminology I should use, "Spectator Swap" sounds the best?)

I made NewVolunteer have a nullable player and then i use that as an optional variable;
and if its supplied to just treat it like a swap thingy

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gonna resolve the other ones about this area because they all kinda roll into here

}

}

private void OnDead(DiedEventArgs ev)
{
Expand Down Expand Up @@ -68,6 +88,7 @@ private void OnVolunteerPeriodEnd()
{
// only doing this to save some resources, don't come at me
List<Exiled.API.Features.Player> scps = Exiled.API.Features.Player.List.Where(p => p.IsScp).ToList();
if (scps.Count == 0) return;
List<string> scpNames = scps.Select(scp => scp.Role.Name).ToList();
List<string> scpNamesCopy = new(scpNames);
scpNamesCopy.RemoveAt(scpNamesCopy.Count-1);
Expand Down
Loading