Trying to create a Bot for a game
Trying to create a Bot for a game
Hello community,
I am trying to create a bot for a game that I play a lot. The bot is intended to level up while I am away from my keyboard. So, I am having difficulties in how to handle the mouse movements and keyboard pressed keys and send them to the window where the game is running. Could anyone give me some directions in how to accomplish this ? Thanks a lot.
Jmauver
			
			
									
									
						I am trying to create a bot for a game that I play a lot. The bot is intended to level up while I am away from my keyboard. So, I am having difficulties in how to handle the mouse movements and keyboard pressed keys and send them to the window where the game is running. Could anyone give me some directions in how to accomplish this ? Thanks a lot.
Jmauver
- 
				superadnim
 - Enthusiast

 - Posts: 480
 - Joined: Thu Jul 27, 2006 4:06 am
 
Oh no... cheater, tell me which game is it and also your character's names so I can get you banned!  
 
No, really. If you gave us at least the name of the game it would be easier to help you.
I guess this is an MMO... Most games handle input through the window's message system (in windows, that is...) and yes, you can send your own input messages. Take a trip into the search feature of the forum, you'll find it all in there.
Basically you must a) find the window handle, could be from the window title (easiest method). b) send the message. c) enjoy cheating.
Some games have anti-cheating systems that prevent this sort of deal, and that's also why knowing the name would help all of us. The guessing game is not my forte either so quit the mystery!.
			
			
									
									No, really. If you gave us at least the name of the game it would be easier to help you.
I guess this is an MMO... Most games handle input through the window's message system (in windows, that is...) and yes, you can send your own input messages. Take a trip into the search feature of the forum, you'll find it all in there.
Basically you must a) find the window handle, could be from the window title (easiest method). b) send the message. c) enjoy cheating.
Some games have anti-cheating systems that prevent this sort of deal, and that's also why knowing the name would help all of us. The guessing game is not my forte either so quit the mystery!.
Thanks
superadnim wrote:Oh no... cheater, tell me which game is it and also your character's names so I can get you banned!![]()
No, really. If you gave us at least the name of the game it would be easier to help you.
I guess this is an MMO... Most games handle input through the window's message system (in windows, that is...) and yes, you can send your own input messages. Take a trip into the search feature of the forum, you'll find it all in there.
Basically you must a) find the window handle, could be from the window title (easiest method). b) send the message. c) enjoy cheating.
Some games have anti-cheating systems that prevent this sort of deal, and that's also why knowing the name would help all of us. The guessing game is not my forte either so quit the mystery!.
Hi Superadnin,
Thanks for your input. The game is Muonline
Jmauver
making a bot that just press keys is not a good way to go, how the bot will know that you are low on health ? targeting something ? etc... 
you might better found the way the server send/receive orders and made a bot that goes beetween the client and the server to intercept/send messages
but you'll have to learn the protocols and this is not an easy task !
			
			
									
									
						you might better found the way the server send/receive orders and made a bot that goes beetween the client and the server to intercept/send messages
but you'll have to learn the protocols and this is not an easy task !
- Rook Zimbabwe
 - Addict

 - Posts: 4322
 - Joined: Tue Jan 02, 2007 8:16 pm
 - Location: Cypress TX
 - Contact:
 
I just have to ask... 
Is the point to PLAY or is the point to LEVEL UP?
If the only purpose you have in the game is to level up, maybe you need to find a new game?
After a certain point in ANY MMORPG is becomes almost impossible to level up and increase power. This is simply because there is no built in balance system. People get frustrated if they cannot achieve early success and increase thier power early on, but as they play it MUST become more and more difficult or everybody walks around with 1,000,000 HP and 100,000,000 GP and the Godly Armor of the Whale etc.
It isn't a game at that point... it is some sort of electronic clickfest pissing contest!
I am not attempting to rag on you I am only stating some issues I have with online games...
			
			
									
									
						Is the point to PLAY or is the point to LEVEL UP?
If the only purpose you have in the game is to level up, maybe you need to find a new game?
After a certain point in ANY MMORPG is becomes almost impossible to level up and increase power. This is simply because there is no built in balance system. People get frustrated if they cannot achieve early success and increase thier power early on, but as they play it MUST become more and more difficult or everybody walks around with 1,000,000 HP and 100,000,000 GP and the Godly Armor of the Whale etc.
It isn't a game at that point... it is some sort of electronic clickfest pissing contest!
I am not attempting to rag on you I am only stating some issues I have with online games...
- Kaeru Gaman
 - Addict

 - Posts: 4826
 - Joined: Sun Mar 19, 2006 1:57 pm
 - Location: Germany
 
@Rook
you speak my mind, mate!
... and gave me a good laugh ...
some online games are no fun anymore because of the wrong people playing them, resp. people playing them the wrong way.
I'm an old Frog with enough gray in my beard, I want to play for relaxment but not to show I'm the coolest mofo in dah hood.
			
			
									
									you speak my mind, mate!
... and gave me a good laugh ...
some online games are no fun anymore because of the wrong people playing them, resp. people playing them the wrong way.
I'm an old Frog with enough gray in my beard, I want to play for relaxment but not to show I'm the coolest mofo in dah hood.
oh... and have a nice day.
						Hi Rook,Rook Zimbabwe wrote:I just have to ask...
Is the point to PLAY or is the point to LEVEL UP?
If the only purpose you have in the game is to level up, maybe you need to find a new game?
After a certain point in ANY MMORPG is becomes almost impossible to level up and increase power. This is simply because there is no built in balance system. People get frustrated if they cannot achieve early success and increase thier power early on, but as they play it MUST become more and more difficult or everybody walks around with 1,000,000 HP and 100,000,000 GP and the Godly Armor of the Whale etc.
It isn't a game at that point... it is some sort of electronic clickfest pissing contest!
I am not attempting to rag on you I am only stating some issues I have with online games...
I understand your point. The purpose of the game is to get stronger by leveling up in order to explorer other maps and stronger monsters. That's why I keep playing with the aim to reach the last and more difficult map. As I said a play a lot, but sometimes I do not have time to play as much as I would wish. I really enjoy the game have been playing it for 3 years now. By creating a bot, I can exercise my PB programming skills and at the same time I help my char a bit
Thanks anyway for sharing your view.
Jmauver
i don't see the point of a bot in a mmorpg 
 that will certainly ruin the game experience for a lot of people, you could be also banned for use of third party software, at this point all the playing time you gave into this game will be lost, and you'll have to play with a new account and start from the ground.
well except all these negative points it may be fun to code it.
i personnaly play a lot of mmorpg (or played) i play to have fun with my buddies ingame, not to go to the top level , after 3 years of playing eqII i'm not at the maximum level, some people are still at the max after just some weeks ...
but, the loose a lot of content , sidequest, and play like it's a job... i don't like this
			
			
									
									
						well except all these negative points it may be fun to code it.
i personnaly play a lot of mmorpg (or played) i play to have fun with my buddies ingame, not to go to the top level , after 3 years of playing eqII i'm not at the maximum level, some people are still at the max after just some weeks ...
but, the loose a lot of content , sidequest, and play like it's a job... i don't like this
- 
				superadnim
 - Enthusiast

 - Posts: 480
 - Joined: Thu Jul 27, 2006 4:06 am
 
Some people bot and sell characters, I know because I wrote some bots and that appears to be the end goal for most of the users.
case: You'd monitor this through memory reading. You need to create a process handle with read access (and write if you plan to modify). Knowing the memory offsets of where each structure is located at, you can easily monitor the character's health, mana, etc. The most important deal is monitoring the battle list and the map itself, not as easy as it sounds.
Aside from that, if you can programatically target enemies and monitor the surroundings while keeping an eye into the player's stats, you'd be on the right path, so to speak.
Not easy and I believe someone else made bots already for that game, although I never played it chances are more than a bot exists. Actually what you're looking for is called a cavebot. Usually they couple the cavebots with other bots/tools such as auto-healing, alarm/monitoring of stats, etc.
But eh... good luck writing a cavebot from scratch, it took me months to even get close to my initial goal. Then I wanted to read the game's map and that took me another whole month, because of the strange way they stored the array in memory... What really takes long is reading and analyzing the process' memory, seeing where everything is at and what it actually means, not a particularly easy task if you haven't done it before.
I'd start with MemHack and 3 gallons of coffee a night.
By the way there are certain methods to avoid getting banned but it all depends on how they deal in that specific game with situations where someone reports you as botting (your fault if that happens, you didn't write a proper cavebot, you should try writing a more credible cavebot first and then worry about dealing with the actual reports, if any). if a GM shows up, you can always a) programatically shut down your bot and alarm you about the situation in any way you see fit.
For what it's worth it, I've seen bots with sms capabilities where you could actually respond to the GM through your cellphone if you were AFK. On the cheapest side, you'd get an sms with a warning so you'd know something bad happened.
Most MMOs will just disconnect you after X minutes of idling, which is great if your bot closed itself due to a GM showing up... you could be afk for all he/she knows and the GM should not ban you, since you're not "in game" (character is still, not responding --- the guy that reported you could be a liar and the next time it happens he could actually get banned for false reports!)
			
			
									
									case: You'd monitor this through memory reading. You need to create a process handle with read access (and write if you plan to modify). Knowing the memory offsets of where each structure is located at, you can easily monitor the character's health, mana, etc. The most important deal is monitoring the battle list and the map itself, not as easy as it sounds.
Aside from that, if you can programatically target enemies and monitor the surroundings while keeping an eye into the player's stats, you'd be on the right path, so to speak.
Not easy and I believe someone else made bots already for that game, although I never played it chances are more than a bot exists. Actually what you're looking for is called a cavebot. Usually they couple the cavebots with other bots/tools such as auto-healing, alarm/monitoring of stats, etc.
But eh... good luck writing a cavebot from scratch, it took me months to even get close to my initial goal. Then I wanted to read the game's map and that took me another whole month, because of the strange way they stored the array in memory... What really takes long is reading and analyzing the process' memory, seeing where everything is at and what it actually means, not a particularly easy task if you haven't done it before.
I'd start with MemHack and 3 gallons of coffee a night.
By the way there are certain methods to avoid getting banned but it all depends on how they deal in that specific game with situations where someone reports you as botting (your fault if that happens, you didn't write a proper cavebot, you should try writing a more credible cavebot first and then worry about dealing with the actual reports, if any). if a GM shows up, you can always a) programatically shut down your bot and alarm you about the situation in any way you see fit.
For what it's worth it, I've seen bots with sms capabilities where you could actually respond to the GM through your cellphone if you were AFK. On the cheapest side, you'd get an sms with a warning so you'd know something bad happened.
Most MMOs will just disconnect you after X minutes of idling, which is great if your bot closed itself due to a GM showing up... you could be afk for all he/she knows and the GM should not ban you, since you're not "in game" (character is still, not responding --- the guy that reported you could be a liar and the next time it happens he could actually get banned for false reports!)
Thanks superadnim,superadnim wrote:Some people bot and sell characters, I know because I wrote some bots and that appears to be the end goal for most of the users.
case: You'd monitor this through memory reading. You need to create a process handle with read access (and write if you plan to modify). Knowing the memory offsets of where each structure is located at, you can easily monitor the character's health, mana, etc. The most important deal is monitoring the battle list and the map itself, not as easy as it sounds.
Aside from that, if you can programatically target enemies and monitor the surroundings while keeping an eye into the player's stats, you'd be on the right path, so to speak.
Not easy and I believe someone else made bots already for that game, although I never played it chances are more than a bot exists. Actually what you're looking for is called a cavebot. Usually they couple the cavebots with other bots/tools such as auto-healing, alarm/monitoring of stats, etc.
But eh... good luck writing a cavebot from scratch, it took me months to even get close to my initial goal. Then I wanted to read the game's map and that took me another whole month, because of the strange way they stored the array in memory... What really takes long is reading and analyzing the process' memory, seeing where everything is at and what it actually means, not a particularly easy task if you haven't done it before.
I'd start with MemHack and 3 gallons of coffee a night.
By the way there are certain methods to avoid getting banned but it all depends on how they deal in that specific game with situations where someone reports you as botting (your fault if that happens, you didn't write a proper cavebot, you should try writing a more credible cavebot first and then worry about dealing with the actual reports, if any). if a GM shows up, you can always a) programatically shut down your bot and alarm you about the situation in any way you see fit.
For what it's worth it, I've seen bots with sms capabilities where you could actually respond to the GM through your cellphone if you were AFK. On the cheapest side, you'd get an sms with a warning so you'd know something bad happened.
Most MMOs will just disconnect you after X minutes of idling, which is great if your bot closed itself due to a GM showing up... you could be afk for all he/she knows and the GM should not ban you, since you're not "in game" (character is still, not responding --- the guy that reported you could be a liar and the next time it happens he could actually get banned for false reports!)
Good explanation and awareness. I am not planning that far, just to control mouse coordinates and pick items that drops from monsters. In fact, until a few months ago, a simple windows script could do the job. But because of hackers who in fact abused the system, the game owners put in place some anti-hacker measures which blocked even the most elementary bot. Using a bot was never a issue or you would get banned for using it. Many players who loves the game bought a Logitech keyboard made for game which you can program for scripts like a bot. I prefer to create my own bot. Some responses for this thread are quite hash, a bit hypocrite, too much politically correct, but most players enjoy so much the game that they would deploy some kind of bot as they have other things to do than play a game all day. One thing is a bot, other thing completely different is a hack that level you up by making you more stronger, killing monsters that you normally can not kill, killing 100 monsters in one go, or even making you richer. That's not I want. Nice and fair people do use bots, and in MUonline it is hard not to find a guild not using it. I play for the challenge, to chill out when I can. Some people just play to talk to buddies, like MSN, everyone is different, I prefer to meet my buddies and have good time with them in parties or going out.
Again, thanks for your good explanation and contribution.
Jmauver
- Rook Zimbabwe
 - Addict

 - Posts: 4322
 - Joined: Tue Jan 02, 2007 8:16 pm
 - Location: Cypress TX
 - Contact:
 
No they don'tNice and fair people do use bots
Using a bot is a cheat. If a player does not like the way a game is constructed they can write their own, or play a different game...
It isn't fair to use a bot if even ONE player in that game is not using a bot.
It is cheating. You know it is... or else why would all bots try to shut down if a GM comes into the scene?
Cheaters might win, they might even level up faster... but they are worthless as human beings!
what is the challenge of letting a bot play the game instead of you?jmauver wrote: I play for the challenge
i don't see the point
i play eqII and in this game you can block you're xp, to not going to fast higher level just by bashing monsters , i do use it a lot
so i can't see the point of using a bot to level up in a game
but i agree that coding a bot may be fun
My advise is to simply contact and ask what level of macro/scripting would be acceptable and what would be too much automation, and stick to their advise.
Another benefit of a dialog with the devs, is that if something goes wrong (your macro/script tool goes haywire or dos something bad that their system flags, or ends up flooding their server with messages or stuck in a loop) then they would most likely block it, then contact you and correct you on what went wrong and unblock it again.
I speak with experience after having created and maintained Gridbot, an entertainment support bot for years, for GridStream Productions in Anarchy Online.
Also, the AO hacker community frown upon exploiters and refuse to help them which is another reason why the AO devs are ok with the AO hackers making and running guild/organization bots. To the extent that at times they have answered and provided information that helped making bots easier for AO.
So work with the devs of the MMO instead of doing your own thing, otherwise don't be surprised if you end up banned if you run over their toes.
			
			
									
									
						Another benefit of a dialog with the devs, is that if something goes wrong (your macro/script tool goes haywire or dos something bad that their system flags, or ends up flooding their server with messages or stuck in a loop) then they would most likely block it, then contact you and correct you on what went wrong and unblock it again.
I speak with experience after having created and maintained Gridbot, an entertainment support bot for years, for GridStream Productions in Anarchy Online.
Also, the AO hacker community frown upon exploiters and refuse to help them which is another reason why the AO devs are ok with the AO hackers making and running guild/organization bots. To the extent that at times they have answered and provided information that helped making bots easier for AO.
So work with the devs of the MMO instead of doing your own thing, otherwise don't be surprised if you end up banned if you run over their toes.
Re: Trying to create a Bot for a game
LOL... A simple question and a diatribe of why not to cheat.  This is a programming forum not an anti-cheating forum.  Not sure how far you may have gotten with your project but I hope to be able to contribute some to your learning curve.  Hate to bring this topic to the surface and restart the anti-Bot rants so I will ask that any further contributors please get off your soap box and actually contribute towards the goal which is learning PureBasic specifically and learning programming generally.
The needs of a bot vs. the programming of a bot are two different discussions. The concept of programming a bot brings about lots of fun discussions about various methods to obtain optimal performance. Unfortunately, this groups decision is to ridicule instead of investigate.
I on the other hand would rather investigate in order to improve not only the requestor's knowledge but also potentially my own knowledge. So with that said. You are basically wanting a move the mouse type some text bot.
I will assume this is for the windows platform, therefore I will be using some code that I wrote last year which contains Windows API calls. Everything I am contributing I found in the forums in some shape or form and was able to bring together. So hopefully this will consolidate some of the information for you.
Set up some procedures using SetCursorPos_(x,y) along with the mouse_event_() API calls:
Now why do I not use the MouseLocate(x,y) command in PB.  Because when I tried it originally back in v3.91 it only worked within the actual PB window.  Using the SetCursorPos_(x,y) sets the position on the current desktop and does not look at what may or may not appear under the cursor once set. (I have not used the MouseLocate(x,y) command since v3.91 or so, therefore I do not know if it works more like SetCursorPos_(x,y) or not).
The MouseButton() commands in PB allow you to see if they have been pressed but does not allow you to "virtually" press them thus I use the Windows API mouse_event_() to simulate a mouse click.
For sending key strokes I would use the SendKeys() procedure by PB located here http://www.purebasic.fr/english/viewtopic.php?t=3766
Now the question is where do you move the mouse to and what to do. A quick an easy program to place a sticky window in the bottom right corner of the desktop to display mouse X and Y positions would be nice.
Something like this should do the job
Now with this program running just open your game. Move the mouse and pause a moment to jot down the mouse cursor locations that are needed.   Note anytime you need to type something from the keyboard and you have the basic information to move the mouse around and type.
You now codify your bot by writing program code that moves the mouse, clicks as appropriate and types keyboard input as needed. Being sure to place delays and pauses for correct timing.
Should be relatively easy as all you have to do is call the appropriate procedure from above and as needed.
For example you might have something like this (from my autologin program):
This is a dumb program meaning it will only do what you have previously done at least once.  If you do it multiple times and it is very repetitive then this will work.  If on the other hand, you want something to figure out where to entrance/door is, open it, move through it, look for monsters, check health and make sure I can fight safely, engage monster, look for next room, etc. then as pointed out by superadnim you would need to monitor memory blocks which will really add lots of intelligence to the bot but at the same time get way, way complicated.
Good luck on your project... feel free to PM me for specific questions.
Slyvnr
			
			
													The needs of a bot vs. the programming of a bot are two different discussions. The concept of programming a bot brings about lots of fun discussions about various methods to obtain optimal performance. Unfortunately, this groups decision is to ridicule instead of investigate.
I on the other hand would rather investigate in order to improve not only the requestor's knowledge but also potentially my own knowledge. So with that said. You are basically wanting a move the mouse type some text bot.
I will assume this is for the windows platform, therefore I will be using some code that I wrote last year which contains Windows API calls. Everything I am contributing I found in the forums in some shape or form and was able to bring together. So hopefully this will consolidate some of the information for you.
Set up some procedures using SetCursorPos_(x,y) along with the mouse_event_() API calls:
Code: Select all
Procedure Click_L_Mouse()
     ;Simulate mouse click
     mouse_event_(#MOUSEEVENTF_LEFTDOWN,0,0,0,0):Delay(7)  ;mouse left button down
     mouse_event_(#MOUSEEVENTF_LEFTUP,0,0,0,0):Delay(7)  ;mouse left button back up
EndProcedure
Procedure Click_R_Mouse()
    mouse_event_(#MOUSEEVENTF_RIGHTDOWN,0,0,0,0):delay(7)  ; Mouse right button down
    mouse_event_(#MOUSEEVENTF_RIGHTUP,0,0,0,0):delay(7)  ; Mouse right button up
EndProcedure
Procedure MoveMouse(x,y)
     SetCursorPos_(x,y)
EndProcedure
The MouseButton() commands in PB allow you to see if they have been pressed but does not allow you to "virtually" press them thus I use the Windows API mouse_event_() to simulate a mouse click.
For sending key strokes I would use the SendKeys() procedure by PB located here http://www.purebasic.fr/english/viewtopic.php?t=3766
Now the question is where do you move the mouse to and what to do. A quick an easy program to place a sticky window in the bottom right corner of the desktop to display mouse X and Y positions would be nice.
Something like this should do the job
Code: Select all
;-----------------------------------------------------
;
;    MouseLoc.pb
;    Date: June 10 2009
;    Author: Kevin Perryman
;    Version 1.1
;
;    V 1.1 06/10/2009
;    Added lines to make window sticky to stay on top
;
;    V 1.0 06/09/2009
;    simply tell us where the mouse cursor is on the
;    desktop
;-----------------------------------------------------
;Declare structures
Structure tagPOINT
  x.l
  y.l
EndStructure 
Global POINT.tagPOINT
;--------------------
;Main program
;--------------------
; Get the resolution of the desktop
ExamineDesktops()
DT_Width=DesktopWidth(0)
DT_Height=DesktopHeight(0)
; Figure out where to place window to display mouse coordinates
Win_Width=90
Win_Height=20
Pos_x=DT_Width-Win_Width-22
Pos_y=DT_Height-Win_Height-52
; create window in which we will display the mouse coordinates
MyWindow=OpenWindow(0, Pos_x, Pos_y, Win_Width, Win_Height, "Mouse Loc", #PB_Window_SystemMenu )
If MyWindow
  txt_titlex=TextGadget(#PB_Any,5,5,10,20,"X:")
  txt_MouseX=TextGadget(#PB_Any,20,5,40,20,"0.00")
  txt_titley=TextGadget(#PB_Any,60,5,10,20,"Y:")
  txt_MouseY=TextGadget(#PB_Any,75,5,40,20,"0.00")
EndIf
;Keep window on top of all other windows
StickyWindow(MuWindow,1)
; setup a variable to check for program close
CLOSEME=0
Repeat
     ;keep window on top 
      
    ; check to see if window X has been pressed
    e=WindowEvent()
    If e=#PB_Event_CloseWindow
     CLOSEME=1  ; if window X has been pressed set variable to end loop
    EndIf
    
    ; Get Cursor Position
    GetCursorPos_(@POINT)
    MouseX$=Str(POINT\x)
    MouseY$=Str(POINT\y)
    
    ;Update Cursor Position in Output window
    SetGadgetText(txt_MouseX,MouseX$)
    SetGadgetText(txt_MouseY,MouseY$)
    
;   ;smoother update of mouse coordinates and also release CPU to other processes
    ;basically helps prevents system resource hogging
    Sleep_(70)  
            
Until CLOSEME  ; if CLOSEME then lets exit and end the program
End
You now codify your bot by writing program code that moves the mouse, clicks as appropriate and types keyboard input as needed. Being sure to place delays and pauses for correct timing.
Should be relatively easy as all you have to do is call the appropriate procedure from above and as needed.
For example you might have something like this (from my autologin program):
Code: Select all
MoveMouse(545,708)
Click_L_Mouse()
Click_L_Mouse() (call twice to simulate double click)
Delay(50)
For i = 1 To 20
          PressKeys(hWnd,backspace$) (clear out the field)
Next i
PressKeys(hWnd,username$) (type in a username)
; relocate mouse cursor to password box
MoveMouse(542,731) 
Click_L_Mouse()  ; single click to place cursor in password box
For i = 1 To 20 
      PressKeys(hWnd,backspace$) ; clear password box
Next i
PressKeys(hWnd,password$) ; enter password
; Move mouse to login button
MoveMouse(513,752) 
Click_L_Mouse()
Delay(5000)  ; wait for program/website to load
Good luck on your project... feel free to PM me for specific questions.
Slyvnr
					Last edited by Slyvnr on Mon May 10, 2010 7:21 pm, edited 1 time in total.
									
			
									
						- Fluid Byte
 - Addict

 - Posts: 2336
 - Joined: Fri Jul 21, 2006 4:41 am
 - Location: Berlin, Germany
 
Re: Trying to create a Bot for a game
Any particular reason why you are raping this thread?
			
			
									
									Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
						
