viewing paste Unknown #9195 | Autohotkey

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
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
Viewed 1003 times, submitted by Guest.