SetKeyDelay -1,-1,-1
SetBatchLines -1
#Warn
#NoEnv
#MaxThreadsPerHotkey 1
g_addrOption := 0x0083BE14
g_addrDelayASPD := 0x0083C504
g_addrCHP := 0x0083E1B4
g_addrMHP := 0x0083E1B8
g_addrCSP := 0x0083E1BC
g_addrMSP := 0x0083E1C0
g_addrDEF := 0x0083C514
g_tick := A_TickCount
g_kGreen := 0x31FF31 ; it's BBGGRR btw
g_delayASPD := 300
g_kScreenX := 0 ; the macro figures these out later, dont bother fixing em!
g_kScreenY := 0
g_kCastbarGreen := 0x21ef10
; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
; setup variables below
g_keyAbra := "{F2}"
g_keyCastCancel := "{F3}"
g_keySight := "{F1}"
g_keyIndulge := "{F5}"
g_keyDie := "]"
g_kStepX := 6 ; how many pixels between each ? top
g_kStepY := 0
g_kQmarkOffsetX := 630 ; where the first ? is
g_kQmarkOffsetY := 83
g_kWindowCancelX := 680 ; where the cancel button on autospell/arrow craft is
g_kWindowCancelY := 524
g_kTeleportCancelX := 773 ; where the cancel button on teleport is
g_kTeleportCancelY := 606
; make sure this is over the white of first aid and gets covered by the delay paw
g_kDelayPawX := 440
g_kDelayPawY := 18
g_kCastbarStartX := 612 ; this value is where the first bit of green shows
g_kCastbarStartY := 261
PGUP::
{
WinGet g_pid, PID, A
WinGetPos g_kScreenX, g_kScreenY, g_kScreenW, g_kScreenH, ahk_pid %g_pid%
CoordMode Mouse|Pixel, Screen
hpLast := 0
spLast := 0
g_kBaseX := g_kQmarkOffsetX
g_kBaseY := g_kQmarkOffsetY
;g_kBaseX := g_kScreenX + g_kQmarkOffsetX
;g_kBaseY := g_kScreenY + g_kQmarkOffsetY
g_kMiddleX := (g_kScreenW >> 1)
g_kMiddleY := (g_kScreenH >> 1)
;g_kMiddleX += g_kBaseX
;g_kMiddleX += g_kBaseY
;g_kWindowCancelX += g_kScreenX
;g_kWindowCancelY += g_kScreenY
;g_kTeleportCancelX += g_kScreenX
;g_kTeleportCancelY += g_kScreenY
;g_kDelayPawX += g_kScreenX
;g_kDelayPawY += g_kScreenY
;g_kCastbarStartX += g_kScreenX
;g_kCastbarStartY += g_kScreenY
g_kTeleportWindowX := g_kTeleportCancelX - 150
g_kTeleportWindowY := g_kTeleportCancelY
xA := g_kBaseX + g_kStepX * 0
xB := g_kBaseX + g_kStepX * 1
xC := g_kBaseX + g_kStepX * 2
xD := g_kBaseX + g_kStepX * 3
yA := g_kBaseY + g_kStepY * 0
yB := g_kBaseY + g_kStepY * 1
yC := g_kBaseY + g_kStepY * 2
yD := g_kBaseY + g_kStepY * 3
;ListVars
;Sleep 50000
i := 0
Loop
{
i := i + 1
sightStatus := readInt(g_addrOption) & 0x1
If ( i >= 5 )
{
i := 0
csp := readInt(g_addrCSP) ; 50 sp = abra cost
msp := readInt(g_addrMSP)
chp := readInt(g_addrCHP)
mhp := readInt(g_addrMHP)
def := readInt(g_addrDEF)
;Msgbox % Floor(chp * 100 / mhp)
;MsgBox % (def = 90)
;MsgBox % (chp = hpLast && csp = spLast)
; 90 def = steel body was cast, oops
; hp too low for indulge
; not regenning or using sp/hp -> trick dead? counter?
die := 0
If ( def = 90 )
die := 1
Else If ( Floor(chp * 100 / mhp) <= 11 )
die := 1
Else If ( chp = hpLast && csp = spLast )
die := 1
hpLast := chp
spLast := csp
If ( die )
{
ControlSend ,,%g_keyDie%, ahk_pid %g_pid%
Sleep 500
Break
}
If ( csp < 100 ) ; sp is so low you need to indulge
{
Loop 3
{
ControlSend ,,%g_keyIndulge%, ahk_pid %g_pid%
Sleep getASPDDelay()
}
}
}
If ( sightStatus = 0 )
{
ControlSend ,,%g_keySight%, ahk_pid %g_pid%
Sleep getASPDDelay()
}
ControlSend ,,%g_keyAbra%, ahk_pid %g_pid%
Sleep 250
PixelGetColor color1, %xA%, %yA%
PixelGetColor color2, %xB%, %yB%
PixelGetColor color3, %xC%, %yC%
PixelGetColor color4, %xD%, %yD%
If (color1 = g_kGreen && color2 = g_kGreen && g_kGreen = 0x31FF31 && color4 = g_kGreen)
{
Break ; we got question marks! GOGOGOGOGOGO!
}
; the send is before so that it will auto cancel rather than post check, the check is only
; for the sleep time of the delay!
ControlSend ,,%g_keyCastCancel%, ahk_pid %g_pid%
PixelGetColor color5, %g_kCastbarStartX%, %g_kCastbarStartY%, Alt
If ( color5 = g_kCastbarGreen )
{
Sleep getASPDDelay()
}
PixelGetColor color5, %g_kMiddleX%, %g_kMiddleY%
If (color5 = 0xFFFFFF) ; pharma window or something is up
{
Sleep 200
Send {Enter 2}
Sleep 200
PixelGetColor, color5, %g_kMiddleX%, %g_kMiddleY%
If (color5 = 0xFFFFFF) ; if it's still there then you gotta click cancel
{
MouseMove g_kWindowCancelX, g_kWindowCancelY
Click %g_kWindowCancelX%, %g_kWindowCancelY%
Sleep 200
}
}
PixelGetColor color5, %g_kTeleportWindowX%, %g_kTeleportWindowY%
If (color5 = 0xFFFFFF) ; teleport window is up! fuckers
{
Sleep 200
MouseMove g_kTeleportCancelX, g_kTeleportCancelY
Click %g_kTeleportCancelX%, %g_kTeleportCancelY%
Sleep 200
}
; check delay status
PixelGetColor color5, %g_kDelayPawX%, %g_kDelayPawY%
If ( color5 != 0xFFFFFF )
{
Sleep getASPDDelay()
}
Else
{
;Continue ;no delay, so loop
}
}
return
}
getASPDDelay()
{
Global g_tick, g_delayASPD, g_addrDelayASPD
;Return 300
If ( (A_TickCount - g_tick) >= 10000 )
{
g_tick := A_TickCount
g_delayASPD := 2 * readInt(g_addrDelayASPD) +10
}
Return g_delayASPD
}
readInt(addr)
{
global g_pid
hModule := DllCall("LoadLibrary", str, "rpm.dll")
if ( A_LastError )
{
MsgBox % "Error: " . A_LastError . " | loadlibrary failed!"
return -1
}
value := DllCall("rpm\getDWORD", UInt, addr, UInt, g_pid)
if ( A_LastError )
{
MsgBox % "Error: " . A_LastError . " | getDWORD failed! (addr: " . addr ")"
return -1
}
DllCall("FreeLibrary", UInt, hModule)
return value
}
PGDN::Pause