Sign in to follow this  
Followers 0
Overlord

moving my character

9 posts in this topic

why won't this work?

;##################################
; Variables
;##################################

Global $currentlocation = 0
$currentx = StringLeft($currentlocation,4) ; current ppos for x
$ybeta = stringtrimleft($currentlocation,5) 
$currenty = stringtrimright($ybeta,2) ; current ppos for y
Global $wpx = 3324 ; start location x (center of screen)
Global $wpy = 2853 ; start location y (center of screen)
Global $moveX= 568
Global $movey= 384

;##################################
; Script
;##################################
;##################################
;move to wp1 (3252,2854)
;##################################
$wpx = $wpx1
$wpy = $wpy1
moving()

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;>>>>>>>>>>FUNCTIONS>>>>>>>>>>>>>>>
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Func calculate_way()
    If $currentx > $wpx Then
                $moveX = 462
            else
                $moveX = 562
    If $currenty > $wpy Then 
                $moveY = 334
            else
                $moveY = 434
    EndIf
    EndIf
     EndFunc

Func Read_SACRED_memory()
            $currentlocation = _ReadString($Sacred, 0x00BD21D2, 700)
      Sleep(10)
     EndFunc

Func moving()
Do 
    Read_SACRED_memory()
    calculate_way()
    MouseClick("left",$moveX,$moveY) ; as described in comments in moving.au3
    sleep($clickingdelay) ; delay for in-game clicking
Until $currentx = $wpx1 and $currenty = $wpy1
EndFunc

this is what my code kinda looks like and he calculates his way, but only once.

he doesn't recalculate his way again when he clicks again. He just keeps on walking and walking and clicking on the same spot.

Share this post


Link to post
Share on other sites



*bump*

anybody please?

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

have no idea what you want to with this script but are you sure about this portion ?

The second IF is only done when the first If is true .

I think your way of Indenting is confusing :P

Func calculate_way()
    If $currentx > $wpx Then
        $moveX = 462
    Else
        $moveX = 562
        If $currenty > $wpy Then
            $moveY = 334
        Else
            $moveY = 434
        EndIf
    EndIf
EndFunc   ;==>calculate_way
Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

what it needs to do is move my char to a desired location in the game.

Since I can view what my location is ($currentlocation), I can let it move to that location.

so, what you are saying could be the reason that he doesn't recalculate?

what if I drop them both in seperate functions?

Share this post


Link to post
Share on other sites

k,

I'm starting to go slightly mad here...

code still aint working. if you have a clue...please tell me.

what I want it to do:

walk to a desired location on screen where I know the X and Y coords for

recalculate if he went beyond the location.

What it does:

calculates his position and start walking in the right direction

what it doesn't do:

recalculate his path and move in the needed direction

$currentx = StringLeft($currentlocation, 4) ; current ppos for x
$ybeta = StringTrimLeft($currentlocation, 5)
$currenty = StringTrimRight($ybeta, 2) ; current ppos for y
$wpx1 = 3252
$wpy1 = 2854
$wpx2 = 3256
$wpy2 = 2864
;##################################
;main script
;##################################
$wpx = $wpx1
$wpy = $wpy1
moving()

;##################################
;main functions
;##################################
Func Read_SACRED_memory()
            $currentlocation = _ReadString($Sacred, 0x00BD21D2, 700)
;             ToolTip("Location: " & $currentlocation, 0, 0); Displays the currentlocation
      Sleep(10)
     EndFunc

Func calculate_way2()
    If $currentx > $wpx Then $moveX = 482   ;LEFT
    If $currentx < $wpx Then $moveX = 542   ;RIGHT
    If $currentx = $wpx Then $moveX = 512   ;MIDDLE OF X
    If $currenty > $wpy Then $moveY = 354   ;UP
    If $currenty < $wpy Then $moveY = 414   ;DOWN
    If $currenty = $wpy Then $moveY = 384   ;MIDDLE OF Y
    EndFunc   ;==>calculate_way2

Func moving()
    Do 
        Read_SACRED_memory()
        calculate_way2()
        ToolTip("moveX: " & $moveX & " moveY: " & $moveY,0,0)
;       If $currentx-$wpx Or $currenty-$wpy <=15 Then Send("{SHIFTDOWN}") ; difference between running/walking - for better accuracy
        MouseClick("left",$moveX,$moveY) ; as described in comments in moving.au3
;       Send("{SHIFTUP}")
        sleep($clickingdelay) ; delay for in-game clicking
        Until $currentx = $wpx1 and $currenty = $wpy1
    EndFunc   ;==>moving

Share this post


Link to post
Share on other sites

can somebody atleast verify that my functions are correct?

I have no idea where the error is or why he doesn't recalculate!

syntaxcheckbeta and syntaxcheckprod don't give me any errors.

and function Do...Until is especially used to run until the expression is true.

it can't be true that I need to split them up for x and y?

Share this post


Link to post
Share on other sites

can somebody atleast verify that my functions are correct?

I have no idea where the error is or why he doesn't recalculate!

syntaxcheckbeta and syntaxcheckprod don't give me any errors.

and function Do...Until is especially used to run until the expression is true.

it can't be true that I need to split them up for x and y?

I've looked at this thread MANY times, and it's hard to tell you anything with a script that "can't" be tested by myself. You're using memory reading and trying to act on those findings, but we don't know what the returns are... why not try removing the memory information, and put in absolute values for testing?

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

I've attached the scripts that I use for this bot and I think the problem could be elsewhere.

If you take a look, you will see.

I think there's a mix-up with the globals...

botscript.zip

Share this post


Link to post
Share on other sites

anybody got any ideas so far?

Share this post


Link to post
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
Sign in to follow this  
Followers 0