Ejemplo n.º 1
0
        internal static void Add(DetectedSkillshotData data)
        {
            if (data == null)
            {
                Console.WriteLine("Invalid DetectedSkillshot");
                return;
            }

            if (data.Data.IsTrap && SkillshotsDetected.Any(x => x.Trap != null && data.Trap.Equals(x.Trap)))
            {
                return;
            }

            if (data.Missile == null && data.Data.DetectByMissile)
            {
                return;
            }

            if (data.Data.type == Type.Cone)
            {
                if (SkillshotsDetected.Any(s => s.Caster.IdEquals(data.Caster) && s.Data.Equals(data.Data)))
                {
                    return;
                }
            }

            if (!data.Data.AllowDuplicates)
            {
                if (SkillshotsDetected.Any(s => s.Missile != null && data.Missile == null && s.Caster != null && data.Caster != null && s.Caster.IdEquals(data.Caster) && s.Data.Equals(data.Data)))
                {
                    // Already Detected by Missile
                    return;
                }

                var replaceByMissile =
                    SkillshotsDetected.FirstOrDefault(s => s.Missile == null && data.Missile != null && s.Caster != null && data.Caster != null && s.Caster.IdEquals(data.Caster) && s.Data.Equals(data.Data));
                if (replaceByMissile != null && data.Missile != null && !(data.Data.StaticStart && data.Data.StaticEnd))
                {
                    // Add the Missile
                    replaceByMissile.Missile = data.Missile;
                    replaceByMissile.End     = data.Missile.EndPosition.To2D();
                    replaceByMissile.Start   = data.Missile.StartPosition.To2D();
                    return;
                }

                if (SkillshotsDetected.Any(s => s.Caster != null && !s.DetectedByMissile && s.Caster.IdEquals(data.Caster) && s.Data.Equals(data.Data)))
                {
                    return;
                }
            }

            if (data.Data.StaticStart && data.Data.StaticEnd && data.Missile == null)
            {
                var start = data.Start;
                var end   = data.End;
                data.Start = end - (end - start).Normalized().Perpendicular() * (data.Range / 2);
                data.End   = end + (end - start).Normalized().Perpendicular() * (data.Range / 2);
            }

            if (data.Data.IsSpellName("YorickE"))
            {
                var start = data.End.Extend(data.Start, 200);
                var end   = data.End.Extend(data.Start, -450);
                data.Start = start;
                data.End   = end;
            }

            if (data.Data.CasterNames.Length == 3 && data.Data.type == Type.CircleMissile)
            {
                var obj = ObjectManager.Get <Obj_AI_Base>().FirstOrDefault(o => o.IsValid && !o.IsDead && o.Team == data.Caster.Team && data.Data.CasterNames[1].Equals(o.BaseSkinName) && data.Data.CasterNames[2].Equals(o.Model));
                if (obj != null)
                {
                    data.Start = obj.ServerPosition.To2D();
                    data.End   = obj.ServerPosition.To2D();
                }
            }

            if (data.Data.IsSpellName("JarvanIVDragonStrike"))
            {
                var jarvanFlag = ObjectManager.Get <Obj_AI_Base>().OrderBy(o => o.Distance(data.EndPosition)).FirstOrDefault(o => o.BaseSkinName.Equals("JarvanIVStandard") && o.Team == data.Caster.Team && o.IsValid && data.IsInside(o));
                if (jarvanFlag != null)
                {
                    var jarvanEQData = SkillshotDatabase.Current.FirstOrDefault(s => s.IsSpellName("JarvanIVEQ"));
                    if (jarvanEQData != null)
                    {
                        var jarvanEQ = new DetectedSkillshotData
                        {
                            Data      = jarvanEQData,
                            Start     = data.Start,
                            End       = jarvanFlag.ServerPosition.To2D(),
                            Caster    = data.Caster,
                            StartTick = Core.GameTickCount,
                        };

                        Add(jarvanEQ);
                        return;
                    }
                }
            }

            if (data.Data.DecaySpeedWithLessRange)
            {
                data.Speed = data.Data.Speed * (data.Start.Distance(data.EndPosition) / data.Data.Range);
            }

            data.DetectedByMissile = data.Missile != null;
            data.FromFOW           = !data.Caster.IsHPBarRendered;

            data.Update();
            SkillshotsDetected.Add(data);
            OnSkillShotDetected.Invoke(data);

            if (data.Data.IsSpellName("SyndraE"))
            {
                var qeData = SkillshotDatabase.Current.FirstOrDefault(s => s.IsSpellName("SyndraEQ"));
                if (qeData != null)
                {
                    var syndraBalls = ObjectManager.Get <Obj_AI_Base>().Where(o => o.BaseSkinName.Equals("SyndraSphere") && o.Team == data.Caster.Team && data.IsInside(o) && o.IsValid && o.Mana > 17.5);
                    foreach (var ball in syndraBalls)
                    {
                        var newDetect = new DetectedSkillshotData
                        {
                            Caster     = data.Caster,
                            Start      = ball.ServerPosition.To2D(),
                            End        = data.Start.Extend(ball.ServerPosition.To2D(), qeData.Range),
                            Data       = qeData,
                            StartTick  = Core.GameTickCount,
                            extraDelay = data.TravelTime(ball)
                        };

                        newDetect.Update();
                        SkillshotsDetected.Add(newDetect);
                        OnSkillShotDetected.Invoke(newDetect);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private static void OnSkillShotUpdate_OnUpdate(DetectedSkillshotData args)
        {
            if (args.Caster == null || !Spells.E.IsReady() || !args.IsEnemy || !args.WillHit(Player.Instance))
            {
                return;
            }

            var spellname = args.Data.MenuItemName;
            var spell     = EnabledSpells.FirstOrDefault(s => s.SpellName.Equals(spellname));

            if (spell == null)
            {
                Logger.Warn($"{spellname} Not valid Spell");
                return;
            }

            if (!spell.Enabled && (!Meniu.BlockExecute || Player.Instance.PredictHealth(args.TravelTime(Player.Instance)) > args.GetSpellDamage(Player.Instance)))
            {
                Logger.Warn($"{spellname} Not Enabled from Menu");
                return;
            }

            Block(args, spell);
        }