
ITSBTH
By: a guest on
Apr 18th, 2009 | syntax:
AutoIt | size: 3.12 KB | hits: 38 | expires: Never
#cs
# Dwarf Fortress functions
# All functions expects the mode be set beforehand, because the cursor is not guaranteed to be in the same spot after leaving and returning to it.
#ce
#Include <NomadMemory.au3>
Global $XAddress = 0x009FC294
, $YAddress = 0x009FC298
Global $UpZKey = "'", $DownZKey = "-"
; The current X and Y position, relative to the start
Global $CurX = 0
, $CurY = 0
, $CurZ = 0
SetPrivilege("SeDebugPrivilege", 1)
MsgBox(16, "Error", "Unable to find Dwarf Fortress")
$DFHandle = _MemoryOpen($DFProcess)
$CurX = _MemoryRead($XAddress, $DFHandle)
$CurY = _MemoryRead($YAddress, $DFHandle)
Func MoveCursor
($x, $y, $z = -1
)
Update()
SendSleep("{RIGHT}")
SendSleep("{LEFT}")
Update()
SendSleep("{DOWN}")
SendSleep("{UP}")
Update()
MoveCursorZ($z)
SendSleep($UpZKey)
$CurZ += 1
SendSleep($DownZKey)
$CurZ -= 1
Func DigMultiLevel
($StartX, $StartY, $StartZ, $EndX, $EndY, $EndZ)
If $StartZ > $EndZ Then ; Swap start and end Z if StartZ is greater than EndZ
$StartZ = $EndZ
$EndZ = $tmp
$EZ = $StartZ
MoveCursorZ($EZ)
Dig($StartX, $StartY, $EndX, $EndY)
$EZ += 1
Func Dig
($StartX, $StartY, $EndX, $EndY)
SendSleep("d")
MoveCursor($StartX, $StartY)
SendSleep("{ENTER}")
MoveCursor($EndX, $EndY)
SendSleep("{ENTER}")
Func CreateStairWell
($X, $Y, $StartZ, $EndZ)
If $StartZ > $EndZ Then ; Swap start and end Z if StartZ is greater than EndZ
$StartZ = $EndZ
$EndZ = $tmp
MoveCursor($X, $Y, $StartZ)
SendSleep("j")
SendSleep("{ENTER}")
SendSleep("{ENTER}")
MoveCursorZ($CurZ - 1)
SendSleep("i")
SendSleep("{ENTER}")
SendSleep("{ENTER}")
MoveCursorZ($CurZ - 1)
SendSleep("u")
SendSleep("{ENTER}")
SendSleep("{ENTER}")
Func Build
($X, $Y, $Z, $BuildString)
SendSleep($BuildString)
MoveCursor($X, $Y, $Z)
SendSleep("{ENTER}")
SendSleep("{ENTER}") ; Select topmost material / building
; Specialized functions
Func CreateQuarter
($X, $Y, $D)
Dig($x - 1, $Y, $X + 1, $Y)
Dig($X, $Y + $D, $X, $Y + $D)
Func CreateQuarters
($StartX, $StartY, $Rows)
Dig($StartX, $StartY, $StartX + 1 + $Rows * 4, $StartY + 2)
CreateQuarter($StartX + 1 + $I * 4, $StartY - 2, 1)
CreateQuarter($StartX + 1 + $I * 4, $StartY + 4, -1)
Setup()
; MoveCursor(10, 10, -3)
CreateQuarters(120, 20, 10)