The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX Ace => VXA Scripts Database => Topic started by: modern algebra on October 17, 2012, 01:54:21 AM

Title: [VXA] Hover Alerts
Post by: modern algebra on October 17, 2012, 01:54:21 AM
Hover Alerts
Version: 1.0.3
Author: modern algebra
Date: 4 November 2012

Version History



Description


This script lets you display a graphic which hovers above any given event, player or follower. The primary virtue of the script is that it allows for a feature like in Diablo, where characters that have something important to say have an exclamation point or something above their heads. However, it is not limited to that: this script can show any picture, icon, text, or combination of icon & text above any character.

A secondary (and completely optional) feature is that you can set it up so that whenever gold, items, weapons, or armours are received through their respective event commands, a hover alert will float above the player's head with the icon, name, and amount of the item received before fading out. (This feature is OFF by default in the script itself, while it is tied to switch 5 in the demo. You can and should change that if you want this feature.)

Features


Screenshots

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fs11.postimage.org%2F4r2zysrfn%2Fhoveralerts1.png&hash=382c554dd7b0b7b45546394213f362330499db52) (http://postimage.org/image/lrlw7h4gv/)

Instructions

Paste the script into its own slot in the Script Editor, above Main but below Materials.

For instructions on configuration and use, please read the header of the script quite thoroughly. I also recommend that you download the demo (http://rmrk.net/index.php?action=dlattach;topic=46911.0;attach=27738) to see a number of sample hover alerts set up.

Script


Retrieve it from Pastebin (http://pastebin.com/ZXHC9b2m) or from the demo (http://rmrk.net/index.php?action=dlattach;topic=46911.0;attach=27738).

Credit



Thanks


Support


Please post in this topic at RMRK.net if you have any questions, suggestions, error reports, or comments about this script. Please do not message me privately, as it is more efficient and useful to answer any concerns you have in the topic where others may benefit from our correspondence.

Known Compatibility Issues

Spoiler for galv's Region Effects:
There is an error with galv's Region Effects (http://galvs-scripts.com/galvs-region-effects/) script, v. 1.7. If you walk through an event-generating region while a hover alert is showing, it will repeatedly restart, like a skipping CD.

To fix it, insert the following code into its own slot in the Script Editor, somewhere below galv's Region Effects script but still above Main.

Code: [Select]
#==============================================================================
#    Hover Alerts + galv's Region Effects
#    Compatibility Patch
#    Version: 1.0
#    Authors: modern algebra (rmrk.net) & galv
#    Date: 5 October 2013
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This patch fixes an error between my Hover Alerts script and galv's Region
#   Effects script. Without it, a hover alert will constantly refresh when
#   walking through an event-generating region.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Insert this script into the Script Editor (F11) in a new slot, somewhere
#   below galv's Region Effects script but still above Main.
#==============================================================================

#==============================================================================
# ** Spriteset_Map
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - gre_refresh_event
#==============================================================================

class Spriteset_Map
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Refresh Event
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def gre_refresh_event(id)
    # Find any existing event with the same ID
    esi = @character_sprites.find_index {|sprite| sprite &&
      sprite.is_a?(Sprite_Character) && sprite.character.is_a?(Game_Event) &&
      sprite.character.gre_event_id == id }
    if esi
      # Dispose Existing Event
      @character_sprites[esi].dispose if !@character_sprites[esi].disposed?
      @character_sprites.delete_at(esi)
    else
      esi = $game_map.events.values.size - 1
    end
    # Refresh new region event
    @character_sprites.insert(esi, Sprite_Character.new(@viewport1, $game_map.events[id]))
  end
end

#==============================================================================
# ** Game_Event
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - gre_event_id
#==============================================================================

class Game_Event
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Event ID
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def gre_event_id
    @id # Get Event ID
  end
end

#==============================================================================
# ** Game_Map
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    overwritten method - region_effect
#==============================================================================

class Game_Map
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Region Effect
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def region_event(dx, dy, event_id, map_id)
    # Retrieve event from the spawn map
    map_id = @map_id if map_id == 0
    event = generated_region_event($data_spawn_map, event_id)
    # Generate ID
    new_id = @effect_var.length < Region_Effects::MAX_EFFECTS ?
      (@events.keys.max.nil? ? 1 : @events.keys.max + 1) : @effect_var.shift
    @effect_var.push(new_id)
    # Create new Event
    @events[new_id] = Game_Event.new(@map_id, event)
    @events[new_id].moveto(dx, dy)
    SceneManager.scene.spriteset.gre_refresh_event(new_id) # Refresh Event
  end
end

Due to the nature of the error, that fix does, however, alter galv's script design, and it may cause errors down the line that I did not anticipate. I do not assign a high probability to that possibility, but I do not give any guarantees. If problems do occur, you can always just delete this patch, but you should also let me know.

I am currently unaware of any other compatibility problems, but please let me know if you encounter any.

Demo


See attached (http://rmrk.net/index.php?action=dlattach;topic=46911.0;attach=27738).

Terms of Use


I adopt RMRK's default Terms of Use (http://rmrk.net/index.php/topic,45481.0.html).
Title: Re: Hover Alerts [VXA]
Post by: Yin on October 17, 2012, 03:02:21 AM
Another nice script MA. Would this be able to be used with a proximity effect? Like if you are 2 tiles away then it will fade in and any further than that, it will fade back out? Or if you are one tile away, it will only show if you are facing the direction of the event?
Title: Re: Hover Alerts [VXA]
Post by: modern algebra on October 17, 2012, 03:08:31 AM
No, but you could do the proximity thing with a parallel process event. You would just need to calculate distance with variables and then use a conditional branch to show or remove the hover graphic. You would not, however, be able to fade it in gradually.
Title: Re: Hover Alerts [VXA]
Post by: Yin on October 17, 2012, 03:13:19 AM
It would be a great addition, but if that's not in the plans, then I can always use a proximity script (I know there's one around). Especially since it goes by the interpreter, so I can put it in a conditional. (I don't like wasting variables if they are not needed :P)

Edit:
Got an error when using :disintegrate

---------------------------
Hover Alerts
---------------------------
Script 'Hover Alerts' line 672: ArgumentError occurred.

comparison of Symbol with 32 failed
---------------------------
OK   
---------------------------
Title: Re: Hover Alerts [VXA]
Post by: modern algebra on October 17, 2012, 08:31:38 PM
Thanks for the error report! As a thank you, I added the proximity feature you requested. You can set it as you do any other option, with the line:
Code: [Select]
proximity = x
where x is the number of squares.
Title: Re: Hover Alerts [VXA]
Post by: Yin on October 17, 2012, 08:52:22 PM
 :discosect: (I hope you can see that smiley, I'm using a weird set of them I think)

No, Thank YOU!

It's perfect now! It can be used for anything. I've seen a bunch of different stuff that is JUST for item gain, and others that are just for popups. This covers both as well as adds another feature that none have such as proximity. It's everything packed in one! Nailed it with this one!
Title: Re: Hover Alerts [VXA]
Post by: Caveras on October 18, 2012, 03:45:08 PM
Nice one! Haven't tested it yet, but could you also use it to display numbers above enemies? Like FF's Doom turn count, you know.. :)
Title: Re: Hover Alerts [VXA]
Post by: modern algebra on October 18, 2012, 07:48:22 PM
No, the script cannot be used on battlers.
Title: Re: Hover Alerts [VXA]
Post by: spywaretoff on October 29, 2012, 04:34:06 PM
Hello

thank you for this great script

Is it possible to display the icons above the name of the NPC ?
Title: Re: Hover Alerts [VXA]
Post by: modern algebra on October 29, 2012, 08:37:58 PM
No, but you could create a picture and make it like that manually if it's not common.
Title: Re: Hover Alerts [VXA]
Post by: Mark20 on October 29, 2012, 08:52:02 PM
Nice, I'm going to plug it into my current project.
Title: Re: Hover Alerts [VXA]
Post by: Yin on November 04, 2012, 08:09:37 PM
Think I found a bug. When you add a sound effect to the event, it plays the sound as soon as you enter the map as well as when you get close to the event (proximity event). It should only play when you get in range right? I have a demo as well if you need one.
Title: Re: Hover Alerts [VXA]
Post by: modern algebra on November 04, 2012, 08:12:26 PM
No, it was only intended to play when it first activates, not every time you approach it. Is that a feature you want added? I personally think it would be annoying if the SE went off everytime it was approached, but I could add that feature if you want it.
Title: Re: Hover Alerts [VXA]
Post by: Yin on November 04, 2012, 08:14:37 PM
No, that's the problem I'm having, it keeps repeating the sound when I get near the event and it plays even as soon as i enter the map when I'm not near the event. I will wrap you up a demo and pm it to you.
Title: Re: Hover Alerts [VXA]
Post by: modern algebra on November 04, 2012, 08:20:16 PM
No need for the demo. Just tell me precisely when you want the SE to play.
Title: Re: Hover Alerts [VXA]
Post by: Yin on November 04, 2012, 08:22:08 PM
Just only as soon as you get near the event.
Title: Re: Hover Alerts [VXA]
Post by: modern algebra on November 04, 2012, 08:38:46 PM
Alright, I updated the script so that the SE will only be played when it first becomes visible and never again after that unless the graphic is refreshed.
Title: Re: Hover Alerts [VXA]
Post by: Yin on November 04, 2012, 08:45:49 PM
Thank you, works like a charm!

PS, Just realized I had 1.01 and I think the current version was 1.02? But 1.03 works fine too!
Title: Re: Hover Alerts [VXA]
Post by: Yin on November 04, 2012, 09:11:16 PM
:| I hate to bring up another something, but I think something broke in this latest update. I was using the rise and disintegrate autogain, it used to work, but now it does not update. My event gives a few items and some gold. It used to update and disintegrate each item, but now it just floats on top of the character and never goes away.
Title: Re: Hover Alerts [VXA]
Post by: modern algebra on November 05, 2012, 12:48:38 AM
I'm not receiving that error in the demo. Did you spell it correctly?
Title: Re: Hover Alerts [VXA]
Post by: Yin on November 05, 2012, 12:51:23 AM
Weird, it happens in my test demo and your script is the only one in there. I'll try recopying the script from the pastebin.

Edit: Works now, I must have copied it wrong  ??? Sorry.
Title: Re: Hover Alerts [VXA]
Post by: liberty on November 15, 2012, 03:41:57 AM
This is a pretty awesome script, but I was wondering if there was a way to effect the volume of the sound effects when an item is gained and when near the item. The problem is that is quite jarring to suddenly hear a sound at 100% volume when the rest of the game is rather subdued, sound-wise.

I know it's not a big deal, but it would be nice. ^.^
Title: Re: Hover Alerts [VXA]
Post by: modern algebra on November 16, 2012, 02:53:49 AM
Yeah.

Quote from: Instructions
#      se - If you wish, you can set an SE to play when the hover alert first
#          appears. It must be an array in the form ["filename", volume, pitch]

So just put the volume after the filename in the array. Ie. the following text in the comment code should play Chime2 at 60 volume:

se = ["Chime2", 60]

You could also alter the pitch by putting another comma and a number.
Title: Re: Hover Alerts [VXA]
Post by: veltonvelton on November 21, 2012, 03:52:31 AM
Bug report - when receiving an item whilst moving, the icon appears repeatedly for every step until the player stops moving. Using a wait command doesn't fix the problem; perhaps the player has to take their hand off the arrow key to make it stop? But yeah. Quite important as I use this as a Zelda-like long grass coin finding thing.
Title: Re: Hover Alerts [VXA]
Post by: veltonvelton on November 21, 2012, 03:16:30 PM
Also a feature suggestion: when you auto gain an item, you could also give an option to change the player graphic momentarily. This would work well with a wait for animation to finish option, to make the player look towards the camera with their hands up, like in other games (can't think of one now)
Title: Re: Hover Alerts [VXA]
Post by: outlandish on November 28, 2012, 02:14:46 PM
Great script! This is just what I always wanted but never got around to asking for. Good job!  ;D
Title: Re: Hover Alerts [VXA]
Post by: veltonvelton on November 28, 2012, 02:27:19 PM
My game is literally at a standstill as this was sort of part of the main concept of it. Modern Algebra, need your help!
Title: Re: Hover Alerts [VXA]
Post by: modern algebra on December 01, 2012, 11:43:25 PM
Sorry veltonvelton. I will try to get to it tonight or tomorrow.

And thanks outlandish! I am happy to hear that.
Title: Re: Hover Alerts [VXA]
Post by: modern algebra on December 09, 2012, 05:20:59 AM
Bug report - when receiving an item whilst moving, the icon appears repeatedly for every step until the player stops moving. Using a wait command doesn't fix the problem; perhaps the player has to take their hand off the arrow key to make it stop? But yeah. Quite important as I use this as a Zelda-like long grass coin finding thing.

Hey. Sorry, I have been unable to recreate the error. Receiving an item while walking works fine in my demo, as far as I can tell.

Could you perhaps recreate the error in the demo and send me a copy so I can see what's going wrong?
Title: Re: Hover Alerts [VXA]
Post by: pinkapinkie on December 09, 2012, 10:08:43 AM
I noticed a little problem with Victor's Control Codes and Text scripts.
When autogaining an item with some codes to change the color, for example, it shows the code and not the item's name color changed.
I don't know which of the two scripts causes the problem though, so I'll link both:

Control Codes: http://victorscripts.wordpress.com/rpg-maker-vx-ace/windows-scripts/control-codes/ (http://victorscripts.wordpress.com/rpg-maker-vx-ace/windows-scripts/control-codes/)
Control Text: http://victorscripts.wordpress.com/rpg-maker-vx-ace/windows-scripts/control-text/ (http://victorscripts.wordpress.com/rpg-maker-vx-ace/windows-scripts/control-text/)

Thanks
Title: Re: Hover Alerts [VXA]
Post by: modern algebra on December 09, 2012, 03:19:04 PM
Well, unfortunately, that's not really a problem I'm willing to fix at the moment. In order to have the script interpret colour codes, I would either have to make the sprite an invisible window or else manually account for every possible code in every possible script. The former I do not want to do as windows will potentially cause more lag and it would foreclose the possibility of some effects, such as flash or showing animations on the hover alert. The latter I simply do not want to do because it's way too much work for very minor benefit.

However, if you want to just account for colour codes, you could add this code into its own slot somewhere below the Hover Alerts script but still above Main:

Code: [Select]
#==============================================================================
# ** Sprite_HoverAlert
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    overwritten method - maha_draw_text
#==============================================================================

class Sprite_HoverAlert
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Draw Text
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def maha_draw_text
    # Else draw the word
    x = 0
    self.bitmap = Bitmap.new(24, 24)
    if @hover_alert.name && !@hover_alert.name.empty?
      maha_reset_font_settings
      # Retrieve actual string
      txt = @hover_alert.name.gsub(/\\[Cc]\[(\d+)\]/, "")
      ts = bitmap.text_size(txt)
      if @hover_alert.icon_index > 0
        x = 28
        ts.width += 28
        ts.height = 24 if ts.height < 24
      end
      # Resize
      bitmap.dispose
      self.bitmap = Bitmap.new(ts.width + 4, ts.height + 4)
      maha_reset_font_settings
      @hover_alert.colour = $1.to_i if @hover_alert.name[/\\[Cc]\[(\d+)\]/]
      bitmap.font.color = text_color(@hover_alert.colour)
      # Draw text
      bitmap.draw_text(x, 0, bitmap.width - x, bitmap.height, txt, 1)
    end
    # Draw Icon
    @hover_alert.icon_hue == 0 ? maha_draw_icon(@hover_alert.icon_index, 0, (height - 24) / 2) :
      maha_draw_icon_with_hue(@hover_alert.icon_index, @hover_alert.icon_hue, 0, (height - 24) / 2)
    @ap_time = -1
    @ap_width = bitmap.width
  end
end

Keep in mind that if this script is ever updated, retaining this code could interfere with other changes to the script.
Title: Re: Hover Alerts [VXA]
Post by: veltonvelton on December 10, 2012, 12:16:21 PM
I've had a problem with VX licenses (namely not having one) so I'm waiting to pay for it when I get paid. So yeah, I'll send you something then if you're still ok to help.
Title: Re: Hover Alerts [VXA]
Post by: modern algebra on December 10, 2012, 09:14:19 PM
Sure. VXA is currently on sale for 2 for 1 (http://package.rpgmakerweb.com/ace-in-a-box/), so if you wanted to get someone a Christmas gift as well, it's a good time to do so. I think the sale goes to the end of December, but don't trust me on that, because that memory is entirely unsourced. My memory of that is about as strong as the time I remember kissing Anne Hathaway, so be alert!
Title: Re: Hover Alerts [VXA]
Post by: The Frontera on December 15, 2012, 03:16:18 PM
Epic script Modern Algebra!
I have a suggestion for a thing I need for my project...
I noticed that if the graphic of the event is set to none, the icon is shown in place of the event [1]
If there's graphic, the icon is shown over the event. [2]
Is there a way to be able to show the icon ON the event even if set the graphic? (like in [1], but this time there's graphic exactly below it)
Thanks in advance
Title: Re: Hover Alerts [VXA]
Post by: modern algebra on December 16, 2012, 02:58:58 AM
For how many graphics do you need to show both a graphic and an icon? If it is a small number, then you could just edit the graphics themselves and paste the icon where you want it to go.
Title: Re: Hover Alerts [VXA]
Post by: The Frontera on December 16, 2012, 05:12:30 PM
Yeah, you are right, that's an option.
But, for example, if I want to show the icon with the flash or fade effect...
In my project I need to show that icon on items that can be destroyed by bombs, and it would be cool if it was flashing.
Title: Re: Hover Alerts [VXA]
Post by: modern algebra on December 16, 2012, 10:44:44 PM
I'm sorry. I had initially misunderstood your request. There is currently no way to adjust the position of the hover alert manually.

I am not opposed to adding that feature, but I suspect it will be some time before I can get around to it.
Title: Re: Hover Alerts [VXA]
Post by: The Frontera on December 17, 2012, 11:55:27 AM
Thank you!
I'll be waiting fot that feature :)
Title: Re: Hover Alerts [VXA]
Post by: ekomega on December 20, 2012, 10:53:43 PM
When I set AUTOGAIN_HOVERALERTS_SWITCH at line 182 = 0, the item gain alerts still pop up.  I think the problem is at line 390, you have if "MA_HoverAlert::AUTOGAIN_HOVERALERTS_SWITCH >= 0".  It should be > 0, not >= 0, right?

Changing it to just > worked for me.

Also, thanks for the script!!!!  ;D

P.S. I just registered, and wanted to mention that the CAPTCHA type verification is impossible to read.  And I hate pop-ups (req. for listening), so this part of registration and posting is difficult and annoying.
Title: Re: Hover Alerts [VXA]
Post by: modern algebra on December 21, 2012, 12:22:04 AM
Yes, you're correct about the error. The CAPTCHA stuff is annoying but is necessary to protect against spam bots. Once you've made a few posts, you no longer have to verify your humanity.
Title: Re: Hover Alerts [VXA]
Post by: omoney on January 07, 2013, 10:42:49 PM
Is there a way to change the text color of the auto popup text in game? For example I want the color to be red when I lose items and the color to be green? when I gain items? Thanks
Title: Re: Hover Alerts [VXA]
Post by: Acezon on January 12, 2013, 02:07:56 PM
How can I remove the icon when a player gains an item?
Title: Re: Hover Alerts [VXA]
Post by: modern algebra on January 12, 2013, 03:09:23 PM
You can go to line 446 in the script, which should look like this:

Code: [Select]
      icon_hue = $imported[:MAIcon_Hue] ? item.icon_hue : 0
      $game_player.show_hover_alert(text, item.icon_index, icon_hue,

Replace both lines with:

Code: [Select]
      $game_player.show_hover_alert(text, 0, 0,
Title: Re: [VXA] Hover Alerts
Post by: Yin on July 10, 2013, 10:34:27 PM
Is there an option to show a windowskin, ( any image that can scale with the text inside ) behind the text? It gets kind of hard to read on certain backgrounds.
Title: Re: [VXA] Hover Alerts
Post by: modern algebra on July 11, 2013, 01:37:58 AM
No, not currently.
Title: Re: [VXA] Hover Alerts
Post by: nev182 on July 30, 2013, 08:42:00 PM
First off, you make amazing things happen Modern Algebra! I love your scripts when I can figure them out. =) I'm new to scripting and I still can't get Hover Alerts to work. Can you or someone post screenshots or a sample game so I can see the correct implementation of the script?

Thanks
Title: Re: [VXA] Hover Alerts
Post by: bluntsword on July 30, 2013, 08:51:17 PM
Hey Nev,

There's a sample game to download that really helped me when it comes to understanding how to use this script. Check it out in the main post!
Title: Re: [VXA] Hover Alerts
Post by: nev182 on July 30, 2013, 09:34:46 PM
Hey Nev,

There's a sample game to download that really helped me when it comes to understanding how to use this script. Check it out in the main post!

The link to the demo didn't work a few days ago when I tried it and now it does. Maybe an error on my part I don't know. Thanks Bluntsword!
Title: Re: [VXA] Hover Alerts
Post by: Gaming Princess Luna on July 30, 2013, 10:41:05 PM
That is a really cool script, I was looking for something like this for my GIAW, but it's kinda to late. :(
But anyway, I will use this in the next demo I will release after the GIAW, if you don't mind. ;)
I surely will give you credits for this great work, there is no question about it... :D
Title: Re: [VXA] Hover Alerts
Post by: Yin on July 31, 2013, 05:12:12 AM
Suggestion:
Auto Alerts for stuff in the actor section (gain or lose Exp, HP, MP, Level, skills, etc) through an event command.
Title: Re: [VXA] Hover Alerts
Post by: Mewgull on August 01, 2013, 04:58:31 PM
I ran into an error when trying to create a hover alert during a common event when drawing a variable in the 'name'

This is what I wrote in the comment:
\hover_alert[-1] { name = "+ #{$game_variables[18]}QP";
icon = 8673; effect = :rise_and_fade; }

This is the error I'm getting:

Script 'MAHoverAlers' line 286: SyntaxError occurred.

unexpected $end, expecting '}'
name = "+ #{$game_variables[18]
Title: Re: [VXA] Hover Alerts
Post by: Yin on August 03, 2013, 10:02:59 PM
If you do compatibility fixes, I seem to have found one when using galv's region effects. When you have a hover alert over the player and walk over a region effected by the script, the hover alert constantly update for every tile walked on until you get off of a region effect tile.

My specific error is: I get an item (Auto gain hover alert) and as I'm walking away and enter a region effect tile, the alert keeps displaying over and over again until I stop walking or until I get off of the region effect terrain.
Title: Re: [VXA] Hover Alerts
Post by: Kalacious on August 04, 2013, 06:14:19 PM
found an issue - or maybe I am doing it wrong. I set up a parallel event to make sure that the hove appears over event 2, it appears over its self instead. see demo
Title: Re: [VXA] Hover Alerts
Post by: modern algebra on October 02, 2013, 12:00:57 AM
Sorry for the delay in responding. I've been away. If any of you still need help:

@Mewgull - It's because of the "#{$game_variables[18]}". The } is messing it up. I should have predicted that and fixed it, but you can do the same thing with:

name = "+ " + $game_variables[18].to_s + "QP";

@Yin - Can you recreate the error in a demo and share it with me?

@Kalacious - You can only set it to another event by that means with an interpreted code, not an automatic one at the top of the page.
Title: Re: [VXA] Hover Alerts
Post by: Yin on October 04, 2013, 02:14:40 AM
Sure, here you go:
http://www.sendspace.com/file/ddblgc

Just get the glowy object and walk on the regions. The alert will keep repeating itself until you stop walking and let it finish. (Those are also MY default settings. I have not tried it with the default settings of the script.)
Title: Re: [VXA] Hover Alerts
Post by: modern algebra on October 05, 2013, 01:15:34 PM
Everytime you walk on an event-generating region, galv's script disposes every character sprite and recreates it. This causes the error you detected since the hover sprite is dependent on the existence of the character to whom it is attached; when the character is disposed, so is the hover sprite.

To fix it, I needed to change that mass disposal feature of galv's script and replace it with one that only recreates the character in issue, but I am not entirely sure how that will interact with other scripts or whether it might cause problems down the line. On the plus side, however, it is less resource-intensive and will probably cause less lag in maps with many events.

Anyway, here is the patch:

Code: [Select]
#==============================================================================
#    Hover Alerts + galv's Region Effects
#    Compatibility Patch
#    Version: 1.0
#    Authors: modern algebra (rmrk.net) & galv
#    Date: 5 October 2013
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This patch fixes an error between my Hover Alerts script and galv's Region
#   Effects script. Without it, a hover alert will constantly refresh when
#   walking through an event-generating region.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Insert this script into the Script Editor (F11) in a new slot, somewhere
#   below galv's Region Effects script but still above Main.
#==============================================================================

#==============================================================================
# ** Spriteset_Map
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - gre_refresh_event
#==============================================================================

class Spriteset_Map
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Refresh Event
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def gre_refresh_event(id)
    # Find any existing event with the same ID
    esi = @character_sprites.find_index {|sprite| sprite &&
      sprite.is_a?(Sprite_Character) && sprite.character.is_a?(Game_Event) &&
      sprite.character.gre_event_id == id }
    if esi
      # Dispose Existing Event
      @character_sprites[esi].dispose if !@character_sprites[esi].disposed?
      @character_sprites.delete_at(esi)
    else
      esi = $game_map.events.values.size - 1
    end
    # Refresh new region event
    @character_sprites.insert(esi, Sprite_Character.new(@viewport1, $game_map.events[id]))
  end
end

#==============================================================================
# ** Game_Event
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - gre_event_id
#==============================================================================

class Game_Event
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Event ID
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def gre_event_id
    @id # Get Event ID
  end
end

#==============================================================================
# ** Game_Map
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    overwritten method - region_effect
#==============================================================================

class Game_Map
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Region Effect
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def region_event(dx, dy, event_id, map_id)
    # Retrieve event from the spawn map
    map_id = @map_id if map_id == 0
    event = generated_region_event($data_spawn_map, event_id)
    # Generate ID
    new_id = @effect_var.length < Region_Effects::MAX_EFFECTS ?
      (@events.keys.max.nil? ? 1 : @events.keys.max + 1) : @effect_var.shift
    @effect_var.push(new_id)
    # Create new Event
    @events[new_id] = Game_Event.new(@map_id, event)
    @events[new_id].moveto(dx, dy)
    SceneManager.scene.spriteset.gre_refresh_event(new_id) # Refresh Event
  end
end

Place it below galv's script but still above Main.
Title: Re: [VXA] Hover Alerts
Post by: Yin on October 05, 2013, 01:44:31 PM
Everytime you walk on an event-generating region, galv's script disposes every character sprite and recreates it. This causes the error you detected since the hover sprite is dependent on the existence of the character to whom it is attached; when the character is disposed, so is the hover sprite.

To fix it, I needed to change that mass disposal feature of galv's script and replace it with one that only recreates the character in issue, but I am not entirely sure how that will interact with other scripts or whether it might cause problems down the line. On the plus side, however, it is less resource-intensive and will probably cause less lag in maps with many events.

Anyway, here is the patch:

Code: [Select]
#==============================================================================
#    Hover Alerts + galv's Region Effects
#    Compatibility Patch
#    Version: 1.0
#    Authors: modern algebra (rmrk.net) & galv
#    Date: 5 October 2013
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This patch fixes an error between my Hover Alerts script and galv's Region
#   Effects script. Without it, a hover alert will constantly refresh when
#   walking through an event-generating region.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Insert this script into the Script Editor (F11) in a new slot, somewhere
#   below galv's Region Effects script but still above Main.
#==============================================================================

#==============================================================================
# ** Spriteset_Map
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - gre_refresh_event
#==============================================================================

class Spriteset_Map
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Refresh Event
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def gre_refresh_event(id)
    # Find any existing event with the same ID
    esi = @character_sprites.find_index {|sprite| sprite &&
      sprite.is_a?(Sprite_Character) && sprite.character.is_a?(Game_Event) &&
      sprite.character.gre_event_id == id }
    if esi
      # Dispose Existing Event
      @character_sprites[esi].dispose if !@character_sprites[esi].disposed?
      @character_sprites.delete_at(esi)
    else
      esi = $game_map.events.values.size - 1
    end
    # Refresh new region event
    @character_sprites.insert(esi, Sprite_Character.new(@viewport1, $game_map.events[id]))
  end
end

#==============================================================================
# ** Game_Event
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - gre_event_id
#==============================================================================

class Game_Event
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Event ID
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def gre_event_id
    @id # Get Event ID
  end
end

#==============================================================================
# ** Game_Map
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    overwritten method - region_effect
#==============================================================================

class Game_Map
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Region Effect
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def region_event(dx, dy, event_id, map_id)
    # Retrieve event from the spawn map
    map_id = @map_id if map_id == 0
    event = generated_region_event($data_spawn_map, event_id)
    # Generate ID
    new_id = @effect_var.length < Region_Effects::MAX_EFFECTS ?
      (@events.keys.max.nil? ? 1 : @events.keys.max + 1) : @effect_var.shift
    @effect_var.push(new_id)
    # Create new Event
    @events[new_id] = Game_Event.new(@map_id, event)
    @events[new_id].moveto(dx, dy)
    SceneManager.scene.spriteset.gre_refresh_event(new_id) # Refresh Event
  end
end

Place it below galv's script but still above Main.

Thanks MA, your patch fixed 2 of my problems that I was having with the region effects script! Including the one effecting hover alerts.  :ghost: :dino: :discosect:
Title: Re: [VXA] Hover Alerts
Post by: modern algebra on October 05, 2013, 01:47:31 PM
You're welcome! What was the other problem you were having?
Title: Re: [VXA] Hover Alerts
Post by: Yin on October 05, 2013, 02:04:23 PM
I was using a smooth scrolling script but it would also jump the screen when walking on a region effect, just like with hover alerts. I removed it because it destroyed my eyes to see my game jumping like that lol, but decided to retry it again with the patch and now it works fine!
Title: Re: [VXA] Hover Alerts
Post by: modern algebra on October 05, 2013, 02:12:15 PM
Cool.
Title: Re: [VXA] Hover Alerts
Post by: Teko on February 24, 2014, 08:32:18 PM
When the hover is on auto (first comment on page), there is no way to show the picture above other event? (or the char on my case).

I'd like to use this scrip to show an exclamation over the char evertime he passes near a chest, box with an item or to show a picture to press A when he passes near a button. That was the only scrip I found that is close to this.
Title: Re: [VXA] Hover Alerts
Post by: modern algebra on May 05, 2014, 03:03:48 AM
I received the following private message:

Quote from: REDACTED date=1399252209
Hello, I am using your code for Hover Alerts, and at one point in my game, the player has to talk to a guard before he can pass through a gate. The guard charges him 500 gold to unlock the gate.  Once that happens, the "-500 gold" comes over the players head as an alert then the game crashes.  The error is:  Script 'Hover Alerts' line 265: NoMethodError occurred. undefined method 'empty?' for nil:NilClass

I tried turning off this kind of hover alert, but when i set the auto gain value to 0, it doesn't get turned off.
If you can solve my predicament, then you will have my thanks!

I responded:

Quote from: modern algebra date=1399258812
In the future, please report errors in the script topic itself. That way, other people could potentially step in when I'm away or too busy to help. As well, it is helpful for other users of the script, since the chances are good that you aren't the only person who has received this error.

Anyway, it's likely an incompatibility of some sort, in the sense that another script has changed the order in which certain methods could be predicted to run. It might be fixable simply by changing the position of this script in the editor.

However, it could also probably be fixed by replacing line 265, which should currently be this:

Code: [Select]
      @hover_alert = @hover_alert_queue.empty? ? nil : @hover_alert_queue.shift

with this:

Code: [Select]
      @hover_alert = (@hover_alert_queue.nil? || @hover_alert_queue.empty?) ? nil : @hover_alert_queue.shift
Title: Re: [VXA] Hover Alerts
Post by: hen1 on May 06, 2014, 05:19:10 PM
Hey, I pasted the script into the script editor and made sure everything is right, the only problem is I dont know how to use the script, is there a button for the hover alerts or do I insert emotions like [:)] ???
Unfortunately it doesn't say on this thread so... any help would be good.  :pacman:
Title: Re: [VXA] Hover Alerts
Post by: modern algebra on May 07, 2014, 02:27:53 AM
Hi hen1, I am not great at explaining how to use my script, but I put the instructions for it in the header of the script from lines 21-142. There are also instructions relating to configuration from lines 158-196.

If you have any specific questions after reading that, then I can try to clarify. However, I am not sure I could do much better a job simply trying to explain it in general than I did in the script itself.
Title: Re: [VXA] Hover Alerts
Post by: Kiyoshi on May 10, 2014, 08:09:28 PM
Code: [Select]
Script 'Hover Alerts' line 751: NoMethodError occurred.
undefined method 'hover_alert' for #<Game_Enemy:0x8d1a760>

There is no chance to get this compatible with GTBS, is it?
Title: Re: [VXA] Hover Alerts
Post by: Yin on September 01, 2014, 03:02:22 AM
Hi again MA. I was wondering if there was a way to add code into the Hover alert comment call (or if there is a way to call an alert to auto display through script call, that would be even better). I tried to add a conditional for a popup that automatically shows. But it conflicts with the "has to be the first command" rule. Instead of having 2 different pages that do the exact same thing except for the initial hover display, I was wondering it I could add some code to check if something is true or not.
Maybe an eval or condition argument that can change the "name" argument?


I just activated it from a different event. That works out fine.
Title: Re: [VXA] Hover Alerts
Post by: modern algebra on September 09, 2014, 11:51:37 PM
Glad to hear it. Sorry that I didn't respond right away. I moved a couple weeks ago and only got my internet today.
Title: Re: [VXA] Hover Alerts
Post by: parafusion on September 10, 2014, 10:37:44 AM
I could be wrong but I think the :fade_bounce function is not working properly. Right now, it is working exactly like the :fade function.

Code: [Select]
      when :bounce then @effect_y += (@effect_time > 16 ? -0.5 : 0.5)
      when :fade_bounce then self.opacity += (@effect_time > 16 ? -8 : 8)   
      # Temporary Effects
      when :fade then self.opacity = 16*@effect_time if @effect_time < 16
      when :rise_and_fade

The original script doesn't seem to be telling the script to run the bouncing function. I added the bouncing function manually and it seems to be working now.

Code: [Select]
      when :bounce then @effect_y += (@effect_time > 16 ? -0.5 : 0.5)
      when :fade_bounce then self.opacity += (@effect_time > 16 ? -8 : 8)
        @effect_y += (@effect_time > 16 ? -0.5 : 0.5)
     
      # Temporary Effects
      when :fade then self.opacity = 16*@effect_time if @effect_time < 16
      when :rise_and_fade

With that being said, I have 0 experience in coding and I don't really know if it was some other things interfering with the script. Sorry if I am wrong  ;)
Title: Re: [VXA] Hover Alerts
Post by: modern algebra on September 10, 2014, 11:24:00 PM
Sorry, I can see how that would be confusing. By :fade_bounce, I didn't mean that it would fade and bounce, just that it would start fully transparent, fade in then fade out. Whereas :fade starts out at fully opaque and just fades out. But certainly, if you're looking for it to fade and bounce then your code seems like it would work.
Title: Re: [VXA] Hover Alerts
Post by: parafusion on September 12, 2014, 08:16:42 AM
Ohhh, okay. Sorry, my mistake.  :( I always seem to jump the gun like that...

Title: Re: [VXA] Hover Alerts
Post by: modern algebra on September 12, 2014, 10:53:09 PM
Not at all. I'm glad you raised it with me and took the initiative to try and find a solution.
Title: Re: Hover Alerts [VXA]
Post by: Chaos17 on September 15, 2014, 10:20:26 AM
Another nice script MA. Would this be able to be used with a proximity effect? Like if you are 2 tiles away then it will fade in and any further than that, it will fade back out? Or if you are one tile away, it will only show if you are facing the direction of the event?

That's too bad, I was looking for an option like this with this script.
Anyway, good jon on this script.

 8)
Title: Re: [VXA] Hover Alerts
Post by: modern algebra on September 15, 2014, 11:05:47 AM
Another nice script MA. Would this be able to be used with a proximity effect? Like if you are 2 tiles away then it will fade in and any further than that, it will fade back out? Or if you are one tile away, it will only show if you are facing the direction of the event?

That's too bad, I was looking for an option like this with this script.
Anyway, good jon on this script.

 8)

Why is that too bad? That feature was added to this script shortly after Yin requested it.
Title: Re: Hover Alerts [VXA]
Post by: Markal Games on September 28, 2014, 04:19:12 AM
Epic script Modern Algebra!
I have a suggestion for a thing I need for my project...
I noticed that if the graphic of the event is set to none, the icon is shown in place of the event [1]
If there's graphic, the icon is shown over the event. [2]
Is there a way to be able to show the icon ON the event even if set the graphic? (like in [1], but this time there's graphic exactly below it)
Thanks in advance

I've been thoroughly enjoying this script, but I second a need for this feature if at all possible!  Any way you could implement it?
Title: Re: [VXA] Hover Alerts
Post by: Kyuukon on October 10, 2014, 03:14:27 AM
Very useful script :D!

I have a little problem: I tried changing the z value of the hover graphic in the line 472,
Code: [Select]
self.z = 500
but for some reason it won't go up from 200 (contrary to the Fix Pictures script). Is there a way to go over that, to let's say 500?
Also, is it possible to align to left a hover text?

Not critical problems but I'd love to know :3 Thanks!
Title: Re: [VXA] Hover Alerts
Post by: modern algebra on October 10, 2014, 11:53:49 PM
What are you trying to get it to appear over? The problem could be that it is in a different viewport.
Title: Re: [VXA] Hover Alerts
Post by: Kyuukon on October 12, 2014, 06:55:35 PM
A fixed picture I use as a fog layer with Z value of 320.

Viewport o.o?
Title: Re: [VXA] Hover Alerts
Post by: Sadrik on November 07, 2014, 09:24:41 PM
I installed thi script to my game.
I would like to disable autogain and use it only on certain items. How to do it if it's possible? :)
Title: Re: [VXA] Hover Alerts
Post by: modern algebra on November 08, 2014, 02:02:57 AM
Around line 182, you should see this:

Code: [Select]
  AUTOGAIN_HOVERALERTS_SWITCH = 5 #  The ID of the switch used to turn the
                                  # autogain feature on and off. If you never
                                  # want to use it, set this to 0.

So, if you never want to use it, set it to 0. If you want to use it sometimes, set it to any integer. Then you can control it by turning the in-game switch with that ID on or off.

There is currently no way to have it on all the time but only display for some items and not others.