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
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
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.
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
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
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!
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
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%)
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
[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
[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.