using CounterStrikeSharp.API; using CounterStrikeSharp.API.Modules.Utils; using src.utils; using static src.jRandomSkills; namespace src.player.skills { public class Regeneration : ISkill { private const Skills skillName = Skills.Regeneration; public static void LoadSkill() { SkillUtils.RegisterSkill(skillName, SkillsInfo.GetValue(skillName, "color")); } public static void OnTick() { int cooldown = Math.Max(1, (int)(64 * SkillsInfo.GetValue(skillName, "cooldown"))); if (Server.TickCount % cooldown != 0) return; foreach (var player in PlayerManager.GetTickPlayers()) { var playerInfo = PlayerManager.GetPlayerByIndex(player!.Index); if (playerInfo?.Skill != skillName) continue; var pawn = player.PlayerPawn.Value; if (pawn == null || !pawn.IsValid) continue; SkillUtils.AddHealth(pawn, SkillsInfo.GetValue(skillName, "healthToAdd")); } } public class SkillConfig : SkillsInfo.DefaultSkillInfo { public int HealthToAdd { get; set; } public float Cooldown { get; set; } public SkillConfig(Skills skill = skillName, bool active = true, string color = "#ff462e", CsTeam onlyTeam = CsTeam.None, bool disableOnFreezeTime = false, bool needsTeammates = false, string requiredPermission = "", float? hudDuration = null, float? descriptionHudDuration = null, int maxPerServer = -1, Rarity rarity = utils.Rarity.Common, int healthToAdd = 1, float cooldown = .25f) : base(skill, active, color, onlyTeam, needsTeammates) { HealthToAdd = healthToAdd; Cooldown = cooldown; } } } }