Creating Custom Scenes

Nekohime1989

Nekohime
Veteran
Joined
May 31, 2014
Messages
498
Reaction score
226
First Language
English
Primarily Uses
RMMZ
Code:
//=============================================================================
// 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
* @default

* @param name1
* @parent Open Sound
* @type file
* @dir audio/se/
* @require 1
* @default 'book2'

* @param volume1
* @parent Open Sound
* @type number
* @min 1
* @max 100
* @default 40

* @param pitch1
* @parent Open Sound
* @type number
* @default 150

* @param pan1
* @parent Open Sound
* @type number
* @min -100
* @max 100
* @default 0

* @param Close Sound
* @default

* @param name2
* @parent Close Sound
* @type file
* @dir audio/se/
* @require 1
* @default 'book2'

* @param volume2
* @parent Close Sound
* @type number
* @min 1
* @max 100
* @default 40

* @param pitch2
* @parent Close Sound
* @type number
* @default 150

* @param pan2
* @parent Close Sound
* @type number
* @min -100
* @max 100
* @default 0
*
* @param Page Sound
* @default

* @param name3
* @parent Page Sound
* @type file
* @dir audio/se/
* @require 1
* @default 'book1'

* @param volume3
* @parent Page Sound
* @type number
* @min 1
* @max 100
* @default 40

* @param pitch3
* @parent Page Sound
* @type number
* @default 150

* @param pan3
* @parent Page Sound
* @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.SetupParameters = function() {
    var name = [String(Rachnera.Parameters['name1']), String(Rachnera.Parameters['name2']), String(Rachnera.Parameters['name3'])];
    var volume = [Number(Rachnera.Parameters['volume1']), Number(Rachnera.Parameters['volume2']), Number(Rachnera.Parameters['volume3'])];
    var pitch = [Number(Rachnera.Parameters['pitch1']), Number(Rachnera.Parameters['pitch2']), Number(Rachnera.Parameters['pitch3'])];
    var pan = [Number(Rachnera.Parameters['pan1']),pan2 = Number(Rachnera.Parameters['pan2']),pan3 = Number(Rachnera.Parameters['pan3'])];
    Rachnera.Param.MapOpenSound = {
        name: name[0],
        volume: volume[0],
        pitch: pitch[0],
        pan: pan[0]
    };
    Rachnera.Param.MapCloseSound = {
        name: name[1],
        volume: volume[1],
        pitch: pitch[1],
        pan: pan[1]
    };
    Rachnera.Param.MapPageSound = {
        name: name[2],
        volume: volume[2],
        pitch: pitch[2],
        pan: pan[2]
    };
}
Rachnera.SetupParameters();

//=============================================================================
//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.callMapGUI = function() {
    AudioManager.playSe(Rachnera.Param.MapOpenSound);
    SceneManager.push(Scene_MapGUI);
    $gameTemp.clearDestination();
    this._waitCount = 2;
};

//-----------------------------------------------------------------------------
// Scene_MapGUIBase
//
// The superclass of all the menu-type scenes.

function Scene_MapGUIBase() {
    this.initialize.apply(this, arguments);
}

Scene_MapGUIBase.prototype = Object.create(Scene_Base.prototype);
Scene_MapGUIBase.prototype.constructor = Scene_MapGUIBase;

Scene_MapGUIBase.prototype.initialize = function() {
    Scene_Base.prototype.initialize.call(this);
};

Scene_MapGUIBase.prototype.create = function() {
    Scene_Base.prototype.create.call(this);
    this.createBackground();
    this.createWindowLayer();
};

Scene_MapGUIBase.prototype.createBackground = function() {
    this._backgroundSprite = new Sprite();
    this._backgroundSprite.bitmap = SceneManager.backgroundBitmap();
    this.addChild(this._backgroundSprite);
};

//-----------------------------------------------------------------------------
// Scene_MapGUI
//
// The scene class of the menu screen.

function Scene_MapGUI() {
    this.initialize.apply(this, arguments);
}

Scene_MapGUI.prototype = Object.create(Scene_MapGUIBase.prototype);
Scene_MapGUI.prototype.constructor = Scene_MapGUI;

Scene_MapGUI.prototype.initialize = function() {
    Scene_MapGUIBase.prototype.initialize.call(this);
};

Scene_MapGUI.prototype.create = function() {
    Scene_MapGUIBase.prototype.create.call(this);
    this.createMapWindow();
};

Scene_MapGUI.prototype.start = function() {
    Scene_MapGUIBase.prototype.start.call(this);
};

Scene_MapGUI.prototype.createMapWindow = function() {
    var overlays = [
        Rachnera.Param.MapOverlay1,
        Rachnera.Param.MapOverlay2,
        Rachnera.Param.MapOverlay3,
        Rachnera.Param.MapOverlay4
    ];
    $gameVariables.setValue(20,$dataMap.mapOverlay);
    this._dummyWindow = new Window_MapGUI(0, 0, Graphics.boxWidth, Graphics.boxHeight);
};

Scene_MapGUI.prototype.update = function() {
    var currentMap = $gameVariables.value(20);
    var overlays = [
        Rachnera.Param.MapOverlay1,
        Rachnera.Param.MapOverlay2,
        Rachnera.Param.MapOverlay3,
        Rachnera.Param.MapOverlay4
    ];
    if(Input.isTriggered('left')) {
        AudioManager.playSe(Rachnera.Param.MapPageSound);
        currentMap = (currentMap-1);
        if (currentMap < 0) currentMap = 3;
        $gameVariables.setValue(20,currentMap);
    }
    else if(Input.isTriggered('right')) {
        AudioManager.playSe(Rachnera.Param.MapPageSound);
        currentMap = (currentMap+1)%4;
        $gameVariables.setValue(20,currentMap);
    }
    else if(Input.isTriggered('escape')) {
        AudioManager.playSe(Rachnera.Param.MapCloseSound);
        this.popScene();
    }
    else if (currentMap === $dataMap.mapOverlay) this._dummyWindow.drawIcon(Rachnera.Param.MapIcon,$dataMap.mapIconX, $dataMap.mapIconY);
    this._dummyWindow.drawPicture(overlays[$gameVariables.value(20)], 0, 0);
    this._dummyWindow.update();
    Scene_Base.prototype.update.call(this);
};

//=============================================================================
// 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) {
    if (command==='MM_DisplayMap') {
      Scene_Map.prototype.callMapGUI();
    }
    else Rachnera.MapSystem_Game_Interpreter_pluginCommand.call(this,command,args);
};

//=============================================================================
// Window_MapGUI
//=============================================================================
function Window_MapGUI() {
    this.initialize.apply(this, arguments);
}

Window_MapGUI.prototype = Object.create(Window_Selectable.prototype);
Window_MapGUI.prototype.constructor = Window_MapGUI;

Window_MapGUI.prototype.initialize = function(x, y, width, height) {
    Window_Base.prototype.initialize.call(this, x, y, width, height);
    this.refresh();
};

Window_MapGUI.prototype.update = function() {
    Window_Base.prototype.update.call(this);
    this.refresh();
}

Window_MapGUI.prototype.refresh = function() {
    this.createContents();
    this.drawAllItems();
};
Do to Scene_Map updating everyframe and the way common events work I have had no choice but to go back to the drawing board and redo my map system from scratch. I've decided to push a custom scene called Scene_MapGUI to the Scene Manager. All is well that ends well however the scene itself does not display any images or icons as it should. :/
 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,977
Members
137,563
Latest member
cexojow
Top