Refactor command system and add static skill support
This commit is contained in:
parent
e33975fe8b
commit
c73473f0ed
22 changed files with 509 additions and 156 deletions
|
|
@ -12,25 +12,25 @@ namespace jRandomSkills
|
||||||
public static class Command
|
public static class Command
|
||||||
{
|
{
|
||||||
private static bool gamePaused = false;
|
private static bool gamePaused = false;
|
||||||
|
private static readonly Config.Settings config = Config.LoadedConfig.Settings;
|
||||||
|
|
||||||
public static void Load()
|
public static void Load()
|
||||||
{
|
{
|
||||||
var config = Config.LoadedConfig?.Settings;
|
|
||||||
if (config == null || config == null) return;
|
if (config == null || config == null) return;
|
||||||
|
|
||||||
var commands = new Dictionary<IEnumerable<string>, (string description, CommandInfo.CommandCallback handler)>
|
var commands = new Dictionary<IEnumerable<string>, (string description, CommandInfo.CommandCallback handler)>
|
||||||
{
|
{
|
||||||
{ SplitCommands(config.SetSkillCommands), ("Set skill", Command_SetSkill) },
|
{ SplitCommands(config.SetSkillCommands.Alias), ("Set skill", Command_SetSkill) },
|
||||||
{ SplitCommands(config.SkillsListCommands), ("Delete all records", Command_SkillsListMenu) },
|
{ SplitCommands(config.SkillsListCommands.Alias), ("Delete all records", Command_SkillsListMenu) },
|
||||||
{ SplitCommands(config.UseSkillCommands), ("Use/Type skill", Command_UseTypeSkill) },
|
{ SplitCommands(config.UseSkillCommands.Alias), ("Use/Type skill", Command_UseTypeSkill) },
|
||||||
{ SplitCommands(config.ChangeMapCommands), ("Change map", Command_ChangeMap) },
|
{ SplitCommands(config.ChangeMapCommands.Alias), ("Change map", Command_ChangeMap) },
|
||||||
{ SplitCommands(config.ConsoleCommands), ("Console command", Command_CustomCommand) },
|
{ SplitCommands(config.ConsoleCommands.Alias), ("Console command", Command_CustomCommand) },
|
||||||
{ SplitCommands(config.StartGameCommands), ("Start game", Command_StartGame) },
|
{ SplitCommands(config.StartGameCommands.Alias), ("Start game", Command_StartGame) },
|
||||||
{ SplitCommands(config.SwapCommands), ("Swap team", Command_Swap) },
|
{ SplitCommands(config.SwapCommands.Alias), ("Swap team", Command_Swap) },
|
||||||
{ SplitCommands(config.ShuffleCommands), ("Shuffle team", Command_Shuffle) },
|
{ SplitCommands(config.ShuffleCommands.Alias), ("Shuffle team", Command_Shuffle) },
|
||||||
{ SplitCommands(config.PauseCommands), ("Pause game", Command_Pause) },
|
{ SplitCommands(config.PauseCommands.Alias), ("Pause game", Command_Pause) },
|
||||||
{ SplitCommands(config.HealCommands), ("Heal", Command_Heal) },
|
{ SplitCommands(config.HealCommands.Alias), ("Heal", Command_Heal) },
|
||||||
{ SplitCommands(config.SetScoreCommands), ("Set teams score", Command_SetScore) },
|
{ SplitCommands(config.SetScoreCommands.Alias), ("Set teams score", Command_SetScore) },
|
||||||
|
{ SplitCommands(config.SetStaticSkillCommands.Alias), ("Set static skill", Command_SetStaticSkill) },
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach (var commandPair in commands)
|
foreach (var commandPair in commands)
|
||||||
|
|
@ -40,7 +40,7 @@ namespace jRandomSkills
|
||||||
|
|
||||||
private static IEnumerable<string> SplitCommands(string commands)
|
private static IEnumerable<string> SplitCommands(string commands)
|
||||||
{
|
{
|
||||||
return commands.Split(',').Select(c => c.Trim());
|
return commands.Split(',').Select(c => c.Trim()).Where(c => !string.IsNullOrEmpty(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
[CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_ONLY)]
|
[CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_ONLY)]
|
||||||
|
|
@ -62,11 +62,11 @@ namespace jRandomSkills
|
||||||
Instance.SkillAction(playerInfo.Skill.ToString(), "TypeSkill", [player, commands]);
|
Instance.SkillAction(playerInfo.Skill.ToString(), "TypeSkill", [player, commands]);
|
||||||
}
|
}
|
||||||
|
|
||||||
[RequiresPermissions("@jRandmosSkills/admin")]
|
[CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||||
[CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_ONLY)]
|
|
||||||
private static void Command_SetSkill(CCSPlayerController? player, CommandInfo command)
|
private static void Command_SetSkill(CCSPlayerController? player, CommandInfo command)
|
||||||
{
|
{
|
||||||
if (player == null) return;
|
Debug.WriteToDebug($"Player {player?.PlayerPawn} used the css_setskill {command.ArgString} command.");
|
||||||
|
if (player == null || !AdminManager.PlayerHasPermissions(player, config.SetSkillCommands.Permissions)) return;
|
||||||
var targetPlayer = Utilities.GetPlayers().FirstOrDefault(p => !p.IsBot
|
var targetPlayer = Utilities.GetPlayers().FirstOrDefault(p => !p.IsBot
|
||||||
&& (p.SteamID.ToString().Equals(command.GetArg(1), StringComparison.CurrentCultureIgnoreCase)
|
&& (p.SteamID.ToString().Equals(command.GetArg(1), StringComparison.CurrentCultureIgnoreCase)
|
||||||
|| p.PlayerName.Equals(command.GetArg(1), StringComparison.CurrentCultureIgnoreCase)) );
|
|| p.PlayerName.Equals(command.GetArg(1), StringComparison.CurrentCultureIgnoreCase)) );
|
||||||
|
|
@ -103,6 +103,7 @@ namespace jRandomSkills
|
||||||
{
|
{
|
||||||
Instance.SkillAction(skillPlayer.Skill.ToString(), "DisableSkill", [targetPlayer]);
|
Instance.SkillAction(skillPlayer.Skill.ToString(), "DisableSkill", [targetPlayer]);
|
||||||
skillPlayer.Skill = skill.Skill;
|
skillPlayer.Skill = skill.Skill;
|
||||||
|
skillPlayer.SpecialSkill = src.player.Skills.None;
|
||||||
Instance.SkillAction(skill.Skill.ToString(), "EnableSkill", [targetPlayer]);
|
Instance.SkillAction(skill.Skill.ToString(), "EnableSkill", [targetPlayer]);
|
||||||
|
|
||||||
player.PrintToChat($" {ChatColors.Green}―――――――――――{ChatColors.DarkRed}◥◣◆◢◤{ChatColors.Green}―――――――――――");
|
player.PrintToChat($" {ChatColors.Green}―――――――――――{ChatColors.DarkRed}◥◣◆◢◤{ChatColors.Green}―――――――――――");
|
||||||
|
|
@ -120,16 +121,18 @@ namespace jRandomSkills
|
||||||
[CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_ONLY)]
|
[CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_ONLY)]
|
||||||
private static void Command_SkillsListMenu(CCSPlayerController? player, CommandInfo command)
|
private static void Command_SkillsListMenu(CCSPlayerController? player, CommandInfo command)
|
||||||
{
|
{
|
||||||
if (player == null) return;
|
Debug.WriteToDebug($"Player {player?.PlayerPawn} used the css_skills {command.ArgString} command.");
|
||||||
|
if (player == null || !AdminManager.PlayerHasPermissions(player, config.SkillsListCommands.Permissions)) return;
|
||||||
Menu.DisplaySkillsList(player);
|
Menu.DisplaySkillsList(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
[CommandHelper(minArgs: 1, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
[CommandHelper(minArgs: 1, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||||
private static void Command_ChangeMap(CCSPlayerController? player, CommandInfo command)
|
private static void Command_ChangeMap(CCSPlayerController? player, CommandInfo command)
|
||||||
{
|
{
|
||||||
if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, "@TESTTEST/TESTAFD"))
|
Debug.WriteToDebug($"Player {player?.PlayerPawn} used the css_map {command.ArgString} command.");
|
||||||
|
if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, config.ChangeMapCommands.Permissions))
|
||||||
{
|
{
|
||||||
|
if (!config.ChangeMapCommands.EnableVoting) return;
|
||||||
player.Vote(VoteType.ChangeMap, command.ArgString);
|
player.Vote(VoteType.ChangeMap, command.ArgString);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -159,8 +162,10 @@ namespace jRandomSkills
|
||||||
[CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
[CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||||
private static void Command_StartGame(CCSPlayerController? player, CommandInfo command)
|
private static void Command_StartGame(CCSPlayerController? player, CommandInfo command)
|
||||||
{
|
{
|
||||||
if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, "@TESTTEST/TESTAFD"))
|
Debug.WriteToDebug($"Player {player?.PlayerPawn} used the css_start {command.ArgString} command.");
|
||||||
|
if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, config.StartGameCommands.Permissions))
|
||||||
{
|
{
|
||||||
|
if (!config.StartGameCommands.EnableVoting) return;
|
||||||
player.Vote(VoteType.StartGame);
|
player.Vote(VoteType.StartGame);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -186,8 +191,10 @@ namespace jRandomSkills
|
||||||
[CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
[CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||||
private static void Command_Swap(CCSPlayerController? player, CommandInfo command)
|
private static void Command_Swap(CCSPlayerController? player, CommandInfo command)
|
||||||
{
|
{
|
||||||
if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, "@TESTTEST/TESTAFD"))
|
Debug.WriteToDebug($"Player {player?.PlayerPawn} used the css_swap {command.ArgString} command.");
|
||||||
|
if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, config.SwapCommands.Permissions))
|
||||||
{
|
{
|
||||||
|
if (!config.SwapCommands.EnableVoting) return;
|
||||||
player.Vote(VoteType.SwapTeam);
|
player.Vote(VoteType.SwapTeam);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -205,8 +212,10 @@ namespace jRandomSkills
|
||||||
[CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
[CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||||
private static void Command_Shuffle(CCSPlayerController? player, CommandInfo command)
|
private static void Command_Shuffle(CCSPlayerController? player, CommandInfo command)
|
||||||
{
|
{
|
||||||
if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, "@TESTTEST/TESTAFD"))
|
Debug.WriteToDebug($"Player {player?.PlayerPawn} used the css_shuffle {command.ArgString} command.");
|
||||||
|
if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, config.ShuffleCommands.Permissions))
|
||||||
{
|
{
|
||||||
|
if (!config.ShuffleCommands.EnableVoting) return;
|
||||||
player.Vote(VoteType.ShuffleTeam);
|
player.Vote(VoteType.ShuffleTeam);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -229,8 +238,10 @@ namespace jRandomSkills
|
||||||
[CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
[CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||||
private static void Command_Pause(CCSPlayerController? player, CommandInfo command)
|
private static void Command_Pause(CCSPlayerController? player, CommandInfo command)
|
||||||
{
|
{
|
||||||
if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, "@TESTTEST/TESTAFD"))
|
Debug.WriteToDebug($"Player {player?.PlayerPawn} used the css_pause {command.ArgString} command.");
|
||||||
|
if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, config.PauseCommands.Permissions))
|
||||||
{
|
{
|
||||||
|
if (!config.PauseCommands.EnableVoting) return;
|
||||||
player.Vote(VoteType.PauseGame);
|
player.Vote(VoteType.PauseGame);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -244,11 +255,12 @@ namespace jRandomSkills
|
||||||
gamePaused = !gamePaused;
|
gamePaused = !gamePaused;
|
||||||
}
|
}
|
||||||
|
|
||||||
[RequiresPermissions("@jRandmosSkills/root")]
|
|
||||||
[CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
[CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||||
private static void Command_Heal(CCSPlayerController? player, CommandInfo command)
|
private static void Command_Heal(CCSPlayerController? player, CommandInfo command)
|
||||||
{
|
{
|
||||||
|
Debug.WriteToDebug($"Player {player?.PlayerPawn} used the css_heal {command.ArgString} command.");
|
||||||
if (player == null || !player.IsValid || player.PlayerPawn.Value == null || !player.PlayerPawn.Value.IsValid || player.LifeState != (byte)LifeState_t.LIFE_ALIVE) return;
|
if (player == null || !player.IsValid || player.PlayerPawn.Value == null || !player.PlayerPawn.Value.IsValid || player.LifeState != (byte)LifeState_t.LIFE_ALIVE) return;
|
||||||
|
if (!AdminManager.PlayerHasPermissions(player, config.HealCommands.Permissions)) return;
|
||||||
SkillUtils.AddHealth(player.PlayerPawn.Value, 100);
|
SkillUtils.AddHealth(player.PlayerPawn.Value, 100);
|
||||||
player.PrintToChat($" {ChatColors.Green}{Localization.GetTranslation("healed")}");
|
player.PrintToChat($" {ChatColors.Green}{Localization.GetTranslation("healed")}");
|
||||||
}
|
}
|
||||||
|
|
@ -256,8 +268,10 @@ namespace jRandomSkills
|
||||||
[CommandHelper(minArgs: 2, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
[CommandHelper(minArgs: 2, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||||
private static void Command_SetScore(CCSPlayerController? player, CommandInfo command)
|
private static void Command_SetScore(CCSPlayerController? player, CommandInfo command)
|
||||||
{
|
{
|
||||||
if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, "@testset/testset"))
|
Debug.WriteToDebug($"Player {player?.PlayerPawn} used the css_setscore {command.ArgString} command.");
|
||||||
|
if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, config.SetScoreCommands.Permissions))
|
||||||
{
|
{
|
||||||
|
if (!config.SetScoreCommands.EnableVoting) return;
|
||||||
player.Vote(VoteType.SetScore, command.ArgString);
|
player.Vote(VoteType.SetScore, command.ArgString);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -276,13 +290,74 @@ namespace jRandomSkills
|
||||||
SkillUtils.SetTeamScores((short)ctScore, (short)tScore, RoundEndReason.RoundDraw);
|
SkillUtils.SetTeamScores((short)ctScore, (short)tScore, RoundEndReason.RoundDraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
[RequiresPermissions("@jRandmosSkills/root")]
|
|
||||||
[CommandHelper(minArgs: 1, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
[CommandHelper(minArgs: 1, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
|
||||||
private static void Command_CustomCommand(CCSPlayerController? player, CommandInfo command)
|
private static void Command_CustomCommand(CCSPlayerController? player, CommandInfo command)
|
||||||
{
|
{
|
||||||
if (player == null) return;
|
Debug.WriteToDebug($"Player {player?.PlayerPawn} used the css_console {command.ArgString} command.");
|
||||||
|
if (player == null || !AdminManager.PlayerHasPermissions(player, config.ConsoleCommands.Permissions)) return;
|
||||||
string param = command.ArgString;
|
string param = command.ArgString;
|
||||||
Server.ExecuteCommand(param);
|
Server.ExecuteCommand(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_ONLY)]
|
||||||
|
private static void Command_SetStaticSkill(CCSPlayerController? player, CommandInfo command)
|
||||||
|
{
|
||||||
|
Debug.WriteToDebug($"Player {player?.PlayerPawn} used the css_setstaticskill {command.ArgString} command.");
|
||||||
|
if (player == null || !AdminManager.PlayerHasPermissions(player, config.SetStaticSkillCommands.Permissions)) return;
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
player.PrintToChat($" {ChatColors.Green}―――――――――――{ChatColors.DarkRed}◥◣◆◢◤{ChatColors.Green}―――――――――――");
|
||||||
|
SkillUtils.PrintToChat(player, Localization.GetTranslation("correct_form_setskill"), true);
|
||||||
|
player.PrintToChat($" {ChatColors.Green}―――――――――――{ChatColors.DarkRed}◥◣◆◢◤{ChatColors.Green}―――――――――――");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (targetPlayer == null)
|
||||||
|
{
|
||||||
|
player.PrintToChat($" {ChatColors.Green}―――――――――――{ChatColors.DarkRed}◥◣◆◢◤{ChatColors.Green}―――――――――――");
|
||||||
|
SkillUtils.PrintToChat(player, Localization.GetTranslation("player_not_found_setskill"), true);
|
||||||
|
player.PrintToChat($" {ChatColors.Green}―――――――――――{ChatColors.DarkRed}◥◣◆◢◤{ChatColors.Green}―――――――――――");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var skillName = command.ArgCount > 3 ? $"{command.GetArg(2)} {command.GetArg(3)}" : command.GetArg(2);
|
||||||
|
var skill = SkillData.Skills.FirstOrDefault(s => s.Name.Equals(skillName, StringComparison.OrdinalIgnoreCase) || s.Skill.ToString().Equals(skillName, StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
|
if (skill == null)
|
||||||
|
{
|
||||||
|
player.PrintToChat($" {ChatColors.Green}―――――――――――{ChatColors.DarkRed}◥◣◆◢◤{ChatColors.Green}―――――――――――");
|
||||||
|
SkillUtils.PrintToChat(player, Localization.GetTranslation("skill_not_found_setskill"), true);
|
||||||
|
player.PrintToChat($" {ChatColors.Green}―――――――――――{ChatColors.DarkRed}◥◣◆◢◤{ChatColors.Green}―――――――――――");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var skillPlayer = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == targetPlayer.SteamID);
|
||||||
|
if (skillPlayer != null)
|
||||||
|
{
|
||||||
|
Instance.SkillAction(skillPlayer.Skill.ToString(), "DisableSkill", [targetPlayer]);
|
||||||
|
skillPlayer.Skill = skill.Skill;
|
||||||
|
skillPlayer.SpecialSkill = src.player.Skills.None;
|
||||||
|
|
||||||
|
if (skill.Skill == src.player.Skills.None)
|
||||||
|
Event.staticSkills.Remove(targetPlayer.SteamID);
|
||||||
|
else
|
||||||
|
Event.staticSkills.Add(targetPlayer.SteamID, skill);
|
||||||
|
Instance.SkillAction(skill.Skill.ToString(), "EnableSkill", [targetPlayer]);
|
||||||
|
|
||||||
|
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}―――――――――――");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -31,6 +31,7 @@ namespace jRandomSkills
|
||||||
{
|
{
|
||||||
if (!votes.Contains(vote) || !vote.GetActive()) return;
|
if (!votes.Contains(vote) || !vote.GetActive()) return;
|
||||||
vote.SetActive(false);
|
vote.SetActive(false);
|
||||||
|
vote.TimeToNextSameVoting = vote.TimeToNextVoting;
|
||||||
Server.PrintToChatAll($" {ChatColors.Red}{Localization.GetTranslation("vote_timeout", commandName)}");
|
Server.PrintToChatAll($" {ChatColors.Red}{Localization.GetTranslation("vote_timeout", commandName)}");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -401,7 +401,7 @@
|
||||||
"skill_not_found_setskill": "No such CHATCOLORS.REDskill found",
|
"skill_not_found_setskill": "No such CHATCOLORS.REDskill found",
|
||||||
"player_not_found_setskill": "No such CHATCOLORS.REDplayer found",
|
"player_not_found_setskill": "No such CHATCOLORS.REDplayer found",
|
||||||
"correct_form_setskill": "Correct usage: CHATCOLORS.RED!setskill <nickname> <skill>",
|
"correct_form_setskill": "Correct usage: CHATCOLORS.RED!setskill <nickname> <skill>",
|
||||||
"correct_form_setskill": "Correct usage: CHATCOLORS.RED!setscore <CT> <TT>",
|
"correct_form_setscore": "Correct usage: CHATCOLORS.RED!setscore <CT> <TT>",
|
||||||
"done_setskill": "skill set",
|
"done_setskill": "skill set",
|
||||||
"error_setskill": "Failed to set CHATCOLORS.REDskill",
|
"error_setskill": "Failed to set CHATCOLORS.REDskill",
|
||||||
"for_setskill": "for",
|
"for_setskill": "for",
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ using CounterStrikeSharp.API.Core;
|
||||||
using CounterStrikeSharp.API.Modules.Memory;
|
using CounterStrikeSharp.API.Modules.Memory;
|
||||||
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
|
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
|
||||||
using CounterStrikeSharp.API.Modules.Utils;
|
using CounterStrikeSharp.API.Modules.Utils;
|
||||||
|
using static CounterStrikeSharp.API.Core.Listeners;
|
||||||
using static jRandomSkills.jRandomSkills;
|
using static jRandomSkills.jRandomSkills;
|
||||||
|
|
||||||
namespace jRandomSkills
|
namespace jRandomSkills
|
||||||
|
|
@ -80,6 +81,11 @@ namespace jRandomSkills
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Instance.RegisterListener<OnMapStart>((string mapName) =>
|
||||||
|
{
|
||||||
|
Debug.WriteToDebug($"Map changed: {mapName}.");
|
||||||
|
});
|
||||||
|
|
||||||
Instance.RegisterEventHandler<EventPlayerShoot>((@event, info) =>
|
Instance.RegisterEventHandler<EventPlayerShoot>((@event, info) =>
|
||||||
{
|
{
|
||||||
var player = @event.Userid;
|
var player = @event.Userid;
|
||||||
|
|
|
||||||
|
|
@ -5,17 +5,23 @@ using CounterStrikeSharp.API.Modules.Utils;
|
||||||
using jRandomSkills.src.player;
|
using jRandomSkills.src.player;
|
||||||
using jRandomSkills.src.utils;
|
using jRandomSkills.src.utils;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using static jRandomSkills.Config;
|
||||||
using static jRandomSkills.jRandomSkills;
|
using static jRandomSkills.jRandomSkills;
|
||||||
|
|
||||||
namespace jRandomSkills
|
namespace jRandomSkills
|
||||||
{
|
{
|
||||||
public static partial class Event
|
public static partial class Event
|
||||||
{
|
{
|
||||||
private static jSkill_SkillInfo ctSkill = new(Skills.None, Config.GetValue<string>(Skills.None, "color"), false);
|
private static readonly jSkill_SkillInfo noneSkill = 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 jSkill_SkillInfo ctSkill = noneSkill;
|
||||||
|
private static jSkill_SkillInfo tSkill = noneSkill;
|
||||||
|
private static jSkill_SkillInfo allSkill = noneSkill;
|
||||||
private static List<jSkill_SkillInfo> debugSkills = new(SkillData.Skills);
|
private static List<jSkill_SkillInfo> debugSkills = new(SkillData.Skills);
|
||||||
|
|
||||||
|
private static readonly Dictionary<ulong, List<jSkill_SkillInfo>> playersSkills = [];
|
||||||
|
public static readonly Dictionary<ulong, jSkill_SkillInfo> staticSkills = [];
|
||||||
|
|
||||||
public static void Load()
|
public static void Load()
|
||||||
{
|
{
|
||||||
Instance.RegisterEventHandler<EventPlayerConnectFull>((@event, info) =>
|
Instance.RegisterEventHandler<EventPlayerConnectFull>((@event, info) =>
|
||||||
|
|
@ -155,7 +161,10 @@ namespace jRandomSkills
|
||||||
|
|
||||||
if (Instance?.GameRules != null && Instance?.GameRules.WarmupPeriod == false)
|
if (Instance?.GameRules != null && Instance?.GameRules.WarmupPeriod == false)
|
||||||
{
|
{
|
||||||
if (Config.LoadedConfig.Settings.GameMode == (int)Config.GameModes.Normal)
|
Config.GameModes gameMode = (Config.GameModes)Config.LoadedConfig.Settings.GameMode;
|
||||||
|
if (staticSkills.TryGetValue(player.SteamID, out var staticSkill))
|
||||||
|
randomSkill = staticSkill;
|
||||||
|
else if (gameMode == Config.GameModes.Normal || gameMode == Config.GameModes.NoRepeat)
|
||||||
{
|
{
|
||||||
List<jSkill_SkillInfo> skillList = new(SkillData.Skills);
|
List<jSkill_SkillInfo> skillList = new(SkillData.Skills);
|
||||||
skillList.RemoveAll(s => s?.Skill == skillPlayer?.Skill || s?.Skill == skillPlayer?.SpecialSkill || s?.Skill == Skills.None);
|
skillList.RemoveAll(s => s?.Skill == skillPlayer?.Skill || s?.Skill == skillPlayer?.SpecialSkill || s?.Skill == Skills.None);
|
||||||
|
|
@ -171,13 +180,26 @@ namespace jRandomSkills
|
||||||
else
|
else
|
||||||
skillList.RemoveAll(s => terroristSkills.Any(s2 => s2.Name == s.Skill.ToString()));
|
skillList.RemoveAll(s => terroristSkills.Any(s2 => s2.Name == s.Skill.ToString()));
|
||||||
|
|
||||||
randomSkill = skillList.Count == 0 ? new jSkill_SkillInfo(Skills.None, Config.GetValue<string>(Skills.None, "color"), false) : skillList[Instance.Random.Next(skillList.Count)];
|
if (gameMode == Config.GameModes.NoRepeat && playersSkills.TryGetValue(player.SteamID, out List<jSkill_SkillInfo>? skills))
|
||||||
|
{
|
||||||
|
skillList.RemoveAll(s => skills.Any(s2 => s2.Skill == s.Skill));
|
||||||
|
if (skillList.Count == 0) skills.Clear();
|
||||||
}
|
}
|
||||||
else if (Config.LoadedConfig.Settings.GameMode == (int)Config.GameModes.TeamSkills)
|
|
||||||
|
randomSkill = skillList.Count == 0 ? noneSkill : skillList[Instance.Random.Next(skillList.Count)];
|
||||||
|
if (gameMode == Config.GameModes.NoRepeat)
|
||||||
|
{
|
||||||
|
if (playersSkills.TryGetValue(player.SteamID, out List<jSkill_SkillInfo>? value))
|
||||||
|
value.Add(randomSkill);
|
||||||
|
else
|
||||||
|
playersSkills.Add(player.SteamID, [randomSkill]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (gameMode == Config.GameModes.TeamSkills)
|
||||||
randomSkill = player.Team == CsTeam.Terrorist ? tSkill : ctSkill;
|
randomSkill = player.Team == CsTeam.Terrorist ? tSkill : ctSkill;
|
||||||
else if (Config.LoadedConfig.Settings.GameMode == (int)Config.GameModes.SameSkills)
|
else if (gameMode == Config.GameModes.SameSkills)
|
||||||
randomSkill = allSkill;
|
randomSkill = allSkill;
|
||||||
else if (Config.LoadedConfig.Settings.GameMode == (int)Config.GameModes.Debug)
|
else if (gameMode == Config.GameModes.Debug)
|
||||||
{
|
{
|
||||||
if (debugSkills.Count == 0)
|
if (debugSkills.Count == 0)
|
||||||
debugSkills = new List<jSkill_SkillInfo>(SkillData.Skills);
|
debugSkills = new List<jSkill_SkillInfo>(SkillData.Skills);
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ namespace jRandomSkills
|
||||||
private static void OnMapStart(string mapName)
|
private static void OnMapStart(string mapName)
|
||||||
{
|
{
|
||||||
Instance.GameRules = null;
|
Instance.GameRules = null;
|
||||||
|
Event.staticSkills.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void InitializeGameRules()
|
private static void InitializeGameRules()
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ namespace jRandomSkills
|
||||||
public class Aimbot : ISkill
|
public class Aimbot : ISkill
|
||||||
{
|
{
|
||||||
private const Skills skillName = Skills.Aimbot;
|
private const Skills skillName = Skills.Aimbot;
|
||||||
private static Dictionary<nint, int> hitGroups = new Dictionary<nint, int>();
|
private static readonly Dictionary<nint, int> hitGroups = [];
|
||||||
|
|
||||||
public static void LoadSkill()
|
public static void LoadSkill()
|
||||||
{
|
{
|
||||||
|
|
@ -27,8 +27,8 @@ namespace jRandomSkills
|
||||||
if (param == null || param.Entity == null || param2 == null || param2.Attacker == null || param2.Attacker.Value == null)
|
if (param == null || param.Entity == null || param2 == null || param2.Attacker == null || param2.Attacker.Value == null)
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
|
|
||||||
CCSPlayerPawn attackerPawn = new CCSPlayerPawn(param2.Attacker.Value.Handle);
|
CCSPlayerPawn attackerPawn = new(param2.Attacker.Value.Handle);
|
||||||
CCSPlayerPawn victimPawn = new CCSPlayerPawn(param.Handle);
|
CCSPlayerPawn victimPawn = new(param.Handle);
|
||||||
|
|
||||||
if (attackerPawn.DesignerName != "player" || victimPawn.DesignerName != "player")
|
if (attackerPawn.DesignerName != "player" || victimPawn.DesignerName != "player")
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
|
|
@ -64,11 +64,8 @@ namespace jRandomSkills
|
||||||
return HookResult.Continue;
|
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 = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||||
{
|
|
||||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#ff0000", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
@ -10,9 +10,9 @@ namespace jRandomSkills
|
||||||
public class BunnyHop : ISkill
|
public class BunnyHop : ISkill
|
||||||
{
|
{
|
||||||
private const Skills skillName = Skills.BunnyHop;
|
private const Skills skillName = Skills.BunnyHop;
|
||||||
private static float maxSpeed = Config.GetValue<float>(skillName, "maxSpeed");
|
private static readonly float maxSpeed = Config.GetValue<float>(skillName, "maxSpeed");
|
||||||
private static float bunnyHopVelocity = Config.GetValue<float>(skillName, "jumpVelocity");
|
private static readonly float bunnyHopVelocity = Config.GetValue<float>(skillName, "jumpVelocity");
|
||||||
private static float jumpBoost = Config.GetValue<float>(skillName, "jumpBoost");
|
private static readonly float jumpBoost = Config.GetValue<float>(skillName, "jumpBoost");
|
||||||
|
|
||||||
public static void LoadSkill()
|
public static void LoadSkill()
|
||||||
{
|
{
|
||||||
|
|
@ -60,17 +60,11 @@ namespace jRandomSkills
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 maxSpeed = 500f, float jumpVelocity = 300f, float jumpBoost = 2f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||||
{
|
{
|
||||||
public float MaxSpeed { get; set; }
|
public float MaxSpeed { get; set; } = maxSpeed;
|
||||||
public float JumpVelocity { get; set; }
|
public float JumpVelocity { get; set; } = jumpVelocity;
|
||||||
public float JumpBoost { get; set; }
|
public float JumpBoost { get; set; } = jumpBoost;
|
||||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#d1430a", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float maxSpeed = 500f, float jumpVelocity = 300f, float jumpBoost = 2f) : base(skill, active, color, onlyTeam, needsTeammates)
|
|
||||||
{
|
|
||||||
MaxSpeed = maxSpeed;
|
|
||||||
JumpVelocity = jumpVelocity;
|
|
||||||
JumpBoost = jumpBoost;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using CounterStrikeSharp.API;
|
using CounterStrikeSharp.API;
|
||||||
using CounterStrikeSharp.API.Core;
|
using CounterStrikeSharp.API.Core;
|
||||||
|
using CounterStrikeSharp.API.Core.Attributes;
|
||||||
using CounterStrikeSharp.API.Modules.Utils;
|
using CounterStrikeSharp.API.Modules.Utils;
|
||||||
using jRandomSkills.src.player;
|
using jRandomSkills.src.player;
|
||||||
|
using static CounterStrikeSharp.API.Core.Listeners;
|
||||||
using static jRandomSkills.jRandomSkills;
|
using static jRandomSkills.jRandomSkills;
|
||||||
|
|
||||||
namespace jRandomSkills
|
namespace jRandomSkills
|
||||||
|
|
@ -10,6 +12,8 @@ namespace jRandomSkills
|
||||||
public class C4Camouflage : ISkill
|
public class C4Camouflage : ISkill
|
||||||
{
|
{
|
||||||
private const Skills skillName = Skills.C4Camouflage;
|
private const Skills skillName = Skills.C4Camouflage;
|
||||||
|
private static bool exists = false;
|
||||||
|
private static readonly Dictionary<ulong, List<uint>> invisibleEntities = [];
|
||||||
|
|
||||||
public static void LoadSkill()
|
public static void LoadSkill()
|
||||||
{
|
{
|
||||||
|
|
@ -77,10 +81,40 @@ namespace jRandomSkills
|
||||||
}
|
}
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Instance.RegisterEventHandler<EventRoundEnd>((@event, info) =>
|
||||||
|
{
|
||||||
|
foreach (var player in Utilities.GetPlayers())
|
||||||
|
{
|
||||||
|
if (!Instance.IsPlayerValid(player)) continue;
|
||||||
|
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||||
|
if (playerInfo?.Skill == skillName)
|
||||||
|
DisableSkill(player);
|
||||||
|
}
|
||||||
|
Instance.RemoveListener<CheckTransmit>(CheckTransmit);
|
||||||
|
exists = false;
|
||||||
|
return HookResult.Continue;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CheckTransmit([CastFrom(typeof(nint))] CCheckTransmitInfoList infoList)
|
||||||
|
{
|
||||||
|
foreach (var (info, player) in infoList)
|
||||||
|
{
|
||||||
|
if (player == null) continue;
|
||||||
|
foreach ((var playerId, var itemList) in invisibleEntities)
|
||||||
|
if (player.SteamID != playerId)
|
||||||
|
foreach (var item in itemList)
|
||||||
|
info.TransmitEntities.Remove(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void EnableSkill(CCSPlayerController player)
|
public static void EnableSkill(CCSPlayerController player)
|
||||||
{
|
{
|
||||||
|
if (!exists)
|
||||||
|
Instance.RegisterListener<CheckTransmit>(CheckTransmit);
|
||||||
|
exists = true;
|
||||||
|
|
||||||
if (player == null || !player.IsValid) return;
|
if (player == null || !player.IsValid) return;
|
||||||
var playerPawn = player.PlayerPawn.Value;
|
var playerPawn = player.PlayerPawn.Value;
|
||||||
|
|
||||||
|
|
@ -100,6 +134,7 @@ namespace jRandomSkills
|
||||||
{
|
{
|
||||||
SetPlayerVisibility(player, true);
|
SetPlayerVisibility(player, true);
|
||||||
SetWeaponVisibility(player, true);
|
SetWeaponVisibility(player, true);
|
||||||
|
invisibleEntities.Remove(player.SteamID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SetPlayerVisibility(CCSPlayerController player, bool enabled)
|
private static void SetPlayerVisibility(CCSPlayerController player, bool enabled)
|
||||||
|
|
@ -113,25 +148,34 @@ namespace jRandomSkills
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SetWeaponVisibility(CCSPlayerController player, bool enabled)
|
private static void SetWeaponVisibility(CCSPlayerController player, bool visible)
|
||||||
{
|
{
|
||||||
if (!Instance.IsPlayerValid(player)) return;
|
if (!Instance.IsPlayerValid(player)) return;
|
||||||
var playerPawn = player.PlayerPawn.Value;
|
var playerPawn = player.PlayerPawn.Value!;
|
||||||
if (playerPawn == null || !playerPawn.IsValid) return;
|
if (playerPawn.WeaponServices == null) return;
|
||||||
var weaponServices = playerPawn.WeaponServices;
|
|
||||||
if (weaponServices == null) return;
|
|
||||||
|
|
||||||
var color = Color.FromArgb(enabled ? 255 : 0, 255, 255, 255);
|
invisibleEntities.Remove(player.SteamID);
|
||||||
foreach (var weapon in weaponServices.MyWeapons)
|
foreach (var weapon in playerPawn.WeaponServices.MyWeapons)
|
||||||
{
|
{
|
||||||
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
|
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
|
||||||
{
|
{
|
||||||
weapon.Value.Render = color;
|
if (!visible)
|
||||||
Utilities.SetStateChanged(weapon.Value, "CBaseModelEntity", "m_clrRender");
|
{
|
||||||
|
if (invisibleEntities.TryGetValue(player.SteamID, out var items))
|
||||||
|
{
|
||||||
|
if (!items.Contains(weapon.Index))
|
||||||
|
items.Add(weapon.Index);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
invisibleEntities.Add(player.SteamID, [weapon.Index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (visible)
|
||||||
|
invisibleEntities.Remove(player.SteamID);
|
||||||
|
}
|
||||||
|
|
||||||
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 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)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ using jRandomSkills.src.player;
|
||||||
using static CounterStrikeSharp.API.Core.Listeners;
|
using static CounterStrikeSharp.API.Core.Listeners;
|
||||||
using static jRandomSkills.jRandomSkills;
|
using static jRandomSkills.jRandomSkills;
|
||||||
using jRandomSkills.src.utils;
|
using jRandomSkills.src.utils;
|
||||||
|
using CounterStrikeSharp.API.Core.Attributes;
|
||||||
|
|
||||||
namespace jRandomSkills
|
namespace jRandomSkills
|
||||||
{
|
{
|
||||||
|
|
@ -13,6 +14,7 @@ namespace jRandomSkills
|
||||||
{
|
{
|
||||||
private const Skills skillName = Skills.Chicken;
|
private const Skills skillName = Skills.Chicken;
|
||||||
private static bool roundEnd = false;
|
private static bool roundEnd = false;
|
||||||
|
private static bool exists = false;
|
||||||
private static readonly string[] disabledWeapons =
|
private static readonly string[] disabledWeapons =
|
||||||
[
|
[
|
||||||
"weapon_ak47", "weapon_m4a4", "weapon_m4a1", "weapon_m4a1_silencer",
|
"weapon_ak47", "weapon_m4a4", "weapon_m4a1", "weapon_m4a1_silencer",
|
||||||
|
|
@ -57,6 +59,8 @@ namespace jRandomSkills
|
||||||
DisableSkill(player);
|
DisableSkill(player);
|
||||||
}
|
}
|
||||||
roundEnd = true;
|
roundEnd = true;
|
||||||
|
Instance.RemoveListener<CheckTransmit>(CheckTransmit);
|
||||||
|
exists = false;
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -92,11 +96,26 @@ namespace jRandomSkills
|
||||||
Instance.RegisterListener<OnTick>(OnTick);
|
Instance.RegisterListener<OnTick>(OnTick);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void CheckTransmit([CastFrom(typeof(nint))] CCheckTransmitInfoList infoList)
|
||||||
|
{
|
||||||
|
foreach (var (info, player) in infoList)
|
||||||
|
{
|
||||||
|
if (player == null) continue;
|
||||||
|
if (chickens.TryGetValue(player, out var chicken))
|
||||||
|
if (chicken != null && chicken.IsValid)
|
||||||
|
info.TransmitEntities.Remove(chicken.Index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void EnableSkill(CCSPlayerController player)
|
public static void EnableSkill(CCSPlayerController player)
|
||||||
{
|
{
|
||||||
var playerPawn = player.PlayerPawn?.Value;
|
var playerPawn = player.PlayerPawn?.Value;
|
||||||
if (playerPawn != null && playerPawn.IsValid)
|
if (playerPawn != null && playerPawn.IsValid)
|
||||||
{
|
{
|
||||||
|
if (!exists)
|
||||||
|
Instance.RegisterListener<CheckTransmit>(CheckTransmit);
|
||||||
|
exists = true;
|
||||||
|
|
||||||
playerPawn.VelocityModifier = 1.1f;
|
playerPawn.VelocityModifier = 1.1f;
|
||||||
|
|
||||||
playerPawn.Health = 50;
|
playerPawn.Health = 50;
|
||||||
|
|
@ -136,11 +155,11 @@ namespace jRandomSkills
|
||||||
SetWeaponAttack(player, false);
|
SetWeaponAttack(player, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var chicken in chickens)
|
if (chickens.TryGetValue(player, out var chicken))
|
||||||
{
|
{
|
||||||
if (chicken.Value != null && chicken.Value.IsValid)
|
if (chicken != null && chicken.IsValid)
|
||||||
chicken.Value.Remove();
|
chicken.Remove();
|
||||||
chickens.Remove(chicken.Key);
|
chickens.Remove(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ namespace jRandomSkills
|
||||||
{
|
{
|
||||||
private const Skills skillName = Skills.Ghost;
|
private const Skills skillName = Skills.Ghost;
|
||||||
private static bool roundEnd = false;
|
private static bool roundEnd = false;
|
||||||
|
private static bool exists = false;
|
||||||
private static readonly string[] disabledWeapons =
|
private static readonly string[] disabledWeapons =
|
||||||
[
|
[
|
||||||
"weapon_deagle", "weapon_revolver", "weapon_glock", "weapon_usp_silencer",
|
"weapon_deagle", "weapon_revolver", "weapon_glock", "weapon_usp_silencer",
|
||||||
|
|
@ -27,7 +28,7 @@ namespace jRandomSkills
|
||||||
"weapon_g3sg1", "weapon_nova", "weapon_xm1014", "weapon_mag7",
|
"weapon_g3sg1", "weapon_nova", "weapon_xm1014", "weapon_mag7",
|
||||||
"weapon_sawedoff", "weapon_m249", "weapon_negev"
|
"weapon_sawedoff", "weapon_m249", "weapon_negev"
|
||||||
];
|
];
|
||||||
private static readonly HashSet<uint> invisibleEntities = [];
|
private static readonly Dictionary<ulong, List<uint>> invisibleEntities = [];
|
||||||
|
|
||||||
public static void LoadSkill()
|
public static void LoadSkill()
|
||||||
{
|
{
|
||||||
|
|
@ -63,6 +64,8 @@ namespace jRandomSkills
|
||||||
DisableSkill(player);
|
DisableSkill(player);
|
||||||
}
|
}
|
||||||
roundEnd = true;
|
roundEnd = true;
|
||||||
|
Instance.RemoveListener<CheckTransmit>(CheckTransmit);
|
||||||
|
exists = false;
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -86,7 +89,18 @@ namespace jRandomSkills
|
||||||
|
|
||||||
if (playerInfo?.Skill != skillName) return HookResult.Continue;
|
if (playerInfo?.Skill != skillName) return HookResult.Continue;
|
||||||
SetWeaponVisibility(player!, false);
|
SetWeaponVisibility(player!, false);
|
||||||
SetWearablesVisibility(player!, false);
|
SetWeaponAttack(player!, true);
|
||||||
|
return HookResult.Continue;
|
||||||
|
});
|
||||||
|
|
||||||
|
Instance.RegisterEventHandler<EventItemEquip>((@event, info) =>
|
||||||
|
{
|
||||||
|
var player = @event.Userid;
|
||||||
|
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
|
||||||
|
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player?.SteamID);
|
||||||
|
|
||||||
|
if (playerInfo?.Skill != skillName) return HookResult.Continue;
|
||||||
|
SetWeaponVisibility(player!, false);
|
||||||
SetWeaponAttack(player!, true);
|
SetWeaponAttack(player!, true);
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
});
|
});
|
||||||
|
|
@ -99,7 +113,6 @@ namespace jRandomSkills
|
||||||
});
|
});
|
||||||
|
|
||||||
Instance.RegisterListener<OnTick>(OnTick);
|
Instance.RegisterListener<OnTick>(OnTick);
|
||||||
Instance.RegisterListener<CheckTransmit>(CheckTransmit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void CheckTransmit([CastFrom(typeof(nint))] CCheckTransmitInfoList infoList)
|
public static void CheckTransmit([CastFrom(typeof(nint))] CCheckTransmitInfoList infoList)
|
||||||
|
|
@ -107,16 +120,21 @@ namespace jRandomSkills
|
||||||
foreach (var (info, player) in infoList)
|
foreach (var (info, player) in infoList)
|
||||||
{
|
{
|
||||||
if (player == null) continue;
|
if (player == null) continue;
|
||||||
foreach (var entity in invisibleEntities)
|
foreach ((var playerId, var itemList) in invisibleEntities)
|
||||||
info.TransmitEntities.Remove((int)entity);
|
if (player.SteamID != playerId)
|
||||||
|
foreach (var item in itemList)
|
||||||
|
info.TransmitEntities.Remove(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void EnableSkill(CCSPlayerController player)
|
public static void EnableSkill(CCSPlayerController player)
|
||||||
{
|
{
|
||||||
|
if (!exists)
|
||||||
|
Instance.RegisterListener<CheckTransmit>(CheckTransmit);
|
||||||
|
exists = true;
|
||||||
|
|
||||||
SetPlayerVisibility(player, false);
|
SetPlayerVisibility(player, false);
|
||||||
SetWeaponVisibility(player, false);
|
SetWeaponVisibility(player, false);
|
||||||
SetWearablesVisibility(player, false);
|
|
||||||
SetWeaponAttack(player, true);
|
SetWeaponAttack(player, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -124,8 +142,8 @@ namespace jRandomSkills
|
||||||
{
|
{
|
||||||
SetPlayerVisibility(player, true);
|
SetPlayerVisibility(player, true);
|
||||||
SetWeaponVisibility(player, true);
|
SetWeaponVisibility(player, true);
|
||||||
SetWearablesVisibility(player, true);
|
|
||||||
SetWeaponAttack(player, false);
|
SetWeaponAttack(player, false);
|
||||||
|
invisibleEntities.Remove(player.SteamID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void OnTick()
|
private static void OnTick()
|
||||||
|
|
@ -152,44 +170,39 @@ namespace jRandomSkills
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SetWearablesVisibility(CCSPlayerController player, bool visible)
|
|
||||||
{
|
|
||||||
if (!Instance.IsPlayerValid(player)) return;
|
|
||||||
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 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)
|
private static void SetWeaponVisibility(CCSPlayerController player, bool visible)
|
||||||
{
|
{
|
||||||
if (!Instance.IsPlayerValid(player)) return;
|
if (!Instance.IsPlayerValid(player)) return;
|
||||||
var playerPawn = player.PlayerPawn.Value!;
|
var playerPawn = player.PlayerPawn.Value!;
|
||||||
if (playerPawn.WeaponServices == null) return;
|
if (playerPawn.WeaponServices == null) return;
|
||||||
|
|
||||||
var color = visible ? Color.FromArgb(255, 255, 255, 255) : Color.FromArgb(0, 255, 255, 255);
|
// var color = visible ? Color.FromArgb(255, 255, 255, 255) : Color.FromArgb(0, 255, 255, 255);
|
||||||
var shadowStrength = visible ? 1.0f : 0.0f;
|
// var shadowStrength = visible ? 1.0f : 0.0f;
|
||||||
|
|
||||||
|
invisibleEntities.Remove(player.SteamID);
|
||||||
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)
|
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
|
||||||
{
|
{
|
||||||
|
if (!visible)
|
||||||
|
{
|
||||||
|
if (invisibleEntities.TryGetValue(player.SteamID, out var items))
|
||||||
|
{
|
||||||
|
if (!items.Contains(weapon.Index))
|
||||||
|
items.Add(weapon.Index);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
invisibleEntities.Add(player.SteamID, [weapon.Index]);
|
||||||
|
}
|
||||||
|
/*
|
||||||
weapon.Value.Render = color;
|
weapon.Value.Render = color;
|
||||||
weapon.Value.ShadowStrength = shadowStrength;
|
weapon.Value.ShadowStrength = shadowStrength;
|
||||||
Utilities.SetStateChanged(weapon.Value, "CBaseModelEntity", "m_clrRender");
|
Utilities.SetStateChanged(weapon.Value, "CBaseModelEntity", "m_clrRender");*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (visible)
|
||||||
|
invisibleEntities.Remove(player.SteamID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SetWeaponAttack(CCSPlayerController player, bool disableWeapon)
|
private static void SetWeaponAttack(CCSPlayerController player, bool disableWeapon)
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ namespace jRandomSkills
|
||||||
{
|
{
|
||||||
private const Skills skillName = Skills.Glaz;
|
private const Skills skillName = Skills.Glaz;
|
||||||
private static bool exists = false;
|
private static bool exists = false;
|
||||||
private static List<int> smokes = new List<int>();
|
private readonly static List<int> smokes = [];
|
||||||
|
|
||||||
public static void LoadSkill()
|
public static void LoadSkill()
|
||||||
{
|
{
|
||||||
|
|
@ -80,11 +80,8 @@ namespace jRandomSkills
|
||||||
SkillUtils.TryGiveWeapon(player, CsItem.SmokeGrenade);
|
SkillUtils.TryGiveWeapon(player, CsItem.SmokeGrenade);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SkillConfig : Config.DefaultSkillInfo
|
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#5d00ff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||||
{
|
|
||||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#5d00ff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
@ -73,8 +73,9 @@ namespace jRandomSkills
|
||||||
if (pawn == null || !pawn.IsValid || pawn.LifeState != (byte)LifeState_t.LIFE_ALIVE) continue;
|
if (pawn == null || !pawn.IsValid || pawn.LifeState != (byte)LifeState_t.LIFE_ALIVE) continue;
|
||||||
|
|
||||||
var beams = step.Value;
|
var beams = step.Value;
|
||||||
if (beams.Count == 0 || pawn.AbsOrigin == null) continue;
|
if (pawn.AbsOrigin == null) continue;
|
||||||
Vector lastBeamVector = beams.LastOrDefault()?.EndPos ?? pawn.AbsOrigin;
|
Vector lastBeamVector = beams.Count > 0
|
||||||
|
? beams.LastOrDefault()!.EndPos : pawn.AbsOrigin;
|
||||||
|
|
||||||
var newBeam = CreateBeamStep(step.Key.Team, lastBeamVector, pawn.AbsOrigin);
|
var newBeam = CreateBeamStep(step.Key.Team, lastBeamVector, pawn.AbsOrigin);
|
||||||
if (newBeam != null)
|
if (newBeam != null)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using CounterStrikeSharp.API;
|
using CounterStrikeSharp.API;
|
||||||
using CounterStrikeSharp.API.Core;
|
using CounterStrikeSharp.API.Core;
|
||||||
|
using CounterStrikeSharp.API.Core.Attributes;
|
||||||
using CounterStrikeSharp.API.Modules.Utils;
|
using CounterStrikeSharp.API.Modules.Utils;
|
||||||
using jRandomSkills.src.player;
|
using jRandomSkills.src.player;
|
||||||
using static CounterStrikeSharp.API.Core.Listeners;
|
using static CounterStrikeSharp.API.Core.Listeners;
|
||||||
|
|
@ -11,15 +12,36 @@ namespace jRandomSkills
|
||||||
public class Ninja : ISkill
|
public class Ninja : ISkill
|
||||||
{
|
{
|
||||||
private const Skills skillName = Skills.Ninja;
|
private const Skills skillName = Skills.Ninja;
|
||||||
|
private static bool exists = false;
|
||||||
private static readonly float idlePercentInvisibility = Config.GetValue<float>(skillName, "idlePercentInvisibility");
|
private static readonly float idlePercentInvisibility = Config.GetValue<float>(skillName, "idlePercentInvisibility");
|
||||||
private static readonly float duckPercentInvisibility = Config.GetValue<float>(skillName, "duckPercentInvisibility");
|
private static readonly float duckPercentInvisibility = Config.GetValue<float>(skillName, "duckPercentInvisibility");
|
||||||
private static readonly float knifePercentInvisibility = Config.GetValue<float>(skillName, "knifePercentInvisibility");
|
private static readonly float knifePercentInvisibility = Config.GetValue<float>(skillName, "knifePercentInvisibility");
|
||||||
private static readonly Dictionary<nint, float> invisibilityChanged = [];
|
private static readonly Dictionary<nint, float> invisibilityChanged = [];
|
||||||
|
private static readonly Dictionary<ulong, List<uint>> invisibleEntities = [];
|
||||||
|
|
||||||
public static void LoadSkill()
|
public static void LoadSkill()
|
||||||
{
|
{
|
||||||
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
|
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
|
||||||
|
|
||||||
|
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
|
||||||
|
{
|
||||||
|
Instance.AddTimer(0.1f, () =>
|
||||||
|
{
|
||||||
|
foreach (var player in Utilities.GetPlayers())
|
||||||
|
{
|
||||||
|
DisableSkill(player);
|
||||||
|
if (!Instance.IsPlayerValid(player)) continue;
|
||||||
|
var playerPawn = player.PlayerPawn?.Value;
|
||||||
|
|
||||||
|
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||||
|
if (playerInfo?.Skill != skillName) continue;
|
||||||
|
EnableSkill(player);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return HookResult.Continue;
|
||||||
|
});
|
||||||
|
|
||||||
Instance.RegisterEventHandler<EventRoundStart>((@event, info) =>
|
Instance.RegisterEventHandler<EventRoundStart>((@event, info) =>
|
||||||
{
|
{
|
||||||
foreach (var player in Utilities.GetPlayers())
|
foreach (var player in Utilities.GetPlayers())
|
||||||
|
|
@ -51,9 +73,46 @@ namespace jRandomSkills
|
||||||
return HookResult.Continue;
|
return HookResult.Continue;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Instance.RegisterEventHandler<EventItemEquip>((@event, info) =>
|
||||||
|
{
|
||||||
|
var player = @event.Userid;
|
||||||
|
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
|
||||||
|
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player?.SteamID);
|
||||||
|
|
||||||
|
if (playerInfo?.Skill != skillName) return HookResult.Continue;
|
||||||
|
UpdateNinja(player);
|
||||||
|
return HookResult.Continue;
|
||||||
|
});
|
||||||
|
|
||||||
|
Instance.RegisterEventHandler<EventRoundEnd>((@event, info) =>
|
||||||
|
{
|
||||||
|
foreach (var player in Utilities.GetPlayers())
|
||||||
|
{
|
||||||
|
if (!Instance.IsPlayerValid(player)) continue;
|
||||||
|
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||||
|
if (playerInfo?.Skill == skillName)
|
||||||
|
DisableSkill(player);
|
||||||
|
}
|
||||||
|
Instance.RemoveListener<CheckTransmit>(CheckTransmit);
|
||||||
|
exists = false;
|
||||||
|
return HookResult.Continue;
|
||||||
|
});
|
||||||
|
|
||||||
Instance.RegisterListener<OnTick>(OnTick);
|
Instance.RegisterListener<OnTick>(OnTick);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void CheckTransmit([CastFrom(typeof(nint))] CCheckTransmitInfoList infoList)
|
||||||
|
{
|
||||||
|
foreach (var (info, player) in infoList)
|
||||||
|
{
|
||||||
|
if (player == null) continue;
|
||||||
|
foreach ((var playerId, var itemList) in invisibleEntities)
|
||||||
|
if (player.SteamID != playerId)
|
||||||
|
foreach (var item in itemList)
|
||||||
|
info.TransmitEntities.Remove(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void OnTick()
|
private static void OnTick()
|
||||||
{
|
{
|
||||||
foreach (var player in Utilities.GetPlayers())
|
foreach (var player in Utilities.GetPlayers())
|
||||||
|
|
@ -64,10 +123,18 @@ namespace jRandomSkills
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void EnableSkill(CCSPlayerController player)
|
||||||
|
{
|
||||||
|
if (!exists)
|
||||||
|
Instance.RegisterListener<CheckTransmit>(CheckTransmit);
|
||||||
|
exists = true;
|
||||||
|
}
|
||||||
|
|
||||||
public static void DisableSkill(CCSPlayerController player)
|
public static void DisableSkill(CCSPlayerController player)
|
||||||
{
|
{
|
||||||
SetPlayerVisibility(player, 0);
|
SetPlayerVisibility(player, 0);
|
||||||
SetWeaponVisibility(player, 0);
|
SetWeaponVisibility(player, 0);
|
||||||
|
invisibleEntities.Remove(player.SteamID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void UpdateNinja(CCSPlayerController? player)
|
private static void UpdateNinja(CCSPlayerController? player)
|
||||||
|
|
@ -92,13 +159,13 @@ namespace jRandomSkills
|
||||||
if (!buttons.HasFlag(PlayerButtons.Moveleft) && !buttons.HasFlag(PlayerButtons.Moveright) && !buttons.HasFlag(PlayerButtons.Forward) && !buttons.HasFlag(PlayerButtons.Back) && flags.HasFlag(PlayerFlags.FL_ONGROUND))
|
if (!buttons.HasFlag(PlayerButtons.Moveleft) && !buttons.HasFlag(PlayerButtons.Moveright) && !buttons.HasFlag(PlayerButtons.Forward) && !buttons.HasFlag(PlayerButtons.Back) && flags.HasFlag(PlayerFlags.FL_ONGROUND))
|
||||||
percentInvisibility += idlePercentInvisibility;
|
percentInvisibility += idlePercentInvisibility;
|
||||||
|
|
||||||
|
SetWeaponVisibility(player, percentInvisibility);
|
||||||
if (invisibilityChanged.TryGetValue(player.Handle, out float oldInvisibility))
|
if (invisibilityChanged.TryGetValue(player.Handle, out float oldInvisibility))
|
||||||
if (percentInvisibility == oldInvisibility)
|
if (percentInvisibility == oldInvisibility)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
invisibilityChanged[player.Handle] = percentInvisibility;
|
invisibilityChanged[player.Handle] = percentInvisibility;
|
||||||
SetPlayerVisibility(player, percentInvisibility);
|
SetPlayerVisibility(player, percentInvisibility);
|
||||||
SetWeaponVisibility(player, percentInvisibility);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SetPlayerVisibility(CCSPlayerController player, float percentInvisibility)
|
private static void SetPlayerVisibility(CCSPlayerController player, float percentInvisibility)
|
||||||
|
|
@ -115,17 +182,25 @@ namespace jRandomSkills
|
||||||
private static void SetWeaponVisibility(CCSPlayerController player, float percentInvisibility)
|
private static void SetWeaponVisibility(CCSPlayerController player, float percentInvisibility)
|
||||||
{
|
{
|
||||||
if (!Instance.IsPlayerValid(player)) return;
|
if (!Instance.IsPlayerValid(player)) return;
|
||||||
var playerPawn = player.PlayerPawn.Value;
|
var playerPawn = player.PlayerPawn.Value!;
|
||||||
if (playerPawn == null || !playerPawn.IsValid || playerPawn.WeaponServices == null) return;
|
if (playerPawn.WeaponServices == null) return;
|
||||||
|
|
||||||
var color = Color.FromArgb(Math.Max(255 - (int)(255 * percentInvisibility * 2), 0), 255, 255, 255);
|
var color = Color.FromArgb(Math.Max(255 - (int)(255 * percentInvisibility * 2), 0), 255, 255, 255);
|
||||||
|
|
||||||
|
invisibleEntities.Remove(player.SteamID);
|
||||||
|
if (color.A != 0) return;
|
||||||
|
|
||||||
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)
|
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
|
||||||
{
|
{
|
||||||
weapon.Value.Render = color;
|
if (invisibleEntities.TryGetValue(player.SteamID, out var items))
|
||||||
Utilities.SetStateChanged(weapon.Value, "CBaseModelEntity", "m_clrRender");
|
{
|
||||||
|
if (!items.Contains(weapon.Index))
|
||||||
|
items.Add(weapon.Index);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
invisibleEntities.Add(player.SteamID, [weapon.Index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ namespace jRandomSkills
|
||||||
|
|
||||||
public static void LoadSkill()
|
public static void LoadSkill()
|
||||||
{
|
{
|
||||||
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
|
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"), false);
|
||||||
|
|
||||||
Instance.RegisterListener<OnTick>(() =>
|
Instance.RegisterListener<OnTick>(() =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -140,52 +140,54 @@ namespace jRandomSkills
|
||||||
public bool TeamMateSkillInfo { get; set; }
|
public bool TeamMateSkillInfo { get; set; }
|
||||||
public bool SummaryAfterTheRound { get; set; }
|
public bool SummaryAfterTheRound { get; set; }
|
||||||
public bool DebugMode { get; set; }
|
public bool DebugMode { get; set; }
|
||||||
public string SetSkillCommands { get; set; }
|
public NormalCommand SetSkillCommands { get; set; }
|
||||||
public string SkillsListCommands { get; set; }
|
public NormalCommand SkillsListCommands { get; set; }
|
||||||
public string UseSkillCommands { get; set; }
|
public NormalCommand UseSkillCommands { get; set; }
|
||||||
public string ChangeMapCommands { get; set; }
|
public NormalCommand HealCommands { get; set; }
|
||||||
public string StartGameCommands { get; set; }
|
public NormalCommand ConsoleCommands { get; set; }
|
||||||
public string ConsoleCommands { get; set; }
|
public NormalCommand SetStaticSkillCommands { get; set; }
|
||||||
public string SwapCommands { get; set; }
|
public VotingCommand StartGameCommands { get; set; }
|
||||||
public string ShuffleCommands { get; set; }
|
public VotingCommand ChangeMapCommands { get; set; }
|
||||||
public string PauseCommands { get; set; }
|
public VotingCommand SwapCommands { get; set; }
|
||||||
public string HealCommands { get; set; }
|
public VotingCommand ShuffleCommands { get; set; }
|
||||||
public string SetScoreCommands { get; set; }
|
public VotingCommand PauseCommands { get; set; }
|
||||||
public VotingCommand[] VotingCommand { get; set; }
|
public VotingCommand SetScoreCommands { get; set; }
|
||||||
|
|
||||||
public Settings()
|
public Settings()
|
||||||
{
|
{
|
||||||
LangCode = "en";
|
LangCode = "en";
|
||||||
GameMode = (int)GameModes.Normal;
|
GameMode = (int)GameModes.NoRepeat;
|
||||||
KillerSkillInfo = true;
|
KillerSkillInfo = true;
|
||||||
TeamMateSkillInfo = true;
|
TeamMateSkillInfo = true;
|
||||||
SummaryAfterTheRound = true;
|
SummaryAfterTheRound = true;
|
||||||
DebugMode = true;
|
DebugMode = true;
|
||||||
|
|
||||||
SetSkillCommands = "ustawskill, setskill, definirhabilidade, configurarhabilidade, 设置技能, 配置技能";
|
SetSkillCommands = new NormalCommand("ustawskill, ustaw_skill, setskill, set_skill, definirhabilidade, configurarhabilidade, 设置技能, 配置技能", "@jRandmosSkills/admin");
|
||||||
SkillsListCommands = "supermoc, skille, listamocy, supermoce, skills, listaHabilidades, habilidades, 技能列表, 超能力列表";
|
SkillsListCommands = new NormalCommand("supermoc, skille, listamocy, supermoce, skills, listaHabilidades, habilidades, 技能列表, 超能力列表", "@jRandmosSkills/admin");
|
||||||
UseSkillCommands = "t, useSkill, usarHabilidade, 技能使用, 使用技能";
|
UseSkillCommands = new NormalCommand("t, useSkill, usarHabilidade, 技能使用, 使用技能", "@jRandmosSkills/admin");
|
||||||
HealCommands = "heal, ulecz, curar, tratar, 治疗, 治愈";
|
HealCommands = new NormalCommand("heal, ulecz, curar, tratar, 治疗, 治愈", "@jRandmosSkills/admin");
|
||||||
ConsoleCommands = "console, sv, 控制台, 服务器";
|
ConsoleCommands = new NormalCommand("console, sv, 控制台, 服务器", "@jRandmosSkills/root");
|
||||||
|
SetStaticSkillCommands = new NormalCommand("ustawstatycznyskill, ustaw_statyczny_skill, setstaticskill, set_static_skill", "@jRandmosSkills/admin");
|
||||||
|
|
||||||
VotingCommand = [
|
StartGameCommands = new VotingCommand(true, "start, go, começar, iniciar, 开始, 启动", "@jRandmosSkills/admin", 15, 60, 15, 500, 2);
|
||||||
new VotingCommand("StartGameCommands", true, "start, go, começar, iniciar, 开始, 启动", "@jRandmosSkills/admin", 15, 60, 15, 500, 2),
|
ChangeMapCommands = new VotingCommand( true, "map, mapa, changemap, zmienmape, zmienmape, mudarMapa, trocarMapa, 更换地图, 更改地图", "@jRandmosSkills/admin", 25, 90, 15, 500, 2);
|
||||||
new VotingCommand("ChangeMapCommands", true, "map, mapa, changemap, zmienmape, zmienmape, mudarMapa, trocarMapa, 更换地图, 更改地图", "@jRandmosSkills/admin", 25, 90, 15, 500, 2),
|
SwapCommands = new VotingCommand(true, "swap, zmiana, trocar, 交换, 切换", "@jRandmosSkills/admin", 15, 90, 15, 20, 2);
|
||||||
new VotingCommand("SwapCommands", true, "swap, zmiana, trocar, 交换, 切换", "@jRandmosSkills/admin", 15, 90, 15, 20, 2),
|
ShuffleCommands = new VotingCommand(true, "shuffle, embaralhar, 随机排序, 洗牌", "@jRandmosSkills/admin", 15, 90, 15, 20, 2);
|
||||||
new VotingCommand("ShuffleCommands", true, "shuffle, embaralhar, 随机排序, 洗牌", "@jRandmosSkills/admin", 15, 90, 15, 90, 2),
|
PauseCommands = new VotingCommand(true, "pause, unpause, pausar, despausar, 暂停, 恢复", "@jRandmosSkills/admin", 15, 60, 15, 2, 2);
|
||||||
new VotingCommand("PauseCommands", true, "pause, unpause, pausar, despausar, 暂停, 恢复", "@jRandmosSkills/admin", 15, 60, 15, 90, 2),
|
SetScoreCommands = new VotingCommand(true, "setscore, wynik, definirPontuacao, configurarPontos, 设置分数, 调整分数", "@jRandmosSkills/root", 15, 90, 15, 90, 2);
|
||||||
new VotingCommand("SetScoreCommands", true, "setscore, wynik, definirPontuacao, configurarPontos, 设置分数, 调整分数", "@jRandmosSkills/root", 15, 90, 15, 90, 2),
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class VotingCommand(string name, bool enableVoting, string alias, string permissions, float timeToVote, float percentagesToSuccess, float timeToNextVoting, float timeToNextSameVoting, int minimumPlayersToStartVoting)
|
public class NormalCommand(string alias, string permissions)
|
||||||
{
|
{
|
||||||
public string Name { get; set; } = name;
|
|
||||||
public bool EnableVoting { get; set; } = enableVoting;
|
|
||||||
public string Alias { get; set; } = alias;
|
public string Alias { get; set; } = alias;
|
||||||
public string Permissions { get; set; } = permissions;
|
public string Permissions { get; set; } = permissions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class VotingCommand(bool enableVoting, string alias, string permissions, float timeToVote, float percentagesToSuccess, float timeToNextVoting, float timeToNextSameVoting, int minimumPlayersToStartVoting) : NormalCommand(alias, permissions)
|
||||||
|
{
|
||||||
|
public bool EnableVoting { get; set; } = enableVoting;
|
||||||
public float TimeToVote { get; set; } = timeToVote;
|
public float TimeToVote { get; set; } = timeToVote;
|
||||||
public float PercentagesToSuccess { get; set; } = percentagesToSuccess;
|
public float PercentagesToSuccess { get; set; } = percentagesToSuccess;
|
||||||
public float TimeToNextVoting { get; set; } = timeToNextVoting;
|
public float TimeToNextVoting { get; set; } = timeToNextVoting;
|
||||||
|
|
@ -207,7 +209,8 @@ namespace jRandomSkills
|
||||||
Normal = 0,
|
Normal = 0,
|
||||||
TeamSkills = 1,
|
TeamSkills = 1,
|
||||||
SameSkills = 2,
|
SameSkills = 2,
|
||||||
Debug = 3,
|
NoRepeat = 3,
|
||||||
|
Debug = 4
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,22 +1,95 @@
|
||||||
{
|
{
|
||||||
"Settings": {
|
"Settings": {
|
||||||
"LangCode": "en",
|
"LangCode": "en",
|
||||||
"GameMode": 0,
|
"GameMode": 3,
|
||||||
"KillerSkillInfo": true,
|
"KillerSkillInfo": true,
|
||||||
"TeamMateSkillInfo": true,
|
"TeamMateSkillInfo": true,
|
||||||
"SummaryAfterTheRound": true,
|
"SummaryAfterTheRound": true,
|
||||||
"DebugMode": true,
|
"DebugMode": true,
|
||||||
"SetSkillCommands": "ustawskill, setskill, definirhabilidade, configurarhabilidade, 设置技能, 配置技能",
|
"SetSkillCommands": {
|
||||||
"SkillsListCommands": "supermoc, skille, listamocy, supermoce, skills, listaHabilidades, habilidades, 技能列表, 超能力列表",
|
"Alias": "ustawskill, ustaw_skill, setskill, set_skill, definirhabilidade, configurarhabilidade, 设置技能, 配置技能",
|
||||||
"UseSkillCommands": "t, useSkill, usarHabilidade, 技能使用, 使用技能",
|
"Permissions": "@jRandmosSkills/admin"
|
||||||
"ChangeMapCommands": "map, mapa, changemap, zmienmape, zmienmape, mudarMapa, trocarMapa, 更换地图, 更改地图",
|
},
|
||||||
"StartGameCommands": "start, go, começar, iniciar, 开始, 启动",
|
"SkillsListCommands": {
|
||||||
"ConsoleCommands": "console, sv, 控制台, 服务器",
|
"Alias": "supermoc, skille, listamocy, supermoce, skills, listaHabilidades, habilidades, 技能列表, 超能力列表",
|
||||||
"SwapCommands": "swap, zmiana, trocar, 交换, 切换",
|
"Permissions": "@jRandmosSkills/admin"
|
||||||
"ShuffleCommands": "shuffle, embaralhar, 随机排序, 洗牌",
|
},
|
||||||
"PauseCommands": "pause, unpause, pausar, despausar, 暂停, 恢复",
|
"UseSkillCommands": {
|
||||||
"HealCommands": "heal, ulecz, curar, tratar, 治疗, 治愈",
|
"Alias": "t, useSkill, usarHabilidade, 技能使用, 使用技能",
|
||||||
"SetScoreCommands": "setscore, wynik, definirPontuacao, configurarPontos, 设置分数, 调整分数"
|
"Permissions": "@jRandmosSkills/admin"
|
||||||
|
},
|
||||||
|
"HealCommands": {
|
||||||
|
"Alias": "heal, ulecz, curar, tratar, 治疗, 治愈",
|
||||||
|
"Permissions": "@jRandmosSkills/admin"
|
||||||
|
},
|
||||||
|
"ConsoleCommands": {
|
||||||
|
"Alias": "console, sv, 控制台, 服务器",
|
||||||
|
"Permissions": "@jRandmosSkills/root"
|
||||||
|
},
|
||||||
|
"SetStaticSkillCommands": {
|
||||||
|
"Alias": "ustawstatycznyskill, ustaw_statyczny_skill, setstaticskill, set_static_skill",
|
||||||
|
"Permissions": "@jRandmosSkills/admin"
|
||||||
|
},
|
||||||
|
"StartGameCommands": {
|
||||||
|
"EnableVoting": true,
|
||||||
|
"TimeToVote": 15.0,
|
||||||
|
"PercentagesToSuccess": 60.0,
|
||||||
|
"TimeToNextVoting": 15.0,
|
||||||
|
"TimeToNextSameVoting": 500.0,
|
||||||
|
"MinimumPlayersToStartVoting": 2,
|
||||||
|
"Alias": "start, go, começar, iniciar, 开始, 启动",
|
||||||
|
"Permissions": "@jRandmosSkills/admin"
|
||||||
|
},
|
||||||
|
"ChangeMapCommands": {
|
||||||
|
"EnableVoting": true,
|
||||||
|
"TimeToVote": 25.0,
|
||||||
|
"PercentagesToSuccess": 90.0,
|
||||||
|
"TimeToNextVoting": 15.0,
|
||||||
|
"TimeToNextSameVoting": 500.0,
|
||||||
|
"MinimumPlayersToStartVoting": 2,
|
||||||
|
"Alias": "map, mapa, changemap, zmienmape, zmienmape, mudarMapa, trocarMapa, 更换地图, 更改地图",
|
||||||
|
"Permissions": "@jRandmosSkills/admin"
|
||||||
|
},
|
||||||
|
"SwapCommands": {
|
||||||
|
"EnableVoting": true,
|
||||||
|
"TimeToVote": 15.0,
|
||||||
|
"PercentagesToSuccess": 90.0,
|
||||||
|
"TimeToNextVoting": 15.0,
|
||||||
|
"TimeToNextSameVoting": 20.0,
|
||||||
|
"MinimumPlayersToStartVoting": 2,
|
||||||
|
"Alias": "swap, zmiana, trocar, 交换, 切换",
|
||||||
|
"Permissions": "@jRandmosSkills/admin"
|
||||||
|
},
|
||||||
|
"ShuffleCommands": {
|
||||||
|
"EnableVoting": true,
|
||||||
|
"TimeToVote": 15.0,
|
||||||
|
"PercentagesToSuccess": 90.0,
|
||||||
|
"TimeToNextVoting": 15.0,
|
||||||
|
"TimeToNextSameVoting": 20.0,
|
||||||
|
"MinimumPlayersToStartVoting": 2,
|
||||||
|
"Alias": "shuffle, embaralhar, 随机排序, 洗牌",
|
||||||
|
"Permissions": "@jRandmosSkills/admin"
|
||||||
|
},
|
||||||
|
"PauseCommands": {
|
||||||
|
"EnableVoting": true,
|
||||||
|
"TimeToVote": 15.0,
|
||||||
|
"PercentagesToSuccess": 60.0,
|
||||||
|
"TimeToNextVoting": 15.0,
|
||||||
|
"TimeToNextSameVoting": 2.0,
|
||||||
|
"MinimumPlayersToStartVoting": 2,
|
||||||
|
"Alias": "pause, unpause, pausar, despausar, 暂停, 恢复",
|
||||||
|
"Permissions": "@jRandmosSkills/admin"
|
||||||
|
},
|
||||||
|
"SetScoreCommands": {
|
||||||
|
"EnableVoting": true,
|
||||||
|
"TimeToVote": 15.0,
|
||||||
|
"PercentagesToSuccess": 90.0,
|
||||||
|
"TimeToNextVoting": 15.0,
|
||||||
|
"TimeToNextSameVoting": 90.0,
|
||||||
|
"MinimumPlayersToStartVoting": 2,
|
||||||
|
"Alias": "setscore, wynik, definirPontuacao, configurarPontos, 设置分数, 调整分数",
|
||||||
|
"Permissions": "@jRandmosSkills/root"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"SkillsInfo": [
|
"SkillsInfo": [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -401,7 +401,7 @@
|
||||||
"skill_not_found_setskill": "No such CHATCOLORS.REDskill found",
|
"skill_not_found_setskill": "No such CHATCOLORS.REDskill found",
|
||||||
"player_not_found_setskill": "No such CHATCOLORS.REDplayer found",
|
"player_not_found_setskill": "No such CHATCOLORS.REDplayer found",
|
||||||
"correct_form_setskill": "Correct usage: CHATCOLORS.RED!setskill <nickname> <skill>",
|
"correct_form_setskill": "Correct usage: CHATCOLORS.RED!setskill <nickname> <skill>",
|
||||||
"correct_form_setskill": "Correct usage: CHATCOLORS.RED!setscore <CT> <TT>",
|
"correct_form_setscore": "Correct usage: CHATCOLORS.RED!setscore <CT> <TT>",
|
||||||
"done_setskill": "skill set",
|
"done_setskill": "skill set",
|
||||||
"error_setskill": "Failed to set CHATCOLORS.REDskill",
|
"error_setskill": "Failed to set CHATCOLORS.REDskill",
|
||||||
"for_setskill": "for",
|
"for_setskill": "for",
|
||||||
|
|
@ -414,6 +414,14 @@
|
||||||
"healed": "You have been healed.",
|
"healed": "You have been healed.",
|
||||||
"game_start": "Game started!",
|
"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",
|
"teammate_skills": "Your teammates' skills",
|
||||||
"summary_start": "======SUMMARY=OF=THE=LAST=ROUND======",
|
"summary_start": "======SUMMARY=OF=THE=LAST=ROUND======",
|
||||||
"summary_end": "======================================="
|
"summary_end": "======================================="
|
||||||
|
|
|
||||||
|
|
@ -414,6 +414,14 @@
|
||||||
"healed": "Zostałeś uleczony.",
|
"healed": "Zostałeś uleczony.",
|
||||||
"game_start": "Gra rozpoczęta!",
|
"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",
|
"teammate_skills": "Supermoce twoich sojuszników",
|
||||||
"summary_start": "======PODSUMOWANIE=Z=OSTATNIEJ=RUNDY======",
|
"summary_start": "======PODSUMOWANIE=Z=OSTATNIEJ=RUNDY======",
|
||||||
"summary_end": "============================================"
|
"summary_end": "============================================"
|
||||||
|
|
|
||||||
|
|
@ -414,6 +414,14 @@
|
||||||
"healed": "Você foi curado.",
|
"healed": "Você foi curado.",
|
||||||
"game_start": "Jogo iniciado!",
|
"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",
|
"teammate_skills": "Habilidades dos seus companheiros de equipe",
|
||||||
"summary_start": "=======RESUMO=DA=ÚLTIMA=RODADA=======",
|
"summary_start": "=======RESUMO=DA=ÚLTIMA=RODADA=======",
|
||||||
"summary_end": "======================================="
|
"summary_end": "======================================="
|
||||||
|
|
|
||||||
|
|
@ -414,6 +414,14 @@
|
||||||
"healed": "你已被治疗。",
|
"healed": "你已被治疗。",
|
||||||
"game_start": "游戏开始!",
|
"game_start": "游戏开始!",
|
||||||
|
|
||||||
|
"vote_started": "投票开始:'{0}'",
|
||||||
|
"vote_timeout": "投票'{0}'超时!",
|
||||||
|
"vote_wait": "您需要等待才能开始另一轮投票!",
|
||||||
|
"vote_same_wait": "您需要等待才能再次发起相同投票!",
|
||||||
|
"vote_not_enough_players": "投票人数不足!",
|
||||||
|
"vote_alredy_voted": "您已投票!",
|
||||||
|
"vote_vote": "投票",
|
||||||
|
|
||||||
"teammate_skills": "你队友的技能",
|
"teammate_skills": "你队友的技能",
|
||||||
"summary_start": "=============上一回合总结==============",
|
"summary_start": "=============上一回合总结==============",
|
||||||
"summary_end": "======================================="
|
"summary_end": "======================================="
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue