Cooldown override: follow bot takeovers, cover BlastShot and Dash
css_setoverride only reset cooldowns before UseSkill, checked against the controller the skill ran on. After a bot takeover that's the bot (SteamID 0), so the human's override was ignored; it now resolves to the controlling human. Bots are keyed by slot, so overriding one bot no longer toggles all of them. BlastShot and Dash trigger from OnTick, not UseSkill, so they never saw the override. They check it now; BlastShot fires once per right-click press while overridden instead of every tick.
This commit is contained in:
parent
5d0cf7ce80
commit
bbf4ac1d22
4 changed files with 33 additions and 11 deletions
|
|
@ -44,7 +44,7 @@ namespace src
|
||||||
public override string ModuleName => "[CS2] [ jRandomSkills ]";
|
public override string ModuleName => "[CS2] [ jRandomSkills ]";
|
||||||
public override string ModuleAuthor => "D3X (Original), Juzlus (Modifier), ByDexterTR (Contributor)";
|
public override string ModuleAuthor => "D3X (Original), Juzlus (Modifier), ByDexterTR (Contributor)";
|
||||||
public override string ModuleDescription => "Plugin adds random skills every round for CS2 by D3X. Modified by Juzlus.";
|
public override string ModuleDescription => "Plugin adds random skills every round for CS2 by D3X. Modified by Juzlus.";
|
||||||
public override string ModuleVersion => "1.2.4.b3-panorama1";
|
public override string ModuleVersion => "1.2.4.b3-panorama2";
|
||||||
|
|
||||||
public override void Load(bool hotReload)
|
public override void Load(bool hotReload)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -68,15 +68,23 @@ namespace src.player.skills
|
||||||
var buttons = player.Buttons;
|
var buttons = player.Buttons;
|
||||||
bool isAttack2 = (buttons & PlayerButtons.Attack2) != 0;
|
bool isAttack2 = (buttons & PlayerButtons.Attack2) != 0;
|
||||||
|
|
||||||
if (skillInfo.CanUse && isAttack2 && !freezeTime)
|
bool pressed = isAttack2 && !skillInfo.WasAttack2;
|
||||||
|
skillInfo.WasAttack2 = isAttack2;
|
||||||
|
|
||||||
|
// With the cooldown override there's no cooldown, so fire once per press instead of every tick.
|
||||||
|
bool noCooldown = CooldownOverride.Has(player);
|
||||||
|
if ((noCooldown ? pressed : skillInfo.CanUse && isAttack2) && !freezeTime)
|
||||||
{
|
{
|
||||||
var weapon = playerPawn.WeaponServices?.ActiveWeapon?.Value;
|
var weapon = playerPawn.WeaponServices?.ActiveWeapon?.Value;
|
||||||
|
|
||||||
if (weapon == null || !weapon.IsValid) continue;
|
if (weapon == null || !weapon.IsValid) continue;
|
||||||
if (!allowedWeapons.Contains(SkillUtils.GetDesignerName(weapon))) continue;
|
if (!allowedWeapons.Contains(SkillUtils.GetDesignerName(weapon))) continue;
|
||||||
|
|
||||||
skillInfo.CanUse = false;
|
if (!noCooldown)
|
||||||
skillInfo.Cooldown = DateTime.Now;
|
{
|
||||||
|
skillInfo.CanUse = false;
|
||||||
|
skillInfo.Cooldown = DateTime.Now;
|
||||||
|
}
|
||||||
SpawnExplosion(player);
|
SpawnExplosion(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -191,6 +199,7 @@ namespace src.player.skills
|
||||||
public ulong SteamID { get; set; }
|
public ulong SteamID { get; set; }
|
||||||
public bool CanUse { get; set; }
|
public bool CanUse { get; set; }
|
||||||
public DateTime Cooldown { get; set; }
|
public DateTime Cooldown { get; set; }
|
||||||
|
public bool WasAttack2 { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#7740c9", CsTeam onlyTeam = CsTeam.None, bool disableOnFreezeTime = false, bool needsTeammates = false, string requiredPermission = "", float? hudDuration = null, float? descriptionHudDuration = null, int maxPerServer = -1, Rarity rarity = Rarity.Common, float explosionRadius = 400.0f, int explosionDamage = 60, float dmgReductionForTeamates = 0.5f, float cooldown = 10f, float force = 1000f, bool friendlyFire = true) : SkillsInfo.DefaultSkillInfo(skill, active, color, onlyTeam, disableOnFreezeTime, needsTeammates, requiredPermission, hudDuration, descriptionHudDuration, maxPerServer, rarity)
|
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#7740c9", CsTeam onlyTeam = CsTeam.None, bool disableOnFreezeTime = false, bool needsTeammates = false, string requiredPermission = "", float? hudDuration = null, float? descriptionHudDuration = null, int maxPerServer = -1, Rarity rarity = Rarity.Common, float explosionRadius = 400.0f, int explosionDamage = 60, float dmgReductionForTeamates = 0.5f, float cooldown = 10f, float force = 1000f, bool friendlyFire = true) : SkillsInfo.DefaultSkillInfo(skill, active, color, onlyTeam, disableOnFreezeTime, needsTeammates, requiredPermission, hudDuration, descriptionHudDuration, maxPerServer, rarity)
|
||||||
|
|
|
||||||
|
|
@ -109,11 +109,15 @@ namespace src.player.skills
|
||||||
skillInfo.Jumps = 0;
|
skillInfo.Jumps = 0;
|
||||||
else if (!isOnGround && jumpPressed && skillInfo.Jumps < 1)
|
else if (!isOnGround && jumpPressed && skillInfo.Jumps < 1)
|
||||||
{
|
{
|
||||||
if (skillInfo.JumpReleasedTicks >= 3 && skillInfo.CanUse)
|
bool noCooldown = CooldownOverride.Has(eventPlayer);
|
||||||
|
if (skillInfo.JumpReleasedTicks >= 3 && (skillInfo.CanUse || noCooldown))
|
||||||
{
|
{
|
||||||
skillInfo.Jumps++;
|
skillInfo.Jumps++;
|
||||||
skillInfo.CanUse = false;
|
if (!noCooldown)
|
||||||
skillInfo.Cooldown = DateTime.Now;
|
{
|
||||||
|
skillInfo.CanUse = false;
|
||||||
|
skillInfo.Cooldown = DateTime.Now;
|
||||||
|
}
|
||||||
|
|
||||||
float moveX = 0;
|
float moveX = 0;
|
||||||
float moveY = 0;
|
float moveY = 0;
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@ namespace src.utils
|
||||||
// Per-player cooldown bypass (css_setoverride). Skills keep their cooldown in their own static
|
// Per-player cooldown bypass (css_setoverride). Skills keep their cooldown in their own static
|
||||||
// per-player state, so instead of touching every skill this clears that state just before the
|
// per-player state, so instead of touching every skill this clears that state just before the
|
||||||
// skill's UseSkill runs. Resetting only at use time (not every tick) matters: AimLock and Noclip
|
// skill's UseSkill runs. Resetting only at use time (not every tick) matters: AimLock and Noclip
|
||||||
// reuse their Cooldown timestamp as the start of the active effect.
|
// reuse their Cooldown timestamp as the start of the active effect. Skills that trigger from
|
||||||
|
// OnTick rather than UseSkill (BlastShot, Dash) check Has themselves.
|
||||||
public static class CooldownOverride
|
public static class CooldownOverride
|
||||||
{
|
{
|
||||||
private static readonly HashSet<ulong> _players = [];
|
private static readonly HashSet<ulong> _players = [];
|
||||||
|
|
@ -17,12 +18,20 @@ namespace src.utils
|
||||||
// Toggles the override and returns the new state.
|
// Toggles the override and returns the new state.
|
||||||
public static bool Toggle(CCSPlayerController player)
|
public static bool Toggle(CCSPlayerController player)
|
||||||
{
|
{
|
||||||
if (_players.Remove(player.SteamID)) return false;
|
if (_players.Remove(Key(player))) return false;
|
||||||
_players.Add(player.SteamID);
|
_players.Add(Key(player));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool Has(CCSPlayerController player) => _players.Contains(player.SteamID);
|
// A bot a human has taken over counts as that human, since skills run on the bot's controller.
|
||||||
|
public static bool Has(CCSPlayerController? player)
|
||||||
|
{
|
||||||
|
player = PlayerManager.GetPlayerFromEvent(player);
|
||||||
|
return player != null && _players.Contains(Key(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bots all have SteamID 0, so key them by slot instead (a SteamID64 is never that small).
|
||||||
|
private static ulong Key(CCSPlayerController player) => player.IsBot ? player.Index : player.SteamID;
|
||||||
|
|
||||||
public static void ResetBeforeUse(Type skillType, CCSPlayerController player)
|
public static void ResetBeforeUse(Type skillType, CCSPlayerController player)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue