# Name: Lumberjack Near Me (Extended)
# Description: Chops trees in successive 10x10 areas until stopped.
# Author: Revisado por ChatGPT e otimizado por Bard
from ClassicAssist.UO.Data import Statics
from ClassicAssist.UO import UOMath
from Assistant import Engine
from System import Convert
import clr
clr.AddReference('System.Core')
# Configurações do Usuário ////////////////////////////////////////////////////////////////////
packAnimals = [0x208c1, 0x208c2, 0x208c0] # IDs dos animais de carga
logs = [0xce0, 0xcda, 0xce3, 0xcdd, 0xcd8, 0xcd6, 0xcd0, 0xcd3, 0xce6, 0xccd, 0xcdc, 0xc9e, 0xcda, 0xce3] # IDs de madeiras no servidor
dropLogs = False # Para descartar a madeira no chão, altere para True
moveLogsToPackAnimal = True # Mover madeiras para animais de carga
# Variáveis Internas /////////////////////////////////////////////////////////////////////////
packCount = 0 # Não alterar
maxPackCnt = len(packAnimals) # Não alterar
# Funções Principais ////////////////////////////////////////////////////////////////////////
def GetNearestTree():
"""Busca árvores em uma área 10x10 ao redor do jogador."""
trees = []
for x in range(Engine.Player.X - 10, Engine.Player.X + 10):
for y in range(Engine.Player.Y - 10, Engine.Player.Y + 10):
statics = Statics.GetStatics(Convert.ChangeType(Engine.Player.Map, int), x, y)
if statics:
for s in statics:
if s.Name.Contains("tree"):
trees.append({'X': s.X, 'Y': s.Y})
return trees
def moveToPackAnimal():
"""Move a madeira do jogador para o animal de carga."""
global packCount
pack = packAnimals[packCount]
for log in logs:
while FindType(log, -1, 'backpack'):
MoveItem("found", pack)
Pause(1000)
packCount += 1
if packCount >= maxPackCnt:
packCount = 0
def CutLogs():
"""Transforma madeira bruta em tábuas."""
while FindType(0x1bdd, -1, "backpack"):
UseLayer("TwoHanded")
WaitForTarget(5000)
Target("found")
Pause(1000)
def moveToTree(tree):
"""Move-se até uma árvore."""
i = 0
while X("self") != tree['X'] or Y("self") != tree['Y']:
if i >= 3:
HeadMsg("Pathfinding falhou. Ignorando árvore.", "self")
return False
HeadMsg("Pathfinding", "self")
Pathfind(tree['X'], tree['Y'], 0)
Pause(2000)
i += 1
return True
def lumberjack():
"""Corta madeira até que o local esteja sem recursos."""
# Corta a árvore uma vez
UseLayer("TwoHanded")
WaitForTarget(1000)
TargetTileOffsetResource(-1, 0, 0)
Pause(1100)
# Aguarda a mensagem de que não há mais madeira no local
while not InJournal("Não tem mais madeira neste local"):
Pause(1000) # Aguarda um segundo antes de verificar o journal novamente
ClearJournal() # Limpa o journal
if dropLogs:
for log in logs:
while FindType(log, -1, 'backpack'):
MoveItemOffset("found", 0, 1, 0, -1)
Pause(1000)
if moveLogsToPackAnimal:
moveToPackAnimal()
# Execução Principal ////////////////////////////////////////////////////////////////////////
while True: # Loop infinito para processar múltiplos tiles 10x10
Trees = GetNearestTree()
if len(Trees) > 0:
TotalTrees = len(Trees)
SysMessage(str(TotalTrees) + " árvores encontradas na fila")
for tree in Trees:
tree['X'] += 1 # Previne que o personagem fique preso
if moveToTree(tree):
lumberjack()
TotalTrees -= 1
SysMessage(str(TotalTrees) + " árvores restantes!")
Msg("all follow me") # Comando para chamar animais de carga
CutLogs()
else:
SysMessage("Sem árvores na área atual. Movendo para uma nova área...")
# Move o jogador para um novo tile 10x10 (ajustar deslocamento conforme necessário)
newX = Engine.Player.X + 20
newY = Engine.Player.Y
Pathfind(newX, newY, 0)
Pause(3000)