/// <summary> /// Fired when the game updates. /// </summary> /// <param name="args">The <see cref="EventArgs" /> instance containing the event data.</param> private static void Game_OnGameUpdate(EventArgs args) { // Remove heros that have finished casting their interruptable spell HeroManager.AllHeroes.ForEach( hero => { if (CastingInterruptableSpell.ContainsKey(hero.NetworkId) && !hero.Spellbook.IsCastingSpell && !hero.Spellbook.IsChanneling && !hero.Spellbook.IsCharging) { CastingInterruptableSpell.Remove(hero.NetworkId); } }); // Trigger OnInterruptableTarget event if needed if (OnInterruptableTarget != null) { HeroManager.Enemies.ForEach( enemy => { var newArgs = GetInterruptableTargetData(enemy); if (newArgs != null) { OnInterruptableTarget(enemy, newArgs); } }); } }
/// <summary> /// Fired when the spellbook stops a cast. /// </summary> /// <param name="sender">The sender.</param> /// <param name="args">The <see cref="SpellbookStopCastEventArgs" /> instance containing the event data.</param> private static void Spellbook_OnStopCast(Spellbook sender, SpellbookStopCastEventArgs args) { var target = sender.Owner as Obj_AI_Hero; if (target != null) { // Check if the spell itself stopped casting (interrupted) if (!target.Spellbook.IsCastingSpell && !target.Spellbook.IsChanneling && !target.Spellbook.IsCharging) { CastingInterruptableSpell.Remove(target.NetworkId); } } }
/// <summary> /// Gets the interruptable target data. /// </summary> /// <param name="target">The target.</param> /// <returns></returns> public static InterruptableTargetEventArgs GetInterruptableTargetData(Obj_AI_Hero target) { if (target.IsValid <Obj_AI_Hero>()) { if (CastingInterruptableSpell.ContainsKey(target.NetworkId)) { // Return the args with spell end time return(new InterruptableTargetEventArgs( CastingInterruptableSpell[target.NetworkId].DangerLevel, target.Spellbook.CastEndTime, CastingInterruptableSpell[target.NetworkId].MovementInterrupts)); } } return(null); }
/// <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 Obj_AI_Hero; 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) { // Mark champ as casting interruptable spell CastingInterruptableSpell.Add(target.NetworkId, spell); } } } }