Code:
#SingleInstance force
;https://github.com/Kalamity/classMemory : memory reading library
#Include classMemory.ahk
SetFormat, Integer, hex
;=================startup load the frameBase (IngameState)===============
;https://github.com/TehCheat/PoEHUD/tree/x64/src/Poe/Offsets.cs: private static readonly Pattern basePtrPattern = new Pattern(new byte[]
basePtrPattern:=[0x40, 0x53, 0x48, 0x83, 0xEC, 0x50, 0x48, 0xC7, 0x44, 0x24, 0x20, 0xFE, 0xFF, 0xFF, 0xFF, 0xC7, 0x44, 0x24, 0x60, 0x00, 0x00, 0x00, 0x00, 0x48, 0x8b, 0x05]
cliexe:="PathOfExile_x64.exe"
while WinID!=1
{
;waiting for the game
WinGet, WinID, List, ahk_exe %cliexe%
Sleep, 1000
}
global poe := new _ClassMemory("ahk_exe " . cliexe, "", hProcessCopy)
PatternIsAt:=poe.modulePatternScan(cliexe, basePtrPattern*)-poe.BaseAddress
;https://github.com/TehCheat/PoEHUD/tree/x64/src/Poe/Offsets.cs : Base = m.ReadInt(m.AddressOfProcess + array[0] + 0x1A) + array[0] + 0x1E;
baseMgrPtr:=poe.read(poe.BaseAddress+PatternIsAt+0x1A, "UInt")+PatternIsAt+0x1E
;https://github.com/TehCheat/PoEHUD/tree/x64/src/Poe/RemoteMemoryObjects/TheGame.cs : Address = m.ReadLong(Offsets.Base + m.AddressOfProcess, 0x8, 0xf8);
;https://github.com/TehCheat/PoEHUD/tree/x64/src/Poe/RemoteMemoryObjects/TheGame.cs : public IngameState IngameState => ReadObject<IngameState>(Address + 0x38);
global frameBase:=poe.read(poe.BaseAddress+baseMgrPtr, "Int64", 0x8, 0xf8, 0x38)
global IngameState:=frameBase
;=======================retrieve current data============================
readPlayerStats(byRef PlayerStats){
;https://github.com/TehCheat/PoEHUD/tree/x64/src/Poe/RemoteMemoryObjects/IngameState.cs : public IngameData Data => ReadObject<IngameData>(Address + 0x160 + Offsets.IgsOffset);
InGameData:=poe.read(IngameState+0x160, "Int64")
PlayerStats.isInGame:=False
if(InGameData>0xffff){
PlayerStats.isInGame:=True
;https://github.com/TehCheat/PoEHUD/tree/x64/src/Poe/RemoteMemoryObjects/IngameData.cs : public Entity LocalPlayer => ReadObject<Entity>(Address + 0x180);
LocalPlayer:=poe.read(InGameData+0x180, "Int64")
;https://github.com/badplayerr/beta-autopot/blob/master/Autopot.ahk : PlayerMain:=ReadMemUInt(pH,PlayerBase+4) PlayerStatsOffset:=ReadMemUInt(pH,PlayerMain+0xC)
LPLifeComponent:=poe.read(LocalPlayer+0x8, "Int64", 0x18)
;https://github.com/TehCheat/PoEHUD/tree/x64/src/Poe/Components/Life.cs : public int CurHP => Address != 0 ? M.ReadInt(Address + 0x54) : 1; public int CurMana => Address != 0 ? M.ReadInt(Address + 0x84) : 1;
poe.readRaw(LPLifeComponent, LifeStructure, 0xB8)
curHP:=NumGet(LifeStructure, 0x54, "UInt")
maxHP:=NumGet(LifeStructure, 0x50, "UInt")
if(maxHP>0 and curHP>0){
PlayerStats.hp:=(curHP*1.0)/(maxHP*1.0)
}else{
PlayerStats.hp:=0.0
}
}
}
;==========================main program loop===============================
lastPopo:=A_TickCount
PlayerStats:=Object()
loop
{
readPlayerStats(PlayerStats)
if(PlayerStats.isInGame=True){
if(PlayerStats.hp>0.0){
now:=A_TickCount
if((PlayerStats.hp<0.8 and now-lastPopo>5000) or (PlayerStats.hp<0.4 and now-lastPopo>1000)){
lastPopo:=now
Send, {1 Down}
Sleep, 30
Send, {1 Up}
}
}
}
Sleep, 30
}
;============================================================================
SC029 & NumpadSub::
ExitApp
Return
SC029 & NumpadAdd::
reload
Return
You'll need to install/reinstall the 64 bits autoHotKey_L to test it. It'll pop the flask in your slot 1 whenever you're health drops under 80%/40% if this works. Also note that most useful information for your bots can be very easily fetched starting from the frameBase (IngameState) in PoE. So that's the important pointer to find for reference or dumb scanning, before the health/mana/.. data.