Results 1 to 10 of 10

Thread: Maplestory - Character & Mob detection | Suggestions please

  1. #1
    Join Date
    Dec 2016
    Posts
    49
    Mentioned
    0 Post(s)
    Quoted
    22 Post(s)

    Default Maplestory - Character & Mob detection | Suggestions please

    Hello,

    So I'm looking into a new project for MapleStory in hopes I can learn something new. I am aiming rather low right now and am looking to have a TBox for my respective attack range search for specific colors, aka my mobs. However, in order to do this I need to be able to detect my characters location as it shifts left, right, up & down slightly which could throw this off.

    Ultimately I am looking for suggestions on approaches to undertake this.

    1. Character detection - I'm terrible with DTM's and unsure if this is the BEST route to take. Also figured wearing unique colors might be a means of setting this however I would probably need to do a constant check every loop for a location. I would suspect this might run into memory issues though?

    2. TBox for attack range - I'm assuming cleanest approach is simply to wrap this up with the TBox (If I decide to search for unique colors) of my character HOWEVER, I'm not quite sure how I would detect the direction I am facing.

    3. Direction character is facing- Original thought is I could detect my key-down for the arrow keys which will work however long term I would want to fully automate this.


    For those unfamiliar with what the game looks like:
    test.png

    Also attached is what I currently have. Any input, ideas or suggestions outside of the above to be implemented are welcome!
    Attached Files Attached Files
    Last edited by BlitzKrieger; 07-13-2017 at 12:14 AM.

  2. #2
    Join Date
    Dec 2016
    Posts
    49
    Mentioned
    0 Post(s)
    Quoted
    22 Post(s)

    Default

    Figured I'd Bump given the lack of input.

    I decided to go the route of detecting the direction I'm facing via whether the left or right arrow keys were pressed. My only problem is keeping the TBox it returns as a static value. At the moment it resets back to (0,0,0,0). I'm sure I am missing something basic. Any pointers would be helpful.

    Simba Code:
    function attackDirection: TBox;
    var
      attackLeft, attackRight: TBox;
    begin
      attackLeft.setBounds(1,1,1,1);
      attackRight.setBounds(2,2,2,2);
      if isKeyDown(37) then
        result := attackLeft;
      if isKeyDown(39) then
        result := attackRight
    end;

  3. #3
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    Quote Originally Posted by BlitzKrieger View Post
    Figured I'd Bump given the lack of input.

    I decided to go the route of detecting the direction I'm facing via whether the left or right arrow keys were pressed. My only problem is keeping the TBox it returns as a static value. At the moment it resets back to (0,0,0,0). I'm sure I am missing something basic. Any pointers would be helpful.

    Simba Code:
    function attackDirection: TBox;
    var
      attackLeft, attackRight: TBox;
    begin
      attackLeft.setBounds(1,1,1,1);
      attackRight.setBounds(2,2,2,2);
      if isKeyDown(37) then
        result := attackLeft;
      if isKeyDown(39) then
        result := attackRight
    end;
    I'm guessing you have some code like
    Simba Code:
    attackBox := attackDirection;
    which will return a [0,0,0,0] TBox when you aren't pressing a key.

    Off the top of my head, something like this could work:
    Simba Code:
    function attackDirection(key: byte): TBox;
    begin
      while isKeyDown(key) do wait(22); //this might be a good idea
      case key of
        37: exit([1, 1, 1, 1]);
        38: exit([2, 2, 2, 2]);
        39: exit([3, 3, 3, 3]);
        40: exit([4, 4, 4, 4]);
      end;
    end;

    procedure mainloop;
    begin
      if isKeyDown(37) then attackBox := attackDirection(37) else
      if isKeyDown(38) then attackBox := attackDirection(38) else
      if isKeyDown(39) then attackBox := attackDirection(39) else
      if isKeyDown(40) then attackBox := attackDirection(40);
    end;

  4. #4
    Join Date
    Dec 2016
    Posts
    49
    Mentioned
    0 Post(s)
    Quoted
    22 Post(s)

    Default

    Quote Originally Posted by Citrus View Post
    I'm guessing you have some code like
    Simba Code:
    attackBox := attackDirection;
    which will return a [0,0,0,0] TBox when you aren't pressing a key.

    Off the top of my head, something like this could work:
    Simba Code:
    function attackDirection(key: byte): TBox;
    begin
      while isKeyDown(key) do wait(22); //this might be a good idea
      case key of
        37: exit([1, 1, 1, 1]);
        38: exit([2, 2, 2, 2]);
        39: exit([3, 3, 3, 3]);
        40: exit([4, 4, 4, 4]);
      end;
    end;

    procedure mainloop;
    begin
      if isKeyDown(37) then attackBox := attackDirection(37) else
      if isKeyDown(38) then attackBox := attackDirection(38) else
      if isKeyDown(39) then attackBox := attackDirection(39) else
      if isKeyDown(40) then attackBox := attackDirection(40);
    end;
    Meant to update this sooner - yes I changed it to a case to resolve that. I forgot about my other issue though and that's the constantly moving TBox for attack range. I'm thinking to find a TPA of my characters color (which my character is what moves coordinates drastically resulting in the changing attackRange) - grab the x,y and then adjust my TBox's off of those coords. Not quite sure how to do this but going to experiment.

    Edit:

    As for what I did in case you have recommendations on how to do it "correctly"
    Simba Code:
    function charDirection: string;
    begin
      if isKeyDown(39) then
        result := 'attackRight';
      if isKeyDown(37) then
        result:= 'attackLeft';
    end;

    procedure mainLoop();
    begin
      case charDirection of
        'attackRight': attackDirection := rangeRight; //attackDirection is declared as a TBox so it's ultimately picking up the other TBox coords.
        'attackLeft': attackDirection := rangeLeft;
        end;

    As for finding mobs I think I should be able to get away with TBox.getColors/TBox.colorExists and just have it search the attackDirection TBox for mob colors - if it detects then to send attack key. Will be working on this once I get the moving attackDirection TBox down.
    Last edited by BlitzKrieger; 07-26-2017 at 02:31 AM.

  5. #5
    Join Date
    Dec 2016
    Posts
    49
    Mentioned
    0 Post(s)
    Quoted
    22 Post(s)

    Default

    Update:
    Used the below code to determine an X, Y coordinate of my character. I think now I can use this to determine my ranges to the left/right respectively by setting my boxes something along the lines of (x + 100, y + 100, x + 200, y + 200) etc..

    I'm using the red on the hat and have set the minArea as large as possible to avoid picking up any false items. If you happen to read this and can think of a better approach im open to ideas!

    Simba Code:
    procedure charxy();
    var
      x, y: integer;

    begin
      msScreen.setBounds(16, 38, 788, 550);

      if findColoredAreaTolerance(x, y, 4573, 16, 38, 788, 550, 222, 39) then
        writeln('x:');
        writeln(x);
        writeln('y:');
        writeln(y);
        writeln(' _-_-_-_-_-_-_');
    end;

    charxy.PNG
    @Citrus;

    I'm off to bed - got stuck on the below if you have any ideas before I look at it again tomorrow.
    Simba Code:
    function charxy(key: byte): TBox;
    var
      x, y, lx1, lx2, rx1, rx2, ry1, ry2, ly1, ly2: integer;
    begin
      if findColoredAreaTolerance(x, y, 4573, 16, 38, 788, 550, 222, 39) then  //searches for red on mark of beta hat to detect players location
      lx1:= (x - 391);                  //numbers are what I need my attack box range to be - however need it to be based off the given x, y coordinates of my characters location
      lx2:= (x + 12);
      ly1:= (y - 71);
      ly2:= (y + 135);
      rx1:= (x + 391);
      rx2:= (x - 12);
      ry1:= (y + 71);
      ry2:= (y - 135);
      if isKeyDown(key) then
      case key of
      37: exit ([lx1, ly1, lx2, ly2]);           //Error: Can't assign "array [0..3] of Int32" to "record [0]Int32; [4]Int32; [8]Int32; [12]Int32; end" at line 40
      39: exit ([rx1, ry1, rx2, ry2]);
      end;
    end;

    Nevermind I am an idiot - changed it to exit (IntToBox(x1, y1, x2, y2)) for the fix. Thanks so much for your insight it's definitely helped be get the flow of this down! I'd spread some rep but apparently I'm unable to?

    Now I just need to implement it to detect mobs within this attackBox and sendkey to attack. Will get this part done tomorrow.
    Last edited by BlitzKrieger; 07-26-2017 at 05:05 AM.

  6. #6
    Join Date
    Dec 2016
    Posts
    49
    Mentioned
    0 Post(s)
    Quoted
    22 Post(s)

    Default

    Update: Detects mobs at the moment although one big problem.... my TBox is extending outside of my client bounds is there a simple fix for this? (any sample code or examples I could look at that might be handling similar issues?)

    Error: You passed wrong values to a finder function: xs > xe (911,508). at line 204
    Execution failed.

    thinking of doing a check for client bounds and comparing my x and y's for client bounds so for example if X1 < 1 then X1:= 1 and if X1 > 900 then X1:= 900.... thoughts on this?
    Last edited by BlitzKrieger; 07-27-2017 at 01:53 AM.

  7. #7
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    Quote Originally Posted by BlitzKrieger View Post
    Update: Detects mobs at the moment although one big problem.... my TBox is extending outside of my client bounds is there a simple fix for this? (any sample code or examples I could look at that might be handling similar issues?)

    Error: You passed wrong values to a finder function: xs > xe (911,508). at line 204
    Execution failed.

    thinking of doing a check for client bounds and comparing my x and y's for client bounds so for example if X1 < 1 then X1:= 1 and if X1 > 900 then X1:= 900.... thoughts on this?
    That isn't a client bounds error; it's a bounds logic error. X1 must be <= X2, and Y1 must be <= Y2. It's saying that your X1 (911) is greater than your X2 (508).
    The code in your previous post is at fault.

  8. #8
    Join Date
    Dec 2016
    Posts
    49
    Mentioned
    0 Post(s)
    Quoted
    22 Post(s)

    Default

    Quote Originally Posted by Citrus View Post
    That isn't a client bounds error; it's a bounds logic error. X1 must be <= X2, and Y1 must be <= Y2. It's saying that your X1 (911) is greater than your X2 (508).
    The code in your previous post is at fault.
    Error: You passed a wrong ys to a finder function: -71. That is below 0, thus out of bounds. at line 204

    Your right. So I basically need to make sure it doesn't go below 0. I was looking at the X, Y incorrectly and assuming 0,0 was from the middle and not the top left. That's my problem. Thanks again.

  9. #9
    Join Date
    Jul 2017
    Posts
    3
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    I was actually attempting on a MapleStory bot earlier this month. But for whatever reason, MapleStory wasn't picking up any keyboard keys being sent to it =/

  10. #10
    Join Date
    Dec 2016
    Posts
    49
    Mentioned
    0 Post(s)
    Quoted
    22 Post(s)

    Default

    Quote Originally Posted by PshYouLost View Post
    I was actually attempting on a MapleStory bot earlier this month. But for whatever reason, MapleStory wasn't picking up any keyboard keys being sent to it =/
    I had to use another software to open it with and it's accepting sendKeys. PressKeys and what not don't seem to go through though but I think that's intentional according to the documentation as it's 'faking' a key event.

    Edit:

    tBox.SetLimit doesn't seem to be sticking. It'll work but then suddenly it stops working and I begin getting negative values again resulting in tbox.ColorExists to fault.

    Simba Code:
    program MapleStory;
    {$DEFINE SMART}
    {$i srl-6/srl.simba}
     var
      attackBox: TBox;
      attackLeft, attackRight: string;
    function HP: boolean;
    var
      x, y: integer;
    begin
      if FindColor(x, y, 15000804, 230, 614, 277, 621) then //searches for white color in hp bar
        exit(true)
      else exit(false);
    end;

    function MP: boolean;
    var
      x, y: integer;
    begin
      if FindColor(x, y, 15000804, 339, 614, 371, 621) then //searches for white color in hp bar
        exit(true)
      else exit(false);
    end;

    function charxy(key: byte): TBox;
    var
      x, y, lx1, lx2, rx1, rx2, ry1, ry2, ly1, ly2: integer;
    begin
      if findColoredAreaTolerance(x, y, 4573, 16, 38, 788, 550, 222, 39) then  //searches for red on mark of beta hat to detect players location
      lx1:= x - 391;                  //numbers are what I need my attack box range to be - however need it to be based off the given x, y coordinates of my characters location
      lx2:= x + 12;
      ly1:= y - 71;
      ly2:= y + 135;
      rx1:= x - 12;
      rx2:= x + 391;
      ry1:= y - 135;
      ry2:= y + 71;

      if isKeyDown(key) then
        case key of
        37: exit (IntToBox(lx1, ly1, lx2, ly2));
        39: exit (IntToBox(rx1, ry1, rx2, ry2));
        end;
    end;

    procedure mainLoop();
    begin
      if isKeyDown(37) then
      begin
        attackBox.setLimit(IntToBox(1, 1, 1006, 640));
        attackBox := charxy(37)
      end
      else if isKeyDown(39) then
      begin
        attackBox.setLimit(IntToBox(1, 1, 1006, 640));
        attackBox := charxy(39);
      end
      else if attackBox.colorExists(65535, 0) then
        sendKeys('c', 10, 10)
      else if HP = true then
      begin
        sendKeys('o', 10, 10); //sends key for hp pot
        wait(600);
      end
      else if MP = true then
      begin
        sendKeys('p', 10, 10); //sends key for mp pot
        wait(600);
      end
      else if not isKeyDown(43) then    //checks if C key is down (attack key)
      begin
        sendKeys('z', 10, 10);      //sends key for loot
        wait(100);
      end;
    end;

    begin
    wait(3000);                                            //pl      tl       br 673, 353 390,282 685, 488

      repeat
        while isKeyDown(116) do //waits while F5 is held
          wait(1000);
        mainLoop();
        writeln(attackBox);
      until false;
    end.
    Last edited by BlitzKrieger; 07-28-2017 at 02:00 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •