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.

Battle Music

Hi. I'm sure you noticed that in many RPG's boss battle music sometimes continues from background music in the scene before the battle. Now i know there are many small script edits that do this but what i'm after is a script that only does this when it's called. I would think this would be fairly simple but seeing as i know NOTHING about RGSS i don't know how much effort it would take but i would greatly appreciate it if someone was to accept this request.
 
One that you can turn on or off? Found your query in Creative Asylum and posted a link for you there. In case you get here first...


I grabbed this from http://www.phylomortis.com

Map BGM in Battle

This script makes it so that you have the option to seamlessly continue playing the map BGM when you enter a battle. To use this script, find the methods indicated and delete the text between the two statements surrounding the red text, and then add the statements in red text in their place. Once this script is installed, you will need to use the "Script" command to call the statement "$game_system.map_bgm_in_battle = true" to make the seamless BGM transfer happen, and "$game_system.map_bgm_in_battle = false" to go back to using the normal battle BGM.

Script by ??? [Posted on the RPG Maker XP RGSS Wiki]

Code:
[color=#339999]class Game_System
# ----------------------------------------
[...]
attr_accessor :map_bgm_in_battle
[...]
@map_bgm_in_battle = false[/color]

Code:
[color=#339999]class Scene_Map
  def call_battle
  [...]
    $game_player.make_encounter_count
[/color][color=#CC0000]    if $game_system.map_bgm_in_battle == false
      $game_temp.map_bgm = $game_system.playing_bgm
      $game_system.bgm_stop
    end
    $game_system.se_play($data_system.battle_start_se)
    if $game_system.map_bgm_in_battle == false
      $game_system.bgm_play($game_system.battle_bgm)
    end
[/color][color=#339999]    $game_player.straighten
  [...]
 end[/color]

Code:
[color=#339999]class Scene_Battle
   def judge
   [...]
      if $game_temp.battle_can_lose[/color][color=#CC0000]
        if $game_system.map_bgm_in_battle == false
          $game_system.bgm_play($game_temp.map_bgm)
        end
[/color][color=#339999]        battle_end(2)
    [...]
end
# ----------------------------
   def update
   [...]
    if $game_temp.battle_abort[/color][color=#CC0000]
      if $game_system.map_bgm_in_battle == false
        $game_system.bgm_play($game_temp.map_bgm)
      end
[/color][color=#339999]      battle_end(1)
   [...]
end
# ----------------------------
   def update_phase2_escape
   [...]
   if success
      $game_system.se_play($data_system.escape_se)[/color][color=#CC0000]
      if $game_system.map_bgm_in_battle == false
        $game_system.bgm_play($game_temp.map_bgm)
      end
[/color][color=#339999]      battle_end(1)
   [...]
end
# ----------------------------
   def start_phase5
    @phase = 5[/color][color=#CC0000]
    if $game_system.map_bgm_in_battle == false
      $game_system.me_play($game_system.battle_end_me)
      $game_system.bgm_play($game_temp.map_bgm)
    end
[/color][color=#339999]    exp = 0
    gold = 0
    treasures = []
   [...]
end[/color]

NOTE: While the basics of this script works... there IS a... FLUKY BUG with RMXP. Explanation and solution below.

The coding is fine, just like you said. BUT apparently RGSS itself doesn't like 'false' values passed to the scripts like this. It has nothing to do with syntax or logical errors. Just that it doesn't like you to pass 'false' values through an [event] code's script command. You can pass a true value, like...

script: $game_system.map_bgm_in_battle = true

... but ...

script: $game_system.map_bgm_in_battle = false

...will freeze it just because it sends a 'false' value.

http://www.dubealex.com/asylum/style_em ... nting2.gif[/IMG] STUUPID STUUPID STUUPID! http://www.dubealex.com/asylum/style_em ... nting2.gif[/IMG]

Now... if you change the value being accepted by $game_system.map_bgm_in_battle to '0' and '1' instead of 'true' and 'false' through the script... then you won't have that problem. http://www.dubealex.com/asylum/style_em ... n_wink.gif[/IMG]
 
That's the bummer... you gotta edit the DEFAULT scripts.

And if you have inserted custom scripts that edit Scene Map and Scene Battle... they may get overwritten... unless you edit the custom scripts just in case.
 
Try this one:

#==========================================================================
# ** SG Optional Battle Music
#==========================================================================
# sandgolem
# Version 1
# 24.06.06
#==========================================================================

# Switch number to activate the Even Music
#
#Also note, in Event enabling this switch, change battle win ME to null
Scene_Map::SG_Disable_BattleMusic = 5

#==========================================================================
#
# To check for updates or find more scripts, visit:
# http://www.gamebaker.com/rmxp/scripts/
#
# To use this script, copy it and insert it in a new section above "Main",
# under the default scripts, and the SDK if you're using it.
#
# Have problems? Official topic:
# http://forums.gamebaker.com/showthread.php?t=13
#
#==========================================================================

begin
SDK.log('SG Optional Battle Music', 'sandgolem', 1, '24.06.06')
if SDK.state('SG Optional Battle Music') != true
@sg_nobattlebgm_disabled = true
end
rescue
end

if !@sg_nobattlebgm_disabled
#--------------------------------------------------------------------------

class Game_System
alias sandgolem_nobattlebgm_system_bgm bgm_play
def bgm_play(bgm)
if !$sg_keep_music
sandgolem_nobattlebgm_system_bgm(bgm)
end
end

alias sandgolem_nobattlebgm_system_bgmstop bgm_stop
def bgm_stop
if !$sg_keep_music
sandgolem_nobattlebgm_system_bgmstop
end
end
end

class Scene_Map
alias sandgolem_nobattlebgm_map_callbattle call_battle
def call_battle
if $game_switches[SG_Disable_BattleMusic]
$sg_keep_music = true
end
sandgolem_nobattlebgm_map_callbattle
$sg_keep_music = nil
end
end

#--------------------------------------------------------------------------
end

The effect will only occur when you turn the switch specified here:

Code:
Scene_Map::SG_Disable_BattleMusic = 5

On, in this case, Switch 5. Be sure to set your Victory ME to nothing in the event you turn on the switch for the continuous music as well. Just paste this above Main and you wont need to change default scripts.
 
That one IS easier to use, but it is an SDK script. Which means that you need the Standard Development Kit script itself (stickied in the RGSS Submitted Scripts forum), and you'll have to use mostly SDK scripts in your project.
 
Oddly, I don't have the SDK in my project, but it work's fine with Cohwheel's RTAB+ Addons and LeGacy's CMS along with several other assorted scripts, including my broken anime cut in script, which I am still working on ^^;
 
Well, whichever one you like the best I'd use, but DerVVulfman trumps me in experience so his system is probably better. I just hate editing my default scripts personally, but be sure to leave commented notes on what you changed in case you need to go back to it later.
 
DerVVulfman;133527 said:
That one IS easier to use, but it is an SDK script. Which means that you need the Standard Development Kit script itself (stickied in the RGSS Submitted Scripts forum), and you'll have to use mostly SDK scripts in your project.
Nope. :)

Almost none of sandgolem's scripts require it, they just support it's logging and quick disabling of scripts. The begin/rescue thing calls the SDK commands and allows RMXP to continue instead of crashing if the SDK isn't being used.
 

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