Func InteractPortal($a_name, $dist = 300)
_MouseDebug()
$Curentarea = GetLevelAreaId()
Local $index, $offset, $count, $item[10], $foundobject = 0
Local $maxtry = 0
startIterateObjectsList($index, $offset, $count)
If _playerdead() = False Then
While iterateObjectsList($index, $offset, $count, $item)
If StringInStr($item[1],'Boss_Portal') And $item[9] < $dist Then
_log($item[1] & " distance : " & $item[9])
While GetDistance($item[2], $item[3], $item[4]) > 40 And $maxtry <= 15
$Coords = FromD3toScreenCoords($item[2], $item[3], $item[4])
MouseClick($MouseClickSet, $Coords[0], $Coords[1], 1, 10)
$maxtry += 1
_log('interactbyactor: click x : ' & $Coords[0] & " y : " & $Coords[1])
Sleep(800)
WEnd
Sleep(800)
Interact($item[2], $item[3], $item[4])
$Newarea = GetLevelAreaId()
Local $BossPortalTry = 0
Local $NewAreaOk = 0
While $NewAreaOk = 0 And $BossPortalTry <= 2
_log("Try n°" & $BossPortalTry + 1 & " bossportal")
Interact($item[2], $item[3], $item[4])
$Newarea = GetLevelAreaId()
Local $areatry = 0
While $Newarea = $Curentarea And $areatry <= 15
$Newarea = GetLevelAreaId()
Sleep(1000)
$areatry += 1
WEnd
If $Newarea <> $Curentarea Then
$NewAreaOk = 1
Else
$BossPortalTry += 1
EndIf
WEnd
If $Newarea <> $Curentarea Then
_log('succesfully teleported to Boss : ' & $Curentarea & ":" & $Newarea)
While Not offsetlist()
Sleep(10)
WEnd
Else
_log('We failed to teleport to boss')
$GameFailed = 1
EndIf
$foundobject = 1
Sleep(100)
ExitLoop
EndIf
WEnd
EndIf
Return $foundobject
EndFunc ;==>InteractPortal