Пример #1
0
        private void SpellDetector_OnProcessDetectedSpells()
        {
            ObjectCache.myHeroCache.UpdateInfo();

            if (ObjectCache.menuCache.cache["DodgeSkillShots"].Cast <KeyBind>().CurrentValue == false)
            {
                lastPosInfo = PositionInfo.SetAllUndodgeable();
                EvadeSpell.UseEvadeSpell();
                return;
            }

            if (ObjectCache.myHeroCache.serverPos2D.CheckDangerousPos(0) ||
                ObjectCache.myHeroCache.serverPos2DExtra.CheckDangerousPos(0))
            {
                if (EvadeSpell.PreferEvadeSpell())
                {
                    lastPosInfo = PositionInfo.SetAllUndodgeable();
                }
                else
                {
                    var calculationTimer = EvadeUtils.TickCount;

                    var posInfo = EvadeHelper.GetBestPosition();

                    var caculationTime = EvadeUtils.TickCount - calculationTimer;

                    if (numCalculationTime > 0)
                    {
                        sumCalculationTime += caculationTime;
                        avgCalculationTime  = sumCalculationTime / numCalculationTime;
                    }
                    numCalculationTime += 1;

                    //Console.WriteLine("CalculationTime: " + caculationTime);

                    /*if (EvadeHelper.GetHighestDetectedSpellID() > EvadeHelper.GetHighestSpellID(posInfo))
                     * {
                     *  return;
                     * }*/
                    if (posInfo != null)
                    {
                        lastPosInfo = posInfo.CompareLastMovePos();

                        var travelTime = ObjectCache.myHeroCache.serverPos2DPing.Distance(lastPosInfo.position) /
                                         myHero.MoveSpeed;

                        lastPosInfo.endTime = EvadeUtils.TickCount + travelTime * 1000 - 100;
                    }

                    CheckHeroInDanger();
                    DodgeSkillShots();          //walking
                    CheckLastMoveTo();
                    EvadeSpell.UseEvadeSpell(); //using spells
                }
            }
            else
            {
                lastPosInfo = PositionInfo.SetAllDodgeable();
                CheckLastMoveTo();
            }


            //Console.WriteLine("SkillsDodged: " + lastPosInfo.dodgeableSpells.Count + " DangerLevel: " + lastPosInfo.undodgeableSpells.Count);
        }
Пример #2
0
        public static bool ActivateEvadeSpell(Spell spell, bool checkSpell = false)
        {
            var sortedEvadeSpells = evadeSpells.OrderBy(s => s.dangerlevel);

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

            if (ObjectCache.menuCache.cache["CalculateWindupDelay"].Cast <CheckBox>().CurrentValue)
            {
                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"].Cast <CheckBox>().CurrentValue == 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"].Cast <ComboBox>().CurrentValue;

                    if (mode == 0)
                    {
                        continue;
                    }
                    else if (mode == 1)
                    {
                        if (spellActivationTime < finalEvadeTime)
                        {
                            continue;
                        }
                    }
                }
                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].LSTo2D();
                            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"].Cast <Slider>().CurrentValue)
                {
                    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).LSNormalized();
                                var range = ObjectCache.myHeroCache.serverPos2D.LSDistance(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).LSNormalized();
                        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);
                    }
                    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)
                {
                    if (evadeSpell.isItem)
                    {
                        var posInfo = EvadeHelper.GetBestPosition(evadeSpell);
                        if (posInfo != null)
                        {
                            CastEvadeSpell(() => Items.UseItem((int)evadeSpell.itemID), processSpell);
                            EvadeCommand.MoveTo(posInfo.position);
                            return(true);
                        }
                    }
                    else
                    {
                        if (evadeSpell.castType == CastType.Target)
                        {
                            var posInfo = EvadeHelper.GetBestPosition(evadeSpell);
                            if (posInfo != null)
                            {
                                CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, myHero), processSpell);
                                EvadeCommand.MoveTo(posInfo.position);
                                return(true);
                            }
                        }
                        else if (evadeSpell.castType == CastType.Self)
                        {
                            var posInfo = EvadeHelper.GetBestPosition(evadeSpell);
                            if (posInfo != null)
                            {
                                CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell), processSpell);
                                EvadeCommand.MoveTo(posInfo.position);
                                return(true);
                            }
                        }

                        else if (evadeSpell.castType == CastType.Position)
                        {
                            var posInfo = EvadeHelper.GetBestPosition(evadeSpell);
                            if (posInfo != null)
                            {
                                CastEvadeSpell(() => EvadeCommand.CastSpell(evadeSpell, posInfo.position), processSpell);

                                EvadeCommand.MoveTo(posInfo.position);
                                return(true);
                            }
                        }
                    }
                }
            }
            return(false);
        }
Пример #3
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;
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (ObjectCache.menuCache.cache["ClickOnlyOnce"].GetValue <bool>() == false ||
                        lastPosInfo.timestamp > lastEvadeOrderTime)
                    {
                        EvadeCommand.MoveTo(lastBestPosition);
                        lastEvadeOrderTime = EvadeUtils.TickCount;
                    }
                }
            }
            else //if not dodging
            {
                //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))
                    {
                        /*if (ObjectCache.menuCache.cache["AllowCrossing"].GetValue<bool>())
                         * {
                         *  var extraDelayBuffer = ObjectCache.menuCache.cache["ExtraPingBuffer"]
                         *      .GetValue<Slider>().Value + 30;
                         *  var extraDist = ObjectCache.menuCache.cache["ExtraCPADistance"]
                         *      .GetValue<Slider>().Value + 10;
                         *
                         *  var tPosInfo = EvadeHelper.CanHeroWalkToPos(movePos, ObjectCache.myHeroCache.moveSpeed, extraDelayBuffer + ObjectCache.gamePing, extraDist);
                         *
                         *  if (tPosInfo.posDangerLevel == 0)
                         *  {
                         *      lastPosInfo = tPosInfo;
                         *      return;
                         *  }
                         * }*/

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