Ejemplo n.º 1
0
        private static void Obj_AI_Base_OnProcessSpellCast(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args)
        {
            var caster = sender as AIHeroClient;
            var hero   = args.Target as AIHeroClient;

            if (caster == null || !caster.IsEnemy)
            {
                return;
            }

            if (Database.SkillShotSpells.SkillShotsSpellsList.Any(s => s.hero == caster.Hero && s.slot == args.Slot && args.SData.Name.Equals(s.SpellName, StringComparison.CurrentCultureIgnoreCase)))
            {
                //Chat.Print("OnProcessSpellCast Detected " + args.SData.Name);
                var spell = Database.SkillShotSpells.SkillShotsSpellsList.FirstOrDefault(s => s.hero == caster.Hero && s.slot == args.Slot && args.SData.Name.Equals(s.SpellName, StringComparison.CurrentCultureIgnoreCase));
                if (spell.DetectByMissile)
                {
                    return;
                }
                OnSkillShotDetected?.Invoke(caster, args, spell, args.Start, args.End, spell.Range, spell.Width, null);
            }

            if (hero == null)
            {
                return;
            }
            if (Database.TargetedSpells.TargetedSpellsList.Any(s => s.hero == caster.Hero && s.slot == args.Slot))
            {
                var spell = Database.TargetedSpells.TargetedSpellsList.FirstOrDefault(s => s.hero == caster.Hero && s.slot == args.Slot);
                OnTargetedSpellDetected?.Invoke(caster, hero, args, spell);
            }
        }
Ejemplo n.º 2
0
        private static void GameObject_OnCreate(GameObject sender, EventArgs args)
        {
            if (sender == null)
            {
                return;
            }

            var missile = sender as MissileClient;
            var caster  = missile?.SpellCaster as AIHeroClient;

            if (caster == null || missile == null || !missile.IsValid || missile.IsAutoAttack() || !caster.IsEnemy)
            {
                return;
            }

            //Chat.Print("OnCreate Detected " + missile.SData.Name + " " + missile.SData.MissileSpeed + " " + missile.SData.CastRange);
            if (Database.SkillShotSpells.SkillShotsSpellsList.Any(s => s.hero == caster.Hero && missile.SData.Name.ToLower() == s.MissileName.ToLower()))
            {
                //Chat.Print("OnCreate Added " + missile.SData.Name);
                var spell = Database.SkillShotSpells.SkillShotsSpellsList.FirstOrDefault(s => s.hero == caster.Hero && missile.SData.Name.ToLower() == s.MissileName.ToLower());
                if (!spell.DetectByMissile)
                {
                    return;
                }
                OnSkillShotDetected?.Invoke(caster, null, spell, missile.StartPosition, missile.EndPosition, spell.Range, spell.Width, missile);
            }
        }
Ejemplo n.º 3
0
        private static void GameObject_OnCreate(GameObject sender, EventArgs args)
        {
            if (sender == null)
            {
                return;
            }

            var missile = sender as MissileClient;
            var caster  = missile?.SpellCaster;

            if (missile == null || !missile.IsValid || !missile.IsEnemy || missile.IsAutoAttack())
            {
                return;
            }
            var missilename = missile.SData.Name;
            var check       = Database.SkillShotSpells.SkillShotsSpellsList.Any(s => missilename.Equals(s.MissileName, StringComparison.CurrentCultureIgnoreCase) ||
                                                                                s.ExtraMissileName != null && s.ExtraMissileName.Any(x => x.Equals(missilename, StringComparison.CurrentCultureIgnoreCase)));

            //Chat.Print("OnCreate Detected " + missile.SData.Name + " " + missile.SData.MissileSpeed + " " + missile.SData.CastRange);
            if (check)
            {
                //Chat.Print("OnCreate Added " + missile.SData.Name);
                var spell = Database.SkillShotSpells.SkillShotsSpellsList.FirstOrDefault(s => missilename.Equals(s.MissileName, StringComparison.CurrentCultureIgnoreCase) ||
                                                                                         s.ExtraMissileName != null && s.ExtraMissileName.Any(x => x.Equals(missilename, StringComparison.CurrentCultureIgnoreCase)));
                //if (!spell.DetectByMissile) return;
                OnSkillShotDetected?.Invoke(caster, null, spell, missile.StartPosition, missile.EndPosition, spell.Range, spell.Width, missile);
            }
        }
Ejemplo n.º 4
0
        private static void Add(DetectedSkillshotData data)
        {
            if (data == null)
            {
                Console.WriteLine("Invalid DetectedSkillshotData");
                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)
                {
                    // 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.DetectedMissile && s.Caster.IdEquals(data.Caster) && s.Data.Equals(data.Data)))
                {
                    return;
                }
            }

            OnSkillShotDetected.Invoke(data);
            SkillshotsDetected.Add(data);
        }
Ejemplo n.º 5
0
        private static void Game_OnTick(EventArgs args)
        {
            foreach (var LuxR in DetectedLuxRParticals)
            {
                var data = SkillshotDatabase.List.FirstOrDefault(s => s.hero.Equals(Champion.Lux) && s.slot.Equals(SpellSlot.R));
                if (data == null)
                {
                    continue;
                }

                if (SkillshotsDetected.Any(s => s.Caster.IdEquals(LuxR.caster) && s.Data.Equals(data)))
                {
                    continue;
                }

                Vector3?start = null;
                Vector3?end   = null;

                if (start == null)
                {
                    if (LuxR.caster != null && LuxR.caster.IsHPBarRendered)
                    {
                        start = LuxR.caster.ServerPosition;
                    }
                    else
                    {
                        if (LuxR.Start.HasValue)
                        {
                            start = LuxR.Start;
                        }
                        else
                        {
                            if (LuxR.Mid.HasValue && LuxR.End.HasValue)
                            {
                                start = LuxR.End.Value.Extend(LuxR.Mid.Value, data.Range).To3DWorld();
                            }
                        }
                    }
                }

                if (end == null)
                {
                    if (LuxR.End.HasValue)
                    {
                        end = LuxR.End.Value;
                    }
                    else
                    {
                        if (LuxR.caster != null && LuxR.caster.IsHPBarRendered)
                        {
                            if (LuxR.End.HasValue)
                            {
                                end = LuxR.End.Value;
                            }
                            if (LuxR.Mid.HasValue)
                            {
                                end = LuxR.caster.ServerPosition.Extend(LuxR.Mid.Value, data.Range).To3DWorld();
                            }
                            else
                            {
                                if (LuxR.Start.HasValue)
                                {
                                    end = LuxR.caster.ServerPosition.Extend(LuxR.Start.Value, data.Range).To3DWorld();
                                }
                            }
                        }
                        else
                        {
                            if (LuxR.Start.HasValue && LuxR.Mid.HasValue)
                            {
                                end = LuxR.Start.Value.Extend(LuxR.Mid.Value, data.Range).To3DWorld();
                            }
                        }
                    }
                }

                if (start.HasValue && end.HasValue)
                {
                    if (!SkillshotsDetected.Any(s => s.Caster.IdEquals(LuxR.caster) && s.Data.Equals(data)))
                    {
                        var detected = new DetectedSkillshotData
                        {
                            Caster    = LuxR.caster,
                            StartTick = Core.GameTickCount,
                            Start     = start.Value.To2D(),
                            End       = end.Value.To2D(),
                            Data      = data
                        };

                        Add(detected);
                    }
                }
            }

            foreach (var skill in SkillshotsDetected)
            {
                OnSkillShotDetected.Invoke(skill);
            }

            DetectedLuxRParticals.RemoveAll(s => Core.GameTickCount - s.StartTick > s.Data.CastDelay);
            SkillshotsDetected.RemoveAll(s => s.Ended);
        }
Ejemplo n.º 6
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);
                    }
                }
            }
        }