v1.2.4.b1
This commit is contained in:
parent
273aa0ff59
commit
332210f58b
14 changed files with 177 additions and 9 deletions
|
|
@ -292,6 +292,7 @@ namespace src.player
|
||||||
public required HashSet<Skills> CtOnly { get; init; }
|
public required HashSet<Skills> CtOnly { get; init; }
|
||||||
public required HashSet<Skills> TOnly { get; init; }
|
public required HashSet<Skills> TOnly { get; init; }
|
||||||
public required HashSet<Skills> PistolRoundBanned { get; init; }
|
public required HashSet<Skills> PistolRoundBanned { get; init; }
|
||||||
|
public required HashSet<Skills> MinPlayerBanned { get; init; }
|
||||||
public required int TerroristCount { get; init; }
|
public required int TerroristCount { get; init; }
|
||||||
public required int CounterTerroristCount { get; init; }
|
public required int CounterTerroristCount { get; init; }
|
||||||
}
|
}
|
||||||
|
|
@ -316,6 +317,7 @@ namespace src.player
|
||||||
PistolRoundBanned = SkillUtils.IsPistolRound()
|
PistolRoundBanned = SkillUtils.IsPistolRound()
|
||||||
? ToSkillSet(SkillsInfo.LoadedConfig.Where(s => s.DisableOnPistolRound).Select(s => s.Name))
|
? ToSkillSet(SkillsInfo.LoadedConfig.Where(s => s.DisableOnPistolRound).Select(s => s.Name))
|
||||||
: [],
|
: [],
|
||||||
|
MinPlayerBanned = ToSkillSet(SkillsInfo.LoadedConfig.Where(s => s.MinPlayer > 0 && validPlayers.Count < s.MinPlayer).Select(s => s.Name)),
|
||||||
TerroristCount = validPlayers.Count(p => p.Team == CsTeam.Terrorist),
|
TerroristCount = validPlayers.Count(p => p.Team == CsTeam.Terrorist),
|
||||||
CounterTerroristCount = validPlayers.Count(p => p.Team == CsTeam.CounterTerrorist),
|
CounterTerroristCount = validPlayers.Count(p => p.Team == CsTeam.CounterTerrorist),
|
||||||
};
|
};
|
||||||
|
|
@ -351,6 +353,9 @@ namespace src.player
|
||||||
if (ctx.PistolRoundBanned.Count != 0)
|
if (ctx.PistolRoundBanned.Count != 0)
|
||||||
skillList.RemoveAll(s => ctx.PistolRoundBanned.Contains(s.Skill));
|
skillList.RemoveAll(s => ctx.PistolRoundBanned.Contains(s.Skill));
|
||||||
|
|
||||||
|
if (ctx.MinPlayerBanned.Count != 0)
|
||||||
|
skillList.RemoveAll(s => ctx.MinPlayerBanned.Contains(s.Skill));
|
||||||
|
|
||||||
if (gameMode == Config.GameModes.NoRepeat && playersSkills.TryGetValue(player.Index, out HashSet<Skills>? skills))
|
if (gameMode == Config.GameModes.NoRepeat && playersSkills.TryGetValue(player.Index, out HashSet<Skills>? skills))
|
||||||
{
|
{
|
||||||
skillList.RemoveAll(s => skills.Contains(s.Skill));
|
skillList.RemoveAll(s => skills.Contains(s.Skill));
|
||||||
|
|
@ -383,6 +388,7 @@ namespace src.player
|
||||||
if (def == null) return false;
|
if (def == null) return false;
|
||||||
if (def.DisableOnPistolRound && SkillUtils.IsPistolRound()) return false;
|
if (def.DisableOnPistolRound && SkillUtils.IsPistolRound()) return false;
|
||||||
if (def.NeedsTeammates && validPlayers.Count(p => p.Team == player.Team) == 1) return false;
|
if (def.NeedsTeammates && validPlayers.Count(p => p.Team == player.Team) == 1) return false;
|
||||||
|
if (def.MinPlayer > 0 && validPlayers.Count < def.MinPlayer) return false;
|
||||||
if (def.MaxPerServer >= 0 && assignmentCounts.TryGetValue(pick.Skill, out var c) && c >= def.MaxPerServer) return false;
|
if (def.MaxPerServer >= 0 && assignmentCounts.TryGetValue(pick.Skill, out var c) && c >= def.MaxPerServer) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -681,6 +687,10 @@ namespace src.player
|
||||||
if (SkillUtils.IsPistolRound())
|
if (SkillUtils.IsPistolRound())
|
||||||
skillList.RemoveAll(s => SkillsInfo.GetValue<bool>(s.Skill, "disableOnPistolRound"));
|
skillList.RemoveAll(s => SkillsInfo.GetValue<bool>(s.Skill, "disableOnPistolRound"));
|
||||||
|
|
||||||
|
SkillsInfo.DefaultSkillInfo[] skillsMinPlayer = [.. SkillsInfo.LoadedConfig.Where(s => s.MinPlayer > 0 && validPlayers.Count < s.MinPlayer)];
|
||||||
|
if (skillsMinPlayer.Length != 0)
|
||||||
|
skillList.RemoveAll(s => skillsMinPlayer.Any(s2 => s2.Name == s.Skill.ToString()));
|
||||||
|
|
||||||
if (gameMode == Config.GameModes.NoRepeat && playersSkills.TryGetValue(player.Index, out HashSet<Skills>? skills))
|
if (gameMode == Config.GameModes.NoRepeat && playersSkills.TryGetValue(player.Index, out HashSet<Skills>? skills))
|
||||||
{
|
{
|
||||||
skillList.RemoveAll(s => skills.Contains(s.Skill));
|
skillList.RemoveAll(s => skills.Contains(s.Skill));
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,6 @@ namespace src.player.skills
|
||||||
foreach (var (info, player) in infoList)
|
foreach (var (info, player) in infoList)
|
||||||
{
|
{
|
||||||
if (player == null || !player.IsValid || player.Team == CsTeam.Spectator) continue;
|
if (player == null || !player.IsValid || player.Team == CsTeam.Spectator) continue;
|
||||||
if (!player.PawnIsAlive) continue;
|
|
||||||
|
|
||||||
var targetHandle = player.Pawn.Value?.ObserverServices?.ObserverTarget.Value?.Handle ?? nint.Zero;
|
var targetHandle = player.Pawn.Value?.ObserverServices?.ObserverTarget.Value?.Handle ?? nint.Zero;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -138,6 +138,11 @@ namespace src.player.skills
|
||||||
else
|
else
|
||||||
skillList.RemoveAll(s => Event.terroristSkills.Any(s2 => s2.Name == s.Skill.ToString()));
|
skillList.RemoveAll(s => Event.terroristSkills.Any(s2 => s2.Name == s.Skill.ToString()));
|
||||||
|
|
||||||
|
int playerCount = PlayerManager.GetTickPlayers().Count(p => p != null && p.IsValid && !p.IsHLTV && (p.Team == CsTeam.Terrorist || p.Team == CsTeam.CounterTerrorist));
|
||||||
|
SkillsInfo.DefaultSkillInfo[] skillsMinPlayer = SkillsInfo.LoadedConfig.Where(s => s.MinPlayer > 0 && playerCount < s.MinPlayer).ToArray();
|
||||||
|
if (skillsMinPlayer.Length != 0)
|
||||||
|
skillList.RemoveAll(s => skillsMinPlayer.Any(s2 => s2.Name == s.Skill.ToString()));
|
||||||
|
|
||||||
return skillList.Count == 0 ? [Event.noneSkill] : skillList;
|
return skillList.Count == 0 ? [Event.noneSkill] : skillList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,6 @@ namespace src.player.skills
|
||||||
foreach (var (info, player) in infoList)
|
foreach (var (info, player) in infoList)
|
||||||
{
|
{
|
||||||
if (player == null || !player.IsValid || player.Team == CsTeam.Spectator) continue;
|
if (player == null || !player.IsValid || player.Team == CsTeam.Spectator) continue;
|
||||||
if (!player.PawnIsAlive) continue;
|
|
||||||
|
|
||||||
var targetHandle = player.Pawn.Value?.ObserverServices?.ObserverTarget.Value?.Handle ?? nint.Zero;
|
var targetHandle = player.Pawn.Value?.ObserverServices?.ObserverTarget.Value?.Handle ?? nint.Zero;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ namespace src.player.skills
|
||||||
|
|
||||||
foreach (var (info, player) in infoList)
|
foreach (var (info, player) in infoList)
|
||||||
{
|
{
|
||||||
if (player == null || !player.IsValid || !player.PawnIsAlive) continue;
|
if (player == null || !player.IsValid) continue;
|
||||||
var playerInfo = PlayerManager.GetPlayerByIndex((PlayerManager.GetPlayerEvent(player)?.Index ?? player.Index));
|
var playerInfo = PlayerManager.GetPlayerByIndex((PlayerManager.GetPlayerEvent(player)?.Index ?? player.Index));
|
||||||
|
|
||||||
if (playerInfo?.Skill != skillName)
|
if (playerInfo?.Skill != skillName)
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ namespace src.player.skills
|
||||||
|
|
||||||
foreach (var (info, player) in infoList)
|
foreach (var (info, player) in infoList)
|
||||||
{
|
{
|
||||||
if (player == null || !player.IsValid || !player.PawnIsAlive) continue;
|
if (player == null || !player.IsValid) continue;
|
||||||
|
|
||||||
var playerInfo = PlayerManager.GetPlayerByIndex((PlayerManager.GetPlayerEvent(player)?.Index ?? player.Index));
|
var playerInfo = PlayerManager.GetPlayerByIndex((PlayerManager.GetPlayerEvent(player)?.Index ?? player.Index));
|
||||||
bool isJackalOwner = playerInfo?.Skill == skillName;
|
bool isJackalOwner = playerInfo?.Skill == skillName;
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,7 @@ namespace src.player.skills
|
||||||
|
|
||||||
foreach (var (info, viewer) in infoList)
|
foreach (var (info, viewer) in infoList)
|
||||||
{
|
{
|
||||||
if (viewer == null || !viewer.IsValid || !viewer.PawnIsAlive) continue;
|
if (viewer == null || !viewer.IsValid) continue;
|
||||||
|
|
||||||
foreach (var kvp in targetVolumes)
|
foreach (var kvp in targetVolumes)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,6 @@ namespace src.player.skills
|
||||||
foreach (var (info, player) in infoList)
|
foreach (var (info, player) in infoList)
|
||||||
{
|
{
|
||||||
if (player == null || !player.IsValid || player.Team == CsTeam.Spectator) continue;
|
if (player == null || !player.IsValid || player.Team == CsTeam.Spectator) continue;
|
||||||
if (!player.PawnIsAlive) continue;
|
|
||||||
|
|
||||||
var targetHandle = player.Pawn.Value?.ObserverServices?.ObserverTarget.Value?.Handle ?? nint.Zero;
|
var targetHandle = player.Pawn.Value?.ObserverServices?.ObserverTarget.Value?.Handle ?? nint.Zero;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -444,7 +444,7 @@ namespace src.player.skills
|
||||||
|
|
||||||
foreach (var (info, player) in infoList)
|
foreach (var (info, player) in infoList)
|
||||||
{
|
{
|
||||||
if (player == null || !player.IsValid || !player.PawnIsAlive) continue;
|
if (player == null || !player.IsValid) continue;
|
||||||
|
|
||||||
uint viewerIndex = PlayerManager.GetPlayerEvent(player)?.Index ?? player.Index;
|
uint viewerIndex = PlayerManager.GetPlayerEvent(player)?.Index ?? player.Index;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ namespace src.player.skills
|
||||||
|
|
||||||
foreach (var (info, player) in infoList)
|
foreach (var (info, player) in infoList)
|
||||||
{
|
{
|
||||||
if (player == null || !player.IsValid || !player.PawnIsAlive) continue;
|
if (player == null || !player.IsValid) continue;
|
||||||
|
|
||||||
var playerInfo = PlayerManager.GetPlayerByIndex((PlayerManager.GetPlayerEvent(player)?.Index ?? player.Index));
|
var playerInfo = PlayerManager.GetPlayerByIndex((PlayerManager.GetPlayerEvent(player)?.Index ?? player.Index));
|
||||||
var targetHandle = player.Pawn.Value?.ObserverServices?.ObserverTarget?.Value?.Handle ?? nint.Zero;
|
var targetHandle = player.Pawn.Value?.ObserverServices?.ObserverTarget?.Value?.Handle ?? nint.Zero;
|
||||||
|
|
|
||||||
|
|
@ -213,7 +213,7 @@ namespace src.utils
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DefaultSkillInfo(Skills skill, bool active = true, string color = "#ffffff", CsTeam onlyTeam = CsTeam.None, bool disableOnFreezeTime = false, bool needsTeammates = false, string requiredPermission = "", float? hudDuration = null, float? descriptionHudDuration = null, int maxPerServer = -1, Rarity rarity = Rarity.Common, bool disableOnPistolRound = false)
|
public class DefaultSkillInfo(Skills skill, bool active = true, string color = "#ffffff", CsTeam onlyTeam = CsTeam.None, bool disableOnFreezeTime = false, bool needsTeammates = false, string requiredPermission = "", float? hudDuration = null, float? descriptionHudDuration = null, int maxPerServer = -1, Rarity rarity = Rarity.Common, bool disableOnPistolRound = false, int minPlayer = 0)
|
||||||
{
|
{
|
||||||
public bool NeedsTeammates { get; set; } = needsTeammates;
|
public bool NeedsTeammates { get; set; } = needsTeammates;
|
||||||
public bool DisableOnFreezeTime { get; set; } = disableOnFreezeTime;
|
public bool DisableOnFreezeTime { get; set; } = disableOnFreezeTime;
|
||||||
|
|
@ -226,6 +226,7 @@ namespace src.utils
|
||||||
public float? DescriptionHudDuration { get; set; } = descriptionHudDuration;
|
public float? DescriptionHudDuration { get; set; } = descriptionHudDuration;
|
||||||
public string RequiredPermission { get; set; } = requiredPermission;
|
public string RequiredPermission { get; set; } = requiredPermission;
|
||||||
public int MaxPerServer { get; set; } = maxPerServer;
|
public int MaxPerServer { get; set; } = maxPerServer;
|
||||||
|
public int MinPlayer { get; set; } = minPlayer;
|
||||||
public string Rarity { get; set; } = rarity.ToString();
|
public string Rarity { get; set; } = rarity.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
File diff suppressed because it is too large
Load diff
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue