#!/usr/bin/env python3 """Fix the 16 bone mismatches found in the audit. Category A — boneless NPCs that should have NO bones: remove their bone rows. Category B — wrong bone type: replace with correct bone item ID. Category C — missing bones entirely (BALROG): add Java's drops + ASHES. """ import sys, os, subprocess sys.path.insert(0, '/Users/tomassimkus/VS/openrsc-develop') os.chdir('/Users/tomassimkus/VS/openrsc-develop') from update_drops import parse_update_sql, write_update_sql from compare_drops import load_enums, BONE_ITEM_IDS _, npc_id_to_name, _, item_id_to_name = load_enums() # Category A: NPCs that should be boneless (remove any bone-item row with weight=0) BONELESS = [206, 244, 384, 473, 613, 614, 665, 713, 757, 758, 759, 760] # Category B: wrong bone item, fix in place # (npc_id, old_iid, new_iid) WRONG_BONE = [ (645, 20, 181), # OTHAINIAN: Bones → Ashes (647, 20, 181), # HOLTHION: Bones → Ashes (651, 20, 413), # GOBLIN_GUARD: Bones → Big Bones ] # Category C: BALROG needs full sync (TEDDY_HEAD guaranteed + ASHES) BALROG_ID = 809 # We need pk_npcdrops_update.sql to drive update_drops.py. Sync it with pk_npcdrops.sql import shutil shutil.copy("pk_npcdrops.sql", "pk_npcdrops_update.sql") print("Synced pk_npcdrops.sql → pk_npcdrops_update.sql for editing") print() # Step 1: BALROG via add-java (no existing rows) print("Step 1: Add BALROG drops from Java...") result = subprocess.run( ["python3", "update_drops.py", "add-java", str(BALROG_ID)], capture_output=True, text=True, ) if "Added drops" in result.stdout: print(" ✓ BALROG added") else: print(f" ⚠ unexpected: {result.stdout[:200]} | err: {result.stderr[:200]}") print() # Steps 2 & 3: direct SQL edits header, rows, footer = parse_update_sql() # Step 2: Remove bone rows from Category A removed_a = 0 new_rows = [] for nid, amt, iid, w, idx in rows: if nid in BONELESS and w == 0 and iid in BONE_ITEM_IDS: removed_a += 1 print(f" Removed bone row: NPC {nid} ({npc_id_to_name.get(nid,'?'):<20}) item {item_id_to_name.get(iid,'?')}({iid})") continue new_rows.append((nid, amt, iid, w, idx)) print(f"\nStep 2: Removed {removed_a} bone rows from boneless NPCs") print() # Step 3: Fix wrong-bone NPCs print("Step 3: Replacing wrong bone items...") wrong_bone_map = {nid: (old, new) for nid, old, new in WRONG_BONE} fixed_b = 0 for i, row in enumerate(new_rows): nid, amt, iid, w, idx = row if nid in wrong_bone_map and w == 0: old, new = wrong_bone_map[nid] if iid == old: new_rows[i] = (nid, amt, new, w, idx) fixed_b += 1 print(f" NPC {nid} ({npc_id_to_name.get(nid,'?'):<14}) {item_id_to_name.get(old,'?')}({old}) → {item_id_to_name.get(new,'?')}({new})") print(f"\nFixed {fixed_b} wrong-bone rows") # Sort & write new_rows.sort(key=lambda r: (r[0], 0 if r[3] == 0 else 1, r[3], r[2])) write_update_sql(header, new_rows, footer) # Copy back to pk_npcdrops.sql shutil.copy("pk_npcdrops_update.sql", "pk_npcdrops.sql") shutil.copy("pk_npcdrops_update.sql", "pk_npcdrops_p2p_update.sql") print() print("Wrote changes back to pk_npcdrops.sql and pk_npcdrops_p2p_update.sql")