Map Safety Level XP
by Kyonides Arkanthes
by Kyonides Arkanthes
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 safe that map actually is. This window will be shown on the menu screen only.
Screenshot
Ruby:
# * Map Safety Level XP * #
# 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.rxdata")[@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, 96)
self.contents = Bitmap.new(w - 32, 64)
map = $game_map
contents.draw_text(0, 0, 128, 28, map.display_name, 1)
safety_color = MapData::SAFETY_COLORS[map.safety_level]
contents.font.color.set(*safety_color)
contents.draw_text(0, 32, 128, 28, map.safety_level_text, 1)
end
end
class Scene_Menu
alias :kyon_map_safety_lvl_scn_menu_main :main
alias :kyon_map_safety_lvl_scn_menu_up :update
def main
@show_map_name = true
@map_name_safe = MapNameSafeWindow.new(0, 320, 160)
@map_name_safe.z += 100
kyon_map_safety_lvl_scn_menu_main
@map_name_safe.dispose
end
def update
if Input.trigger?(Input::L) or Input.trigger?(Input::R)
if @command_window.active
@show_map_name = !@show_map_name
@map_name_safe.z = @show_map_name ? 100 : 0
@steps_window.z = @show_map_name ? 0 : 100
end
return
end
kyon_map_safety_lvl_scn_menu_up
end
end
Terms & Conditions
Free for use in commercial and non commercial games unless you have pissed me off.
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.