#!/usr/bin/env python3 """On the 5 weaker bosses (RED/BLUE_DRAGON, GREATER_DEMON, LESSER_DEMON, LESSER_DEMON_WMAZE), lower DRAGON_SWORD and DRAGON_AXE weight to match each NPC's LEFT_HALF_DRAGON_SQUARE_SHIELD weight, so all dragon items on these monsters drop at the same rate. Leaves the 4 main bosses (KBD, Black Dragon, Black Demon, Fire Giant) untouched. """ import sys, os 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 from collections import defaultdict _, npc_id_to_name, _, _ = load_enums() WEAKER = [201, 202, 184, 22, 181] # Red, Blue, Greater, Lesser, Lesser WMaze DRAGON_SWORD = 593 DRAGON_AXE = 594 LEFT_HALF = 1277 header, rows, footer = parse_update_sql() # Sum LEFT_HALF weights per weaker NPC (it can have multiple entries) left_w = defaultdict(int) for nid, _, iid, w, _ in rows: if nid in WEAKER and iid == LEFT_HALF: left_w[nid] += w # Remove existing DRAGON_SWORD and DRAGON_AXE rows for these NPCs new_rows = [r for r in rows if not (r[0] in WEAKER and r[2] in (DRAGON_SWORD, DRAGON_AXE))] removed = len(rows) - len(new_rows) # Add new sword/axe rows with weight = LEFT_HALF weight on each NPC added = [] for nid in WEAKER: w = left_w[nid] if w > 0: new_rows.append((nid, '1', DRAGON_SWORD, w, 0)) new_rows.append((nid, '1', DRAGON_AXE, w, 0)) added.append((nid, w)) 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) # Verify final rates final_total = defaultdict(int) for nid, _, _, w, _ in new_rows: if nid in WEAKER: final_total[nid] += w print(f"Removed {removed} old sword/axe entries.\n") print(f"{'NPC':<24} {'weight':>8} {'sword/axe rate':>16} {'left rate (was)':>18}") print("-" * 75) for nid, w in added: name = npc_id_to_name.get(nid, "?") tot = final_total[nid] odds = round(tot / w) if w > 0 else 0 left_odds = round(tot / left_w[nid]) if left_w[nid] > 0 else 0 print(f"{name:<24} {w:>8,} {'1/'+f'{odds:,}':>16} {'1/'+f'{left_odds:,}':>18}")