Exemplo n.º 1
0
        public static void CreateSpellData(Obj_AI_Base hero, Vector3 spellStartPos, Vector3 spellEndPos,
                                           SpellData spellData, GameObject obj = null, float extraEndTick = 0.0f, bool processSpell = true,
                                           SpellType spellType = SpellType.None, bool checkEndExplosion   = true, bool onUpdate     = false, float spellRadius = 0)
        {
            var activeSpells = detectedSpells.Select(entry => entry.Value);

            if (activeSpells.Count(spell => spell.info.spellName == spellData.spellName) > 1 && onUpdate)
            {
                return;
            }

            var checkEndCollision = ObjectCache.menuCache.cache["CheckSpellCollision"].GetValue <bool>();

            if (checkEndExplosion && spellData.hasEndExplosion)
            {
                if (checkEndCollision)
                {
                    var predictedEndTime = spellData.spellDelay + (spellData.range / spellData.projectileSpeed) * 1000;
                    if (!collisionObjs.ContainsKey(spellIDCount))
                    {
                        collisionObjs.Add(spellIDCount,
                                          new CollisionCandidate(hero, spellStartPos.To2D(), spellIDCount, EvadeUtils.TickCount, spellStartPos.To2D(),
                                                                 spellEndPos.To2D(), spellData, predictedEndTime));
                    }
                }

                CreateSpellData(hero, spellStartPos, spellEndPos, spellData,
                                obj, extraEndTick, false, spellData.spellType, false);

                CreateSpellData(hero, spellStartPos, spellEndPos, spellData,
                                obj, extraEndTick, true, SpellType.Circular, false);

                return;
            }

            if (spellStartPos.Distance(myHero.Position) < spellData.range + 1000)
            {
                Vector2 startPosition = spellStartPos.To2D();
                Vector2 endPosition   = spellEndPos.To2D();
                Vector2 direction     = (endPosition - startPosition).Normalized();
                float   endTick       = 0;

                if (spellType == SpellType.None)
                {
                    spellType = spellData.spellType;
                }

                if (spellData.fixedRange) //for diana q
                {
                    if (endPosition.Distance(startPosition) > spellData.range)
                    {
                        endPosition = startPosition + direction * spellData.range;
                    }
                }

                if (spellType == SpellType.Line)
                {
                    endTick     = spellData.spellDelay + (spellData.range / spellData.projectileSpeed) * 1000;
                    endPosition = startPosition + direction * spellData.range;

                    if (spellData.useEndPosition)
                    {
                        var range = spellEndPos.To2D().Distance(spellStartPos.To2D());
                        endTick     = spellData.spellDelay + (range / spellData.projectileSpeed) * 1000;
                        endPosition = spellEndPos.To2D();
                    }

                    if (obj != null)
                    {
                        endTick -= spellData.spellDelay;
                    }
                }
                else if (spellType == SpellType.Circular)
                {
                    endTick = spellData.spellDelay;

                    if (spellData.projectileSpeed == 0)
                    {
                        endPosition = hero.ServerPosition.To2D();
                    }
                    else if (spellData.projectileSpeed > 0)
                    {
                        endTick = endTick + 1000 * startPosition.Distance(endPosition) / spellData.projectileSpeed;

                        if (spellData.spellType == SpellType.Line && spellData.hasEndExplosion && !spellData.useEndPosition)
                        {
                            if (checkEndCollision)
                            {
                                if (!onUpdate)
                                {
                                    endPosition = Vector2.Zero;
                                    endTick     = 0;
                                }
                                else
                                {
                                    endTick -= spellData.spellDelay;
                                }
                            }
                            else
                            {
                                endPosition = startPosition + direction * spellData.range;
                            }
                        }
                    }
                }
                else if (spellType == SpellType.Arc)
                {
                    endTick = endTick + 1000 * startPosition.Distance(endPosition) / spellData.projectileSpeed;

                    if (obj != null)
                    {
                        endTick -= spellData.spellDelay;
                    }
                }
                else if (spellType == SpellType.Cone)
                {
                    return;
                }
                else
                {
                    return;
                }

                if (spellData.invert)
                {
                    var dir = (startPosition - endPosition).Normalized();
                    endPosition = startPosition + dir * startPosition.Distance(endPosition);
                }

                if (spellData.isPerpendicular)
                {
                    startPosition = spellEndPos.To2D() - direction.Perpendicular() * spellData.secondaryRadius;
                    endPosition   = spellEndPos.To2D() + direction.Perpendicular() * spellData.secondaryRadius;
                }

                endTick += extraEndTick;

                Spell newSpell = new Spell();

                newSpell.startTime = EvadeUtils.TickCount;
                newSpell.endTime   = EvadeUtils.TickCount + endTick;
                newSpell.startPos  = startPosition;
                newSpell.endPos    = endPosition;
                newSpell.height    = spellEndPos.Z + spellData.extraDrawHeight;
                newSpell.direction = direction;
                newSpell.heroID    = hero.NetworkId;
                newSpell.info      = spellData;
                newSpell.spellType = spellType;
                newSpell.radius    = spellRadius > 0 ? spellRadius : newSpell.GetSpellRadius();

                if (obj != null)
                {
                    newSpell.spellObject  = obj;
                    newSpell.projectileID = obj.NetworkId;
                }

                int spellID = CreateSpell(newSpell, processSpell);

                DelayAction.Add((int)(endTick + spellData.extraEndTime), () => DeleteSpell(spellID));
            }
        }
Exemplo n.º 2
0
        private static void CheckSpellCollision()
        {
            if (ObjectCache.menuCache.cache["CheckSpellCollision"].GetValue <bool>() == false)
            {
                return;
            }

            foreach (KeyValuePair <int, Spell> entry in detectedSpells)
            {
                Spell spell           = entry.Value;
                var   collisionObject = spell.CheckSpellCollision();
                if (collisionObject != null)
                {
                    spell.predictedEndPos = spell.GetSpellProjection(collisionObject.ServerPosition.To2D());

                    if (spell.currentSpellPosition.Distance(collisionObject.ServerPosition) <
                        collisionObject.BoundingRadius + spell.radius)
                    {
                        if (!spell.info.hasEndExplosion || spell.spellType != SpellType.Circular)
                        {
                            DelayAction.Add(1, () => DeleteSpell(entry.Key));
                        }
                    }
                }
            }

            foreach (KeyValuePair <int, CollisionCandidate> entry in collisionObjs)
            {
                CollisionCandidate cand = entry.Value;

                var spellTime = cand.spellTime = EvadeUtils.TickCount - cand.startTick - cand.spellInfo.spellDelay;
                if (spellTime >= 0)
                {
                    cand.currentPos = cand.startPos +
                                      (cand.endPos - cand.startPos).Normalized() * cand.spellInfo.projectileSpeed *
                                      (cand.spellTime / 1000);
                }

                var collisionObj = cand.currentPos.To3D().CheckPositionCollision(cand.endPos.To3D(), cand.spellInfo, false);
                if (collisionObj != null)
                {
                    var data = cand.spellInfo.CopyData();
                    data.spellDelay = 0;

                    foreach (KeyValuePair <int, Spell> value in detectedSpells)
                    {
                        Spell spell = value.Value;

                        if (spell.spellType == SpellType.Line && spell.info.hasEndExplosion)
                        {
                            if (spell.info.spellName == cand.spellInfo.spellName)
                            {
                                DelayAction.Add(1, () => DeleteSpell(value.Key)); // delete the skillshot
                            }
                        }
                    }

                    CreateSpellData(cand.candidateHero, cand.startPos.To3D(), collisionObj.ServerPosition,
                                    data, null, 0, true, SpellType.Circular, false, true); // create the explosion

                    collisionObjs.Remove(cand.candidateId);
                    break;
                }

                DelayAction.Add((int)cand.endTime, () => collisionObjs.Remove(cand.candidateId));
            }
        }
Exemplo n.º 3
0
        public static void CreateSpellData(Obj_AI_Base hero, Vector3 spellStartPos, Vector3 spellEndPos,
                                           SpellData spellData, GameObject obj = null, float extraEndTick = 0.0f, bool processSpell = true,
                                           SpellType spellType = SpellType.None, bool checkEndExplosion   = true, float spellRadius = 0)
        {
            if (checkEndExplosion && spellData.hasEndExplosion)
            {
                CreateSpellData(hero, spellStartPos, spellEndPos, spellData,
                                obj, extraEndTick, false, spellData.spellType, false);

                CreateSpellData(hero, spellStartPos, spellEndPos, spellData,
                                obj, extraEndTick, true, SpellType.Circular, false);

                return;
            }

            if (spellStartPos.Distance(myHero.Position) < spellData.range + 1000)
            {
                var startPosition = spellStartPos.To2D();
                var endPosition   = spellEndPos.To2D();
                var direction     = (endPosition - startPosition).Normalized();
                var endTick       = 0f;

                if (spellType == SpellType.None)
                {
                    spellType = spellData.spellType;
                }

                if (spellData.fixedRange) //for diana q
                {
                    if (endPosition.Distance(startPosition) > spellData.range)
                    {
                        endPosition = startPosition + direction * spellData.range;
                    }
                }

                if (spellType == SpellType.Line)
                {
                    endTick     = spellData.spellDelay + (spellData.range / spellData.projectileSpeed) * 1000;
                    endPosition = startPosition + direction * spellData.range;

                    if (spellData.fixedRange) // for all lines
                    {
                        if (endPosition.Distance(startPosition) < spellData.range)
                        {
                            endPosition = startPosition + direction * spellData.range;
                        }
                    }

                    if (endPosition.Distance(startPosition) > spellData.range)
                    {
                        endPosition = startPosition + direction * spellData.range;
                    }

                    if (spellData.useEndPosition)
                    {
                        var range = endPosition.Distance(startPosition);
                        endTick = spellData.spellDelay + (range / spellData.projectileSpeed) * 1000;
                    }

                    if (obj != null)
                    {
                        endTick -= spellData.spellDelay;
                    }
                }
                else if (spellType == SpellType.Circular)
                {
                    endTick = spellData.spellDelay;

                    if (endPosition.Distance(startPosition) > spellData.range)
                    {
                        endPosition = startPosition + direction * spellData.range;
                    }

                    if (spellData.projectileSpeed == 0 && hero != null)
                    {
                        endPosition = hero.ServerPosition.To2D();
                    }
                    else if (spellData.projectileSpeed > 0)
                    {
                        endTick = endTick + 1000 * startPosition.Distance(endPosition) / spellData.projectileSpeed;

                        if (spellData.spellType == SpellType.Line && spellData.hasEndExplosion)
                        {
                            if (!spellData.useEndPosition)
                            {
                                endPosition = startPosition + direction * spellData.range;
                            }
                        }
                    }
                }
                else if (spellType == SpellType.Arc)
                {
                    endTick = endTick + 1000 * startPosition.Distance(endPosition) / spellData.projectileSpeed;

                    if (obj != null)
                    {
                        endTick -= spellData.spellDelay;
                    }
                }
                else if (spellType == SpellType.Cone)
                {
                    endPosition = startPosition + direction * spellData.range;
                    endTick     = spellData.spellDelay;

                    if (endPosition.Distance(startPosition) > spellData.range)
                    {
                        endPosition = startPosition + direction * spellData.range;
                    }

                    if (spellData.projectileSpeed == 0 && hero != null)
                    {
                        endPosition = hero.ServerPosition.To2D();
                    }
                    else if (spellData.projectileSpeed > 0)
                    {
                        endTick = endTick + 1000 * startPosition.Distance(endPosition) / spellData.projectileSpeed;
                    }
                }
                else
                {
                    return;
                }

                if (spellData.invert)
                {
                    var dir = (startPosition - endPosition).Normalized();
                    endPosition = startPosition + dir * startPosition.Distance(endPosition);
                }

                if (spellData.isPerpendicular)
                {
                    startPosition = spellEndPos.To2D() - direction.Perpendicular() * spellData.secondaryRadius;
                    endPosition   = spellEndPos.To2D() + direction.Perpendicular() * spellData.secondaryRadius;
                }

                endTick += extraEndTick;

                Spell newSpell = new Spell();
                newSpell.startTime = EvadeUtils.TickCount;
                newSpell.endTime   = EvadeUtils.TickCount + endTick;
                newSpell.startPos  = startPosition;
                newSpell.endPos    = endPosition;
                newSpell.height    = spellEndPos.Z + spellData.extraDrawHeight;
                newSpell.direction = direction;
                newSpell.info      = spellData;
                newSpell.spellType = spellType;
                newSpell.radius    = spellRadius > 0 ? spellRadius : newSpell.GetSpellRadius();

                if (spellType == SpellType.Cone)
                {
                    newSpell.radius  = 100 + (newSpell.radius * 3); // for now.. eh
                    newSpell.cnStart = startPosition + direction;
                    newSpell.cnLeft  = endPosition + direction.Perpendicular() * newSpell.radius;
                    newSpell.cnRight = endPosition - direction.Perpendicular() * newSpell.radius;
                }

                if (hero != null)
                {
                    newSpell.heroID = hero.NetworkId;
                }

                if (obj != null)
                {
                    newSpell.spellObject  = obj;
                    newSpell.projectileID = obj.NetworkId;
                }

                int spellID = CreateSpell(newSpell, processSpell);

                if (extraEndTick != 1337f) // traps
                {
                    DelayAction.Add((int)(endTick + spellData.extraEndTime), () => DeleteSpell(spellID));
                }
            }
        }
Exemplo n.º 4
0
        public static void CreateSpellData(Obj_AI_Base hero, Vector3 spellStartPos, Vector3 spellEndPos,
                                           SpellData spellData, GameObject obj = null, float extraEndTick = 0.0f, bool processSpell = true,
                                           SpellType spellType = SpellType.None, bool checkEndExplosion   = true, float spellRadius = 0)
        {
            if (checkEndExplosion && spellData.hasEndExplosion)
            {
                CreateSpellData(hero, spellStartPos, spellEndPos,
                                spellData, obj, extraEndTick, false,
                                spellData.spellType, false);

                CreateSpellData(hero, spellStartPos, spellEndPos,
                                spellData, obj, extraEndTick, true,
                                SpellType.Circular, false);

                return;
            }

            if (spellStartPos.Distance(myHero.Position) < spellData.range + 1000)
            {
                Vector2 startPosition = spellStartPos.To2D();
                Vector2 endPosition   = spellEndPos.To2D();
                Vector2 direction     = (endPosition - startPosition).Normalized();
                float   endTick       = 0;

                if (spellType == SpellType.None)
                {
                    spellType = spellData.spellType;
                }

                if (spellData.fixedRange) //for diana q
                {
                    if (endPosition.Distance(startPosition) > spellData.range)
                    {
                        //var heroCastPos = hero.ServerPosition.To2D();
                        //direction = (endPosition - heroCastPos).Normalized();
                        endPosition = startPosition + direction * spellData.range;
                    }
                }

                if (spellType == SpellType.Line)
                {
                    endTick     = spellData.spellDelay + (spellData.range / spellData.projectileSpeed) * 1000;
                    endPosition = startPosition + direction * spellData.range;

                    if (spellData.useEndPosition)
                    {
                        var range = spellEndPos.To2D().Distance(spellStartPos.To2D());
                        endTick     = spellData.spellDelay + (range / spellData.projectileSpeed) * 1000;
                        endPosition = spellEndPos.To2D();
                    }

                    if (obj != null)
                    {
                        endTick -= spellData.spellDelay;
                    }
                }
                else if (spellType == SpellType.Circular)
                {
                    endTick = spellData.spellDelay;

                    if (spellData.projectileSpeed == 0)
                    {
                        endPosition = hero.ServerPosition.To2D();
                    }
                    else if (spellData.projectileSpeed > 0)
                    {
                        if (spellData.spellType == SpellType.Line &&
                            spellData.hasEndExplosion &&
                            spellData.useEndPosition == false)
                        {
                            endPosition = startPosition + direction * spellData.range;
                        }

                        endTick = endTick + 1000 * startPosition.Distance(endPosition) / spellData.projectileSpeed;
                    }
                }
                else if (spellType == SpellType.Arc)
                {
                    endTick = endTick + 1000 * startPosition.Distance(endPosition) / spellData.projectileSpeed;

                    if (obj != null)
                    {
                        endTick -= spellData.spellDelay;
                    }
                }
                else if (spellType == SpellType.Cone)
                {
                    return;
                }
                else
                {
                    return;
                }

                endTick += extraEndTick;

                Spell newSpell = new Spell();

                newSpell.startTime = EvadeUtils.TickCount;
                newSpell.endTime   = EvadeUtils.TickCount + endTick;
                newSpell.startPos  = startPosition;
                newSpell.endPos    = endPosition;
                newSpell.height    = spellEndPos.Z + spellData.extraDrawHeight;
                newSpell.direction = direction;
                newSpell.heroID    = hero.NetworkId;
                newSpell.info      = spellData;
                newSpell.spellType = spellType;
                newSpell.radius    = spellRadius > 0 ? spellRadius : newSpell.GetSpellRadius();

                if (obj != null)
                {
                    newSpell.spellObject  = obj;
                    newSpell.projectileID = obj.NetworkId;
                }

                int spellID = CreateSpell(newSpell, processSpell);

                DelayAction.Add((int)(endTick + spellData.extraEndTime), () => DeleteSpell(spellID));
            }
        }
Exemplo n.º 5
0
        //private void TestUnderTurret()
        //{
        //    if (Game.CursorPos.To2D().IsUnderTurret())
        //    {
        //        Render.Circle.DrawCircle(Game.CursorPos, 50, Color.Red, 3);
        //    }
        //    else
        //    {
        //        Render.Circle.DrawCircle(Game.CursorPos, 50, Color.White, 3);
        //    }
        //}

        private void Drawing_OnDraw(EventArgs args)
        {
            //PrintTimers();

            //EvadeHelper.CheckMovePath(Game.CursorPos.To2D());

            //TestUnderTurret();


            /*if (EvadeHelper.CheckPathCollision(myHero, Game.CursorPos.To2D()))
             * {
             *  var paths = myHero.GetPath(ObjectCache.myHeroCache.serverPos2DExtra.To3D(), Game.CursorPos);
             *  foreach (var path in paths)
             *  {
             *      Render.Circle.DrawCircle(path, ObjectCache.myHeroCache.boundingRadius, Color.Red, 3);
             *  }
             * }
             * else
             * {
             *  Render.Circle.DrawCircle(Game.CursorPos, ObjectCache.myHeroCache.boundingRadius, Color.White, 3);
             * }*/

            foreach (KeyValuePair <int, Spell> entry in SpellDetector.drawSpells)
            {
                Spell spell = entry.Value;

                if (spell.spellType == SpellType.Line)
                {
                    Vector2 spellPos = spell.currentSpellPosition;


                    Render.Circle.DrawCircle(new Vector3(spellPos.X, spellPos.Y, myHero.Position.Z), spell.info.radius, Color.White, 3);

                    /*spellPos = spellPos + spell.direction * spell.info.projectileSpeed * (60 / 1000); //move the spellPos by 50 miliseconds forwards
                     * spellPos = spellPos + spell.direction * 200; //move the spellPos by 50 units forwards
                     *
                     * Render.Circle.DrawCircle(new Vector3(spellPos.X, spellPos.Y, myHero.Position.Z), spell.info.radius, Color.White, 3);*/
                }
            }

            if (testMenu.Get <CheckBox>("TestHeroPos").CurrentValue)
            {
                var path = myHero.Path;
                if (path.Length > 0)
                {
                    var heroPos2 = EvadeHelper.GetRealHeroPos(ObjectCache.gamePing + 50);// path[path.Length - 1].To2D();
                    var heroPos1 = ObjectCache.myHeroCache.serverPos2D;

                    Render.Circle.DrawCircle(new Vector3(heroPos2.X, heroPos2.Y, myHero.ServerPosition.Z), ObjectCache.myHeroCache.boundingRadius, Color.Red, 3);
                    Render.Circle.DrawCircle(new Vector3(myHero.ServerPosition.X, myHero.ServerPosition.Y, myHero.ServerPosition.Z), ObjectCache.myHeroCache.boundingRadius, Color.White, 3);

                    var heroPos   = Drawing.WorldToScreen(ObjectManager.Player.Position);
                    var dimension = Drawing.GetTextEntent("Evade: ON", 12);
                    Drawing.DrawText(heroPos.X - dimension.Width / 2, heroPos.Y, Color.Red, "" + (int)(heroPos2.Distance(heroPos1)));

                    Render.Circle.DrawCircle(new Vector3(circleRenderPos.X, circleRenderPos.Y, myHero.ServerPosition.Z), 10, Color.Red, 3);
                }
            }

            if (testMenu.Get <CheckBox>("DrawHeroPos").CurrentValue)
            {
                Render.Circle.DrawCircle(new Vector3(myHero.ServerPosition.X, myHero.ServerPosition.Y, myHero.ServerPosition.Z), ObjectCache.myHeroCache.boundingRadius, Color.White, 3);
            }


            if (testMenu.Get <KeyBind>("TestMoveTo").CurrentValue)
            {
                //var keyBind = testMenu.Get<KeyBind>("TestMoveTo"); TODO: ??
                //testMenu.Item("TestMoveTo").SetValue(new KeyBind(keyBind.Key, KeyBindType.Toggle, false));

                /*lastRightMouseClickTime = EvadeUtils.TickCount;
                 * myHero.IssueOrder(GameObjectOrder.MoveTo, Game.CursorPos,false);*/

                Player.IssueOrder(GameObjectOrder.MoveTo, Game.CursorPos);

                var dir = (Game.CursorPos - myHero.Position).Normalized();
                //var pos2 = myHero.Position - dir * Game.CursorPos.Distance(myHero.Position);

                //var pos2 = myHero.Position.To2D() - dir.To2D() * 75;
                var pos2 = Game.CursorPos.To2D() - dir.To2D() * 75;

                //Console.WriteLine(myHero.BBox.Maximum.Distance(myHero.Position));

                DelayAction.Add(20, () => Player.IssueOrder(GameObjectOrder.MoveTo, pos2.To3D(), false));
                //myHero.IssueOrder(GameObjectOrder.MoveTo, pos2, false);
            }

            if (testMenu.Get <CheckBox>("TestPath").CurrentValue)
            {
                var     tPath     = myHero.GetPath(Game.CursorPos);
                Vector2 lastPoint = Vector2.Zero;

                foreach (Vector3 point in tPath)
                {
                    var point2D = point.To2D();
                    Render.Circle.DrawCircle(new Vector3(point.X, point.Y, point.Z), ObjectCache.myHeroCache.boundingRadius, Color.Violet, 3);

                    lastPoint = point2D;
                }
            }

            if (testMenu.Get <CheckBox>("TestPath").CurrentValue)
            {
                var     tPath     = myHero.GetPath(Game.CursorPos);
                Vector2 lastPoint = Vector2.Zero;

                foreach (Vector3 point in tPath)
                {
                    var point2D = point.To2D();
                    //Render.Circle.DrawCircle(new Vector3(point.X, point.Y, point.Z), ObjectCache.myHeroCache.boundingRadius, Color.Violet, 3);

                    lastPoint = point2D;
                }

                foreach (KeyValuePair <int, Spell> entry in SpellDetector.spells)
                {
                    Spell spell = entry.Value;

                    Vector2 to = Game.CursorPos.To2D();
                    var     dir = (to - myHero.Position.To2D()).Normalized();
                    Vector2 cPos1, cPos2;

                    var cpa     = MathUtilsCPA.CPAPointsEx(myHero.Position.To2D(), dir * ObjectCache.myHeroCache.moveSpeed, spell.endPos, spell.direction * spell.info.projectileSpeed, to, spell.endPos);
                    var cpaTime = MathUtilsCPA.CPATime(myHero.Position.To2D(), dir * ObjectCache.myHeroCache.moveSpeed, spell.endPos, spell.direction * spell.info.projectileSpeed);

                    //ConsolePrinter.Print("" + cpaTime);
                    //Render.Circle.DrawCircle(cPos1.To3D(), ObjectCache.myHeroCache.boundingRadius, Color.Red, 3);

                    if (cpa < ObjectCache.myHeroCache.boundingRadius + spell.radius)
                    {
                    }
                }
            }

            if (testMenu.Get <CheckBox>("ShowBuffs").CurrentValue)
            {
                var target = myHero;

                foreach (var hero in HeroManager.Enemies)
                {
                    target = hero;
                }

                var buffs = target.Buffs;

                //ConsolePrinter.Print(myHero.ChampionName);

                //if(myHero.IsDead)
                //    ConsolePrinter.Print("dead");

                if (!target.IsTargetable)
                {
                    ConsolePrinter.Print("invul" + EvadeUtils.TickCount);
                }

                int height = 20;

                foreach (var buff in buffs)
                {
                    if (buff.IsValid())
                    {
                        Drawing.DrawText(10, height, Color.White, buff.Name);
                        height += 20;

                        ConsolePrinter.Print(buff.Name);
                    }
                }
            }

            if (testMenu.Get <CheckBox>("TestTracker").CurrentValue)
            {
                foreach (KeyValuePair <int, ObjectTrackerInfo> entry in ObjectTracker.objTracker)
                {
                    var info = entry.Value;

                    Vector3 endPos2;
                    if (info.usePosition == false)
                    {
                        endPos2 = info.obj.Position;
                    }
                    else
                    {
                        endPos2 = info.position;
                    }

                    Render.Circle.DrawCircle(new Vector3(endPos2.X, endPos2.Y, myHero.Position.Z), 50, Color.Green, 3);
                }


                /*foreach (var obj in ObjectManager.Get<Obj_AI_Minion>())
                 * {
                 *  ConsolePrinter.Print("minion: " + obj.Name);
                 *  if (obj.Name == "Ekko")
                 *  {
                 *      var pos = obj.Position;
                 *      Render.Circle.DrawCircle(pos, 100, Color.Green, 3);
                 *  }
                 * }*/
            }

            if (testMenu.Get <CheckBox>("ShowMissileInfo").CurrentValue)
            {
                if (testMissile != null)
                {
                    //Render.Circle.DrawCircle(testMissile.Position, testMissile.BoundingRadius, Color.White, 3);
                }
            }

            if (testMenu.Get <CheckBox>("TestWall").CurrentValue)
            {
                /*foreach (var posInfo in sortedBestPos)
                 * {
                 *  var posOnScreen = Drawing.WorldToScreen(posInfo.position.To3D());
                 *  //Drawing.DrawText(posOnScreen.X, posOnScreen.Y, Color.Aqua, "" + (int)posInfo.closestDistance);
                 *
                 *
                 *  if (!posInfo.rejectPosition)
                 *  {
                 *      Drawing.DrawText(posOnScreen.X, posOnScreen.Y, Color.Aqua, "" + (int)posInfo.closestDistance);
                 *  }
                 *
                 *  Drawing.DrawText(posOnScreen.X, posOnScreen.Y, Color.Aqua, "" + (int)posInfo.closestDistance);
                 *
                 *  if (posInfo.posDangerCount <= 0)
                 *  {
                 *      var pos = posInfo.position;
                 *      Render.Circle.DrawCircle(new Vector3(pos.X, pos.Y, myHero.Position.Z), (float)25, Color.White, 3);
                 *  }
                 * }*/

                int posChecked    = 0;
                int maxPosToCheck = 50;
                int posRadius     = 50;
                int radiusIndex   = 0;

                Vector2             heroPoint = ObjectCache.myHeroCache.serverPos2D;
                List <PositionInfo> posTable  = new List <PositionInfo>();

                while (posChecked < maxPosToCheck)
                {
                    radiusIndex++;

                    int curRadius       = radiusIndex * (2 * posRadius);
                    int curCircleChecks = (int)Math.Ceiling((2 * Math.PI * (double)curRadius) / (2 * (double)posRadius));

                    for (int i = 1; i < curCircleChecks; i++)
                    {
                        posChecked++;
                        var cRadians = (2 * Math.PI / (curCircleChecks - 1)) * i; //check decimals
                        var pos      = new Vector2((float)Math.Floor(heroPoint.X + curRadius * Math.Cos(cRadians)), (float)Math.Floor(heroPoint.Y + curRadius * Math.Sin(cRadians)));

                        if (EvadeHelper.CheckPathCollision(myHero, pos))
                        {
                            Render.Circle.DrawCircle(new Vector3(pos.X, pos.Y, myHero.Position.Z), (float)25, Color.White, 3);
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
        private void SpellMissile_OnCreate(GameObject obj, EventArgs args)
        {
            /*if (sender.Name.ToLower().Contains("minion")
            || sender.Name.ToLower().Contains("turret")
            || sender.Type == GameObjectType.obj_GeneralParticleEmitter)
            || {
            ||  return;
            || }
            ||
            || if (sender.IsValid<MissileClient>())
            || {
            ||  var tMissile = sender as MissileClient;
            ||  if (tMissile.SpellCaster.Type != GameObjectType.AIHeroClient)
            ||  {
            ||      return;
            ||  }
            || }
            ||
            || ConsolePrinter.Print(sender.Type + " : " + sender.Name);*/

            //if ((obj as MissileClient) != null)
            //{
            //    MissileClient autoattack = (MissileClient)obj;

            //    /*if (!autoattack.SpellCaster.IsMinion)
            //    {
            //        ConsolePrinter.Print("Missile Name " + autoattack.SData.Name);
            //        ConsolePrinter.Print("Missile Speed " + autoattack.SData.MissileSpeed);
            //        ConsolePrinter.Print("LineWidth " + autoattack.SData.LineWidth);
            //        ConsolePrinter.Print("Range " + autoattack.SData.CastRange);
            //        ConsolePrinter.Print("Accel " + autoattack.SData.MissileAccel);
            //    }*/
            //}


            //ConsolePrinter.Print(obj.Name + ": " + obj.Type);

            if (obj.GetType() != typeof(MissileClient))
            {
                return;
            }

            if (testMenu.Get <CheckBox>("ShowMissileInfo").CurrentValue)
            {
                return;
            }


            MissileClient missile = (MissileClient)obj;

            if (missile.SpellCaster.GetType() != typeof(AIHeroClient) || ((AIHeroClient)missile.SpellCaster).IsValid())
            {
                return;
            }


            var testMissileSpeedStartTime = EvadeUtils.TickCount;
            var testMissileSpeedStartPos  = missile.Position.To2D();

            DelayAction.Add(250, () =>
            {
                if (missile != null && missile.IsValid && !missile.IsDead)
                {
                    testMissileSpeedStartTime = EvadeUtils.TickCount;
                    testMissileSpeedStartPos  = missile.Position.To2D();
                }
            });

            testMissile          = missile;
            testMissileStartTime = EvadeUtils.TickCount;

            ConsolePrinter.Print("Est.CastTime: " + (EvadeUtils.TickCount - lastHeroSpellCastTime));
            ConsolePrinter.Print("Missile Name " + missile.SData.Name);
            ConsolePrinter.Print("Missile Speed " + missile.SData.MissileSpeed);
            ConsolePrinter.Print("Max Speed " + missile.SData.MissileMaxSpeed);
            ConsolePrinter.Print("LineWidth " + missile.SData.LineWidth);
            ConsolePrinter.Print("Range " + missile.SData.CastRange);
            //ConsolePrinter.Print("Angle " + missile.SData.CastConeAngle);

            /*ConsolePrinter.Print("Offset: " + missile.SData.ParticleStartOffset);
             * ConsolePrinter.Print("Missile Speed " + missile.SData.MissileSpeed);
             * ConsolePrinter.Print("LineWidth " + missile.SData.LineWidth);
             * circleRenderPos = missile.SData.ParticleStartOffset.To2D();*/

            //ConsolePrinter.Print("Acquired: " + (EvadeUtils.TickCount - lastSpellCastTime));

            Draw.RenderObjects.Add(
                new Draw.RenderCircle(missile.StartPosition.To2D(), 500));
            Draw.RenderObjects.Add(
                new Draw.RenderCircle(missile.EndPosition.To2D(), 500));

            DelayAction.Add(750, () =>
            {
                if (missile != null && missile.IsValid && !missile.IsDead)
                {
                    var dist = missile.Position.To2D().Distance(testMissileSpeedStartPos);
                    ConsolePrinter.Print("Est.Missile speed: " + dist / (EvadeUtils.TickCount - testMissileSpeedStartTime));
                }
            });

            SpellData spellData;

            if (missile.SpellCaster != null && missile.SpellCaster.Team != myHero.Team &&
                missile.SData.Name != null && SpellDetector.onMissileSpells.TryGetValue(missile.SData.Name, out spellData) &&
                missile.StartPosition != null && missile.EndPosition != null)
            {
                if (missile.StartPosition.Distance(myHero.Position) < spellData.range + 1000)
                {
                    var hero = missile.SpellCaster;

                    if (hero.IsVisible)
                    {
                        foreach (KeyValuePair <int, Spell> entry in SpellDetector.spells)
                        {
                            Spell spell = entry.Value;

                            if (spell.info.missileName == missile.SData.Name &&
                                spell.heroID == missile.SpellCaster.NetworkId)
                            {
                                if (spell.info.isThreeWay == false && spell.info.isSpecial == false)
                                {
                                    //spell.spellObject = obj;
                                    ConsolePrinter.Print("Acquired: " + (EvadeUtils.TickCount - spell.startTime));
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 7
0
        private void DodgeSkillShots()
        {
            if (!Situation.ShouldDodge())
            {
                isDodging = false;
                return;
            }

            /*
             * if (isDodging && playerInDanger == false) //serverpos test
             * {
             *  myHero.IssueOrder(GameObjectOrder.HoldPosition, myHero, false);
             * }*/

            if (isDodging)
            {
                if (lastPosInfo != null)
                {
                    /*foreach (KeyValuePair<int, Spell> entry in SpellDetector.spells)
                     * {
                     *  Spell spell = entry.Value;
                     *
                     *  Console.WriteLine("" + (int)(TickCount-spell.startTime));
                     * }*/


                    Vector2 lastBestPosition = lastPosInfo.position;

                    if (ObjectCache.menuCache.cache["RecalculatePosition"].GetValue <bool>())//recheck path
                    {
                        var dodgeInterval = ObjectCache.menuCache.cache["DodgeInterval"].GetValue <Slider>().Value;
                        if (lastPosInfo != null && !lastPosInfo.recalculatedPath &&
                            dodgeInterval <= EvadeUtils.TickCount - lastPosInfo.timestamp)
                        {
                            var path = myHero.Path;
                            if (path.Length > 0)
                            {
                                var movePos = path[path.Length - 1].To2D();

                                if (movePos.Distance(lastPosInfo.position) < 5) //more strict checking
                                {
                                    var posInfo = EvadeHelper.CanHeroWalkToPos(movePos, ObjectCache.myHeroCache.moveSpeed, 0, 0, false);
                                    if (posInfo.isSamePosInfo(lastPosInfo) &&
                                        posInfo.posDangerCount > lastPosInfo.posDangerCount)
                                    {
                                        var newPosInfo = EvadeHelper.GetBestPosition();
                                        if (newPosInfo.posDangerCount < posInfo.posDangerCount)
                                        {
                                            lastPosInfo = newPosInfo;
                                            CheckHeroInDanger();
                                        }
                                        else if (EvadeSpell.PreferEvadeSpell())
                                        {
                                            lastPosInfo = PositionInfo.SetAllUndodgeable();
                                        }
                                        else
                                        {
                                            lastPosInfo.recalculatedPath = true;
                                        }
                                    }
                                }
                            }
                        }
                    }

                    EvadeCommand.MoveTo(lastBestPosition);

                    if (Game.Time * 1000 - lastIssueOrderTime < 1)
                    {
                        DelayAction.Add(0, () => EvadeCommand.MoveTo(lastBestPosition));
                    }
                }
            }
            else //if not dodging
            {
                //return;
                //Check if hero will walk into a skillshot
                var path = myHero.Path;
                if (path.Length > 0)
                {
                    var movePos = path[path.Length - 1].To2D();

                    if (EvadeHelper.CheckMovePath(movePos))
                    {
                        var posInfo = EvadeHelper.GetBestPositionMovementBlock(movePos);
                        if (posInfo != null)
                        {
                            EvadeCommand.MoveTo(posInfo.position);

                            if (Game.Time * 1000 - lastIssueOrderTime < 1)
                            {
                                DelayAction.Add(0, () => EvadeCommand.MoveTo(posInfo.position));
                            }
                        }
                        return;
                    }
                }
            }
        }
Exemplo n.º 8
0
        public static bool ActivateEvadeSpell(Spell spell, bool checkSpell = false)
        {
            if (spell.info.spellName.Contains("_trap"))
            {
                return(false);
            }

            var sortedEvadeSpells = evadeSpells.OrderBy(s => s.dangerlevel);

            var   extraDelayBuffer    = ObjectCache.menuCache.cache["ExtraPingBuffer"].GetValue <Slider>().Value;
            float spellActivationTime = ObjectCache.menuCache.cache["SpellActivationTime"].GetValue <Slider>().Value + ObjectCache.gamePing + extraDelayBuffer;

            if (ObjectCache.menuCache.cache["CalculateWindupDelay"].GetValue <bool>())
            {
                var extraWindupDelay = Evade.lastWindupTime - EvadeUtils.TickCount;
                if (extraWindupDelay > 0)
                {
                    return(false);
                }
            }

            foreach (var evadeSpell in sortedEvadeSpells)
            {
                var processSpell = true;

                if (ObjectCache.menuCache.cache[evadeSpell.name + "UseEvadeSpell"].GetValue <bool>() == false ||
                    GetSpellDangerLevel(evadeSpell) > spell.GetSpellDangerLevel() ||
                    (evadeSpell.isItem == false && myHero.Spellbook.CanUseSpell(evadeSpell.spellKey) != SpellState.Ready) ||
                    (evadeSpell.isItem && !Items.CanUseItem((int)evadeSpell.itemID)) ||
                    (evadeSpell.checkSpellName && myHero.Spellbook.GetSpell(evadeSpell.spellKey).Name != evadeSpell.spellName))
                {
                    continue; //can't use spell right now
                }

                float evadeTime, spellHitTime;
                spell.CanHeroEvade(myHero, out evadeTime, out spellHitTime);

                float finalEvadeTime = (spellHitTime - evadeTime);

                if (checkSpell)
                {
                    var mode = ObjectCache.menuCache.cache[evadeSpell.name + "EvadeSpellMode"]
                               .GetValue <StringList>().SelectedIndex;

                    if (mode == 0)
                    {
                        continue;
                    }
                    else if (mode == 1)
                    {
                        if (spellActivationTime < finalEvadeTime)
                        {
                            continue;
                        }
                    }
                }
                else
                {
                    //if (ObjectCache.menuCache.cache[evadeSpell.name + "LastResort"].GetValue<bool>())
                    if (evadeSpell.spellDelay <= 50 && evadeSpell.evadeType != EvadeType.Dash)
                    {
                        var path = myHero.Path;
                        if (path.Length > 0)
                        {
                            var movePos = path[path.Length - 1].To2D();
                            var posInfo = EvadeHelper.CanHeroWalkToPos(movePos, ObjectCache.myHeroCache.moveSpeed, 0, 0);

                            if (GetSpellDangerLevel(evadeSpell) > posInfo.posDangerLevel)
                            {
                                continue;
                            }
                        }
                    }
                }

                if (evadeSpell.evadeType != EvadeType.Dash && spellHitTime > evadeSpell.spellDelay + 100 + Game.Ping +
                    ObjectCache.menuCache.cache["ExtraPingBuffer"].GetValue <Slider>().Value)
                {
                    processSpell = false;

                    if (checkSpell == false)
                    {
                        continue;
                    }
                }

                if (evadeSpell.isSpecial)
                {
                    if (evadeSpell.useSpellFunc != null)
                    {
                        if (evadeSpell.useSpellFunc(evadeSpell, processSpell))
                        {
                            return(true);
                        }
                    }

                    continue;
                }
                else if (evadeSpell.evadeType == EvadeType.Blink)
                {
                    if (evadeSpell.castType == CastType.Position)
                    {
                        var posInfo = EvadeHelper.GetBestPositionBlink();
                        if (posInfo != null)
                        {
                            CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.position), processSpell);
                            //DelayAction.Add(50, () => myHero.IssueOrder(GameObjectOrder.MoveTo, posInfo.position.To3D()));
                            return(true);
                        }
                    }
                    else if (evadeSpell.castType == CastType.Target)
                    {
                        var posInfo = EvadeHelper.GetBestPositionTargetedDash(evadeSpell);
                        if (posInfo != null && posInfo.target != null && posInfo.posDangerLevel == 0)
                        {
                            CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.target), processSpell);
                            //DelayAction.Add(50, () => myHero.IssueOrder(GameObjectOrder.MoveTo, posInfo.position.To3D()));
                            return(true);
                        }
                    }
                }
                else if (evadeSpell.evadeType == EvadeType.Dash)
                {
                    if (evadeSpell.castType == CastType.Position)
                    {
                        var posInfo = EvadeHelper.GetBestPositionDash(evadeSpell);
                        if (posInfo != null && CompareEvadeOption(posInfo, checkSpell))
                        {
                            if (evadeSpell.isReversed)
                            {
                                var dir   = (posInfo.position - ObjectCache.myHeroCache.serverPos2D).Normalized();
                                var range = ObjectCache.myHeroCache.serverPos2D.Distance(posInfo.position);
                                var pos   = ObjectCache.myHeroCache.serverPos2D - dir * range;

                                posInfo.position = pos;
                            }

                            CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.position), processSpell);
                            //DelayAction.Add(50, () => myHero.IssueOrder(GameObjectOrder.MoveTo, posInfo.position.To3D()));
                            return(true);
                        }
                    }
                    else if (evadeSpell.castType == CastType.Target)
                    {
                        var posInfo = EvadeHelper.GetBestPositionTargetedDash(evadeSpell);
                        if (posInfo != null && posInfo.target != null && posInfo.posDangerLevel == 0)
                        {
                            CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.target), processSpell);
                            //DelayAction.Add(50, () => myHero.IssueOrder(GameObjectOrder.MoveTo, posInfo.position.To3D()));
                            return(true);
                        }
                    }
                }
                else if (evadeSpell.evadeType == EvadeType.WindWall)
                {
                    if (spell.hasProjectile() || evadeSpell.spellName == "FioraW") //temp fix, don't have fiora :'(
                    {
                        var dir = (spell.startPos - ObjectCache.myHeroCache.serverPos2D).Normalized();
                        var pos = ObjectCache.myHeroCache.serverPos2D + dir * 100;

                        CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, pos), processSpell);
                        return(true);
                    }
                }
                else if (evadeSpell.evadeType == EvadeType.SpellShield)
                {
                    if (evadeSpell.isItem)
                    {
                        CastEvadeSpell(() => Items.UseItem((int)evadeSpell.itemID), processSpell);
                        return(true);
                    }

                    if (evadeSpell.castType == CastType.Target)
                    {
                        CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, myHero), processSpell);
                        return(true);
                    }

                    if (evadeSpell.castType == CastType.Self)
                    {
                        CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell), processSpell);
                        return(true);
                    }
                }
                else if (evadeSpell.evadeType == EvadeType.MovementSpeedBuff)
                {
                    if (evadeSpell.isItem)
                    {
                        var posInfo = EvadeHelper.GetBestPosition();
                        if (posInfo != null)
                        {
                            CastEvadeSpell(() => Items.UseItem((int)evadeSpell.itemID), processSpell);
                            DelayAction.Add(5, () => EvadeCommand.MoveTo(posInfo.position));
                            return(true);
                        }
                    }
                    else
                    {
                        if (evadeSpell.castType == CastType.Self)
                        {
                            var posInfo = EvadeHelper.GetBestPosition();
                            if (posInfo != null)
                            {
                                CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell), processSpell);
                                DelayAction.Add(5, () => EvadeCommand.MoveTo(posInfo.position));
                                return(true);
                            }
                        }

                        else if (evadeSpell.castType == CastType.Position)
                        {
                            var posInfo = EvadeHelper.GetBestPosition();
                            if (posInfo != null)
                            {
                                CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.position), processSpell);
                                DelayAction.Add(5, () => EvadeCommand.MoveTo(posInfo.position));
                                return(true);
                            }
                        }
                    }
                }
            }

            return(false);
        }
Exemplo n.º 9
0
        public static void CreateSpellData(Obj_AI_Base hero, Vector3 startStartPos, Vector3 spellEndPos,
                                           SpellData spellData, GameObject obj = null, float extraEndTick = 0.0f, bool processSpell = true)
        {
            if (startStartPos.Distance(myHero.Position) < spellData.range + 1000)
            {
                Vector2 startPosition = startStartPos.To2D();
                Vector2 endPosition   = spellEndPos.To2D();
                Vector2 direction     = (endPosition - startPosition).Normalized();
                float   endTick       = 0;

                if (spellData.fixedRange) //for diana q
                {
                    if (endPosition.Distance(startPosition) > spellData.range)
                    {
                        //var heroCastPos = hero.ServerPosition.To2D();
                        //direction = (endPosition - heroCastPos).Normalized();
                        endPosition = startPosition + direction * spellData.range;
                    }
                }

                if (spellData.spellType == SpellType.Line)
                {
                    endTick     = spellData.spellDelay + (spellData.range / spellData.projectileSpeed) * 1000;
                    endPosition = startPosition + direction * spellData.range;

                    if (obj != null)
                    {
                        endTick -= spellData.spellDelay;
                    }
                }
                else if (spellData.spellType == SpellType.Circular)
                {
                    endTick = spellData.spellDelay;

                    if (spellData.projectileSpeed == 0)
                    {
                        endPosition = hero.ServerPosition.To2D();
                    }
                    else if (spellData.projectileSpeed > 0)
                    {
                        endTick = endTick + 1000 * startPosition.Distance(endPosition) / spellData.projectileSpeed;
                    }
                }
                else if (spellData.spellType == SpellType.Cone)
                {
                    return;
                }

                endTick += extraEndTick;

                Spell newSpell = new Spell();

                newSpell.startTime = EvadeUtils.TickCount;
                newSpell.endTime   = EvadeUtils.TickCount + endTick;
                newSpell.startPos  = startPosition;
                newSpell.endPos    = endPosition;
                newSpell.direction = direction;
                newSpell.heroID    = hero.NetworkId;
                newSpell.info      = spellData;

                if (obj != null)
                {
                    newSpell.spellObject  = obj;
                    newSpell.projectileID = obj.NetworkId;
                }

                int spellID = CreateSpell(newSpell, processSpell);

                DelayAction.Add((int)endTick, () => DeleteSpell(spellID));
            }
        }