1.) I cannot get a consistent listing of Agents.
The code below is what am using.
It works sometimes. Usually need to restart the guild wars and the bot.
Most of the time , the list is generated , but all the names are blank.
Some of the time I see corruption in the output , after several outputs, that
have a lot of chinese looking characters.
I think everytime I restart the bot , it cant get the agent info anymore.
I can always get a good return value from GetMaxAgents.
Here is some output form Bergen Hot Springs...
Output when working:
LA2: 1 Name: Alesia [Healer Henchman]
LA2: 2 Name: Stefan [Fighter Henchman]
LA2: 3 Name: Orion [Mage Henchman]
LA2: 4 Name: Reyna [Archer Henchman]
LA2: 5 Name: Dunham [Enchanter Henchman]
LA2: 6 Name: Claude [Cultist Henchman]
LA2: 7 Name: Little Thom [Brawler Henchman]
LA2: 9 Name:
LA2: 15 Name: Krytan Herald
LA2: 16 Name: Andar D'leod
LA2: 17 Name: Dannel Smythe
LA2: 18 Name: Layman Josef
LA2: 19 Name: Penelope Randell
LA2: 20 Name: Kailan [Armor]
LA2: 21 Name: Luka [Merchant]
LA2: 22 Name: Sewell [Weapons]
LA2: 23 Name: Milny Samhammil [Collector]
LA2: 24 Name: Xunlai Agent [Storage]
LA2: 25 Name: Xunlai Chest
Done...
Output when not working:
LA2: 1 Name:
LA2: 2 Name:
LA2: 3 Name:
LA2: 4 Name:
LA2: 5 Name:
LA2: 6 Name:
LA2: 7 Name:
LA2: 9 Name:
LA2: 15 Name:
LA2: 16 Name:
LA2: 17 Name:
LA2: 18 Name:
LA2: 19 Name:
LA2: 20 Name:
LA2: 21 Name:
LA2: 22 Name:
LA2: 23 Name:
LA2: 24 Name:
LA2: 25 Name:
Done...
Code:
Func ListAgents2() Local $AgentId Local $AgentName Local $AgentArray Local $AgentArray = GetAgentArray( 0xDB ) For $i = 1 To $AgentArray[0] Local $AgentId = DllStructGetData( $AgentArray[$i] , 'ID') Local $AgentName = GetAgentName( $AgentID ) ConsoleWrite( " LA2: " & $AgentID & [MENTION=546457]tab[/MENTION] & "Name:" & [MENTION=546457]tab[/MENTION] & $AgentName & [MENTION=3576271]CRLF[/MENTION] ) Next ConsoleWrite( "Done..." & [MENTION=3576271]CRLF[/MENTION] ) EndFunc ; ListAgents2
Code:
;~ Description: Quickly creates an array of agents of a given type
Func GetAgentArray($aType = 0)
Local $lStruct
Local $lCount
Local $lBuffer = ''
DllStructSetData($mMakeAgentArray, 2, $aType)
MemoryWrite($mAgentCopyCount, -1, 'long')
Enqueue($mMakeAgentArrayPtr, 8)
Local $lDeadlock = TimerInit()
Do
Sleep(1)
$lCount = MemoryRead($mAgentCopyCount, 'long')
Until $lCount >= 0 Or TimerDiff($lDeadlock) > 5000
If $lCount < 0 Then $lCount = 0
For $i = 1 To $lCount
$lBuffer &= 'Byte[448];'
Next
$lBuffer = DllStructCreate($lBuffer)
DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWProcHandle, 'int', $mAgentCopyBase, 'ptr', DllStructGetPtr($lBuffer), 'int', DllStructGetSize($lBuffer), 'int', '')
Local $lReturnArray[$lCount + 1] = [$lCount]
For $i = 1 To $lCount
$lReturnArray[$i] = 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')
$lStruct = DllStructCreate('byte[448]', DllStructGetPtr($lReturnArray[$i]))
DllStructSetData($lStruct, 1, DllStructGetData($lBuffer, $i))
Next
Return $lReturnArray
EndFunc ;==>GetAgentArray
Code:
;~ Description: Returns the name of an agent.
Func GetAgentName($aAgent = -2)
If IsDllStruct($aAgent) = 0 Then
Local $lAgentID = ConvertID($aAgent)
If $lAgentID = 0 Then Return ''
Else
Local $lAgentID = DllStructGetData($aAgent, 'ID')
EndIf
Local $lAddress = $mStringLogBase + 256 * $lAgentID
Local $lName = MemoryRead($lAddress, 'wchar [128]')
If $lName = '' Then
DisplayAll(True)
Sleep(100)
DisplayAll(False)
EndIf
Local $lName = MemoryRead($lAddress, 'wchar [128]')
$lName = StringRegExpReplace($lName, '[<]{1}([^>]+)[>]{1}', '')
Return $lName
EndFunc ;==>GetAgentName
( again , it worked before , maybe the update , but i have updated GWA2 from the most recent update thread on this forum. )
Any insights will be helpfull.






