Example #1
0
        public static PositionInfo CompareLastMovePos(this PositionInfo newPosInfo)
        {
            PositionInfo posInfo = null;
            var          path    = MyHero.Path;

            if (path.Length > 0)
            {
                var movePos = path[path.Length - 1].To2D();
                posInfo = EvadeHelper.CanHeroWalkToPos(movePos, GameData.HeroInfo.MoveSpeed, 0, 0, false);
            }
            else
            {
                posInfo = EvadeHelper.CanHeroWalkToPos(GameData.HeroInfo.ServerPos2D, GameData.HeroInfo.MoveSpeed, 0, 0, false);
            }

            if (posInfo.PosDangerCount < newPosInfo.PosDangerCount)
            {
                return(posInfo);
            }

            return(newPosInfo);
        }
Example #2
0
        private void RecalculatePath()
        {
            if (ObjectCache.menuCache.cache["RecalculatePosition"].As <MenuBool>().Enabled&& isDodging) //recheck path
            {
                if (lastPosInfo != null && !lastPosInfo.recalculatedPath)
                {
                    var path = myHero.Path;
                    if (path.Length > 0)
                    {
                        var movePos = path.Last().To2D();

                        if (movePos.Distance(lastPosInfo.position) < 5) //more strict checking
                        {
                            var posInfo =
                                EvadeHelper.CanHeroWalkToPos(movePos, ObjectCache.myHeroCache.moveSpeed, 0, 0, false);
                            if (posInfo.posDangerCount > lastPosInfo.posDangerCount)
                            {
                                lastPosInfo.recalculatedPath = true;

                                if (EvadeSpell.PreferEvadeSpell())
                                {
                                    lastPosInfo = PositionInfo.SetAllUndodgeable();
                                }
                                else
                                {
                                    var newPosInfo = EvadeHelper.GetBestPosition();
                                    if (newPosInfo.posDangerCount < posInfo.posDangerCount)
                                    {
                                        lastPosInfo = newPosInfo;
                                        CheckHeroInDanger();
                                        DodgeSkillShots();
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Example #3
0
        public static bool IsBetterMovePos(this PositionInfo newPosInfo)
        {
            PositionInfo posInfo = null;
            var          path    = MyHero.Path;

            if (path.Length > 0)
            {
                var movePos = path[path.Length - 1].To2D();
                posInfo = EvadeHelper.CanHeroWalkToPos(movePos, ObjectCache.MyHeroCache.MoveSpeed, 0, 0, false);
            }
            else
            {
                posInfo = EvadeHelper.CanHeroWalkToPos(ObjectCache.MyHeroCache.ServerPos2D, ObjectCache.MyHeroCache.MoveSpeed, 0, 0, false);
            }

            if (posInfo.PosDangerCount < newPosInfo.PosDangerCount)
            {
                return(false);
            }

            return(true);
        }
Example #4
0
        private void RecalculatePath()
        {
            if (ConfigValue.RecalculatePath.GetBool() && IsDodging) //recheck path
            {
                if (LastPosInfo != null && !LastPosInfo.RecalculatedPath)
                {
                    var path = GameData.MyHero.Path;
                    if (path.Length > 0)
                    {
                        var movePos = path.Last().To2D();

                        if (movePos.Distance(LastPosInfo.Position) < 5) //more strict checking
                        {
                            var posInfo = EvadeHelper.CanHeroWalkToPos(movePos, GameData.HeroInfo.MoveSpeed, 0, 0, false);
                            if (posInfo.PosDangerCount > LastPosInfo.PosDangerCount)
                            {
                                LastPosInfo.RecalculatedPath = true;

                                if (EvadeSpell.PreferEvadeSpell())
                                {
                                    LastPosInfo = PositionInfo.SetAllUndodgeable();
                                }
                                else
                                {
                                    var newPosInfo = EvadeHelper.GetBestPosition();
                                    if (newPosInfo.PosDangerCount < posInfo.PosDangerCount)
                                    {
                                        LastPosInfo = newPosInfo;
                                        CheckHeroInDanger();
                                        DodgeSkillShots();
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Example #5
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"].As <MenuSlider>().Value;
            var spellActivationTime = ObjectCache.MenuCache.Cache["SpellActivationTime"].As <MenuSlider>().Value + ObjectCache.GamePing + extraDelayBuffer;

            if (ObjectCache.MenuCache.Cache["CalculateWindupDelay"].Enabled)
            {
                var extraWindupDelay = Evade.LastWindupTime - Environment.TickCount;
                if (extraWindupDelay > 0)
                {
                    return(false);
                }
            }

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

                if (!Evade.EvadeSpellMenu[evadeSpell.CharName + evadeSpell.Name + "EvadeSpellSettings"][evadeSpell.Name + "UseEvadeSpell"].Enabled ||
                    GetSpellDangerLevel(evadeSpell) > spell.GetSpellDangerLevel() || !MyHero.SpellBook.CanUseSpell(evadeSpell.SpellKey) ||
                    evadeSpell.CheckSpellName && MyHero.SpellBook.GetSpell(evadeSpell.SpellKey).Name != evadeSpell.SpellName)
                {
                    continue;
                }

                spell.CanHeroEvade(MyHero, out var evadeTime, out var spellHitTime);

                var finalEvadeTime = spellHitTime - evadeTime;

                if (checkSpell)
                {
                    var mode = Evade.EvadeSpellMenu[evadeSpell.CharName + evadeSpell.Name + "EvadeSpellSettings"][evadeSpell.Name + "EvadeSpellMode"].As <MenuList>().Value;

                    switch (mode)
                    {
                    case 0: continue;

                    case 1:
                        if (spellActivationTime < finalEvadeTime)
                        {
                            continue;
                        }
                        break;
                    }
                }
                else
                {
                    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"].As <MenuSlider>().Value)
                {
                    processSpell = false;

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

                if (evadeSpell.IsSpecial)
                {
                    if (evadeSpell.UseSpellFunc == null)
                    {
                        continue;
                    }
                    if (evadeSpell.UseSpellFunc(evadeSpell, processSpell))
                    {
                        return(true);
                    }
                }
                else
                {
                    switch (evadeSpell.EvadeType)
                    {
                    case EvadeType.Blink:
                        if (evadeSpell.CastType == CastType.Position)
                        {
                            var posInfo = EvadeHelper.GetBestPositionBlink();
                            if (posInfo != null)
                            {
                                if (processSpell)
                                {
                                    MyHero.SpellBook.CastSpell(evadeSpell.SpellKey, posInfo.Position.To3D());
                                }
                                //CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.position), processSpell);
                                //DelayAction.Add(50, () => myHero.IssueOrder(OrderType.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)
                            {
                                if (processSpell)
                                {
                                    MyHero.SpellBook.CastSpell(evadeSpell.SpellKey, posInfo.Target);
                                }
                                //CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.target), processSpell);
                                //DelayAction.Add(50, () => myHero.IssueOrder(OrderType.MoveTo, posInfo.position.To3D()));
                                return(true);
                            }
                        }
                        break;

                    case 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;
                                }

                                if (processSpell)
                                {
                                    MyHero.SpellBook.CastSpell(evadeSpell.SpellKey, 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)
                            {
                                if (processSpell)
                                {
                                    MyHero.SpellBook.CastSpell(evadeSpell.SpellKey, posInfo.Target);
                                }

                                return(true);
                            }
                        }
                        break;

                    case EvadeType.WindWall:
                        if (spell.HasProjectile() || evadeSpell.SpellName == "FioraW")
                        {
                            var dir = (spell.StartPos - ObjectCache.MyHeroCache.ServerPos2D).Normalized();
                            var pos = ObjectCache.MyHeroCache.ServerPos2D + dir * 100;

                            if (processSpell)
                            {
                                MyHero.SpellBook.CastSpell(evadeSpell.SpellKey, pos.To3D());
                            }

                            return(true);
                        }
                        break;

                    case EvadeType.SpellShield:
                        if (evadeSpell.IsItem)
                        {
                            if (processSpell)
                            {
                                MyHero.SpellBook.CastSpell(evadeSpell.SpellKey);
                            }
                            //CastEvadeSpell(() => myHero.SpellBook.CastSpell(evadeSpell.spellKey), processSpell);
                            return(true);
                        }

                        switch (evadeSpell.CastType)
                        {
                        case CastType.Target:
                            if (processSpell)
                            {
                                MyHero.SpellBook.CastSpell(evadeSpell.SpellKey, MyHero);
                            }
                            // CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, myHero), processSpell);
                            return(true);

                        case CastType.Self:
                            if (processSpell)
                            {
                                MyHero.SpellBook.CastSpell(evadeSpell.SpellKey);
                            }
                            //CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell), processSpell);
                            return(true);
                        }

                        break;

                    case EvadeType.MovementSpeedBuff:
                        if (evadeSpell.IsItem)
                        {
                            var posInfo = EvadeHelper.GetBestPosition();
                            if (posInfo != null)
                            {
                                if (processSpell)
                                {
                                    MyHero.SpellBook.CastSpell(evadeSpell.SpellKey);
                                }
                                //CastEvadeSpell(() => myHero.SpellBook.CastSpell(evadeSpell.spellKey), processSpell);
                                DelayAction.Add(5, () => EvadeCommand.MoveTo(posInfo.Position));
                                return(true);
                            }
                        }
                        else
                        {
                            switch (evadeSpell.CastType)
                            {
                            case CastType.Self:
                            {
                                var posInfo = EvadeHelper.GetBestPosition();
                                if (posInfo != null)
                                {
                                    if (processSpell)
                                    {
                                        MyHero.SpellBook.CastSpell(evadeSpell.SpellKey);
                                    }
                                    //CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell), processSpell);
                                    DelayAction.Add(5, () => EvadeCommand.MoveTo(posInfo.Position));
                                    return(true);
                                }
                                break;
                            }

                            case CastType.Position:
                            {
                                var posInfo = EvadeHelper.GetBestPosition();
                                if (posInfo != null)
                                {
                                    if (processSpell)
                                    {
                                        MyHero.SpellBook.CastSpell(evadeSpell.SpellKey, posInfo.Position.To3D());
                                    }
                                    //CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.position), processSpell);
                                    DelayAction.Add(5, () => EvadeCommand.MoveTo(posInfo.Position));
                                    return(true);
                                }
                                break;
                            }

                            case CastType.Target: break;

                            default: throw new ArgumentOutOfRangeException();
                            }
                        }
                        break;
                    }
                }
            }

            return(false);
        }
Example #6
0
        private void Game_OnCastSpell(Spellbook spellbook, SpellbookCastSpellEventArgs args)
        {
            if (!spellbook.Owner.IsMe)
            {
                return;
            }

            var    sData = spellbook.GetSpell(args.Slot);
            string name;

            if (SpellDetector.ChanneledSpells.TryGetValue(sData.Name, out name))
            {
                //Evade.isChanneling = true;
                //Evade.channelPosition = GameData.HeroInfo.serverPos2D;
                LastStopEvadeTime = EvadeUtils.TickCount + Game.Ping + 100;
            }

            if (EvadeSpell.LastSpellEvadeCommand != null &&
                EvadeSpell.LastSpellEvadeCommand.Timestamp + Game.Ping + 150 > EvadeUtils.TickCount)
            {
                args.Process = false;
            }

            LastSpellCast     = args.Slot;
            LastSpellCastTime = EvadeUtils.TickCount;

            //moved from processPacket

            /*if (args.Slot == SpellSlot.Recall)
             * {
             *  lastStopPosition = GameData.MyHero.ServerPosition.To2D();
             * }*/

            if (Situation.ShouldDodge())
            {
                if (IsDodging && SpellDetector.Spells.Count() > 0)
                {
                    foreach (KeyValuePair <String, SpellData> entry in SpellDetector.WindupSpells)
                    {
                        SpellData spellData = entry.Value;

                        if (spellData.SpellKey == args.Slot) //check if it's a spell that we should block
                        {
                            args.Process = false;
                            return;
                        }
                    }
                }
            }

            foreach (var evadeSpell in EvadeSpell.EvadeSpells)
            {
                if (evadeSpell.IsItem == false && evadeSpell.SpellKey == args.Slot)
                {
                    if (evadeSpell.EvadeType == EvadeType.Blink ||
                        evadeSpell.EvadeType == EvadeType.Dash)
                    {
                        //Block spell cast if flashing/blinking into spells
                        if (args.EndPosition.To2D().CheckDangerousPos(6, true)) //for blink + dash
                        {
                            args.Process = false;
                            return;
                        }

                        if (evadeSpell.EvadeType == EvadeType.Dash)
                        {
                            var extraDelayBuffer = Config.Properties.GetInt(ConfigValue.ExtraPingBuffer);
                            var extraDist        = Config.Properties.GetInt(ConfigValue.ExtraCpaDistance);

                            var dashPos = Game.CursorPos.To2D(); //real pos?

                            if (evadeSpell.FixedRange)
                            {
                                var dir = (dashPos - GameData.MyHero.ServerPosition.To2D()).Normalized();
                                dashPos = GameData.MyHero.ServerPosition.To2D() + dir * evadeSpell.Range;
                            }

                            //Draw.RenderObjects.Add(new Draw.RenderPosition(dashPos, 1000));

                            var posInfo = EvadeHelper.CanHeroWalkToPos(dashPos, evadeSpell.Speed,
                                                                       extraDelayBuffer + Game.Ping, extraDist);

                            if (posInfo.PosDangerLevel > 0)
                            {
                                args.Process = false;
                                return;
                            }
                        }

                        LastPosInfo = PositionInfo.SetAllUndodgeable(); //really?

                        if (IsDodging || EvadeUtils.TickCount < LastDodgingEndTime + 500)
                        {
                            EvadeCommand.MoveTo(Game.CursorPos.To2D()); //block moveto
                            LastStopEvadeTime = EvadeUtils.TickCount + Game.Ping + 100;
                        }
                    }
                    return;
                }
            }
        }
Example #7
0
        private void Game_OnCastSpell(Obj_AI_Base sender, SpellBookCastSpellEventArgs args)
        {
            if (!sender.IsMe)
            {
                return;
            }

            var    sData = sender.SpellBook.GetSpell(args.Slot);
            string name;

            if (SpellDetector.channeledSpells.TryGetValue(sData.Name, out name))
            {
                lastStopEvadeTime = EvadeUtils.TickCount + ObjectCache.gamePing + 100;
            }

            //block spell commmands if evade spell just used
            if (EvadeSpell.lastSpellEvadeCommand != null &&
                EvadeSpell.lastSpellEvadeCommand.timestamp + ObjectCache.gamePing + 150 > EvadeUtils.TickCount)
            {
                args.Process = false;
            }

            lastSpellCast     = args.Slot;
            lastSpellCastTime = EvadeUtils.TickCount;

            //moved from processPacket

            /*if (args.Slot == SpellSlot.Recall)
             * {
             *  lastStopPosition = myHero.ServerPosition.To2D();
             * }*/

            // fix : uncomment all
            if (Situation.ShouldDodge())
            {
                if (isDodging && SpellDetector.spells.Any())
                {
                    foreach (var entry in SpellDetector.windupSpells)
                    {
                        var spellData = entry.Value;

                        if (spellData.spellKey == args.Slot) //check if it's a spell that we should block
                        {
                            args.Process = false;
                            return;
                        }
                    }
                }
            }

            foreach (var evadeSpell in EvadeSpell.evadeSpells)
            {
                if (evadeSpell.isItem == false && evadeSpell.spellKey == args.Slot &&
                    evadeSpell.untargetable == false)
                {
                    if (evadeSpell.evadeType == EvadeType.Blink)
                    {
                        var blinkPos = args.Start.To2D();

                        var posInfo = EvadeHelper.CanHeroWalkToPos(blinkPos, evadeSpell.speed, ObjectCache.gamePing, 0);
                        if (posInfo != null && posInfo.posDangerLevel == 0)
                        {
                            //Console.WriteLine("Evade spell");
                            EvadeCommand.MoveTo(posInfo.position);
                            lastStopEvadeTime = EvadeUtils.TickCount + ObjectCache.gamePing + evadeSpell.spellDelay;
                        }
                    }

                    if (evadeSpell.evadeType == EvadeType.Dash)
                    {
                        var dashPos = args.Start.To2D();
                        // fix : uncommont .target
                        if (args.Target != null)
                        {
                            dashPos = args.Target.Position.To2D();
                        }

                        if (evadeSpell.fixedRange || dashPos.Distance(myHero.ServerPosition.To2D()) > evadeSpell.range)
                        {
                            var dir = (dashPos - myHero.ServerPosition.To2D()).Normalized();
                            dashPos = myHero.ServerPosition.To2D() + dir * evadeSpell.range;
                        }

                        var posInfo = EvadeHelper.CanHeroWalkToPos(dashPos, evadeSpell.speed, ObjectCache.gamePing, 0);
                        if (posInfo != null && posInfo.posDangerLevel > 0)
                        {
                            args.Process = false;
                            return;
                        }

                        if (isDodging || EvadeUtils.TickCount < lastDodgingEndTime + 500)
                        {
                            //Console.WriteLine("Evade Spell 2");
                            EvadeCommand.MoveTo(Game.CursorPos.To2D());
                            lastStopEvadeTime = EvadeUtils.TickCount + ObjectCache.gamePing + 100;
                        }
                    }
                    return;
                }
            }
        }
Example #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"].As <MenuSlider>().Value;
            var spellActivationTime = ObjectCache.menuCache.cache["SpellActivationTime"].As <MenuSlider>().Value +
                                      ObjectCache.gamePing + extraDelayBuffer;

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

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

                if (Evade.evadeSpellMenu[evadeSpell.charName + evadeSpell.name + "EvadeSpellSettings"][
                        evadeSpell.name + "UseEvadeSpell"].As <MenuBool>().Value == false ||
                    GetSpellDangerLevel(evadeSpell) > spell.GetSpellDangerLevel() ||
                    !myHero.SpellBook.CanUseSpell(evadeSpell.spellKey) || 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);

                var finalEvadeTime = spellHitTime - evadeTime;

                if (checkSpell)
                {
                    var mode =
                        Evade.evadeSpellMenu[evadeSpell.charName + evadeSpell.name + "EvadeSpellSettings"][
                            evadeSpell.name + "EvadeSpellMode"]
                        .As <MenuList>().Value;

                    if (mode == 0)
                    {
                        continue;
                    }
                    if (mode == 1)
                    {
                        if (spellActivationTime < finalEvadeTime)
                        {
                            continue;
                        }
                    }
                }
                else
                {
                    //if (Evade.menu[evadeSpell.name + "LastResort"].As<MenuBool>().Enabled)
                    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"].As <MenuSlider>().Value)
                {
                    processSpell = false;

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

                if (evadeSpell.isSpecial)
                {
                    if (evadeSpell.useSpellFunc != null)
                    {
                        if (evadeSpell.useSpellFunc(evadeSpell, processSpell))
                        {
                            return(true);
                        }
                    }
                }
                else if (evadeSpell.evadeType == EvadeType.Blink)
                {
                    if (evadeSpell.castType == CastType.Position)
                    {
                        var posInfo = EvadeHelper.GetBestPositionBlink();
                        if (posInfo != null)
                        {
                            if (processSpell)
                            {
                                myHero.SpellBook.CastSpell(evadeSpell.spellKey, posInfo.position.To3D());
                            }
                            //CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.position), processSpell);
                            //DelayAction.Add(50, () => myHero.IssueOrder(OrderType.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)
                        {
                            if (processSpell)
                            {
                                myHero.SpellBook.CastSpell(evadeSpell.spellKey, posInfo.target);
                            }
                            //CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.target), processSpell);
                            //DelayAction.Add(50, () => myHero.IssueOrder(OrderType.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;
                            }

                            if (processSpell)
                            {
                                myHero.SpellBook.CastSpell(evadeSpell.spellKey, posInfo.position.To3D());
                            }
                            //DelayAction.Add(50, () => myHero.IssueOrder(OrderType.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)
                        {
                            if (processSpell)
                            {
                                myHero.SpellBook.CastSpell(evadeSpell.spellKey, posInfo.target);
                            }
                            //CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.target), processSpell);
                            //DelayAction.Add(50, () => myHero.IssueOrder(OrderType.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;

                        if (processSpell)
                        {
                            myHero.SpellBook.CastSpell(evadeSpell.spellKey, pos.To3D());
                        }
                        //CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, pos), processSpell);
                        return(true);
                    }
                }
                else if (evadeSpell.evadeType == EvadeType.SpellShield)
                {
                    if (evadeSpell.isItem)
                    {
                        if (processSpell)
                        {
                            myHero.SpellBook.CastSpell(evadeSpell.spellKey);
                        }
                        //CastEvadeSpell(() => myHero.SpellBook.CastSpell(evadeSpell.spellKey), processSpell);
                        return(true);
                    }

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

                    if (evadeSpell.castType == CastType.Self)
                    {
                        if (processSpell)
                        {
                            myHero.SpellBook.CastSpell(evadeSpell.spellKey);
                        }
                        //CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell), processSpell);
                        return(true);
                    }
                }
                else if (evadeSpell.evadeType == EvadeType.MovementSpeedBuff)
                {
                    if (evadeSpell.isItem)
                    {
                        var posInfo = EvadeHelper.GetBestPosition();
                        if (posInfo != null)
                        {
                            if (processSpell)
                            {
                                myHero.SpellBook.CastSpell(evadeSpell.spellKey);
                            }
                            //CastEvadeSpell(() => myHero.SpellBook.CastSpell(evadeSpell.spellKey), processSpell);
                            DelayAction.Add(5, () => EvadeCommand.MoveTo(posInfo.position));
                            return(true);
                        }
                    }
                    else
                    {
                        if (evadeSpell.castType == CastType.Self)
                        {
                            var posInfo = EvadeHelper.GetBestPosition();
                            if (posInfo != null)
                            {
                                if (processSpell)
                                {
                                    myHero.SpellBook.CastSpell(evadeSpell.spellKey);
                                }
                                //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)
                            {
                                if (processSpell)
                                {
                                    myHero.SpellBook.CastSpell(evadeSpell.spellKey, posInfo.position.To3D());
                                }
                                //CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.position), processSpell);
                                DelayAction.Add(5, () => EvadeCommand.MoveTo(posInfo.position));
                                return(true);
                            }
                        }
                    }
                }
            }

            return(false);
        }
Example #9
0
        public static bool ActivateEvadeSpell(Spell spell, bool checkSpell = false)
        {
            var sortedEvadeSpells = EvadeSpells.OrderBy(s => s.Dangerlevel);

            var   extraDelayBuffer    = Config.Properties.GetInt(ConfigValue.ExtraPingBuffer);
            float spellActivationTime = ConfigValue.SpellActivationTime.GetInt() + Game.Ping + extraDelayBuffer;

            if (ConfigValue.CalculateWindupDelay.GetBool())
            {
                var extraWindupDelay = ezEvade.LastWindupTime - EvadeUtils.TickCount;
                if (extraWindupDelay > 0)
                {
                    return(false);
                }
            }

            foreach (var evadeSpell in sortedEvadeSpells)
            {
                var processSpell = true;
                if (!Config.Properties.GetEvadeSpell(evadeSpell.Name).Use ||
                    ((int)GetSpellDangerLevel(evadeSpell) > (int)spell.GetSpellDangerLevel()) ||
                    (!evadeSpell.IsItem && 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 = Config.Properties.GetEvadeSpell(evadeSpell.Name).SpellMode;

                    switch (mode)
                    {
                    case SpellModes.Undodgeable:
                        continue;

                    case SpellModes.ActivationTime:
                        if (spellActivationTime < finalEvadeTime)
                        {
                            continue;
                        }
                        break;
                    }
                }
                else
                {
                    //if (ObjectCache.menuCache.cache[evadeSpell.name + "LastResort"].Cast<CheckBox>().CurrentValue)
                    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, GameData.HeroInfo.MoveSpeed, 0, 0);

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

                if (evadeSpell.EvadeType != EvadeType.Dash && spellHitTime > evadeSpell.SpellDelay + 100 + Game.Ping +
                    Config.Properties.GetInt(ConfigValue.ExtraPingBuffer))
                {
                    processSpell = false;

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

                if (evadeSpell.IsSpecial)
                {
                    if (evadeSpell.UseSpellFunc != null)
                    {
                        if (evadeSpell.UseSpellFunc(evadeSpell, processSpell))
                        {
                            return(true);
                        }
                    }
                    continue;
                }

                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 - GameData.HeroInfo.ServerPos2D).Normalized();
                                var range = GameData.HeroInfo.ServerPos2D.Distance(posInfo.Position);
                                var pos   = GameData.HeroInfo.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") //TODO: temp fix, don't have fiora :'(
                    {
                        var dir = (spell.StartPos - GameData.HeroInfo.ServerPos2D).Normalized();
                        var pos = GameData.HeroInfo.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);
                    }
                    else
                    {
                        if (evadeSpell.CastType == CastType.Target)
                        {
                            CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, MyHero), processSpell);
                            return(true);
                        }
                        else if (evadeSpell.CastType == CastType.Self)
                        {
                            CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell), processSpell);
                            return(true);
                        }
                    }
                }
                else if (evadeSpell.EvadeType == EvadeType.MovementSpeedBuff)
                {
                }
            }

            return(false);
        }