Ejemplo n.º 1
0
        public void TweakMelee(BoogieBot.Common.Object Monster)
        {
            double Distance    = Monster.GetCoordinates().DistanceTo(BoogieCore.world.getPlayerObject().GetCoordinates());
            double sensitivity = 2.5; // default melee distance is 4.8 - 2.5 = 2.3, no monster will chase us at 2.3
            double min         = 4.5 - sensitivity;

            if (min < 1.0)
            {
                min = 1.0;
            }

            if (Distance > 4.5)
            {
                // Too far
                //Spam("Tweak forwards. "+ Distance + " > " + Context.MeleeDistance);
                mover.Forwards(true);
                Thread.Sleep(100);
                mover.Forwards(false);
            }
            else if (Distance < min)
            {
                // Too close
                //Spam("Tweak backwards. "+ Distance + " < " + min);
                mover.Backwards(true);
                Thread.Sleep(200);
                mover.Backwards(false);
            }
        }
Ejemplo n.º 2
0
        public bool MoveToGetThemInFront(BoogieBot.Common.Object Target, BoogieBot.Common.Object Add)
        {
            double bearing = Add.GetOrientation();

            if (!IsInFrontOfMe(Add))
            {
                BoogieCore.Log(LogType.System, "Got the add " + Add.Name + " behind me");

                /*
                 * hmm, just back up? or turn a bit too?
                 */

                mover.Backwards(true);
                if (bearing < 0)
                {
                    BoogieCore.Log(LogType.System, "  back up left");
                    mover.RotateLeft(true);
                }
                else
                {
                    BoogieCore.Log(LogType.System, "  back up right");
                    mover.RotateRight(true);
                }
                Thread.Sleep(300);
                mover.RotateLeft(false);
                mover.RotateRight(false);
                Thread.Sleep(300);
                mover.Backwards(false);
                return(true);
            }
            return(false);
        }
Ejemplo n.º 3
0
        /*
         */
        // return value from -PI to PI
        //
        double BearingToMe(BoogieBot.Common.Object unit)
        {
            Coordinate MyLocation = BoogieCore.world.getPlayerObject().GetCoordinates();
            float      bearing    = 0;// fixme (float)unit.GetHeadingDelta(MyLocation);

            return(bearing);
        }
Ejemplo n.º 4
0
        public float Score(float x, float y, float z)
        {
            Coordinate l  = new Coordinate(x, y, z);
            Coordinate me = BoogieCore.World.getPlayerObject().GetCoordinates();

            if (l.DistanceTo(me) > 100.0)
            {
                return(0);
            }
            float s = 0;

            foreach (UnitData ud in dic.Values)
            {
                BoogieBot.Common.Object unit = ud.unit;
                if (unit.Reaction >= 2)
                {
                    float d = unit.coord.DistanceTo(l);
                    if (d < 30)
                    {
                        float n  = 30 - d;
                        uint  ld = unit.Level - BoogieCore.world.getPlayerObject().Level;
                        //if(ld < 0)
                        //    n /= -ld+2;
                        s += n;
                    }
                }
            }
            //if(s>0)
            //    GContext.Main.Log("  " + l + " score " + s);
            return(s);
        }
Ejemplo n.º 5
0
 public UnitData(BoogieBot.Common.Object u)
 {
     unit          = u;
     guid          = (long)u.GUID.GetOldGuid();
     movementSpeed = 0.0;
     oldLocation   = u.coord;
 }
Ejemplo n.º 6
0
        public double GetSpeed(BoogieBot.Common.Object u)
        {
            UnitData ud;

            if (dic.TryGetValue((long)u.GUID.GetOldGuid(), out ud))
            {
                return(ud.movementSpeed);
            }
            return(0.0);
        }
Ejemplo n.º 7
0
        public Coordinate InFrontOf(BoogieBot.Common.Object unit, double d)
        {
            double x       = unit.GetCoordinates().X;
            double y       = unit.GetCoordinates().Y;
            double z       = unit.GetCoordinates().Z;
            double heading = unit.GetOrientation();

            x += Math.Cos(heading) * d;
            y += Math.Sin(heading) * d;

            return(new Coordinate((float)x, (float)y, (float)z));
        }
Ejemplo n.º 8
0
        public static bool IsHordePlayerFaction(BoogieBot.Common.Object u)
        {
            int f = 0;// u.FactionID;

            if (f == 2 ||
                f == 5 ||
                f == 6 ||
                f == 116 ||
                f == 1610)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 9
0
        public static bool IsAlliancePlayerFaction(BoogieBot.Common.Object u)
        {
            int f = 0;//u.FactionID;

            if (f == 1 ||
                f == 3 ||
                f == 4 ||
                f == 115 ||
                f == 1629)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 10
0
        public static bool IsStupidItem(BoogieBot.Common.Object unit)
        {
            //if (unit.CreatureType == GCreatureType.Totem) return true;
            // Filter out all stupid sting found in outland
            string name = unit.Name.ToLower();

            if (name.Contains("target") || name.Contains("trigger") ||
                name.Contains("flak cannon") || name.Contains("trip wire") ||
                name.Contains("infernal rain") || name.Contains("anilia") ||
                name.Contains("teleporter credit") || name.Contains("door fel cannon") ||
                name.Contains("ethereum glaive") || name.Contains("orb flight"))
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 11
0
        public Coordinate PredictedLocation(BoogieBot.Common.Object mob)
        {
            Coordinate currentLocation = mob.GetCoordinates();
            double     x       = currentLocation.X;
            double     y       = currentLocation.Y;
            double     z       = currentLocation.Z;
            double     heading = mob.GetOrientation();
            double     dist    = 4;

            x += Math.Cos(heading) * dist;
            y += Math.Sin(heading) * dist;

            Coordinate predictedLocation = new Coordinate((float)x, (float)y, (float)z);

            Coordinate closestLocatition = currentLocation;

            if (predictedLocation.DistanceTo(BoogieCore.world.getPlayerObject().GetCoordinates()) < closestLocatition.DistanceTo(BoogieCore.world.getPlayerObject().GetCoordinates()))
            {
                closestLocatition = predictedLocation;
            }
            return(closestLocatition);
        }
Ejemplo n.º 12
0
        // called when we have died, return when we are alive again
        private void GhostRun()
        {
            BoogieCore.Log(LogType.System, "I died. Let's resurrect");
            Coordinate CorpseLocation = null;



            Coordinate gloc = new Coordinate(0, 0, 0);

            if (CorpseLocation != null)
            {
                gloc = CorpseLocation;
            }

            Location   target = null;
            Coordinate gtarget;

            BoogieCore.Log(LogType.System, "Corpse is at " + gloc);

            if (gloc.Z == 0)
            {
                BoogieCore.Log(LogType.System, "hmm, corpse Z == 0");
                target = new Location(gloc);
                for (int q = 0; q < 50; q += 5)
                {
                    float stand_z = 0;
                    int   flags   = 0;
                    float x       = gloc.X + random.Next(20) - 10;
                    float y       = gloc.Y + random.Next(20) - 10;
                    bool  ok      = world.triangleWorld.FindStandableAt(x, y,
                                                                        -5000,
                                                                        5000,
                                                                        out stand_z, out flags, 0, 0);
                    if (ok)
                    {
                        target = new Location(x, y, stand_z);
                        break;
                    }
                }
            }
            else
            {
                target = new Location(gloc);
            }
            gtarget = new Coordinate(target.X, target.Y, target.Z);

            BoogieCore.Log(LogType.System, "Corpse is at " + target);
            EasyMover em = new EasyMover(this, target, false, false);

            // 2. Run to corpse
            while (Me.IsDead && Me.DistanceTo(gloc) > 20)     // fixme
            {
                EasyMover.MoveResult mr = em.move();
                if (mr != EasyMover.MoveResult.Moving)
                {
                    return;                                        // buhu
                }
                UpdateMyPos();
                Thread.Sleep(50);
            }
            mover.Stop();

            // 3. Find a safe place to res
            // is within 20 yds of corpse now, dialog must be up
            float SafeDistance = 25.0f;

            while (true)
            {
                // some brute force :p
                BoogieBot.Common.Object[] monsters = BoogieCore.world.getObjectListArray();
                float    best_score    = 1E30f;
                float    best_distance = 1E30f;
                Location best_loc      = null;
                for (float x = -35; x <= 35; x += 5)
                {
                    for (float y = -35; y <= 35; y += 5)
                    {
                        float      rx  = target.X + x;
                        float      ry  = target.Y + y;
                        Coordinate xxx = new Coordinate(rx, ry, 0);
                        if (xxx.DistanceTo(gtarget) < 35)
                        {
                            float stand_z = 0;
                            int   flags   = 0;
                            bool  ok      = world.triangleWorld.FindStandableAt(rx, ry,
                                                                                target.Z - 20,
                                                                                target.Z + 20,
                                                                                out stand_z, out flags, 0, 0);
                            if (ok)
                            {
                                float      score = 0.0f;
                                Coordinate l     = new Coordinate(rx, ry, stand_z);
                                foreach (BoogieBot.Common.Object monster in monsters)
                                {
                                    if (monster != null && !monster.IsDead)
                                    {
                                        float d = l.DistanceTo(monster.GetCoordinates());
                                        if (d < 35)
                                        {
                                            // one point per yard
                                            score += 35 - d;
                                        }
                                    }
                                }
                                float this_d = Me.DistanceTo(l);
                                if (score <= best_score && this_d < best_distance)
                                {
                                    best_score    = score;
                                    best_distance = this_d;
                                    best_loc      = new Location(l);
                                }
                            }
                        }
                    }
                }
                if (best_loc != null)
                {
                    Coordinate best_gloc = new Coordinate(best_loc.X, best_loc.Y, best_loc.Z);
                    // walk over there
                    WalkTo(best_gloc, false, 10000, true);

                    // Check if I am safe
                    bool safe = true;
                    BoogieBot.Common.Object unsafe_monster = null;
                    foreach (BoogieBot.Common.Object monster in monsters)
                    {
                        if (!monster.IsDead && !PPather.IsStupidItem(monster))
                        {
                            float d = Me.DistanceTo(monster.GetCoordinates());
                            if (d < SafeDistance)
                            {
                                if (Math.Abs(monster.GetPositionZ() - Me.Location.Z) < 15)
                                {
                                    safe           = false;
                                    unsafe_monster = monster;
                                }
                            }
                        }
                    }
                    if (safe)
                    {
                        break;     // yeah
                    }
                }

                // hmm, look again
                Thread.Sleep(2000);
                SafeDistance -= 0.5f;
            }
        }
Ejemplo n.º 13
0
 public UnitData(BoogieBot.Common.Object u)
 {
     unit = u;
     guid = (long)u.GUID.GetOldGuid();
     movementSpeed = 0.0;
     oldLocation = u.coord;
 }
Ejemplo n.º 14
0
        public bool Approach(BoogieBot.Common.Object monster, bool AbortIfUnsafe, int timeout)
        {
            BoogieCore.Log(LogType.System, "[Approach] 1");
            Coordinate loc    = monster.GetCoordinates();
            float      DistTo = loc.DistanceTo(BoogieCore.world.getPlayerObject().GetCoordinates());

            BoogieCore.Log(LogType.System, "[Approach] Distance to object: {0}", DistTo);
            if (DistTo < 4.5f &&
                Math.Abs(loc.O) < PI / 8)
            {
                mover.Stop();
                return(true);
            }

            GSpellTimer   approachTimeout = new GSpellTimer(timeout, false);
            StuckDetecter sd              = new StuckDetecter(this, 1, 2);
            GSpellTimer   t               = new GSpellTimer(0);
            bool          doJump          = random.Next(4) == 0;
            EasyMover     em              = null;
            GSpellTimer   NewTargetUpdate = new GSpellTimer(1000);


            BoogieCore.Log(LogType.System, "[Approach] 2");
            do
            {
                BoogieCore.Log(LogType.System, "[Approach] 3");
                UpdateMyPos();
                BoogieCore.Log(LogType.System, "[Approach] 4");
                // Check for stuck
                if (sd.checkStuck())
                {
                    BoogieCore.Log(LogType.System, "[Approach] 5");
                    BoogieCore.Log(LogType.System, "Major stuck on approach. Giving up");
                    mover.Stop();
                    return(false);
                }
                double distance = monster.GetCoordinates().DistanceTo(BoogieCore.world.getPlayerObject().GetCoordinates());
                BoogieCore.Log(LogType.System, "[Approach] 6 - Dist = {0}", distance);
                bool moved;

                if (distance < 8)
                {
                    loc = monster.GetCoordinates();
                    BoogieCore.Log(LogType.System, "[Approach] 7");
                    moved = mover.moveTowardsFacing(loc, 4.5f, loc);
                    BoogieCore.Log(LogType.System, "[Approach] 8 {0}", moved);
                }
                else
                {
                    BoogieCore.Log(LogType.System, "[Approach] 9");
                    if (em == null)
                    {
                        loc = monster.GetCoordinates();
                        em  = new EasyMover(this, new Location(loc), false, AbortIfUnsafe);
                    }
                    BoogieCore.Log(LogType.System, "[Approach] 10");
                    EasyMover.MoveResult mr = em.move();
                    BoogieCore.Log(LogType.System, "[Approach] 11 {0}", mr);
                    moved = true;
                    if (mr != EasyMover.MoveResult.Moving)
                    {
                        moved = false;
                    }
                    BoogieCore.Log(LogType.System, "[Approach] 12");
                }
                BoogieCore.Log(LogType.System, "[Approach] 13");

                if (!moved)
                {
                    mover.Stop();
                    return(true);
                }
            } while (!approachTimeout.IsReadySlow);
            mover.Stop();
            BoogieCore.Log(LogType.System, "Approach timed out");
            return(false);
        }
Ejemplo n.º 15
0
 public bool Approach(BoogieBot.Common.Object monster, bool AbortIfUnsafe)
 {
     return(Approach(monster, AbortIfUnsafe, 10000));
 }
Ejemplo n.º 16
0
        public bool IsInFrontOfMe(BoogieBot.Common.Object unit)
        {
            double bearing = unit.GetOrientation();

            return(bearing < PI / 2.0 && bearing > -PI / 2.0);
        }
Ejemplo n.º 17
0
 public bool IsItSafeAt(BoogieBot.Common.Object ignore, BoogieBot.Common.Object u)
 {
     return(IsItSafeAt(ignore, u.GetCoordinates()));
 }
Ejemplo n.º 18
0
 public static bool IsPlayerFaction(BoogieBot.Common.Object u)
 {
     return(IsHordePlayerFaction(u) || IsAlliancePlayerFaction(u));
 }
Ejemplo n.º 19
0
 public bool IsItSafeAt(BoogieBot.Common.Object ignore, Location l)
 {
     return(IsItSafeAt(ignore, new Coordinate(l.X, l.Y, l.Z)));
 }
Ejemplo n.º 20
0
 public bool Face(BoogieBot.Common.Object monster, double tolerance)
 {
     BoogieBot.Common.Object player = BoogieCore.world.getPlayerObject();
     player.SetOrientation(player.CalculateAngle(monster.GetPositionX(), monster.GetPositionY()));
     return(true);
 }
Ejemplo n.º 21
0
 public bool Face(BoogieBot.Common.Object monster)
 {
     return(Face(monster, PI / 8));
 }
Ejemplo n.º 22
0
 public bool IsItSafeAt(BoogieBot.Common.Object ignore, Coordinate l)
 {
     return(true);
 }