|
You last visited: Today at 15:04
Advertisement
Problem with health structs
Discussion on Problem with health structs within the GW Bots forum part of the Guild Wars category.
02/23/2020, 16:32
|
#1
|
elite*gold: 0
Join Date: Aug 2015
Posts: 52
Received Thanks: 8
|
Problem with health structs
I have some issues trying to perfect the healing on my war supplies bot, so it doesn't just pop the healing stance as soon as it fights, better if we get down to 75% ish health and then use it, so it lasts better during the fights.
I remember using the first code below, like a year ago and worked fine, but now it just pops the healing stance even if we are 100% health, meaning it doesnt get the struct health percentage?.
So i tried using the GetHealth() function, and it does work on myself, but for some reason it cannot get mikus health properly. I know for a fact that she has 600 health, because i've tried:
If GetHealth(-1) < 601 then......
If GetHealth(-1) > 600 then.....
and those worked for me, but if i do like < 400, wich is 75% then it just heals when shes 100%..
Does anybody know a better way? would greatly appreciate it
Code:
local $mmiku
$mmiku = getagentbyname("Miku")
If DllStructGetData($mself, "HP") < 0.7 Or DllStructGetData($mmiku, "HP") < 0.5 Then ;Have Also tried -2 instead of $mself.
If canuseskill(6, 2) Then
useskill(6, $mselfid)
Return True
EndIf
EndIf
Code:
Local $mmiku
Local $ldistance
;HEAL BOTH OR SELF
If GetHealth(-2) < 450 Then ;75%hp (works on me)
$mmiku = TargetNearestAlly()
Sleep(getping() + 100)
If GetHealth(-1) < 400 Then ;75% hp (this one doesnt work on her)
If IsRecharged(6) Then
out("Healing Us")
Sleep(getping() + 50)
useskill(6, 2)
$ldistance = getdistance(-1, -2)
If $ldistance > 900 Then
out("Moving Closer To Miku to heal")
ControlSend(getwindowhandle(), "", "", "{space}")
Sleep(getping() + 1500)
EndIf
EndIf
Else
If IsRecharged(6) Then ;heal only self (doesnt run to miku if necessery)
out("SelfHeal")
Sleep(getping() + 50)
useskill(6, 2)
Sleep(getping() + 100)
EndIf
EndIf
EndIf
|
|
|
02/23/2020, 16:42
|
#2
|
elite*gold: 143
Join Date: Oct 2011
Posts: 72
Received Thanks: 31
|
Quote:
Originally Posted by sadusten
I have some issues trying to perfect the healing on my war supplies bot, so it doesn't just pop the healing stance as soon as it fights, better if we get down to 75% ish health and then use it, so it lasts better during the fights.
I remember using the first code below, like a year ago and worked fine, but now it just pops the healing stance even if we are 100% health, meaning it doesnt get the struct health percentage?.
So i tried using the GetHealth() function, and it does work on myself, but for some reason it cannot get mikus health properly. I know for a fact that she has 600 health, because i've tried:
If GetHealth(-1) < 601 then......
If GetHealth(-1) > 600 then.....
and those worked for me, but if i do like < 400, wich is 75% then it just heals when shes 100%..
Does anybody know a better way? would greatly appreciate it
Code:
local $mmiku
$mmiku = getagentbyname("Miku")
If DllStructGetData($mself, "HP") < 0.7 Or DllStructGetData($mmiku, "HP") < 0.5 Then ;Have Also tried -2 instead of $mself.
If canuseskill(6, 2) Then
useskill(6, $mselfid)
Return True
EndIf
EndIf
Code:
Local $mmiku
Local $ldistance
;HEAL BOTH OR SELF
If GetHealth(-2) < 450 Then ;75%hp (works on me)
$mmiku = TargetNearestAlly()
Sleep(getping() + 100)
If GetHealth(-1) < 400 Then ;75% hp (this one doesnt work on her)
If IsRecharged(6) Then
out("Healing Us")
Sleep(getping() + 50)
useskill(6, 2)
$ldistance = getdistance(-1, -2)
If $ldistance > 900 Then
out("Moving Closer To Miku to heal")
ControlSend(getwindowhandle(), "", "", "{space}")
Sleep(getping() + 1500)
EndIf
EndIf
Else
If IsRecharged(6) Then ;heal only self (doesnt run to miku if necessery)
out("SelfHeal")
Sleep(getping() + 50)
useskill(6, 2)
Sleep(getping() + 100)
EndIf
EndIf
EndIf
|
probably
Code:
$mmiku = getagentbyname("Miku")
isnt working. Check whats inside the variable.
bcs DllStructGetData return 0 if it fails. so 0 < 0.5 always hit true
|
|
|
02/23/2020, 17:01
|
#3
|
elite*gold: 0
Join Date: Aug 2015
Posts: 52
Received Thanks: 8
|
Quote:
Originally Posted by Zvend
probably
Code:
$mmiku = getagentbyname("Miku")
isnt working. Check whats inside the variable.
bcs DllStructGetData return 0 if it fails. so 0 < 0.5 always hit true
|
I don't quite understand what you mean by check whats inside the variable, do you mean the actual function getagentbyname()?, if so then that function hasn't been changed.
|
|
|
02/23/2020, 17:02
|
#4
|
elite*gold: 143
Join Date: Oct 2011
Posts: 72
Received Thanks: 31
|
Quote:
Originally Posted by sadusten
I don't quite understand what you mean by check whats inside the variable, do you mean the actual function getagentbyname()?, if so then that function hasn't been changed.
|
yes. check what the function is returning. I think it does not return the correct agent as u were looking for Miku
|
|
|
02/23/2020, 17:15
|
#5
|
elite*gold: 0
Join Date: Aug 2015
Posts: 52
Received Thanks: 8
|
Quote:
Originally Posted by Zvend
yes. check what the function is returning. I think it does not return the correct agent as u were looking for Miku
|
This shit too deep for a newbie like me :>
Code:
;~ Description: Returns agent by name.
Func GetAgentByName($aName)
If $mUseStringLog = False Then Return
Local $lName, $lAddress
For $i = 1 To GetMaxAgents()
$lAddress = $mStringLogBase + 256 * $i
$lName = MemoryRead($lAddress, 'wchar [128]')
$lName = StringRegExpReplace($lName, '[<]{1}([^>]+)[>]{1}', '')
If StringInStr($lName, $aName) > 0 Then Return GetAgentByID($i)
Next
DisplayAll(True)
Sleep(100)
DisplayAll(False)
DisplayAll(True)
Sleep(100)
DisplayAll(False)
For $i = 1 To GetMaxAgents()
$lAddress = $mStringLogBase + 256 * $i
$lName = MemoryRead($lAddress, 'wchar [128]')
$lName = StringRegExpReplace($lName, '[<]{1}([^>]+)[>]{1}', '')
If StringInStr($lName, $aName) > 0 Then Return GetAgentByID($i)
Next
EndFunc ;==>GetAgentByName
;~ Description: Returns an agent struct.
Func GetAgentByID($aAgentID = -2)
;returns dll struct if successful
Local $lAgentPtr = GetAgentPtr($aAgentID)
If $lAgentPtr = 0 Then Return 0
;Offsets: 0x2C=AgentID 0x9C=Type 0xF4=PlayerNumber 0114=Energy Pips
Local $lAgentStruct = DllStructCreate('ptr vtable;byte unknown1[24];byte unknown2[4];ptr NextAgent;byte unknown3[8];long Id;float Z;byte unknown4[8];float BoxHoverWidth;float BoxHoverHeight;byte unknown5[8];float Rotation;byte unknown6[8];long NameProperties;byte unknown7[24];float X;float Y;byte unknown8[8];float NameTagX;float NameTagY;float NameTagZ;byte unknown9[12];long Type;float MoveX;float MoveY;byte unknown10[28];long Owner;byte unknown30[8];long ExtraType;byte unknown11[24];float AttackSpeed;float AttackSpeedModifier;word PlayerNumber;byte unknown12[6];ptr Equip;byte unknown13[10];byte Primary;byte Secondary;byte Level;byte Team;byte unknown14[6];float EnergyPips;byte unknown[4];float EnergyPercent;long MaxEnergy;byte unknown15[4];float HPPips;byte unknown16[4];float HP;long MaxHP;long Effects;byte unknown17[4];byte Hex;byte unknown18[18];long ModelState;long TypeMap;byte unknown19[16];long InSpiritRange;byte unknown20[16];long LoginNumber;float ModelMode;byte unknown21[4];long ModelAnimation;byte unknown22[32];byte LastStrike;byte Allegiance;word WeaponType;word Skill;byte unknown23[4];word WeaponItemId;word OffhandItemId')
DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWProcHandle, 'int', $lAgentPtr, 'ptr', DllStructGetPtr($lAgentStruct), 'int', DllStructGetSize($lAgentStruct), 'int', '')
Return $lAgentStruct
EndFunc ;==>GetAgentByID
;~ Description: Internal use for GetAgentByID()
Func GetAgentPtr($aAgentID)
Local $lOffset[3] = [0, 4 * ConvertID($aAgentID), 0]
Local $lAgentStructAddress = MemoryReadPtr($mAgentBase, $lOffset)
Return $lAgentStructAddress[0]
EndFunc ;==>GetAgentPtr
;~ Description: Returns number of agents currently loaded.
Func GetMaxAgents()
Return MemoryRead($mMaxAgents)
EndFunc ;==>GetMaxAgents
|
|
|
02/23/2020, 17:26
|
#6
|
elite*gold: 143
Join Date: Oct 2011
Posts: 72
Received Thanks: 31
|
Quote:
Code:
local $mmiku
$mmiku = getagentbyname("Miku")
ConsoleWrite('@@ Debug: $mmiku = "' & $mmiku & '"' & @CRLF)
If DllStructGetData($mself, "HP") < 0.7 Or DllStructGetData($mmiku, "HP") < 0.5 Then ;Have Also tried -2 instead of $mself.
If canuseskill(6, 2) Then
useskill(6, $mselfid)
Return True
EndIf
EndIf
|
try this and see what the value of the var is
|
|
|
02/23/2020, 17:34
|
#7
|
elite*gold: 0
Join Date: Aug 2015
Posts: 52
Received Thanks: 8
|
Quote:
Originally Posted by Zvend
Code:
local $mmiku
$mmiku = getagentbyname("Miku")
ConsoleWrite('@@ Debug(' & [MENTION=7844948]SCRIPTL[/MENTION]ineNumber & ') : $mmiku = "' & $mmiku & '"' & [MENTION=3576271]CRLF[/MENTION])
If DllStructGetData($mself, "HP") < 0.7 Or DllStructGetData($mmiku, "HP") < 0.5 Then ;Have Also tried -2 instead of $mself.
If canuseskill(6, 2) Then
useskill(6, $mselfid)
Return True
EndIf
EndIf
try this and see what the value of the var is
|
|
|
|
02/23/2020, 17:37
|
#8
|
elite*gold: 143
Join Date: Oct 2011
Posts: 72
Received Thanks: 31
|
Quote:
Originally Posted by sadusten
|
CHeck again my code. I had to quote it because this website made mentions in the code..........
|
|
|
02/23/2020, 17:53
|
#9
|
elite*gold: 0
Join Date: Aug 2015
Posts: 52
Received Thanks: 8
|
Quote:
Originally Posted by Zvend
CHeck again my code. I had to quote it because this website made mentions in the code..........
|
Would be nice if you told me what it will do, i dont rly know debuggings etc so what var do you want me to check out after running your line? It looks like its just quickly going through all characters in compass range. I also noticed that in other old gwa's, there was a return false after the for->next on the bottom.
Code:
Local $mmiku
$mmiku = getagentbyname("Miku")
ConsoleWrite('@@ Debug: $mmiku = "' & $mmiku & '"' & [MENTION=3576271]CRLF[/MENTION])
If DllStructGetData($mmiku, "HP") < 0.7 Then
If canuseskill(6, 2) Then
useskill(6, $mselfid)
Return True
EndIf
EndIf
Sleep(5000)
Code:
;~ Description: Returns agent by name.
Func GetAgentByName($aName)
If $mUseStringLog = False Then Return
Local $lName, $lAddress
For $i = 1 To GetMaxAgents()
$lAddress = $mStringLogBase + 256 * $i
$lName = MemoryRead($lAddress, 'wchar [128]')
$lName = StringRegExpReplace($lName, '[<]{1}([^>]+)[>]{1}', '')
If StringInStr($lName, $aName) > 0 Then Return GetAgentByID($i)
Next
DisplayAll(True)
Sleep(100)
DisplayAll(False)
DisplayAll(True)
Sleep(100)
DisplayAll(False)
For $i = 1 To GetMaxAgents()
$lAddress = $mStringLogBase + 256 * $i
$lName = MemoryRead($lAddress, 'wchar [128]')
$lName = StringRegExpReplace($lName, '[<]{1}([^>]+)[>]{1}', '')
If StringInStr($lName, $aName) > 0 Then Return GetAgentByID($i)
Next
Return False ;<------------------------------This wasnt here. Still didnt work though.
EndFunc ;==>GetAgentByName
|
|
|
02/23/2020, 18:02
|
#10
|
elite*gold: 143
Join Date: Oct 2011
Posts: 72
Received Thanks: 31
|
- Start your autoit Editor in AdminMode
- Open your script
- Press F5
- Look at the console which appears by SciTE
- Something like
Code:
@@ Debug: $mmiku = "___"
will appear, where ___ is the value of ur variable.
|
|
|
02/23/2020, 18:06
|
#11
|
elite*gold: 0
Join Date: Aug 2015
Posts: 52
Received Thanks: 8
|
Quote:
Originally Posted by Zvend
- Start your autoit Editor in AdminMode
- Open your script
- Press F5
- Look at the console which appears by SciTE
- Something like
Code:
@@ Debug: $mmiku = "___"
will appear, where ___ is the value of ur variable.
|
@@ Debug: $mmiku = "False"
|
|
|
02/23/2020, 18:54
|
#12
|
elite*gold: 143
Join Date: Oct 2011
Posts: 72
Received Thanks: 31
|
Quote:
Originally Posted by sadusten
@@ Debug: $mmiku = "False"
|
as i told you. Your Variable is False which means it is equal to 0 (Zero).
You cannot read out any values from your agent since its not getting found.
You will need to find a way to put Miku as an agent into your variable and your code will work.
TL-DR: Your getagentbyname("Miku") function does not work!
|
|
|
02/23/2020, 19:12
|
#13
|
elite*gold: 0
Join Date: Aug 2015
Posts: 52
Received Thanks: 8
|
Quote:
Originally Posted by Zvend
as i told you. Your Variable is False which means it is equal to 0 (Zero).
You cannot read out any values from your agent since its not getting found.
You will need to find a way to put Miku as an agent into your variable and your code will work.
TL-DR: Your getagentbyname("Miku") function does not work!
|
ok i see, but going back to my first post, howcome with the code below i find miku and tries to heal her, but only if i type
gethealth(-1) < 601
but when doing gethealth(-1) < 400 it tries to heal her when shes 100% or 0% doesnt matter, basically just pops heal.
Code:
local $mmiku
$mmiku = TargetNearestAlly()
Sleep(getping() + 100)
If GetHealth(-1) < 400 Then ;75% hp
If IsRecharged(6) Then
out("Healing Miku")
Sleep(getping() + 50)
useskill(6, 2)
$ldistance = getdistance(-1, -2)
If $ldistance > 900 Then
out("Moving Closer To Miku to heal")
ControlSend(getwindowhandle(), "", "", "{space}")
Sleep(getping() + 1500)
EndIf
EndIf
Endif
Code:
;~ Description: Returns health of an agent. (Must have caused numerical change in health)
Func GetHealth($aAgent = -2)
If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
Return DllStructGetData($aAgent, 'HP') * DllStructGetData($aAgent, 'MaxHP')
EndFunc ;==>GetHealth
|
|
|
02/23/2020, 19:20
|
#14
|
elite*gold: 143
Join Date: Oct 2011
Posts: 72
Received Thanks: 31
|
Quote:
Originally Posted by sadusten
ok i see, but going back to my first post, howcome with the code below i find miku and tries to heal her, but only if i type
gethealth(-1) < 601
but when doing gethealth(-1) < 400 it tries to heal her when shes 100% or 0% doesnt matter, basically just pops heal.
Code:
local $mmiku
$mmiku = TargetNearestAlly()
Sleep(getping() + 100)
If GetHealth(-1) < 400 Then ;75% hp
If IsRecharged(6) Then
out("Healing Miku")
Sleep(getping() + 50)
useskill(6, 2)
$ldistance = getdistance(-1, -2)
If $ldistance > 900 Then
out("Moving Closer To Miku to heal")
ControlSend(getwindowhandle(), "", "", "{space}")
Sleep(getping() + 1500)
EndIf
EndIf
Endif
Code:
;~ Description: Returns health of an agent. (Must have caused numerical change in health)
Func GetHealth($aAgent = -2)
If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
Return DllStructGetData($aAgent, 'HP') * DllStructGetData($aAgent, 'MaxHP')
EndFunc ;==>GetHealth
|
In the other function you call this: $mmiku = TargetNearestAlly()
and in your function you call this: $mmiku = getagentbyname("Miku")
Code:
;~ Description: Returns health of an agent. (Must have caused numerical change in health)
Func GetHealth($aAgent = -2)
If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
Return DllStructGetData($aAgent, 'HP') * DllStructGetData($aAgent, 'MaxHP')
EndFunc ;==>GetHealth
The GetHealth function will only return the right values if the agent u re getting the health from belongs to you. e.g. you can only get your exact HP of yourself and your heros.
All other agents will return 0 in MaxHP. you can just get their health in percent.
its better to work with following function:
Code:
Func GetHealthPercent($aAgent = -2)
If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
Return DllStructGetData($aAgent, 'HP')
EndFunc
which will return a value between 0 and 1 where 0 is dead (0%) and 1 is full hp (100%)
|
|
|
02/23/2020, 19:24
|
#15
|
elite*gold: 0
Join Date: Aug 2015
Posts: 52
Received Thanks: 8
|
Quote:
Originally Posted by Zvend
In the other function you call this: $mmiku = TargetNearestAlly()
and in your function you call this: $mmiku = getagentbyname("Miku")
Code:
;~ Description: Returns health of an agent. (Must have caused numerical change in health)
Func GetHealth($aAgent = -2)
If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
Return DllStructGetData($aAgent, 'HP') * DllStructGetData($aAgent, 'MaxHP')
EndFunc ;==>GetHealth
The GetHealth function will only return the right values if the agent u re getting the health from belongs to you. e.g. you can only get your exact HP of yourself and your heros.
All other agents will return 0 in MaxHP. you can just get their health in percent.
its better to work with following function:
Code:
Func GetHealthPercent($aAgent = -2)
If IsDllStruct($aAgent) = 0 Then $aAgent = GetAgentByID($aAgent)
Return DllStructGetData($aAgent, 'HP')
EndFunc
which will return a value between 0 and 1 where 0 is dead (0%) and 1 is full hp (100%)
|
Oh okay i see, thanks for your help, and the reason why i had
Code:
$mmiku = targetnextally() instead of the getagentbyname("Miku")
is because it didnt work so i just wanted her targeted and then gethealth(-1) but now i know
|
|
|
|
|
Similar Threads
|
[Release] Structs and Misc Bot functions
02/08/2013 - 12Sky2 Hacks, Bots, Cheats & Exploits - 32 Replies
Just posting some of the old information from my bot for all you people still actively working on TwelveSky2 that may want to start to work on a memory based botting system.
To start with here are some of the structs I used for making my bot. This is the first time I had ever done something like this, so they are nowhere near professional or fully completed, but there fully working for main bot functions you may need(unless the game client changed drastically at some point):
struct...
|
Suche aktuelle structs
09/07/2011 - WarRock - 3 Replies
Hallo und zwar wollte ich fragen ob jemand die aktuellen structs für mich hat :) danke im vorraus :D
|
Tausche ESP + Structs gegen Zombie OPK
11/29/2010 - WarRock - 5 Replies
closed ganz schnell -.-
|
[Request] Packet Structs
10/14/2008 - CO2 Private Server - 9 Replies
So, has anyone structured the packets for patch 5017? If so, any change you could either post them here or PM them to me? I'm looking for complete structures so I don't need the actual code.
|
All times are GMT +2. The time now is 15:04.
|
|