Je viens de modifier l'algo pour le déplacement du bot :-)
Je pense que vous l'avez remarqué, mais le bot revient souvent sur ses propres pas.
Actuellement le bot se déplace de cette façon :
- Va au point A
- Sur le chemin bute tout les monstres et ramasse tous les drops
- Une fois point va au point B.
- ...
Le problème c'est que si j'ai croisé beaucoup de monstres, je suis peut être à l'autre bout de la map. Le bot va donc faire un demi-tour pour aller jusqu'au point A. Puis reprendre son chemin.
J'ai donc modifié l'algo de cette façon :
- Va au point A
- Sur le chemin bute tout les monstres et ramasse tous les drops
- Quel est le point le plus proche qui va dans la bonne direction ? -> X
- Va au point X
- ...
De cette façon, le bot ignore certain point de passage et ne retourne plus sur ses pas.
Je l'ai testé quelques heures, et je n'ai pas trouvé de bugs pour le moment :-)
Pour réaliser ceci j'ai complètement modifié le fichier sequence.au3 et j'ai créé un nouveau fichier usePath.au3 qui contient les méthodes du nouvel algo.
Il vous suffit donc de remplacer sequence.au3 (je vous conseille de faire un backup de l'ancien) et d'ajouter usePath.au3 dans votre répertoire du bot. La séquence est celle par défaut : Coeur --> Champ --> Tour.
Si vous ne pouvez pas utiliser mes fichiers (suite à une de vos modifs ou une séquence utilisée différente), voici les modifications a apporter :
- Tout d'abord, la séquence est totalement modifiée, il faut fournir le trajet complet que le bot doit faire sur la map. Donc ne plus lui lui filer les points un par un, mais tous d'un coup. Voici la nouvelle méthode sequence() du fichier sequence.au3 :
Spoiler
#include "usePath.au3"
#include "Array.au3"
Func sequence()
Buffinit()
;#######################################################################
;#################### La sequence se place ici #########################
;#######################################################################
UsePath(getAreaCorePath())
UnBuff()
Sleep(Random(1000, 1500))
TakeWP(2, 0, 4, 0) ;passage do core au field
Sleep(Random(1000, 1500))
Buffinit()
UsePath(getAreaFieldPath())
UnBuff()
Sleep(Random(1000, 1500))
TakeWP(3, 1, 4, 0) ;passage Tour des damnes
Sleep(Random(1000, 1500))
Buffinit()
UsePath(getAreaTowerPath())
UnBuff()
sleep(400)
TakeWP(0,0,3,4) ;Retour en ville
sleep(400)
;#######################################################################
UnBuff()
EndFunc ;==>Sequence
Func getAreaCorePath()
Local $AreaCorePath
GetPosToAnArray($AreaCorePath, 206.692764282227, 722.693603515625, -35.8240203857422,1,25)
GetPosToAnArray($AreaCorePath, 327.7802734375, 722.134643554688, 0.100000239908695, 0, 25)
GetPosToAnArray($AreaCorePath, 361.233367919922, 723.155029296875, 0.0999998897314072, 1, 25)
GetPosToAnArray($AreaCorePath, 396.636413574219, 727.132934570313, 0.292241543531418, 1, 25)
GetPosToAnArray($AreaCorePath, 432.108215332031, 727.035888671875, 0.100000008940697, 1, 25)
GetPosToAnArray($AreaCorePath, 456.810638427734, 729.560546875, 0.100000239908695, 1, 25)
GetPosToAnArray($AreaCorePath, 480.919036865234, 720.064331054688, 0.100016579031944, 1, 25)
GetPosToAnArray($AreaCorePath, 513.213439941406, 722.520812988281, 0.425226032733917, 1, 25)
GetPosToAnArray($AreaCorePath, 538.431396484375, 709.400390625, 0.526270031929016, 1, 25)
GetPosToAnArray($AreaCorePath, 575.289001464844, 678.577880859375, 0.100015267729759,1,20) ; pour tenter de réduire coinçage lave
GetPosToAnArray($AreaCorePath, 564.48583984375, 683.751708984375, 0.100019082427025,1,20) ; pour tenter de réduire coinçage lave
GetPosToAnArray($AreaCorePath, 545.650268554688, 672.3134765625, 0.100015260279179, 1, 25)
GetPosToAnArray($AreaCorePath, 539.451477050781, 619.96484375, 0.100015252828598, 1, 25)
GetPosToAnArray($AreaCorePath, 576.119018554688, 570.673034667969, 0.100018046796322, 1, 25)
GetPosToAnArray($AreaCorePath, 628.105224609375, 554.906677246094, 0.0998855605721474, 1, 25)
GetPosToAnArray($AreaCorePath, 665.031372070313, 555.267944335938, 0.100015252828598, 1, 25)
GetPosToAnArray($AreaCorePath, 719.467163085938, 548.17138671875, 0.100015260279179, 1, 25)
GetPosToAnArray($AreaCorePath, 754.357421875, 562.712158203125, 0.100015260279179, 1, 25)
GetPosToAnArray($AreaCorePath, 763.181457519531, 587.658752441406, 0.100015252828598, 1, 25)
GetPosToAnArray($AreaCorePath, 782.532104492188, 639.928649902344, 0.10002288967371, 1, 25)
GetPosToAnArray($AreaCorePath, 826.19873046875, 668.012878417969, 0.100015252828598, 1, 25)
GetPosToAnArray($AreaCorePath, 865.750671386719, 706.178344726563, 0.100015267729759, 1, 25)
GetPosToAnArray($AreaCorePath, 930.536315917969, 725.045166015625, 0.112262189388275, 1, 25)
GetPosToAnArray($AreaCorePath, 969.425354003906, 721.049072265625, 0.10000005364418, 1, 25)
GetPosToAnArray($AreaCorePath, 1019.24328613281, 721.808349609375, 0.100000001490116, 1, 25)
GetPosToAnArray($AreaCorePath, 1053.24243164063, 710.680908203125, 0.0999999940395355, 1, 25)
GetPosToAnArray($AreaCorePath, 1091.68542480469, 715.635681152344, 0.100002571940422, 1, 25)
GetPosToAnArray($AreaCorePath, 1113.78527832031, 739.478576660156, 0.10000005364418, 1, 25)
GetPosToAnArray($AreaCorePath, 1134.54772949219, 737.803466796875, 0.100000247359276, 1, 25)
GetPosToAnArray($AreaCorePath, 1129.98010253906, 699.320434570313, 0.10000379383564, 1, 25)
GetPosToAnArray($AreaCorePath, 1154.44641113281, 693.430969238281, 0.100000008940697, 1, 25)
return $AreaCorePath
EndFunc
Func getAreaFieldPath()
Local $AreaFieldPath
GetPosToAnArray($AreaFieldPath, 3399.53051757813, 592.883728027344, 4.13610076904297, 1, 25)
GetPosToAnArray($AreaFieldPath, 3366.55126953125, 532.103759765625, 4.13610172271729, 1, 25)
GetPosToAnArray($AreaFieldPath, 3375.353515625, 480.171478271484, 4.13610172271729, 1, 25)
GetPosToAnArray($AreaFieldPath, 3403.6728515625, 444.356506347656, 4.13613319396973, 1, 25)
GetPosToAnArray($AreaFieldPath, 3429.77807617188, 411.916900634766, 4.23610067367554, 1, 25)
GetPosToAnArray($AreaFieldPath, 3468.111328125, 408.373016357422, 4.2361011505127, 1, 25)
GetPosToAnArray($AreaFieldPath, 3484.93579101563, 359.990142822266, 4.22556018829346, 1, 25)
GetPosToAnArray($AreaFieldPath, 3466.748046875, 308.676666259766, 4.17197513580322, 1, 25)
GetPosToAnArray($AreaFieldPath, 3437.67309570313, 291.675415039063, 4.13613271713257, 1, 25)
GetPosToAnArray($AreaFieldPath, 3406.36547851563, 244.697494506836, 4.13611698150635, 1, 25)
GetPosToAnArray($AreaFieldPath, 3388.49169921875, 200.068740844727, 4.23610258102417, 1, 25)
GetPosToAnArray($AreaFieldPath, 3350.751953125, 198.755294799805, 4.13610219955444, 1, 25)
GetPosToAnArray($AreaFieldPath, 3307.78100585938, 208.113327026367, 4.13610219955444, 1, 25)
GetPosToAnArray($AreaFieldPath, 3307.79125976563, 241.903762817383, 4.13610076904297, 1, 25)
GetPosToAnArray($AreaFieldPath, 3318.9599609375, 275.009155273438, 4.13610172271729, 1, 25)
GetPosToAnArray($AreaFieldPath, 3312.99609375, 311.989135742188, 4.13610124588013, 1, 25)
GetPosToAnArray($AreaFieldPath, 3288.59008789063, 344.426574707031, 4.1361026763916, 1, 25)
GetPosToAnArray($AreaFieldPath, 3257.61889648438, 373.536071777344, 4.13610076904297, 1, 25)
GetPosToAnArray($AreaFieldPath, 3240.26611328125, 407.972412109375, 4.13610029220581, 1, 25)
GetPosToAnArray($AreaFieldPath, 3217.18432617188, 441.216430664063, 4.1361026763916, 1, 25)
GetPosToAnArray($AreaFieldPath, 3190.22143554688, 473.004699707031, 4.1361026763916, 1, 25)
GetPosToAnArray($AreaFieldPath, 3135.6044921875, 461.222076416016, 4.13601922988892, 1, 25)
GetPosToAnArray($AreaFieldPath, 3097.26635742188, 472.799011230469, 4.13611936569214, 1, 25)
GetPosToAnArray($AreaFieldPath, 3030.88232421875, 477.130798339844, 4.13611888885498, 1, 25)
GetPosToAnArray($AreaFieldPath, 2968.85131835938, 483.541351318359, 4.13609933853149, 1, 25)
GetPosToAnArray($AreaFieldPath, 2917.94946289063, 488.521362304688, 4.13609886169434, 1, 25)
GetPosToAnArray($AreaFieldPath, 2886.7392578125, 516.322448730469, 4.13610076904297, 1, 25)
GetPosToAnArray($AreaFieldPath, 2886.50659179688, 558.705749511719, 4.13609886169434, 1, 25)
GetPosToAnArray($AreaFieldPath, 2883.32739257813, 600.420715332031, 4.13609838485718, 1, 25)
GetPosToAnArray($AreaFieldPath, 2882.255859375, 645.2822265625, 4.13609838485718, 1, 25)
GetPosToAnArray($AreaFieldPath, 2887.01318359375, 684.532897949219, 4.13609886169434, 1, 25)
GetPosToAnArray($AreaFieldPath, 2899.3046875, 716.864624023438, 4.13609933853149, 1, 25)
GetPosToAnArray($AreaFieldPath, 2921.9951171875, 739.088012695313, 4.13610076904297, 1, 25)
GetPosToAnArray($AreaFieldPath, 2951.82763671875, 755.687866210938, 4.13610076904297, 1, 25)
GetPosToAnArray($AreaFieldPath, 2979.94775390625, 765.159973144531, 4.13610124588013, 1, 25)
GetPosToAnArray($AreaFieldPath, 3014.10180664063, 769.427551269531, 4.13610076904297, 1, 25)
GetPosToAnArray($AreaFieldPath, 3054.04125976563, 766.797485351563, 4.13610076904297, 1, 25)
GetPosToAnArray($AreaFieldPath, 3096.26635742188, 764.203125, 4.13610029220581, 1, 25)
GetPosToAnArray($AreaFieldPath, 3136.11743164063, 755.73046875, 4.13610076904297, 1, 25)
GetPosToAnArray($AreaFieldPath, 3174.6708984375, 744.937744140625, 4.13610076904297, 1, 25)
GetPosToAnArray($AreaFieldPath, 3216.310546875, 738.722961425781, 4.13610029220581, 1, 25)
GetPosToAnArray($AreaFieldPath, 3254.8466796875, 729.619506835938, 4.13610076904297, 1, 25)
GetPosToAnArray($AreaFieldPath, 3294.07983398438, 719.999389648438, 4.13610029220581, 1, 25)
GetPosToAnArray($AreaFieldPath, 3332.939453125, 711.259643554688, 4.13610076904297, 1, 25)
GetPosToAnArray($AreaFieldPath, 3367.51147460938, 692.129089355469, 4.13610029220581, 1, 25)
GetPosToAnArray($AreaFieldPath, 3399.13647460938, 664.135131835938, 4.13610076904297, 1, 25)
GetPosToAnArray($AreaFieldPath, 3428.82641601563, 608.385925292969, 4.34261417388916, 1, 25)
GetPosToAnArray($AreaFieldPath, 3451.57177734375, 600.710083007813, 4.34298276901245, 1, 25)
Return $AreaFieldPath
EndFunc
Func getAreaTowerPath()
Local $AreaTowerPath
GetPosToAnArray($AreaTowerPath, 1034.87683105469, 974.274597167969, -9.89999580383301,1,25)
GetPosToAnArray($AreaTowerPath, 1050.51672363281, 960.936279296875, -9.89999580383301,1,25)
GetPosToAnArray($AreaTowerPath, 1094.24975585938, 953.144287109375, -9.89999580383301,1,25)
GetPosToAnArray($AreaTowerPath, 1117.02392578125, 955.590881347656, -9.89999580383301,1,25)
GetPosToAnArray($AreaTowerPath, 1145.00964355469, 961.575256347656, -9.89999580383301,1,25)
GetPosToAnArray($AreaTowerPath, 1165.630859375, 983.526733398438, -9.89999580383301,1,25)
GetPosToAnArray($AreaTowerPath, 1182.31018066406, 1006.12457275391, -10.6088771820068,1,25)
GetPosToAnArray($AreaTowerPath, 1197.29956054688, 1026.62243652344, -19.8041534423828,1,25)
GetPosToAnArray($AreaTowerPath, 1223.38537597656, 1043.30065917969, -19.899995803833,1,25)
GetPosToAnArray($AreaTowerPath, 1252.603515625, 1049.03295898438, -19.8999996185303,1,25)
GetPosToAnArray($AreaTowerPath, 1275.02661132813, 1044.48864746094, -19.8999996185303,1,25)
GetPosToAnArray($AreaTowerPath, 1279.72912597656, 1075.57690429688, -19.3072338104248,1,25)
GetPosToAnArray($AreaTowerPath, 1250.63647460938, 1057.48840332031, -19.8999977111816,1,25)
GetPosToAnArray($AreaTowerPath, 1218.94616699219, 1082.34899902344, -19.8999977111816,1,25)
GetPosToAnArray($AreaTowerPath, 1202.55932617188, 1120.49279785156, -29.4506244659424,1,25)
GetPosToAnArray($AreaTowerPath, 1204.93212890625, 1153.86730957031, -29.9000015258789,1,25)
GetPosToAnArray($AreaTowerPath, 1218.45642089844, 1175.30676269531, -29.8126411437988,1,25)
GetPosToAnArray($AreaTowerPath, 1245.81555175781, 1193.84704589844, -29.2436428070068,1,25)
GetPosToAnArray($AreaTowerPath, 1225.37438964844, 1218.22961425781, -38.284839630127,1,25)
GetPosToAnArray($AreaTowerPath, 1194.29711914063, 1246.72497558594, -38.9255752563477,1,25)
GetPosToAnArray($AreaTowerPath, 1151.62231445313, 1264.8193359375, -39.4154205322266,1,25)
GetPosToAnArray($AreaTowerPath, 1109.62268066406, 1281.12841796875, -39.8999977111816,1,25)
GetPosToAnArray($AreaTowerPath, 1068.10583496094, 1280.99169921875, -39.0772972106934,1,25)
GetPosToAnArray($AreaTowerPath, 1028.46960449219, 1273.67138671875, -39.8134651184082,1,25)
GetPosToAnArray($AreaTowerPath, 997.777893066406, 1260.45288085938, -29.6894512176514,1,25)
GetPosToAnArray($AreaTowerPath, 958.253723144531, 1238.6318359375, -29.9000053405762,1,25)
GetPosToAnArray($AreaTowerPath, 945.312744140625, 1216.36499023438, -29.0591831207275,1,25)
GetPosToAnArray($AreaTowerPath, 956.874084472656, 1183.43566894531, -29.4052772521973,1,25)
GetPosToAnArray($AreaTowerPath, 979.314453125, 1158.69665527344, -29.8999996185303,1,25)
GetPosToAnArray($AreaTowerPath, 1013.87780761719, 1158.54309082031, -29.6089477539063,1,25)
GetPosToAnArray($AreaTowerPath, 1013.73992919922, 1190.357421875, -29.9000015258789,1,25)
GetPosToAnArray($AreaTowerPath, 983.1796875, 1162.912109375, -29.8999977111816,1,25)
GetPosToAnArray($AreaTowerPath, 949.358581542969, 1125.56713867188, -29.9000091552734,1,25)
GetPosToAnArray($AreaTowerPath, 956.013488769531, 1080.52478027344, -29.9000034332275,1,25)
GetPosToAnArray($AreaTowerPath, 967.2021484375, 1051.49743652344, -26.8313446044922,1,25)
GetPosToAnArray($AreaTowerPath, 970.408142089844, 1016.98254394531, -19.8999996185303,1,25)
GetPosToAnArray($AreaTowerPath, 922.792724609375, 988.321044921875, -19.8999977111816,1,25)
GetPosToAnArray($AreaTowerPath, 929.850280761719, 953.324462890625, -9.80142784118652,1,25)
GetPosToAnArray($AreaTowerPath, 953.000915527344, 925.924377441406, -9.89999866485596,1,25)
GetPosToAnArray($AreaTowerPath, 983.352233886719, 923.179504394531, -9.43467140197754,1,25)
GetPosToAnArray($AreaTowerPath, 998.278686523438, 963.086059570313, -9.65192985534668,1,25)
GetPosToAnArray($AreaTowerPath, 1022.95446777344, 982.567810058594, -9.89999580383301,1,25)
Return $AreaTowerPath
EndFunc
Func GetPosToAnArray(ByRef $array, $x, $y, $z, $attaque, $range)
Local $Bound = 0
If IsArray($array) Then
$Bound = UBound($array)
ReDim $array[$Bound+1][5]
Else
Local $arrayTemp[1][5]
$array = $arrayTemp
EndIf
$array[$Bound][0] = $x
$array[$Bound][1] = $y
$array[$Bound][2] = $z
$array[$Bound][3] = $attaque
$array[$Bound][4] = $range
Return $array
EndFuncEnsuite il faut une méthode qui remplace totalement MoveToPos(), celle-ci permettait d'aller à un point précis ! Il faut la remplacer par celle-ci (qui est une grosse modification de MovToPos()) qui prend en paramètre une liste de point qui représente le trajet. Remplacez MoveToPos par cette fonction dans le fichier toolkit.au3 :
Spoiler
;;--------------------------------------------------------------------------------
; Function: UsePath(ByRef $path)
; Description:
;;--------------------------------------------------------------------------------
Func UsePath(ByRef $path)
Local $posIndex = 0
Local $size = UBound($path)
Local $TimeOut = TimerInit()
Local $toggletry = 0
$grabtimeout = 0
$killtimeout = 0
$Coords = FromD3toScreenCoords($path[$posIndex][0], $path[$posIndex][1], $path[$posIndex][2])
MouseMove($Coords[0], $Coords[1], 3)
$LastCP = GetCurrentPos()
MouseDown("middle")
Sleep(10)
While 1
If _playerdead() Or $GameOverTime = True Or $GameFailed = 1 Or $SkippedMove > 6 Then
$GameFailed = 1
ExitLoop
EndIf
If TimerDiff($TimeOut) > 75000 Then
_log("UsePath Timed out ! ! ! ")
$GameFailed = 1
ExitLoop
EndIf
GameOverTime()
If $GameOverTime = True Then
ExitLoop
EndIf
$Distance = GetDistance($path[$posIndex][0],$path[$posIndex][1],$path[$posIndex][2])
If $Distance < $path[$posIndex][4] Then
$posIndex +=1
If ($posIndex > $size - 1) Then ExitLoop
$TimeOut = TimerInit()
$toggletry = 0
$grabtimeout = 0
$killtimeout = 0
EndIf
;If _MemoryRead($ClickToMoveToggle, $d3, 'float') = 0 Then ExitLoop
Local $angle = 1
Local $Radius = 25
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
While _MemoryRead($ClickToMoveToggle, $d3, 'float') = 0
;_log("Togglemove : " & _MemoryRead($ClickToMoveToggle, $d3, 'float'))
$Coords = FromD3toScreenCoords($path[$posIndex][0],$path[$posIndex][1],$path[$posIndex][2])
$angle += $Step
$Radius += 45
;MouseMove($Coords[0] - (Cos($angle) * $Radius), $Coords[1] - (Sin($angle) * $Radius), 3)
; ci desssous du dirty code pour eviter de cliquer n'importe ou hos de la fenetre du jeu
$Coords[0] = $Coords[0] - (Cos($angle) * $Radius)
$Coords[1] = $Coords[1] - (Sin($angle) * $Radius)
$Coords[0] = min($Coords[0], 790)
$Coords[0] = max($Coords[0], 40) ;car on a pas l'envie de cliquer dans les icone du chat
$Coords[1] = min($Coords[1], 540);car on a pas l'envie de cliquer dans la bare des skills
$Coords[1] = max($Coords[1],10)
MouseMove($Coords[0], $Coords[1], 3)
$toggletry += 1
;_log("Tryin move :" & " x:" & $_x & " y:" & $_y & "coords: " & $Coords[0] & "-" & $Coords[1] & " angle: " & $angle & " Toggle try: " & $toggletry)
If $angle >= 2.0 * $PI Or $toggletry > 9 Or _playerdead() Then
$SkippedMove += 1
_log("Toggle try: " & $toggletry & " Movement Skipped : " & $SkippedMove & " Pos Skipped : " & $posIndex)
$newIndex = $posIndex + 1;
If ($newIndex > $size -1 )Then ExitLoop 2
If ($newIndex <> $posIndex) Then
_log("MoveToPos pos " & $posIndex & " to pos " & $newIndex)
$posIndex = $newIndex
$TimeOut = TimerInit()
$toggletry = 0
$grabtimeout = 0
$killtimeout = 0
EndIf
ExitLoop
EndIf
Sleep(10)
WEnd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Sleep(10)
;ConsoleWrite("currentloc: " & $_Myoffset & " - "&$CurrentLoc[0] & " : " & $CurrentLoc[1] & " : " & $CurrentLoc[2] &@CRLF)
;ConsoleWrite("distance/m range: " & $Distance & " : " & $pos[4] & @CRLF)
If $path[$posIndex][3] = 1 And GetDistance($LastCP[0], $LastCP[1], $LastCP[2]) >= $a_range / 2 Then
MouseUp("middle")
$LastCP = GetCurrentPos()
If $path[$posIndex][3] = 1 Then Attack($a_range, $monsterList)
;ConsoleWrite("Last check: " & $Distance & @CRLF)
EndIf
$newIndex = getNextPosIndex($path, $posIndex)
If ($newIndex > $size - 1)Then ExitLoop
If ($newIndex <> $posIndex) Then
_log("MoveToPos pos " & $posIndex & " to pos " & $newIndex)
$posIndex = $newIndex
$TimeOut = TimerInit()
$toggletry = 0
$grabtimeout = 0
$killtimeout = 0
EndIf
$Coords = FromD3toScreenCoords($path[$posIndex][0],$path[$posIndex][1],$path[$posIndex][2])
MouseMove($Coords[0], $Coords[1], 3)
MouseDown("middle")
WEnd
MouseUp("middle")
;;
;Sleep(100)
EndFunc ;==>UsePath
J'avoue que MoveToPos est compliquée à comprendre, il y a des variables non utilisées et des vérifs partout sur des variables globales. Je pense qu'elle a été beaucoup patchée pour fixer des bugs. Donc j'espère ne pas trop avoir cassé ces différents patchs...
- Ensuite une nouvelle fonction qui permet de récupérer l'index de la prochaine position à atteindre. Ce point est le plus proche de la position courante du bot qui est dans la bonne direction et par lequel je ne suis pas déja passé. Il faut donc faire un peu de math :-) A ajouter dans toolkit.au3 :
Spoiler
;;--------------------------------------------------------------------------------
; Function: getNextPosIndex(ByRef $arr, $index)
; Description: Return the nearest point with the good direction
;
; Note(s): http://www.exaflop.org/docs/cgafaq/cga1.html
;;--------------------------------------------------------------------------------
Func getNextPosIndex(ByRef $arr, $index)
$indexPoint = $index
$DistanceMin = -1
$size = UBound($arr)
If( $indexPoint = $size-1 ) Then Return $indexPoint
While $indexPoint < $size
$CurrentLoc = GetCurrentPos()
$Distance = getDistance($arr[$indexPoint][0], $arr[$indexPoint][1], $arr[$indexPoint][2])
If $Distance > $DistanceMin And $DistanceMin > 0 Then
Local $Ax = $arr[$indexPoint -1][0]
Local $Ay = $arr[$indexPoint -1][1]
Local $Bx = $arr[$indexPoint][0]
Local $By = $arr[$indexPoint][1]
Local $T = ($Ay-$CurrentLoc[1])*($Ay-$By)-($Ax-$CurrentLoc[0])*($Bx-$Ax)
Local $L = Sqrt( ($Bx-$Ax)*($Bx-$Ax) + ($By-$Ay)*($By-$Ay) )
Local $R = $T/($L * $L);
If( $R > 0 AND $R < 1 ) Then
_log("Bad direction, go to pos " & $indexPoint)
Return $indexPoint
Endif
Return $indexPoint-1
EndIf
$DistanceMin = $Distance
$indexPoint += 1
Wend
Return $indexPoint-1
EndFunc
Et pour finir, juste 2 méthodes min et max. A ajouter dans toolkit.au3 :
Spoiler
Func max($val1, $val2) If( $val1 > $val2 ) Then Return $val1 Return $val2 EndFunc Func min($val1, $val2) If( $val1 < $val2 ) Then Return $val1 Return $val2 EndFunc
Bon botting ;-)
Fichier(s) joint(s)
-
usePath-1.0.rar 5.74 Ko
50 téléchargement(s)
-
usePath-1.1.rar 5.29 Ko
76 téléchargement(s)


Ce sujet est fermé








