Jump to content

Script that eats Cpu


Guest hewge
 Share

Recommended Posts

Guest hewge

Anyone know how i can make this script to not eat so much cpu ?

any ideas ?

and if someone wanna know its for tibia. :)

(sorry for my bad english)

pkat2.au3

Link to comment
Share on other sites

This should work, you only need one while wend loop to do what you want.

Having two loops in the format you were origionally using is a definate cpu gobbler.

I just edited this in notepad, becasue im in work, so I havnt tested it.

Dim $xuh = 1130, $yuh = 400
Dim $xplayer = 550, $yplayer = 435
Dim $Activation
Dim $Activation1
Dim $Activation2
Dim $aim
Dim $hitpointcoord
Dim $color_hitpoint
Dim $rune

HotkeySet ("{NUMPAD1}", "activate")
HotkeySet ("{NUMPAD2}", "activate1")
HotkeySet ("{NUMPAD3}", "activate2")
HotkeySet ("{NUMPAD5}", "use_uh")
HotkeySet ("{NUMPAD6}", "setminhp")
HotkeySet ("{NUMPAD4}", "Setrune")
HotkeySet ("{NUMPAD0}", "shoot")
HotkeySet ("{PGDN}", "use_uh")
HotkeySet ("{END}", "shoot")
HotkeySet ("{F5}", "Terminate")

MsgBox ( 32, "Configuration", "Move cursor to where the hitpoint indicator should be")
Sleep (5000)
$hitpointcoord = MouseGetPos ()
$color_hitpoint = PixelGetColor ($hitpointcoord[0], $hitpointcoord[1])
MsgBox ( 32, "Configuration", "Done")

Func setminhp ()
$hitpointcoord = MouseGetPos ()
$color_hitpoint = PixelGetColor ($hitpointcoord[0], $hitpointcoord[1])
EndFunc

While 1
    If $Activation = 0 Then
              Sleep (1000)
    else 
              If $Activation1 < 3 And PixelGetColor ($hitpointcoord[0], hitpointcoord[1]) <> $color_hitpoint Then
                         BlockInput (1)
                        $aim = MouseGetPos ()
                        MouseClick ("Right", $xuh, $yuh, 1, 0)
                        Sleep (10)
                        MouseClick ("Left", $xplayer, $yplayer, 1 ,0)
                        Sleep (10)
                        MouseMove ($aim[0], $aim[1], 0)
                        BlockInput (0)
              Else
              EndIf
    Endif
Wend

Func use_uh ()
    BlockInput (1)
    $aim = MouseGetPos ()    
    MouseClick ("Right", $xuh, $yuh, 1, 0)
    Sleep (10)
    MouseClick ("Left", $xplayer, $yplayer, 1 ,0)
    Sleep (10)
    MouseMove ($aim[0], $aim[1], 0)
    BlockInput (0)
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func Setrune ()
    $rune = MouseGetPos()
EndFunc

Func activate ()
    $Activation = $Activation + 1
    If $Activation > 1 Then
    $Activation = 0
    $Activation1 = 0
    $Activation2 = 0
    Else

    EndIf
EndFunc
    

Func shoot ()
    BlockInput (1)
    $aim = MouseGetPos ()
    Sleep (10)
    MouseMove ($rune[0], $rune[1], 0)
    MouseDown ("right")
    MouseUp ("right")
    Sleep (10)
    MouseMove ($aim[0], $aim[1], 0)
    Sleep (10)
    MouseDown ("left")
    MouseUp ("Left")
    BlockInput (0)
EndFunc


Func activate1 ()
    $Activation1 = $Activation1 + 1
    If $Activation1 > 3 Then $Activation1 = 0
EndFunc

Func activate2 ()
    $Activation2 = $Activation2 + 1
    If $Activation2 > 3 Then $Activation2 = 0
EndFunc
Edited by Nova
Link to comment
Share on other sites

Guest hewge

Thanks , testing it now :)

If statements Must have a Then keyword :/

Edited by hewge
Link to comment
Share on other sites

This should work, you only need one while wend loop to do what you want.

Having two loops in the format you were origionally using is a definate cpu gobbler.

I just edited this in notepad, becasue im in work, so I havnt tested it.

While $Activation = 0
    Sleep (1000)

While 1
    If $Activation = 0 Then
              Sleep (1000)
    else 
              If $Activation1 < 3 And PixelGetColor ($hitpointcoord[0], hitpointcoord[1]) <> $color_hitpoint Then
                         BlockInput (1)
                        $aim = MouseGetPos ()
                        MouseClick ("Right", $xuh, $yuh, 1, 0)
                        Sleep (10)
                        MouseClick ("Left", $xplayer, $yplayer, 1 ,0)
                        Sleep (10)
                        MouseMove ($aim[0], $aim[1], 0)
                        BlockInput (0)
              Else
              EndIf
    Endif
Wend

<{POST_SNAPBACK}>

Shouldn't you get rid of the While $Activation = 0 and the sleep after it. Just tryin to help.

-Aaron

Link to comment
Share on other sites

Of course, this is what happens when you try help somebody using notepad as your script editor and not being able to run the script your trying to fix while on a computer at work.

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...