//=============================================================================
// 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 Images
* @default
* @param Floor 1 Overlay
* @parent Images
* @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
* @parent Images
* @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
* @parent Images
* @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
* @parent Images
* @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 52
* @param Map Icon
* @desc This is the icon to display the players position on the map.
* @default 15
*
* @param Open Sound
* @type struct<Sound>
* @default {"Sound":"book2","Volume":90,"Number":"1","Pan":"0"}*
* @param Close Sound
* @type struct<Sound>
* @default {"Sound":"book2","Volume":90,"Number":"1","Pan":"0"}
*
* @param Page Sound
* @type struct<Sound>
* @default {"Sound":"book2","Volume":90,"Number":"1","Pan":"0"}
*
*/
/*~struct~Sound:
* @param name
* @type file
* @dir audio/se/
* @require 1
* @param volume
* @type number
* @min 1
* @max 100
* @default 90
*
* @param pitch
* @type number
* @decimals 2
* @min 0.5
* @max 1.5
* @default 1
*
* @param pan
* @type number
* @min -100
* @max 100
* @default 0
*/
//=============================================================================
//=============================================================================
//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.OpenSound = Json(Rachnera.Parameters['OpenSound'])['Structure'];
Rachnera.Param.CloseSound = Json(Rachnera.Parameters['CloseSound'])['Structure'];
Rachnera.Param.PageSound = Json(Rachnera.Parameters['PageSound'])['Structure'];
//=============================================================================
//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);
}
}
};
//=============================================================================
// Scene_Map
//=============================================================================
Scene_Map.prototype.callMapDisplay = function() {
var se = {
name: JSON.parse(Rachnera.Param.OpenSound['name']),
volume: JSON.parse(Rachnera.Param.OpenSound['volume']),
pitch: JSON.parse(Rachnera.Param.OpenSound['pitch']),
pan: JSON.parse(Rachnera.Param.OpenSound['pan'])
};
AudioManager.playSe(se);
SceneManager.push(Scene_MapDisplay);
$gameTemp.clearDestination();
this._waitCount = 2;
};
//=============================================================================
// Scene_mapdisplay
//=============================================================================
function Scene_MapDisplay() {
this.initialize.apply(this, arguments);
}
Scene_MapDisplay.prototype = Object.create(Scene_MapDisplayBase.prototype);
Scene_MapDisplay.prototype.constructor = Scene_MapDisplay;
Scene_MapDisplay.prototype.initialize = function() {
Scene_Base.prototype.initialize.call(this);
};
Scene_MapDisplay.prototype.create = function() {
Scene_Base.prototype.create.call(this);
this.createMap();
};
Scene_MapDisplay.prototype.start = function() {
Scene_MapDisplayBase.prototype.start.call(this);
this._statusWindow.refresh();
};
Scene_MapDisplay.prototype.createMap = function() {
var overlays = [
Rachnera.Param.MapOverlay1,
Rachnera.Param.MapOverlay2,
Rachnera.Param.MapOverlay3,
Rachnera.Param.MapOverlay4
];
$gameVariables.setValue(20,$dataMap.mapOverlay);
$gameScreen.showPicture(100, overlays[$gameVariables.value(20), 0, 0, 0, 100, 100, 255, 0);
};
Scene_MapDisplay.prototype.update = function() {
var currentMap = $gameVariables.value(20);
var closesound = {
name: JSON.parse(Rachnera.Param.PageSound['name']),
volume: JSON.parse(Rachnera.Param.PageSound['volume']),
pitch: JSON.parse(Rachnera.Param.PageSound['pitch']),
pan: JSON.parse(Rachnera.Param.PageSound['pan'])
};
var pagesound = {
name: JSON.parse(Rachnera.Param.CloseSound['name']),
volume: JSON.parse(Rachnera.Param.CloseSound['volume']),
pitch: JSON.parse(Rachnera.Param.CloseSound['pitch']),
pan: JSON.parse(Rachnera.Param.CloseSound['pan'])
};
if(Input.isPressed('left')) {
AudioManager.playSe(pagesound);
currentMap = (currentMap-1);
if (currentMap < 0) currentMap = 3;
$gameVariables.setValue(20,currentMap);
$gameScreen.showPicture(100, overlays[$gameVariables.value(20), 0, 0, 0, 100, 100, 255, 0);
}
else if(Input.isPressed('right')) {
AudioManager.playSe(pagesound);
currentMap = (currentMap+1)%4;
$gameVariables.setValue(20,currentMap);
$gameScreen.showPicture(100, overlays[$gameVariables.value(20), 0, 0, 0, 100, 100, 255, 0);
}
else if(Input.isPressed('escape')) {
AudioManager.playSe(closesound);
this.popScene.bind(this));
}
else {
if (currentMap === $dataMap.mapOverlay) ;
$windowBase.drawIcon(Rachnera.Param.MapIcon,$dataMap.mapIconX, $dataMap.mapIconY);
}
};