Forum in READ ONLY mode! All questions and discussions on Discord official server, invite link: https://discord.gg/VxsGzJ7

Автолабер на питоне.

Only working scripts
Post Reply
tovarisch
Posts: 6
Joined: 27.08.2012 13:15

Автолабер на питоне.

Post by tovarisch »

Собсно давно у меня лежит, используется для DRW. Выходим посреди леса и включаем скрипт. Вырубает лес в радиусе 40ка тайлов, обходит энтов, хайдится кормится, сбрасывает все в дом. Настроить нужно только def Home чтобы после порта чел подходил к дому без глитчей на ступеньках.

Code: Select all

from datetime import datetime
from datetime import timedelta
import math
import random


visitedTrees	= []
chopRadius		= 40
forestRune		= ''
scriptBox		= 0x40393B06
reaperType		= 0x002F
foodType		= 0x103B # òèï åäû äëÿ êîðìåæêè
logsType		= 0x1BDD
runebook		= 0x403F9514
homeRune		= '33'
exeType			= 0x0F47
ents			= []
XO				= GetX(Self())
YO				= GetY(Self())


def grounZero(a, delta=0.0000000001):
	if abs(a) < delta:
		return 0
	else:
		return a

def myCeil(a):
	return int(math.copysign(math.ceil(abs(a)),a))


def recallRB(runeName):
	cx = GetX(Self())
	cy = GetY(Self())
	UseObject(runebook)
	WaitGump(runeName)
	Wait(10000)
	CheckLag(60000)
	if cx == GetX(Self()) and cy == GetY(Self()):
		return False
	else:
		return True


def findReaper():
	return FindType(reaperType, Ground())
	
def markEnt(x, y, id):
	for ent in ents:
		if ent['id'] == id:
			return False
	ents.append({'x': x, 'y': y, 'id': id, 'resetTime': datetime.now() + timedelta(minutes=30)})
	return True

def isEntNear(tile):
	for ent in ents:
		if Dist(ent['x'], ent['y'], tile['x'], tile['y'])<17:
			if ent['resetTime'] < datetime.now():
				ents.remove(ent)
			else:
				return True
	return False
	

def markVisited(tree):
	tree['resetTime'] = datetime.now() + timedelta(minutes=30)
	visitedTrees.append(tree)


def isVisited(treeX):
	for tree in visitedTrees:
		if (tree['x'] == treeX['x']) and (tree['y'] == treeX['y']):
			if tree['resetTime'] < datetime.now():
				visitedTrees.remove(tree)
				return False
			else:
				return True
	return False


def Home(waitMS):
	recallRB('33')
	CheckLag(60000)
	MoveXY(810, 1480, True, 0, False)
	OpenDoor()
	Wait(300)
	MoveXY(810, 1479, True, 0, False)
	OpenDoor()
	Wait(300)
	MoveXY(809, 1475, True, 0, False)
	CheckLag(60000)

	Wait(1000)
	UseObject(scriptBox)
	Wait(1000)
	CheckLag(60000)

	MoveItems(Backpack(), logsType, 0xFFFF, scriptBox, 0, 0, 0, 1000)
	CheckLag(60000)

	food = FindType(foodType, Backpack())
	if GetQuantity(food) < 10:
		Grab(FindType(foodType, scriptBox), 20)
	CheckLag(60000)

	FindType(exeType, Backpack())
	if FindCount() < 1:
			Grab(FindType(exeType, scriptBox), 1)
	CheckLag(60000)

	Wait(waitMS)
	Disconnect()


def Iddler():
	if FeedTime	< datetime.now():
		UseType(foodType, 0xFFFF)
		# FeedTime = datetime.now() + timedelta(minutes=5)


def Sisuritu():
	reaper = findReaper()
	if reaper != 0:
		print('reaper found: '+ GetName(reaper))
		myX =  GetX(Self())
		myY =  GetY(Self())
		entX =	GetX(reaper)
		entY =  GetY(reaper)
		markEnt(entX, entY, reaper)
		toX = int(myX + math.copysign(25,myX-entX))
		toY = int(myY + math.copysign(25,myY-entY))
		MoveXY(toX, toY, True, 1, True)
		if not Hidden():
			UseSkill('Hiding')
		return True
	return False


def ChopTree(tree):
	print (tree)
	tryes = 0
	if NewMoveXY(tree['x'], tree['y'], True, 1, False):
		Wait(200)
		while not Dead():
			if not Hidden():
				UseSkill('Hiding')
				Wait(4000)
			ClearJournal()
			WaitTargetTile(tree['tile'] ,tree['x'] ,tree['y'], 0)
			UseType(0x0F47, 0xFFFF)
			while InJournal('You put the|any useable wood.|no logs here to chop.|reach this.|too far away.') < 1:
				Wait(500)
				CheckLag(60000)
				if Sisuritu():
					return False
			tryes+=1
			if InJournal('There are no logs here to chop.|reach this.|too far away.')>0 or tryes > 18:
				markVisited(tree)
				return True
			Wait(200)


def FindTree():
	treeTiles = [3240,3242,3277,3283,3286,3288,3289,3290,3291,3294,3296,3299,3302,3393,3394,3395,3396,3415,3416,3417,3418,3419,3438,3439,3440,3441,3442,3460,3461,3462,3480,3482,3488]
	for r in range(1,5):
		sectors = r*8
		for cutStep in range(sectors):
			deltaX=myCeil(grounZero(math.cos((cutStep*math.pi*2/sectors)))*r)+GetX(Self())
			deltaY=myCeil(grounZero(math.sin((cutStep*math.pi*2/sectors)))*r)+GetY(Self())
			if Dist(XO, YO, deltaX, deltaY)<chopRadius and not isVisited({'x':deltaX, 'y':deltaY}) and not isEntNear({'x':deltaX, 'y':deltaY}):
				staticTiles = ReadStaticsXY(deltaX, deltaY, 1)
				for tile in staticTiles:
					if tile.Tile in treeTiles:
						return {'tile': tile.Tile, 'x': deltaX, 'y': deltaY}
	return False


SetWalkUnmountTimer(400)
SetRunUnmountTimer(400)
SetWalkMountTimer(400)
SetRunMountTimer(400)
DropDelay = 1000
SetFindDistance(17)
FeedTime = datetime.now() + timedelta(minutes=5)

while not Dead() and Connected():
	Sisuritu()
	tree = FindTree()
	if tree:
		ChopTree(tree)
	else:
		print('no fresh trees, finding new loc')
		newX = random.randint(-chopRadius,chopRadius)+XO
		newY = random.randint(-chopRadius,chopRadius)+YO
		print(str(newX)+':'+str(newY)+'? hmm.. ')
		if not isEntNear({'x':newX, 'y':newY}):
			print('Ok its free and safe')
			NewMoveXY(newX, newY, True, 1, False)
		else:
			print('no, there is Ent!')
	if Weight() > Str()*4:
		print('well done, going home')
		Home(0)
	else:
		print('Having '+str(Weight())+' stones of lumber')	
	Iddler()
	Wait(400)
else:
	Beep()
	Wait(5000)
	Beep()
	Wait(5000)
	Beep()
	Wait(5000)
	Beep()
	Wait(5000)
tovarisch
Posts: 6
Joined: 27.08.2012 13:15

Re: Автолабер на питоне.

Post by tovarisch »

Кстати помнит о свежести деревьев и к пустым не подходит пока те не реснутся
Oldboy
Posts: 1
Joined: 29.04.2015 2:05

Re: Автолабер на питоне.

Post by Oldboy »

'BEGIN' expected и все *( что не так ?
Тaксидермист
Neophyte
Neophyte
Posts: 21
Joined: 27.02.2015 3:50

Re: Автолабер на питоне.

Post by Тaксидермист »

Это как-бэ питон, а не паскаль.
Post Reply