v1.2.2.b1
This commit is contained in:
parent
0fb3d63cd8
commit
46195c2663
147 changed files with 3470 additions and 2161 deletions
|
|
@ -1,4 +1,4 @@
|
|||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Timers;
|
||||
using CounterStrikeSharp.API.Modules.Utils;
|
||||
|
|
@ -12,7 +12,8 @@ namespace src.player.skills
|
|||
public class Darkness : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Darkness;
|
||||
private static readonly ConcurrentDictionary<ulong, byte> playersInDark = [];
|
||||
private static readonly ConcurrentDictionary<uint, byte> playersInDark = [];
|
||||
private static readonly ConcurrentDictionary<uint, uint> playersToTarget = [];
|
||||
private static readonly object setLock = new();
|
||||
|
||||
public static void LoadSkill()
|
||||
|
|
@ -26,31 +27,25 @@ namespace src.player.skills
|
|||
{
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (playersInDark.ContainsKey(player.SteamID))
|
||||
if (playersInDark.ContainsKey(player.Index))
|
||||
DisableSkill(player);
|
||||
SkillUtils.CloseMenu(player);
|
||||
}
|
||||
playersInDark.Clear();
|
||||
playersToTarget.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public static void PlayerDeath(EventPlayerDeath @event)
|
||||
{
|
||||
var player = @event.Userid;
|
||||
if (player == null) return;
|
||||
DisableSkill(player);
|
||||
}
|
||||
|
||||
public static void OnTick()
|
||||
{
|
||||
if (Server.TickCount % 32 != 0) return;
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!SkillUtils.HasMenu(player)) continue;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = PlayerManager.GetPlayerByIndex(player!.Index);
|
||||
|
||||
if (playerInfo == null || playerInfo.Skill != skillName) continue;
|
||||
var enemies = Utilities.GetPlayers().Where(p => p.PawnIsAlive && p.Team != player.Team && p.IsValid && !p.IsBot && !p.IsHLTV && p.Team != CsTeam.Spectator && p.Team != CsTeam.None).ToArray();
|
||||
var enemies = Utilities.GetPlayers().Where(p =>p != null &&p.IsValid).Select(p => PlayerManager.GetPlayerEvent(p)).Where(p =>p != null &&p.IsValid &&p.Team != player.Team &&p.PlayerPawn?.Value != null &&p.PlayerPawn.Value.IsValid &&p.PlayerPawn.Value.Health > 0 &&!p.IsHLTV &&p.Team != CsTeam.Spectator&& p.Team != CsTeam.None).ToArray();
|
||||
|
||||
ConcurrentBag<(string, string)> menuItems = [.. enemies.Select(e => (e.PlayerName, e.Index.ToString()))];
|
||||
SkillUtils.UpdateMenu(player, menuItems);
|
||||
|
|
@ -59,8 +54,8 @@ namespace src.player.skills
|
|||
|
||||
public static void TypeSkill(CCSPlayerController player, string[] commands)
|
||||
{
|
||||
if (player == null || !player.IsValid || !player.PawnIsAlive) return;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (player == null || !player.IsValid || player.LifeState != (byte)LifeState_t.LIFE_ALIVE) return;
|
||||
var playerInfo = PlayerManager.GetPlayerByIndex(player!.Index);
|
||||
if (playerInfo?.Skill != skillName) return;
|
||||
|
||||
if (playerInfo.SkillUsed)
|
||||
|
|
@ -70,7 +65,8 @@ namespace src.player.skills
|
|||
}
|
||||
|
||||
string enemyId = commands[0];
|
||||
var enemy = Utilities.GetPlayers().FirstOrDefault(p => p.Team != player.Team && p.Index.ToString() == enemyId);
|
||||
if (!uint.TryParse(enemyId, out uint enemyIndex)) { player.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("selectplayerskill_incorrect_enemy_index")); return; }
|
||||
var enemy = Utilities.GetPlayerFromIndex((int)enemyIndex);
|
||||
|
||||
if (enemy == null)
|
||||
{
|
||||
|
|
@ -79,18 +75,20 @@ namespace src.player.skills
|
|||
}
|
||||
|
||||
SetUpPostProcessing(enemy);
|
||||
playersToTarget[player.Index] = enemy.Index;
|
||||
playerInfo.SkillUsed = true;
|
||||
|
||||
player.PrintToChat($" {ChatColors.Green}" + player.GetTranslation("darkness_player_info", enemy.PlayerName));
|
||||
enemy.PrintToChat($" {ChatColors.Red}" + enemy.GetTranslation("darkness_enemy_info"));
|
||||
}
|
||||
|
||||
public static void EnableSkill(CCSPlayerController player)
|
||||
{
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = PlayerManager.GetPlayerByIndex(player!.Index);
|
||||
if (playerInfo == null) return;
|
||||
playerInfo.SkillUsed = false;
|
||||
|
||||
var enemies = Utilities.GetPlayers().Where(p => p.PawnIsAlive && p.Team != player.Team && p.IsValid && !p.IsBot && !p.IsHLTV && p.Team != CsTeam.Spectator && p.Team != CsTeam.None).ToArray();
|
||||
var enemies = Utilities.GetPlayers().Where(p =>p != null &&p.IsValid).Select(p => PlayerManager.GetPlayerEvent(p)).Where(p =>p != null &&p.IsValid &&p.Team != player.Team &&p.PlayerPawn?.Value != null &&p.PlayerPawn.Value.IsValid &&p.PlayerPawn.Value.Health > 0 &&!p.IsHLTV &&p.Team != CsTeam.Spectator&& p.Team != CsTeam.None).ToArray();
|
||||
if (enemies.Length > 0)
|
||||
{
|
||||
ConcurrentBag<(string, string)> menuItems = [.. enemies.Select(e => (e.PlayerName, e.Index.ToString()))];
|
||||
|
|
@ -104,34 +102,50 @@ namespace src.player.skills
|
|||
{
|
||||
lock (setLock)
|
||||
{
|
||||
SetUpPostProcessing(player, true);
|
||||
if (playersToTarget.TryRemove(player.Index, out uint targetIndex))
|
||||
{
|
||||
var target = Utilities.GetPlayerFromIndex((int)targetIndex);
|
||||
if (target != null && target.IsValid)
|
||||
SetUpPostProcessing(target, true);
|
||||
playersInDark.TryRemove(targetIndex, out _);
|
||||
}
|
||||
|
||||
SkillUtils.CloseMenu(player);
|
||||
}
|
||||
}
|
||||
|
||||
public static void PlayerDeath(EventPlayerDeath @event)
|
||||
{
|
||||
var player = @event.Userid;
|
||||
if (player == null || !player.IsValid) return;
|
||||
|
||||
SetUpPostProcessing(player, true);
|
||||
playersInDark.TryRemove(player.Index, out _);
|
||||
SkillUtils.CloseMenu(player);
|
||||
}
|
||||
|
||||
private static void SetUpPostProcessing(CCSPlayerController player, bool turnOff = false)
|
||||
{
|
||||
if (player == null || !player.IsValid) return;
|
||||
|
||||
ulong? playerSteamID = player?.SteamID;
|
||||
if (playerSteamID == null) return;
|
||||
uint playerIndex = player.Index;
|
||||
|
||||
lock (setLock)
|
||||
{
|
||||
if (!turnOff)
|
||||
{
|
||||
playersInDark.TryAdd((ulong)playerSteamID, 0);
|
||||
playersInDark.TryAdd(playerIndex, 0);
|
||||
ApplyColor(player);
|
||||
|
||||
Timer? darkTimer = null;
|
||||
darkTimer = Instance.AddTimer(5f, () => {
|
||||
if (!playersInDark.ContainsKey((ulong)playerSteamID))
|
||||
if (!playersInDark.ContainsKey(playerIndex))
|
||||
{
|
||||
darkTimer?.Kill();
|
||||
return;
|
||||
}
|
||||
|
||||
var target = Utilities.GetPlayers().FirstOrDefault(p => p.IsValid && p.SteamID == playerSteamID);
|
||||
var target = Utilities.GetPlayerFromIndex((int)playerIndex);
|
||||
if (target == null || !target.IsValid)
|
||||
{
|
||||
darkTimer?.Kill();
|
||||
|
|
@ -145,7 +159,7 @@ namespace src.player.skills
|
|||
else
|
||||
{
|
||||
SkillUtils.ApplyScreenColor(player, r: 0, g: 0, b: 0, a: 0, duration: 200, holdTime: 0);
|
||||
playersInDark.TryRemove((ulong)playerSteamID, out _);
|
||||
playersInDark.TryRemove(playerIndex, out _);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -161,7 +175,7 @@ namespace src.player.skills
|
|||
holdTime: 3000);
|
||||
}
|
||||
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#383838", CsTeam onlyTeam = CsTeam.None, bool disableOnFreezeTime = false, bool needsTeammates = false, string requiredPermission = "", int maxPerServer = -1, Rarity rarity = Rarity.Uncommon, int r = 0, int g = 0, int b = 0, int a = 230) : SkillsInfo.DefaultSkillInfo(skill, active, color, onlyTeam, disableOnFreezeTime, needsTeammates, requiredPermission, maxPerServer, rarity)
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#383838", CsTeam onlyTeam = CsTeam.None, bool disableOnFreezeTime = false, bool needsTeammates = false, string requiredPermission = "", int maxPerServer = -1, Rarity rarity = Rarity.Rare, int r = 0, int g = 0, int b = 0, int a = 230) : SkillsInfo.DefaultSkillInfo(skill, active, color, onlyTeam, disableOnFreezeTime, needsTeammates, requiredPermission, maxPerServer, rarity)
|
||||
{
|
||||
public int R { get; set; } = r;
|
||||
public int G { get; set; } = g;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue