Do you know the sendpacket header and size for TargetNearestEnemy() as well? I tried to get it with a packet sniffer but nothing is coming up.
for me it does not seem that there are packets involved in the targeting stuff.
as a workaround (if i need the 2nd and 3rd nearest agent as well) i currently use sorted arrays:
Code:
#include <Array.au3>
Func GetAgentArraySorted($aAgentType = 0) ;returns a 2-dimensional array([agentID, [distance]) sorted by distance
Local $lDistance
Local $lAgentArray = GetAgentArray($aAgentType)
Local $lReturnArray[1][2]
Local $lMe = GetAgentByID(-2)
Local $AgentID
For $i = 1 To $lAgentArray[0]
$lDistance = (DllStructGetData($lMe, 'X') - DllStructGetData($lAgentArray[$i], 'X')) ^ 2 + (DllStructGetData($lMe, 'Y') - DllStructGetData($lAgentArray[$i], 'Y')) ^ 2
$AgentID = DllStructGetData($lAgentArray[$i], 'ID')
ReDim $lReturnArray[$i][2]
$lReturnArray[$i - 1][0] = $AgentID
$lReturnArray[$i - 1][1] = Sqrt($lDistance)
Next
_ArraySort($lReturnArray, 0, 0, 0, 1)
Return $lReturnArray
EndFunc ;==>GetAgentArraySorted
$AgentArray = GetAgentArraySorted()
For $i = 0 To UBound($AgentArray) - 1
$Agent = GetAgentByID($AgentArray[$i][0])
Next
make sure to set the correct $aAgentType, so you dont pull items when you want to look for enemies (0xDB) or you dont pull npcs etc when you want to pick up items (0x400).
for me it does not seem that there are packets involved in the targeting stuff.
as a workaround (if i need the 2nd and 3rd nearest agent as well) i currently use sorted arrays:
Code:
#include <Array.au3>
Func GetAgentArraySorted($aAgentType = 0) ;returns a 2-dimensional array([agentID, [distance]) sorted by distance
Local $lDistance
Local $lAgentArray = GetAgentArray($aAgentType)
Local $lReturnArray[1][2]
Local $lMe = GetAgentByID(-2)
Local $AgentID
For $i = 1 To $lAgentArray[0]
$lDistance = (DllStructGetData($lMe, 'X') - DllStructGetData($lAgentArray[$i], 'X')) ^ 2 + (DllStructGetData($lMe, 'Y') - DllStructGetData($lAgentArray[$i], 'Y')) ^ 2
$AgentID = DllStructGetData($lAgentArray[$i], 'ID')
ReDim $lReturnArray[$i][2]
$lReturnArray[$i - 1][0] = $AgentID
$lReturnArray[$i - 1][1] = Sqrt($lDistance)
Next
_ArraySort($lReturnArray, 0, 0, 0, 1)
Return $lReturnArray
EndFunc ;==>GetAgentArraySorted
$AgentArray = GetAgentArraySorted()
For $i = 0 To UBound($AgentArray) - 1
$Agent = GetAgentByID($AgentArray[$i][0])
Next
make sure to set the correct $aAgentType, so you dont pull items when you want to look for enemies (0xDB) or you dont pull npcs etc when you want to pick up items (0x400).
Thanks for that but i had a little bit of hope left we can use sendpacket for all the broken functions.
Func TargetNearestEnemy()
Local $target = GetNearestEnemyToAgent(-2)
ChangeTarget($target)
EndFunc
I've had a lot of game crashes. I think this is caused by the ChangeTarget() function. In the GWCA code I see another offset for the memory pattern. I think that causes the error. Until now, all game clients are running again without major problems.
That's ******* great ! Well done my friend thank for the update it's working for me, i'm pretty sure there is plenty of other people sharing their functions too then we gonna make a huge database for the new gwa2
This is because your TargetNearestEnemy () and SendChat () functions are not up to date.
Take a look at my last post. This will allow you to repair the TargetNearestEnemy ().
The SendChat () must look like this:
If $lBlocked > 0 Then
If TimerDiff($ChatStuckTimer) > 3000 Then ; use a timer to avoid spamming /stuck
SendChat("stuck", "/")
$ChatStuckTimer = TimerInit()
EndIf
$lBlocked = 0
$lHosCount = 0
EndIf
If GetDistance() > 1100 Then ; target is far, we probably got stuck.
If TimerDiff($ChatStuckTimer) > 3000 Then ; dont spam
SendChat("stuck", "/")
$ChatStuckTimer = TimerInit()
RndSleep(GetPing())
If GetDistance() > 1100 Then ; we werent stuck, but target broke aggro. select a new one.
TargetNearestEnemy()
EndIf
EndIf
EndIf
EndIf
So I'm wondering for the sendchat function if it's code i need to change ?
Last Chaos GuardianS - New 2019 Server (Opening 12 January 2019) 01/27/2019 - Last Chaos Private Server - 180 Replies https://www.youtube.com/watch?v=kCfwdUoPHu0
Website Coming Soon
Server Information
Start level :1
Max level:165
Experience:x2
Skill Points:x3