Created: 7 days ago on 05/12/2025, 05:31:37 AMUpdated: 6 days ago on 05/13/2025, 02:42:01 AM
FileType: No file type provided
Size: 5924
Category: No category provided
Skills: cooking
Hotkey: No hotkey provided
Tags: No tags provided
Description:
Name the script "crafting_trainer_cooking.py".
I am still working on this script. basic fish steak took me to 51.2 but gains stopped there. I will update any other items i need to craft shortly.
Tested on Unchained AoS in noobie dungeon at the infidel forge. Throw the cooked fish steaks on the ground, or take them home when you get full.
This script uses the generic crafting method to cook one fish steak at a time. You need frying pans and a pet named "packy" and need to be standing by a fire source. Name the pet whatever you like but change the variable. You also need to have the inventory of the pack animal open.
Note: if you are near a trash barrel then you can use the section "handle junk if overweight by uncommenting it.
# Razor Enhanced - Generalized Crafting Trainer (Cooking example)
from AutoComplete import *
# -----------------------------
# 🔧 CONFIGURATION (Cooking)
# -----------------------------
skill_name = "Cooking"
tool_id = 0x097F # Frying pan
material_id = 0x097A # fish steak
petName = "packy"
threshold=1
max_to_move=1
training_plan = [
{"min": 50, "max": 51.2, "gumps": [29, 16], "junk": [0x097B]}
]
# -----------------------------
# Inventory Management
# -----------------------------
def get_packy_backpack_serial():
filter = Mobiles.Filter()
filter.Name = petName
filter.RangeMax = 3
filter.IsHuman = False
filter.IsGhost = False
packies = Mobiles.ApplyFilter(filter)
if not packies or not packies[0].Backpack:
Misc.SendMessage("Packy not found or not open!", 33)
return None
return packies[0].Backpack.Serial
def count_items(item_id, container_serial):
items = Items.FindAllByID(item_id, -1, container_serial, False, False)
return sum(item.Amount for item in items)
def move_items_by_type(item_id, source_serial, dest_serial, max_count=100):
items = Items.FindAllByID(item_id, -1, source_serial, False, False)
moved = 0
for item in items:
if moved >= max_count:
break
amount = min(item.Amount, max_count - moved)
Items.Move(item.Serial, dest_serial, amount, 0, 0)
moved += amount
Misc.Pause(900)
def discard_item(item_id, color=-1, container_serial=Player.Backpack.Serial):
trash = Misc.ReadSharedValue("trash")
if trash is None:
Misc.SendMessage("No trash barrel selected!", 33)
return
items = Items.FindAllByID(item_id, color, container_serial, False, False)
for item in items:
Items.Move(item.Serial, trash, item.Amount, 0, 0)
Misc.Pause(600)
def refill_material(threshold=20, max_to_move=100):
restock = Misc.ReadSharedValue("restock")
if restock is None:
Misc.SendMessage("Restock not set!", 33)
Misc.ScriptStop("crafting_trainer_cooking.py")
return
if count_items(material_id, restock) == 0:
Player.HeadMessage(38, "Packy is empty! Stopping.")
Misc.ScriptStop("crafting_trainer_cooking.py")
return
if count_items(material_id, Player.Backpack.Serial) < threshold:
move_items_by_type(material_id, restock, Player.Backpack.Serial, max_to_move)
Misc.Pause(1000)
# -----------------------------
# Tool Use and Crafting
# -----------------------------
def use_tool():
tool = Items.FindByID(tool_id, 0x0, Player.Backpack.Serial, False, False)
if tool:
Items.UseItem(tool)
return True
return False
# -----------------------------
# Junk Cleanup
# -----------------------------
def discard_all(junk_ids):
for item_id in junk_ids:
discard_item(item_id)
# -----------------------------
# MAIN SCRIPT
# -----------------------------
if not Items.FindByID(tool_id, 0x0, Player.Backpack.Serial, False, False):
Player.HeadMessage(38, 'Missing crafting tool!')
Misc.ScriptStop("crafting_trainer_cooking.py")
# Setup: restock + trash barrel
restock = get_packy_backpack_serial()
if restock is None:
Misc.ScriptStop("crafting_trainer_cooking.py")
Misc.SetSharedValue("restock", restock)
if not Misc.CheckSharedValue("trash"):
Player.HeadMessage(68, "Select your trash barrel")
trash = Target.PromptTarget()
Misc.SetSharedValue("trash", trash)
# Get current skill level
skill = Player.GetSkillValue(skill_name)
if skill < 30:
Player.HeadMessage(38, f"Train {skill_name} to 30 manually.")
Misc.ScriptStop("crafting_trainer_cooking.py")
# Match to training range
for entry in training_plan:
if entry["min"] <= skill < entry["max"]:
refill_material(threshold, max_to_move)
if use_tool():
Misc.Pause(1000)
Gumps.WaitForGump(0x38920abd, 15000)
for gump_id in entry["gumps"]:
Gumps.SendAction(0x38920abd, gump_id)
Gumps.WaitForGump(0x38920abd, 15000)
discard_all(entry["junk"])
break
else:
Player.HeadMessage(68, f"{skill_name} training complete!")
Misc.ScriptStop("crafting_trainer_cooking.py")
# Handle junk if overweight
#if Player.MaxWeight - Player.Weight < 20:
# for item_id in sum([e["junk"] for e in training_plan], []):
# discard_item(item_id)
Misc.Pause(1000)