Add option to disable/enable Fog of War

This commit is contained in:
dazedanon 2025-12-21 12:20:00 -06:00
parent fa9d3bdcb1
commit 0e00f840f5

View file

@ -28,8 +28,10 @@
* - Fog of War: Only explored areas are revealed on the minimap
* - Exit Discovery: Exits are only shown after the player uses them
*
* Settings:
* - Can be enabled/disabled from the Options menu ("Minimap/Cartograph")
* Settings (Options Menu):
* - "Minimap (Mod)": Enable/disable the minimap feature entirely
* - "Fog of War": When ON, only explored areas and used exits are shown
* When OFF, the entire map and all exits are revealed
*/
(function() {
@ -83,22 +85,25 @@
// ConfigManager - Add minimap enabled setting
//=========================================================================
// Default value (enabled by default)
// Default values (enabled by default)
ConfigManager.minimapEnabled = true;
ConfigManager.minimapFogOfWar = true; // Fog of war enabled by default
// Hook into makeData to save the setting
// Hook into makeData to save the settings
const _ConfigManager_makeData = ConfigManager.makeData;
ConfigManager.makeData = function() {
const config = _ConfigManager_makeData.call(this);
config.minimapEnabled = this.minimapEnabled;
config.minimapFogOfWar = this.minimapFogOfWar;
return config;
};
// Hook into applyData to load the setting
// Hook into applyData to load the settings
const _ConfigManager_applyData = ConfigManager.applyData;
ConfigManager.applyData = function(config) {
_ConfigManager_applyData.call(this, config);
this.minimapEnabled = this.readFlag(config, "minimapEnabled", true);
this.minimapFogOfWar = this.readFlag(config, "minimapFogOfWar", true);
};
//=========================================================================
@ -109,6 +114,7 @@
Window_Options.prototype.makeCommandList = function() {
_Window_Options_makeCommandList.call(this);
this.addCommand("Minimap (Mod)", "minimapEnabled");
this.addCommand(" Fog of War", "minimapFogOfWar");
};
//=========================================================================
@ -332,12 +338,13 @@
const rawExits = [];
const mapId = $gameMap.mapId();
// Collect all transfer events (only activated exits in explored areas)
// Collect all transfer events (only activated exits in explored areas, unless fog of war is disabled)
const fogEnabled = ConfigManager.minimapFogOfWar;
for (const event of $gameMap.events()) {
if (!event) continue;
// Only include exits in explored areas
if (!$gameSystem.isTileExplored(mapId, event.x, event.y)) {
// Only include exits in explored areas (if fog of war is enabled)
if (fogEnabled && !$gameSystem.isTileExplored(mapId, event.x, event.y)) {
continue;
}
@ -354,8 +361,8 @@
if (params[0] === 0) { // Direct designation (not variable)
const targetMapId = params[1];
// Only show exits that have been activated (used by player)
if (!$gameSystem.isExitActivated(mapId, targetMapId, event.x, event.y)) {
// Only show exits that have been activated (used by player) - if fog of war is enabled
if (fogEnabled && !$gameSystem.isExitActivated(mapId, targetMapId, event.x, event.y)) {
continue;
}
@ -1194,11 +1201,12 @@
}
// Draw important events as markers (except transfers - those are drawn as numbered markers separately)
const fogEnabledForMarkers = ConfigManager.minimapFogOfWar;
for (const event of $gameMap.events()) {
if (!event) continue;
// Only show markers in explored areas
if (!$gameSystem.isTileExplored($gameMap.mapId(), event.x, event.y)) {
// Only show markers in explored areas (if fog of war is enabled)
if (fogEnabledForMarkers && !$gameSystem.isTileExplored($gameMap.mapId(), event.x, event.y)) {
continue;
}
@ -1237,8 +1245,10 @@
}
}
// Draw fog of war over unexplored areas
this.drawFogOfWar(bitmap, mapWidth, mapHeight, tileWidth, tileHeight);
// Draw fog of war over unexplored areas (if enabled)
if (ConfigManager.minimapFogOfWar) {
this.drawFogOfWar(bitmap, mapWidth, mapHeight, tileWidth, tileHeight);
}
};
Scene_Map.prototype.drawFogOfWar = function(bitmap, mapWidth, mapHeight, tileWidth, tileHeight) {