Beispiel #1
0
        /// <summary>
        ///     Gets called when a new skillshot gets detected. It only gets called once per skillshot.
        /// </summary>
        /// <param name="skillshot"></param>
        static void Detector_OnDetectSkillshot(Skillshot skillshot)
        {
            var isAlreadyDetected = false;
            foreach (var detectedSkillshot in DetectedSkillshots)
            {
                if (detectedSkillshot.SData.SpellName != skillshot.SData.SpellName
                    || detectedSkillshot.Caster.NetworkId != skillshot.Caster.NetworkId)
                {
                    continue;
                }

                //TODO: additional distance check(s) might be required.
                if (skillshot.Direction.AngleBetween(detectedSkillshot.Direction) < 5)
                {
                    isAlreadyDetected = true;

                    //Add the missile information to the detected skillshot.
                    if (skillshot.DetectionType == SkillshotDetectionType.MissileCreate)
                    {
                        try
                        {
                            ((SkillshotMissile)detectedSkillshot).Missile = ((SkillshotMissile)skillshot).Missile;
                        }
                        catch (Exception)
                        {
                            LogManager.GetCurrentClassLogger()
                                .Warn(
                                    $"Wrong SpellType for Skillshot {skillshot.SData.SpellName}, a missile type was expected but instead got {skillshot.GetType().Name}.");
                        }
                    }
                }
            }

            if (isAlreadyDetected)
            {
                return;
            }

            skillshot.PrintSpellData();
            DetectedSkillshots.Add(skillshot);
            OnDetectSkillshot?.Invoke(skillshot);
        }
Beispiel #2
0
        /// <summary>
        /// Gets called when a new skillshot gets detected. It only gets called once per skillshot.
        /// </summary>
        /// <param name="skillshot"></param>
        static void Detector_OnDetectSkillshot(Skillshot skillshot)
        {
            var isAlreadyDetected = false;
            foreach (var detectedSkillshot in DetectedSkillshots)
            {
                if (detectedSkillshot.SData.SpellName != skillshot.SData.SpellName || detectedSkillshot.Caster.NetworkId != skillshot.Caster.NetworkId)
                {
                    continue;
                }
                
                //TODO: additional distance check(s) might be required.
                if (skillshot.Direction.AngleBetween(detectedSkillshot.Direction) < 5)
                {
                    isAlreadyDetected = true;
                    
                    //Add the missile information to the detected skillshot.
                    if (skillshot.DetectionType == SkillshotDetectionType.MissileCreate)
                    {
                        try
                        {
                            ((SkillshotMissile)detectedSkillshot).Missile = ((SkillshotMissile)skillshot).Missile;
                        }
                        catch (Exception ex)
                        {
                            Logging.Write()(Enumerations.LogLevel.Warn, "Wrong SpellType for Skillshot {0}, a Missile Type was expected", skillshot.SData.SpellName);
                        }
                    }
                }
            }

            if (isAlreadyDetected)
            {
                return;
            }

            skillshot.PrintSpellData();
            DetectedSkillshots.Add(skillshot);
            OnDetectSkillshot?.Invoke(skillshot);
        }
Beispiel #3
0
 /// <summary>
 /// Gets called when a skillshot is detected, take into account that it can trigger twice for the same skillshot, one when OnProcessSpellCast is called and another when OnMissileCreate is called.
 /// </summary>
 /// <param name="skillshot">The detected skillshot</param>
 private static void TriggerOnDetectSkillshot(Skillshot skillshot)
 {
     OnDetectSkillshot?.Invoke(skillshot);
 }
Beispiel #4
0
 /// <summary>
 ///     Gets called when a skillshot is detected, take into account that it can trigger twice for the same skillshot, one
 ///     when OnProcessSpellCast is called and another when OnMissileCreate is called.
 /// </summary>
 /// <param name="skillshot">The detected skillshot</param>
 private static void TriggerOnDetectSkillshot(Skillshot skillshot)
 {
     OnDetectSkillshot?.Invoke(skillshot);
 }
Beispiel #5
0
        //[PermissionSet(SecurityAction.Assert, Unrestricted = true)]
        private static void TriggerOnDetectSkillshot(
            SpellDatabaseEntry spellDatabaseEntry,
            Obj_AI_Base caster,
            SkillshotDetectionType detectionType,
            Vector2 start,
            Vector2 end,
            int time,
            MissileClient missile = null)
        {
            Skillshot skillshot = null;

            switch (spellDatabaseEntry.SpellType)
            {
            case SpellType.SkillshotMissileArc:
                skillshot = new SkillshotMissileArc(spellDatabaseEntry);
                break;

            case SpellType.SkillshotMissileCircle:
                skillshot = new SkillshotMissileCircle(spellDatabaseEntry);
                break;

            case SpellType.SkillshotMissileLine:
                skillshot = new SkillshotMissileLine(spellDatabaseEntry);
                break;

            case SpellType.SkillshotCircle:
                skillshot = new SkillshotCircle(spellDatabaseEntry);
                break;

            case SpellType.SkillshotCone:
                skillshot = new SkillshotCone(spellDatabaseEntry);
                break;

            case SpellType.SkillshotLine:
                skillshot = new SkillshotLine(spellDatabaseEntry);
                break;

            case SpellType.SkillshotRing:
                skillshot = new SkillshotRing(spellDatabaseEntry);
                break;
            }

            if (skillshot == null)
            {
                return;
            }

            var type =
                Type.GetType(
                    $"LeagueSharp.SDK.Core.Wrappers.Spells.Detector.Skillshots_{skillshot.SData.ChampionName}{skillshot.SData.Slot}");

            if (type != null)
            {
                skillshot = (Skillshot)Activator.CreateInstance(type);
            }

            skillshot.DetectionType = detectionType;
            skillshot.Caster        = caster;
            skillshot.StartPosition = start;
            skillshot.EndPosition   = end;
            skillshot.StartTime     = time;

            if (missile != null)
            {
                try
                {
                    ((SkillshotMissile)skillshot).Missile = missile;
                }
                catch (Exception)
                {
                    //LogManager.GetCurrentClassLogger().Warn($"Wrong SpellType for SkillShot {skillshot.SData.SpellName}, a missile type was expected but instead got a {missile.GetType().Name}.");
                }
            }

            if (!skillshot.Process())
            {
                return;
            }

            TriggerOnDetectSkillshot(skillshot);
        }