Code: Select all
IF NOT A_IsAdmin
{
Run *RunAs "%A_ScriptFullPath%"
ExitApp
}
#Include, memory.ahk
#SingleInstance force
WinGet, id, List, BlankTK
;Rename fighters client to "Hunter" or change it in the script
WinGet, Hunter, PID, Hunter
hwnd1 := MemoryOpenFromPID(Hunter)
SelfVita = 0x6FE238
;Main client vitality address
SelfCVOff = 0x104
;current vita offset
SelfMVOff = 0x108
;max vita offset
SelfMana = 0x6FE238
SelfCMOff = 0x10C
SelfMMOff = 0x110
;same as vita
;rename poet client to "Shifter" Or change it in the script
WinGet, Shifter, PID, Shifter
hwnd2 := MemoryOpenFromPID(Shifter)
2SelfVita = 0x6FE238
2SelfCVOff = 0x104
2SelfMVOff = 0x108
;Same as the above but for the 2nd client
2SelfMana = 0x6FE238
2SelfCMOff = 0x10C
2SelfMMOff = 0x110
;same as the above but for the 2nd client
Cast:
Loop
{
2SselfMana2 := MemoryReadPointer(hwnd1,2SelfMana, "int",,1,2SelfCMOff)
;2nd client current mana
2SselfmMana2 := MemoryReadPointer(hwnd1,2SelfMana, "int",,1,2SelfMMOff)
;2nd client max mana
2SselfVita2 := MemoryReadPointer(hwnd1,2SelfVita, "int",,1,2SelfCVOff)
;2nd client current vita
2SselfmVita2 := MemoryReadPointer(hwnd1,2SelfVita, "int",,1,2SelfMVOff)
;2nd client max vita
SselfVita2 := MemoryReadPointer(hwnd2,SelfVita, "int",,1,SelfCVOff)
;1st client current vita
SselfmVita2 := MemoryReadPointer(hwnd2,SelfVita, "int",,1,SelfMVOff)
;1st client max vita
SselfMana2 := MemoryReadPointer(hwnd2,SelfMana, "int",,1,SelfCMOff)
;1st client current mana
SselfmMana2 := MemoryReadPointer(hwnd2,SelfMana, "int",,1,SelfMMOff)
;1st client max mana
ManaPercentP := ((SselfmMana2 - SselfMana2)/SselfmMana2*100)
VitaPercentF := ((2SselfmVita2 - 2SselfVita2)/2SselfmVita2*100)
VitaPercentP := ((SselfmVita2 - SselfVita2)/SselfmVita2*100)
ManaPercentF := ((2SselfmMana2 - 2SselfMana2)/2SselfmMana2*100)
;P= poet F= fighter
;This basically turns the values into the actual % value for an easy to use var
If ((ManaPercentP >= 75))
ControlSend,, {Escape}{3}, Shifter
;If the poets mana is 25% or less we invoke to refill mana
If ((VitaPercentF >= 60) AND (ManaPercentP < 95))
ControlSend,, {Escape}{Shift Down}{z}{s}{Shift Up}{1}, Shifter
;If fighters vita is below 40% and poets mana is above 5% heal them
If ((VitaPercentF >= 10))
ControlSend,, {Escape}{Shift Down}{z}{x}{Shift Up}{1}, Shifter
;If fighters vita is below 10% restore them
If ((VitaPercentP >= 10))
ControlSend,, {Escape}{Shift Down}{z}{s}{Shift Up}{1}, Shifter
;If poets vita is below 10% heal itself.
If ((ManaPercentF >= 5) AND (ManaPercentP < 95))
ControlSend,, {Escape}{0}{Enter}, Shifter
;If fighters mana below 95% and poets mana higher than 5% give fighter mana
}
Insert::exitapp
Code: Select all
MemoryOpenFromPID(PID, Privilege=0x1F0FFF)
{
HWND := DllCall("OpenProcess", "Uint", Privilege, "int", 0, "int", PID)
return HWND
}
MemoryOpenFromName(Name, Privilege=0x1F0FFF)
{
Process, Exist, %Name%
PID := ErrorLevel
Return MemoryOpenFromPID(PID, Privilege)
}
MemoryOpenFromTitle(title, privilege=0x1F0FFF)
{
WinGet, PID, PID, %title%
Return MemoryOpenFromPID(PID, Privilege)
}
MemoryClose(hwnd)
{
return DllCall("CloseHandle", "int", hwnd)
}
MemoryWrite(hwnd, address, writevalue, datatype="int", length=4, offset=0)
{
VarSetCapacity(finalvalue, length, 0)
NumPut(writevalue, finalvalue, 0, datatype)
return DllCall("WriteProcessMemory", "Uint", hwnd, "Uint", address+offset, "Uint", &finalvalue, "Uint", length, "Uint", 0)
}
MemoryRead(hwnd, address, datatype="int", length=4, offset=0)
{
VarSetCapacity(readvalue,length, 0)
DllCall("ReadProcessMemory","Uint",hwnd,"Uint",address+offset,"Str",readvalue,"Uint",length,"Uint *",0)
finalvalue := NumGet(readvalue,0,datatype)
return finalvalue
}
MemoryWritePointer(hwnd, base, writevalue, datatype="int", length=4, offsets=0, offset_1=0, offset_2=0, offset_3=0, offset_4=0, offset_5=0, offset_6=0, offset_7=0, offset_8=0, offset_9=0)
{
B_FormatInteger := A_FormatInteger
Loop, %offsets%
{
baseresult := MemoryRead(hwnd,base)
Offset := Offset_%A_Index%
SetFormat, integer, h
base := baseresult + Offset
SetFormat, integer, d
}
SetFormat, Integer, %B_FormatInteger%
return MemoryWrite(hwnd,address,writevalue,datatype,length)
}
MemoryReadPointer(hwnd, base, datatype="int", length=4, offsets=0, offset_1=0, offset_2=0, offset_3=0, offset_4=0, offset_5=0, offset_6=0, offset_7=0, offset_8=0, offset_9=0)
{
B_FormatInteger := A_FormatInteger
Loop, %offsets%
{
baseresult := MemoryRead(hwnd,base)
Offset := Offset_%A_Index%
SetFormat, integer, h
base := baseresult + Offset
SetFormat, integer, d
}
SetFormat, Integer, %B_FormatInteger%
return MemoryRead(hwnd,base,datatyp,length)
}
MemoryGetAddrPID(PID, DllName)
{
VarSetCapacity(me32, 548, 0)
NumPut(548, me32)
snapMod := DllCall("CreateToolhelp32Snapshot", "Uint", 0x00000008, "Uint", PID)
If (snapMod = -1)
Return 0
If (DllCall("Module32First", "Uint", snapMod, "Uint", &me32))
{
Loop
{
If (!DllCall("lstrcmpi", "Str", DllName, "UInt", &me32 + 32)) {
DllCall("CloseHandle", "UInt", snapMod)
Return NumGet(&me32 + 20)
}
}
Until !DllCall("Module32Next", "Uint", snapMod, "UInt", &me32)
}
DllCall("CloseHandle", "Uint", snapMod)
Return 0
}
MemoryGetAddrName(Name, DllName)
{
Process, Exist, %Name%
PID := ErrorLevel
Return MemoryGetAddrPID(PID, DllName)
}
MemoryGetAddrTitle(Title, DllName)
{
WinGet, PID, PID, %Title%
Return MemoryGetAddrPID(PID, DllName)
}
SetPrivilege(privilege = "SeDebugPrivilege")
{
success := DllCall("advapi32.dll\LookupPrivilegeValueA","uint",0,"str",privilege,"int64*",luid_SeDebugPrivilege)
if (success = 1) && (ErrorLevel = 0)
{
returnval = 0
}
else
{
returnval = %ErrorLevel%
}
return %returnval%
}
SuspendProcess(hwnd)
{
return DllCall("ntdll\NtSuspendProcess","uint",hwnd)
}
ResumeProcess(hwnd)
{
return DllCall("ntdll\NtResumeProcess","uint",hwnd)
}