TazUO Lumberscript: Unterschied zwischen den Versionen
Aus UO-Sigena Wiki
(Die Seite wurde neu angelegt: „Dieses Script ist für TazUO Legion Scripts (Python). Aktuell gibt es nur eine Sunnaroute. <nowiki> # Important: You need to define a "detect item" graphic #…“) |
(kein Unterschied)
|
Version vom 19. Oktober 2025, 02:39 Uhr
Dieses Script ist für TazUO Legion Scripts (Python). Aktuell gibt es nur eine Sunnaroute.
# Important: You need to define a "detect item" graphic
# At least one of this needs to be in your backpack.
# It is used to detect the container ID of your pack animal.
# Said item must only exist directly in your main backpack.
# This is due to odd pack animal container handling on the Sigena freeshard.
# TODO: Count successful minings per tile to avoid "useless mines" to get the empty message
# TODO: max count clay: 3, ore: 9
import API
food_gid = 0x1728
#detect_item_gid = 0xeed # Gold / Kristall
detect_item_gid = 3617 # Bandage
packanimal_gids = [0x0124, 0x0123]
axe_gid = 0x13AF
lumber_range = 1
tile_marking_hue = 31
active_route = "sunna"
wood_gid = 0x1BDD
lumber_messages = {
"fail" : ["Es gelingt euch nicht, verwertbares Holz zu schlagen."],
"success": ["in Euren Rucksack.", ],
"empty": ["Hier gibt es kein verwertbares Holz."]
}
pack_full_message = "Euer Tier kann ein solches Gewicht nicht tragen."
filter_tree_names = [
# anything ending with 'baum' is anyway valid.
"Walnuss",
"Esche",
"Kastanie",
"Buche",
"Eiche",
"Kiefer",
"Kirschbaum",
"Zeder",
"Weide",
"Baum",
"o'hii Baum", #wtf?
]
def main():
packis = detect_pack_animals()
move_ore_to_packanimal(packis)
for waypoint in waypoints[active_route]:
API.SysMsg(f"Pathfind: {waypoint[0]}, {waypoint[1]}", 33)
API.Msg("all follow me")
API.Pathfind(x=waypoint[0], y=waypoint[1], z=waypoint[2], distance=0, wait=True, timeout=20)
for tree in get_trees_in_range():
lumber_result = -1
while lumber_result != 2:
API.Pause(0.01)
lumber_result = hack(tree)
if API.Player.WeightMax < API.Player.Weight + 15:
move_ore_to_packanimal(packis)
API.MarkTile(tree.X, tree.Y, tile_marking_hue, API.GetMap())
move_ore_to_packanimal(packis)
def detect_pack_animals():
API.Pause(1)
packis = {}
animal_serials = get_animal_serials()
for packi_serial in animal_serials:
packis[packi_serial] = {
"container": detect_packi_container_id(packi_serial),
"is_full": False
}
return packis
def detect_packi_container_id(packi_serial) -> int:
API.UseObject(packi_serial)
detect_item = API.FindType(detect_item_gid, API.Backpack)
API.QueueMoveItem(detect_item, packi_serial, 1)
API.Pause(0.5)
items = API.FindTypeAll(detect_item_gid)
for item in items:
if item.Container != API.Backpack:
API.QueueMoveItem(item, API.Backpack)
return item.Container
return 0
def get_animal_serials():
animals = []
mobiles = API.GetAllMobiles()
if mobiles:
for mob in mobiles:
if mob.Graphic in packanimal_gids:
animals.append(mob)
API.SysMsg(f"Found Packi: {mob.Name}, {mob.Serial}", 33)
return animals
def move_ore_to_packanimal(packis):
API.Msg("all come")
API.Pause(0.5)
for pack_serial in packis:
if packis[pack_serial]["is_full"]:
continue
items_to_move = []
ores = API.FindTypeAll(graphic=wood_gid, container=API.Backpack)
if ores:
items_to_move += ores
API.UseObject(pack_serial)
API.Pause(0.1)
for item in items_to_move:
API.QueueMoveItem(item.Serial, packis[pack_serial]["container"])
API.Pause(0.5)
# TODO: Improve. Don't rely on journal?
if API.InJournal(msg=pack_full_message, clearMatches=True):
packis[pack_serial]["is_full"] = True
def hack(tree) -> int:
axe = get_axe()
API.UseObject(axe.Serial)
API.WaitForTarget()
API.Target(x=tree.X, y=tree.Y, z=tree.Z, graphic=tree.Graphic)
while True:
API.Pause(0.1)
if API.InJournalAny(msgs=lumber_messages["success"], clearMatches=True):
return 1
if API.InJournalAny(msgs=lumber_messages["fail"], clearMatches=True):
return 0
if API.InJournalAny(msgs=lumber_messages["empty"], clearMatches=True):
return 2
def get_trees_in_range():
trees = []
for x in range(lumber_range * -1, lumber_range + 1):
for y in range(lumber_range * -1, lumber_range + 1):
statics = API.GetStaticsAt(x + API.Player.X, y + API.Player.Y)
if not statics:
continue
for static in statics:
if static.Hue != tile_marking_hue and (static.Name.endswith("baum") or static.Name in filter_tree_names):
API.SysMsg(f"Tree {static.X}, {static.Y}, {static.Z}, {static.Name}", 33)
trees.append(static)
return trees
def get_axe():
# Check weapon hand first
axe = API.FindLayer("OneHanded")
if axe and axe.Graphic == axe_gid:
return axe
# Search rest of your backpack
axe = API.FindType(graphic=axe_gid)
if not axe:
raise Exception("No axe found")
return axe
waypoints = {
"sunna": [
[1732, 1195, 0],
[1733, 1198, 0],
[1739, 1204, 5],
[1748, 1204, 5],
[1749, 1208, 6],
[1748, 1211, 0],
[1756, 1204, 5],
[1758, 1199, 0],
[1760, 1201, 0],
[1760, 1206, 5],
[1772, 1205, 5],
[1775, 1202, 0],
[1779, 1199, 0],
[1779, 1205, 0],
[1778, 1208, 5],
[1776, 1217, 0],
[1780, 1215, 0],
[1784, 1215, 1],
[1785, 1211, 6],
[1786, 1208, 5],
[1791, 1203, 2],
[1790, 1213, 0],
[1794, 1214, 0],
[1795, 1211, 0],
[1797, 1220, 0],
[1799, 1225, 0],
[1807, 1218, 0],
[1809, 1224, 5],
[1801, 1232, 0],
[1801, 1236, 0],
[1800, 1237, 0],
[1804, 1242, 5],
[1809, 1239, 5],
[1815, 1233, 5],
[1815, 1231, 5],
[1816, 1230, 5],
[1813, 1228, 5],
[1813, 1220, 0],
[1826, 1220, 0],
[1828, 1225, 0],
[1824, 1229, 5],
[1821, 1236, 5],
[1821, 1246, 11],
[1817, 1247, 10],
[1813, 1250, 5],
[1806, 1251, 5],
[1805, 1253, 1],
[1800, 1251, 0],
[1801, 1255, 0],
[1804, 1257, 0],
[1809, 1256, 5],
[1813, 1258, 5],
[1818, 1261, 10],
[1820, 1257, 12],
[1819, 1254, 10],
[1824, 1250, 10],
[1828, 1250, 15],
[1831, 1246, 11],
[1829, 1241, 10],
[1833, 1240, 10],
[1837, 1229, 5],
]
}
main()