public CooldownManager(List <Spell> spells) { Cooldowns = new(); if (spells != null) { foreach (Spell spell in spells) { if (!Cooldowns.ContainsKey(spell.Name)) { Cooldowns.Add(spell.Name, DateTime.UtcNow); } } } }
public void AddCooldown(string ID, string type, string key, int time = 0) { if (!Cooldowns.ContainsKey(ID)) { Cooldowns.Add(ID, new Dictionary <string, Dictionary <string, int> >()); } if (!Cooldowns[ID].ContainsKey(type)) { Cooldowns[ID].Add(type, new Dictionary <string, int>()); } if (!Cooldowns[ID][type].ContainsKey(key)) { Cooldowns[ID][type].Add(key, time); } Core.Instance.SvManager.StartCoroutine(StartCooldown(ID, type, key)); }
public bool UseBuffSpell(StrikingDummy target, Spells spell, bool verbose = false) { if (GcdDuration <= 0) { throw new Exception($"Warning! Using off-gcd ability { spell } when GCD is available! Remaining cooldown on { spell }: { Cooldowns[spell]}"); } if (Cooldowns.ContainsKey(spell) || QueuedEffects.ContainsKey(Skills.StatusEffects.AnimationLocked)) { return(false); } SpellLibrary.QueueEffect(this, spell, target, verbose); Cooldowns.Add(spell, SpellLibrary.SpellCooldowns(spell)); return(true); }
public void Load() { foreach (var player in Core.Instance.SvManager.Database.Users.FindAll().ToDictionary(x => x.ID, x => x.Character.CustomData)) { if (player.Value.Data == null || !player.Value.Data.ContainsKey(CustomDataKey)) { continue; } var cooldownsObj = player.Value.FetchCustomData <Dictionary <string, Dictionary <string, int> > >(CustomDataKey); Cooldowns.Add(player.Key, cooldownsObj); foreach (var cooldownType in cooldownsObj) { foreach (var cooldown in cooldownType.Value) { AddCooldown(player.Key, cooldownType.Key, cooldown.Key); } } } ready = true; }
private void OnTriggerSend(SteamPlayer player, string name, ESteamCall mode, ESteamPacket type, params object[] arguments) { if (name == "tellGesture") { var up = UnturnedPlayer.FromSteamPlayer(player); var id = int.Parse(arguments[0].ToString()); if (id == 8) { if (!Configuration.Instance.UsePermissions || up.HasPermission("pickpocket")) { Player victimPlayer = RaycastHelper.GetPlayerFromHits(up.Player, Configuration.Instance.MaxDistance); if (victimPlayer != null) { if (Cooldowns.TryGetValue(up.Id.ToString(), out DateTime expireDate) && expireDate > DateTime.Now) { UnturnedChat.Say(up.CSteamID, Translate("COOLDOWN", System.Math.Truncate((expireDate - DateTime.Now).TotalSeconds)), MessageColor); } else { if (expireDate != null) { Cooldowns.Remove(up.Id); } UnturnedPlayer victim = UnturnedPlayer.FromPlayer(victimPlayer); if (victim.HasPermission("bypass.pickpocket")) { UnturnedChat.Say(up, Translate("BYPASS"), MessageColor); return; } PickpocketComponent comp = up.Player.gameObject.AddComponent <PickpocketComponent>(); comp.Initialize(up, victim, this); Cooldowns.Add(up.Id, DateTime.Now.AddSeconds(Configuration.Instance.PickpocketCooldown)); } } } } } }
/// <summary> /// Tells the music player to play the song with the specific id /// </summary> /// <param name="id">Id of the song to play</param> /// <returns></returns> public async Task PlayID(string id) { Song song = SongList.First(x => x.id == id); if (song?.path == null) { throw new ApiError("Song has no path"); } await PlayFile(song.path); if (Cooldowns.TryGetValue(id, out Timer timer2)) { timer2.Dispose(); Cooldowns.Remove(id); } Timer timer = new Timer(6.48e+7); timer.Elapsed += delegate { CooldownElapsed(id); }; song.canBePlayed = false; song.cooldownExpiry = DateTime.UtcNow.AddMilliseconds(6.48e+7); timer.AutoReset = false; timer.Start(); Cooldowns.Add(id, timer); }
public double UseDamageSpell(StrikingDummy target, Spells spell, bool verbose = false) { if (GcdDuration <= 0 && spell != Spells.PrePullSuiton) { var remainingCd = Cooldowns.ContainsKey(spell) ? Cooldowns[spell] : 0; throw new Exception($"Warning! Using off-gcd ability { spell } when GCD is available! Remaining cooldown on { spell }: { remainingCd }"); } if (Cooldowns.ContainsKey(spell) || QueuedEffects.ContainsKey(Skills.StatusEffects.AnimationLocked)) { return(0); } if (spell == Spells.FumaShuriken || spell == Spells.Raiton || spell == Spells.Suiton) { if (Cooldowns.ContainsKey(Spells.FumaShuriken) || Cooldowns.ContainsKey(Spells.Raiton) || Cooldowns.ContainsKey(Spells.Suiton)) { return(0); } } if (spell == Spells.TrickAttack) { if (!StatusEffects.ContainsKey(Skills.StatusEffects.Suiton)) { throw new Exception($"Warning! Cannot use TA without Suiton active!"); } if (verbose) { Console.WriteLine("Suiton removed after TA cast!"); } StatusEffects.Remove(Skills.StatusEffects.Suiton); } var potency = SpellLibrary.SpellPotencies(spell); var multiplier = CalculateMultiplier(target, SpellLibrary.SpellDamageType(spell)); var damage = FormulaLibrary.WeaponSkills(potency, Weapon.WeaponDamage, GetDexterity(), Det, multiplier); var guaranteeCrit = false; if (spell == Spells.FumaShuriken || spell == Spells.Raiton || spell == Spells.Suiton) { if (StatusEffects.ContainsKey(Skills.StatusEffects.Kassatsu)) { guaranteeCrit = true; StatusEffects.Remove(Skills.StatusEffects.Kassatsu); } } if (guaranteeCrit) { damage *= FormulaLibrary.CritDmg(Crt); } else { damage = (damage * CalculateCritChance() * FormulaLibrary.CritDmg(Crt)) + (damage * (1 - CalculateCritChance())); } SpellLibrary.QueueEffect(this, spell, target, verbose); if (spell == Spells.FumaShuriken) { Cooldowns.Add(spell, 500 + SpellLibrary.SpellCooldowns(spell)); } else if (spell == Spells.Raiton) { Cooldowns.Add(spell, 1000 + SpellLibrary.SpellCooldowns(spell)); } else if (spell == Spells.Suiton) { Cooldowns.Add(spell, 1500 + SpellLibrary.SpellCooldowns(spell)); } else if (spell == Spells.PrePullSuiton) { Cooldowns.Add(Spells.Suiton, SpellLibrary.SpellCooldowns(Spells.Suiton)); } else { Cooldowns.Add(spell, SpellLibrary.SpellCooldowns(spell)); } return(damage); }