/// <summary> /// Function called by OnProcessSpellCast event /// </summary> /// <param name="sender">Sender</param> /// <param name="args">Processed Spell Cast Data</param> private static void Obj_AI_Base_OnProcessSpellCast(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args) { var target = sender as Obj_AI_Hero; if (target == null || CastingInterruptableSpell.ContainsKey(target.NetworkId)) { return; } if (!InterruptableSpells.ContainsKey(target.ChampionName)) { return; } var spell = InterruptableSpells[target.ChampionName].Find( s => { var firstOrDefault = target.Spellbook.Spells.FirstOrDefault(x => x.SData.Name == args.SData.Name); return(firstOrDefault != null && s.Slot == firstOrDefault.Slot); }); if (spell != null) { CastingInterruptableSpell.TryAdd(target.NetworkId, spell); } }
/// <summary> /// Registers the spell. /// </summary> /// <param name="champName">Name of the champ.</param> /// <param name="spell">The spell.</param> private static void RegisterSpell(string champName, InterruptableSpell spell) { if (!InterruptableSpells.ContainsKey(champName)) { InterruptableSpells.Add(champName, new List <InterruptableSpell>()); } InterruptableSpells[champName].Add(spell); }
/// <summary> /// Registers the spell. /// </summary> /// <param name="champName">Name of the champ.</param> /// <param name="spell">The spell.</param> private static void RegisterSpell(string champName, InterruptableSpell spell) { if (HeroManager.Enemies.All(h => h.ChampionName != champName)) { return; } if (!InterruptableSpells.ContainsKey(champName)) { InterruptableSpells.Add(champName, new List <InterruptableSpell>()); } InterruptableSpells[champName].Add(spell); }
/// <summary> /// Fired when the game processes spell casts. /// </summary> /// <param name="sender">The sender.</param> /// <param name="args">The <see cref="GameObjectProcessSpellCastEventArgs" /> instance containing the event data.</param> private static void Obj_AI_Base_OnProcessSpellCast(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args) { var target = sender as AIHeroClient; if (target != null && !CastingInterruptableSpell.ContainsKey(target.NetworkId)) { // Check if the target is known to have interruptable spells if (InterruptableSpells.ContainsKey(target.ChampionName)) { // Get the interruptable spell var spell = InterruptableSpells[target.ChampionName].Find( s => s.Slot == target.GetSpellSlot(args.SData.Name)); if (spell != null && spell.Enabled) { // Mark champ as casting interruptable spell CastingInterruptableSpell.Add(target.NetworkId, spell); } } } }