The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: modern algebra on August 28, 2009, 01:00:09 AM

Title: Versus Popup
Post by: modern algebra on August 28, 2009, 01:00:09 AM
Versus Popup
Version: 1.0
Author: modern algebra
Date: August 27, 2009

Version History



Description


This script allows you to show a brief versus screen at the beginning of the battle that takes the face of the first actor and the battler of the first enemy of the troop and shows them before the battle begins, with an image of your choosing between them.

Features


Screenshots

(http://img141.imageshack.us/img141/4285/versuspopupscreen.png) (http://img141.imageshack.us/i/versuspopupscreen.png/)

Instructions

In order for this script to work, you MUST have an image (of arbitrary size) in the System folder of graphics called "Versus". This is the image that will be displayed between the actor face and the enemy battler. A sample image (http://rmrk.net/index.php?action=dlattach;topic=34571.0;attach=17659) is attached to this post, but you can make your own image for this and it can be any size.

If you wish to change the amount of time the versus screen is up for, or the SE that plays, or if you are using faces that are non-standard size, than see the Editable Region at line 42 to receive instructions on how to configure those options.

Place this script above Main and below Materials.

Script


Code: [Select]
#==============================================================================
#    Versus Popup
#    Version: 1.0
#    Author: modern algebra (rmrk.net)
#    Date: August 27, 2009
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This script allows you to show a brief versus screen at the beginning of
#   the battle that takes the face of the first actor and the battler of the
#   first enemy and shows them before the battle begins, with an image of your
#   choosing between them.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    In order for this script to work, you MUST have an image (of arbitrary
#   size) in the System folder of graphics called "Versus". This is the image
#   that will be displayed between the actor face and the enemy battler.
#
#    If you wish to change the amount of time the versus screen is up for, the
#   opacity of the background, the SE that plays, or if you are using faces
#   that are non-standard size, than see the Editable Region at line 42 to
#   receive instructions on how to configure those options.
#
#    Place this script above Main and below Materials.
#==============================================================================

#==============================================================================
# ** Scene Battle
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new constants - MAVP_POPUP_FRAMES, MAVP_FACE_SIZE, MAVP_SE,
#      MAVP_BACK_OPACITY
#    aliased method - process_battle_start
#    new method - create_versus_images
#==============================================================================

class Scene_Battle
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * CONSTANTS
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  #  EDITABLE REGION
  #``````````````````````````````````````````````````````````````````````````
  #  The constants do the following:
  #    MAVP_POPUP_FRAMES - the number of frames the versus screen remains up
  #      for. Note that there are 60 frames in a second.
  #    MAVP_FACE_SIZE - the face size of your faces. Note that the default
  #      face size is 96. This should not be changed unless you are using
  #      faces that are either larger or smaller than RTP.
  #    MAVP_SE - You can set an SE to play when the versus screen first shows
  #      up. The format for this is:
  #          MAVP_SE = ["filename", volume, pitch]
  #      If you do not fill in volume or pitch, they default to 100 each. If
  #      you leave the array empty (MAVP_SE = []), then no SE will play.
  #    MAVP_BACK_OPACITY - The opacity of the grey background that hides the
  #      battle scene. The value can be 0-255, where 0 is fully transparent
  #      and 255 is fully opaque
  #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  MAVP_POPUP_FRAMES = 120
  MAVP_FACE_SIZE = 96
  MAVP_SE = ["Battle2"]
  MAVP_BACK_OPACITY = 128
  #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Process Start Battle
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malg_asbsh_vs_popup_prcs_stbtl_7jc2 process_battle_start
  def process_battle_start (*args)
    create_dimming_bg
    create_face_window
    create_enemy_battler
    create_versus_image
    # Play SE if set
    RPG::SE.new (*MAVP_SE).play unless MAVP_SE.empty?
    # Make versus popup
    wait (MAVP_POPUP_FRAMES)
    # Dispose versus images
    @dimbg_sprite.bitmap.dispose
    @dimbg_sprite.dispose
    @versus_sprite.dispose
    @actor_window.dispose
    @battler_sprite.dispose
    $game_temp.background_bitmap.dispose
    # Run Original Method
    malg_asbsh_vs_popup_prcs_stbtl_7jc2 (*args)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Create Dimming BG
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def create_dimming_bg
    # Create Background
    @dimbg_sprite = Sprite.new
    @dimbg_sprite.bitmap = Bitmap.new (Graphics.width, Graphics.height)
    @dimbg_sprite.bitmap.fill_rect (@dimbg_sprite.bitmap.rect, Color.new (16, 16, 16, MAVP_BACK_OPACITY))
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Create Face Window
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def create_face_window
    # Create Face images
    @actor_window = Window_Base.new (16, (Graphics.height - 160 - MAVP_FACE_SIZE) / 2, 32 + MAVP_FACE_SIZE, 128)
    @actor_window.opacity = 0
    @actor_window.draw_actor_face ($game_party.members[0], 0, 0, MAVP_FACE_SIZE) unless $game_party.members.empty?
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Create Enemy Battler
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def create_enemy_battler
    # Create Battler Image
    @battler_sprite = Sprite_Base.new
    unless $game_troop.members.empty?
      enemy = $game_troop.members[0]
      @battler_sprite.bitmap = Cache.battler (enemy.battler_name, enemy.battler_hue)
      @battler_sprite.x = Graphics.width - 32 - @battler_sprite.bitmap.width
      @battler_sprite.y = (Graphics.height - 128 - @battler_sprite.bitmap.height) / 2
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Create Versus Image
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def create_versus_image
    # Create versus image
    @versus_sprite = Sprite_Base.new
    @versus_sprite.z = 200
    @versus_sprite.bitmap = Cache.system ("Versus")
    @versus_sprite.x = @actor_window.x + @actor_window.width - 16
    @versus_sprite.x += (@battler_sprite.x - @versus_sprite.x - @versus_sprite.width) / 2
    @versus_sprite.y = (Graphics.height - 128 - @versus_sprite.bitmap.height) / 2
  end
end

Credit



Thanks


Support


Please post here for support.

Known Compatibility Issues

No known compatibility issues, though it won't work with some exotic CBSes, particularly ones that occur outside of Scene_Battle


Creative Commons License
This script by modern algebra is licensed under a Creative Commons Attribution-Non-Commercial-Share Alike 2.5 Canada License.
Title: Re: Versus Popup
Post by: Irock on August 28, 2009, 01:10:10 AM
I don't know what it is about you and the color red for battle fonts, but it doesn't look very good. ._.
Title: Re: Versus Popup
Post by: modern algebra on August 28, 2009, 01:23:18 AM
I don't know what it is about you and the color red for battle fonts, but it doesn't look very good. ._.

Well, it's just a sample image. I would hope that people who use this script make their own. And for Damage Popups, people can change that if they want to; HP Damage colour is configurable in the script.


Also, one thing that I've noticed - exceptionally large battlers like EvilKing make this script look awful, so I am considering cutting or stretching exceptionally large battlers. If anyone would like me to, just tell me.
Title: Re: Versus Popup
Post by: Irock on August 28, 2009, 01:31:05 AM
Yeah, I know it's all configurable. I was just making an observation. ;d
Title: Re: Versus Popup
Post by: stucko on October 23, 2011, 04:24:42 AM
i was just wondering if this script could be modified so it only activates the vs image when a switch is turned on. I'd like to use it just for my boss battles.
Title: Re: Versus Popup
Post by: Adon on October 25, 2011, 09:31:17 PM
Modern, I would like it if you created a different version where the party leader(slot 1)'s sprite was used instead of a face.
Title: Re: Versus Popup
Post by: pacdiggity on October 26, 2011, 07:26:12 AM
Replace line 104 with this:
Code: [Select]
    @actor_window.draw_actor_graphic ($game_party.members[0], 0, 0) unless $game_party.members.empty?
Title: Re: Versus Popup
Post by: D&P3 on February 01, 2012, 08:59:00 AM
i was just wondering if this script could be modified so it only activates the vs image when a switch is turned on. I'd like to use it just for my boss battles.

Here you go.

INSTRUCTIONS:
Just change MAVP_SWITCH (in the editable region) to the event switch you want to use.
And activate the switch before a battle you want to use it in.

Versus Pop-Up remains active as long as the event switch in ON.
So either switch it off after your boss battle, or keep it on if you still want to use it.


Code: [Select]
#==============================================================================
#    Versus Popup
#    Version: 1.0
#    Author: modern algebra (rmrk.net)
#    Date: August 27, 2009
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This script allows you to show a brief versus screen at the beginning of
#   the battle that takes the face of the first actor and the battler of the
#   first enemy and shows them before the battle begins, with an image of your
#   choosing between them.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    In order for this script to work, you MUST have an image (of arbitrary
#   size) in the System folder of graphics called "Versus". This is the image
#   that will be displayed between the actor face and the enemy battler.
#
#    If you wish to change the amount of time the versus screen is up for, the
#   opacity of the background, the SE that plays, or if you are using faces
#   that are non-standard size, than see the Editable Region at line 42 to
#   receive instructions on how to configure those options.
#
#    Place this script above Main and below Materials.
#==============================================================================

#==============================================================================
# ** Scene Battle
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new constants - MAVP_POPUP_FRAMES, MAVP_FACE_SIZE, MAVP_SE,
#      MAVP_BACK_OPACITY
#    aliased method - process_battle_start
#    new method - create_versus_images
#==============================================================================

class Scene_Battle
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * CONSTANTS
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  #  EDITABLE REGION
  #``````````````````````````````````````````````````````````````````````````
  #  The constants do the following:
  #
  #    MAVP_SWITCH - The switch id to activate the script, if you want to only
  #      use the pop-up when fighting a boss battle, activate the switch just
  #      before the fight. Otherwise, if you wish to use the versus pop-up
  #      the entire game, just activate the switch in your beginning scene.
  #      You deactivate the pop-up by turning off the switch.
  #
  #    MAVP_POPUP_FRAMES - the number of frames the versus screen remains up
  #      for. Note that there are 60 frames in a second.
  #
  #    MAVP_FACE_SIZE - the face size of your faces. Note that the default
  #      face size is 96. This should not be changed unless you are using
  #      faces that are either larger or smaller than RTP.
  #
  #    MAVP_SE - You can set an SE to play when the versus screen first shows
  #      up. The format for this is:
  #          MAVP_SE = ["filename", volume, pitch]
  #      If you do not fill in volume or pitch, they default to 100 each. If
  #      you leave the array empty (MAVP_SE = []), then no SE will play.
  #
  #    MAVP_BACK_OPACITY - The opacity of the grey background that hides the
  #      battle scene. The value can be 0-255, where 0 is fully transparent
  #      and 255 is fully opaque
  #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  MAVP_SWITCH = 122               #Event Switch ID
  MAVP_POPUP_FRAMES = 120
  MAVP_FACE_SIZE = 96
  MAVP_SE = ["Battle2"]
  MAVP_BACK_OPACITY = 128
  #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Process Start Battle
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malg_asbsh_vs_popup_prcs_stbtl_7jc2 process_battle_start
  def process_battle_start (*args)
    unless $game_switches[MAVP_SWITCH]
       malg_asbsh_vs_popup_prcs_stbtl_7jc2 (*args)
   else
    create_dimming_bg
    create_face_window
    create_enemy_battler
    create_versus_image
    # Play SE if set
    RPG::SE.new (*MAVP_SE).play unless MAVP_SE.empty?
    # Make versus popup
    wait (MAVP_POPUP_FRAMES)
    # Dispose versus images
    @dimbg_sprite.bitmap.dispose
    @dimbg_sprite.dispose
    @versus_sprite.dispose
    @actor_window.dispose
    @battler_sprite.dispose
    $game_temp.background_bitmap.dispose
    # Run Original Method
    malg_asbsh_vs_popup_prcs_stbtl_7jc2 (*args)
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Create Dimming BG
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def create_dimming_bg
    # Create Background
    @dimbg_sprite = Sprite.new
    @dimbg_sprite.bitmap = Bitmap.new (Graphics.width, Graphics.height)
    @dimbg_sprite.bitmap.fill_rect (@dimbg_sprite.bitmap.rect, Color.new (16, 16, 16, MAVP_BACK_OPACITY))
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Create Face Window
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def create_face_window
    # Create Face images
    @actor_window = Window_Base.new (16, (Graphics.height - 160 - MAVP_FACE_SIZE) / 2, 32 + MAVP_FACE_SIZE, 128)
    @actor_window.opacity = 0
    @actor_window.draw_actor_face ($game_party.members[0], 0, 0, MAVP_FACE_SIZE) unless $game_party.members.empty?
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Create Enemy Battler
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def create_enemy_battler
    # Create Battler Image
    @battler_sprite = Sprite_Base.new
    unless $game_troop.members.empty?
      enemy = $game_troop.members[0]
      @battler_sprite.bitmap = Cache.battler (enemy.battler_name, enemy.battler_hue)
      @battler_sprite.x = Graphics.width - 32 - @battler_sprite.bitmap.width
      @battler_sprite.y = (Graphics.height - 128 - @battler_sprite.bitmap.height) / 2
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Create Versus Image
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def create_versus_image
    # Create versus image
    @versus_sprite = Sprite_Base.new
    @versus_sprite.z = 200
    @versus_sprite.bitmap = Cache.system ("Versus")
    @versus_sprite.x = @actor_window.x + @actor_window.width - 16
    @versus_sprite.x += (@battler_sprite.x - @versus_sprite.x - @versus_sprite.width) / 2
    @versus_sprite.y = (Graphics.height - 128 - @versus_sprite.bitmap.height) / 2
  end
end
Title: Re: Versus Popup
Post by: LoganF on February 01, 2012, 10:02:10 AM
'SWITCH' is a bad name to put into the global namespace because it's very likely another script would also think of using that and there'd be a conflict.

It either wants to be contained within a module, or add some garbage letters to the name to increase it's uniqueness. An example can be seen in the script:

malg_asbsh_vs_popup_prcs_stbtl_7jc2

The 7jc2 part at the end is a set of random letters that are added making the alias name very unique. It's incredibly unlikely that the same name will exist again.

My suggestion would be to follow the same format as the other constants in the script and precede 'SWITCH' with MAVP_ for MAVP_SWITCH. I'd also place that variable with the other 4 constants in Scene_Battle to further encapsulate the name.
Title: Re: Versus Popup
Post by: D&P3 on February 01, 2012, 11:10:58 AM
You're right.

I was trying to keep it simple for non-scripters, but I do see that it could cause problems.

Also the variable was out of the editable region because I like to have the event switch be the first thing I see in my scripts (It's a habit).

Fixed.