Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 00:00

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[HELP] AutoIT BOT need assistance

Discussion on [HELP] AutoIT BOT need assistance within the AutoIt forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Jun 2010
Posts: 71
Received Thanks: 17
Question [HELP] AutoIT BOT need assistance

Hello everybody,

First of all I need to say I am new to AutoIT language. I know Java and C++, but read all over the net that these are not ideal for mmorpg botting, and to top it all, also read that AutoIT has some cool features which makes life easier.

So long story short, I need your assistance for this very basic bot program, which just stands still, selects mobs, attack and then check Hp/Mp then loot and so on. The game is Rode Online btw, I'll post the screenshots for the pixels to make myself clear.



These are my Functions, all in one class.

Quote:
Func checkHpMp();1
If isHpLow() Then
useSkill( 1) ;use hp potion
EndIf

If isMpLow() Then
useSkill( 2) ;use mana potion
EndIf
EndFunc

Func isMobDead();2
If Hex(PixelGetColor( 898, 74), 6) == "3B815A" Then
Return False
Else
Return True
EndIf
EndFunc

Func isMobSelected();3
If Hex(PixelGetColor( 898, 74), 6) == "3B815A" Then
Return True
Else
Return False
EndIf
EndFunc

Func isHpLow();4
If Hex(PixelGetColor( 863, 1011), 6) <> "151E34" Then
Return True
Else
Return False
EndIf
EndFunc

Func isMpLow();5
If Hex(PixelGetColor( 1053, 1011), 6) <> "125386" Then
Return True
Else
Return False
EndIf
EndFunc

Func isHpMid();6
If Hex(PixelGetColor( 869, 982), 6) <> "BD526C" Then
Return True
Else
Return False
EndIf
EndFunc

Func targetMob();7
Send("{TAB}")
Sleep(200)
EndFunc

Func useSkill( $skillNo);8
Send($skillNo)
Sleep(200)
EndFunc
1. For the checkHpMp function, can I use other functions that are declared by me in a function declared by me? checkHpMp includes isHpLow and isMpLow, thats why Im asking.

2 & 3. Well isMobDead and isMobSelected are in fact the same functions. I check the same pixel to decide true or false. And since I call isMobSelected earlier than the other one, I think it will work.

This is the location I look at:


4, 5 & 6. isHpLow, isHpMid and isMpLow looks at the Hp and Mana bars ofc I selected the pixels to correspond to portions of Hp and Mp according to my resolution

7. targetMob uses the TAB button on the keyboard to select the nearest mob.

8. useSkill takes in some parameter and then sends the game that button.

This is the Main class I wrote. exit and pause options are not yet implemented I know, this is kinda an outline. But it doesnt work for some reason :/

Quote:
#include <Color.au3>
#include "myFunctions.au3"

$exit = False
$paused = False
;Global $resting = false
$skillNumber = 3 ; Since hp and mp potions are 1 & 2

Sleep(4000)

While NOT $exit
If Not $paused Then
Sleep (100)
If isHpMid() Then
Send("{Z}") ; This is the rest button in the game
Sleep(20000)
EndIf

targetMob()

While isMobSelected()
checkHpMp() ; checks hp/mp before combat and uses pots if needed
useSkill( $skillNumber) ; spams 3-4-5-6-7, the mob would be dead by then
Sleep(500)

$skillNumber = $skillNumber + 1

If isMobDead() Then ; checks if the mob is dead
checkHpMp() ; looks again for hp and mp
Sleep(4000)
$skillNumber = 3 ; resets the skillnumber so that it will start from 3 again
Send("{V}"); for looting
EndIf
WEnd
EndIf
WEnd
Well, my indentation is spoiled by e-pvp, I am sorry for that, please try to follow

Now the real question:

Bot selects mobs but does not attack them. Is there something wrong with the skill usage ? And any other suggestions critics are appreciated. I know the code is really noobish and sucks but this was my second attempt in AutoIT.

Thank you!

Update: I edited the bot, and now it seems the checkHpMp thing does not work. When I comment the lines involve it the bot works fine. But I need to check my Hp ofc. Please Help!
yttuncel is offline  
Old 03/27/2012, 16:55   #2
 
elite*gold: 0
Join Date: Feb 2010
Posts: 92
Received Thanks: 11
Maybe the follwoing Fragments will help you with your project.
You only have to customize it detailed.

Code:
HotKeySet("^q", "leave")
HotKeySet("{PAUSE}", "Pause") ;HotKeySet Programm Pause

$size = WinGetPos("Game")
$HP=0
$MP=0
While 1
	
	Mobcheck()
	HPMPCheck()
	Attack()
	
WEnd

Func HPMPCheck() ;checking both
	
	$XOffset=789
	
	for $z = 1 to 2
		
		switch $z
		case 1 
			$Pixelcolor = HPColor
			$YOffset = 123
		case 2
			$Pixelcolor = MPColor
			$YOffset = 456
		EndSwitch
	
		for $i = 0 to 100 Step 10 ;replace 100 with length of HP Bar and Step 10 with desired detailment
			$color = pixelgetcolor($size[0]$XOffset+$i,$size[1]+$YOffset)
			if $color <> $Pixelcolor then
				switch $z
				case 1 
					$HP= $i
				case 2
					$MP= $i
				EndSwitch
                                $i = 10000
			EndIf
		Next
	Next
	
	
EndFunc


Func leave() 
	
exit

EndFunc

Func Pause()

ToolTip("Pause- continue with END-Bar",1,10)
While 1
    Sleep ( 300 )
    If _IsPressed("23", $dll) Then; End Taste
	WinActivate("Game")
	WinWaitActive ("Game")
	ExitLoop
	EndIf
WEnd
	
EndFunc

Probably next time you dont want to use Pixelsearch, so you will use Memory.
Here is a (untranslated) Fragment from my own Bot (other RPG) you can use after you've concerned with Memoryread yourself:

Code:
Func HPMPKontrolle()
	

$read1 = _MemoryRead($RAMAktHP, $info);aktuelle HP
$read2 = _MemoryRead($RAMGesHP, $info);gesamt HP

$read3 = _MemoryRead($RAMAktMP, $info);aktuelle MP
$read4 = _MemoryRead($RAMGesMP, $info);gesamt MP

if $read1<($read2*($HP1pottenbeiProzent/100)) Then
	if BereitHP1() = true then
		$SollLeiste=$LeisteHP1
		Leisteaussuchen()
		Send("{" & $TasteHP1 & " DOWN}" )
		sleep(80)
		Send("{" & $TasteHP1 & " UP}" )
		$HP1Timer = $Timer ; Sehr wichtig!
		$hp1gepottet=$hp1gepottet+1
	EndIf
EndIf

if $read1<($read2*($HP2pottenbeiProzent/100)) Then
	if BereitHP2() = true then
		$SollLeiste=$LeisteHP2
		Leisteaussuchen()
		Send("{" & $TasteHP2 & " DOWN}" )
		sleep(80)
		Send("{" & $TasteHP2 & " UP}" )
		$HP2Timer = $Timer ; Sehr wichtig!
		$hp2gepottet=$hp2gepottet+1
	EndIf
EndIf
		
if $read3<($read4*($MPpottenbeiProzent/100)) Then
	if BereitMP() = true then
		$SollLeiste=$LeisteMP
		Leisteaussuchen()
		Send("{" & $TasteMP & " DOWN}" )
		sleep(80)
		Send("{" & $TasteMP & " UP}" )
		$MPTimer = $Timer ; Sehr wichtig!
		$mpgepottet=$mpgepottet+1
	EndIf
EndIf

EndFunc
BotofWar is offline  
Old 03/27/2012, 17:50   #3
 
elite*gold: 50
Join Date: Mar 2010
Posts: 1,373
Received Thanks: 521
Quote:
Originally Posted by yttuncel View Post
These are my Functions, all in one class.
Where is the class?
jacky919 is offline  
Old 03/28/2012, 05:54   #4
 
elite*gold: 0
Join Date: Jun 2010
Posts: 71
Received Thanks: 17
Quote:
Originally Posted by jacky919 View Post
Where is the class?
What do you mean ?

@BotOfWar

Thanks man I'll definitely be checking your algorithm after I'm done with this thing.

I've updated the bot and now it is useable, and avoids death to some extent.

How can I prevent moving though? Sometimes when the nearby mobs are done, it targets a far mob and automoves when skill is pressed. I checked auto move to target in options menu of the game, but no results. Thanks!
yttuncel is offline  
Old 03/28/2012, 11:05   #5
 
elite*gold: 0
Join Date: Feb 2010
Posts: 92
Received Thanks: 11
At the game I was playing the following thing deactivated Skills:

Code:
Func Mobcheck()
	
..............

if $mob = 0 Then
	mouseclick("left",yourselfX,youselfY,5)
EndIf

...........


EndFunc
BotofWar is offline  
Old 03/28/2012, 15:29   #6
 
lolkop's Avatar
 
elite*gold: 280
Join Date: May 2007
Posts: 2,818
Received Thanks: 3,483
why don't you work with the memory of that game?
lolkop is offline  
Old 03/28/2012, 20:10   #7
 
elite*gold: 0
Join Date: Jun 2010
Posts: 71
Received Thanks: 17
@lolkop, because I'm brand new at bot coding and dll and memory stuff.
Can you guys give me some tutorial links that are reliable and effective ?

@Botofwar, but in my case it targets the mob, but mob is far away so that it moves towards the mob to get in range(I am a ranger class btw). So I have to at least turn to initial position back after killing that mob, or just cancel if it is out of range. I think I found a solution via pixel search, but I will be concerning with memory stuff as soon as possible
yttuncel is offline  
Old 03/28/2012, 20:17   #8
 
elite*gold: 50
Join Date: Mar 2010
Posts: 1,373
Received Thanks: 521
Quote:
Originally Posted by yttuncel View Post
What do you mean ?
>>
Quote:
Originally Posted by yttuncel
These are my Functions, all in one class.
jacky919 is offline  
Old 03/28/2012, 20:38   #9
 
lolkop's Avatar
 
elite*gold: 280
Join Date: May 2007
Posts: 2,818
Received Thanks: 3,483
Quote:
Originally Posted by yttuncel View Post
@lolkop, because I'm brand new at bot coding and dll and memory stuff.
Can you guys give me some tutorial links that are reliable and effective ?
well, reversing is kinda complex for beginners. i've just downloaded the game and checked it out, to be able to help you a little.

to start with memory stuff, you can use the winapis. here are some small codeexamples for usefull functions:
Code:
Func OpenProcess($pid)
	Local $mid = DllCall('kernel32.dll', 'int', 'OpenProcess', 'int', 0x1F0FFF, 'int', 1, 'int', $pid)
	Return $mid[0]
EndFunc

Func ReadProcessMemory($process_hwnd, $adress, $type = 'dword')
	Local $struct = DllStructCreate($type)
	DllCall('kernel32.dll', 'int', 'ReadProcessMemory', 'int', $process_hwnd, 'int', $adress, 'ptr', DllStructGetPtr($struct), 'int', DllStructGetSize($struct), 'int', '')
	Return DllStructGetData($struct, 1)
EndFunc

Func CloseHandle($hwnd)
	DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $hwnd)
EndFunc
a basic example for the current game-version:
Code:
$mid = OpenProcess(ProcessExists('rode.exe'))
While Sleep(100)
	$base = ReadProcessMemory($mid, 0x13D9D8C)
	$currentHp = ReadProcessMemory($mid, $base + 0xC34)
	ToolTip($currentHp)
WEnd
CloseHandle($mid)
the pointer of the character-struct for the current client is located at 0x13D9D8C.

exploring the struct will show you the most important values for the beginning. as you can see, i've added the currentHp offset to the example too.
lolkop is offline  
Thanks
1 User
Old 03/28/2012, 23:19   #10
 
elite*gold: 0
Join Date: Jun 2010
Posts: 71
Received Thanks: 17
@lolkop, thank you very much, I'll be revising these as soon as I find some free time!
I'll be posting my further questions here
yttuncel is offline  
Old 04/05/2012, 20:30   #11
 
elite*gold: 0
Join Date: Jun 2010
Posts: 2
Received Thanks: 0
were you able to get the bot functional?
babooy is offline  
Old 05/08/2012, 19:53   #12
 
elite*gold: 0
Join Date: Aug 2011
Posts: 6
Received Thanks: 0
Quote:
Originally Posted by babooy View Post
were you able to get the bot functional?
Yeah, I am wondering this as well.
haxereth is offline  
Reply


Similar Threads Similar Threads
Latale - AutoIT - Requesting some assistance
02/22/2012 - General Gaming Discussion - 0 Replies
Alright, so I'm still a beginner with AutoIT but I'm attempting to make a simple grinding bot. I've made several scripts for different maps that can run for 8+ hours just grinding with little to no problems. These are only for the lower level maps though. Sadly, due to my limited knowledge of AutoIT, I've been unable to make anything more advanced than just 'keep doing these movements over and over'. Basic information for anybody willing to help: -There is a 'sit' skill which heals...
Looking for Assistance
06/27/2011 - Dekaron Private Server - 1 Replies
Looking for assistance in a couple of categories. I need a bit of help in the web developing field. I've been working on a server for a few weeks now, payed for a webhost and all, but i've been having a bit of trouble setting up a launcher, mostly because I'm not sure which one I should go for. If someone could hit me up on msn, and assist me with this, I'd be very appreciative. (No, I don't not expect anyone to do the work for me, all i'm asking is that you lead me in the right path, and...
Need assistance
04/22/2010 - Dekaron Private Server - 6 Replies
Ok my problem is that we packed our client into a data.pak but when ever we upload it for players to download they get to the extraction process of the client and it gives a corrupt file error. no matter which way i compress the file it comes out corrupt when u DL the file. ive tryed .rar,.exe,.zip.etc same result everytime can neone help me with this issue?
assistance plz?
03/19/2010 - Mabinogi - 1 Replies
hello, im a longtime mabi player and ive used mods before so i know a little about them, but i would like to know how to make my own, such as putting certain items in place of others in the npc shop(i had a mod where slices of meat were friend summons capsules, and would like to try and put other useful items in the npc shops)
Hello, Could I get a little assistance?
09/04/2006 - Conquer Online 2 - 7 Replies
Hello there :P, To start off - I am a level 112 Archer - Archer... I have the following equipment (By the way..before you say my equipment sucks, I got hacked and the hacker reborned me and stole my stuff..I couldn't get it back) : --Elite +4 Taoist Cap level 112 (Using CoToBo to repair it) --Elite +1 Necklace --Elite +2 Attack ring --Elite +2 1 socket bow (Yeah, It sucks I know.)



All times are GMT +1. The time now is 00:00.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.