コード例 #1
0
ファイル: Program.cs プロジェクト: Bia10/boogiebot
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            bot = new BoogieBot();

            try
            {
                BoogieCore.InitCore(Log, EventHandler);
                Application.Run(bot);
            }
            catch (Exception ex)
            {
                //if (
                //String error = String.Format("Error: {0}\n\nStackTrace:\n\n{1}", ex.InnerException.Message, ex.InnerException.StackTrace);
                MessageBox.Show(ex.Message, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
コード例 #2
0
ファイル: BoogieBot.cs プロジェクト: Bia10/boogiebot
        public void Connect()
        {
            Log(LogType.System, "--------------------------------------------------------------");

            bool connected = BoogieCore.ConnectToRealmListServer();

            if (connected)
            {
                this.stopToolStripMenuItem.Enabled  = true;
                this.startToolStripMenuItem.Enabled = false;
                this.connectedStatusLabel.Text      = "Connected.";
            }
            else
            {
                this.startToolStripMenuItem.Enabled = true;
                this.stopToolStripMenuItem.Enabled  = false;
                this.connectedStatusLabel.Text      = "Disconnected.";
                this.locationStatusLabel.Text       = "()";
            }
        }
コード例 #3
0
ファイル: PPather.cs プロジェクト: Bia10/boogiebot
        public void OnStopGlide()
        {
            BoogieCore.Log(LogType.System, "Inside OnStopGlider()");


            WantedState = RunState_e.Stopped;
            RunState    = RunState_e.Stopped;

            SaveAllState();


            if (world != null)
            {
                world.Close();
            }



            BoogieCore.Log(LogType.System, "TotalMemory " + System.GC.GetTotalMemory(false) / (1024 * 1024) + " MB");
            world = null; // release RAM

            BoogieCore.Log(LogType.System, "TotalMemory after GC " + System.GC.GetTotalMemory(true) / (1024 * 1024) + " MB");
        }
コード例 #4
0
ファイル: PPather.cs プロジェクト: Bia10/boogiebot
        private void Startup()
        {
            RunState    = RunState_e.Paused;
            WantedState = RunState_e.Running;

            BoogieCore.Log(LogType.System, "TotalMemory before " + System.GC.GetTotalMemory(true) / (1024 * 1024) + " MB");

            WasAt = null;

            string zone = FigureOutZone();

            MPQTriangleSupplier mpq = new MPQTriangleSupplier();

            CurrentContinent = mpq.SetZone(zone);

            BoogieCore.Log(LogType.System, "Zone is : " + zone);
            BoogieCore.Log(LogType.System, "Continent is : " + CurrentContinent);


            string myFaction = "Unknown";


            ChunkedTriangleCollection triangleWorld = new ChunkedTriangleCollection(512);

            triangleWorld.SetMaxCached(9);
            triangleWorld.AddSupplier(mpq);

            world = new PathGraph(CurrentContinent, triangleWorld, null);
            mover = new Mover();
            radar = new UnitRadar();
            BoogieCore.Log(LogType.System, "Pather loaded!");

            while (ShouldRun)
            {
                Thread.Sleep(100);
            }
        }
コード例 #5
0
ファイル: PPather.cs プロジェクト: Bia10/boogiebot
 public void UpdateMyPos()
 {
     BoogieCore.Log(LogType.System, "[Update] 1");
     //radar.Update();
     if (world != null)
     {
         Coordinate loc  = BoogieCore.world.getPlayerObject().GetCoordinates();
         Location   isAt = new Location(loc.X, loc.Y, loc.Z);
         BoogieCore.Log(LogType.System, "[Update] 2");
         //if(WasAt != null)  Context.Log("was " + WasAt.location);
         //Context.Log("isAt " + isAt);
         if (WasAt != null)
         {
             BoogieCore.Log(LogType.System, "[Update] 3");
             if (WasAt.GetLocation().GetDistanceTo(isAt) > 20)
             {
                 WasAt = null;
             }
         }
         BoogieCore.Log(LogType.System, "[Update] 4");
         WasAt = world.TryAddSpot(WasAt, isAt);
         BoogieCore.Log(LogType.System, "[Update] 5");
     }
 }
コード例 #6
0
ファイル: PPather.cs プロジェクト: Bia10/boogiebot
        // 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;
            }
        }
コード例 #7
0
ファイル: PPather.cs プロジェクト: Bia10/boogiebot
        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);
        }
コード例 #8
0
ファイル: BoogieBot.cs プロジェクト: Bia10/boogiebot
 private void playerClassDump_MenuItem_Click(object sender, EventArgs e)
 {
     BoogieCore.Log(LogType.System, "{0}", BoogieCore.Player);
 }
コード例 #9
0
ファイル: BoogieBot.cs プロジェクト: Bia10/boogiebot
 private void playerObjectDump_MenuItem_Click(object sender, EventArgs e)
 {
     Common.Object mObj = BoogieCore.world.getPlayerObject();
     BoogieCore.Log(LogType.System, "{0}", mObj);
 }
コード例 #10
0
ファイル: BoogieBot.cs プロジェクト: Bia10/boogiebot
        private void objectNames_MenuItem_Click(object sender, EventArgs e)
        {
            String names = BoogieCore.world.DEBUG_ObjectNames();

            BoogieCore.Log(LogType.System, "World: Listing names:\n{0}", names);
        }
コード例 #11
0
ファイル: BoogieBot.cs プロジェクト: Bia10/boogiebot
        private void objectCount_MenuItem_Click(object sender, EventArgs e)
        {
            int count = BoogieCore.world.DEBUG_ObjectCount();

            BoogieCore.Log(LogType.System, "World: {0} objects stored in the world.", count);
        }
コード例 #12
0
ファイル: Moving.cs プロジェクト: Bia10/boogiebot
        public bool moveTowardsFacing(Coordinate to, double distance, Coordinate facing)
        {
            bool       moving = false;
            Coordinate myLoc  = BoogieCore.world.getPlayerObject().GetCoordinates();
            double     d      = to.DistanceTo(myLoc);

            BoogieCore.Log(LogType.System, "[Move] D = {0}", d);
            BoogieCore.Log(LogType.System, "[Move] myLoc = {0}", myLoc);
            BoogieCore.Log(LogType.System, "[Move] To = {0}", to);

            if (d > distance)
            {
                int dir = GetLocationDirection(to);
                if (dir != 0)
                {
                    moving |= true;
                }
                if (dir == 1 || dir == 3 || dir == 0)
                {
                    StrafeLeft(false); StrafeRight(false);
                }
                ;
                if (dir == 2 || dir == 4 || dir == 0)
                {
                    Forwards(false); Backwards(false);
                }
                ;
                if (dir == 1)
                {
                    Forwards(true);
                }
                if (dir == 2)
                {
                    StrafeRight(true);
                }
                if (dir == 3)
                {
                    Backwards(true);
                }
                if (dir == 4)
                {
                    StrafeLeft(true);
                }
                BoogieCore.Log(LogType.System, "[Move] Get Direction: {0}", dir);
                //Context.Log("Move dir: " + dir);
            }
            else
            {
                BoogieCore.Log(LogType.System, "[Move] Is close {0}", d);
                StrafeLeft(false);
                StrafeRight(false);
                Forwards(false);
                Backwards(false);
                return(false);
            }

            BoogieCore.Log(LogType.System, "[Move] 1");
            double bearing = BoogieCore.World.getPlayerObject().CalculateAngle(facing.X, facing.Y);

            if (bearing < -PI / 8)
            {
                BoogieCore.Log(LogType.System, "[Move] 2");
                moving |= true;
            }
            else if (bearing > PI / 8)
            {
                BoogieCore.Log(LogType.System, "[Move] 3");
                moving |= true;
            }

            return(moving);
        }
コード例 #13
0
ファイル: Chat.cs プロジェクト: Bia10/boogiebot
        private void Input_KeyDown(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Return)
            {
                defaultLanguage = (Languages)BoogieCore.configFile.ReadInteger("Connection", "DefaultLanguage");

                e.Handled = true;
                if (input.Text != "")
                {
                    string cmd = "", arguments = "";

                    string regx  = @"^\/(\w+)\s*(.*)\s*$";
                    Match  match = Regex.Match(input.Text, regx);

                    if (match.Success)
                    {
                        BoogieCore.Log(LogType.SystemDebug, "RegExp match! Count: {0} Matches: ", match.Captures.Count + 1);
                        for (int i = 1; i <= match.Captures.Count + 1; i++)
                        {
                            BoogieCore.Log(LogType.SystemDebug, "Match #{0} = \"{1}\" ", i, match.Groups[i].Value);
                        }

                        cmd       = match.Groups[1].Value;
                        arguments = match.Groups[2].Value;
                    }

                    if (cmd == "update")
                    {
                        UpdateList();
                        input.Text = "";
                        return;
                    }

                    if (cmd == "join")
                    {
                        BoogieCore.WorldServerClient.JoinChannel(arguments, null);
                        input.Text = "";
                        return;
                    }

                    if (cmd == "part" || cmd == "leave")
                    {
                        BoogieCore.WorldServerClient.PartChannel(arguments);
                        input.Text = "";
                        return;
                    }

                    if (cmd == "whisper" || cmd == "w")
                    {
                        string regx2 = @"(\w+)\s*(.*)\s*$";
                        Match  match2 = Regex.Match(arguments, regx2);
                        string user = null, msg = null;

                        if (match2.Success)
                        {
                            user = match2.Groups[1].Value;
                            msg  = match2.Groups[2].Value;
                            if (user.Length > 2 && msg.Length >= 1)
                            {
                                BoogieCore.WorldServerClient.SendChatMsg(ChatMsg.CHAT_MSG_WHISPER, defaultLanguage, msg, user);
                            }
                        }
                        return;
                    }

                    if (type.SelectedItem.ToString() != "")
                    {
                        if (type.SelectedItem.ToString().ToLower() == "say")
                        {
                            BoogieCore.WorldServerClient.SendChatMsg(ChatMsg.CHAT_MSG_SAY, defaultLanguage, input.Text);
                            input.Text = "";
                            return;
                        }
                        if (type.SelectedItem.ToString().ToLower() == "act")
                        {
                            BoogieCore.WorldServerClient.SendChatMsg(ChatMsg.CHAT_MSG_EMOTE, defaultLanguage, input.Text);
                            input.Text = "";
                            return;
                        }
                        if (type.SelectedItem.ToString().ToLower() == "yell")
                        {
                            BoogieCore.WorldServerClient.SendChatMsg(ChatMsg.CHAT_MSG_YELL, defaultLanguage, input.Text);
                            input.Text = "";
                            return;
                        }

                        BoogieCore.WorldServerClient.SendChatMsg(ChatMsg.CHAT_MSG_CHANNEL, defaultLanguage, input.Text, type.SelectedItem.ToString());
                        input.Text = "";
                        return;
                    }
                }
            }
        }
コード例 #14
0
ファイル: CharList.cs プロジェクト: Bia10/boogiebot
 private void listView1_DoubleClicked(object sender, EventArgs e)
 {
     BoogieCore.Log(LogType.SystemDebug, "Attempting to login character {0}", listView1.SelectedItems[0].SubItems[1].Text);
     BoogieCore.WorldServerClient.LoginChar(UInt64.Parse(listView1.SelectedItems[0].SubItems[0].Text));
     this.Hide();
 }