[Release][Autohotkey script] PoE Autoflasks & autoquit. menu

User Tag List

Page 25 of 32 FirstFirst ... 212223242526272829 ... LastLast
Results 361 to 375 of 473
  1. #361
    TehCheat's Avatar ★ Elder ★
    Reputation
    2562
    Join Date
    Oct 2013
    Posts
    1,900
    Thanks G/R
    349/2264
    Trade Feedback
    5 (100%)
    Mentioned
    32 Post(s)
    Tagged
    1 Thread(s)
    Broken again, flask offsets changed somewhere...

    [Release][Autohotkey script] PoE Autoflasks & autoquit.
  2. #362
    Crackjack's Avatar Active Member
    Reputation
    23
    Join Date
    Aug 2008
    Posts
    220
    Thanks G/R
    26/15
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by TehCheat View Post
    Broken again, flask offsets changed somewhere...
    God i wish i knew how to do this.. So used to have the autoflasks and focus on the actual gameplay and not the health and mana pool!

    Any kind soul who knows how to update this?

  3. #363
    blacklider's Avatar Member
    Reputation
    1
    Join Date
    Jun 2013
    Posts
    30
    Thanks G/R
    1/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Need Update offsets

  4. #364
    lethaldiamond's Avatar Knight-Lieutenant
    Reputation
    26
    Join Date
    Mar 2011
    Posts
    347
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does some1 try this Minecraft server hack - YouTube

  5. #365
    oxyelite's Avatar Member
    Reputation
    1
    Join Date
    Feb 2013
    Posts
    16
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am interested in trying to make this work again. Can someone tell me exactly which offsets need to be found?

  6. #366
    TehCheat's Avatar ★ Elder ★
    Reputation
    2562
    Join Date
    Oct 2013
    Posts
    1,900
    Thanks G/R
    349/2264
    Trade Feedback
    5 (100%)
    Mentioned
    32 Post(s)
    Tagged
    1 Thread(s)
    Originally Posted by oxyelite View Post
    I am interested in trying to make this work again. Can someone tell me exactly which offsets need to be found?
    Code:
    FlaskInvBase:=GetMultilevelPointer(pH,[UiBase+0x8e8,0x900,0x20])
    Pretty much those ones. Possible some others further down the chain, but that's for sure not correct now. The Player offsets all look good, I still get proper HP/ES/Mana off of them. But the flask pointers are all broken, and 0x8e8 is definitely not right anymore.

    EDIT:

    Ah, here ya go, change that line to:
    Code:
    FlaskInvBase:=GetMultilevelPointer(pH,[UiBase+0x968,0x980,0x20])
    Should be good to go after that.
    Last edited by TehCheat; 11-13-2013 at 09:19 PM.

  7. #367
    Crackjack's Avatar Active Member
    Reputation
    23
    Join Date
    Aug 2008
    Posts
    220
    Thanks G/R
    26/15
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by TehCheat View Post
    Code:
    FlaskInvBase:=GetMultilevelPointer(pH,[UiBase+0x8e8,0x900,0x20])
    Pretty much those ones. Possible some others further down the chain, but that's for sure not correct now. The Player offsets all look good, I still get proper HP/ES/Mana off of them. But the flask pointers are all broken, and 0x8e8 is definitely not right anymore.

    EDIT:

    Ah, here ya go, change that line to:
    Code:
    FlaskInvBase:=GetMultilevelPointer(pH,[UiBase+0x968,0x980,0x20])
    Should be good to go after that.
    You sir, made my day - Hell you made my time up until next patch screw this up!

    Thank you!

  8. #368
    chaosad1's Avatar Member
    Reputation
    1
    Join Date
    Mar 2009
    Posts
    84
    Thanks G/R
    2/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, not working for me...

    Anyone else have success with this change?

  9. #369
    ReadyToKill's Avatar Banned
    Reputation
    13
    Join Date
    Sep 2012
    Posts
    395
    Thanks G/R
    11/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    did u also change this part?

    baseMgrPtr:=0x78fd54 ; 0.11.3b delete for script to try to auto-scan for it in newer versions, scan takes 4-5 seconds

    Also thx for fixing this up, everything working fine again, Autoflask, FullBright and ItemAlert all working! However, i was never able to find anyone working on particle control, anyone able to get that working, so we can disable all those constant flashy effects that makes our pc crawl?

  10. #370
    TehCheat's Avatar ★ Elder ★
    Reputation
    2562
    Join Date
    Oct 2013
    Posts
    1,900
    Thanks G/R
    349/2264
    Trade Feedback
    5 (100%)
    Mentioned
    32 Post(s)
    Tagged
    1 Thread(s)
    I don't actually use that script, I have a c# program I run (gui selection of some things), but I use the exact same offsets. That's all I needed to change. Make sure you're using the latest script from the link on page 23.

    EDIT: Yes, don't forget to fix the baseMgrPtr, or comment it out so it will search for it, as ReadyToKill mentioned above. I always search in my program, so I always ignore that change.

  11. #371
    chaosad1's Avatar Member
    Reputation
    1
    Join Date
    Mar 2009
    Posts
    84
    Thanks G/R
    2/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by TehCheat View Post
    I don't actually use that script, I have a c# program I run (gui selection of some things), but I use the exact same offsets. That's all I needed to change. Make sure you're using the latest script from the link on page 23.

    EDIT: Yes, don't forget to fix the baseMgrPtr, or comment it out so it will search for it, as ReadyToKill mentioned above. I always search in my program, so I always ignore that change.
    Thanks a ton guys, didnt realize there was an updated version, just found this today, lol

    Working great now, woot!

  12. #372
    DXENEME's Avatar Sergeant CoreCoins Purchaser
    Reputation
    8
    Join Date
    Jun 2012
    Posts
    60
    Thanks G/R
    0/0
    Trade Feedback
    10 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    EDIT: Fixed it, for anyone who's a derp like me heres the working script.

    Code:
    SetBatchLines, -1
    DetectHiddenWindows, On
    
    cliname=Path of Exile
    cliexe=PathOfExile.exe
    trayNotifications:=true ;display tray notifications about script actions : drinking potions, autoquitting
    autoPotionsWatchdogPeriod:=100 ;milliseconds, decrease this value to have script recheck life/mana/flasks availability more often/increase chances of getting saved from death in time
    lagCompensation:=50
    
    autoQuitMode:=1 ; default autoQuit method : 0 =winKill, 1 = exit to login screen
    autoQuitPauseBeforeClick:=100
    autoQuitSoftToleranceBeforeKill:=2000 ; try to quit to loginscreen at most milliseconds before killing game window(in case we can't quit by clicking menu option for some reason)
    
    PlayerConfig:={}
    PlayerConfig["Default"]:={minLifeRatioToDrink: 0.45, minManaRatioToDrink: 0.55, minManaToDrink: 40, minLifeRatioToPopGranite: 0.65, minLifeRatioToQuit: 0.35} ;  disableAutoPotions:true, minLifeRatioToQuit:, minNShieldRatioToQuit: , HasZealotsOath: false, }
    
    PlayerConfig["Default"].FlaskConfig:=[]
    
    PlayerConfig["Default"].FlaskConfig[1]:={Hotkey:"{1 Down 1 UP}"} ; ,OverrideFlaskDuration:70, instantRecoveryOnLowLife:true, } ;specify override recovery time in deciseconds, e.g. 7 seconds = 70
    PlayerConfig["Default"].FlaskConfig[2]:={Hotkey:"{2 Down 2 UP}"}
    PlayerConfig["Default"].FlaskConfig[3]:={Hotkey:"{3 Down 3 UP}"}
    PlayerConfig["Default"].FlaskConfig[4]:={Hotkey:"{4 Down 4 UP}"}
    PlayerConfig["Default"].FlaskConfig[5]:={Hotkey:"{5 Down 5 UP}"}
    
    PlayerConfig["YourHardcorePlayerName"]:={minLifeRatioToDrink: 0.7, minManaRatioToDrink: 0.35, minManaToDrink: 70, minLifeRatioToQuit: 0.4}
    PlayerConfig["YourHardcorePlayerName"].FlaskConfig:=[]
    PlayerConfig["YourHardcorePlayerName"].FlaskConfig[1]:={Hotkey:"{1 Down 1 UP}"}
    PlayerConfig["YourHardcorePlayerName"].FlaskConfig[2]:={Hotkey:"{2 Down 2 UP}"}
    PlayerConfig["YourHardcorePlayerName"].FlaskConfig[3]:={Hotkey:"{3 Down 3 UP}"}
    PlayerConfig["YourHardcorePlayerName"].FlaskConfig[4]:={Hotkey:"{4 Down 4 UP}"}
    PlayerConfig["YourHardcorePlayerName"].FlaskConfig[5]:={Hotkey:"{5 Down 5 UP}"}
    
    autoPotionsState:=true
    
    WindowQueuedFlaskEffects:=[] ;keyed by "%hwnd%%CurrPid%", hpQueueEndtime, manaQueueEndtime
    
    baseMgrPtr:=0x78fd54 ; 0.11.3b delete for script to try to auto-scan for it in newer versions, scan takes 4-5 seconds
    
    basePtrAoBArray:=[0x6A,0xFF,0x68,"?","?","?","?",0x50,0x64,"?","?","?","?","?","?",0xA1,"?","?","?","?",0x81,0xEC,"?","?","?","?",0x53,0x55,0x56,0x57,0x33,0xFF,0x3B,0xC7]
    basePtrAobOffset:=0x10
    
    WindowBasicsCache:=[] ; keyed by "%hwnd%%CurrPid%", entries are objects with properties processHandle, moduleBase, moduleSize, baseFramePtr
    
    #Include AutoHotkeyMemoryLib.ahk
    
    Loop
    {
       AutoPotions()
    }
    
    GetWindowBasics(hwnd, byref mB="", byref pH="", byref mS="")
    {
       
       global WindowBasicsCache
       global cliexe
       
       WinGet, CurrPid, PID, ahk_id %hwnd%
       
       k="%hwnd%%CurrPid%"
       
       mB:=WindowBasicsCache[k].mBase
       mS:=WindowBasicsCache[k].mSize
       
       if mB=
       {
          WindowBasicsCache[k]:=Object()
          GetModuleInfo(cliexe, CurrPid, mB, mS)
          if (mB="" || mS="")
          {
             MsgBox, Failed to obtain moduleBase or moduleSize for PID %CurrPid%, script will now terminate
             ExitApp
          }      
          WindowBasicsCache[k].mBase:=mB
          WindowBasicsCache[k].mSize:=mS
       }
    
       pH:=WindowBasicsCache[k].ProcessHandle
       if pH=
       {
          pH:=GetProcessHandle(CurrPid)
          if (pH="" || pH=-1)
          {
             MsgBox, Invalid process handle obtained for PID %CurrPid%, script will now terminate
             ExitApp
          }      
          WindowBasicsCache[k].ProcessHandle:=pH
       }
    }
    
    ScanBaseMgrPtr(mBase,pH,moduleSize)
    {
       global basePtrAoBArray
       global basePtrAobOffset
       global baseMgrPtr
       aobResult:=AobScan(pH,mBase,moduleSize,basePtrAoBArray)
    
       if aobResult
       {
          SetFormat, IntegerFast, hex
          baseMgrPtr:=ReadMemUInt(pH,mBase+aobResult+basePtrAobOffset)-mBase
          MsgBox, PoE Base ptr found with AoB Scan baseMgrPtr = %baseMgrPtr%, save this value to script for quick startup
          SetFormat, IntegerFast, dec
       }
       else
       {
          MsgBox, baseMgrPtr not found with AoBScan, script will now terminate
          ExitApp
       }   
    }
    
    GetFrameBase(hwnd)
    {
       global baseMgrPtr
       global WindowBasicsCache
    
       WinGet, CurrPid, PID, ahk_id %hwnd%
       k="%hwnd%%CurrPid%"
    
       fB:=WindowBasicsCache[k].fBase
    
       if fB=
       {
          GetWindowBasics(hwnd, mBase, pH, mSize)
    
          if baseMgrPtr=
          {
             ScanBaseMgrPtr(mBase, pH, mSize)
          }
    
          fB:=GetMultilevelPointer(pH,[mBase+baseMgrPtr,4,0x7C,0x94])
          WindowBasicsCache[k].fBase:=fB
       }
       return fB
    }
    
    GetUiBase(hwnd)
    {
       global baseMgrPtr
    
          GetWindowBasics(hwnd, mBase, pH, mSize)
          
          if baseMgrPtr=
          {
             ScanBaseMgrPtr(mBase, pH, mSize)
          }
          
    	FrameBase:=GetFrameBase(hwnd)
    	if (FrameBase="" || FrameBase=0)
    		return
    	uiBase:=GetMultilevelPointer(pH,[FrameBase+0xBC,0xA4,0x50])
    	return uiBase
    }
    
    ReadClientResolution(hwnd, ByRef w, ByRef h)
    {
       GetWindowBasics(hwnd,mBase,pH)
       if (mBase!=0 && pH && pH!=-1)
       {
          FrameBase:=GetFrameBase(hwnd)
          w:=ReadMemUInt(pH,FrameBase+0x1340)
          h:=ReadMemUInt(pH,FrameBase+0x1344)
          return true
       }   
    }
    
    ReadPlayerStats(hwnd, byRef PlayerStats)
    {
       GetWindowBasics(hwnd, mBase, pH)
       fBase:=GetFrameBase(hwnd)
       PlayerBase:=GetMultilevelPointer(pH,[fBase+0xBC,0x59C])
       PlayerMain:=ReadMemUInt(pH,PlayerBase+4)
       PlayerStatsOffset:=ReadMemUInt(pH,PlayerMain+0xC)
    	PlayerStats.MaxHP:=ReadMemUInt(pH,PlayerStatsOffset+0x50)
    	PlayerStats.CurrHP:=ReadMemUInt(pH,PlayerStatsOffset+0x54)	
    	PlayerStats.ReservedHPFlat:=ReadMemUInt(pH,PlayerStatsOffset+0x5C)
    	PlayerStats.ReservedHPPercent:=ReadMemUInt(pH,PlayerStatsOffset+0x60)
    	PlayerStats.MaxMana:=ReadMemUInt(pH,PlayerStatsOffset+0x74)
    	PlayerStats.ReservedManaFlat:=ReadMemUInt(pH,PlayerStatsOffset+0x80)
    	PlayerStats.ReservedManaPercent:=ReadMemUInt(pH,PlayerStatsOffset+0x84)
    	PlayerStats.CurrMana:=ReadMemUInt(pH,PlayerStatsOffset+0x78)
    	PlayerStats.MaxNShield:=ReadMemUInt(pH,PlayerStatsOffset+0x98)
    	PlayerStats.CurrNShield:=ReadMemUInt(pH,PlayerStatsOffset+0x9C)
       
       if (ReadMemUInt(pH, ReadMemUInt(pH,PlayerMain+0x14)+0x24)<8) ;names shorter than 7 chars are stored immediately in component
          PlayerStats.Name:=ReadMemStr(pH, ReadMemUint(pH,PlayerMain+0x14)+0x10,100,"UTF-16") ;immediate name in component
       else
          PlayerStats.Name:=ReadMemStr(pH, GetMultilevelPointer(pH,[PlayerMain+0x14,0x10]),100,"UTF-16") ; otherwise pointer to name is stored
    }
    
    ReadFlasksData(hwnd, byRef FlasksData)
    {
       GetWindowBasics(hwnd, mBase, pH)
       
       UiBase:=GetUiBase(hwnd)
       
       if (!UiBase) ;not InGame
          return
       
       FlaskInvBase:=GetMultilevelPointer(pH,[UiBase+0x968,0x980,0x20])
    
       Loop, 5
       {
          currFlaskPtr:=ReadMemUInt(pH,FlaskInvBase+(A_Index-1)*4)
          if (currFlaskPtr!=0) ; there's a flask in said slot
          {
             FlasksData[A_Index]:={}
    
             FlaskChargesPtr:=GetMultilevelPointer(ph,[currFlaskPtr,4,0x1C,4,4,0xC])
             FlasksData[A_Index].ChargesCurrent:=ReadMemUInt(pH,FlaskChargesPtr+0xC)
             FlasksData[A_Index].ChargesPerUse:=ReadMemUInt(pH,ReadMemUInt(pH,FlaskChargesPtr+8)+0xC)
             
             if (FlasksData[A_Index].ChargesCurrent < FlasksData[A_Index].ChargesPerUse) ; not enough charges in this flask to use it, don't bother
                continue
    
             FlaskMetadataPtr:=GetMultilevelPointer(ph,[currFlaskPtr,0,8])
             FlaskMetadataStr:=ReadMemStr(ph,FlaskMetadataPtr,70,"UTF-16")
             FlaskTypeStr:=SubStr(FlaskMetadataStr,23)
             FlasksData[A_Index].type:=FlaskTypeStr
             
             FlaskLocalstatsPtr:=GetMultilevelPointer(ph,[currFlaskPtr,4,0x18,0x20,0xC])
             
             if InStr(FlaskTypeStr, "Life")
             {
                FlasksData[A_Index].HPRegAmount:=ReadMemUInt(pH,FlaskLocalstatsPtr+4)
                FlasksData[A_Index].EffectDuration:=ReadMemUInt(pH,FlaskLocalstatsPtr+0xC)
             }
    
             if InStr(FlaskTypeStr, "Mana")
             {
                FlasksData[A_Index].ManaRegAmount:=ReadMemUInt(pH,FlaskLocalstatsPtr+4)
                FlasksData[A_Index].EffectDuration:=ReadMemUInt(pH,FlaskLocalstatsPtr+0xC)
             }
             
             if InStr(FlaskTypeStr, "Hybrid")
             {
                FlasksData[A_Index].HPRegAmount:=ReadMemUInt(pH,FlaskLocalstatsPtr+4)
                FlasksData[A_Index].ManaRegAmount:=ReadMemUInt(pH,FlaskLocalstatsPtr+0xC)
                FlasksData[A_Index].EffectDuration:=ReadMemUInt(pH,FlaskLocalstatsPtr+0x14)
             }
    
             if InStr(FlaskTypeStr, "FlaskUtility")
             {
                FlasksData[A_Index].EffectDuration:=ReadMemUInt(pH,FlaskLocalstatsPtr+0x4)
             }
          }
       }
    }
    
    IsInGame(hwnd)
    {
    	if (hwnd=0 || hwnd="")
    		return false
    	GetWindowBasics(hwnd,mBase,pH)
    	if (mBase="" || mBase=0 || pH="" || pH=-1)
    		return false
    	fBase:=GetFrameBase(hwnd)
    	if (fBase="" || fBase=0)
    		return false
    	localConnection:=ReadMemUInt(pH,fBase+0xc0)
    	if (localConnection=0 || localConnection="")
    		return false
    	else
    		return true
    }
    
    SetGameStateMenu(hwnd)
    {
    	if (hwnd=0 || hwnd="")
    		return false
    	GetWindowBasics(hwnd,mBase,pH)
    	if (mBase="" || mBase=0 || pH="" || pH=-1)
    		return false
    	fBase:=GetFrameBase(hwnd)
    	if (fBase="" || fBase=0)
    		return false
    	localConnection:=ReadMemUInt(pH,fBase+0xc0)
    	if (localConnection!="" && localConnection!=0)
    	{
    		WriteMemUInt(pH,localConnection+0x2578,1)
    	}
    }
    
    ReadCursorScreenPosition(hwnd,ByRef cX, ByRef cY)
    {
       GetWindowBasics(hwnd,mBase,pH)
       if (mBase!=0 && pH && pH!=-1)
       {
          FrameBase:=GetFrameBase(hwnd)
          cX:=ReadMemSInt(pH,FrameBase+0x155c)
          cY:=ReadMemSInt(pH,FrameBase+0x1560)
          return true
       }   
    }
    
    ScreenToClient(hwnd, ByRef x, ByRef y)
    {
        VarSetCapacity(pt, 8)
        NumPut(x, pt, 0)
        NumPut(y, pt, 4)
        DllCall("ScreenToClient", "uint", hwnd, "uint", &pt)
        x := NumGet(pt, 0, "int")
        y := NumGet(pt, 4, "int")
       VarSetCapacity(pt, 0)
    }
    
    GetClientCoords(byRef mx, byRef my)
    {
       hwnd:=WinActive("A")   
       CoordMode, Mouse, Screen
       MouseGetPos, mx, my
       ScreenToClient(hwnd,mx,my) ;get mouse pos relative to window client rect
    }
    
    GetFractionalCoords(ByRef fX, ByRef fY)
    {
       hwnd:=WinActive("A")
       
       if (!IsInGame(hwnd))
          GetClientCoords(mx,my)
       else
          ReadCursorScreenPosition(hwnd,mx,my)
       
       ReadClientResolution(hwnd,w,h)
       
       fX:=mx/w
       fY:=my/h
    }
    
    GetClientCoordsFromFractional(hwnd, fX,fY, ByRef cX, ByRef cY)
    {
       ReadClientResolution(hwnd,w,h)
       cX:=fX*w
       cY:=fY*h      
    }
    
    QuitToLoginScreen(hwnd)
    {	
    	if (!IsInGame(hwnd))
    	{
    		return
    	}
    	SetGameStateMenu(hwnd)
    }
    
    GetMaxChargesFlaskOfType(ByRef FlasksData,TypeStr)
    {
       currMaxCharges:=0
       Loop, 5
          if (InStr(FlasksData[A_Index].type,TypeStr))
          {
             if FlasksData[A_Index].ChargesCurrent>currMaxCharges
             {
                currMaxI:=A_Index
                currMaxCharges:=FlasksData[A_Index].ChargesCurrent
             }
          }
       return currMaxI
    }
    
    AutoPotions()
    {
       global autoPotionsWatchdogPeriod
       global lagCompensation
       global PlayerConfig
       global WindowQueuedFlaskEffects
       global cliname
       global cliexe
       global trayNotifications
       global autoQuitMode
       
       if (autoPotionsState!=true)
          return
    
       WinGet, WinID, List, %cliname%
       
       Loop, %WinID%
       {
          
          WinGet, ProcModuleName, ProcessName,  % "ahk_id" WinID%A_Index%
          
          If(ProcModuleName!=cliexe) ; got a window with title "Path of Exile" but exe is not Client.exe, perhaps we have browser window open with PoE site, ignore it
             continue
          
          if (!IsInGame(WinID%A_Index%)) ;not ingame
             continue
    		 
    	if (WinID%A_Index%=WinActive("A"))
    	   ThisID:=WinActive("A")
          
          PlayerStats:={}
          ReadPlayerStats(WinID%A_Index%, PlayerStats)
          
          if (PlayerStats.MaxHP<1 || PlayerStats.CurrHP=0) ;dead, don't bother
             continue
    
          if (PlayerConfig.HasKey(PlayerStats.Name))
             CurrentConfig:=PlayerConfig[PlayerStats.Name]
          else
             CurrentConfig:=PlayerConfig["Default"]
             
          
          if PlayerStats.MaxNShield>0
          {
             currNShieldRatio:=PlayerStats.CurrNShield/PlayerStats.MaxNShield
          }
          
          if (PlayerStats.MaxHP>1)
          {
             currLifeRatio:=PlayerStats.CurrHP/(PlayerStats.MaxHP-PlayerStats.ReservedHPFlat-PlayerStats.MaxHP*PlayerStats.ReservedHPPercent/100)
          }
          
          if CurrentConfig.HasZealotsOath
          {
             currLifeRatio:=currNShieldRatio
          }
             
          if (PlayerStats.MaxMana>0)
          {
             currManaRatio:=PlayerStats.CurrMana/(PlayerStats.MaxMana-PlayerStats.ReservedManaFlat-PlayerStats.MaxMana*PlayerStats.ReservedManaPercent/100)
          }
          
          if (currLifeRatio<CurrentConfig.minLifeRatioToQuit || currNShieldRatio<CurrentConfig.minNShieldRatioToQuit)
          {
             if (autoQuitMode=0)
             {
                TrayTip, PoE autoPotions AutoQuit by closing window, specified min life reached, %A_Space% , 2
                WinKill, % "ahk_id" WinID%A_Index%
             }
             else if (autoQuitMode=1)
             {
                QuitToLoginScreen(WinID%A_Index%)
             }
    		 autoQuit:=1
             continue
          }
          
          if (CurrentConfig.disableAutoPotions)
             continue
          
          FlasksData:=[]
          ReadFlasksData(WinID%A_Index%,FlasksData)
          
          WinGet, CurrPID, PID,  % "ahk_id" WinID%A_Index%
          hwnd:=WinID%A_Index%
          k="%hwnd%%CurrPid%"
          if (!WindowQueuedFlaskEffects.HasKey(k))
          {
             WindowQueuedFlaskEffects[k]:={}
          }
          
          if (currLifeRatio<CurrentConfig.minLifeRatioToPopGranite || currNShieldRatio<CurrentConfig.minNShieldRatioToPopGranite)
             if ((!WindowQueuedFlaskEffects[k].HasKey("graniteQueueEndtime")) || (A_TickCount>=(WindowQueuedFlaskEffects[k].graniteQueueEndtime-lagCompensation)))
                {
                   flaskNum:=GetMaxChargesFlaskOfType(FlasksData,"FlaskUtility5") ; granite flask
                   if (flaskNum!="")
                   {
                      if CurrentConfig.FlaskConfig[flaskNum].HasKey("OverrideFlaskDuration")
                         EffectDuration:=CurrentConfig.FlaskConfig[flaskNum].OverrideFlaskDuration
                      else
                         EffectDuration:=FlasksData[flaskNum].EffectDuration
                         
                      WindowQueuedFlaskEffects[k].graniteQueueEndtime:=A_TickCount+EffectDuration*100
    
                      if (trayNotifications)
                      {
                         pname:=PlayerStats.Name
                         TrayTip, PoE autoPotions popping Granite flask %flaskNum% on %pname%, %A_Space% , 2
                      }
                      hKey:=CurrentConfig.FlaskConfig[flaskNum].Hotkey
                      ControlSend,,%hkey%, % "ahk_id" hwnd
                      break
                   }
                }
                   
          if (currLifeRatio=1)
             WindowQueuedFlaskEffects[k].hpQueueEndtime:=A_TickCount
          
          if (currManaRatio=1)
             WindowQueuedFlaskEffects[k].ManaQueueEndtime:=A_TickCount
          
          if (currLifeRatio<CurrentConfig.minLifeRatioToDrink || (PlayerStats.CurrHP<CurrentConfig.minLifeToDrink))
             if ((!WindowQueuedFlaskEffects[k].HasKey("hpQueueEndtime")) || (A_TickCount>=(WindowQueuedFlaskEffects[k].hpQueueEndtime-lagCompensation)))
             {
                      tflaskNum1:=GetMaxChargesFlaskOfType(FlasksData,"FlaskLife")
                      tflaskNum2:=GetMaxChargesFlaskOfType(FlasksData,"FlaskHybrid")
                      if ((tflaskNum1!=) && (tflaskNum2!=))
                         flaskNum:=(FlasksData[tflaskNum1].ChargesCurrent>FlasksData[tflaskNum2].ChargesCurrent) ? tflaskNum1 : tflaskNum2
                      else
                      {
                         if (tflaskNum1!="")
                            flaskNum:=tflaskNum1
                         if (tflaskNum2!="")
                            flaskNum:=tflaskNum2
                      }
                      if (flaskNum!="")
                      {
                         if CurrentConfig.FlaskConfig[flaskNum].HasKey("OverrideFlaskDuration")
                            EffectDuration:=CurrentConfig.FlaskConfig[flaskNum].OverrideFlaskDuration
                         else
                            EffectDuration:=FlasksData[flaskNum].EffectDuration
                         
                         if ((CurrentConfig.FlaskConfig[flaskNum].instantRecoveryOnLowLife) && ((PlayerStats.CurrHP/PlayerStats.MaxHP)<=0.35)) ; "Low life" can be caused by auras hp reservation from blood magic
                            EffectDuration:=lagCompensation
                            
                         WindowQueuedFlaskEffects[k].hpQueueEndtime:=A_TickCount+EffectDuration*100
                         if (FlasksData[flaskNum].HasKey("ManaRegAmount")) ; hybrid flask
                            WindowQueuedFlaskEffects[k].ManaQueueEndtime:=A_TickCount+EffectDuration*100
    
                         if (trayNotifications)
                         {
                            pname:=PlayerStats.Name
                            TrayTip, PoE autoPotions sipping HP flask %flaskNum% on %pname%, %A_Space% , 2
                         }
                         hKey:=CurrentConfig.FlaskConfig[flaskNum].Hotkey
                         ControlSend,,%hkey%, % "ahk_id" hwnd
                         break
                      }
                }
    
          if (PlayerStats.MaxMana>0 && (currManaRatio<CurrentConfig.minManaRatioToDrink || PlayerStats.CurrMana<CurrentConfig.minManaToDrink))      
             if ((!WindowQueuedFlaskEffects[k].HasKey("ManaQueueEndtime")) || (A_TickCount>=(WindowQueuedFlaskEffects[k].ManaQueueEndtime-lagCompensation)))
             {
                   tflaskNum1:=GetMaxChargesFlaskOfType(FlasksData,"FlaskMana")
                   tflaskNum2:=GetMaxChargesFlaskOfType(FlasksData,"FlaskHybrid")
                   
                   if ((tflaskNum1!=) && (tflaskNum2!=))
                      flaskNum:=(FlasksData[tflaskNum1].ChargesCurrent>FlasksData[tflaskNum2].ChargesCurrent) ? tflaskNum1 : tflaskNum2
                   else
                   {
                      if (tflaskNum1!="")
                         flaskNum:=tflaskNum1
                      if (tflaskNum2!="")
                         flaskNum:=tflaskNum2
                   }
    
                   if (flaskNum!="")
                   {
                      if CurrentConfig.FlaskConfig[flaskNum].HasKey("OverrideFlaskDuration")
                         {
                            EffectDuration:=CurrentConfig.FlaskConfig[flaskNum].OverrideFlaskDuration
                         }
                      else
                         EffectDuration:=FlasksData[flaskNum].EffectDuration
    
                      if ((CurrentConfig.FlaskConfig[flaskNum].instantRecoveryOnLowLife) && ((PlayerStats.CurrHP/PlayerStats.MaxHP)<=0.35))
                         EffectDuration:=lagCompensation
                      
                      WindowQueuedFlaskEffects[k].ManaQueueEndtime:=A_TickCount+EffectDuration*100
                      if (FlasksData[flaskNum].HasKey("HPRegAmount")) ; hybrid flask
                         WindowQueuedFlaskEffects[k].hpQueueEndtime:=A_TickCount+EffectDuration*100
                      
                      hKey:=CurrentConfig.FlaskConfig[flaskNum].Hotkey
                      if (trayNotifications)
                      {
                         pname:=PlayerStats.Name
                         TrayTip, PoE autoPotions sipping mana flask %flaskNum% on %pname%, %A_Space% , 2
                      }
                      ControlSend,,%hkey%, % "ahk_id" hwnd
                      break
                   }
             }               
       }
       
        if ((autoQuit=1) && (ThisID!="") && (ThisID!=WinActive("A")))
          WinActivate, % "ahk_id" ThisID
    
       Sleep, %autoPotionsWatchdogPeriod%   
    }
    
    F1::
       global autoPotionsState
       global trayNotifications
       autoPotionsState:=not autoPotionsState
       if (trayNotifications)
       {
          if (autoPotionsState=true)
             TrayTip, PoE autoPotions is on, %A_Space% , 2
          else
             TrayTip, PoE autoPotions is off, %A_Space%  , 2
       }
    return
    
    F2::
       GetClientCoords(mx,my)
       GetFractionalCoords(fx,fy)
       msgbox, mx=%mx% my=%my% fx=%fx% fy=%fy%
    return
    
    F4::
       QuitToLoginScreen(WinActive("A"))
    return
    Last edited by DXENEME; 11-14-2013 at 01:18 AM.

  13. #373
    artsy's Avatar Private
    Reputation
    1
    Join Date
    Jul 2013
    Posts
    6
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by dxeneme View Post
    edit: Fixed it, for anyone who's a derp like me heres the working script.

    Code:
    setbatchlines, -1
    detecthiddenwindows, on
    
    cliname=path of exile
    cliexe=pathofexile.exe
    traynotifications:=true ;display tray notifications about script actions : Drinking potions, autoquitting
    autopotionswatchdogperiod:=100 ;milliseconds, decrease this value to have script recheck life/mana/flasks availability more often/increase chances of getting saved from death in time
    lagcompensation:=50
    
    autoquitmode:=1 ; default autoquit method : 0 =winkill, 1 = exit to login screen
    autoquitpausebeforeclick:=100
    autoquitsofttolerancebeforekill:=2000 ; try to quit to loginscreen at most milliseconds before killing game window(in case we can't quit by clicking menu option for some reason)
    
    playerconfig:={}
    playerconfig["default"]:={minliferatiotodrink: 0.45, minmanaratiotodrink: 0.55, minmanatodrink: 40, minliferatiotopopgranite: 0.65, minliferatiotoquit: 0.35} ;  disableautopotions:true, minliferatiotoquit:, minnshieldratiotoquit: , haszealotsoath: False, }
    
    playerconfig["default"].flaskconfig:=[]
    
    playerconfig["default"].flaskconfig[1]:={hotkey:"{1 down 1 up}"} ; ,overrideflaskduration:70, instantrecoveryonlowlife:true, } ;specify override recovery time in deciseconds, e.g. 7 seconds = 70
    playerconfig["default"].flaskconfig[2]:={hotkey:"{2 down 2 up}"}
    playerconfig["default"].flaskconfig[3]:={hotkey:"{3 down 3 up}"}
    playerconfig["default"].flaskconfig[4]:={hotkey:"{4 down 4 up}"}
    playerconfig["default"].flaskconfig[5]:={hotkey:"{5 down 5 up}"}
    
    playerconfig["yourhardcoreplayername"]:={minliferatiotodrink: 0.7, minmanaratiotodrink: 0.35, minmanatodrink: 70, minliferatiotoquit: 0.4}
    playerconfig["yourhardcoreplayername"].flaskconfig:=[]
    playerconfig["yourhardcoreplayername"].flaskconfig[1]:={hotkey:"{1 down 1 up}"}
    playerconfig["yourhardcoreplayername"].flaskconfig[2]:={hotkey:"{2 down 2 up}"}
    playerconfig["yourhardcoreplayername"].flaskconfig[3]:={hotkey:"{3 down 3 up}"}
    playerconfig["yourhardcoreplayername"].flaskconfig[4]:={hotkey:"{4 down 4 up}"}
    playerconfig["yourhardcoreplayername"].flaskconfig[5]:={hotkey:"{5 down 5 up}"}
    
    autopotionsstate:=true
    
    windowqueuedflaskeffects:=[] ;keyed by "%hwnd%%currpid%", hpqueueendtime, manaqueueendtime
    
    basemgrptr:=0x78fd54 ; 0.11.3b delete for script to try to auto-scan for it in newer versions, scan takes 4-5 seconds
    
    baseptraobarray:=[0x6a,0xff,0x68,"?","?","?","?",0x50,0x64,"?","?","?","?","?","?",0xa1,"?","?","?","?",0x81,0xec,"?","?","?","?",0x53,0x55,0x56,0x57,0x33,0xff,0x3b,0xc7]
    baseptraoboffset:=0x10
    
    windowbasicscache:=[] ; keyed by "%hwnd%%currpid%", entries are objects with properties processhandle, modulebase, modulesize, baseframeptr
    
    #include autohotkeymemorylib.ahk
    
    loop
    {
       autopotions()
    }
    
    getwindowbasics(hwnd, byref mb="", byref ph="", byref ms="")
    {
       
       global windowbasicscache
       global cliexe
       
       winget, currpid, pid, ahk_id %hwnd%
       
       k="%hwnd%%currpid%"
       
       mb:=windowbasicscache[k].mbase
       ms:=windowbasicscache[k].msize
       
       if mb=
       {
          windowbasicscache[k]:=object()
          getmoduleinfo(cliexe, currpid, mb, ms)
          if (mb="" || ms="")
          {
             msgbox, failed to obtain modulebase or modulesize for pid %currpid%, script will now terminate
             exitapp
          }      
          windowbasicscache[k].mbase:=mb
          windowbasicscache[k].msize:=ms
       }
    
       ph:=windowbasicscache[k].processhandle
       if ph=
       {
          ph:=getprocesshandle(currpid)
          if (ph="" || ph=-1)
          {
             msgbox, invalid process handle obtained for pid %currpid%, script will now terminate
             exitapp
          }      
          windowbasicscache[k].processhandle:=ph
       }
    }
    
    scanbasemgrptr(mbase,ph,modulesize)
    {
       global baseptraobarray
       global baseptraoboffset
       global basemgrptr
       aobresult:=aobscan(ph,mbase,modulesize,baseptraobarray)
    
       if aobresult
       {
          setformat, integerfast, hex
          basemgrptr:=readmemuint(ph,mbase+aobresult+baseptraoboffset)-mbase
          msgbox, poe base ptr found with aob scan basemgrptr = %basemgrptr%, save this value to script for quick startup
          setformat, integerfast, dec
       }
       else
       {
          msgbox, basemgrptr not found with aobscan, script will now terminate
          exitapp
       }   
    }
    
    getframebase(hwnd)
    {
       global basemgrptr
       global windowbasicscache
    
       winget, currpid, pid, ahk_id %hwnd%
       k="%hwnd%%currpid%"
    
       fb:=windowbasicscache[k].fbase
    
       if fb=
       {
          getwindowbasics(hwnd, mbase, ph, msize)
    
          if basemgrptr=
          {
             scanbasemgrptr(mbase, ph, msize)
          }
    
          fb:=getmultilevelpointer(ph,[mbase+basemgrptr,4,0x7c,0x94])
          windowbasicscache[k].fbase:=fb
       }
       return fb
    }
    
    getuibase(hwnd)
    {
       global basemgrptr
    
          getwindowbasics(hwnd, mbase, ph, msize)
          
          if basemgrptr=
          {
             scanbasemgrptr(mbase, ph, msize)
          }
          
    	framebase:=getframebase(hwnd)
    	if (framebase="" || framebase=0)
    		return
    	uibase:=getmultilevelpointer(ph,[framebase+0xbc,0xa4,0x50])
    	return uibase
    }
    
    readclientresolution(hwnd, byref w, byref h)
    {
       getwindowbasics(hwnd,mbase,ph)
       if (mbase!=0 && ph && ph!=-1)
       {
          framebase:=getframebase(hwnd)
          w:=readmemuint(ph,framebase+0x1340)
          h:=readmemuint(ph,framebase+0x1344)
          return true
       }   
    }
    
    readplayerstats(hwnd, byref playerstats)
    {
       getwindowbasics(hwnd, mbase, ph)
       fbase:=getframebase(hwnd)
       playerbase:=getmultilevelpointer(ph,[fbase+0xbc,0x59c])
       playermain:=readmemuint(ph,playerbase+4)
       playerstatsoffset:=readmemuint(ph,playermain+0xc)
    	playerstats.maxhp:=readmemuint(ph,playerstatsoffset+0x50)
    	playerstats.currhp:=readmemuint(ph,playerstatsoffset+0x54)	
    	playerstats.reservedhpflat:=readmemuint(ph,playerstatsoffset+0x5c)
    	playerstats.reservedhppercent:=readmemuint(ph,playerstatsoffset+0x60)
    	playerstats.maxmana:=readmemuint(ph,playerstatsoffset+0x74)
    	playerstats.reservedmanaflat:=readmemuint(ph,playerstatsoffset+0x80)
    	playerstats.reservedmanapercent:=readmemuint(ph,playerstatsoffset+0x84)
    	playerstats.currmana:=readmemuint(ph,playerstatsoffset+0x78)
    	playerstats.maxnshield:=readmemuint(ph,playerstatsoffset+0x98)
    	playerstats.currnshield:=readmemuint(ph,playerstatsoffset+0x9c)
       
       if (readmemuint(ph, readmemuint(ph,playermain+0x14)+0x24)<8) ;names shorter than 7 chars are stored immediately in component
          playerstats.name:=readmemstr(ph, readmemuint(ph,playermain+0x14)+0x10,100,"utf-16") ;immediate name in component
       else
          playerstats.name:=readmemstr(ph, getmultilevelpointer(ph,[playermain+0x14,0x10]),100,"utf-16") ; otherwise pointer to name is stored
    }
    
    readflasksdata(hwnd, byref flasksdata)
    {
       getwindowbasics(hwnd, mbase, ph)
       
       uibase:=getuibase(hwnd)
       
       if (!uibase) ;not ingame
          return
       
       flaskinvbase:=getmultilevelpointer(ph,[uibase+0x968,0x980,0x20])
    
       loop, 5
       {
          currflaskptr:=readmemuint(ph,flaskinvbase+(a_index-1)*4)
          if (currflaskptr!=0) ; there's a flask in said slot
          {
             flasksdata[a_index]:={}
    
             flaskchargesptr:=getmultilevelpointer(ph,[currflaskptr,4,0x1c,4,4,0xc])
             flasksdata[a_index].chargescurrent:=readmemuint(ph,flaskchargesptr+0xc)
             flasksdata[a_index].chargesperuse:=readmemuint(ph,readmemuint(ph,flaskchargesptr+8)+0xc)
             
             if (flasksdata[a_index].chargescurrent < flasksdata[a_index].chargesperuse) ; not enough charges in this flask to use it, don't bother
                continue
    
             flaskmetadataptr:=getmultilevelpointer(ph,[currflaskptr,0,8])
             flaskmetadatastr:=readmemstr(ph,flaskmetadataptr,70,"utf-16")
             flasktypestr:=substr(flaskmetadatastr,23)
             flasksdata[a_index].type:=flasktypestr
             
             flasklocalstatsptr:=getmultilevelpointer(ph,[currflaskptr,4,0x18,0x20,0xc])
             
             if instr(flasktypestr, "life")
             {
                flasksdata[a_index].hpregamount:=readmemuint(ph,flasklocalstatsptr+4)
                flasksdata[a_index].effectduration:=readmemuint(ph,flasklocalstatsptr+0xc)
             }
    
             if instr(flasktypestr, "mana")
             {
                flasksdata[a_index].manaregamount:=readmemuint(ph,flasklocalstatsptr+4)
                flasksdata[a_index].effectduration:=readmemuint(ph,flasklocalstatsptr+0xc)
             }
             
             if instr(flasktypestr, "hybrid")
             {
                flasksdata[a_index].hpregamount:=readmemuint(ph,flasklocalstatsptr+4)
                flasksdata[a_index].manaregamount:=readmemuint(ph,flasklocalstatsptr+0xc)
                flasksdata[a_index].effectduration:=readmemuint(ph,flasklocalstatsptr+0x14)
             }
    
             if instr(flasktypestr, "flaskutility")
             {
                flasksdata[a_index].effectduration:=readmemuint(ph,flasklocalstatsptr+0x4)
             }
          }
       }
    }
    
    isingame(hwnd)
    {
    	if (hwnd=0 || hwnd="")
    		return false
    	getwindowbasics(hwnd,mbase,ph)
    	if (mbase="" || mbase=0 || ph="" || ph=-1)
    		return false
    	fbase:=getframebase(hwnd)
    	if (fbase="" || fbase=0)
    		return false
    	localconnection:=readmemuint(ph,fbase+0xc0)
    	if (localconnection=0 || localconnection="")
    		return false
    	else
    		return true
    }
    
    setgamestatemenu(hwnd)
    {
    	if (hwnd=0 || hwnd="")
    		return false
    	getwindowbasics(hwnd,mbase,ph)
    	if (mbase="" || mbase=0 || ph="" || ph=-1)
    		return false
    	fbase:=getframebase(hwnd)
    	if (fbase="" || fbase=0)
    		return false
    	localconnection:=readmemuint(ph,fbase+0xc0)
    	if (localconnection!="" && localconnection!=0)
    	{
    		writememuint(ph,localconnection+0x2578,1)
    	}
    }
    
    readcursorscreenposition(hwnd,byref cx, byref cy)
    {
       getwindowbasics(hwnd,mbase,ph)
       if (mbase!=0 && ph && ph!=-1)
       {
          framebase:=getframebase(hwnd)
          cx:=readmemsint(ph,framebase+0x155c)
          cy:=readmemsint(ph,framebase+0x1560)
          return true
       }   
    }
    
    screentoclient(hwnd, byref x, byref y)
    {
        varsetcapacity(pt, 8)
        numput(x, pt, 0)
        numput(y, pt, 4)
        dllcall("screentoclient", "uint", hwnd, "uint", &pt)
        x := numget(pt, 0, "int")
        y := numget(pt, 4, "int")
       varsetcapacity(pt, 0)
    }
    
    getclientcoords(byref mx, byref my)
    {
       hwnd:=winactive("a")   
       coordmode, mouse, screen
       mousegetpos, mx, my
       screentoclient(hwnd,mx,my) ;get mouse pos relative to window client rect
    }
    
    getfractionalcoords(byref fx, byref fy)
    {
       hwnd:=winactive("a")
       
       if (!isingame(hwnd))
          getclientcoords(mx,my)
       else
          readcursorscreenposition(hwnd,mx,my)
       
       readclientresolution(hwnd,w,h)
       
       fx:=mx/w
       fy:=my/h
    }
    
    getclientcoordsfromfractional(hwnd, fx,fy, byref cx, byref cy)
    {
       readclientresolution(hwnd,w,h)
       cx:=fx*w
       cy:=fy*h      
    }
    
    quittologinscreen(hwnd)
    {	
    	if (!isingame(hwnd))
    	{
    		return
    	}
    	setgamestatemenu(hwnd)
    }
    
    getmaxchargesflaskoftype(byref flasksdata,typestr)
    {
       currmaxcharges:=0
       loop, 5
          if (instr(flasksdata[a_index].type,typestr))
          {
             if flasksdata[a_index].chargescurrent>currmaxcharges
             {
                currmaxi:=a_index
                currmaxcharges:=flasksdata[a_index].chargescurrent
             }
          }
       return currmaxi
    }
    
    autopotions()
    {
       global autopotionswatchdogperiod
       global lagcompensation
       global playerconfig
       global windowqueuedflaskeffects
       global cliname
       global cliexe
       global traynotifications
       global autoquitmode
       
       if (autopotionsstate!=true)
          return
    
       winget, winid, list, %cliname%
       
       loop, %winid%
       {
          
          winget, procmodulename, processname,  % "ahk_id" winid%a_index%
          
          if(procmodulename!=cliexe) ; got a window with title "path of exile" but exe is not client.exe, perhaps we have browser window open with poe site, ignore it
             continue
          
          if (!isingame(winid%a_index%)) ;not ingame
             continue
    		 
    	if (winid%a_index%=winactive("a"))
    	   thisid:=winactive("a")
          
          playerstats:={}
          readplayerstats(winid%a_index%, playerstats)
          
          if (playerstats.maxhp<1 || playerstats.currhp=0) ;dead, don't bother
             continue
    
          if (playerconfig.haskey(playerstats.name))
             currentconfig:=playerconfig[playerstats.name]
          else
             currentconfig:=playerconfig["default"]
             
          
          if playerstats.maxnshield>0
          {
             currnshieldratio:=playerstats.currnshield/playerstats.maxnshield
          }
          
          if (playerstats.maxhp>1)
          {
             currliferatio:=playerstats.currhp/(playerstats.maxhp-playerstats.reservedhpflat-playerstats.maxhp*playerstats.reservedhppercent/100)
          }
          
          if currentconfig.haszealotsoath
          {
             currliferatio:=currnshieldratio
          }
             
          if (playerstats.maxmana>0)
          {
             currmanaratio:=playerstats.currmana/(playerstats.maxmana-playerstats.reservedmanaflat-playerstats.maxmana*playerstats.reservedmanapercent/100)
          }
          
          if (currliferatio<currentconfig.minliferatiotoquit || currnshieldratio<currentconfig.minnshieldratiotoquit)
          {
             if (autoquitmode=0)
             {
                traytip, poe autopotions autoquit by closing window, specified min life reached, %a_space% , 2
                winkill, % "ahk_id" winid%a_index%
             }
             else if (autoquitmode=1)
             {
                quittologinscreen(winid%a_index%)
             }
    		 autoquit:=1
             continue
          }
          
          if (currentconfig.disableautopotions)
             continue
          
          flasksdata:=[]
          readflasksdata(winid%a_index%,flasksdata)
          
          winget, currpid, pid,  % "ahk_id" winid%a_index%
          hwnd:=winid%a_index%
          k="%hwnd%%currpid%"
          if (!windowqueuedflaskeffects.haskey(k))
          {
             windowqueuedflaskeffects[k]:={}
          }
          
          if (currliferatio<currentconfig.minliferatiotopopgranite || currnshieldratio<currentconfig.minnshieldratiotopopgranite)
             if ((!windowqueuedflaskeffects[k].haskey("granitequeueendtime")) || (a_tickcount>=(windowqueuedflaskeffects[k].granitequeueendtime-lagcompensation)))
                {
                   flasknum:=getmaxchargesflaskoftype(flasksdata,"flaskutility5") ; granite flask
                   if (flasknum!="")
                   {
                      if currentconfig.flaskconfig[flasknum].haskey("overrideflaskduration")
                         effectduration:=currentconfig.flaskconfig[flasknum].overrideflaskduration
                      else
                         effectduration:=flasksdata[flasknum].effectduration
                         
                      windowqueuedflaskeffects[k].granitequeueendtime:=a_tickcount+effectduration*100
    
                      if (traynotifications)
                      {
                         pname:=playerstats.name
                         traytip, poe autopotions popping granite flask %flasknum% on %pname%, %a_space% , 2
                      }
                      hkey:=currentconfig.flaskconfig[flasknum].hotkey
                      controlsend,,%hkey%, % "ahk_id" hwnd
                      break
                   }
                }
                   
          if (currliferatio=1)
             windowqueuedflaskeffects[k].hpqueueendtime:=a_tickcount
          
          if (currmanaratio=1)
             windowqueuedflaskeffects[k].manaqueueendtime:=a_tickcount
          
          if (currliferatio<currentconfig.minliferatiotodrink || (playerstats.currhp<currentconfig.minlifetodrink))
             if ((!windowqueuedflaskeffects[k].haskey("hpqueueendtime")) || (a_tickcount>=(windowqueuedflaskeffects[k].hpqueueendtime-lagcompensation)))
             {
                      tflasknum1:=getmaxchargesflaskoftype(flasksdata,"flasklife")
                      tflasknum2:=getmaxchargesflaskoftype(flasksdata,"flaskhybrid")
                      if ((tflasknum1!=) && (tflasknum2!=))
                         flasknum:=(flasksdata[tflasknum1].chargescurrent>flasksdata[tflasknum2].chargescurrent) ? Tflasknum1 : Tflasknum2
                      else
                      {
                         if (tflasknum1!="")
                            flasknum:=tflasknum1
                         if (tflasknum2!="")
                            flasknum:=tflasknum2
                      }
                      if (flasknum!="")
                      {
                         if currentconfig.flaskconfig[flasknum].haskey("overrideflaskduration")
                            effectduration:=currentconfig.flaskconfig[flasknum].overrideflaskduration
                         else
                            effectduration:=flasksdata[flasknum].effectduration
                         
                         if ((currentconfig.flaskconfig[flasknum].instantrecoveryonlowlife) && ((playerstats.currhp/playerstats.maxhp)<=0.35)) ; "low life" can be caused by auras hp reservation from blood magic
                            effectduration:=lagcompensation
                            
                         windowqueuedflaskeffects[k].hpqueueendtime:=a_tickcount+effectduration*100
                         if (flasksdata[flasknum].haskey("manaregamount")) ; hybrid flask
                            windowqueuedflaskeffects[k].manaqueueendtime:=a_tickcount+effectduration*100
    
                         if (traynotifications)
                         {
                            pname:=playerstats.name
                            traytip, poe autopotions sipping hp flask %flasknum% on %pname%, %a_space% , 2
                         }
                         hkey:=currentconfig.flaskconfig[flasknum].hotkey
                         controlsend,,%hkey%, % "ahk_id" hwnd
                         break
                      }
                }
    
          if (playerstats.maxmana>0 && (currmanaratio<currentconfig.minmanaratiotodrink || playerstats.currmana<currentconfig.minmanatodrink))      
             if ((!windowqueuedflaskeffects[k].haskey("manaqueueendtime")) || (a_tickcount>=(windowqueuedflaskeffects[k].manaqueueendtime-lagcompensation)))
             {
                   tflasknum1:=getmaxchargesflaskoftype(flasksdata,"flaskmana")
                   tflasknum2:=getmaxchargesflaskoftype(flasksdata,"flaskhybrid")
                   
                   if ((tflasknum1!=) && (tflasknum2!=))
                      flasknum:=(flasksdata[tflasknum1].chargescurrent>flasksdata[tflasknum2].chargescurrent) ? Tflasknum1 : Tflasknum2
                   else
                   {
                      if (tflasknum1!="")
                         flasknum:=tflasknum1
                      if (tflasknum2!="")
                         flasknum:=tflasknum2
                   }
    
                   if (flasknum!="")
                   {
                      if currentconfig.flaskconfig[flasknum].haskey("overrideflaskduration")
                         {
                            effectduration:=currentconfig.flaskconfig[flasknum].overrideflaskduration
                         }
                      else
                         effectduration:=flasksdata[flasknum].effectduration
    
                      if ((currentconfig.flaskconfig[flasknum].instantrecoveryonlowlife) && ((playerstats.currhp/playerstats.maxhp)<=0.35))
                         effectduration:=lagcompensation
                      
                      windowqueuedflaskeffects[k].manaqueueendtime:=a_tickcount+effectduration*100
                      if (flasksdata[flasknum].haskey("hpregamount")) ; hybrid flask
                         windowqueuedflaskeffects[k].hpqueueendtime:=a_tickcount+effectduration*100
                      
                      hkey:=currentconfig.flaskconfig[flasknum].hotkey
                      if (traynotifications)
                      {
                         pname:=playerstats.name
                         traytip, poe autopotions sipping mana flask %flasknum% on %pname%, %a_space% , 2
                      }
                      controlsend,,%hkey%, % "ahk_id" hwnd
                      break
                   }
             }               
       }
       
        if ((autoquit=1) && (thisid!="") && (thisid!=winactive("a")))
          winactivate, % "ahk_id" thisid
    
       sleep, %autopotionswatchdogperiod%   
    }
    
    f1::
       Global autopotionsstate
       global traynotifications
       autopotionsstate:=not autopotionsstate
       if (traynotifications)
       {
          if (autopotionsstate=true)
             traytip, poe autopotions is on, %a_space% , 2
          else
             traytip, poe autopotions is off, %a_space%  , 2
       }
    return
    
    f2::
       Getclientcoords(mx,my)
       getfractionalcoords(fx,fy)
       msgbox, mx=%mx% my=%my% fx=%fx% fy=%fy%
    return
    
    f4::
       Quittologinscreen(winactive("a"))
    return

    ty mate! I love you ur great!

  14. #374
    blacklider's Avatar Member
    Reputation
    1
    Join Date
    Jun 2013
    Posts
    30
    Thanks G/R
    1/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks you so much !! Works again !!

  15. #375
    rolandxcalibur8's Avatar Member
    Reputation
    1
    Join Date
    Nov 2009
    Posts
    12
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there any way we can get this working for the steam version of 1.0.1? Please, and thank you!

    Originally Posted by DXENEME View Post
    EDIT: Fixed it, for anyone who's a derp like me heres the working script.

    Code:
    SetBatchLines, -1
    DetectHiddenWindows, On
    
    cliname=Path of Exile
    cliexe=PathOfExile.exe
    trayNotifications:=true ;display tray notifications about script actions : drinking potions, autoquitting
    autoPotionsWatchdogPeriod:=100 ;milliseconds, decrease this value to have script recheck life/mana/flasks availability more often/increase chances of getting saved from death in time
    lagCompensation:=50
    
    autoQuitMode:=1 ; default autoQuit method : 0 =winKill, 1 = exit to login screen
    autoQuitPauseBeforeClick:=100
    autoQuitSoftToleranceBeforeKill:=2000 ; try to quit to loginscreen at most milliseconds before killing game window(in case we can't quit by clicking menu option for some reason)
    
    PlayerConfig:={}
    PlayerConfig["Default"]:={minLifeRatioToDrink: 0.45, minManaRatioToDrink: 0.55, minManaToDrink: 40, minLifeRatioToPopGranite: 0.65, minLifeRatioToQuit: 0.35} ;  disableAutoPotions:true, minLifeRatioToQuit:, minNShieldRatioToQuit: , HasZealotsOath: false, }
    
    PlayerConfig["Default"].FlaskConfig:=[]
    
    PlayerConfig["Default"].FlaskConfig[1]:={Hotkey:"{1 Down 1 UP}"} ; ,OverrideFlaskDuration:70, instantRecoveryOnLowLife:true, } ;specify override recovery time in deciseconds, e.g. 7 seconds = 70
    PlayerConfig["Default"].FlaskConfig[2]:={Hotkey:"{2 Down 2 UP}"}
    PlayerConfig["Default"].FlaskConfig[3]:={Hotkey:"{3 Down 3 UP}"}
    PlayerConfig["Default"].FlaskConfig[4]:={Hotkey:"{4 Down 4 UP}"}
    PlayerConfig["Default"].FlaskConfig[5]:={Hotkey:"{5 Down 5 UP}"}
    
    PlayerConfig["YourHardcorePlayerName"]:={minLifeRatioToDrink: 0.7, minManaRatioToDrink: 0.35, minManaToDrink: 70, minLifeRatioToQuit: 0.4}
    PlayerConfig["YourHardcorePlayerName"].FlaskConfig:=[]
    PlayerConfig["YourHardcorePlayerName"].FlaskConfig[1]:={Hotkey:"{1 Down 1 UP}"}
    PlayerConfig["YourHardcorePlayerName"].FlaskConfig[2]:={Hotkey:"{2 Down 2 UP}"}
    PlayerConfig["YourHardcorePlayerName"].FlaskConfig[3]:={Hotkey:"{3 Down 3 UP}"}
    PlayerConfig["YourHardcorePlayerName"].FlaskConfig[4]:={Hotkey:"{4 Down 4 UP}"}
    PlayerConfig["YourHardcorePlayerName"].FlaskConfig[5]:={Hotkey:"{5 Down 5 UP}"}
    
    autoPotionsState:=true
    
    WindowQueuedFlaskEffects:=[] ;keyed by "%hwnd%%CurrPid%", hpQueueEndtime, manaQueueEndtime
    
    baseMgrPtr:=0x78fd54 ; 0.11.3b delete for script to try to auto-scan for it in newer versions, scan takes 4-5 seconds
    
    basePtrAoBArray:=[0x6A,0xFF,0x68,"?","?","?","?",0x50,0x64,"?","?","?","?","?","?",0xA1,"?","?","?","?",0x81,0xEC,"?","?","?","?",0x53,0x55,0x56,0x57,0x33,0xFF,0x3B,0xC7]
    basePtrAobOffset:=0x10
    
    WindowBasicsCache:=[] ; keyed by "%hwnd%%CurrPid%", entries are objects with properties processHandle, moduleBase, moduleSize, baseFramePtr
    
    #Include AutoHotkeyMemoryLib.ahk
    
    Loop
    {
       AutoPotions()
    }
    
    GetWindowBasics(hwnd, byref mB="", byref pH="", byref mS="")
    {
       
       global WindowBasicsCache
       global cliexe
       
       WinGet, CurrPid, PID, ahk_id %hwnd%
       
       k="%hwnd%%CurrPid%"
       
       mB:=WindowBasicsCache[k].mBase
       mS:=WindowBasicsCache[k].mSize
       
       if mB=
       {
          WindowBasicsCache[k]:=Object()
          GetModuleInfo(cliexe, CurrPid, mB, mS)
          if (mB="" || mS="")
          {
             MsgBox, Failed to obtain moduleBase or moduleSize for PID %CurrPid%, script will now terminate
             ExitApp
          }      
          WindowBasicsCache[k].mBase:=mB
          WindowBasicsCache[k].mSize:=mS
       }
    
       pH:=WindowBasicsCache[k].ProcessHandle
       if pH=
       {
          pH:=GetProcessHandle(CurrPid)
          if (pH="" || pH=-1)
          {
             MsgBox, Invalid process handle obtained for PID %CurrPid%, script will now terminate
             ExitApp
          }      
          WindowBasicsCache[k].ProcessHandle:=pH
       }
    }
    
    ScanBaseMgrPtr(mBase,pH,moduleSize)
    {
       global basePtrAoBArray
       global basePtrAobOffset
       global baseMgrPtr
       aobResult:=AobScan(pH,mBase,moduleSize,basePtrAoBArray)
    
       if aobResult
       {
          SetFormat, IntegerFast, hex
          baseMgrPtr:=ReadMemUInt(pH,mBase+aobResult+basePtrAobOffset)-mBase
          MsgBox, PoE Base ptr found with AoB Scan baseMgrPtr = %baseMgrPtr%, save this value to script for quick startup
          SetFormat, IntegerFast, dec
       }
       else
       {
          MsgBox, baseMgrPtr not found with AoBScan, script will now terminate
          ExitApp
       }   
    }
    
    GetFrameBase(hwnd)
    {
       global baseMgrPtr
       global WindowBasicsCache
    
       WinGet, CurrPid, PID, ahk_id %hwnd%
       k="%hwnd%%CurrPid%"
    
       fB:=WindowBasicsCache[k].fBase
    
       if fB=
       {
          GetWindowBasics(hwnd, mBase, pH, mSize)
    
          if baseMgrPtr=
          {
             ScanBaseMgrPtr(mBase, pH, mSize)
          }
    
          fB:=GetMultilevelPointer(pH,[mBase+baseMgrPtr,4,0x7C,0x94])
          WindowBasicsCache[k].fBase:=fB
       }
       return fB
    }
    
    GetUiBase(hwnd)
    {
       global baseMgrPtr
    
          GetWindowBasics(hwnd, mBase, pH, mSize)
          
          if baseMgrPtr=
          {
             ScanBaseMgrPtr(mBase, pH, mSize)
          }
          
    	FrameBase:=GetFrameBase(hwnd)
    	if (FrameBase="" || FrameBase=0)
    		return
    	uiBase:=GetMultilevelPointer(pH,[FrameBase+0xBC,0xA4,0x50])
    	return uiBase
    }
    
    ReadClientResolution(hwnd, ByRef w, ByRef h)
    {
       GetWindowBasics(hwnd,mBase,pH)
       if (mBase!=0 && pH && pH!=-1)
       {
          FrameBase:=GetFrameBase(hwnd)
          w:=ReadMemUInt(pH,FrameBase+0x1340)
          h:=ReadMemUInt(pH,FrameBase+0x1344)
          return true
       }   
    }
    
    ReadPlayerStats(hwnd, byRef PlayerStats)
    {
       GetWindowBasics(hwnd, mBase, pH)
       fBase:=GetFrameBase(hwnd)
       PlayerBase:=GetMultilevelPointer(pH,[fBase+0xBC,0x59C])
       PlayerMain:=ReadMemUInt(pH,PlayerBase+4)
       PlayerStatsOffset:=ReadMemUInt(pH,PlayerMain+0xC)
    	PlayerStats.MaxHP:=ReadMemUInt(pH,PlayerStatsOffset+0x50)
    	PlayerStats.CurrHP:=ReadMemUInt(pH,PlayerStatsOffset+0x54)	
    	PlayerStats.ReservedHPFlat:=ReadMemUInt(pH,PlayerStatsOffset+0x5C)
    	PlayerStats.ReservedHPPercent:=ReadMemUInt(pH,PlayerStatsOffset+0x60)
    	PlayerStats.MaxMana:=ReadMemUInt(pH,PlayerStatsOffset+0x74)
    	PlayerStats.ReservedManaFlat:=ReadMemUInt(pH,PlayerStatsOffset+0x80)
    	PlayerStats.ReservedManaPercent:=ReadMemUInt(pH,PlayerStatsOffset+0x84)
    	PlayerStats.CurrMana:=ReadMemUInt(pH,PlayerStatsOffset+0x78)
    	PlayerStats.MaxNShield:=ReadMemUInt(pH,PlayerStatsOffset+0x98)
    	PlayerStats.CurrNShield:=ReadMemUInt(pH,PlayerStatsOffset+0x9C)
       
       if (ReadMemUInt(pH, ReadMemUInt(pH,PlayerMain+0x14)+0x24)<8) ;names shorter than 7 chars are stored immediately in component
          PlayerStats.Name:=ReadMemStr(pH, ReadMemUint(pH,PlayerMain+0x14)+0x10,100,"UTF-16") ;immediate name in component
       else
          PlayerStats.Name:=ReadMemStr(pH, GetMultilevelPointer(pH,[PlayerMain+0x14,0x10]),100,"UTF-16") ; otherwise pointer to name is stored
    }
    
    ReadFlasksData(hwnd, byRef FlasksData)
    {
       GetWindowBasics(hwnd, mBase, pH)
       
       UiBase:=GetUiBase(hwnd)
       
       if (!UiBase) ;not InGame
          return
       
       FlaskInvBase:=GetMultilevelPointer(pH,[UiBase+0x968,0x980,0x20])
    
       Loop, 5
       {
          currFlaskPtr:=ReadMemUInt(pH,FlaskInvBase+(A_Index-1)*4)
          if (currFlaskPtr!=0) ; there's a flask in said slot
          {
             FlasksData[A_Index]:={}
    
             FlaskChargesPtr:=GetMultilevelPointer(ph,[currFlaskPtr,4,0x1C,4,4,0xC])
             FlasksData[A_Index].ChargesCurrent:=ReadMemUInt(pH,FlaskChargesPtr+0xC)
             FlasksData[A_Index].ChargesPerUse:=ReadMemUInt(pH,ReadMemUInt(pH,FlaskChargesPtr+8)+0xC)
             
             if (FlasksData[A_Index].ChargesCurrent < FlasksData[A_Index].ChargesPerUse) ; not enough charges in this flask to use it, don't bother
                continue
    
             FlaskMetadataPtr:=GetMultilevelPointer(ph,[currFlaskPtr,0,8])
             FlaskMetadataStr:=ReadMemStr(ph,FlaskMetadataPtr,70,"UTF-16")
             FlaskTypeStr:=SubStr(FlaskMetadataStr,23)
             FlasksData[A_Index].type:=FlaskTypeStr
             
             FlaskLocalstatsPtr:=GetMultilevelPointer(ph,[currFlaskPtr,4,0x18,0x20,0xC])
             
             if InStr(FlaskTypeStr, "Life")
             {
                FlasksData[A_Index].HPRegAmount:=ReadMemUInt(pH,FlaskLocalstatsPtr+4)
                FlasksData[A_Index].EffectDuration:=ReadMemUInt(pH,FlaskLocalstatsPtr+0xC)
             }
    
             if InStr(FlaskTypeStr, "Mana")
             {
                FlasksData[A_Index].ManaRegAmount:=ReadMemUInt(pH,FlaskLocalstatsPtr+4)
                FlasksData[A_Index].EffectDuration:=ReadMemUInt(pH,FlaskLocalstatsPtr+0xC)
             }
             
             if InStr(FlaskTypeStr, "Hybrid")
             {
                FlasksData[A_Index].HPRegAmount:=ReadMemUInt(pH,FlaskLocalstatsPtr+4)
                FlasksData[A_Index].ManaRegAmount:=ReadMemUInt(pH,FlaskLocalstatsPtr+0xC)
                FlasksData[A_Index].EffectDuration:=ReadMemUInt(pH,FlaskLocalstatsPtr+0x14)
             }
    
             if InStr(FlaskTypeStr, "FlaskUtility")
             {
                FlasksData[A_Index].EffectDuration:=ReadMemUInt(pH,FlaskLocalstatsPtr+0x4)
             }
          }
       }
    }
    
    IsInGame(hwnd)
    {
    	if (hwnd=0 || hwnd="")
    		return false
    	GetWindowBasics(hwnd,mBase,pH)
    	if (mBase="" || mBase=0 || pH="" || pH=-1)
    		return false
    	fBase:=GetFrameBase(hwnd)
    	if (fBase="" || fBase=0)
    		return false
    	localConnection:=ReadMemUInt(pH,fBase+0xc0)
    	if (localConnection=0 || localConnection="")
    		return false
    	else
    		return true
    }
    
    SetGameStateMenu(hwnd)
    {
    	if (hwnd=0 || hwnd="")
    		return false
    	GetWindowBasics(hwnd,mBase,pH)
    	if (mBase="" || mBase=0 || pH="" || pH=-1)
    		return false
    	fBase:=GetFrameBase(hwnd)
    	if (fBase="" || fBase=0)
    		return false
    	localConnection:=ReadMemUInt(pH,fBase+0xc0)
    	if (localConnection!="" && localConnection!=0)
    	{
    		WriteMemUInt(pH,localConnection+0x2578,1)
    	}
    }
    
    ReadCursorScreenPosition(hwnd,ByRef cX, ByRef cY)
    {
       GetWindowBasics(hwnd,mBase,pH)
       if (mBase!=0 && pH && pH!=-1)
       {
          FrameBase:=GetFrameBase(hwnd)
          cX:=ReadMemSInt(pH,FrameBase+0x155c)
          cY:=ReadMemSInt(pH,FrameBase+0x1560)
          return true
       }   
    }
    
    ScreenToClient(hwnd, ByRef x, ByRef y)
    {
        VarSetCapacity(pt, 8)
        NumPut(x, pt, 0)
        NumPut(y, pt, 4)
        DllCall("ScreenToClient", "uint", hwnd, "uint", &pt)
        x := NumGet(pt, 0, "int")
        y := NumGet(pt, 4, "int")
       VarSetCapacity(pt, 0)
    }
    
    GetClientCoords(byRef mx, byRef my)
    {
       hwnd:=WinActive("A")   
       CoordMode, Mouse, Screen
       MouseGetPos, mx, my
       ScreenToClient(hwnd,mx,my) ;get mouse pos relative to window client rect
    }
    
    GetFractionalCoords(ByRef fX, ByRef fY)
    {
       hwnd:=WinActive("A")
       
       if (!IsInGame(hwnd))
          GetClientCoords(mx,my)
       else
          ReadCursorScreenPosition(hwnd,mx,my)
       
       ReadClientResolution(hwnd,w,h)
       
       fX:=mx/w
       fY:=my/h
    }
    
    GetClientCoordsFromFractional(hwnd, fX,fY, ByRef cX, ByRef cY)
    {
       ReadClientResolution(hwnd,w,h)
       cX:=fX*w
       cY:=fY*h      
    }
    
    QuitToLoginScreen(hwnd)
    {	
    	if (!IsInGame(hwnd))
    	{
    		return
    	}
    	SetGameStateMenu(hwnd)
    }
    
    GetMaxChargesFlaskOfType(ByRef FlasksData,TypeStr)
    {
       currMaxCharges:=0
       Loop, 5
          if (InStr(FlasksData[A_Index].type,TypeStr))
          {
             if FlasksData[A_Index].ChargesCurrent>currMaxCharges
             {
                currMaxI:=A_Index
                currMaxCharges:=FlasksData[A_Index].ChargesCurrent
             }
          }
       return currMaxI
    }
    
    AutoPotions()
    {
       global autoPotionsWatchdogPeriod
       global lagCompensation
       global PlayerConfig
       global WindowQueuedFlaskEffects
       global cliname
       global cliexe
       global trayNotifications
       global autoQuitMode
       
       if (autoPotionsState!=true)
          return
    
       WinGet, WinID, List, %cliname%
       
       Loop, %WinID%
       {
          
          WinGet, ProcModuleName, ProcessName,  % "ahk_id" WinID%A_Index%
          
          If(ProcModuleName!=cliexe) ; got a window with title "Path of Exile" but exe is not Client.exe, perhaps we have browser window open with PoE site, ignore it
             continue
          
          if (!IsInGame(WinID%A_Index%)) ;not ingame
             continue
    		 
    	if (WinID%A_Index%=WinActive("A"))
    	   ThisID:=WinActive("A")
          
          PlayerStats:={}
          ReadPlayerStats(WinID%A_Index%, PlayerStats)
          
          if (PlayerStats.MaxHP<1 || PlayerStats.CurrHP=0) ;dead, don't bother
             continue
    
          if (PlayerConfig.HasKey(PlayerStats.Name))
             CurrentConfig:=PlayerConfig[PlayerStats.Name]
          else
             CurrentConfig:=PlayerConfig["Default"]
             
          
          if PlayerStats.MaxNShield>0
          {
             currNShieldRatio:=PlayerStats.CurrNShield/PlayerStats.MaxNShield
          }
          
          if (PlayerStats.MaxHP>1)
          {
             currLifeRatio:=PlayerStats.CurrHP/(PlayerStats.MaxHP-PlayerStats.ReservedHPFlat-PlayerStats.MaxHP*PlayerStats.ReservedHPPercent/100)
          }
          
          if CurrentConfig.HasZealotsOath
          {
             currLifeRatio:=currNShieldRatio
          }
             
          if (PlayerStats.MaxMana>0)
          {
             currManaRatio:=PlayerStats.CurrMana/(PlayerStats.MaxMana-PlayerStats.ReservedManaFlat-PlayerStats.MaxMana*PlayerStats.ReservedManaPercent/100)
          }
          
          if (currLifeRatio<CurrentConfig.minLifeRatioToQuit || currNShieldRatio<CurrentConfig.minNShieldRatioToQuit)
          {
             if (autoQuitMode=0)
             {
                TrayTip, PoE autoPotions AutoQuit by closing window, specified min life reached, %A_Space% , 2
                WinKill, % "ahk_id" WinID%A_Index%
             }
             else if (autoQuitMode=1)
             {
                QuitToLoginScreen(WinID%A_Index%)
             }
    		 autoQuit:=1
             continue
          }
          
          if (CurrentConfig.disableAutoPotions)
             continue
          
          FlasksData:=[]
          ReadFlasksData(WinID%A_Index%,FlasksData)
          
          WinGet, CurrPID, PID,  % "ahk_id" WinID%A_Index%
          hwnd:=WinID%A_Index%
          k="%hwnd%%CurrPid%"
          if (!WindowQueuedFlaskEffects.HasKey(k))
          {
             WindowQueuedFlaskEffects[k]:={}
          }
          
          if (currLifeRatio<CurrentConfig.minLifeRatioToPopGranite || currNShieldRatio<CurrentConfig.minNShieldRatioToPopGranite)
             if ((!WindowQueuedFlaskEffects[k].HasKey("graniteQueueEndtime")) || (A_TickCount>=(WindowQueuedFlaskEffects[k].graniteQueueEndtime-lagCompensation)))
                {
                   flaskNum:=GetMaxChargesFlaskOfType(FlasksData,"FlaskUtility5") ; granite flask
                   if (flaskNum!="")
                   {
                      if CurrentConfig.FlaskConfig[flaskNum].HasKey("OverrideFlaskDuration")
                         EffectDuration:=CurrentConfig.FlaskConfig[flaskNum].OverrideFlaskDuration
                      else
                         EffectDuration:=FlasksData[flaskNum].EffectDuration
                         
                      WindowQueuedFlaskEffects[k].graniteQueueEndtime:=A_TickCount+EffectDuration*100
    
                      if (trayNotifications)
                      {
                         pname:=PlayerStats.Name
                         TrayTip, PoE autoPotions popping Granite flask %flaskNum% on %pname%, %A_Space% , 2
                      }
                      hKey:=CurrentConfig.FlaskConfig[flaskNum].Hotkey
                      ControlSend,,%hkey%, % "ahk_id" hwnd
                      break
                   }
                }
                   
          if (currLifeRatio=1)
             WindowQueuedFlaskEffects[k].hpQueueEndtime:=A_TickCount
          
          if (currManaRatio=1)
             WindowQueuedFlaskEffects[k].ManaQueueEndtime:=A_TickCount
          
          if (currLifeRatio<CurrentConfig.minLifeRatioToDrink || (PlayerStats.CurrHP<CurrentConfig.minLifeToDrink))
             if ((!WindowQueuedFlaskEffects[k].HasKey("hpQueueEndtime")) || (A_TickCount>=(WindowQueuedFlaskEffects[k].hpQueueEndtime-lagCompensation)))
             {
                      tflaskNum1:=GetMaxChargesFlaskOfType(FlasksData,"FlaskLife")
                      tflaskNum2:=GetMaxChargesFlaskOfType(FlasksData,"FlaskHybrid")
                      if ((tflaskNum1!=) && (tflaskNum2!=))
                         flaskNum:=(FlasksData[tflaskNum1].ChargesCurrent>FlasksData[tflaskNum2].ChargesCurrent) ? tflaskNum1 : tflaskNum2
                      else
                      {
                         if (tflaskNum1!="")
                            flaskNum:=tflaskNum1
                         if (tflaskNum2!="")
                            flaskNum:=tflaskNum2
                      }
                      if (flaskNum!="")
                      {
                         if CurrentConfig.FlaskConfig[flaskNum].HasKey("OverrideFlaskDuration")
                            EffectDuration:=CurrentConfig.FlaskConfig[flaskNum].OverrideFlaskDuration
                         else
                            EffectDuration:=FlasksData[flaskNum].EffectDuration
                         
                         if ((CurrentConfig.FlaskConfig[flaskNum].instantRecoveryOnLowLife) && ((PlayerStats.CurrHP/PlayerStats.MaxHP)<=0.35)) ; "Low life" can be caused by auras hp reservation from blood magic
                            EffectDuration:=lagCompensation
                            
                         WindowQueuedFlaskEffects[k].hpQueueEndtime:=A_TickCount+EffectDuration*100
                         if (FlasksData[flaskNum].HasKey("ManaRegAmount")) ; hybrid flask
                            WindowQueuedFlaskEffects[k].ManaQueueEndtime:=A_TickCount+EffectDuration*100
    
                         if (trayNotifications)
                         {
                            pname:=PlayerStats.Name
                            TrayTip, PoE autoPotions sipping HP flask %flaskNum% on %pname%, %A_Space% , 2
                         }
                         hKey:=CurrentConfig.FlaskConfig[flaskNum].Hotkey
                         ControlSend,,%hkey%, % "ahk_id" hwnd
                         break
                      }
                }
    
          if (PlayerStats.MaxMana>0 && (currManaRatio<CurrentConfig.minManaRatioToDrink || PlayerStats.CurrMana<CurrentConfig.minManaToDrink))      
             if ((!WindowQueuedFlaskEffects[k].HasKey("ManaQueueEndtime")) || (A_TickCount>=(WindowQueuedFlaskEffects[k].ManaQueueEndtime-lagCompensation)))
             {
                   tflaskNum1:=GetMaxChargesFlaskOfType(FlasksData,"FlaskMana")
                   tflaskNum2:=GetMaxChargesFlaskOfType(FlasksData,"FlaskHybrid")
                   
                   if ((tflaskNum1!=) && (tflaskNum2!=))
                      flaskNum:=(FlasksData[tflaskNum1].ChargesCurrent>FlasksData[tflaskNum2].ChargesCurrent) ? tflaskNum1 : tflaskNum2
                   else
                   {
                      if (tflaskNum1!="")
                         flaskNum:=tflaskNum1
                      if (tflaskNum2!="")
                         flaskNum:=tflaskNum2
                   }
    
                   if (flaskNum!="")
                   {
                      if CurrentConfig.FlaskConfig[flaskNum].HasKey("OverrideFlaskDuration")
                         {
                            EffectDuration:=CurrentConfig.FlaskConfig[flaskNum].OverrideFlaskDuration
                         }
                      else
                         EffectDuration:=FlasksData[flaskNum].EffectDuration
    
                      if ((CurrentConfig.FlaskConfig[flaskNum].instantRecoveryOnLowLife) && ((PlayerStats.CurrHP/PlayerStats.MaxHP)<=0.35))
                         EffectDuration:=lagCompensation
                      
                      WindowQueuedFlaskEffects[k].ManaQueueEndtime:=A_TickCount+EffectDuration*100
                      if (FlasksData[flaskNum].HasKey("HPRegAmount")) ; hybrid flask
                         WindowQueuedFlaskEffects[k].hpQueueEndtime:=A_TickCount+EffectDuration*100
                      
                      hKey:=CurrentConfig.FlaskConfig[flaskNum].Hotkey
                      if (trayNotifications)
                      {
                         pname:=PlayerStats.Name
                         TrayTip, PoE autoPotions sipping mana flask %flaskNum% on %pname%, %A_Space% , 2
                      }
                      ControlSend,,%hkey%, % "ahk_id" hwnd
                      break
                   }
             }               
       }
       
        if ((autoQuit=1) && (ThisID!="") && (ThisID!=WinActive("A")))
          WinActivate, % "ahk_id" ThisID
    
       Sleep, %autoPotionsWatchdogPeriod%   
    }
    
    F1::
       global autoPotionsState
       global trayNotifications
       autoPotionsState:=not autoPotionsState
       if (trayNotifications)
       {
          if (autoPotionsState=true)
             TrayTip, PoE autoPotions is on, %A_Space% , 2
          else
             TrayTip, PoE autoPotions is off, %A_Space%  , 2
       }
    return
    
    F2::
       GetClientCoords(mx,my)
       GetFractionalCoords(fx,fy)
       msgbox, mx=%mx% my=%my% fx=%fx% fy=%fy%
    return
    
    F4::
       QuitToLoginScreen(WinActive("A"))
    return

Page 25 of 32 FirstFirst ... 212223242526272829 ... LastLast

Similar Threads

  1. [Release] Custom scripts
    By ion564 in forum World of Warcraft Emulator Servers
    Replies: 20
    Last Post: 05-12-2008, 07:02 PM
  2. [Release] WarsongGulch Script
    By Pragma in forum World of Warcraft Emulator Servers
    Replies: 33
    Last Post: 03-23-2008, 08:07 PM
  3. [Release] |Custom Scripted Instance| Shadow Lair
    By wurstbr0t in forum World of Warcraft Emulator Servers
    Replies: 18
    Last Post: 03-05-2008, 12:03 PM
  4. [RELEASE]Ascent/script compiles 3710 (latest 2/6/08)
    By vivec45 in forum WoW EMU Guides & Tutorials
    Replies: 0
    Last Post: 02-06-2008, 07:04 AM
  5. [RELEASE] FunServer Script's ( + Level Cap 80-255 )
    By ~SaiLyn~ in forum World of Warcraft Emulator Servers
    Replies: 36
    Last Post: 01-10-2008, 02:44 PM
All times are GMT -5. The time now is 03:11 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search