Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # [Xp/Vx] Show Event Name
- # Version: 3.14
- # Author : LiTTleDRAgo
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- #
- # Explanation:
- #
- # - This script shows event name in map
- #
- # Instructions:
- #
- # - Setup the few configurations below.
- # - This script uses comments in the event's pages at any line.
- #
- # Comment : Show Name
- #
- # That's all
- #
- # To show name actor, set the event name to \a[ ActorID ]
- # To show value of variable, set to \v[ VariableID ]
- #
- # Extra Function
- # \fontsize[ Size ]
- # \bold
- # \italic
- # \fontname[ Fontname ]
- # \color[ R, G, B, ALPHA ]
- # \sn[ Name ]
- #
- # Press Z and C together to turn on the name on / off
- #
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- module EventName
- FONT = ['Calibri',12] # Font Name and Font Size
- BOLD = true # Toggle Bold
- ITALIC = true # Toggle Italic
- PLAYER_NAME = true # Show the player name too?
- SWITCH = 50 # Switch for Disable Show Event Name
- PRESS_BTN = [Input::A, # (Z Keyboard XP) (Shift Keyboard VX)
- Input::C] # (C/Enter Keyboard XP) (Z/Enter Keyboard VX)
- COLOR = Color.new(255,255,255,240) # Color Default
- POSITION = "A" # A = Above, B = Below
- RANGE = 3 # Range from character to show the name
- end
- #------------------------------------------------------------------------------
- # SDK Check
- #------------------------------------------------------------------------------
- if Object.const_defined?('SDK')
- SDK.log('Show Event Name', 'LiTTleDRAgo', 3, '03.02.11')
- @event_name_disabled = !SDK.enabled?('Show Event Name')
- end
- if !@event_name_disabled
- Sprite_Base = RPG::Sprite if !defined? Sprite_Base
- #==============================================================================
- # ** Sprite_EventName
- #------------------------------------------------------------------------------
- # This sprite is used to display Event Name. It observes a instance of the
- # Game_Character class and automatically changes sprite conditions.
- #==============================================================================
- class Sprite_EventName < Sprite_Base
- FONT = EventName::FONT
- BOLD = EventName::BOLD
- ITALIC = EventName::ITALIC
- PLAYER_NAME = EventName::PLAYER_NAME
- DIS_EV_SWITCH = EventName::SWITCH
- PRESS_BTN = EventName::PRESS_BTN
- COLOR = EventName::COLOR
- POS = EventName::POSITION
- RANGE = EventName::RANGE
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :character
- #--------------------------------------------------------------------------
- # * Object Initialization
- # viewport : viewport
- # character : character (Game_Character)
- #--------------------------------------------------------------------------
- def initialize(v,character)
- super(v)
- @character = character
- @name_event = Sprite.new
- @name_event.bitmap = Bitmap.new(100,280)
- @name_event.visible = true
- refresh_name
- update
- end
- #--------------------------------------------------------------------------
- # * Coloring
- #--------------------------------------------------------------------------
- def coloring
- size, name, bold, italic, color = FONT[1], FONT[0], BOLD, ITALIC, COLOR
- if $xrxs_xas
- @char.gsub!(/<Enemy(\d+)>/i) do color = Color.new(255,0,0,240) end
- elsif $BlizzABS && @character.is_a?(Map_Battler)
- case @character.ai.group
- when 1 then color = Color.new(0 , 0 , 255, 240)
- when 2 then color = Color.new(255, 0 , 0 , 240)
- when 3 then color = Color.new(128, 128, 128, 240)
- when 4 then color = Color.new(128, 128, 128, 240)
- when 5 then color = Color.new(255, 255, 0 , 240)
- when 6 then color = Color.new(0 , 255, 0 , 240)
- end
- end
- @char.gsub!(/\\fontsize\[(\d+)\]/) do size = $1.to_i end
- @char.gsub!('\\bold') do bold = true end
- @char.gsub!('\\italic') do italic = true end
- @char.gsub!(/\\fontname\[(.*?)\]/) do name = $1.to_s end
- @char.gsub!(/\\color\[(\d+),(\d+),(\d+),(\d+)\]/) do
- color = Color.new($1.to_i,$2.to_i,$3.to_i,$4.to_i) end
- @name_event.bitmap.font.name = name
- @name_event.bitmap.font.bold = bold
- @name_event.bitmap.font.italic = italic
- @name_event.bitmap.font.size = size
- @name_event.bitmap.font.color = color
- end
- #--------------------------------------------------------------------------
- # * Check Name
- #--------------------------------------------------------------------------
- def event_name_check
- @char.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
- @char.gsub!(/\\[Aa]\[([0-9]+)\]/) { !$game_actors[$1.to_i].nil? ?
- $game_actors[$1.to_i].name : ''}
- @char.gsub!(/\\fontsize\[(\d+)\]/) {''}
- @char.gsub!('\\bold') {''}
- @char.gsub!('\\italic') {''}
- @char.gsub!(/\\fontname\[(.*?)\]/) {''}
- @char.gsub!(/\\color\[(\d+),(\d+),(\d+),(\d+)\]/) {''}
- if $xrxs_xas
- @char.gsub!(/<Footstep>/i) {''}
- @char.gsub!(/<Throw(\d+)>/i) {''}
- @char.gsub!(/<Somaria(\d+)>/i) {''}
- @char.gsub!(/<Hookshot(\d+)>/i) {''}
- @char.gsub!(/<Enemy(\d+)>/i) { !$data_enemies[$1.to_i].nil? ?
- $data_enemies[$1.to_i].name : ''}
- end
- @char.gsub!(/\\[Ss][Nn]\[(.*?)\]/) do @char = $1.to_s end
- end
- #--------------------------------------------------------------------------
- # * Update
- #--------------------------------------------------------------------------
- def update
- super
- if @tile_id != @character.tile_id or
- @character_name != @character.character_name or
- (!rpgvx? && @character_hue != @character.character_hue)
- @tile_id, @character_name = @character.tile_id, @character.character_name
- @character_hue = @character.character_hue if !rpgvx?
- refresh_name
- end
- return @name_event.visible = false if !DIS_EV_SWITCH.nil? and
- (@character.opacity < 50 or $game_switches[DIS_EV_SWITCH])
- visibility if !PRESS_BTN.nil?
- if @name_event.visible
- refresh_name if @cw.nil?
- @name_event.x = @character.screen_x - (@cw.nil? ? 0 : @cw /2)
- @name_event.y = @character.screen_y - (POS == "A" ? @ch : 0)
- @name_event.z = 1
- @name_event.opacity = @character.opacity
- @name_event.blend_type = @character.blend_type
- @name_event.bush_depth = @character.bush_depth
- end
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh_name
- return if @name_event.nil? or @name_event.bitmap.nil? or
- @name_event.disposed? or !@name_event.visible or @character.name_effect.nil?
- @name_event.bitmap.clear
- @character.name_effect.each {|@char| coloring; event_name_check }
- draw_name if ($BlizzABS && @character.is_a?(Map_Actor) && PLAYER_NAME) or
- ($BlizzABS && @character.is_a?(Map_Enemy) && @character.nametag) or
- (@character.is_a?(Game_Event) && @character.nametag) or
- (@character.is_a?(Game_Player) && PLAYER_NAME) or
- ($xas_caterpillar && @character.is_a?(Game_Party) && PLAYER_NAME)
- @x_frame, @y_frame = 4, 4
- if POS == "A"
- if rpgvx?
- @cw = @name_event.bitmap.width / @x_frame / 2
- @ch = @name_event.bitmap.height / @y_frame - 40
- return
- end
- bit = RPG::Cache.character(@character.character_name,
- @character.character_hue)
- @cw = bit.width / @x_frame / 2
- @ch = bit.height / @y_frame + 15
- else
- @cw = @name_event.bitmap.width / @x_frame / 2
- @ch = @name_event.bitmap.height / @y_frame - 40
- end
- end
- #--------------------------------------------------------------------------
- # * Draw Name
- #--------------------------------------------------------------------------
- def draw_name
- if defined? Bitmap.draw_hemming_text
- @name_event.bitmap.draw_hemming_text(0, 0, 100, 20, @char ,4)
- else
- @name_event.bitmap.draw_text(0, 0, 100, 20, @char ,4)
- end
- end
- #--------------------------------------------------------------------------
- # * Dispose
- #--------------------------------------------------------------------------
- def dispose
- super
- @name_event.dispose
- end
- #--------------------------------------------------------------------------
- # * Visibility
- #--------------------------------------------------------------------------
- def visibility
- pressed = Input.press?(PRESS_BTN[0]) && Input.trigger?(PRESS_BTN[1])
- if RANGE != nil && !@pressed
- x = ($game_player.x-@character.x).abs+($game_player.y-@character.y).abs
- @name_event.visible = (x <= RANGE)
- end
- if !@pressed && pressed
- @name_event.visible, @pressed = false, true
- elsif @pressed && pressed
- @name_event.visible, @pressed = true, false
- end
- end
- end
- #==============================================================================
- # ** Kernel
- #==============================================================================
- module Kernel
- def rpgvx?() return (defined? Graphics.resize_screen) end
- end
- Cache = RPG::Cache if !defined? Cache
- #==============================================================================
- # ** Game_Party
- #------------------------------------------------------------------------------
- # This class handles the party. It includes information on amount of gold
- # and items. The instance of this class is referenced by $game_party.
- #==============================================================================
- class Game_Party
- #--------------------------------------------------------------------------
- # * Name
- #--------------------------------------------------------------------------
- def name_effect() leader_name end
- #--------------------------------------------------------------------------
- # * Leader Name
- #--------------------------------------------------------------------------
- def leader_name
- return @actors[0].nil? ? '' : @actors[0].name if !rpgvx?
- return members[0].nil? ? '' : members[0].name
- end
- end
- #==============================================================================
- # ** Game_Event
- #------------------------------------------------------------------------------
- # This class deals with events. It handles functions including event page
- # switching via condition determinants, and running parallel process events.
- # It's used within the Game_Map class.
- #==============================================================================
- class Game_Event
- #--------------------------------------------------------------------------
- # * Name
- #--------------------------------------------------------------------------
- def name_effect() @event.name end
- #--------------------------------------------------------------------------
- # * Nametag
- #--------------------------------------------------------------------------
- def nametag
- return (!@list.nil? && @list.any? {|i| i.code == 108 &&
- i.parameters == ['Show Name']})
- end
- end
- #==============================================================================
- # ** Game_Player
- #------------------------------------------------------------------------------
- # This class handles maps. It includes event starting determinants and map
- # scrolling functions. The instance of this class is referenced by $game_map.
- #==============================================================================
- class Game_Player
- #--------------------------------------------------------------------------
- # * Name
- #--------------------------------------------------------------------------
- def name_effect() return $game_party.leader_name end
- end
- #==============================================================================
- # ** Map Battler
- #------------------------------------------------------------------------------
- # This class handles battlers in Blizz ABS
- #==============================================================================
- if $BlizzABS
- class Map_Battler
- def name_effect() return @battler.name end
- def nametag
- return (!@list.nil? && @list.any? {|i| i.code == 108 &&
- i.parameters == ['Show Name']})
- end
- end
- end
- #==============================================================================
- # ** Scene_Map
- #------------------------------------------------------------------------------
- # This class performs the map screen processing.
- #==============================================================================
- class Scene_Map
- attr_accessor :spriteset
- end
- #--------------------------------------------------------------------------
- # * Refresh Name
- #--------------------------------------------------------------------------
- def refresh_name(val=nil)
- return $scene.spriteset.eventname[val].refresh_name if !val.nil?
- $scene.spriteset.eventname.each {|i| i.refresh_name}
- end
- #==============================================================================
- # ** Spriteset_Map
- #------------------------------------------------------------------------------
- # This class brings together map screen sprites, tilemaps, etc. It's used
- # within the Scene_Map class.
- #==============================================================================
- class Spriteset_Map
- PRESS_BTN = EventName::PRESS_BTN
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :eventname
- #--------------------------------------------------------------------------
- # * Main Processing
- #--------------------------------------------------------------------------
- def init_eventname
- @eventname = []
- @eventname[0] = Sprite_EventName.new(@viewport1,$game_player)
- ($game_map.events.keys.sort).each {|i|
- @eventname[i] = Sprite_EventName.new(@viewport1,$game_map.events[i])}
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- alias update_eventname_earlier update
- def update
- @eventname.nil? ? init_eventname : @eventname.each {|i|i.update if !i.nil?}
- update_eventname_earlier
- end
- #--------------------------------------------------------------------------
- # * Dispose
- #--------------------------------------------------------------------------
- alias dispose_eventname dispose
- def dispose
- @eventname.each {|i| i.dispose if !i.nil?}
- dispose_eventname
- end
- end
- #--------------------------------------------------------------------------
- # SDK Check End
- #--------------------------------------------------------------------------
- end
- #--------------------------------------------------------------------------
- # END OF SCRIPT
- #--------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement