Refactor skill lookup logic and vote system, update language files
Refactored command handling to improve player and skill lookup logic, replaced some list operations with direct queries, and updated method signatures for clarity and null safety. The vote system was reworked to support more robust vote tracking, cooldowns, and localized chat messages. Language files were updated to add new vote-related translations. Various code style and nullability improvements were made throughout the plugin.
This commit is contained in:
parent
54b265d43d
commit
e33975fe8b
117 changed files with 1532 additions and 1674 deletions
|
|
@ -15,12 +15,12 @@ namespace jRandomSkills
|
|||
|
||||
public static void Load()
|
||||
{
|
||||
var config = Config.config?.Settings;
|
||||
var config = Config.LoadedConfig?.Settings;
|
||||
if (config == null || config == null) return;
|
||||
|
||||
var commands = new Dictionary<IEnumerable<string>, (string description, CommandInfo.CommandCallback handler)>
|
||||
{
|
||||
{ SplitCommands(config.SetSkillCommands), ("Delete record", Command_SetSkill) },
|
||||
{ SplitCommands(config.SetSkillCommands), ("Set skill", Command_SetSkill) },
|
||||
{ SplitCommands(config.SkillsListCommands), ("Delete all records", Command_SkillsListMenu) },
|
||||
{ SplitCommands(config.UseSkillCommands), ("Use/Type skill", Command_UseTypeSkill) },
|
||||
{ SplitCommands(config.ChangeMapCommands), ("Change map", Command_ChangeMap) },
|
||||
|
|
@ -47,7 +47,8 @@ namespace jRandomSkills
|
|||
private static void Command_UseTypeSkill(CCSPlayerController? player, CommandInfo _)
|
||||
{
|
||||
if (player == null) return;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo == null) return;
|
||||
|
||||
var playerPawn = player.PlayerPawn.Value;
|
||||
if (playerPawn?.CBodyComponent == null) return;
|
||||
|
|
@ -56,9 +57,9 @@ namespace jRandomSkills
|
|||
string[] commands = _.ArgString.Trim().Split(" ", StringSplitOptions.RemoveEmptyEntries);
|
||||
Debug.WriteToDebug($"Player {player.PlayerName} used the skill: {playerInfo.Skill}");
|
||||
if (commands == null || commands.Length == 0)
|
||||
Instance.SkillAction(playerInfo!.Skill.ToString(), "UseSkill", new object[] { player });
|
||||
Instance.SkillAction(playerInfo.Skill.ToString(), "UseSkill", [player]);
|
||||
else
|
||||
Instance.SkillAction(playerInfo!.Skill.ToString(), "TypeSkill", new object[] { player, commands });
|
||||
Instance.SkillAction(playerInfo.Skill.ToString(), "TypeSkill", [player, commands]);
|
||||
}
|
||||
|
||||
[RequiresPermissions("@jRandmosSkills/admin")]
|
||||
|
|
@ -66,8 +67,9 @@ namespace jRandomSkills
|
|||
private static void Command_SetSkill(CCSPlayerController? player, CommandInfo command)
|
||||
{
|
||||
if (player == null) return;
|
||||
|
||||
(List<CCSPlayerController> players, string targetname) = FindTarget.Find(command, 2, false, true);
|
||||
var targetPlayer = Utilities.GetPlayers().FirstOrDefault(p => !p.IsBot
|
||||
&& (p.SteamID.ToString().Equals(command.GetArg(1), StringComparison.CurrentCultureIgnoreCase)
|
||||
|| p.PlayerName.Equals(command.GetArg(1), StringComparison.CurrentCultureIgnoreCase)) );
|
||||
|
||||
if (command.ArgCount < 2)
|
||||
{
|
||||
|
|
@ -77,7 +79,7 @@ namespace jRandomSkills
|
|||
return;
|
||||
}
|
||||
|
||||
if (players.Count == 0)
|
||||
if (targetPlayer == null)
|
||||
{
|
||||
player.PrintToChat($" {ChatColors.Green}―――――――――――{ChatColors.DarkRed}◥◣◆◢◤{ChatColors.Green}―――――――――――");
|
||||
SkillUtils.PrintToChat(player, Localization.GetTranslation("player_not_found_setskill"), true);
|
||||
|
|
@ -96,34 +98,30 @@ namespace jRandomSkills
|
|||
return;
|
||||
}
|
||||
|
||||
foreach (CCSPlayerController target in players)
|
||||
var skillPlayer = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == targetPlayer.SteamID);
|
||||
if (skillPlayer != null)
|
||||
{
|
||||
var skillPlayer = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == target.SteamID);
|
||||
if (skillPlayer != null)
|
||||
{
|
||||
Instance.SkillAction(skillPlayer.Skill.ToString(), "DisableSkill", [targetPlayer]);
|
||||
skillPlayer.Skill = skill.Skill;
|
||||
Instance.SkillAction(skill.Skill.ToString(), "EnableSkill", [targetPlayer]);
|
||||
|
||||
Instance.SkillAction(skillPlayer.Skill.ToString(), "DisableSkill", new object[] { target });
|
||||
skillPlayer.Skill = skill.Skill;
|
||||
Instance.SkillAction(skill.Skill.ToString(), "EnableSkill", new object[] { target });
|
||||
|
||||
player.PrintToChat($" {ChatColors.Green}―――――――――――{ChatColors.DarkRed}◥◣◆◢◤{ChatColors.Green}―――――――――――");
|
||||
SkillUtils.PrintToChat(player, $"{Localization.GetTranslation("done_setskill")}: {ChatColors.LightRed}{skill.Name} {ChatColors.Lime}{Localization.GetTranslation("for_setskill")} {ChatColors.LightRed}{target.PlayerName}", false);
|
||||
player.PrintToChat($" {ChatColors.Green}―――――――――――{ChatColors.DarkRed}◥◣◆◢◤{ChatColors.Green}―――――――――――");
|
||||
}
|
||||
else
|
||||
{
|
||||
player.PrintToChat($" {ChatColors.Green}―――――――――――{ChatColors.DarkRed}◥◣◆◢◤{ChatColors.Green}―――――――――――");
|
||||
SkillUtils.PrintToChat(player, Localization.GetTranslation("error_setskill"), true);
|
||||
player.PrintToChat($" {ChatColors.Green}―――――――――――{ChatColors.DarkRed}◥◣◆◢◤{ChatColors.Green}―――――――――――");
|
||||
}
|
||||
player.PrintToChat($" {ChatColors.Green}―――――――――――{ChatColors.DarkRed}◥◣◆◢◤{ChatColors.Green}―――――――――――");
|
||||
SkillUtils.PrintToChat(player, $"{Localization.GetTranslation("done_setskill")}: {ChatColors.LightRed}{skill.Name} {ChatColors.Lime}{Localization.GetTranslation("for_setskill")} {ChatColors.LightRed}{targetPlayer.PlayerName}", false);
|
||||
player.PrintToChat($" {ChatColors.Green}―――――――――――{ChatColors.DarkRed}◥◣◆◢◤{ChatColors.Green}―――――――――――");
|
||||
}
|
||||
else
|
||||
{
|
||||
player.PrintToChat($" {ChatColors.Green}―――――――――――{ChatColors.DarkRed}◥◣◆◢◤{ChatColors.Green}―――――――――――");
|
||||
SkillUtils.PrintToChat(player, Localization.GetTranslation("error_setskill"), true);
|
||||
player.PrintToChat($" {ChatColors.Green}―――――――――――{ChatColors.DarkRed}◥◣◆◢◤{ChatColors.Green}―――――――――――");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_ONLY)]
|
||||
private static void Command_SkillsListMenu(CCSPlayerController? player, CommandInfo command)
|
||||
{
|
||||
if (player == null) return;
|
||||
|
||||
Menu.DisplaySkillsList(player);
|
||||
}
|
||||
|
||||
|
|
@ -135,10 +133,10 @@ namespace jRandomSkills
|
|||
player.Vote(VoteType.ChangeMap, command.ArgString);
|
||||
return;
|
||||
}
|
||||
ChangeMap(player, command);
|
||||
ChangeMap(command);
|
||||
}
|
||||
|
||||
private static void ChangeMap(CCSPlayerController? player, CommandInfo command)
|
||||
private static void ChangeMap(CommandInfo command)
|
||||
{
|
||||
string map = command.GetArg(1);
|
||||
|
||||
|
|
@ -163,13 +161,13 @@ namespace jRandomSkills
|
|||
{
|
||||
if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, "@TESTTEST/TESTAFD"))
|
||||
{
|
||||
player.Vote(VoteType.StartGame, command.ArgString);
|
||||
player.Vote(VoteType.StartGame);
|
||||
return;
|
||||
}
|
||||
StartGame(player, command);
|
||||
StartGame(command);
|
||||
}
|
||||
|
||||
private static void StartGame(CCSPlayerController? player, CommandInfo command)
|
||||
private static void StartGame(CommandInfo command)
|
||||
{
|
||||
int cheats = command.GetArg(1) == "sv" ? 1 : 0;
|
||||
Server.ExecuteCommand($"mp_freezetime {(cheats == 1 ? 0 : 5)}");
|
||||
|
|
@ -190,13 +188,13 @@ namespace jRandomSkills
|
|||
{
|
||||
if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, "@TESTTEST/TESTAFD"))
|
||||
{
|
||||
player.Vote(VoteType.SwapTeam, command.ArgString);
|
||||
player.Vote(VoteType.SwapTeam);
|
||||
return;
|
||||
}
|
||||
Swap(player, command);
|
||||
Swap();
|
||||
}
|
||||
|
||||
private static void Swap(CCSPlayerController? _player, CommandInfo command)
|
||||
private static void Swap()
|
||||
{
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
if (Instance.IsPlayerValid(player) && new CsTeam[] { CsTeam.CounterTerrorist, CsTeam.Terrorist }.Contains(player.Team))
|
||||
|
|
@ -209,13 +207,13 @@ namespace jRandomSkills
|
|||
{
|
||||
if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, "@TESTTEST/TESTAFD"))
|
||||
{
|
||||
player.Vote(VoteType.ShuffleTeam, command.ArgString);
|
||||
player.Vote(VoteType.ShuffleTeam);
|
||||
return;
|
||||
}
|
||||
Shuffle(player, command);
|
||||
Shuffle();
|
||||
}
|
||||
|
||||
private static void Shuffle(CCSPlayerController? _player, CommandInfo command)
|
||||
private static void Shuffle()
|
||||
{
|
||||
var players = Utilities.GetPlayers().FindAll(p => (Instance.IsPlayerValid(p) && new CsTeam[] { CsTeam.CounterTerrorist, CsTeam.Terrorist }.Contains(p.Team)));
|
||||
double CTlimit = Instance.Random.Next(0, 2) == 0 ? Math.Floor(players.Count / 2.0) : Math.Ceiling(players.Count / 2.0);
|
||||
|
|
@ -233,13 +231,13 @@ namespace jRandomSkills
|
|||
{
|
||||
if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, "@TESTTEST/TESTAFD"))
|
||||
{
|
||||
player.Vote(VoteType.PauseGame, command.ArgString);
|
||||
player.Vote(VoteType.PauseGame);
|
||||
return;
|
||||
}
|
||||
Pause(player, command);
|
||||
Pause();
|
||||
}
|
||||
|
||||
private static void Pause(CCSPlayerController? player, CommandInfo command)
|
||||
private static void Pause()
|
||||
{
|
||||
Server.PrintToChatAll($" {(gamePaused ? ChatColors.Green : ChatColors.Red)}{Localization.GetTranslation(gamePaused ? "unpause" : "pause")}");
|
||||
Server.ExecuteCommand( gamePaused ? "mp_unpause_match" : "mp_pause_match");
|
||||
|
|
@ -250,6 +248,7 @@ namespace jRandomSkills
|
|||
[CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||
private static void Command_Heal(CCSPlayerController? player, CommandInfo command)
|
||||
{
|
||||
if (player == null || !player.IsValid || player.PlayerPawn.Value == null || !player.PlayerPawn.Value.IsValid || player.LifeState != (byte)LifeState_t.LIFE_ALIVE) return;
|
||||
SkillUtils.AddHealth(player.PlayerPawn.Value, 100);
|
||||
player.PrintToChat($" {ChatColors.Green}{Localization.GetTranslation("healed")}");
|
||||
}
|
||||
|
|
@ -269,7 +268,8 @@ namespace jRandomSkills
|
|||
{
|
||||
if (!int.TryParse(command.GetArg(1), out int ctScore) || !int.TryParse(command.GetArg(2), out int tScore))
|
||||
{
|
||||
SkillUtils.PrintToChat(player, Localization.GetTranslation("correct_form_setscore"), true);
|
||||
if (player != null && player.IsValid)
|
||||
SkillUtils.PrintToChat(player, Localization.GetTranslation("correct_form_setscore"), true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,49 +1,75 @@
|
|||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Events;
|
||||
using CounterStrikeSharp.API.Modules.Utils;
|
||||
using jRandomSkills.src.utils;
|
||||
|
||||
namespace jRandomSkills
|
||||
{
|
||||
public static class VoteSystem
|
||||
{
|
||||
private static HashSet<VoteData> votes = new HashSet<VoteData>();
|
||||
private static readonly HashSet<VoteData> votes = [];
|
||||
|
||||
public static void Load()
|
||||
private static VoteData? CreateVote(VoteType voteType, string? args = null)
|
||||
{
|
||||
jRandomSkills.Instance.DeregisterEventHandler<EventPlayerChat>((@event, info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
var text = @event.Text;
|
||||
return HookResult.Continue;
|
||||
});
|
||||
}
|
||||
var vote = new VoteData(10,
|
||||
() => {
|
||||
Server.ExecuteCommand($"{VoteTypeCommands.GetCommand(voteType)}{(!string.IsNullOrEmpty(args) ? $" {args}" : "")}");
|
||||
}, 60, 2, 5, 2, voteType, args);
|
||||
|
||||
if (vote.MinimumPlayersToStartVoting > Utilities.GetPlayers().Count(p => !p.IsBot))
|
||||
return null;
|
||||
|
||||
private static VoteData CreateVote(VoteType voteType, string? args = null)
|
||||
{
|
||||
var vote = new VoteData(10,
|
||||
() => {
|
||||
Server.ExecuteCommand($"{VoteTypeCommands.GetCommand(voteType)}{(args != null ? $" {args}" : "")}");
|
||||
}, 60, voteType, args);
|
||||
votes.Add(vote);
|
||||
string commandName = $"!{VoteTypeCommands.GetCommand(vote.Type)?.Replace("css_", "")}{(!string.IsNullOrEmpty(vote?.Args) ? $" {vote?.Args}" : "")}";
|
||||
|
||||
jRandomSkills.Instance.AddTimer(vote?.TimeToVote ?? 0, () =>
|
||||
Server.PrintToChatAll($" {ChatColors.Lime}{Localization.GetTranslation("vote_started", commandName)}");
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
player.EmitSound("UIPanorama.tab_mainmenu_news");
|
||||
|
||||
if (vote == null) return vote;
|
||||
jRandomSkills.Instance.AddTimer(vote.TimeToVote, () =>
|
||||
{
|
||||
if (!votes.Contains(vote) || !vote.GetActive()) return;
|
||||
vote.SetActive(false);
|
||||
Server.PrintToChatAll($" {ChatColors.Red}{Localization.GetTranslation("vote_timeout", commandName)}");
|
||||
});
|
||||
|
||||
float[] times = [vote.TimeToVote, vote.TimeToVote + vote.TimeToNextVoting, vote.TimeToVote + vote.TimeToNextSameVoting];
|
||||
jRandomSkills.Instance.AddTimer(times.Max(), () =>
|
||||
{
|
||||
if (!votes.Contains(vote)) return;
|
||||
votes.Remove(vote);
|
||||
Server.PrintToChatAll($" {ChatColors.Red}Vote '!{VoteTypeCommands.GetCommand(vote.Type)?.Replace("css_", "")}' timed out!");
|
||||
});
|
||||
return vote;
|
||||
}
|
||||
|
||||
public static void Vote(this CCSPlayerController player, VoteType voteType, string? args = null)
|
||||
{
|
||||
var vote = votes.FirstOrDefault(v => v.Type == voteType);
|
||||
var vote = votes.FirstOrDefault(v => v.Type == voteType && v.Args == args && v.GetActive());
|
||||
if (vote == null)
|
||||
{
|
||||
if (votes.Any(v => v.NextVoting() > DateTime.Now))
|
||||
{
|
||||
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("vote_wait")}");
|
||||
return;
|
||||
}
|
||||
else if (votes.Any(v => v.Type == voteType && v.NextSameVoting() > DateTime.Now))
|
||||
{
|
||||
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("vote_same_wait")}");
|
||||
return;
|
||||
}
|
||||
|
||||
vote = CreateVote(voteType, args);
|
||||
}
|
||||
|
||||
if (vote == null)
|
||||
{
|
||||
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("vote_not_enough_players")}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!vote.PlayersVoted.Add(player.SteamID))
|
||||
player.PrintToChat($" {ChatColors.Red}You have already voted!");
|
||||
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("vote_alredy_voted")}");
|
||||
else CheckVote(vote);
|
||||
}
|
||||
|
||||
|
|
@ -56,30 +82,46 @@ namespace jRandomSkills
|
|||
if (voted >= playersNeeded)
|
||||
{
|
||||
vote.SuccessAction.Invoke();
|
||||
votes.Remove(vote);
|
||||
vote.SetActive(false);
|
||||
}
|
||||
else
|
||||
Server.PrintToChatAll($" {ChatColors.Yellow}Vote '!{VoteTypeCommands.GetCommand(vote.Type)?.Replace("css_", "")}': {ChatColors.Green}{voted}/{playersNeeded}");
|
||||
Server.PrintToChatAll($" {ChatColors.Yellow}{Localization.GetTranslation("vote_vote")} '!{VoteTypeCommands.GetCommand(vote.Type)?.Replace("css_", "")}{(!string.IsNullOrEmpty(vote?.Args) ? $" {vote?.Args}" : "")}': {ChatColors.Green}{voted}/{playersNeeded}");
|
||||
}
|
||||
}
|
||||
|
||||
public class VoteData
|
||||
public class VoteData(float timeToVote, Action successAction, float percentagesToSuccess, float timeToNextVoting, float timeToNextSameVoting, int minimumPlayersToStartVoting, VoteType type, string? args = null)
|
||||
{
|
||||
public float TimeToVote { get; set; }
|
||||
public Action SuccessAction { get; set; }
|
||||
public float PercentagesToSuccess { get; set; }
|
||||
public VoteType Type { get; set; }
|
||||
public string Args { get; set; }
|
||||
public HashSet<ulong> PlayersVoted { get; set; }
|
||||
private bool Active { get; set; } = true;
|
||||
public float TimeToVote { get; set; } = timeToVote;
|
||||
public Action SuccessAction { get; set; } = successAction;
|
||||
public float PercentagesToSuccess { get; set; } = percentagesToSuccess;
|
||||
public float TimeToNextVoting { get; set; } = timeToNextVoting;
|
||||
public float TimeToNextSameVoting { get; set; } = timeToNextSameVoting;
|
||||
public int MinimumPlayersToStartVoting { get; set; } = minimumPlayersToStartVoting;
|
||||
public VoteType Type { get; set; } = type;
|
||||
public string? Args { get; set; } = args;
|
||||
public HashSet<ulong> PlayersVoted { get; set; } = [];
|
||||
|
||||
public VoteData(float timeToVote, Action successAction, float percentagesToSuccess, VoteType type, string? args = null)
|
||||
private DateTime CreatedTime { get; set; } = DateTime.Now;
|
||||
|
||||
public void SetActive(bool active)
|
||||
{
|
||||
TimeToVote = timeToVote;
|
||||
SuccessAction = successAction;
|
||||
PercentagesToSuccess = percentagesToSuccess;
|
||||
Type = type;
|
||||
Args = args;
|
||||
PlayersVoted = new HashSet<ulong>();
|
||||
Active = active;
|
||||
}
|
||||
|
||||
public bool GetActive()
|
||||
{
|
||||
return Active;
|
||||
}
|
||||
|
||||
public DateTime NextVoting()
|
||||
{
|
||||
return CreatedTime.AddSeconds(TimeToVote + TimeToNextVoting);
|
||||
}
|
||||
|
||||
public DateTime NextSameVoting()
|
||||
{
|
||||
return CreatedTime.AddSeconds(TimeToVote + TimeToNextSameVoting);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -95,7 +137,7 @@ namespace jRandomSkills
|
|||
|
||||
public static class VoteTypeCommands
|
||||
{
|
||||
private static readonly Dictionary<VoteType, string> names = new Dictionary<VoteType, string>()
|
||||
private static readonly Dictionary<VoteType, string> names = new()
|
||||
{
|
||||
{ VoteType.StartGame, "css_start" },
|
||||
{ VoteType.PauseGame, "css_pause" },
|
||||
|
|
|
|||
|
|
@ -8,13 +8,17 @@ using System.Reflection;
|
|||
|
||||
namespace jRandomSkills
|
||||
{
|
||||
#pragma warning disable IDE1006 // Style nazewnictwa
|
||||
public partial class jRandomSkills : BasePlugin
|
||||
#pragma warning restore IDE1006 // Style nazewnictwa
|
||||
{
|
||||
#pragma warning disable CS8618 // Pole niedopuszczające wartości null musi zawierać wartość inną niż null podczas kończenia działania konstruktora. Rozważ zadeklarowanie pola jako dopuszczającego wartość null.
|
||||
public static jRandomSkills Instance { get; private set; }
|
||||
#pragma warning restore CS8618 // Pole niedopuszczające wartości null musi zawierać wartość inną niż null podczas kończenia działania konstruktora. Rozważ zadeklarowanie pola jako dopuszczającego wartość null.
|
||||
|
||||
public List<jSkill_PlayerInfo> skillPlayer { get; } = new List<jSkill_PlayerInfo>();
|
||||
public List<jSkill_PlayerInfo> SkillPlayer { get; } = [];
|
||||
public Random Random { get; } = new Random();
|
||||
public CCSGameRules GameRules { get; set; }
|
||||
public CCSGameRules? GameRules { get; set; }
|
||||
|
||||
public override string ModuleName => "[CS2] [ jRandomSkills ]";
|
||||
public override string ModuleAuthor => "D3X, Juzlus";
|
||||
|
|
@ -40,13 +44,15 @@ namespace jRandomSkills
|
|||
if (Config.GetValue<bool>(skill, "active"))
|
||||
SkillAction(skill.ToString()!, "LoadSkill");
|
||||
|
||||
Debug.WriteToDebug($"jRandomSkills v{Instance.ModuleVersion} ({SkillData.Skills.Count - 1}/{Config.config.SkillsInfo.Length - 1} Skills) loaded!");
|
||||
Debug.WriteToDebug($"GameModes: {(Config.GameModes)Config.config.Settings.GameMode}, Lang: {Config.config.Settings.LangCode}");
|
||||
Debug.WriteToDebug($"jRandomSkills v{Instance.ModuleVersion} ({SkillData.Skills.Count - 1}/{Config.LoadedConfig.SkillsInfo.Length - 1} Skills) loaded!");
|
||||
Debug.WriteToDebug($"GameModes: {(Config.GameModes)Config.LoadedConfig.Settings.GameMode}, Lang: {Config.LoadedConfig.Settings.LangCode}");
|
||||
foreach (var skill in SkillData.Skills)
|
||||
Debug.WriteToDebug($"Loaded: {skill.Skill}");
|
||||
}
|
||||
|
||||
internal void SkillAction(string skill, string methodName, object[] param = null)
|
||||
#pragma warning disable CA1822 // Oznaczaj elementy członkowskie jako statyczne
|
||||
internal void SkillAction(string skill, string methodName, object[]? param = null)
|
||||
#pragma warning restore CA1822 // Oznaczaj elementy członkowskie jako statyczne
|
||||
{
|
||||
string className = $"jRandomSkills.{skill}";
|
||||
Type? type = Type.GetType(className);
|
||||
|
|
@ -70,23 +76,27 @@ namespace jRandomSkills
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
internal void AddCommand(string name, string description, CommandInfo.CommandCallback handler)
|
||||
internal new void AddCommand(string name, string description, CommandInfo.CommandCallback handler)
|
||||
{
|
||||
var definition = new CommandDefinition(name, description, handler);
|
||||
CommandDefinitions.Add(definition);
|
||||
CommandManager.RegisterCommand(definition);
|
||||
}
|
||||
|
||||
internal bool IsPlayerValid(CCSPlayerController player)
|
||||
#pragma warning disable CA1822 // Oznaczaj elementy członkowskie jako statyczne
|
||||
internal bool IsPlayerValid(CCSPlayerController? player)
|
||||
#pragma warning restore CA1822 // Oznaczaj elementy członkowskie jako statyczne
|
||||
{
|
||||
return player != null && player.IsValid && player.PlayerPawn?.Value != null && player.PlayerPawn.Value.LifeState == (byte)LifeState_t.LIFE_ALIVE;
|
||||
return player != null && player.IsValid && player.PlayerPawn?.Value != null && player.PlayerPawn.Value.IsValid && player.PlayerPawn.Value.LifeState == (byte)LifeState_t.LIFE_ALIVE;
|
||||
}
|
||||
|
||||
public uint[] footstepSoundEvents = { 3109879199, 70939233, 1342713723, 2722081556, 1909915699, 3193435079, 2300993891, 3847761506, 4084367249, 1342713723, 3847761506, 2026488395, 2745524735, 2684452812, 2265091453, 1269567645, 520432428, 3266483468, 1346129716, 2061955732, 2240518199, 2829617974, 1194677450, 1803111098, 3749333696, 29217150, 1692050905, 2207486967, 2633527058, 3342414459, 988265811, 540697918, 1763490157, 3755338324, 3161194970, 3753692454, 3166948458, 3997353267, 3161194970, 3753692454, 3166948458, 3997353267, 809738584, 3368720745, 3295206520, 3184465677, 123085364, 3123711576, 737696412, 1403457606, 1770765328, 892882552, 3023174225, 4163677892, 3952104171, 4082928848, 1019414932, 1485322532, 1161855519, 1557420499, 1163426340, 809738584, 3368720745, 2708661994, 2479376962, 3295206520, 1404198078, 1194093029, 1253503839, 2189706910, 1218015996, 96240187, 1116700262, 84876002, 1598540856, 2231399653 };
|
||||
public uint[] silentSoundEvents = { 2551626319, 765706800, 765706800, 2860219006, 2162652424, 2551626319, 2162652424, 117596568, 117596568, 740474905, 1661204257, 3009312615, 1506215040, 115843229, 3299941720, 1016523349, 2684452812, 2067683805, 2067683805, 1016523349, 4160462271, 1543118744, 585390608, 3802757032, 2302139631, 2546391140, 144629619, 4152012084, 4113422219, 1627020521, 2899365092, 819435812, 3218103073, 961838155, 1535891875, 1826799645, 3460445620, 1818046345, 3666896632, 3099536373, 1440734007, 1409986305, 1939055066, 782454593, 4074593561, 1540837791, 3257325156 };
|
||||
public uint[] footstepSoundEvents = [3109879199, 70939233, 1342713723, 2722081556, 1909915699, 3193435079, 2300993891, 3847761506, 4084367249, 1342713723, 3847761506, 2026488395, 2745524735, 2684452812, 2265091453, 1269567645, 520432428, 3266483468, 1346129716, 2061955732, 2240518199, 2829617974, 1194677450, 1803111098, 3749333696, 29217150, 1692050905, 2207486967, 2633527058, 3342414459, 988265811, 540697918, 1763490157, 3755338324, 3161194970, 3753692454, 3166948458, 3997353267, 3161194970, 3753692454, 3166948458, 3997353267, 809738584, 3368720745, 3295206520, 3184465677, 123085364, 3123711576, 737696412, 1403457606, 1770765328, 892882552, 3023174225, 4163677892, 3952104171, 4082928848, 1019414932, 1485322532, 1161855519, 1557420499, 1163426340, 809738584, 3368720745, 2708661994, 2479376962, 3295206520, 1404198078, 1194093029, 1253503839, 2189706910, 1218015996, 96240187, 1116700262, 84876002, 1598540856, 2231399653];
|
||||
public uint[] silentSoundEvents = [2551626319, 765706800, 765706800, 2860219006, 2162652424, 2551626319, 2162652424, 117596568, 117596568, 740474905, 1661204257, 3009312615, 1506215040, 115843229, 3299941720, 1016523349, 2684452812, 2067683805, 2067683805, 1016523349, 4160462271, 1543118744, 585390608, 3802757032, 2302139631, 2546391140, 144629619, 4152012084, 4113422219, 1627020521, 2899365092, 819435812, 3218103073, 961838155, 1535891875, 1826799645, 3460445620, 1818046345, 3666896632, 3099536373, 1440734007, 1409986305, 1939055066, 782454593, 4074593561, 1540837791, 3257325156];
|
||||
}
|
||||
|
||||
#pragma warning disable IDE1006
|
||||
public class jSkill_PlayerInfo
|
||||
#pragma warning restore IDE1006
|
||||
{
|
||||
public required ulong SteamID { get; set; }
|
||||
public required string PlayerName { get; set; }
|
||||
|
|
@ -96,23 +106,16 @@ namespace jRandomSkills
|
|||
public bool IsDrawing { get; set; }
|
||||
}
|
||||
|
||||
public class jSkill_SkillInfo
|
||||
#pragma warning disable IDE1006
|
||||
public class jSkill_SkillInfo(Skills skill, string color, bool display)
|
||||
#pragma warning restore IDE1006
|
||||
{
|
||||
public Skills Skill { get; }
|
||||
public string Name { get; }
|
||||
public string Description { get; }
|
||||
public string Color { get; }
|
||||
public Skills Skill { get; } = skill;
|
||||
public string Name { get; } = Localization.GetTranslation(skill.ToString().ToLower());
|
||||
public string Description { get; } = Localization.GetTranslation($"{skill.ToString().ToLower()}_desc");
|
||||
public string Color { get; } = color;
|
||||
|
||||
public bool Display { get; }
|
||||
|
||||
public jSkill_SkillInfo(Skills skill, string color, bool display)
|
||||
{
|
||||
Skill = skill;
|
||||
Name = Localization.GetTranslation(skill.ToString().ToLower());
|
||||
Description = Localization.GetTranslation($"{skill.ToString().ToLower()}_desc");
|
||||
Color = color;
|
||||
Display = display;
|
||||
}
|
||||
public bool Display { get; } = display;
|
||||
|
||||
public static implicit operator Skills(jSkill_SkillInfo v)
|
||||
{
|
||||
|
|
@ -122,6 +125,6 @@ namespace jRandomSkills
|
|||
|
||||
public static class SkillData
|
||||
{
|
||||
public static List<jSkill_SkillInfo> Skills { get; } = new List<jSkill_SkillInfo>();
|
||||
public static List<jSkill_SkillInfo> Skills { get; } = [];
|
||||
}
|
||||
}
|
||||
|
|
@ -414,6 +414,14 @@
|
|||
"healed": "You have been healed.",
|
||||
"game_start": "Game started!",
|
||||
|
||||
"vote_started": "Vote started: '{0}'",
|
||||
"vote_timeout": "Vote '{0}' timed out!",
|
||||
"vote_wait": "You need to wait before starting another vote!",
|
||||
"vote_same_wait": "You need to wait before starting the same vote again!",
|
||||
"vote_not_enough_players": "Not enough players to start a vote!",
|
||||
"vote_alredy_voted": "You have already voted!",
|
||||
"vote_vote": "Vote",
|
||||
|
||||
"teammate_skills": "Your teammates' skills",
|
||||
"summary_start": "======SUMMARY=OF=THE=LAST=ROUND======",
|
||||
"summary_end": "======================================="
|
||||
|
|
|
|||
|
|
@ -414,6 +414,14 @@
|
|||
"healed": "Zostałeś uleczony.",
|
||||
"game_start": "Gra rozpoczęta!",
|
||||
|
||||
"vote_started": "Głosowanie rozpoczęte: '{0}'",
|
||||
"vote_timeout": "Głosowanie '{0}' przekroczyło limit czasu!",
|
||||
"vote_wait": "Musisz poczekać, zanim rozpoczniesz kolejne głosowanie!",
|
||||
"vote_same_wait": "Musisz poczekać, zanim ponownie rozpoczniesz to samo głosowanie!",
|
||||
"vote_not_enough_players": "Za mało graczy, aby rozpocząć głosowanie!",
|
||||
"vote_alredy_voted": "Już zagłosowałeś!",
|
||||
"vote_vote": "Głosowanie",
|
||||
|
||||
"teammate_skills": "Supermoce twoich sojuszników",
|
||||
"summary_start": "======PODSUMOWANIE=Z=OSTATNIEJ=RUNDY======",
|
||||
"summary_end": "============================================"
|
||||
|
|
|
|||
|
|
@ -414,6 +414,14 @@
|
|||
"healed": "Você foi curado.",
|
||||
"game_start": "Jogo iniciado!",
|
||||
|
||||
"vote_started": "Votação iniciada: '{0}'",
|
||||
"vote_timeout": "Votação '{0}' expirou!",
|
||||
"vote_wait": "Você precisa esperar antes de iniciar outra votação!",
|
||||
"vote_same_wait": "Você precisa esperar antes de iniciar a mesma votação novamente!",
|
||||
"vote_not_enough_players": "Não há jogadores suficientes para iniciar uma votação!",
|
||||
"vote_alredy_voted": "Você já votou!",
|
||||
"vote_vote": "Votar",
|
||||
|
||||
"teammate_skills": "Habilidades dos seus companheiros de equipe",
|
||||
"summary_start": "=======RESUMO=DA=ÚLTIMA=RODADA=======",
|
||||
"summary_end": "======================================="
|
||||
|
|
|
|||
|
|
@ -414,6 +414,14 @@
|
|||
"healed": "你已被治疗。",
|
||||
"game_start": "游戏开始!",
|
||||
|
||||
"vote_started": "投票开始:'{0}'",
|
||||
"vote_timeout": "投票'{0}'超时!",
|
||||
"vote_wait": "您需要等待才能开始另一轮投票!",
|
||||
"vote_same_wait": "您需要等待才能再次发起相同投票!",
|
||||
"vote_not_enough_players": "投票人数不足!",
|
||||
"vote_alredy_voted": "您已投票!",
|
||||
"vote_vote": "投票",
|
||||
|
||||
"teammate_skills": "你队友的技能",
|
||||
"summary_start": "=============上一回合总结==============",
|
||||
"summary_end": "======================================="
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace jRandomSkills
|
|||
{
|
||||
public static class Debug
|
||||
{
|
||||
private static string sessionId;
|
||||
private static string sessionId = "00000";
|
||||
|
||||
public static void Load()
|
||||
{
|
||||
|
|
@ -83,6 +83,7 @@ namespace jRandomSkills
|
|||
Instance.RegisterEventHandler<EventPlayerShoot>((@event, info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
Debug.WriteToDebug($"{(player.IsBot ? "Bot" : "Player")} {player.PlayerName} fired a shot.");
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
|
@ -98,8 +99,8 @@ namespace jRandomSkills
|
|||
if (param == null || param.Entity == null || param2 == null || param2.Attacker == null || param2.Attacker.Value == null)
|
||||
return HookResult.Continue;
|
||||
|
||||
CCSPlayerPawn attackerPawn = new CCSPlayerPawn(param2.Attacker.Value.Handle);
|
||||
CCSPlayerPawn victimPawn = new CCSPlayerPawn(param.Handle);
|
||||
CCSPlayerPawn attackerPawn = new(param2.Attacker.Value.Handle);
|
||||
CCSPlayerPawn victimPawn = new(param.Handle);
|
||||
|
||||
if (attackerPawn.DesignerName != "player" || victimPawn.DesignerName != "player")
|
||||
return HookResult.Continue;
|
||||
|
|
@ -110,7 +111,7 @@ namespace jRandomSkills
|
|||
CCSPlayerController attacker = attackerPawn.Controller.Value.As<CCSPlayerController>();
|
||||
CCSPlayerController victim = victimPawn.Controller.Value.As<CCSPlayerController>();
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
if (playerInfo == null) return HookResult.Continue;
|
||||
|
||||
Debug.WriteToDebug($"{(victim.IsBot ? "Bot" : "Player")} {victim.PlayerName} took damage from {(attacker.IsBot ? "bot" : "player")} {attacker.PlayerName}.");
|
||||
|
|
@ -119,7 +120,7 @@ namespace jRandomSkills
|
|||
|
||||
public static void WriteToDebug(string message)
|
||||
{
|
||||
if (Config.config.Settings.DebugMode != true)
|
||||
if (Config.LoadedConfig.Settings.DebugMode != true)
|
||||
return;
|
||||
|
||||
string filename = $"Debug_{sessionId}.txt";
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ using static jRandomSkills.jRandomSkills;
|
|||
|
||||
namespace jRandomSkills
|
||||
{
|
||||
public static class Event
|
||||
public static partial class Event
|
||||
{
|
||||
private static jSkill_SkillInfo ctSkill = new jSkill_SkillInfo(Skills.None, Config.GetValue<string>(Skills.None, "color"), false);
|
||||
private static jSkill_SkillInfo tSkill = new jSkill_SkillInfo(Skills.None, Config.GetValue<string>(Skills.None, "color"), false);
|
||||
private static jSkill_SkillInfo allSkill = new jSkill_SkillInfo(Skills.None, Config.GetValue<string>(Skills.None, "color"), false);
|
||||
private static List<jSkill_SkillInfo> debugSkills = new List<jSkill_SkillInfo>(SkillData.Skills);
|
||||
private static jSkill_SkillInfo ctSkill = new(Skills.None, Config.GetValue<string>(Skills.None, "color"), false);
|
||||
private static jSkill_SkillInfo tSkill = new(Skills.None, Config.GetValue<string>(Skills.None, "color"), false);
|
||||
private static jSkill_SkillInfo allSkill = new(Skills.None, Config.GetValue<string>(Skills.None, "color"), false);
|
||||
private static List<jSkill_SkillInfo> debugSkills = new(SkillData.Skills);
|
||||
|
||||
public static void Load()
|
||||
{
|
||||
|
|
@ -24,7 +24,7 @@ namespace jRandomSkills
|
|||
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
|
||||
Instance.skillPlayer.Add(new jSkill_PlayerInfo
|
||||
Instance.SkillPlayer.Add(new jSkill_PlayerInfo
|
||||
{
|
||||
SteamID = player.SteamID,
|
||||
PlayerName = player.PlayerName,
|
||||
|
|
@ -39,11 +39,11 @@ namespace jRandomSkills
|
|||
+ "Original plugin created by:\n{AUTHOR1}\n"
|
||||
+ "Modified and improved by:\n{AUTHOR2}";
|
||||
string langWelcomeMsg = Localization.GetTranslation("welcome_message", "welcome");
|
||||
string welcomeMsg = Regex.IsMatch(langWelcomeMsg, @"\{AUTHOR1\}", RegexOptions.IgnoreCase) && Regex.IsMatch(langWelcomeMsg, @"\{AUTHOR2\}", RegexOptions.IgnoreCase) ? langWelcomeMsg : defaultWelcomeMsg;
|
||||
string welcomeMsg = MyRegex().IsMatch(langWelcomeMsg) && MyRegex1().IsMatch(langWelcomeMsg) ? langWelcomeMsg : defaultWelcomeMsg;
|
||||
|
||||
foreach (string line in welcomeMsg.Split("\n"))
|
||||
player.PrintToChat($" {ChatColors.Green}" + line.Replace("{PLAYER}", $" {ChatColors.Red}{player.PlayerName}{ChatColors.Green}", StringComparison.OrdinalIgnoreCase)
|
||||
.Replace("{SERVER_NAME}", $" {ChatColors.Red}{ConVar.Find("hostname").StringValue ?? "Default Server"}{ChatColors.Green}", StringComparison.OrdinalIgnoreCase)
|
||||
.Replace("{SERVER_NAME}", $" {ChatColors.Red}{ConVar.Find("hostname")?.StringValue ?? "Default Server"}{ChatColors.Green}", StringComparison.OrdinalIgnoreCase)
|
||||
.Replace("{VERSION}", $" {ChatColors.Red}v{Instance.ModuleVersion}{ChatColors.Green}", StringComparison.OrdinalIgnoreCase)
|
||||
.Replace("{SKILLS_COUNT}", $" {ChatColors.Red}{SkillData.Skills.Count - 1}{ChatColors.Green}", StringComparison.OrdinalIgnoreCase)
|
||||
.Replace("{AUTHOR1}", $" {ChatColors.Red}Jakub Bartosik (D3X){ChatColors.Green} ({ChatColors.Red}https://github.com/jakubbartosik/dRandomSkills{ChatColors.Green})", StringComparison.OrdinalIgnoreCase)
|
||||
|
|
@ -58,10 +58,10 @@ namespace jRandomSkills
|
|||
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
|
||||
var skillPlayer = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var skillPlayer = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (skillPlayer != null)
|
||||
{
|
||||
Instance.skillPlayer.Remove(skillPlayer);
|
||||
Instance.SkillPlayer.Remove(skillPlayer);
|
||||
}
|
||||
|
||||
return HookResult.Continue;
|
||||
|
|
@ -71,7 +71,7 @@ namespace jRandomSkills
|
|||
{
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
var skillPlayer = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var skillPlayer = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (skillPlayer != null)
|
||||
skillPlayer.IsDrawing = true;
|
||||
}
|
||||
|
|
@ -90,16 +90,17 @@ namespace jRandomSkills
|
|||
string skillsText = "";
|
||||
foreach (var _player in _players)
|
||||
{
|
||||
var _playerSkill = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == _player.SteamID);
|
||||
var _playerSkill = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == _player.SteamID);
|
||||
if (_playerSkill != null)
|
||||
{
|
||||
var skillInfo = SkillData.Skills.FirstOrDefault(p => p.Skill == _playerSkill.Skill);
|
||||
var specialSkillInfo = SkillData.Skills.FirstOrDefault(s => s.Skill == _playerSkill.SpecialSkill);
|
||||
skillsText += $" {ChatColors.DarkRed}{_player.PlayerName}{ChatColors.Lime}: {(_playerSkill.SpecialSkill == Skills.None ? skillInfo.Name : $"{specialSkillInfo.Name} -> {skillInfo.Name}")}\n";
|
||||
if (skillInfo == null) continue;
|
||||
skillsText += $" {ChatColors.DarkRed}{_player.PlayerName}{ChatColors.Lime}: {(_playerSkill.SpecialSkill == Skills.None || specialSkillInfo == null ? skillInfo.Name : $"{specialSkillInfo.Name} -> {skillInfo.Name}")}\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.config.Settings.SummaryAfterTheRound && !string.IsNullOrEmpty(skillsText))
|
||||
if (Config.LoadedConfig.Settings.SummaryAfterTheRound && !string.IsNullOrEmpty(skillsText))
|
||||
{
|
||||
player.PrintToChat(" ");
|
||||
player.PrintToChat($" {ChatColors.Lime}{Localization.GetTranslation("summary_start")}");
|
||||
|
|
@ -117,28 +118,28 @@ namespace jRandomSkills
|
|||
|
||||
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
|
||||
{
|
||||
Config.DefaultSkillInfo[] terroristSkills = Config.config.SkillsInfo.Where(s => s.OnlyTeam == (int)CsTeam.Terrorist).ToArray();
|
||||
Config.DefaultSkillInfo[] counterterroristSkills = Config.config.SkillsInfo.Where(s => s.OnlyTeam == (int)CsTeam.CounterTerrorist).ToArray();
|
||||
Config.DefaultSkillInfo[] allTeamsSkills = Config.config.SkillsInfo.Where(s => s.OnlyTeam == 0).ToArray();
|
||||
Config.DefaultSkillInfo[] terroristSkills = Config.LoadedConfig.SkillsInfo.Where(s => s.OnlyTeam == (int)CsTeam.Terrorist).ToArray();
|
||||
Config.DefaultSkillInfo[] counterterroristSkills = Config.LoadedConfig.SkillsInfo.Where(s => s.OnlyTeam == (int)CsTeam.CounterTerrorist).ToArray();
|
||||
Config.DefaultSkillInfo[] allTeamsSkills = Config.LoadedConfig.SkillsInfo.Where(s => s.OnlyTeam == 0).ToArray();
|
||||
|
||||
if (Config.config.Settings.GameMode == (int)Config.GameModes.TeamSkills)
|
||||
if (Config.LoadedConfig.Settings.GameMode == (int)Config.GameModes.TeamSkills)
|
||||
{
|
||||
List<jSkill_SkillInfo> tSkills = new List<jSkill_SkillInfo>(SkillData.Skills);
|
||||
List<jSkill_SkillInfo> tSkills = new(SkillData.Skills);
|
||||
tSkills.RemoveAll(s => s.Skill == tSkill.Skill || s.Skill == Skills.None || counterterroristSkills.Any(s2 => s2.Name == s.Skill.ToString()));
|
||||
tSkill = tSkills.Count == 0 ? new jSkill_SkillInfo(Skills.None, Config.GetValue<string>(Skills.None, "color"), false) : tSkills[Instance.Random.Next(tSkills.Count)];
|
||||
tSkill = tSkills.Count == 0 ? new(Skills.None, Config.GetValue<string>(Skills.None, "color"), false) : tSkills[Instance.Random.Next(tSkills.Count)];
|
||||
|
||||
List<jSkill_SkillInfo> ctSkills = new List<jSkill_SkillInfo>(SkillData.Skills);
|
||||
List<jSkill_SkillInfo> ctSkills = new(SkillData.Skills);
|
||||
ctSkills.RemoveAll(s => s.Skill == ctSkill.Skill || s.Skill == Skills.None || terroristSkills.Any(s2 => s2.Name == s.Skill.ToString()));
|
||||
ctSkill = ctSkills.Count == 0 ? new jSkill_SkillInfo(Skills.None, Config.GetValue<string>(Skills.None, "color"), false) : ctSkills[Instance.Random.Next(ctSkills.Count)];
|
||||
ctSkill = ctSkills.Count == 0 ? new(Skills.None, Config.GetValue<string>(Skills.None, "color"), false) : ctSkills[Instance.Random.Next(ctSkills.Count)];
|
||||
}
|
||||
else if (Config.config.Settings.GameMode == (int)Config.GameModes.SameSkills)
|
||||
else if (Config.LoadedConfig.Settings.GameMode == (int)Config.GameModes.SameSkills)
|
||||
{
|
||||
List<jSkill_SkillInfo> allSkills = new List<jSkill_SkillInfo>(SkillData.Skills);
|
||||
List<jSkill_SkillInfo> allSkills = new(SkillData.Skills);
|
||||
allSkills.RemoveAll(s => s.Skill == allSkill.Skill || s.Skill == Skills.None || !allTeamsSkills.Any(s2 => s2.Name == s.Skill.ToString()));
|
||||
allSkill = allSkills.Count == 0 ? new jSkill_SkillInfo(Skills.None, Config.GetValue<string>(Skills.None, "color"), false) : allSkills[Instance.Random.Next(allSkills.Count)];
|
||||
allSkill = allSkills.Count == 0 ? new(Skills.None, Config.GetValue<string>(Skills.None, "color"), false) : allSkills[Instance.Random.Next(allSkills.Count)];
|
||||
}
|
||||
else if (Config.config.Settings.GameMode == (int)Config.GameModes.Debug && debugSkills.Count == 0)
|
||||
debugSkills = new List<jSkill_SkillInfo>(SkillData.Skills);
|
||||
else if (Config.LoadedConfig.Settings.GameMode == (int)Config.GameModes.Debug && debugSkills.Count == 0)
|
||||
debugSkills = new(SkillData.Skills);
|
||||
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
|
|
@ -146,23 +147,22 @@ namespace jRandomSkills
|
|||
var teammates = Utilities.GetPlayers().Where(p => p.Team == playerTeam && p != player);
|
||||
string teammateSkills = "";
|
||||
|
||||
var skillPlayer = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
|
||||
var skillPlayer = Instance?.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (skillPlayer != null)
|
||||
{
|
||||
skillPlayer.IsDrawing = false;
|
||||
jSkill_SkillInfo randomSkill = new jSkill_SkillInfo(Skills.None, Config.GetValue<string>(Skills.None, "color"), false);
|
||||
jSkill_SkillInfo randomSkill = new(Skills.None, Config.GetValue<string>(Skills.None, "color"), false);
|
||||
|
||||
if (Instance?.GameRules?.WarmupPeriod == false)
|
||||
if (Instance?.GameRules != null && Instance?.GameRules.WarmupPeriod == false)
|
||||
{
|
||||
if (Config.config.Settings.GameMode == (int)Config.GameModes.Normal)
|
||||
if (Config.LoadedConfig.Settings.GameMode == (int)Config.GameModes.Normal)
|
||||
{
|
||||
List<jSkill_SkillInfo> skillList = new List<jSkill_SkillInfo>(SkillData.Skills);
|
||||
List<jSkill_SkillInfo> skillList = new(SkillData.Skills);
|
||||
skillList.RemoveAll(s => s?.Skill == skillPlayer?.Skill || s?.Skill == skillPlayer?.SpecialSkill || s?.Skill == Skills.None);
|
||||
|
||||
if (Utilities.GetPlayers().FindAll(p => p.Team == player.Team && p.IsValid && !p.IsBot).Count == 1)
|
||||
{
|
||||
Config.DefaultSkillInfo[] skillsNeedsTeammates = Config.config.SkillsInfo.Where(s => s.NeedsTeammates).ToArray();
|
||||
Config.DefaultSkillInfo[] skillsNeedsTeammates = Config.LoadedConfig.SkillsInfo.Where(s => s.NeedsTeammates).ToArray();
|
||||
skillList.RemoveAll(s => skillsNeedsTeammates.Any(s2 => s2.Name == s.Skill.ToString()));
|
||||
}
|
||||
|
||||
|
|
@ -173,11 +173,11 @@ namespace jRandomSkills
|
|||
|
||||
randomSkill = skillList.Count == 0 ? new jSkill_SkillInfo(Skills.None, Config.GetValue<string>(Skills.None, "color"), false) : skillList[Instance.Random.Next(skillList.Count)];
|
||||
}
|
||||
else if (Config.config.Settings.GameMode == (int)Config.GameModes.TeamSkills)
|
||||
else if (Config.LoadedConfig.Settings.GameMode == (int)Config.GameModes.TeamSkills)
|
||||
randomSkill = player.Team == CsTeam.Terrorist ? tSkill : ctSkill;
|
||||
else if (Config.config.Settings.GameMode == (int)Config.GameModes.SameSkills)
|
||||
else if (Config.LoadedConfig.Settings.GameMode == (int)Config.GameModes.SameSkills)
|
||||
randomSkill = allSkill;
|
||||
else if (Config.config.Settings.GameMode == (int)Config.GameModes.Debug)
|
||||
else if (Config.LoadedConfig.Settings.GameMode == (int)Config.GameModes.Debug)
|
||||
{
|
||||
if (debugSkills.Count == 0)
|
||||
debugSkills = new List<jSkill_SkillInfo>(SkillData.Skills);
|
||||
|
|
@ -194,17 +194,17 @@ namespace jRandomSkills
|
|||
if (randomSkill.Display)
|
||||
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{randomSkill.Name}{ChatColors.Lime}: {randomSkill.Description}", false);
|
||||
|
||||
if (Config.config.Settings.TeamMateSkillInfo)
|
||||
if (Config.LoadedConfig.Settings.TeamMateSkillInfo)
|
||||
{
|
||||
Instance.AddTimer(0.5f, () =>
|
||||
Instance?.AddTimer(0.5f, () =>
|
||||
{
|
||||
foreach (var teammate in teammates)
|
||||
{
|
||||
var teammateSkill = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == teammate.SteamID)?.Skill;
|
||||
var teammateSkill = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == teammate.SteamID)?.Skill;
|
||||
if (teammateSkill != null)
|
||||
{
|
||||
var skillInfo = SkillData.Skills.FirstOrDefault(p => p.Skill == teammateSkill);
|
||||
teammateSkills += $" {ChatColors.DarkRed}{teammate.PlayerName}{ChatColors.Lime}: {skillInfo.Name}\n";
|
||||
teammateSkills += $" {ChatColors.DarkRed}{teammate.PlayerName}{ChatColors.Lime}: {(skillInfo == null ? Skills.None : skillInfo.Name)}\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -231,14 +231,15 @@ namespace jRandomSkills
|
|||
|
||||
if (victim == null || attacker == null || victim == attacker) return HookResult.Continue;
|
||||
|
||||
if(Config.config.Settings.KillerSkillInfo)
|
||||
if(Config.LoadedConfig.Settings.KillerSkillInfo)
|
||||
{
|
||||
var attackerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
var attackerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
if (attackerInfo != null)
|
||||
{
|
||||
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == attackerInfo.Skill);
|
||||
var specialSkillData = SkillData.Skills.FirstOrDefault(s => s.Skill == attackerInfo.SpecialSkill);
|
||||
string skillDesc = skillData?.Description;
|
||||
if (skillData == null || specialSkillData == null) return HookResult.Continue;
|
||||
string skillDesc = skillData.Description;
|
||||
|
||||
SkillUtils.PrintToChat(victim, $"{Localization.GetTranslation("enemy_skill")} {ChatColors.DarkRed}{attacker.PlayerName}{ChatColors.Lime}:", false);
|
||||
SkillUtils.PrintToChat(victim, $"{ChatColors.DarkRed}{(attackerInfo.SpecialSkill == Skills.None ? skillData.Name : $"{specialSkillData.Name} -> {skillData.Name}")}{ChatColors.Lime} - {skillDesc}", false);
|
||||
|
|
@ -248,5 +249,10 @@ namespace jRandomSkills
|
|||
return HookResult.Continue;
|
||||
});
|
||||
}
|
||||
|
||||
[GeneratedRegex(@"\{AUTHOR1\}", RegexOptions.IgnoreCase, "pl-PL")]
|
||||
private static partial Regex MyRegex();
|
||||
[GeneratedRegex(@"\{AUTHOR2\}", RegexOptions.IgnoreCase, "pl-PL")]
|
||||
private static partial Regex MyRegex1();
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@ using CounterStrikeSharp.API;
|
|||
using CounterStrikeSharp.API.Core;
|
||||
using jRandomSkills.src.player;
|
||||
using jRandomSkills.src.utils;
|
||||
using System.Reflection.Metadata;
|
||||
using static CounterStrikeSharp.API.Core.Listeners;
|
||||
using static jRandomSkills.jRandomSkills;
|
||||
|
||||
|
|
@ -40,15 +39,14 @@ namespace jRandomSkills
|
|||
{
|
||||
if (Instance?.GameRules == null || Instance?.GameRules?.Handle == IntPtr.Zero)
|
||||
InitializeGameRules();
|
||||
else
|
||||
Instance.GameRules.GameRestart = Instance?.GameRules?.RestartRoundTime < Server.CurrentTime;
|
||||
else if (Instance != null)
|
||||
Instance.GameRules.GameRestart = Instance.GameRules?.RestartRoundTime < Server.CurrentTime;
|
||||
}
|
||||
|
||||
private static void UpdatePlayerHud(CCSPlayerController player)
|
||||
{
|
||||
if (player == null) return;
|
||||
|
||||
var skillPlayer = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var skillPlayer = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (skillPlayer == null) return;
|
||||
|
||||
string infoLine = "";
|
||||
|
|
@ -83,7 +81,7 @@ namespace jRandomSkills
|
|||
var observedPlayer = Utilities.GetPlayers().FirstOrDefault(p => p?.Pawn?.Value?.Handle == pawn?.ObserverServices?.ObserverTarget?.Value?.Handle);
|
||||
if (observedPlayer == null) return;
|
||||
|
||||
var observeredPlayerSkill = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == observedPlayer.SteamID);
|
||||
var observeredPlayerSkill = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == observedPlayer.SteamID);
|
||||
if (observeredPlayerSkill == null) return;
|
||||
|
||||
var observeredPlayerSkillInfo = SkillData.Skills.FirstOrDefault(s => s.Skill == observeredPlayerSkill.Skill);
|
||||
|
|
@ -97,10 +95,9 @@ namespace jRandomSkills
|
|||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(infoLine) && string.IsNullOrEmpty(skillLine))
|
||||
return;
|
||||
|
||||
if (string.IsNullOrEmpty(infoLine) && string.IsNullOrEmpty(skillLine)) return;
|
||||
var hudContent = infoLine + skillLine;
|
||||
if (player == null || !player.IsValid) return;
|
||||
player.PrintToCenterHtml(hudContent);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ namespace jRandomSkills
|
|||
CCSPlayerController attacker = attackerPawn.Controller.Value.As<CCSPlayerController>();
|
||||
CCSPlayerController victim = victimPawn.Controller.Value.As<CCSPlayerController>();
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
if (playerInfo == null) return HookResult.Continue;
|
||||
|
||||
if (attacker.PawnIsAlive)
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ namespace jRandomSkills
|
|||
public class Anomaly : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Anomaly;
|
||||
private static int maxSize = Config.GetValue<int>(skillName, "secondsInBack");
|
||||
private static float tickRate = 64;
|
||||
private static float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
|
||||
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = new Dictionary<ulong, PlayerSkillInfo>();
|
||||
private static readonly int maxSize = Config.GetValue<int>(skillName, "secondsInBack");
|
||||
private static readonly float tickRate = 64;
|
||||
private static readonly float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
|
||||
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -26,7 +26,7 @@ namespace jRandomSkills
|
|||
{
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -44,11 +44,10 @@ namespace jRandomSkills
|
|||
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
if (SkillPlayerInfo.ContainsKey(player.SteamID))
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
|
@ -57,15 +56,16 @@ namespace jRandomSkills
|
|||
{
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
if (SkillPlayerInfo.TryGetValue(player.SteamID, out var skillInfo))
|
||||
{
|
||||
UpdateHUD(player, skillInfo);
|
||||
if (Server.TickCount % tickRate != 0) return;
|
||||
var pawn = player.PlayerPawn.Value;
|
||||
if (pawn != null && pawn.IsValid)
|
||||
if (pawn != null && pawn.IsValid && pawn.AbsOrigin != null)
|
||||
{
|
||||
if (skillInfo.LastRotations == null || skillInfo.LastPositions == null) continue;
|
||||
skillInfo.LastPositions.Add(new Vector(pawn.AbsOrigin.X, pawn.AbsOrigin.Y, pawn.AbsOrigin.Z));
|
||||
skillInfo.LastRotations.Add(new QAngle(pawn.EyeAngles.X, pawn.EyeAngles.Y, pawn.EyeAngles.Z));
|
||||
if (skillInfo.LastRotations.Count > maxSize)
|
||||
|
|
@ -86,15 +86,14 @@ namespace jRandomSkills
|
|||
SteamID = player.SteamID,
|
||||
CanUse = true,
|
||||
Cooldown = DateTime.MinValue,
|
||||
LastPositions = new List<Vector>(),
|
||||
LastRotations = new List<QAngle>(),
|
||||
LastPositions = [],
|
||||
LastRotations = [],
|
||||
};
|
||||
}
|
||||
|
||||
public static void DisableSkill(CCSPlayerController player)
|
||||
{
|
||||
if (SkillPlayerInfo.ContainsKey(player.SteamID))
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
}
|
||||
|
||||
private static void UpdateHUD(CCSPlayerController player, PlayerSkillInfo skillInfo)
|
||||
|
|
@ -132,8 +131,9 @@ namespace jRandomSkills
|
|||
{
|
||||
skillInfo.CanUse = false;
|
||||
skillInfo.Cooldown = DateTime.Now;
|
||||
Vector lastPosition = skillInfo.LastPositions.FirstOrDefault();
|
||||
QAngle lastRotation = skillInfo.LastRotations.FirstOrDefault();
|
||||
if (skillInfo.LastRotations == null || skillInfo.LastRotations.Count == 0 || skillInfo.LastPositions == null || skillInfo.LastPositions.Count == 0) return;
|
||||
Vector? lastPosition = skillInfo.LastPositions.FirstOrDefault();
|
||||
QAngle? lastRotation = skillInfo.LastRotations.FirstOrDefault();
|
||||
if (lastPosition != null && lastRotation != null)
|
||||
playerPawn.Teleport(lastPosition, lastRotation, null);
|
||||
}
|
||||
|
|
@ -145,19 +145,14 @@ namespace jRandomSkills
|
|||
public ulong SteamID { get; set; }
|
||||
public bool CanUse { get; set; }
|
||||
public DateTime Cooldown { get; set; }
|
||||
public List<Vector> LastPositions { get; set; }
|
||||
public List<QAngle> LastRotations { get; set; }
|
||||
public List<Vector>? LastPositions { get; set; }
|
||||
public List<QAngle>? LastRotations { get; set; }
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#a86eff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int secondsInBack = 5, float cooldown = 15) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public int SecondsInBack { get; set; }
|
||||
public float Cooldown { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#a86eff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int secondsInBack = 5, float cooldown = 15) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
SecondsInBack = secondsInBack;
|
||||
Cooldown = cooldown;
|
||||
}
|
||||
public int SecondsInBack { get; set; } = secondsInBack;
|
||||
public float Cooldown { get; set; } = cooldown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -22,7 +22,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -35,13 +35,15 @@ namespace jRandomSkills
|
|||
{
|
||||
var player = @event.Userid;
|
||||
var attacker = @event.Attacker;
|
||||
|
||||
|
||||
if (player == null || !player.IsValid || player.LifeState != (byte)LifeState_t.LIFE_ALIVE) return HookResult.Continue;
|
||||
if (attacker == null || !attacker.IsValid) return HookResult.Continue;
|
||||
|
||||
var playerPawn = player.PlayerPawn.Value;
|
||||
if (playerPawn == null || !playerPawn.IsValid) return HookResult.Continue;
|
||||
|
||||
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var attackerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var attackerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
|
||||
if (playerInfo?.Skill == skillName)
|
||||
playerPawn.FlashDuration = 0.0f;
|
||||
|
|
@ -57,11 +59,8 @@ namespace jRandomSkills
|
|||
SkillUtils.TryGiveWeapon(player, CsItem.FlashbangGrenade);
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#D6E6FF", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#D6E6FF", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -21,11 +21,11 @@ namespace jRandomSkills
|
|||
|
||||
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim) || attacker == victim) return HookResult.Continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == victim.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == victim?.SteamID);
|
||||
|
||||
if (playerInfo?.Skill == skillName && hitgroup == (int)HitGroup_t.HITGROUP_HEAD)
|
||||
{
|
||||
ApplyIronHeadEffect(victim, @event.DmgHealth);
|
||||
ApplyIronHeadEffect(victim!, @event.DmgHealth);
|
||||
return HookResult.Stop;
|
||||
}
|
||||
|
||||
|
|
@ -36,6 +36,7 @@ namespace jRandomSkills
|
|||
private static void ApplyIronHeadEffect(CCSPlayerController victim, float damage)
|
||||
{
|
||||
var playerPawn = victim.PlayerPawn.Value;
|
||||
if (playerPawn == null || !playerPawn.IsValid) return;
|
||||
var newHealth = playerPawn.Health + damage;
|
||||
|
||||
if (newHealth > 100)
|
||||
|
|
@ -44,11 +45,8 @@ namespace jRandomSkills
|
|||
playerPawn.Health = (int)newHealth;
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#8B4513", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#8B4513", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10,6 +10,8 @@ namespace jRandomSkills
|
|||
public class AreaReaper : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.AreaReaper;
|
||||
private static readonly string[] bombsiteA = ["A", "a"];
|
||||
private static readonly string[] bombsiteB = ["B", "b"];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -22,7 +24,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -44,7 +46,7 @@ namespace jRandomSkills
|
|||
|
||||
public static void TypeSkill(CCSPlayerController player, string[] commands)
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return;
|
||||
|
||||
if (playerInfo.SkillChance == 1)
|
||||
|
|
@ -53,7 +55,7 @@ namespace jRandomSkills
|
|||
return;
|
||||
}
|
||||
|
||||
int site = new string[]{ "A", "a" }.Contains(commands[0]) ? 0 : new string[] { "B", "b" }.Contains(commands[0]) ? 1 : -1;
|
||||
int site = bombsiteA.Contains(commands[0]) ? 0 : bombsiteB.Contains(commands[0]) ? 1 : -1;
|
||||
if (site == -1) {
|
||||
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("areareaper_incorrect_site")}");
|
||||
return;
|
||||
|
|
@ -72,7 +74,8 @@ namespace jRandomSkills
|
|||
|
||||
public static void EnableSkill(CCSPlayerController player)
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo == null) return;
|
||||
playerInfo.SkillChance = 0;
|
||||
|
||||
SkillUtils.PrintToChat(player, Localization.GetTranslation("areareaper") + ":", false);
|
||||
|
|
@ -81,9 +84,11 @@ namespace jRandomSkills
|
|||
player.PrintToChat($" {ChatColors.Green}· {ChatColors.Red}/t {ChatColors.Green}B");
|
||||
}
|
||||
|
||||
#pragma warning disable IDE0060 // Usuń nieużywany parametr
|
||||
public static void DisableSkill(CCSPlayerController player)
|
||||
#pragma warning restore IDE0060 // Usuń nieużywany parametr
|
||||
{
|
||||
if (Instance.skillPlayer.FirstOrDefault(p => p.Skill == skillName) != null)
|
||||
if (Instance.SkillPlayer.FirstOrDefault(p => p.Skill == skillName) != null)
|
||||
return;
|
||||
EnableBombsite();
|
||||
}
|
||||
|
|
@ -95,11 +100,8 @@ namespace jRandomSkills
|
|||
bombTarget.AcceptInput("Enable");
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#edf5b5", CsTeam onlyTeam = CsTeam.CounterTerrorist, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#edf5b5", CsTeam onlyTeam = CsTeam.CounterTerrorist, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -27,7 +27,7 @@ namespace jRandomSkills
|
|||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -39,7 +39,8 @@ namespace jRandomSkills
|
|||
|
||||
public static void EnableSkill(CCSPlayerController player)
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo == null) return;
|
||||
|
||||
float newScale = (float)Instance.Random.NextDouble() * (Config.GetValue<float>(skillName, "ChanceTo") - Config.GetValue<float>(skillName, "ChanceFrom")) + Config.GetValue<float>(skillName, "ChanceFrom");
|
||||
playerInfo.SkillChance = newScale;
|
||||
|
|
@ -55,8 +56,8 @@ namespace jRandomSkills
|
|||
if (param == null || param.Entity == null || param2 == null || param2.Attacker == null || param2.Attacker.Value == null)
|
||||
return HookResult.Continue;
|
||||
|
||||
CCSPlayerPawn attackerPawn = new CCSPlayerPawn(param2.Attacker.Value.Handle);
|
||||
CCSPlayerPawn victimPawn = new CCSPlayerPawn(param.Handle);
|
||||
CCSPlayerPawn attackerPawn = new(param2.Attacker.Value.Handle);
|
||||
CCSPlayerPawn victimPawn = new(param.Handle);
|
||||
|
||||
if (attackerPawn.DesignerName != "player" || victimPawn.DesignerName != "player")
|
||||
return HookResult.Continue;
|
||||
|
|
@ -67,24 +68,22 @@ namespace jRandomSkills
|
|||
CCSPlayerController attacker = attackerPawn.Controller.Value.As<CCSPlayerController>();
|
||||
CCSPlayerController victim = victimPawn.Controller.Value.As<CCSPlayerController>();
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == victim.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == victim.SteamID);
|
||||
if (playerInfo == null) return HookResult.Continue;
|
||||
|
||||
if (playerInfo.Skill == skillName && victim.PawnIsAlive)
|
||||
param2.Damage *= (float)playerInfo.SkillChance;
|
||||
{
|
||||
float? skillChance = playerInfo.SkillChance;
|
||||
param2.Damage *= skillChance ?? 1f;
|
||||
}
|
||||
|
||||
return HookResult.Continue;
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#d1430a", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float chanceFrom = .65f, float chanceTo = .85f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float ChanceFrom { get; set; }
|
||||
public float ChanceTo { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#d1430a", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float chanceFrom = .65f, float chanceTo = .85f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
ChanceFrom = chanceFrom;
|
||||
ChanceTo = chanceTo;
|
||||
}
|
||||
public float ChanceFrom { get; set; } = chanceFrom;
|
||||
public float ChanceTo { get; set; } = chanceTo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -8,9 +8,9 @@ namespace jRandomSkills
|
|||
public class Assassin : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Assassin;
|
||||
private static float damageMultiplier = Config.GetValue<float>(skillName, "damageMultiplier");
|
||||
private static float toleranceDeg = Config.GetValue<float>(skillName, "toleranceDeg");
|
||||
private static string[] nades = { "inferno", "flashbang", "smokegrenade", "decoy", "hegrenade" };
|
||||
private static readonly float damageMultiplier = Config.GetValue<float>(skillName, "damageMultiplier");
|
||||
private static readonly float toleranceDeg = Config.GetValue<float>(skillName, "toleranceDeg");
|
||||
private static readonly string[] nades = ["inferno", "flashbang", "smokegrenade", "decoy", "hegrenade"];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -27,11 +27,11 @@ namespace jRandomSkills
|
|||
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim) || attacker == victim) return HookResult.Continue;
|
||||
if (nades.Contains(weapon)) return HookResult.Continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == attacker?.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return HookResult.Continue;
|
||||
|
||||
if (IsBehind(attacker, victim))
|
||||
SkillUtils.TakeHealth(victim.PlayerPawn.Value, (int)(damage * (damageMultiplier - 1f)));
|
||||
if (IsBehind(attacker!, victim!))
|
||||
SkillUtils.TakeHealth(victim!.PlayerPawn.Value, (int)(damage * (damageMultiplier - 1f)));
|
||||
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
|
@ -42,6 +42,7 @@ namespace jRandomSkills
|
|||
var attackerPawn = attacker.PlayerPawn.Value;
|
||||
var victimPawn = victim.PlayerPawn.Value;
|
||||
if (attackerPawn == null || !attackerPawn.IsValid || victimPawn == null || !victimPawn.IsValid) return false;
|
||||
if (victimPawn.AbsRotation == null || attackerPawn.AbsRotation == null) return false;
|
||||
var angles = GetAngleRange(victimPawn.AbsRotation.Y);
|
||||
return IsBeetween(angles.Item1, angles.Item2, attackerPawn.AbsRotation.Y);
|
||||
}
|
||||
|
|
@ -64,15 +65,10 @@ namespace jRandomSkills
|
|||
return (target >= a || target <= b);
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#d9d9d9", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float damageMultiplier = 2f, float toleranceDeg = 45f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float DamageMultiplier { get; set; }
|
||||
public float ToleranceDeg { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#d9d9d9", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float damageMultiplier = 2f, float toleranceDeg = 45f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
DamageMultiplier = damageMultiplier;
|
||||
ToleranceDeg = toleranceDeg;
|
||||
}
|
||||
public float DamageMultiplier { get; set; } = damageMultiplier;
|
||||
public float ToleranceDeg { get; set; } = toleranceDeg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -21,7 +21,7 @@ namespace jRandomSkills
|
|||
{
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerPawn = player.PlayerPawn.Value;
|
||||
|
||||
if (playerInfo?.Skill == skillName && playerPawn != null)
|
||||
|
|
@ -48,25 +48,22 @@ namespace jRandomSkills
|
|||
|
||||
public static void DisableSkill(CCSPlayerController player)
|
||||
{
|
||||
player.Pawn.Value.ActualGravityScale = 1;
|
||||
if (player == null || !player.IsValid || player.PlayerPawn.Value == null || !player.PlayerPawn.Value.IsValid) return;
|
||||
player.PlayerPawn.Value.ActualGravityScale = 1;
|
||||
}
|
||||
|
||||
private static void ApplyGravityModifier(CCSPlayerController player)
|
||||
{
|
||||
if (player == null || !player.IsValid || player.PlayerPawn.Value == null || !player.PlayerPawn.Value.IsValid) return;
|
||||
float gravityModifier = (float)Math.Round(Instance.Random.NextDouble() * (Config.GetValue<float>(skillName, "ChanceTo") - Config.GetValue<float>(skillName, "chanceFrom")) + Config.GetValue<float>(skillName, "chanceFrom"), 1);
|
||||
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{Localization.GetTranslation("astronaut")}{ChatColors.Lime}: " + Localization.GetTranslation("astronaut_desc2", gravityModifier), false);
|
||||
player.Pawn.Value.ActualGravityScale = gravityModifier;
|
||||
player.PlayerPawn.Value.ActualGravityScale = gravityModifier;
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#7E10AD", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float chanceFrom = .1f, float chanceTo = .7f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float ChanceFrom { get; set; }
|
||||
public float ChanceTo { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#7E10AD", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float chanceFrom = .1f, float chanceTo = .7f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
ChanceFrom = chanceFrom;
|
||||
ChanceTo = chanceTo;
|
||||
}
|
||||
public float ChanceFrom { get; set; } = chanceFrom;
|
||||
public float ChanceTo { get; set; } = chanceTo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10,10 +10,10 @@ namespace jRandomSkills
|
|||
public class Baseball : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Baseball;
|
||||
private static float speedMultipier = Config.GetValue<float>(skillName, "speedMultipier");
|
||||
private static float maxSpeed = Config.GetValue<float>(skillName, "maxSpeed");
|
||||
private static int damageDeal = Config.GetValue<int>(skillName, "damageDeal");
|
||||
private static HashSet<CDecoyProjectile> decoys = new HashSet<CDecoyProjectile>();
|
||||
private static readonly float speedMultipier = Config.GetValue<float>(skillName, "speedMultipier");
|
||||
private static readonly float maxSpeed = Config.GetValue<float>(skillName, "maxSpeed");
|
||||
private static readonly int damageDeal = Config.GetValue<int>(skillName, "damageDeal");
|
||||
private static readonly HashSet<CDecoyProjectile> decoys = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -26,7 +26,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -44,10 +44,10 @@ namespace jRandomSkills
|
|||
if (weapon != "decoy") return HookResult.Continue;
|
||||
if (!Instance.IsPlayerValid(victim) || !Instance.IsPlayerValid(attacker)) return HookResult.Continue;
|
||||
|
||||
var attackerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
var attackerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == attacker?.SteamID);
|
||||
if (attackerInfo?.Skill != skillName) return HookResult.Continue;
|
||||
|
||||
SkillUtils.TakeHealth(victim.PlayerPawn.Value, damageDeal);
|
||||
SkillUtils.TakeHealth(victim!.PlayerPawn.Value, damageDeal);
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
||||
|
|
@ -58,10 +58,15 @@ namespace jRandomSkills
|
|||
return;
|
||||
|
||||
var decoy = @event.As<CDecoyProjectile>();
|
||||
if (decoy == null || !decoy.IsValid || decoy.OwnerEntity == null || decoy.OwnerEntity.Value == null || !decoy.OwnerEntity.Value.IsValid) return;
|
||||
|
||||
var pawn = decoy.OwnerEntity.Value.As<CCSPlayerPawn>();
|
||||
if (pawn == null || !pawn.IsValid || pawn.Controller == null || pawn.Controller.Value == null || !pawn.Controller.Value.IsValid) return;
|
||||
|
||||
var player = pawn.Controller.Value.As<CCSPlayerController>();
|
||||
if (player == null || !player.IsValid) return;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return;
|
||||
decoys.Add(decoy);
|
||||
});
|
||||
|
|
@ -69,7 +74,8 @@ namespace jRandomSkills
|
|||
Instance.RegisterEventHandler<EventDecoyStarted>((@event, info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return HookResult.Continue;
|
||||
|
||||
var decoy = decoys.FirstOrDefault(d => d.Index == @event.Entityid);
|
||||
|
|
@ -86,7 +92,7 @@ namespace jRandomSkills
|
|||
{
|
||||
foreach (var decoy in decoys)
|
||||
{
|
||||
if (decoy == null || !decoy.IsValid)
|
||||
if (!decoy.IsValid)
|
||||
{
|
||||
decoys.Remove(decoy);
|
||||
continue;
|
||||
|
|
@ -114,17 +120,11 @@ namespace jRandomSkills
|
|||
SkillUtils.TryGiveWeapon(player, CsItem.DecoyGrenade);
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#2effc7", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float speedMultipier = 2f, float maxSpeed = 900f, int damageDeal = 9999) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float SpeedMultipier { get; set; }
|
||||
public float MaxSpeed { get; set; }
|
||||
public float DamageDeal { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#2effc7", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float speedMultipier = 2f, float maxSpeed = 900f, int damageDeal = 9999) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
SpeedMultipier = speedMultipier;
|
||||
MaxSpeed = maxSpeed;
|
||||
DamageDeal = damageDeal;
|
||||
}
|
||||
public float SpeedMultipier { get; set; } = speedMultipier;
|
||||
public float MaxSpeed { get; set; } = maxSpeed;
|
||||
public float DamageDeal { get; set; } = damageDeal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ namespace jRandomSkills
|
|||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -40,9 +40,9 @@ namespace jRandomSkills
|
|||
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim) || attacker == victim)
|
||||
return HookResult.Continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == attacker?.SteamID);
|
||||
|
||||
if (playerInfo?.Skill == skillName && victim.PawnIsAlive)
|
||||
if (playerInfo?.Skill == skillName && victim!.PawnIsAlive)
|
||||
{
|
||||
if (Instance.Random.NextDouble() <= playerInfo.SkillChance)
|
||||
RotateEnemy(victim);
|
||||
|
|
@ -54,7 +54,8 @@ namespace jRandomSkills
|
|||
|
||||
public static void EnableSkill(CCSPlayerController player)
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo == null) return;
|
||||
float newChance = (float)Instance.Random.NextDouble() * (Config.GetValue<float>(skillName, "ChanceTo") - Config.GetValue<float>(skillName, "ChanceFrom")) + Config.GetValue<float>(skillName, "ChanceFrom");
|
||||
playerInfo.SkillChance = newChance;
|
||||
newChance = (float)Math.Round(newChance, 2) * 100;
|
||||
|
|
@ -64,30 +65,27 @@ namespace jRandomSkills
|
|||
|
||||
private static void RotateEnemy(CCSPlayerController player)
|
||||
{
|
||||
if (player.PlayerPawn.Value.LifeState != (int)LifeState_t.LIFE_ALIVE)
|
||||
return;
|
||||
if (player == null || !player.IsValid) return;
|
||||
var pawn = player.PlayerPawn.Value;
|
||||
|
||||
var currentPosition = player.PlayerPawn.Value.AbsOrigin;
|
||||
var currentAngles = player.PlayerPawn.Value.EyeAngles;
|
||||
if (pawn == null || !pawn.IsValid || pawn.LifeState != (int)LifeState_t.LIFE_ALIVE) return;
|
||||
|
||||
QAngle newAngles = new QAngle(
|
||||
var currentPosition = pawn.AbsOrigin;
|
||||
var currentAngles = pawn.EyeAngles;
|
||||
|
||||
QAngle newAngles = new(
|
||||
currentAngles.X,
|
||||
currentAngles.Y + 180,
|
||||
currentAngles.Z
|
||||
);
|
||||
|
||||
player.PlayerPawn.Value.Teleport(currentPosition, newAngles, new Vector(0, 0, 0));
|
||||
pawn.Teleport(currentPosition, newAngles, new Vector(0, 0, 0));
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#00FF00", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float chanceFrom = .2f, float chanceTo = .4f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float ChanceFrom { get; set; }
|
||||
public float ChanceTo { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#00FF00", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float chanceFrom = .2f, float chanceTo = .4f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
ChanceFrom = chanceFrom;
|
||||
ChanceTo = chanceTo;
|
||||
}
|
||||
public float ChanceFrom { get; set; } = chanceFrom;
|
||||
public float ChanceTo { get; set; } = chanceTo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,9 +9,9 @@ namespace jRandomSkills
|
|||
public class BladeMaster : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.BladeMaster;
|
||||
private static string[] noReflectionWeapon = { "inferno", "flashbang", "smokegrenade", "decoy", "hegrenade", "knife", "taser" };
|
||||
private static float torseReflectionChance = Config.GetValue<float>(skillName, "torseReflectionChance") * 100;
|
||||
private static float legReflectionChance = Config.GetValue<float>(skillName, "legReflectionChance") * 100;
|
||||
private static readonly string[] noReflectionWeapon = ["inferno", "flashbang", "smokegrenade", "decoy", "hegrenade", "knife", "taser"];
|
||||
private static readonly float torseReflectionChance = Config.GetValue<float>(skillName, "torseReflectionChance") * 100;
|
||||
private static readonly float legReflectionChance = Config.GetValue<float>(skillName, "legReflectionChance") * 100;
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -25,7 +25,7 @@ namespace jRandomSkills
|
|||
string weapon = @event.Weapon;
|
||||
|
||||
if (noReflectionWeapon.Contains(weapon) || !Instance.IsPlayerValid(victim)) return HookResult.Continue;
|
||||
var victimInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == victim.SteamID);
|
||||
var victimInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == victim?.SteamID);
|
||||
if (victimInfo == null || victimInfo.Skill != skillName) return HookResult.Continue;
|
||||
|
||||
int chance = Instance.Random.Next(0, 101);
|
||||
|
|
@ -38,11 +38,12 @@ namespace jRandomSkills
|
|||
if (chance > torseReflectionChance)
|
||||
return HookResult.Continue;
|
||||
|
||||
var pawn = victim.PlayerPawn.Value;
|
||||
var pawn = victim!.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid) return HookResult.Continue;
|
||||
|
||||
var activeWeapon = pawn.WeaponServices.ActiveWeapon.Value;
|
||||
if (activeWeapon == null || !activeWeapon.IsValid || activeWeapon.DesignerName != "weapon_knife") return HookResult.Continue;
|
||||
var weaponServices = pawn.WeaponServices;
|
||||
if (weaponServices == null) return HookResult.Continue;
|
||||
if (weaponServices.ActiveWeapon == null || !weaponServices.ActiveWeapon.IsValid || weaponServices.ActiveWeapon.Value == null || !weaponServices.ActiveWeapon.Value.IsValid || weaponServices.ActiveWeapon.Value.DesignerName != "weapon_knife") return HookResult.Continue;
|
||||
|
||||
RestoreHealth(victim, damage);
|
||||
return HookResult.Stop;
|
||||
|
|
@ -52,6 +53,7 @@ namespace jRandomSkills
|
|||
private static void RestoreHealth(CCSPlayerController victim, float damage)
|
||||
{
|
||||
var playerPawn = victim.PlayerPawn.Value;
|
||||
if (playerPawn == null || !playerPawn.IsValid || playerPawn.LifeState != (byte)LifeState_t.LIFE_ALIVE) return;
|
||||
var newHealth = playerPawn.Health + damage;
|
||||
|
||||
if (newHealth > 100)
|
||||
|
|
@ -61,15 +63,10 @@ namespace jRandomSkills
|
|||
Utilities.SetStateChanged(playerPawn, "CBaseEntity", "m_iHealth");
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#cc7504", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float torseReflectionChance = .95f, float legReflectionChance = .80f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float TorseReflectionChance { get; set; }
|
||||
public float LegReflectionChance { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#cc7504", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float torseReflectionChance = .95f, float legReflectionChance = .80f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
TorseReflectionChance = torseReflectionChance;
|
||||
LegReflectionChance = legReflectionChance;
|
||||
}
|
||||
public float TorseReflectionChance { get; set; } = torseReflectionChance;
|
||||
public float LegReflectionChance { get; set; } = legReflectionChance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -24,7 +24,7 @@ namespace jRandomSkills
|
|||
{
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
GiveBunnyHop(player);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ namespace jRandomSkills
|
|||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerPawn = player.PlayerPawn?.Value;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -37,9 +37,9 @@ namespace jRandomSkills
|
|||
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
if (!player.IsValid || player.PlayerPawn.Value == null) return HookResult.Continue;
|
||||
if (player == null || !player.IsValid || player.PlayerPawn.Value == null) return HookResult.Continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
DisableSkill(player);
|
||||
|
||||
|
|
@ -50,9 +50,9 @@ namespace jRandomSkills
|
|||
{
|
||||
var player = @event.Userid;
|
||||
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player?.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return HookResult.Continue;
|
||||
EnableSkill(player);
|
||||
EnableSkill(player!);
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
||||
|
|
@ -62,18 +62,18 @@ namespace jRandomSkills
|
|||
var weapon = @event.Item;
|
||||
|
||||
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player?.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return HookResult.Continue;
|
||||
|
||||
if (weapon == "c4")
|
||||
{
|
||||
SetPlayerVisibility(player, false);
|
||||
SetWeaponVisibility(player, false);
|
||||
SetPlayerVisibility(player!, false);
|
||||
SetWeaponVisibility(player!, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetPlayerVisibility(player, true);
|
||||
SetWeaponVisibility(player, true);
|
||||
SetPlayerVisibility(player!, true);
|
||||
SetWeaponVisibility(player!, true);
|
||||
}
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
|
@ -81,8 +81,16 @@ namespace jRandomSkills
|
|||
|
||||
public static void EnableSkill(CCSPlayerController player)
|
||||
{
|
||||
var activeWeapon = player.PlayerPawn.Value.WeaponServices.ActiveWeapon.Value;
|
||||
if (activeWeapon == null || !activeWeapon.IsValid || activeWeapon.DesignerName != "weapon_c4") return;
|
||||
if (player == null || !player.IsValid) return;
|
||||
var playerPawn = player.PlayerPawn.Value;
|
||||
|
||||
if (playerPawn == null || !playerPawn.IsValid) return;
|
||||
if (playerPawn.WeaponServices == null || playerPawn.WeaponServices.ActiveWeapon == null || !playerPawn.WeaponServices.ActiveWeapon.IsValid) return;
|
||||
if (playerPawn.WeaponServices.ActiveWeapon.Value == null || !playerPawn.WeaponServices.ActiveWeapon.Value.IsValid) return;
|
||||
|
||||
var activeWeapon = playerPawn.WeaponServices.ActiveWeapon.Value;
|
||||
if (activeWeapon.DesignerName != "weapon_c4") return;
|
||||
|
||||
SetPlayerVisibility(player, false);
|
||||
SetWeaponVisibility(player, false);
|
||||
}
|
||||
|
|
@ -97,7 +105,7 @@ namespace jRandomSkills
|
|||
private static void SetPlayerVisibility(CCSPlayerController player, bool enabled)
|
||||
{
|
||||
var playerPawn = player.PlayerPawn.Value;
|
||||
if (playerPawn != null)
|
||||
if (playerPawn != null && playerPawn.IsValid)
|
||||
{
|
||||
var color = Color.FromArgb(enabled ? 255 : 0, 255, 255, 255);
|
||||
playerPawn.Render = color;
|
||||
|
|
@ -109,10 +117,12 @@ namespace jRandomSkills
|
|||
{
|
||||
if (!Instance.IsPlayerValid(player)) return;
|
||||
var playerPawn = player.PlayerPawn.Value;
|
||||
if (playerPawn == null || !playerPawn.IsValid) return;
|
||||
var weaponServices = playerPawn.WeaponServices;
|
||||
if (weaponServices == null) return;
|
||||
|
||||
var color = Color.FromArgb(enabled ? 255 : 0, 255, 255, 255);
|
||||
|
||||
foreach (var weapon in playerPawn.WeaponServices?.MyWeapons)
|
||||
foreach (var weapon in weaponServices.MyWeapons)
|
||||
{
|
||||
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
|
||||
{
|
||||
|
|
@ -122,11 +132,8 @@ namespace jRandomSkills
|
|||
}
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#00911f", CsTeam onlyTeam = CsTeam.Terrorist, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#00911f", CsTeam onlyTeam = CsTeam.Terrorist, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ namespace jRandomSkills
|
|||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -38,9 +38,9 @@ namespace jRandomSkills
|
|||
var victim = @event.Userid;
|
||||
|
||||
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim) || attacker == victim) return HookResult.Continue;
|
||||
var attackerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
var attackerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == attacker?.SteamID);
|
||||
|
||||
if (attackerInfo?.Skill == skillName && victim.PawnIsAlive)
|
||||
if (attackerInfo?.Skill == skillName && victim!.PawnIsAlive)
|
||||
{
|
||||
if (Instance.Random.NextDouble() <= attackerInfo.SkillChance)
|
||||
{
|
||||
|
|
@ -58,7 +58,8 @@ namespace jRandomSkills
|
|||
|
||||
public static void EnableSkill(CCSPlayerController player)
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo == null) return;
|
||||
float newChance = (float)Instance.Random.NextDouble() * (Config.GetValue<float>(skillName, "chanceTo") - Config.GetValue<float>(skillName, "chanceFrom")) + Config.GetValue<float>(skillName, "chanceFrom");
|
||||
playerInfo.SkillChance = newChance;
|
||||
newChance = (float)Math.Round(newChance, 2) * 100;
|
||||
|
|
@ -66,15 +67,10 @@ namespace jRandomSkills
|
|||
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{Localization.GetTranslation("catapult")}{ChatColors.Lime}: " + Localization.GetTranslation("catapult_desc2", newChance), false);
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#FF4500", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float chanceFrom = .2f, float chanceTo = .4f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float ChanceFrom { get; set; }
|
||||
public float ChanceTo { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#FF4500", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float chanceFrom = .2f, float chanceTo = .4f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
ChanceFrom = chanceFrom;
|
||||
ChanceTo = chanceTo;
|
||||
}
|
||||
public float ChanceFrom { get; set; } = chanceFrom;
|
||||
public float ChanceTo { get; set; } = chanceTo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -13,35 +13,17 @@ namespace jRandomSkills
|
|||
{
|
||||
private const Skills skillName = Skills.Chicken;
|
||||
private static bool roundEnd = false;
|
||||
private static string[] disabledWeapons =
|
||||
{
|
||||
"weapon_ak47",
|
||||
"weapon_m4a4",
|
||||
"weapon_m4a1",
|
||||
"weapon_m4a1_silencer",
|
||||
"weapon_famas",
|
||||
"weapon_galilar",
|
||||
"weapon_aug",
|
||||
"weapon_sg553",
|
||||
"weapon_mp9",
|
||||
"weapon_mac10",
|
||||
"weapon_bizon",
|
||||
"weapon_mp7",
|
||||
"weapon_ump45",
|
||||
"weapon_p90",
|
||||
"weapon_mp5sd",
|
||||
"weapon_ssg08",
|
||||
"weapon_awp",
|
||||
"weapon_scar20",
|
||||
"weapon_g3sg1",
|
||||
"weapon_nova",
|
||||
"weapon_xm1014",
|
||||
"weapon_mag7",
|
||||
"weapon_sawedoff",
|
||||
"weapon_m249",
|
||||
private static readonly string[] disabledWeapons =
|
||||
[
|
||||
"weapon_ak47", "weapon_m4a4", "weapon_m4a1", "weapon_m4a1_silencer",
|
||||
"weapon_famas", "weapon_galilar", "weapon_aug", "weapon_sg553",
|
||||
"weapon_mp9", "weapon_mac10", "weapon_bizon", "weapon_mp7",
|
||||
"weapon_ump45", "weapon_p90", "weapon_mp5sd", "weapon_ssg08",
|
||||
"weapon_awp", "weapon_scar20", "weapon_g3sg1", "weapon_nova",
|
||||
"weapon_xm1014", "weapon_mag7", "weapon_sawedoff", "weapon_m249",
|
||||
"weapon_negev"
|
||||
};
|
||||
private static Dictionary<CCSPlayerController, CBaseModelEntity> chickens = new Dictionary<CCSPlayerController, CBaseModelEntity>();
|
||||
];
|
||||
private static readonly Dictionary<CCSPlayerController, CBaseModelEntity> chickens = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -55,7 +37,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -70,7 +52,7 @@ namespace jRandomSkills
|
|||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
DisableSkill(player);
|
||||
}
|
||||
|
|
@ -81,9 +63,9 @@ namespace jRandomSkills
|
|||
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
if (!player.IsValid || player.PlayerPawn.Value == null) return HookResult.Continue;
|
||||
if (player == null || !player.IsValid || player.PlayerPawn.Value == null) return HookResult.Continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
DisableSkill(player);
|
||||
|
||||
|
|
@ -93,7 +75,8 @@ namespace jRandomSkills
|
|||
Instance.RegisterEventHandler<EventItemPickup>((@event, info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return HookResult.Continue;
|
||||
SetWeaponAttack(player, true);
|
||||
return HookResult.Continue;
|
||||
|
|
@ -112,13 +95,14 @@ namespace jRandomSkills
|
|||
public static void EnableSkill(CCSPlayerController player)
|
||||
{
|
||||
var playerPawn = player.PlayerPawn?.Value;
|
||||
if (playerPawn != null)
|
||||
if (playerPawn != null && playerPawn.IsValid)
|
||||
{
|
||||
playerPawn.VelocityModifier = 1.1f;
|
||||
|
||||
playerPawn.Health = 50;
|
||||
Utilities.SetStateChanged(playerPawn, "CBaseEntity", "m_iHealth");
|
||||
|
||||
if (playerPawn.CBodyComponent == null || playerPawn.CBodyComponent.SceneNode == null) return;
|
||||
playerPawn.CBodyComponent.SceneNode.Scale = 0.2f;
|
||||
Utilities.SetStateChanged(playerPawn, "CBaseEntity", "m_CBodyComponent");
|
||||
|
||||
|
|
@ -141,6 +125,7 @@ namespace jRandomSkills
|
|||
playerPawn.Health += 50;
|
||||
Utilities.SetStateChanged(playerPawn, "CBaseEntity", "m_iHealth");
|
||||
|
||||
if (playerPawn.CBodyComponent == null || playerPawn.CBodyComponent.SceneNode == null) return;
|
||||
playerPawn.CBodyComponent.SceneNode.Scale = 1f;
|
||||
Utilities.SetStateChanged(playerPawn, "CBaseEntity", "m_CBodyComponent");
|
||||
|
||||
|
|
@ -163,11 +148,11 @@ namespace jRandomSkills
|
|||
{
|
||||
if (roundEnd || player == null || !player.IsValid) return;
|
||||
var pawn = player?.PlayerPawn?.Value;
|
||||
if (pawn == null || !pawn.IsValid) return;
|
||||
if (pawn == null || !pawn.IsValid || pawn.WeaponServices == null || pawn.WeaponServices.MyWeapons == null) return;
|
||||
|
||||
foreach (var weapon in pawn?.WeaponServices?.MyWeapons)
|
||||
foreach (var weapon in pawn.WeaponServices.MyWeapons)
|
||||
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
|
||||
if (disabledWeapons.Contains(weapon?.Value?.DesignerName))
|
||||
if (disabledWeapons.Contains(weapon.Value.DesignerName))
|
||||
{
|
||||
weapon.Value.NextPrimaryAttackTick = disableWeapon ? int.MaxValue : Server.TickCount;
|
||||
weapon.Value.NextSecondaryAttackTick = disableWeapon ? int.MaxValue : Server.TickCount;
|
||||
|
|
@ -180,10 +165,11 @@ namespace jRandomSkills
|
|||
private static void CreateChicken(CCSPlayerController player)
|
||||
{
|
||||
var playerPawn = player.PlayerPawn.Value;
|
||||
if (playerPawn == null || !playerPawn.IsValid) return;
|
||||
var chickenModel = Utilities.CreateEntityByName<CDynamicProp>("prop_dynamic");
|
||||
if (chickenModel == null)
|
||||
return;
|
||||
Vector pos = new Vector(0, 0, 0);
|
||||
Vector pos = new(0, 0, 0);
|
||||
|
||||
chickenModel.CBodyComponent!.SceneNode!.Owner!.Entity!.Flags = (uint)(chickenModel.CBodyComponent!.SceneNode!.Owner!.Entity!.Flags & ~(1 << 2));
|
||||
chickenModel.SetModel("models/chicken/chicken.vmdl");
|
||||
|
|
@ -195,22 +181,22 @@ namespace jRandomSkills
|
|||
Instance.AddTimer(1f, () => chickens.TryAdd(player, chickenModel));
|
||||
}
|
||||
|
||||
private static async void OnTick()
|
||||
private static void OnTick()
|
||||
{
|
||||
foreach (var valuePair in chickens)
|
||||
{
|
||||
var player = valuePair.Key;
|
||||
var chicken = valuePair.Value;
|
||||
if (player == null || !player.IsValid) continue;
|
||||
if (chicken == null && !chicken.IsValid) continue;
|
||||
if (chicken == null || !chicken.IsValid) continue;
|
||||
|
||||
var pawn = player.Pawn.Value;
|
||||
if (pawn == null && !pawn.IsValid) continue;
|
||||
if (pawn == null || !pawn.IsValid || pawn.AbsOrigin == null || chicken.AbsOrigin == null) continue;
|
||||
|
||||
float X = (float)Math.Round(pawn.AbsOrigin.X, 2);
|
||||
float Y = (float)Math.Round(pawn.AbsOrigin.Y, 2);
|
||||
float Z = (float)Math.Round(pawn.AbsOrigin.Z, 2);
|
||||
Vector pos = new Vector(X, Y, Z);
|
||||
Vector pos = new(X, Y, Z);
|
||||
if (chicken.AbsOrigin.X != pos.X || chicken.AbsOrigin.Y != pos.Y || chicken.AbsOrigin.Z != pos.Z)
|
||||
chicken.Teleport(pos, pawn.AbsRotation, null);
|
||||
UpdateHUD(player);
|
||||
|
|
@ -219,10 +205,14 @@ namespace jRandomSkills
|
|||
|
||||
private static void UpdateHUD(CCSPlayerController player)
|
||||
{
|
||||
if (player == null || !player.IsValid || player.PlayerPawn.Value == null || !player.PlayerPawn.Value.IsValid) return;
|
||||
var pawn = player.PlayerPawn.Value;
|
||||
if (pawn.WeaponServices == null || pawn.WeaponServices.ActiveWeapon == null || !pawn.WeaponServices.ActiveWeapon.IsValid || pawn.WeaponServices.ActiveWeapon.Value == null || !pawn.WeaponServices.ActiveWeapon.Value.IsValid) return;
|
||||
|
||||
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == skillName);
|
||||
if (skillData == null) return;
|
||||
|
||||
var weapon = player.PlayerPawn.Value.WeaponServices.ActiveWeapon.Value;
|
||||
var weapon = pawn.WeaponServices.ActiveWeapon.Value;
|
||||
if (weapon == null || !disabledWeapons.Contains(weapon.DesignerName)) return;
|
||||
|
||||
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
|
||||
|
|
@ -233,11 +223,8 @@ namespace jRandomSkills
|
|||
player.PrintToCenterHtml(hudContent);
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#FF8B42", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#FF8B42", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@ namespace jRandomSkills
|
|||
public class ChillOut : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.ChillOut;
|
||||
private static float bombArmedTime = Config.GetValue<float>(skillName, "bombArmedTime");
|
||||
private static readonly float bombArmedTime = Config.GetValue<float>(skillName, "bombArmedTime");
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -21,12 +21,12 @@ namespace jRandomSkills
|
|||
|
||||
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
|
||||
|
||||
var anyChillOut = Instance.skillPlayer.FirstOrDefault(p => p.Skill == skillName);
|
||||
var anyChillOut = Instance.SkillPlayer.FirstOrDefault(p => p.Skill == skillName);
|
||||
if (anyChillOut != null)
|
||||
{
|
||||
var bombEntities = Utilities.FindAllEntitiesByDesignerName<CC4>("weapon_c4").ToList();
|
||||
|
||||
if (bombEntities.Any())
|
||||
if (bombEntities.Count != 0)
|
||||
{
|
||||
var bomb = bombEntities.FirstOrDefault();
|
||||
if (bomb != null)
|
||||
|
|
@ -38,13 +38,9 @@ namespace jRandomSkills
|
|||
});
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#343deb", CsTeam onlyTeam = CsTeam.CounterTerrorist, bool needsTeammates = false, float bombArmedTime = 10f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float BombArmedTime { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#343deb", CsTeam onlyTeam = CsTeam.CounterTerrorist, bool needsTeammates = false, float bombArmedTime = 10f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
BombArmedTime = bombArmedTime;
|
||||
}
|
||||
public float BombArmedTime { get; set; } = bombArmedTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -22,20 +22,17 @@ namespace jRandomSkills
|
|||
|
||||
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim) || attacker == victim) return HookResult.Continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == attacker?.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return HookResult.Continue;
|
||||
|
||||
if (weapon == "knife")
|
||||
SkillUtils.TakeHealth(victim.PlayerPawn.Value, 9999);
|
||||
SkillUtils.TakeHealth(victim!.PlayerPawn.Value, 9999);
|
||||
return HookResult.Continue;
|
||||
});
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#88a31a", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#88a31a", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10,9 +10,9 @@ namespace jRandomSkills
|
|||
public class Darkness : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Darkness;
|
||||
private static float brightness = Config.GetValue<float>(skillName, "brightness");
|
||||
private static Dictionary<CCSPlayerController, CPostProcessingVolume> deafultPostProcessing = new Dictionary<CCSPlayerController, CPostProcessingVolume>();
|
||||
private static List<CPostProcessingVolume> newPostProcessing = new List<CPostProcessingVolume>();
|
||||
private static readonly float brightness = Config.GetValue<float>(skillName, "brightness");
|
||||
private static readonly Dictionary<CCSPlayerController, CPostProcessingVolume> deafultPostProcessing = [];
|
||||
private static readonly List<CPostProcessingVolume> newPostProcessing = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -25,7 +25,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -46,7 +46,9 @@ namespace jRandomSkills
|
|||
|
||||
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
|
||||
{
|
||||
SetUpPostProcessing(@event.Userid, true);
|
||||
var player = @event.Userid;
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
SetUpPostProcessing(player, true);
|
||||
return HookResult.Continue;
|
||||
});
|
||||
}
|
||||
|
|
@ -54,7 +56,7 @@ namespace jRandomSkills
|
|||
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);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return;
|
||||
|
||||
if (playerInfo.SkillChance == 1)
|
||||
|
|
@ -80,7 +82,8 @@ namespace jRandomSkills
|
|||
|
||||
public static void EnableSkill(CCSPlayerController player)
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo == null) return;
|
||||
playerInfo.SkillChance = 0;
|
||||
|
||||
SkillUtils.PrintToChat(player, Localization.GetTranslation("darkness") + ":", false);
|
||||
|
|
@ -104,11 +107,18 @@ namespace jRandomSkills
|
|||
|
||||
private static void SetUpPostProcessing(CCSPlayerController player, bool dontCreateNew = false)
|
||||
{
|
||||
if (player == null || !player.IsValid) return;
|
||||
var pawn = player.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid || pawn.CameraServices == null) return;
|
||||
|
||||
var postProcessingVolumes = pawn.CameraServices.PostProcessingVolumes.FirstOrDefault();
|
||||
if (postProcessingVolumes == null || postProcessingVolumes.Value == null) return;
|
||||
|
||||
if (deafultPostProcessing.TryGetValue(player, out var oldPostProcessing))
|
||||
{
|
||||
player.PlayerPawn.Value.CameraServices.PostProcessingVolumes.FirstOrDefault().Raw = oldPostProcessing.EntityHandle.Raw;
|
||||
postProcessingVolumes.Raw = oldPostProcessing.EntityHandle.Raw;
|
||||
deafultPostProcessing.Remove(player);
|
||||
Utilities.SetStateChanged(player.PlayerPawn.Value, "CBasePlayerPawn", "m_pCameraServices");
|
||||
Utilities.SetStateChanged(pawn, "CBasePlayerPawn", "m_pCameraServices");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -116,21 +126,19 @@ namespace jRandomSkills
|
|||
return;
|
||||
|
||||
var postProcessing = Utilities.CreateEntityByName<CPostProcessingVolume>("post_processing_volume");
|
||||
if (postProcessing == null) return;
|
||||
|
||||
postProcessing.ExposureControl = true;
|
||||
postProcessing.MaxExposure = brightness;
|
||||
postProcessing.MinExposure = brightness;
|
||||
deafultPostProcessing.TryAdd(player, player.PlayerPawn.Value.CameraServices.PostProcessingVolumes.FirstOrDefault().Value);
|
||||
player.PlayerPawn.Value.CameraServices.PostProcessingVolumes.FirstOrDefault().Raw = postProcessing.EntityHandle.Raw;
|
||||
Utilities.SetStateChanged(player.PlayerPawn.Value, "CBasePlayerPawn", "m_pCameraServices");
|
||||
deafultPostProcessing.TryAdd(player, postProcessingVolumes.Value);
|
||||
postProcessingVolumes.Raw = postProcessing.EntityHandle.Raw;
|
||||
Utilities.SetStateChanged(pawn, "CBasePlayerPawn", "m_pCameraServices");
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#383838", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float brightness = .01f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float Brightness { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#383838", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float brightness = .01f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
Brightness = brightness;
|
||||
}
|
||||
public float Brightness { get; set; } = brightness;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -22,7 +22,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ namespace jRandomSkills
|
|||
{
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
DisableSkill(player);
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ namespace jRandomSkills
|
|||
{
|
||||
if (player == null) return;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return;
|
||||
|
||||
var playerPawn = player.PlayerPawn.Value;
|
||||
|
|
@ -76,9 +76,10 @@ namespace jRandomSkills
|
|||
{
|
||||
foreach (var enemy in enemies)
|
||||
{
|
||||
var enemyInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == enemy.SteamID);
|
||||
var enemyInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == enemy.SteamID);
|
||||
if (enemyInfo == null) continue;
|
||||
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == enemyInfo.Skill);
|
||||
if (skillData == null) continue;
|
||||
player.PrintToChat($" {ChatColors.Green}⠀⠀⠀[{ChatColors.Red}{enemy.Index}{ChatColors.Green}] {enemy.PlayerName}: {ChatColors.Red}{skillData.Name}");
|
||||
}
|
||||
}
|
||||
|
|
@ -89,14 +90,15 @@ namespace jRandomSkills
|
|||
|
||||
public static void DisableSkill(CCSPlayerController player)
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo == null) return;
|
||||
playerInfo.SpecialSkill = Skills.None;
|
||||
}
|
||||
|
||||
private static void DeacitvateSkill(CCSPlayerController player, CCSPlayerController enemy)
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var enemyInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == enemy.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var enemyInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == enemy.SteamID);
|
||||
|
||||
if (playerInfo != null)
|
||||
{
|
||||
|
|
@ -107,18 +109,15 @@ namespace jRandomSkills
|
|||
|
||||
if (enemyInfo != null)
|
||||
{
|
||||
Instance.SkillAction(enemyInfo.Skill.ToString(), "DisableSkill", new object[] { enemy });
|
||||
Instance.SkillAction(enemyInfo.Skill.ToString(), "DisableSkill", [enemy]);
|
||||
enemyInfo.SpecialSkill = enemyInfo.Skill;
|
||||
enemyInfo.Skill = Skills.None;
|
||||
enemy.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("deactivator_enemy_info"));
|
||||
}
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#919191", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#919191", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ namespace jRandomSkills
|
|||
public class Deaf : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Deaf;
|
||||
private static HashSet<CCSPlayerController> deafPlayers = new HashSet<CCSPlayerController>();
|
||||
private static readonly HashSet<CCSPlayerController> deafPlayers = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -24,7 +24,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -35,7 +35,9 @@ namespace jRandomSkills
|
|||
|
||||
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
|
||||
{
|
||||
DisableSkill(@event.Userid);
|
||||
var player = @event.Userid;
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
DisableSkill(player);
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
||||
|
|
@ -61,7 +63,7 @@ namespace jRandomSkills
|
|||
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);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return;
|
||||
|
||||
if (playerInfo.SkillChance == 1)
|
||||
|
|
@ -87,7 +89,8 @@ namespace jRandomSkills
|
|||
|
||||
public static void EnableSkill(CCSPlayerController player)
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo == null) return;
|
||||
playerInfo.SkillChance = 0;
|
||||
|
||||
SkillUtils.PrintToChat(player, Localization.GetTranslation("deaf") + ":", false);
|
||||
|
|
@ -109,11 +112,8 @@ namespace jRandomSkills
|
|||
deafPlayers.Remove(player);
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#dae01f", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#dae01f", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ namespace jRandomSkills
|
|||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -38,9 +38,9 @@ namespace jRandomSkills
|
|||
var victim = @event.Userid;
|
||||
|
||||
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim) || attacker == victim) return HookResult.Continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == attacker?.SteamID);
|
||||
|
||||
if (playerInfo?.Skill == skillName && victim.PawnIsAlive)
|
||||
if (playerInfo?.Skill == skillName && victim!.PawnIsAlive)
|
||||
{
|
||||
if (Instance.Random.NextDouble() <= playerInfo.SkillChance)
|
||||
{
|
||||
|
|
@ -59,7 +59,8 @@ namespace jRandomSkills
|
|||
|
||||
public static void EnableSkill(CCSPlayerController player)
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo == null) return;
|
||||
float newChance = (float)Instance.Random.NextDouble() * (Config.GetValue<float>(skillName, "chanceTo") - Config.GetValue<float>(skillName, "chanceFrom")) + Config.GetValue<float>(skillName, "chanceFrom");
|
||||
playerInfo.SkillChance = newChance;
|
||||
newChance = (float)Math.Round(newChance, 2) * 100;
|
||||
|
|
@ -67,15 +68,10 @@ namespace jRandomSkills
|
|||
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{Localization.GetTranslation("disarmament")}{ChatColors.Lime}: " + Localization.GetTranslation("disarmament_desc2", newChance), false);
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#FF4500", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float chanceFrom = .2f, float chanceTo = .5f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float ChanceFrom { get; set; }
|
||||
public float ChanceTo { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#FF4500", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float chanceFrom = .2f, float chanceTo = .5f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
ChanceFrom = chanceFrom;
|
||||
ChanceTo = chanceTo;
|
||||
}
|
||||
public float ChanceFrom { get; set; } = chanceFrom;
|
||||
public float ChanceTo { get; set; } = chanceTo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ namespace jRandomSkills
|
|||
public class Distancer : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Distancer;
|
||||
private static HashSet<CCSPlayerController> distancerPlayers = new HashSet<CCSPlayerController>();
|
||||
private static readonly HashSet<CCSPlayerController> distancerPlayers = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -23,7 +23,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -60,7 +60,7 @@ namespace jRandomSkills
|
|||
{
|
||||
var enemyPawn = enemy.PlayerPawn.Value;
|
||||
if (enemyPawn == null || !enemyPawn.IsValid) continue;
|
||||
if (enemyPawn.LifeState != (byte)LifeState_t.LIFE_ALIVE) continue;
|
||||
if (enemyPawn.LifeState != (byte)LifeState_t.LIFE_ALIVE || playerPawn.AbsOrigin == null || enemyPawn.AbsOrigin == null) continue;
|
||||
double distance = (int)SkillUtils.GetDistance(playerPawn.AbsOrigin, enemyPawn.AbsOrigin);
|
||||
if (distance >= closetDistance) continue;
|
||||
closetDistance = distance;
|
||||
|
|
@ -88,11 +88,8 @@ namespace jRandomSkills
|
|||
distancerPlayers.Remove(player);
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#00f2ff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#00f2ff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@ namespace jRandomSkills
|
|||
public class Dracula : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Dracula;
|
||||
private static float healthRegainScale = Config.GetValue<float>(skillName, "healthRegainScale");
|
||||
private static readonly float healthRegainScale = Config.GetValue<float>(skillName, "healthRegainScale");
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -22,11 +22,11 @@ namespace jRandomSkills
|
|||
|
||||
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim) || attacker == victim) return HookResult.Continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == attacker?.SteamID);
|
||||
|
||||
if (playerInfo?.Skill == skillName && victim.PawnIsAlive)
|
||||
if (playerInfo?.Skill == skillName && victim!.PawnIsAlive)
|
||||
{
|
||||
HealAttacker(attacker, @event.DmgHealth);
|
||||
HealAttacker(attacker!, @event.DmgHealth);
|
||||
}
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
|
@ -46,13 +46,9 @@ namespace jRandomSkills
|
|||
Utilities.SetStateChanged(attackerPawn, "CBaseEntity", "m_iHealth");
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#FA050D", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float healthRegainScale = .3f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float HealthRegainScale { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#FA050D", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float healthRegainScale = .3f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
HealthRegainScale = healthRegainScale;
|
||||
}
|
||||
public float HealthRegainScale { get; set; } = healthRegainScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -22,7 +22,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -36,7 +36,7 @@ namespace jRandomSkills
|
|||
{
|
||||
if (player == null) return;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return;
|
||||
|
||||
var playerPawn = player.PlayerPawn.Value;
|
||||
|
|
@ -65,8 +65,10 @@ namespace jRandomSkills
|
|||
{
|
||||
foreach (var enemy in enemies)
|
||||
{
|
||||
var enemyInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == enemy.SteamID);
|
||||
var enemyInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == enemy.SteamID);
|
||||
if (enemyInfo == null) continue;
|
||||
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == enemyInfo.Skill);
|
||||
if (skillData == null) continue;
|
||||
player.PrintToChat($" {ChatColors.Green}⠀⠀⠀[{ChatColors.Red}{enemy.Index}{ChatColors.Green}] {enemy.PlayerName}: {ChatColors.Red}{skillData.Name}");
|
||||
}
|
||||
}
|
||||
|
|
@ -77,30 +79,28 @@ namespace jRandomSkills
|
|||
|
||||
public static void DisableSkill(CCSPlayerController player)
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo == null) return;
|
||||
playerInfo.SpecialSkill = Skills.None;
|
||||
}
|
||||
|
||||
private static void DuplicateSkill(CCSPlayerController player, CCSPlayerController enemy)
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var enemyInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == enemy.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var enemyInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == enemy.SteamID);
|
||||
|
||||
if (playerInfo != null)
|
||||
if (playerInfo != null && enemyInfo != null)
|
||||
{
|
||||
playerInfo.Skill = enemyInfo.Skill;
|
||||
playerInfo.SpecialSkill = skillName;
|
||||
Instance.SkillAction(enemyInfo.Skill.ToString(), "EnableSkill", new object[] { player });
|
||||
Instance.SkillAction(enemyInfo.Skill.ToString(), "EnableSkill", [player]);
|
||||
|
||||
player.PrintToChat($" {ChatColors.Green}" + Localization.GetTranslation("duplicator_player_info", enemy.PlayerName));
|
||||
}
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#ffb73b", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#ffb73b", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ namespace jRandomSkills
|
|||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
player.Respawn();
|
||||
|
|
@ -49,7 +49,9 @@ namespace jRandomSkills
|
|||
|
||||
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
|
||||
{
|
||||
DisableSkill(@event.Userid);
|
||||
var player = @event.Userid;
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
DisableSkill(player);
|
||||
return HookResult.Continue;
|
||||
});
|
||||
}
|
||||
|
|
@ -57,12 +59,13 @@ namespace jRandomSkills
|
|||
public static void EnableSkill(CCSPlayerController player)
|
||||
{
|
||||
var playerPawn = player.PlayerPawn?.Value;
|
||||
if (playerPawn != null)
|
||||
if (playerPawn != null && player.IsValid)
|
||||
{
|
||||
float newSize = (float)Instance.Random.NextDouble() * (Config.GetValue<float>(skillName, "maxScale") - Config.GetValue<float>(skillName, "minScale")) + Config.GetValue<float>(skillName, "minScale");
|
||||
newSize = (float)Math.Round(newSize, 2);
|
||||
|
||||
// playerPawn.CBodyComponent.SceneNode.GetSkeletonInstance().Scale = newSize;
|
||||
if (playerPawn.CBodyComponent == null || playerPawn.CBodyComponent.SceneNode == null) return;
|
||||
playerPawn.CBodyComponent.SceneNode.Scale = newSize;
|
||||
Utilities.SetStateChanged(playerPawn, "CBaseEntity", "m_CBodyComponent");
|
||||
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{Localization.GetTranslation("dwarf")}{ChatColors.Lime}: " + Localization.GetTranslation("dwarf_desc2", newSize), false);
|
||||
|
|
@ -75,21 +78,16 @@ namespace jRandomSkills
|
|||
if (playerPawn != null && playerPawn?.CBodyComponent != null)
|
||||
{
|
||||
// playerPawn.CBodyComponent.SceneNode.GetSkeletonInstance().Scale = 1;
|
||||
if (playerPawn.CBodyComponent == null || playerPawn.CBodyComponent.SceneNode == null) return;
|
||||
playerPawn.CBodyComponent.SceneNode.Scale = 1;
|
||||
Utilities.SetStateChanged(playerPawn, "CBaseEntity", "m_CBodyComponent");
|
||||
}
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#ffff00", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float minScale = .6f, float maxScale = .95f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float MinScale { get; set; }
|
||||
public float MaxScale { get; set; }
|
||||
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#ffff00", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float minScale = .6f, float maxScale = .95f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
MinScale = minScale;
|
||||
MaxScale = maxScale;
|
||||
}
|
||||
public float MinScale { get; set; } = minScale;
|
||||
public float MaxScale { get; set; } = maxScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,8 +11,8 @@ namespace jRandomSkills
|
|||
public class EnemySpawn : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.EnemySpawn;
|
||||
private static float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
|
||||
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = new Dictionary<ulong, PlayerSkillInfo>();
|
||||
private static readonly float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
|
||||
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -25,7 +25,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) return;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
{
|
||||
EnableSkill(player);
|
||||
|
|
@ -45,11 +45,10 @@ namespace jRandomSkills
|
|||
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
if (SkillPlayerInfo.ContainsKey(player.SteamID))
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
|
@ -58,7 +57,7 @@ namespace jRandomSkills
|
|||
{
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
if (SkillPlayerInfo.TryGetValue(player.SteamID, out var skillInfo))
|
||||
UpdateHUD(player, skillInfo);
|
||||
|
|
@ -78,22 +77,7 @@ namespace jRandomSkills
|
|||
|
||||
public static void DisableSkill(CCSPlayerController player)
|
||||
{
|
||||
if (SkillPlayerInfo.ContainsKey(player.SteamID))
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
}
|
||||
|
||||
public static Vector GetEnemySpawn(CCSPlayerController player)
|
||||
{
|
||||
List<CCSPlayerController> enemy = Utilities.GetPlayers().FindAll(p => Instance.IsPlayerValid(p) && p.Team != player.Team && p.PawnIsAlive);
|
||||
if (enemy.Count == 0)
|
||||
{
|
||||
var abs = player.PlayerPawn.Value.AbsOrigin;
|
||||
return new Vector(abs.X, abs.Y, abs.Z);
|
||||
}
|
||||
|
||||
CCSPlayerController randomEnemy = enemy[Instance.Random.Next(0, enemy.Count)];
|
||||
var eAbs = randomEnemy.PlayerPawn.Value.AbsOrigin;
|
||||
return new Vector(eAbs.X, eAbs.Y, eAbs.Z);
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
}
|
||||
|
||||
private static void UpdateHUD(CCSPlayerController player, PlayerSkillInfo skillInfo)
|
||||
|
|
@ -138,14 +122,15 @@ namespace jRandomSkills
|
|||
|
||||
private static Vector GetEnemySpawnVector(CCSPlayerController player)
|
||||
{
|
||||
var abs = player.PlayerPawn.Value.AbsOrigin;
|
||||
var abs = player!.PlayerPawn!.Value?.AbsOrigin;
|
||||
var spawns = Utilities.FindAllEntitiesByDesignerName<SpawnPoint>(player.Team == CsTeam.CounterTerrorist ? "info_player_terrorist" : "info_player_counterterrorist").ToList();
|
||||
if (spawns.Any())
|
||||
if (spawns.Count != 0)
|
||||
{
|
||||
var randomSpawn = spawns[Instance.Random.Next(spawns.Count)];
|
||||
return randomSpawn.AbsOrigin;
|
||||
if (randomSpawn.AbsOrigin != null)
|
||||
return randomSpawn.AbsOrigin;
|
||||
}
|
||||
return new Vector(abs.X, abs.Y, abs.Z);
|
||||
return abs == null ? new Vector(0, 0, 0) : new Vector(abs.X, abs.Y, abs.Z);
|
||||
}
|
||||
|
||||
public class PlayerSkillInfo
|
||||
|
|
@ -155,13 +140,9 @@ namespace jRandomSkills
|
|||
public DateTime Cooldown { get; set; }
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#ff8c92", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 15f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float Cooldown { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#ff8c92", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 15f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
Cooldown = cooldown;
|
||||
}
|
||||
public float Cooldown { get; set; } = cooldown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -12,8 +12,8 @@ namespace jRandomSkills
|
|||
public class ExplosiveShot : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.ExplosiveShot;
|
||||
private static float damage = Config.GetValue<float>(skillName, "damage");
|
||||
private static float damageRadius = Config.GetValue<float>(skillName, "damageRadius");
|
||||
private static readonly float damage = Config.GetValue<float>(skillName, "damage");
|
||||
private static readonly float damageRadius = Config.GetValue<float>(skillName, "damageRadius");
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -26,7 +26,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -40,7 +40,8 @@ namespace jRandomSkills
|
|||
|
||||
public static void EnableSkill(CCSPlayerController player)
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo == null) return;
|
||||
float newChance = (float)Instance.Random.NextDouble() * (Config.GetValue<float>(skillName, "ChanceTo") - Config.GetValue<float>(skillName, "ChanceFrom")) + Config.GetValue<float>(skillName, "ChanceFrom");
|
||||
playerInfo.SkillChance = newChance;
|
||||
newChance = (float)Math.Round(newChance, 2) * 100;
|
||||
|
|
@ -72,7 +73,7 @@ namespace jRandomSkills
|
|||
if (param == null || param.Entity == null || param2 == null || param2.Attacker == null || param2.Attacker.Value == null)
|
||||
return HookResult.Continue;
|
||||
|
||||
CCSPlayerPawn attackerPawn = new CCSPlayerPawn(param2.Attacker.Value.Handle);
|
||||
CCSPlayerPawn attackerPawn = new(param2.Attacker.Value.Handle);
|
||||
if (attackerPawn.DesignerName != "player")
|
||||
return HookResult.Continue;
|
||||
|
||||
|
|
@ -80,7 +81,7 @@ namespace jRandomSkills
|
|||
return HookResult.Continue;
|
||||
|
||||
CCSPlayerController attacker = attackerPawn.Controller.Value.As<CCSPlayerController>();
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
if (playerInfo == null || playerInfo.Skill != skillName) return HookResult.Continue;
|
||||
|
||||
if (Instance.Random.NextDouble() <= playerInfo.SkillChance)
|
||||
|
|
@ -88,19 +89,12 @@ namespace jRandomSkills
|
|||
return HookResult.Continue;
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#9c0000", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float damage = 10f, float damageRadius = 190f, float chanceFrom = .15f, float chanceTo = .3f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float Damage { get; set; }
|
||||
public float DamageRadius { get; set; }
|
||||
public float ChanceFrom { get; set; }
|
||||
public float ChanceTo { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#9c0000", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float damage = 10f, float damageRadius = 190f, float chanceFrom = .15f, float chanceTo = .3f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
Damage = damage;
|
||||
DamageRadius = damageRadius;
|
||||
ChanceFrom = chanceFrom;
|
||||
ChanceTo = chanceTo;
|
||||
}
|
||||
public float Damage { get; set; } = damage;
|
||||
public float DamageRadius { get; set; } = damageRadius;
|
||||
public float ChanceFrom { get; set; } = chanceFrom;
|
||||
public float ChanceTo { get; set; } = chanceTo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,8 +11,8 @@ namespace jRandomSkills
|
|||
{
|
||||
private const Skills skillName = Skills.FalconEye;
|
||||
private static bool blocked = false;
|
||||
private static float distance = Config.GetValue<float>(skillName, "distance");
|
||||
private static Dictionary<ulong, (uint, CDynamicProp)> cameras = new Dictionary<ulong, (uint, CDynamicProp)>();
|
||||
private static readonly float distance = Config.GetValue<float>(skillName, "distance");
|
||||
private static readonly Dictionary<ulong, (uint, CDynamicProp)> cameras = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -41,11 +41,14 @@ namespace jRandomSkills
|
|||
{
|
||||
var player = @event.Userid;
|
||||
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player?.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return HookResult.Continue;
|
||||
|
||||
if (cameras.TryGetValue(player.SteamID, out var cameraInfo) && cameraInfo.Item1 == player.PlayerPawn.Value.CameraServices!.ViewEntity!.Raw)
|
||||
var pawn = player!.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid || pawn.CameraServices == null) return HookResult.Continue;
|
||||
|
||||
if (cameras.TryGetValue(player!.SteamID, out var cameraInfo) && cameraInfo.Item1 == pawn.CameraServices.ViewEntity.Raw)
|
||||
BlockWeapon(player, true);
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
|
@ -71,13 +74,14 @@ namespace jRandomSkills
|
|||
if (cameras.TryGetValue(player.SteamID, out var cameraInfo) && cameraInfo.Item2.IsValid)
|
||||
{
|
||||
var pawn = player.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid || pawn.AbsOrigin == null) continue;
|
||||
if (pawn.LifeState != (byte)LifeState_t.LIFE_ALIVE)
|
||||
{
|
||||
ChangeCamera(player, true);
|
||||
continue;
|
||||
}
|
||||
Vector pos = new Vector(pawn.AbsOrigin.X, pawn.AbsOrigin.Y, pawn.AbsOrigin.Z + 1000);
|
||||
QAngle angle = new QAngle(90, 0, -pawn.V_angle.Y);
|
||||
Vector pos = new(pawn.AbsOrigin.X, pawn.AbsOrigin.Y, pawn.AbsOrigin.Z + 1000);
|
||||
QAngle angle = new(90, 0, -pawn.V_angle.Y);
|
||||
cameraInfo.Item2.Teleport(pos, angle);
|
||||
}
|
||||
}
|
||||
|
|
@ -87,6 +91,7 @@ namespace jRandomSkills
|
|||
uint orginalCameraRaw;
|
||||
uint newCameraRaw;
|
||||
var pawn = player.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid || pawn.CameraServices == null) return;
|
||||
if (cameras.TryGetValue(player.SteamID, out var cameraInfo) && cameraInfo.Item2.IsValid)
|
||||
{
|
||||
orginalCameraRaw = cameraInfo.Item1;
|
||||
|
|
@ -101,7 +106,7 @@ namespace jRandomSkills
|
|||
if (newCameraRaw == 0)
|
||||
return;
|
||||
|
||||
bool defaultCam = forceToDefault ? true : (pawn.CameraServices!.ViewEntity!.Raw == orginalCameraRaw ? false : true);
|
||||
bool defaultCam = forceToDefault || (pawn.CameraServices.ViewEntity.Raw != orginalCameraRaw);
|
||||
pawn!.CameraServices!.ViewEntity.Raw = defaultCam ? orginalCameraRaw : newCameraRaw;
|
||||
Utilities.SetStateChanged(pawn, "CBasePlayerPawn", "m_pCameraServices");
|
||||
BlockWeapon(player, !defaultCam);
|
||||
|
|
@ -113,7 +118,8 @@ namespace jRandomSkills
|
|||
if (camera == null || !camera.IsValid) return 0;
|
||||
|
||||
var pawn = player.PlayerPawn.Value;
|
||||
Vector pos = new Vector(pawn.AbsOrigin.X, pawn.AbsOrigin.Y, pawn.AbsOrigin.Z + distance);
|
||||
if (pawn == null || !pawn.IsValid || pawn.AbsOrigin == null) return 0;
|
||||
Vector pos = new(pawn.AbsOrigin.X, pawn.AbsOrigin.Y, pawn.AbsOrigin.Z + distance);
|
||||
|
||||
camera.Render = Color.FromArgb(0, 255, 255, 255);
|
||||
camera.Teleport(pos, new QAngle(90, 0, 0));
|
||||
|
|
@ -124,7 +130,13 @@ namespace jRandomSkills
|
|||
|
||||
private static void BlockWeapon(CCSPlayerController player, bool block)
|
||||
{
|
||||
foreach (var weapon in player.Pawn.Value.WeaponServices?.MyWeapons)
|
||||
var pawn = player.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid) return;
|
||||
|
||||
var weaponServices = pawn.WeaponServices;
|
||||
if (weaponServices == null) return;
|
||||
|
||||
foreach (var weapon in weaponServices.MyWeapons)
|
||||
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
|
||||
{
|
||||
weapon.Value.NextPrimaryAttackTick = block ? int.MaxValue : Server.TickCount;
|
||||
|
|
@ -135,13 +147,9 @@ namespace jRandomSkills
|
|||
}
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#d1f542", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float distance = 1000f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float Distance { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#d1f542", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float distance = 1000f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
Distance = distance;
|
||||
}
|
||||
public float Distance { get; set; } = distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@ namespace jRandomSkills
|
|||
var playerPawn = player.PlayerPawn.Value;
|
||||
if (playerPawn?.CBodyComponent == null) return;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return;
|
||||
if (!player.IsValid || !player.PawnIsAlive) return;
|
||||
|
||||
|
|
@ -29,18 +29,19 @@ namespace jRandomSkills
|
|||
|
||||
private static void InstaReload(CCSPlayerPawn pawn)
|
||||
{
|
||||
var activeWeapon = pawn.WeaponServices.ActiveWeapon.Value;
|
||||
if (activeWeapon == null || !activeWeapon.IsValid) return;
|
||||
if (pawn == null || !pawn.IsValid) return;
|
||||
var weaponServices = pawn.WeaponServices;
|
||||
if (weaponServices == null || weaponServices.ActiveWeapon == null || !weaponServices.ActiveWeapon.IsValid) return;
|
||||
|
||||
var activeWeapon = weaponServices.ActiveWeapon.Value;
|
||||
if (activeWeapon == null || !activeWeapon.IsValid || activeWeapon.VData == null) return;
|
||||
|
||||
activeWeapon.Clip1 = activeWeapon.VData.MaxClip1;
|
||||
Utilities.SetStateChanged(activeWeapon, "CBasePlayerWeapon", "m_iClip1");
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#ffc061", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#ffc061", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float distance = 1000f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -24,10 +24,11 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerPawn = player.PlayerPawn?.Value;
|
||||
var playerPawn = player.PlayerPawn.Value;
|
||||
if (playerPawn == null || !playerPawn.IsValid) continue;
|
||||
|
||||
playerPawn.VelocityModifier = 1;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -47,10 +48,10 @@ namespace jRandomSkills
|
|||
var player = Utilities.GetPlayers().FirstOrDefault(p => p.Pawn?.Value != null && p.Pawn.Value.IsValid && p.Pawn.Value.Index == userIndex);
|
||||
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player?.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return HookResult.Continue;
|
||||
|
||||
if (player.Buttons.HasFlag(PlayerButtons.Speed) || player.Buttons.HasFlag(PlayerButtons.Duck))
|
||||
if (player!.Buttons.HasFlag(PlayerButtons.Speed) || player.Buttons.HasFlag(PlayerButtons.Duck))
|
||||
{
|
||||
um.Recipients.Clear();
|
||||
return HookResult.Handled;
|
||||
|
|
@ -63,10 +64,10 @@ namespace jRandomSkills
|
|||
public static void EnableSkill(CCSPlayerController player)
|
||||
{
|
||||
var playerPawn = player.PlayerPawn.Value;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerPawn == null) return;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerPawn == null || playerInfo == null) return;
|
||||
|
||||
var skillConfig = Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString());
|
||||
var skillConfig = Config.LoadedConfig.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString());
|
||||
if (skillConfig == null) return;
|
||||
|
||||
float newSpeed = (float)Instance.Random.NextDouble() * (Config.GetValue<float>(skillName, "ChanceTo") - Config.GetValue<float>(skillName, "ChanceFrom")) + Config.GetValue<float>(skillName, "ChanceFrom");
|
||||
|
|
@ -90,24 +91,19 @@ namespace jRandomSkills
|
|||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
|
||||
var playerPawn = player.PlayerPawn?.Value;
|
||||
if (playerPawn != null && playerPawn.VelocityModifier != 0)
|
||||
playerPawn.VelocityModifier = Math.Max((float)playerInfo?.SkillChance, 1);
|
||||
playerPawn.VelocityModifier = Math.Max((float)(playerInfo?.SkillChance ?? 1), 1);
|
||||
}
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#A31912", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float chanceFrom = 1.2f, float chanceTo = 3.0f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float ChanceFrom { get; set; }
|
||||
public float ChanceTo { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#A31912", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float chanceFrom = 1.2f, float chanceTo = 3.0f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
ChanceFrom = chanceFrom;
|
||||
ChanceTo = chanceTo;
|
||||
}
|
||||
public float ChanceFrom { get; set; } = chanceFrom;
|
||||
public float ChanceTo { get; set; } = chanceTo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -13,12 +13,12 @@ namespace jRandomSkills
|
|||
public class Fortnite : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Fortnite;
|
||||
private static float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
|
||||
private static int barricadeHealth = Config.GetValue<int>(skillName, "barricadeHealth");
|
||||
private static string propModel = Config.GetValue<string>(skillName, "propModel");
|
||||
private static readonly float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
|
||||
private static readonly int barricadeHealth = Config.GetValue<int>(skillName, "barricadeHealth");
|
||||
private static readonly string propModel = Config.GetValue<string>(skillName, "propModel");
|
||||
|
||||
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = new Dictionary<ulong, PlayerSkillInfo>();
|
||||
private static Dictionary<ulong, int> barricades = new Dictionary<ulong, int>();
|
||||
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = [];
|
||||
private static readonly Dictionary<ulong, int> barricades = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -31,7 +31,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) return;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -50,11 +50,10 @@ namespace jRandomSkills
|
|||
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
if (SkillPlayerInfo.ContainsKey(player.SteamID))
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
||||
|
|
@ -62,7 +61,7 @@ namespace jRandomSkills
|
|||
{
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
if (SkillPlayerInfo.TryGetValue(player.SteamID, out var skillInfo))
|
||||
UpdateHUD(player, skillInfo);
|
||||
|
|
@ -89,8 +88,7 @@ namespace jRandomSkills
|
|||
|
||||
public static void DisableSkill(CCSPlayerController player)
|
||||
{
|
||||
if (SkillPlayerInfo.ContainsKey(player.SteamID))
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
}
|
||||
|
||||
private static void UpdateHUD(CCSPlayerController player, PlayerSkillInfo skillInfo)
|
||||
|
|
@ -137,13 +135,13 @@ namespace jRandomSkills
|
|||
{
|
||||
var playerPawn = player.PlayerPawn.Value;
|
||||
var box = Utilities.CreateEntityByName<CDynamicProp>("prop_dynamic_override");
|
||||
if (box == null) return;
|
||||
if (box == null || playerPawn == null || !playerPawn.IsValid || playerPawn.AbsOrigin == null || playerPawn.AbsRotation == null) return;
|
||||
|
||||
float distance = 50;
|
||||
Vector pos = playerPawn.AbsOrigin + SkillUtils.GetForwardVector(playerPawn.AbsRotation) * distance;
|
||||
QAngle angle = new QAngle(playerPawn.AbsRotation.X, playerPawn.AbsRotation.Y + 90, playerPawn.AbsRotation.Z);
|
||||
QAngle angle = new(playerPawn.AbsRotation.X, playerPawn.AbsRotation.Y + 90, playerPawn.AbsRotation.Z);
|
||||
|
||||
box.Entity.Name = box.Globalname = $"FortniteWall_{Server.TickCount}";
|
||||
box.Entity!.Name = box.Globalname = $"FortniteWall_{Server.TickCount}";
|
||||
box.Collision.SolidType = SolidType_t.SOLID_VPHYSICS;
|
||||
box.CBodyComponent!.SceneNode!.Owner!.Entity!.Flags = (uint)(box.CBodyComponent!.SceneNode!.Owner!.Entity!.Flags & ~(1 << 2));
|
||||
box.DispatchSpawn();
|
||||
|
|
@ -187,17 +185,11 @@ namespace jRandomSkills
|
|||
public DateTime Cooldown { get; set; }
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#1b04cc", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 2f, int barricadeHealth = 115, string propModel = "models/props/de_aztec/hr_aztec/aztec_scaffolding/aztec_scaffold_wall_support_128.vmdl") : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float Cooldown { get; set; }
|
||||
public int BarricadeHealth { get; set; }
|
||||
public string PropModel { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#1b04cc", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 2f, int barricadeHealth = 115, string propModel = "models/props/de_aztec/hr_aztec/aztec_scaffolding/aztec_scaffold_wall_support_128.vmdl") : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
Cooldown = cooldown;
|
||||
BarricadeHealth = barricadeHealth;
|
||||
PropModel = propModel;
|
||||
}
|
||||
public float Cooldown { get; set; } = cooldown;
|
||||
public int BarricadeHealth { get; set; } = barricadeHealth;
|
||||
public string PropModel { get; set; } = propModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,16 +14,13 @@ namespace jRandomSkills
|
|||
{
|
||||
private const Skills skillName = Skills.FragileBomb;
|
||||
private static int bombHealth = Config.GetValue<int>(skillName, "maxBombHealth");
|
||||
private static int maxBombHealth = Config.GetValue<int>(skillName, "maxBombHealth");
|
||||
private static readonly int maxBombHealth = Config.GetValue<int>(skillName, "maxBombHealth");
|
||||
|
||||
private static CPlantedC4 plantedC4;
|
||||
private static CTriggerMultiple triggerC4;
|
||||
private static CPlantedC4? plantedC4;
|
||||
private static CTriggerMultiple? triggerC4;
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
|
||||
return;
|
||||
|
||||
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
|
||||
|
||||
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
|
||||
|
|
@ -49,7 +46,7 @@ namespace jRandomSkills
|
|||
private static void CreateTrigger()
|
||||
{
|
||||
var trigger = Utilities.CreateEntityByName<CTriggerMultiple>("trigger_multiple");
|
||||
if (trigger == null || plantedC4 == null) return;
|
||||
if (trigger == null || plantedC4 == null || trigger.AbsOrigin == null || plantedC4.AbsOrigin == null) return;
|
||||
|
||||
trigger.Collision.SolidType = SolidType_t.SOLID_CAPSULE;
|
||||
trigger.Collision.SolidFlags = 0;
|
||||
|
|
@ -93,19 +90,19 @@ namespace jRandomSkills
|
|||
if (param == null || param.Entity == null || param2 == null || param2.Attacker == null || param2.Attacker.Value == null)
|
||||
return HookResult.Continue;
|
||||
|
||||
CCSPlayerPawn attackerPawn = new CCSPlayerPawn(param2.Attacker.Value.Handle);
|
||||
CCSPlayerPawn attackerPawn = new(param2.Attacker.Value.Handle);
|
||||
|
||||
if (attackerPawn.DesignerName != "player" || param.DesignerName != "trigger_multiple")
|
||||
return HookResult.Continue;
|
||||
|
||||
CTriggerMultiple trigger = new CTriggerMultiple(param.Handle);
|
||||
CTriggerMultiple trigger = new(param.Handle);
|
||||
|
||||
if (attackerPawn == null || attackerPawn.Controller?.Value == null || trigger == null || !trigger.Globalname.StartsWith("planted_bomb_prop_"))
|
||||
return HookResult.Continue;
|
||||
|
||||
CCSPlayerController attacker = attackerPawn.Controller.Value.As<CCSPlayerController>();
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
if (playerInfo == null || playerInfo.Skill != skillName) return HookResult.Continue;
|
||||
|
||||
bombHealth -= (int)param2.TotalledDamage;
|
||||
|
|
@ -119,13 +116,9 @@ namespace jRandomSkills
|
|||
return HookResult.Continue;
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#5d00ff", CsTeam onlyTeam = CsTeam.CounterTerrorist, bool needsTeammates = false, int maxBombHealth = 1000) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public int MaxBombHealth { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#5d00ff", CsTeam onlyTeam = CsTeam.CounterTerrorist, bool needsTeammates = false, int maxBombHealth = 1000) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
MaxBombHealth = maxBombHealth;
|
||||
}
|
||||
public int MaxBombHealth { get; set; } = maxBombHealth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,14 +9,11 @@ namespace jRandomSkills
|
|||
public class FriendlyFire : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.FriendlyFire;
|
||||
private static float healthMultiplier = Config.GetValue<float>(skillName, "healthMultiplier");
|
||||
private static string[] nades = { "inferno", "flashbang", "smokegrenade", "decoy", "hegrenade" };
|
||||
private static readonly float healthMultiplier = Config.GetValue<float>(skillName, "healthMultiplier");
|
||||
private static readonly string[] nades = ["inferno", "flashbang", "smokegrenade", "decoy", "hegrenade"];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
|
||||
return;
|
||||
|
||||
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
|
||||
|
||||
Instance.RegisterEventHandler<EventPlayerHurt>((@event, info) =>
|
||||
|
|
@ -30,25 +27,22 @@ namespace jRandomSkills
|
|||
if (nades.Contains(weapon)) return HookResult.Continue;
|
||||
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim) || attacker == victim) return HookResult.Continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
if (playerInfo?.Skill != skillName || attacker.Team != victim.Team) return HookResult.Continue;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == attacker?.SteamID);
|
||||
if (playerInfo?.Skill != skillName || attacker!.Team != victim!.Team) return HookResult.Continue;
|
||||
|
||||
Server.ExecuteCommand("mp_autokick 0");
|
||||
|
||||
var pawn = victim.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid) return HookResult.Continue;
|
||||
SkillUtils.AddHealth(pawn, damage + (int)(damage * healthMultiplier), pawn.MaxHealth);
|
||||
|
||||
return HookResult.Continue;
|
||||
});
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#ff0000", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = true, float healthMultiplier = 1.5f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float HealthMultiplier { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#ff0000", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = true, float healthMultiplier = 1.5f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
HealthMultiplier = healthMultiplier;
|
||||
}
|
||||
public float HealthMultiplier { get; set; } = healthMultiplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,15 +11,12 @@ namespace jRandomSkills
|
|||
public class FrozenDecoy : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.FrozenDecoy;
|
||||
private static float decoyRadius = Config.GetValue<float>(skillName, "triggerRadius");
|
||||
private static int slownessMultiplier = Config.GetValue<int>(skillName, "slownessMultiplier");
|
||||
private static List<Vector> decoys = new List<Vector>();
|
||||
private static readonly float decoyRadius = Config.GetValue<float>(skillName, "triggerRadius");
|
||||
private static readonly int slownessMultiplier = Config.GetValue<int>(skillName, "slownessMultiplier");
|
||||
private static readonly List<Vector> decoys = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
|
||||
return;
|
||||
|
||||
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
|
||||
|
||||
Instance.RegisterEventHandler<EventRoundStart>((@event, info) =>
|
||||
|
|
@ -35,7 +32,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -47,7 +44,8 @@ namespace jRandomSkills
|
|||
Instance.RegisterEventHandler<EventDecoyStarted>((@event, info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return HookResult.Continue;
|
||||
decoys.Add(new Vector(@event.X, @event.Y, @event.Z));
|
||||
return HookResult.Continue;
|
||||
|
|
@ -56,7 +54,8 @@ namespace jRandomSkills
|
|||
Instance.RegisterEventHandler<EventDecoyDetonate>((@event, @info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return HookResult.Continue;
|
||||
decoys.RemoveAll(v => v.X == @event.X && v.Y == @event.Y && v.Z == @event.Z);
|
||||
return HookResult.Continue;
|
||||
|
|
@ -67,11 +66,13 @@ namespace jRandomSkills
|
|||
foreach (Vector decoyPos in decoys)
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
double distance = SkillUtils.GetDistance(decoyPos, player.PlayerPawn.Value.AbsOrigin);
|
||||
var pawn = player.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid || pawn.AbsOrigin == null) return;
|
||||
double distance = SkillUtils.GetDistance(decoyPos, pawn.AbsOrigin);
|
||||
if (distance <= decoyRadius)
|
||||
{
|
||||
double modifier = Math.Clamp(distance / decoyRadius, 0f, 1f);
|
||||
player.PlayerPawn.Value.VelocityModifier = (float)Math.Pow(modifier, slownessMultiplier);
|
||||
pawn.VelocityModifier = (float)Math.Pow(modifier, slownessMultiplier);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -82,15 +83,10 @@ namespace jRandomSkills
|
|||
SkillUtils.TryGiveWeapon(player, CsItem.DecoyGrenade);
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#00eaff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float triggerRadius = 180, int slownessMultiplier = 5) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float TriggerRadius { get; set; }
|
||||
public int SlownessMultiplier { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#00eaff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float triggerRadius = 180, int slownessMultiplier = 5) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
TriggerRadius = triggerRadius;
|
||||
SlownessMultiplier = slownessMultiplier;
|
||||
}
|
||||
public float TriggerRadius { get; set; } = triggerRadius;
|
||||
public int SlownessMultiplier { get; set; } = slownessMultiplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
using System.Collections.Immutable;
|
||||
using System.Drawing;
|
||||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Core.Attributes;
|
||||
using CounterStrikeSharp.API.Modules.Utils;
|
||||
using jRandomSkills.src.player;
|
||||
using jRandomSkills.src.utils;
|
||||
|
|
@ -13,48 +15,23 @@ namespace jRandomSkills
|
|||
{
|
||||
private const Skills skillName = Skills.Ghost;
|
||||
private static bool roundEnd = false;
|
||||
private static string[] disabledWeapons =
|
||||
{
|
||||
"weapon_deagle",
|
||||
"weapon_revolver",
|
||||
"weapon_glock",
|
||||
"weapon_usp_silencer",
|
||||
"weapon_cz75a",
|
||||
"weapon_fiveseven",
|
||||
"weapon_p250",
|
||||
"weapon_tec9",
|
||||
"weapon_elite",
|
||||
"weapon_hkp2000",
|
||||
"weapon_ak47",
|
||||
"weapon_m4a1",
|
||||
"weapon_m4a4",
|
||||
"weapon_m4a1_silencer",
|
||||
"weapon_famas",
|
||||
"weapon_galilar",
|
||||
"weapon_aug",
|
||||
"weapon_sg553",
|
||||
"weapon_mp9",
|
||||
"weapon_mac10",
|
||||
"weapon_bizon",
|
||||
"weapon_mp7",
|
||||
"weapon_ump45",
|
||||
"weapon_p90",
|
||||
"weapon_mp5sd",
|
||||
"weapon_ssg08",
|
||||
"weapon_awp",
|
||||
"weapon_scar20",
|
||||
"weapon_g3sg1",
|
||||
"weapon_nova",
|
||||
"weapon_xm1014",
|
||||
"weapon_mag7",
|
||||
"weapon_sawedoff",
|
||||
"weapon_m249",
|
||||
"weapon_negev"
|
||||
};
|
||||
private static readonly string[] disabledWeapons =
|
||||
[
|
||||
"weapon_deagle", "weapon_revolver", "weapon_glock", "weapon_usp_silencer",
|
||||
"weapon_cz75a", "weapon_fiveseven", "weapon_p250", "weapon_tec9",
|
||||
"weapon_elite", "weapon_hkp2000", "weapon_ak47", "weapon_m4a1",
|
||||
"weapon_m4a4", "weapon_m4a1_silencer", "weapon_famas", "weapon_galilar",
|
||||
"weapon_aug", "weapon_sg553", "weapon_mp9", "weapon_mac10",
|
||||
"weapon_bizon", "weapon_mp7", "weapon_ump45", "weapon_p90",
|
||||
"weapon_mp5sd", "weapon_ssg08", "weapon_awp", "weapon_scar20",
|
||||
"weapon_g3sg1", "weapon_nova", "weapon_xm1014", "weapon_mag7",
|
||||
"weapon_sawedoff", "weapon_m249", "weapon_negev"
|
||||
];
|
||||
private static readonly HashSet<uint> invisibleEntities = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
|
||||
if (Config.LoadedConfig.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
|
||||
return;
|
||||
|
||||
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
|
||||
|
|
@ -67,7 +44,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -81,7 +58,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
DisableSkill(player);
|
||||
}
|
||||
|
|
@ -92,9 +69,9 @@ namespace jRandomSkills
|
|||
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
if (!player.IsValid || player.PlayerPawn.Value == null) return HookResult.Continue;
|
||||
if (player == null || !player.IsValid || player.PlayerPawn.Value == null) return HookResult.Continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
DisableSkill(player);
|
||||
|
||||
|
|
@ -105,11 +82,12 @@ namespace jRandomSkills
|
|||
{
|
||||
var player = @event.Userid;
|
||||
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player?.SteamID);
|
||||
|
||||
if (playerInfo?.Skill != skillName) return HookResult.Continue;
|
||||
SetWeaponVisibility(player, false);
|
||||
SetWeaponAttack(player, true);
|
||||
SetWeaponVisibility(player!, false);
|
||||
SetWearablesVisibility(player!, false);
|
||||
SetWeaponAttack(player!, true);
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
||||
|
|
@ -121,12 +99,24 @@ namespace jRandomSkills
|
|||
});
|
||||
|
||||
Instance.RegisterListener<OnTick>(OnTick);
|
||||
Instance.RegisterListener<CheckTransmit>(CheckTransmit);
|
||||
}
|
||||
|
||||
public static void CheckTransmit([CastFrom(typeof(nint))] CCheckTransmitInfoList infoList)
|
||||
{
|
||||
foreach (var (info, player) in infoList)
|
||||
{
|
||||
if (player == null) continue;
|
||||
foreach (var entity in invisibleEntities)
|
||||
info.TransmitEntities.Remove((int)entity);
|
||||
}
|
||||
}
|
||||
|
||||
public static void EnableSkill(CCSPlayerController player)
|
||||
{
|
||||
SetPlayerVisibility(player, false);
|
||||
SetWeaponVisibility(player, false);
|
||||
SetWearablesVisibility(player, false);
|
||||
SetWeaponAttack(player, true);
|
||||
}
|
||||
|
||||
|
|
@ -134,6 +124,7 @@ namespace jRandomSkills
|
|||
{
|
||||
SetPlayerVisibility(player, true);
|
||||
SetWeaponVisibility(player, true);
|
||||
SetWearablesVisibility(player, true);
|
||||
SetWeaponAttack(player, false);
|
||||
}
|
||||
|
||||
|
|
@ -141,7 +132,7 @@ namespace jRandomSkills
|
|||
{
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
UpdateHUD(player);
|
||||
}
|
||||
|
|
@ -161,15 +152,36 @@ namespace jRandomSkills
|
|||
}
|
||||
}
|
||||
|
||||
private static void SetWeaponVisibility(CCSPlayerController player, bool visible)
|
||||
private static void SetWearablesVisibility(CCSPlayerController player, bool visible)
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) return;
|
||||
var playerPawn = player.PlayerPawn.Value;
|
||||
var playerPawn = player.PlayerPawn.Value!;
|
||||
|
||||
var color = visible ? Color.FromArgb(255, 255, 255, 255) : Color.FromArgb(0, 255, 255, 255);
|
||||
var shadowStrength = visible ? 1.0f : 0.0f;
|
||||
|
||||
foreach (var weapon in playerPawn.WeaponServices?.MyWeapons)
|
||||
foreach (var item in playerPawn.MyWearables)
|
||||
{
|
||||
if (item != null && item.IsValid && item.Value != null && item.Value.IsValid)
|
||||
{
|
||||
Server.PrintToChatAll($"NAME: {item.Value.DesignerName}");
|
||||
item.Value.Render = color;
|
||||
item.Value.ShadowStrength = shadowStrength;
|
||||
Utilities.SetStateChanged(item.Value, "CBaseModelEntity", "m_clrRender");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetWeaponVisibility(CCSPlayerController player, bool visible)
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) return;
|
||||
var playerPawn = player.PlayerPawn.Value!;
|
||||
if (playerPawn.WeaponServices == null) return;
|
||||
|
||||
var color = visible ? Color.FromArgb(255, 255, 255, 255) : Color.FromArgb(0, 255, 255, 255);
|
||||
var shadowStrength = visible ? 1.0f : 0.0f;
|
||||
|
||||
foreach (var weapon in playerPawn.WeaponServices.MyWeapons)
|
||||
{
|
||||
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
|
||||
{
|
||||
|
|
@ -184,11 +196,11 @@ namespace jRandomSkills
|
|||
{
|
||||
if (roundEnd || player == null || !player.IsValid) return;
|
||||
var pawn = player?.PlayerPawn?.Value;
|
||||
if (pawn == null || !pawn.IsValid) return;
|
||||
if (pawn == null || !pawn.IsValid || pawn.WeaponServices == null) return;
|
||||
|
||||
foreach (var weapon in pawn?.WeaponServices?.MyWeapons)
|
||||
foreach (var weapon in pawn.WeaponServices.MyWeapons)
|
||||
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
|
||||
if (disabledWeapons.Contains(weapon?.Value?.DesignerName))
|
||||
if (disabledWeapons.Contains(weapon.Value.DesignerName))
|
||||
{
|
||||
weapon.Value.NextPrimaryAttackTick = disableWeapon ? int.MaxValue : Server.TickCount;
|
||||
weapon.Value.NextSecondaryAttackTick = disableWeapon ? int.MaxValue : Server.TickCount;
|
||||
|
|
@ -200,11 +212,15 @@ namespace jRandomSkills
|
|||
|
||||
private static void UpdateHUD(CCSPlayerController player)
|
||||
{
|
||||
if (player == null || !player.IsValid) return;
|
||||
var pawn = player.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid || pawn.WeaponServices == null) return;
|
||||
|
||||
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == skillName);
|
||||
if (skillData == null) return;
|
||||
|
||||
var weapon = player.PlayerPawn.Value.WeaponServices.ActiveWeapon.Value;
|
||||
if (weapon == null || !disabledWeapons.Contains(weapon.DesignerName)) return;
|
||||
var weapon = pawn.WeaponServices.ActiveWeapon.Value;
|
||||
if (weapon == null || !weapon.IsValid || !disabledWeapons.Contains(weapon.DesignerName)) return;
|
||||
|
||||
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
|
||||
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
|
||||
|
|
@ -214,11 +230,8 @@ namespace jRandomSkills
|
|||
player.PrintToCenterHtml(hudContent);
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#FFFFFF", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#FFFFFF", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -27,7 +27,7 @@ namespace jRandomSkills
|
|||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -61,10 +61,10 @@ namespace jRandomSkills
|
|||
foreach (var (info, player) in infoList)
|
||||
{
|
||||
if (player == null) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
|
||||
var observedPlayer = Utilities.GetPlayers().FirstOrDefault(p => p?.Pawn?.Value?.Handle == player?.Pawn?.Value?.ObserverServices?.ObserverTarget?.Value?.Handle);
|
||||
var observerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == observedPlayer?.SteamID);
|
||||
var observerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == observedPlayer?.SteamID);
|
||||
|
||||
if (playerInfo?.Skill != skillName && observerInfo?.Skill != skillName) continue;
|
||||
foreach (var smoke in smokes)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace jRandomSkills
|
|||
public class Glitch : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Glitch;
|
||||
private static HashSet<CCSPlayerController> glitchedPlayers = new HashSet<CCSPlayerController>();
|
||||
private static readonly HashSet<CCSPlayerController> glitchedPlayers = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -23,7 +23,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -43,7 +43,7 @@ namespace jRandomSkills
|
|||
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);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return;
|
||||
|
||||
if (playerInfo.SkillChance == 1)
|
||||
|
|
@ -70,7 +70,8 @@ namespace jRandomSkills
|
|||
|
||||
public static void EnableSkill(CCSPlayerController player)
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo == null) return;
|
||||
playerInfo.SkillChance = 0;
|
||||
|
||||
SkillUtils.PrintToChat(player, Localization.GetTranslation("glitch") + ":", false);
|
||||
|
|
@ -93,11 +94,8 @@ namespace jRandomSkills
|
|||
glitchedPlayers.Remove(player);
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#f542ef", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#f542ef", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,19 +23,19 @@ namespace jRandomSkills
|
|||
if (grenade.OwnerEntity.Value == null || !grenade.OwnerEntity.Value.IsValid) return;
|
||||
|
||||
var pawn = grenade.OwnerEntity.Value.As<CCSPlayerPawn>();
|
||||
var player = pawn.Controller.Value.As<CCSPlayerController>();
|
||||
if (pawn == null || !pawn.IsValid || pawn.Controller == null || pawn.Controller.Value == null || !pawn.Controller.Value.IsValid) return;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var player = pawn.Controller.Value.As<CCSPlayerController>();
|
||||
if (player == null || !player.IsValid) return;
|
||||
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return;
|
||||
grenade.Bounces = 555;
|
||||
});
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#fff52e", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#fff52e", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,9 +11,9 @@ namespace jRandomSkills
|
|||
public class GodMode : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.GodMode;
|
||||
private static float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
|
||||
private static float duration = Config.GetValue<float>(skillName, "duration");
|
||||
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = new Dictionary<ulong, PlayerSkillInfo>();
|
||||
private static readonly float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
|
||||
private static readonly float duration = Config.GetValue<float>(skillName, "duration");
|
||||
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -25,7 +25,7 @@ namespace jRandomSkills
|
|||
{
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
{
|
||||
EnableSkill(player);
|
||||
|
|
@ -45,11 +45,10 @@ namespace jRandomSkills
|
|||
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
if (SkillPlayerInfo.ContainsKey(player.SteamID))
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
|
@ -58,7 +57,7 @@ namespace jRandomSkills
|
|||
{
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
if (SkillPlayerInfo.TryGetValue(player.SteamID, out var skillInfo))
|
||||
UpdateHUD(player, skillInfo);
|
||||
|
|
@ -78,8 +77,7 @@ namespace jRandomSkills
|
|||
|
||||
public static void DisableSkill(CCSPlayerController player)
|
||||
{
|
||||
if (SkillPlayerInfo.ContainsKey(player.SteamID))
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
}
|
||||
|
||||
private static void UpdateHUD(CCSPlayerController player, PlayerSkillInfo skillInfo)
|
||||
|
|
@ -112,7 +110,7 @@ namespace jRandomSkills
|
|||
|
||||
if (SkillPlayerInfo.TryGetValue(player.SteamID, out var skillInfo))
|
||||
{
|
||||
if (!player.IsValid || !player.PawnIsAlive) return;
|
||||
if (!player.IsValid || !player.PawnIsAlive || player.PlayerPawn.Value == null || !player.PlayerPawn.Value.IsValid) return;
|
||||
if (skillInfo.CanUse)
|
||||
{
|
||||
skillInfo.CanUse = false;
|
||||
|
|
@ -139,15 +137,10 @@ namespace jRandomSkills
|
|||
public DateTime Cooldown { get; set; }
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#e0d83a", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 30f, float duration = 2f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float Cooldown { get; set; }
|
||||
public float Duration { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#e0d83a", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 30f, float duration = 2f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
Cooldown = cooldown;
|
||||
Duration = duration;
|
||||
}
|
||||
public float Cooldown { get; set; } = cooldown;
|
||||
public float Duration { get; set; } = duration;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,9 +11,9 @@ namespace jRandomSkills
|
|||
public class HealingSmoke : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.HealingSmoke;
|
||||
private static int smokeHeal = Config.GetValue<int>(skillName, "smokeHeal");
|
||||
private static float smokeRadius = Config.GetValue<float>(skillName, "smokeRadius");
|
||||
private static List<Vector> smokes = new List<Vector>();
|
||||
private static readonly int smokeHeal = Config.GetValue<int>(skillName, "smokeHeal");
|
||||
private static readonly float smokeRadius = Config.GetValue<float>(skillName, "smokeRadius");
|
||||
private static readonly List<Vector> smokes = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -32,7 +32,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -44,7 +44,8 @@ namespace jRandomSkills
|
|||
Instance.RegisterEventHandler<EventSmokegrenadeDetonate>((@event, info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return HookResult.Continue;
|
||||
smokes.Add(new Vector(@event.X, @event.Y, @event.Z));
|
||||
return HookResult.Continue;
|
||||
|
|
@ -53,7 +54,8 @@ namespace jRandomSkills
|
|||
Instance.RegisterEventHandler<EventSmokegrenadeExpired>((@event, @info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return HookResult.Continue;
|
||||
smokes.RemoveAll(v => v.X == @event.X && v.Y == @event.Y && v.Z == @event.Z);
|
||||
return HookResult.Continue;
|
||||
|
|
@ -65,10 +67,15 @@ namespace jRandomSkills
|
|||
if (name != "smokegrenade_projectile") return;
|
||||
|
||||
var grenade = @event.As<CBaseCSGrenadeProjectile>();
|
||||
var pawn = grenade.OwnerEntity.Value.As<CCSPlayerPawn>();
|
||||
var player = pawn.Controller.Value.As<CCSPlayerController>();
|
||||
if (grenade == null || !grenade.IsValid || grenade.OwnerEntity == null || !grenade.OwnerEntity.IsValid || grenade.OwnerEntity.Value == null || !grenade.OwnerEntity.Value.IsValid) return;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var pawn = grenade.OwnerEntity.Value.As<CCSPlayerPawn>();
|
||||
if (pawn == null || !pawn.IsValid || pawn.Controller == null || !pawn.Controller.IsValid || pawn.Controller.Value == null || !pawn.Controller.Value.IsValid) return;
|
||||
|
||||
var player = pawn.Controller.Value.As<CCSPlayerController>();
|
||||
if (player == null || !player.IsValid) return;
|
||||
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return;
|
||||
|
||||
Server.NextFrame(() =>
|
||||
|
|
@ -85,8 +92,9 @@ namespace jRandomSkills
|
|||
foreach (Vector smokePos in smokes)
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
if (Server.TickCount % 17 == 0)
|
||||
if (SkillUtils.GetDistance(smokePos, player.PlayerPawn.Value.AbsOrigin) <= smokeRadius)
|
||||
AddHealth(player.PlayerPawn.Value, smokeHeal);
|
||||
if (player.PlayerPawn.Value != null && player.PlayerPawn.Value.IsValid && player.PlayerPawn.Value.AbsOrigin != null)
|
||||
if (SkillUtils.GetDistance(smokePos, player.PlayerPawn.Value.AbsOrigin) <= smokeRadius)
|
||||
AddHealth(player.PlayerPawn.Value, smokeHeal);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -107,15 +115,10 @@ namespace jRandomSkills
|
|||
Utilities.SetStateChanged(player, "CBaseEntity", "m_iHealth");
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#1fe070", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int smokeHeal = 1, float smokeRadius = 180) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public int SmokeHeal { get; set; }
|
||||
public float SmokeRadius { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#1fe070", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int smokeHeal = 1, float smokeRadius = 180) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
SmokeHeal = smokeHeal;
|
||||
SmokeRadius = smokeRadius;
|
||||
}
|
||||
public int SmokeHeal { get; set; } = smokeHeal;
|
||||
public float SmokeRadius { get; set; } = smokeRadius;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@ namespace jRandomSkills
|
|||
public class Hermit : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Hermit;
|
||||
private static readonly Dictionary<string, int> maxReserveAmmo = new Dictionary<string, int>
|
||||
private static readonly Dictionary<string, int> dictionary = new()
|
||||
{
|
||||
{ "weapon_glock", 120 },
|
||||
{ "weapon_usp_silencer", 24 },
|
||||
|
|
@ -47,8 +47,9 @@ namespace jRandomSkills
|
|||
{ "weapon_m249", 200 },
|
||||
{ "weapon_negev", 300 }
|
||||
};
|
||||
private static readonly Dictionary<string, int> maxReserveAmmo = dictionary;
|
||||
|
||||
private static int healthToAdd = Config.GetValue<int>(skillName, "healthToAdd");
|
||||
private static readonly int healthToAdd = Config.GetValue<int>(skillName, "healthToAdd");
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -59,14 +60,14 @@ namespace jRandomSkills
|
|||
var attacker = @event.Attacker;
|
||||
if (!Instance.IsPlayerValid(attacker)) return HookResult.Continue;
|
||||
|
||||
var attackerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
var attackerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == attacker?.SteamID);
|
||||
if (attackerInfo?.Skill != skillName) return HookResult.Continue;
|
||||
|
||||
var pawn = attacker.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid) return HookResult.Continue;
|
||||
var pawn = attacker!.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid || pawn.WeaponServices == null) return HookResult.Continue;
|
||||
|
||||
var weapon = pawn.WeaponServices.ActiveWeapon.Value;
|
||||
if (weapon == null || !weapon.IsValid) return HookResult.Continue;
|
||||
if (weapon == null || !weapon.IsValid || weapon.VData == null) return HookResult.Continue;
|
||||
|
||||
var maxReserveAmmoClip = maxReserveAmmo.TryGetValue(weapon.DesignerName, out var reserve) ? reserve : 100;
|
||||
weapon.Clip1 = weapon.VData.MaxClip1;
|
||||
|
|
@ -80,13 +81,9 @@ namespace jRandomSkills
|
|||
});
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#ded678", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int healthToAdd = 25) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public int HealthToAdd { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#ded678", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int healthToAdd = 25) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
HealthToAdd = healthToAdd;
|
||||
}
|
||||
public int HealthToAdd { get; set; } = healthToAdd;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10,8 +10,8 @@ namespace jRandomSkills
|
|||
public class HolyHandGrenade : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.HolyHandGrenade;
|
||||
private static float damageMultiplier = Config.GetValue<float>(skillName, "damageMultiplier");
|
||||
private static float damageRadiusMultiplier = Config.GetValue<float>(skillName, "damageRadiusMultiplier");
|
||||
private static readonly float damageMultiplier = Config.GetValue<float>(skillName, "damageMultiplier");
|
||||
private static readonly float damageRadiusMultiplier = Config.GetValue<float>(skillName, "damageRadiusMultiplier");
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -24,7 +24,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -42,13 +42,14 @@ namespace jRandomSkills
|
|||
Server.NextFrame(() =>
|
||||
{
|
||||
var hegrenade = @event.As<CHEGrenadeProjectile>();
|
||||
var playerPawn = hegrenade.Thrower.Value;
|
||||
if (hegrenade == null || !hegrenade.IsValid) return;
|
||||
|
||||
var playerPawn = hegrenade.Thrower.Value;
|
||||
if (playerPawn == null || !playerPawn.IsValid) return;
|
||||
|
||||
var player = Utilities.GetPlayers().FirstOrDefault(p => p.PlayerPawn.Index == playerPawn.Index);
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName)
|
||||
return;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player?.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return;
|
||||
|
||||
hegrenade.Damage *= damageMultiplier;
|
||||
hegrenade.DmgRadius *= damageRadiusMultiplier;
|
||||
|
|
@ -61,15 +62,10 @@ namespace jRandomSkills
|
|||
SkillUtils.TryGiveWeapon(player, CsItem.HEGrenade);
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#ffdd00", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float damageMultiplier = 2f, float damageRadiusMultiplier = 2f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float DamageMultiplier { get; set; }
|
||||
public float DamageRadiusMultiplier { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#ffdd00", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float damageMultiplier = 2f, float damageRadiusMultiplier = 2f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
DamageMultiplier = damageMultiplier;
|
||||
DamageRadiusMultiplier = damageRadiusMultiplier;
|
||||
}
|
||||
public float DamageMultiplier { get; set; } = damageMultiplier;
|
||||
public float DamageRadiusMultiplier { get; set; } = damageRadiusMultiplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -24,7 +24,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
{
|
||||
string model = GetEnemyModel(player);
|
||||
|
|
@ -50,11 +50,15 @@ namespace jRandomSkills
|
|||
|
||||
private static string GetEnemyModel(CCSPlayerController player)
|
||||
{
|
||||
CCSPlayerController[] models = Utilities.GetPlayers().FindAll(p => p.IsValid && p.PawnIsAlive && p.Team != player.Team).ToArray();
|
||||
if (models.Length > 0)
|
||||
CCSPlayerController[] models = [.. Utilities.GetPlayers().FindAll(p => p.IsValid && p.PawnIsAlive && p.Team != player.Team)];
|
||||
if (models != null && models.Length > 0)
|
||||
{
|
||||
string modelName = models[Instance.Random.Next(models.Length)].PlayerPawn.Value.CBodyComponent.SceneNode.GetSkeletonInstance().ModelState.ModelName;
|
||||
if (modelName != null) return modelName;
|
||||
var model = models[Instance.Random.Next(models.Length)];
|
||||
if (model != null && model.IsValid && model.PlayerPawn.Value != null && model.PlayerPawn.Value.IsValid && model.PlayerPawn.Value.CBodyComponent != null && model.PlayerPawn.Value.CBodyComponent.SceneNode != null)
|
||||
{
|
||||
string modelName = model.PlayerPawn.Value.CBodyComponent.SceneNode.GetSkeletonInstance().ModelState.ModelName;
|
||||
if (!string.IsNullOrEmpty(modelName)) return modelName;
|
||||
}
|
||||
}
|
||||
return player.Team == CsTeam.CounterTerrorist ? defaultTModel : defaultCTModel;
|
||||
}
|
||||
|
|
@ -73,11 +77,8 @@ namespace jRandomSkills
|
|||
});
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#99140B", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#99140B", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -19,12 +19,10 @@ namespace jRandomSkills
|
|||
|
||||
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player?.SteamID);
|
||||
|
||||
if (playerInfo?.Skill == skillName)
|
||||
{
|
||||
ApplyInfiniteAmmo(player);
|
||||
}
|
||||
ApplyInfiniteAmmo(player!);
|
||||
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
|
@ -35,10 +33,10 @@ namespace jRandomSkills
|
|||
|
||||
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player?.SteamID);
|
||||
|
||||
if (playerInfo?.Skill == skillName)
|
||||
player.GiveNamedItem($"weapon_{@event.Weapon}");
|
||||
player!.GiveNamedItem($"weapon_{@event.Weapon}");
|
||||
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
|
@ -49,12 +47,10 @@ namespace jRandomSkills
|
|||
|
||||
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player?.SteamID);
|
||||
|
||||
if (playerInfo?.Skill == skillName)
|
||||
{
|
||||
ApplyInfiniteAmmo(player);
|
||||
}
|
||||
ApplyInfiniteAmmo(player!);
|
||||
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
|
@ -64,16 +60,11 @@ namespace jRandomSkills
|
|||
{
|
||||
var activeWeaponHandle = player.PlayerPawn.Value?.WeaponServices?.ActiveWeapon;
|
||||
if (activeWeaponHandle?.Value != null)
|
||||
{
|
||||
activeWeaponHandle.Value.Clip1 = 100;
|
||||
}
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#0000FF", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#0000FF", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -12,11 +12,11 @@ namespace jRandomSkills
|
|||
public class Jackal : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Jackal;
|
||||
private static int maxStepBeam = Config.GetValue<int>(skillName, "maxStepBeam");
|
||||
private static readonly int maxStepBeam = Config.GetValue<int>(skillName, "maxStepBeam");
|
||||
private static bool exists = false;
|
||||
|
||||
private static Dictionary<uint, uint> authorBeams = new Dictionary<uint, uint>();
|
||||
private static Dictionary<CCSPlayerController, List<CBeam>> stepBeams = new Dictionary<CCSPlayerController, List<CBeam>>();
|
||||
private static readonly Dictionary<uint, uint> authorBeams = [];
|
||||
private static readonly Dictionary<CCSPlayerController, List<CBeam>> stepBeams = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -29,7 +29,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -63,7 +63,7 @@ namespace jRandomSkills
|
|||
foreach (var step in stepBeams.ToList())
|
||||
{
|
||||
var player = step.Key;
|
||||
if (player == null || !player.IsValid)
|
||||
if (!player.IsValid)
|
||||
{
|
||||
stepBeams.Remove(player);
|
||||
continue;
|
||||
|
|
@ -73,7 +73,8 @@ namespace jRandomSkills
|
|||
if (pawn == null || !pawn.IsValid || pawn.LifeState != (byte)LifeState_t.LIFE_ALIVE) continue;
|
||||
|
||||
var beams = step.Value;
|
||||
Vector lastBeamVector = beams?.LastOrDefault()?.EndPos ?? pawn?.AbsOrigin;
|
||||
if (beams.Count == 0 || pawn.AbsOrigin == null) continue;
|
||||
Vector lastBeamVector = beams.LastOrDefault()?.EndPos ?? pawn.AbsOrigin;
|
||||
|
||||
var newBeam = CreateBeamStep(step.Key.Team, lastBeamVector, pawn.AbsOrigin);
|
||||
if (newBeam != null)
|
||||
|
|
@ -109,7 +110,7 @@ namespace jRandomSkills
|
|||
}
|
||||
}
|
||||
|
||||
public static CBeam CreateBeamStep(CsTeam team, Vector start, Vector stop)
|
||||
public static CBeam? CreateBeamStep(CsTeam team, Vector start, Vector stop)
|
||||
{
|
||||
CBeam beam = Utilities.CreateEntityByName<CBeam>("beam")!;
|
||||
if (beam == null) return null;
|
||||
|
|
@ -131,7 +132,7 @@ namespace jRandomSkills
|
|||
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);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return;
|
||||
|
||||
if (playerInfo.SkillChance == 1)
|
||||
|
|
@ -150,7 +151,7 @@ namespace jRandomSkills
|
|||
}
|
||||
|
||||
authorBeams.Add(player.Index, enemy.Index);
|
||||
stepBeams.Add(enemy, new List<CBeam>());
|
||||
stepBeams.Add(enemy, []);
|
||||
playerInfo.SkillChance = 1;
|
||||
player.PrintToChat($" {ChatColors.Green}" + Localization.GetTranslation("jackal_player_info", enemy.PlayerName));
|
||||
}
|
||||
|
|
@ -160,7 +161,8 @@ namespace jRandomSkills
|
|||
if (!exists)
|
||||
Instance.RegisterListener<Listeners.CheckTransmit>(CheckTransmit);
|
||||
exists = true;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo == null) return;
|
||||
playerInfo.SkillChance = 0;
|
||||
|
||||
SkillUtils.PrintToChat(player, Localization.GetTranslation("jackal") + ":", false);
|
||||
|
|
@ -183,13 +185,9 @@ namespace jRandomSkills
|
|||
stepBeams.Remove(player);
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#f542ef", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int maxStepBeam = 50) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public int MaxStepBeam { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#f542ef", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int maxStepBeam = 50) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
MaxStepBeam = maxStepBeam;
|
||||
}
|
||||
public int MaxStepBeam { get; set; } = maxStepBeam;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ namespace jRandomSkills
|
|||
public class Jammer : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Jammer;
|
||||
private static HashSet<CCSPlayerController> jammedPlayers = new HashSet<CCSPlayerController>();
|
||||
private static readonly HashSet<CCSPlayerController> jammedPlayers = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -23,7 +23,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@ namespace jRandomSkills
|
|||
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);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return;
|
||||
|
||||
if (playerInfo.SkillChance == 1)
|
||||
|
|
@ -72,6 +72,7 @@ namespace jRandomSkills
|
|||
private static void SetCrosshair(CCSPlayerController player, bool enabled)
|
||||
{
|
||||
var pawn = player.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid) return;
|
||||
pawn.HideHUD = (uint)(enabled
|
||||
? (pawn.HideHUD & ~(1 << 8))
|
||||
: (pawn.HideHUD | (1 << 8)));
|
||||
|
|
@ -80,7 +81,8 @@ namespace jRandomSkills
|
|||
|
||||
public static void EnableSkill(CCSPlayerController player)
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo == null) return;
|
||||
playerInfo.SkillChance = 0;
|
||||
|
||||
SkillUtils.PrintToChat(player, Localization.GetTranslation("jammer") + ":", false);
|
||||
|
|
@ -103,11 +105,8 @@ namespace jRandomSkills
|
|||
jammedPlayers.Remove(player);
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#42f5a7", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#42f5a7", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ namespace jRandomSkills
|
|||
public class JumpBan : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.JumpBan;
|
||||
private static Dictionary<CCSPlayerPawn, int> bannedPlayers = new Dictionary<CCSPlayerPawn, int>();
|
||||
private static readonly Dictionary<CCSPlayerPawn, int> bannedPlayers = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -23,7 +23,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -41,6 +41,7 @@ namespace jRandomSkills
|
|||
Instance.RegisterEventHandler<EventPlayerJump>((@event, info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
if (player == null || !player.IsValid || player.PlayerPawn.Value == null || !player.PlayerPawn.Value.IsValid) return HookResult.Continue;
|
||||
if (!bannedPlayers.TryGetValue(player.PlayerPawn.Value, out _)) return HookResult.Continue;
|
||||
bannedPlayers[player.PlayerPawn.Value] = Server.TickCount + 10;
|
||||
return HookResult.Stop;
|
||||
|
|
@ -63,7 +64,7 @@ namespace jRandomSkills
|
|||
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);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return;
|
||||
|
||||
if (playerInfo.SkillChance == 1)
|
||||
|
|
@ -75,7 +76,7 @@ namespace jRandomSkills
|
|||
string enemyId = commands[0];
|
||||
var enemy = Utilities.GetPlayers().FirstOrDefault(p => p.Team != player.Team && p.Index.ToString() == enemyId);
|
||||
|
||||
if (enemy == null)
|
||||
if (enemy == null || !enemy.IsValid || enemy.PlayerPawn.Value == null || !enemy.PlayerPawn.Value.IsValid)
|
||||
{
|
||||
player.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("selectplayerskill_incorrect_enemy_index"));
|
||||
return;
|
||||
|
|
@ -89,7 +90,8 @@ namespace jRandomSkills
|
|||
|
||||
public static void EnableSkill(CCSPlayerController player)
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo == null) return;
|
||||
playerInfo.SkillChance = 0;
|
||||
|
||||
SkillUtils.PrintToChat(player, Localization.GetTranslation("jumpban") + ":", false);
|
||||
|
|
@ -108,14 +110,12 @@ namespace jRandomSkills
|
|||
|
||||
public static void DisableSkill(CCSPlayerController player)
|
||||
{
|
||||
if (player == null || !player.IsValid || player.PlayerPawn.Value == null || !player.PlayerPawn.Value.IsValid) return;
|
||||
bannedPlayers.Remove(player.PlayerPawn.Value);
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#b01e5d", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#b01e5d", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ namespace jRandomSkills
|
|||
public class JumpingJack : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.JumpingJack;
|
||||
private static int addHealth = Config.GetValue<int>(skillName, "healthToAdd");
|
||||
private static readonly int addHealth = Config.GetValue<int>(skillName, "healthToAdd");
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -17,7 +17,8 @@ namespace jRandomSkills
|
|||
Instance.RegisterEventHandler<EventPlayerJump>((@event, info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return HookResult.Continue;
|
||||
|
||||
SkillUtils.AddHealth(player.PlayerPawn.Value, addHealth);
|
||||
|
|
@ -25,13 +26,9 @@ namespace jRandomSkills
|
|||
});
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#a86eff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int healthToAdd = 3) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public int HealthToAdd { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#a86eff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int healthToAdd = 3) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
HealthToAdd = healthToAdd;
|
||||
}
|
||||
public int HealthToAdd { get; set; } = healthToAdd;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ namespace jRandomSkills
|
|||
public class KillerFlash : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.KillerFlash;
|
||||
private static float flashDuration = Config.GetValue<float>(skillName, "flashDuration");
|
||||
private static readonly float flashDuration = Config.GetValue<float>(skillName, "flashDuration");
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -23,7 +23,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -36,12 +36,12 @@ namespace jRandomSkills
|
|||
{
|
||||
var player = @event.Userid;
|
||||
var attacker = @event.Attacker;
|
||||
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
|
||||
if (!Instance.IsPlayerValid(player) || !Instance.IsPlayerValid(attacker)) return HookResult.Continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var attackerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player?.SteamID);
|
||||
var attackerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == attacker?.SteamID);
|
||||
|
||||
if (attackerInfo?.Skill == skillName && playerInfo?.Skill != Skills.AntyFlash && player?.PlayerPawn.Value.FlashDuration >= flashDuration)
|
||||
if (attackerInfo?.Skill == skillName && playerInfo?.Skill != Skills.AntyFlash && player!.PlayerPawn.Value!.FlashDuration >= flashDuration)
|
||||
player?.PlayerPawn?.Value?.CommitSuicide(false, true);
|
||||
|
||||
return HookResult.Continue;
|
||||
|
|
@ -53,13 +53,9 @@ namespace jRandomSkills
|
|||
SkillUtils.TryGiveWeapon(player, CsItem.FlashbangGrenade);
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#57bcff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float flashDuration = 1f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float FlashDuration { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#57bcff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float flashDuration = 1f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
FlashDuration = flashDuration;
|
||||
}
|
||||
public float FlashDuration { get; set; } = flashDuration;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -22,7 +22,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ namespace jRandomSkills
|
|||
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);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return;
|
||||
|
||||
if (playerInfo.SkillChance == 1)
|
||||
|
|
@ -61,7 +61,8 @@ namespace jRandomSkills
|
|||
|
||||
public static void EnableSkill(CCSPlayerController player)
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo == null) return;
|
||||
playerInfo.SkillChance = 0;
|
||||
|
||||
SkillUtils.PrintToChat(player, Localization.GetTranslation("lifeswap") + ":", false);
|
||||
|
|
@ -83,21 +84,16 @@ namespace jRandomSkills
|
|||
var playerPawn = player.PlayerPawn.Value;
|
||||
var enemyPawn = enemy.PlayerPawn.Value;
|
||||
|
||||
if (playerPawn.LifeState != (byte)LifeState_t.LIFE_ALIVE || enemyPawn.LifeState != (byte)LifeState_t.LIFE_ALIVE)
|
||||
return;
|
||||
if (playerPawn == null || !playerPawn.IsValid || enemyPawn == null || !enemyPawn.IsValid) return;
|
||||
if (playerPawn.LifeState != (byte)LifeState_t.LIFE_ALIVE || enemyPawn.LifeState != (byte)LifeState_t.LIFE_ALIVE) return;
|
||||
|
||||
int playerHealth = playerPawn.Health;
|
||||
playerPawn.Health = enemyPawn.Health;
|
||||
enemyPawn.Health = playerHealth;
|
||||
(enemyPawn.Health, playerPawn.Health) = (playerPawn.Health, enemyPawn.Health);
|
||||
Utilities.SetStateChanged(playerPawn, "CBaseEntity", "m_iHealth");
|
||||
Utilities.SetStateChanged(enemyPawn, "CBaseEntity", "m_iHealth");
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#a3651a", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#a3651a", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ namespace jRandomSkills
|
|||
public class LongKnife : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.LongKnife;
|
||||
private static float maxDistance = Config.GetValue<float>(skillName, "maxDistance");
|
||||
private static readonly float maxDistance = Config.GetValue<float>(skillName, "maxDistance");
|
||||
|
||||
public unsafe static void LoadSkill()
|
||||
{
|
||||
|
|
@ -25,18 +25,20 @@ namespace jRandomSkills
|
|||
var player = @event.Userid;
|
||||
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player?.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return HookResult.Continue;
|
||||
|
||||
var activeWeapon = player.Pawn.Value.WeaponServices.ActiveWeapon.Value;
|
||||
if (activeWeapon?.DesignerName != "weapon_knife") return HookResult.Continue;
|
||||
var pawn = player!.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid || pawn.AbsOrigin == null || pawn.WeaponServices == null) return HookResult.Continue;
|
||||
|
||||
var pawn = player.PlayerPawn.Value;
|
||||
Vector eyePos = new Vector(pawn.AbsOrigin.X, pawn.AbsOrigin.Y, pawn.AbsOrigin.Z + pawn.ViewOffset.Z);
|
||||
var activeWeapon = pawn.WeaponServices.ActiveWeapon.Value;
|
||||
if (activeWeapon == null || !activeWeapon.IsValid || activeWeapon.DesignerName != "weapon_knife") return HookResult.Continue;
|
||||
|
||||
Vector eyePos = new(pawn.AbsOrigin.X, pawn.AbsOrigin.Y, pawn.AbsOrigin.Z + pawn.ViewOffset.Z);
|
||||
Vector endPos = eyePos + SkillUtils.GetForwardVector(pawn.EyeAngles) * maxDistance;
|
||||
|
||||
Ray ray = new Ray(Vector3.Zero);
|
||||
CTraceFilter filter = new CTraceFilter(pawn.Index, pawn.Index)
|
||||
Ray ray = new(Vector3.Zero);
|
||||
CTraceFilter filter = new(pawn.Index, pawn.Index)
|
||||
{
|
||||
m_nObjectSetMask = 0xf,
|
||||
m_nCollisionGroup = (byte)CollisionGroup.COLLISION_GROUP_PLAYER_MOVEMENT,
|
||||
|
|
@ -55,20 +57,16 @@ namespace jRandomSkills
|
|||
if (!trace.HitPlayer(out CCSPlayerController? target) || target == null)
|
||||
return HookResult.Continue;
|
||||
|
||||
if (target.Handle == player.Handle || trace.Distance() <= 70) return HookResult.Continue;
|
||||
if (target.Handle == player.Handle || target.PlayerPawn.Value == null || !target.PlayerPawn.Value.IsValid || trace.Distance() <= 70) return HookResult.Continue;
|
||||
target.PlayerPawn.Value.EmitSound("Player.DamageBody.Onlooker");
|
||||
SkillUtils.TakeHealth(target.PlayerPawn.Value, Instance.Random.Next(21, 34));
|
||||
return HookResult.Continue;
|
||||
});
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#c9f8ff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float maxDistance = 4096f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float MaxDistance { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#c9f8ff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float maxDistance = 4096f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
MaxDistance = maxDistance;
|
||||
}
|
||||
public float MaxDistance { get; set; } = maxDistance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ namespace jRandomSkills
|
|||
public class LongZeus : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.LongZeus;
|
||||
private static float maxDistance = Config.GetValue<float>(skillName, "maxDistance");
|
||||
private static readonly float maxDistance = Config.GetValue<float>(skillName, "maxDistance");
|
||||
|
||||
public unsafe static void LoadSkill()
|
||||
{
|
||||
|
|
@ -27,7 +27,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -41,18 +41,20 @@ namespace jRandomSkills
|
|||
var player = @event.Userid;
|
||||
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player?.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return HookResult.Continue;
|
||||
|
||||
var activeWeapon = player.Pawn.Value.WeaponServices.ActiveWeapon.Value;
|
||||
if (activeWeapon?.DesignerName != "weapon_taser") return HookResult.Continue;
|
||||
var pawn = player!.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid || pawn.AbsOrigin == null || pawn.WeaponServices == null) return HookResult.Continue;
|
||||
|
||||
var pawn = player.PlayerPawn.Value;
|
||||
Vector eyePos = new Vector(pawn.AbsOrigin.X, pawn.AbsOrigin.Y, pawn.AbsOrigin.Z + pawn.ViewOffset.Z);
|
||||
var activeWeapon = pawn.WeaponServices.ActiveWeapon.Value;
|
||||
if (activeWeapon == null || !activeWeapon.IsValid || activeWeapon.DesignerName != "weapon_taser") return HookResult.Continue;
|
||||
|
||||
Vector eyePos = new(pawn.AbsOrigin.X, pawn.AbsOrigin.Y, pawn.AbsOrigin.Z + pawn.ViewOffset.Z);
|
||||
Vector endPos = eyePos + SkillUtils.GetForwardVector(pawn.EyeAngles) * maxDistance;
|
||||
|
||||
Ray ray = new Ray(Vector3.Zero);
|
||||
CTraceFilter filter = new CTraceFilter(pawn.Index, pawn.Index)
|
||||
Ray ray = new(Vector3.Zero);
|
||||
CTraceFilter filter = new(pawn.Index, pawn.Index)
|
||||
{
|
||||
m_nObjectSetMask = 0xf,
|
||||
m_nCollisionGroup = (byte)CollisionGroup.COLLISION_GROUP_PLAYER_MOVEMENT,
|
||||
|
|
@ -82,13 +84,9 @@ namespace jRandomSkills
|
|||
SkillUtils.TryGiveWeapon(player, CsItem.Zeus);
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#6effc7", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float maxDistance = 4096f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float MaxDistance { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#6effc7", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float maxDistance = 4096f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
MaxDistance = maxDistance;
|
||||
}
|
||||
public float MaxDistance { get; set; } = maxDistance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10,8 +10,8 @@ namespace jRandomSkills
|
|||
public class Magnifier : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Magnifier;
|
||||
private static uint customFOV = Config.GetValue<uint>(skillName, "customFOV");
|
||||
private static Dictionary<CCSPlayerController, uint> playersFOV = new Dictionary<CCSPlayerController, uint>();
|
||||
private static readonly uint customFOV = Config.GetValue<uint>(skillName, "customFOV");
|
||||
private static readonly Dictionary<CCSPlayerController, uint> playersFOV = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -24,7 +24,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@ namespace jRandomSkills
|
|||
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);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return;
|
||||
|
||||
if (playerInfo.SkillChance == 1)
|
||||
|
|
@ -75,7 +75,8 @@ namespace jRandomSkills
|
|||
|
||||
public static void EnableSkill(CCSPlayerController player)
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo == null) return;
|
||||
playerInfo.SkillChance = 0;
|
||||
|
||||
SkillUtils.PrintToChat(player, Localization.GetTranslation("magnifier") + ":", false);
|
||||
|
|
@ -102,13 +103,9 @@ namespace jRandomSkills
|
|||
playersFOV.Remove(player);
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#9ba882", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, uint customFOV = 50) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public uint CustomFOV { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#9ba882", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, uint customFOV = 50) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
CustomFOV = customFOV;
|
||||
}
|
||||
public uint CustomFOV { get; set; } = customFOV;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,10 +11,10 @@ namespace jRandomSkills
|
|||
public class Medic : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Medic;
|
||||
private static int healthToAdd = Config.GetValue<int>(skillName, "healthToAdd");
|
||||
private static int healthShotLimit = Config.GetValue<int>(skillName, "healthShotLimit");
|
||||
private static float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
|
||||
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = new Dictionary<ulong, PlayerSkillInfo>();
|
||||
private static readonly int healthToAdd = Config.GetValue<int>(skillName, "healthToAdd");
|
||||
private static readonly int healthShotLimit = Config.GetValue<int>(skillName, "healthShotLimit");
|
||||
private static readonly float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
|
||||
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -27,7 +27,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) return;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -45,11 +45,10 @@ namespace jRandomSkills
|
|||
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
if (SkillPlayerInfo.ContainsKey(player.SteamID))
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
||||
|
|
@ -57,7 +56,7 @@ namespace jRandomSkills
|
|||
{
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
if (SkillPlayerInfo.TryGetValue(player.SteamID, out var skillInfo))
|
||||
UpdateHUD(player, skillInfo);
|
||||
|
|
@ -78,8 +77,7 @@ namespace jRandomSkills
|
|||
|
||||
public static void DisableSkill(CCSPlayerController player)
|
||||
{
|
||||
if (SkillPlayerInfo.ContainsKey(player.SteamID))
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
}
|
||||
|
||||
private static void UpdateHUD(CCSPlayerController player, PlayerSkillInfo skillInfo)
|
||||
|
|
@ -101,7 +99,7 @@ namespace jRandomSkills
|
|||
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
|
||||
string remainingLine = cooldown != 0
|
||||
? $"<font class='fontSize-m' color='#FFFFFF'>{Localization.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>"
|
||||
: $"<font class='fontSize-m' color='#{(skillInfo.Count == 0 ? "FF0000" : "00FF00")}'>{skillInfo.Count}/{healthShotLimit}</font> <br>";
|
||||
: $"<font class='fontSize-m' color='#{(skillInfo == null || skillInfo.Count == 0 ? "FF0000" : "00FF00")}'>{(skillInfo == null ? 0 : skillInfo.Count)}/{healthShotLimit}</font> <br>";
|
||||
|
||||
var hudContent = infoLine + skillLine + remainingLine;
|
||||
player.PrintToCenterHtml(hudContent);
|
||||
|
|
@ -134,17 +132,11 @@ namespace jRandomSkills
|
|||
public DateTime Cooldown { get; set; }
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#10c212", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int healthToAdd = 50, int healthShotLimit = 3, float cooldown = 1f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public int HealthToAdd { get; set; }
|
||||
public int HealthShotLimit { get; set; }
|
||||
public float Cooldown { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#10c212", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int healthToAdd = 50, int healthShotLimit = 3, float cooldown = 1f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
HealthToAdd = healthToAdd;
|
||||
HealthShotLimit = healthShotLimit;
|
||||
Cooldown = cooldown;
|
||||
}
|
||||
public int HealthToAdd { get; set; } = healthToAdd;
|
||||
public int HealthShotLimit { get; set; } = healthShotLimit;
|
||||
public float Cooldown { get; set; } = cooldown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -22,7 +22,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ namespace jRandomSkills
|
|||
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);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return;
|
||||
|
||||
if (playerInfo.SkillChance == 1)
|
||||
|
|
@ -61,7 +61,8 @@ namespace jRandomSkills
|
|||
|
||||
public static void EnableSkill(CCSPlayerController player)
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo == null) return;
|
||||
playerInfo.SkillChance = 0;
|
||||
|
||||
SkillUtils.PrintToChat(player, Localization.GetTranslation("moneyswap") + ":", false);
|
||||
|
|
@ -71,7 +72,8 @@ namespace jRandomSkills
|
|||
if (enemies.Length > 0)
|
||||
{
|
||||
foreach (var enemy in enemies)
|
||||
player.PrintToChat($" {ChatColors.Green}⠀⠀⠀[{ChatColors.Red}{enemy.Index}{ChatColors.Green}] {enemy.PlayerName}: ${enemy.InGameMoneyServices.Account}");
|
||||
if (enemy != null && enemy.IsValid && enemy.InGameMoneyServices != null)
|
||||
player.PrintToChat($" {ChatColors.Green}⠀⠀⠀[{ChatColors.Red}{enemy.Index}{ChatColors.Green}] {enemy.PlayerName}: ${enemy.InGameMoneyServices.Account}");
|
||||
}
|
||||
else
|
||||
player.PrintToChat($" {ChatColors.Red}⠀⠀⠀{Localization.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
|
||||
|
|
@ -80,8 +82,10 @@ namespace jRandomSkills
|
|||
|
||||
private static void SwapMoney(CCSPlayerController player, CCSPlayerController enemy)
|
||||
{
|
||||
var playerMoneyServices = player?.InGameMoneyServices;
|
||||
var enemyMoneyServices = enemy?.InGameMoneyServices;
|
||||
if (player == null || !player.IsValid || enemy == null || !enemy.IsValid) return;
|
||||
|
||||
var playerMoneyServices = player.InGameMoneyServices;
|
||||
var enemyMoneyServices = enemy.InGameMoneyServices;
|
||||
if (playerMoneyServices == null || enemyMoneyServices == null) return;
|
||||
|
||||
int playerMoney = playerMoneyServices.Account;
|
||||
|
|
@ -92,11 +96,8 @@ namespace jRandomSkills
|
|||
Utilities.SetStateChanged(enemy, "CCSPlayerController", "m_pInGameMoneyServices");
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#52f54c", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#52f54c", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,8 +9,8 @@ namespace jRandomSkills
|
|||
public class Muhammed : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Muhammed;
|
||||
private static float explosionRadius = Config.GetValue<float>(skillName, "explosionRadius");
|
||||
private static int explosionDamage = Config.GetValue<int>(skillName, "explosionDamage");
|
||||
private static readonly float explosionRadius = Config.GetValue<float>(skillName, "explosionRadius");
|
||||
private static readonly int explosionDamage = Config.GetValue<int>(skillName, "explosionDamage");
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -18,12 +18,12 @@ namespace jRandomSkills
|
|||
|
||||
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
|
||||
{
|
||||
CCSPlayerController player = @event.Userid;
|
||||
var player = @event.Userid;
|
||||
if (!IsDeadPlayerValid(player)) return HookResult.Continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player?.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
SpawnExplosion(player);
|
||||
SpawnExplosion(player!);
|
||||
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
|
@ -34,7 +34,10 @@ namespace jRandomSkills
|
|||
var heProjectile = Utilities.CreateEntityByName<CHEGrenadeProjectile>("hegrenade_projectile");
|
||||
if (heProjectile == null || !heProjectile.IsValid) return;
|
||||
|
||||
Vector pos = player.PlayerPawn.Value.AbsOrigin;
|
||||
var pawn = player.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid || pawn.AbsOrigin == null) return;
|
||||
|
||||
Vector pos = pawn.AbsOrigin;
|
||||
pos.Z += 10;
|
||||
|
||||
heProjectile.TicksAtZeroVelocity = 100;
|
||||
|
|
@ -55,21 +58,15 @@ namespace jRandomSkills
|
|||
});
|
||||
}
|
||||
|
||||
private static bool IsDeadPlayerValid(CCSPlayerController player)
|
||||
private static bool IsDeadPlayerValid(CCSPlayerController? player)
|
||||
{
|
||||
return player != null && player.IsValid && player.PlayerPawn?.Value != null;
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#F5CB42", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float explosionRadius = 500.0f, int explosionDamage = 999) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float ExplosionRadius { get; set; }
|
||||
public int ExplosionDamage { get; set; }
|
||||
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#F5CB42", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float explosionRadius = 500.0f, int explosionDamage = 999) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
ExplosionRadius = explosionRadius;
|
||||
ExplosionDamage = explosionDamage;
|
||||
}
|
||||
public float ExplosionRadius { get; set; } = explosionRadius;
|
||||
public int ExplosionDamage { get; set; } = explosionDamage;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,10 +11,10 @@ namespace jRandomSkills
|
|||
public class Ninja : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Ninja;
|
||||
private static float idlePercentInvisibility = Config.GetValue<float>(skillName, "idlePercentInvisibility");
|
||||
private static float duckPercentInvisibility = Config.GetValue<float>(skillName, "duckPercentInvisibility");
|
||||
private static float knifePercentInvisibility = Config.GetValue<float>(skillName, "knifePercentInvisibility");
|
||||
private static Dictionary<nint, float> invisibilityChanged = new Dictionary<nint, float>();
|
||||
private static readonly float idlePercentInvisibility = Config.GetValue<float>(skillName, "idlePercentInvisibility");
|
||||
private static readonly float duckPercentInvisibility = Config.GetValue<float>(skillName, "duckPercentInvisibility");
|
||||
private static readonly float knifePercentInvisibility = Config.GetValue<float>(skillName, "knifePercentInvisibility");
|
||||
private static readonly Dictionary<nint, float> invisibilityChanged = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -31,9 +31,9 @@ namespace jRandomSkills
|
|||
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
if (!player.IsValid || player.PlayerPawn.Value == null) return HookResult.Continue;
|
||||
if (player == null || !player.IsValid || player.PlayerPawn.Value == null) return HookResult.Continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
DisableSkill(player);
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ namespace jRandomSkills
|
|||
{
|
||||
var player = @event.Userid;
|
||||
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player?.SteamID);
|
||||
|
||||
if (playerInfo?.Skill != skillName) return HookResult.Continue;
|
||||
UpdateNinja(player);
|
||||
|
|
@ -58,7 +58,7 @@ namespace jRandomSkills
|
|||
{
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
UpdateNinja(player);
|
||||
}
|
||||
|
|
@ -70,16 +70,24 @@ namespace jRandomSkills
|
|||
SetWeaponVisibility(player, 0);
|
||||
}
|
||||
|
||||
private static void UpdateNinja(CCSPlayerController player)
|
||||
private static void UpdateNinja(CCSPlayerController? player)
|
||||
{
|
||||
var flags = (PlayerFlags)player.PlayerPawn.Value.Flags;
|
||||
if (player == null || !player.IsValid) return;
|
||||
var pawn = player.PlayerPawn?.Value;
|
||||
if (pawn == null || !pawn.IsValid || pawn.LifeState != (byte)LifeState_t.LIFE_ALIVE) return;
|
||||
|
||||
var flags = (PlayerFlags)pawn.Flags;
|
||||
var buttons = player.Buttons;
|
||||
var activeWeapon = player.PlayerPawn.Value.WeaponServices.ActiveWeapon.Value;
|
||||
|
||||
var weaponServices = pawn.WeaponServices;
|
||||
if (weaponServices == null) return;
|
||||
|
||||
var activeWeapon = weaponServices.ActiveWeapon.Value;
|
||||
float percentInvisibility = 0;
|
||||
|
||||
if (buttons.HasFlag(PlayerButtons.Duck))
|
||||
percentInvisibility += duckPercentInvisibility;
|
||||
if (activeWeapon.DesignerName == "weapon_knife")
|
||||
if (activeWeapon != null && activeWeapon.DesignerName == "weapon_knife")
|
||||
percentInvisibility += knifePercentInvisibility;
|
||||
if (!buttons.HasFlag(PlayerButtons.Moveleft) && !buttons.HasFlag(PlayerButtons.Moveright) && !buttons.HasFlag(PlayerButtons.Forward) && !buttons.HasFlag(PlayerButtons.Back) && flags.HasFlag(PlayerFlags.FL_ONGROUND))
|
||||
percentInvisibility += idlePercentInvisibility;
|
||||
|
|
@ -108,10 +116,11 @@ namespace jRandomSkills
|
|||
{
|
||||
if (!Instance.IsPlayerValid(player)) return;
|
||||
var playerPawn = player.PlayerPawn.Value;
|
||||
if (playerPawn == null || !playerPawn.IsValid || playerPawn.WeaponServices == null) return;
|
||||
|
||||
var color = Color.FromArgb(Math.Max(255 - (int)(255 * percentInvisibility * 2), 0), 255, 255, 255);
|
||||
|
||||
foreach (var weapon in playerPawn.WeaponServices?.MyWeapons)
|
||||
foreach (var weapon in playerPawn.WeaponServices.MyWeapons)
|
||||
{
|
||||
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
|
||||
{
|
||||
|
|
@ -121,17 +130,11 @@ namespace jRandomSkills
|
|||
}
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#dedede", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float idlePercentInvisibility = .3f, float duckPercentInvisibility = .3f, float knifePercentInvisibility = .3f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float IdlePercentInvisibility { get; set; }
|
||||
public float DuckPercentInvisibility { get; set; }
|
||||
public float KnifePercentInvisibility { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#dedede", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float idlePercentInvisibility = .3f, float duckPercentInvisibility = .3f, float knifePercentInvisibility = .3f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
IdlePercentInvisibility = idlePercentInvisibility;
|
||||
DuckPercentInvisibility = duckPercentInvisibility;
|
||||
KnifePercentInvisibility = knifePercentInvisibility;
|
||||
}
|
||||
public float IdlePercentInvisibility { get; set; } = idlePercentInvisibility;
|
||||
public float DuckPercentInvisibility { get; set; } = duckPercentInvisibility;
|
||||
public float KnifePercentInvisibility { get; set; } = knifePercentInvisibility;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -20,12 +20,12 @@ namespace jRandomSkills
|
|||
var weapon = @event.Weapon;
|
||||
|
||||
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player?.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return HookResult.Continue;
|
||||
|
||||
if (weapon == "hegrenade" || weapon == "inferno")
|
||||
{
|
||||
SkillUtils.AddHealth(player.PlayerPawn.Value, damage);
|
||||
SkillUtils.AddHealth(player!.PlayerPawn.Value, damage);
|
||||
damage = 0;
|
||||
return HookResult.Stop;
|
||||
}
|
||||
|
|
@ -33,11 +33,8 @@ namespace jRandomSkills
|
|||
});
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#a38c1a", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#a38c1a", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -22,7 +22,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ namespace jRandomSkills
|
|||
|
||||
Instance.RegisterEventHandler<EventRoundEnd>((@event, info) =>
|
||||
{
|
||||
DisableSkill(null);
|
||||
Server.ExecuteCommand("weapon_accuracy_nospread 0");
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
||||
|
|
@ -55,14 +55,12 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
|
||||
if (playerInfo?.Skill == skillName)
|
||||
{
|
||||
var weapon = player.Pawn.Value.WeaponServices?.ActiveWeapon.Value;
|
||||
if (weapon == null) continue;
|
||||
|
||||
var pawn = player.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid || pawn.CameraServices == null) continue;
|
||||
pawn.AimPunchTickBase = 0;
|
||||
pawn.AimPunchTickFraction = 0f;
|
||||
pawn.CameraServices.CsViewPunchAngleTick = 0;
|
||||
|
|
@ -71,11 +69,8 @@ namespace jRandomSkills
|
|||
}
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#8a42f5", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#8a42f5", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,9 +11,9 @@ namespace jRandomSkills
|
|||
public class Noclip : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Noclip;
|
||||
private static float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
|
||||
private static float duration = Config.GetValue<float>(skillName, "duration");
|
||||
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = new Dictionary<ulong, PlayerSkillInfo>();
|
||||
private static readonly float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
|
||||
private static readonly float duration = Config.GetValue<float>(skillName, "duration");
|
||||
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -25,7 +25,7 @@ namespace jRandomSkills
|
|||
{
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
{
|
||||
EnableSkill(player);
|
||||
|
|
@ -45,11 +45,10 @@ namespace jRandomSkills
|
|||
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
if (SkillPlayerInfo.ContainsKey(player.SteamID))
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
|
@ -58,7 +57,7 @@ namespace jRandomSkills
|
|||
{
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
if (SkillPlayerInfo.TryGetValue(player.SteamID, out var skillInfo))
|
||||
UpdateHUD(player, skillInfo);
|
||||
|
|
@ -78,8 +77,7 @@ namespace jRandomSkills
|
|||
|
||||
public static void DisableSkill(CCSPlayerController player)
|
||||
{
|
||||
if (SkillPlayerInfo.ContainsKey(player.SteamID))
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
}
|
||||
|
||||
private static void UpdateHUD(CCSPlayerController player, PlayerSkillInfo skillInfo)
|
||||
|
|
@ -140,15 +138,10 @@ namespace jRandomSkills
|
|||
public DateTime Cooldown { get; set; }
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#44ebd4", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 30f, float duration = 2f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float Cooldown { get; set; }
|
||||
public float Duration { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#44ebd4", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 30f, float duration = 2f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
Cooldown = cooldown;
|
||||
Duration = duration;
|
||||
}
|
||||
public float Cooldown { get; set; } = cooldown;
|
||||
public float Duration { get; set; } = duration;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -37,7 +37,7 @@ namespace jRandomSkills
|
|||
CCSPlayerController attacker = attackerPawn.Controller.Value.As<CCSPlayerController>();
|
||||
CCSPlayerController victim = victimPawn.Controller.Value.As<CCSPlayerController>();
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
if (playerInfo == null) return HookResult.Continue;
|
||||
|
||||
if (playerInfo.Skill == skillName && attacker.PawnIsAlive)
|
||||
|
|
|
|||
|
|
@ -22,12 +22,12 @@ namespace jRandomSkills
|
|||
var hitgroup = (HitGroup_t)@event.Hitgroup;
|
||||
|
||||
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim)) return HookResult.Continue;
|
||||
var victimInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == victim.SteamID);
|
||||
var victimInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == victim?.SteamID);
|
||||
if (victimInfo == null || victimInfo.Skill != skillName) return HookResult.Continue;
|
||||
|
||||
HitGroup_t[] disabledHitbox = { HitGroup_t.HITGROUP_LEFTARM, HitGroup_t.HITGROUP_RIGHTARM, HitGroup_t.HITGROUP_LEFTLEG, HitGroup_t.HITGROUP_RIGHTLEG };
|
||||
HitGroup_t[] disabledHitbox = [HitGroup_t.HITGROUP_LEFTARM, HitGroup_t.HITGROUP_RIGHTARM, HitGroup_t.HITGROUP_LEFTLEG, HitGroup_t.HITGROUP_RIGHTLEG];
|
||||
if (hitgroup != HitGroup_t.HITGROUP_HEAD)
|
||||
RestoreHealth(victim, damage);
|
||||
RestoreHealth(victim!, damage);
|
||||
return HookResult.Stop;
|
||||
});
|
||||
}
|
||||
|
|
@ -35,6 +35,7 @@ namespace jRandomSkills
|
|||
private static void RestoreHealth(CCSPlayerController victim, float damage)
|
||||
{
|
||||
var playerPawn = victim.PlayerPawn.Value;
|
||||
if (playerPawn == null || !playerPawn.IsValid) return;
|
||||
var newHealth = playerPawn.Health + damage;
|
||||
|
||||
if (newHealth > 100)
|
||||
|
|
@ -44,11 +45,8 @@ namespace jRandomSkills
|
|||
Utilities.SetStateChanged(playerPawn, "CBaseEntity", "m_iHealth");
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#3c47de", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#3c47de", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,8 +11,8 @@ namespace jRandomSkills
|
|||
public class PawelJumper : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.PawelJumper;
|
||||
private static int extraJumpsMin = Config.GetValue<int>(skillName, "extraJumpsMin");
|
||||
private static int extraJumpsMax = Config.GetValue<int>(skillName, "extraJumpsMax");
|
||||
private static readonly int extraJumpsMin = Config.GetValue<int>(skillName, "extraJumpsMin");
|
||||
private static readonly int extraJumpsMax = Config.GetValue<int>(skillName, "extraJumpsMax");
|
||||
|
||||
private static readonly PlayerFlags[] LF = new PlayerFlags[64];
|
||||
private static readonly int?[] J = new int?[64];
|
||||
|
|
@ -27,7 +27,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) return;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
{
|
||||
GiveAdditionalJump(player);
|
||||
|
|
@ -39,10 +39,10 @@ namespace jRandomSkills
|
|||
public static void EnableSkill(CCSPlayerController player)
|
||||
{
|
||||
var playerPawn = player.PlayerPawn.Value;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerPawn == null) return;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerPawn == null || playerInfo == null) return;
|
||||
|
||||
var skillConfig = Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString());
|
||||
var skillConfig = Config.LoadedConfig.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString());
|
||||
if (skillConfig == null) return;
|
||||
|
||||
float extraJumps = (float)Instance.Random.Next(extraJumpsMin, extraJumpsMax + 1);
|
||||
|
|
@ -53,11 +53,13 @@ namespace jRandomSkills
|
|||
private static void GiveAdditionalJump(CCSPlayerController player)
|
||||
{
|
||||
var playerPawn = player.PlayerPawn.Value;
|
||||
if (playerPawn == null || !playerPawn.IsValid) return;
|
||||
|
||||
var flags = (PlayerFlags)playerPawn.Flags;
|
||||
var buttons = player.Buttons;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerPawn == null) return;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerPawn == null || playerInfo == null) return;
|
||||
|
||||
if ((LF[player.Slot] & PlayerFlags.FL_ONGROUND) != 0 && (flags & PlayerFlags.FL_ONGROUND) == 0 && (LB[player.Slot] & PlayerButtons.Jump) == 0 && (buttons & PlayerButtons.Jump) != 0)
|
||||
{
|
||||
|
|
@ -77,15 +79,10 @@ namespace jRandomSkills
|
|||
LB[player.Slot] = buttons;
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#FFA500", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int extraJumpsMin = 1, int extraJumpsMax = 4) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public int ExtraJumpsMin { get; set; }
|
||||
public int ExtraJumpsMax { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#FFA500", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int extraJumpsMin = 1, int extraJumpsMax = 4) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
ExtraJumpsMin = extraJumpsMin;
|
||||
ExtraJumpsMax = extraJumpsMax;
|
||||
}
|
||||
public int ExtraJumpsMin { get; set; } = extraJumpsMin;
|
||||
public int ExtraJumpsMax { get; set; } = extraJumpsMax;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ namespace jRandomSkills
|
|||
{
|
||||
if (!IsDeadPlayerValid(player)) continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -35,10 +35,9 @@ namespace jRandomSkills
|
|||
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
if (player == null || !player.IsValid || player.PlayerPawn.Value == null || !player.PlayerPawn.Value.IsValid) return HookResult.Continue;
|
||||
|
||||
if (player == null || !player.IsValid || !player.PlayerPawn.Value.IsValid) return HookResult.Continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
{
|
||||
if (Instance.Random.NextDouble() <= playerInfo.SkillChance)
|
||||
|
|
@ -55,7 +54,8 @@ namespace jRandomSkills
|
|||
|
||||
public static void EnableSkill(CCSPlayerController player)
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo == null) return;
|
||||
float newChance = (float)Instance.Random.NextDouble() * (Config.GetValue<float>(skillName, "ChanceTo") - Config.GetValue<float>(skillName, "ChanceFrom")) + Config.GetValue<float>(skillName, "ChanceFrom");
|
||||
playerInfo.SkillChance = newChance;
|
||||
newChance = (float)Math.Round(newChance, 2) * 100;
|
||||
|
|
@ -68,15 +68,10 @@ namespace jRandomSkills
|
|||
return player != null && player.IsValid && player.PlayerPawn?.Value != null;
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#ff5C0A", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float chanceFrom = .2f, float chanceTo = .4f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float ChanceFrom { get; set; }
|
||||
public float ChanceTo { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#ff5C0A", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float chanceFrom = .2f, float chanceTo = .4f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
ChanceFrom = chanceFrom;
|
||||
ChanceTo = chanceTo;
|
||||
}
|
||||
public float ChanceFrom { get; set; } = chanceFrom;
|
||||
public float ChanceTo { get; set; } = chanceTo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,8 +11,8 @@ namespace jRandomSkills
|
|||
public class Pilot : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Pilot;
|
||||
private static float maximumFuel = Config.GetValue<float>(skillName, "maximumFuel");
|
||||
private static readonly Dictionary<ulong, Pilot_PlayerInfo> PlayerPilotInfo = new Dictionary<ulong, Pilot_PlayerInfo>();
|
||||
private static readonly float maximumFuel = Config.GetValue<float>(skillName, "maximumFuel");
|
||||
private static readonly Dictionary<ulong, Pilot_PlayerInfo> PlayerPilotInfo = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -24,11 +24,9 @@ namespace jRandomSkills
|
|||
{
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
{
|
||||
EnableSkill(player);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -38,13 +36,10 @@ namespace jRandomSkills
|
|||
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
{
|
||||
if (PlayerPilotInfo.ContainsKey(player.SteamID))
|
||||
PlayerPilotInfo.Remove(player.SteamID);
|
||||
}
|
||||
PlayerPilotInfo.Remove(player.SteamID);
|
||||
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
|
@ -53,7 +48,7 @@ namespace jRandomSkills
|
|||
{
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
HandlePilot(player);
|
||||
}
|
||||
|
|
@ -73,8 +68,7 @@ namespace jRandomSkills
|
|||
|
||||
public static void DisableSkill(CCSPlayerController player)
|
||||
{
|
||||
if (PlayerPilotInfo.ContainsKey(player.SteamID))
|
||||
PlayerPilotInfo.Remove(player.SteamID);
|
||||
PlayerPilotInfo.Remove(player.SteamID);
|
||||
}
|
||||
|
||||
private static void HandlePilot(CCSPlayerController player)
|
||||
|
|
@ -155,11 +149,11 @@ namespace jRandomSkills
|
|||
QAngle eye_angle = playerPawn.EyeAngles;
|
||||
double pitch = (Math.PI / 180) * eye_angle.X;
|
||||
double yaw = (Math.PI / 180) * eye_angle.Y;
|
||||
Vector eye_vector = new Vector((float)(Math.Cos(yaw) * Math.Cos(pitch)), (float)(Math.Sin(yaw) * Math.Cos(pitch)), (float)(-Math.Sin(pitch)));
|
||||
Vector eye_vector = new((float)(Math.Cos(yaw) * Math.Cos(pitch)), (float)(Math.Sin(yaw) * Math.Cos(pitch)), (float)(-Math.Sin(pitch)));
|
||||
|
||||
Vector currentVelocity = playerPawn.AbsVelocity;
|
||||
|
||||
Vector jetpackVelocity = new Vector(
|
||||
Vector jetpackVelocity = new(
|
||||
eye_vector.X * 5.0f,
|
||||
eye_vector.Y * 5.0f,
|
||||
0.80f * 15.0f
|
||||
|
|
@ -183,13 +177,9 @@ namespace jRandomSkills
|
|||
public DateTime PilotStartTime { get; set; }
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#1466F5", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float maximumFuel = 100f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float MaximumFuel { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#1466F5", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float maximumFuel = 100f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
MaximumFuel = maximumFuel;
|
||||
}
|
||||
public float MaximumFuel { get; set; } = maximumFuel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@ namespace jRandomSkills
|
|||
public class Planter : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Planter;
|
||||
private static int extraC4BlowTime = Config.GetValue<int>(skillName, "extraC4BlowTime");
|
||||
private static readonly int extraC4BlowTime = Config.GetValue<int>(skillName, "extraC4BlowTime");
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -22,7 +22,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
Schema.SetSchemaValue<bool>(player.Pawn.Value.Handle, "CCSPlayerPawn", "m_bInBombZone", false);
|
||||
Schema.SetSchemaValue<bool>(player!.PlayerPawn!.Value!.Handle, "CCSPlayerPawn", "m_bInBombZone", false);
|
||||
}
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
|
@ -32,7 +32,7 @@ namespace jRandomSkills
|
|||
var player = @event.Userid;
|
||||
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player?.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return HookResult.Continue;
|
||||
|
||||
var plantedBomb = Utilities.FindAllEntitiesByDesignerName<CPlantedC4>("planted_c4").FirstOrDefault();
|
||||
|
|
@ -47,7 +47,8 @@ namespace jRandomSkills
|
|||
|
||||
public static void DisableSkill(CCSPlayerController player)
|
||||
{
|
||||
Schema.SetSchemaValue<bool>(player.Pawn.Value.Handle, "CCSPlayerPawn", "m_bInBombZone", false);
|
||||
if (!Instance.IsPlayerValid(player)) return;
|
||||
Schema.SetSchemaValue<bool>(player!.PlayerPawn.Value!.Handle, "CCSPlayerPawn", "m_bInBombZone", false);
|
||||
}
|
||||
|
||||
private static void OnTick()
|
||||
|
|
@ -55,20 +56,16 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
|
||||
if (playerInfo?.Skill == skillName)
|
||||
Schema.SetSchemaValue<bool>(player.Pawn.Value.Handle, "CCSPlayerPawn", "m_bInBombZone", true);
|
||||
Schema.SetSchemaValue<bool>(player!.PlayerPawn.Value!.Handle, "CCSPlayerPawn", "m_bInBombZone", true);
|
||||
}
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#7d7d7d", CsTeam onlyTeam = CsTeam.Terrorist, bool needsTeammates = false, int extraC4BlowTime = 60) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public int ExtraC4BlowTime { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#7d7d7d", CsTeam onlyTeam = CsTeam.Terrorist, bool needsTeammates = false, int extraC4BlowTime = 60) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
ExtraC4BlowTime = extraC4BlowTime;
|
||||
}
|
||||
public int ExtraC4BlowTime { get; set; } = extraC4BlowTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10,9 +10,9 @@ namespace jRandomSkills
|
|||
public class Poison : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Poison;
|
||||
private static float cooldown = Config.GetValue<float>(skillName, "Cooldown");
|
||||
private static int healthToDamage = Config.GetValue<int>(skillName, "Damage");
|
||||
private static HashSet<CCSPlayerController> poisonedPlayers = new HashSet<CCSPlayerController>();
|
||||
private static readonly float cooldown = Config.GetValue<float>(skillName, "Cooldown");
|
||||
private static readonly int healthToDamage = Config.GetValue<int>(skillName, "Damage");
|
||||
private static readonly HashSet<CCSPlayerController> poisonedPlayers = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -25,7 +25,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ namespace jRandomSkills
|
|||
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);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return;
|
||||
|
||||
if (playerInfo.SkillChance == 1)
|
||||
|
|
@ -84,7 +84,8 @@ namespace jRandomSkills
|
|||
|
||||
public static void EnableSkill(CCSPlayerController player)
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo == null) return;
|
||||
playerInfo.SkillChance = 0;
|
||||
|
||||
SkillUtils.PrintToChat(player, Localization.GetTranslation("poison") + ":", false);
|
||||
|
|
@ -106,15 +107,10 @@ namespace jRandomSkills
|
|||
poisonedPlayers.Remove(player);
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#902eff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 1, int damage = 1) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public int Damage { get; set; }
|
||||
public float Cooldown { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#902eff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 1, int damage = 1) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
Damage = damage;
|
||||
Cooldown = cooldown;
|
||||
}
|
||||
public int Damage { get; set; } = damage;
|
||||
public float Cooldown { get; set; } = cooldown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10,12 +10,12 @@ namespace jRandomSkills
|
|||
public class PrimaryBan : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.PrimaryBan;
|
||||
private static HashSet<ulong> bannedPlayers = new HashSet<ulong>();
|
||||
private static string[] disabledWeapons =
|
||||
{
|
||||
private static readonly HashSet<ulong> bannedPlayers = [];
|
||||
private static readonly string[] disabledWeapons =
|
||||
[
|
||||
"ak47", "m4a1", "m4a4", "m4a1_silencer", "famas", "galilar", "aug", "sg553", "mp9", "mac10", "bizon", "mp7", "ump45",
|
||||
"p90", "mp5sd", "ssg08", "awp", "scar20", "g3sg1", "nova", "xm1014", "mag7", "sawedoff", "m249", "negev"
|
||||
};
|
||||
];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -28,7 +28,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ namespace jRandomSkills
|
|||
{
|
||||
var player = @event.Userid;
|
||||
var weapon = @event.Item;
|
||||
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
if (!bannedPlayers.Contains(player.SteamID) || !disabledWeapons.Contains(weapon)) return HookResult.Continue;
|
||||
player.ExecuteClientCommand("slot3");
|
||||
return HookResult.Stop;
|
||||
|
|
@ -57,7 +57,7 @@ namespace jRandomSkills
|
|||
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);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return;
|
||||
|
||||
if (playerInfo.SkillChance == 1)
|
||||
|
|
@ -94,7 +94,8 @@ namespace jRandomSkills
|
|||
|
||||
public static void EnableSkill(CCSPlayerController player)
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo == null) return;
|
||||
playerInfo.SkillChance = 0;
|
||||
|
||||
SkillUtils.PrintToChat(player, Localization.GetTranslation("primaryban") + ":", false);
|
||||
|
|
@ -116,11 +117,8 @@ namespace jRandomSkills
|
|||
bannedPlayers.Remove(player.SteamID);
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#ffc061", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#ffc061", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -22,12 +22,12 @@ namespace jRandomSkills
|
|||
var hitgroup = (HitGroup_t)@event.Hitgroup;
|
||||
|
||||
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim)) return HookResult.Continue;
|
||||
var victimInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == victim.SteamID);
|
||||
var victimInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == victim?.SteamID);
|
||||
if (victimInfo == null || victimInfo.Skill != skillName) return HookResult.Continue;
|
||||
|
||||
HitGroup_t[] disabledHitbox = { HitGroup_t.HITGROUP_LEFTARM, HitGroup_t.HITGROUP_RIGHTARM, HitGroup_t.HITGROUP_LEFTLEG, HitGroup_t.HITGROUP_RIGHTLEG };
|
||||
HitGroup_t[] disabledHitbox = [HitGroup_t.HITGROUP_LEFTARM, HitGroup_t.HITGROUP_RIGHTARM, HitGroup_t.HITGROUP_LEFTLEG, HitGroup_t.HITGROUP_RIGHTLEG];
|
||||
if (disabledHitbox.Contains(hitgroup))
|
||||
RestoreHealth(victim, damage);
|
||||
RestoreHealth(victim!, damage);
|
||||
return HookResult.Stop;
|
||||
});
|
||||
}
|
||||
|
|
@ -35,6 +35,7 @@ namespace jRandomSkills
|
|||
private static void RestoreHealth(CCSPlayerController victim, float damage)
|
||||
{
|
||||
var playerPawn = victim.PlayerPawn.Value;
|
||||
if (playerPawn == null || !playerPawn.IsValid) return;
|
||||
var newHealth = playerPawn.Health + damage;
|
||||
|
||||
if (newHealth > 100)
|
||||
|
|
@ -44,11 +45,8 @@ namespace jRandomSkills
|
|||
Utilities.SetStateChanged(playerPawn, "CBaseEntity", "m_iHealth");
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#9c9c9c", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#9c9c9c", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,11 +11,11 @@ namespace jRandomSkills
|
|||
public class PsychicDefusing : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.PsychicDefusing;
|
||||
private static readonly Dictionary<CCSPlayerPawn, PlayerSkillInfo> SkillPlayerInfo = new Dictionary<CCSPlayerPawn, PlayerSkillInfo>();
|
||||
private static Vector bombLocation = null;
|
||||
private static float maxDefusingRange = Config.GetValue<float>(skillName, "maxDefusingRange");
|
||||
private static float defusingTime = Config.GetValue<float>(skillName, "defusingTime");
|
||||
private static float tickRate = 64f;
|
||||
private static readonly Dictionary<CCSPlayerPawn, PlayerSkillInfo> SkillPlayerInfo = [];
|
||||
private static Vector? bombLocation = null;
|
||||
private static readonly float maxDefusingRange = Config.GetValue<float>(skillName, "maxDefusingRange");
|
||||
private static readonly float defusingTime = Config.GetValue<float>(skillName, "defusingTime");
|
||||
private static readonly float tickRate = 64f;
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -28,7 +28,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -47,11 +47,14 @@ namespace jRandomSkills
|
|||
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var pawn = player.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid) return HookResult.Continue;
|
||||
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
if (SkillPlayerInfo.ContainsKey(player.PlayerPawn.Value))
|
||||
SkillPlayerInfo.Remove(player.PlayerPawn.Value);
|
||||
SkillPlayerInfo.Remove(pawn);
|
||||
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
|
@ -72,7 +75,7 @@ namespace jRandomSkills
|
|||
var player = skillInfo.Key;
|
||||
var info = skillInfo.Value;
|
||||
|
||||
if (SkillUtils.GetDistance(player.AbsOrigin, bombLocation) > maxDefusingRange)
|
||||
if (player.AbsOrigin == null || SkillUtils.GetDistance(player.AbsOrigin, bombLocation) > maxDefusingRange)
|
||||
{
|
||||
info.Defusing = false;
|
||||
info.DefusingTime = defusingTime;
|
||||
|
|
@ -96,14 +99,18 @@ namespace jRandomSkills
|
|||
SkillPlayerInfo.Clear();
|
||||
}
|
||||
|
||||
UpdateHUD(player.Controller.Value.As<CCSPlayerController>(), info);
|
||||
var playerController = player.Controller.Value;
|
||||
if (playerController == null || !player.Controller.IsValid) return;
|
||||
UpdateHUD(playerController.As<CCSPlayerController>(), info);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void EnableSkill(CCSPlayerController player)
|
||||
{
|
||||
SkillPlayerInfo[player.PlayerPawn.Value] = new PlayerSkillInfo
|
||||
var pawn = player.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid) return;
|
||||
SkillPlayerInfo[pawn] = new PlayerSkillInfo
|
||||
{
|
||||
SteamID = player.SteamID,
|
||||
Defusing = false,
|
||||
|
|
@ -113,8 +120,9 @@ namespace jRandomSkills
|
|||
|
||||
public static void DisableSkill(CCSPlayerController player)
|
||||
{
|
||||
if (SkillPlayerInfo.ContainsKey(player.PlayerPawn.Value))
|
||||
SkillPlayerInfo.Remove(player.PlayerPawn.Value);
|
||||
var pawn = player.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid) return;
|
||||
SkillPlayerInfo.Remove(pawn);
|
||||
}
|
||||
|
||||
private static void UpdateHUD(CCSPlayerController player, PlayerSkillInfo skillInfo)
|
||||
|
|
@ -139,15 +147,10 @@ namespace jRandomSkills
|
|||
public float DefusingTime { get; set; }
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#507529", CsTeam onlyTeam = CsTeam.CounterTerrorist, bool needsTeammates = false, float maxDefusingRange = 80f, float defusingTime = 10f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float MaxDefusingRange { get; set; }
|
||||
public float DefusingTime { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#507529", CsTeam onlyTeam = CsTeam.CounterTerrorist, bool needsTeammates = false, float maxDefusingRange = 80f, float defusingTime = 10f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
MaxDefusingRange = maxDefusingRange;
|
||||
DefusingTime = defusingTime;
|
||||
}
|
||||
public float MaxDefusingRange { get; set; } = maxDefusingRange;
|
||||
public float DefusingTime { get; set; } = defusingTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10,8 +10,8 @@ namespace jRandomSkills
|
|||
public class Push : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Push;
|
||||
private static float jumpVelocity = Config.GetValue<float>(skillName, "jumpVelocity");
|
||||
private static float pushVelocity = Config.GetValue<float>(skillName, "pushVelocity");
|
||||
private static readonly float jumpVelocity = Config.GetValue<float>(skillName, "jumpVelocity");
|
||||
private static readonly float pushVelocity = Config.GetValue<float>(skillName, "pushVelocity");
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -25,7 +25,7 @@ namespace jRandomSkills
|
|||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -42,12 +42,12 @@ namespace jRandomSkills
|
|||
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim) || attacker == victim)
|
||||
return HookResult.Continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == attacker?.SteamID);
|
||||
|
||||
if (playerInfo?.Skill == skillName && victim.PawnIsAlive)
|
||||
if (playerInfo?.Skill == skillName && victim!.PawnIsAlive)
|
||||
{
|
||||
if (Instance.Random.NextDouble() <= playerInfo.SkillChance)
|
||||
PushEnemy(victim, attacker.PlayerPawn.Value.EyeAngles);
|
||||
PushEnemy(victim, attacker!.PlayerPawn.Value!.EyeAngles);
|
||||
}
|
||||
|
||||
return HookResult.Continue;
|
||||
|
|
@ -56,7 +56,8 @@ namespace jRandomSkills
|
|||
|
||||
public static void EnableSkill(CCSPlayerController player)
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo == null) return;
|
||||
float newChance = (float)Instance.Random.NextDouble() * (Config.GetValue<float>(skillName, "ChanceTo") - Config.GetValue<float>(skillName, "ChanceFrom")) + Config.GetValue<float>(skillName, "ChanceFrom");
|
||||
playerInfo.SkillChance = newChance;
|
||||
newChance = (float)Math.Round(newChance, 2) * 100;
|
||||
|
|
@ -66,7 +67,7 @@ namespace jRandomSkills
|
|||
|
||||
private static void PushEnemy(CCSPlayerController player, QAngle attackerAngle)
|
||||
{
|
||||
if (player.PlayerPawn.Value.LifeState != (int)LifeState_t.LIFE_ALIVE)
|
||||
if (player.PlayerPawn.Value == null || !player.PlayerPawn.Value.IsValid || player.PlayerPawn.Value.LifeState != (int)LifeState_t.LIFE_ALIVE)
|
||||
return;
|
||||
|
||||
var currentPosition = player.PlayerPawn.Value.AbsOrigin;
|
||||
|
|
@ -78,19 +79,12 @@ namespace jRandomSkills
|
|||
player.PlayerPawn.Value.Teleport(currentPosition, currentAngles, newVelocity);
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#1e9ab0", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float chanceFrom = 1f, float chanceTo = 1f, float jumpVelocity = 300f, float pushVelocity = 400f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float ChanceFrom { get; set; }
|
||||
public float ChanceTo { get; set; }
|
||||
public float JumpVelocity { get; set; }
|
||||
public float PushVelocity { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#1e9ab0", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float chanceFrom = 1f, float chanceTo = 1f, float jumpVelocity = 300f, float pushVelocity = 400f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
ChanceFrom = chanceFrom;
|
||||
ChanceTo = chanceTo;
|
||||
JumpVelocity = jumpVelocity;
|
||||
PushVelocity = pushVelocity;
|
||||
}
|
||||
public float ChanceFrom { get; set; } = chanceFrom;
|
||||
public float ChanceTo { get; set; } = chanceTo;
|
||||
public float JumpVelocity { get; set; } = jumpVelocity;
|
||||
public float PushVelocity { get; set; } = pushVelocity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ namespace jRandomSkills
|
|||
public class Pyro : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Pyro;
|
||||
private static float regenerationMultiplier = Config.GetValue<float>(skillName, "regenerationMultiplier");
|
||||
private static readonly float regenerationMultiplier = Config.GetValue<float>(skillName, "regenerationMultiplier");
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -23,7 +23,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -39,10 +39,10 @@ namespace jRandomSkills
|
|||
string weapon = @event.Weapon;
|
||||
|
||||
if (weapon != "inferno" || !Instance.IsPlayerValid(victim)) return HookResult.Continue;
|
||||
var victimInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == victim.SteamID);
|
||||
var victimInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == victim?.SteamID);
|
||||
if (victimInfo == null || victimInfo.Skill != skillName) return HookResult.Continue;
|
||||
|
||||
RestoreHealth(victim, damage * regenerationMultiplier);
|
||||
RestoreHealth(victim!, damage * regenerationMultiplier);
|
||||
return HookResult.Stop;
|
||||
});
|
||||
}
|
||||
|
|
@ -55,6 +55,7 @@ namespace jRandomSkills
|
|||
private static void RestoreHealth(CCSPlayerController victim, float damage)
|
||||
{
|
||||
var playerPawn = victim.PlayerPawn.Value;
|
||||
if (playerPawn == null || !playerPawn.IsValid) return;
|
||||
var newHealth = playerPawn.Health + damage;
|
||||
|
||||
if (newHealth > 100)
|
||||
|
|
@ -64,13 +65,9 @@ namespace jRandomSkills
|
|||
Utilities.SetStateChanged(playerPawn, "CBaseEntity", "m_iHealth");
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#3c47de", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float regenerationMultiplier = 1.5f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float RegenerationMultiplier { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#3c47de", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float regenerationMultiplier = 1.5f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
RegenerationMultiplier = regenerationMultiplier;
|
||||
}
|
||||
public float RegenerationMultiplier { get; set; } = regenerationMultiplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -22,14 +22,17 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
|
||||
if (playerInfo?.Skill == skillName)
|
||||
{
|
||||
var weapon = player.Pawn.Value.WeaponServices?.ActiveWeapon.Value;
|
||||
if (weapon == null) continue;
|
||||
|
||||
var pawn = player.PlayerPawn.Value;
|
||||
var pawn = player.PlayerPawn.Value!;
|
||||
var weaponServices = pawn.WeaponServices;
|
||||
if (weaponServices == null || weaponServices.ActiveWeapon == null || !weaponServices.ActiveWeapon.IsValid) continue;
|
||||
|
||||
var weapon = weaponServices.ActiveWeapon.Value;
|
||||
if (weapon == null || !weapon.IsValid || pawn.CameraServices == null) continue;
|
||||
|
||||
pawn.AimPunchTickBase = 0;
|
||||
pawn.AimPunchTickFraction = 0f;
|
||||
pawn.CameraServices.CsViewPunchAngleTick = 0;
|
||||
|
|
@ -41,11 +44,8 @@ namespace jRandomSkills
|
|||
}
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#8a42f5", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#8a42f5", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ namespace jRandomSkills
|
|||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
{
|
||||
SetEnemiesVisibleOnRadar(player);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,16 +12,16 @@ namespace jRandomSkills
|
|||
public class RandomWeapon : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.RandomWeapon;
|
||||
private static float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
|
||||
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = new Dictionary<ulong, PlayerSkillInfo>();
|
||||
private static readonly float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
|
||||
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = [];
|
||||
|
||||
private static string[] pistols = { "weapon_deagle", "weapon_revolver", "weapon_glock", "weapon_usp_silencer",
|
||||
"weapon_cz75a", "weapon_fiveseven", "weapon_p250", "weapon_tec9", "weapon_elite", "weapon_hkp2000" };
|
||||
private static readonly string[] pistols = [ "weapon_deagle", "weapon_revolver", "weapon_glock", "weapon_usp_silencer",
|
||||
"weapon_cz75a", "weapon_fiveseven", "weapon_p250", "weapon_tec9", "weapon_elite", "weapon_hkp2000" ];
|
||||
|
||||
private static string[] rifles = { "weapon_mp9", "weapon_mac10", "weapon_bizon", "weapon_mp7", "weapon_ump45", "weapon_p90",
|
||||
private static readonly string[] rifles = [ "weapon_mp9", "weapon_mac10", "weapon_bizon", "weapon_mp7", "weapon_ump45", "weapon_p90",
|
||||
"weapon_mp5sd", "weapon_famas", "weapon_galilar", "weapon_m4a1", "weapon_m4a1_silencer", "weapon_ak47",
|
||||
"weapon_aug", "weapon_sg553", "weapon_ssg08", "weapon_awp", "weapon_scar20", "weapon_g3sg1",
|
||||
"weapon_nova", "weapon_xm1014", "weapon_mag7", "weapon_sawedoff", "weapon_m249", "weapon_negev" };
|
||||
"weapon_nova", "weapon_xm1014", "weapon_mag7", "weapon_sawedoff", "weapon_m249", "weapon_negev" ];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -33,7 +33,7 @@ namespace jRandomSkills
|
|||
{
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
{
|
||||
EnableSkill(player);
|
||||
|
|
@ -53,11 +53,10 @@ namespace jRandomSkills
|
|||
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
if (SkillPlayerInfo.ContainsKey(player.SteamID))
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
|
@ -66,7 +65,7 @@ namespace jRandomSkills
|
|||
{
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
if (SkillPlayerInfo.TryGetValue(player.SteamID, out var skillInfo))
|
||||
UpdateHUD(player, skillInfo);
|
||||
|
|
@ -86,8 +85,7 @@ namespace jRandomSkills
|
|||
|
||||
public static void DisableSkill(CCSPlayerController player)
|
||||
{
|
||||
if (SkillPlayerInfo.ContainsKey(player.SteamID))
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
}
|
||||
|
||||
private static void UpdateHUD(CCSPlayerController player, PlayerSkillInfo skillInfo)
|
||||
|
|
@ -132,15 +130,18 @@ namespace jRandomSkills
|
|||
|
||||
private static void RemoveAndGiveWeapon(CCSPlayerController player)
|
||||
{
|
||||
List<string> playerWeapons = new List<string>();
|
||||
foreach (var item in player?.PlayerPawn?.Value?.WeaponServices?.MyWeapons)
|
||||
if (!string.IsNullOrEmpty(item?.Value?.DesignerName))
|
||||
playerWeapons.Add(item?.Value?.DesignerName);
|
||||
var pawn = player.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid || pawn.WeaponServices == null) return;
|
||||
|
||||
List<string> playerWeapons = [];
|
||||
foreach (var item in pawn.WeaponServices.MyWeapons)
|
||||
if (item != null && item.IsValid && item.Value != null && item.Value.IsValid && !string.IsNullOrEmpty(item.Value.DesignerName))
|
||||
playerWeapons.Add(item.Value.DesignerName);
|
||||
|
||||
if (playerWeapons.Count == 0)
|
||||
return;
|
||||
|
||||
List<string> weaponList = new List<string>(pistols.Concat(rifles));
|
||||
List<string> weaponList = new(pistols.Concat(rifles));
|
||||
weaponList.RemoveAll(w => playerWeapons.Contains(w));
|
||||
|
||||
if (weaponList.Count == 0)
|
||||
|
|
@ -154,9 +155,9 @@ namespace jRandomSkills
|
|||
|
||||
if (!string.IsNullOrEmpty(weaponToRemove))
|
||||
{
|
||||
foreach (var item in player.PlayerPawn.Value.WeaponServices.MyWeapons)
|
||||
foreach (var item in pawn.WeaponServices.MyWeapons)
|
||||
{
|
||||
if (item != null && item.Value != null && item.Value.DesignerName == weaponToRemove)
|
||||
if (item != null && item.IsValid && item.Value != null && item.Value.IsValid && item.Value.DesignerName == weaponToRemove)
|
||||
item.Value.Remove();
|
||||
}
|
||||
}
|
||||
|
|
@ -174,13 +175,9 @@ namespace jRandomSkills
|
|||
public DateTime Cooldown { get; set; }
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#e0873a", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 15f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float Cooldown { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#e0873a", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 15f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
Cooldown = cooldown;
|
||||
}
|
||||
public float Cooldown { get; set; } = cooldown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10,8 +10,8 @@ namespace jRandomSkills
|
|||
public class ReZombie : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.ReZombie;
|
||||
private static int zombieHealth = Config.GetValue<int>(skillName, "zombieHealth");
|
||||
private static HashSet<CCSPlayerController> zombies = new HashSet<CCSPlayerController>();
|
||||
private static readonly int zombieHealth = Config.GetValue<int>(skillName, "zombieHealth");
|
||||
private static readonly HashSet<CCSPlayerController> zombies = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -21,7 +21,7 @@ namespace jRandomSkills
|
|||
{
|
||||
var player = @event.Userid;
|
||||
var weapon = @event.Item;
|
||||
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
if (!zombies.Contains(player) || weapon == "c4") return HookResult.Continue;
|
||||
player.ExecuteClientCommand("slot3");
|
||||
return HookResult.Stop;
|
||||
|
|
@ -38,14 +38,15 @@ namespace jRandomSkills
|
|||
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
if (player == null || !player.IsValid || !player.PlayerPawn.Value.IsValid || zombies.Contains(player)) return HookResult.Continue;
|
||||
if (player == null || !player.IsValid || player.PlayerPawn.Value == null || !player.PlayerPawn.Value.IsValid || zombies.Contains(player)) return HookResult.Continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return HookResult.Continue;
|
||||
|
||||
var pawn = player.PlayerPawn.Value;
|
||||
Vector deadPosition = new Vector(pawn.AbsOrigin.X, pawn.AbsOrigin.Y, pawn.AbsOrigin.Z);
|
||||
QAngle deadRotation = new QAngle(pawn.EyeAngles.X, pawn.EyeAngles.Y, pawn.EyeAngles.Z);
|
||||
if (pawn.AbsOrigin == null) return HookResult.Continue;
|
||||
Vector deadPosition = new(pawn.AbsOrigin.X, pawn.AbsOrigin.Y, pawn.AbsOrigin.Z);
|
||||
QAngle deadRotation = new(pawn.EyeAngles.X, pawn.EyeAngles.Y, pawn.EyeAngles.Z);
|
||||
|
||||
player.Respawn();
|
||||
Instance.AddTimer(.2f, () => {
|
||||
|
|
@ -69,6 +70,7 @@ namespace jRandomSkills
|
|||
|
||||
public static void DisableSkill(CCSPlayerController player)
|
||||
{
|
||||
if (player == null || !player.IsValid || player.PlayerPawn.Value == null || !player.PlayerPawn.Value.IsValid) return;
|
||||
zombies.Remove(player);
|
||||
SetPlayerColor(player.PlayerPawn.Value, true);
|
||||
}
|
||||
|
|
@ -80,13 +82,9 @@ namespace jRandomSkills
|
|||
Utilities.SetStateChanged(pawn, "CBaseModelEntity", "m_clrRender");
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#ff5C0A", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int zombieHealth = 200) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public int ZombieHealth { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#ff5C0A", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int zombieHealth = 200) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
ZombieHealth = zombieHealth;
|
||||
}
|
||||
public int ZombieHealth { get; set; } = zombieHealth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,8 +11,8 @@ namespace jRandomSkills
|
|||
public class ReactiveArmor : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.ReactiveArmor;
|
||||
private static float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
|
||||
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = new Dictionary<ulong, PlayerSkillInfo>();
|
||||
private static readonly float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
|
||||
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -24,7 +24,7 @@ namespace jRandomSkills
|
|||
{
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -42,11 +42,10 @@ namespace jRandomSkills
|
|||
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
if (SkillPlayerInfo.ContainsKey(player.SteamID))
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
|
@ -55,7 +54,7 @@ namespace jRandomSkills
|
|||
{
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
if (SkillPlayerInfo.TryGetValue(player.SteamID, out var skillInfo))
|
||||
UpdateHUD(player, skillInfo);
|
||||
|
|
@ -69,7 +68,7 @@ namespace jRandomSkills
|
|||
int damage = @event.DmgHealth;
|
||||
|
||||
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim)) return HookResult.Continue;
|
||||
if (SkillPlayerInfo.TryGetValue(victim.SteamID, out var skillInfo))
|
||||
if (SkillPlayerInfo.TryGetValue(victim!.SteamID, out var skillInfo))
|
||||
{
|
||||
if (!victim.IsValid || !victim.PawnIsAlive || !skillInfo.CanUse) return HookResult.Continue;
|
||||
skillInfo.CanUse = false;
|
||||
|
|
@ -94,8 +93,7 @@ namespace jRandomSkills
|
|||
|
||||
public static void DisableSkill(CCSPlayerController player)
|
||||
{
|
||||
if (SkillPlayerInfo.ContainsKey(player.SteamID))
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
}
|
||||
|
||||
private static void UpdateHUD(CCSPlayerController player, PlayerSkillInfo skillInfo)
|
||||
|
|
@ -124,6 +122,7 @@ namespace jRandomSkills
|
|||
private static void RestoreHealth(CCSPlayerController victim, float damage)
|
||||
{
|
||||
var playerPawn = victim.PlayerPawn.Value;
|
||||
if (playerPawn == null || !playerPawn.IsValid) return;
|
||||
var newHealth = playerPawn.Health + damage;
|
||||
|
||||
if (newHealth > 100)
|
||||
|
|
@ -140,13 +139,9 @@ namespace jRandomSkills
|
|||
public DateTime Cooldown { get; set; }
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#3cded3", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 15) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float Cooldown { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#3cded3", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 15) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
Cooldown = cooldown;
|
||||
}
|
||||
public float Cooldown { get; set; } = cooldown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ namespace jRandomSkills
|
|||
if (Server.TickCount % (int)(64 * cooldown) != 0) return;
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
|
||||
var pawn = player.PlayerPawn.Value;
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ namespace jRandomSkills
|
|||
public class Replicator : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Replicator;
|
||||
private static float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
|
||||
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = new Dictionary<ulong, PlayerSkillInfo>();
|
||||
private static readonly float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
|
||||
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -27,7 +27,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) return;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -45,11 +45,10 @@ namespace jRandomSkills
|
|||
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
if (SkillPlayerInfo.ContainsKey(player.SteamID))
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
||||
|
|
@ -57,7 +56,7 @@ namespace jRandomSkills
|
|||
{
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
if (SkillPlayerInfo.TryGetValue(player.SteamID, out var skillInfo))
|
||||
UpdateHUD(player, skillInfo);
|
||||
|
|
@ -79,8 +78,7 @@ namespace jRandomSkills
|
|||
|
||||
public static void DisableSkill(CCSPlayerController player)
|
||||
{
|
||||
if (SkillPlayerInfo.ContainsKey(player.SteamID))
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
}
|
||||
|
||||
private static void UpdateHUD(CCSPlayerController player, PlayerSkillInfo skillInfo)
|
||||
|
|
@ -127,7 +125,7 @@ namespace jRandomSkills
|
|||
{
|
||||
var playerPawn = player.PlayerPawn.Value;
|
||||
var replica = Utilities.CreateEntityByName<CDynamicProp>("prop_dynamic");
|
||||
if (replica == null)
|
||||
if (replica == null || playerPawn == null || !playerPawn.IsValid || playerPawn.AbsOrigin == null || playerPawn.AbsRotation == null)
|
||||
return;
|
||||
|
||||
float distance = 40;
|
||||
|
|
@ -140,7 +138,7 @@ namespace jRandomSkills
|
|||
replica.Flags |= (uint)Flags_t.FL_DUCKING;
|
||||
replica.CBodyComponent!.SceneNode!.Owner!.Entity!.Flags = (uint)(replica.CBodyComponent!.SceneNode!.Owner!.Entity!.Flags & ~(1 << 2));
|
||||
replica.SetModel(playerPawn!.CBodyComponent!.SceneNode!.GetSkeletonInstance().ModelState.ModelName);
|
||||
replica.Entity.Name = replica.Globalname = $"Replica_{Server.TickCount}_{(player.Team == CsTeam.CounterTerrorist ? "CT" : "TT")}";
|
||||
replica.Entity!.Name = replica.Globalname = $"Replica_{Server.TickCount}_{(player.Team == CsTeam.CounterTerrorist ? "CT" : "TT")}";
|
||||
replica.Teleport(pos, playerPawn.AbsRotation, null);
|
||||
replica.DispatchSpawn();
|
||||
replica.AcceptInput("EnableCollision");
|
||||
|
|
@ -154,7 +152,7 @@ namespace jRandomSkills
|
|||
if (param == null || param.Entity == null || param2 == null || param2.Attacker == null || param2.Attacker.Value == null)
|
||||
return HookResult.Continue;
|
||||
|
||||
CCSPlayerPawn attackerPawn = new CCSPlayerPawn(param2.Attacker.Value.Handle);
|
||||
CCSPlayerPawn attackerPawn = new(param2.Attacker.Value.Handle);
|
||||
if (string.IsNullOrEmpty(param.Entity.Name)) return HookResult.Continue;
|
||||
if (!param.Entity.Name.StartsWith("Replica_")) return HookResult.Continue;
|
||||
|
||||
|
|
@ -176,13 +174,9 @@ namespace jRandomSkills
|
|||
public DateTime Cooldown { get; set; }
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#a3000b", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 15f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float Cooldown { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#a3000b", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 15f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
Cooldown = cooldown;
|
||||
}
|
||||
public float Cooldown { get; set; } = cooldown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,8 +11,8 @@ namespace jRandomSkills
|
|||
public class Retreat : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Retreat;
|
||||
private static float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
|
||||
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = new Dictionary<ulong, PlayerSkillInfo>();
|
||||
private static readonly float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
|
||||
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -24,7 +24,7 @@ namespace jRandomSkills
|
|||
{
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
{
|
||||
EnableSkill(player);
|
||||
|
|
@ -44,11 +44,10 @@ namespace jRandomSkills
|
|||
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
|
||||
{
|
||||
var player = @event.Userid;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (player == null || !player.IsValid) return HookResult.Continue;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
if (SkillPlayerInfo.ContainsKey(player.SteamID))
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
|
@ -57,7 +56,7 @@ namespace jRandomSkills
|
|||
{
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
if (SkillPlayerInfo.TryGetValue(player.SteamID, out var skillInfo))
|
||||
UpdateHUD(player, skillInfo);
|
||||
|
|
@ -77,8 +76,7 @@ namespace jRandomSkills
|
|||
|
||||
public static void DisableSkill(CCSPlayerController player)
|
||||
{
|
||||
if (SkillPlayerInfo.ContainsKey(player.SteamID))
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
SkillPlayerInfo.Remove(player.SteamID);
|
||||
}
|
||||
|
||||
private static void UpdateHUD(CCSPlayerController player, PlayerSkillInfo skillInfo)
|
||||
|
|
@ -121,16 +119,15 @@ namespace jRandomSkills
|
|||
}
|
||||
}
|
||||
|
||||
private static Vector GetSpawnVector(CCSPlayerController player)
|
||||
private static Vector? GetSpawnVector(CCSPlayerController player)
|
||||
{
|
||||
var abs = player.PlayerPawn.Value.AbsOrigin;
|
||||
var spawns = Utilities.FindAllEntitiesByDesignerName<SpawnPoint>(player.Team == CsTeam.Terrorist ? "info_player_terrorist" : "info_player_counterterrorist").ToList();
|
||||
if (spawns.Any())
|
||||
if (spawns.Count != 0)
|
||||
{
|
||||
var randomSpawn = spawns[Instance.Random.Next(spawns.Count)];
|
||||
return randomSpawn.AbsOrigin;
|
||||
}
|
||||
return new Vector(abs.X, abs.Y, abs.Z);
|
||||
return null;
|
||||
}
|
||||
|
||||
public class PlayerSkillInfo
|
||||
|
|
@ -140,13 +137,9 @@ namespace jRandomSkills
|
|||
public DateTime Cooldown { get; set; }
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#a86eff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 15f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float Cooldown { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#a86eff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 15f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
Cooldown = cooldown;
|
||||
}
|
||||
public float Cooldown { get; set; } = cooldown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@ namespace jRandomSkills
|
|||
public class ReturnToSender : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.ReturnToSender;
|
||||
private static HashSet<nint> playersToSender = new HashSet<nint>();
|
||||
private static readonly HashSet<nint> playersToSender = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -28,13 +28,15 @@ namespace jRandomSkills
|
|||
int damage = @event.DmgHealth;
|
||||
|
||||
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim) || attacker == victim) return HookResult.Continue;
|
||||
var attackerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
var attackerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == attacker?.SteamID);
|
||||
if (attackerInfo == null || attackerInfo.Skill != skillName) return HookResult.Continue;
|
||||
|
||||
if (playersToSender.TryGetValue(victim.Handle, out _))
|
||||
if (playersToSender.TryGetValue(victim!.Handle, out _))
|
||||
return HookResult.Continue;
|
||||
|
||||
victim.PlayerPawn.Value.Teleport(GetSpawnVector(victim));
|
||||
var spawn = GetSpawnVector(victim);
|
||||
if (spawn == null) return HookResult.Continue;
|
||||
victim!.PlayerPawn!.Value!.Teleport(spawn);
|
||||
playersToSender.Add(victim.Handle);
|
||||
return HookResult.Stop;
|
||||
});
|
||||
|
|
@ -45,23 +47,19 @@ namespace jRandomSkills
|
|||
playersToSender.Remove(player.Handle);
|
||||
}
|
||||
|
||||
private static Vector GetSpawnVector(CCSPlayerController player)
|
||||
private static Vector? GetSpawnVector(CCSPlayerController player)
|
||||
{
|
||||
var abs = player.PlayerPawn.Value.AbsOrigin;
|
||||
var spawns = Utilities.FindAllEntitiesByDesignerName<SpawnPoint>(player.Team == CsTeam.Terrorist ? "info_player_terrorist" : "info_player_counterterrorist").ToList();
|
||||
if (spawns.Any())
|
||||
if (spawns.Count != 0)
|
||||
{
|
||||
var randomSpawn = spawns[Instance.Random.Next(spawns.Count)];
|
||||
return randomSpawn.AbsOrigin;
|
||||
}
|
||||
return new Vector(abs.X, abs.Y, abs.Z);
|
||||
return null;
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#a68132", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#a68132", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,8 +9,8 @@ namespace jRandomSkills
|
|||
public class RichBoy : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.RichBoy;
|
||||
private static int minMoney = Config.GetValue<int>(skillName, "minMoney");
|
||||
private static int maxMoney = Config.GetValue<int>(skillName, "maxMoney");
|
||||
private static readonly int minMoney = Config.GetValue<int>(skillName, "minMoney");
|
||||
private static readonly int maxMoney = Config.GetValue<int>(skillName, "maxMoney");
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -22,7 +22,7 @@ namespace jRandomSkills
|
|||
{
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
|
||||
if (playerInfo?.Skill == skillName)
|
||||
{
|
||||
|
|
@ -38,7 +38,8 @@ namespace jRandomSkills
|
|||
|
||||
public static void EnableSkill(CCSPlayerController player)
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo == null) return;
|
||||
int moneyBonus = Instance.Random.Next(minMoney, maxMoney);
|
||||
playerInfo.SkillChance = moneyBonus;
|
||||
AddMoney(player, moneyBonus);
|
||||
|
|
@ -46,29 +47,25 @@ namespace jRandomSkills
|
|||
|
||||
public static void DisableSkill(CCSPlayerController player)
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
AddMoney(player, -(int)playerInfo.SkillChance);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo == null) return;
|
||||
AddMoney(player, -(int)(playerInfo.SkillChance ?? 0));
|
||||
}
|
||||
|
||||
private static void AddMoney(CCSPlayerController player, int money)
|
||||
{
|
||||
var moneyServices = player?.InGameMoneyServices;
|
||||
|
||||
if (player == null || !player.IsValid) return;
|
||||
var moneyServices = player.InGameMoneyServices;
|
||||
if (moneyServices == null) return;
|
||||
|
||||
moneyServices.Account = Math.Max(moneyServices.Account + money, 0);
|
||||
Utilities.SetStateChanged(player, "CCSPlayerController", "m_pInGameMoneyServices");
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#D4AF37", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int minMoney = 5000, int maxMoney = 15000) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public int MinMoney { get; set; }
|
||||
public int MaxMoney { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#D4AF37", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int minMoney = 5000, int maxMoney = 15000) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
MinMoney = minMoney;
|
||||
MaxMoney = maxMoney;
|
||||
}
|
||||
public int MinMoney { get; set; } = minMoney;
|
||||
public int MaxMoney { get; set; } = maxMoney;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@ namespace jRandomSkills
|
|||
public class RobinHood : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.RobinHood;
|
||||
private static int moneyMultiplier = Config.GetValue<int>(skillName, "moneyMultiplier");
|
||||
private static readonly int moneyMultiplier = Config.GetValue<int>(skillName, "moneyMultiplier");
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -22,11 +22,11 @@ namespace jRandomSkills
|
|||
var damage = @event.DmgHealth;
|
||||
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim) || attacker == victim) return HookResult.Continue;
|
||||
|
||||
var attackerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
var attackerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == attacker?.SteamID);
|
||||
if (attackerInfo?.Skill != skillName) return HookResult.Continue;
|
||||
|
||||
int moneyToSteal = damage * moneyMultiplier;
|
||||
StealMoney(victim, attacker, moneyToSteal);
|
||||
StealMoney(victim!, attacker!, moneyToSteal);
|
||||
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
|
@ -40,19 +40,15 @@ namespace jRandomSkills
|
|||
|
||||
var moneyToAdd = victimMoneyServices.Account < money ? victimMoneyServices.Account : money;
|
||||
victimMoneyServices.Account = Math.Max(victimMoneyServices.Account - money, 0);
|
||||
Utilities.SetStateChanged(victim, "CCSPlayerController", "m_pInGameMoneyServices");
|
||||
Utilities.SetStateChanged(victim!, "CCSPlayerController", "m_pInGameMoneyServices");
|
||||
|
||||
attackerMoneyServices.Account = Math.Min(attackerMoneyServices.Account + moneyToAdd, 16000);
|
||||
Utilities.SetStateChanged(attacker, "CCSPlayerController", "m_pInGameMoneyServices");
|
||||
Utilities.SetStateChanged(attacker!, "CCSPlayerController", "m_pInGameMoneyServices");
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#119125", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int moneyMultiplier = 35) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public int MoneyMultiplier { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#119125", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int moneyMultiplier = 35) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
MoneyMultiplier = moneyMultiplier;
|
||||
}
|
||||
public int MoneyMultiplier { get; set; } = moneyMultiplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,10 +9,10 @@ namespace jRandomSkills
|
|||
public class Rubber: ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Rubber;
|
||||
private static float rubberTime = Config.GetValue<float>(skillName, "slownessTime");
|
||||
private static float rubberModifier = Config.GetValue<float>(skillName, "slownessModifier");
|
||||
private static readonly float rubberTime = Config.GetValue<float>(skillName, "slownessTime");
|
||||
private static readonly float rubberModifier = Config.GetValue<float>(skillName, "slownessModifier");
|
||||
|
||||
private static Dictionary<CCSPlayerPawn, float> playersToSlow = new Dictionary<CCSPlayerPawn, float>();
|
||||
private static readonly Dictionary<CCSPlayerPawn, float> playersToSlow = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -24,9 +24,9 @@ namespace jRandomSkills
|
|||
var victim = @event.Userid;
|
||||
|
||||
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim) || attacker == victim) return HookResult.Continue;
|
||||
var attackerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
var attackerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == attacker?.SteamID);
|
||||
|
||||
var victimPawn = victim.PlayerPawn.Value;
|
||||
var victimPawn = victim!.PlayerPawn.Value;
|
||||
if (victimPawn == null || !victimPawn.IsValid) return HookResult.Continue;
|
||||
|
||||
if (attackerInfo?.Skill == skillName)
|
||||
|
|
@ -65,15 +65,10 @@ namespace jRandomSkills
|
|||
pawn.VelocityModifier = rubberModifier;
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#8B4513", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float slownessTime = 2f, float slownessModifier = .2f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float SlownessTime { get; set; }
|
||||
public float SlownessModifier { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#8B4513", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float slownessTime = 2f, float slownessModifier = .2f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
SlownessTime = slownessTime;
|
||||
SlownessModifier = slownessModifier;
|
||||
}
|
||||
public float SlownessTime { get; set; } = slownessTime;
|
||||
public float SlownessModifier { get; set; } = slownessModifier;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -20,12 +20,12 @@ namespace jRandomSkills
|
|||
|
||||
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player?.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
{
|
||||
var bombEntities = Utilities.FindAllEntitiesByDesignerName<CC4>("weapon_c4").ToList();
|
||||
|
||||
if (bombEntities.Any())
|
||||
if (bombEntities.Count != 0)
|
||||
{
|
||||
var bomb = bombEntities.FirstOrDefault();
|
||||
if (bomb != null)
|
||||
|
|
@ -45,7 +45,7 @@ namespace jRandomSkills
|
|||
|
||||
if (Instance.IsPlayerValid(player))
|
||||
{
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player?.SteamID);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
{
|
||||
var plantedBomb = Utilities.FindAllEntitiesByDesignerName<CPlantedC4>("planted_c4").FirstOrDefault();
|
||||
|
|
@ -63,11 +63,8 @@ namespace jRandomSkills
|
|||
});
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#8A2BE2", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#8A2BE2", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,8 +9,8 @@ namespace jRandomSkills
|
|||
public class SecondLife : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.SecondLife;
|
||||
private static int secondLifeHealth = Config.GetValue<int>(skillName, "startHealth");
|
||||
private static HashSet<nint> secondLifePlayers = new HashSet<nint>();
|
||||
private static readonly int secondLifeHealth = Config.GetValue<int>(skillName, "startHealth");
|
||||
private static readonly HashSet<nint> secondLifePlayers = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -24,7 +24,7 @@ namespace jRandomSkills
|
|||
{
|
||||
if (player == null || !player.IsValid || player.PlayerPawn?.Value == null) continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -45,16 +45,18 @@ namespace jRandomSkills
|
|||
int damage = @event.DmgHealth;
|
||||
|
||||
if (!Instance.IsPlayerValid(victim)) return HookResult.Continue;
|
||||
var victimInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == victim.SteamID);
|
||||
var victimInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == victim?.SteamID);
|
||||
if (victimInfo == null || victimInfo.Skill != skillName) return HookResult.Continue;
|
||||
|
||||
var victimPawn = victim.PlayerPawn.Value;
|
||||
if (victimPawn.Health > 0 || secondLifePlayers.TryGetValue(victim.Handle, out _) == true)
|
||||
var victimPawn = victim!.PlayerPawn.Value;
|
||||
if (victimPawn!.Health > 0 || secondLifePlayers.TryGetValue(victim.Handle, out _) == true)
|
||||
return HookResult.Continue;
|
||||
|
||||
secondLifePlayers.Add(victim.Handle);
|
||||
SetHealth(victim, secondLifeHealth);
|
||||
victimPawn.Teleport(GetSpawnVector(victim), victimPawn.AbsRotation, null);
|
||||
var spawn = GetSpawnVector(victim);
|
||||
if (spawn != null)
|
||||
victimPawn.Teleport(spawn, victimPawn.AbsRotation, null);
|
||||
return HookResult.Stop;
|
||||
});
|
||||
}
|
||||
|
|
@ -83,25 +85,24 @@ namespace jRandomSkills
|
|||
Utilities.SetStateChanged(pawn, "CCSPlayerPawn", "m_ArmorValue");
|
||||
}
|
||||
|
||||
private static Vector GetSpawnVector(CCSPlayerController player)
|
||||
private static Vector? GetSpawnVector(CCSPlayerController player)
|
||||
{
|
||||
var abs = player.PlayerPawn.Value.AbsOrigin;
|
||||
var pawn = player.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid) return null;
|
||||
|
||||
var abs = pawn.AbsOrigin;
|
||||
var spawns = Utilities.FindAllEntitiesByDesignerName<SpawnPoint>(player.Team == CsTeam.Terrorist ? "info_player_terrorist" : "info_player_counterterrorist").ToList();
|
||||
if (spawns.Any())
|
||||
if (spawns.Count != 0)
|
||||
{
|
||||
var randomSpawn = spawns[Instance.Random.Next(spawns.Count)];
|
||||
return randomSpawn.AbsOrigin;
|
||||
}
|
||||
return new Vector(abs.X, abs.Y, abs.Z);
|
||||
return abs == null ? null : new Vector(abs.X, abs.Y, abs.Z);
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#d41c1c", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int startHealth = 50) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public int StartHealth { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#d41c1c", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int startHealth = 50) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
StartHealth = startHealth;
|
||||
}
|
||||
public int StartHealth { get; set; } = startHealth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -16,8 +16,8 @@ namespace jRandomSkills
|
|||
public class Shade : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Shade;
|
||||
private static float teleportDistance = Config.GetValue<float>(skillName, "teleportDistance");
|
||||
private static Dictionary<CCSPlayerController, float> noSpace = new Dictionary<CCSPlayerController, float>();
|
||||
private static readonly float teleportDistance = Config.GetValue<float>(skillName, "teleportDistance");
|
||||
private static readonly Dictionary<CCSPlayerController, float> noSpace = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -30,11 +30,11 @@ namespace jRandomSkills
|
|||
|
||||
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim)) return HookResult.Continue;
|
||||
|
||||
var victimInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == victim.SteamID);
|
||||
var attackerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
|
||||
var victimInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == victim?.SteamID);
|
||||
var attackerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == attacker?.SteamID);
|
||||
|
||||
if (attackerInfo?.Skill == skillName)
|
||||
TeleportAttackerBehindVictim(attacker, victim);
|
||||
TeleportAttackerBehindVictim(attacker!, victim!);
|
||||
|
||||
return HookResult.Continue;
|
||||
});
|
||||
|
|
@ -55,8 +55,7 @@ namespace jRandomSkills
|
|||
|
||||
public static void DisableSkill(CCSPlayerController player)
|
||||
{
|
||||
if (noSpace.ContainsKey(player))
|
||||
noSpace.Remove(player);
|
||||
noSpace.Remove(player);
|
||||
}
|
||||
|
||||
private static void UpdateHUD(CCSPlayerController player)
|
||||
|
|
@ -74,8 +73,9 @@ namespace jRandomSkills
|
|||
private unsafe static bool CheckTeleport(CCSPlayerController player, Vector startPos, Vector endPos)
|
||||
{
|
||||
var pawn = player.PlayerPawn.Value;
|
||||
Ray ray = new Ray(new Vector3(-16, -16, -0), new Vector3(16, 16, 72));
|
||||
CTraceFilter filter = new CTraceFilter(pawn.Index, pawn.Index)
|
||||
if (pawn == null || !pawn.IsValid) return false;
|
||||
Ray ray = new(new Vector3(-16, -16, -0), new Vector3(16, 16, 72));
|
||||
CTraceFilter filter = new(pawn.Index, pawn.Index)
|
||||
{
|
||||
m_nObjectSetMask = 0xf,
|
||||
m_nCollisionGroup = (byte)CollisionGroup.COLLISION_GROUP_PLAYER_MOVEMENT,
|
||||
|
|
@ -98,19 +98,19 @@ namespace jRandomSkills
|
|||
var victimPawn = victim.PlayerPawn.Value;
|
||||
var attackerPawn = attacker.PlayerPawn.Value;
|
||||
|
||||
if (victimPawn == null || attackerPawn == null) return;
|
||||
if (victimPawn == null || attackerPawn == null || victimPawn.AbsOrigin == null || victimPawn.AbsRotation == null) return;
|
||||
|
||||
QAngle victimAngles = victimPawn.AbsRotation;
|
||||
Vector victimEyePos = new Vector(victimPawn.AbsOrigin.X, victimPawn.AbsOrigin.Y, victimPawn.AbsOrigin.Z + victimPawn.ViewOffset.Z);
|
||||
int[] angles = { 0, 90, -90 };
|
||||
Vector victimEyePos = new(victimPawn.AbsOrigin.X, victimPawn.AbsOrigin.Y, victimPawn.AbsOrigin.Z + victimPawn.ViewOffset.Z);
|
||||
int[] angles = [0, 90, -90];
|
||||
|
||||
bool teleported = false;
|
||||
foreach (int extraAngle in angles)
|
||||
{
|
||||
QAngle newAngle = new QAngle(victimAngles.X, victimAngles.Y + extraAngle, victimAngles.Z);
|
||||
QAngle newAngle = new(victimAngles.X, victimAngles.Y + extraAngle, victimAngles.Z);
|
||||
Vector behindPosition = victimEyePos - SkillUtils.GetForwardVector(newAngle) * teleportDistance;
|
||||
if (!CheckTeleport(victim, victimEyePos, behindPosition)) continue;
|
||||
attackerPawn.Teleport(behindPosition, newAngle, new Vector(0, 0, 0));
|
||||
attackerPawn.Teleport(behindPosition, newAngle, new(0, 0, 0));
|
||||
teleported = true;
|
||||
break;
|
||||
}
|
||||
|
|
@ -118,13 +118,9 @@ namespace jRandomSkills
|
|||
noSpace[attacker] = Server.TickCount + (64 * 2);
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#4d4d4d", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float teleportDistance = 100f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float TeleportDistance { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#4d4d4d", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float teleportDistance = 100f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
TeleportDistance = teleportDistance;
|
||||
}
|
||||
public float TeleportDistance { get; set; } = teleportDistance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace jRandomSkills
|
|||
public class ShortBomb : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.ShortBomb;
|
||||
private static int detonationTime = Config.GetValue<int>(skillName, "detonationTime");
|
||||
private static readonly int detonationTime = Config.GetValue<int>(skillName, "detonationTime");
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -20,7 +20,7 @@ namespace jRandomSkills
|
|||
var player = @event.Userid;
|
||||
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player?.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return HookResult.Continue;
|
||||
|
||||
var plantedBomb = Utilities.FindAllEntitiesByDesignerName<CPlantedC4>("planted_c4").FirstOrDefault();
|
||||
|
|
@ -31,13 +31,9 @@ namespace jRandomSkills
|
|||
});
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#f5b74c", CsTeam onlyTeam = CsTeam.Terrorist, bool needsTeammates = false, int detonationTime = 20) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public int DetonationTime { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#f5b74c", CsTeam onlyTeam = CsTeam.Terrorist, bool needsTeammates = false, int detonationTime = 20) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
DetonationTime = detonationTime;
|
||||
}
|
||||
public int DetonationTime { get; set; } = detonationTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -27,7 +27,7 @@ namespace jRandomSkills
|
|||
var player = Utilities.GetPlayers().FirstOrDefault(p => p.Pawn?.Value != null && p.Pawn.Value.IsValid && p.Pawn.Value.Index == userIndex);
|
||||
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
|
||||
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player?.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return HookResult.Continue;
|
||||
|
||||
um.Recipients.Clear();
|
||||
|
|
@ -35,11 +35,8 @@ namespace jRandomSkills
|
|||
}, HookMode.Pre);
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#333333", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#333333", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue