Map Safety Level MV
#1
Map Safety Level MV

by Kyonides


Introduction

I have come up with a very simple scriptlet that will allow the game developers to show a simple map name window plus a brand new label telling the player how Police Killer safe that map actually is. This window will be shown on the menu screen only. Happy with a sweat

Screenshots
[Image: mapsafetylevelace01.jpg]
The Plugin

Code:
//========================================================================================
// Map Safety Level MV.js
//========================================================================================
/*:
* @plugindesc This script allows you to display the current map's name and safety level.
* @version 2023-01-06
* @author Kyonides Arkanthes
*
* @param None
*
* @help
* Aliased Functions:
*   Game_Map#setup
* Overwritten Functions:
*   Scene_Menu#create
*
* Map Note: <safety N>
* where N is a number. Valid Options: 0 through Maximum.
*
* Plugin Calls:
*
*   $gameMap.getSafetyLevel();
*   $gameMap.setSafetyLevel(Number);
*   $gameMap.getSafetyLevelByMapId(Number);
*   $gameMap.safetyLevels();
*/

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

MapSafetyWindow.prototype = Object.create(Window_Base.prototype);
MapSafetyWindow.prototype.constructor = MapSafetyWindow;

MapSafetyWindow.prototype.initialize = function(x, y, width, height) {
  Window_Base.prototype.initialize.call(this, x, y, width, height);
  let w = this.contentsWidth();
  this.drawText($gameMap.displayName(), 0, 0, w, "center");
  this.changeTextColor(this.currentColor());
  this.drawText(this.currentLevel(), 0, 36, w, "center");
};

MapSafetyWindow.prototype.currentColor = function() {
  let level = $gameMap.getSafetyLevel();
  if (level == 0) {
    return "rgb(255, 0, 0)";
  } else if (level == 1) {
    return "rgb(255, 165, 0)";
  } else if (level == 2) {
    return "rgb(255, 255, 0)";
  } else if (level == 3) {
    return "rgb(255, 255, 255)";
  } else if (level == 4) {
    return "rgb(90, 205, 90)";
  } else if (level == 5) {
    return "rgb(0, 255, 0)";
  }
  return "rgb(255, 255, 255)";
}

MapSafetyWindow.prototype.currentLevel = function() {
  let level = $gameMap.getSafetyLevel();
  if (level == 0) {
    return "A Nightmare";
  } else if (level == 1) {
    return "Dangerous";
  } else if (level == 2) {
    return "Unsafe";
  } else if (level == 3) {
    return "Normal Place";
  } else if (level == 4) {
    return "Great Place";
  } else if (level == 5) {
    return "The Utopia";
  }
  return "Error!";
}

const Game_Map_safety_init = Game_Map.prototype.initialize;
const Game_Map_safety_setup = Game_Map.prototype.setup;

Game_Map.prototype.initialize = function() {
  Game_Map_safety_init.call(this);
  this._safetyLevels = [];
}

Game_Map.prototype.setup = function(mapId) {
  Game_Map_safety_setup.call(this, mapId);
  if (this._safetyLevels[mapId] == null) {
    let slvl = $dataMap.meta.safety || 0;
    this.setSafetyLevel(slvl);
  }
}

Game_Map.prototype.getSafetyLevel = function() {
  return this._safetyLevels[this._mapId];
}

Game_Map.prototype.setSafetyLevel = function(level) {
  return this._safetyLevels[this._mapId] = level;
}

Game_Map.prototype.getSafetyLevelByMapId = function(mapId) {
  return this._safetyLevels[mapId];
}

Game_Map.prototype.safetyLevels = function() {
  return this._safetyLevels;
}

Scene_Menu.prototype.create = function() {
  Scene_MenuBase.prototype.create.call(this);
  this.createCommandWindow();
  this.createMapSafetyWindow();
  this.createGoldWindow();
  this.createStatusWindow();
};

Scene_Menu.prototype.createMapSafetyWindow = function() {
  let w = this._commandWindow.width;
  let h = this._commandWindow.height;
  this._mapSafetyWindow = new MapSafetyWindow(0, h, w, 108);
  this.addWindow(this._mapSafetyWindow);
}

Terms & Conditions

Free for use in commercial and non commercial games unless you have pissed me off. Angry
Please include my nickname in your game credits.
I seriously hope this will not be the only script of mine that you will include in your games. Winking
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }


Messages In This Thread
Map Safety Level MV - by kyonides - 09-01-2024, 08:47 PM



Users browsing this thread: 2 Guest(s)