Esempio n. 1
0
        /// <summary>
        ///     Function called by OnProcessSpellCast event
        /// </summary>
        /// <param name="sender">The 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 || CastingInterruptableSpellDictionary.ContainsKey(target.NetworkId))
            {
                return;
            }

            if (!InterruptableSpellsDictionary.ContainsKey(target.ChampionName))
            {
                return;
            }

            var spell = InterruptableSpellsDictionary[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)
            {
                CastingInterruptableSpellDictionary.Add(target.NetworkId, spell);
            }
        }
        /// <summary>
        ///     Function called by OnDoCast event
        /// </summary>
        /// <param name="sender">
        ///     The sender
        /// </param>
        /// <param name="args">
        ///     Processed Spell Cast Data
        /// </param>
        private static void EventInterruptableSpell(AIBaseClient sender, AIBaseClientProcessSpellCastEventArgs args)
        {
            var target = sender as AIHeroClient;

            if (target == null || CastingInterruptableSpellDictionary.ContainsKey(target.NetworkId))
            {
                return;
            }

            var globalInterruptSpell = GlobalInterruptableSpells.FirstOrDefault(s => s.Name.Equals(args.SData.Name.ToLower()));

            if (globalInterruptSpell != null)
            {
                CastingInterruptableSpellDictionary.Add(target.NetworkId, globalInterruptSpell);
                return;
            }

            if (!InterruptableSpellsDictionary.ContainsKey(target.CharacterName))
            {
                return;
            }

            var spell = InterruptableSpellsDictionary[target.CharacterName].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)
            {
                CastingInterruptableSpellDictionary.Add(target.NetworkId, spell);
            }
        }
Esempio n. 3
0
        /// <summary>
        ///     Function called by the stop cast event.
        /// </summary>
        /// <param name="sender">Sender Spell-book</param>
        /// <param name="args">Spell-book Stop Data</param>
        private static void Spellbook_OnStopCast(Spellbook sender, SpellbookStopCastEventArgs args)
        {
            var target = sender.Owner as Obj_AI_Hero;

            if (target == null)
            {
                return;
            }

            if (!target.Spellbook.IsCastingSpell && !target.Spellbook.IsChanneling && !target.Spellbook.IsCharging)
            {
                CastingInterruptableSpellDictionary.Remove(target.NetworkId);
            }
        }
Esempio n. 4
0
        /// <summary>
        ///     Function called by the stop cast event.
        /// </summary>
        /// <param name="sender">
        ///     Sender Spell-book
        /// </param>
        private static void EventInterruptableSpell(Obj_AI_Base sender)
        {
            var target = sender as AIHeroClient;

            if (target == null)
            {
                return;
            }

            if (!target.Spellbook.IsCastingSpell && !target.Spellbook.IsChanneling && !target.Spellbook.IsCharging)
            {
                CastingInterruptableSpellDictionary.Remove(target.NetworkId);
            }
        }
Esempio n. 5
0
        /// <summary>
        ///     Gets the <see cref="InterruptableTargetEventArgs" /> for the unit.
        /// </summary>
        /// <param name="target">The unit</param>
        /// <returns>
        ///     <see cref="InterruptableTargetEventArgs" />
        /// </returns>
        public static InterruptableTargetEventArgs GetInterruptableTargetData(Obj_AI_Hero target)
        {
            if (target == null || !target.IsValid)
            {
                return(null);
            }

            InterruptableSpellData value;

            if (CastingInterruptableSpellDictionary.TryGetValue(target.NetworkId, out value))
            {
                return(new InterruptableTargetEventArgs(
                           target,
                           value.DangerLevel,
                           target.Spellbook.CastEndTime,
                           value.MovementInterrupts));
            }

            return(null);
        }
Esempio n. 6
0
        /// <summary>
        ///     Function called by update tick event.
        /// </summary>
        /// <param name="args"><see cref="System.EventArgs" /> event data</param>
        private static void Game_OnGameUpdate(EventArgs args)
        {
            foreach (var hero in
                     GameObjects.Heroes.Where(
                         hero =>
                         CastingInterruptableSpellDictionary.ContainsKey(hero.NetworkId) && !hero.Spellbook.IsCastingSpell &&
                         !hero.Spellbook.IsChanneling && !hero.Spellbook.IsCharging))
            {
                CastingInterruptableSpellDictionary.Remove(hero.NetworkId);
            }

            if (OnInterruptableTarget == null)
            {
                return;
            }

            foreach (var newArgs in
                     GameObjects.EnemyHeroes.Select(GetInterruptableTargetData).Where(newArgs => newArgs != null))
            {
                OnInterruptableTarget(newArgs.Sender, newArgs);
            }
        }
Esempio n. 7
0
        /// <summary>
        ///     Function called by update tick event.
        /// </summary>
        private static void EventInterruptableSpell()
        {
            foreach (var hero in
                     GameObjects.Heroes.Where(
                         hero =>
                         CastingInterruptableSpellDictionary.ContainsKey(hero.NetworkId) && !hero.Spellbook.IsCastingSpell &&
                         !hero.Spellbook.IsChanneling && !hero.Spellbook.IsCharging))
            {
                CastingInterruptableSpellDictionary.Remove(hero.NetworkId);
            }

            if (OnInterruptableTarget == null)
            {
                return;
            }

            foreach (var newArgs in
                     GameObjects.EnemyHeroes.Select(GetInterruptableTargetData).Where(newArgs => newArgs != null))
            {
                OnInterruptableTarget(MethodBase.GetCurrentMethod().DeclaringType, newArgs);
            }
        }