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.

"BGM continues after Battle" - need a ".dll" file

In the default of RMXP, after a battle, the Map BGM will be re-played :( that's bad!
And this is an useful Script to make BGM can continue playing after battle of RMXP
But it needs a file called "Audio.dll", but I can't find out it
So someone know that file, please help me :(
Here is the Script :

Code:
#==============================================================================

# Não reinciar Música do mapa após uma batalha

# por Atoa

# Novo modulo de Audio por Poccil

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

 

class Win32API

@@RGSSWINDOW=nil

@@GetCurrentThreadId=Win32API.new('kernel32','GetCurrentThreadId', '%w()','l')

@@GetWindowThreadProcessId=Win32API.new('user32','GetWindowThreadProcessId', '%w(l p)','l')

@@FindWindowEx=Win32API.new('user32','FindWindowEx', '%w(l l p p)','l')

def Win32API.GetPrivateProfileString(section, key)

val = "\0"*256

gps = Win32API.new('kernel32', 'GetPrivateProfileString',%w(p p p p l p), 'l')

gps.call(section, key, "", val, 256, ".\\Game.ini")

val.delete!("\0")

return val

end

end

 

class Thread

def Thread.exclusive

_old = Thread.critical

begin

Thread.critical = true

return yield

ensure

Thread.critical = _old

end

end

end

 

class AudioContext

attr_reader :context

def initialize

init = Win32API.new("audio.dll", "AudioContextInitialize", '', 'l')

@context=init.call()

end

def dispose

if @context!=0

init = Win32API.new("audio.dll", "AudioContextFree", 'l', '')

init.call(context)

@context=0

end

end

end

 

$AtExitProcs=[] if !$AtExitProcs

def exit(code=0)

for p in $AtExitProcs

p.call

end

raise SystemExit.new(code)

end

 

def at_exit(&block)

$AtExitProcs.push(Proc.new(&block))

end

 

module AudioState

w32_LL = Win32API.new("kernel32.dll", "LoadLibrary", 'p', 'l')

w32_FL = Win32API.new("kernel32.dll", "FreeLibrary", 'p', 'l')

@handle = w32_LL.call("audio.dll")

at_exit { w32_FL.call(@handle) }

AudioContextIsActive=Win32API.new("audio.dll","AudioContextIsActive","l","l")

AudioContextPlay=Win32API.new("audio.dll","AudioContextPlay","lpllll","")

AudioContextStop=Win32API.new("audio.dll","AudioContextStop","l","")

AudioContextFadeOut=Win32API.new("audio.dll","AudioContextFadeOut","ll","")

AudioContextGetPosition=Win32API.new("audio.dll","AudioContextGetPosition","l","l")

AudioContextFadeIn=Win32API.new("audio.dll","AudioContextFadeIn","ll","")

AudioContextSetVolume=Win32API.new("audio.dll","AudioContextSetVolume","ll","")

AudioContextSEPlay=Win32API.new("audio.dll","AudioContextSEPlay","lplll","")

if !@MEContext

@MEContext=AudioContext.new

at_exit { @MEContext.dispose }

end

if !@BGMContext

@BGMContext=AudioContext.new

at_exit { @BGMContext.dispose }

end

if !@SEContext

@SEContext=AudioContext.new

at_exit { @SEContext.dispose }

end

@channel=nil

@bgm=nil

@name=""

@pitch=100

@bgmVolume=100.0

@meVolume=100.0

@seVolume=100.0

def self.setWaitingBGM(bgm,volume,pitch,position)

@waitingBGM=[bgm,volume,pitch,position]

end

def self.bgmActive?

return (AudioContextIsActive.call(@BGMContext.context)!=0)

end

def self.meActive?

return (AudioContextIsActive.call(@MEContext.context)!=0)

end

def self.waitingBGM

@waitingBGM

end

def self.context

@BGMContext.context

end

def self.system

@system

end

def self.bgm

@bgm

end

def self.name

@name

end

def self.pitch

@pitch

end

def self.volume

@volume

end

def self.waitingBGM=(value)

Thread.exclusive{@waitingBGM=value}

end

def self.volume=(value)

@volume=value

end

def self.bgm=(value)

@bgm=value

end

def self.name=(value)

@name=value

end

def self.pitch=(value)

@pitch=value

end

end

 

def Audio_bgm_playing?

AudioState.channel!=nil

end

def Audio_bgm_name

AudioState.name

end

def Audio_bgm_pitch

AudioState.pitch

end

def Audio_bgm_play(name, volume, pitch, position = 0)

begin

filename = canonicalize(rtpGetPath(name,[".mid",".mp3",".wma",".ogg",".wav",""]))

if AudioState.meActive?

AudioState.setWaitingBGM(filename,volume,pitch,position)

return

end

AudioState::AudioContextPlay.call(AudioState.context,filename,volume,pitch,position,1)

AudioState.name=filename

AudioState.volume=volume

AudioState.pitch=pitch

rescue Hangup

rescue

p $!.message,$!.backtrace

end

end

def Audio_bgm_stop()

begin

AudioState::AudioContextStop.call(AudioState.context)

AudioState.waitingBGM=nil

AudioState.name = ""

rescue

p $!.message,$!.backtrace

end

end

def Audio_bgm_get_position

return AudioState::AudioContextGetPosition.call(AudioState.context)

end

def Audio_bgm_fade(ms)

AudioState::AudioContextFadeOut.call(AudioState.context,ms.to_i)

end

def Audio_bgm_fadein(ms)

AudioState::AudioContextFadeIn.call(AudioState.context,ms.to_i)

end

def Audio_bgm_get_volume

return 0 if !AudioState.bgmActive?

return AudioState.volume

end

def Audio_bgm_set_volume(volume)

return if !AudioState.bgmActive?

AudioState.volume = volume * 1.0

AudioState::AudioContextSetVolume.call(AudioState.context,volume.to_i)

end

 

module Graphics

if !defined?(audiomodule_update)

class << self

alias audiomodule_update update

end

end

def self.update

Audio.update

audiomodule_update

end

end

 

module Audio

@@musicstate=nil

@@soundstate=nil

def self.update

return if Graphics.frame_count%10!=0

if AudioState.waitingBGM && !AudioState.meActive?

waitbgm=AudioState.waitingBGM

AudioState.waitingBGM=nil

bgm_play(waitbgm[0],waitbgm[1],waitbgm[2],waitbgm[3])

end

end

def self.bgm_play(name,volume=80,pitch=100,position=nil)

begin

if position==nil || position==0

Kernel.Audio_bgm_play(name,volume,pitch,0)

else

Kernel.Audio_bgm_play(name,volume,pitch,position)

Kernel.Audio_bgm_fadein(500)

end

rescue Hangup

bgm_play(name,volume,pitch,position)

end

end

def self.bgm_fade(ms)

Kernel.Audio_bgm_fade(ms)

end

def self.bgm_stop

Kernel.Audio_bgm_stop()

end

def self.bgm_position

ret=Kernel.Audio_bgm_get_position

return ret

end

end

 

module Win32

class Registry

module Constants

HKEY_CLASSES_ROOT = 0x80000000

HKEY_CURRENT_USER = 0x80000001

HKEY_LOCAL_MACHINE = 0x80000002

HKEY_USERS = 0x80000003

HKEY_PERFORMANCE_DATA = 0x80000004

HKEY_PERFORMANCE_TEXT = 0x80000050

HKEY_PERFORMANCE_NLSTEXT = 0x80000060

HKEY_CURRENT_CONFIG = 0x80000005

HKEY_DYN_DATA = 0x80000006

REG_NONE = 0

REG_SZ = 1

REG_EXPAND_SZ = 2

REG_BINARY = 3

REG_DWORD = 4

REG_DWORD_LITTLE_ENDIAN = 4

REG_DWORD_BIG_ENDIAN = 5

REG_LINK = 6

REG_MULTI_SZ = 7

REG_RESOURCE_LIST = 8

REG_FULL_RESOURCE_DESCRIPTOR = 9

REG_RESOURCE_REQUIREMENTS_LIST = 10

REG_QWORD = 11

REG_QWORD_LITTLE_ENDIAN = 11

STANDARD_RIGHTS_READ = 0x00020000

STANDARD_RIGHTS_WRITE = 0x00020000

KEY_QUERY_VALUE = 0x0001

KEY_SET_VALUE = 0x0002

KEY_CREATE_SUB_KEY = 0x0004

KEY_ENUMERATE_SUB_KEYS = 0x0008

KEY_NOTIFY = 0x0010

KEY_CREATE_LINK = 0x0020

KEY_READ = STANDARD_RIGHTS_READ |

KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY

KEY_WRITE = STANDARD_RIGHTS_WRITE |

KEY_SET_VALUE | KEY_CREATE_SUB_KEY

KEY_EXECUTE = KEY_READ

KEY_ALL_ACCESS = KEY_READ | KEY_WRITE | KEY_CREATE_LINK

REG_OPTION_RESERVED = 0x0000

REG_OPTION_NON_VOLATILE = 0x0000

REG_OPTION_VOLATILE = 0x0001

REG_OPTION_CREATE_LINK = 0x0002

REG_OPTION_BACKUP_RESTORE = 0x0004

REG_OPTION_OPEN_LINK = 0x0008

REG_LEGAL_OPTION = REG_OPTION_RESERVED |

REG_OPTION_NON_VOLATILE | REG_OPTION_CREATE_LINK |

REG_OPTION_BACKUP_RESTORE | REG_OPTION_OPEN_LINK

REG_CREATED_NEW_KEY = 1

REG_OPENED_EXISTING_KEY = 2

REG_WHOLE_HIVE_VOLATILE = 0x0001

REG_REFRESH_HIVE = 0x0002

REG_NO_LAZY_FLUSH = 0x0004

REG_FORCE_RESTORE = 0x0008

MAX_KEY_LENGTH = 514

MAX_VALUE_LENGTH = 32768

end

include Constants

include Enumerable

class Error < ::StandardError

FormatMessageA=Win32API.new('kernel32.dll','FormatMessageA','LPLLPLP','L')

def initialize(code)

@code = code

msg = "\0" * 1024

len = FormatMessageA.call(0x1200, 0, code, 0, msg, 1024, 0)

super msg[0, len].tr("\r", '').chomp

end

attr_reader :code

end

class PredefinedKey < Registry

def initialize(hkey, keyname)

@hkey = hkey

@parent = nil

@keyname = keyname

@disposition = REG_OPENED_EXISTING_KEY

end

def close

raise Error.new(5)

end

def class

Registry

end

Constants.constants.grep(/^HKEY_/) do |c|

Registry.const_set c, new(Constants.const_get(c), c)

end

end

module API

[

%w/RegOpenKeyExA LPLLP L/,

%w/RegCreateKeyExA LPLLLLPPP L/,

%w/RegEnumValueA LLPPPPPP L/,

%w/RegEnumKeyExA LLPPLLLP L/,

%w/RegQueryValueExA LPLPPP L/,

%w/RegSetValueExA LPLLPL L/,

%w/RegFlushKey L L/,

%w/RegCloseKey L L/,

%w/RegQueryInfoKey LPPPPPPPPPPP L/,

].each do |fn|

const_set fn[0].intern, Win32API.new('advapi32.dll', *fn)

end

module_function

def check(result)

raise Error, result, caller(2) if result != 0

end

def packdw(dw)

[dw].pack('V')

end

def unpackdw(dw)

dw += [0].pack('V')

dw.unpack('V')[0]

end

def packqw(qw)

[ qw & 0xFFFFFFFF, qw >> 32 ].pack('VV')

end

def unpackqw(qw)

qw = qw.unpack('VV')

(qw[1] << 32) | qw[0]

end

def OpenKey(hkey, name, opt, desired)

result = packdw(0)

check RegOpenKeyExA.call(hkey, name, opt, desired, result)

unpackdw(result)

end

def CreateKey(hkey, name, opt, desired)

result = packdw(0)

disp = packdw(0)

check RegCreateKeyExA.call(hkey, name, 0, 0, opt, desired,

0, result, disp)

[ unpackdw(result), unpackdw(disp) ]

end

def EnumValue(hkey, index)

name = ' ' * Constants::MAX_KEY_LENGTH

size = packdw(Constants::MAX_KEY_LENGTH)

check RegEnumValueA.call(hkey, index, name, size, 0, 0, 0, 0)

name[0, unpackdw(size)]

end

def EnumKey(hkey, index)

name = ' ' * Constants::MAX_KEY_LENGTH

size = packdw(Constants::MAX_KEY_LENGTH)

wtime = ' ' * 8

check RegEnumKeyExA.call(hkey, index, name, size, 0, 0, 0, wtime)

[ name[0, unpackdw(size)], unpackqw(wtime) ]

end

def QueryValue(hkey, name)

type = packdw(0)

size = packdw(0)

check RegQueryValueExA.call(hkey, name, 0, type, 0, size)

data = ' ' * unpackdw(size)

check RegQueryValueExA.call(hkey, name, 0, type, data, size)

[ unpackdw(type), data[0, unpackdw(size)] ]

end

def SetValue(hkey, name, type, data, size)

check RegSetValueExA.call(hkey, name, 0, type, data, size)

end

def FlushKey(hkey)

check RegFlushKey.call(hkey)

end

def CloseKey(hkey)

check RegCloseKey.call(hkey)

end

def QueryInfoKey(hkey)

subkeys = packdw(0)

maxsubkeylen = packdw(0)

values = packdw(0)

maxvaluenamelen = packdw(0)

maxvaluelen = packdw(0)

secdescs = packdw(0)

wtime = ' ' * 8

check RegQueryInfoKey.call(hkey, 0, 0, 0, subkeys, maxsubkeylen, 0,

values, maxvaluenamelen, maxvaluelen, secdescs, wtime)

[ unpackdw(subkeys), unpackdw(maxsubkeylen), unpackdw(values),

unpackdw(maxvaluenamelen), unpackdw(maxvaluelen),

unpackdw(secdescs), unpackqw(wtime) ]

end

end

def self.expand_environ(str)

str.gsub(/%([^%]+)%/) { ENV[$1] || $& }

end

@@type2name = { }

%w[

REG_NONE REG_SZ REG_EXPAND_SZ REG_BINARY REG_DWORD

REG_DWORD_BIG_ENDIAN REG_LINK REG_MULTI_SZ

REG_RESOURCE_LIST REG_FULL_RESOURCE_DESCRIPTOR

REG_RESOURCE_REQUIREMENTS_LIST REG_QWORD

].each do |type|

@@type2name[Constants.const_get(type)] = type

end

def self.type2name(type)

@@type2name[type] || type.to_s

end

def self.wtime2time(wtime)

Time.at((wtime - 116444736000000000) / 10000000)

end

def self.time2wtime(time)

time.to_i * 10000000 + 116444736000000000

end

private_class_method :new

def self.open(hkey, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED)

subkey = subkey.chomp('\\')

begin

newkey = API.OpenKey(hkey.hkey, subkey, opt, desired)

rescue Error

return nil

end

obj = new(newkey, hkey, subkey, REG_OPENED_EXISTING_KEY)

if block_given?

begin

yield obj

ensure

obj.close

end

else

obj

end

end

def self.create(hkey, subkey, desired = KEY_ALL_ACCESS, opt = 0x0000)

newkey, disp = API.CreateKey(hkey.hkey, subkey, opt, desired)

obj = new(newkey, hkey, subkey, disp)

if block_given?

begin

yield obj

ensure

obj.close

end

else

obj

end

end

@@final = proc { |hkey| proc { API.CloseKey(hkey[0]) if hkey[0] } }

def initialize(hkey, parent, keyname, disposition)

@hkey = hkey

@parent = parent

@keyname = keyname

@disposition = disposition

@hkeyfinal = [ hkey ]

ObjectSpace.define_finalizer self, @@final.call(@hkeyfinal)

end

attr_reader :hkey, :parent, :keyname, :disposition

def created?

@disposition == REG_CREATED_NEW_KEY

end

def open?

!@hkey.nil?

end

def name

parent = self

name = @keyname

while parent = parent.parent

name = parent.keyname + '\\' + name

end

name

end

def inspect

"\#"

end

def _dump(depth)

raise TypeError, "can't dump Win32::Registry"

end

def open(subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED, &blk)

self.class.open(self, subkey, desired, opt, &blk)

end

def create(subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED, &blk)

self.class.create(self, subkey, desired, opt, &blk)

end

def close

API.CloseKey(@hkey)

@hkey = @parent = @keyname = nil

@hkeyfinal[0] = nil

end

def each_value

index = 0

while true

begin

subkey = API.EnumValue(@hkey, index)

rescue Error

break

end

begin

type, data = read(subkey)

rescue Error

next

end

yield subkey, type, data

index += 1

end

index

end

alias each each_value

def each_key

index = 0

while true

begin

subkey, wtime = API.EnumKey(@hkey, index)

rescue Error

break

end

yield subkey, wtime

index += 1

end

index

end

def keys

keys_ary = []

each_key { |key,| keys_ary << key }

keys_ary

end

def read(name, *rtype)

type, data = API.QueryValue(@hkey, name)

unless rtype.empty? or rtype.include?(type)

string = "Type mismatch (expect #{rtype.inspect} but #{type} present)"

raise TypeError, string

end

case type

when REG_SZ, REG_EXPAND_SZ

[ type, data.chop ]

when REG_MULTI_SZ

[ type, data.split(/\0/) ]

when REG_BINARY

[ type, data ]

when REG_DWORD

[ type, API.unpackdw(data) ]

when REG_DWORD_BIG_ENDIAN

[ type, data.unpack('N')[0] ]

when REG_QWORD

[ type, API.unpackqw(data) ]

else

raise TypeError, "Type #{type} is not supported."

end

end

def [](name, *rtype)

type, data = read(name, *rtype)

case type

when REG_SZ, REG_DWORD, REG_QWORD, REG_MULTI_SZ

data

when REG_EXPAND_SZ

Registry.expand_environ(data)

else

raise TypeError, "Type #{type} is not supported."

end

end

def read_s(name)

read(name, REG_SZ)[1]

end

def read_s_expand(name)

type, data = read(name, REG_SZ, REG_EXPAND_SZ)

if type == REG_EXPAND_SZ

Registry.expand_environ(data)

else

data

end

end

def read_i(name)

read(name, REG_DWORD, REG_DWORD_BIG_ENDIAN, REG_QWORD)[1]

end

def read_bin(name)

read(name, REG_BINARY)[1]

end

def write(name, type, data)

case type

when REG_SZ, REG_EXPAND_SZ

data = data.to_s + "\0"

when REG_MULTI_SZ

data = data.to_a.join("\0") + "\0\0"

when REG_BINARY

data = data.to_s

when REG_DWORD

data = API.packdw(data.to_i)

when REG_DWORD_BIG_ENDIAN

data = [data.to_i].pack('N')

when REG_QWORD

data = API.packqw(data.to_i)

else

raise TypeError, "Unsupported type #{type}"

end

API.SetValue(@hkey, name, type, data, data.length)

end

def []=(name, rtype, value = nil)

if value

write name, rtype, value

else

case value = rtype

when Integer

write name, REG_DWORD, value

when String

write name, REG_SZ, value

when Array

write name, REG_MULTI_SZ, value

else

raise TypeError, "Unexpected type #{value.class}"

end

end

value

end

def write_s(name, value)

write name, REG_SZ, value.to_s

end

def write_i(name, value)

write name, REG_DWORD, value.to_i

end

def write_bin(name, value)

write name, REG_BINARY, value.to_s

end

def flush

API.FlushKey @hkey

end

def info

API.QueryInfoKey(@hkey)

end

%w[

num_keys max_key_length

num_values max_value_name_length max_value_length

descriptor_length wtime

].each_with_index do |s, i|

eval <<-__END__

def #{s}

info[#{i}]

end

__END__

end

end

end

 

def getExistingPath(file,extensions=[])

return file if FileTest.exist?(file)

if extensions

for ext in extensions

fullfile=file+ext

return fullfile if FileTest.exist?(fullfile)

end

end

return nil

end

 

def rtpGetDirectory(key,rtpname)

rtp=Win32API.GetPrivateProfileString("Game",rtpname)

return nil if !rtp || rtp==""

begin

path=key.read_s(rtp)

if path && path!="" 

return path

end

return nil

rescue

return nil

end 

end

 

def rtpGetPathHelper(key,rtpname,file,extensions)

path=rtpGetDirectory(key,rtpname)

return path ? getExistingPath(path+"\\"+file,extensions) : nil

end

 

def chdirRTP(rtpname)

Win32::Registry.open(

Win32::Registry::HKEY_LOCAL_MACHINE,"SOFTWARE\\Enterbrain\\RGSS\\RTP"){|key|

path=rtpGetDirectory(key,rtpname)

if path && path!=""

if block_given?

Dir.chdir(path){ yield }

else

Dir.chdir(path)

end

end

}

end

 

def rtpGetPath(file,extensions=[])

path=getExistingPath(file,extensions)

if !path

Win32::Registry.open(

Win32::Registry::HKEY_LOCAL_MACHINE,"SOFTWARE\\Enterbrain\\RGSS\\RTP"){|key|

path=rtpGetPathHelper(key,"RTP1",file,extensions)

path=rtpGetPathHelper(key,"RTP2",file,extensions) if !path

path=rtpGetPathHelper(key,"RTP3",file,extensions) if !path }

end

return path

end

 

 

def getPlayMusic

begin

ret=true

Win32::Registry.open(

Win32::Registry::HKEY_CURRENT_USER,"SOFTWARE\\Enterbrain\\RGSS"){|key|

ret=(key["PlayMusic"] == 1)}

return ret

rescue

return true

end

end

 

def getPlaySound

begin

ret=true

Win32::Registry.open(

Win32::Registry::HKEY_CURRENT_USER,"SOFTWARE\\Enterbrain\\RGSS"){|key|

ret=(key["PlaySound"] == 1)}

return ret

rescue

p $!.message,$!.class.name

return true

end

end

 

module FileTest

Image_ext = ['.bmp', '.png', '.jpg', '.jpeg']

Audio_ext = ['.mp3', '.mid', '.midi', '.ogg', '.wav', '.wma']

def self.audio_exist?(filename)

return !rtpGetPath(filename,Audio_ext).nil?

end

def self.image_exist?(filename)

return !rtpGetPath(filename,Image_ext).nil?

end

end

 

class Hangup < Exception

end

 

def strsplit(str,re)

ret=[]

tstr=str

while re=~tstr

ret[ret.length]=$~.pre_match

tstr=$~.post_match

end

ret[ret.length]=tstr if ret.length

return ret

end

 

def canonicalize(c)

csplit=strsplit(c,/[\/\\]/)

pos=-1

ret=[]

retstr=""

for x in csplit

if x=="."

elsif x==".."

if pos>=0

ret.delete_at(pos) 

pos-=1

end

else

ret.push(x)

pos+=1

end

end

for i in 0...ret.length

retstr+="/" if i>0

retstr+=ret[i]

end

return retstr

end

 

class Game_System

attr_accessor :bgm_position

def audioBgmPlay(str,vol,pitch,position)

Audio.bgm_play(str,vol,pitch,position)

end

def audioBgmFade(time)

Audio.bgm_fade(time) 

end

def audioBgmStop

Audio.bgm_stop 

end

def bgm_play_ex(bgm,volume,pitch,setplaying,position=0)

if bgm.is_a?(String)

bgm=RPG::AudioFile.new(bgm,volume,pitch)

end

if setplaying

@playing_bgm = bgm==nil ? nil : bgm.clone

end

if bgm != nil and bgm.name != ""

audioBgmPlay("Audio/BGM/" + bgm.name, bgm.volume, bgm.pitch,position) if !@defaultBGM

else

audioBgmStop if !@defaultBGM

end

if @defaultBGM

audioBgmPlay("Audio/BGM/"+@defaultBGM.name, @defaultBGM.volume,@defaultBGM.pitch,position)

end

Graphics.frame_reset

end

def bgm_play(bgm,volume=100,pitch=100,position=0)

bgm_play_ex(bgm,volume,pitch,true,position)

end

def bgm_stop

@bgm_position=0

@playing_bgm = nil

audioBgmStop if !@defaultBGM

end

def bgm_fade(time)

@playing_bgm = nil

audioBgmFade((time * 1000).floor) if !@defaultBGM

end

def getPlayingBGM

return @playing_bgm ? @playing_bgm.clone : nil

end

def bgm_memorize

@memorized_bgm = @playing_bgm

end

def bgm_restore

bgm_play(@memorized_bgm)

end

def setDefaultBGM(bgm,volume=100,pitch=100)

if bgm.is_a?(String)

bgm=RPG::AudioFile.new(bgm,volume,pitch)

end

if bgm != nil and bgm.name != ""

@defaultBGM=bgm==nil ? nil : bgm.clone

Audio.bgm_play("Audio/BGM/"+bgm.name)

else

@defaultBGM=nil

self.bgm_play(@playing_bgm)

end

end

def bgm_pause(fadetime=0.0)

pos=Audio.bgm_position

if fadetime>0.0

bgm_fade(fadetime)

end

@bgm_position=pos

end

def bgm_unpause

@bgm_position=0

end

def bgm_resume(bgm,volume=100,pitch=100);

bgm_play(bgm,volume,pitch,@bgm_position)

@bgm_position=0

end 

end

 

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

# Scene_Map

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

class Scene_Map

def call_battle

$game_temp.battle_calling = false

$game_temp.menu_calling = false

$game_temp.menu_beep = false

$game_player.make_encounter_count

$playingBGM=$game_system.playing_bgm

$game_system.bgm_pause

$game_system.se_play($data_system.battle_start_se)

$game_system.bgm_play($game_system.battle_bgm)

$game_player.straighten

$scene = Scene_Battle.new

end

end

 

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

# Scene_Battle

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

class Scene_Battle

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

alias battle_end_alias battle_end

def battle_end(result)

battle_end_alias(result)

Audio.me_stop

$game_system.bgm_resume($playingBGM) 

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