Re: [Tutoriel] Deplacements et changements de map D. en sock
Petites optimisations/simplifications du code...
Tu peux facilement éviter les boucles; elles ne sont pas utiles ici. Ainsi, au lieu de :
For i = 532 To 559
If Cell_ID = i Then
Map_ID = Map_ID - 1
param1.WriteUInt32(Map_ID)
Dofus.DofusWriter(221)
End If
Next
tu peux écrire :
If (Cell_ID<=559) AND (Cell_ID>=532) Then
Map_ID = Map_ID - 1
param1.WriteUInt32(Map_ID)
Dofus.DofusWriter(221)
End If
Comme Cell_ID ne devrait pas pouvoir dépasser 559, tu peux encore simplifier en :
If (Cell_ID>=532) Then
Map_ID = Map_ID - 1
param1.WriteUInt32(Map_ID)
Dofus.DofusWriter(221)
End If
Pour les boucles avec un "step", c'est un tout petit peu plus délicat.
Ainsi par exemple, tu peux remplacer :
For i = 27 To 559 Step 28
If Cell_ID = i Then
Map_ID = Map_ID - 512
param1.WriteUInt32(Map_ID)
Dofus.DofusWriter(221)
End If
Next
For i = 13 To 545 Step 28
If Cell_ID = i Then
Map_ID = Map_ID - 512
param1.WriteUInt32(Map_ID)
Dofus.DofusWriter(221)
End If
Next
Par :
If (mod(Cell_ID, 28)=27) OR (mod(Cell_ID, 28)=13) Then
Map_ID = Map_ID - 512
param1.WriteUInt32(Map_ID)
Dofus.DofusWriter(221)
End If
Ce qui en fait revient au même que :
If mod(Cell_ID, 14)=13 Then
Map_ID = Map_ID - 512
param1.WriteUInt32(Map_ID)
Dofus.DofusWriter(221)
End If