The Wiki for Tale 4 is in read-only mode and is available for archival and reference purposes only. Please visit the current Tale 11 Wiki in the meantime.

If you have any issues with this Wiki, please post in #wiki-editing on Discord or contact Brad in-game.

Difference between revisions of "User:Sithid/Macros/AutoIT/Grass"

From A Tale in the Desert
Jump to navigationJump to search
Line 5: Line 5:
 
Once running, simply switch to atitd and hit the pause button, things should go on their own from there.
 
Once running, simply switch to atitd and hit the pause button, things should go on their own from there.
  
grass.exe coming shortly, script form only until then( having the .exe makes it so you dont have to have autoit installed to use my script ).
 
  
[[Media:grass.au3]]
+
== The Macro ==
 +
 
 +
<code>
 +
#cs --------------------------------------------------------------------------------------
 +
 +
AutoIt Version 3.2.12.1
 +
Author: Sithid
 +
Date: 07.12.08
 +
Version: 0.0.3.0
 +
 +
Script Function:
 +
Grass collection with simple Gui.
 +
 
 +
#ce --------------------------------------------------------------------------------------
 +
 
 +
#include <GUIConstantsEx.au3>
 +
#include <GUIConstants.au3>
 +
#include <WindowsConstants.au3>
 +
 
 +
Opt( "MustDeclareVars", 1 )
 +
 
 +
Global $Paused
 +
Global $EventMsg
 +
Global $StartTime
 +
Global $Idle = False
 +
Global $GrassCounter = 0
 +
Global $MinutesPassed = 0
 +
Global $SecondsPassed = 0
 +
Global $PrevTotalSeconds = 0
 +
 
 +
; Stuff you can/should edit.
 +
Global $XCenter = 720 ; X axis center of screen.
 +
Global $YCEnter = 450 ; Y axis center of screen.
 +
Global $Distance = 200 ; distance from avatar to click( in screen coords )
 +
Global $WaitDuration = 2500; delay between picking and then moving to pick again
 +
Global $GrassToCollect = 500 ; amount of grass to pick
 +
 
 +
; setup hotkeys
 +
HotKeySet("{PAUSE}", "TogglePause")
 +
HotKeySet("{ESC}", "Terminate")
 +
HotKeySet("{F5}", "Refresh" )
 +
 
 +
WinWaitActive("eGenesis Client") ; wait for active client window
 +
 
 +
; setup basic gui
 +
Dim $GUI = GUICreate( "Grass Macro", 250, 50, 1200, 50, $WS_POPUP, $WS_EX_TOPMOST )
 +
Dim $TitleLabel = GUICtrlCreateLabel ("Grass Macro", 1, 5, 250, 15 )
 +
Dim $TimeLabel = GUICtrlCreatelabel( "", 1, 20, 200, 15 )
 +
Dim $CountLabel = GUICtrlCreateLabel( "" , 1, 35, 200, 15 )
 +
 
 +
GUISetBkColor( 0xFFFFFF, $GUI )
 +
GUISetState( @SW_SHOW )
 +
 
 +
$StartTime = TimerInit()
 +
 
 +
; start script paused
 +
TogglePause()
 +
 
 +
; infinite loop, reset then call main picking function
 +
Do
 +
Reset()
 +
Main()
 +
Until 1 = 2
 +
 
 +
Terminate()
 +
 
 +
#cs
 +
*
 +
* Main pick function.
 +
* Function tries to pick grass, increments grass counter and then refreshes.
 +
* Repeated a second time to click below the avatar instead of up like the first time.
 +
*
 +
* Functions tops when the grass counter reaches the total number you wanted to pick.
 +
*
 +
#ce
 +
Func Main()
 +
 +
Do
 +
$EventMsg = GUIGetMsg()
 +
 +
If $EventMsg = $GUI_EVENT_CLOSE Then ExitLoop
 +
 +
MouseClick( "left", 222,70, 1, 5 )
 +
MouseClick( "left", $XCenter, $YCEnter + $Distance, 1, 5 )
 +
Sleep($WaitDuration)
 +
 +
$GrassCounter += 1
 +
Refresh()
 +
 +
MouseClick( "left", 222,70, 1, 5 )
 +
MouseClick( "left", $XCenter, $YCEnter - $Distance, 1, 5 )
 +
Sleep($WaitDuration)
 +
 +
$GrassCounter += 1
 +
Refresh()
 +
 
 +
Until $GrassCounter >= $GrassToCollect
 +
 
 +
TogglePause()
 +
 +
EndFunc
 +
 
 +
; Refreshes the gui time display and title text.
 +
Func Refresh()
 +
 +
Local $CurTotalSeconds = Round( TimerDiff( $StartTime ) / 1000.0 )
 +
$SecondsPassed += $CurTotalSeconds - $PrevTotalSeconds
 +
$PrevTotalSeconds = $CurTotalSeconds
 +
 
 +
If $SecondsPassed > 60 Then
 +
$SecondsPassed = 0
 +
$MinutesPassed += 1;
 +
ElseIf $SecondsPassed < 0 Then
 +
$SecondsPassed = 0
 +
EndIf
 +
 +
If $Idle Then
 +
GUICtrlSetData( $TitleLabel, "Grass Macro - [IDLE]" )
 +
Else
 +
GUICtrlSetData( $TitleLabel, "Grass Macro - [ACTIVE]" )
 +
EndIf
 +
 
 +
GUICtrlSetData( $TimeLabel, $MinutesPassed & " minutes, " & $SecondsPassed & " seconds passed." )
 +
GUICtrlSetData( $CountLabel, $GrassCounter & " total grass collected." )
 +
 +
EndFunc
 +
 
 +
; resets counters and gui elements, refreshes to update displayed gui.
 +
Func Reset()
 +
 +
$GrassCounter = 0
 +
$StartTime = TimerInit()
 +
$MinutesPassed = 0
 +
$SecondsPassed = 0
 +
Refresh()
 +
 +
EndFunc
 +
 
 +
; pausing support, adjusts gui colors to help know when macro is paused.
 +
Func TogglePause()
 +
 +
$Idle = True
 +
Reset()
 +
 +
Local $SleepCount = 0;
 +
 +
$Paused = Not $Paused
 +
 +
GUICtrlSetBkColor( $TitleLabel, 0xFF3333 )
 +
GUICtrlSetColor( $TitleLabel, 0xFFFFFF )
 +
 +
While $Paused
 +
Sleep(100)
 +
$SleepCount += 100;
 +
 +
If $SleepCount >= 1000 Then
 +
Refresh()
 +
$SleepCount = 0
 +
EndIf
 +
WEnd
 +
 +
GUICtrlSetBkColor( $TitleLabel, 0x11FF00 )
 +
GUICtrlSetColor( $TitleLabel, 0x000000 )
 +
 +
$Idle = False
 +
 +
EndFunc
 +
 
 +
Func Terminate()
 +
Exit 0
 +
EndFunc
 +
</code>

Revision as of 10:47, 15 December 2008

Grass Macro

My basic grass macro. Be sure to adjust the configurable vars within the script before building and running.

Once running, simply switch to atitd and hit the pause button, things should go on their own from there.


The Macro

  1. cs --------------------------------------------------------------------------------------

AutoIt Version 3.2.12.1 Author: Sithid Date: 07.12.08 Version: 0.0.3.0

Script Function: Grass collection with simple Gui.

  1. ce --------------------------------------------------------------------------------------
  1. include <GUIConstantsEx.au3>
  2. include <GUIConstants.au3>
  3. include <WindowsConstants.au3>

Opt( "MustDeclareVars", 1 )

Global $Paused Global $EventMsg Global $StartTime Global $Idle = False Global $GrassCounter = 0 Global $MinutesPassed = 0 Global $SecondsPassed = 0 Global $PrevTotalSeconds = 0

Stuff you can/should edit.

Global $XCenter = 720 ; X axis center of screen. Global $YCEnter = 450 ; Y axis center of screen. Global $Distance = 200 ; distance from avatar to click( in screen coords ) Global $WaitDuration = 2500; delay between picking and then moving to pick again Global $GrassToCollect = 500 ; amount of grass to pick

setup hotkeys

HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") HotKeySet("{F5}", "Refresh" )

WinWaitActive("eGenesis Client") ; wait for active client window

setup basic gui

Dim $GUI = GUICreate( "Grass Macro", 250, 50, 1200, 50, $WS_POPUP, $WS_EX_TOPMOST ) Dim $TitleLabel = GUICtrlCreateLabel ("Grass Macro", 1, 5, 250, 15 ) Dim $TimeLabel = GUICtrlCreatelabel( "", 1, 20, 200, 15 ) Dim $CountLabel = GUICtrlCreateLabel( "" , 1, 35, 200, 15 )

GUISetBkColor( 0xFFFFFF, $GUI ) GUISetState( @SW_SHOW )

$StartTime = TimerInit()

start script paused

TogglePause()

infinite loop, reset then call main picking function

Do Reset() Main() Until 1 = 2

Terminate()

  1. cs
  • Main pick function.
  • Function tries to pick grass, increments grass counter and then refreshes.
  • Repeated a second time to click below the avatar instead of up like the first time.
  • Functions tops when the grass counter reaches the total number you wanted to pick.
  1. ce

Func Main()

Do $EventMsg = GUIGetMsg()

If $EventMsg = $GUI_EVENT_CLOSE Then ExitLoop

MouseClick( "left", 222,70, 1, 5 ) MouseClick( "left", $XCenter, $YCEnter + $Distance, 1, 5 ) Sleep($WaitDuration)

$GrassCounter += 1 Refresh()

MouseClick( "left", 222,70, 1, 5 ) MouseClick( "left", $XCenter, $YCEnter - $Distance, 1, 5 ) Sleep($WaitDuration)

$GrassCounter += 1 Refresh()

Until $GrassCounter >= $GrassToCollect

TogglePause()

EndFunc

Refreshes the gui time display and title text.

Func Refresh()

Local $CurTotalSeconds = Round( TimerDiff( $StartTime ) / 1000.0 ) $SecondsPassed += $CurTotalSeconds - $PrevTotalSeconds $PrevTotalSeconds = $CurTotalSeconds

If $SecondsPassed > 60 Then $SecondsPassed = 0 $MinutesPassed += 1; ElseIf $SecondsPassed < 0 Then $SecondsPassed = 0 EndIf

If $Idle Then GUICtrlSetData( $TitleLabel, "Grass Macro - [IDLE]" ) Else GUICtrlSetData( $TitleLabel, "Grass Macro - [ACTIVE]" ) EndIf

GUICtrlSetData( $TimeLabel, $MinutesPassed & " minutes, " & $SecondsPassed & " seconds passed." ) GUICtrlSetData( $CountLabel, $GrassCounter & " total grass collected." )

EndFunc

resets counters and gui elements, refreshes to update displayed gui.

Func Reset()

$GrassCounter = 0 $StartTime = TimerInit() $MinutesPassed = 0 $SecondsPassed = 0 Refresh()

EndFunc

pausing support, adjusts gui colors to help know when macro is paused.

Func TogglePause()

$Idle = True Reset()

Local $SleepCount = 0;

$Paused = Not $Paused

GUICtrlSetBkColor( $TitleLabel, 0xFF3333 ) GUICtrlSetColor( $TitleLabel, 0xFFFFFF )

While $Paused Sleep(100) $SleepCount += 100;

If $SleepCount >= 1000 Then Refresh() $SleepCount = 0 EndIf WEnd

GUICtrlSetBkColor( $TitleLabel, 0x11FF00 ) GUICtrlSetColor( $TitleLabel, 0x000000 )

$Idle = False

EndFunc

Func Terminate() Exit 0 EndFunc