diff --git a/data/ascension_overrides.json b/data/ascension_overrides.json index 59512b5..b45029f 100644 --- a/data/ascension_overrides.json +++ b/data/ascension_overrides.json @@ -4,6 +4,9 @@ "_dungeon_replacements_comment": "When the kg map is the wrong layout for Ascension (e.g. retail/Cata layout vs classic), replace the entire dungeon's map with one we author manually. Coords are in the new map's pixel space (0..width, 0..height). Bosses come from AtlasLoot's per-dungeon entries with cords.", "dungeon_replacements": {}, + "_map_image_swaps_comment": "Swap the rendered image for one or more floors WITHOUT changing the kg enemy/pack/patrol data. Coords stay in kg's pixel space; the swapped image is force-stretched to those dims by the browser. Use this when a different render of the SAME WoW texture is sharper but has a different aspect ratio.", + "map_image_swaps": {}, + "overrides": [ { "tile_key": "stratholme", diff --git a/tools/kg_build_data.py b/tools/kg_build_data.py index 61c2419..e7e60e4 100644 --- a/tools/kg_build_data.py +++ b/tools/kg_build_data.py @@ -226,10 +226,12 @@ def main() -> int: overrides = [] dungeon_replacements = {} + map_image_swaps = {} if OVERRIDES_PATH.exists(): ov_doc = json.loads(OVERRIDES_PATH.read_text()) overrides = ov_doc.get("overrides", []) dungeon_replacements = ov_doc.get("dungeon_replacements", {}) + map_image_swaps = ov_doc.get("map_image_swaps", {}) # Load AtlasLoot map data on demand for dungeon replacements. atlasloot_data = None @@ -389,6 +391,29 @@ def main() -> int: ex["kg_floor_id"] = new_floor ex["ascension_override"] = True + # Map image swap: rescale every coord from kg's pixel space + # (image dimensions in floor_summary) into the new image space. + swap = map_image_swaps.get(d["tile_key"]) + if swap: + new_w, new_h = swap["width"], swap["height"] + for m in entry["maps"]: + sx = new_w / m["width"] + sy = new_h / m["height"] + m["width"], m["height"] = new_w, new_h + for e in m["enemies"]: + e["pos"] = [round(e["pos"][0] * sx, 1), round(e["pos"][1] * sy, 1)] + for p in m["packs"]: + p["vertices"] = [[round(v[0] * sx, 1), round(v[1] * sy, 1)] for v in p["vertices"]] + for pa in m["patrols"]: + pa["vertices"] = [[round(v[0] * sx, 1), round(v[1] * sy, 1)] for v in pa["vertices"]] + for ic in m["icons"]: + ic["pos"] = [round(ic["pos"][0] * sx, 1), round(ic["pos"][1] * sy, 1)] + # Extras already use the kg pixel space; rescale too. + # Use the first map's pre-swap factor — extras are dungeon-level. + for ex in entry.get("extras", []): + ex["pos"] = [round(ex["pos"][0] * (new_w / 6144), 1), + round(ex["pos"][1] * (new_h / 4096), 1)] + dungeons.append(entry) dungeons.sort(key=lambda d: d["name"])