v1.2.4.b1
This commit is contained in:
parent
332210f58b
commit
a1d76f94d7
5 changed files with 81 additions and 21 deletions
|
|
@ -75,25 +75,27 @@ namespace src.player.skills
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (emitter == null)
|
List<CCSPlayerController> allowed = [];
|
||||||
{
|
|
||||||
foreach (var p in PlayerManager.GetTickPlayers().Where(p => p != null && p.IsValid))
|
|
||||||
um.Recipients.Remove(p);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var recipient in PlayerManager.GetTickPlayers().Where(p => p != null && p.IsValid))
|
if (emitter != null)
|
||||||
|
foreach (var recipient in um.Recipients)
|
||||||
{
|
{
|
||||||
|
if (recipient == null || !recipient.IsValid) continue;
|
||||||
|
if (recipient.Team == emitter.Team) continue;
|
||||||
|
|
||||||
bool hasSkill = SkillPlayerInfo.ContainsKey(recipient.Index);
|
bool hasSkill = SkillPlayerInfo.ContainsKey(recipient.Index);
|
||||||
|
|
||||||
var bot = PlayerManager.GetPlayerEvent(recipient);
|
var bot = PlayerManager.GetPlayerEvent(recipient);
|
||||||
bool botSkill = bot != null && SkillPlayerInfo.ContainsKey(bot.Index);
|
bool botSkill = bot != null && bot.IsValid && SkillPlayerInfo.ContainsKey(bot.Index);
|
||||||
|
|
||||||
bool isTeammate = recipient.Team == emitter.Team;
|
if (!hasSkill && !botSkill) continue;
|
||||||
|
|
||||||
if ((!hasSkill && !botSkill) || isTeammate)
|
allowed.Add(recipient);
|
||||||
um.Recipients.Remove(recipient);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
um.Recipients.Clear();
|
||||||
|
foreach (var recipient in allowed)
|
||||||
|
um.Recipients.Add(recipient);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void OnTick()
|
public static void OnTick()
|
||||||
|
|
|
||||||
|
|
@ -32,13 +32,21 @@ namespace src.player.skills
|
||||||
{
|
{
|
||||||
roundEnded = false;
|
roundEnded = false;
|
||||||
KillAllKnives();
|
KillAllKnives();
|
||||||
owedKnife.Clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RoundEnd()
|
public static void RoundEnd()
|
||||||
{
|
{
|
||||||
roundEnded = true;
|
roundEnded = true;
|
||||||
KillAllKnives(rememberOwed: 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)
|
private static void KillAllKnives(bool rememberOwed = false)
|
||||||
|
|
@ -164,7 +172,7 @@ namespace src.player.skills
|
||||||
{
|
{
|
||||||
if (player == null || !player.IsValid) return;
|
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)
|
if (knivesInfo.TryRemove(player.Index, out KnifeInfo? knifeInfo) && knifeInfo != null)
|
||||||
{
|
{
|
||||||
|
|
@ -172,8 +180,53 @@ namespace src.player.skills
|
||||||
DisableKnifeSkill(knifeInfo);
|
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");
|
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)
|
public static void PlayerDisconnect(uint playerIndex)
|
||||||
|
|
|
||||||
|
|
@ -87,10 +87,15 @@ namespace src.player.skills
|
||||||
if (!restored.HasHelmet) return;
|
if (!restored.HasHelmet) return;
|
||||||
|
|
||||||
var itemServices = victimPawn.ItemServices?.As<CCSPlayer_ItemServices>();
|
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);
|
private readonly record struct PendingArmor(int Armor, bool HasHelmet);
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue