LightbulbTrove Auto Potion

Posts 17 of 7 · Page 1 of 1
Trove Auto Potion
Hi guys, I think it would be really nice if someone create a kind of auto potion in trove.

Example: If your life down to 20 % automatically you will use a potion.

I think it is not hard to make , since just press "Q " at a moment, Sorry for my bad English , I'm from Brazil ! haha

Thanks for reading this far, and even more
I'll look into it, it sounds very simple.
Here:

Newest AHK Installed.
Create a new AHK script, Copy/Paste the code below into the .ahk
Once you done that, can compile the .ahk into an exe or just run the .ahk script
Make sure Trove is the active window before starting the program!

Numpad9 = Start
Alt+Numpad9 = Stop
Alt+numpad7 = Exit Program


 
"Code"

Code:
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
CoordMode, Mouse, Screen
SetTitleMatchMode, 3
SetKeyDelay, 0, 2


Numpad9::
	WinGet, Handle, ID, A
	WinGet, pidn, PID, A
	Break := 0
	InputBox, HealAt, Enter Percent, Percent To Heal At?
	SetFormat, float, 1
	BaseHealth := GetHealth(Handle, pidn)
	Heal := (Health * HealAt) / 100
	Loop {
		GetHealth(Handle, pidn)
		If (Health < Heal)
		{
			ControlSend, , {q}, ahk_pid %pidn%
			Sleep, 500
		}
		If (Break = 1)
		{
			break
		}
		else
		{
			Sleep, 30
		}
	}
Return

!NumPad7::
	ExitApp

!NumPad9::
	Break := 1
return

GetHealth(Handle, pid)
{ 
	Global Health
	Base := getProcessBaseAddress(Handle)
	pointerBase := base + 0x0090D828
	z1 := ReadMemory(pointerBase, pid)
	z2 := ReadMemory(z1 + 0x98, pid)
    z3 := ReadMemory(z2 + 0x28, pid)
    z4 := ReadMemory(z3 + 0x10, pid)
	z5 := z4 + 0xcc
	Health := ReadMemory(z5, pid)
}

getProcessBaseAddress(Handle)
{
	return DllCall( A_PtrSize = 4
                            ? "GetWindowLong"
                            : "GetWindowLongPtr"
                        , "Ptr", Handle
                        , "Int", -6
                        , "Int64") ; Use Int64 to prevent negative overflow when AHK is 32 bit and target process is 64bit
     ; If DLL call fails, returned value will = 0
}   

ReadMemory(MADDRESS, pid)
{
VarSetCapacity(MVALUE,4,0)
ProcessHandle := DllCall("OpenProcess", "Int", 24, "Char", 0, "UInt", pid, "UInt")
;DllCall("ReadProcessMemory","UInt",ProcessHandle,"UInt",MADDRESS,"Str",MVALUE,"UInt",4,"UInt *",0)
DllCall("ReadProcessMemory", "UInt", ProcessHandle, "Ptr", MADDRESS, "Ptr", &MVALUE, "Uint",4)
Loop 4
result += *(&MVALUE + A_Index-1) << 8*(A_Index-1)

return, result
}
Quote Originally Posted by HaHaItsJake View Post
Here:

Newest AHK Installed.
Create a new AHK script, Copy/Paste the code below into the .ahk
Once you done that, can compile the .ahk into an exe or just run the .ahk script
Make sure Trove is the active window before starting the program!

Numpad9 = Start
Alt+Numpad9 = Stop
Alt+numpad7 = Exit Program


 
"Code"

Code:
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
CoordMode, Mouse, Screen
SetTitleMatchMode, 3
SetKeyDelay, 0, 2


Numpad9::
	WinGet, Handle, ID, A
	WinGet, pidn, PID, A
	Break := 0
	InputBox, HealAt, Enter Percent, Percent To Heal At?
	SetFormat, float, 1
	BaseHealth := GetHealth(Handle, pidn)
	Heal := (Health * HealAt) / 100
	Loop {
		GetHealth(Handle, pidn)
		If (Health < Heal)
		{
			ControlSend, , {q}, ahk_pid %pidn%
			Sleep, 500
		}
		If (Break = 1)
		{
			break
		}
		else
		{
			Sleep, 30
		}
	}
Return

!NumPad7::
	ExitApp

!NumPad9::
	Break := 1
return

GetHealth(Handle, pid)
{ 
	Global Health
	Base := getProcessBaseAddress(Handle)
	pointerBase := base + 0x0090D828
	z1 := ReadMemory(pointerBase, pid)
	z2 := ReadMemory(z1 + 0x98, pid)
    z3 := ReadMemory(z2 + 0x28, pid)
    z4 := ReadMemory(z3 + 0x10, pid)
	z5 := z4 + 0xcc
	Health := ReadMemory(z5, pid)
}

getProcessBaseAddress(Handle)
{
	return DllCall( A_PtrSize = 4
                            ? "GetWindowLong"
                            : "GetWindowLongPtr"
                        , "Ptr", Handle
                        , "Int", -6
                        , "Int64") ; Use Int64 to prevent negative overflow when AHK is 32 bit and target process is 64bit
     ; If DLL call fails, returned value will = 0
}   

ReadMemory(MADDRESS, pid)
{
VarSetCapacity(MVALUE,4,0)
ProcessHandle := DllCall("OpenProcess", "Int", 24, "Char", 0, "UInt", pid, "UInt")
;DllCall("ReadProcessMemory","UInt",ProcessHandle,"UInt",MADDRESS,"Str",MVALUE,"UInt",4,"UInt *",0)
DllCall("ReadProcessMemory", "UInt", ProcessHandle, "Ptr", MADDRESS, "Ptr", &MVALUE, "Uint",4)
Loop 4
result += *(&MVALUE + A_Index-1) << 8*(A_Index-1)

return, result
}
What do you put after pressing 9 I tried several different numbers, such as 5000 or 50 , but it does not use the potion... could you help me ? (OBS : I Have 23k of life)
Quote Originally Posted by Vitooooo View Post
What do you put after pressing 9 I tried several different numbers, such as 5000 or 50 , but it does not use the potion... could you help me ? (OBS : I Have 23k of life)
That would be because the game updated and I need to update the address. I will do that later today. The prompt that comes up is the % you want to heal at. 20 = 20% , 50 = 50%, 30 = 30%, etc - of your current full health at the time you started the script.

I will update the address and will be posting as a release.
Quote Originally Posted by HaHaItsJake View Post
That would be because the game updated and I need to update the address. I will do that later today. The prompt that comes up is the % you want to heal at. 20 = 20% , 50 = 50%, 30 = 30%, etc - of your current full health at the time you started the script.

I will update the address and will be posting as a release.
OKay ! And thank you for your dedication
Posts 17 of 7 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?