[Autoit] Howto move your pawn ;)

12/21/2006 21:16 Christoph_#1
Ok at first you need these 3 files which carry support functions, except for mem.au3 all come with autoit shipped. Mem.au3 can be gathered from the autoitscript community (you might look there for other code as well).

Feel free to play around with the code, it's not really nice because I never had the time to polish/finish it (and I fear I won't in the next months b/c I have many tests to pass).

Code:
#include <String.au3>
#include <Mem.au3>
#include <Array.au3>
And A Support function that converts the hex data from memory to decimal offsets.

Code:
Func _HexadecimalToDecimal($var)
  $result = 0
  $sum = 0
  $power=0
  
  Do
    $currentDigit = StringRight(_MemRev($var),$power+1)
    $currentDigit = StringLeft($currentDigit,1)
    If $currentDigit = "A" Then
      $currentDigit = 10
    ElseIf $currentDigit = "B" Then
      $currentDigit = 11
    ElseIf $currentDigit = "C" Then
      $currentDigit = 12
    ElseIf $currentDigit = "D" Then
      $currentDigit = 13
    ElseIf $currentDigit = "E" Then
      $currentDigit = 14
    ElseIf $currentDigit = "F" Then
      $currentDigit = 15
    EndIf
    $result=$currentDigit*16^$power
    $power = $power + 1
    $sum = $sum + $result
  Until $currentDigit = "x"
  
  Return $sum
EndFunc;==>_HexadecimalToDecimal by joshdb
Now you can start reading the memory and read your x/y coordinates from it, those used are old ones, check the sticky for the actual ones. I have marked the offsets (that's the only thing you need to change witch new patches).

Quote:

$Process = "Conquer.exe"
$Pid = ProcessExists($Process)
$h_open = _MemOpen($pid)
$ReadX = _MemRead($h_open,0x4FE53C,4)
$XCoord = _HexadecimalToDecimal($ReadX)
$ReadY = _MemRead($h_open,0x4FE540,4)
$YCoord = _HexadecimalToDecimal($ReadY)
_MemClose($h_open)
$MyCx=$XCoord
$MyCy=$YCoord
At first you need to setup your waypoints (in my case it where 4). $WP is the starting waypoint "counter".

Code:
;~ Waypoints
$WP=0
$WP1x=471
$WP1y=753

$WP2x=515
$WP2y=688

$WP3x=612
$WP3y=763

$WP4x=520
$WP4y=746
The final function. I made this one very simple: the screen is cut into quarters and juding from your position and the next waypoint the bot just clicks the screen to move, it's simple and works, if you want it more efficient you could move into 8 directions instead of 4, however that will be harder to understand.

Currently the bot moves to Waypoint 1,2,3,4 and then back to 1. The MyCx,-20 part means he considers a waypoint as reached if he is only +-20 coordinates away from it, depending on your needs you can use 5 or less as well.

Best part is to put that into a variable you declare in the function cos now you have to change all of them << my bad.

You MUST read the x/y offsets before you start moving. Best is to put the mem reading part into the code like below.

The function is not really nice because I coded a logic for each waypoint instead of using variables. But if you just need a level bot that kills one spawn over and over it will do it's job.

But I won't be able to make anything nice in the next months so it might be helpfull for someone else.

Quote:

func gotoWP ()

Quote:

&#036;Process = "Conquer.exe"
&#036;Pid = ProcessExists(&#036;Process)
&#036;h_open = _MemOpen(&#036;pid)
&#036;ReadX = _MemRead(&#036;h_open,0x4FE53C,4)
&#036;XCoord = _HexadecimalToDecimal(&#036;ReadX)
&#036;ReadY = _MemRead(&#036;h_open,0x4FE540,4)
&#036;YCoord = _HexadecimalToDecimal(&#036;ReadY)
_MemClose(&#036;h_open)
&#036;MyCx=&#036;XCoord
&#036;MyCy=&#036;YCoord
IF &#036;MyCx >= &#036;WP1x AND &#036;MyCx-20< &#036;WP1x AND &#036;MyCy >= &#036;WP1y AND &#036;MyCy-20 < &#036;WP1y Then
&#036;WP=1
Endif
IF &#036;MyCx >= &#036;WP2x AND &#036;MyCx-20< &#036;WP2x AND &#036;MyCy >= &#036;WP2y AND &#036;MyCy-20 < &#036;WP2y Then
&#036;WP=2
Endif
IF &#036;MyCx >= &#036;WP3x AND &#036;MyCx-20< &#036;WP3x AND &#036;MyCy >= &#036;WP3y AND &#036;MyCy-20 < &#036;WP3y Then
&#036;WP=3
Endif
IF &#036;MyCx >= &#036;WP4x AND &#036;MyCx-20< &#036;WP4x AND &#036;MyCy >= &#036;WP4y AND &#036;MyCy-20 < &#036;WP4y Then
&#036;WP=0
Endif
Select
Case &#036;WP=0
IF &#036;MyCx >= &#036;WP1x AND &#036;MyCy >= &#036;WP1y Then
Move1()
Endif
IF &#036;MyCx <= &#036;WP1x AND &#036;MyCy <= &#036;WP1y Then
Move4()
Endif
IF &#036;MyCx <= &#036;WP1x AND &#036;MyCy >= &#036;WP1y Then
Move2()
Endif
IF &#036;MyCx >= &#036;WP1x AND &#036;MyCy <= &#036;WP1y Then
Move3()
Endif
Case &#036;WP=1
IF &#036;MyCx >= &#036;WP2x AND &#036;MyCy >= &#036;WP2y Then
Move1()
Endif
IF &#036;MyCx <= &#036;WP2x AND &#036;MyCy <= &#036;WP2y Then
Move4()
Endif
IF &#036;MyCx <= &#036;WP2x AND &#036;MyCy >= &#036;WP2y Then
Move2()
Endif
IF &#036;MyCx >= &#036;WP2x AND &#036;MyCy <= &#036;WP2y Then
Move3()
Endif
Case &#036;WP=2
IF &#036;MyCx >= &#036;WP3x AND &#036;MyCy >= &#036;WP3y Then
Move1()
Endif
IF &#036;MyCx <= &#036;WP3x AND &#036;MyCy <= &#036;WP3y Then
Move4()
Endif
IF &#036;MyCx <= &#036;WP3x AND &#036;MyCy >= &#036;WP3y Then
Move2()
Endif
IF &#036;MyCx >= &#036;WP3x AND &#036;MyCy <= &#036;WP3y Then
Move3()
Endif
Case &#036;WP=3
IF &#036;MyCx >= &#036;WP4x AND &#036;MyCy >= &#036;WP4y Then
Move1()
Endif
IF &#036;MyCx <= &#036;WP4x AND &#036;MyCy <= &#036;WP4y Then
Move4()
Endif
IF &#036;MyCx <= &#036;WP4x AND &#036;MyCy >= &#036;WP4y Then
Move2()
Endif
IF &#036;MyCx >= &#036;WP4x AND &#036;MyCy <= &#036;WP4y Then
Move3()
Endif
EndSelect
EndFunc
And finally the move functions that actually make the bot move. Remove the " Send("{CTRLDOWN}"" if you want to walk/run instead of jumping.

Code:
func Move1 &#40;&#41;
  &#036;xrand1=Random&#40;341,682,1&#41;
	&#036;yrand1=Random&#40;20,256,1&#41;
  MouseMove&#40;&#036;xrand1,&#036;yrand1,0&#41;
	Send&#40;&#34;{CTRLDOWN}&#34;&#41;
  MouseClick&#40;&#34;Left&#34;&#41;
  Send&#40;&#34;{CTRLUP}&#34;&#41;
  Sleep&#40;300&#41;
EndFunc

func Move4 &#40;&#41;
  &#036;xrand2=Random&#40;314,682,1&#41;
  &#036;yrand2=Random&#40;512,640,1&#41;
  MouseMove&#40;&#036;xrand2,&#036;yrand2,0&#41;
  Send&#40;&#34;{CTRLDOWN}&#34;&#41;
  MouseClick&#40;&#34;Left&#34;&#41;
  Send&#40;&#34;{CTRLUP}&#34;&#41;
  Sleep&#40;300&#41;
EndFunc

func Move2 &#40;&#41;
  &#036;xrand3=Random&#40;512,1000,1&#41;
  &#036;yrand3=Random&#40;256,512&#41;
  MouseMove&#40;&#036;xrand3,&#036;yrand3,0&#41;
   Send&#40;&#34;{CTRLDOWN}&#34;&#41;
  MouseClick&#40;&#34;Left&#34;&#41;
  Send&#40;&#34;{CTRLUP}&#34;&#41;
  Sleep&#40;300&#41;
EndFunc

func Move3 &#40;&#41;n
  &#036;xrand4=Random&#40;20,314&#41;
  &#036;yrand4=Random&#40;384,640&#41;
  MouseMove&#40;&#036;xrand4,&#036;yrand4,0&#41;
   Send&#40;&#34;{CTRLDOWN}&#34;&#41;
  MouseClick&#40;&#34;Left&#34;&#41;
  Send&#40;&#34;{CTRLUP}&#34;&#41;
  Sleep&#40;300&#41;
EndFunc
12/21/2006 21:27 pjay#2
what the hell is this -_-
12/21/2006 21:41 Christoph_#3
Autoit Sourcecode...
12/21/2006 23:14 yokoyoko#4
i don't get it, is it moving to coords or just 4 set points? too bad i'm working with autohotkey
12/22/2006 01:20 Christoph_#5
It moves to the coordinates you give him.

Btw: The Syntax of Autohotkey / Autoit is pretty much the same.
12/22/2006 02:31 pjay#6
this is... fun to use.. how do u use it?
12/22/2006 12:13 Christoph_#7
Basicly you need to paste most of the stuff into your script, put the correct offsets for x/y into it, setup your own waypoints and call gotoWP (), that's it.

I did make a autohunter for me long ago before I used partner. Usually you do:

1) Scan for Monsters, if none
2) Scan for Items, if none
3) Move,
4) Repeat.
12/22/2006 12:34 crazyred#8
Great post, Chris.

Well, I'm also on AutoIt for quite some time, making bots for MapleSEA well.

They patched AutoIt macros and I started to use AHK.

Wow, and can I ask for your old AutoHunter source code? I thought of making a AutoHunter/Lab Lvler that is way simpler to use than MacroExpress though. Might help me lots with your old source code.
12/22/2006 12:36 Master_Mati#9
if its moves to coords u give..then its nothink more then another way to get to bot jail. As far as i remember ..bjx used simmilar method of walking... walking always on same coords..
12/22/2006 12:54 retlic#10
Can someone please put this into an au.3 program for me to edit and set my own co-ordinates coz i dont get how to put it together. [img]text2schild.php?smilienummer=1&text=Im AutoIt noob ' border='0' alt='Im AutoIt noob ' />
12/22/2006 14:23 DarkMaster000#11
lol i dont think i know exactly what it does..... but does it pretty much let u teleport to set coor?
12/22/2006 14:53 pjay#12
where do you put these codes? macro express?
12/22/2006 16:02 crazyred#13
These are AutoIt source.

AutoIt scripts ends with .au3 extensions.

Google AutoIt, People.

Learn to do things yourself.
12/22/2006 16:42 pjay#14
Quote:
Originally posted by crazyred@Dec 22 2006, 16:02
These are AutoIt source.

AutoIt scripts ends with .au3 extensions.

Google AutoIt, People.

Learn to do things yourself.
why you gota be mean for... i just asked a simple question :|
12/22/2006 16:53 crazyred#15
It's not meant to be targetted at anyone particularly.

Just funny to see how people ask without googling about AutoIt first.