Character Hover Graphics
Version: 1.3
Author: modern algebra
Date: March 10, 2009
Version History
- <Version 1.3> 03.10.2009 - You can now use animated pictures and set them above the characters
- <Version 1.2> 03.10.2009 - Allowed the option to set font colour and size when setting text to float
- <Version 1.1> 01.27.2009 - Fixed Bug with map scrolling
- <Version 1.0b> 01.26.2009 - Fixed Bounce
- <Version 1.0> 01.25.2009 - Original Release
Description
This script allows you to place a graphic to hover over any characters in the map. Like in Diablo, when an NPC has something important to say, you can place an exclamation mark or any other thing else over his/her head.
Features
- Can show either a picture or text over any event or the player
- Allows for showing animated pictures
- Can set colour and size of text if drawing it
- Option to have the graphic bounce up and down or not.
- easy call script functionality
Screenshots
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg239.imageshack.us%2Fimg239%2F9350%2Fexclamationfe2.png&hash=e98955b7c1961de167f28fdcbb459ff04c113a8b)
Instructions
Please see the header of the script.
Script
#==============================================================================
# Character Hover Graphics
# Version: 1.3
# Author: modern algebra
# Date: March 10, 2009
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Instructions:
# Place this script above Main and below Materials.
#
# To have a graphic hover, first you need to import the picture that you want
# to have hovering in the Pictures folder. Then, you can place it over any
# event with this in a call script:
#
# set_hover_graphic (char_index, picture, bouncing_boolean, colour, size)
#
# Where:
# *char_index is the index of the event that you want it to hover over. If
# this is set to -1, it will be over the player. If it is set to 0, it
# will be over the current event. If it is set to any other ID, then it
# will be over the event with that ID. If this is not set, it is
# assumed to be 0
# *picture is the name of the picture that you want to have hovering in
# quotation marks. So, if your picture is named Exclamation! then
# you would put: "Exclamation!" here. Remember, these graphics must be
# in your Pictures folder. If the picture you denote is not in the
# Picture file, then it will instead draw the actual word you send
# through. If you set this to nil, then it will turn off any graphic
# currently hovering over the specified event. If you leave this space
# blank, it will default to nil.
# If the name of the picture is prefaced by %[x], then the picture
# will animate, with x being the number of frames. SO, a picture that
# is named %[6]Teardrop and is 192 x 32, will consist of 6 frames, each
# 32 x 32 cutouts of the file. If you do not specify a number of frames
# and merely preface the file with %, then it will default to 4 frames.
# *bouncing boolean is either true or false, where true means that the
# graphic will bounce up and down and false meaning it will be
# stationary. If it is not set, then it defaults to false
# *colour is the color you want the text drawn in, and this will only work
# if it is writing text, not using a picture. If you set this as an
# integer, it will take the colour of the corresponding index from the
# windowskin palette. If you put an array, it will take that as the
# RGB values. So, [255, 0, 0] would be RED, etc... If you leave this
# blank, it defaults to 0, so the normal color on the windowskin palette.
# *size is the size of the text. Again, this matters only if it is text
# being drawn and not a picture. This determines the size of the text
# drawn. If left blank, it will default to 20.
#
# EXAMPLES:
#
# set_hover_graphic (0, "Exclamation!")
# - Assuming there is a picture in your Pictures folder named
# "Exclamation!", it will set that picture to hover over the event that
# calls it. If no such picture exists, it will print the text:
# "Exclamation!" over the character
#
# set_hover_graphic (5, "?", true)
# - Assuming there is a picture in your Pictures folder named "?", it
# will set that picture to hover over the event with ID 5. If
# no such picture exists, it will print a question mark over Event 5. It
# will be bouncing.
#
# set_hover_graphic (-1, "Player Name", false, 8, 28)
# - This will print "Player Name" over the player. It will not be
# bouncing. It will be drawn in the colour with index 8 on the windowskin
# pallette. It will be size 28.
#
# set_hover_graphic (-1)
# - Will delete any hover graphic that is over the player.
#==============================================================================
# ** Game_Character
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new instance variable - ma_hover_graphic, ma_hgfloat
#==============================================================================
class Game_Character
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Public Instance Variable
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
attr_accessor :ma_hover_graphic # The picture name of hover graphic
attr_accessor :ma_hgfloat # Boolean on bouncing
attr_accessor :ma_hgcolour # Colour of text
attr_accessor :ma_hgsize # Size of text
end
#==============================================================================
# ** Game Interpreter
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new method - set_hover_graphic
#==============================================================================
class Game_Interpreter
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Set Hover Graphic
# char_index : the index of the character
# picture_name : the picture to show over the character
# float : boolean with whether or not you want graphic to bounce
# colour : integer -> windowskin palette; array -> RGB
# size : the size of the text
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def set_hover_graphic (char_index = 0, picture_name = nil, float = false, colour = 0, size = 20)
# Get Character
char_index = @event_id if char_index == 0
target = char_index == -1 ? $game_player : $game_map.events[char_index]
return if target == nil
target.ma_hover_graphic = picture_name
target.ma_hgfloat = picture_name == nil ? nil : float
if colour.is_a? (Array)
colour.push (255) while colour.size < 4
else
windowskin = Cache.system ("Window")
clr = windowskin.get_pixel(64 + (size % 8) * 8, 96 + (size / 8) * 8)
colour = clr.alpha == 0 ? [255, 255, 255, 255] : [clr.red, clr.green, clr.blue, clr.alpha]
end
target.ma_hgcolour = colour
target.ma_hgsize = size.is_a? (Integer) ? size : 20
end
end
#==============================================================================
# ** Sprite Character
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Chages:
# aliased methods - dispose, update
# new method - ma_start_hover_graphic, ma_update_hover_graphic,
# ma_dispose_hover_graphic
#==============================================================================
class Sprite_Character
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Dispose
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modlg_hvr_graphc_dispse_94nb5 dispose
def dispose
# Dispose hover graphic
ma_dispose_hover_graphic
# Run Original Method
modlg_hvr_graphc_dispse_94nb5
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Frame Update
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias malg_hover_grfx_upd_char_954bn update
def update
# Run Original Method
malg_hover_grfx_upd_char_954bn
# Update Hover Graphic
if @hover_sprite == nil && @character.ma_hover_graphic != nil
ma_start_hover_graphic (@character.ma_hover_graphic, @character.ma_hgfloat,
@character.ma_hgcolour, @character.ma_hgsize)
end
ma_update_hover_graphic
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Start Hover Graphic
# picture_name : the name of the picture to float
# float : boolean on whether picture should float
# colour : the colour of the text
# size : the size of the text
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def ma_start_hover_graphic (picture_name, float, colour, size)
ma_dispose_hover_graphic
@hover_sprite = ::Sprite.new(viewport)
begin
# Use picture if it exists
bmp = Cache.picture (picture_name)
if picture_name[/^%(\[(\d+)\])?/] != nil # If animated graphic
# Split into an array of bitmaps
@frame_bmp_array = []
frames_n = $2 == nil ? 4 : $2.to_i
width = bmp.width / frames_n
for i in 0...frames_n
frame_bmp = Bitmap.new (width, bmp.height)
frame_bmp.blt (0, 0, bmp, Rect.new (i*width, 0, width, bmp.height))
@frame_bmp_array.push (frame_bmp)
end
bmp.dispose
@hover_sprite.bitmap = @frame_bmp_array[0]
@gframe_count = 0
@frame_index = 0
else
@hover_sprite.bitmap = bmp
end
rescue
# Else draw the word
@hover_sprite.bitmap = Bitmap.new (32, 32)
# Retrieve actual string
ts = @hover_sprite.bitmap.text_size (picture_name)
# Resize bitmap if too long
if ts.width + 4 > @hover_sprite.bitmap.width
@hover_sprite.bitmap.dispose
@hover_sprite.bitmap = Bitmap.new (ts.width + 4, [ts.height + 4, 32].max)
end
# Draw text
@hover_sprite.bitmap.font.color = Color.new (colour[0], colour[1], colour[2], colour[3])
@hover_sprite.bitmap.font.size = size
@hover_sprite.bitmap.draw_text (0, 0, @hover_sprite.bitmap.width, 32, picture_name, 1)
end
@gframe_count = -1 if @gframe_count != 0
@hover_sprite.x = self.x - (@hover_sprite.bitmap.width / 2)
@hover_sprite.y = self.y - self.height - @hover_sprite.bitmap.height
@hover_sprite.z = z + 200
@float_count = float ? 0 : -1
@float_y = 0
@ma_last_xy = [self.x, self.y]
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Update Hover Graphic
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def ma_update_hover_graphic
ma_dispose_hover_graphic if @character.ma_hover_graphic == nil
return if @hover_sprite == nil
# Reset x, y if map has scrolled
if @ma_last_xy != [self.x, self.y]
@hover_sprite.x = self.x - (@hover_sprite.bitmap.width / 2)
@hover_sprite.y = self.y - self.height - @hover_sprite.bitmap.height + @float_y
@ma_last_xy = [self.x, self.y]
end
# If the bitmap is animated
if @gframe_count != -1
# Count up
@gframe_count += 1
# Change graphics ever 8 frames
if @gframe_count == 12
@gframe_count = 0
@frame_index = (@frame_index + 1) % @frame_bmp_array.size
@hover_sprite.bitmap = @frame_bmp_array[@frame_index]
end
end
# If bouncing
if @float_count != -1
@float_count += 1
# Modify y every 2 frames
return if @float_count % 2 == 0
# If not yet asceneded 8 pixels
if @float_count <= 16
@hover_sprite.y -= 1
@float_y -= 1
else # Return to original position
@hover_sprite.y += 1
@float_y += 1
@float_count %= 28
end
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Dispose Hover Graphic
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def ma_dispose_hover_graphic
if @hover_sprite != nil
@hover_sprite.dispose
@frame_bmp_array.each { |bmp| bmp.dispose unless bmp.disposed? } if @frame_bmp_array != nil
@hover_sprite = nil
@ma_last_xy = nil
@gframe_count = nil
@frame_index = nil
@float_count = nil
@float_y = nil
end
end
end
Credit
Thanks
- lomastul, for requesting the script
- sasofrass, for suggesting ading option to set colour and size
- grafikal009, for suggesting animated icons
Support
Please post in this topic at RMRK for the swiftest support.
Known Compatibility Issues
No known compatibility issues. If you do encounter something, try placing this script below all of your other custom scripts and see if the problem persists.
Author's Notes
If you post this script elsewhere, please link to this topic at RMRK so that people know where to go for updates and support.
Looks good. I'll have to take a closer look at the bouncing graphic feature a bit later.
When I set the bouncing flag to true, it does work...
However, the bouncing picture do not return back to its original place, precisely. It does bounce but slowly the picture is advancing down. It can even go down past the event it's supposed to be above.
My picture is 32x32 pixels, same as the tile.
The picture will reset back to its original place when I receive some item from different chest on same map.
Weird, I had thought I fixed that.
Anyway, I replaced the code in the first post with one that ought to work - try it now.
It works as it intended now. Many thanks!
This definitely caught my eye and looked really nice. So I stuck it in a project to test it out.. and came up with what I call an error.
When I call the script, and it hovers an image or text over an event, should the player move and cause the screen to have to scroll.. the hovering image or text goes along with the screen.
Is this something that's fixable.. or just has to be dealt with?
-Heart of Shadow-
It is fixable. I will do so soon. Thank you for notifying me of the error.
OK, it should be fixed now. The first post has been updated with the corrected code.
Righteous. Just tried out the updated script and it works wonderfully.
No more "errors" that I could spot right off the bat. =P
Nicely done, MA.
Sweet. 'Cuz I think I'm sick of placing an event above an NPC to display an icon of some sort that has to move with the NPC.
Might use this though I don't think I'll be finishing any games anytime soon, since I'm still experimenting and such.
Heh. I really like this script. I'm using it so that the player can easily know which NPC out of the fifty billion in each pub or whatever is the vendor/innkeeper/mentor/etc.; basically, I'm using it to distinguish service NPCs from the commonfolk.
Good work. =D
Hey MA, do you think you will make it optional to have the icons be animated? (I mean besides bouncing) That'd be awesome
Version 1.2 released
Not much different, but someone on another forum suggested that it would be a good idea to be able to set the colour and the size when drawing text, and I agreed. So that's that.
@grafikal: animated icons sounds cool. Do you have any specific format you would like that in?
Nothing specific, I think it'd be awesome to have something animate around like if a player were poisoned, it could visually show it, or an NPC rather.
An idea for the animated suggestion: It could use a "characterset" type thing, like the balloon emotes do.
I don't know how hard that would be to implement, but I think that'd be kinda cool. The Tankentai SBS has a feature similar to this in that when an actor is at critical HP, the sweatdrop emote will loop it's animation over their head until they die or get healed above that critical point. That is prolly the closest existing example to what my idea is.
Just throwing some thoughts out there. Lemme know if you'd like any clarification or something.
-Heart of Shadow-
Yeah, that sounds like something of what I'll do. I think I will make it just so that there is a character that, if at the start of the name identifies it as animated, and you can set the number of frames in the filename, so like:
%[4]Exclamation
or something, and what that would do is make it so that it will cycle between 4 frames. I don't think I will make speed an option...
And the frames will go across, so if Exlamation is 84 x 32, each frame would be 21 x 32
EDIT::
OK, Version 1.3 is now up. Please inform me if you encounter any bugs.
Really good script Modern Algebra. ;D :P
But I was wondering if there was somewhere i could get a yellow exclamation mark, a grey question mark and a yellow question mark images (32x32 pixels)that I could put over NPCs and which would be used to do available quest, unfinished quest and finished quests like the most RPG based-games uses. Thanks and like I said really good script :P I love it.
I'm sure it wouldn't be hard to make them. Do you have an image editing program? Because then you could make thin in whatever font and shade you want. I can make them for you if you don't.
The font I used is Black Rose
Is there any way to make it only show for a few seconds at each map transition?
If you've ever played Final Fantasy IX, I'm referring to the way to HERE Icon works.
Every time you transition from map to map, a pointer shows over the character's head for a few seconds, then disappears, but can be called to show permanently at the press of the Select Button.
Any way to do that with this? I'm sure it's possible.
Well, the easiest way is just with a parallel process at the beginning of each map.
Something like:
Script: set_hover_graphic (-1, "Here Arrow")
Wait: 240 Frames
Script: set_hover_graphic (-1)
Erase Event
Well that definitely works, thank you!
EDIT: Okay so maybe not, I get a syntax error. But that's fine, I suppose I can work with the overhead view always being there.
It works for me. Can you screenshot the event that you do it in?
Sure thing.
http://i25.tinypic.com/2nslxg9.jpg
But after five seconds of looking over at the screenshot I took, I figured out what the problem was. Sorry about that.
Once again, great script. I appreciate the time and effort you must've put into this.
yeah, well you shouldn't let the command go to two lines since it evaluates them separately.
instead, you could put:
n = "pointerdown"
set_hover_graphic (-1, n)
but yeah, you said you figured it out so that was probably unnecessary.
I hate to necropost, but I've got a script error I haven't figured out how to fix:
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg412.imageshack.us%2Fimg412%2F7797%2Fhovererror.png&hash=69946f916af61160e230cc86c72520528548790f)
This is what I have for the event:
http://img191.imageshack.us/img191/2319/hovererror2.png
Take out the .png from Pointer.
Hope that helps.
I tried that, but it didn't seem to change anything.
That is a strange error and I must admit that I'm confused. It must be a script incompatibility though considering that the code is calling from an event interpreter. Normally any NoMethodError for that should be coming out of Game_Interpreter, not Kernel. Obviously, Kernel is mixed in with all objects, including Game_Interpreter, so using eval would normally recognize methods of Interpreter, not go to Kernel. The only thing I can think of is that some other scripter messed around with eval in Game_Interpreter and instead of aliasing it used Kernel.eval, thinking that it would be the same (it's not!), which would check Kernel and obviously not recognize methods in Game_Interpreter...
So, ah... that probably didn't mean anything to you but I think that must be it. Press CTRL+SHIFT+F in the Script Editor and type in the find field:
Kernel.eval
Whatever script comes up is the culprit. Report back to me what you find.
I've located the kernel.eval in a Random NPC Generation script, which is about three above this script. Should I place this one above that one?
EDIT: Okay, so I placed the Hovering Image script above it, and the same thing happens. I kinda want to keep the random NPC generation system. Anyway around this? Here's the random NPC generation:
[spoiler]#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# NPC Generator
# by berka rgss2
# www.rpgmakervx-fr.com
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# Rgss 2 v 2.0 based on mithos & pipo work
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# -Instructions-
# Write in an event, call a script command:
#
# minumum required:
# [event] # compulsory !
# chara : "Actor01" # name of the charset file or: chara : rand
#
# and optional settings:
# x : 5 # x position, random if nothing
# y : 10 # y position, random if nothing
# nom : "Event01" # event's name or nom: rand
# c_index : 0 # charset's index
# face : "Actor01" # name of the faceset file or: face : true (=> same as chara)
# f_index : 0 # faceset's index
# dir : 2 # event direction
# type_mov:0 # movement type
# vit_mov:0 # movement speed
# freq_mov:0 # muvement frequency
# texte:"bonjour" # dialog or texte:rand (cf. list above)
# trigger:0 # event trigger
# prio_type:1 # priority
# script: "print @a=1" # script command
# combat: 1,true,false # battle: id_monster, esc, follow if defeated
# or: 0,0,1000 # gold: 0/1 (add/rem),0/1 (Const/var),amount (nbr/var_id)
# objet: 2,0,0,10 # item: id,0/1 (add/rem),0/1 (Const/var),amount (nbr/var_id)
# arme: 2,0,0,10 # weapon: id,0/1 (add/rem),0/1 (Const/var),amount (nbr/var_id)
# bouclier: 2,0,0,10 # armor: id,0/1 (add/rem),0/1 (Const/var),amount (nbr/var_id)
# suppr : true # erase this generated event
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# Example:
#
# [event]
# chara:rand
# texte:rand
# type_mov : 1
#
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
$characters="preteritus random" # series of charsets used to create random character
# people1, people2...
$chara_nbre=1 # nombre de fichiers people
# Random dialogs (too lazy to translate everything)
$dialogues=["Test text", "Test text 2", "Test text 3"]
# in-game: $dialogues << "You are now an heroe for me !"
#==============================================================================
# END OF CUSTOMIZATION
#==============================================================================
$nom=[%w(Gw Ul Et Rh Ed Gr Dr Dw Tr Gh As Ar Ag Xor), # name generator
%w(ai ia eo ui yn or ul ur a e i o u y yr ya yl),
%w(th rk dd gh z l mn lyr zar gor ryn nia lia )]
#==============================================================================
# ** Berka's Module
#------------------------------------------------------------------------------
# This module lists the commands that the events can perform.
#==============================================================================
module Berka
module Pnj_Gen
Tag = "[event]" # Tag of NPC generator
Separateur = ":" # Separator: cmd/value
Index_Chara = 8 # Number of patterns
Commandes = {:face => "[101,[@_face,@_f_index,0,2]]", # List of commands
:or => "[125,[*@_or]]",
:objet => "[126,[*@_objet]]",
:arme => "[127,[*@_arme]]",
:bouclier => "[128,[*@_bouclier]]",
:combat => "[301,[0,*@_combat])]",
:script => "[355,[@_script]]",
:suppr => "[214]",
:texte => "[401,[@_texte]]",
:area => "[402,[@_area]]"
}
ProfCoord = 100 # Deep of x/y scan
end
end
include Berka::Pnj_Gen
#==============================================================================
# ** Array
#------------------------------------------------------------------------------
# This class has been edited to allow for random values to be returned.
#==============================================================================
class Array
def arand
self[Kernel.rand(self.size)]
end
end
#==============================================================================
# ** Object
#------------------------------------------------------------------------------
# This class has been edited to check if it is a "?"
#==============================================================================
class Object
def rand?
self == "?"
end
end
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
# Edited to do ?
#==============================================================================
class Game_Map
include RPG
def check_event(x,y)
for event in @events.values
return event.id if event.x==x&&event.y==y
end
return nil
end
def make_event(com)
self.instance_variables.each{|v|eval("#{v}=nil") if v.include?("@_")}
rand="?"
com.each_with_index{|c,i|eval("@_#{c.first.id2name}=#{c[1]}")}
set_rand
set_options
return if @_x.nil?||@_y.nil?
if check_event(@_x,@_y).nil?
@event=Event.new(@_x,@_y)
com.each{|c|c=c.first
ajout_cmd(*eval("#{Commandes[c]}"))if Commandes.has_key?(c)
}
@event.id=creerid
@event.name=@_nom
@event.pages.first.graphic.character_name=@_chara
@event.pages.first.graphic.character_index=@_c_index
@event.pages.first.graphic.direction=@_dir
@event.pages.first.move_type=@_type_mov
@event.pages.first.move_frequency=@_freq_mov
@event.pages.first.move_speed=@_vit_mov
@event.pages.first.through=@_trav
@event.pages.first.trigger=@_trigger
@event.pages.first.priority_type=@_prio_type
@events[@event.id]=Game_Event.new(@map_id,@event)
@need_refresh=true
$scene.refresh_spriteset
end
end
def set_rand
rand="?"
if !@_area.nil?
for i in $data_areas.values
if @_area == i.id
@_x = rand(i.rect.width)+i.rect.x
@_y = rand(i.rect.height)+i.rect.y
end
end
end
@_chara||=rand
@_nom=aleatoire_nom if @_nom.nil?
@_texte=$dialogues.arand if @_texte.rand?
@_x,@_y=*aleatoire_pos if @_x.nil?||@_y.nil?
@_pers=aleatoire_perso
if @_chara.rand?||@_c_index.rand?
@_face,@_f_index,@_chara,@_c_index=@_pers
end
end
def set_options
@_chara=@_pers.first if @chara.nil?
@_c_index=@_pers[1] if @_c_index.nil?
@_face,@_f_index = "",0 if @_face==false
@_dir||=3
@_type_mov||=0
@_freq_mov||=3
@_vit_mov||=3
@_trav||=false
@_trigger||=0
@_prio_type||=1
end
def aleatoire_pos
ProfCoord.times{
x,y=Kernel.rand(width).to_i,Kernel.rand(height).to_i
next if x==$game_player.x&&y==$game_player.y
(return x,y) if passable?(x,y)&&!check_event(x,y)
}
return nil,nil
end
def aleatoire_perso
i=Kernel.rand(Index_Chara-1)
res=$characters+(Kernel.rand($chara_nbre)+1).to_s
return [res,i,res,i]
end
def aleatoire_nom
n="#{$nom.first.arand}#{$nom[1].arand}#{$nom[2].arand}"
n<<$nom[1].arand if rand(4)==1
return n
end
def event_name(id)
@events[id].name if !@events[id].nil?
end
def creerid
id=1
id+=1 while @events.keys.include?(id)
return id
end
def ajout_cmd(code,param=[],i=0)
cmd=EventCommand.new
cmd.code,cmd.parameters,cmd.indent=code,param,i
@event.pages.first.list.insert(-2,cmd)
end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# Edited to allow for disposing, then remaking the map's spriteset.
#==============================================================================
class Scene_Map < Scene_Base
def refresh_spriteset
@spriteset.dispose;@spriteset=Spriteset_Map.new
end
end
#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
# Changes the call script command to check if the tag's included
#==============================================================================
class Game_Interpreter
def eval(script)
if script.include?(Tag)
com=[];script.gsub!(Tag,'')
list=script.split("\n")
s=Separateur
list.each_with_index{|e,i|e.gsub!(' '+s,s);e.gsub!(s+' ',s);f=e.split(s)
com<<[f.first.to_sym,f[1]]if !f[1].nil?}
$game_map.make_event(com)
return
end
return Kernel.eval(script)
end
end
#==============================================================================
# END OF SCRIPT
#==============================================================================[/spoiler]
Yeah, replace the last part:
#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
# Changes the call script command to check if the tag's included
#==============================================================================
class Game_Interpreter
def eval(script)
if script.include?(Tag)
com=[];script.gsub!(Tag,'')
list=script.split("\n")
s=Separateur
list.each_with_index{|e,i|e.gsub!(' '+s,s);e.gsub!(s+' ',s);f=e.split(s)
com<<[f.first.to_sym,f[1]]if !f[1].nil?}
$game_map.make_event(com)
return
end
return Kernel.eval(script)
end
end
with:
#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
# Changes the call script command to check if the tag's included
#==============================================================================
class Game_Interpreter
alias mal_brk_npcgfix_eval_2de4 eval
def eval(script)
if script.include?(Tag)
com=[];script.gsub!(Tag,'')
list=script.split("\n")
s=Separateur
list.each_with_index{|e,i|e.gsub!(' '+s,s);e.gsub!(s+' ',s);f=e.split(s)
com<<[f.first.to_sym,f[1]]if !f[1].nil?}
$game_map.make_event(com)
return
end
return mal_brk_npcgfix_eval_2de4 (script)
end
end
And I mean replace it - don't just put it underneath.
Aha, that did it! Thanks for the help Modern Algebra! Except now, I just can't get the picture to float above an event. I have the same event I posted before:
http://img191.imageshack.us/img191/2319/hovererror2.png
Am I suppose to do something else to get this to work? I already tried getting rid of the .png, but it didn't seem to change anything.
Well, the .png isn't necessary, but it wouldn't mess it up. Nothing is showing? The only thing I can think of for nothing at all showing would be another script incompatibility, or in the alternative, you have another parallel process that is turning it off every frame as well and you overlooked it.
Try placing it below all the other scripts you're using, but still above Main.
Hm, I did that but nothing changed. What kinds of scripts could be causing this?
I don't know - it might not work with some anti-lag scripts if you set that particular event to not be updated, since it relies on the sprite updating to put up the graphic. Anyway, there doesn't appear to be anything wrong with how you called it, so the only thing I could think of it happening naturally (without other script interference) is if you had another event running simultaneously that turned it off.
But anyway, try making a new project - put the script in and test it there. Then add your other scripts in one by one and see when it stops working.
Okay, so the problem with it, after searching for the source, was from the Anti Lag script like you thought. I tried to use the "DOUPDATE" feature with it, but it isn't changing anything. Is there anyway to get them both to work?
Show me the antilag script and I'll see.
Here's the one I'm using:
[spoiler]#==============================================================================
# A N T I L A G V X
#------------------------------------------------------------------------------
# Author: Andrew McKellar (Anaryu) (anmckell@gmail.com)
#
# Version: 1.2h
#
# 1.2 March 5th 4:15pm EST: Implemented feedback from (Zeriab) and other ideas
# for updating sprites/events that are off-screen/parallel also added
# off-screen updating for events that are set with a specific move route.
# 1.2a March 6th 5:09am EST: Changed on_screen to use Graphics module instead
# of static values. (Zeriab)
# 1.2b March 7th 12:36am EST: Changed Game_Player to use standard functions
# instead of special ones. Changed empty array check to use proper empty?
# 1.2c March 10th 10:13pm EST: Updated events that used a tile and a character
# on multiple pages to be drawn as a sprite correctly. (eugene)
# 1.2d March 14th 4:12am EST: Fixed errors with vehicles, passability,
# and airship landing.
# 1.2e March 18th 1:47am EST: Fixed errors with passability and tileset
# graphics in multi-page events.
# 1.2f June 9th 4:34pm EST: Fixed errors with diagonal movement having the
# turn_ok setting passed in while the original functions didn't use it.
# 1.2g June 20th 7:49pm EST: Fixed bugs regarding diagonal movement for
# events (last update was just player!) and fixed bug with jump function
# not updating location.
# 1.2h September 20th 10:35am EST: Added a check so changing graphics on a blank
# event from another event, or using Show Animation or Show Bubble will
# activate the event automatically and set it to be in use. Also added two
# new globals to allow you to choose how far off-screen updates will still
# be performed (see below.) Also fixed efficiency loss by having several
# math functions in the on_screen function (called constantly) and moved
# those to initialize function instead.
# 1.2i November 29th 6:14pm EST: Fixed issue with balloon use over non-event
# characters.
# 1.2j December 22nd 3:59am EST: Fixed issues when 'moveto' or Move Event
# commands were used.
#
# This script modifies background functions, only other low-level or map
# modification scripts should conflict.
#
# Please credit if used, no need to ask for permission for commercial use.
#==============================================================================
# If true this will allow the system to ignore all events that are off screen
# unless you add "DOUPDATE" to their name. (DOUPDATE events will always update)
#
# If false this will means the system will ALWAYS update EVERY EVENT on the map
# - this should only be used if you experience weird compatability issues due
# to some custom scripts, it's better to try putting the DOUPDATE flag on events
# that do special things or have special settings that don't work when this
# flag is set to true.
#
# X_OFFSCREEN_SQUARES and Y_OFFSCREEN_SQUARES are how many squares in the X and Y
# direction we should update events. Default of 1 means any event one square
# off-screen will still be updated. The larger this value, the less efficiency
# you will see from the anti-lag system, however it can be used to make large
# events update instead of hang on screen.
ALLOW_SCREEN_IGNORE = true
X_OFFSCREEN_SQUARES = 1
Y_OFFSCREEN_SQUARES = 1
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
# This class handles maps. It includes scrolling and passage determination
# functions. The instance of this class is referenced by $game_map.
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :pmap
attr_reader :emap
attr_accessor :etilemap
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias :pre_antilag_setup :setup
def setup(map_id)
# Run normal initialize
pre_antilag_setup(map_id)
# Add events to emap
@emap = {}
for event in @events.values
if not event.ignore_location
loc = event.x.to_s + "_" + event.y.to_s
@emap[loc] = [] if @emap[loc] == nil
@emap[loc].push(event.id)
end
end
# Create the passability map
@pmap = Table.new($game_map.width, $game_map.height)
for i in 0...$game_map.width
for j in 0...$game_map.height
passable?(i,j) ? pass = 1 : pass = 0
@pmap[i,j] = pass
end
end
end
#--------------------------------------------------------------------------
# * Clear Event location
#--------------------------------------------------------------------------
def clear_event_loc(event)
# Add the event into the @emap hash
loc = event.x.to_s + "_" + event.y.to_s
if @emap[loc] != nil
@emap[loc].delete(event.id)
# Clean up after ourselves
@emap.delete(loc) if @emap[loc].empty?
end
end
#--------------------------------------------------------------------------
# * Set Event location
#--------------------------------------------------------------------------
def set_event_loc(event)
# Add the event into the @emap hash
loc = event.x.to_s + "_" + event.y.to_s
@emap[loc] = [] if @emap[loc] == nil
@emap[loc].push(event.id)
end
#--------------------------------------------------------------------------
# * Get array of event at designated coordinates
# x : x-coordinate
# y : y-coordinate
#--------------------------------------------------------------------------
alias :pre_antilag_events_xy :events_xy
def events_xy(x, y)
# Grab the events from the hash
loc = x.to_s + "_" + y.to_s
event_ids = @emap[loc]
# Use the IDs to build an array of events
events = []
if event_ids != nil
for id in event_ids
if id == 0
events.push($game_player)
else
events.push(@events[id])
end
end
end
# Return this array for the passability to use
return events
end
#--------------------------------------------------------------------------
# * Determine if Passable
# x : x coordinate
# y : y coordinate
# flag : The impassable bit to be looked up
# (normally 0x01, only changed for vehicles)
#--------------------------------------------------------------------------
alias :pre_antilag_passable? :passable?
def passable?(x, y, flag = 0x01)
for event in events_xy(x, y) # events with matching coordinates
next if event.tile_id == 0 # graphics are not tiled
next if event.priority_type > 0 # not [Below characters]
next if event.through # pass-through state
pass = @passages[event.tile_id] # get passable attribute
next if pass & 0x10 == 0x10 # *: Does not affect passage
return true if pass & flag == 0x00 # o: Passable
return false if pass & flag == flag # x: Impassable
end
for i in [2, 1, 0] # in order from on top of layer
tile_id = @map.data[x, y, i] # get tile ID
return false if tile_id == nil # failed to get tile: Impassable
pass = @passages[tile_id] # get passable attribute
next if pass & 0x10 == 0x10 # *: Does not affect passage
return true if pass & flag == 0x00 # o: Passable
return false if pass & flag == flag # x: Impassable
end
if @etilemap != nil
for i in [2, 1, 0] # in order from on top of layer
tile_id = @etilemap[x, y, i] # get tile ID
return false if tile_id == nil # failed to get tile: Impassable
pass = @passages[tile_id] # get passable attribute
next if pass & 0x10 == 0x10 # *: Does not affect passage
return true if pass & flag == 0x00 # o: Passable
return false if pass & flag == flag # x: Impassable
end
end
return false # Impassable
end
end
#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
# This class deals with characters. It's used as a superclass of the
# Game_Player and Game_Event classes.
#==============================================================================
class Game_Character
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :ignore_update
attr_reader :ignore_sprite
attr_reader :ignore_location
attr_reader :force_update
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias :pre_antilag_initialize :initialize
def initialize
# Run normal initialize
pre_antilag_initialize
# Set our ignore flag based on our event name
@ignore_update = false
@ignore_sprite = false
@ignore_location = false
@force_update = false
@x_offscreen_value = (Graphics.width + (X_OFFSCREEN_SQUARES * 32)) * 8
@y_offscreen_value = (Graphics.height + (Y_OFFSCREEN_SQUARES * 32)) * 8
@x_offscreen_squares = X_OFFSCREEN_SQUARES * 32 * 8
@y_offscreen_squares = Y_OFFSCREEN_SQUARES * 32 * 8
end
#--------------------------------------------------------------------------
# * On Screen
#--------------------------------------------------------------------------
def on_screen
x_range = ((@real_x <= ($game_map.display_x + @x_offscreen_value)) and (@real_x >= ($game_map.display_x - @x_offscreen_squares)))
y_range = ((@real_y <= ($game_map.display_y + @y_offscreen_value)) and (@real_y >= ($game_map.display_y - @y_offscreen_squares)))
if x_range and y_range
return true
end
return false
end
#--------------------------------------------------------------------------
# * Jump
# x_plus : x-coordinate plus value
# y_plus : y-coordinate plus value
#--------------------------------------------------------------------------
alias :pre_antilag_jump :jump
def jump(x_plus, y_plus)
$game_map.clear_event_loc(self)
pre_antilag_jump(x_plus, y_plus)
$game_map.set_event_loc(self)
end
#--------------------------------------------------------------------------
# * Move to Designated Position
# x : x-coordinate
# y : y-coordinate
#--------------------------------------------------------------------------
alias :pre_antilag_moveto :moveto
def moveto(x, y)
$game_map.clear_event_loc(self) if $game_map.emap != nil
pre_antilag_moveto(x, y)
$game_map.set_event_loc(self) if $game_map.emap != nil
end
#--------------------------------------------------------------------------
# * Clear anti-lag flags
#--------------------------------------------------------------------------
def clear_antilag_flags
# Turn all the ignore values to false for one reason or another
@ignore_sprite = false
@ignore_location = false
@ignore_update = false
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 < Game_Character
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :id
attr_reader :original_forced_update
#--------------------------------------------------------------------------
# * Object Initialization
# map_id : map ID
# event : event (RPG::Event)
#--------------------------------------------------------------------------
alias :pre_antilag_event_initialize :initialize
def initialize(map_id, event)
# Run normal initialize
pre_antilag_event_initialize(map_id, event)
# Set our ignore flag based on our event name
decide_ignore
@allow_screen_ignore = ALLOW_SCREEN_IGNORE
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias :pre_antilag_update :update
def update
# Only run update if @ignore_update is false
if update?
pre_antilag_update
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update?
# Check our logic and return if we should update
ignore = ((not @ignore_update) and (on_screen and @allow_screen_ignore))
return (@force_update or ignore or @move_route_forcing)
end
#--------------------------------------------------------------------------
# * Event page setup
#--------------------------------------------------------------------------
alias :pre_antilag_setup :setup
def setup(new_page)
# Run normal setup
pre_antilag_setup(new_page)
# Set our forced flag if we're running as a parallel process now
# if not, set it to our "default" set during the decide_ignore function
if @trigger == 4 or @trigger == 3
@force_update = true
else
@force_update = @original_force_update
end
end
#--------------------------------------------------------------------------
# * Move Type : Custom
#--------------------------------------------------------------------------
alias :pre_antilag_move_type_custom :move_type_custom
def move_type_custom
# Ensure the sprite has been created if it's a blank event
# with no code on itself but someone else set a graphic on it
if @ignore_sprite
command = @move_route.list[@move_route_index] # Get movement command
case command.code
when 41 # Change Graphic
create_sprite if @ignore_sprite
end
end
# Run the original move type custom command
pre_antilag_move_type_custom
end
#--------------------------------------------------------------------------
# * Create Sprite
# Create a sprite for this poor event if one hasn't been made
#--------------------------------------------------------------------------
def create_sprite
# Ensure ignore sprite value is set to false
@ignore_sprite = false
@ignore_location = false
@ignore_update = false
# Try to add a new sprite to the map
if $scene.is_a?(Scene_Map)
$scene.create_event_sprite(self)
end
end
#--------------------------------------------------------------------------
# * Decide if Ignorable for Updates or Sprites
#--------------------------------------------------------------------------
def decide_ignore
# Not ignore by default
@ignore_location = true
@ignore_sprite = true
@ignore_update = false
@original_force_update = false
# Decide if we should ignore ourselves or not
if @event.name == "IGNORE"
@ignore_update = true
elsif @event.pages.size == 1
if @list != nil
if @list.size == 1
if @character_name == "" or @tile_id != 0
@ignore_update = true
end
end
end
end
# Check if we'll ever need a sprite
tiles = []
for page in @event.pages
# Check for single-tile events
if page.graphic.tile_id != 0
tiles.push(page.graphic.tile_id) if not tiles.include?(page.graphic.tile_id)
if page.priority_type == 2 or tiles.size > 1 or @event.pages.size > 1
@ignore_sprite = false
@ignore_location = false
end
end
# Check for character graphic instead
if page.graphic.character_name != ""
@ignore_sprite = false
@ignore_location = false
end
# Check all pages for code to run
if page.list.size > 1
for item in page.list
if item.code != 108
@ignore_location = false
end
end
end
end
# Check to see if we have any tiles and a no initial page
if @list == nil and tiles.size > 0
@ignore_sprite = false
@ignore_location = false
end
# Force tags
if @event.name.include?("DOSPRITE")
@ignore_sprite = false
end
if @event.name.include?("DOLOC")
@ignore_location = false
end
if @event.name.include?("DOUPDATE")
@ignore_update = false
@force_update = true
@original_force_update = true
end
end
#--------------------------------------------------------------------------
# * Move Functions
#--------------------------------------------------------------------------
alias :pre_antilag_move_down :move_down
def move_down(turn_ok = true)
$game_map.clear_event_loc(self)
pre_antilag_move_down(turn_ok)
$game_map.set_event_loc(self)
end
alias :pre_antilag_move_left :move_left
def move_left(turn_ok = true)
$game_map.clear_event_loc(self)
pre_antilag_move_left(turn_ok)
$game_map.set_event_loc(self)
end
alias :pre_antilag_move_right :move_right
def move_right(turn_ok = true)
$game_map.clear_event_loc(self)
pre_antilag_move_right(turn_ok)
$game_map.set_event_loc(self)
end
alias :pre_antilag_move_up :move_up
def move_up(turn_ok = true)
$game_map.clear_event_loc(self)
pre_antilag_move_up(turn_ok)
$game_map.set_event_loc(self)
end
alias :pre_antilag_move_lower_left :move_lower_left
def move_lower_left(turn_ok = true)
$game_map.clear_event_loc(self)
pre_antilag_move_lower_left
$game_map.set_event_loc(self)
end
alias :pre_antilag_move_upper_left :move_upper_left
def move_upper_left(turn_ok = true)
$game_map.clear_event_loc(self)
pre_antilag_move_upper_left
$game_map.set_event_loc(self)
end
alias :pre_antilag_move_lower_right :move_lower_right
def move_lower_right(turn_ok = true)
$game_map.clear_event_loc(self)
pre_antilag_move_lower_right
$game_map.set_event_loc(self)
end
alias :pre_antilag_move_upper_right :move_upper_right
def move_upper_right(turn_ok = true)
$game_map.clear_event_loc(self)
pre_antilag_move_upper_right
$game_map.set_event_loc(self)
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 < Game_Character
#--------------------------------------------------------------------------
# * Priority Type
#--------------------------------------------------------------------------
def priority_type
return 1
end
#--------------------------------------------------------------------------
# * Triggers
#--------------------------------------------------------------------------
def trigger
return -1
end
#--------------------------------------------------------------------------
# * Triggers
#--------------------------------------------------------------------------
def triggers
return []
end
#--------------------------------------------------------------------------
# * Triggers
#--------------------------------------------------------------------------
def id
return 0
end
#--------------------------------------------------------------------------
# * Triggers
#--------------------------------------------------------------------------
def tile_id
return 0
end
#--------------------------------------------------------------------------
# * Determine if Airship can Land
# x : x-coordinate
# y : y-coordinate
#--------------------------------------------------------------------------
alias :pre_antilag_airship_land_ok? :airship_land_ok?
def airship_land_ok?(x, y)
unless $game_map.airship_land_ok?(x, y)
return false # The tile passable attribute is unlandable
end
# Check all events to ensure only the player is there
for event in $game_map.events_xy(x, y)
if event != $game_player
return false
end
end
return true # Can land
end
#--------------------------------------------------------------------------
# * Move Functions
#--------------------------------------------------------------------------
alias :pre_antilag_move_down :move_down
def move_down(turn_ok = true)
$game_map.clear_event_loc(self)
pre_antilag_move_down(turn_ok)
$game_map.set_event_loc(self)
end
alias :pre_antilag_move_left :move_left
def move_left(turn_ok = true)
$game_map.clear_event_loc(self)
pre_antilag_move_left(turn_ok)
$game_map.set_event_loc(self)
end
alias :pre_antilag_move_right :move_right
def move_right(turn_ok = true)
$game_map.clear_event_loc(self)
pre_antilag_move_right(turn_ok)
$game_map.set_event_loc(self)
end
alias :pre_antilag_move_up :move_up
def move_up(turn_ok = true)
$game_map.clear_event_loc(self)
pre_antilag_move_up(turn_ok)
$game_map.set_event_loc(self)
end
alias :pre_antilag_move_lower_left :move_lower_left
def move_lower_left
$game_map.clear_event_loc(self)
pre_antilag_move_lower_left
$game_map.set_event_loc(self)
end
alias :pre_antilag_move_upper_left :move_upper_left
def move_upper_left
$game_map.clear_event_loc(self)
pre_antilag_move_upper_left
$game_map.set_event_loc(self)
end
alias :pre_antilag_move_lower_right :move_lower_right
def move_lower_right
$game_map.clear_event_loc(self)
pre_antilag_move_lower_right
$game_map.set_event_loc(self)
end
alias :pre_antilag_move_upper_right :move_upper_right
def move_upper_right
$game_map.clear_event_loc(self)
pre_antilag_move_upper_right
$game_map.set_event_loc(self)
end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs the map screen processing.
#==============================================================================
class Scene_Map < Scene_Base
#--------------------------------------------------------------------------
# * Create Sprite
# :event - The event to give to the spriteset to make a sprite for
#--------------------------------------------------------------------------
def create_event_sprite(event)
# Tell the spriteset to make the sprite for the event
@spriteset.create_event_sprite(event)
end
end
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
# This class brings together map screen sprites, tilemaps, etc. It's used
# within the Scene_Map class.
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# * Create Character Sprite
#--------------------------------------------------------------------------
alias pre_antilag_create_characters create_characters
def create_characters
#pre_antilag_create_characters
@character_sprites = []
for i in $game_map.events.keys.sort
unless $game_map.events[i].ignore_sprite
sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
@character_sprites.push(sprite)
end
end
for vehicle in $game_map.vehicles
sprite = Sprite_Character.new(@viewport1, vehicle)
@character_sprites.push(sprite)
end
@character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
end
#--------------------------------------------------------------------------
# * Create Character Sprite
#--------------------------------------------------------------------------
def create_event_sprite(event)
# Check if we can find a sprite already created for the event
found = false
for sprite in @character_sprites
found = true if sprite.character == event
end
# If we didn't find one create it
if not found
@character_sprites.push(Sprite_Character.new(@viewport1, event))
end
end
#--------------------------------------------------------------------------
# * Create Tilemap
#--------------------------------------------------------------------------
alias pre_antilag_create_tilemap create_tilemap
def create_tilemap
# Normal tilemap creation
pre_antilag_create_tilemap
# Add the new tilemap!
@etilemap = Tilemap.new(@viewport1)
@etilemap.bitmaps[0] = Cache.system("TileA1")
@etilemap.bitmaps[1] = Cache.system("TileA2")
@etilemap.bitmaps[2] = Cache.system("TileA3")
@etilemap.bitmaps[3] = Cache.system("TileA4")
@etilemap.bitmaps[4] = Cache.system("TileA5")
@etilemap.bitmaps[5] = Cache.system("TileB")
@etilemap.bitmaps[6] = Cache.system("TileC")
@etilemap.bitmaps[7] = Cache.system("TileD")
@etilemap.bitmaps[8] = Cache.system("TileE")
emap = Table.new($game_map.data.xsize, $game_map.data.ysize, 3)
# Add only events that are not "above" character
for event in $game_map.events.values
if event.tile_id > 0 and event.priority_type < 2 and event.ignore_sprite
emap[event.x, event.y, 1] = event.tile_id
end
end
@etilemap.map_data = emap
$game_map.etilemap = emap
end
#--------------------------------------------------------------------------
# * Dispose of Tilemap
#--------------------------------------------------------------------------
alias :pre_antilag_dispose_tilemap :dispose_tilemap
def dispose_tilemap
# Normal dispose
pre_antilag_dispose_tilemap
# Dispose of new event tilemap
@etilemap.dispose
end
#--------------------------------------------------------------------------
# * Update Tilemap
#--------------------------------------------------------------------------
alias :pre_antilag_update_tilemap :update_tilemap
def update_tilemap
# Normal update
pre_antilag_update_tilemap
# Work with new event tilemap
@etilemap.ox = $game_map.display_x / 8
@etilemap.oy = $game_map.display_y / 8
@etilemap.update
end
#--------------------------------------------------------------------------
# * Update Character Sprite
#--------------------------------------------------------------------------
alias :pre_antilag_update_characters :update_characters
def update_characters
for sprite in @character_sprites
sprite.update if sprite.character.on_screen
end
end
end
#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
# An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# * Show Animation
#--------------------------------------------------------------------------
alias :pre_antilag_command_212 :command_212
def command_212
character = get_character(@params[0])
if character != nil
character.create_sprite if character.ignore_sprite
character.clear_antilag_flags
end
pre_antilag_command_212
end
#--------------------------------------------------------------------------
# * Show Balloon Icon
#--------------------------------------------------------------------------
alias :pre_antilag_command_213 :command_213
def command_213
character = get_character(@params[0])
if character != nil
character.create_sprite if character.ignore_sprite
character.clear_antilag_flags
end
pre_antilag_command_213
end
end
[/spoiler]
You don't need DOUPDATE; put DOSPRITE instead.
That did it! Thanks for all the help, Modern Algebra! I appreciate it. :D
This is Awesome! One question though...is it possible to make it so that the hover graphic only appears when you're next to the event? And have it disappear when you aren't next to it. For example:
[spoiler]
There is no bubble over the sign.
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi278.photobucket.com%2Falbums%2Fkk96%2FArcono%2F1.png&hash=973ceb7467f3a71d1583bd873fc8cd945a3db5f6)
But here there is.
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi278.photobucket.com%2Falbums%2Fkk96%2FArcono%2F2.png&hash=7e337bf4c9a86ae3cf465d291f97e85a9642dcaa)
[/spoiler]
There's no automatic way built into the script.
But: you could set player touch events around the area that turn it on when you get close and turn it off when you draw away, but that may be a little cluttered. You could also use a parallel process event that looks something like this, where x1 and y1 are the coordinates of the sign.
@>Control Variables: [Player X] = Player's X
@>Control Variables: [Player X] -= x1
@>Conditional Branch: [Player X] < -1
@>Jump to Label: Turn Hover Off
: Else
@>Conditional Branch: [Player X] > 1
@>Jump to Label: Turn Hover Off
@>
: Branch END
@>
: Branch END
@>Control Variables: [Player Y] = Player's Y
@>Control Variables: [Player Y] -= y1
@>Conditional Branch: [Player Y] < -1
@>Jump to Label: Turn Hover Off
: Else
@>Conditional Branch: [Player Y] > 1
@>Jump to Label: Turn Hover Off
@>
: Branch END
@>
: Branch END
@>Script: set_hover_graphic (event_id, "hover_graphic")
@>Jump to Label: End Event
@>Label: Turn Hover Off
@>Script: set_hover_graphic (event_id)
@>Label: End Event
@>Wait: 6 frames
If you wanted this to be a common feature and not only for things like signs, however, then it would be imprudent.
I'm sorry if I'm necroing, but I have been having an issue with the script. The graphic appears perfectly, but when I try to change it, I have to open up the menu to make it update. Could this have something to do with the update methods in Scene_Menu? I am using the KGCYanflyPLUS pack, but in a project with no other scripts, this still occurs.
Quote from: TheSpy on December 08, 2010, 01:25:17 AM
I'm sorry if I'm necroing, but I have been having an issue with the script. The graphic appears perfectly, but when I try to change it, I have to open up the menu to make it update. Could this have something to do with the update methods in Scene_Menu? I am using the KGCYanflyPLUS pack, but in a project with no other scripts, this still occurs.
I have the same problem! You have to reset the hover graphic at first and then change it.
So:
set_hover_graphic (ID)
and then change it to what ever.
But I have another problem:Try to set a hover graphic, save the game and quit it. Restart the game and you will see that the hover graphic is gone! So it doesn't save anything...
It would be great if modern algebra or someone else could solve it.
I don't want to make on every map an event which activates or deactives this hover graphic! It should work automatically.
If somewhere on another map a hover graphic is true it should be saved too, if I go on that map. So every visible graphic should be saved. The invisible doesn't matter.
Just put it in my new project. MA, your work is fantastic!
I'm glad to hear that EvilM00s! My VX scripts probably aren't as good as they could be though.
Well, I can say that with all the useful notations you put in, I'm beginning to uinderstand Ruby WAAAY better than I did.
Hi I am trying to use this script but having a problem. I am using RPGMVX
I want to make so after accepting a quest then exclamation mark goes to a grey question mark, then once you have fulfilled the quest and ready to turn it in the grey question mark above the quest giver is then gold. Once that NPC has no more quests the graphic is gone and doesn't come back, not sure if I am overlooking how to do it.
Thanks and thanks for this wonderful script :)
Sure. In the event after the quest is accepted, just change the hover graphic by using the following code in a script command:
set_hover_graphic(event_id, "<<grey question mark>>")
(event_id being the integer ID of the event, and replace <<grey question mark>> with whatever name you have for the picture you are using.)
Then, when the quest is ready, you can do the same thing but change it to gold. If this is happening in a different map, then you can use a parallel process in the quest giver map that checks the status of the quest and assigns the right hover graphic, then deletes itself.
Finally, when it's finished, do the same thing and either give the quest giver nothing or the regular exclamation mark if there are still other quests to give.
Hi thanks for the help but its still seems to not work, I put the gold exclamation as a seperate parallel event and had it set to event 55 so its above the npc, but when choosing yes to accept the quest the exclamation doesnt change to a grey question mark.
I tried using a switch in event 55 and putting a conditional branch in the parallel process event but it doesnt do anything.
Sorry for being a bother like this.
Well, you can just do it directly in the same event when the person accepts the quest, can't you (assuming that the parallel process is erased after it runs once)? I don't have RMVX any more, so I can't really test the script.
I'm sorry for necroposting as well.
algebra, is there any chance you'll update the vx-script with the proximity-settings from the vxa-version?
thanks!