SUB GoToXY prec original modification 00 SerrouS dim turn индекс ГетДи

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
SUB GoToXY(x,y,prec)
#original (c) ...
#modification 2.00 (c) SerrouS
dim turn[8] ; индекс - ГетДир, значение поворот направо под 45 градусов
turn[0] = 39
turn[1] = 34
turn[2] = 40
turn[3] = 35
turn[4] = 37
turn[5] = 36
turn[6] = 38
turn[7] = 33
dim deltax[8]; индекс - аналогично, значение - изменение координаты при проходе стенки
dim deltay[8]
deltax[0] = 1
deltax[1] = 1
deltax[2] = 1
deltax[3] = 0
deltax[4] = -1
deltax[5] = -1
deltax[6] = -1
deltax[7] = 0
deltay[0] = -1
deltay[1] = 0
deltay[2] = 1
deltay[3] = 1
deltay[4] = 1
deltay[5] = 0
deltay[6] = -1
deltay[7] = -1
var dx,dy
var mx,my ; current coords
var lx = 0, ly = 0, ld = -1 ; last move coords
var pathFind = 0 ; as logical 0 - norm, 1 - block
var ind
var recursInd = 0
var fout = 0
var stepdelay = 300
InitStack()
repeat
mx=UO.GetX()
my=UO.GetY()
; calculating for precision coming
dx = mx - x
If dx < 0 Then
dx = 0 - dx
EndIf ;get ABS diff
dy = my - y
If dy < 0 Then
dy = 0 - dy
EndIf
If dy > dx Then
dx = dy
EndIf
If dx <= prec Then
Return
EndIf
if mx == x and my == y then
return
endif
lx = mx
ly = my
ld = UO.GetDir() ; cause once pressing can only change the direcction
if mx == x and my > y then
UO.Press(33)
endif
if mx == x and my < y then
UO.Press(35)
endif
if mx < x and my == y then
UO.Press(34)
endif
if mx < x and my > y then
UO.Press(39)
endif
if mx < x and my < y then
UO.Press(40)
endif
if mx > x and my == y then
UO.Press(36)
endif
if mx > x and my > y then
UO.Press(38)
endif
if mx > x and my < y then
UO.Press(37)
endif
wait( stepdelay )
if lx == UO.GetX() and ly == UO.GetY() and ld == UO.GetDir() then
; now there is a stop situation
recursInd = 0
repeat
#################################################
ind = ld
fout = 0
repeat ; идем в обход пока не упремся снова или не кончится стена
mx = UO.GetX()
my = UO.GetY()
ld = UO.GetDir()
UO.Press( turn[ ind ] )
wait( stepdelay )
if (UO.GetX() == mx and UO.GetY() == my and ld == UO.GetDir()) then
fout = 1 ; уперлись
else
dx = UO.GetX() - mx
dy = UO.GetY() - my
if deltax[ ind ] == dx and deltay[ ind ] == dy then
fout = 2 ; препятствие пройдено
endif
endif
until fout
if fout == 1 then ; уходим на следующий поворот
recursInd = recursInd + 1
Push( str( ind ) )
;ld = ind
else ; fout == 2
; надо попытаться восстановить контекст из стека, или выйти из обхода
pathFind = 0
if recursInd then ; восстановление
pathFind = 1
recursInd = recursInd - 1
ld = val(Pop()) - 1
if ld == -1 then
ld = 7
endif
UO.Press( turn[ld] )
wait ( stepdelay ) ; в сиду того, что ондо нажатие меняет напрваление
endif
endif
#################################################
until not recursInd and not pathFind
endif
until 0
endsub
#(c)SerrouS
Sub InitStack()
UO.SetGlobal('STACK', '0')
endsub
Sub Push( param )
var chk = val(UO.GetGlobal('STACK')) ; количество элементов в стеке
UO.SetGlobal('STACK',str(chk + 1))
UO.SetGlobal('STACK_'+str(chk), param)
endsub
Sub Pop ()
var chk = val(UO.GetGlobal('STACK')) ; количество элементов в стеке
if chk then
UO.SetGlobal('STACK',str(chk - 1))
return UO.GetGlobal('STACK_'+str(chk - 1))
else
return ''
endif
endsub
Sub CheckLag()
DeleteJournal( 'backpack' )
UO.Click( 'backpack' )
repeat
wait(100)
until UO.InJournal( 'backpack' )
return
end sub
Sub DeleteJournal( string1 )
VAR nom = UO.InJournal( string1 )
If nom > 0 Then
UO.SetJournalLine( Nom - 1, 'string replaced' )
DeleteJournal( string1 )
Endif
endsub
SUB GoTo(o,u,Target)
VAR i
VAR do,du,Exit=0
While Exit<>1
If Target<>"" Then
do=UO.GetX(Target)-UO.GetX()
du=UO.GetY(Target)-UO.GetY()
;
If UO.GetDistance(Target)<2 Then
Exit=1
Endif
Else
do=o-UO.GetX()
du=u-UO.GetY()
If do==0 AND du==0 Then
Exit=1
Endif
Endif
If do<>0 AND du<>0 Then
If do>0 AND do>0 Then
GoSE()
Endif
If do>0 AND du<0 Then
GoNE()
Endif
If do<0 AND du>0 Then
GoSW()
Endif
If do<0 AND du<0 Then
GoWN()
Endif
Endif
If do<>0 AND du==0 Then
If do>0 Then
GoE()
Endif
If do<0 Then
GoW()
Endif
Endif
If do==0 AND du<>0 Then
If du>0 Then
GoS()
Endif
If du<0 Then
GoN()
Endif
Endif
Wend
end sub
Sub GoW()
VAR walkwait=300
VAR o,u,dir=6
VAR key=36 ; Home key
o=UO.GetX()
u=UO.GetY()
while UO.GetDir()<>dir
UO.Press(key)
wait(walkwait)
If UO.GetDir()<>dir Then
CheckLag()
Endif
wend
UO.Press(key)
wait(walkwait)
If o==UO.GetX() AND u==UO.GetY() Then
CheckLag()
Endif
If UO.GetX()+1==o Then
return -1
Else
return 1
Endif
end sub
Sub GoN()
VAR walkwait=300
VAR o,u,dir=0
VAR key=33 ; PgUp
o=UO.GetX()
u=UO.GetY()
while UO.GetDir()<>dir
UO.Press(key)
wait(walkwait)
If UO.GetDir()<>dir Then
CheckLag()
Endif
wend
UO.Press(key)
wait(walkwait)
If o==UO.GetX() AND u==UO.GetY() Then
CheckLag()
Endif
If UO.GetY()+1==u Then
return -1
Else
return 1
Endif
end sub
Sub GoE()
VAR walkwait=300
VAR o,u,dir=2
VAR key=34 ; PgDown
o=UO.GetX()
u=UO.GetY()
while UO.GetDir()<>dir
UO.Press(key)
wait(walkwait)
If UO.GetDir()<>dir Then
CheckLag()
Endif
wend
UO.Press(key)
wait(walkwait)
If o==UO.GetX() AND u==UO.GetY() Then
CheckLag()
Endif
If UO.GetX()-1==o Then
return -1
Else
return 1
Endif
end sub
Sub GoS()
VAR walkwait=300
VAR o,u,dir=4
VAR key=35 ; End
o=UO.GetX()
u=UO.GetY()
while UO.GetDir()<>dir
UO.Press(key)
wait(walkwait)
If UO.GetDir()<>dir Then
CheckLag()
Endif
wend
UO.Press(key)
wait(walkwait)
If o==UO.GetX() AND u==UO.GetY() Then
CheckLag()
Endif
If UO.GetY()-1==u Then
return -1
Else
return 1
Endif
end sub
Sub GoWN()
VAR walkwait=300
VAR o,u,dir=7
VAR key=38 ; UpArrow
o=UO.GetX()
u=UO.GetY()
If UO.GetDir()<>dir Then
UO.Press(key)
wait(walkwait)
If UO.GetDir()<>dir Then
CheckLag()
Endif
Endif
If UO.GetDir()==dir Then
UO.Press(key)
wait(walkwait)
If o==UO.GetX() AND u==UO.GetY() Then
CheckLag()
Endif
If UO.GetDir()==dir Then
return -1
Else
return UO.GetDir()
Endif
Else
return UO.GetDir()
Endif
end sub
Sub GoNE()
VAR walkwait=300
VAR o,u,dir=1
VAR key=39 ; RightArrow
o=UO.GetX()
u=UO.GetY()
If UO.GetDir()<>dir Then
UO.Press(key)
wait(walkwait)
If UO.GetDir()<>dir Then
CheckLag()
Endif
Endif
If UO.GetDir()==dir Then
UO.Press(key)
wait(walkwait)
If o==UO.GetX() AND u==UO.GetY() Then
CheckLag()
Endif
If UO.GetDir()==dir Then
return -1
Else
return UO.GetDir()
Endif
Else
return UO.GetDir()
Endif
end sub
Sub GoSE()
VAR walkwait=300
VAR o,u,dir=3
VAR key=40 ; DownArrow
o=UO.GetX()
u=UO.GetY()
If UO.GetDir()<>dir Then
UO.Press(key)
wait(walkwait)
If UO.GetDir()<>dir Then
CheckLag()
Endif
Endif
If UO.GetDir()==dir Then
UO.Press(key)
wait(walkwait)
If o==UO.GetX() AND u==UO.GetY() Then
CheckLag()
Endif
If UO.GetDir()==dir Then
return -1
Else
return UO.GetDir()
Endif
Else
return UO.GetDir()
Endif
end sub
Sub GoSW()
VAR walkwait=300
VAR o,u,dir=5
VAR key=37 ; LeftArrow
o=UO.GetX()
u=UO.GetY()
If UO.GetDir()<>dir Then
UO.Press(key)
wait(walkwait)
If UO.GetDir()<>dir Then
CheckLag()
Endif
Endif
If UO.GetDir()==dir Then
UO.Press(key)
wait(walkwait)
If o==UO.GetX() AND u==UO.GetY() Then
CheckLag()
Endif
If UO.GetDir()==dir Then
return -1
Else
return UO.GetDir()
Endif
Else
return UO.GetDir()
Endif
end sub
###############################################START################################################
sub START()
repeat
wait(50)
if uo.count('0x11F6') >= 60 and uo.count('0x0FA0') >= 180 then
craft()
end if
if uo.count('0x170F') then
gotoxy(2383,3391,0)
wait(1000)
CheckLag()
uo.say('pay')
wait(1000)
gotoxy(2383,3397,0)
end if
if uo.count('0x11F6') <= 60 then
kroliki()
end if
if uo.count('0x0FA0') <= 180 then
xlopok()
end if
end if
wait(50)
until uo.dead()
end sub
Sub xlopok()
if uo.count('0x0DF9') <= 29 then
gotoxy(2368,3411,0)
repeat
wait(50)
if uo.countground('0x0C4F') then
uo.usefromground('0x0C4F')
until uo.dead() or uo.count('0x0DF9') >= 30
end if
gotoxy(2368,3408,0)
repeat
wait(50)
uo.DeleteJournal()
if uo.countground('0x0C4F') then
uo.usefromground('0x0C4F')
until uo.dead() or uo.count('0x0DF9') >= 30
end if
gotoxy(2365,3408,0)
repeat
wait(50)
uo.DeleteJournal()
if uo.countground('0x0C4F') then
uo.usefromground('0x0C4F')
until uo.dead() or uo.count('0x0DF9') >= 30
end if
gotoxy(2362,3408,0)
repeat
wait(50)
uo.DeleteJournal()
if uo.countground('0x0C4F') then
uo.usefromground('0x0C4F')
until uo.dead() or uo.count('0x0DF9') >= 30
end if
gotoxy(2362,3411,0)
repeat
wait(50)
uo.DeleteJournal()
if uo.countground('0x0C4F') then
uo.usefromground('0x0C4F')
until uo.dead() or uo.count('0x0DF9') >= 30
end if
else
gotoxy(2370,3396,0)
repeat
uo.DeleteJournal()
uo.waittargetobject('0x40046DB7')
uo.usetype('0x0DF9')
wait(1300)
uo.waittargetobject('0x4002F7AE')
uo.usetype('0x0DF9')
wait(1300)
until uo.count("0x0FA0") >= 180
end if
end sub
Sub craft()
repeat
uo.DeleteJournal()
uo.waittargettype("0x11F6")
uo.usetype('0x0F9D')
wait(200)
CheckLag()
UO.LDblClick(64,68)
wait(3500)
until uo.count('0x11F6') < 2 or uo.inJournal("You can")
end sub
Sub kroliki()
repeat
gotoxy(2390,3440,0)
kill()
wait(100)
until uo.count("0x11F6") >= 60 or uo.dead()
end sub
SUB kill()
uo.set('finddistance','8')
uo.findtype('0x00CD','-1','ground')
while uo.findcount()>0
goto((uo.getx('findtype')),(uo.gety('findtype')),'finditem')
uo.attack('finditem')
wait(1000)
repeat
wait(50)
while uo.getdistance('finditem') >= 2
wait(100)
goto((uo.getx('findtype')),(uo.gety('findtype')),'finditem')
wend
until uo.gethp('finditem') == 0
while uo.gethp('finditem')<>0
wait(100)
wend
loot()
uo.findtype('0x00CD','-1','ground')
wend
endsub
SUB loot()
var fur = '0x11F6'
var corpse='0x2006'
var waittime=1000
var body,bodypack,i
DIM Loot[4]
Loot[0]=0x11F6
Loot[1]=0x0587
Loot[2]=0x0DF9
Loot[3]=0x0FA0
Loot[4]=0x13F6
uo.set('finddistance','2')
while uo.countonground(corpse)>0
uo.waittargetground('0x2006')
uo.usetype('0x13F6')
wait(1000)
uo.findtype(corpse,'-1','ground')
body=uo.getserial('finditem')
uo.useobject('backpack')
repeat
wait(100)
until uo.getserial('lastcontainer')==uo.getserial('backpack')
uo.useobject(body)
repeat
wait(100)
until uo.getserial('lastcontainer')<>uo.getserial('backpack')
bodypack=uo.getserial('lastcontainer')
For i=0 to 1
repeat
UO.FindType(Loot[i],-1,bodypack)
if UO.GetQuantity('finditem') then
UO.MoveItem('finditem','backpack')
repeat
wait(100)
until uo.containerof('finditem')==uo.getserial('backpack')
wait(waittime)
endif
until uo.findcount()==0
next
uo.ignore(body)
wend
endsub
wait(2000)
end sub