
Представляю сабж на ваш суд:
Code: Select all
######## Антиантимакрос для шарда Абисс ###########
# (c) GMX
# Скрипт актуален на 29.11.2010 г.
#
sub antiabyss()
# Основная функция.
# Выбирает шесть контрольных точек на нарисованной цифре,
# измеряет между ними расстояние, сверяется с шаблоном и
# нажимает нужную кнопочку
var res1, res2, res3, res4, res5, res6, result, counter, choice
counter=0
result=0
res1=testn(1,4) # выбираем контрольные точки
res2=testn(4,5)
res3=testn(7,8)
res4=testn(8,11)
res5=testn(5,8)
res6=testn(2,3)
if (res1>20 and res2>20 and res3>20 and res4>20) and res6<14 then # двойка
uo.print("Possibly 2!!!!!")
result=2
end if
if (res1>20 and res2>20 and res3<14 and res4<14) then # тройка
uo.print("Possibly 3!!!!!")
result=3
end if
if (res1<14 and res2<14 and res3<14 and res4<14) then # пятерка
uo.print("Possibly 5!!!!!")
result=5
end if
if (res1>17 and res2<14 and res3>17 and res4<14) then # шестерка
uo.print("Possibly 6!!!!!")
result=6
end if
if (res1>17 and res2>17 and res5<14) and res6>16 then # восьмерка
uo.print("Possibly 8!!!!!")
result=8
end if
if (res1<14 and res2>17 and res3<14 and res4>17) then # девятка
uo.print("Possibly 9!!!!!")
result=9
end if
choice=choose(result) # выбираем нужный результат
uo.print("Choice №"+str(choice))
uo.print('++++++++++++++')
uo.print("Pressing...")
if choice==1 then # и жмем на нужную кнопку
uo.lclick(163,199)
end if
if choice==2 then
uo.lclick(163,235)
end if
if choice==3 then
uo.lclick(163,268)
end if
endsub
sub testn(num1,num2)
# Функция считывает координаты точек, составляющих цифру,
# и возвращает расстояние между двумя точками,
# переданными в качестве параметров функции
var i,res
DIM x[11]
DIM y[11]
for i=1 to 11
x[i]=val(GetWord(uo.lastGump("command",i+2), 2))
y[i]=val(GetWord(uo.lastGump("command",i+2), 3))
next
res=SQRT((x[num1]-x[num2])*(x[num1]-x[num2])+(y[num1]-y[num2])*(y[num1]-y[num2])) # вспоминаем теорему Пифагора ;)
uo.print(str(res))
return res
endsub
sub choose(num) # Функция считывает варианты ответов и возвращает нужный
var count,i
for i=1 to 3
count=val(uo.lastGump("text",i))
uo.print('count='+str(count))
if num==count then
return i
end if
next
uo.print('Somthing wrong. Zero returned!!!!!')
return 0
endsub
Sub GetWord( st, nom )
; (c) Edred
; Возвращает слово из строки str за номером num
; если такого слова нет - возвращаем ''
;
; Разделителем слов считаем пробел. Несколько пробелов подряд считаются за один.
; Функция сделана без рекурсии специально для считывания слов из сверхдлинных строк!
;
VAR tmpst, i, dlin, kol = 0, start = 0
dlin = len( st )
For i=0 To dlin - 1
If mid( st, i, 1 ) == ' ' OR i == dlin - 1 Then
kol = kol + 1
If kol == nom Then
; это первый пробел после нужного нам слова
tmpst = mid( st, start, i - start )
return tmpst
Else
While mid( st, i, 1 ) == ' '
i = i + 1
Wend
If kol == nom - 1 Then
start = i
Endif
Endif
Endif
Next
tmpst = ''
return tmpst
endsub
sub SQRT(x) # Квадратный корень
if x<0 then
return 0
end if
var tmp=int(2*len(str(x)))
var result=XtoPowerY(2,tmp)
repeat
tmp=result
result=0.5*(result+x/result)
until abs(tmp-result)<0.00001
return result
end sub
sub abs(x) # модуль числа
if (x < 0) then
x = -x
end if
return x
end sub
sub IsWholeNum(num) # является ли число целым
if (num-int(num)) == 0 then
return true
else
return false
end if
end sub
sub XtoPowerY(x,y) # возведение в степень
if not IsWholeNum(y) or y<0 or (x==0 and y==0) then
return 0
end if
var i,result=1
if y>0 then
for i = 1 to y
result=result*x
next
else
return 1
end if
return result
end sub
Примечание для самых маленьких: чтобы это чудо заработало в основной скрипт нужно вставить что-нибудь вроде:
Code: Select all
if not uo.LastGump("replyed") then
uo.print("Antimacros detected!!!")
wait(500)
antiabyss()
end if