Main Menu
  • Welcome to The RPG Maker Resource Kit.

[VXA] Hover Alerts

Started by modern algebra, October 17, 2012, 01:54:21 AM

0 Members and 4 Guests are viewing this topic.

modern algebra

Hover Alerts
Version: 1.0.3
Author: modern algebra
Date: 4 November 2012

Version History




  • <Version 1.0.3> 2012.11.04 - Fixed a bug where the SE would play all the time when a repeated effect is selected
  • <Version 1.0.2> 2012.10.28 - Fixed another bug with :disintegrate
  • <Version 1.0.1> 2012.10.17 - Fixed a bug with :disintegrate and added the proximity feature
  • <Version 1.0.0> 2012.10.16 - Original Release

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


  • Can show a graphic above any character on the map.
  • Can show either pictures, icons, text, or a combination of icon & text.
  • Sets up very simply through comments.
  • You can set up to a dozen different features for each hover alert, including but not limited to relevant font options for text and a timer that will dispose the alert after a sufficient number of frames. You can also exclude any of those options from any given hover alert.
  • If showing a picture, you can set it to animate by including in its name %[n] and n animation frames in the graphic itself.
  • Can show a number of neat effects for the hover alerts, such as bouncing it, fading it out, or disintegrating it.
  • Can activate an option which will automatically show an alert above the player with the icon, name, and amount of any items or gold gained through events and have it fade out or disintegrate.

Screenshots



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 to see a number of sample hover alerts set up.

Script



Retrieve it from Pastebin or from the demo.

Credit



  • modern algebra

Thanks

  • Yin, for notifying me of the :disintegrate error, for suggesting the proximity feature, and for alerting me to a compatibility error with galv's Region Effects script

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=galv's Region Effects]
There is an error with galv's 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.


#==============================================================================
#    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.
[/spoiler]

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

Demo



See attached.

Terms of Use



I adopt RMRK's default Terms of Use.

Yin

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?

modern algebra

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.

Yin

#3
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   
---------------------------

modern algebra

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: proximity = x where x is the number of squares.

Yin

 :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!

Caveras

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.. :)

modern algebra

No, the script cannot be used on battlers.

spywaretoff

Hello

thank you for this great script

Is it possible to display the icons above the name of the NPC ?
World of Forestia project

modern algebra

No, but you could create a picture and make it like that manually if it's not common.

Mark20

Nice, I'm going to plug it into my current project.

Yin

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.

modern algebra

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.

Yin

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.

modern algebra

No need for the demo. Just tell me precisely when you want the SE to play.

Yin

Just only as soon as you get near the event.

modern algebra

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.

Yin

#17
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!

Yin

:| 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.

modern algebra

#19
I'm not receiving that error in the demo. Did you spell it correctly?

Yin

#20
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.

liberty

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. ^.^

modern algebra

#22
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.

veltonvelton

#23
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.
  • Web designer
  • Music producer/DJ
  • Graphic Designer
Why am I 'training wheels'??

veltonvelton

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)
  • Web designer
  • Music producer/DJ
  • Graphic Designer
Why am I 'training wheels'??