Wednesday, March 3, 2010

[GF][autoIt] - Simple Jelly Coin Grindbot

 Here all, I got BORED


This script is using autoIt (http://www.autoitscript.com/); coding is done in SciTE (included in full download of autoIt)

This is a simple bot, useful to those new to botting/scripting, and should be nothing new to anyone familiar. Might stir up some ideas for other bots, but that is it.

Game: Grand Fantasia
Char/Class: Used with mage (due to AOE directly around player; Can easily be adapted for any class)
Where: Kaslow plains
Purpose: Grind and Obtain Jelly Rabbit Coins
To use: Set 'Magic Cloud' to 5, Summon Sprite, Goto Kaslow plains, Open the map, Run script.

Note: For "Picking up loot", I am using my sprite. However there is a skill for picking up loot as well, slightly more time-consuming to do, but very easy to integrate.


First we declare our variables, namely paused, but I like to know the start/end times too.
;Set Variables
Global $Paused
Global $Time

To keep things simple, I always move the window to 0,0 on my screen. This makes checking coordinates easy.
I then give the window focus.
;Position Window
WinMove("Grand Fantasia","",0,0)
WinActivate("Grand Fantasia", "")
if @error > 0 Then
    _Debug(string(@error))
    exit 0
EndIf
I'll get to _Debug() later, it's an output I use for debugging.

Next I set up hotkeys, and set variables:
;Set hotkeys
HotKeySet("{PAUSE}", "_Pause")
HotKeySet("{END}", "_Exit")
$Paused = False

_Pause()
$Time = String(@Hour) & ":" & String(@Min) & ":" & String(@Sec)
_Debug("Start: " & $Time)
$Timer = TimerInit()
I set Paused to false because the _Pause() Function inverses it, and causes the script to sleep until unpaused.
time simply relays the current time (24hour) when the script is unpaused.

Next, is the main function:
while 1   
    ;154,343
    MouseClick("Left",314,426)
    sleep(45000)
   
    _Open()
   
    ;282,451
    MouseClick("Left",391,362)
    sleep(45000)

    _Open()
WEnd
Yes, that is all I use for main, very small, small is good. the commented coords are the X/Y coordinates according to the characters location in game. While the mouse_click clicks that location (give or take 1x/1y) making your character move there.
Sleeping for 45,000 (45secs) is an estimate of how long it takes to go between the two points. Longer equals safer, shorter equals faster.

_Open() is the next function, and is outlined here:
Func _Open()
    ;Open Chests!
        send("5")
        send("5")
        send("5")
        send("5")
        send("5")
        send("5")
        send("5")
        send("5")
        send("5")
        send("5")
        send("5")
        send("5")
            sleep(5000)
EndFunc
Keep it simple, 5 is my key for "Toxic Cloud", which does area-of-effect damage to everything around me. Pots/chests included.
I have the program "mashing 5" because it doesn't always register on the active window (happens for several aeria game's games).
If you are not using a mage, simple have the camera spin to the desired view (A or D keys), pixel scan for the pot/chest colours, and click/attack them.


The sprite should now loot everything for you, or you have have the script press "loot" a few times, with an appropriate pause in between to allow for running-time)


Lastly, the _Debug(), _Paused(), and _Exit() functions:
Func _Debug(ByRef $var)
    ConsoleWrite("  " & $var & @CRLF)
EndFunc

func _Pause()
    $Paused = Not $Paused
    While $Paused
        ToolTip("Paused",0,0)
        sleep(100)
    WEnd
        ToolTip("Running",0,0)
EndFunc
   
func _Exit()
    $Time = String(@Hour) & ":" & String(@Min) & ":" & String(@Sec)
    _Debug("End: " & $Time)
    Exit 0
EndFunc
_Debug() simply creates a new line on the output (scite), and prints text on to it. Handy for finding out what line of code is not working. Or the time. etc.

_Paused() Toggles being the script running, or not running. Creating a tooltip at 0,0 to tell you the status.

_Exit() relays the time of ending, and then exits the program. simple

Full script, http://pastebin.com/GTsf2CcT

Don't expect me to troubleshoot every/any thing for you though. Learning experience.