Map Safety Level VX + ACE
#1
Map Safety Level VX + ACE

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: mapsafetylevelvx01.jpg]
[Image: mapsafetylevelace01.jpg]
VX Script

Code:
# * Map Safety Level VX * #
#   Scripter : Kyonides Arkanthes
#   2022-12-30

# This scriptlet lets you set some texts as Safety Level Labels, and then you
# can call a method to set a new level at any given time.

# Valid Levels: 0 up to your safety maximum level.

# * Get or Set Current Map's Safety Level * #
# $game_map.safety_level
# $game_map.safety_level = NewLevel

# * Preset a given Map's Safety Level * #
# SAFETY_LEVELS = { MapIDa => Level, MapIDb => Level, etc. }

# * Define a given Map's Safety Level Color * #
# - Alpha is optional. Valid Values: 0 through 255
# SAFETY_LEVELS[0] = [Red, Green, Blue, Alpha]

module MapData
  DEFAULT_SAFETY_LEVEL = 0
  SAFETY_LEVELS = { 1 => 3 }
  SAFETY_LABELS = [] # Just leave it alone.
  SAFETY_COLORS = [] # Just leave it alone.
  SAFETY_LABELS[0] = "A Nightmare"
  SAFETY_LABELS[1] = "Dangerous"
  SAFETY_LABELS[2] = "Unsafe"
  SAFETY_LABELS[3] = "Normal Place"
  SAFETY_LABELS[4] = "Great Place"
  SAFETY_LABELS[5] = "The Utopia"
  SAFETY_COLORS[0] = [255, 0, 0]
  SAFETY_COLORS[1] = [255, 165, 0]
  SAFETY_COLORS[2] = [255, 255, 0]
  SAFETY_COLORS[3] = [255, 255, 255]
  SAFETY_COLORS[4] = [90, 205, 90]
  SAFETY_COLORS[5] = [0, 255, 0]
end

class Game_Map
  alias :kyon_map_safety_lvl_gm_map_init :initialize
  alias :kyon_map_safety_lvl_gm_map_setup :setup
  def initialize
    kyon_map_safety_lvl_gm_map_init
    @safety_levels = MapData::SAFETY_LEVELS.dup
    @safety_levels.default = MapData::DEFAULT_SAFETY_LEVEL
  end

  def get_mapinfos_name
    load_data("Data/MapInfos.rvdata")[@map_id].name
  end

  def display_name
    @display_name ||= get_mapinfos_name
  end

  def safety_level
    @safety_levels[@map_id]
  end

  def safety_level=(new_level)
    @safety_levels[@map_id] = new_level
  end

  def safety_level_text
    MapData::SAFETY_LABELS[@safety_levels[@map_id]]
  end
  attr_reader :safety_levels
  attr_writer :display_name
end

class MapNameSafeWindow < Window_Base
  def initialize(wx, wy, w)
    super(wx, wy, w, WLH * 2 + 32)
    self.contents = Bitmap.new(w - 32, WLH * 2)
    map = $game_map
    contents.draw_text(0, 0, 128, 24, map.display_name, 1)
    safety_color = MapData::SAFETY_COLORS[map.safety_level]
    contents.font.color.set(*safety_color)
    contents.draw_text(0, 24, 128, 24, map.safety_level_text, 1)
  end
end

class Scene_Menu
  alias :kyon_map_safety_lvl_scn_menu_start :start
  alias :kyon_map_safety_lvl_scn_menu_term :terminate
  def start
    kyon_map_safety_lvl_scn_menu_start
    create_map_safety_window
  end

  def create_map_safety_window
    @map_name_safe = MapNameSafeWindow.new(0, Graphics.height - 80 - 56, 160)
  end

  def terminate
    kyon_map_safety_lvl_scn_menu_term
    @map_name_safe.dispose
  end
end

ACE Script

Code:
# * Map Safety Level ACE * #
#   Scripter : Kyonides Arkanthes
#   2022-12-30

# This scriptlet lets you set some texts as Safety Level Labels, and then you
# can leave a map note to set its initial safety level.

# <map safety 1>

# Valid Levels: 0 up to your safety maximum level.

# * Get or Set Current Map's Safety Level * #
# $game_map.safety_level
# $game_map.safety_level = NewLevel

# * Define a given Map's Safety Level Color * #
# - Alpha is optional. Valid Values: 0 through 255
# SAFETY_LEVELS[0] = [Red, Green, Blue, Alpha]

module MapData
  SAFETY_REGEX = /map safety (\d+)/i
  SAFETY_LABELS = [] # Just leave it alone.
  SAFETY_COLORS = [] # Just leave it alone.
  SAFETY_LABELS[0] = "A Nightmare"
  SAFETY_LABELS[1] = "Dangerous"
  SAFETY_LABELS[2] = "Unsafe"
  SAFETY_LABELS[3] = "Normal Place"
  SAFETY_LABELS[4] = "Great Place"
  SAFETY_LABELS[5] = "The Utopia"
  SAFETY_COLORS[0] = [255, 0, 0]
  SAFETY_COLORS[1] = [255, 165, 0]
  SAFETY_COLORS[2] = [255, 255, 0]
  SAFETY_COLORS[3] = [255, 255, 255]
  SAFETY_COLORS[4] = [90, 205, 90]
  SAFETY_COLORS[5] = [0, 255, 0]
end

class Game_Map
  alias :kyon_map_safety_lvl_gm_map_init :initialize
  alias :kyon_map_safety_lvl_gm_map_setup :setup
  def initialize
    kyon_map_safety_lvl_gm_map_init
    @safety_levels ||= {}
  end

  def setup(map_id)
    kyon_map_safety_lvl_gm_map_setup(map_id)
    reset_safety_level unless @safety_levels[@map_id]
  end

  def reset_safety_level
    @map.note[MapData::SAFETY_REGEX]
    @safety_levels[@map_id] = $1.to_i
  end

  def safety_level
    @safety_levels[@map_id]
  end

  def safety_level=(new_level)
    @safety_levels[@map_id] = new_level
  end

  def safety_level_text
    MapData::SAFETY_LABELS[@safety_levels[@map_id]]
  end
  attr_reader :safety_levels
end

class MapNameSafeWindow < Window_Base
  def initialize(wx, wy, w)
    super(wx, wy, w, 72)
    self.contents = Bitmap.new(w - 32, 48)
    map = $game_map
    contents.draw_text(0, 0, 128, 24, map.display_name, 1)
    safety_color = MapData::SAFETY_COLORS[map.safety_level]
    contents.font.color.set(*safety_color)
    contents.draw_text(0, 24, 128, 24, map.safety_level_text, 1)
  end
end

class Scene_Menu
  alias :kyon_map_safety_lvl_scn_menu_start :start
  def start
    kyon_map_safety_lvl_scn_menu_start
    create_map_safety_window
  end

  def create_map_safety_window
    @map_name_safe = MapNameSafeWindow.new(0, Graphics.height - 120, 160)
  end
end

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 }


Possibly Related Threads…
Thread Author Replies Views Last Post
   Level Up ME & SE ACE kyonides 0 748 01-24-2024, 01:59 AM
Last Post: kyonides



Users browsing this thread: 1 Guest(s)