Ejemplo n.º 1
0
        public void Interact()
        {
            var    screen       = System.Windows.Forms.Screen.PrimaryScreen.Bounds;
            var    width        = screen.Width;
            var    height       = screen.Height;
            bool   found        = false;
            int    X            = Cursor.Position.X;
            int    Y            = Cursor.Position.Y;
            IntPtr activeWindow = GetForegroundWindow();

            for (int i = 0; i < width; i += 40)
            {
                for (int j = 0; j < height; j += 40)
                {
                    Cursor.Position = new Point(i, j);
                    short cursor = magic.ReadShort((uint)TbcOffsets.General.Cursor);
                    if (cursor == 16 || cursor == 18 || cursor == 8 || cursor == 12)
                    {
                        SetForegroundWindow(handle);
                        keyboardSim.MouseButtonDown();
                        keyboardSim.MouseButtonUp();
                        keyboardSim.MouseButtonDown();
                        keyboardSim.MouseButtonUp();
                        Thread.Sleep(1000);
                        keyboardSim.KeyDown(loot);
                        keyboardSim.KeyUp(loot);
                        found = true;
                    }
                    else if (cursor == 13 || cursor == 11)
                    {
                        SetForegroundWindow(handle);
                        keyboardSim.MouseButtonDown();
                        keyboardSim.MouseButtonUp();
                        keyboardSim.MouseButtonDown();
                        keyboardSim.MouseButtonUp();
                        Thread.Sleep(3000);
                        keyboardSim.KeyDown(loot);
                        keyboardSim.KeyUp(loot);
                        found = true;
                    }
                    Thread.Sleep(1);
                    if (found)
                    {
                        break;
                    }
                }
                if (found)
                {
                    break;
                }
            }
            Cursor.Position = new Point(X, Y);
            SetForegroundWindow(activeWindow);
        }
Ejemplo n.º 2
0
        public bool WalkToPoint(float targetX, float targetY, float targetZ, bool value, float currentX, float currentY, float currentZ)
        {
            float bodyx = magic.ReadFloat((uint)TbcOffsets.General.PlayerCorpseX);
            float bodyy = 0;
            float bodyz = 0;

            dead = false;
            if (bodyx != 0)
            {
                bodyy = magic.ReadFloat((uint)TbcOffsets.General.PlayerCorpseY);
                bodyz = magic.ReadFloat((uint)TbcOffsets.General.PlayerCorpseZ);
                dead  = true;
            }

            float startingX = currentX;
            float startingY = currentY;
            float startingZ = currentZ;
            bool  inCombat  = value;
            float dX        = targetX - startingX;
            float dY        = targetY - startingY;
            float dZ        = targetZ - startingZ;
            float rotation  = (float)Math.Atan2(targetY - startingY, targetX - startingX);

            if (rotation < 0)
            {
                rotation = rotation + (2f * (float)Math.PI);
            }
            float myRotation = magic.ReadFloat((uint)TbcOffsets.General.PlayerRotation);

            myRotation = float.Parse(myRotation.ToString("0.0"));
            rotation   = float.Parse(rotation.ToString("0.0"));
            float angle1;
            float angle2;
            float distance = (float)Math.Sqrt(dX * dX + dY * dY + dZ * dZ);

            while ((distance > 3f && distance <= 100f) && !halt)
            {
                if ((!settings.IgnoreMobs || !settings.IgnorePlayers) && (!inCombat || magic.ReadUInt(magic.ReadUInt((uint)TbcOffsets.General.PlayerBase) + (uint)TbcOffsets.General.CombatStateOffset) == (int)TbcOffsets.CombatState.InCombat && magic.ReadUInt64((uint)TbcOffsets.General.TargetGuid) != 0))
                {
                    if (inCombat)
                    {
                        inCombat = bot.GetCombat.CombatMode();
                    }
                    else
                    {
                        inCombat = bot.GetCombat.CombatMode();
                        if (inCombat)
                        {
                            return(true);
                        }
                    }
                }
                int playerHealth = objectManager.GetPlayer().Health;
                if (playerHealth <= 0 && profile.IsGhostSet)
                {
                    bot.GetOther.ReleaseScript();
                    dead = true;
                    Thread.Sleep(1000);
                    return(true);
                }
                else if (playerHealth <= 0 && !profile.IsGhostSet)
                {
                    bot.Halt();
                }

                if (dead)
                {
                    float gX = bodyx - startingX;
                    float gY = bodyy - startingY;
                    float gZ = bodyz - startingZ;
                    if ((float)Math.Sqrt(gX * gX + gY * gY + gZ * gZ) < 30)
                    {
                        keyboardSim.KeyUp(walk);
                        keyboardSim.KeyUp(turnleft);
                        keyboardSim.KeyUp(turnright);
                        while (magic.ReadFloat((uint)TbcOffsets.General.PlayerCorpseX) != 0)
                        {
                            bot.GetOther.RetrieveScript();
                        }

                        bot.GetOther.Rebuff();
                        dead = false;
                        break;
                    }
                }
                if (!profile.IgnoreZ && startingZ > targetZ)
                {
                    if (startingZ - targetZ > 0.3f)
                    {
                        keyboardSim.KeyDown(godown);
                    }
                    else
                    {
                        keyboardSim.KeyUp(godown);
                    }
                }
                else if (!profile.IgnoreZ && startingZ < targetZ)
                {
                    if (targetZ - startingZ > 0.3f)
                    {
                        keyboardSim.KeyDown(goup);
                    }
                    else
                    {
                        keyboardSim.KeyUp(goup);
                    }
                }

                if (myRotation != rotation)
                {
                    if (myRotation >= rotation)
                    {
                        angle1 = myRotation - rotation;
                        angle2 = rotation + (2 * (float)Math.PI - myRotation);
                        if (angle1 < angle2)
                        {
                            if (angle1 > 0.3)
                            {
                                keyboardSim.KeyDown(turnright);
                                keyboardSim.KeyUp(turnleft);
                            }
                            else
                            {
                                keyboardSim.KeyUp(turnleft);
                                keyboardSim.KeyUp(turnright);
                            }

                            if (angle1 < Math.PI / 2 && distance > 3)
                            {
                                keyboardSim.KeyDown(walk);
                            }
                        }
                        else
                        {
                            if (angle2 > 0.3)
                            {
                                keyboardSim.KeyDown(turnleft);
                                keyboardSim.KeyUp(turnright);
                            }
                            else
                            {
                                keyboardSim.KeyUp(turnleft);
                                keyboardSim.KeyUp(turnright);
                            }

                            if (angle2 < Math.PI / 2 && distance > 3)
                            {
                                keyboardSim.KeyDown(walk);
                            }
                        }
                    }
                    else if (myRotation < rotation)
                    {
                        angle1 = rotation - myRotation;
                        angle2 = myRotation + (2 * (float)Math.PI - rotation);
                        if (angle1 < angle2)
                        {
                            if (angle1 > 0.3)
                            {
                                keyboardSim.KeyDown(turnleft);
                                keyboardSim.KeyUp(turnright);
                            }
                            else
                            {
                                keyboardSim.KeyUp(turnleft);
                                keyboardSim.KeyUp(turnright);
                            }

                            if (angle1 < Math.PI / 2 && distance > 3)
                            {
                                keyboardSim.KeyDown(walk);
                            }
                        }
                        else
                        {
                            if (angle2 > 0.3)
                            {
                                keyboardSim.KeyDown(turnright);
                                keyboardSim.KeyUp(turnleft);
                            }
                            else
                            {
                                keyboardSim.KeyUp(turnleft);
                                keyboardSim.KeyUp(turnright);
                            }

                            if (angle2 < Math.PI / 2 && distance > 3)
                            {
                                keyboardSim.KeyDown(walk);
                            }
                        }
                    }
                }

                else
                {
                    keyboardSim.KeyDown(walk);
                    keyboardSim.KeyUp(turnleft);
                    keyboardSim.KeyUp(turnright);
                    Random random = new Random();
                    if (random.Next(10) == 0)
                    {
                        keyboardSim.KeyDown(goup);
                        keyboardSim.KeyUp(goup);
                    }
                }
                startingX  = magic.ReadFloat((uint)TbcOffsets.General.PlayerX);
                startingY  = magic.ReadFloat((uint)TbcOffsets.General.PlayerY);
                startingZ  = magic.ReadFloat((uint)TbcOffsets.General.PlayerZ);
                dX         = targetX - startingX;
                dY         = targetY - startingY;
                dZ         = targetZ - startingZ;
                myRotation = magic.ReadFloat((uint)TbcOffsets.General.PlayerRotation);
                rotation   = (float)Math.Atan2(targetY - startingY, targetX - startingX);
                if (rotation < 0)
                {
                    rotation = rotation + (2f * (float)Math.PI);
                }
                myRotation = float.Parse(myRotation.ToString("0.0"));
                rotation   = float.Parse(rotation.ToString("0.0"));
                float temp = distance;
                distance = (float)Math.Sqrt(dX * dX + dY * dY + dZ * dZ);
                if (temp - distance == 0)
                {
                    Antistuck();
                }
            }
            keyboardSim.KeyUp(walk);
            keyboardSim.KeyUp(turnleft);
            keyboardSim.KeyUp(turnright);
            return(false);
        }
Ejemplo n.º 3
0
        public bool CombatMode()
        {
            ulong target = magic.ReadUInt64((uint)TbcOffsets.General.TargetGuid);
            bool  stuck  = false;
            //Investigate
            bool combatSuccessful = false;

            if (target == 0)
            {
                keyboardSim.KeyDown(targetKey);

                keyboardSim.KeyUp(targetKey);
            }
            else
            {
                objectManager.PopulateList();
                List <WorkWork.Memory.Object> objs = objectManager.GetObjects();
                for (int i = 0; i < objs.Count; i++)
                {
                    WorkWork.Memory.Object obj = objs[i];
                    int type = obj.Type;
                    if ((type == 4 && !settings.IgnorePlayers) || (type == 3 && !settings.IgnoreMobs))
                    {
                        ulong guid = obj.Guid;
                        if (target == guid && obj.Health > 0 && !stuck)
                        {
                            if (type == 3)
                            {
                                string name = obj.Name;
                                foreach (String ignoredMob in profile.GetIgnoredMobs())
                                {
                                    if (name == ignoredMob)
                                    {
                                        stuck = true;
                                        keyboardSim.KeyDown(targetKey);

                                        keyboardSim.KeyUp(targetKey);
                                    }
                                }
                            }
                            foreach (WorkWork.Memory.Object ignoredObjects in ignoredMobs)
                            {
                                if (ignoredObjects.Guid == guid)
                                {
                                    stuck = true;
                                    keyboardSim.KeyDown(targetKey);

                                    keyboardSim.KeyUp(targetKey);
                                }
                                else
                                {
                                    foreach (ulong ignoredMobGuid in profile.getIgnoredMobsGuid)
                                    {
                                        if (guid == ignoredMobGuid)
                                        {
                                            stuck = true;
                                            keyboardSim.KeyDown(targetKey);

                                            keyboardSim.KeyUp(targetKey);
                                        }
                                    }
                                }
                            }

                            var watch        = Stopwatch.StartNew();
                            int startingHP   = objectManager.GetPlayer().Health;
                            int startingMP   = objectManager.GetPlayer().Mana;
                            int currentCombo = 0;
                            while (obj.Health > 0 && !halt && !stuck)
                            {
                                currentCombo = DpsRotation(obj, currentCombo);
                                if (AutoAttack() && objectManager.GetPlayer().Health > 0)
                                {
                                    bot.GetPathing.WalkToMob(obj, 5);
                                }
                                if (watch.ElapsedMilliseconds > averageTime * 3 && averageTime > 0)
                                {
                                    ignoredMobs.Add(obj);
                                    stuck = true;
                                }
                                if (halt || (objectManager.GetPlayer().Health <= 0) || bot.GetPathing.Dead || magic.ReadFloat((uint)TbcOffsets.General.PlayerCorpseX) != 0)
                                {
                                    stuck = true;
                                }
                            }
                            watch.Stop();
                            if (!stuck)
                            {
                                int counter;
                                int endingHP = objectManager.GetPlayer().Health;
                                if (endingHP < startingHP)
                                {
                                    endingHP  = startingHP - endingHP;
                                    endingHP += endingHP / 2;
                                    healthPerMob[hpCounter] = endingHP;
                                    hpCounter++;
                                    if (hpCounter == 10)
                                    {
                                        hpCounter = 0;
                                    }
                                    counter           = 0;
                                    bot.AverageHealth = 0;
                                    foreach (int hp in healthPerMob)
                                    {
                                        if (hp > 0)
                                        {
                                            counter++;
                                            bot.AverageHealth += hp;
                                        }
                                    }
                                    if (counter > 0)
                                    {
                                        bot.AverageHealth /= counter;
                                    }
                                }
                                if (objectManager.GetPlayer().MaxMana > 0)
                                {
                                    int endingMP = objectManager.GetPlayer().Mana;
                                    if (endingMP < startingMP)
                                    {
                                        endingMP  = startingMP - endingMP;
                                        endingMP += endingMP / 2;
                                        manaPerMob[mpCounter] = endingMP;
                                        mpCounter++;
                                        if (mpCounter == 10)
                                        {
                                            mpCounter = 0;
                                        }
                                        counter         = 0;
                                        bot.AverageMana = 0;
                                        foreach (int mp in manaPerMob)
                                        {
                                            if (mp > 0)
                                            {
                                                counter++;
                                                bot.AverageMana += mp;
                                            }
                                        }
                                        if (counter > 0)
                                        {
                                            bot.AverageMana /= counter;
                                        }
                                    }
                                }
                                if (magic.ReadUInt(magic.ReadUInt((uint)TbcOffsets.General.PlayerBase) + (uint)TbcOffsets.General.CombatStateOffset) == (int)TbcOffsets.CombatState.InCombat && magic.ReadUInt64((uint)TbcOffsets.General.TargetGuid) != 0)
                                {
                                    CombatMode();
                                }

                                timePerMob[timeCounter] = watch.ElapsedMilliseconds;
                                timeCounter++;
                                if (timeCounter == 10)
                                {
                                    timeCounter = 0;
                                }
                                averageTime = 0;
                                counter     = 0;
                                foreach (long temp in timePerMob)
                                {
                                    if (temp > 0)
                                    {
                                        counter++;
                                        averageTime += temp;
                                    }
                                }
                                if (counter > 0)
                                {
                                    averageTime /= counter;
                                }
                                if (objectManager.GetPlayer().Health > 0)
                                {
                                    if (settings.Looting)
                                    {
                                        bot.GetPathing.WalkToMob(obj, 3);
                                        bot.GetOther.Interact();
                                        if (settings.Skinning)
                                        {
                                            bot.GetOther.Interact();
                                        }
                                    }
                                    combatSuccessful = true;
                                    bot.MobsKilled++;
                                    statistics.Changed = true;
                                    bot.GetOther.Regen();
                                    afterCombatSpells(currentCombo, "aftercombat");
                                }
                            }
                            break;
                        }
                        else if (target == guid && obj.Health <= 0)
                        {
                            keyboardSim.KeyDown(targetKey);
                            keyboardSim.KeyUp(targetKey);
                            break;
                        }
                    }
                }
            }


            return(combatSuccessful);
        }