C# pathing bot menu

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    C# pathing bot

    In my bot right now, I'm working on my map display of the waypoints(and soon players/npcs...etc). It's just using primitive graphics from System.Drawing with circles around each waypoint, connecting consecutive waypoints with a green line. I had some very elaborate code, but it wasn't working the way I liked it. It had the center of a picturebox as the origin of WoW(x,y-wise). My waypoints were tiny and couldn't tell one from the other. I need some help rewriting this. Not sure how to do it =/

    Here's my old code anyways...

    Code:
     
    Graphics g = Graphics.FromImage(bm);
    float XLow, YLow, XHigh, YHigh;
    XLow = 0;
    YLow = 0;
    XHigh = 0;
    YHigh = 0;
    int index = 0;
    XLow = m_parent.wm.waypoints[0].X;
    YLow = m_parent.wm.waypoints[0].Y;
    foreach (Location loc in m_parent.wm.waypoints)
    {
    if (XLow > loc.X)
    XLow = loc.X;
    if (YLow > loc.Y)
    YLow = loc.Y;
    if (YHigh < loc.Y)
    YHigh = loc.Y;
    if (XHigh < loc.X)
    XHigh = loc.X;
    }
    List<Point> offsets = new List<Point>();
    foreach (Location loc in m_parent.wm.waypoints)
    {
    offsets.Add(new Point(Convert.ToInt32(loc.X - XLow), Convert.ToInt32(loc.Y - YLow)));
    }
    float scaleX = XHigh - XLow;
    if (scaleX < 0)
    scaleX = scaleX * (-1);
    float scaleY = YHigh - YLow;
    if (scaleY < 0)
    scaleY = scaleY * (-1);
    scaleX = (pictureBox1.Width / 2) / scaleX;
    scaleY = (pictureBox1.Height / 2) / scaleY;
    foreach (Point p in offsets)
    {
    float newX = p.X * scaleX;
    float newY = p.Y * scaleY;
    newX = (pictureBox1.Width / 2) + newX;
    newY = (pictureBox1.Height / 2) + newY;
    wps.Add(new Point(Convert.ToInt32(newX), Convert.ToInt32(newY)));
    }
    foreach (Point pt in wps)
    {
    bm.SetPixel(pt.X, pt.Y, Color.Red);
    g.DrawEllipse(new Pen(Brushes.Blue, 1), new Rectangle(pt.X - 5, pt.Y - 5, 10, 10));
    
    }
    while ((index + 1) <= (m_parent.wm.waypoints.Count - 1))
    {
    g.DrawLine(new Pen(Brushes.Green, 1f), wps[index], wps[index + 1]);
    index++;
    }
    Just a small hint would be nice, I couldn't find anything on google. Hard to google something like this o.O

    C# pathing bot
  2. #2
    Apoc's Avatar Angry Penguin
    Reputation
    1388
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/13
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hint: If you actually DID write this, you wouldn't be having any issues right now, would you?

    Anyhow, AFK 20-30 min while I dig up other code to give an example.

  3. #3
    Apoc's Avatar Angry Penguin
    Reputation
    1388
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/13
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
            private static void DrawLine(Graphics canvas, Point from, Point to)
            {
                Pen p = new Pen(Color.Red, 1);
                canvas.DrawLine(p, from.X, from.Y, to.X, to.Y);
            }
    
            private static void DrawPoint(Graphics canvas, Point pt, int radius)
            {
                canvas.DrawRectangle(Pens.Blue, pt.X, pt.Y, radius, radius);
                canvas.FillRectangle(Brushes.Blue, pt.X, pt.Y, radius, radius);
            }
    
            private void panel1_Paint(object sender, PaintEventArgs e)
            {
                if (selectedCmbProfile != null)
                {
                    Graphics gfx = e.Graphics;
                    Point last = new Point(0.0f, 0.0f, 0.0f);
                    panel1.SuspendLayout();
                    foreach (Point point in selectedCmbProfile.Points)
                    {
                        DrawPoint(gfx, point, 4);
                        if (last.IsValid)
                        {
                            DrawLine(gfx, last, point);
                        }
                        last = point;
                    }
                    panel1.ResumeLayout(true);
                }
            }
    Doesn't have any of the logic in there to center/scale the graphics.

    Search though, that's already been answered.

  4. #4
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well. It always seems like whenever I code something to do something, and I compare it to your code, mine looks childish. Oh well. It's for my eyes only. I'll search for the logic, though that's what I needed help with. Lol.

  5. #5
    Apoc's Avatar Angry Penguin
    Reputation
    1388
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/13
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  6. #6
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, I'm not really sure how the search button missed that...

  7. #7
    dkilkhan's Avatar Private
    Reputation
    2
    Join Date
    May 2008
    Posts
    11
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's some short methods from the visualization I use on my project...

    Code:
    private void DrawFacingLine(DObject obj)
    {
         int x = (int)(zoom * (Me.X - obj.X)) + (MAP_WIDTH / 2);
         int y = (int)(zoom * (Me.Y - obj.Y)) + (MAP_HEIGHT / 2);
    
         double new_x = x + (FACING_LINE * Math.Cos(obj.Facing + (Math.PI / 2)));
         double new_y = y + (FACING_LINE * Math.Sin(obj.Facing - (Math.PI / 2)));
         gb.DrawLine(Pens.Black, x, y, (int)new_x, (int)new_y);
    }
    
    private Point NormalizedLoc(DLocation myLoc, DLocation objLoc) 
    {
         return new Point((int)(zoom * (myLoc.Y - objLoc.Y)) + (MAP_HEIGHT / 2), (int)(zoom * (myLoc.X - objLoc.X)) + (MAP_WIDTH / 2));
    }
    Assuming your player object (Me) is the center of your map (width/2, height/2), the first draws a line representing the facing angle of the given game object with length of facing_line. The second normalizes the given object's location to the center player (again, Me). The resulting x/y is reversed as it was the only one that made visual sense when looking at it running...

  8. #8
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's pretty cool, I may add something along those lines to it later. Right now, that's overkill for what it's for. I just need it to show the waypoints and the active player location(which it isn't doing...). I just have to get it updating the player location and it should be good. Might just clear the bitmap and repaint the whole thing 2x a sec or so. Hope it works.

  9. #9
    dkilkhan's Avatar Private
    Reputation
    2
    Join Date
    May 2008
    Posts
    11
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, in any case you have to normalize the coordinates to your radar map for them to show properly.

    Also, I suppose for slow updating it's not an issue, but if you are going for anything semi-real time, you'll want to implement double buffering otherwise you'll get unsightly flickering of the canvas.

  10. #10
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This may sound noobish(and probably is), but does just using the form control "DoubleBuffer" and setting it true make it double buffered? Or do you have to manually do the buffering?

  11. #11
    dkilkhan's Avatar Private
    Reputation
    2
    Join Date
    May 2008
    Posts
    11
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know what you are drawing to, but in my case I it drew up on a PictureBox. I just maintained two bitmaps and alternated them, drawing to one and displaying the other. It worked decently enough for my purposes (which was just debugging path/enemy finding).

    There's a ton of info already out there for all kinds of specific cases.

  12. #12
    Apoc's Avatar Angry Penguin
    Reputation
    1388
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/13
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    WinForms already has the ability to double buffer for you. (Set the property to true.)

    There's no need to maintain two different images, as it can easily be handled for you. Also, using a picture box may not be the best idea. I prefer to use a simple Panel, then each of my 'points' are another panel. (So you are able to use the tooltip to show the 'actual' point representing that... erm... point.)

  13. #13
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Offtopic, but do you have any books that you would recommend for better coding practices? I know the language pretty decently now, and am making small projects that do random tasks(simple fileserver with authentication, accessing databases, xml, etc). I feel that my code seems very, one-way and will crash sometimes and I don't know why. Anyway, have any recommendations?

  14. #14
    MaiN's Avatar Elite User
    Reputation
    335
    Join Date
    Sep 2006
    Posts
    1,047
    Thanks G/R
    0/10
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, how about using DrawPath? Isn't it there for a reason?
    Atleast I think I saw a DrawPath in System.Drawing..
    [16:15:41] Cypher: caus the CPU is a dick
    [16:16:07] kynox: CPU is mad
    [16:16:15] Cypher: CPU is all like
    [16:16:16] Cypher: whatever, i do what i want

  15. #15
    galpha's Avatar Member
    Reputation
    5
    Join Date
    Nov 2007
    Posts
    48
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As Apoc said, a picturebox isn't meant to handle drawing ontop. It is a simple control meant to host an image. You usually find those "best practices" on multiple sites. I remember seeing that on MSDN if I recall.

Page 1 of 2 12 LastLast

Similar Threads

  1. Path of Exile Bot?
    By TheRealSlimShady in forum MMO Exploits|Hacks
    Replies: 6
    Last Post: 05-02-2020, 03:14 AM
  2. [Bot] Path of Exile - Bots, Hacks, Cheats - All in one place
    By Rotondo in forum PoE Bots and Programs
    Replies: 2
    Last Post: 04-11-2013, 02:21 PM
  3. Path of Exile Wordpress Bot
    By naughtier in forum PoE Bots and Programs
    Replies: 1
    Last Post: 02-06-2013, 09:24 AM
  4. Pathing bot
    By Backfire104 in forum WoW Bots Questions & Requests
    Replies: 0
    Last Post: 10-24-2010, 05:20 AM
  5. F making your own bot path
    By Cherry Got Wowed in forum World of Warcraft Guides
    Replies: 7
    Last Post: 10-22-2007, 01:46 PM
All times are GMT -5. The time now is 04:36 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search