Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save douglasparker/7cdab7fda3c17acec60ca519ca00f5f0 to your computer and use it in GitHub Desktop.
Save douglasparker/7cdab7fda3c17acec60ca519ca00f5f0 to your computer and use it in GitHub Desktop.
[AHK] Final Fantasy: XIV - Sanctuary Farm: An AutoHotkey script for farming your Island Sanctuary.

An AutoHotkey script for farming your Island Sanctuary.

Configuration

Follow the following instructions to configure your game client for use with this script.

Movement

This script requires you to set your movement type to Standard in Movement Settings!

Macros

This script requires the following custom macros to be setup in FFXIV:

Acquire & auto run to target

  • Default Binding (Recommended): [Num3] 1
/Merror off
/micon "Duty Action I"
/ac "Duty Action I"
/targetnpc
/lockon on
/automove on

Footnotes

  1. You can setup a different key binding, but you will need to edit the following line in the AHK script.

#SingleInstance Force
#InstallKeybdHook
SendMode Input
DetectHiddenWindows, On
SetKeyDelay , 50, 30, ; 50ms is the default delay between presses, 30ms is the press length
if !A_IsAdmin
{
Run *RunAs "%A_ScriptFullPath%"
ExitApp
}
Exit
NumpadDiv::
ID := WinExist("A")
; ToolTip % ID, 0, 0 ; Displays a windowID in top left, put a semicolon in front of this line to disablesss
LargeTurnLoopCounter = 0
LargeTurnLoopCounterMaximum = 16
Loop
{
; Acquire target & auto run to target
Random AcquireTargetDelay, 1800, 2900 ; this will randomize time for pressing your hotkey from 1,8s to 2,9s
ControlSend, , {Numpad3}, ahk_id %ID%
sleep %AcquireTargetDelay%
; Confirm button
Random ConfirmDelay, 300, 800 ; this will randomize time for pressing your hotkey from 0,3s to 0,8s
ControlSend, , {Numpad0}, ahk_id %ID%
sleep %ConfirmDelay%
Random TurnDirection, 0, 1
Random SmallTurnDelay, 200, 400
Random MediumTurnChance, 1, 12
Random MediumTurnDelay, 500, 700
Random LargeTurnDelay, 1000, 1200
LargeTurnLoopCounter++
if(LargeTurnLoopCounter >= LargeTurnLoopCounterMaximum)
{
; Remove target
ControlSend, , {NumpadDot}, ahk_id %ID%
; Reset Camera and Zoom Out
ControlSend, , {ctrl down}{shift down}{end}{shift up}{ctrl up}, ahk_id %ID%
ControlSend, , {PgDn down}, ahk_id %ID%
sleep 1500
ControlSend, , {PgDn up}, ahk_id %ID%
if (TurnDirection){
ControlSend, , {d down}, ahk_id %ID%
sleep %LargeTurnDelay%
ControlSend, , {d up}, ahk_id %ID%
}
else {
ControlSend, , {a down}, ahk_id %ID%
sleep %LargeTurnDelay%
ControlSend, , {a up}, ahk_id %ID%
}
LargeTurnLoopCounter = 0
}
else if(MediumTurnChance == 1)
{
if (TurnDirection){
ControlSend, , {d down}{Space}, ahk_id %ID%
sleep %MediumTurnDelay%
ControlSend, , {d up}, ahk_id %ID%
}
else {
ControlSend, , {a down}{Space}, ahk_id %ID%
sleep %MediumTurnDelay%
ControlSend, , {a up}, ahk_id %ID%
}
}
; Small turn, happens most of the time.
else
{
if (TurnDirection){
ControlSend, , {d down}, ahk_id %ID%
sleep %SmallTurnDelay%
ControlSend, , {d up}, ahk_id %ID%
}
else {
ControlSend, , {a down}, ahk_id %ID%
sleep %SmallTurnDelay%
ControlSend, , {a up}, ahk_id %ID%
}
}
}
return
NumpadMult::Pause,Toggle
F9::ExitApp
Copy link

ghost commented Oct 3, 2023

edit: Oh nevermind I am dumb. I had to press / aka NumpadDiv to start the loop..

Unsure if it's only me but nothing happens when I run the script. I do receive a UAC prompt and the script shows up in Task Manager but other than that it's radio silence. My setup used AHK 2.X by default so it prompted me to install AHK 1.X which I did. The F9 bind to exit the script does work so I am sure I can interact with it somewhat. Thinking the ahk_id parts of the script were sending inputs somewhere else I tried replacing all of them with ahk_class FFXIVGAME but it didn't help either. I did reset my keybinds and set my movement type back to Standard.

@douglasparker
Copy link
Author

edit: Oh nevermind I am dumb. I had to press / aka NumpadDiv to start the loop..

Unsure if it's only me but nothing happens when I run the script. I do receive a UAC prompt and the script shows up in Task Manager but other than that it's radio silence. My setup used AHK 2.X by default so it prompted me to install AHK 1.X which I did. The F9 bind to exit the script does work so I am sure I can interact with it somewhat. Thinking the ahk_id parts of the script were sending inputs somewhere else I tried replacing all of them with ahk_class FFXIVGAME but it didn't help either. I did reset my keybinds and set my movement type back to Standard.

All good! I forgot that I made this a gist, but there may be an improved version of the script here: https://github.com/douglasparker/ahk-final-fantasy-xiv

@eddiethewheel
Copy link

@douglasparker
whenever I run this I get "too far" away and my character doesn't move since 6.5 update. Any ideas? If I'm standing right next to the node it will work once but never again. Keyboard mode >> standard movement. It also appears to never use the Duty Action I.

@douglasparker
Copy link
Author

@douglasparker whenever I run this I get "too far" away and my character doesn't move since 6.5 update. Any ideas? If I'm standing right next to the node it will work once but never again. Keyboard mode >> standard movement. It also appears to never use the Duty Action I.

Make sure you setup the required Macro as described here: https://github.com/douglasparker/ahk-final-fantasy-xiv#macros

It must be set to Numpad 3 and have the same commands as described in the link above.

The script is started with Numpad Divide.

These defaults can be changed, but you have to edit the script yourself.

I made this script for a friend and I don't actually play the game, so the support I can give is limited.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment