#===============================================================================
#
# Blink Low Stat Numbers
# Authors: Heretic
# Version 1.0
#
#------------------------------------------------------------------------------
#
# This class will allow Numeric Stats displayed to Blink when they are below
# 1/4th of the Actor's Max Stats.
#
# It works for displaying Actor Stats. You can modify it to display
# Enemy Stats, if you have a script that allows you to do so, but some
# rescripting of this script may be needed.
#
# You'll probably need to place this script Below any Custom
# Menu Systems you have. It can go above everything else.
#
# This will work in EVERY screen that Actor's Stats are to be displayed.
#
# --- Compatability (Scripters) ---
#
# If the Stats do not Blink, you'll need to make some changes.
#
# #1 - The Window that holds your Status you expect to blink must have an
# Update Method that is called once per frame. The Update Method
# MUST make a call to "super" in definition.
#
# Scene_Status is a good example of a Scene that does not update once
# per frame. Scene_Status def update was given an alias to update the
# Status Window once per frame so that the Status Window can be redrawn
# with the new Stat Color. It is at the bottom.
#
# #2 - If the Type (Class) of Window that is being updated has a Refresh
# method, make sure the Type (Class) is included in Window_Base update.
# (search for "New Classes Go Here" and use a "is_a?" on that class)
#
# Just one line, which is pretty easy to get working.
#
# #3 - If the Type (Class) of Window does NOT have a Refresh Method, you
# need to make sure it updates once per frame, and then make sure it
# has a way to redraw (Refresh) the contents of the window. Custom
# Refresh Definitions may be necessary.
#
# Examine Window_Help because that class does not contain a
# Refresh Method Definition, but custom ones were built.
#
# Legal: Due to the need to modify the contents of this script for to work
# with as many Menu Systems as possible, you are allowed to modify this
# script to get it to work correctly with other Scripts.
#
# You are allowed to post this script on other websites and modify it
# however you may need to do so.
#===============================================================================
#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
# This class will allow HP and SP to Blink every couple of frames in
# every Window that displays an Actor's HP and SP.
#
# It was written to not be dependant on any other classes, so it can
# be used as a Battle Addon for just about any game.
#==============================================================================
class Window_Base < Window
if defined?(Window_BattleBars)
#--------------------------------------------------------------------------
# * Critical Color - Dynamic Color based on Frames Counter...
# ** - This is a redefinition to allows color to change
#--------------------------------------------------------------------------
def critical_stat_color
return Color.new(255, 255, 255) if $game_system.critical_flash_color
return Color.new(255, 64, 128)
end
else
#--------------------------------------------------------------------------
# * Get Crisis Text Color - Replaces Default Definition
#--------------------------------------------------------------------------
def crisis_color
return Color.new(255, 255, 255) if $game_system.critical_flash_color
return Color.new(255, 64, 128)
end
end
#--------------------------------------------------------------------------
# * Frame Update - Inherited by All Windows Classes with "super" calls
#--------------------------------------------------------------------------
alias heretic_flash_critical_hp_update update
def update
# Call Original - Original checks for changes in Windowskins
heretic_flash_critical_hp_update
# In case of Loading Menu Screen, $game_party not intialized
if $game_party
for actor in $game_party.actors
# Change Color of HP during Critical Color (HP < 1/4th of Max)
if $game_system.critical_color_change?(actor)
# If Inheriting Window is one of the following Classes
if self.is_a?(Window_BattleStatus) or
self.is_a?(Window_MenuStatus) or
self.is_a?(Window_Status) or
self.is_a?(Window_Target) or
self.is_a?(Window_SkillStatus)
# New Classes Go Here
# Redraw the Window to display the new Stat with Alt Colored Text
self.refresh
end
# Break the "for" loop instead of redrawing for each Actor
return
end
end
end
end
end
#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
# New Variables:
# @flash_frames - How many Frames to wait to change the Critical Flash Color
# @critical_flash_color - Changes True / False every @flash_frames
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :flash_frames # Frames between changing Flash Color
attr_accessor :critical_flash_color # Alternates between True / False
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias critical_flash_color_initialize initialize
def initialize
# Call Original
critical_flash_color_initialize
# How many Frames to wait between changing Critical Flash Color
@flash_frames = 15
# This alters the Color of critical_color when called - DO NOT EDIT OR CALL
@critical_flash_color = false
end
#--------------------------------------------------------------------------
# * Critical Color Change - Returns True or False
#
# Call $game_system.critical_color_change?(actor[optional]) to detect if
# a change in critical color needs to take place.
#--------------------------------------------------------------------------
def critical_color_change?(actor=nil)
# If Remainer of Division is 0
if Graphics.frame_count % @flash_frames == 0
# If updating or Actor HP / SP is less than One Quarter of Max HP / SP
if actor.nil? or
((actor.hp <= actor.maxhp / 4 or
actor.sp <= actor.maxsp / 4) and
actor.hp > 0)
return true
end
end
return false
end
end
#==============================================================================
# ** Graphics Module
#------------------------------------------------------------------------------
# Allows Critical Flash Color True / False Value to always be updated
#==============================================================================
module Graphics
unless $graphics_flash_color_class_defined
# Prevents F12 Crash
$graphics_flash_color_class_defined = true
class << self
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias critical_flash_color_graphics_update update
def update
# Call Original
critical_flash_color_graphics_update
# If Critical Color is changing
if $game_system.critical_color_change?
# Changes the Critical Color - Flips True to False
$game_system.critical_flash_color = !$game_system.critical_flash_color
end
end
end
end
end
#==============================================================================
# ** Window_Help
#------------------------------------------------------------------------------
# This window shows skill and item explanations along with actor status.
#
# It has two possible definitions.
# - The first possible definition is used with the XRXS ATB System.
# - The second uses the Default Enterbrain Definition.
#
# --- Using this Class with Custom Menu Systems Compatability ---
#
# Since the Help_Window does not contain a Refresh Method, a special refresh
# was written which will only affect an Actor's display. If you have a
# custom Menu System, you may need to rewrite the second definition for
# the Graphics to display in their appropriate places. You'll have to take
# a look at what ever Menu System you are using, and probably only need to
# duplicate the contents of the customized "def set_actor(actor)" to get
# your contents to look appropriate in your Menu System.
#
# This class was modified to provide the framework for displaying
# Enemy Refresh Methods for Enemy HP / SP Stat systems. The contents of
# refresh_help_enemy(enemy) will probably need to be overwritten with
# the way that the script you use to display Enemy Stats displays the
# enemy Stats.
#
#==============================================================================
class Window_Help < Window_Base
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# If Window is being Shown
if self.visible
# Change Color of HP during Critical Color (HP < 1/4th of Max)
if @actor and $game_system.critical_color_change?(@actor)
# Refresh Method for Actors
if @actor.is_a?(Game_Actor)
# Redraw the Help Window for Actor
self.refresh_help_actor(@actor)
# Refresh Method for Enemies
# --- Uncomment this section to enable Blinking Enemy Stats ---
# elsif @actor.is_a?(Game_Enemy)
# # Redraw the Help Window for Enemy
# self.refresh_help_enemy(@actor)
end
end
end
end
#----------------------------------------------------------------------------
# This line will cause the method to be defined differently.
#
# It is used to allow this script to be compatible with another
# script that I am working on by defining the method differently.
#----------------------------------------------------------------------------
if defined?(Window_BattleBars) and defined?(Window_CP)
#--------------------------------------------------------------------------
# * Redraw Help Window for Actor - Gradient HP / SP Bars - ATB System
#--------------------------------------------------------------------------
def refresh_help_actor(actor)
self.contents.clear
# Draw the HP and SP Meter Lines
draw_actor_hp_meter_line(actor, 318, 12, 110, 12)
draw_actor_sp_meter_line(actor, 490, 12, 110, 12)
# HP Label (Standard HP Label Omitted In draw_actor_hp_shadow)
self.contents.font.color = system_color
self.contents.draw_text(284, 0, 32, 32, $data_system.words.hp)
# SP Label (Standard SP Label Omitted In draw_actor_hp_shadow)
self.contents.font.color = system_color
self.contents.draw_text(460, 0, 32, 32, $data_system.words.sp)
# Draw HP and SP with Shadow Text
draw_actor_hp_shadow(actor, 284, 0)
draw_actor_sp_shadow(actor, 458, 0)
# Draw other relative Data
draw_actor_name(actor, 4, 0)
draw_actor_state(actor, 140, 0)
end
else
#--------------------------------------------------------------------------
# * Redraw Help Window for Actor - Original Enterbrain Definition
#
# Rewrite the contents of this definition for displaying contents for
# your Actors (not Enemies) if using a Customized Menu System.
#
# Try using the contents of your Menu System's "def set_actor(actor)" to
# display your corresponding style for your Menu System.
#--------------------------------------------------------------------------
def refresh_help_actor(actor)
self.contents.clear
draw_actor_name(actor, 4, 0)
draw_actor_state(actor, 140, 0)
draw_actor_hp(actor, 284, 0)
draw_actor_sp(actor, 460, 0)
end
end
#--------------------------------------------------------------------------
# * Set Enemy - Displays Enemy Data in Help Window - Alias
# enemy : name and status displaying enemy
#
# If this definition is fully redefined later, it may need to be modified
# to include "@actor = enemy" to work correctly. It will probably cause
# your Enemy Help Window to go blank, so adding that code should fix it.
#--------------------------------------------------------------------------
alias low_stat_set_enemy set_enemy
def set_enemy(enemy)
# Store Enemy as Actor
@actor = enemy
# Call Original
low_stat_set_enemy(enemy)
end
#--------------------------------------------------------------------------
# * Redraw Help Window for Enemy - New Definition
#--------------------------------------------------------------------------
def refresh_help_enemy(enemy)
# To Enable this method, look at line 229 (Ctrl + G) and remove the #'s.
# Clear all data displayed in the Help Window
self.contents.clear
# Place the Contents here with the contents of your Menu System's
# way of drawing Enemy Data in the Help Window
# Replace this with Set Enemy Definitions. This is Enterbrain's Default.
text = enemy.name
state_text = make_battler_state_text(enemy, 112, false)
if state_text != ""
text += " " + state_text
end
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, self.width - 40, 32, text, 1)
self.visible = true
# Display the Text - DO NOT CALL the default method of "set_text" because
# it clears @actor, which will cause the text on the screen to go blank.
# Just use draw_text or other commands that display your text, and
# set visible to true.
end
end
#===============================================================================
# ** Scene_Status
#-------------------------------------------------------------------------------
# @status_window needs to be updated so it can be checked for needing a refresh
#
# Since Scene_Status does not update @status_window by default, it is added
# in here to just update it.
#
# Refresh is using the Original Refresh Method to provide a high degree of
# compatability with other Menu Systems or Customized Graphics. By default
# Scene_Status did NOT call update to the Status Window, which is necessary
# to check for changes and allows it to refresh.
#
# If using a Custom Menu System that already calls @status_window.update, then
# remove the Scene_Status as it is defined here, otherwise, it updates twice
# and you'll get a performance hit.
#
# If you have a Custom Scene where whatever the Window is called is not being
# updated, duplicate this class to modify the Update method for that class
# and update the Window.
#
# Note: You may need to create a New Script BELOW your Custom Menu System
# in order to alias the update class. The only contents that would be needed
# are the several lines below, modified accordingly.
#===============================================================================
class Scene_Status
alias scene_status_flash_color_update update
def update
# Call Original
scene_status_flash_color_update
# Update Status Window to allow Color Change
@status_window.update
end
end