pre v1.1.2

This commit is contained in:
Juzlus 2025-09-03 04:20:40 +02:00
parent 504011456b
commit 54b265d43d
35 changed files with 584 additions and 129 deletions

View file

@ -127,11 +127,19 @@ namespace jRandomSkills
Menu.DisplaySkillsList(player); Menu.DisplaySkillsList(player);
} }
[RequiresPermissions("@jRandmosSkills/admin")]
[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) return; if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, "@TESTTEST/TESTAFD"))
{
player.Vote(VoteType.ChangeMap, command.ArgString);
return;
}
ChangeMap(player, command);
}
private static void ChangeMap(CCSPlayerController? player, CommandInfo command)
{
string map = command.GetArg(1); string map = command.GetArg(1);
if (string.IsNullOrEmpty(map)) if (string.IsNullOrEmpty(map))
@ -150,13 +158,20 @@ namespace jRandomSkills
Server.ExecuteCommand($"changelevel {map}"); Server.ExecuteCommand($"changelevel {map}");
} }
[RequiresPermissions("@jRandmosSkills/admin")]
[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) return; if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, "@TESTTEST/TESTAFD"))
int cheats = command.GetArg(1) == "sv" ? 1 : 0; {
player.Vote(VoteType.StartGame, command.ArgString);
return;
}
StartGame(player, command);
}
private static void StartGame(CCSPlayerController? player, CommandInfo command)
{
int cheats = command.GetArg(1) == "sv" ? 1 : 0;
Server.ExecuteCommand($"mp_freezetime {(cheats == 1 ? 0 : 5)}"); Server.ExecuteCommand($"mp_freezetime {(cheats == 1 ? 0 : 5)}");
Server.ExecuteCommand("mp_warmup_end"); Server.ExecuteCommand("mp_warmup_end");
Server.ExecuteCommand("mp_restartgame 1"); Server.ExecuteCommand("mp_restartgame 1");
@ -170,18 +185,18 @@ namespace jRandomSkills
}); });
} }
[RequiresPermissions("@jRandmosSkills/root")] [CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
[CommandHelper(minArgs: 1, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)] private static void Command_Swap(CCSPlayerController? player, CommandInfo command)
private static void Command_CustomCommand(CCSPlayerController? player, CommandInfo command)
{ {
if (player == null) return; if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, "@TESTTEST/TESTAFD"))
string param = command.ArgString; {
Server.ExecuteCommand(param); player.Vote(VoteType.SwapTeam, command.ArgString);
return;
}
Swap(player, command);
} }
[RequiresPermissions("@jRandmosSkills/admin")] private static void Swap(CCSPlayerController? _player, CommandInfo command)
[CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
private static void Command_Swap(CCSPlayerController? _player, CommandInfo command)
{ {
foreach (var player in Utilities.GetPlayers()) foreach (var player in Utilities.GetPlayers())
if (Instance.IsPlayerValid(player) && new CsTeam[] { CsTeam.CounterTerrorist, CsTeam.Terrorist }.Contains(player.Team)) if (Instance.IsPlayerValid(player) && new CsTeam[] { CsTeam.CounterTerrorist, CsTeam.Terrorist }.Contains(player.Team))
@ -189,9 +204,18 @@ namespace jRandomSkills
Server.ExecuteCommand($"mp_restartgame 1"); Server.ExecuteCommand($"mp_restartgame 1");
} }
[RequiresPermissions("@jRandmosSkills/admin")]
[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"))
{
player.Vote(VoteType.ShuffleTeam, command.ArgString);
return;
}
Shuffle(player, command);
}
private static void Shuffle(CCSPlayerController? _player, CommandInfo command)
{ {
var players = Utilities.GetPlayers().FindAll(p => (Instance.IsPlayerValid(p) && new CsTeam[] { CsTeam.CounterTerrorist, CsTeam.Terrorist }.Contains(p.Team))); 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); double CTlimit = Instance.Random.Next(0, 2) == 0 ? Math.Floor(players.Count / 2.0) : Math.Ceiling(players.Count / 2.0);
@ -204,9 +228,18 @@ namespace jRandomSkills
Server.ExecuteCommand($"mp_restartgame 1"); Server.ExecuteCommand($"mp_restartgame 1");
} }
[RequiresPermissions("@jRandmosSkills/admin")]
[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"))
{
player.Vote(VoteType.PauseGame, command.ArgString);
return;
}
Pause(player, command);
}
private static void Pause(CCSPlayerController? player, CommandInfo command)
{ {
Server.PrintToChatAll($" {(gamePaused ? ChatColors.Green : ChatColors.Red)}{Localization.GetTranslation(gamePaused ? "unpause" : "pause")}"); Server.PrintToChatAll($" {(gamePaused ? ChatColors.Green : ChatColors.Red)}{Localization.GetTranslation(gamePaused ? "unpause" : "pause")}");
Server.ExecuteCommand( gamePaused ? "mp_unpause_match" : "mp_pause_match"); Server.ExecuteCommand( gamePaused ? "mp_unpause_match" : "mp_pause_match");
@ -221,9 +254,18 @@ namespace jRandomSkills
player.PrintToChat($" {ChatColors.Green}{Localization.GetTranslation("healed")}"); player.PrintToChat($" {ChatColors.Green}{Localization.GetTranslation("healed")}");
} }
[RequiresPermissions("@jRandmosSkills/root")]
[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"))
{
player.Vote(VoteType.SetScore, command.ArgString);
return;
}
SetScore(player, command);
}
private static void SetScore(CCSPlayerController? player, CommandInfo command)
{ {
if (!int.TryParse(command.GetArg(1), out int ctScore) || !int.TryParse(command.GetArg(2), out int tScore)) if (!int.TryParse(command.GetArg(1), out int ctScore) || !int.TryParse(command.GetArg(2), out int tScore))
{ {
@ -233,5 +275,14 @@ 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)]
private static void Command_CustomCommand(CCSPlayerController? player, CommandInfo command)
{
if (player == null) return;
string param = command.ArgString;
Server.ExecuteCommand(param);
}
} }
} }

View file

@ -0,0 +1,110 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Events;
using CounterStrikeSharp.API.Modules.Utils;
namespace jRandomSkills
{
public static class VoteSystem
{
private static HashSet<VoteData> votes = new HashSet<VoteData>();
public static void Load()
{
jRandomSkills.Instance.DeregisterEventHandler<EventPlayerChat>((@event, info) =>
{
var player = @event.Userid;
var text = @event.Text;
return HookResult.Continue;
});
}
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);
jRandomSkills.Instance.AddTimer(vote?.TimeToVote ?? 0, () =>
{
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);
if (vote == null)
vote = CreateVote(voteType, args);
if (!vote.PlayersVoted.Add(player.SteamID))
player.PrintToChat($" {ChatColors.Red}You have already voted!");
else CheckVote(vote);
}
private static void CheckVote(VoteData vote)
{
int voted = vote.PlayersVoted.Count;
int playerCount = Utilities.GetPlayers().Where(p => !p.IsBot).ToArray().Length;
int playersNeeded = (int)Math.Ceiling(playerCount * (vote.PercentagesToSuccess / 100f));
if (voted >= playersNeeded)
{
vote.SuccessAction.Invoke();
votes.Remove(vote);
}
else
Server.PrintToChatAll($" {ChatColors.Yellow}Vote '!{VoteTypeCommands.GetCommand(vote.Type)?.Replace("css_", "")}': {ChatColors.Green}{voted}/{playersNeeded}");
}
}
public class VoteData
{
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; }
public VoteData(float timeToVote, Action successAction, float percentagesToSuccess, VoteType type, string? args = null)
{
TimeToVote = timeToVote;
SuccessAction = successAction;
PercentagesToSuccess = percentagesToSuccess;
Type = type;
Args = args;
PlayersVoted = new HashSet<ulong>();
}
}
public enum VoteType
{
StartGame,
PauseGame,
ShuffleTeam,
SwapTeam,
ChangeMap,
SetScore,
}
public static class VoteTypeCommands
{
private static readonly Dictionary<VoteType, string> names = new Dictionary<VoteType, string>()
{
{ VoteType.StartGame, "css_start" },
{ VoteType.PauseGame, "css_pause" },
{ VoteType.ShuffleTeam, "css_shuffle" },
{ VoteType.SwapTeam, "css_swap" },
{ VoteType.ChangeMap, "css_map" },
{ VoteType.SetScore, "css_setscore" },
};
public static string GetCommand(VoteType type) => names[type];
}
}

View file

@ -19,7 +19,7 @@ namespace jRandomSkills
public override string ModuleName => "[CS2] [ jRandomSkills ]"; public override string ModuleName => "[CS2] [ jRandomSkills ]";
public override string ModuleAuthor => "D3X, Juzlus"; public override string ModuleAuthor => "D3X, Juzlus";
public override string ModuleDescription => "Plugin adds random skills every round for CS2 by D3X. Modified by Juzlus."; public override string ModuleDescription => "Plugin adds random skills every round for CS2 by D3X. Modified by Juzlus.";
public override string ModuleVersion => "1.1.0"; public override string ModuleVersion => "1.1.2";
public override void Load(bool hotReload) public override void Load(bool hotReload)
{ {

View file

@ -199,6 +199,12 @@
"longzeus": "Long Zeus", "longzeus": "Long Zeus",
"longzeus_desc": "Zeus deals damage regardless of distance", "longzeus_desc": "Zeus deals damage regardless of distance",
"magnifier": "Magnifier",
"magnifier_desc": "Forces the enemy's screen to zoom in, reducing their field of view",
"magnifier_enemy_info": "Your field of view has been distorted!",
"magnifier_player_info": "Player '{0}' has been forced into zoom mode.",
"magnifier_select_info": "Select the player whose screen you want to magnify:",
"medic": "Medic", "medic": "Medic",
"medic_desc": "Click [css_useSkill] to use a healing charge that restores 50 health", "medic_desc": "Click [css_useSkill] to use a healing charge that restores 50 health",
@ -230,7 +236,8 @@
"onlyhead_desc": "You only take damage to the head", "onlyhead_desc": "You only take damage to the head",
"paweljumper": "Pawel Jumper", "paweljumper": "Pawel Jumper",
"paweljumper_desc": "You get an extra jump", "paweljumper_desc": "You get a random number of extra jumps",
"paweljumper_desc2": "You get {0} extra jumps",
"phoenix": "Phoenix", "phoenix": "Phoenix",
"phoenix_desc": "You have a random chance to respawn after death", "phoenix_desc": "You have a random chance to respawn after death",
@ -353,6 +360,9 @@
"thirdeye": "Third Eye", "thirdeye": "Third Eye",
"thirdeye_desc": "Click [css_useSkill] to activate third-person view", "thirdeye_desc": "Click [css_useSkill] to activate third-person view",
"thorns": "Thorns",
"thorns_desc": "Your opponent will receive a portion of the damage that they inflicted on you",
"toxicsmoke": "Toxic Smoke", "toxicsmoke": "Toxic Smoke",
"toxicsmoke_desc": "Your smoke grenades deal damage", "toxicsmoke_desc": "Your smoke grenades deal damage",

View file

@ -199,6 +199,12 @@
"longzeus": "Długi Zeus", "longzeus": "Długi Zeus",
"longzeus_desc": "Zeus zadaje obrażenia niezależnie od odległości", "longzeus_desc": "Zeus zadaje obrażenia niezależnie od odległości",
"magnifier": "Lupa",
"magnifier_desc": "Przybiżasz ekran wybranemu przeciwnikowi",
"magnifier_enemy_info": "Twoje pole widzenia zostało zniekształcone!",
"magnifier_player_info": "Gracz '{0}' został zmuszony do przejścia w tryb powiększenia.",
"magnifier_select_info": "Wybierz gracza, którego ekran chcesz powiększyć:",
"medic": "Medyk", "medic": "Medyk",
"medic_desc": "Kliknij [css_useSkill], aby użyć ładunku leczniczego, który przywraca 50 punktów zdrowia", "medic_desc": "Kliknij [css_useSkill], aby użyć ładunku leczniczego, który przywraca 50 punktów zdrowia",
@ -230,7 +236,8 @@
"onlyhead_desc": "Otrzymujesz obrażenia tylko w głowę", "onlyhead_desc": "Otrzymujesz obrażenia tylko w głowę",
"paweljumper": "Pawel Jumper", "paweljumper": "Pawel Jumper",
"paweljumper_desc": "Otrzymujesz dodatkowy skok", "paweljumper_desc": "Otrzymujesz losową liczbę dodatkowych skoków",
"paweljumper_desc2": "Otrzymujesz {0} dodatkowych skoków",
"phoenix": "Feniks", "phoenix": "Feniks",
"phoenix_desc": "Masz losową szans na odrodzenie się po śmierci", "phoenix_desc": "Masz losową szans na odrodzenie się po śmierci",
@ -353,6 +360,9 @@
"thirdeye": "Trzecie Oko", "thirdeye": "Trzecie Oko",
"thirdeye_desc": "Kliknij [css_useSkill], aby aktywować trzecią osobę", "thirdeye_desc": "Kliknij [css_useSkill], aby aktywować trzecią osobę",
"thorns": "Ciernie",
"thorns_desc": "Twój przeciwnik otrzymuje część obrażeń, które zadał ci",
"toxicsmoke": "Toksyczny Dym", "toxicsmoke": "Toksyczny Dym",
"toxicsmoke_desc": "Twoje granaty dymny zadają obrażenia", "toxicsmoke_desc": "Twoje granaty dymny zadają obrażenia",

View file

@ -199,6 +199,12 @@
"longzeus": "Zeus Longo", "longzeus": "Zeus Longo",
"longzeus_desc": "Zeus causa dano independentemente da distância", "longzeus_desc": "Zeus causa dano independentemente da distância",
"magnifier": "Lupa",
"magnifier_desc": "Força a tela do inimigo a ampliar, reduzindo seu campo de visão",
"magnifier_enemy_info": "Seu campo de visão foi distorcido!",
"magnifier_player_info": "O jogador ‘{0}’ foi forçado a entrar no modo de zoom.",
"magnifier_select_info": "Selecione o jogador cuja tela você deseja ampliar:",
"medic": "Médico", "medic": "Médico",
"medic_desc": "Clique em [css_useSkill] para usar uma carga de cura que restaura 50 de saúde", "medic_desc": "Clique em [css_useSkill] para usar uma carga de cura que restaura 50 de saúde",
@ -230,7 +236,8 @@
"onlyhead_desc": "Você só recebe dano na cabeça", "onlyhead_desc": "Você só recebe dano na cabeça",
"paweljumper": "Pawel Jumper", "paweljumper": "Pawel Jumper",
"paweljumper_desc": "Você ganha um pulo extra", "paweljumper_desc": "Você recebe um número aleatório de saltos extras",
"paweljumper_desc2": "Você ganha {0} saltos extras",
"phoenix": "Fênix", "phoenix": "Fênix",
"phoenix_desc": "Você tem uma chance aleatória de renascer após a morte", "phoenix_desc": "Você tem uma chance aleatória de renascer após a morte",
@ -353,6 +360,9 @@
"thirdeye": "Terceiro Olho", "thirdeye": "Terceiro Olho",
"thirdeye_desc": "Clique em [css_useSkill] para ativar a visão em terceira pessoa", "thirdeye_desc": "Clique em [css_useSkill] para ativar a visão em terceira pessoa",
"thorns": "Espinhos",
"thorns_desc": "Seu oponente receberá uma parte do dano que causou a você",
"toxicsmoke": "Fumaça Tóxica", "toxicsmoke": "Fumaça Tóxica",
"toxicsmoke_desc": "Suas granadas de fumaça causam dano", "toxicsmoke_desc": "Suas granadas de fumaça causam dano",

View file

@ -199,6 +199,12 @@
"longzeus": "长宙斯", "longzeus": "长宙斯",
"longzeus_desc": "宙斯电击枪无论距离多远都能造成伤害", "longzeus_desc": "宙斯电击枪无论距离多远都能造成伤害",
"magnifier": "放大镜",
"magnifier_desc": "强制敌方屏幕放大,缩小其视野范围",
"magnifier_enemy_info": "你的视野已被扭曲!",
"magnifier_player_info": "玩家'{0}'已被强制进入放大模式。",
"magnifier_select_info": "选择需要放大的玩家:",
"medic": "医务兵", "medic": "医务兵",
"medic_desc": "点击 [css_useSkill] 使用治疗装置恢复50点生命值", "medic_desc": "点击 [css_useSkill] 使用治疗装置恢复50点生命值",
@ -230,7 +236,8 @@
"onlyhead_desc": "你只会在头部受到伤害", "onlyhead_desc": "你只会在头部受到伤害",
"paweljumper": "帕维尔跳跃者", "paweljumper": "帕维尔跳跃者",
"paweljumper_desc": "你获得额外的跳跃", "paweljumper_desc": "你将获得随机数量的额外跳跃机会",
"paweljumper_desc2": "你获得 {0} 次额外跳跃",
"phoenix": "凤凰", "phoenix": "凤凰",
"phoenix_desc": "你有随机几率在死亡后复活", "phoenix_desc": "你有随机几率在死亡后复活",
@ -353,6 +360,9 @@
"thirdeye": "第三只眼", "thirdeye": "第三只眼",
"thirdeye_desc": "点击 [css_useSkill] 激活第三人称视角", "thirdeye_desc": "点击 [css_useSkill] 激活第三人称视角",
"thorns": "荊棘",
"thorns_desc": "你的對手將承受其對你造成傷害的一部分",
"toxicsmoke": "毒烟", "toxicsmoke": "毒烟",
"toxicsmoke_desc": "你的烟雾弹会造成伤害", "toxicsmoke_desc": "你的烟雾弹会造成伤害",

View file

@ -66,6 +66,7 @@ public enum Skills
LifeSwap, LifeSwap,
LongKnife, LongKnife,
LongZeus, LongZeus,
Magnifier,
Medic, Medic,
MoneySwap, MoneySwap,
Muhammed, Muhammed,
@ -111,6 +112,7 @@ public enum Skills
Teleporter, Teleporter,
Thief, Thief,
ThirdEye, ThirdEye,
Thorns,
ToxicSmoke, ToxicSmoke,
Wallhack, Wallhack,
Watchmaker, Watchmaker,

View file

@ -153,6 +153,8 @@ namespace jRandomSkills
skillPlayer.IsDrawing = false; skillPlayer.IsDrawing = false;
jSkill_SkillInfo randomSkill = new jSkill_SkillInfo(Skills.None, Config.GetValue<string>(Skills.None, "color"), false); jSkill_SkillInfo randomSkill = new jSkill_SkillInfo(Skills.None, Config.GetValue<string>(Skills.None, "color"), false);
if (Instance?.GameRules?.WarmupPeriod == false)
{
if (Config.config.Settings.GameMode == (int)Config.GameModes.Normal) if (Config.config.Settings.GameMode == (int)Config.GameModes.Normal)
{ {
List<jSkill_SkillInfo> skillList = new List<jSkill_SkillInfo>(SkillData.Skills); List<jSkill_SkillInfo> skillList = new List<jSkill_SkillInfo>(SkillData.Skills);
@ -183,6 +185,7 @@ namespace jRandomSkills
debugSkills.RemoveAt(0); debugSkills.RemoveAt(0);
player.PrintToChat($"{SkillData.Skills.Count - debugSkills.Count}/{SkillData.Skills.Count}"); player.PrintToChat($"{SkillData.Skills.Count - debugSkills.Count}/{SkillData.Skills.Count}");
} }
}
skillPlayer.Skill = randomSkill.Skill; skillPlayer.Skill = randomSkill.Skill;
skillPlayer.SpecialSkill = Skills.None; skillPlayer.SpecialSkill = Skills.None;

View file

@ -2,8 +2,8 @@ using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core; using CounterStrikeSharp.API.Core;
using jRandomSkills.src.player; using jRandomSkills.src.player;
using jRandomSkills.src.utils; using jRandomSkills.src.utils;
using System.Reflection.Metadata;
using static CounterStrikeSharp.API.Core.Listeners; using static CounterStrikeSharp.API.Core.Listeners;
using static jRandomSkills.Config;
using static jRandomSkills.jRandomSkills; using static jRandomSkills.jRandomSkills;
namespace jRandomSkills namespace jRandomSkills
@ -38,10 +38,10 @@ namespace jRandomSkills
private static void UpdateGameRules() private static void UpdateGameRules()
{ {
if (Instance.GameRules == null) if (Instance?.GameRules == null || Instance?.GameRules?.Handle == IntPtr.Zero)
InitializeGameRules(); InitializeGameRules();
else else
Instance.GameRules.GameRestart = Instance.GameRules.RestartRoundTime < Server.CurrentTime; Instance.GameRules.GameRestart = Instance?.GameRules?.RestartRoundTime < Server.CurrentTime;
} }
private static void UpdatePlayerHud(CCSPlayerController player) private static void UpdatePlayerHud(CCSPlayerController player)

View file

@ -161,8 +161,11 @@ namespace jRandomSkills
private static void SetWeaponAttack(CCSPlayerController player, bool disableWeapon) private static void SetWeaponAttack(CCSPlayerController player, bool disableWeapon)
{ {
if (roundEnd) return; if (roundEnd || player == null || !player.IsValid) return;
foreach (var weapon in player.Pawn.Value.WeaponServices?.MyWeapons) var pawn = player?.PlayerPawn?.Value;
if (pawn == null || !pawn.IsValid) return;
foreach (var weapon in pawn?.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 (disabledWeapons.Contains(weapon?.Value?.DesignerName)) if (disabledWeapons.Contains(weapon?.Value?.DesignerName))
{ {

View file

@ -73,7 +73,6 @@ namespace jRandomSkills
SteamID = player.SteamID, SteamID = player.SteamID,
CanUse = true, CanUse = true,
Cooldown = DateTime.MinValue, Cooldown = DateTime.MinValue,
LastClick = DateTime.MinValue,
}; };
} }
@ -134,8 +133,6 @@ namespace jRandomSkills
skillInfo.Cooldown = DateTime.Now; skillInfo.Cooldown = DateTime.Now;
playerPawn.Teleport(GetEnemySpawnVector(player)); playerPawn.Teleport(GetEnemySpawnVector(player));
} }
else
skillInfo.LastClick = DateTime.Now;
} }
} }
@ -156,7 +153,6 @@ namespace jRandomSkills
public ulong SteamID { get; set; } public ulong SteamID { get; set; }
public bool CanUse { get; set; } public bool CanUse { get; set; }
public DateTime Cooldown { get; set; } public DateTime Cooldown { get; set; }
public DateTime LastClick { get; set; }
} }
public class SkillConfig : Config.DefaultSkillInfo public class SkillConfig : Config.DefaultSkillInfo

View file

@ -13,13 +13,16 @@ namespace jRandomSkills
public class Fortnite : ISkill public class Fortnite : ISkill
{ {
private const Skills skillName = Skills.Fortnite; private const Skills skillName = Skills.Fortnite;
private static float timerCooldown = Config.GetValue<float>(skillName, "Cooldown"); private static float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
private const string propModel = "models/props/de_aztec/hr_aztec/aztec_scaffolding/aztec_scaffold_wall_support_128.vmdl"; private static int barricadeHealth = Config.GetValue<int>(skillName, "barricadeHealth");
private static string propModel = Config.GetValue<string>(skillName, "propModel");
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = new Dictionary<ulong, PlayerSkillInfo>(); private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = new Dictionary<ulong, PlayerSkillInfo>();
private static Dictionary<ulong, int> barricades = new Dictionary<ulong, int>();
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.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) => Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{ {
@ -40,6 +43,7 @@ namespace jRandomSkills
Instance.RegisterEventHandler<EventRoundEnd>((@event, info) => Instance.RegisterEventHandler<EventRoundEnd>((@event, info) =>
{ {
SkillPlayerInfo.Clear(); SkillPlayerInfo.Clear();
barricades.Clear();
return HookResult.Continue; return HookResult.Continue;
}); });
@ -80,7 +84,6 @@ namespace jRandomSkills
SteamID = player.SteamID, SteamID = player.SteamID,
CanUse = true, CanUse = true,
Cooldown = DateTime.MinValue, Cooldown = DateTime.MinValue,
LastClick = DateTime.MinValue,
}; };
} }
@ -127,8 +130,6 @@ namespace jRandomSkills
skillInfo.Cooldown = DateTime.Now; skillInfo.Cooldown = DateTime.Now;
CreateBox(player); CreateBox(player);
} }
else
skillInfo.LastClick = DateTime.Now;
} }
} }
@ -146,6 +147,7 @@ namespace jRandomSkills
box.Collision.SolidType = SolidType_t.SOLID_VPHYSICS; box.Collision.SolidType = SolidType_t.SOLID_VPHYSICS;
box.CBodyComponent!.SceneNode!.Owner!.Entity!.Flags = (uint)(box.CBodyComponent!.SceneNode!.Owner!.Entity!.Flags & ~(1 << 2)); box.CBodyComponent!.SceneNode!.Owner!.Entity!.Flags = (uint)(box.CBodyComponent!.SceneNode!.Owner!.Entity!.Flags & ~(1 << 2));
box.DispatchSpawn(); box.DispatchSpawn();
barricades.Add(box.Index, barricadeHealth);
Server.NextFrame(() => Server.NextFrame(() =>
{ {
box.SetModel(propModel); box.SetModel(propModel);
@ -167,7 +169,14 @@ namespace jRandomSkills
var box = param.As<CDynamicProp>(); var box = param.As<CDynamicProp>();
if (box == null || !box.IsValid) return HookResult.Continue; if (box == null || !box.IsValid) return HookResult.Continue;
box.EmitSound("Wood_Plank.BulletImpact", volume: 1f); box.EmitSound("Wood_Plank.BulletImpact", volume: 1f);
box.Remove();
if (barricades.TryGetValue(box.Index, out int health))
{
health -= (int)param2.Damage;
barricades[box.Index] = health;
if (health <= 0) box.Remove();
}
else box.Remove();
return HookResult.Continue; return HookResult.Continue;
} }
@ -176,15 +185,18 @@ namespace jRandomSkills
public ulong SteamID { get; set; } public ulong SteamID { get; set; }
public bool CanUse { get; set; } public bool CanUse { get; set; }
public DateTime Cooldown { get; set; } public DateTime Cooldown { get; set; }
public DateTime LastClick { get; set; }
} }
public class SkillConfig : Config.DefaultSkillInfo public class SkillConfig : Config.DefaultSkillInfo
{ {
public float Cooldown { get; set; } public float Cooldown { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#1b04cc", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 2f) : base(skill, active, color, onlyTeam, needsTeammates) 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; Cooldown = cooldown;
BarricadeHealth = barricadeHealth;
PropModel = propModel;
} }
} }
} }

View file

@ -182,8 +182,11 @@ namespace jRandomSkills
private static void SetWeaponAttack(CCSPlayerController player, bool disableWeapon) private static void SetWeaponAttack(CCSPlayerController player, bool disableWeapon)
{ {
if (roundEnd) return; if (roundEnd || player == null || !player.IsValid) return;
foreach (var weapon in player.Pawn.Value.WeaponServices?.MyWeapons) var pawn = player?.PlayerPawn?.Value;
if (pawn == null || !pawn.IsValid) return;
foreach (var weapon in pawn?.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 (disabledWeapons.Contains(weapon?.Value?.DesignerName)) if (disabledWeapons.Contains(weapon?.Value?.DesignerName))
{ {

View file

@ -31,9 +31,6 @@ namespace jRandomSkills
if (playerInfo?.Skill == skillName) if (playerInfo?.Skill == skillName)
EnableSkill(player); EnableSkill(player);
} }
if (exists)
Instance.RegisterListener<Listeners.CheckTransmit>(CheckTransmit);
}); });
return HookResult.Continue; return HookResult.Continue;
}); });
@ -41,7 +38,6 @@ namespace jRandomSkills
Instance.RegisterEventHandler<EventRoundEnd>((@event, @info) => Instance.RegisterEventHandler<EventRoundEnd>((@event, @info) =>
{ {
smokes.Clear(); smokes.Clear();
if (exists)
Instance.RemoveListener<Listeners.CheckTransmit>(CheckTransmit); Instance.RemoveListener<Listeners.CheckTransmit>(CheckTransmit);
exists = false; exists = false;
return HookResult.Continue; return HookResult.Continue;
@ -66,8 +62,11 @@ namespace jRandomSkills
{ {
if (player == null) continue; if (player == 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;
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);
if (playerInfo?.Skill != skillName && observerInfo?.Skill != skillName) continue;
foreach (var smoke in smokes) foreach (var smoke in smokes)
info.TransmitEntities.Remove(smoke); info.TransmitEntities.Remove(smoke);
} }
@ -75,6 +74,8 @@ namespace jRandomSkills
public static void EnableSkill(CCSPlayerController player) public static void EnableSkill(CCSPlayerController player)
{ {
if (!exists)
Instance.RegisterListener<Listeners.CheckTransmit>(CheckTransmit);
exists = true; exists = true;
SkillUtils.TryGiveWeapon(player, CsItem.SmokeGrenade); SkillUtils.TryGiveWeapon(player, CsItem.SmokeGrenade);
} }

View file

@ -73,7 +73,6 @@ namespace jRandomSkills
SteamID = player.SteamID, SteamID = player.SteamID,
CanUse = true, CanUse = true,
Cooldown = DateTime.MinValue, Cooldown = DateTime.MinValue,
LastClick = DateTime.MinValue,
}; };
} }
@ -130,8 +129,6 @@ namespace jRandomSkills
} }
}); });
} }
else
skillInfo.LastClick = DateTime.Now;
} }
} }
@ -140,7 +137,6 @@ namespace jRandomSkills
public ulong SteamID { get; set; } public ulong SteamID { get; set; }
public bool CanUse { get; set; } public bool CanUse { get; set; }
public DateTime Cooldown { get; set; } public DateTime Cooldown { get; set; }
public DateTime LastClick { get; set; }
} }
public class SkillConfig : Config.DefaultSkillInfo public class SkillConfig : Config.DefaultSkillInfo

View file

@ -33,9 +33,6 @@ namespace jRandomSkills
if (playerInfo?.Skill != skillName) continue; if (playerInfo?.Skill != skillName) continue;
EnableSkill(player); EnableSkill(player);
} }
if (exists)
Instance.RegisterListener<Listeners.CheckTransmit>(CheckTransmit);
}); });
return HookResult.Continue; return HookResult.Continue;
@ -52,7 +49,6 @@ namespace jRandomSkills
authorBeams.Clear(); authorBeams.Clear();
stepBeams.Clear(); stepBeams.Clear();
if (exists)
Instance.RemoveListener<Listeners.CheckTransmit>(CheckTransmit); Instance.RemoveListener<Listeners.CheckTransmit>(CheckTransmit);
exists = false; exists = false;
return HookResult.Continue; return HookResult.Continue;
@ -63,14 +59,21 @@ namespace jRandomSkills
private static void OnTick() private static void OnTick()
{ {
foreach (var step in stepBeams) if (Server.TickCount % 8 != 0) return;
foreach (var step in stepBeams.ToList())
{ {
if (Server.TickCount % 8 != 0) continue; var player = step.Key;
if (player == null || !player.IsValid)
{
stepBeams.Remove(player);
continue;
}
var pawn = player.PlayerPawn.Value;
if (pawn == null || !pawn.IsValid || pawn.LifeState != (byte)LifeState_t.LIFE_ALIVE) continue;
var pawn = step.Key.PlayerPawn.Value;
var beams = step.Value; var beams = step.Value;
if (pawn.LifeState != (byte)LifeState_t.LIFE_ALIVE) continue; Vector lastBeamVector = beams?.LastOrDefault()?.EndPos ?? pawn?.AbsOrigin;
Vector lastBeamVector = 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)
@ -93,8 +96,14 @@ namespace jRandomSkills
{ {
var enemy = step.Key; var enemy = step.Key;
var beams = step.Value; var beams = step.Value;
var observedPlayer = Utilities.GetPlayers().FirstOrDefault(p => p?.Pawn?.Value?.Handle == player?.Pawn?.Value?.ObserverServices?.ObserverTarget?.Value?.Handle);
bool playerHasBeam = authorBeams.TryGetValue(player.Index, out uint pIndex) && pIndex == enemy.Index;
bool observerHasBeam = observedPlayer != null && authorBeams.TryGetValue(observedPlayer.Index, out uint oIndex) && oIndex == enemy.Index;
foreach (var beam in beams) foreach (var beam in beams)
if (!authorBeams.TryGetValue(player.Index, out uint enemyIndex) || enemyIndex != enemy.Index) if (!playerHasBeam && !observerHasBeam)
info.TransmitEntities.Remove(beam); info.TransmitEntities.Remove(beam);
} }
} }
@ -148,6 +157,8 @@ namespace jRandomSkills
public static void EnableSkill(CCSPlayerController player) public static void EnableSkill(CCSPlayerController player)
{ {
if (!exists)
Instance.RegisterListener<Listeners.CheckTransmit>(CheckTransmit);
exists = true; exists = true;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID); var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
playerInfo.SkillChance = 0; playerInfo.SkillChance = 0;

View file

@ -0,0 +1,114 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using static jRandomSkills.jRandomSkills;
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>();
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"), false);
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
Instance.AddTimer(0.1f, () =>
{
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) continue;
EnableSkill(player);
}
});
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventRoundEnd>((@event, info) =>
{
foreach (var player in playersFOV.Keys)
DisableSkill(player);
return HookResult.Continue;
});
}
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);
if (playerInfo?.Skill != skillName) return;
if (playerInfo.SkillChance == 1)
{
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("areareaper_used_info")}");
return;
}
string enemyId = commands[0];
var enemy = Utilities.GetPlayers().FirstOrDefault(p => p.Team != player.Team && p.Index.ToString() == enemyId);
if (enemy == null)
{
player.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("selectplayerskill_incorrect_enemy_index"));
return;
}
if (!playersFOV.ContainsKey(enemy))
playersFOV.Add(enemy, enemy.DesiredFOV);
Server.PrintToChatAll($"FOV: {enemy.DesiredFOV}");
enemy.DesiredFOV = customFOV;
Utilities.SetStateChanged(enemy, "CBasePlayerController", "m_iDesiredFOV");
playerInfo.SkillChance = 1;
player.PrintToChat($" {ChatColors.Green}" + Localization.GetTranslation("magnifier_player_info", enemy.PlayerName));
enemy.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("magnifier_enemy_info"));
}
public static void EnableSkill(CCSPlayerController player)
{
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
playerInfo.SkillChance = 0;
SkillUtils.PrintToChat(player, Localization.GetTranslation("magnifier") + ":", false);
player.PrintToChat($" {ChatColors.Green}{Localization.GetTranslation("magnifier_select_info")}");
var enemies = Utilities.GetPlayers().Where(p => p.Team != player.Team && p.IsValid && !p.IsBot).ToArray();
if (enemies.Length > 0)
{
foreach (var enemy in enemies)
player.PrintToChat($" {ChatColors.Green}⠀⠀⠀[{ChatColors.Red}{enemy.Index}{ChatColors.Green}] {enemy.PlayerName}");
}
else
player.PrintToChat($" {ChatColors.Red}⠀⠀⠀{Localization.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
player.PrintToChat($" {ChatColors.Green}{Localization.GetTranslation("selectplayerskill_command")} {ChatColors.Red}index");
}
public static void DisableSkill(CCSPlayerController player)
{
if (playersFOV.TryGetValue(player, out uint fov))
{
player.DesiredFOV = fov;
Utilities.SetStateChanged(player, "CBasePlayerController", "m_iDesiredFOV");
}
playersFOV.Remove(player);
}
public class SkillConfig : Config.DefaultSkillInfo
{
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;
}
}
}
}

View file

@ -73,7 +73,6 @@ namespace jRandomSkills
SteamID = player.SteamID, SteamID = player.SteamID,
CanUse = true, CanUse = true,
Cooldown = DateTime.MinValue, Cooldown = DateTime.MinValue,
LastClick = DateTime.MinValue,
}; };
} }
@ -131,8 +130,6 @@ namespace jRandomSkills
playerPawn.ActualMoveType = MoveType_t.MOVETYPE_NOCLIP; playerPawn.ActualMoveType = MoveType_t.MOVETYPE_NOCLIP;
Instance.AddTimer(duration, () => playerPawn.ActualMoveType = MoveType_t.MOVETYPE_WALK); Instance.AddTimer(duration, () => playerPawn.ActualMoveType = MoveType_t.MOVETYPE_WALK);
} }
else
skillInfo.LastClick = DateTime.Now;
} }
} }
@ -141,7 +138,6 @@ namespace jRandomSkills
public ulong SteamID { get; set; } public ulong SteamID { get; set; }
public bool CanUse { get; set; } public bool CanUse { get; set; }
public DateTime Cooldown { get; set; } public DateTime Cooldown { get; set; }
public DateTime LastClick { get; set; }
} }
public class SkillConfig : Config.DefaultSkillInfo public class SkillConfig : Config.DefaultSkillInfo

View file

@ -2,6 +2,7 @@ using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core; using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils; using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player; using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using static CounterStrikeSharp.API.Core.Listeners; using static CounterStrikeSharp.API.Core.Listeners;
using static jRandomSkills.jRandomSkills; using static jRandomSkills.jRandomSkills;
@ -10,6 +11,9 @@ namespace jRandomSkills
public class PawelJumper : ISkill public class PawelJumper : ISkill
{ {
private const Skills skillName = Skills.PawelJumper; 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 PlayerFlags[] LF = new PlayerFlags[64]; private static readonly PlayerFlags[] LF = new PlayerFlags[64];
private static readonly int?[] J = new int?[64]; private static readonly int?[] J = new int?[64];
private static readonly PlayerButtons[] LB = new PlayerButtons[64]; private static readonly PlayerButtons[] LB = new PlayerButtons[64];
@ -32,12 +36,29 @@ 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 skillConfig = Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString());
if (skillConfig == null) return;
float extraJumps = (float)Instance.Random.Next(extraJumpsMin, extraJumpsMax + 1);
playerInfo.SkillChance = extraJumps;
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{Localization.GetTranslation("paweljumper")}{ChatColors.Lime}: " + Localization.GetTranslation("paweljumper_desc2", extraJumps), false);
}
private static void GiveAdditionalJump(CCSPlayerController player) private static void GiveAdditionalJump(CCSPlayerController player)
{ {
var playerPawn = player.PlayerPawn.Value; var playerPawn = player.PlayerPawn.Value;
var flags = (PlayerFlags)playerPawn.Flags; var flags = (PlayerFlags)playerPawn.Flags;
var buttons = player.Buttons; var buttons = player.Buttons;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerPawn == 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) if ((LF[player.Slot] & PlayerFlags.FL_ONGROUND) != 0 && (flags & PlayerFlags.FL_ONGROUND) == 0 && (LB[player.Slot] & PlayerButtons.Jump) == 0 && (buttons & PlayerButtons.Jump) != 0)
{ {
//J[player.Slot] ++; //J[player.Slot] ++;
@ -46,7 +67,7 @@ namespace jRandomSkills
{ {
J[player.Slot] = 0; J[player.Slot] = 0;
} }
else if ((LB[player.Slot] & PlayerButtons.Jump) == 0 && (buttons & PlayerButtons.Jump) != 0 && J[player.Slot] < 1) else if ((LB[player.Slot] & PlayerButtons.Jump) == 0 && (buttons & PlayerButtons.Jump) != 0 && J[player.Slot] < playerInfo.SkillChance)
{ {
J[player.Slot]++; J[player.Slot]++;
playerPawn.AbsVelocity.Z = 300; playerPawn.AbsVelocity.Z = 300;
@ -58,8 +79,12 @@ namespace jRandomSkills
public class SkillConfig : Config.DefaultSkillInfo public class SkillConfig : Config.DefaultSkillInfo
{ {
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#FFA500", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(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;
} }
} }
} }

View file

@ -81,7 +81,6 @@ namespace jRandomSkills
SteamID = player.SteamID, SteamID = player.SteamID,
CanUse = true, CanUse = true,
Cooldown = DateTime.MinValue, Cooldown = DateTime.MinValue,
LastClick = DateTime.MinValue,
}; };
} }
@ -128,8 +127,6 @@ namespace jRandomSkills
skillInfo.Cooldown = DateTime.Now; skillInfo.Cooldown = DateTime.Now;
RemoveAndGiveWeapon(player); RemoveAndGiveWeapon(player);
} }
else
skillInfo.LastClick = DateTime.Now;
} }
} }
@ -175,7 +172,6 @@ namespace jRandomSkills
public ulong SteamID { get; set; } public ulong SteamID { get; set; }
public bool CanUse { get; set; } public bool CanUse { get; set; }
public DateTime Cooldown { get; set; } public DateTime Cooldown { get; set; }
public DateTime LastClick { get; set; }
} }
public class SkillConfig : Config.DefaultSkillInfo public class SkillConfig : Config.DefaultSkillInfo

View file

@ -89,7 +89,6 @@ namespace jRandomSkills
SteamID = player.SteamID, SteamID = player.SteamID,
CanUse = true, CanUse = true,
Cooldown = DateTime.MinValue, Cooldown = DateTime.MinValue,
LastClick = DateTime.MinValue,
}; };
} }
@ -139,7 +138,6 @@ namespace jRandomSkills
public ulong SteamID { get; set; } public ulong SteamID { get; set; }
public bool CanUse { get; set; } public bool CanUse { get; set; }
public DateTime Cooldown { get; set; } public DateTime Cooldown { get; set; }
public DateTime LastClick { get; set; }
} }
public class SkillConfig : Config.DefaultSkillInfo public class SkillConfig : Config.DefaultSkillInfo

View file

@ -74,7 +74,6 @@ namespace jRandomSkills
SteamID = player.SteamID, SteamID = player.SteamID,
CanUse = true, CanUse = true,
Cooldown = DateTime.MinValue, Cooldown = DateTime.MinValue,
LastClick = DateTime.MinValue,
}; };
} }
@ -121,8 +120,6 @@ namespace jRandomSkills
skillInfo.Cooldown = DateTime.Now; skillInfo.Cooldown = DateTime.Now;
CreateReplica(player); CreateReplica(player);
} }
else
skillInfo.LastClick = DateTime.Now;
} }
} }
@ -177,7 +174,6 @@ namespace jRandomSkills
public ulong SteamID { get; set; } public ulong SteamID { get; set; }
public bool CanUse { get; set; } public bool CanUse { get; set; }
public DateTime Cooldown { get; set; } public DateTime Cooldown { get; set; }
public DateTime LastClick { get; set; }
} }
public class SkillConfig : Config.DefaultSkillInfo public class SkillConfig : Config.DefaultSkillInfo

View file

@ -72,7 +72,6 @@ namespace jRandomSkills
SteamID = player.SteamID, SteamID = player.SteamID,
CanUse = true, CanUse = true,
Cooldown = DateTime.MinValue, Cooldown = DateTime.MinValue,
LastClick = DateTime.MinValue,
}; };
} }
@ -119,8 +118,6 @@ namespace jRandomSkills
skillInfo.Cooldown = DateTime.Now; skillInfo.Cooldown = DateTime.Now;
playerPawn.Teleport(GetSpawnVector(player)); playerPawn.Teleport(GetSpawnVector(player));
} }
else
skillInfo.LastClick = DateTime.Now;
} }
} }
@ -141,7 +138,6 @@ namespace jRandomSkills
public ulong SteamID { get; set; } public ulong SteamID { get; set; }
public bool CanUse { get; set; } public bool CanUse { get; set; }
public DateTime Cooldown { get; set; } public DateTime Cooldown { get; set; }
public DateTime LastClick { get; set; }
} }
public class SkillConfig : Config.DefaultSkillInfo public class SkillConfig : Config.DefaultSkillInfo

View file

@ -26,8 +26,13 @@ namespace jRandomSkills
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim) || attacker == victim) return HookResult.Continue; 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;
if (victimPawn == null || !victimPawn.IsValid) return HookResult.Continue;
if (attackerInfo?.Skill == skillName) if (attackerInfo?.Skill == skillName)
playersToSlow.Add(victim.PlayerPawn.Value, Server.TickCount + (64 * rubberTime)); if (playersToSlow.ContainsKey(victimPawn))
playersToSlow[victimPawn] = Server.TickCount + (64 * rubberTime);
else playersToSlow.TryAdd(victimPawn, Server.TickCount + (64 * rubberTime));
return HookResult.Continue; return HookResult.Continue;
}); });

View file

@ -70,7 +70,6 @@ namespace jRandomSkills
SteamID = player.SteamID, SteamID = player.SteamID,
CanUse = true, CanUse = true,
Cooldown = DateTime.MinValue, Cooldown = DateTime.MinValue,
LastClick = DateTime.MinValue,
}; };
} }
@ -117,8 +116,6 @@ namespace jRandomSkills
skillInfo.Cooldown = DateTime.Now; skillInfo.Cooldown = DateTime.Now;
MakeSound(player); MakeSound(player);
} }
else
skillInfo.LastClick = DateTime.Now;
} }
} }
@ -134,7 +131,6 @@ namespace jRandomSkills
public ulong SteamID { get; set; } public ulong SteamID { get; set; }
public bool CanUse { get; set; } public bool CanUse { get; set; }
public DateTime Cooldown { get; set; } public DateTime Cooldown { get; set; }
public DateTime LastClick { get; set; }
} }
public class SkillConfig : Config.DefaultSkillInfo public class SkillConfig : Config.DefaultSkillInfo

View file

@ -0,0 +1,42 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class Thorns : ISkill
{
private const Skills skillName = Skills.Thorns;
private static float healthTakenScale = Config.GetValue<float>(skillName, "healthTakenScale");
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventPlayerHurt>((@event, info) =>
{
var attacker = @event.Attacker;
var victim = @event.Userid;
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim) || attacker == victim) return HookResult.Continue;
var victimInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == victim.SteamID);
if (victimInfo?.Skill == skillName && victim.PawnIsAlive && attacker.PawnIsAlive)
{
SkillUtils.TakeHealth(attacker.PlayerPawn.Value, (int)(@event.DmgHealth * healthTakenScale));
attacker.EmitSound("Player.DamageBody.Onlooker");
}
return HookResult.Continue;
});
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float HealthTakenScale { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#962631", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float healthTakenScale = .3f) : base(skill, active, color, onlyTeam, needsTeammates)
{
HealthTakenScale = healthTakenScale;
}
}
}
}

View file

@ -31,9 +31,6 @@ namespace jRandomSkills
if (playerInfo?.Skill == skillName) if (playerInfo?.Skill == skillName)
EnableSkill(player); EnableSkill(player);
} }
if (exists)
Instance.RegisterListener<Listeners.CheckTransmit>(CheckTransmit);
}); });
return HookResult.Continue; return HookResult.Continue;
}); });
@ -47,7 +44,6 @@ namespace jRandomSkills
} }
glows.Clear(); glows.Clear();
if (exists)
Instance.RemoveListener<Listeners.CheckTransmit>(CheckTransmit); Instance.RemoveListener<Listeners.CheckTransmit>(CheckTransmit);
exists = false; exists = false;
return HookResult.Continue; return HookResult.Continue;
@ -60,7 +56,12 @@ namespace jRandomSkills
{ {
if (player == null) continue; if (player == 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;
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);
if (playerInfo?.Skill == skillName || (observerInfo != null && observerInfo?.Skill == skillName))
continue;
foreach (var glow in glows) foreach (var glow in glows)
{ {
@ -72,6 +73,8 @@ namespace jRandomSkills
public static void EnableSkill(CCSPlayerController player) public static void EnableSkill(CCSPlayerController player)
{ {
if (!exists)
Instance.RegisterListener<Listeners.CheckTransmit>(CheckTransmit);
exists = true; exists = true;
SetGlowEffectForEnemies(player); SetGlowEffectForEnemies(player);
} }
@ -106,7 +109,7 @@ namespace jRandomSkills
modelGlow.Glow.GlowColorOverride = enemy.Team == CsTeam.Terrorist ? Color.FromArgb(255, 255, 165, 0) : Color.FromArgb(255, 173, 216, 230); modelGlow.Glow.GlowColorOverride = enemy.Team == CsTeam.Terrorist ? Color.FromArgb(255, 255, 165, 0) : Color.FromArgb(255, 173, 216, 230);
modelGlow.Glow.GlowRange = 5000; modelGlow.Glow.GlowRange = 5000;
modelGlow.Glow.GlowTeam = (int)player.Team; modelGlow.Glow.GlowTeam = -1;
modelGlow.Glow.GlowType = 3; modelGlow.Glow.GlowType = 3;
modelGlow.Glow.GlowRangeMin = 100; modelGlow.Glow.GlowRangeMin = 100;

View file

@ -69,7 +69,7 @@ namespace jRandomSkills
private static void UpdateHUD(CCSPlayerController player) private static void UpdateHUD(CCSPlayerController player)
{ {
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == skillName); var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == skillName);
if (skillData == null) return; if (skillData == null || Instance?.GameRules == null || Instance?.GameRules?.RoundTime == null || Instance.GameRules?.RoundStartTime == null) return;
int seconds = 1 + (int)(Instance.GameRules.RoundTime - (Server.CurrentTime - Instance.GameRules.RoundStartTime)); int seconds = 1 + (int)(Instance.GameRules.RoundTime - (Server.CurrentTime - Instance.GameRules.RoundStartTime));

View file

@ -266,6 +266,8 @@
}, },
{ {
"Cooldown": 2.0, "Cooldown": 2.0,
"BarricadeHealth": 115,
"PropModel": "models/props/de_aztec/hr_aztec/aztec_scaffolding/aztec_scaffold_wall_support_128.vmdl",
"NeedsTeammates": false, "NeedsTeammates": false,
"OnlyTeam": 0, "OnlyTeam": 0,
"Color": "#1b04cc", "Color": "#1b04cc",
@ -435,6 +437,14 @@
"Active": true, "Active": true,
"Name": "LongZeus" "Name": "LongZeus"
}, },
{
"CustomFOV": 50,
"NeedsTeammates": false,
"OnlyTeam": 0,
"Color": "#9ba882",
"Active": true,
"Name": "Magnifier"
},
{ {
"HealthToAdd": 50, "HealthToAdd": 50,
"HealthShotLimit": 3, "HealthShotLimit": 3,
@ -516,6 +526,8 @@
"Name": "OnlyHead" "Name": "OnlyHead"
}, },
{ {
"ExtraJumpsMin": 1,
"ExtraJumpsMax": 4,
"NeedsTeammates": false, "NeedsTeammates": false,
"OnlyTeam": 0, "OnlyTeam": 0,
"Color": "#FFA500", "Color": "#FFA500",
@ -803,6 +815,14 @@
"Active": true, "Active": true,
"Name": "ThirdEye" "Name": "ThirdEye"
}, },
{
"HealthTakenScale": 0.3,
"NeedsTeammates": false,
"OnlyTeam": 0,
"Color": "#962631",
"Active": true,
"Name": "Thorns"
},
{ {
"SmokeDamage": 2, "SmokeDamage": 2,
"SmokeRadius": 180.0, "SmokeRadius": 180.0,

View file

@ -199,6 +199,12 @@
"longzeus": "Long Zeus", "longzeus": "Long Zeus",
"longzeus_desc": "Zeus deals damage regardless of distance", "longzeus_desc": "Zeus deals damage regardless of distance",
"magnifier": "Magnifier",
"magnifier_desc": "Forces the enemy's screen to zoom in, reducing their field of view",
"magnifier_enemy_info": "Your field of view has been distorted!",
"magnifier_player_info": "Player '{0}' has been forced into zoom mode.",
"magnifier_select_info": "Select the player whose screen you want to magnify:",
"medic": "Medic", "medic": "Medic",
"medic_desc": "Click [css_useSkill] to use a healing charge that restores 50 health", "medic_desc": "Click [css_useSkill] to use a healing charge that restores 50 health",
@ -230,7 +236,8 @@
"onlyhead_desc": "You only take damage to the head", "onlyhead_desc": "You only take damage to the head",
"paweljumper": "Pawel Jumper", "paweljumper": "Pawel Jumper",
"paweljumper_desc": "You get an extra jump", "paweljumper_desc": "You get a random number of extra jumps",
"paweljumper_desc2": "You get {0} extra jumps",
"phoenix": "Phoenix", "phoenix": "Phoenix",
"phoenix_desc": "You have a random chance to respawn after death", "phoenix_desc": "You have a random chance to respawn after death",
@ -353,6 +360,9 @@
"thirdeye": "Third Eye", "thirdeye": "Third Eye",
"thirdeye_desc": "Click [css_useSkill] to activate third-person view", "thirdeye_desc": "Click [css_useSkill] to activate third-person view",
"thorns": "Thorns",
"thorns_desc": "Your opponent will receive a portion of the damage that they inflicted on you",
"toxicsmoke": "Toxic Smoke", "toxicsmoke": "Toxic Smoke",
"toxicsmoke_desc": "Your smoke grenades deal damage", "toxicsmoke_desc": "Your smoke grenades deal damage",

View file

@ -199,6 +199,12 @@
"longzeus": "Długi Zeus", "longzeus": "Długi Zeus",
"longzeus_desc": "Zeus zadaje obrażenia niezależnie od odległości", "longzeus_desc": "Zeus zadaje obrażenia niezależnie od odległości",
"magnifier": "Lupa",
"magnifier_desc": "Przybiżasz ekran wybranemu przeciwnikowi",
"magnifier_enemy_info": "Twoje pole widzenia zostało zniekształcone!",
"magnifier_player_info": "Gracz '{0}' został zmuszony do przejścia w tryb powiększenia.",
"magnifier_select_info": "Wybierz gracza, którego ekran chcesz powiększyć:",
"medic": "Medyk", "medic": "Medyk",
"medic_desc": "Kliknij [css_useSkill], aby użyć ładunku leczniczego, który przywraca 50 punktów zdrowia", "medic_desc": "Kliknij [css_useSkill], aby użyć ładunku leczniczego, który przywraca 50 punktów zdrowia",
@ -230,7 +236,8 @@
"onlyhead_desc": "Otrzymujesz obrażenia tylko w głowę", "onlyhead_desc": "Otrzymujesz obrażenia tylko w głowę",
"paweljumper": "Pawel Jumper", "paweljumper": "Pawel Jumper",
"paweljumper_desc": "Otrzymujesz dodatkowy skok", "paweljumper_desc": "Otrzymujesz losową liczbę dodatkowych skoków",
"paweljumper_desc2": "Otrzymujesz {0} dodatkowych skoków",
"phoenix": "Feniks", "phoenix": "Feniks",
"phoenix_desc": "Masz losową szans na odrodzenie się po śmierci", "phoenix_desc": "Masz losową szans na odrodzenie się po śmierci",
@ -353,6 +360,9 @@
"thirdeye": "Trzecie Oko", "thirdeye": "Trzecie Oko",
"thirdeye_desc": "Kliknij [css_useSkill], aby aktywować trzecią osobę", "thirdeye_desc": "Kliknij [css_useSkill], aby aktywować trzecią osobę",
"thorns": "Ciernie",
"thorns_desc": "Twój przeciwnik otrzymuje część obrażeń, które zadał ci",
"toxicsmoke": "Toksyczny Dym", "toxicsmoke": "Toksyczny Dym",
"toxicsmoke_desc": "Twoje granaty dymny zadają obrażenia", "toxicsmoke_desc": "Twoje granaty dymny zadają obrażenia",

View file

@ -199,6 +199,12 @@
"longzeus": "Zeus Longo", "longzeus": "Zeus Longo",
"longzeus_desc": "Zeus causa dano independentemente da distância", "longzeus_desc": "Zeus causa dano independentemente da distância",
"magnifier": "Lupa",
"magnifier_desc": "Força a tela do inimigo a ampliar, reduzindo seu campo de visão",
"magnifier_enemy_info": "Seu campo de visão foi distorcido!",
"magnifier_player_info": "O jogador ‘{0}’ foi forçado a entrar no modo de zoom.",
"magnifier_select_info": "Selecione o jogador cuja tela você deseja ampliar:",
"medic": "Médico", "medic": "Médico",
"medic_desc": "Clique em [css_useSkill] para usar uma carga de cura que restaura 50 de saúde", "medic_desc": "Clique em [css_useSkill] para usar uma carga de cura que restaura 50 de saúde",
@ -230,7 +236,8 @@
"onlyhead_desc": "Você só recebe dano na cabeça", "onlyhead_desc": "Você só recebe dano na cabeça",
"paweljumper": "Pawel Jumper", "paweljumper": "Pawel Jumper",
"paweljumper_desc": "Você ganha um pulo extra", "paweljumper_desc": "Você recebe um número aleatório de saltos extras",
"paweljumper_desc2": "Você ganha {0} saltos extras",
"phoenix": "Fênix", "phoenix": "Fênix",
"phoenix_desc": "Você tem uma chance aleatória de renascer após a morte", "phoenix_desc": "Você tem uma chance aleatória de renascer após a morte",
@ -353,6 +360,9 @@
"thirdeye": "Terceiro Olho", "thirdeye": "Terceiro Olho",
"thirdeye_desc": "Clique em [css_useSkill] para ativar a visão em terceira pessoa", "thirdeye_desc": "Clique em [css_useSkill] para ativar a visão em terceira pessoa",
"thorns": "Espinhos",
"thorns_desc": "Seu oponente receberá uma parte do dano que causou a você",
"toxicsmoke": "Fumaça Tóxica", "toxicsmoke": "Fumaça Tóxica",
"toxicsmoke_desc": "Suas granadas de fumaça causam dano", "toxicsmoke_desc": "Suas granadas de fumaça causam dano",

View file

@ -199,6 +199,12 @@
"longzeus": "长宙斯", "longzeus": "长宙斯",
"longzeus_desc": "宙斯电击枪无论距离多远都能造成伤害", "longzeus_desc": "宙斯电击枪无论距离多远都能造成伤害",
"magnifier": "放大镜",
"magnifier_desc": "强制敌方屏幕放大,缩小其视野范围",
"magnifier_enemy_info": "你的视野已被扭曲!",
"magnifier_player_info": "玩家'{0}'已被强制进入放大模式。",
"magnifier_select_info": "选择需要放大的玩家:",
"medic": "医务兵", "medic": "医务兵",
"medic_desc": "点击 [css_useSkill] 使用治疗装置恢复50点生命值", "medic_desc": "点击 [css_useSkill] 使用治疗装置恢复50点生命值",
@ -230,7 +236,8 @@
"onlyhead_desc": "你只会在头部受到伤害", "onlyhead_desc": "你只会在头部受到伤害",
"paweljumper": "帕维尔跳跃者", "paweljumper": "帕维尔跳跃者",
"paweljumper_desc": "你获得额外的跳跃", "paweljumper_desc": "你将获得随机数量的额外跳跃机会",
"paweljumper_desc2": "你获得 {0} 次额外跳跃",
"phoenix": "凤凰", "phoenix": "凤凰",
"phoenix_desc": "你有随机几率在死亡后复活", "phoenix_desc": "你有随机几率在死亡后复活",
@ -353,6 +360,9 @@
"thirdeye": "第三只眼", "thirdeye": "第三只眼",
"thirdeye_desc": "点击 [css_useSkill] 激活第三人称视角", "thirdeye_desc": "点击 [css_useSkill] 激活第三人称视角",
"thorns": "荊棘",
"thorns_desc": "你的對手將承受其對你造成傷害的一部分",
"toxicsmoke": "毒烟", "toxicsmoke": "毒烟",
"toxicsmoke_desc": "你的烟雾弹会造成伤害", "toxicsmoke_desc": "你的烟雾弹会造成伤害",