Jump to content

Movement algorithm


Recommended Posts

I am working on a bot for Eudemons. I finally got the memory reading to read the x,y position in game. I also have the center x,y.

I'm having trouble trying to come up with a loop that will take me to a destination x,y (handle to reach), from the current position (handle being read).

For instance. I'm at 400,410 , I need to get to 500, 600. I haven't found a successfull way to get from A to B. Every loop the coordinates are being checked, and once both coordinates match, to stop moving.

Could anyone help me come up with some ideas? I'll write the code, I just need some suggestions on how I can try and pinpoint this.

Thanks

Link to comment
Share on other sites

Hi,

You need to give us more information about what is actually happening. For example do you give the function the values you want to move the mouse to? Or do you always just want to move from 400,410? Can you be a bit more specific :)

Dave

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------"I don't need to know everything, I just need to know where to find it when I need it"....EinsteinAnd in our case... That's the AutoIT helpfile ;) Please read before posting!!!

Link to comment
Share on other sites

Alright, I'll try and be more descriptive of my goal.

What I'm trying to do:

As a first bot project, I want to make a Log bot. There are 2 static areas which I need to get to. In a loop, I have the CURRENT characters coordinates being read. I'll have the Static Coordinates predefined inside the program. I want to have the current coordinates being checked against the predefined.

If the current coordinates arent equal to the predefined, to move towards it until it reaches the predefined coordinates. I'm having trouble making the character move (mouse clicks) towards the predefined coordinates. It's either up,down,left, right, top right, topl leftk, bottom right, bottom left.

According to the current coordinates move in either one of those locations to reach the predefined.

here is what I have so far:

#include <mem.au3>
#include <GuiConstants.au3>
#include <misc.au3>

HotKeySet("'","_exit")
$Process = 'soul.exe' ;-> Target process
$PID = ProcessExists($Process) ;-> Get Process ID
$Address = 0x0070A79C            ;$v_read is the current characters X coordinate
$Address2 = 0x00709330           ;$v_read2 is the current characters Y coordinate
;$Value = 12 ;-> Value to write
    
GuiCreate("LogBot", 111, 73,0,254 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))


GuiSetState()

$Label_1 = GuiCtrlCreateLabel("0,0", 10, 10, 90, 20)
$Button_2 = GuiCtrlCreateButton("Button2", 0, 40, 110, 30)
WinActivate("[Eudemons Online] Beta Test","")
sleep(500)
WinMove("[Eudemons Online] Beta Test","",167,87)

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button_2
    
            While 1
            
            sleep(10)
            $OpenProcess = _MemOpen(0x38, False, $PID) ;-> Enable reading/writing to the process and get the handle

            $v_Read = _MemRead($OpenProcess, $Address, 4) ;-> Read a 1 byte value from the defined address
            $v_Read2 = _MemRead($OpenProcess, $Address2, 4) ;-> Read a 1 byte value from the defined address
            GUICtrlSetData($Label_1,$v_Read &","& $v_Read2)

            ; $v_Read = _MemWrite($OpenProcess, $Address, $Value, 1);-> Write a new 1 byte value to the defined address
            ;MsgBox(0,"Info", "Writing the value "&$Value&" to address "&HEX($Address, 8))
            
            ; $v_Read = _MemRead($OpenProcess, $Address, 1) ;-> Read the new value from the defined address
            ;MsgBox(0,"Info", "The value of address "&HE ($Address, 8)&" is now: "&$v_Read)

        _MemClose($OpenProcess) ;-> Disable reading/writing to the process
        
        _Bot($v_Read,$v_Read2)
        
        WEnd
    EndSelect
WEnd
Exit

Func _Bot($v_Read,$v_Read2)

;$v_read is the current characters X coordinate




_MouseTrap(167,87,1188,853)         ;Traps the mouse to the Client Window Size

$Pre_X_Coor = 400                   ;Pre-Defined X coordinate for NPC
$Pre_Y_Coor = 500                   ;Pre-Defined Y coordinate for NPC




;Left




;Right



;Down



;Up


EndFunc



Func _Exit()
    _MouseTrap()
    Exit
EndFunc
Edited by acidfear
Link to comment
Share on other sites

I would consider looking at Law of Cosines. From there you can get a general idea on how to rotate your character with the help of _Mousemoveplus.

Keep mouse moving yourself until the angle is approximately 0 (this means your facing target), then just make character move forward until the distance between you and the destination is approximately 0. This assumes that nothing is blocking your path, else you'd have to add more logic.

Edited by Toady

www.itoady.com

A* (A-star) Searching Algorithm - A.I. Artificial Intelligence bot path finding

Link to comment
Share on other sites

Ok, thanks for the links. I looked and read through some of the law of Cosines, but it still seems foggy in my mind. I can conceive a basic concept, but when I try to put it in code it doesn't seem to work right. For ex. I'd have it check X first and have it move until X is the same, and then do the Y. But it doesn't seem to work :/.

I'll try experimenting a bit more and see if I can get something close.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...