v1.2.4.b1

This commit is contained in:
ByDexter 2026-09-04 16:50:10 +03:00
parent 332210f58b
commit a1d76f94d7
5 changed files with 81 additions and 21 deletions

View file

@ -75,25 +75,27 @@ namespace src.player.skills
}
}
if (emitter == null)
{
foreach (var p in PlayerManager.GetTickPlayers().Where(p => p != null && p.IsValid))
um.Recipients.Remove(p);
return;
}
List<CCSPlayerController> allowed = [];
foreach (var recipient in PlayerManager.GetTickPlayers().Where(p => p != null && p.IsValid))
{
bool hasSkill = SkillPlayerInfo.ContainsKey(recipient.Index);
if (emitter != null)
foreach (var recipient in um.Recipients)
{
if (recipient == null || !recipient.IsValid) continue;
if (recipient.Team == emitter.Team) continue;
var bot = PlayerManager.GetPlayerEvent(recipient);
bool botSkill = bot != null && SkillPlayerInfo.ContainsKey(bot.Index);
bool hasSkill = SkillPlayerInfo.ContainsKey(recipient.Index);
bool isTeammate = recipient.Team == emitter.Team;
var bot = PlayerManager.GetPlayerEvent(recipient);
bool botSkill = bot != null && bot.IsValid && SkillPlayerInfo.ContainsKey(bot.Index);
if ((!hasSkill && !botSkill) || isTeammate)
um.Recipients.Remove(recipient);
}
if (!hasSkill && !botSkill) continue;
allowed.Add(recipient);
}
um.Recipients.Clear();
foreach (var recipient in allowed)
um.Recipients.Add(recipient);
}
public static void OnTick()

View file

@ -32,13 +32,21 @@ namespace src.player.skills
{
roundEnded = false;
KillAllKnives();
owedKnife.Clear();
}
public static void RoundEnd()
{
roundEnded = true;
KillAllKnives(rememberOwed: true);
foreach (var player in PlayerManager.GetTickPlayers())
{
if (player == null || !player.IsValid || !player.PawnIsAlive) continue;
if (PlayerManager.GetPlayerByIndex(player.Index)?.Skill != skillName) continue;
if (CheckHasKnife(player)) continue;
owedKnife[player.Index] = 0;
}
}
private static void KillAllKnives(bool rememberOwed = false)
@ -164,7 +172,7 @@ namespace src.player.skills
{
if (player == null || !player.IsValid) return;
bool wasDropped = owedKnife.TryRemove(player.Index, out _);
bool wasDropped = owedKnife.ContainsKey(player.Index);
if (knivesInfo.TryRemove(player.Index, out KnifeInfo? knifeInfo) && knifeInfo != null)
{
@ -172,8 +180,53 @@ namespace src.player.skills
DisableKnifeSkill(knifeInfo);
}
if (wasDropped && player.PawnIsAlive)
if (!wasDropped) return;
if (!player.PawnIsAlive)
{
owedKnife[player.Index] = 0;
ScheduleRepay(player.Index, 0);
return;
}
if (!CheckHasKnife(player))
player.GiveNamedItem("weapon_knife");
owedKnife.TryRemove(player.Index, out _);
}
private const int RepayAttempts = 10;
private static void ScheduleRepay(uint playerIndex, int attempt)
{
if (attempt >= RepayAttempts)
{
owedKnife.TryRemove(playerIndex, out _);
return;
}
Instance.AddTimer(1f, () =>
{
if (!owedKnife.ContainsKey(playerIndex)) return;
var player = Utilities.GetPlayerFromIndex((int)playerIndex);
if (player == null || !player.IsValid)
{
owedKnife.TryRemove(playerIndex, out _);
return;
}
if (!player.PawnIsAlive)
{
ScheduleRepay(playerIndex, attempt + 1);
return;
}
if (!CheckHasKnife(player))
player.GiveNamedItem("weapon_knife");
owedKnife.TryRemove(playerIndex, out _);
}, TimerFlags.STOP_ON_MAPCHANGE);
}
public static void PlayerDisconnect(uint playerIndex)

View file

@ -87,10 +87,15 @@ namespace src.player.skills
if (!restored.HasHelmet) return;
var itemServices = victimPawn.ItemServices?.As<CCSPlayer_ItemServices>();
if (itemServices == null || itemServices.HasHelmet) return;
if (itemServices != null && !itemServices.HasHelmet)
itemServices.HasHelmet = true;
itemServices.HasHelmet = true;
Utilities.SetStateChanged(victim, "CCSPlayerController", "m_bPawnHasHelmet");
var owner = victimPawn.Controller.Value?.As<CCSPlayerController>();
if (owner != null && owner.IsValid && !owner.PawnHasHelmet)
{
owner.PawnHasHelmet = true;
Utilities.SetStateChanged(owner, "CCSPlayerController", "m_bPawnHasHelmet");
}
}
private readonly record struct PendingArmor(int Armor, bool HasHelmet);