//=============================================================================
// Manor Mouse Map System
// MM_MapSystem.js
//=============================================================================
var Imported = Imported || {};
Imported.MM_MapSystem = true;
var Rachnera = Rachnera || {};
Rachnera.MapSystem = Rachnera.MapSystem || {};
//=============================================================================
/*:
* @plugindesc Handles the map system.
* @author Rachnera
*
* @param Floor 1 Overlay
* @type file
* @dir img/pictures/
* @require 1
* @desc This is the filename of your map base. Do not include an extension.
* @default floor1overlay
*
* @param Floor 2 Overlay
* @type file
* @dir img/pictures/
* @require 1
* @desc This is the filename of your map base. Do not include an extension.
* @default floor2overlay
*
* @param Floor 3 Overlay
* @type file
* @dir img/pictures/
* @require 1
* @desc This is the filename of your map base. Do not include an extension.
* @default floor3overlay
*
* @param Outside Overlay
* @type file
* @dir img/pictures/
* @require 1
* @desc This is the filename of your map base. Do not include an extension.
* @default outsideoverlay
*
* @param MapOverlay Picture Number
* @min 1
* @max 100
* @desc This is picture number that is used for displaying the map overlays.
* @default 100
*
* @param Map Icon
* @desc This is the icon to display the players position on the map.
* @default 15
*
* @param Map Variable
* @desc This is the game variable that stores the map being displayed.
* @default 5
*
*/
//=============================================================================
//=============================================================================
//Parameters
//=============================================================================
Rachnera.Parameters = PluginManager.parameters('MM_MapSystem');
Rachnera.Param = Rachnera.Param || {};
Rachnera.Param.MapOverlay1 = String(Rachnera.Parameters['Floor 1 Overlay']);
Rachnera.Param.MapOverlay2 = String(Rachnera.Parameters['Floor 2 Overlay']);
Rachnera.Param.MapOverlay3 = String(Rachnera.Parameters['Floor 3 Overlay']);
Rachnera.Param.MapOverlay4 = String(Rachnera.Parameters['Outside Overlay']);
Rachnera.Param.MapPicture = Number(Rachnera.Parameters['MapOverlay Picture Number']);
Rachnera.Param.MapIcon = Number(Rachnera.Parameters['Map Icon']);
Rachnera.Param.MapVariable = Number(Rachnera.Parameters['Map Variable']);
//=============================================================================
//Data Manager
//=============================================================================
Rachnera.MapSystem.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
DataManager.isDatabaseLoaded = function() {
if (!Rachnera.MapSystem.DataManager_isDatabaseLoaded.call(this)) return false;
return true;
};
DataManager.processMapSystemNotetags = function() {
if (!$dataMap) return;
$dataMap.mapOverlay = 0;
$dataMap.mapIconX = 0;
$dataMap.mapIconY = 0;
if (!$dataMap.note) return;
var notedata = $dataMap.note.split(/[\r\n]+/);
for (var i = 0; i < notedata.length; i++) {
var line = notedata[i];
if (line.match(/<(?:MAP):[ ](\d+)[ ](\d+)[ ](\d+)>/i)) {
$dataMap.mapOverlay = parseInt(RegExp.$1).clamp(0,3);
$dataMap.mapIconX = parseInt(RegExp.$2);
$dataMap.mapIconY = parseInt(RegExp.$3);
}
}
};
//=============================================================================
// Game_Map
//=============================================================================
Rachnera.MapSystem.Game_Map_setup = Game_Map.prototype.setup;
Game_Map.prototype.setup = function(mapId) {
if ($dataMap) DataManager.processMapSystemNotetags();
Rachnera.MapSystem.Game_Map_setup.call(this, mapId);
};
//=============================================================================
// Game_Interpreter
//=============================================================================
Rachnera.MapSystem.Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
var overlays = [
Rachnera.Param.MapOverlay1,
Rachnera.Param.MapOverlay2,
Rachnera.Param.MapOverlay3,
Rachnera.Param.MapOverlay4
];
if (command === 'MapGUI_GetCurrentFloor') {
var index = $dataMap.mapOverlay;
$gameScreen.showPicture(Rachnera.Param.MapPicture, overlays[index], 0 , 0, 0, 100, 100, 255, 0);
$gameVariables.setValue(Rachnera.Param.MapVariable,index);
}
else if (command === 'MapGUI_NextMap') {
var currentMap = $gameVariables.value(Rachnera.Param.MapVariable);
currentMap = (currentMap + 1)%4;
$gameScreen.showPicture(Rachnera.Param.MapPicture, overlays[currentMap], 0 , 0, 0, 100, 100, 255, 0);
$gameVariables.setValue(Rachnera.Param.MapVariable,currentMap);
}
else if (command === 'MapGUI_PreviousMap') {
var currentMap = $gameVariables.value(Rachnera.Param.MapVariable);
currentMap -= 1;
if (currentMap < 0) currentMap = 3;
$gameScreen.showPicture(Rachnera.Param.MapPicture, overlays[currentMap], 0 , 0, 0, 100, 100, 255, 0);
$gameVariables.setValue(Rachnera.Param.MapVariable,currentMap);
}
else if (command === 'MapGUI_DisplayMapIcon') {
//notetags determine the x and y coordinates of the map
this.drawIcon(Rachnera.Param.MapIcon,$dataMap.mapIconX-16,$dataMap.mapIconY-16);
}
else Rachnera.MapSystem.Game_Interpreter_pluginCommand.call(this,command,args);
};