From 5e133807dd16e919a4e4cf04e335209b6d35e70b Mon Sep 17 00:00:00 2001 From: dazedanon Date: Sun, 21 Dec 2025 13:27:49 -0600 Subject: [PATCH] Fix exit reveals --- js/plugins/MinimapZoom.js | 93 +++++++++++++++++++++++++++++++++------ 1 file changed, 79 insertions(+), 14 deletions(-) diff --git a/js/plugins/MinimapZoom.js b/js/plugins/MinimapZoom.js index 83491bf..45a329e 100644 --- a/js/plugins/MinimapZoom.js +++ b/js/plugins/MinimapZoom.js @@ -247,24 +247,74 @@ // params[1]: map ID (or variable ID) // params[2]: x (or variable ID) // params[3]: y (or variable ID) + + // Get actual values (handle both direct and variable designation) + let toMapId, toX, toY; if (params[0] === 0) { - // Direct designation - record this exit as activated - const fromMapId = $gameMap.mapId(); - const toMapId = params[1]; - const toX = params[2]; - const toY = params[3]; - // Use the event's position as the exit location - const event = $gameMap.event(this._eventId); - if (event) { - $gameSystem.activateExit(fromMapId, toMapId, event.x, event.y); - } - // Also record the arrival exit (where player comes out on destination map) - // This marks the exit on the destination map that leads back - $gameSystem.activateExit(toMapId, fromMapId, toX, toY); + toMapId = params[1]; + toX = params[2]; + toY = params[3]; + } else { + toMapId = $gameVariables.value(params[1]); + toX = $gameVariables.value(params[2]); + toY = $gameVariables.value(params[3]); } + + const fromMapId = $gameMap.mapId(); + + // Use the event's position as the exit location + const event = $gameMap.event(this._eventId); + if (event) { + $gameSystem.activateExit(fromMapId, toMapId, event.x, event.y); + } + // Also record the arrival exit (where player comes out on destination map) + $gameSystem.activateExit(toMapId, fromMapId, toX, toY); + + // Store info about where we came from so we can reveal the return exit + $gameSystem._pendingEntryReveal = { + destinationMapId: toMapId, + sourceMapId: fromMapId, + landingX: toX, + landingY: toY + }; + return _Game_Interpreter_command201.call(this, params); }; + // Find nearby exit events and activate them (so they show on minimap) + Game_System.prototype.activateNearbyExits = function(mapId, targetMapId, nearX, nearY) { + for (const event of $gameMap.events()) { + if (!event) continue; + + // Only check events within reasonable distance + const dx = Math.abs(event.x - nearX); + const dy = Math.abs(event.y - nearY); + if (dx > 15 || dy > 15) continue; + + const eventData = event.event(); + if (!eventData) continue; + + // Check all pages for Transfer Player command leading to target map + for (const page of eventData.pages) { + if (!page || !page.list) continue; + + for (const cmd of page.list) { + if (cmd.code === 201) { // Transfer Player command + const params = cmd.parameters; + let cmdTargetMapId = params[0] === 0 ? params[1] : $gameVariables.value(params[1]); + + if (cmdTargetMapId === targetMapId) { + // Reveal and activate this exit + this.revealAroundPosition(mapId, event.x, event.y, EXPLORE_RADIUS); + this.activateExit(mapId, targetMapId, event.x, event.y); + } + break; + } + } + } + } + }; + // Track player movement to reveal tiles const _Game_Player_moveStraight = Game_Player.prototype.moveStraight; Game_Player.prototype.moveStraight = function(d) { @@ -279,16 +329,31 @@ Game_Player.prototype.performTransfer = function() { _Game_Player_performTransfer.call(this); if ($gameMap.mapId() > 0) { + // Reveal around player's new position $gameSystem.revealAroundPosition($gameMap.mapId(), this.x, this.y, EXPLORE_RADIUS); + // Note: Exit reveal is handled in Scene_Map.start after map is fully loaded } }; - // Reveal on game load as well + // Reveal on game load as well - and handle pending entry reveals const _Scene_Map_start = Scene_Map.prototype.start; Scene_Map.prototype.start = function() { _Scene_Map_start.call(this); if ($gameMap.mapId() > 0) { $gameSystem.revealAroundPosition($gameMap.mapId(), $gamePlayer.x, $gamePlayer.y, EXPLORE_RADIUS); + + // Check for pending entry reveal - find and activate nearby exits leading back + if ($gameSystem._pendingEntryReveal && + $gameSystem._pendingEntryReveal.destinationMapId === $gameMap.mapId()) { + const entry = $gameSystem._pendingEntryReveal; + $gameSystem.activateNearbyExits( + $gameMap.mapId(), + entry.sourceMapId, + entry.landingX, + entry.landingY + ); + $gameSystem._pendingEntryReveal = null; + } } };