Rogue - autoleveling

01/16/2005 18:48 Lowfyr#1
© yokkal from bh

First off, let me start by addressing the idiots who are going to be pissed about this. If you're against bots, don't use them. Now that that's out of the way...

Here's the code to a rogue leveling bot that I made (props to nathan546 for a little initial motivation). Sorry, it doesn't have a cool name like Acidic's bot. However, if you want to call it something, call it "YokkalBot"! Yeah I just made that up on the spot.

Anyway, here are the main functions the bot performs:
1) Makes sure you're all healed up (or mostly healed)
2) Runs around in a circle tabbing for monsties
3) Once it finds one, he stops and throws a knife then waits a few secs for the monstie to run to him
4) Uses SS/Evis. to kick the mob's ass until it is dead
5) Equips new throwing knives when you run out (so you can do more than 200 runs at a time)


So here's the code:

Code:
Dim $Botting=0 
Dim $Walking=0 

$Start=IniRead("config_rogue.ini","Whatevs","StartMe","0") 
$Stop=IniRead("config_rogue.ini","Whatevs","StopMe","0") 
$mx=IniRead("config_rogue.ini","Whatevs","MonsterPixelX","0") 
$my=IniRead("config_rogue.ini","Whatevs","MonsterPixelY","0") 
$mph=IniRead("config_rogue.ini","Whatevs","MonsterPixelHex","0") 
$num=IniRead("config_rogue.ini","Whatevs","NumThrowStacks","0") 
$mdx=IniRead("config_rogue.ini","Whatevs","MonsterDetectX","0") 
$mdy=IniRead("config_rogue.ini","Whatevs","MonsterDetectY","0") 
$mdh=IniRead("config_rogue.ini","Whatevs","MonsterDetectHex","0") 
$Heal=IniRead("config_rogue.ini","Heal","UseHeal","0") 
$hx=IniRead("config_rogue.ini","Heal","HealPixelX","0") 
$hy=IniRead("config_rogue.ini","Heal","HealPixelY","0") 
$hph=IniRead("config_rogue.ini","Heal","HealPixelHex","0") 
$Attack1=IniRead("config_rogue.ini","Attack","Attack1","0") 
$Attack2=IniRead("config_rogue.ini","Attack","Attack2","0") 
$AttackThrow=IniRead("config_rogue.ini","Attack","AttackThrow","0") 
$Sleep1=IniRead("config_rogue.ini","Attack","Sleep","0") 
$SleepAfterThrow=IniRead("config_rogue.ini","Attack","SleepAfterThrow","0") 

HotkeySet("{F8}","Debug") 
HotkeySet("{" & $Start & "}","StartBot") 
HotkeySet("{" & $Stop & "}","StopBot") 
HotkeySet("{F7}","Ex") 

;----------------------- *Main code *--------------------------------------- 
$n = 0 
While $n <= $num 

 *$i = 0 
 *While $i<200 
 * *If $Botting=1 Then 
 * * *While NOT hex(PixelGetColor($hx,$hy),6)=$hph 
 * Sleep(200) 
 * * *WEnd 
 * * *
 * * *Do 
 * If $Botting=1 Then 
 * Walk() 
 * Send("{TAB}") 
 * EndIf 
 * * *Until hex(PixelGetColor($mx,$my),6)=$mph 

 * * *If $Botting=1 Then 
 * Attack() 
 * * *EndIf 
 * *Else 
 * * *$i=0 
 * *EndIf 
 *$i=$i+1 
 *WEnd 

$n=$n+1 
Equip() 

WEnd 
;--------------------------------------------------------------------------- 


Func Walk() 
If NOT $walking Then 
send("{NUMLOCK toggle}") 
$walking=1 
EndIf 
MouseClickDrag("right",187,387,390,317,10) 
send("{UP}") 
$walking=0 
sleep(160+random(40)) 
EndFunc 


Func Attack() 
If $walking Then 
send("{UP}"); 
$walking=0 
EndIf 
If hex(PixelGetColor($mx,$my),6)=$mph THEN 
Send($AttackThrow) 
Sleep($SleepAfterThrow) 
While hex(PixelGetColor($mx,$my),6)=$mph 
 *Send($Attack1) 
 *Sleep($Sleep1) 
WEnd 
Sleep($Sleep1) 
Sleep($Sleep1) 
Sleep($Sleep1) 
Sleep($Sleep1) 
Send($Attack2) 
While hex(PixelGetColor($mdx,$mdy),6)=$mdh 
Sleep($Sleep1) 
Send($Attack1) 
WEnd 
EndIf 
EndFunc 

Func Equip() 
Send("b") 
Sleep(200) 
Send("c") 
Sleep(200) 
If $n=1 Then 
MouseClick("left", 683, 445) 
Sleep(200) 
MouseClick("left", 179, 423) 
EndIf 
If $n=2 Then 
MouseClick("left", 716, 445) 
Sleep(200) 
MouseClick("left", 179, 423) 
EndIf 
If $n=3 Then 
MouseClick("left", 748, 445) 
Sleep(200) 
MouseClick("left", 179, 423) 
EndIf 
If $n=4 Then 
MouseClick("left", 782, 445) 
Sleep(200) 
MouseClick("left", 179, 423) 
EndIf 
Sleep(200) 
Send("{ESC}") 
Sleep(200) 
EndFunc 


Func StartBot() 
$Botting=1 
EndFunc 

Func StopBot() 
$Botting=0 
If $walking Then 
send("{UP}") 
$walking=0 
EndIf 
EndFunc 

Func Ex() 
ProcessClose("bot_rogue.exe") 
EndFunc 

Func Debug() 
$pos = MouseGetPos() 
MsgBox(0, "Debug", "MonsterPixelHex: " & hex(PixelGetColor($mx,$my),6) & " HealPixelHex: " & 

hex(PixelGetColor($hx,$hy),6) & " * X: " & $pos[0] & " Y: " & $pos[1] & " Hex: " & 

hex(PixelGetColor($pos[0],$pos[1]),6)) 
EndFunc




And this is my config_rogue.ini :

Code:
[Whatevs] 
StartMe=F5 
StopMe=F6 
MonsterPixelX=229 
MonsterPixelY=69 
MonsterPixelHex=00AF00 
MonsterDetectX=205 
MonsterDetectY=69 
MonsterDetectHex=007800 
NumThrowStacks=1 

[Heal] 
UseHeal=1 
HealPixelX=138 
HealPixelY=69 
HealPixelHex=00CD00 

[Attack] 
Attack1="1" 
Attack2="2" 
Sleep1=200 
AttackThrow="7" 
SleepAfterThrow=2000
Now to the explanation. I blocked in the "main code" section, so all the other functions are called either by hotkeys or by that code. To start the bot, just load it up while in an area with monsters and press F5. F6 stops the bot. Oh and I put an emergency exit hotkey (F7) in case anything goes terrribly wrong and the bot starts eating babies or something similar.

Also, let me point out that the HEX of the pixels, and maybe even the pixels themselves (the numerical values) will probably be different for you. You will have the find these yourself, but it should be easy because I have put in a function that will display the hex of the coordinates you put in for MonsterPixelX/Y, MonsterDetectX/Y, and HealPixelX/Y. In addition, this function will display the current corrdinates of the mouse, as well as the hex for that position. The hotkey is F8 for this.

So now I'm going to explain that the variables in the config_rogue.ini are. StartMe and StopMe are obviously the start and stop bot hotkeys. MonsterPixelX, MonsterPixelY, and MonsterPixelHex are the coordinates of the life bar of a monster at around 25% health and the hex associated with that. This is used to detect WHEN to use Eviscerate. MonsterDetectX, MonsterDetectY, and MonsterDetectHex are the coordinates and hex of the monster at the very far left side of the life bar (basically 0 life). This is used to detect WHEN the monster is dead. UseHeal is obvious. HealPixelX, HealPixelY, and HealPixelHex are the coords and hex of YOUR life at whatever health you want to heal to before you go fight another monstie. Just compile the bot like it is, run it, and press F8 over these spots and change the .ini accordingly. Oh, and as for the attack variables.... Attack1 is my SS, Attack2 is my Eviscerate, Sleep is the wait in ms between the attacks, AttackThrow is obviously the number that the knife is set on, and SleepAfterThrow gives the monster time to run up to you once you piss it off. I forgot about one variable, NumThrowStacks. This is how many throw stacks you have IN YOUR BACKPACK. With the way I have it right now, you can have up to 4 extras, starting from the TOP LEFT and filling in the row. Of course, by looking at the code you will be able to see it'll be super-easy to change it if you want.

And here's a little rundown of the bot code: First, it sleeps while your health is lower than the health you set. It's for a rogue, and since my rogue doesn't use food I didn't add it. It would take a whole LINE of code to add a feeding function if you wanted (or a stealth, which would be smart and I was too lazy to do). If you use stealth while healing, make sure to unstealth right after the While loop ends. Ok, next the bot walks then presses TAB until a monstie is found. Once it finds the guy, the attack function is called (mine worked for me, but it should be easy to change should you need to). Also, after 200 mobs have been killed, the bot calls the equip function to equip a new stack of knives to pull with. It's easy to tell what the function does if you check it out.

Ok... I'm almost done. Let me point out, though, that I know if another mob starts attacking you and you kill the other one you're on, you'll just sit there until you die because the heal process will never finish. Also, I know this bot doesn't loot. I didn't feel like writing a looting function because I am just interested in leveling. If someone wants to throw a looting function in there that would be great, just stick it after Attack() or something. Somebody can also throw a little "vanish" feature in there if your life gets too low, that way you will most likely not die in the span of a few hours. One more potential bug: If a monster is ranged, it will not run up to you (DUH!) so you would just stand there wanking yourself. Someone can also add a detection for that and have the rogue walk up if needed.

Now, to the people who expected a .exe that they could just download here and run. Go to hell. I'm expecting this to be a project that we (by "we" I mean everyone) keeps improving on until the bot is nearly perfect. I just wanted to give it a kick in the right direction by releasing this code to start with. I plan on making a bot for every class, so be ready for that as well (though I am about to start school again and have a HELL of a schedule ahead of me).

So finally, if you have never used AutoIt don't be scared. Three days ago I had never looked at AutoIt code before. It's a very easy scripting language to learn. Go here for a download of it (this will also compile the .au3 file to a .exe so you can run it): [Only registered and activated users can see links. Click Here To Register...]



Well, that's all I have. Make sure to post your improved code since I left plenty of room for it and make any comments/suggestions. I'm sure even with a post this long that there was something I forgot to mention.

Peace!
01/17/2005 16:46 lagalot#2
can a mac use it?
01/17/2005 16:57 Lowfyr#3
nope, theres no autoit mac version
01/17/2005 19:56 oOblaaa#4
hm, sry aber kann die anleitung dieses teils da auch ma jemand in deutsch posten ? wegen ordner wo das rein muss, was ich im spiel machen muss....thx *liebfrag*
02/17/2005 01:55 franuzz#5
hi i was wondering what to do with the .ini file?? sorry im new to this. i have the script running in game, but when i press f8 it gives me an error and shutsdown the script
02/17/2005 09:36 Lowfyr#6
Quote:
Originally posted by oOblaaa@Jan 17 2005, 19:56
hm, sry aber kann die anleitung dieses teils da auch ma jemand in deutsch posten ? wegen ordner wo das rein muss, was ich im spiel machen muss....thx *liebfrag*
ordner? ist normal egal wo das liegt, solange die config datei im gleichen folder is

Quote:
hi i was wondering what to do with the .ini file?? sorry im new to this. i have the script running in game, but when i press f8 it gives me an error and shutsdown the script
all your configs are stored in the .ini
02/17/2005 21:28 franuzz#7
well i saved the file as config_rogue.ini and it has exactly what is supposed ot be in the .ini..... what do i do with the file now that i have it saved?
when im ingame, with the autoit script running, i press f5, which starts the sript but has the wrong x,y coordinates. I think im supposed to press f8 to get coordinates or somthing so i can set the mouse to click on w/e i need. does the .ini file stay where my .au3 file is? im confused!
help??
02/18/2005 00:07 modrit#8
hat den schon irgendwer zum laufen gebracht?

hab die gleich fehler meldung wenn ich auf f8 drücke
f5/'f6 passiert nix =)
02/18/2005 09:45 Lowfyr#9
read the long text under the code, it's well explained howto setup the bot

Quote:
does the .ini file stay where my .au3 file is?
yes
02/18/2005 12:03 Mizu#10
Wer fragen dazu hat, einfach mal im Query anschreiben.
Werds gleich auch mal durchtesten.
02/19/2005 01:25 modrit#11
und hast ihn getestet funktioniert er bei dir?
02/20/2005 09:50 Flame#12
mh ... würde gerne mal wissen , was ich mit dem CODE und mit der rogue.ini machen muss :)
danke für hilfe
Flame
03/06/2005 15:50 modrit#13
den mal wieder raus holen tut ^^

mein forceschock ist abgelaufen nun die frage.
hat wer nen laufenden kostenlosen bot?
vielleiCht auch ne pReisewerte vorAb version von forCeschocK??
09/14/2006 00:51 Hella123#14
i dont know were to put the code for this can someone plz help me



<font size=1> i am a noob
09/14/2006 10:11 imported__X_#15
Quote:
Originally posted by Hella123@Sep 14 2006, 00:51
i dont know were to put the code for this can someone plz help me



<font size=1> i am a noob
Look at the date of Lowfyrs post^^