This commit is contained in:
Juzlus 2025-09-15 23:58:34 +02:00
parent 714624d96a
commit 2102f0581f
96 changed files with 1279 additions and 413 deletions

View file

@ -83,9 +83,9 @@ namespace jRandomSkills
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == skillName);
if (skillData == null) return;
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
string remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{Localization.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>" : "";
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{player.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{player.GetSkillName(skillData.Skill)}</font> <br>";
string remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{player.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>" : "";
var hudContent = infoLine + skillLine + remainingLine;
player.PrintToCenterHtml(hudContent);

View file

@ -32,13 +32,13 @@ namespace jRandomSkills
if (playerInfo.SkillChance == 1)
{
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("areareaper_used_info")}");
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("areareaper_used_info")}");
return;
}
int site = bombsiteA.Contains(commands[0]) ? 0 : bombsiteB.Contains(commands[0]) ? 1 : -1;
if (site == -1) {
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("areareaper_incorrect_site")}");
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("areareaper_incorrect_site")}");
return;
}
@ -47,10 +47,10 @@ namespace jRandomSkills
{
bombTargets[site].AcceptInput("Disable");
playerInfo.SkillChance = 1;
player.PrintToChat($" {ChatColors.Green}{Localization.GetTranslation("areareaper_site_disabled", (site == 0 ? 'A' : 'B'))}");
player.PrintToChat($" {ChatColors.Green}{player.GetTranslation("areareaper_site_disabled", (site == 0 ? 'A' : 'B'))}");
}
else
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("areareaper_no_site")}");
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("areareaper_no_site")}");
}
public static void EnableSkill(CCSPlayerController player)
@ -59,7 +59,7 @@ namespace jRandomSkills
if (playerInfo == null) return;
playerInfo.SkillChance = 0;
HashSet<(string, string)> menuItems = [(Localization.GetTranslation("bombsite_a"), "a"), (Localization.GetTranslation("bombsite_b"), "b")];
HashSet<(string, string)> menuItems = [(player.GetTranslation("bombsite_a"), "a"), (player.GetTranslation("bombsite_b"), "b")];
SkillUtils.CreateMenu(player, menuItems);
}

View file

@ -24,7 +24,7 @@ namespace jRandomSkills
float newScale = (float)Instance.Random.NextDouble() * (Config.GetValue<float>(skillName, "ChanceTo") - Config.GetValue<float>(skillName, "ChanceFrom")) + Config.GetValue<float>(skillName, "ChanceFrom");
playerInfo.SkillChance = newScale;
newScale = (float)Math.Round(newScale, 2);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{Localization.GetTranslation("armored")}{ChatColors.Lime}: " + Localization.GetTranslation("armored_desc2", newScale), false);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{player.GetTranslation("armored")}{ChatColors.Lime}: " + player.GetTranslation("armored_desc2", newScale), false);
}
public static void OnTakeDamage(DynamicHook h)

View file

@ -30,14 +30,22 @@ namespace jRandomSkills
public static void DisableSkill(CCSPlayerController player)
{
if (player == null || !player.IsValid || player.PlayerPawn.Value == null || !player.PlayerPawn.Value.IsValid) return;
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo == null) return;
player.PlayerPawn.Value.ActualGravityScale = 1;
playerInfo.SkillChance = 1;
}
private static void ApplyGravityModifier(CCSPlayerController player)
{
if (player == null || !player.IsValid || player.PlayerPawn.Value == null || !player.PlayerPawn.Value.IsValid) return;
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo == null) return;
float gravityModifier = (float)Math.Round(Instance.Random.NextDouble() * (Config.GetValue<float>(skillName, "ChanceTo") - Config.GetValue<float>(skillName, "chanceFrom")) + Config.GetValue<float>(skillName, "chanceFrom"), 1);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{Localization.GetTranslation("astronaut")}{ChatColors.Lime}: " + Localization.GetTranslation("astronaut_desc2", gravityModifier), false);
playerInfo.SkillChance = gravityModifier;
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{player.GetTranslation("astronaut")}{ChatColors.Lime}: " + player.GetTranslation("astronaut_desc2", gravityModifier), false);
player.PlayerPawn.Value.ActualGravityScale = gravityModifier;
}

View file

@ -46,7 +46,7 @@ namespace jRandomSkills
if (playerInfo.SkillChance == 1)
{
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("areareaper_used_info")}");
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("areareaper_used_info")}");
return;
}
@ -55,14 +55,14 @@ namespace jRandomSkills
if (enemy == null)
{
player.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("selectplayerskill_incorrect_enemy_index"));
player.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("selectplayerskill_incorrect_enemy_index"));
return;
}
ResetMoney(enemy);
playerInfo.SkillChance = 1;
player.PrintToChat($" {ChatColors.Green}" + Localization.GetTranslation("bankrupt_player_info", enemy.PlayerName));
enemy.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("bankrupt_enemy_info"));
player.PrintToChat($" {ChatColors.Green}" + player.GetTranslation("bankrupt_player_info", enemy.PlayerName));
enemy.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("bankrupt_enemy_info"));
}
public static void EnableSkill(CCSPlayerController player)
@ -78,7 +78,7 @@ namespace jRandomSkills
SkillUtils.CreateMenu(player, menuItems);
}
else
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
}
private static void ResetMoney(CCSPlayerController enemy)

View file

@ -36,7 +36,7 @@ namespace jRandomSkills
playerInfo.SkillChance = newChance;
newChance = (float)Math.Round(newChance, 2) * 100;
newChance = (float)Math.Round(newChance);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{Localization.GetTranslation("behind")}{ChatColors.Lime}: " + Localization.GetTranslation("behind_desc2", newChance), false);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{player.GetTranslation("behind")}{ChatColors.Lime}: " + player.GetTranslation("behind_desc2", newChance), false);
}
private static void RotateEnemy(CCSPlayerController player)

View file

@ -62,7 +62,7 @@ namespace jRandomSkills
public static void EnableSkill(CCSPlayerController player)
{
Event.enableTransmit = true;
SkillUtils.EnableTransmit();
if (player == null || !player.IsValid) return;
var playerPawn = player.PlayerPawn.Value;

View file

@ -40,7 +40,7 @@ namespace jRandomSkills
playerInfo.SkillChance = newChance;
newChance = (float)Math.Round(newChance, 2) * 100;
newChance = (float)Math.Round(newChance);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{Localization.GetTranslation("catapult")}{ChatColors.Lime}: " + Localization.GetTranslation("catapult_desc2", newChance), false);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{player.GetTranslation("catapult")}{ChatColors.Lime}: " + player.GetTranslation("catapult_desc2", newChance), false);
}
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#FF4500", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float chanceFrom = .2f, float chanceTo = .4f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)

View file

@ -60,7 +60,7 @@ namespace jRandomSkills
var playerPawn = player.PlayerPawn?.Value;
if (playerPawn != null && playerPawn.IsValid)
{
Event.enableTransmit = true;
SkillUtils.EnableTransmit();
playerPawn.VelocityModifier = 1.1f;
playerPawn.Health = 50;
@ -176,9 +176,9 @@ namespace jRandomSkills
var weapon = pawn.WeaponServices.ActiveWeapon.Value;
if (weapon == null || !disabledWeapons.Contains(weapon.DesignerName)) return;
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
string remainingLine = $"<font class='fontSize-m' color='#FF0000'>{Localization.GetTranslation("disabled_weapon")}</font> <br>";
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{player.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{player.GetSkillName(skillData.Skill)}</font> <br>";
string remainingLine = $"<font class='fontSize-m' color='#FF0000'>{player.GetTranslation("disabled_weapon")}</font> <br>";
var hudContent = infoLine + skillLine + remainingLine;
player.PrintToCenterHtml(hudContent);

View file

@ -62,7 +62,7 @@ namespace jRandomSkills
if (playerInfo.SkillChance == 1)
{
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("areareaper_used_info")}");
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("areareaper_used_info")}");
return;
}
@ -71,14 +71,14 @@ namespace jRandomSkills
if (enemy == null)
{
player.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("selectplayerskill_incorrect_enemy_index"));
player.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("selectplayerskill_incorrect_enemy_index"));
return;
}
SetUpPostProcessing(enemy);
playerInfo.SkillChance = 1;
player.PrintToChat($" {ChatColors.Green}" + Localization.GetTranslation("darkness_player_info", enemy.PlayerName));
enemy.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("darkness_enemy_info"));
player.PrintToChat($" {ChatColors.Green}" + player.GetTranslation("darkness_player_info", enemy.PlayerName));
enemy.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("darkness_enemy_info"));
}
public static void EnableSkill(CCSPlayerController player)
@ -94,7 +94,7 @@ namespace jRandomSkills
SkillUtils.CreateMenu(player, menuItems);
}
else
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
}
public static void DisableSkill(CCSPlayerController player)

View file

@ -0,0 +1,75 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class Dash : ISkill
{
private const Skills skillName = Skills.Dash;
private static readonly PlayerFlags[] LF = new PlayerFlags[64];
private static readonly int?[] J = new int?[64];
private static readonly PlayerButtons[] LB = new PlayerButtons[64];
private static readonly float jumpVelocity = Config.GetValue<float>(skillName, "jumpVelocity");
private static readonly float pushVelocity = Config.GetValue<float>(skillName, "pushVelocity");
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
}
public static void OnTick()
{
foreach (var player in Utilities.GetPlayers())
{
if (!Instance.IsPlayerValid(player)) return;
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill == skillName)
GiveAdditionalJump(player);
}
}
private static void GiveAdditionalJump(CCSPlayerController player)
{
var playerPawn = player.PlayerPawn.Value;
if (playerPawn == null || !playerPawn.IsValid) return;
var flags = (PlayerFlags)playerPawn.Flags;
var buttons = player.Buttons;
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerPawn == null || playerInfo == null) return;
if ((LF[player.Slot] & PlayerFlags.FL_ONGROUND) != 0 && (flags & PlayerFlags.FL_ONGROUND) == 0 && (LB[player.Slot] & PlayerButtons.Jump) == 0 && (buttons & PlayerButtons.Jump) != 0)
{
}
else if ((flags & PlayerFlags.FL_ONGROUND) != 0)
{
J[player.Slot] = 0;
}
else if ((LB[player.Slot] & PlayerButtons.Jump) == 0 && (buttons & PlayerButtons.Jump) != 0 && J[player.Slot] < 1)
{
J[player.Slot]++;
Vector newVelocity = SkillUtils.GetForwardVector(playerPawn.EyeAngles) * pushVelocity;
newVelocity.Z = playerPawn.AbsVelocity.Z + jumpVelocity;
playerPawn.AbsVelocity.X = newVelocity.X;
playerPawn.AbsVelocity.Y = newVelocity.Y;
playerPawn.AbsVelocity.Z = newVelocity.Z;
}
LF[player.Slot] = flags;
LB[player.Slot] = buttons;
}
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#42bbfc", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float jumpVelocity = 150f, float pushVelocity = 600f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
{
public float JumpVelocity { get; set; } = jumpVelocity;
public float PushVelocity { get; set; } = pushVelocity;
}
}
}

View file

@ -32,19 +32,17 @@ namespace jRandomSkills
if (playerInfo == null || playerInfo.Skill != skillName) continue;
var enemies = Utilities.GetPlayers().Where(p => p.PawnIsAlive && p.Team != player.Team && p.IsValid && !p.IsBot && !p.IsHLTV && p.Team != CsTeam.Spectator && p.Team != CsTeam.None).ToArray();
if (enemies.Length > 0)
HashSet<(string, string)> menuItems = [];
foreach (var enemy in enemies)
{
HashSet<(string, string)> menuItems = [];
foreach (var enemy in enemies)
{
var enemyInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == enemy.SteamID);
if (enemyInfo == null) continue;
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == enemyInfo.Skill);
if (skillData == null) continue;
menuItems.Add(($"{enemy.PlayerName} : {skillData.Name}", enemy.Index.ToString()));
}
SkillUtils.CreateMenu(player, menuItems);
var enemyInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == enemy.SteamID);
if (enemyInfo == null) continue;
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == enemyInfo.Skill);
if (skillData == null) continue;
menuItems.Add(($"{enemy.PlayerName} : {player.GetSkillName(skillData.Skill)}", enemy.Index.ToString()));
}
SkillUtils.UpdateMenu(player, menuItems);
}
}
@ -64,7 +62,7 @@ namespace jRandomSkills
if (enemy == null)
{
player.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("selectplayerskill_incorrect_enemy_index"));
player.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("selectplayerskill_incorrect_enemy_index"));
return;
}
@ -83,12 +81,12 @@ namespace jRandomSkills
if (enemyInfo == null) continue;
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == enemyInfo.Skill);
if (skillData == null) continue;
menuItems.Add(($"{enemy.PlayerName} : {skillData.Name}", enemy.Index.ToString()));
menuItems.Add(($"{enemy.PlayerName} : {player.GetSkillName(skillData.Skill)}", enemy.Index.ToString()));
}
SkillUtils.CreateMenu(player, menuItems);
}
else
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
}
public static void DisableSkill(CCSPlayerController player)
@ -108,7 +106,7 @@ namespace jRandomSkills
{
playerInfo.Skill = Skills.None;
playerInfo.SpecialSkill = skillName;
player.PrintToChat($" {ChatColors.Green}" + Localization.GetTranslation("deactivator_player_info", enemy.PlayerName));
player.PrintToChat($" {ChatColors.Green}" + player.GetTranslation("deactivator_player_info", enemy.PlayerName));
}
if (enemyInfo != null)
@ -116,7 +114,7 @@ namespace jRandomSkills
Instance.SkillAction(enemyInfo.Skill.ToString(), "DisableSkill", [enemy]);
enemyInfo.SpecialSkill = enemyInfo.Skill;
enemyInfo.Skill = Skills.None;
enemy.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("deactivator_enemy_info"));
enemy.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("deactivator_enemy_info"));
}
}

View file

@ -57,7 +57,7 @@ namespace jRandomSkills
if (playerInfo.SkillChance == 1)
{
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("areareaper_used_info")}");
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("areareaper_used_info")}");
return;
}
@ -66,14 +66,14 @@ namespace jRandomSkills
if (enemy == null)
{
player.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("selectplayerskill_incorrect_enemy_index"));
player.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("selectplayerskill_incorrect_enemy_index"));
return;
}
deafPlayers.Add(enemy);
playerInfo.SkillChance = 1;
player.PrintToChat($" {ChatColors.Green}" + Localization.GetTranslation("deaf_player_info", enemy.PlayerName));
enemy.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("deaf_enemy_info"));
player.PrintToChat($" {ChatColors.Green}" + player.GetTranslation("deaf_player_info", enemy.PlayerName));
enemy.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("deaf_enemy_info"));
}
public static void EnableSkill(CCSPlayerController player)
@ -89,7 +89,7 @@ namespace jRandomSkills
SkillUtils.CreateMenu(player, menuItems);
}
else
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
}
public static void DisableSkill(CCSPlayerController player)

View file

@ -46,7 +46,7 @@ namespace jRandomSkills
playerInfo.SkillChance = newChance;
newChance = (float)Math.Round(newChance, 2) * 100;
newChance = (float)Math.Round(newChance);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{Localization.GetTranslation("disarmament")}{ChatColors.Lime}: " + Localization.GetTranslation("disarmament_desc2", newChance), false);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{player.GetTranslation("disarmament")}{ChatColors.Lime}: " + player.GetTranslation("disarmament_desc2", newChance), false);
}
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#FF4500", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float chanceFrom = .2f, float chanceTo = .5f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)

View file

@ -48,8 +48,8 @@ namespace jRandomSkills
string distanceColor = closetDistance > 1500 ? "#00FF00" : closetDistance > 600 ? "#FFFF00" : "#FF0000";
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{player.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{player.GetSkillName(skillData.Skill)}</font> <br>";
string remainingLine = $"<font class='fontSize-m' color='#FFFFFF'>{closetEnemy}: <font color='{distanceColor}'>{closetDistance}</font></font> <br>";
var hudContent = infoLine + skillLine + remainingLine;

View file

@ -13,7 +13,7 @@ namespace jRandomSkills
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"), false);
}
public static void NewRound()
@ -32,19 +32,17 @@ namespace jRandomSkills
if (playerInfo == null || playerInfo.Skill != skillName) continue;
var enemies = Utilities.GetPlayers().Where(p => p.PawnIsAlive && p != player && p.IsValid && !p.IsBot && !p.IsHLTV && p.Team != CsTeam.Spectator && p.Team != CsTeam.None).ToArray();
if (enemies.Length > 0)
HashSet<(string, string)> menuItems = [];
foreach (var enemy in enemies)
{
HashSet<(string, string)> menuItems = [];
foreach (var enemy in enemies)
{
var enemyInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == enemy.SteamID);
if (enemyInfo == null) continue;
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == enemyInfo.Skill);
if (skillData == null) continue;
menuItems.Add(($"{enemy.PlayerName} : {skillData.Name}", enemy.Index.ToString()));
}
SkillUtils.CreateMenu(player, menuItems);
var enemyInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == enemy.SteamID);
if (enemyInfo == null) continue;
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == enemyInfo.Skill);
if (skillData == null) continue;
menuItems.Add(($"{enemy.PlayerName} : {player.GetSkillName(skillData.Skill)}", enemy.Index.ToString()));
}
SkillUtils.UpdateMenu(player, menuItems);
}
}
@ -64,7 +62,7 @@ namespace jRandomSkills
if (enemy == null)
{
player.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("selectplayerskill_incorrect_enemy_index"));
player.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("selectplayerskill_incorrect_enemy_index"));
return;
}
@ -76,6 +74,7 @@ namespace jRandomSkills
var enemies = Utilities.GetPlayers().Where(p => p.PawnIsAlive && p != player && p.IsValid && !p.IsBot && !p.IsHLTV && p.Team != CsTeam.Spectator && p.Team != CsTeam.None).ToArray();
if (enemies.Length > 0)
{
List<string> skills = [];
HashSet<(string, string)> menuItems = [];
foreach (var enemy in enemies)
{
@ -83,12 +82,23 @@ namespace jRandomSkills
if (enemyInfo == null) continue;
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == enemyInfo.Skill);
if (skillData == null) continue;
menuItems.Add(($"{enemy.PlayerName} : {skillData.Name}", enemy.Index.ToString()));
skills.Add(skillData.Skill.ToString());
menuItems.Add(($"{enemy.PlayerName} : {player.GetSkillName(skillData.Skill)}", enemy.Index.ToString()));
}
int ctSkills = Event.counterterroristSkills.Count(s => skills.Contains(s.Name));
int ttSkills = Event.terroristSkills.Count(s => skills.Contains(s.Name));
if ((player.Team == CsTeam.Terrorist && ctSkills == skills.Count) || (player.Team == CsTeam.CounterTerrorist && ttSkills == skills.Count))
{
Event.SetRandomSkill(player);
return;
}
SkillUtils.CreateMenu(player, menuItems);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{player.GetSkillName(skillName)}{ChatColors.Lime}: {player.GetSkillDescription(skillName)}", false);
}
else
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
}
public static void DisableSkill(CCSPlayerController player)
@ -103,17 +113,31 @@ namespace jRandomSkills
{
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
var enemyInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == enemy.SteamID);
if (playerInfo == null || enemyInfo == null) return;
if (playerInfo != null && enemyInfo != null)
var enemySkill = enemyInfo.Skill;
bool ctSkill = Event.counterterroristSkills.Any(s => s.Name == enemySkill.ToString());
bool ttSkill = Event.terroristSkills.Any(s => s.Name == enemySkill.ToString());
if ((player.Team == CsTeam.Terrorist && ctSkill) || (player.Team == CsTeam.CounterTerrorist && ttSkill))
{
Instance.AddTimer(.1f, () =>
{
playerInfo.Skill = enemyInfo.Skill;
playerInfo.SpecialSkill = skillName;
Instance.SkillAction(enemyInfo.Skill.ToString(), "EnableSkill", [player]);
Instance.SkillAction(skillName.ToString(), "EnableSkill", [player]);
player.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("thief_incorrect_skill", enemy.PlayerName));
});
player.PrintToChat($" {ChatColors.Green}" + Localization.GetTranslation("duplicator_player_info", enemy.PlayerName));
return;
}
SkillUtils.CloseMenu(player);
Instance.AddTimer(.1f, () =>
{
playerInfo.Skill = enemySkill;
playerInfo.SpecialSkill = skillName;
SkillUtils.CloseMenu(player);
Instance.SkillAction(enemySkill.ToString(), "EnableSkill", [player]);
});
player.PrintToChat($" {ChatColors.Green}" + player.GetTranslation("duplicator_player_info", enemy.PlayerName));
}
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#ffb73b", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)

View file

@ -38,7 +38,7 @@ namespace jRandomSkills
playerInfo.SkillChance = newSize;
SkillUtils.ChangePlayerScale(player, newSize);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{Localization.GetTranslation("dwarf")}{ChatColors.Lime}: " + Localization.GetTranslation("dwarf_desc2", newSize), false);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{player.GetTranslation("dwarf")}{ChatColors.Lime}: " + player.GetTranslation("dwarf_desc2", newSize), false);
}
}

View file

@ -0,0 +1,148 @@
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 Earthquake : ISkill
{
private const Skills skillName = Skills.Earthquake;
private static readonly float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
private static readonly float amplitude = Config.GetValue<float>(skillName, "amplitude");
private static readonly float frequency = Config.GetValue<float>(skillName, "frequency");
private static readonly float duration = Config.GetValue<float>(skillName, "duration");
private static readonly float radius = Config.GetValue<float>(skillName, "radius");
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = [];
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
}
public static void NewRound()
{
SkillPlayerInfo.Clear();
}
public static void EnableSkill(CCSPlayerController player)
{
SkillPlayerInfo[player.SteamID] = new PlayerSkillInfo
{
SteamID = player.SteamID,
CanUse = true,
Cooldown = DateTime.MinValue,
};
}
public static void DisableSkill(CCSPlayerController player)
{
SkillPlayerInfo.Remove(player.SteamID);
}
public static void PlayerDeath(EventPlayerDeath @event)
{
var player = @event.Userid;
if (player == null || !player.IsValid) return;
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill == skillName)
SkillPlayerInfo.Remove(player.SteamID);
}
public static void OnTick()
{
foreach (var player in Utilities.GetPlayers())
{
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill == skillName)
if (SkillPlayerInfo.TryGetValue(player.SteamID, out var skillInfo))
UpdateHUD(player, skillInfo);
}
}
private static void UpdateHUD(CCSPlayerController player, PlayerSkillInfo skillInfo)
{
float cooldown = 0;
if (skillInfo != null)
{
float time = (int)(skillInfo.Cooldown.AddSeconds(timerCooldown) - DateTime.Now).TotalSeconds;
cooldown = Math.Max(time, 0);
if (cooldown == 0 && skillInfo?.CanUse == false)
skillInfo.CanUse = true;
}
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == skillName);
if (skillData == null) return;
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{player.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{player.GetSkillName(skillData.Skill)}</font> <br>";
string remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{player.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>" : "";
var hudContent = infoLine + skillLine + remainingLine;
player.PrintToCenterHtml(hudContent);
}
public static void UseSkill(CCSPlayerController player)
{
var playerPawn = player.PlayerPawn.Value;
if (playerPawn?.CBodyComponent == null) return;
if (SkillPlayerInfo.TryGetValue(player.SteamID, out var skillInfo))
{
if (!player.IsValid || !player.PawnIsAlive) return;
if (skillInfo.CanUse)
{
skillInfo.CanUse = false;
skillInfo.Cooldown = DateTime.Now;
MakeShake(player);
}
}
}
private static void MakeShake(CCSPlayerController player)
{
foreach (var enemy in Utilities.GetPlayers().Where(p => p != null && p.IsValid && p.PawnIsAlive))
CreateShake(player);
}
private static void CreateShake(CCSPlayerController player)
{
var pawn = player.PlayerPawn.Value;
if (pawn == null || !pawn.IsValid || pawn.AbsOrigin == null) return;
var shake = Utilities.CreateEntityByName<CEnvShake>("env_shake");
if (shake == null) return;
shake.DispatchSpawn();
if (!shake.IsValid) return;
shake.Amplitude = amplitude;
shake.Frequency = frequency;
shake.Duration = duration;
shake.Radius = radius;
shake.Teleport(new Vector(pawn.AbsOrigin.X, pawn.AbsOrigin.Y, pawn.AbsOrigin.Z + pawn.ViewOffset.Z));
shake.AcceptInput("SetParent", pawn, pawn, "!activator");
shake.AcceptInput("StartShake");
}
public class PlayerSkillInfo
{
public ulong SteamID { get; set; }
public bool CanUse { get; set; }
public DateTime Cooldown { get; set; }
}
public class SkillConfig(Skills skill = skillName, bool active = false, string color = "#42f59b", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 16f, float amplitude = 15f, float frequency = 500f, float duration = 8f, float radius = 50f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
{
public float Cooldown { get; set; } = cooldown;
public float Amplitude { get; set; } = amplitude;
public float Frequency { get; set; } = frequency;
public float Duration { get; set; } = duration;
public float Radius { get; set; } = radius;
}
}
}

View file

@ -64,9 +64,9 @@ namespace jRandomSkills
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == skillName);
if (skillData == null) return;
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
string remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{Localization.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>" : "";
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{player.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{player.GetSkillName(skillData.Skill)}</font> <br>";
string remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{player.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>" : "";
var hudContent = infoLine + skillLine + remainingLine;
player.PrintToCenterHtml(hudContent);

View file

@ -27,7 +27,7 @@ namespace jRandomSkills
playerInfo.SkillChance = newChance;
newChance = (float)Math.Round(newChance, 2) * 100;
newChance = (float)Math.Round(newChance);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{Localization.GetTranslation("explosiveshot")}{ChatColors.Lime}: " + Localization.GetTranslation("explosiveshot_desc2", newChance), false);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{player.GetTranslation("explosiveshot")}{ChatColors.Lime}: " + player.GetTranslation("explosiveshot_desc2", newChance), false);
}
private static void SpawnExplosion(Vector vector)

View file

@ -64,7 +64,7 @@ namespace jRandomSkills
jumpedPlayers.TryAdd(player.SteamID, 0);
playerPawn.VelocityModifier = newSpeed;
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{Localization.GetTranslation("flash")}{ChatColors.Lime}: " + Localization.GetTranslation("flash_desc2", newSpeed), false);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{player.GetTranslation("flash")}{ChatColors.Lime}: " + player.GetTranslation("flash_desc2", newSpeed), false);
}
public static void DisableSkill(CCSPlayerController player)

View file

@ -72,9 +72,9 @@ namespace jRandomSkills
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == skillName);
if (skillData == null) return;
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
string remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{Localization.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>" : "";
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{player.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{player.GetSkillName(skillData.Skill)}</font> <br>";
string remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{player.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>" : "";
var hudContent = infoLine + skillLine + remainingLine;
player.PrintToCenterHtml(hudContent);

View file

@ -107,7 +107,7 @@ namespace jRandomSkills
return;
}
Server.PrintToChatAll($" {ChatColors.Gold}{Localization.GetTranslation("fragilebomb_bomb_health")}: {ChatColors.Red}{bombHealth}{ChatColors.Gold}/{ChatColors.Green}{maxBombHealth}");
Localization.PrintTranslationToChatAll($" {ChatColors.Gold}{{0}}: {ChatColors.Red}{bombHealth}{ChatColors.Gold}/{ChatColors.Green}{maxBombHealth}", ["fragilebomb_bomb_health"]);
}
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#5d00ff", CsTeam onlyTeam = CsTeam.CounterTerrorist, bool needsTeammates = false, int maxBombHealth = 1000) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)

View file

@ -31,14 +31,14 @@ namespace jRandomSkills
if (playerInfo.SkillChance == 1)
{
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("areareaper_used_info")}");
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("areareaper_used_info")}");
return;
}
var skill = SkillData.Skills.FirstOrDefault(s => s.Name.Equals(commands[0], StringComparison.OrdinalIgnoreCase) || s.Skill.ToString().Equals(commands[0], StringComparison.OrdinalIgnoreCase));
var skill = SkillData.Skills.FirstOrDefault(s => player.GetSkillName(s.Skill).Equals(commands[0], StringComparison.OrdinalIgnoreCase) || s.Skill.ToString().Equals(commands[0], StringComparison.OrdinalIgnoreCase));
if (skill == null)
{
player.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("skill_not_found_setskill"));
player.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("skill_not_found_setskill"));
return;
}
@ -73,9 +73,9 @@ namespace jRandomSkills
skills.Remove(firstSkill);
var secondSkill = skills[Instance.Random.Next(skills.Count)];
HashSet<(string, string)> menuItems = [(firstSkill.Name, firstSkill.Skill.ToString()),
(secondSkill.Name, secondSkill.Skill.ToString()),
(Localization.GetTranslation("gambler_more", refreshPrice), skillName.ToString())];
HashSet<(string, string)> menuItems = [(player.GetSkillName(firstSkill.Skill), firstSkill.Skill.ToString()),
(player.GetSkillName(secondSkill.Skill), secondSkill.Skill.ToString()),
(player.GetTranslation("gambler_more", refreshPrice), skillName.ToString())];
SkillUtils.CreateMenu(player, menuItems);
}

View file

@ -77,7 +77,7 @@ namespace jRandomSkills
public static void EnableSkill(CCSPlayerController player)
{
Event.enableTransmit = true;
SkillUtils.EnableTransmit();
SetPlayerVisibility(player, false);
SetWeaponVisibility(player, false);
SetWeaponAttack(player, true);
@ -180,9 +180,9 @@ namespace jRandomSkills
var weapon = pawn.WeaponServices.ActiveWeapon.Value;
if (weapon == null || !weapon.IsValid || !disabledWeapons.Contains(weapon.DesignerName)) return;
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
string remainingLine = $"<font class='fontSize-m' color='#FF0000'>{Localization.GetTranslation("disabled_weapon")}</font> <br>";
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{player.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{player.GetSkillName(skillData.Skill)}</font> <br>";
string remainingLine = $"<font class='fontSize-m' color='#FF0000'>{player.GetTranslation("disabled_weapon")}</font> <br>";
var hudContent = infoLine + skillLine + remainingLine;
player.PrintToCenterHtml(hudContent);

View file

@ -51,7 +51,7 @@ namespace jRandomSkills
public static void EnableSkill(CCSPlayerController player)
{
Event.enableTransmit = true;
SkillUtils.EnableTransmit();
SkillUtils.TryGiveWeapon(player, CsItem.SmokeGrenade);
}

View file

@ -57,7 +57,7 @@ namespace jRandomSkills
if (playerInfo.SkillChance == 1)
{
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("areareaper_used_info")}");
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("areareaper_used_info")}");
return;
}
@ -66,15 +66,15 @@ namespace jRandomSkills
if (enemy == null)
{
player.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("selectplayerskill_incorrect_enemy_index"));
player.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("selectplayerskill_incorrect_enemy_index"));
return;
}
glitchedPlayers.Add(enemy);
enemy.ReplicateConVar("sv_disable_radar", "1");
playerInfo.SkillChance = 1;
player.PrintToChat($" {ChatColors.Green}" + Localization.GetTranslation("glitch_player_info", enemy.PlayerName));
enemy.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("glitch_enemy_info"));
player.PrintToChat($" {ChatColors.Green}" + player.GetTranslation("glitch_player_info", enemy.PlayerName));
enemy.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("glitch_enemy_info"));
}
public static void EnableSkill(CCSPlayerController player)
@ -90,7 +90,7 @@ namespace jRandomSkills
SkillUtils.CreateMenu(player, menuItems);
}
else
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
}
public static void DisableSkill(CCSPlayerController player)

View file

@ -65,9 +65,9 @@ namespace jRandomSkills
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == skillName);
if (skillData == null) return;
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
string remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{Localization.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>" : "";
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{player.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{player.GetSkillName(skillData.Skill)}</font> <br>";
string remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{player.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>" : "";
var hudContent = infoLine + skillLine + remainingLine;
player.PrintToCenterHtml(hudContent);
@ -86,14 +86,14 @@ namespace jRandomSkills
skillInfo.CanUse = false;
skillInfo.Cooldown = DateTime.Now;
player.PrintToChat($" {ChatColors.Green} {Localization.GetTranslation("godmode_on")}");
player.PrintToChat($" {ChatColors.Green} {player.GetTranslation("godmode_on")}");
player.PlayerPawn.Value.TakesDamage = false;
Instance.AddTimer(duration, () => {
if (player.IsValid && player.PawnIsAlive)
{
player.PlayerPawn.Value.TakesDamage = true;
player.PrintToChat($" {ChatColors.Red} {Localization.GetTranslation("godmode_off")}");
player.PrintToChat($" {ChatColors.Red} {player.GetTranslation("godmode_off")}");
}
});
}

View file

@ -0,0 +1,39 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Entities.Constants;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class Grenadier : ISkill
{
private const Skills skillName = Skills.Grenadier;
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
}
public static void EnableSkill(CCSPlayerController player)
{
if (!Instance.IsPlayerValid(player)) return;
SkillUtils.TryGiveWeapon(player, CsItem.HEGrenade);
}
public static void GrenadeThrown(EventGrenadeThrown @event)
{
var player = @event.Userid;
var weapon = @event.Weapon;
if (weapon != "hegrenade" || !Instance.IsPlayerValid(player)) return;
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player?.SteamID);
if (playerInfo?.Skill == skillName)
player!.GiveNamedItem($"weapon_{weapon}");
}
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#4a6e21", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}

View file

@ -12,7 +12,6 @@ namespace jRandomSkills
{
private const Skills skillName = Skills.Jackal;
private static readonly int maxStepBeam = Config.GetValue<int>(skillName, "maxStepBeam");
private static bool exists = false;
private static readonly Dictionary<CCSPlayerController, List<CBeam>> stepBeams = [];
public static void LoadSkill()
@ -27,8 +26,6 @@ namespace jRandomSkills
if (beam != null && beam.IsValid)
beam.AcceptInput("Kill");
stepBeams.Clear();
Instance.RemoveListener<Listeners.CheckTransmit>(CheckTransmit);
exists = false;
}
public static void OnTick()
@ -44,21 +41,20 @@ namespace jRandomSkills
}
var pawn = player.PlayerPawn.Value;
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 || pawn.AbsOrigin == null) continue;
var beams = step.Value;
if (pawn.AbsOrigin == null) continue;
Vector lastBeamVector = beams.Count > 0
? beams.LastOrDefault()!.EndPos : pawn.AbsOrigin;
Vector lastBeamVector = (beams != null && beams.Count > 0 && beams.Last() != null)
? beams.Last().EndPos : pawn.AbsOrigin;
var newBeam = CreateBeamStep(step.Key.Team, lastBeamVector, pawn.AbsOrigin);
if (newBeam != null)
beams.Add(newBeam);
step.Value.Add(newBeam);
if (beams.Count >= maxStepBeam)
if (beams?.Count >= maxStepBeam)
{
beams[0].AcceptInput("Kill");
beams.RemoveAt(0);
step.Value.RemoveAt(0);
}
}
}
@ -91,6 +87,9 @@ namespace jRandomSkills
CBeam beam = Utilities.CreateEntityByName<CBeam>("beam")!;
if (beam == null) return null;
beam.DispatchSpawn();
if (!beam.IsValid) return null;
beam.Render = team == CsTeam.Terrorist ? Color.FromArgb(100, 255, 165, 0) : Color.FromArgb(100, 173, 216, 230);
beam.Width = 2.0f;
beam.EndWidth = 2.0f;
@ -99,25 +98,28 @@ namespace jRandomSkills
beam.EndPos.X = stop.X;
beam.EndPos.Y = stop.Y;
beam.EndPos.Z = stop.Z;
beam.DispatchSpawn();
beam.AcceptInput("FollowEntity", beam, null!, "");
return beam;
}
public static void EnableSkill(CCSPlayerController player)
public static void EnableSkill(CCSPlayerController _)
{
if (!exists)
{
Instance.RegisterListener<Listeners.CheckTransmit>(CheckTransmit);
foreach (var _player in Utilities.GetPlayers().Where(p => p.IsValid && !p.IsBot && !p.IsHLTV && p.Team != CsTeam.Spectator))
SkillUtils.EnableTransmit();
foreach (var _player in Utilities.GetPlayers().Where(p => p.IsValid && !p.IsBot && !p.IsHLTV && p.Team != CsTeam.Spectator))
if (!stepBeams.ContainsKey(_player))
stepBeams.Add(_player, []);
}
exists = true;
}
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#f542ef", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int maxStepBeam = 50) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
public static void DisableSkill(CCSPlayerController player)
{
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo == null) return;
playerInfo.Skill = Skills.None;
if (!Instance.SkillPlayer.Any(s => s.Skill == skillName))
NewRound();
}
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#f542ef", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int maxStepBeam = 100) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
{
public int MaxStepBeam { get; set; } = maxStepBeam;
}

View file

@ -50,7 +50,7 @@ namespace jRandomSkills
if (playerInfo.SkillChance == 1)
{
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("areareaper_used_info")}");
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("areareaper_used_info")}");
return;
}
@ -59,15 +59,15 @@ namespace jRandomSkills
if (enemy == null)
{
player.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("selectplayerskill_incorrect_enemy_index"));
player.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("selectplayerskill_incorrect_enemy_index"));
return;
}
jammedPlayers.Add(enemy);
SetCrosshair(enemy, false);
playerInfo.SkillChance = 1;
player.PrintToChat($" {ChatColors.Green}" + Localization.GetTranslation("jammer_player_info", enemy.PlayerName));
enemy.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("jammer_enemy_info"));
player.PrintToChat($" {ChatColors.Green}" + player.GetTranslation("jammer_player_info", enemy.PlayerName));
enemy.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("jammer_enemy_info"));
}
private static void SetCrosshair(CCSPlayerController player, bool enabled)
@ -93,7 +93,7 @@ namespace jRandomSkills
SkillUtils.CreateMenu(player, menuItems);
}
else
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
}
public static void DisableSkill(CCSPlayerController player)

View file

@ -106,9 +106,9 @@ namespace jRandomSkills
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == skillName);
if (skillData == null) return;
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
string remainingLine = $"<font class='fontSize-m' color='#FFFFFF'>{Localization.GetTranslation("jester_mode")}: <font color='{(jesterMode ? "#00ff00" : "#ff0000")}'>{Localization.GetTranslation(jesterMode ? "jester_on" : "jester_off")}</font></font> <br>";
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{player.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{player.GetSkillName(skillData.Skill)}</font> <br>";
string remainingLine = $"<font class='fontSize-m' color='#FFFFFF'>{player.GetTranslation("jester_mode")}: <font color='{(jesterMode ? "#00ff00" : "#ff0000")}'>{player.GetTranslation(jesterMode ? "jester_on" : "jester_off")}</font></font> <br>";
var hudContent = infoLine + skillLine + remainingLine;
player.PrintToCenterHtml(hudContent);

View file

@ -65,7 +65,7 @@ namespace jRandomSkills
if (playerInfo.SkillChance == 1)
{
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("areareaper_used_info")}");
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("areareaper_used_info")}");
return;
}
@ -74,14 +74,14 @@ namespace jRandomSkills
if (enemy == null || !enemy.IsValid || enemy.PlayerPawn.Value == null || !enemy.PlayerPawn.Value.IsValid)
{
player.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("selectplayerskill_incorrect_enemy_index"));
player.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("selectplayerskill_incorrect_enemy_index"));
return;
}
bannedPlayers[enemy.PlayerPawn.Value] = 0;
playerInfo.SkillChance = 1;
player.PrintToChat($" {ChatColors.Green}" + Localization.GetTranslation("jumpban_player_info", enemy.PlayerName));
enemy.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("jumpban_enemy_info"));
player.PrintToChat($" {ChatColors.Green}" + player.GetTranslation("jumpban_player_info", enemy.PlayerName));
enemy.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("jumpban_enemy_info"));
}
public static void EnableSkill(CCSPlayerController player)
@ -97,7 +97,7 @@ namespace jRandomSkills
SkillUtils.CreateMenu(player, menuItems);
}
else
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
}
public static void DisableSkill(CCSPlayerController player)

View file

@ -46,7 +46,7 @@ namespace jRandomSkills
if (playerInfo.SkillChance == 1)
{
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("areareaper_used_info")}");
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("areareaper_used_info")}");
return;
}
@ -55,14 +55,14 @@ namespace jRandomSkills
if (enemy == null)
{
player.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("selectplayerskill_incorrect_enemy_index"));
player.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("selectplayerskill_incorrect_enemy_index"));
return;
}
SwapHealth(player, enemy);
playerInfo.SkillChance = 1;
player.PrintToChat($" {ChatColors.Green}" + Localization.GetTranslation("lifeswap_player_info", enemy.PlayerName));
enemy.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("lifeswap_enemy_info"));
player.PrintToChat($" {ChatColors.Green}" + player.GetTranslation("lifeswap_player_info", enemy.PlayerName));
enemy.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("lifeswap_enemy_info"));
}
public static void EnableSkill(CCSPlayerController player)
@ -78,7 +78,7 @@ namespace jRandomSkills
SkillUtils.CreateMenu(player, menuItems);
}
else
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
}
private static void SwapHealth(CCSPlayerController player, CCSPlayerController enemy)

View file

@ -1,9 +1,12 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Entities.Constants;
using CounterStrikeSharp.API.Modules.Utils;
using CS2TraceRay.Class;
using CS2TraceRay.Enum;
using CS2TraceRay.Struct;
using jRandomSkills.src.player;
using System.Drawing;
using System.Numerics;
using static jRandomSkills.jRandomSkills;
using Vector = CounterStrikeSharp.API.Modules.Utils.Vector;
@ -52,7 +55,22 @@ namespace jRandomSkills
filter.m_nHierarchyIds[0] = pawn.GetHierarchyId();
filter.m_nHierarchyIds[1] = 0;
CGameTrace trace = TraceRay.TraceHull(eyePos, endPos, filter, ray);
CGameTrace trace = TraceRay.TraceHull(eyePos, endPos, filter, ray);
if (Config.LoadedConfig.Settings.CS2TraceRayDebug)
{
CreateLine(eyePos, endPos, Color.FromArgb(255, 255, 255, 0));
CreateLine(new Vector(trace.StartPos.X, trace.StartPos.Y, trace.StartPos.Z), new Vector(trace.EndPos.X, trace.EndPos.Y, trace.EndPos.Z), Color.FromArgb(255, 255, 0, 0));
CreateLine(new Vector(trace.StartPos.X, trace.StartPos.Y, trace.StartPos.Z), new Vector(trace.Position.X, trace.Position.Y, trace.Position.Z), Color.FromArgb(255, 0, 0, 255));
if (trace.DidHit())
{
var val = Activator.CreateInstance(typeof(CBaseEntity), trace.HitEntity) as CBaseEntity;
player.PrintToChat($"Hit: {trace.DidHit()}, Entity: {(val == null ? "null" : val.DesignerName)}, Solid: {trace.AllSolid}, Contents: {(Contents)trace.Contents}");
}
else
player.PrintToChat($"Hit: {trace.DidHit()}, Entity: {trace.HitEntity}, Solid: {trace.AllSolid}, Contents: {(Contents)trace.Contents}");
}
if (!trace.HitPlayer(out CCSPlayerController? target) || target == null)
return;
@ -62,6 +80,24 @@ namespace jRandomSkills
SkillUtils.TakeHealth(target.PlayerPawn.Value, Instance.Random.Next(21, 34));
}
private static void CreateLine(Vector start, Vector end, Color color)
{
CBeam beam = Utilities.CreateEntityByName<CBeam>("beam")!;
if (beam == null) return;
beam.Render = color;
beam.Width = 2.0f;
beam.EndWidth = 2.0f;
beam.Teleport(start);
beam.EndPos.X = end.X;
beam.EndPos.Y = end.Y;
beam.EndPos.Z = end.Z;
beam.DispatchSpawn();
beam.AcceptInput("FollowEntity", beam, null!, "");
}
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#c9f8ff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float maxDistance = 4096f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
{
public float MaxDistance { get; set; } = maxDistance;

View file

@ -1,9 +1,12 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Entities.Constants;
using CounterStrikeSharp.API.Modules.Utils;
using CS2TraceRay.Class;
using CS2TraceRay.Enum;
using CS2TraceRay.Struct;
using jRandomSkills.src.player;
using System.Drawing;
using System.Numerics;
using static jRandomSkills.jRandomSkills;
using Vector = CounterStrikeSharp.API.Modules.Utils.Vector;
@ -54,6 +57,21 @@ namespace jRandomSkills
filter.m_nHierarchyIds[1] = 0;
CGameTrace trace = TraceRay.TraceHull(eyePos, endPos, filter, ray);
if (Config.LoadedConfig.Settings.CS2TraceRayDebug)
{
CreateLine(eyePos, endPos, Color.FromArgb(255, 255, 255, 0));
CreateLine(new Vector(trace.StartPos.X, trace.StartPos.Y, trace.StartPos.Z), new Vector(trace.EndPos.X, trace.EndPos.Y, trace.EndPos.Z), Color.FromArgb(255, 255, 0, 0));
CreateLine(new Vector(trace.StartPos.X, trace.StartPos.Y, trace.StartPos.Z), new Vector(trace.Position.X, trace.Position.Y, trace.Position.Z), Color.FromArgb(255, 0, 0, 255));
if (trace.DidHit())
{
var val = Activator.CreateInstance(typeof(CBaseEntity), trace.HitEntity) as CBaseEntity;
player.PrintToChat($"Hit: {trace.DidHit()}, Entity: {(val == null ? "null" : val.DesignerName)}, Solid: {trace.AllSolid}, Contents: {(Contents)trace.Contents}");
}
else
player.PrintToChat($"Hit: {trace.DidHit()}, Entity: {trace.HitEntity}, Solid: {trace.AllSolid}, Contents: {(Contents)trace.Contents}");
}
if (!trace.HitPlayer(out CCSPlayerController? target) || target == null)
return;
@ -66,6 +84,24 @@ namespace jRandomSkills
SkillUtils.TryGiveWeapon(player, CsItem.Zeus);
}
private static void CreateLine(Vector start, Vector end, Color color)
{
CBeam beam = Utilities.CreateEntityByName<CBeam>("beam")!;
if (beam == null) return;
beam.Render = color;
beam.Width = 2.0f;
beam.EndWidth = 2.0f;
beam.Teleport(start);
beam.EndPos.X = end.X;
beam.EndPos.Y = end.Y;
beam.EndPos.Z = end.Z;
beam.DispatchSpawn();
beam.AcceptInput("FollowEntity", beam, null!, "");
}
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#6effc7", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float maxDistance = 4096f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
{
public float MaxDistance { get; set; } = maxDistance;

View file

@ -58,7 +58,7 @@ namespace jRandomSkills
if (playerInfo.SkillChance == 1)
{
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("areareaper_used_info")}");
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("areareaper_used_info")}");
return;
}
@ -67,7 +67,7 @@ namespace jRandomSkills
if (enemy == null)
{
player.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("selectplayerskill_incorrect_enemy_index"));
player.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("selectplayerskill_incorrect_enemy_index"));
return;
}
@ -77,8 +77,8 @@ namespace jRandomSkills
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"));
player.PrintToChat($" {ChatColors.Green}" + player.GetTranslation("magnifier_player_info", enemy.PlayerName));
enemy.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("magnifier_enemy_info"));
}
public static void EnableSkill(CCSPlayerController player)
@ -94,7 +94,7 @@ namespace jRandomSkills
SkillUtils.CreateMenu(player, menuItems);
}
else
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
}
public static void DisableSkill(CCSPlayerController player)

View file

@ -67,10 +67,10 @@ namespace jRandomSkills
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == skillName);
if (skillData == null) return;
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{player.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{player.GetSkillName(skillData.Skill)}</font> <br>";
string remainingLine = cooldown != 0
? $"<font class='fontSize-m' color='#FFFFFF'>{Localization.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>"
? $"<font class='fontSize-m' color='#FFFFFF'>{player.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>"
: $"<font class='fontSize-m' color='#{(skillInfo == null || skillInfo.Count == 0 ? "FF0000" : "00FF00")}'>{(skillInfo == null ? 0 : skillInfo.Count)}/{healthShotLimit}</font> <br>";
var hudContent = infoLine + skillLine + remainingLine;

View file

@ -46,7 +46,7 @@ namespace jRandomSkills
if (playerInfo.SkillChance == 1)
{
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("areareaper_used_info")}");
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("areareaper_used_info")}");
return;
}
@ -55,14 +55,14 @@ namespace jRandomSkills
if (enemy == null)
{
player.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("selectplayerskill_incorrect_enemy_index"));
player.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("selectplayerskill_incorrect_enemy_index"));
return;
}
SwapMoney(player, enemy);
playerInfo.SkillChance = 1;
player.PrintToChat($" {ChatColors.Green}" + Localization.GetTranslation("moneyswap_player_info", enemy.PlayerName));
enemy.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("moneyswap_enemy_info"));
player.PrintToChat($" {ChatColors.Green}" + player.GetTranslation("moneyswap_player_info", enemy.PlayerName));
enemy.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("moneyswap_enemy_info"));
}
public static void EnableSkill(CCSPlayerController player)
@ -78,7 +78,7 @@ namespace jRandomSkills
SkillUtils.CreateMenu(player, menuItems);
}
else
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
}
private static void SwapMoney(CCSPlayerController player, CCSPlayerController enemy)

View file

@ -3,6 +3,7 @@ using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Entities;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using Microsoft.Extensions.Logging;
using static jRandomSkills.jRandomSkills;
@ -48,7 +49,7 @@ namespace jRandomSkills
heProjectile.DispatchSpawn();
heProjectile.AcceptInput("InitializeSpawnFromWorld", player.PlayerPawn.Value, player.PlayerPawn.Value, "");
heProjectile.DetonateTime = 0;
Server.PrintToChatAll($" {ChatColors.DarkRed}► {ChatColors.Green}[{ChatColors.DarkRed} qRandomSkills {ChatColors.Green}] {ChatColors.DarkRed}{player.PlayerName}: {ChatColors.Lime}ALLAHU AKBAR!!!");
Server.PrintToChatAll($" {ChatColors.DarkRed}► {ChatColors.Green}[{ChatColors.DarkRed} jRandomSkills {ChatColors.Green}] {ChatColors.DarkRed}{player.PlayerName}: {ChatColors.Lime}ALLAHU AKBAR!!!");
var fileNames = new[] { "radiobotfallback01", "radiobotfallback02", "radiobotfallback04" };
Instance.AddTimer(0.1f, () =>

View file

@ -71,7 +71,7 @@ namespace jRandomSkills
public static void EnableSkill(CCSPlayerController _)
{
Event.enableTransmit = true;
SkillUtils.EnableTransmit();
}
public static void DisableSkill(CCSPlayerController player)

View file

@ -69,13 +69,13 @@ namespace jRandomSkills
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == skillName);
if (skillData == null) return;
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{player.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{player.GetSkillName(skillData.Skill)}</font> <br>";
string remainingLine = cooldown != 0
? (
flying != 0
? $"<font class='fontSize-m' color='#FFFFFF'>{Localization.GetTranslation("active_hud_info", $"<font color='#00FF00'>{Math.Round(flying / 100, 2)}</font>")}</font> <br>"
: $"<font class='fontSize-m' color='#FFFFFF'>{Localization.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>"
? $"<font class='fontSize-m' color='#FFFFFF'>{player.GetTranslation("active_hud_info", $"<font color='#00FF00'>{Math.Round(flying / 100, 2)}</font>")}</font> <br>"
: $"<font class='fontSize-m' color='#FFFFFF'>{player.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>"
) : "";
var hudContent = infoLine + skillLine + remainingLine;

View file

@ -44,7 +44,7 @@ namespace jRandomSkills
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);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{player.GetTranslation("paweljumper")}{ChatColors.Lime}: " + player.GetTranslation("paweljumper_desc2", extraJumps), false);
}
private static void GiveAdditionalJump(CCSPlayerController player)

View file

@ -27,7 +27,7 @@ namespace jRandomSkills
{
player.Respawn();
Instance.AddTimer(.2f, () => player.Respawn());
SkillUtils.PrintToChat(player, Localization.GetTranslation("phoenix_respawn"), false); ;
SkillUtils.PrintToChat(player, player.GetTranslation("phoenix_respawn"), false); ;
}
}
}
@ -40,7 +40,7 @@ namespace jRandomSkills
playerInfo.SkillChance = newChance;
newChance = (float)Math.Round(newChance, 2) * 100;
newChance = (float)Math.Round(newChance);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{Localization.GetTranslation("phoenix")}{ChatColors.Lime}: " + Localization.GetTranslation("phoenix_desc2", newChance), false);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{player.GetTranslation("phoenix")}{ChatColors.Lime}: " + player.GetTranslation("phoenix_desc2", newChance), false);
}
private static bool IsDeadPlayerValid(CCSPlayerController player)

View file

@ -71,9 +71,9 @@ namespace jRandomSkills
if (skillData == null) return;
string fuelColor = GetFuelColor(pilotInfo.Fuel);
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
string remainingLine = $"<font class='fontSize-m' color='#ffffff'>{Localization.GetTranslation("pilot_hud_info")}:</font> <font color='{fuelColor}'>{(pilotInfo.Fuel/maximumFuel)*100:F0}%</font> <br>";
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{player.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{player.GetSkillName(skillData.Skill)}</font> <br>";
string remainingLine = $"<font class='fontSize-m' color='#ffffff'>{player.GetTranslation("pilot_hud_info")}:</font> <font color='{fuelColor}'>{(pilotInfo.Fuel/maximumFuel)*100:F0}%</font> <br>";
var hudContent = infoLine + skillLine + remainingLine;
player.PrintToCenterHtml(hudContent);

View file

@ -43,7 +43,7 @@ namespace jRandomSkills
if (!Instance.IsPlayerValid(player)) continue;
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill == skillName)
if (playerInfo?.Skill == skillName && Instance?.GameRules?.FreezePeriod == false)
Schema.SetSchemaValue<bool>(player!.PlayerPawn.Value!.Handle, "CCSPlayerPawn", "m_bInBombZone", true);
}
}

View file

@ -58,7 +58,7 @@ namespace jRandomSkills
if (playerInfo.SkillChance == 1)
{
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("areareaper_used_info")}");
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("areareaper_used_info")}");
return;
}
@ -67,14 +67,14 @@ namespace jRandomSkills
if (enemy == null)
{
player.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("selectplayerskill_incorrect_enemy_index"));
player.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("selectplayerskill_incorrect_enemy_index"));
return;
}
poisonedPlayers.Add(enemy);
playerInfo.SkillChance = 1;
player.PrintToChat($" {ChatColors.Green}" + Localization.GetTranslation("poison_player_info", enemy.PlayerName));
enemy.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("poison_enemy_info"));
player.PrintToChat($" {ChatColors.Green}" + player.GetTranslation("poison_player_info", enemy.PlayerName));
enemy.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("poison_enemy_info"));
}
public static void EnableSkill(CCSPlayerController player)
@ -90,7 +90,7 @@ namespace jRandomSkills
SkillUtils.CreateMenu(player, menuItems);
}
else
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
}
public static void DisableSkill(CCSPlayerController player)

View file

@ -62,7 +62,7 @@ namespace jRandomSkills
if (playerInfo.SkillChance == 1)
{
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("areareaper_used_info")}");
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("areareaper_used_info")}");
return;
}
@ -71,15 +71,15 @@ namespace jRandomSkills
if (enemy == null)
{
player.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("selectplayerskill_incorrect_enemy_index"));
player.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("selectplayerskill_incorrect_enemy_index"));
return;
}
bannedPlayers.Add(enemy.SteamID);
CheckWeapon(enemy);
playerInfo.SkillChance = 1;
player.PrintToChat($" {ChatColors.Green}" + Localization.GetTranslation("primaryban_player_info", enemy.PlayerName));
enemy.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("primaryban_enemy_info"));
player.PrintToChat($" {ChatColors.Green}" + player.GetTranslation("primaryban_player_info", enemy.PlayerName));
enemy.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("primaryban_enemy_info"));
}
private static void CheckWeapon(CCSPlayerController player)
@ -105,7 +105,7 @@ namespace jRandomSkills
SkillUtils.CreateMenu(player, menuItems);
}
else
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
}
public static void DisableSkill(CCSPlayerController player)

View file

@ -112,9 +112,9 @@ namespace jRandomSkills
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == skillName);
if (skillData == null) return;
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
string remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{Localization.GetTranslation("psychicdefusing_hud_info", $"<font color='#00d5ff'>{cooldown}</font>")}</font> <br>" : "";
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{player.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{player.GetSkillName(skillData.Skill)}</font> <br>";
string remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{player.GetTranslation("psychicdefusing_hud_info", $"<font color='#00d5ff'>{cooldown}</font>")}</font> <br>" : "";
var hudContent = infoLine + skillLine + remainingLine;
player.PrintToCenterHtml(hudContent);

View file

@ -42,7 +42,7 @@ namespace jRandomSkills
playerInfo.SkillChance = newChance;
newChance = (float)Math.Round(newChance, 2) * 100;
newChance = (float)Math.Round(newChance);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{Localization.GetTranslation("push")}{ChatColors.Lime}: " + Localization.GetTranslation("push_desc2", newChance), false);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{player.GetTranslation("push")}{ChatColors.Lime}: " + player.GetTranslation("push_desc2", newChance), false);
}
private static void PushEnemy(CCSPlayerController player, QAngle attackerAngle)

View file

@ -9,8 +9,8 @@ namespace jRandomSkills
public class Rambo : ISkill
{
private const Skills skillName = Skills.Rambo;
private static int minExtraHealth = Config.GetValue<int>(skillName, "minExtraHealth");
private static int maxExtraHealth = Config.GetValue<int>(skillName, "maxExtraHealth");
private static readonly int minExtraHealth = Config.GetValue<int>(skillName, "minExtraHealth");
private static readonly int maxExtraHealth = Config.GetValue<int>(skillName, "maxExtraHealth");
public static void LoadSkill()
{
@ -52,15 +52,10 @@ namespace jRandomSkills
Utilities.SetStateChanged(pawn, "CBaseEntity", "m_iHealth");
}
public class SkillConfig : Config.DefaultSkillInfo
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#009905", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int minExtraHealth = 50, int maxExtraHealth = 501) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
{
public int MinExtraHealth { get; set; }
public int MaxExtraHealth { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#009905", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int minExtraHealth = 50, int maxExtraHealth = 501) : base(skill, active, color, onlyTeam, needsTeammates)
{
MinExtraHealth = minExtraHealth;
MaxExtraHealth = maxExtraHealth;
}
public int MinExtraHealth { get; set; } = minExtraHealth;
public int MaxExtraHealth { get; set; } = maxExtraHealth;
}
}
}

View file

@ -73,9 +73,9 @@ namespace jRandomSkills
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == skillName);
if (skillData == null) return;
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
string remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{Localization.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>" : "";
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{player.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{player.GetSkillName(skillData.Skill)}</font> <br>";
string remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{player.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>" : "";
var hudContent = infoLine + skillLine + remainingLine;
player.PrintToCenterHtml(hudContent);

View file

@ -80,9 +80,9 @@ namespace jRandomSkills
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == skillName);
if (skillData == null) return;
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
string remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{Localization.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>" : "";
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{player.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{player.GetSkillName(skillData.Skill)}</font> <br>";
string remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{player.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>" : "";
var hudContent = infoLine + skillLine + remainingLine;
player.PrintToCenterHtml(hudContent);

View file

@ -65,9 +65,9 @@ namespace jRandomSkills
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == skillName);
if (skillData == null) return;
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
string remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{Localization.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>" : "";
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{player.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{player.GetSkillName(skillData.Skill)}</font> <br>";
string remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{player.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>" : "";
var hudContent = infoLine + skillLine + remainingLine;
player.PrintToCenterHtml(hudContent);

View file

@ -64,9 +64,9 @@ namespace jRandomSkills
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == skillName);
if (skillData == null) return;
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
string remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{Localization.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>" : "";
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{player.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{player.GetSkillName(skillData.Skill)}</font> <br>";
string remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{player.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>" : "";
var hudContent = infoLine + skillLine + remainingLine;
player.PrintToCenterHtml(hudContent);

View file

@ -50,6 +50,8 @@ namespace jRandomSkills
public static void DisableSkill(CCSPlayerController player)
{
secondLifePlayers.Remove(player.Handle);
if (player.PlayerPawn.Value == null) return;
SetHealth(player, Math.Min(player.PlayerPawn.Value.Health + secondLifeHealth, 100));
}
private static void SetHealth(CCSPlayerController player, int health)
@ -58,9 +60,7 @@ namespace jRandomSkills
if (pawn == null || !pawn.IsValid) return;
pawn.Health = health;
pawn.MaxHealth = health;
Utilities.SetStateChanged(pawn, "CBaseEntity", "m_iHealth");
Utilities.SetStateChanged(pawn, "CBaseEntity", "m_iMaxHealth");
pawn.ArmorValue = 0;
Utilities.SetStateChanged(pawn, "CCSPlayerPawn", "m_ArmorValue");

View file

@ -59,9 +59,9 @@ namespace jRandomSkills
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == skillName);
if (skillData == null) return;
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
string remainingLine = $"<font class='fontSize-m' color='#FF0000'>{Localization.GetTranslation("shade_nospace")}</font> <br>";
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{player.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{player.GetSkillName(skillData.Skill)}</font> <br>";
string remainingLine = $"<font class='fontSize-m' color='#FF0000'>{player.GetTranslation("shade_nospace")}</font> <br>";
var hudContent = infoLine + skillLine + remainingLine;
player.PrintToCenterHtml(hudContent);
}

View file

@ -9,6 +9,7 @@ namespace jRandomSkills
public class SniperElite : ISkill
{
private const Skills skillName = Skills.SniperElite;
private static readonly Dictionary<ulong, List<CEntityInstance>> playerAWPs = [];
private static readonly Dictionary<ulong, string> sniperElites = [];
private static readonly string[] rifles = [ "weapon_mp9", "weapon_mac10", "weapon_bizon", "weapon_mp7", "weapon_ump45", "weapon_p90",
@ -24,6 +25,7 @@ namespace jRandomSkills
public static void NewRound()
{
sniperElites.Clear();
playerAWPs.Clear();
}
public static void PlayerDeath(EventPlayerDeath @event)
@ -32,18 +34,27 @@ namespace jRandomSkills
if (player == null || !player.IsValid) return;
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill == skillName)
sniperElites.Remove(player.SteamID);
DisableSkill(player);
}
public static void WeaponEquip(EventItemEquip @event)
{
var player = @event.Userid;
if (player == null || !player.IsValid) return;
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill == skillName)
DeleteDroppedAWP(player);
}
public static void EnableSkill(CCSPlayerController player)
{
sniperElites.Add(player.SteamID, "weapon_awp");
sniperElites.TryAdd(player.SteamID, "weapon_awp");
}
public static void DisableSkill(CCSPlayerController player)
{
sniperElites.Remove(player.SteamID);
playerAWPs.Remove(player.SteamID);
}
public static void UseSkill(CCSPlayerController player)
@ -64,18 +75,58 @@ namespace jRandomSkills
try
{
string? activeRifle = GetActiveRifle(player);
if (!string.IsNullOrEmpty(activeRifle))
player.RemoveItemByDesignerName(activeRifle, true);
sniperElites[player.SteamID] = activeRifle ?? "weapon_awp";
Server.NextFrame(() => player.GiveNamedItem(holdedWeapon ?? "weapon_awp") );
CBasePlayerWeapon? activeRifle = GetActiveRifle(player);
if (activeRifle != null && activeRifle.IsValid)
RemoveWeapon(player, activeRifle.DesignerName);
sniperElites[player.SteamID] = (activeRifle != null && activeRifle.IsValid) ? SkillUtils.GetDesignerName(activeRifle) : "weapon_awp";
Server.NextFrame(() => {
string weapon = holdedWeapon ?? "weapon_awp";
if (player == null || !player.IsValid || player.PlayerPawn.Value == null || !player.PlayerPawn.Value.IsValid) return;
var createdWeapon = player.PlayerPawn.Value?.ItemServices?.As<CCSPlayer_ItemServices>().GiveNamedItem<CEntityInstance>(weapon);
if (createdWeapon != null && createdWeapon.IsValid && createdWeapon.DesignerName == "weapon_awp")
{
if (playerAWPs.TryGetValue(player.SteamID, out List<CEntityInstance>? value))
value.Add(createdWeapon);
else
playerAWPs.Add(player.SteamID, [createdWeapon]);
}
DeleteDroppedAWP(player);
});
}
catch { }
}
private static string? GetActiveRifle(CCSPlayerController player)
private static void DeleteDroppedAWP(CCSPlayerController player)
{
string rifle = string.Empty;
var pawn = player.PlayerPawn.Value;
if (pawn == null || !pawn.IsValid) return;
var weaponServices = pawn.WeaponServices;
if (weaponServices == null) return;
List<uint> playerWeapons = weaponServices.MyWeapons.Where(w => w != null && w.IsValid && w.Value != null && w.Value.IsValid)
.Select(w => w.Value!.Index).ToList();
if (playerAWPs.TryGetValue(player.SteamID, out var AWPs))
foreach (var awp in AWPs.ToList())
{
if (awp != null && awp.IsValid)
{
if (!playerWeapons.Contains(awp.Index))
{
awp.AcceptInput("Kill");
AWPs.Remove(awp);
}
}
else
AWPs.Remove(awp!);
}
}
private static CBasePlayerWeapon? GetActiveRifle(CCSPlayerController player)
{
CBasePlayerWeapon? rifle = null;
var pawn = player.PlayerPawn.Value;
if (pawn == null || !pawn.IsValid) return rifle;
var weaponServices = pawn.WeaponServices;
@ -84,11 +135,21 @@ namespace jRandomSkills
foreach (var weapon in weaponServices.MyWeapons)
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
if (rifles.Contains(weapon.Value.DesignerName))
rifle = SkillUtils.GetDesignerName(weapon.Value);
rifle = weapon.Value;
return rifle;
}
private static void RemoveWeapon(CCSPlayerController player, string designerName)
{
var pawn = player.PlayerPawn.Value;
if (pawn == null || !pawn.IsValid || pawn.WeaponServices == null) return;
public class SkillConfig(Skills skill = skillName, bool active = false, string color = "#e0873a", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
foreach (var item in pawn.WeaponServices.MyWeapons)
if (item != null && item.IsValid && item.Value != null && item.Value.IsValid && item.Value.DesignerName == designerName)
item.Value.AcceptInput("Kill");
}
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#e0873a", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
{
}
}

View file

@ -23,7 +23,7 @@ namespace jRandomSkills
float newScale = (float)Instance.Random.NextDouble() * (Config.GetValue<float>(skillName, "ChanceTo") - Config.GetValue<float>(skillName, "ChanceFrom")) + Config.GetValue<float>(skillName, "ChanceFrom");
playerInfo.SkillChance = newScale;
newScale = (float)Math.Round(newScale, 2);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{Localization.GetTranslation("soldier")}{ChatColors.Lime}: " + Localization.GetTranslation("soldier_desc2", newScale), false);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{player.GetTranslation("soldier")}{ChatColors.Lime}: " + player.GetTranslation("soldier_desc2", newScale), false);
}
public static void OnTakeDamage(DynamicHook h)

View file

@ -73,9 +73,9 @@ namespace jRandomSkills
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == skillName);
if (skillData == null) return;
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
string remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{Localization.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>" : "";
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{player.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{player.GetSkillName(skillData.Skill)}</font> <br>";
string remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{player.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>" : "";
var hudContent = infoLine + skillLine + remainingLine;
player.PrintToCenterHtml(hudContent);

View file

@ -69,16 +69,16 @@ namespace jRandomSkills
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == skillName);
if (skillData == null) return;
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{player.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{player.GetSkillName(skillData.Skill)}</font> <br>";
string remainingLine = "";
if (showInfo)
remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{Localization.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>"
: skillInfo != null && !skillInfo.FindedEnemy ? $"<font class='fontSize-m' color='#FF0000'>{Localization.GetTranslation("hud_info_no_enemy")}</font> <br>"
remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{player.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>"
: skillInfo != null && !skillInfo.FindedEnemy ? $"<font class='fontSize-m' color='#FF0000'>{player.GetTranslation("hud_info_no_enemy")}</font> <br>"
: "";
else
remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{Localization.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>" : "";
remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{player.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>" : "";
var hudContent = infoLine + skillLine + remainingLine;
player.PrintToCenterHtml(hudContent);

View file

@ -13,7 +13,7 @@ namespace jRandomSkills
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"), false);
}
public static void OnTick()
@ -26,19 +26,17 @@ namespace jRandomSkills
if (playerInfo == null || playerInfo.Skill != skillName) continue;
var enemies = Utilities.GetPlayers().Where(p => p.PawnIsAlive && p.Team != player.Team && p.IsValid && !p.IsBot && !p.IsHLTV && p.Team != CsTeam.Spectator && p.Team != CsTeam.None).ToArray();
if (enemies.Length > 0)
HashSet<(string, string)> menuItems = [];
foreach (var enemy in enemies)
{
HashSet<(string, string)> menuItems = [];
foreach (var enemy in enemies)
{
var enemyInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == enemy.SteamID);
if (enemyInfo == null) continue;
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == enemyInfo.Skill);
if (skillData == null) continue;
menuItems.Add(($"{enemy.PlayerName} : {skillData.Name}", enemy.Index.ToString()));
}
SkillUtils.CreateMenu(player, menuItems);
var enemyInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == enemy.SteamID);
if (enemyInfo == null) continue;
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == enemyInfo.Skill);
if (skillData == null) continue;
menuItems.Add(($"{enemy.PlayerName} : {player.GetSkillName(skillData.Skill)}", enemy.Index.ToString()));
}
SkillUtils.UpdateMenu(player, menuItems);
}
}
@ -64,7 +62,7 @@ namespace jRandomSkills
if (enemy == null)
{
player.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("selectplayerskill_incorrect_enemy_index"));
player.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("selectplayerskill_incorrect_enemy_index"));
return;
}
@ -76,6 +74,7 @@ namespace jRandomSkills
var enemies = Utilities.GetPlayers().Where(p => p.PawnIsAlive && p.Team != player.Team && p.IsValid && !p.IsBot && !p.IsHLTV && p.Team != CsTeam.Spectator && p.Team != CsTeam.None).ToArray();
if (enemies.Length > 0)
{
List<string> skills = [];
HashSet<(string, string)> menuItems = [];
foreach (var enemy in enemies)
{
@ -83,12 +82,23 @@ namespace jRandomSkills
if (enemyInfo == null) continue;
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == enemyInfo.Skill);
if (skillData == null) continue;
menuItems.Add(($"{enemy.PlayerName} : {skillData.Name}", enemy.Index.ToString()));
skills.Add(skillData.Skill.ToString());
menuItems.Add(($"{enemy.PlayerName} : {player.GetSkillName(skillData.Skill)}", enemy.Index.ToString()));
}
int ctSkills = Event.counterterroristSkills.Count(s => skills.Contains(s.Name));
int ttSkills = Event.terroristSkills.Count(s => skills.Contains(s.Name));
if ((player.Team == CsTeam.Terrorist && ctSkills == skills.Count) || (player.Team == CsTeam.CounterTerrorist && ttSkills == skills.Count))
{
Event.SetRandomSkill(player);
return;
}
SkillUtils.CreateMenu(player, menuItems);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{player.GetSkillName(skillName)}{ChatColors.Lime}: {player.GetSkillDescription(skillName)}", false);
}
else
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
}
public static void DisableSkill(CCSPlayerController player)
@ -104,29 +114,38 @@ namespace jRandomSkills
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
var enemyInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == enemy.SteamID);
if (playerInfo == null || enemyInfo == null) return;
var enemySkill = enemyInfo.Skill;
bool ctSkill = Event.counterterroristSkills.Any(s => s.Name == enemySkill.ToString());
bool ttSkill = Event.terroristSkills.Any(s => s.Name == enemySkill.ToString());
if (playerInfo != null)
if ((player.Team == CsTeam.Terrorist && ctSkill) || (player.Team == CsTeam.CounterTerrorist && ttSkill))
{
Instance.AddTimer(.1f, () =>
{
playerInfo.Skill = enemySkill;
playerInfo.SpecialSkill = skillName;
Instance.SkillAction(enemySkill.ToString(), "EnableSkill", [player]);
player.PrintToChat($" {ChatColors.Green}" + Localization.GetTranslation("thief_player_info", enemy.PlayerName));
Instance.SkillAction(skillName.ToString(), "EnableSkill", [player]);
player.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("thief_incorrect_skill", enemy.PlayerName));
});
return;
}
if (enemyInfo != null)
SkillUtils.CloseMenu(player);
Instance.AddTimer(.1f, () =>
{
Instance.AddTimer(.1f, () =>
{
Instance.SkillAction(enemySkill.ToString(), "DisableSkill", [enemy]);
enemyInfo.SpecialSkill = enemySkill;
enemyInfo.Skill = Skills.None;
enemy.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("thief_enemy_info"));
});
}
playerInfo.Skill = enemySkill;
playerInfo.SpecialSkill = skillName;
SkillUtils.CloseMenu(player);
Instance.SkillAction(enemySkill.ToString(), "EnableSkill", [player]);
player.PrintToChat($" {ChatColors.Green}" + player.GetTranslation("thief_player_info", enemy.PlayerName));
});
Instance.AddTimer(.1f, () =>
{
Instance.SkillAction(enemySkill.ToString(), "DisableSkill", [enemy]);
enemyInfo.SpecialSkill = enemySkill;
enemyInfo.Skill = Skills.None;
enemy.PrintToChat($" {ChatColors.Red}" + player.GetTranslation("thief_enemy_info"));
});
}
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#adaec7", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)

View file

@ -53,10 +53,20 @@ namespace jRandomSkills
public static void EnableSkill(CCSPlayerController player)
{
Event.enableTransmit = true;
SkillUtils.EnableTransmit();
SetGlowEffectForEnemies(player);
}
public static void DisableSkill(CCSPlayerController player)
{
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo == null) return;
playerInfo.Skill = Skills.None;
if (!Instance.SkillPlayer.Any(s => s.Skill == skillName))
NewRound();
}
private static void SetGlowEffectForEnemies(CCSPlayerController player)
{
CsTeam originalTeam = player.Team;

View file

@ -47,9 +47,9 @@ namespace jRandomSkills
Instance.GameRules.RoundTime += player.Team == CsTeam.Terrorist ? roundTime : -roundTime;
if (player.Team == CsTeam.Terrorist)
Server.PrintToChatAll($" {ChatColors.Orange}{Localization.GetTranslation("watchmaker_tt", roundTime)}");
Localization.PrintTranslationToChatAll($" {ChatColors.Orange}{{0}}", ["watchmaker_tt"], [roundTime]);
else
Server.PrintToChatAll($" {ChatColors.LightBlue}{Localization.GetTranslation("watchmaker_ct", roundTime)}");
Localization.PrintTranslationToChatAll($" {ChatColors.LightBlue}{{0}}", ["watchmaker_ct"], [roundTime]);
}
public static void OnTick()
@ -70,8 +70,8 @@ namespace jRandomSkills
int seconds = 1 + (int)(Instance.GameRules.RoundTime - (Server.CurrentTime - Instance.GameRules.RoundStartTime));
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{player.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{player.GetSkillName(skillData.Skill)}</font> <br>";
string remainingLine = $"<font class='fontSize-m' color='#FFFFFF'>{SkillUtils.SecondsToTimer(seconds)}</font> <br>";
var hudContent = infoLine + skillLine + remainingLine;

View file

@ -77,17 +77,17 @@ namespace jRandomSkills
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == skillName);
if (skillData == null) return;
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{player.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{player.GetSkillName(skillData.Skill)}</font> <br>";
string remainingLine = "";
if (showInfo)
remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{Localization.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>"
: skillInfo != null && !skillInfo.FindedEnemy ? $"<font class='fontSize-m' color='#FF0000'>{Localization.GetTranslation("hud_info_no_enemy")}</font> <br>"
: skillInfo != null && !skillInfo.HaveWeapon ? $"<font class='fontSize-m' color='#FF0000'>{Localization.GetTranslation("weaponsswap_hud_info2")}</font> <br>"
remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{player.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>"
: skillInfo != null && !skillInfo.FindedEnemy ? $"<font class='fontSize-m' color='#FF0000'>{player.GetTranslation("hud_info_no_enemy")}</font> <br>"
: skillInfo != null && !skillInfo.HaveWeapon ? $"<font class='fontSize-m' color='#FF0000'>{player.GetTranslation("weaponsswap_hud_info2")}</font> <br>"
: "";
else
remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{Localization.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>" : "";
remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{player.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>" : "";
var hudContent = infoLine + skillLine + remainingLine;
player.PrintToCenterHtml(hudContent);
@ -127,10 +127,16 @@ namespace jRandomSkills
skillInfo.CanUse = false;
skillInfo.Cooldown = DateTime.Now;
player.RemoveWeapons();
enemy.RemoveWeapons();
GiveWeapons(player, enemyWeapon, playerWeapon.Contains("weapon_c4"));
GiveWeapons(enemy, playerWeapon, (enemyWeapon != null && enemyWeapon.Contains("weapon_c4")));
RemoveC4(player);
RemoveC4(enemy);
Server.NextFrame(() =>
{
player.RemoveWeapons();
enemy.RemoveWeapons();
GiveWeapons(player, enemyWeapon, playerWeapon.Contains("weapon_c4"));
GiveWeapons(enemy, playerWeapon, (enemyWeapon != null && enemyWeapon.Contains("weapon_c4")));
});
}
else
skillInfo.LastClick = DateTime.Now;
@ -167,6 +173,16 @@ namespace jRandomSkills
return enemies[Instance.Random.Next(enemies.Length)];
}
private static void RemoveC4(CCSPlayerController player)
{
var pawn = player.PlayerPawn.Value;
if (pawn == null || !pawn.IsValid || pawn.WeaponServices == null) return;
foreach (var item in pawn.WeaponServices.MyWeapons)
if (item != null && item.IsValid && item.Value != null && item.Value.IsValid && item.Value.DesignerName == "weapon_c4")
item.Value.AcceptInput("Kill");
}
public class PlayerSkillInfo
{
public ulong SteamID { get; set; }