Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Alternative Message Effect (Updated to V2)

-Introduction-

This script was written as a request for my good friend Samot! What it is, it simply shows an image while a message is being displayed, you could use it just for a snazzy visual effect whenever and wherever you want, and enable/disable it with ease.

Also good for people who have a hard to read font, or hate using windowskins. The image's display is above the map and below the message , so with a slightly dark image the message will stand out better from the map.

-Instructions-

Place this script above main and below the SDK if you're using it. You must place an image in the Graphics/Windowskins directory, and name it whatever, just as long as the name defined in the script and the name of the image are the same.

Also, I wrote it for Samot, so you can change the module name "Samot" to whatever you want, or remove it, and the extra 'end' on the module.

-Call Script Information-

Msg_Back::Enabled = true/false (enables/disables image in-game)
Msg_Back::Image = "Message_Back" (changes graphic image in-game)
Msg_Back::Opacity = 0...255 (changes image opacity in-game)
Msg_Back::Transition = 0...9+ (changes transition time to fade in/out image)
Msg_Back::Tone        = Tone.new(0, 0, 0, 0) (Changes screen color tone temporarily during message)

-Screenshots-

http://i224.photobucket.com/albums/dd288/Kain_Nobel/MsgbackScript.png[/img]

http://i224.photobucket.com/albums/dd28 ... Script.png[/img]

-Materials-

Message_Back[0] # Top Position
http://i224.photobucket.com/albums/dd28 ... _Back0.png[/img]
Message_Back[1] # Middle Position
http://i224.photobucket.com/albums/dd28 ... _Back1.png[/img]
Message Back[2] # Bottom Position
http://i224.photobucket.com/albums/dd28 ... _Back2.png[/img]

-The Script-

Code:
#===============================================================================
# ~** Message Back Image : Top / Middle / Bottom **~
#-------------------------------------------------------------------------------
# Written by  : Kain Nobel
# Version     : 2.0
# Updated     : 07/08/2008
# Created     : 06/30/2008
#===============================================================================
# * Special Thanks : Samot for origional "Message_Back" image.
#===============================================================================
# ** Instructions **
#-------------------------------------------------------------------------------
#   Requires an image in the windowskin folder, the name must be the same
# as what you've defined in the Msg_Back module. By default, the image that
# comes with this script is already pre-transparent even with opacity 255.
#-------------------------------------------------------------------------------
#   This version of the script requires 3 images, you can name them whatever
# you want, but they are indexed like so...
#
#   o   "Message_Back[0]"        => Message at Top
#   o   "Message_Back[1]"        => Message in Middle
#   o   "Message_Back[2]"        => Message at Bottom
#
#   But when named in the module, just name it like "Message_Back", don't
# include the [#] with it, this process is automatic.
#-------------------------------------------------------------------------------
#   This script aliases the following methods.
#   *  Scene_Map, main
#   *  Scene_Map, update
#-------------------------------------------------------------------------------
#   This script creates the following methods.
#   *  Scene_Map, setup_msg_backs
#   *  Scene_Map, update_msg_backs
#   *  Scene_Map, msgback_fade_in
#   *  Scene_Map, msgback_fade_out
#===============================================================================
# ** Customizable Module ;)
#-------------------------------------------------------------------------------
#   Enable/Disable the message back within this module, and pick the name of
# the image you want to use for your message back.
#===============================================================================
module Msg_Back
  Enabled     = true
  Image       = "Message_Back"
  Opacity     = 255
  Transition  = 10
  Tone        = Tone.new(-96, -96, -96, 0)
end
#===============================================================================
# ** Scene_Map
#-------------------------------------------------------------------------------
#   Enhanced to show an image behind the message window.
#===============================================================================
class Scene_Map
  #-----------------------------------------------------------------------------
  alias_method :kn_msgback_scene_map_main,    :main
  alias_method :kn_msgback_scene_map_update,  :update
  #-----------------------------------------------------------------------------
  # * Main Method (*Aliased*)
  #-----------------------------------------------------------------------------
  def main
    # Setup Message Back script
    setup_msg_backs
    # Aliased Method call for Scene_Map's "main" method.
    kn_msgback_scene_map_main
    # Then, after the loop do visible in origional method,
    # You must dispose of the Message Back image.
    for i in 0...@msg_back.size
      @msg_back[i].dispose
    end
  end
  #-----------------------------------------------------------------------------
  # * Update
  #-----------------------------------------------------------------------------
  def update
    # Aliased Method call for Scene_Map's "update" method.
    kn_msgback_scene_map_update
    # If Message Window is Showing
    if Msg_Back::Enabled
      unless $game_system.message_position.nil?
        @pos = $game_system.message_position
      end
      update_msg_backs
    end
  end
  #-----------------------------------------------------------------------------
  # * Create Message Backs
  #-----------------------------------------------------------------------------
  def setup_msg_backs
    # Create Msg_Back Images, by default they're not visible.
    @msg_back         = [Sprite.new, Sprite.new, Sprite.new]
    # Create script-specific variables
    @tone             = $game_screen.tone
    @fade = (Msg_Back::Opacity / Msg_Back::Transition)
    for i in 0...@msg_back.size
      @blank    = RPG::Cache.windowskin("")
      @filename = RPG::Cache.windowskin(Msg_Back::Image + "[#{i}]") rescue @blank
      @msg_back[i].bitmap  = @filename
      @msg_back[i].opacity = 0
      @msg_back[i].z       = 550
      @msg_back[i].visible = false
    end
  end
  #-----------------------------------------------------------------------------
  # * Update Message Back
  #-----------------------------------------------------------------------------
  def update_msg_backs
    if $game_temp.message_window_showing  ; msgback_fade_in
    else                                  ; msgback_fade_out
    end
  end
  #-----------------------------------------------------------------------------
  # * Memorize Msg Tone
  #-----------------------------------------------------------------------------
  def msgback_fade_in
    # Set Msg Back image to visible
    @msg_back[@pos].visible = true
    # Fade in Msg Back image
    unless @msg_back[@pos].opacity == Msg_Back::Opacity
      @msg_back[@pos].opacity += @fade
    end
    # Fade screen to desired tone
    unless $game_screen.tone == Msg_Back::Tone
      $game_screen.start_tone_change(Msg_Back::Tone, 0)
    end
  end
  #-----------------------------------------------------------------------------
  # * Recall Origional Tone
  #-----------------------------------------------------------------------------
  def msgback_fade_out
    # Fade out Msg Back image
    unless @msg_back[@pos].opacity == 0 ; @msg_back[@pos].opacity -= @fade
    else                                ; @msg_back[@pos].visible  = false
    end
    # Restore origional Screen Tone
    unless $game_screen.tone == @tone
      $game_screen.start_tone_change(@tone, 0)
    end
  end
end

-Credits-

Kain Nobel, and Samot for the idea.
 
I like this :D

Thanks again, Kain!

http://img55.imageshack.us/img55/1319/screentestrn9.png[/img]
 
I really dig this script, but I have one question. Is is the image size stretched to fit the screen, or will a smaller image take up a smaller portion of the screen while showing the map behind. For example, if I had a picture of the character's face that is speaking, will it fill up the whole screen? And if that's the case, how would we specify it's x and y points?
 
If you wanted to display that pic.. -ALWAYS- at the same spot, you could add:

Code:
@msg_back.x       = X
@msg_back.y       = Y

.. Where the capitals X and Y are their respective coordinates in pixels..

Add this somewhere between
"# Create Messageback image, by default its not visible" and
"# Aliased Method call for Scene_Map's "main" method."
..to make it work.

Oh, and I don't believe the image is streched..
But that's up to Kain to answer..

By the way..
Kain, I had some troubles with the choice window..
It appeared under the image.
I fixed it by changing the @msg_back.z's value to 1000..
 
Thanks for the info Samot, it works perfectly! It shows the image at it's actual dimensions, which is exactly what I wanted.
 
aight....heres sumthing i noticed and can't fix (cuz i don't know nething bout scripting....).....when i added the script to a new project, then used the call script thing to change the image......the new image wouldn't show up until i went to the menu and exited the menu.....i'm sure its got sumthing to do with updating sumthing....but i have no clue.....if ne1 could help...it would be greatly appreciated....


edit:
1 more thing......the image loads after the text appears......would it be possible to make it load before or while the text is appearing?

edit 2: fixed the image load thing.....it was because i was using a letter by letter script.......
 
I've updated the script, be sure to change your materials accordingly if you use it. Tried to upload a demo, but script is easy enough to use and the instructions are within.

The only difference is now it shows image based on Message Window Position, so it'll either be on top, middle or bottom. This however requires 3 images in this version, because the 1 image by itself won't tile right.

Have fun :thumb:
 
Hey man, nice script!  If I may ask, would it be possible to call the script when the player enters a certain map instead of when there's text?  I know you can purely do that with events, but hey, sometimes scripts give more conveniency to whoever uses them.  Thanks!
 
Yeah, you can do it in a call script.

MSG_Back::Enabled = false

Actually, all of this...

Code:
module Msg_Back
  Enabled     = true
  Image       = "Message_Back"
  Opacity     = 255
  Transition  = 10
  Tone        = Tone.new(-96, -96, -96, 0)
end

Can be changed with a call script like that. So if you only want it to work for one message, do it like so

@>Script: Msg_Back::Enabled = true
@>Message: Hi, I am a message.
@>Script: Msg_Back::Enabled = false

Somebody did point out that there is a stupid bug with the interpreter command_355 (Call script command), which doesn't allow you to set things to 'false' without the game freezing.

So you'll have to go into Interpreter 7 and replace command_355 with this....

Code:
class Interpreter
  #--------------------------------------------------------------------------
  # * Script
  #--------------------------------------------------------------------------
  def command_355
    # Set first line to script
    script = @list[@index].parameters[0] + "\n"
    # Loop
    loop do
      # If next event command is second line of script or after
      if @list[@index+1].code == 655
        # Add second line or after to script
        script += @list[@index+1].parameters[0] + "\n"
      # If event command is not second line or after
      else
        # Abort loop
        break
      end
      # Advance index
      @index += 1
    end
    # Evaluation
    result = eval(script)
    # If return value is false
    #if result == false
      # End
    #  return false
    #end
    # Continue
    return true
  end
end
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top