Event Proximity Icons
Authors: ForeverZer0
Version: 1.4
Type: Event Add-On
Key Term: Misc Add-on
IntroductionThis script will allow you to have various icons appear over events' heads when the player gets within a certain range of them, and the appropriate tag is found as a comment in their page.
Features- Easy to use
- Can use any number of custom tags you want
- Adjustable coordinates for icons
- Adjustable cycle times for changing icons
- Adjustable proximity before icons show
- Icons transition in/out smoothly
- Ability to have event simply glow when within range instead of use icons
- Can customize the color and speed of the glow effect
Screenshots
DemoDemo Link
Script#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
# Event Proximity Icons
# Author: ForeverZer0
# Version: 1.4
# Date: 6.4.2012
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
#
# Introduction:
# This script will allow you to have various icons appear over events' heads
# when the player gets within a certain range of them, and the appropriate
# tag is found asa comment in their page.
#
# Features:
# - Easy to use
# - Can use any number of custom tags you want
# - Adjustable coordinates for icons
# - Adjustable cycle times for changing icons
# - Adjustable proximity before icons show
# - Icons transition in/out smoothly
# - Can use glow feature instead of icons
# - Set custom glow color and speed
#
# Instructions:
# - See configuration below.
# - Make sure all icons are located in Graphics/Pictures directory
#
# Credits:
# - ForeverZer0, for the script
# - Zexion, for requesting it
# - Taiine, for her constant reminders to add Blizz-ABS compatibility ;)
#
##+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
# BEGIN CONFIGURATION
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
TAGS = ['TALK', 'SEARCH', 'ATTACK']
# These are th codes that will be searched for in event page comments
ICONS = ['talk', 'search', 'attack']
# These are the filenames of the respective codes, located in Pictures folder
PROXIMITY = 3
# The number of tiles away the player must be to event to show the icons.
CYCLE_TIME = 2
# The number of seconds before the icon cycles to the next one (if available)
ICON_OFFSET = [0, -8]
# The offset of the icon coodinates, adjust to your icon size
# [X_OFFSET, Y_OFFSET]
GLOW_ONLY = false
# Set to true to have sprites glow when within range instead of using icons
GLOW_COLOR = Color.new(255, 255, 200, 128)
# The color of the glow. (RED, GREEN, BLUE, ALPHA)
GLOW_SPEED = 40
# The glow speed. 40 = 1 second
ALWAYS_ON_TOP = false
# Set to true if icons always display over everything else.
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
# END CONFIGURATION
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
#===============================================================================
# ** Game_Map
#===============================================================================
class Game_Map
attr_accessor :proximity_data
alias zer0_proximity_setup setup
def setup(map_id)
@proximity_data = {}
zer0_proximity_setup(map_id)
end
end
#===============================================================================
# ** Game_Event
#===============================================================================
class Game_Event
alias zer0_proximity_init initialize
def initialize(map_id, event)
# Normal method
$game_map.proximity_data[event.id] = [false, []]
zer0_proximity_init(map_id, event)
# A little extra work now, but it greatly reduces the number of checks later
@event.pages.each {|page| page.list.each {|command|
if [108, 408].include?(command.code) &&
command.parameters.any? {|param| TAGS.include?(param) }
$game_map.proximity_data[@id][0] = true
end
}}
refresh
end
alias zer0_proximity_tag_refresh refresh
def refresh
# Call normal refresh method
zer0_proximity_tag_refresh
# Check current page
if !GLOW_ONLY && $game_map.proximity_data[@id][0] && @page != nil
# Set default values
$game_map.proximity_data[@id] = [false, []]
# Iterate commands and check if tag is present. If so, set respective flag
@page.list.each {|command|
if [108, 408].include?(command.code) &&
TAGS.include?(command.parameters[0])
$game_map.proximity_data[@id][0] = true
$game_map.proximity_data[@id][1].push(command.parameters[0])
end
}
end
end
end
#===============================================================================
# ** Sprite_Character
#===============================================================================
class Sprite_Character
alias zer0_proximity_tag_init initialize
def initialize(viewport, character = nil)
# Check if the sprite is that of an event, and has icons
if character.id != 0
flag = $game_map.proximity_data[character.id][0]
if character.is_a?(Game_Event) && flag
if ALWAYS_ON_TOP
topview = Viewport.new(0, 0, 640, 480)
topview.z = 9999
end
# Initialize sprite and bitmaps
@icon_sprite = ALWAYS_ON_TOP ? Sprite.new(topview) : Sprite.new(viewport)
@icon_sprite.opacity = @icon_index = 0
end
end
# Normal initialize method
zer0_proximity_tag_init(viewport, character)
end
alias zer0_proximity_tag_upd update
def update
# Normal update method
zer0_proximity_tag_upd
# Update the icons if needed
if ![nil, 0].include?(@character.id)
flag = $game_map.proximity_data[@character.id][0]
if @character.is_a?(Game_Event) && flag
GLOW_ONLY ? update_glow : update_icons
end
end
end
def update_glow
# Check proximity, then set flash if within range.
range_x = @character.x - $game_player.x
range_y = @character.y - $game_player.y
range = Math.hypot(range_x, range_y).abs
if range <= PROXIMITY && Graphics.frame_count % GLOW_SPEED == 0
self.flash(GLOW_COLOR, GLOW_SPEED)
end
end
def update_icons
# Return if no icons exist for page, or set icon if none is defined
if $game_map.proximity_data[@character.id][1].empty?
return
elsif @icon_sprite.bitmap == nil
icon_name = $game_map.proximity_data[@character.id][1][0]
@icon_sprite.bitmap = RPG::Cache.picture(icon_name)
end
bw = bh = 0
# Calculate width and height of icon and figure into the coordinates
if @icon_sprite.bitmap != nil
bw = ((self.bitmap.width / 4) - @icon_sprite.bitmap.width) / 2
by = -@icon_sprite.bitmap.height
end
# Set coordinates of icon relative to sprite
@icon_sprite.x = (self.x - self.ox) + bw + ICON_OFFSET[0]
@icon_sprite.y = (self.y - self.oy) + bh + ICON_OFFSET[1]
# Check range, fading in/out smoothly as needed
if $BlizzABS
pix = $BlizzABS.pixel
char_x, char_y = @character.x, @character.y
player_x, player_y = $game_player.x / pix , $game_player.y / pix
if @character.is_a?(Map_Battler)
char_x /= pix
char_y /= pix
end
else
char_x, char_y = @character.x, @character.y
player_x, player_y = $game_player.x, $game_player.y
end
range_x = char_x - player_x
range_y = char_y - player_y
range = Math.hypot(range_x, range_y).abs
@icon_sprite.opacity += (range <= PROXIMITY) ? 10 : -10
# Cycle icon bitmap as needed
if @icon_sprite.opacity > 0 && Graphics.frame_count % (CYCLE_TIME * 40) == 0
size = $game_map.proximity_data[@character.id][1].size
@icon_index = (@icon_index + 1) % size
icon_name = $game_map.proximity_data[@character.id][1][@icon_index]
@icon_sprite.bitmap = RPG::Cache.picture(icon_name)
end
end
alias zer0_proximity_icon_dispose dispose
def dispose
# Disposed the icon sprite
if @icon_sprite != nil && !@icon_sprite.disposed?
@icon_sprite.dispose
end
zer0_proximity_icon_dispose
end
end
InstructionsPlace above "Main", and below default scripts.
Instructions are within the script.
CompatibilityPixel movement scripts may cause issues, though I DID add compatibility for Blizz-ABS pixel-movement.
BlizzABS's ABSEAL will under certain circumstances not update events without graphics, which may include some of your proximity events, causing them not to work. To fix this issue, place the small script below anywhere below the BlizzABS scripts.
class Game_Character
alias zer0_proximity_update? update?
def update?
if self.is_a?(Game_Event) && $game_map.proximity_data.include?(self.id)
if @trigger == 3 || @trigger == 4 || self.name.clone.gsub!('\\eal') {''}
return true
end
return in_abseal_range?
end
return zer0_proximity_update?
end
end
Credits and Thanks- ForeverZer0, for the script
- Zexion, for the idea and the request
- Taiine, for her moral support adding Blizz-ABS compatibility

- Vexus, for helping track down the ABSEAL bug
Author's NotesPlease report any bugs/issues so that they can be resolved.
Enjoy!