#==============================================================================
# ** Event Icon & Text Display
#------------------------------------------------------------------------------
# SephirothSpawn
# Original Text Display By Áص¹
# Version 4.0
# 2007-07-30
# SDK : Version 2.0, Parts I & II
#------------------------------------------------------------------------------
# * Version History :
#
# Version 1 -------------------------------------------- (Approx. 2006-01-01)
# Version 2 ---------------------------------------------------- (2006-03-04)
# Version 3 ---------------------------------------------------- (2006-08-22)
# - Update : Re-scripted Much of the System
# Version 3.01 ------------------------------------------------ (2006-10-23)
# - Bug Fix : Fixed Erase Event
# Version 3.1 ------------------------------------------------- (2007-01-11)
# - Update : Removed Shadow Text Elements
# Version 3.11 ------------------------------------------------ (2007-02-08)
# - Update : Updated to SDK 2.0
# Version 4 ---------------------------------------------------- (2007-07-30)
# - Update : Rescripted to include text and icons
#------------------------------------------------------------------------------
# * Requirements :
#
# Method & Class Library (2.1+)
#------------------------------------------------------------------------------
# * Description :
#
# This script was designed to add floating text and icons over events and
# players on the map. You can control the color of the text and choose
# multiple options for the text over the player.
#------------------------------------------------------------------------------
# * Instructions
#
# Place The Script Below the SDK and Above Main.
#
# Setting Event Display Text. Replace <text> with the text you want to be
# displayed of event.
# Comment: {ETD<text>}
#
# For icons, use [icon_name] in text. Make sure to seperate with space.
#
# For Default Settings, refer to customization.
# For Modifing Setting during game play, refer to syntax.
#------------------------------------------------------------------------------
# * Customization
#
# Default Event Text Color
# - ETD_Default_EventText_Color = Color.new(red, green, blue)
#
# Default Player Text Color
# - ETD_Default_PlayerText_Color = Color.new(red, green, blue)
#
# Default Player Display Option
# - ETD_Default_PlayerText = 'Name', 'Class', 'Level', 'Hp', 'Sp'
#------------------------------------------------------------------------------
# * Syntax
#
# Changing Character Display Text
# - <game_character>.etd_display_text = 'String'
# Changing Character Display Color
# - <game_character>.etd_display_color = Color.new(r, g, b, a)
#
# * Substitute <game_character> with $game_player for the player, or
# $game_map.events[event_id] to replace with an event.
#==============================================================================
#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Event Icon & Text Display', 'SephirothSpawn', 4.0, '2007-07-30')
SDK.check_requirements(2.0, [2], {'Method & Class Library' => 2.1})
#SDK.disable('Event Icon & Text Display')
#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.enabled?('Event Icon & Text Display')
#==============================================================================
# ** Game_Character
#==============================================================================
class Game_Character
#--------------------------------------------------------------------------
# * Defaults
#
# ~ Default Player Display Options (Non-Case Sensitive):
# 'Name', 'Class', 'Level', 'Hp', 'Sp'
#--------------------------------------------------------------------------
ETD_Default_EventText_Color = Color.new(0, 0, 200)
ETD_Default_PlayerText_Color = Color.new(200, 0, 0)
ETD_Default_PlayerText = 'name'
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :etd_display_color
attr_accessor :etd_display_text
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias_method :seph_etd_gmchr_init, :initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Sets ETD Options
@etd_display_color = self.is_a?(Game_Player) ?
ETD_Default_PlayerText_Color : ETD_Default_EventText_Color
# Original Initialization
seph_etd_gmchr_init
end
end
#==============================================================================
# ** Game_Event
#==============================================================================
class Game_Event < Game_Character
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias_method :seph_etd_gmevt_refresh, :refresh
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
# Original Refresh Method
seph_etd_gmevt_refresh
# Erase ETD Display Text
@etd_display_text = nil
# Checks to see if display text
unless @list.nil? || @erased
for i in [email=0...@list.size]0...@list.size[/email]
if @list[i].code == 108
@list[i].parameters[0].dup.gsub!(/\{[Ee][Tt][Dd](.+?)\}/) do
@etd_display_color = ETD_Default_EventText_Color
@etd_display_text = $1
end
end
end
end
end
end
#==============================================================================
# ** Game_Player
#==============================================================================
class Game_Player < Game_Character
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias_method :seph_etd_gmplyr_refresh, :refresh
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
# Original Refresh Method
seph_etd_gmplyr_refresh
# Gets First Actor
actor = $game_party.actors[0]
# Retrn if Nil Actor
return if actor.nil?
# Determines Text
case ETD_Default_PlayerText.dup.downcase
when 'name' ; txt = actor.name
when 'class' ; txt = actor.class_name
when 'level' ; txt = "Level: #{actor.level}"
when 'hp' ; txt = "HP: #{actor.hp} / #{actor.maxhp}"
when 'sp' ; txt = "SP: #{actor.sp} / #{actor.maxsp}"
else ; txt = ''
end
# Creates Text Display
@etd_display_color = ETD_Default_PlayerText_Color
@etd_display_text = txt
end
end
#==============================================================================
# ** Sprite_Character
#==============================================================================
class Sprite_Character < RPG::Sprite
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias_method :seph_etd_spchr_update, :update
alias_method :seph_etd_spchr_dispose, :dispose
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Original update Method
seph_etd_spchr_update
# Character Display Update Method
update_display_text
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
# Original Dispose
seph_etd_spchr_dispose
# Dispose ETD Sprite
dispose_etd_sprite
end
#--------------------------------------------------------------------------
# * Dispose ETD Sprite
#--------------------------------------------------------------------------
def dispose_etd_sprite
# Dispose ETD Sprite
unless @_etd_text_sprite.nil?
@_etd_text_sprite.dispose
@_etd_text_sprite = nil
end
end
#--------------------------------------------------------------------------
# * Update Display Sprite
#--------------------------------------------------------------------------
def update_display_text
# If Character Has No ETD
if @character.etd_display_text.nil?
# Dispose ETD Sprite
dispose_etd_sprite
return
end
# If ETD Text Sprite Doesn't Exist
if @_etd_text_sprite.nil?
# Create ETD Text Sprite
create_etd_sprite
return
end
# If ETD Sprite Parameters Don't Match Characters
unless @_etd_display_text == @character.etd_display_text &&
@_etd_display_color == @character.etd_display_color
# Dispose Sprite
dispose_etd_sprite
# Recreate Sprite
create_etd_sprite
end
# Update ETD Sprite Position
@_etd_text_sprite.x = self.x
@_etd_text_sprite.y = self.y - self.oy / 2 - 24
@_etd_text_sprite.z = self.z
@_etd_text_sprite.visible = self.visible
end
#--------------------------------------------------------------------------
# * Create ETD Sprite
#--------------------------------------------------------------------------
def create_etd_sprite
# Creates Display Bitmap
bitmap = Bitmap.new(192, 26)
# Draws ETD Display Text
begin
bitmap.font.color = @character.etd_display_color
rescue
@character.etd_display_color = @character.is_a?(Game_Player) ?
Game_Character::ETD_Default_PlayerText_Color :
Game_Character::ETD_Default_EventText_Color
bitmap.font.color = @character.etd_display_color
end
bitmap.draw_icon_text(0, 0, 192, 24, @character.etd_display_text, 1)
# Creates Display Text Sprite
@_etd_text_sprite = Sprite.new(self.viewport)
@_etd_text_sprite.bitmap = bitmap
@_etd_text_sprite.ox = 80
@_etd_text_sprite.oy = 24
@_etd_text_sprite.x = self.x
@_etd_text_sprite.y = self.y - self.oy / 2 - 24
@_etd_text_sprite.z = 3000
@_etd_text_sprite.visible = true
# Saves ETD Text
@_etd_display_text = @character.etd_display_text
@_etd_display_color = @character.etd_display_color
end
end
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end