Files
isaac-port/notes/_tools/b5tools/boss.py
T
shweetandClaude Opus 5.5 ad8f933086 Salvage Repentance+ 1.9.7.17 decompilation toolkit, notes and name database
Ghidra 12.2 project and full dump of isaac-ng.exe v1.9.7.17, query scripts, notes
indexed by entity, anm2/rooms reimplementations, and db/ (names + fields) that
build.sh re-applies. Fixes awk numeric address comparison in find.sh/decompile.sh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 13:08:19 -04:00

44 lines
2.2 KiB
Python

"""boss.py KEY "Name" ITEM STAGE[/alt]:COUNT...: registers a boss: bosses.json (appended), its 1% item and the Rebirth
boss pool (itempools.json), COUNT entries in each named stage's pool (its alt's with /alt; a pool listing weight-1 bosses
four times takes 4) and one in The Void's."""
import json, re, sys
V = 'resources/data/versions/rebirth/'
key, name, item, stages = sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4:]
p = V + 'bosses.json'; s = open(p).read()
if f'"key": "{key}"' not in s:
s = re.sub(r'(\n \{"key": [^\n]*\})\n \]', lambda m: m.group(1) + f',\n {{"key": "{key}", "name": "{name}"}}\n ]', s, count=1)
open(p, 'w').write(s)
p = V + 'itempools.json'; s = open(p).read()
if f'"bosses": ["{key}"]' not in s:
s = s.replace(' {"key": "rebirth_boss_pool"',
f' {{"key": "{key}_{item}", "bosses": ["{key}"], "items": ["{item}"], "one_in": 100}},\n {{"key": "rebirth_boss_pool"', 1)
s = re.sub(r'("key": "rebirth_boss_pool", "bosses": \[[^\]]*)\]', lambda m: m.group(1) + f', "{key}"]', s, count=1)
open(p, 'w').write(s)
p = V + 'stages.json'; s = open(p).read()
def pool_add(start, count, end):
"""Adds count entries to the bosses list between start and end (unless it names the boss already); a stage with
none of its own (one inheriting its base's) gets its own."""
global s
m = re.compile(r'"bosses": \[([^\]]*)\]').search(s, start, end)
if m is None:
at = s.index('\n', s.index('"name": ', start)) + 1
s = s[:at] + ' "bosses": [' + ', '.join(f'"{key}"' for _ in range(count)) + '],\n' + s[at:]
return
if f'"{key}"' in m.group(1):
return
s = s[:m.end() - 1] + ''.join(f', "{key}"' for _ in range(count)) + s[m.end() - 1:]
for spec in stages + ['the_void:1']:
stage, count = spec.rsplit(':', 1)
stage, _, alt = stage.partition('/')
at = s.index(f'"key": "{stage}"')
end = s.find('"key": "', at + 1)
end = len(s) if end < 0 else end
if alt:
at = s.index('"alt": {', at)
pool_add(at, int(count), end)
open(p, 'w').write(s)
json.load(open(V + 'stages.json')); json.load(open(V + 'itempools.json')); json.load(open(V + 'bosses.json'))