If i'm not wrong that func returns an array, maybe you are making a wrong use of the values?
Why are you so certain that this function crashes the game? Maybe one of the functions that calls this one is trying to perform illegal actions, hence the game crashing.Quote:
Is there something wrong with this function?
It is crashing the game.
Func GetNearestEnemyToAgent($aAgent = -2)
Local $lNearestAgent, $lNearestDistance = 100000000
Local $lDistance
Local $lAgentArray = GetAgentArray(0xDB)
If Not IsDllStruct($aAgent) Then $aAgent = GetAgentByID($aAgent)
Local $lID = DllStructGetData($aAgent, 'ID')
For $i = 1 To $lAgentArray[0]
$lDistance = (DllStructGetData($aAgent, 'X') - DllStructGetData($lAgentArray[$i], 'X')) ^ 2 + (DllStructGetData($aAgent, 'Y') - DllStructGetData($lAgentArray[$i], 'Y')) ^ 2
If DllStructGetData($lAgentArray[$i], 'Allegiance') <> 3 Then ContinueLoop
If DllStructGetData($lAgentArray[$i], 'HP') <= 0 Then ContinueLoop
If BitAND(DllStructGetData($lAgentArray[$i], 'Effects'), 0x0010) > 0 Then ContinueLoop
$lDistance = (DllStructGetData($aAgent, 'X') - DllStructGetData($lAgentArray[$i], 'X')) ^ 2 + (DllStructGetData($aAgent, 'Y') - DllStructGetData($lAgentArray[$i], 'Y')) ^ 2
If $lDistance < $lNearestDistance Then
If DllStructGetData($lAgentArray[$i], 'ID') == $lID Then ContinueLoop
$lNearestAgent = $lAgentArray[$i]
$lNearestDistance = $lDistance
EndIf
Next
SetExtended(Sqrt($lNearestDistance))
Return $lNearestAgent
EndFunc ;==>GetNearestEnemyToAgent
If i am not mistaken, this function and toolbox don't go well together and cause a crash.Quote:
Is there something wrong with this function?
It is crashing the game.
Func GetNearestEnemyToAgent($aAgent = -2)
Local $lNearestAgent, $lNearestDistance = 100000000
Local $lDistance
Local $lAgentArray = GetAgentArray(0xDB)
If Not IsDllStruct($aAgent) Then $aAgent = GetAgentByID($aAgent)
Local $lID = DllStructGetData($aAgent, 'ID')
For $i = 1 To $lAgentArray[0]
$lDistance = (DllStructGetData($aAgent, 'X') - DllStructGetData($lAgentArray[$i], 'X')) ^ 2 + (DllStructGetData($aAgent, 'Y') - DllStructGetData($lAgentArray[$i], 'Y')) ^ 2
If DllStructGetData($lAgentArray[$i], 'Allegiance') <> 3 Then ContinueLoop
If DllStructGetData($lAgentArray[$i], 'HP') <= 0 Then ContinueLoop
If BitAND(DllStructGetData($lAgentArray[$i], 'Effects'), 0x0010) > 0 Then ContinueLoop
$lDistance = (DllStructGetData($aAgent, 'X') - DllStructGetData($lAgentArray[$i], 'X')) ^ 2 + (DllStructGetData($aAgent, 'Y') - DllStructGetData($lAgentArray[$i], 'Y')) ^ 2
If $lDistance < $lNearestDistance Then
If DllStructGetData($lAgentArray[$i], 'ID') == $lID Then ContinueLoop
$lNearestAgent = $lAgentArray[$i]
$lNearestDistance = $lDistance
EndIf
Next
SetExtended(Sqrt($lNearestDistance))
Return $lNearestAgent
EndFunc ;==>GetNearestEnemyToAgent
I tried following your guide to find patterns to update the GWA2 for certain functions to work but have been unsuccessful. I even used the exact pattern you showed as an example for ScanTraderFunction and it just keeps erroring and closing the GW client. I even updated some of the patterns that yoshikawa helped me out with but that errors out my guild wars client as well.Quote:
I added a write up on pattern scanning updates as previously stated:
[Only registered and activated users can see links. Click Here To Register...]
Modify this Func to your needs:Quote:
anyone can help me with a func that detect if all party is dead?
Func CheckPartyDead()
$DeadParty = 0
For $i =1 to GetHeroCount()
If GetIsDead(GetHeroID($i)) = True Then
$DeadParty +=1
EndIf
If $DeadParty >= 6 Then
$DeadOnTheRun = 1
CurrentAction("We Wipe, going back oupost to save time")
EndIf
Next
EndFunc
die Func PickUpLoot funktioniert eigentlich, was nicht klappt ohne dirtyfix ist das verkaufen.Quote:
Moin Leute...
Da mein Englisch eine mittelschwere Katastrophe ist, bin ich leider gezwungen hier mal auf deutsch zu fragen.
Was ich geschnallt habe:
- alte Bots funktionieren nicht mehr, da ein Update alles kaputt gemacht hat
- man Braucht die neue GWA2.au3
- man Braucht die GWA2_Headers.au3
- man muss in die alten "Scripts" #include GWA2_Headers.au3
Was ich überhaupt nicht gerafft habe:
- die Option "Func PickUpLoot" und weshalb sie nicht mehr geht...
- welshalb mein Sunspearbot abschmiert, sobald der Wurm benutzt wird etc...
Vieleicht hat ja jemand mal Zeit und Lust mir dem Kram etwas zu erklären und näher zu bringen.
LG
Func PickUpLoot()
Local $lMe
Local $lBlockedTimer
Local $lBlockedCount = 0
Local $lItemExists = True
For $i = 1 To GetMaxAgents()
$lAgent = GetAgentByID($i)
If (CountFreeSlots()=0) Then Return False
If Not (GetIsMovable($lAgent)) Then ContinueLoop
If Not (GetCanPickUp($lAgent)) Then ContinueLoop
$lItem = GetItemByAgentID($i)
If (CanPickUp2($lItem)) Then ;hier mal prüfen ob die Function vorhanden ist, ansonsten anpassen
Do
If (GetDistance($lItem) > 150) Then Move(DllStructGetData($lItem, 'X'), DllStructGetData($lItem, 'Y'))
PickUpItem($lItem)
Sleep(GetPing())
Do
If (GetIsDead(-2)) Then Return False
Sleep(100)
$lMe = GetAgentByID(-2)
Until ((DllStructGetData($lMe, 'MoveX') == 0) AND (DllStructGetData($lMe, 'MoveY') == 0))
$lBlockedTimer = TimerInit()
Do
If (GetIsDead(-2)) Then Return False
Sleep(3)
$lItemExists = IsDllStruct(GetAgentByID($i))
Until Not ($lItemExists) OR (TimerDiff($lBlockedTimer) > Random(5000, 7500, 1))
If $lItemExists Then $lBlockedCount += 1
Until Not $lItemExists OR $lBlockedCount > 5
EndIf
Next
EndFunc ;==>PickUpLoot
Your GWA2 should have the GetEffect Func, use something like this to see if your target has a specific buff. :mofo:Quote:
I'm writing a bot for Auto ST player, where while in combat, I want to use the Displacement, Shelter ... Question, how can I check if I have a certain buff so I don't spam it if the skill is available? Is there a function to check buff on another player/hero also for weapon spells?
Func HasEffect($aEffectSkillID) If DllStructGetData(GetEffect($aEffectSkillID), "SkillID") == 0 Then Return False Else Return True EndIf EndFunc
Func Attack($x, $s = "enemies")
local $TimerToGetOut = TimerInit()
Do
$useSkill = -1
$target = GetNearestEnemyToAgent(-2)
$distance = GetDistance($target, -2)
If DllStructGetData($target, 'ID') <> 0 AND $distance < $x Then
ChangeTarget($target)
Sleep(150)
CallTarget($target)
Sleep(150)
Attack($target)
Sleep(150)
ElseIf DllStructGetData($target, 'ID') = 0 OR $distance > $x Then
exitloop
EndIf
For $i = 0 To 8
$targetHP = DllStructGetData(GetCurrentTarget(),'HP')
if $targetHP = 0 then ExitLoop
$distance = GetDistance($target, -2)
if $distance > $x then ExitLoop
$TargetAllegiance = DllStructGetData(GetCurrentTarget(),'Allegiance')
if $TargetAllegiance = 0x1 OR $TargetAllegiance = 0x4 OR $TargetAllegiance = 0x5 OR $TargetAllegiance = 0x6 Then ExitLoop
$TargetIsDead = DllStructGetData(GetCurrentTarget(), 'Effects')
If $TargetIsDead = 0x0010 Then ExitLoop
$TargetItem = DllStructGetData(GetCurrentTarget(),'Type')
if $TargetItem = 0x400 then ExitLoop
$energy = GetEnergy(-2)
$recharge = DllStructGetData(GetSkillBar(), "Recharge" & $i+1)
$adrenaline = DllStructGetData(GetSkillBar(), "Adrenaline" & $i+1)
Local $Energy = StringReplace(StringReplace(StringReplace(StringMid(DllStructGetData($useskill, 'Unknown4'), 6, 1), 'C', '25'), 'B', '15'), 'A', '10')
If $recharge = 0 Then
$useSkill = $i + 1
$variabletosort = 0
UseSkill($useSkill, $target)
Sleep(200)
EndIf
$target = GetNearestEnemyToAgent(-2)
Attack($target)
Sleep(150)
if $i = 8 then $i = -1 ; change -1
Next
$TargetAllegiance = DllStructGetData(GetCurrentTarget(),'Allegiance')
$TargetIsDead = DllStructGetData(GetCurrentTarget(), 'Effects')
$targetHP = DllStructGetData(GetCurrentTarget(),'HP')
$TargetItem = DllStructGetData(GetCurrentTarget(),'Type')
Until DllStructGetData($target, 'ID') = 0 OR $distance > $x OR $TargetAllegiance = 0x1 OR $TargetAllegiance = 0x4 OR $TargetAllegiance = 0x5 OR $TargetAllegiance = 0x6 OR $TargetIsDead = 0x0010 OR $targetHP = 0 OR $TargetItem = 0x400 OR TimerDiff($TimerToGetOut) > 240000
EndFunc
Got it, I think my GetEffect is busted. It returns False when the spirit is alive, but for Shelter, it just keeps spamming it. Do you call TargetSelf() before using this? It seems GetEffect targets self already since $aHeroNumber = 0, which I am assuming the player itself. I think my GWA2 might be super outdated, would you mind sharing me yours I can probably figure out what the problem on my end. From what I read, it's suppose to return to me an array or struct, but what to do with that array lol I have no idea. My console keeps saying Shelter doesn't exist, but Displacement and Union do and doesn't get casted, Shelter on the other hand keeps getting spammed. I'm very close though! Appreciate all your help :handsdown:Quote:
Your GWA2 should have the GetEffect Func, use something like this to see if your target has a specific buff. :mofo:
Code:Func HasEffect($aEffectSkillID) If DllStructGetData(GetEffect($aEffectSkillID), "SkillID") == 0 Then Return False Else Return True EndIf EndFunc