QoE Update — 2

## Added

- **`Spectator` use cooldown** (`UseCooldown` in skillsInfo.json, default 0.5s) — every press destroyed and recreated the camera prop, with no rate limit.
- **`SkillUtils.ClearCursesFor(playerIndex)`** — clears a leaving player's curse bookkeeping from both sides (as curser and as victim).
- **`SkillUtils.AnyCurseCapacity(player)`** — reports whether a player still has  any enemy left that is under the curse limit.
- **`Spectator.PlayerDisconnect`** handler.
- **`Thief`** added to the curse skill set.

## Changed

- **`CurseSkillPerPlayer` is ignored in GameMode 1 (TeamSkills), 2 (SameSkills) and 5 (Debug).**
- **Curse target menus no longer go empty.** When every living enemy is already at the limit, the menu falls back to the unfiltered list and the claim is forced through.
- `C4Camouflage` `MaxPerServer` -1 -> 1
This commit is contained in:
ByDexter 2026-07-31 01:38:50 +03:00
parent b0b50a224f
commit 7292ab1787
9 changed files with 101 additions and 35 deletions

View file

@ -478,6 +478,8 @@ namespace src.player
foreach (var skill in SkillData.Skills)
Instance.SkillAction(skill.Skill.ToString(), "PlayerDisconnect", [leavingIndex]);
SkillUtils.ClearCursesFor(leavingIndex);
PlayerManager.UnregisterPlayer(player.Index);
EntityManager.DestroyPlayerEntities(player.Index);

View file

@ -13,6 +13,7 @@ namespace src.player.skills
private const Skills skillName = Skills.Spectator;
private const string cameraViewModel = "models/sprays/spray_plane.vmdl";
private static readonly ConcurrentDictionary<uint, (uint, uint, uint)> cameras = [];
private static readonly ConcurrentDictionary<uint, DateTime> lastUse = [];
public static void LoadSkill()
{
@ -26,6 +27,15 @@ namespace src.player.skills
EntityManager.DestroyEntity(info.Value.Item2);
cameras.Clear();
lastUse.Clear();
}
public static void PlayerDisconnect(uint playerIndex)
{
if (cameras.TryRemove(playerIndex, out var cameraInfo) && cameraInfo.Item2 != 0)
EntityManager.DestroyEntity(cameraInfo.Item2);
lastUse.TryRemove(playerIndex, out _);
}
public static void WeaponPickup(EventItemPickup @event)
@ -45,6 +55,11 @@ namespace src.player.skills
{
var playerPawn = player.PlayerPawn.Value;
if (playerPawn?.CBodyComponent == null) return;
float cooldown = SkillsInfo.GetValue<float>(skillName, "useCooldown");
if (lastUse.TryGetValue(player.Index, out var last) && (DateTime.Now - last).TotalSeconds < cooldown) return;
lastUse[player.Index] = DateTime.Now;
ChangeCamera(player);
}
@ -54,6 +69,7 @@ namespace src.player.skills
ChangeCamera(player, true);
EntityManager.DestroyPlayerEntities(player.Index);
cameras.TryRemove(player.Index, out _);
lastUse.TryRemove(player.Index, out _);
}
public static void OnTick()
@ -141,12 +157,19 @@ namespace src.player.skills
p.PlayerPawn.Value.Health > 0).ToList();
if (enemies.Count == 0)
{
EntityManager.DestroyEntity(camera.Index);
return 0;
}
var enemy = enemies[Instance.Random.Next(enemies.Count)];
var pawn = enemy.PlayerPawn.Value;
if (pawn == null || !pawn.IsValid || pawn.CameraServices == null || pawn.AbsOrigin == null) return 0;
if (pawn == null || !pawn.IsValid || pawn.CameraServices == null || pawn.AbsOrigin == null)
{
EntityManager.DestroyEntity(camera.Index);
return 0;
}
QAngle angle = new(0, pawn.EyeAngles.Y, 0);
@ -204,9 +227,10 @@ namespace src.player.skills
}
}
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#42f5da", 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, float distance = 100f) : SkillsInfo.DefaultSkillInfo(skill, active, color, onlyTeam, disableOnFreezeTime, needsTeammates, requiredPermission, hudDuration, descriptionHudDuration, maxPerServer, rarity)
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#42f5da", 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, float distance = 100f, float useCooldown = .5f) : SkillsInfo.DefaultSkillInfo(skill, active, color, onlyTeam, disableOnFreezeTime, needsTeammates, requiredPermission, hudDuration, descriptionHudDuration, maxPerServer, rarity)
{
public float Distance { get; set; } = distance;
public float UseCooldown { get; set; } = useCooldown;
}
}
}

View file

@ -25,21 +25,7 @@ namespace src.player.skills
var playerInfo = PlayerManager.GetPlayerByIndex(player!.Index);
if (playerInfo?.Skill != skillName) continue;
var enemies = PlayerManager.GetTickPlayers().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();
var enemies = SkillUtils.GetSelectableEnemies(player, true);
ConcurrentBag<(string, string)> menuItems = [];
foreach (var enemy in enemies)
@ -106,14 +92,7 @@ namespace src.player.skills
var playerEvent = PlayerManager.GetPlayerFromEvent(player);
if (playerEvent == null || !playerEvent.IsValid) return;
var enemies = PlayerManager.GetTickPlayers()
.Where(p => p != null
&& p.IsValid
&& p.Team != player.Team
&& p.PlayerPawn?.Value?.Health > 0
&& p.Team != CsTeam.Spectator
&& p.Team != CsTeam.None)
.ToArray();
var enemies = SkillUtils.GetSelectableEnemies(player, true);
if (enemies.Length > 0)
{

View file

@ -21,6 +21,8 @@ namespace src.player.skills
private static readonly Color terroristWire = Color.FromArgb(255, 255, 64, 64);
private static readonly Color counterTerroristWire = Color.FromArgb(255, 64, 128, 255);
private const double attemptCooldown = .5;
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, SkillsInfo.GetValue<string>(skillName, "color"));
@ -125,6 +127,9 @@ namespace src.player.skills
if (!SkillPlayerInfo.TryGetValue(player.Index, out var skillInfo) || !skillInfo.CanUse) return;
if ((DateTime.Now - skillInfo.LastAttempt).TotalSeconds < attemptCooldown) return;
skillInfo.LastAttempt = DateTime.Now;
if (!TryPlaceWire(player))
{
playerEvent.PrintToChat($" {ChatColors.Red}" + playerEvent.GetTranslation("tripwire_no_wall_info"));
@ -306,6 +311,7 @@ namespace src.player.skills
{
public bool CanUse { get; set; }
public DateTime Cooldown { get; set; }
public DateTime LastAttempt { get; set; }
}
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#ff3b3b", CsTeam onlyTeam = CsTeam.None, bool disableOnFreezeTime = false, bool needsTeammates = false, string requiredPermission = "", float? hudDuration = null, float? descriptionHudDuration = null, int maxPerServer = -1, Rarity rarity = Rarity.Rare, float radarDuration = 5f, float triggerRadius = 24f, float wireHeight = 30f, float wireWidth = 1.5f, float maxWallDistance = 400f, float cooldown = 20f) : SkillsInfo.DefaultSkillInfo(skill, active, color, onlyTeam, disableOnFreezeTime, needsTeammates, requiredPermission, hudDuration, descriptionHudDuration, maxPerServer, rarity)