v1.2.2.b1
This commit is contained in:
parent
0fb3d63cd8
commit
46195c2663
147 changed files with 3470 additions and 2161 deletions
|
|
@ -1,17 +1,16 @@
|
|||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.UserMessages;
|
||||
using CounterStrikeSharp.API.Modules.Utils;
|
||||
using src.utils;
|
||||
using System.Collections.Concurrent;
|
||||
using static src.jRandomSkills;
|
||||
|
||||
namespace src.player.skills
|
||||
{
|
||||
public class SoundMaker : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.SoundMaker;
|
||||
private static readonly ConcurrentDictionary<ulong, byte> SkillPlayerInfo = [];
|
||||
private static readonly ConcurrentDictionary<uint, byte> SkillPlayerInfo = [];
|
||||
private static readonly object setLock = new();
|
||||
|
||||
private const string soundEventName = "Hostage.Pain";
|
||||
|
|
@ -30,22 +29,23 @@ namespace src.player.skills
|
|||
|
||||
public static void EnableSkill(CCSPlayerController player)
|
||||
{
|
||||
SkillPlayerInfo.TryAdd(player.SteamID, 0);
|
||||
SkillPlayerInfo.TryAdd(player.Index, 0);
|
||||
}
|
||||
|
||||
public static void DisableSkill(CCSPlayerController player)
|
||||
{
|
||||
SkillPlayerInfo.TryRemove(player.SteamID, out _);
|
||||
SkillPlayerInfo.TryRemove(player.Index, out _);
|
||||
SkillUtils.ResetPrintHTML(player);
|
||||
}
|
||||
|
||||
public static void PlayerDeath(EventPlayerDeath @event)
|
||||
{
|
||||
var player = @event.Userid;
|
||||
var player = PlayerManager.GetPlayerEvent(@event.Userid);
|
||||
if (player == null || !player.IsValid) return;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
|
||||
var playerInfo = PlayerManager.GetPlayerByIndex(player!.Index);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
SkillPlayerInfo.TryRemove(player.SteamID, out _);
|
||||
SkillPlayerInfo.TryRemove(player.Index, out _);
|
||||
}
|
||||
|
||||
public static void PlayerMakeSound(UserMessage um)
|
||||
|
|
@ -53,21 +53,45 @@ namespace src.player.skills
|
|||
var soundevent = um.ReadUInt("soundevent_hash");
|
||||
if (soundevent != soundEventHash) return;
|
||||
|
||||
var userIndex = um.ReadUInt("source_entity_index");
|
||||
if (userIndex == 0) return;
|
||||
var entityIndex = um.ReadUInt("source_entity_index");
|
||||
if (entityIndex == 0) return;
|
||||
|
||||
var sourcePlayer = Utilities.GetPlayers().FirstOrDefault(p => p.Pawn?.Value != null && p.Pawn.Value.IsValid && p.Pawn.Value.Index == userIndex);
|
||||
if (sourcePlayer == null || !sourcePlayer.IsValid) return;
|
||||
|
||||
var toRemove = um.Recipients.Where(r =>
|
||||
CCSPlayerController? emitter = null;
|
||||
foreach (var p in Utilities.GetPlayers().Where(p => p != null && p.IsValid))
|
||||
{
|
||||
if (r.Team == sourcePlayer.Team) return true;
|
||||
if (SkillPlayerInfo.ContainsKey(r.SteamID)) return false;
|
||||
return true;
|
||||
}).ToList();
|
||||
if (p.PlayerPawn.Value?.Index == entityIndex)
|
||||
{
|
||||
emitter = p;
|
||||
break;
|
||||
}
|
||||
|
||||
foreach (var player in toRemove)
|
||||
um.Recipients.Remove(player);
|
||||
var entities = EntityManager.GetPlayerEntities(p.Index, "empty_prop");
|
||||
if (entities.Count > 0 && entities[0] == entityIndex)
|
||||
{
|
||||
emitter = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (emitter == null)
|
||||
{
|
||||
foreach (var p in Utilities.GetPlayers().Where(p => p != null && p.IsValid))
|
||||
um.Recipients.Remove(p);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var recipient in Utilities.GetPlayers().Where(p => p != null && p.IsValid))
|
||||
{
|
||||
bool hasSkill = SkillPlayerInfo.ContainsKey(recipient.Index);
|
||||
|
||||
var bot = PlayerManager.GetPlayerEvent(recipient);
|
||||
bool botSkill = bot != null && SkillPlayerInfo.ContainsKey(bot.Index);
|
||||
|
||||
bool isTeammate = recipient.Team == emitter.Team;
|
||||
|
||||
if ((!hasSkill && !botSkill) || isTeammate)
|
||||
um.Recipients.Remove(recipient);
|
||||
}
|
||||
}
|
||||
|
||||
public static void OnTick()
|
||||
|
|
@ -75,8 +99,20 @@ namespace src.player.skills
|
|||
if (Server.TickCount % (60 * SkillsInfo.GetValue<int>(skillName, "cooldown")) != 0) return;
|
||||
|
||||
foreach (var player in Utilities.GetPlayers()
|
||||
.Where(p => p != null && p.IsValid && p.PawnIsAlive && p.PlayerPawn.Value != null && p.PlayerPawn.Value.IsValid))
|
||||
.Where(p => p != null && p.IsValid && p.PlayerPawn.Value != null && p.PlayerPawn.Value.IsValid && p.PlayerPawn.Value.Health > 0))
|
||||
{
|
||||
var entities = EntityManager.GetPlayerEntities(player.Index, "empty_prop");
|
||||
|
||||
if (entities.Count == 0)
|
||||
{
|
||||
player.PlayerPawn.Value!.EmitSound(soundEventName, volume: 1f);
|
||||
continue;
|
||||
}
|
||||
|
||||
var entity = Utilities.GetEntityFromIndex<CDynamicProp>((int)entities[0]);
|
||||
if (entity != null && entity.IsValid)
|
||||
entity.EmitSound(soundEventName, volume: 1f);
|
||||
}
|
||||
}
|
||||
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#e3ed8c", CsTeam onlyTeam = CsTeam.None, bool disableOnFreezeTime = false, bool needsTeammates = false, string requiredPermission = "", int maxPerServer = -1, Rarity rarity = Rarity.Common, int cooldown = 2) : SkillsInfo.DefaultSkillInfo(skill, active, color, onlyTeam, disableOnFreezeTime, needsTeammates, requiredPermission, maxPerServer, rarity)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue