Skip to content

Commit

Permalink
..
Browse files Browse the repository at this point in the history
  • Loading branch information
NOTIF-API authored Aug 26, 2023
1 parent 4d0d8e9 commit 63ee907
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 20 deletions.
95 changes: 95 additions & 0 deletions SCP-600V/API/RoleGet.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
using Exiled.API.Features;
using MEC;
using PlayerRoles;
using SCP_600V.Extension;
using System.Collections.Generic;
using System.Linq;
using Exiled.CustomRoles.API.Features;


namespace SCP_600V.API.Role
{
public class Role
{
/// <summary>
/// gets a list of players with the Breeder role on the server
/// </summary>
/// <returns>Player list</returns>
public static List<Player> Scp600Players() => Player.List.Where(x => x != null & x.SessionVariables.ContainsKey("IsSCP600")).ToList();
/// <summary>
/// gets a list of players who have the Serpent's Hand role on the server
/// </summary>
/// <returns>Player list</returns>
public static List<Player> SHPlayers() => Player.List.Where(x => x != null & x.SessionVariables.ContainsKey("IsSH")).ToList();
/// <summary>
/// gets a list of players with the role of Mask of Obsession on the server
/// </summary>
/// <returns>Player list</returns>
public static List<Player> Scp035Players() => Player.List.Where(x => x != null & x.SessionVariables.ContainsKey("IsScp035")).ToList();
/// <summary>
/// Gets a player and defines their role
/// </summary>
/// <param name="player">Player to check</param>
/// <returns>returns true if the player is SCP-600 or not null</returns>
public static bool IsScp600(Player player)
{
if (player != null & player.SessionVariables.ContainsKey("IsSCP600"))
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// Gives the role of SCP-600V to the player
/// </summary>
/// <param name="player">The player who will receive the role of SCP-600V</param>
public static void Spawn(Player player)
{
if (player == null && player.IsDead)
{
return;
}
else
{
CustomRole.Get(typeof(Scp600CotumRoleBase)).AddRole(player);
}
}
/// <summary>
/// Gives the role of SCP-600V to the player
/// </summary>
/// <param name="player">The player who will receive the role of SCP-600V</param>
/// <param name="MaxHealt">Assigning a custom MaxHealt parameter to a player</param>
public static void Spawn(Player player, int MaxHealt = 400)
{
if (player == null && player.IsDead)
{
return;
}
else
{
CustomRole.Get(typeof(Scp600CotumRoleBase)).AddRole(player);
Timing.CallDelayed(2f, () =>
{
player.MaxHealth = MaxHealt;
player.Health = MaxHealt;
});
}
}
/// <summary>
/// Allows you to get the number of people who do not have the role Breeder on the server
/// </summary>
/// <param name="team">Team to check</param>
/// <returns>returns the number of players in the team excluding scp</returns>
public static int AmountTeamNotScp(Team team) => Player.List.Count(x => x != null & !x.SessionVariables.ContainsKey("IsSCP600") & x.Role.Team == team);
/// <summary>
/// Determine if a player who is an SCP is in the team
/// </summary>
/// <param name="team">Team to check</param>
/// <returns>returns true if the SCP player is on the team</returns>
public static bool ScpInTeam(Team team) => Player.List.Any(x => x != null & x.Role.Team == team & x.SessionVariables.ContainsKey("IsSCP600"));

}
}
2 changes: 1 addition & 1 deletion SCP-600V/Command/GetPlayerAsScp600.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
if (player != null && player.CheckPermission("s6.GetPlayers"))
{
StringBuilder playerListBuilder = new StringBuilder();
foreach (Player ply in RoleGet.Scp600Players())
foreach (Player ply in Role.Scp600Players())
{
playerListBuilder.Append(ply.Nickname).Append(", ");
}
Expand Down
2 changes: 1 addition & 1 deletion SCP-600V/Command/MaxHealth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal class MaxHealth : ICommand
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
Player ply = Player.Get(sender);
if (ply != null && ply.CheckPermission("s6.ChengeMHP") && RoleGet.IsScp600(ply))
if (ply != null && ply.CheckPermission("s6.ChengeMHP") && Role.IsScp600(ply))
{
string arg = arguments.At(0);
if (!string.IsNullOrEmpty(arg) & int.TryParse(arg, out _))
Expand Down
4 changes: 2 additions & 2 deletions SCP-600V/Command/Spawn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
response = "Player not found by id";
return false;
}
RoleSet.Spawn(GiveTo);
Role.Spawn(GiveTo);
response = $"Role successfully assigned to player {GiveTo.DisplayNickname}";
return true;
}
else
{
GiveTo = Player.Get(sender);
RoleSet.Spawn(GiveTo);
Role.Spawn(GiveTo);
response = "role successfully issued (if nothing happened maybe you are an observer)";
return true;
}
Expand Down
6 changes: 3 additions & 3 deletions SCP-600V/EventHandler/GameEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal class GameEvents
// does not allow escape for 600
internal void OnEscape(EscapingEventArgs e)
{
if (e.Player != null && RoleGet.IsScp600(e.Player))
if (e.Player != null && Role.IsScp600(e.Player))
{
Log.Debug($"Canceling escape scp600 player: [{e.Player.Nickname}]");
e.IsAllowed = false;
Expand All @@ -20,7 +20,7 @@ internal void OnEscape(EscapingEventArgs e)
// does not allow 106 to catch 600 in its dimension
internal void EnterignPocketDemens(EnteringPocketDimensionEventArgs e)
{
if (e.Player != null && RoleGet.IsScp600(e.Player))
if (e.Player != null && Role.IsScp600(e.Player))
{
Log.Debug("Scp-106 don't touch scp600 in pocket demension");
e.IsAllowed = false;
Expand All @@ -29,7 +29,7 @@ internal void EnterignPocketDemens(EnteringPocketDimensionEventArgs e)
// making sure SCPs can't kill 600
internal void HurtingPlayer(HurtingEventArgs e)
{
if (e.Player != null & e.Attacker != null & RoleGet.IsScp600(e.Player) & e.Attacker.Role.Team == Team.SCPs)
if (e.Player != null & e.Attacker != null & Role.IsScp600(e.Player) & e.Attacker.Role.Team == Team.SCPs)
{
e.IsAllowed = false;
}
Expand Down
12 changes: 6 additions & 6 deletions SCP-600V/EventHandler/RoundEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ internal void OnEndingRound(EndingRoundEventArgs e)
bool scp = false;
bool human = false;

int mtf = TeamGet.AmountTeamNotScp(Team.FoundationForces);
int d = TeamGet.AmountTeamNotScp(Team.ClassD);
int s = TeamGet.AmountTeamNotScp(Team.SCPs);
int mtf = Role.AmountTeamNotScp(Team.FoundationForces);
int d = Role.AmountTeamNotScp(Team.ClassD);
int s = Role.AmountTeamNotScp(Team.SCPs);

if (mtf > 0 || d > 0)
{
human = true;
}
if (s > 0 || RoleGet.Scp600Players().Count() > 0)
if (s > 0 || Role.Scp600Players().Count() > 0)
{
scp = true;
}
Expand All @@ -44,7 +44,7 @@ internal void OnRoundStarted()
{
players.Add(p);
}
RoleSet.Spawn(players[UnityEngine.Random.Range(1, players.Count())]);
Role.Spawn(players[UnityEngine.Random.Range(1, players.Count())]);
Log.Debug("Spawned random players");
}
else
Expand All @@ -54,7 +54,7 @@ internal void OnRoundStarted()
}
internal bool IsSpawnable()
{
if (UnityEngine.Random.value <= Sai.Instance.Config.PercentToSpawn)
if (UnityEngine.Random.value <= Sai.Instance.Config.PercentToSpawn/100)
{
return true;
}
Expand Down
3 changes: 1 addition & 2 deletions SCP-600V/Extension/Scp600CotumRoleBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ public override void AddRole(Player player)
}
});
}
base.RoleAdded(player);
}
protected override void RoleAdded(Player player)
{
Expand All @@ -138,7 +137,7 @@ protected override void RoleAdded(Player player)
player.ChangeAppearance(this.StartAppearance, false, 0);
this.VisibledRole = RoleTypeId.ClassD;
});
base.RoleRemoved(player);
base.RoleAdded(player);
}
protected override void RoleRemoved(Player player)
{
Expand Down
4 changes: 2 additions & 2 deletions SCP-600V/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
// Можно задать все значения или принять номера сборки и редакции по умолчанию
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.2.0.0")]
[assembly: AssemblyFileVersion("2.2.0.0")]
[assembly: AssemblyVersion("2.2.1.0")]
[assembly: AssemblyFileVersion("2.2.1.0")]
[assembly: NeutralResourcesLanguage("ru-RU")]
4 changes: 1 addition & 3 deletions SCP-600V/SCP-600V.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<ItemGroup>
<Compile Include="API\Role\RoleGet.cs" />
<Compile Include="API\Role\RoleSet.cs" />
<Compile Include="API\Role\TeamGet.cs" />
<Compile Include="API\RoleGet.cs" />
<Compile Include="Command\GetPlayerAsScp600.cs" />
<Compile Include="Command\GetSessionVariables.cs" />
<Compile Include="Command\MaxHealth.cs" />
Expand Down

0 comments on commit 63ee907

Please sign in to comment.