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.

Individual Troop Themes

PK8

Member

Individual Troop Themes
Version: 1


Introduction
This script allows game makers to give a specific Troop ID their own theme song. Useful for Boss battles and other unique battles.

Features
  • Give a specific troop ID their own theme.
  • Set the song, volume and pitch.

Screenshots
No screencaps.

Demo
No demo is needed.

Script
XP
Ruby:
<span style="color:#000080; font-style:italic;">=begin

<span style="color:#000080; font-style:italic;">╔══════════════════════════════════════════════════════════════════════════════╗

<span style="color:#000080; font-style:italic;">║ Individual Troop Themes XP                                                   ║

<span style="color:#000080; font-style:italic;">║ by PK8                                                                       ║

<span style="color:#000080; font-style:italic;">║ September 28th, 2009                                                         ║

<span style="color:#000080; font-style:italic;">║ [url=http://rmvxp.com]http://rmvxp.com[/url]                                                             ║

<span style="color:#000080; font-style:italic;">╟──────────────────────────────────────────────────────────────────────────────╢

<span style="color:#000080; font-style:italic;">║ ■ Table of Contents                                                          ║

<span style="color:#000080; font-style:italic;">║ ├─ Author's Notes                - Line 16─18                                ║

<span style="color:#000080; font-style:italic;">║ ├─ Introduction & Description    - Line 20─22                                ║

<span style="color:#000080; font-style:italic;">║ ├─ Features                      - Line 24─26                                ║

<span style="color:#000080; font-style:italic;">║ ├─ How to Use                    - Line 28─30                                ║

<span style="color:#000080; font-style:italic;">║ ├─ Methods Aliased               - Line 32,33                                ║

<span style="color:#000080; font-style:italic;">║ └─ Thanks                        - Line 35,36                                ║

<span style="color:#000080; font-style:italic;">╟──────────────────────────────────────────────────────────────────────────────╢

<span style="color:#000080; font-style:italic;">║ ■ Author's Notes                                                             ║

<span style="color:#000080; font-style:italic;">║ This script was requested by a user in HBGames.org's IRC channel (I forgot   ║

<span style="color:#000080; font-style:italic;">║ his name) and I was interested in creating this script so... here you go!    ║

<span style="color:#000080; font-style:italic;">╟──────────────────────────────────────────────────────────────────────────────╢

<span style="color:#000080; font-style:italic;">║ ■ Introduction & Description                                                 ║

<span style="color:#000080; font-style:italic;">║ This script allows game makers to give a specific Troop ID their own theme   ║

<span style="color:#000080; font-style:italic;">║ song. Useful for Boss battles and other unique battles.                      ║

<span style="color:#000080; font-style:italic;">╟──────────────────────────────────────────────────────────────────────────────╢

<span style="color:#000080; font-style:italic;">║ ■ Features                                                                   ║

<span style="color:#000080; font-style:italic;">║ ─ Give a specific troop ID their own theme.                                  ║

<span style="color:#000080; font-style:italic;">║ ─ Set the song, volume and pitch.                                            ║

<span style="color:#000080; font-style:italic;">╟──────────────────────────────────────────────────────────────────────────────╢

<span style="color:#000080; font-style:italic;">║ ■ How to Use                                                                 ║

<span style="color:#000080; font-style:italic;">║ To give a troop ID their own battle theme, simply type this:                 ║

<span style="color:#000080; font-style:italic;">║ Troops_Theme[id] = ["file", volume, pitch]                                   ║

<span style="color:#000080; font-style:italic;">╟──────────────────────────────────────────────────────────────────────────────╢

<span style="color:#000080; font-style:italic;">║ ■ Methods Aliased                                                            ║

<span style="color:#000080; font-style:italic;">║ ─ initialize of Spriteset_Battle                                             ║

<span style="color:#000080; font-style:italic;">╟──────────────────────────────────────────────────────────────────────────────╢

<span style="color:#000080; font-style:italic;">║ ■ Thanks                                                                     ║

<span style="color:#000080; font-style:italic;">║ ─ JoeYoung requested something like this in the HBGames.org's IRC channel.   ║

<span style="color:#000080; font-style:italic;">╚══════════════════════════════════════════════════════════════════════════════╝

<span style="color:#000080; font-style:italic;">=end

 

#------------------------------------------------------------------------------

# * Customise

#------------------------------------------------------------------------------

class PK8

  Troops_Theme = {} # Do not touch this.

  

  #          [id] = [Music File, Volume, Pitch]

  Troops_Theme[1] = ["002-Battle02", 100, 100]

  Troops_Theme[2] = ["009-LastBoss01", 100, 100]

end

 

#==============================================================================

# ** Spriteset_Battle

#------------------------------------------------------------------------------

#  This class brings together battle screen sprites. It's used within

#  the Scene_Battle class.

#==============================================================================

class Spriteset_Battle

  alias_method(:pk8_troops_theme_initialize, :initialize)

  def initialize

    pk8_troops_theme_initialize

    start_troop_theme

  end

  

  #----------------------------------------------------------------------------

  # * Start Troop Theme

  #----------------------------------------------------------------------------

  def start_troop_theme

    PK8::Troops_Theme.each_key { | i |

    # If Troop ID equals the key.

    if $game_temp.battle_troop_id == i

      # If specified BGM isn't nil or empty.

      if PK8::Troops_Theme[i][0] != nil and !PK8::Troops_Theme[i][0].empty?

        # Sets BGM volume to 100 if nil.

        PK8::Troops_Theme[i][1] = 100 if PK8::Troops_Theme[i][1] == nil

        # Sets BGM pitch to 100 if nil.

        PK8::Troops_Theme[i][2] = 100 if PK8::Troops_Theme[i][2] == nil

        # Plays BGM.

        Audio.bgm_play("Audio/BGM/#{PK8::Troops_Theme[i][0]}",

        PK8::Troops_Theme[i][1], PK8::Troops_Theme[i][2])

      end

      break 

    end }

  end

end
VX
Ruby:
<span style="color:#000080; font-style:italic;">=begin

<span style="color:#000080; font-style:italic;">╔══════════════════════════════════════════════════════════════════════════════╗​

<span style="color:#000080; font-style:italic;">║ Individual Troop Themes VX                                                   ║

<span style="color:#000080; font-style:italic;">║ by PK8                                                                       ║

<span style="color:#000080; font-style:italic;">║ September 28th, 2009                                                         ║

<span style="color:#000080; font-style:italic;">║ [url=http://rmvxp.com]http://rmvxp.com[/url]                                                             ║

<span style="color:#000080; font-style:italic;">╟──────────────────────────────────────────────────────────────────────────────╢​

<span style="color:#000080; font-style:italic;">║ ■ Table of Contents                                                          ║

<span style="color:#000080; font-style:italic;">║ ├─ Author's Notes                - Line 16─18                                ║

<span style="color:#000080; font-style:italic;">║ ├─ Introduction & Description    - Line 20─22                                ║

<span style="color:#000080; font-style:italic;">║ ├─ Features                      - Line 24─26                                ║

<span style="color:#000080; font-style:italic;">║ ├─ How to Use                    - Line 28─30                                ║

<span style="color:#000080; font-style:italic;">║ ├─ Methods Aliased               - Line 32,33                                ║

<span style="color:#000080; font-style:italic;">║ └─ Thanks                        - Line 35─37                                ║

<span style="color:#000080; font-style:italic;">╟──────────────────────────────────────────────────────────────────────────────╢​

<span style="color:#000080; font-style:italic;">║ ■ Author's Notes                                                             ║

<span style="color:#000080; font-style:italic;">║ This script was requested by a user in HBGames.org's IRC channel (I forgot   ║

<span style="color:#000080; font-style:italic;">║ his name) and I was interested in creating this script so... here you go!    ║

<span style="color:#000080; font-style:italic;">╟──────────────────────────────────────────────────────────────────────────────╢​

<span style="color:#000080; font-style:italic;">║ ■ Introduction & Description                                                 ║

<span style="color:#000080; font-style:italic;">║ This script allows game makers to give a specific Troop ID their own theme   ║

<span style="color:#000080; font-style:italic;">║ song. Useful for Boss battles and other unique battles.                      ║

<span style="color:#000080; font-style:italic;">╟──────────────────────────────────────────────────────────────────────────────╢​

<span style="color:#000080; font-style:italic;">║ ■ Features                                                                   ║

<span style="color:#000080; font-style:italic;">║ ─ Give a specific troop ID their own theme.                                  ║

<span style="color:#000080; font-style:italic;">║ ─ Set the song, volume and pitch.                                            ║

<span style="color:#000080; font-style:italic;">╟──────────────────────────────────────────────────────────────────────────────╢​

<span style="color:#000080; font-style:italic;">║ ■ How to Use                                                                 ║

<span style="color:#000080; font-style:italic;">║ To give a troop ID their own battle theme, simply type this:                 ║

<span style="color:#000080; font-style:italic;">║ Troops_Theme[id] = ["file", volume, pitch]                                   ║

<span style="color:#000080; font-style:italic;">╟──────────────────────────────────────────────────────────────────────────────╢​

<span style="color:#000080; font-style:italic;">║ ■ Methods Aliased                                                            ║

<span style="color:#000080; font-style:italic;">║ ─ call_battle of Scene_Map                                                   ║

<span style="color:#000080; font-style:italic;">╟──────────────────────────────────────────────────────────────────────────────╢​

<span style="color:#000080; font-style:italic;">║ ■ Thanks                                                                     ║

<span style="color:#000080; font-style:italic;">║ ─ JoeYoung requested something like this in the HBGames.org's IRC channel.   ║

<span style="color:#000080; font-style:italic;">║ ─ Decibel showing me how I could find the ID of the troop I'm battling.      ║

<span style="color:#000080; font-style:italic;">╚══════════════════════════════════════════════════════════════════════════════╝​

<span style="color:#000080; font-style:italic;">=end

 

#------------------------------------------------------------------------------

# * Customise

#------------------------------------------------------------------------------

class PK8

  Troops_Theme = {} # Do not touch this.

  

  #          [id] = [Music File, Volume, Pitch]

  Troops_Theme[1] = ["Airship", 100, 100]

  Troops_Theme[2] = ["Battle10", 100, 100]

end

 

#==============================================================================

# ** Scene_Map

#------------------------------------------------------------------------------

#  This class performs the map screen processing.

#==============================================================================

class Scene_Map

  alias_method(:pk8_troops_theme_call_battle, :call_battle)

  def call_battle

    pk8_troops_theme_call_battle

    start_troop_theme

  end

 

  #----------------------------------------------------------------------------

  # * Start Troop Theme

  #----------------------------------------------------------------------------

  def start_troop_theme

    PK8::Troops_Theme.each_key { | i |

    # If Troop ID equals the key.

    if $game_troop.troop.id == i

      # If specified BGM isn't nil or empty.

      if PK8::Troops_Theme[i][0] != nil and !PK8::Troops_Theme[i][0].empty?

        # Sets BGM volume to 100 if nil.

        PK8::Troops_Theme[i][1] = 100 if PK8::Troops_Theme[i][1] == nil

        # Sets BGM pitch to 100 if nil.

        PK8::Troops_Theme[i][2] = 100 if PK8::Troops_Theme[i][2] == nil

        # Plays BGM.

        Audio.bgm_play("Audio/BGM/#{PK8::Troops_Theme[i][0]}",

        PK8::Troops_Theme[i][1], PK8::Troops_Theme[i][2])

      end

      break

    end }

  end

end

Instructions
Instructions are in the script.

FAQ
Awaiting question.

Compatibility
XP: I'm not sure if it's compatible with the SDK or any custom battle scripts. This script aliases Spriteset_Battle's initialize method.
VX: This script aliases Scene_Map's call_battle.

Credits and Thanks
XP/VX: JoeYoung requested something like this in HBGames.org's IRC channel.
VX: Decibel showing me how I could find the ID of the troop I'm battling. I decided to "cheat" by using instance_eval. I found a proper way.

Author's Notes
This script was requested by someone, I was interested, voila! :P

Terms and Conditions
Exclusive to RMVXP.com and HBGames.org. Credit me!
 
This looks great to me. If I'm not mistaken this is an old feature from RM2k or RM2k3 right? I remember missing it at the time and then never thinking about it.
 

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