diff --git a/jRandomSkills - SRC Files/src/jRandomSkills.cs b/jRandomSkills - SRC Files/src/jRandomSkills.cs index b06e06f..bed51d3 100644 --- a/jRandomSkills - SRC Files/src/jRandomSkills.cs +++ b/jRandomSkills - SRC Files/src/jRandomSkills.cs @@ -28,7 +28,7 @@ namespace src public override string ModuleName => "[CS2] [ jRandomSkills ]"; public override string ModuleAuthor => "D3X, Juzlus"; public override string ModuleDescription => "Plugin adds random skills every round for CS2 by D3X. Modified by Juzlus."; - public override string ModuleVersion => "1.2.1.b3"; + public override string ModuleVersion => "1.2.1.b4"; public override void Load(bool hotReload) { @@ -197,7 +197,7 @@ namespace src Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.Cyan; Console.Write(", SkillButton: "); Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.LightBlue; - Console.Write(Config.LoadedConfig.AlternativeSkillButton); + Console.Write(Config.LoadedConfig.AlternativeSkillButton ?? "(NULL)"); Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.Cyan; Console.Write(", HtmlHudFix: "); @@ -239,7 +239,7 @@ namespace src foreach (Skills skill in Enum.GetValues(typeof(Skills))) if (skill.ToString() == "None") continue; - else if (SkillsInfo.GetValue(skill, "active")) + else if (SkillData.Skills.Any(s => s.Skill == skill)) enabled.Add(skill); else disabled.Add(skill); diff --git a/jRandomSkills - SRC Files/src/lang/en.json b/jRandomSkills - SRC Files/src/lang/en.json index e91eed4..d55af0b 100644 --- a/jRandomSkills - SRC Files/src/lang/en.json +++ b/jRandomSkills - SRC Files/src/lang/en.json @@ -523,5 +523,7 @@ "wildthrow_select_info": "Select a player:", "throwingknife": "Throwing Knife", - "throwingknife_desc": "Click [css_useSkill] to throw a knife. But watch out for others" + "throwingknife_desc": "Click [css_useSkill] to throw a knife. But watch out for others", + + "planter_planting": "Planting ({0})..." } \ No newline at end of file diff --git a/jRandomSkills - SRC Files/src/player/skills/ChillOut.cs b/jRandomSkills - SRC Files/src/player/skills/ChillOut.cs index 6850385..4db5405 100644 --- a/jRandomSkills - SRC Files/src/player/skills/ChillOut.cs +++ b/jRandomSkills - SRC Files/src/player/skills/ChillOut.cs @@ -87,7 +87,6 @@ namespace src.player.skills { float remaining = plantTime + extraTime - currentTime; playerInfo.PrintHTML = $"{player.GetTranslation("planter_planting", $"{Math.Max(0, remaining):0.0}s")}"; - player.PrintToCenter(""); } } } diff --git a/jRandomSkills - SRC Files/src/player/skills/Hermit.cs b/jRandomSkills - SRC Files/src/player/skills/Hermit.cs index 5421c9a..214b98d 100644 --- a/jRandomSkills - SRC Files/src/player/skills/Hermit.cs +++ b/jRandomSkills - SRC Files/src/player/skills/Hermit.cs @@ -12,15 +12,15 @@ namespace src.player.skills private const Skills skillName = Skills.Hermit; private static readonly ConcurrentDictionary ConcurrentDictionary = new( [ - new KeyValuePair("weapon_glock", 120), new KeyValuePair("weapon_usp_silencer", 24), new KeyValuePair("weapon_hkp2000", 52), new KeyValuePair("weapon_p250", 26), - new KeyValuePair("weapon_cz75", 12), new KeyValuePair("weapon_deagle", 35), new KeyValuePair("weapon_fiveseven", 100), new KeyValuePair("weapon_elite", 120), - new KeyValuePair("weapon_tec9", 90), new KeyValuePair("weapon_revolver", 8), new KeyValuePair("weapon_mac10", 100), new KeyValuePair("weapon_mp9", 120), - new KeyValuePair("weapon_mp7", 120), new KeyValuePair("weapon_mp5", 120), new KeyValuePair("weapon_mp5sd", 120), new KeyValuePair("weapon_ump45", 100), - new KeyValuePair("weapon_p90", 100), new KeyValuePair("weapon_bizon", 120), new KeyValuePair("weapon_ak47", 90), new KeyValuePair("weapon_m4a1", 90), - new KeyValuePair("weapon_m4a1_silencer", 80), new KeyValuePair("weapon_galilar", 90), new KeyValuePair("weapon_famas", 90), new KeyValuePair("weapon_aug", 90), - new KeyValuePair("weapon_sg556", 90), new KeyValuePair("weapon_ssg08", 90), new KeyValuePair("weapon_awp", 30), new KeyValuePair("weapon_scar20", 90), - new KeyValuePair("weapon_g3sg1", 90), new KeyValuePair("weapon_nova", 32), new KeyValuePair("weapon_xm1014", 32), new KeyValuePair("weapon_sawedoff", 32), - new KeyValuePair("weapon_mag7", 32), new KeyValuePair("weapon_m249", 200), new KeyValuePair("weapon_negev", 300) + new KeyValuePair("weapon_glock", 3), new KeyValuePair("weapon_usp_silencer", 2), new KeyValuePair("weapon_hkp2000", 4), new KeyValuePair("weapon_p250", 3), + new KeyValuePair("weapon_cz75", 2), new KeyValuePair("weapon_deagle", 3), new KeyValuePair("weapon_fiveseven", 2), new KeyValuePair("weapon_elite", 2), + new KeyValuePair("weapon_tec9", 3), new KeyValuePair("weapon_revolver", 2), new KeyValuePair("weapon_mac10", 3), new KeyValuePair("weapon_mp9", 2), + new KeyValuePair("weapon_mp7", 3), new KeyValuePair("weapon_mp5", 3), new KeyValuePair("weapon_mp5sd", 3), new KeyValuePair("weapon_ump45", 3), + new KeyValuePair("weapon_p90", 2), new KeyValuePair("weapon_bizon", 2), new KeyValuePair("weapon_ak47", 3), new KeyValuePair("weapon_m4a1", 4), + new KeyValuePair("weapon_m4a1_silencer", 3), new KeyValuePair("weapon_galilar", 4), new KeyValuePair("weapon_famas", 4), new KeyValuePair("weapon_aug", 3), + new KeyValuePair("weapon_sg556", 3), new KeyValuePair("weapon_ssg08", 2), new KeyValuePair("weapon_awp", 2), new KeyValuePair("weapon_scar20", 2), + new KeyValuePair("weapon_g3sg1", 2), new KeyValuePair("weapon_nova", 32), new KeyValuePair("weapon_xm1014", 32), new KeyValuePair("weapon_sawedoff", 32), + new KeyValuePair("weapon_mag7", 3), new KeyValuePair("weapon_m249", 2), new KeyValuePair("weapon_negev", 2) ]); private static readonly ConcurrentDictionary maxReserveAmmo = ConcurrentDictionary; @@ -52,7 +52,7 @@ namespace src.player.skills SkillUtils.AddHealth(pawn, SkillsInfo.GetValue(skillName, "healthToAdd")); } - public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#ded678", CsTeam onlyTeam = CsTeam.None, bool disableOnFreezeTime = false, bool needsTeammates = false, string requiredPermission = "", int healthToAdd = 25) : SkillsInfo.DefaultSkillInfo(skill, active, color, onlyTeam, disableOnFreezeTime, needsTeammates, requiredPermission) + public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#ded678", CsTeam onlyTeam = CsTeam.None, bool disableOnFreezeTime = false, bool needsTeammates = false, string requiredPermission = "", int healthToAdd = 100) : SkillsInfo.DefaultSkillInfo(skill, active, color, onlyTeam, disableOnFreezeTime, needsTeammates, requiredPermission) { public int HealthToAdd { get; set; } = healthToAdd; } diff --git a/jRandomSkills - SRC Files/src/player/skills/Pilot.cs b/jRandomSkills - SRC Files/src/player/skills/Pilot.cs index ab67d81..49e196f 100644 --- a/jRandomSkills - SRC Files/src/player/skills/Pilot.cs +++ b/jRandomSkills - SRC Files/src/player/skills/Pilot.cs @@ -34,12 +34,7 @@ namespace src.player.skills public static void EnableSkill(CCSPlayerController player) { - PlayerPilotInfo.TryAdd(player.SteamID, new Pilot_PlayerInfo - { - SteamID = player.SteamID, - Fuel = SkillsInfo.GetValue(skillName, "maximumFuel"), - LastButtons = 0 - }); + PlayerPilotInfo.TryAdd(player.SteamID, new Pilot_PlayerInfo { SteamID = player.SteamID }); } public static void DisableSkill(CCSPlayerController player) @@ -57,29 +52,55 @@ namespace src.player.skills var flags = (PlayerFlags)playerPawn.Flags; var buttons = player.Buttons; + float currentTime = Server.CurrentTime; - bool isJumpDown = (playerPawn.MovementServices?.Buttons?.ButtonStates[0] & (ulong)PlayerButtons.Jump) != 0 || (buttons & PlayerButtons.Jump) != 0; + bool isJumpDown = (buttons & PlayerButtons.Jump) != 0 + || (playerPawn.MovementServices?.Buttons?.ButtonStates[0] & (ulong)PlayerButtons.Jump) != 0; bool wasJumpDown = (pilotInfo.LastButtons & PlayerButtons.Jump) != 0; - bool jumpPressed = (isJumpDown && !wasJumpDown) || (playerPawn.MovementServices?.QueuedButtonChangeMask & (ulong)PlayerButtons.Jump) != 0; - bool isOnGround = (flags & PlayerFlags.FL_ONGROUND) != 0; - bool inUse = jumpPressed && !isOnGround; - var maximumFuel = SkillsInfo.GetValue(skillName, "maximumFuel"); - pilotInfo.Fuel = Math.Min( - Math.Max( - 0, - pilotInfo.Fuel - (inUse - ? SkillsInfo.GetValue(skillName, "fuelConsumption") - : -SkillsInfo.GetValue(skillName, "refuelling"))), - maximumFuel); - pilotInfo.LastButtons = buttons; + if (jumpPressed && !isOnGround) + { + if (pilotInfo.JumpCount == 0) + pilotInfo.JumpCount++; + else + { + pilotInfo.JumpCount++; + pilotInfo.LastJumpTime = currentTime; - if (inUse && pilotInfo.Fuel > 0) + if (pilotInfo.JumpCount >= 2) + pilotInfo.IsFlying = true; + } + } + else if (!isJumpDown && currentTime - pilotInfo.LastJumpTime > .1f) + pilotInfo.IsFlying = false; + + if (isOnGround) + { + pilotInfo.IsFlying = false; + if (isOnGround) pilotInfo.JumpCount = 0; + } + + bool inUse = pilotInfo.IsFlying && pilotInfo.Fuel > 0 && !isOnGround; + + float maximumFuel = SkillsInfo.GetValue(skillName, "maximumFuel"); + float consumption = SkillsInfo.GetValue(skillName, "fuelConsumption"); + float refuelling = SkillsInfo.GetValue(skillName, "refuelling"); + + pilotInfo.Fuel = Math.Clamp( + pilotInfo.Fuel + (inUse ? -consumption : refuelling), + 0, + maximumFuel + ); + + if (inUse) ApplyPilotEffect(player); + else if (pilotInfo.Fuel <= 0) + pilotInfo.IsFlying = false; + pilotInfo.LastButtons = buttons; UpdateHUD(player, pilotInfo); } @@ -141,9 +162,12 @@ namespace src.player.skills public class Pilot_PlayerInfo { - public ulong SteamID { get; set; } - public float Fuel { get; set; } - public PlayerButtons LastButtons { get; set; } + public required ulong SteamID { get; set; } + public float Fuel { get; set; } = SkillsInfo.GetValue(skillName, "maximumFuel"); + public PlayerButtons LastButtons { get; set; } = 0; + public int JumpCount { get; set; } = 0; + public float LastJumpTime { get; set; } = 0; + public bool IsFlying { get; set; } = false; } public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#1466F5", CsTeam onlyTeam = CsTeam.None, bool disableOnFreezeTime = true, bool needsTeammates = false, string requiredPermission = "", float maximumFuel = 150f, float fuelConsumption = .64f, float refuelling = .1f) : SkillsInfo.DefaultSkillInfo(skill, active, color, onlyTeam, disableOnFreezeTime, needsTeammates, requiredPermission) diff --git a/jRandomSkills - SRC Files/src/player/skills/Planter.cs b/jRandomSkills - SRC Files/src/player/skills/Planter.cs index 1697e03..d4cca24 100644 --- a/jRandomSkills - SRC Files/src/player/skills/Planter.cs +++ b/jRandomSkills - SRC Files/src/player/skills/Planter.cs @@ -47,7 +47,7 @@ namespace src.player.skills if (plantedBomb != null) Server.NextFrame(() => plantedBomb.C4Blow = Server.CurrentTime + SkillsInfo.GetValue(skillName, "extraC4BlowTime")); - foreach (var p in Utilities.GetPlayers().Where(p => p.IsValid && p.PawnIsAlive)) + foreach (var p in Utilities.GetPlayers().Where(p => p.IsValid)) p.PrintToCenterAlert(p.GetTranslation("bombplanted", SkillsInfo.GetValue(skillName, "extraC4BlowTime"))); } @@ -94,7 +94,7 @@ namespace src.player.skills { float remaining = plantTime + 3f - currentTime; playerInfo.PrintHTML = $"{player.GetTranslation("planter_planting", $"{Math.Max(0, remaining):0.0}s")}"; - player.PrintToCenter(""); + player.PrintToCenter(" "); } } } diff --git a/jRandomSkills - SRC Files/src/player/skills/PsychicDefusing.cs b/jRandomSkills - SRC Files/src/player/skills/PsychicDefusing.cs index b27667b..9c1451a 100644 --- a/jRandomSkills - SRC Files/src/player/skills/PsychicDefusing.cs +++ b/jRandomSkills - SRC Files/src/player/skills/PsychicDefusing.cs @@ -4,6 +4,7 @@ using CounterStrikeSharp.API.Modules.Utils; using static src.jRandomSkills; using System.Collections.Concurrent; using src.utils; +using CounterStrikeSharp.API.Modules.Entities.Constants; namespace src.player.skills { diff --git a/jRandomSkills - SRC Files/src/player/skills/ShortBomb.cs b/jRandomSkills - SRC Files/src/player/skills/ShortBomb.cs index f553380..a38f4e4 100644 --- a/jRandomSkills - SRC Files/src/player/skills/ShortBomb.cs +++ b/jRandomSkills - SRC Files/src/player/skills/ShortBomb.cs @@ -27,7 +27,7 @@ namespace src.player.skills if (plantedBomb != null) Server.NextFrame(() => plantedBomb.C4Blow = Server.CurrentTime + SkillsInfo.GetValue(skillName, "detonationTime")); - foreach (var p in Utilities.GetPlayers().Where(p => p.IsValid && p.PawnIsAlive)) + foreach (var p in Utilities.GetPlayers().Where(p => p.IsValid)) p.PrintToCenterAlert(p.GetTranslation("bombplanted", SkillsInfo.GetValue(skillName, "detonationTime"))); } diff --git a/jRandomSkills - SRC Files/src/player/skills/ToxicSmoke.cs b/jRandomSkills - SRC Files/src/player/skills/ToxicSmoke.cs index 25d1b5a..b0cfc08 100644 --- a/jRandomSkills - SRC Files/src/player/skills/ToxicSmoke.cs +++ b/jRandomSkills - SRC Files/src/player/skills/ToxicSmoke.cs @@ -1,7 +1,6 @@ using CounterStrikeSharp.API; using CounterStrikeSharp.API.Core; using CounterStrikeSharp.API.Modules.Entities.Constants; -using CounterStrikeSharp.API.Modules.Memory; using CounterStrikeSharp.API.Modules.Utils; using src.utils; using System.Collections.Concurrent; diff --git a/jRandomSkills - SRC Files/src/utils/SkillUtils.cs b/jRandomSkills - SRC Files/src/utils/SkillUtils.cs index 3dbdc33..dbc5fc0 100644 --- a/jRandomSkills - SRC Files/src/utils/SkillUtils.cs +++ b/jRandomSkills - SRC Files/src/utils/SkillUtils.cs @@ -162,12 +162,12 @@ namespace src.utils ? "info_player_counterterrorist" : "info_player_terrorist"; - var spawns = Utilities.FindAllEntitiesByDesignerName(spawnPointName).ToList(); + var spawns = Utilities.FindAllEntitiesByDesignerName(spawnPointName).Where(s => s.IsValid && s.Enabled).ToList(); if (spawns.Count != 0) { var randomSpawn = spawns[jRandomSkills.Instance.Random.Next(spawns.Count)]; if (randomSpawn != null && randomSpawn.IsValid && randomSpawn.AbsOrigin != null) - return randomSpawn.AbsOrigin; + return new Vector(randomSpawn.AbsOrigin.X, randomSpawn.AbsOrigin.Y, randomSpawn.AbsOrigin.Z); } return null; } @@ -415,7 +415,8 @@ namespace src.utils short tScore = (short)(winnerTeam == CsTeam.Terrorist ? tTeams.Score + 1 : tTeams.Score); UpdateServerTeamScores(ctScore, tScore); - TerminateRoundFunc.Invoke(jRandomSkills.Instance.GameRules.Handle, 5f, winnerTeam == CsTeam.CounterTerrorist ? RoundEndReason.BombDefused : RoundEndReason.TargetBombed, 0, 0); + jRandomSkills.Instance.GameRules?.TerminateRound(5f, winnerTeam == CsTeam.CounterTerrorist ? RoundEndReason.BombDefused : RoundEndReason.TargetBombed); + // TerminateRoundFunc.Invoke(jRandomSkills.Instance.GameRules.Handle, 5f, winnerTeam == CsTeam.CounterTerrorist ? RoundEndReason.BombDefused : RoundEndReason.TargetBombed, 0, 0); } private static void UpdateServerTeamScores(short ctScore, short tScore) diff --git a/jRandomSkills - Server Files/plugins/jRandomSkills/WASDMenuAPI.dll b/jRandomSkills - Server Files/plugins/jRandomSkills/WASDMenuAPI.dll index ae4e502..683217e 100644 Binary files a/jRandomSkills - Server Files/plugins/jRandomSkills/WASDMenuAPI.dll and b/jRandomSkills - Server Files/plugins/jRandomSkills/WASDMenuAPI.dll differ diff --git a/jRandomSkills - Server Files/plugins/jRandomSkills/jRandomSkills.dll b/jRandomSkills - Server Files/plugins/jRandomSkills/jRandomSkills.dll index 0ad5188..9c3bce8 100644 Binary files a/jRandomSkills - Server Files/plugins/jRandomSkills/jRandomSkills.dll and b/jRandomSkills - Server Files/plugins/jRandomSkills/jRandomSkills.dll differ diff --git a/jRandomSkills - Server Files/plugins/jRandomSkills/languages/en.json b/jRandomSkills - Server Files/plugins/jRandomSkills/languages/en.json index e91eed4..d55af0b 100644 --- a/jRandomSkills - Server Files/plugins/jRandomSkills/languages/en.json +++ b/jRandomSkills - Server Files/plugins/jRandomSkills/languages/en.json @@ -523,5 +523,7 @@ "wildthrow_select_info": "Select a player:", "throwingknife": "Throwing Knife", - "throwingknife_desc": "Click [css_useSkill] to throw a knife. But watch out for others" + "throwingknife_desc": "Click [css_useSkill] to throw a knife. But watch out for others", + + "planter_planting": "Planting ({0})..." } \ No newline at end of file