Ejemplo n.º 1
0
        public static void checkLoot()
        {
            CWSpellTimer CheckLootTimer = new CWSpellTimer(500);
            try
            {
                while (true)
                {
                    if (!D3Control.IsInGame() || D3Control.Player.IsDead)
                    {
                        Thread.Sleep(3000);
                        continue;
                    }

                    if (CheckLootTimer.IsReady)
                    {
                        D3Control.checkLoots();
                        CheckLootTimer.Reset();
                    }
                    Thread.Sleep(500);
                }
            }
            catch { }
        }
Ejemplo n.º 2
0
        void handleStrafe()
        {
            CWSpellTimer checkBuffTimer = new CWSpellTimer(5 * 1000);
            CWSpellTimer castGeneratorTimer = new CWSpellTimer(CombatConfig.DHNatalyaWWSettings.HatredGeneratorTimer * 1000);
            if (D3Control.canCast("Strafe")) //
            {
                CWSpellTimer tempTimer2 = new CWSpellTimer(60 * 1000, false);
                var cancast = false;
                int retryTimes = 0;
                do
                {
                recast:
                    bool RGBossFight = false;
                    if (checkIgnoreandMaxTrial(ref LiveMobsAround))
                        break;
                    if (!D3Control.IsInGame() || D3Control.Player.IsDead)
                    {
                        return;
                    }
                    if (D3Control.Player.HpPct < 45)
                        D3Control.usePotion();

                    if (DoorCheckTimer.IsReady)
                    {
                        D3Control.openDoor(35);
                        DoorCheckTimer.Reset();
                    }
                    LiveMobsAround = D3Control.RetrieveAllObjects(maxScanRange, Descriptor.eActorType.Monster);   // only live mobs will be returned.

                    if (LiveMobsAround == null || LiveMobsAround.Count == 0)
                        return;
                    //float minDistance = float.MaxValue;
                    bool closeEnemy = false;
                    float minDistance = float.MaxValue;
                    bool hasElite = false;

                    for (int i = 0; i < LiveMobsAround.Count; i++)// (var mob in LiveMobsAround)
                    {
                        var mob = LiveMobsAround[i];
                        if (D3Control.ISRG((D3Unit)mob))
                        {
                            RGBossFight = true;
                            RGBoss = mob;
                        }
                        var distance = mob.DistanceFromPlayer;
                        var los = D3Control.LOS(mob);
                        if (minDistance > distance && !los)
                        {
                            minDistance = distance;
                            if (distance <= 55)
                            {
                                closeEnemy = true;
                            }
                        }
                        else if (distance >= 60)
                        {   // remove all the non-visible and far mobs
                            LiveMobsAround.RemoveAt(i--);
                        }
                        if (!hasElite && ((D3Unit)mob).IsElite)
                            hasElite = true;
                    }
                    if (!RGBossFight)
                        RGBoss = null;
                    if (!closeEnemy) // no more enemy nearby?
                        return;
                    //if (CombatConfig.SkillBuild == build.NatalyaWW && (CombatConfig.DHNatalyaWWSettings.RoVOnCD || CombatConfig.DHNatalyaWWSettings.natalyaRoVTimer.IsReady))
                    {
                        // if (CombatConfig.DHNatalyaWWSettings.RoVInterval * 1000 != CombatConfig.DHNatalyaWWSettings.natalyaRoVTimer.Duration)
                        //   CombatConfig.DHNatalyaWWSettings.natalyaRoVTimer.ChangeDuration(CombatConfig.DHNatalyaWWSettings.RoVInterval * 1000);
                        //if (D3Control.canCast("Rain of Vengeance")) // to test if the spell is enabled first then search the best location to cast it
                        {
                            var loc = Surroundings.FindMobBlock(ref LiveMobsAround, FindTypes.Max);
                            if (CastDH1Spell("Rain of Vengeance", loc))
                            {
                                ;
                            }
                        }
                    }

                    Vector3D strafeSpot = null;
                    int lowLifeDistance = 5 * ((100 - D3Control.Player.HpPct) / 30);
                    int eliteDistance = 0;
                    if (hasElite)
                        eliteDistance = 5;

                    strafeSpot = WWCheckGlobeShrineLoc();
                    if (strafeSpot == null)
                    {
                        if (D3Control.isObjectValid(RGBoss))
                            strafeSpot = handleRGAOE(RGBoss.Location);
                        //strafeSpot = selectWWLocation(55, ref LiveMobsAround, 15);

                    }
                    var mob1 = selectClosestMob(60, ref LiveMobsAround, 50);
                    var hasFocusBuff = D3Control.HasBuff("Focus");
                    if (!hasFocusBuff)
                        D3Control.output("No focus buff?");
                    if (CombatConfig.DHNatalyaWWSettings.CastHatredGenerator && (castGeneratorTimer.IsReady || !hasFocusBuff))
                    {
                        handleHatredGeneratorSkills(mob1.Location);
                        castGeneratorTimer.Reset();
                    }
                    if (strafeSpot == null)
                    {
                        if (LiveMobsAround.Count > 1 && minDistance > CombatConfig.DHNatalyaWWSettings.FightDistance + lowLifeDistance + eliteDistance)
                        {   // too far from the enemies?
                            if (mob1 != null)
                                strafeSpot = mob1.Location;
                        }
                        else
                            strafeSpot = newSelectStrafeLocation(55, ref LiveMobsAround, ref  mob1, 40);// selectStrafeLocation(55, ref LiveMobsAround, 40);
                    }
                    if (D3Control.Player.HpPct <= 75)
                    {
                        if (CastDH2Spell("Shadow Power", D3Control.Player.Location))
                        {

                        }
                        else if (CastDH2Spell("Smoke Screen", D3Control.Player.Location))
                        {
                            //return;
                        }
                        if (!D3Control.HasBuff("Shadow Power"))
                        {
                            if (CastDH2Spell("Shadow Power", D3Control.Player.Location))
                            {
                                return;
                            }

                        }
                    }
                    if (strafeSpot != null)
                    {

                        if (CastDH1Spell("Strafe", strafeSpot))
                        {
                            retryTimes = 0;
                            D3Control.stopMoving();
                            //D3Control.output("Strafe Successful?");
                            //Thread.Sleep(50);// wait a bit?
                            //if (checkBuffTimer.IsReady)
                            {
                                checkBuff(D3Control.Player);
                                checkBuffTimer.Reset();
                            }
                            //Thread.Sleep(100);// wait a bit?

                        }
                        else
                        {
                            if (retryTimes++ < 3 && D3Control.isSpellEnabled("Strafe"))
                            {
                                //LiveMobsAround = D3Control.RetrieveAllObjects(maxScanRange, Descriptor.eActorType.Monster);   // only live mobs will be returned.
                                //strafeSpot = selectStrafeLocation(55, ref LiveMobsAround, 40);
                                goto recast;
                            }
                            D3Control.output("Strafe Failed?");
                            break;
                        }
                    }
                    else
                    {
                        D3Control.output("No Strafe target?");

                        break;
                    }

                    cancast = D3Control.canCast("Strafe");
                    if (!cancast)
                    {
                        D3Control.output("Cannot Cast FStrafe");
                    }
                    else
                    {
                        //Thread.Sleep(50);
                    }

                } while (cancast && !tempTimer2.IsReady);
            }
        }
Ejemplo n.º 3
0
        void handleCarnEvil()
        {
            CWSpellTimer checkBuffTimer = new CWSpellTimer(5 * 1000);
            CWSpellTimer castSpenderTimer = new CWSpellTimer(CombatConfig.WitchDoctorCarnEvilSettings.manaSpenderTimer * 1000);
            {
                CWSpellTimer tempTimer2 = new CWSpellTimer(60 * 1000, false);
                var cancast = false;
                int retryTimes = 0;
                do
                {
                recast:
                    bool RGBossFight = false;
                    if (checkIgnoreandMaxTrial(ref LiveMobsAround))
                        break;
                    if (!D3Control.IsInGame() || D3Control.Player.IsDead)
                    {
                        return;
                    }
                    if (D3Control.Player.HpPct < 45)
                        D3Control.usePotion();
                    checkBuff(D3Control.Player);
                    if (DoorCheckTimer.IsReady)
                    {
                        D3Control.openDoor(35);
                        DoorCheckTimer.Reset();
                    }
                    LiveMobsAround = D3Control.RetrieveAllObjects(maxScanRange, Descriptor.eActorType.Monster);   // only live mobs will be returned.

                    if (LiveMobsAround == null || LiveMobsAround.Count == 0)
                        return;
                    //float minDistance = float.MaxValue;
                    bool closeEnemy = false;
                    float minDistance = float.MaxValue;
                    bool hasElite = false;
                    D3Object closeMob = null;
                    for (int i = 0; i < LiveMobsAround.Count; i++)// (var mob in LiveMobsAround)
                    {
                        var mob = LiveMobsAround[i];
                        if (D3Control.ISRG((D3Unit)mob))
                        {
                            RGBossFight = true;
                            RGBoss = mob;
                        }
                        var distance = mob.DistanceFromPlayer;
                        var los = D3Control.LOS(mob);
                        if (minDistance > distance && !los)
                        {
                            minDistance = distance;
                            if (distance <= 55)
                            {
                                closeEnemy = true;
                            }
                            closeMob = mob;
                        }
                        else if (distance >= 60)
                        {   // remove all the non-visible and far mobs
                            LiveMobsAround.RemoveAt(i--);
                        }
                        if (!hasElite && ((D3Unit)mob).IsElite)
                            hasElite = true;
                    }
                    if (!RGBossFight)
                        RGBoss = null;
                    if (!closeEnemy) // no more enemy nearby?
                        return;

                    Vector3D fightSpot = null;

                    Vector3D spiritSpenderLoc2 = closeMob.Location;
                    if (spiritSpenderLoc2.GetDistanceTo(D3Control.Player.Location) <= 18)
                    {
                        CastWitchDoctorSpell("Soul Harvest", D3Control.Player.Location);
                    }
                    if (RGBossFight)
                        spiritSpenderLoc2 = RGBoss.Location;
                    if (CastWitchDoctorSpell("Hex", closeMob.Location))
                    {

                    }
                    CastWitchDoctorSpell("Big Bad Voodoo", D3Control.Player.Location);
                    //spiritSpenderLoc2 = D3Control.Player.Location;
                    if (CastWitchDoctorSpell("Grasp of the Dead", spiritSpenderLoc2))
                    {
                        //return;
                    }
                    if (castSpenderTimer.IsReady && handleSpenderSkills(spiritSpenderLoc2))
                    {
                        castSpenderTimer.Reset();
                    }
                    fightSpot = WWCheckGlobeShrineLoc();
                    if (fightSpot == null)
                    {
                        if (D3Control.isObjectValid(RGBoss))
                            fightSpot = handleRGAOE(RGBoss.Location);
                        //strafeSpot = selectWWLocation(55, ref LiveMobsAround, 15);

                    }
                    //var mob1 = selectClosestMob(60, ref LiveMobsAround, 50);

                    if (D3Control.Player.HpPct <= CombatConfig.WitchDoctorCarnEvilSettings.spiritWalkHPPct || D3Control.Player.isBeingCCed() || closeMob.DistanceFromPlayer < CombatConfig.WitchDoctorCarnEvilSettings.spiritWalkEnemyDistance)
                    {
                        if (CastWitchDoctorSpell("Spirit Walk", D3Control.Player.Location))
                        {
                        }
                    }
                    if (fightSpot == null)
                    {
                        /*if (LiveMobsAround.Count > 1 && minDistance > CombatConfig.WitchDoctorCarnEvilSettings.fightDistance + lowLifeDistance + eliteDistance)
                        {   // too far from the enemies?
                            if (mob1 != null)
                                strafeSpot = mob1.Location;
                        }
                        else/**/
                        fightSpot = SelectFightLocation(55, ref LiveMobsAround, ref  closeMob, CombatConfig.WitchDoctorCarnEvilSettings.fightDistance, false);// selectStrafeLocation(55, ref LiveMobsAround, 40);
                    }

                    if (fightSpot != null && fightSpot.GetDistanceTo(D3Control.Player.Location) > 5) //  strafeSpot != null)
                    {
                        D3Control.output("Move to a better place.");

                        D3Control.ClickMoveToWait(fightSpot);
                    }
                    else
                    {
                        D3Control.stopMoving();
                        D3Control.output("No need to move?");
                    }
                    //CastWitchDoctorDirectionSpell("Poison Dart", closeMob.Location);
                    CastWitchDoctorTargetSpell("Poison Dart", closeMob);

                } while (!tempTimer2.IsReady);
            }
        }
Ejemplo n.º 4
0
        public void handleCharge()
        {
            CWSpellTimer tempTimer2 = new CWSpellTimer(30 * 1000, false);
            CWSpellTimer checkAncientTimer = new CWSpellTimer(3 * 1000);
            if (D3Control.canCast("Furious Charge")) //
            {
                var cancast = false;
                CWSpellTimer tempTimer = new CWSpellTimer(1500, false);
                do
                {
                    if (!D3Control.IsInGame() || D3Control.Player.IsDead)
                    {
                        return;
                    }
                    if (checkIgnoreandMaxTrial(ref LiveMobsAround))
                        break;
                    var dashingTarget = selectFarestMob(55, ref LiveMobsAround, 50);

                    if (dashingTarget != null)
                    {
                        if (dashingTarget.IsElite || LiveMobsAround.Count > 5)
                        {
                            if (D3Control.canCast("Call of the Ancients") && checkAncientTimer.IsReady && !D3Control.hasThreeAncients() && CastBarbarianSpell("Call of the Ancients", D3Control.Player.Location))
                            {
                                checkAncientTimer.Reset();
                            }
                            else if (!D3Control.HasBuff("Wrath of the Berserker"))
                            {
                                CastBarbarianSpell("Wrath of the Berserker", D3Control.Player.Location);
                            }
                        }
                        int retryTimes = 0;
                    recast:

                        if (LiveMobsAround.Count == 1 && CastBarbarianTargetSpell("Furious Charge", dashingTarget) || CastBarbarianDirectionSpell("Furious Charge", dashingTarget.Location))
                        {
                            retryTimes = 0;
                            D3Control.stopMoving();
                            D3Control.output("Furious Charge Successful?");
                            tempTimer.Reset();
                            Thread.Sleep(200);// wait a bit?
                            while (D3Control.Player.isMovingForward && !tempTimer.IsReady)
                            {
                                Thread.Sleep(50);// wait a bit?
                            }
                            checkBuff(D3Control.Player);

                            //Thread.Sleep(100);// wait a bit?

                        }
                        else
                        {
                            if (retryTimes++ < 3 && D3Control.isSpellEnabled("Furious Charge"))
                            {
                                LiveMobsAround = D3Control.RetrieveAllObjects(maxScanRange, Descriptor.eActorType.Monster);   // only live mobs will be returned.
                                dashingTarget = selectFarestMob(55, ref LiveMobsAround, 50);
                                goto recast;
                            }
                            D3Control.output("Furious Charge Failed?");
                            break;
                        }
                    }
                    else
                    {
                        D3Control.output("No Furious Charge target?");

                        break;
                    }
                    LiveMobsAround = D3Control.RetrieveAllObjects(maxScanRange, Descriptor.eActorType.Monster);   // only live mobs will be returned.
                    if (LiveMobsAround == null || LiveMobsAround.Count == 0)
                        return;
                    if (LiveMobsAround != null && LiveMobsAround.Count > 0 && (CombatConfig.BarbDefaultSettings.IKSpendFury && (!D3Control.isOnCD("Wrath of the Berserker") || !D3Control.isOnCD("Call of the Ancients"))))
                    {   // no spend fury to reduce the cd for berserker or CotA?
                        handleSeismicSlam();
                        if (D3Control.canCast("Hammer of the Ancients"))
                        {
                            var target = GetNextTargetMob(ref LiveMobsAround);
                            if (CastBarbarianTargetSpell("Hammer of the Ancients", target))
                            {
                            }
                        }
                    }/**/

                    cancast = D3Control.canCast("Furious Charge");
                    if (!cancast)
                    {
                        D3Control.output("Cannot Cast Furious Charge?");
                    }
                    else
                    {
                        Thread.Sleep(150);
                    }

                } while (cancast && !tempTimer2.IsReady);
            }
        }

        public void handleThreeLeaps()
        {
            int leapTimes = 1;
            CWSpellTimer tempTimer = new CWSpellTimer(2000, false);
            while (leapTimes < 3 && !tempTimer.IsReady)
            {
                LiveMobsAround = D3Control.RetrieveAllObjects(maxScanRange, Descriptor.eActorType.Monster);   // only live mobs will be returned.
                if (LiveMobsAround.Count > 0)
                    D3Control.output(string.Format("There are {0} mobs around.", LiveMobsAround.Count));
                else
                    D3Control.output(string.Format("No more mobs around?."));
                var TargetMob = GetNextTargetMob(ref LiveMobsAround);
                if (D3Control.isObjectValid(TargetMob))
                {
                    if (CastBarbarianSpell("LeapAttack", TargetMob.Location))
                    {
                        leapTimes++;
                        Thread.Sleep(200);
                    }
                }
                //else
                //    break;
                Thread.Sleep(100);

            }
        }

        public bool moveToStartFight(D3Player entity)
        {
            handleAOE();
            if (D3Control.curTarget == null)
                return false;
            if (D3Control.Player.HpPct <= CombatConfig.BarbDefaultSettings.HealthGlobePct)
            {
                D3Object healthGlobe = D3Control.ClosestHealthGlobe;
                if (healthGlobe != null && !D3Control.LOS(healthGlobe.Location))
                {
                    if (D3Control.CastLocationSpell("Furious Charge", healthGlobe.Location, true))
                    {

                    }
                    D3Control.MoveTo(healthGlobe, 2.5f);
                    return true;
                }
            }
            if (D3Control.Player.HpPct > 80)
            {
                D3Object shrine = D3Control.ClosestShrine;
                if (shrine != null)
                {
                    D3Control.MoveTo(shrine, 5);
                    if (shrine.DistanceFromPlayer < 6)
                    {
                        Thread.Sleep(100);
                        D3Control.interactWithTarget(shrine);
                        return true;
                    }
                }
            }
            if (D3Control.getDoorInWay(D3Control.curTarget) != null)
            {
                D3Control.output("A door inbetween? Try to move closer and open the door.");
                D3Control.MoveTo(D3Control.curTarget, 2.5f);      // a thread doing the move
                return false;
            }

            if (D3Control.isObjectValid(D3Control.curTarget) && !D3Control.curTarget.IsDead)
            {

                if (CombatConfig.SkillBuild == build.BarbIKWW)
                {
                    handleWW();
                }
                else if (CombatConfig.SkillBuild == build.IKHotA)
                {
                    try
                    {
                        handleIKHotA();
                    }
                    catch { }
                }
                else if (D3Control.canCast("Furious Charge")) //
                {
                    handleCharge();
                }
                else if (D3Control.curTarget.DistanceFromPlayer <= 55 && !D3Control.LOS(D3Control.curTarget))
                {
                    if (CastBarbarianSpell("LeapAttack", D3Control.curTarget.Location))
                    {
                        if (CombatConfig.BarbDefaultSettings.ThreeLeaps)
                        {
                            handleThreeLeaps();
                        }
                        else
                        {
                        }
                    }
                }
                if (D3Control.canCast("Weapon Throw"))
                {
                    if (meleeRange < 30)
                        meleeRange = 30;
                }
                var LOS = D3Control.LOS(D3Control.curTarget);
                var dist = D3Control.curTarget.DistanceFromPlayer;
                if (dist > meleeRange || LOS)
                {
                    if (LOS)
                    {
                        if (dist > 5 && meleeRange > dist)
                        {
                            D3Control.MoveTo(D3Control.curTarget, dist - 5);      // a thread doing the move
                        }

                    }

                    if (meleeRange > 12)
                    {
                        D3Control.MoveTo(D3Control.curTarget, meleeRange);      // a thread doing the move
                    }
                    else
                    {
                        D3Control.MoveTo(D3Control.curTarget, 12);      // a thread doing the move
                    }

                }

            }
            return true;
        }

        public D3Unit selectClosestMob(int range, ref List<D3Object> mobs, int idealSkillRange)
        {
            float min = float.MaxValue;
            D3Object idealTarget = null;
            D3Object secondIdealTarget = null;
            var nearMobs = GetNearByEnemy(ref mobs, 15);

            foreach (var mob in mobs)
            {   // for leap slam, pick anyone within the range
                var distance = mob.DistanceFromPlayer;
                if (!D3Control.isObjectValid(mob) || ((D3Unit)mob).IsDead)
                    continue;

                if (isFirstKillTarget((D3Unit)mob) && distance < 50)
                {
                    if (nearMobs.Count < 3)
                    {// if not a lot mobs nearby, try to kill the target with the highest priority.
                        return (D3Unit)mob;
                    }
                }
                //else if (D3Control.IsMobTS(mob))
                //    return (D3Unit)mob;

                if (distance <= range)   // set this range properly. The bot's loot procedure will stop loot if there are mobs within a certain range. So set this range accordingly
                {
                    if (distance < min && distance < idealSkillRange && !D3Control.LOS(mob))
                    {
                        idealTarget = mob;
                        min = distance;
                    }
                    else if (secondIdealTarget == null && distance < min && !D3Control.LOS(mob))
                    {
                        secondIdealTarget = mob;
                    }
                }
            }
            if (idealTarget != null)
            {
                return (D3Unit)idealTarget;
            }
            else if (secondIdealTarget != null)
            {
                return (D3Unit)secondIdealTarget;
            }
            return null;
        }

        public D3Unit selectFarestMob(int range, ref List<D3Object> mobs, int idealSkillRange)
        {
            float max = float.MinValue;
            D3Object idealTarget = null;
            D3Object secondIdealTarget = null;
            foreach (var mob in mobs)
            {
                if (!D3Control.isObjectValid(mob) || ((D3Unit)mob).IsDead)
                    continue;
                var distance = mob.DistanceFromPlayer;
                if (distance <= range)
                {
                    if (distance > max && distance < idealSkillRange && !D3Control.LOS(mob))
                    {
                        idealTarget = mob;
                        max = distance;
                    }
                    else if (secondIdealTarget == null && distance > max && !D3Control.LOS(mob))
                    {
                        secondIdealTarget = mob;
                    }
                }
            }
            if (idealTarget != null)
            {
                return (D3Unit)idealTarget;
            }
            else if (secondIdealTarget != null)
            {
                return (D3Unit)secondIdealTarget;
            }
            return null;
        }

        public Vector3D selectWWLocation(int range, ref List<D3Object> mobs, int idealSkillRange)
        {
            float max = float.MinValue;
            D3Object idealTarget = null;
            D3Object secondIdealTarget = null;
            if (mobs.Count == 1)
            {   // only 1 mob?
                D3Control.output("Boss Fight?");
                idealSkillRange = CombatConfig.BarbIKWWSettings.BossFightDistance;
                var distanceMob = mobs[0].DistanceFromPlayer;
                if (distanceMob >= idealSkillRange)
                {   // too far? move closer, find a spot closer to the target
                    return D3Control.getMySideSpot(mobs[0].Location, 0, distanceMob - idealSkillRange); // 0 is 0 degree which is toward the target, which means to get closer
                }
                if (mobs[0].DistanceFromPlayer < idealSkillRange)
                {   // too close,  backoff a bit,
                    if (CombatConfig.SkillBuild == build.BarbIKWW) // other builds may also call this function
                    {
                        D3Control.output("Too close to the boss?");
                        var loc1 = D3Control.getMySideSpot(mobs[0].Location, 180, idealSkillRange - distanceMob); // 180 is 180 degree , which means to backoff a bit

                        if (D3Control.LOS(loc1))
                        {   // cannot "See" the loc? blocked by something? find a right or left spot*
                            D3Control.output("the spot to back of is no good, try other direction.");

                            loc1 = findAMySideSpot(mobs[0].Location, 30, 15);
                            if (loc1 != null && !D3Control.LOS(loc1))
                            {
                                D3Control.output("left spot is good");
                                return loc1;
                            }
                            loc1 = findAMySideSpot(mobs[0].Location, -30, 15);
                            if (loc1 != null && !D3Control.LOS(loc1))
                            {
                                D3Control.output("right spot is good");

                                return loc1;
                            }
                            loc1 = findAMySideSpot(mobs[0].Location, 0, (int)distanceMob + idealSkillRange);
                            if (loc1 != null && !D3Control.LOS(loc1))
                            {
                                D3Control.output("back, left, and right are all bad, try to go across the mob");

                                return loc1;
                            }
                            else
                            {
                                D3Control.output("okk finally try the mob place");

                                return mobs[0].Location;
                            }
                        }
                        else
                        {
                            D3Control.output("the spot to back of is good to go");

                            return loc1;
                        }
                    }
                }
            }
            var dashingTarget = selectFarestMob(55, ref LiveMobsAround, 50);
            if (dashingTarget != null)
                return dashingTarget.Location;
            return null;
        }

        internal static void setFury()
        {
            if (abilityInfoDic.Count == 0)
            {
                abilityInfoDic.Add("Hammer of the Ancients", 20);
                abilityInfoDic.Add("Siesmic Slam", 30);
                abilityInfoDic.Add("Rend", 20);
                abilityInfoDic.Add("Battle Rage", 20);
                abilityInfoDic.Add("Sprint", 20);
                abilityInfoDic.Add("Whirlwind", 10);
                abilityInfoDic.Add("Ancient Spear", 25);
                abilityInfoDic.Add("Earthquake", 50);
            }
        }

        protected override void DoEnter(D3Player Entity)
        {
        }

        /// <summary>
        /// This happens when we are being attacked by some mobs or when we
        /// have found something to kill 
        /// </summary>
        protected override void DoExecute(D3Player Entity)
        {
            try
            {
                CWSpellTimer combatThresholdTimer = new CWSpellTimer(120 * 1000, false);// in case something is wrong
                Vector3D targetLoc = null;
                bool enemyFound = false;
                var timePre = DateTime.Now;
                while (true)
                {
                    Thread.Sleep(CombatConfig.CombatLoopSleepTime);

                    var timeNow = DateTime.Now;
                    //D3Control.output(string.Format("Loop time is {0}", DateTime.Now.Subtract(timePre).Milliseconds));
                    if (!D3Control.IsInGame() || D3Control.Player.IsDead || combatThresholdTimer.IsReady)
                        break;
                    checkThreadStatus();
                    checkBuff(D3Control.Player);

                    timePre = DateTime.Now;
                    LiveMobsAround = D3Control.RetrieveAllObjects(maxScanRange, Descriptor.eActorType.Monster);   // only live mobs will be returned.
                    /*bool checkIgnore = D3Control.TargetManager.applyIgnoreSettings();
                    if (D3Control.ReachedMaxTrialLevel || checkIgnore && D3Control.IgnoreNumber >= LiveMobsAround.Count)
                    {
                        D3Control.TargetManager.ClearTarget();
                        break;
                    }/**/
                    if (checkIgnoreandMaxTrial(ref LiveMobsAround))
                        break;
                    //D3Control.output(string.Format("Time 1 is {0}", DateTime.Now.Subtract(timePre).Milliseconds));
                    timePre = DateTime.Now;
                    D3Unit TargetMob = null;
                    var nearMobs = GetNearByEnemy(ref LiveMobsAround, 15);

                    if (D3Control.canCast("Revenge"))
                    {
                        if (nearMobs != null && nearMobs.Count > 0)
                        {
                            if (CastBarbarianSpell("Revenge", D3Control.Player.Location))
                                continue;
                        }
                    }
                    if (nearMobs != null && nearMobs.Count > 5)
                    {
                        if (D3Control.CastLocationSpell("Avalanche", nearMobs[0].Location, true))
                            continue;
                    }
                    bool InCombat = D3Control.Player.isInCombat;
                    if (!InCombat)
                    {
                        if (D3Control.GoodLootsAround())
                        {
                            if (nearMobs == null || nearMobs.Count == 0)
                                return;
                        }
                    }
                    TargetMob = GetNextTargetMob(ref LiveMobsAround);
                    if (TargetMob != null)
                    {
                        // D3Control.output(((D3Unit)TargetMob).ToString() );

                    }

                    if (D3.D3Control.curTarget == null)
                    {
                        if (TargetMob != null)
                        {   // ok no current target and find a target mob to kill, do it
                            D3Control.TargetManager.SetAttackTarget(TargetMob);
                        }
                        else
                        {
                            if (InCombat)
                            {
                                D3Control.output("In combat and cannot find next target??");
                                DoExit(D3Control.Player);
                                return;
                            }
                            else
                            {
                                D3Control.output("Out of combat?");
                                D3Control.TargetManager.ClearTarget();
                                DoExit(D3Control.Player);
                                return;
                            }
                        }
                    }
                    else
                    {   // current target is not null

                        if (!D3Control.curTarget.Equals(TargetMob))
                        {
                            try
                            {
                                if (!isFirstKillTarget(D3.D3Control.curTarget))
                                {
                                    if (TargetMob != null)
                                    {
                                        if (isFirstKillTarget(TargetMob))
                                        {
                                            D3Control.TargetManager.SetAttackTarget(TargetMob);
                                        }
                                        else
                                        {
                                            if (!D3Control.curTarget.IsElite)
                                            {
                                                D3Control.output("Target Switched?");
                                                D3Control.stopMoving();
                                                D3Control.TargetManager.SetAttackTarget(TargetMob);
                                            }
                                            else if (D3Control.LOS(D3Control.curTarget))
                                            {
                                                D3Control.output("Target Switched?");
                                                D3Control.stopMoving();
                                                D3Control.TargetManager.SetAttackTarget(TargetMob);
                                            }
                                        }
                                    }
                                }
                                else if (TargetMob != null)
                                {
                                    D3Control.output("Target Switched?");
                                    D3Control.stopMoving();
                                    D3Control.TargetManager.SetAttackTarget(TargetMob);
                                }
                            }
                            catch { }
                        }
                    }
                    if (targetLoc == null || !D3Control.isInCombatMoving())
                    {
                    STARTPulling:

                        if (D3Control.isObjectValid(D3Control.curTarget) && !D3Control.curTarget.IsDead && !D3Control.curTarget.IsNpc && D3Control.curTarget.Type == Descriptor.eActorType.Monster)
                        {
                            // make sure this function call is added if you have a while loop in DoExecute to handle the target selection.
                            // it handles some boss fights, where you have to kill the minions first.
                            targetLoc = D3Control.curTarget.Location;

                            D3Control.TargetManager.handleSpecialFight();
                            meleeRange = D3Control.getMobRange(D3Control.curTarget);
                            timePre = DateTime.Now;

                            try
                            {
                                doPulling(D3Control.Player);
                            }
                            catch { }
                            finally
                            {
                                try2AvoidAOE();
                            }

                            //D3Control.output(string.Format("Time 6 is {0}", DateTime.Now.Subtract(timePre).Milliseconds));
                            timePre = DateTime.Now;

                            continue;
                        }
                        else
                        {
                            D3Control.TargetManager.ClearTarget();
                            if (D3Control.isObjectValid(TargetMob) && !TargetMob.IsDead)
                            {
                                D3Control.TargetManager.SetAttackTarget((D3Unit)TargetMob);
                                TargetMob = null;
                                goto STARTPulling;
                            }
                            else
                                targetLoc = null;/*/**/

                        }
                        if (!D3Control.isObjectValid(TargetMob))
                        {
                            continue;
                        }
                    }
                    else
                    {
                        if (targetLoc == new Vector3D()) // invalid location?
                        {
                            DoExit(D3Control.Player);
                            return;
                        }
                        if (InCombat)
                        {

                            if (D3Control.isObjectValid(TargetMob) && !TargetMob.IsDead)
                            {
                                D3Control.TargetManager.SetAttackTarget((D3Unit)TargetMob);
                                targetLoc = D3Control.curTarget.Location;
                            }
                            else
                            {
                                targetLoc = null;
                            }
                        }/**/
                    }
                }
            }
            catch (Exception e)
            {
                D3Control.output(string.Format("Exception:{0}", e.ToString()));
            }
            DoExit(D3Control.Player);

            return;
        }

        protected override void DoExit(D3Player entity)
        {
            //on exit, if there is a previous state, go back to it
            if (PreviousState != null)
            {
                CallChangeStateEvent(entity, PreviousState, false, false);
            }
        }

        protected override void DoFinish(D3Player entity)
        {
        }

        static void checkThreadStatus()
        {
            if (keepSpellThread != null && keepSpellThread.IsAlive)
            {
            }
            else
            {
                try
                {
                    if (keepSpellThread != null)
                        keepSpellThread.Abort();
                }
                catch { }
                finally
                {
                    keepSpellThread = null;
                }
                keepSpellThread = new Thread(new ThreadStart(keepSpell)) { Name = "Check Buff" }; ;
                keepSpellThread.IsBackground = true;
                keepSpellThread.Start();
            }

            D3Control.checkLootThreadHandling();
        }

        bool checkIgnoreandMaxTrial(ref List<D3Object> Mobs)
        {
            bool res = false;
            bool checkIgnore = D3Control.TargetManager.toIgnore(ref LiveMobsAround);// D3Control.TargetManager.applyIgnoreSettings();
            if (checkIgnore || D3Control.ReachedMaxTrialLevel)
            {
                D3Control.TargetManager.ClearTarget();
                res = true;
            }
            return res;
        }

        void checkSprint()
        {
            if (CombatConfig.BarbIKWWSettings.CastSprint && D3Control.Player.Fury >= CombatConfig.BarbIKWWSettings.CastSprintFuryThreshold)
            {
                if (D3Control.canCast("Sprint") && !D3Control.HasBuff("Sprint"))
                {
                    CastBarbarianSpell("Sprint", D3Control.Player.Location);
                }
            }
        }

        void doFuryGenerator(ref D3Unit target)
        {
            if (CastBarbarianTargetSpell("Bash", target))
            {
            }
            else if (CastBarbarianTargetSpell("Frenzy", target))
            {
            }
            else if (CastBarbarianTargetSpell("Weapon Throw", target))
            {
                //Thread.Sleep(100);
            }
            else if (CastBarbarianTargetSpell("Cleave", target))
            {

            }
        }

        void doPulling(D3Player entity)
        {
            //rendTimer.ChangeDuration(3 * 1000);
            var preTime = DateTime.Now;
            if (!GlobalBaseBotState.checkBeforePull(entity))
                return;
            if (!D3Control.TargetManager.isTargetGoodForAttack((D3Unit)D3Control.curTarget)) // check the internal timer expires, which means the target is not good for attack, then block this target, the block is done inside the fuction call
            {
                return;
            }
            if (CombatConfig.SkillBuild == build.IKHotA)
            {
                try
                {
                    handleIKHotA();
                }
                catch { }
            }
            else
                handleCharge();

            if (!moveToStartFight(entity))
            {
                return;
            }
            D3Unit target = D3Control.curTarget;
            if (!D3Control.isObjectValid(target))
                return;
            bool isElite = target.IsElite;
            bool isTS = D3Control.IsMobTS(target);
            if ((isElite || isTS) && D3Control.Player.isInCombat && target.DistanceFromPlayer < meleeRange)
            {

                if ((CombatConfig.BarbDefaultSettings.EarthquakeSettings.OnTS && isTS || CombatConfig.BarbDefaultSettings.EarthquakeSettings.OnElite && isElite) && CastBarbarianSpell("Earthquake", D3Control.Player.Location))
                {

                }
                else if ((CombatConfig.BarbDefaultSettings.CalloftheAcientsSettings.OnTS && isTS || CombatConfig.BarbDefaultSettings.CalloftheAcientsSettings.OnElite && isElite) && !D3Control.hasThreeAncients() && CastBarbarianSpell("Call of the Ancients", D3Control.Player.Location))
                {
                }
                else if ((CombatConfig.BarbDefaultSettings.WotBSettings.OnTS && isTS || CombatConfig.BarbDefaultSettings.WotBSettings.OnElite && isElite) && CastBarbarianSpell("Wrath of the Berserker", D3Control.Player.Location))
                {
                }
                else if ((CombatConfig.BarbDefaultSettings.AvalancheSettings.OnTS && isTS || CombatConfig.BarbDefaultSettings.AvalancheSettings.OnElite && isElite) && D3Control.CastLocationSpell("Avalanche", target.Location, true))
                {
                }
            }
            else if (target.DistanceFromPlayer < meleeRange)
            {
                if ((CombatConfig.BarbDefaultSettings.EarthquakeSettings.OnCD) && CastBarbarianSpell("Earthquake", D3Control.Player.Location))
                {
                }
                else if ((CombatConfig.BarbDefaultSettings.CalloftheAcientsSettings.OnCD) && !D3Control.hasThreeAncients() && CastBarbarianSpell("Call of the Ancients", D3Control.Player.Location))
                {
                }
                else if ((CombatConfig.BarbDefaultSettings.WotBSettings.OnCD) && CastBarbarianSpell("Wrath of the Berserker", D3Control.Player.Location))
                {
                }

                else if ((CombatConfig.BarbDefaultSettings.AvalancheSettings.OnCD) && D3Control.CastLocationSpell("Avalanche", target.Location, true))
                {
                }
            }
            if (!D3Control.isObjectValid(target) || target.IsDead)
                return;
            if (target.DistanceFromPlayer >= 25 && target.DistanceFromPlayer <= 60 && !D3Control.LOS(target))
            {

                if (CastBarbarianTargetSpell("Ancient Spear", target))
                {
                }

                else if (CastBarbarianSpell("LeapAttack", target.Location))
                {
                    if (CombatConfig.BarbDefaultSettings.ThreeLeaps)
                    {
                        handleThreeLeaps();
                    }
                    else
                    {
                    }
                }
                else if (CastBarbarianTargetSpell("Weapon Throw", target))
                {
                }
            }

            if (D3Control.isObjectValid(target) && !target.IsDead)
            {
                if (target.DistanceFromPlayer <= 20 || target.DistanceFromPlayer <= meleeRange)
                {

                    if (CastBarbarianSpell("Revenge", D3Control.Player.Location))
                    {
                    }
                    else if (target.DistanceFromPlayer <= meleeRange && rendTimer.IsReady && CastBarbarianSpell("Rend", D3Control.Player.Location))
                    {
                        rendTimer.Reset();
                        return;
                    }
                    if (D3Control.canCast("Siesmic Slam"))
                    {
                        var nearbyMobs = GetNearByEnemy(ref LiveMobsAround, 12); // to check nearby mobs first, if there are too many mobs nearby, focus on those first. else, try to find the densest block

                        if (nearbyMobs != null && nearbyMobs.Count > 0)
                        {
                            CastBarbarianSpell("Siesmic Slam", target.Location);
                        }
                        else
                        {

                            var loc = Surroundings.FindMobBlock(ref LiveMobsAround, FindTypes.Max);
                            if (loc == null || loc.Length == 0)
                            {
                                CastBarbarianTargetSpell("Siesmic Slam", nearbyMobs[0]);
                            }
                            else
                            {
                                CastBarbarianSpell("Siesmic Slam", loc);
                                D3Control.output("Siesmic Slam");
                                return;
                            }
                        }

                    }

                    if (CastBarbarianSpell("Overpower", D3Control.Player.Location))   //霸气无双
                    {
                    }
                    if (D3Control.canCast("Whirlwind"))
                    {
                        var wwTarget = selectFarestMob(35, ref LiveMobsAround, 25);

                        if (wwTarget != null)
                        {
                            if (CastBarbarianDirectionSpell("Whirlwind", wwTarget.Location))
                            {
                            }
                        }
                        else if (CastBarbarianDirectionSpell("Whirlwind", D3Control.curTarget.Location))
                        {
                        }

                    }
                    if (CastBarbarianTargetSpell("Hammer of the Ancients", target))
                    {
                    }
                    else if (CastBarbarianTargetSpell("Ancient Spear", target))
                    {
                    }
                    else if (D3Control.Player.Fury < CombatConfig.BarbDefaultSettings.PrimarySkillFuryThreshold) //|| !D3Control.Player.isMovingForward)
                    {
                        if (CastBarbarianTargetSpell("Bash", target))
                        {
                        }
                        else if (CastBarbarianTargetSpell("Frenzy", target))
                        {
                        }
                        else if (CastBarbarianTargetSpell("Weapon Throw", target))
                        {
                            //Thread.Sleep(100);
                        }
                        else if (CastBarbarianTargetSpell("Cleave", target))
                        {

                        }
                        else
                        {
                            CastBarbarianTargetSpell("Default Attack", target);
                        }
                    }
                    // D3Control.output(string.Format("Time spent casting spells 3 {0}", DateTime.Now.Subtract(preTime).TotalMilliseconds));
                }
            }
            return;
        }

        List<D3Object> GetNearByEnemy(ref List<D3Object> Mobs, int range)
        {
            List<D3Object> res = new List<D3Object>();
            if (Mobs != null)
            {
                foreach (var mob in Mobs)
                {
                    if (D3Control.isObjectValid(mob) && !((D3Unit)mob).IsDead)
                    {
                        if (mob.DistanceFromPlayer <= range)
                        {
                            res.Add(mob);
                        }
                    }
                }
            }
            return res;
        }

        D3Unit GetNextTargetMob(ref List<D3Object> liveMobs)
        {
            D3Unit res = null;
            if (CombatConfig.SkillBuild == build.BarbDefault || CombatConfig.SkillBuild == build.BarbIKWW || CombatConfig.SkillBuild == build.IKHotA)
            {
                res = selectClosestMob(CombatConfig.BarbDefaultSettings.InCombatSearchRange, ref liveMobs, 50);
            }
            return res;
        }

        void handleAOE()
        {
            D3Unit closetEnemy = null;
            var nearMobs = GetNearByEnemy(ref LiveMobsAround, 15);
            var count = -1;
            if (nearMobs != null)
                count = nearMobs.Count;
            try
            {
                if ((CombatConfig.BarbDefaultSettings.EarthquakeSettings.NearMobCount <= count) && CastBarbarianSpell("Earthquake", D3Control.Player.Location))
                {
                }
                else if ((CombatConfig.BarbDefaultSettings.CalloftheAcientsSettings.NearMobCount < count) && !D3Control.hasThreeAncients() && CastBarbarianSpell("Call of the Ancients", D3Control.Player.Location))
                {

                }
                else if ((CombatConfig.BarbDefaultSettings.WotBSettings.NearMobCount < count) && CastBarbarianSpell("Wrath of the Berserker", D3Control.Player.Location))
                {
                }
                else if ((CombatConfig.BarbDefaultSettings.AvalancheSettings.NearMobCount < count) && D3Control.CastLocationSpell("Avalanche", nearMobs[0].Location, true))
                {
                }
            }
            catch { }
            finally
            {
                try2AvoidAOE();

            }

            if (D3Control.canCast("Ground Stomp"))
            {
                int stompRange = 14;
                var stompIndex = D3Control.GetSpellRuneIndex("Ground Stomp");
                if (stompIndex == (int)GroundStompRune.WrenchingSmash)
                {
                    stompRange = 24;
                }
                else if (stompIndex == (int)GroundStompRune.FootofthMountain)
                {
                    stompRange = 30;
                }
                var nearMobsGroundStomp = GetNearByEnemy(ref LiveMobsAround, stompRange);

                if (nearMobsGroundStomp.Count > 0 && CastBarbarianSpell("Ground Stomp", D3Control.Player.Location))
                {
                    return;
                }
            }
            if (count > AOEMonsters)
            {
                if (CastBarbarianSpell("Revenge", D3Control.Player.Location))
                {
                    return;
                }
                else if (rendTimer.IsReady && CastBarbarianSpell("Rend", D3Control.Player.Location))
                {
                    rendTimer.Reset();
                    return;
                }

            }
            else
                return;
        }

        void handleIKHotA()
        {
            CWSpellTimer checkBuffTimer = new CWSpellTimer(1 * 1000);
            CWSpellTimer checkAncientTimer = new CWSpellTimer(1 * 1000);
            //CWSpellTimer FGTimer = new CWSpellTimer(CombatConfig.BarbIKWWSettings.CastFuryGeneratorTimer * 1000);
            CWSpellTimer tempTimer2 = new CWSpellTimer(90 * 1000, false);
            var cancast = false;
            int retryTimes = 0;
            do
            {
                try
                {

                recast:

                    if (!D3Control.IsInGame() || D3Control.Player.IsDead)
                    {
                        return;
                    }
                    if (checkIgnoreandMaxTrial(ref LiveMobsAround))
                        break;
                    if (D3Control.Player.HpPct < 45)
                        D3Control.usePotion();
                    if (D3Control.canCast("Call of the Ancients") && checkAncientTimer.IsReady && !D3Control.hasThreeAncients() && CastBarbarianSpell("Call of the Ancients", D3Control.Player.Location))
                    {
                        checkAncientTimer.Reset();
                    }
                    if (!D3Control.HasBuff("Wrath of the Berserker"))
                    {
                        CastBarbarianSpell("Wrath of the Berserker", D3Control.Player.Location);
                    }
                    if (DoorCheckTimer.IsReady)
                    {
                        D3Control.openDoor(35);
                        DoorCheckTimer.Reset();
                    }
                    LiveMobsAround = D3Control.RetrieveAllObjects(maxScanRange, Descriptor.eActorType.Monster);   // only live mobs will be returned.

                    if (LiveMobsAround == null || LiveMobsAround.Count == 0)
                        return;
                    if (D3Control.Player.HpPct <= CombatConfig.BarbDefaultSettings.ignorePainHPPct)
                    {
                        if (CastBarbarianSpell("Ignore Pain", D3Control.Player.Location))
                        {
                        }
                    }
                    //float minDistance = float.MaxValue;
                    bool closeEnemy = false;
                    float minDistance = float.MaxValue;
                    bool hasElite = false;
                    D3Unit closestMob = null;
                    bool RGBossFight = false;
                    foreach (var mob in LiveMobsAround)
                    {
                        var distance = mob.DistanceFromPlayer;
                        if (D3Control.ISRG((D3Unit)mob))
                        {
                            RGBossFight = true;
                            RGBoss = mob;
                        }
                        if (minDistance > distance)
                        {
                            minDistance = distance;
                            closestMob = (D3Unit)mob;
                        }
                        if (!hasElite && ((D3Unit)mob).IsElite)
                            hasElite = true;
                        if (distance <= 55 && !D3Control.LOS(mob))
                        {
                            closeEnemy = true;
                        }
                    }
                    if (!RGBossFight)
                        RGBoss = null;
                    if (!closeEnemy) // no more enemy nearby?
                        return;
                    Vector3D wwSpot = WWCheckGlobeShrineLoc();
                    if (wwSpot == null)
                    {
                        if (D3Control.Player.HpPct <= 80 && avoidAOETimer.IsReady && safeSpot != null)
                        {
                            wwSpot = safeSpot;
                            if (wwSpot != null)
                            {
                                D3Control.output("Try to avoid AOE");
                                if (!D3Control.canCast("Furious Charge"))
                                {   // cannot cast charge, try to cast ww to avoid aoe

                                    if (D3Control.canCast("Whirlwind"))
                                    {
                                        int retryPre = 0;
                                    tryPreiousSpot:
                                        if (CastBarbarianDirectionSpell("Whirlwind", wwSpot))
                                        {
                                        }
                                        if (retryPre < 5 && D3Control.Player.Location.GetDistanceTo(wwSpot) > 3)
                                        {
                                            retryPre++;
                                            goto tryPreiousSpot;
                                        }/**/
                                    }
                                }
                                else
                                {
                                    CombatConfig.BarbIKHotASettings.FGTimer.Reset(); // reset this time to force cast furious charge
                                }
                            }
Ejemplo n.º 5
0
        // the always teleport build
        void handleTalRashaAetherWalker()
        {
            CWSpellTimer checkBuffTimer = new CWSpellTimer(5 * 1000);
            CWSpellTimer teleportTimer = new CWSpellTimer(3 * 1000);
            CWSpellTimer blizzTimer = new CWSpellTimer(7000); // 5.5 secs to make sure you get the tr6 buffer
            CWSpellTimer hydraTimer = new CWSpellTimer(7000);
            CWSpellTimer hydraHardTimer = new CWSpellTimer(2500); // wait at least this time to test again hydra #
            CWSpellTimer bossFightMoveTimer = new CWSpellTimer(3000);
            Vector3D lastBlizzLoc = null;
            Vector3D bossFightSpot = null;
            CWSpellTimer ConventionPrepareTimer = new CWSpellTimer(2 * 1000);
            CWSpellTimer TaegukTimer = new CWSpellTimer(2500);
            bool enteredPrepareState = false;
            // if (D3Control.canCast("Strafe")) //
             {
                CWSpellTimer tempTimer2 = new CWSpellTimer(120 * 1000, false);
                int retryTimes = 0;
                do
                {
                recast:
                    bool RGBossFight = false;
                    DateTime startTime = DateTime.Now;
                    if (checkIgnoreandMaxTrial(ref LiveMobsAround))
                        break;
                    if (!D3Control.IsInGame() || D3Control.Player.IsDead)
                    {
                        return;
                    }
                    if (D3Control.Player.HpPct < 45)
                        D3Control.usePotion();

                    if (DoorCheckTimer.IsReady)
                    {
                        D3Control.openDoor(35);
                        DoorCheckTimer.Reset();
                    }

                    D3Control.CoEType CoEBuffType = D3Control.GetCoEBuffType();
                    if (CoEBuffType == D3Control.CoEType.Cold)
                    {
                        if (!enteredPrepareState)
                        {
                            ConventionPrepareTimer.Reset();
                        }
                        if (ConventionPrepareTimer.IsReady)
                        {   // once this is ready, enter the bombing state
                            enteredPrepareState = true;
                        }
                    }
                    else
                    {
                        enteredPrepareState = false;
                    }

                    LiveMobsAround = D3Control.RetrieveAllObjects(maxScanRange, Descriptor.eActorType.Monster);   // only live mobs will be returned.
                    if (LiveMobsAround == null || LiveMobsAround.Count == 0)
                        return;
                    checkBuff(D3Control.Player);

                    //float minDistance = float.MaxValue;
                    bool closeEnemy = false;
                    float minDistance = float.MaxValue;
                    bool hasElite = false;
                    foreach (var mob in LiveMobsAround)
                    {
                        if (D3Control.ISRG((D3Unit)mob))
                        {
                            RGBossFight = true;
                            RGBoss = mob;
                        }
                        var distance = mob.DistanceFromPlayer;
                        if (minDistance > distance)
                            minDistance = distance;
                        if (!hasElite && ((D3Unit)mob).IsElite)
                            hasElite = true;
                        if (distance <= 55 && !D3Control.LOS(mob))
                        {
                            closeEnemy = true;
                        }
                    }
                    if (!RGBossFight)
                        RGBoss = null;

                    if (!closeEnemy && !RGBossFight) // no more enemy nearby?
                        return;

                    var playerHP = D3Control.Player.HpPct;
                    bossFightSpot = null;

                    var coeState = D3Control.GetCoEBuffType();

                    bool canCastTeleport = D3Control.canCast("Teleport");

                    if (RGBossFight && D3Control.canCast("Teleport"))
                    {   // if boss fight && move timer is ready or teleport is ready, MOVE
                        var bossLoc = RGBoss.Location;
                        if (enteredPrepareState || coeState == D3Control.CoEType.Fire)
                        {
                            handleAetherWalkerBossFight(bossLoc);
                        }
                        else
                        {
                            D3Control.output("Boss fight, no nuke time now, trying to get a safe spot");

                            bool hasGoodSpot = false;
                            for (int i = 1; i < 12; i++)
                            {
                                if (!canCastTeleport && (i > 3 || i < 10))
                                    continue;
                                bossFightSpot = D3Control.getStartSideSpot(bossLoc, D3Control.Player.Location, i * 30, 50);
                                if (!D3Control.LOS(bossFightSpot))
                                {
                                    hasGoodSpot = true;
                                    break;
                                }
                            }
                            if (!hasGoodSpot)
                            {
                                D3Control.output("Cannot find a good spot?");
                                bossFightSpot = D3Control.getStartSideSpot(bossLoc, D3Control.Player.Location, 0, 35);
                            }
                            if (bossFightSpot != null)
                            {
                                if (TaegukTimer.IsReady || D3Control.Player.HpPct < 50 || bossFightSpot.GetDistanceTo(D3Control.Player.Location) < 30)
                                {
                                    CastWizardSpell("Teleport", bossFightSpot);
                                    Thread.Sleep(600);
                                    TaegukTimer.Reset();
                                }
                                else //if (CastWizardSpell("Teleport", bossFightSpot))
                                {
                                    D3Control.ClickMoveToWait(bossFightSpot);
                                }
                            }

                        }

                    }
                    // no a boss fight
                    //if (D3Control.canCast("Teleport"))
                    {
                        Vector3D teleportSpot = null;
                        Vector3D meteorSpot = null;
                        teleportSpot = CheckGlobeShrineLoc();
                        if (teleportSpot == null)
                        {
                            if (D3Control.isObjectValid(RGBoss))
                                teleportSpot = handleRGAOE(RGBoss.Location);
                            //strafeSpot = selectWWLocation(55, ref LiveMobsAround, 15);

                        }
                        meteorSpot= Surroundings.FindMobBlock(ref LiveMobsAround, FindTypes.Max);
                        if (teleportSpot == null )//&& (teleportTimer.IsReady || playerHP <= 60))
                        {   // no need to get health globe or the shadow power
                            if (playerHP <= 40)//&& LiveMobsAround.Count == 1)
                            {   // hp too low or RG fight, find a safe place?
                                teleportSpot = Surroundings.FindMobBlock(ref LiveMobsAround, FindTypes.Min);

                            }
                            else
                            {

                                teleportSpot = meteorSpot;

                            }

                            if (teleportSpot == null)
                            {
                                teleportSpot = D3Control.Player.Location;
                            }

                        }

                        if (teleportSpot != null)
                        {
                            if (enteredPrepareState || D3Control.GetCoEBuffType() == D3Control.CoEType.Fire)
                            {
                                handleAetherWalkerTrashFight(teleportSpot, meteorSpot);
                            }
                            else
                            {
                                if (teleportSpot != null)
                                {
                                    if (CastWizardSpell("Teleport", teleportSpot))
                                    {
                                        teleportTimer.Reset();
                                        Thread.Sleep(150);
                                    }
                                }

                            }
                        }
                        //D3Control.output(string.Format("Loop time {0}", DateTime.Now.Subtract(startTime).TotalMilliseconds));
                    }/**/
                } while (!tempTimer2.IsReady);
            }
        }

        bool isFirstKillTarget(D3Unit mob)
        {
            bool res = false;
            res = D3Control.TargetManager.FirstKillTargetIDs.Contains(mob.ID);
            return res;
        }

        bool IsMobTS(D3Object mob)
        {
            bool res = false;
            res = D3Control.IsMobTS(mob);
            return res;
        }

        void KeepTaeguk()
        {
        }

        void moverun(Vector3D location)
        {
            if (moveBackTimer.IsReady)
            {
                moveBackTimer.Reset();
                float distance = D3Control.Player.DistanceTo(location);
                D3Control.ClickMoveTo(location);
                try
                {
                    Thread.Sleep((int)(distance * 1000 / D3Control.Player.speed));
                }
                catch { }
            }
        }

        bool try2AvoidAOE()
        {
            if (D3Control.AOETimer * 1000 != moveBackTimer.Duration)
                moveBackTimer.ChangeDuration(D3Control.AOETimer * 1000);
            if (safeSpot != null && moveBackTimer.IsReady)
            {
                var tempSpot = safeSpot;
                safeSpot = null;
                D3Control.output("AOE detected, try to avoid those.");
                DateTime start = DateTime.Now;
                moverun(tempSpot);
               // D3Control.output(string.Format("{0}", DateTime.Now.Subtract(start).TotalMilliseconds));
                D3Control.output("Done");
                return true;
            }
            return false;
        }

        #endregion Methods

        #region Nested Types

        class TalRashaHandler
        {
            #region Methods

            /*void HandleSignatureSpell()
            {
                bool noCloseEnemy = false;
                if (D3Control.canCast("Electrocute"))
                {
                    var retryElectrocuteTime = 0;
                    Vector3D ElectroLoc = null;
                retryElectrocute:
                    D3Control.output(string.Format("Electrocute {0}", retryElectrocuteTime));
                    if ((ElectrocuteRune)D3Control.GetSpellRuneIndex("Electrocute") == ElectrocuteRune.ArcLightning)
                    {   // a location spell
                        var mobDistance = closestMob.DistanceFromPlayer;
                        var closestMobv1 = closestMob.Location;
                        if (true)//mobDistance <= 15)
                        {
                            ElectroLoc = closestMobv1;
                            //CastWizardSpell("Electrocute", closestMobv1);
                        }
                        else
                        {
                            ElectroLoc = D3Control.getMySideSpot(closestMobv1, 0, 12);
                            noCloseEnemy = true;

                            //CastWizardSpell("Electrocute", ElectroLoc);

                        }
                        if (ElectroLoc == null)
                            ElectroLoc = D3Control.Player.Location;
                    }
                    else
                    {
                        ElectroLoc = closestMob.Location;

                    }

                    if (!CastWizardSpell("Electrocute", ElectroLoc))
                    {
                        Thread.Sleep(300);
                        if (retryElectrocuteTime++ < 3)
                        {
                            goto retryElectrocute;
                        }
                    }
                    if (noCloseEnemy)
                        D3Control.MoveTo(closestMob.Location, 12);
                }

            }/**/
            void handleBlizz()
            {
            }

            #endregion Methods
        }
Ejemplo n.º 6
0
        void handleTalRasha()
        {
            CWSpellTimer checkBuffTimer = new CWSpellTimer(5 * 1000);
            CWSpellTimer teleportTimer = new CWSpellTimer(3 * 1000);
            CWSpellTimer blizzTimer = new CWSpellTimer(7000); // 5.5 secs to make sure you get the tr6 buffer
            CWSpellTimer hydraTimer = new CWSpellTimer(7000);
            CWSpellTimer hydraHardTimer = new CWSpellTimer(2500); // wait at least this time to test again hydra #
            CWSpellTimer bossFightMoveTimer = new CWSpellTimer(2000);
            Vector3D lastBlizzLoc = null;
            Vector3D bossFightSpot = null;
            CWSpellTimer ConventionPrepareTimer = new CWSpellTimer(2 * 1000);
            CWSpellTimer TaegukTimer = new CWSpellTimer(3 * 1000);

            // if (D3Control.canCast("Strafe")) //
            {
                CWSpellTimer tempTimer2 = new CWSpellTimer(120 * 1000, false);
                int retryTimes = 0;
                do
                {
                recast:
                    bool RGBossFight = false;
                    // DateTime startTime = DateTime.Now;
                    if (checkIgnoreandMaxTrial(ref LiveMobsAround))
                        break;
                    if (!D3Control.IsInGame() || D3Control.Player.IsDead)
                    {
                        return;
                    }
                    if (D3Control.Player.HpPct < 45)
                        D3Control.usePotion();

                    if (DoorCheckTimer.IsReady)
                    {
                        D3Control.openDoor(35);
                        DoorCheckTimer.Reset();
                    }
                    LiveMobsAround = D3Control.RetrieveAllObjects(maxScanRange, Descriptor.eActorType.Monster);   // only live mobs will be returned.
                    if (LiveMobsAround == null || LiveMobsAround.Count == 0)
                        return;
                    checkBuff(D3Control.Player);

                    //float minDistance = float.MaxValue;
                    bool closeEnemy = false;
                    float minDistance = float.MaxValue;
                    bool hasElite = false;
                    foreach (var mob in LiveMobsAround)
                    {
                        if (D3Control.ISRG((D3Unit)mob))
                        {
                            RGBossFight = true;
                            RGBoss = mob;
                        }
                        var distance = mob.DistanceFromPlayer;
                        if (minDistance > distance)
                            minDistance = distance;
                        if (!hasElite && ((D3Unit)mob).IsElite)
                            hasElite = true;
                        if (distance <= 55 && !D3Control.LOS(mob))
                        {
                            closeEnemy = true;
                        }
                    }
                    if (!RGBossFight)
                        RGBoss = null;

                    if (!closeEnemy) // no more enemy nearby?
                        return;

                    var playerHP = D3Control.Player.HpPct;
                    bossFightSpot = null;

                    bool canCastTeleport = D3Control.canCast("Teleport");

                    if (RGBossFight && (bossFightMoveTimer.IsReady || D3Control.canCast("Teleport")))
                    {   // if boss fight && move timer is ready or teleport is ready, MOVE
                        var bossLoc = RGBoss.Location;
                        //D3Control.output("Boss fight, trying to get a side spot");
                        bool hasGoodSpot = false;
                        for (int i = 1; i < 12; i++)
                        {
                            if (!canCastTeleport && (i > 3 || i < 10))
                                continue;
                            bossFightSpot = D3Control.getStartSideSpot(bossLoc, D3Control.Player.Location, i * 30, 40);
                            if (!D3Control.LOS(bossFightSpot))
                            {
                                hasGoodSpot = true;
                                break;
                            }
                        }
                        if (!hasGoodSpot)
                            bossFightSpot = D3Control.getStartSideSpot(bossLoc, D3Control.Player.Location, 0, 30);

                        //tel
                    }
                    if (D3Control.canCast("Teleport"))
                    {
                        Vector3D teleportSpot = null;
                        teleportSpot = CheckGlobeShrineLoc();
                        if (teleportSpot == null)
                        {
                            if (D3Control.isObjectValid(RGBoss))
                                teleportSpot = handleRGAOE(RGBoss.Location);
                            //strafeSpot = selectWWLocation(55, ref LiveMobsAround, 15);
                            if (teleportSpot == null)
                                teleportSpot = bossFightSpot;

                        }

                        if (teleportSpot == null && (teleportTimer.IsReady || playerHP <= 60))
                        {   // no need to get health globe or the shadow power
                            if (playerHP <= 40)//&& LiveMobsAround.Count == 1)
                            {   // hp too low or RG fight, find a safe place?
                                teleportSpot = Surroundings.FindMobBlock(ref LiveMobsAround, FindTypes.Min);

                            }
                            else if (RGBossFight)
                            {
                                teleportSpot = bossFightSpot;

                            }
                            else //if (playerHP <= 60)
                            {   // low on life, try to teleport to a mob far away
                                //teleportSpot = selectTeleportLocation(55, ref LiveMobsAround, 40);// Surroundings.FindMobBlock(ref LiveMobsAround, FindTypes.Min);
                                var teleportToMob = selectFarestMob(55, ref LiveMobsAround, 40);// Surroundings.FindMobBlock(ref LiveMobsAround, FindTypes.Min);
                                if (teleportToMob != null)
                                    teleportSpot = teleportToMob.Location;

                            }
                            if (teleportSpot == null)
                            {
                                teleportSpot = D3Control.Player.Location;
                            }
                            /*else
                            {   // hpPct ok, try to find a block with densest mobs
                                teleportSpot = Surroundings.FindMobBlock(ref LiveMobsAround, FindTypes.Max);
                                bool goodSpot = false;
                                if (teleportSpot != null && teleportSpot.GetDistanceTo(D3Control.Player.Location) > 12)
                                {   // the target spot is good to go
                                    goodSpot = true;
                                }
                                if (!goodSpot)
                                {
                                    var teleportToMob = selectFarestMob(55, ref LiveMobsAround, 40);// Surroundings.FindMobBlock(ref LiveMobsAround, FindTypes.Min);
                                    if (teleportToMob != null)
                                        teleportSpot = teleportToMob.Location;
                                }
                            }/**/
                        }

                        if (teleportSpot != null)
                        {
                            if (CastWizardSpell("Teleport", teleportSpot))
                            {
                                teleportTimer.Reset();
                                Thread.Sleep(150);
                            }
                        }
                    }

                    if (/*!blizzTimer.IsReady &&*/ hydraTimer.IsReady && (hydraTimer.IsReady || CombatConfig.WizardTalRashaSettings.HydraCount > D3.D3Control.getWizHydraNumber(50)))
                    {   // make sure blizz is casted first, cuz it consumes more arcane power
                        int hydraRetryTime = 0;
                    retryCastHydra:

                        Vector3D hydraLoc = null;
                        if (RGBossFight)
                        {
                            /*if (LiveMobsAround.Count == 1)
                            {
                                if (RGBoss.DistanceFromPlayer < 40)
                                    hydraLoc = D3Control.Player.Location;
                                else
                                    hydraLoc = RGBoss.Location;
                            }
                            else/**/
                            hydraLoc = RGBoss.Location;
                        }
                        else
                        {
                            hydraLoc = D3Control.Player.Location;
                        }
                        var FlashesOfInsightBuffCount = D3Control.BuffStackCount("Tal Rasha's Elements");
                        if (CastWizardSpell("Hydra", hydraLoc))
                        {

                            hydraTimer.Reset();
                            D3Control.output("Hydra successful?");
                            Thread.Sleep(150);

                        }
                        else
                        {   // some how the cast spell successful or not does not work sometimes here. no idea, need more testing
                            Thread.Sleep(200);
                            if (FlashesOfInsightBuffCount < D3Control.BuffStackCount("Tal Rasha's Elements"))
                            {   // successfull
                                hydraHardTimer.Reset();
                                D3Control.output("Hydra successful?");

                            }
                            else
                                D3Control.output("Hydra failed?");
                            /*
                            if (hydraRetryTime++ < 3)
                            {
                                Thread.Sleep(150);
                               goto retryCastHydra;
                            }/**/
                        }
                        hydraHardTimer.Reset();

                    }

                    var closestMob = selectClosestMob(50, ref LiveMobsAround, 45);//

                    if (blizzTimer.IsReady || D3Control.Player.ArcanePower > 50)
                    {   // to cast blizz

                        int retryBlizzTime = 0;

                    retryCastBlizz:

                        var nearMobsCount = GetNearByEnemy(ref LiveMobsAround, 12);
                        Vector3D tempBlizzLoc = null;
                        if (nearMobsCount != null && nearMobsCount.Count > 0)
                        {   // some mobs around, cast it right around the player
                            tempBlizzLoc = D3Control.Player.Location;
                            // D3Control.output("Cast blizz at the player location");

                        }
                        else
                        {
                            tempBlizzLoc = Surroundings.FindMobBlock(ref LiveMobsAround, FindTypes.Max);
                            // D3Control.output("Cast blizz at the densest mob location");

                        }
                        if (tempBlizzLoc == null)
                        {
                            if (closestMob != null)
                            {
                                //   D3Control.output("Cast blizz at the closest mob");
                                tempBlizzLoc = closestMob.Location;
                            }
                        }
                        if (tempBlizzLoc == null)
                            tempBlizzLoc = D3Control.Player.Location;
                        if (tempBlizzLoc != null)
                        {
                            lastBlizzLoc = tempBlizzLoc;
                            if (!CastWizardSpell("Blizzard", tempBlizzLoc))
                            {
                                if (retryTimes++ < 3)
                                {
                                    Thread.Sleep(150);
                                    goto retryCastBlizz;
                                }
                            }
                            else
                            {

                                blizzTimer.Reset();
                                Thread.Sleep(150);
                            }

                        }

                    }
                    if (RGBossFight && bossFightMoveTimer.IsReady && bossFightSpot != null)
                    {
                        D3Control.ClickMoveToWait(bossFightSpot);

                    }
                    bool noCloseEnemy = false;
                    //for (int i = 0; i < 3; i++)
                    {
                        if (D3Control.canCast("Electrocute"))
                        {
                            var retryElectrocuteTime = 0;
                            Vector3D ElectroLoc = null;
                        retryElectrocute:
                            //D3Control.output(string.Format("Electrocute {0}", retryElectrocuteTime));
                            if ((ElectrocuteRune)D3Control.GetSpellRuneIndex("Electrocute") == ElectrocuteRune.ArcLightning)
                            {   // a location spell
                                var mobDistance = closestMob.DistanceFromPlayer;
                                var closestMobv1 = closestMob.Location;
                                if (!RGBossFight || mobDistance < 15)//mobDistance <= 15)
                                {
                                    ElectroLoc = closestMobv1;
                                    //CastWizardSpell("Electrocute", closestMobv1);
                                }
                                else
                                {
                                    ElectroLoc = D3Control.Player.Location;
                                    /*
                                    ElectroLoc = D3Control.getMySideSpot(closestMobv1, 0, 12);
                                    noCloseEnemy = true;
                                    /**/
                                    //CastWizardSpell("Electrocute", ElectroLoc);

                                }/**/
                                if (ElectroLoc == null)
                                    ElectroLoc = D3Control.Player.Location;
                            }
                            else
                            {
                                ElectroLoc = closestMob.Location;

                            }

                            if (!CastWizardSpell("Electrocute", ElectroLoc))
                            {
                                /*Thread.Sleep(500);
                                if (retryElectrocuteTime++ < 3)
                                {
                                    goto retryElectrocute;
                                }/**/
                            }
                            else
                            {
                                Thread.Sleep(150);
                            }
                            if (noCloseEnemy)
                                D3Control.MoveTo(closestMob.Location, 12);
                        }
                    }
                } while (!tempTimer2.IsReady);
            }
        }