BGM No Loop
#1
BGM No Loop

HiddenChest Exclusive!
XP Related

by Kyonides

Introduction

This is a simple scriplet that will let RMXP users play one BGM after another based on which map ID's are included in the MAP_BGM array.

There still is one important detail you must know: Audio.bgm_loop is set to true, meaning that all the other maps will keep playing the same old song. Metalhead Rapper 

Warning

You need to be using HiddenChest version 1.1.81 or later!

Script for RMXP Editor
Code:
# * BGM No Loop XP * #
#   Scripter : Kyonides Arkanthes
#   2024-06-13

# This scriptlet allows you to prevent the game from playing the same old song
# over and over again. Now you can define a list of BGMs for specific maps!

module BgmNoLoop
  WAIT = 20
  VOLUME = 60
  MAP_BGM = {}
  MAP_BGM[1] = ["015-Theme04", "017-Theme06"]
end

class Game_Map
  alias :kyon_bgm_no_loop_gm_map_setup :setup
  def setup(map_id)
    check_bgm_loop(map_id)
    kyon_bgm_no_loop_gm_map_setup(map_id)
  end

  def check_bgm_loop(map_id)
    Audio.bgm_loop = !BgmNoLoop::MAP_BGM.has_key?(map_id)
    puts "Check Loop in Map ##{map_id}: " + Audio.bgm_loop.to_s
  end

  def map_bgm
    @map.bgm
  end

  def find_bgms
    bgm = @map.bgm
    $game_system.bgm_volume = bgm.volume
    bgms = []
    bgms << bgm unless bgm.name.empty?
    bgms + BgmNoLoop::MAP_BGM[@map_id]
  end
end

class Game_System
  alias :kyon_bgm_no_loop_gm_sys_init :initialize
  alias :kyon_bgm_no_loop_gm_sys_up :update
  def initialize
    kyon_bgm_no_loop_gm_sys_init
    reset_bgm_timer
    reset_bgm_volume
    @bgm_index = 0
  end

  def reset_bgm_timer
    @bgm_timer = BgmNoLoop::WAIT
  end

  def reset_bgm_volume
    @bgm_volume ||= BgmNoLoop::VOLUME
  end

  def update
    kyon_bgm_no_loop_gm_sys_up
    return if $game_temp.in_battle or Audio.bgm_playing?
    return if Audio.bgm_loop
    if @bgm_timer > 0
      @bgm_timer -= 1
      return
    end
    reset_bgm_timer
    bgms = $game_map.find_bgms
    @bgm_index ||= 0
    @bgm_index = (@bgm_index + 1) % bgms.size
    bgm = bgms[@bgm_index]
    bgm = RPG::AudioFile.new(bgm) if bgm.is_a?(String)
    bgm_play(bgm) if bgm != nil
  end

  def bgm_play(bgm)
    reset_bgm_volume
    @playing_bgm = bgm
    if bgm != nil and bgm.name != ""
      Audio.bgm_play("Audio/BGM/" + bgm.name, @bgm_volume, bgm.pitch)
    else
      Audio.bgm_stop
    end
    Graphics.frame_reset
  end
  attr_accessor :bgm_volume
end

Terms & Conditions

Free for any kind of game running on the HiddenChest engine. [Image: wink.gif]
Due credit is mandatory.
Don't post the contents of this topic anywhere else!
You better paste a link to this thread and make them come here instead.
That's it! [Image: tongue.gif]
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }
#2
Are the themes always playing in order or can you play them randomly? So that it doesnt always start with the same old first track of the array when you enter the map :P
Reply }
#3
Interesting Update

After getting the same request from 2 different individuals, namely 2 people whose avatars are connected to the night, I decided to let my script play the songs randomly.

Really, I didn't feel Indifferent the need to do that but I guess Thinking that I had no other choice but to implement it at once.
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }




Users browsing this thread: 2 Guest(s)