Page 1 of 1

Скупка по рунам

Posted: 2016-01-10 21:03:56
by kobol
Скупка регов, перемещаясь по рункам. Гораздо дешевле чем по книге. Рунка на 20 поездок стоит всего 250 гп, то есть 12,5 гп за поездку. Раз в 20 дешевле , чем по книге. :lol:
Тестилась на старой инже и на новой.
Скупать можно любые товары по байлистам, но периодически нужно прикупать рунки и реги для полетов, поэтому надо замарчить хотя бы одного мага.

Code: Select all

var clr=38, clo=43, cly=53, clg=63, clb=3, cla=89, clda=83, clp=120 , clgr=1088, clw=2998

# красный   - '38' или '0x0026'  # темно-бирюзовый - '83' или '0x0053'
# оранжевый - '43' или '0x002B'  # голубой    - '89'  или '0x0059'
# желтый    - '53' или '0x0035'  # синий      - '3'   или '0x0003'
# зеленый   - '63' или '0x003F'  # фиолетовый - '120' или '0x0078'

# '1088' - по умолчанию
# 1152 - бирюзовый 1151 - черный 1155 - фиолетовый 1156 - белый  1158 - кр 1161 - синий 1162 - темно зел 1166 ткр 1169 сз 
# 2500 2524 - оранж  2517 кр 2567 малин 2566=0x0A06 белый 
#  2998 - белый 3008 3221 3600 и выше - контур

Var LifeLimit=uo.getMaxHP() ;UO.Life 
Var WeightLimit=uo.getMaxHP()*4 ;720

############################################################
sub BuyRegByRune()
## Kobol 2016
## Марчатся рунки рядом с вендорами м складываются в пак. Туда же складываются пустые рунки,  штук 5, реги для перемещения
##Чар ищет в паке рунки и если находит не пустую, то реколится по ней. Покупает у мага все, что нужно, в т.ч реги для полета 
## Докупает пустых рунок, если из осталось меньше 5 шт. 
## Если после перелета на рунке остается 1 заряд, то чар марчит пустую рунку на текущее место. Рунки с одним зарядом больше не 
## используются.
## При превышении весового лимита чар реколится по 9 слоту книги к своему сундуку в заборе и скидывает туда накупленное.
## Если у вендора нет товара, ждет некоторое время и делает вторую 
## попытку. Если и она неудачна, то летит дальше. В некоторых местах идет ко второму вендору и докупает у него. 
## Ну вроде все.##


var curweapon=0, i, k, runa, fRCL=0, RuneL, VenName="",Ven="", MyX, MyY
var OldX=uo.GetX()
var OldY=uo.GetY()
var Time

dim Runka[4]
Runka[0]="0x1F14"
Runka[1]="0x1F15"
Runka[2]="0x1F16"
Runka[3]="0x1F17"

dim RunID[20]  ; серийники рун
var rserial, rname, rcharges, brserial ; серийник рункм

var MyMoney
MyMoney=UO.Gold


uo.charprint('0x09DC','h_rekol() Try to recall !!!! ')
checklag()
UO.IgnoreReset() 
uo.deletejournal()
wait(100)

UO.FindType("0x1F4C","0x0000","2") ; 'recall scroll ### 0x1F14 0x1F15 - кверх ногами справа налево  0x1F16 кверх ногами слева направо 0x1F17 
if UO.GetQuantity("finditem")>0 then
	fRCL=1 ; recall scroll found 
end if

fRCL=0 ;' скроллы пока не используем


#if uo.weight > WeightLimit then  # Максимальный вес при котором домой с рудой 
#return
#end if 

# 1848-Tr1 

RegAgain:

while uo.weight < WeightLimit*1.3 and UO.Gold>2000
	
	
	## перемещаемся
	for i=0 to 3 
		;' выбираем рунку
		checklag()
		uo.findtype (Runka[i],"0x0000","backpack")
		wait(100)
		
		;if UO.GetQuantity("finditem")>0 then
		while UO.FindCount() > 0 
			checklag()

			wait(100)
			rserial=uo.getserial("finditem")
			wait(100)
			printincolor("149 New rserial="+rserial,1155)
			
			if rserial== "0xFFFFFFFF" then
				printincolor("162  rserial="+rserial,0)
				goto blankR
			end if
			
			wait(200)
			uo.deletejournal()
			wait(200)
			
			k=0
			ClikAgain: ###<<<<<<<<<<<<<
			uo.click(rserial)
			wait(300)
			RuneL=uo.injournal("charges")-1
			if RuneL==-1 and k<10 then 
				k=k+1
				checklag()

				goto ClikAgain
			end if
			
			if k==10 then
			printincolor("181 k==10  rserial="+rserial,0)
				goto blankR
			end if
			k=0
			;printincolor("120 RuneL="+str(RuneL),clb)
			
			;uo.journalserial(uo.injournal("too close")) == "Server ID" 
			
			rname=UO.Journal(RuneL-1)
			rcharges=UO.Journal(RuneL)
			
			;printincolor("120 "+rname,clg)
			;printincolor("120 "+rcharges,clg)
			
			rcharges=val(mid(rcharges,1,2))
			;printincolor("120 "+rname,clr)
			;printincolor("120 rcharges="+str(rcharges),clr)
			
			uo.ignore("finditem")
			
			if rcharges==1 then
				#' если на рунке остался один заряд больше ее не используем - запас для марки
				;printincolor("187 ONLY 1 CHARGE!!! rcharges="+str(rcharges)+" "+rserial,clm)
				UO.TextPrint ("187 ONLY 1 CHARGE!!! goto blankR rcharges="+str(rcharges)+" "+rserial)
				checklag()
				uo.ignore(rserial)
				goto blankR
			end if
			
			
			if instr(rname,"Blank")> -1 then
				;' blank rune пропускаем 
				;printincolor("126 ignore "+rname,clb)
				;printincolor("127 ignore "+rserial,clb)
				checklag()
				uo.ignore(rserial)
				goto blankR
			end if
			
			
			;printincolor(rserial,clr)
			;printincolor(rname,cla)
			uo.ignore(rserial)
			
			;' перелетаем на новое место ------------- 
			checklag()
			uo.waittargetobject(rserial)
			wait (100)
			if fRCL==1 then
				uo.usetype("0x1F4C") ;' Recall Scroll
				wait (1000)
				test()
				return
			else
				uo.print ("Recall scroll  not found")
				uo.deletejournal()
				wait(100)
				;Uo.Exec("cast 'Recall' rserial")
				
				goNext:
				uo.cast("Recall",rserial)
				wait (500)
				if UO.InJournal(" mana ") then
					UO.Deletejournal()
					UO.UseSkill("Meditation")
					k=0 
					
					Repeat 
						k=k+1 
						checklag()
							If uo.getHP() < uo.getMaxHP()-10  then 
								uo.say("guards")
								uo.playwav("FrsUndrAttack.wav" ) ; pip2.wav
							end if
						
						Wait(8000) 
					Until UO.InJournal("You are") or UO.InJournal("You lose") or k>10 
					
					UO.DeleteJournal() 
					goto goNext
				else
					wait (8000)
					checklag()
				end if     
				
				MyX=uo.getX()
				wait(200)
				MyY=uo.getY()
				wait(200)
            
				
				; 'if oldX<>uo.getX() or oldY<>uo.getY() then
				checklag()
				if oldX<>MyX or oldY<>MyY then
					
					;'--- перелетели на новое место. покупаем реги
					printincolor("200 h_rekol Recol success",cla-2)
					
					#' ----- проверка остатка зарядов ---------
					######### ######## ###### ###### ##### ##########  #########
					
					UO.DeleteJournal() 
					uo.click(rserial)
					wait(300)
					RuneL=uo.injournal("charges")-1
					
					rname=UO.Journal(RuneL-1)
					rcharges=UO.Journal(RuneL)
					
					;printincolor("263 "+rname,clg+5)
					;printincolor("264 "+rcharges,clg+5)
					
					rcharges=val(mid(rcharges,1,2))
					;printincolor("120 rcharges="+str(rcharges),clg+2)
					
					UO.TextPrint ("269 Check 1  rcharges="+str(rcharges))
					printincolor("--- !!! 270 Check 1 rcharges="+str(rcharges),clw)
					;' проверяем остались ли на рунке заряды 
					;' если до полета оставался один заряд, то он израсходовался
					
					
					if rcharges==1 then
						# марчим рунку на это место
						# выбрасываем рунку
						;UO.DropHere(rserial)
						printincolor("148 UO.DropHere rserial= "+rserial,clp)
						UO.TextPrint ("148 UO.DropHere rserial= "+rserial)
						brserial=GetBlanklRune()
						printincolor("148 brserial= "+brserial,clp)
						
						goMArk:
						printincolor(" 269 Try Uo.cast(Mark, brserial)="+(brserial),2567)
						
						checklag()
						Uo.cast("Mark", brserial)
						wait (500)
						if UO.InJournal(" mana ") then
							UO.Deletejournal()
							UO.UseSkill("Meditation")
							k=0 
							
							Repeat 
								k=k+1 
								checklag()
							If uo.getHP() < uo.getMaxHP()-10  then 
								uo.say("guards")
								uo.playwav("FrsUndrAttack.wav" ) ; pip2.wav
							end if
								
								Wait(8000) 
							Until UO.InJournal("You are") or UO.InJournal("You lose") or k>10 
							
							UO.DeleteJournal() 
							goto goMArk
						else
							wait (8000)
							checklag()
							
						end if                 
						printincolor(" 287 Result Uo.cast(Mark, brserial)="+(brserial),2567)
						
						;return
						#########    ########    ########    ##########   ##########   ##########  #########
					end if
					
					# 'в зависимости от места покупки выбираем имя вендора
					Ven=""
					if uo.getX()<2918 and uo.getX()> 2911 then
						# Vesper ------
						Ven="Angelo"
					end if
					
					if uo.getX()<1418 and uo.getX()> 1413 then
						# Brit Ins
						Ven="Jina"
					end if
					
					
					;' покупаем реги или что там
					buyVendor(ven, "BScr")
					
					if MyMoney == UO.Gold  and uo.getX()<4680 then
						printincolor("No items bought. Waiting for refresh", clg)
						uo.playwav("pip1.wav" )
						
						k=0   
						if uo.journal ("reach the vendor") then
							k=20
						end if
						UO.DeleteJournal()
						while k<60
							If uo.getHP() < uo.getMaxHP()-10  then 
								uo.say("guards")
								uo.playwav("FrsUndrAttack.wav" ) ; pip2.wav
							end if
							hiding()
							uo.warmode(0) 
							
							wait(1500)
							k=k+1
							uo.playwav("pip2l.wav" ) ; pip2.wav
						wend
						
						;' покупаем реги или что там еще раз
						buyVendor(ven, "BScr")
						if MyMoney == UO.Gold  then
							printincolor("No items bought again. Go to the next point", clp)
							uo.playwav("pip1.wav" )
						end if
						
						
					else
						MyMoney = UO.Gold
						printincolor("buy complete success", clg)
						uo.playwav("ding.wav" ) 
					end if
					
					
					# 'добираем реги у соседних вендоров
					
					if uo.getX()<2918 and uo.getX()> 2911 then
						ChaserXY(2918,668)
						ChaserXY(2913,665)
						printincolor("Try to buy from vendor 2913,665  Vesper", clp)
						
						;' покупаем реги или что там еще раз
						buyVendor("Bryant", "BScr")

						if MyMoney == UO.Gold  then
							printincolor("No items bought again. Go to the next point", clp)
							uo.playwav("pip1.wav" )
						end if
						
					end if
					

					if uo.getX()<1418 and uo.getX()> 1413 then
						ChaserXY(1410,1600)
						;ChaserXY(2913,665)
						printincolor("Try to buy from vendor 1410,1600 BritIns  ", clp)
						;' покупаем реги или что там еще раз
						buyVendor("Yusuf", "BScr") ### !!!!!!!!
						if MyMoney == UO.Gold  then
							printincolor("No items bought again. Go to the next point", clp)
							uo.playwav("pip1.wav" )
						end if
						
					end if
					
					if uo.getX()<1599 and uo.getX()>1596 and uo.getY()<1653 and uo.getY()>1648 then
						ChaserXY(1593,1648)
						ChaserXY(1594,1657)
						printincolor("Try to buy from vendor 1592,1657 Brit daln" , clp)
						;' покупаем реги или что там еще раз
						buyVendor("Winona", "BScr")
						if MyMoney == UO.Gold  then
							printincolor("No items bought again. Go to the next point", clp)
							uo.playwav("pip1.wav" )
						end if
						
					end if
					
					if uo.getX()<5735 and uo.getX()>5730 and uo.getY()<3199 and uo.getY()>3190 then
						ChaserXY(5736,3196)
						;ChaserXY(1592,1657)
						printincolor("Try to buy from near vendor 5736,3196", clp)
						;' покупаем реги или что там еще раз
						buyVendor(ven, "BScr")
						if MyMoney == UO.Gold  then
							printincolor("No items bought again. Go to the next point", clp)
							uo.playwav("pip1.wav" )
						end if
						
						printincolor("Try to buy from near vendor 4547,851", clp)
						;' покупаем реги или что там еще раз
						buyVendor(ven, "BScr")
						if MyMoney == UO.Gold  then
							printincolor("No items bought again. Go to the next point", clp)
							uo.playwav("pip1.wav" )
						end if
						wait (200)
						ChaserXY(4550,859)
						;ChaserXY(1592,1657)
						printincolor("Try to buy from near vendor MoonGlow 4550,859", clp)
						;' покупаем реги или что там еще раз
						buyVendor(ven, "BScr")
						if MyMoney == UO.Gold  then
							printincolor("No items bought again. Go to the next point", clp)
							uo.playwav("C:\Program Files\Drago World\Ultima Online\scripts\pip1.wav" )
						end if
						
						
					end if
					
					;hiding()
					uo.warmode(0) 
					wait(500)
				else 
					uo.ignore(rserial)
				printincolor("479 ignore(rserial)="+rserial,clr)
				end if
			
				oldX=MyX
				oldY=MyY
				printincolor("498 MyX="+str(MyX)+" MyY="+str(MyY), 5)
			
			end if
			blankR:
			;printincolor(" 469 blankR: Search next rune", 5)
			checklag()
			uo.ignore(rserial)
			uo.findtype (Runka[i],"0x0000","backpack")
			wait(100)
		wend
	next
	restart1:
	printincolor("495 IgnoreReset() ",1152)
	UO.IgnoreReset() 
	wait (1000)
wend
printincolor("Weight Limit exceeded", clr)

checklag()
RunebookRecall(9)
checklag()
DropRegSunduk()
goto RegAgain
end sub
###

############################################################
sub GetBlanklRune()
var curweapon=0, i, RNum, runa, fRCL=0,RuneL
var OldX=uo.GetX()
var OldY=uo.GetY()
var Time, ven=""

dim Runka[4]
Runka[0]="0x1F14"
Runka[1]="0x1F15"
Runka[2]="0x1F16"
Runka[3]="0x1F17"

dim RunID[20]  ; серийники рун
var rserial, bserial,rname, rcharges ; серийник рункм

uo.charprint("0x09DC","Get Rune begin!! ")
checklag()
UO.IgnoreReset() 
UO.Deletejournal()
wait(100)
RNum=0
for i=0 to 3 

	checklag()
	uo.findtype (Runka[i],"0x0000","-1")
	
	while UO.FindCount() > 0 
		uo.deletejournal()
		
		checklag()
		uo.click("finditem")
		wait(100)
			RuneL=uo.injournal("Rune")-1
			rname=UO.Journal(RuneL)
			rcharges=UO.Journal(RuneL+1)
		rserial=uo.getserial("finditem")
		;printincolor(rname,clb)
		
		if instr(rname,"Blank")>-1 then
			RNum=RNum+1
			bserial=uo.getserial("finditem")
			;printincolor(rname,cla)
			;printincolor(bserial,cla)
			;return rserial
		else
		
		end if
		checklag()
		uo.ignore(rserial) ; если не бланк - игнорим и бланк игнорим
		uo.findtype (Runka[i],"0x0000","-1")
		wait(200)
	wend
	wait(100)
next

checklag()
UO.IgnoreReset() 
printincolor("RNum="+str(RNum),clr)

;если бланк рунок меньше 5 - покупаем
if RNum<5 then
	uo.set("buydelay","4000")
	UO.Buy("BlankRunes",ven)
	wait(4300)
	printincolor("BlankRunes buy complete", clg)
	wait(100)
	uo.say("bye")
	wait(200)
	uo.playwav("piip1.wav" ) 
end if

printincolor("90 bserial= "+bserial,clb)

return bserial
end sub




########################################################
sub RunebookRecall(n) 
var oldX=uo.getX() 
var oldY=uo.getY() 
var time
;ID=0x40239516 Type=0x0EFA 
repeat 
uo.Exec('warmode 0') 
uo.UseObject('0x40239516') 
wait(1000) 
uo.LClick(135, n*15+55) 
wait(500) 
uo.LClick(135, n*15+55) 
time=uo.Timer() 
repeat 
wait(500) 
until oldX<>uo.getX() or oldY<>uo.getY() or uo.Life==0 or uo.InJournal('needs') or time+200<uo.Timer() 
uo.DeleteJournal() 
until oldX<>uo.getX() or oldY<>uo.getY() 

end sub 

##################################################
sub DropRegSunduk() ; перекладка руды в сундук
hiding()
if uo.waiting() then
	uo.canceltarget()
endif
VAR a,Exit
VAR UnloadCont='0x4003205c' ;  '0x40041342' ; АЙДИ сундука для руды
DIM Reg[9]
Reg[0]="0x0E34" ; blank
Reg[1]="0x0F8C" #SA
Reg[2]="0x0F86" #MR
Reg[3]="0x0F7B" #BM
Reg[4]="0x0F84" #GA
Reg[5]="0x0F85" #GI
Reg[6]="0x0F8D" #SS
Reg[7]="0x0F88" #NS
Reg[8]="0x0F7A" #BP

UO.SetReceivingContainer(UnloadCont)
wait(500)
For a=0 to 8
	Exit=0
	repeat
	UO.FindType(Reg[a])
	if UO.GetQuantity("finditem")>0 then
		UO.Grab("0","finditem")
		wait(1500)
		checklag()
	Else
		Exit=1
	endif
	until Exit==1
Next
UO.UnSetReceivingContainer()
end sub

###################################################
sub buyVendor(VenName, buyList)
VAR vend, ven=VenName, i=401
var MyMoney
MyMoney=UO.Gold
uo.set("buydelay","4000")
UO.Buy(buyList,ven)
wait(4300)
uo.say("bye")
wait(200)
if MyMoney == UO.Gold  then
	printincolor("No items bought again. Go to the next point", clp)
	uo.playwav("piip1.wav" )
else
	uo.playwav("pip2.wav" ) 
end if
end sub

Sub CheckLag()
UO.DeleteJournal()
UO.Click("backpack")
repeat
	Wait(300)
until UO.InJournal("backpack")
endsub

sub PrintInColor(text,color)
# PrintInColor("здесь текст",'цвет текста')
# красный   - '38' или '0x0026'  # темно-бирюзовый - '83' или '0x0053'
# оранжевый - '43' или '0x002B'  # голубой    - '89'  или '0x0059'
# желтый    - '53' или '0x0035'  # синий      - '3'   или '0x0003'
# зеленый   - '63' или '0x003F'  # фиолетовый - '120' или '0x0078'
# '1088' - по умолчанию
# 1152 - бирюзовый 1151 - черный 1155 - фиолетовый 1156 - белый  1158 - кр 1161 - синий 1162 - темно зел 1166 ткр 1169 сз 
# 2500 2524 - оранж  2517 кр 2567 малин 2566=0x0A06 белый 
#  2998 - белый 3008 3221 3600 и выше - контур


UO.ConColor(color)
;UO.Exec('set quiet 0')   # Показывать сообщения Injection.
UO.Print(text)
;UO.Exec('set quiet 1')   # Не показывать сообщения Injection.
UO.ConColor('1088')
endsub

sub ChaserXY(X,Y)
VAR dx, dy, dxOld, dyOld, i

var cdist
;cdist=uo.getdistance(target)

i=0
While i<30
	i=i+1
	If  not uo.dead() Then
		dx=X-UO.GetX()
		dy=Y-UO.GetY()
		;If UO.GetDistance(Target)<3 Then
		;return
		;Endif
	else
		Return
	Endif
	
	if abs(dx)<1 and abs(dy)<1 then
		return
	end if
	
	If dx<>0 AND dy<>0 Then
		If dx>0 AND dy>0 Then
			UO.Press(40) ; DownArrow
		Endif
		
		If dx>0 AND dy<0 Then
			UO.Press(39) ; RightArrow
		Endif
		
		If dx<0 AND dy>0 Then
			UO.Press(37) ; LeftArrow
		Endif
		
		If dx<0 AND dy<0 Then
			UO.Press(38) ; UpArrow
		Endif
	Endif
	
	If dx<>0 AND dy==0 Then
		If dx>0 Then
			UO.Press(34) ; PgDown
		Endif
		
		If dx<0 Then
			UO.Press(36) ; Home key
		Endif
	Endif
	
	If dx==0 AND dy<>0 Then
		If dy>0 Then
			UO.Press(35) ; End
		Endif
		
		If dy<0 Then
			UO.Press(33) ; PgUp
		Endif
	Endif
	
	dx=X-UO.GetX()
	dy=Y-UO.GetY()
	
	if abs(dx)<1 and abs(dy)<1 then
		return
	end if
	
	wait (walkwait)
Wend

end sub

############################################################
Sub InStr(Source, subStr)
var n = len(subStr)
var j
if len(Source)>=len(subStr) then
	for var i = 0 to len(Source)-n
		j = 0
		while (j < n) and (Source[i+j] == subStr[j])
			j = j+1;
		wend
		if j == n then
			return i
		end if
	next
else
end if
return -1
end sub

#####################################
sub abs(a)
Var b
If a<0 Then
	b=-a
Else
	b=a
endif
return b
endsub