# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Panic HUD ║ Version: 1.00 ║
# ║ Author: Roninator2 ║ ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function: ║ Date Created ║
# ║ ╠════════════════════╣
# ║ Draw A Panic Number on Map ║ 28 Dec 2021 ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ A script to display a number to indicate danager ║
# ║ Designed for a horror/ thriller type game ║
# ║ ║
# ║ Set the values below to your preference ║
# ╚══════════════════════════════════════════════════════════╝
# ╔═════════════════════════════════════╗
# ║ Terms of use: ║
# ║ Free for all uses in RPG Maker ║
# ╚═════════════════════════════════════╝
module R2_Panic_Number_Colour
Panic_Var = 23 # variable used to adjust the panic
Colours = [11, 17, 20, 18] # Windowskin colours
# Green, Yellow, Orange, Red
Number_Hud_X = 480 # X location
Number_Hud_Y = 10 # Y location
Number_Hud_Width = 60 # Number width
Number_Hud_Height = 50 # Number height
Window_Graphic = "Window" # Set the window graphics
Window_Opacity = 255 # Set the window opacity
Window_Back_Opacity = 255 # Set the back opacity
Warning_Sound = "Buzzer1" # Sound to play at warning point
Warning_Mark = 95 # Point of when sound will play
Image = "Border" # image to display when number is high
Image_OI = [0, 80, 160, 240] # Opacity Increment
Font = "Arial" # Set the font
Font_Size = 24 # Set the font size
Switch = 5 # Switch to turn number off
end
class Panic_Window < Window_Base
def initialize
x = R2_Panic_Number_Colour::Number_Hud_X
y = R2_Panic_Number_Colour::Number_Hud_Y
w = R2_Panic_Number_Colour::Number_Hud_Width
h = R2_Panic_Number_Colour::Number_Hud_Height
super(x,y,w,h)
self.windowskin = Cache.system(R2_Panic_Number_Colour::Window_Graphic)
self.opacity = R2_Panic_Number_Colour::Window_Opacity
self.back_opacity = R2_Panic_Number_Colour::Window_Back_Opacity
self.contents_opacity = 255
@current_number = $game_variables[R2_Panic_Number_Colour::Panic_Var]
@panic_image = nil
self.windowskin = Cache.system(R2_Panic_Number_Colour::Window_Graphic)
refresh
end
def panic_data
@current_number = $game_variables[R2_Panic_Number_Colour::Panic_Var]
@current_number = 100 if $game_variables[R2_Panic_Number_Colour::Panic_Var] >= 100
draw_panic_hud(0, 0)
if @current_number == R2_Panic_Number_Colour::Warning_Mark
snd = RPG::SE.new(R2_Panic_Number_Colour::Warning_Sound, 100, 100)
snd.play
end
end
def show_panic(ind)
@panic_image.dispose if !@panic_image.nil?
@panic_image = Sprite.new
@panic_image.bitmap = Cache.picture(R2_Panic_Number_Colour::Image)
@panic_image.opacity = R2_Panic_Number_Colour::Image_OI[ind]
end
def draw_panic_hud(x, y)
draw_text_ex(0, 0, @current_number)
end
def refresh
self.contents.clear
panic_data
end
def panic_data_changed
return true if @current_number != $game_variables[R2_Panic_Number_Colour::Panic_Var]
return false
end
alias r2_panic_update update
def update
refresh if panic_data_changed
r2_panic_update
end
def image_erase
@panic_image.bitmap.dispose
@panic_image.dispose
end
alias r2_font_reset_colour reset_font_settings
def reset_font_settings
r2_font_reset_colour
font = R2_Panic_Number_Colour::Font
font_size = R2_Panic_Number_Colour::Font_Size
self.contents.font = Font.new(font, font_size)
$game_variables[R2_Panic_Number_Colour::Panic_Var] = 100 if
$game_variables[R2_Panic_Number_Colour::Panic_Var] >= 100
cnt = R2_Panic_Number_Colour::Colours.size
chk = 100 / cnt
if $game_variables[R2_Panic_Number_Colour::Panic_Var] == 100
col = 3
else
col = ($game_variables[R2_Panic_Number_Colour::Panic_Var] / chk).to_i
end
color = text_color(R2_Panic_Number_Colour::Colours[col])
contents.font.color.set(color)
show_panic(col)
end
end
class Scene_Map < Scene_Base
alias r2_map_panic_start start
def start
r2_map_panic_start
@map_panic_shown = true if @map_panic_shown.nil?
start_panic
end
def start_panic
@map_panic = Panic_Window.new
end
alias r2_map_panic_update update
def update
r2_map_panic_update
if $game_switches[R2_Panic_Number_Colour::Switch] == false
@map_panic_shown = false
else
@map_panic_shown = true
end
if @map_panic_shown == false
@map_panic.close if @map_panic.open?
else
@map_panic.open if @map_panic.close?
panic_update
end
end
def panic_update
@map_panic.update if @map_panic_shown == true
if @map_panic_shown == true
@map_panic.image_erase if $game_player.transfer?
@map_panic.image_erase if $game_player.encounter
@map_panic.image_erase if @menu_calling && !$game_player.moving?
@map_panic.image_erase if $TEST && Input.press?(:F9)
end
end
end