Ambient Sound
DescrizioneCon questo script puoi impostare gli eventi per riprodurre suoni se accanto al giocatore, variando volume, pitch, ecc.
Puoi anche personalizzare gli effetti cambiando le caratteristiche audio, via codice.
Per usare questo script bisogna configurare nello script gli effetti, quindi scriverne solo il nome in un commento nella pagina dell'evento voluto.
Autore
mikb89
Allegati
Demo multilingua v. 1.0 (1,33MB)
http://www.mediafire...alkn9m7g22gb023
Istruzioni per l'uso
Copiare lo script normalmente sotto Modules e sopra Main, quindi configurare gli effetti voluti.
Script
Spoiler
# Ambient Sound v. 1.0 # VX Ace version # by mikb89 # Dettagli: # Le possibilità audio di RPG Maker fanno schifo. C'è questo Audio Pump # Up - FMOD Ex (script che estende il sistema audio usando le librerie FMod) # e lo menzionerò pressoché ovunque qui e lì nella demo. Comunque questo # script funziona lo stesso anche senza aggiungerlo. # Quello che QUESTO script fa penso sia chiaro. Puoi impostare gli eventi per # riprodurre suoni se accanto al giocatore, variando volume, pitch, ecc. # Puoi anche personalizzare gli effetti, come quello sotto del gallo, cambiando # le caratteristiche audio, via codice. # Per usare questo script bisogna configurare QUI gli effetti, quindi scriverne # il nome in un commento nella pagina dell'evento voluto. # Configurazioni: module AMBISOUND # Impostazioni se usi Audio Pump Up - FMOD Ex. SOUND_CHANNEL = 3 # Canale da usare per ogni suono. Metti 0 o negativo per disattivare. USE_PAN = true # Vuoi sentire i suoni da vero sistema stereo? # Es. se un suono viene da destra, si sentirà di più nella cassa destra. # Fine della configurazione APU. DELAY = 10 # Consente di non aggiornare l'audio troppo spesso. Più grande il numero, # minore il lag. EFFECTS = { #"name" => ["TYPE", "filename", max_vol, pitch, range, vol_min, :def] "radio" => ["BGM", "Airship", 100, 100, 8, 10, nil], # <- metti , finché non è l'ultimo "radioLow"=> ["BGM", "Airship", 70, 100, 2, 0, nil], "chicken" => ["SE", "Chicken", 80, 80, 3, 0, :chicken], "tremolo" => ["BGS", "Wind", 80, 100, 5, 0, :tremolo] } # Spiegazione: # "name" è quel che andrai a scrivere nel commento per usare l'effetto. # "TYPE" è uno fra "BGM", "BGS", "ME", "SE". # "filename" è il nome del file che vuoi ascoltare. # max_volume è il massimo volume che il suono può raggiungere. # cioè quando il pg è sopra l'evento. # pitch è il pitch. Standard per BGM/BGS è 100, per ME/SE è 80. # range è la distanza massima in cui è possibile udire il suono. # volume_min è il volume minimo da avere per far partire il suono. Se il pg è # nei limiti del range, ma il volume sarebbe minore di questo valore, l'audio # non partirà, in modo da lasciar dissolvere meglio il precedente. # :def ti lascia creare una funzione per gestire l'audio. Puoi sceglierne una # fra quelle di default o aggiungerne se te la cavi con gli script. # def di esempio def self.chicken(sound) # pollo! o qualcosa di simile return unless sound # sound è nil quando la def viene chiamata come stop. # scriviamo return perché non è necessario stoppare un se. if (@last_chick ||= 0) >= 4+rand(6) # evita di riprodurre ogni volta @last_chick = 0 pitchange = rand(20)-10 # pitch cambiato a caso sound.pitch += pitchange volchange = rand(1) == 0 ? rand(30)-10 : sound.volume*-1 # evitiamo ancora (volume 0) sound.volume += volchange sound.play # DOBBIAMO chiamare questo per riprodurre il suono else @last_chick += 1 end end def self.tremolo(sound) # questo esempio richiede Audio Pump Up - FMOD Ex return if !$imported || !$imported[:mikb89_apu_fmod] unless sound # fermiamo il suono return unless @trem_chan # il canale è nil??? FMod.bgs_stop(@trem_chan) # stop return # ci fermiamo end return if (@last_tremolo_volume ||= sound.volume) == sound.volume @last_tremolo_volume = sound.volume # ultimo volume # evitiamo di riprodurre lo stesso bgs allo stesso volume (questo è default # per bgm e bgs quando non sono specificate def) cv = APU::CURRENT_CHANNEL_VARIABLE # variabile canale da opzioni APU var = @trem_chan = $game_variables[cv] # canale corrente $game_variables[cv] = @trem_chan = APU::MAX_CHANNELS - 1 if var < 1 add_eff = true # tremolo già aggiunto? # se il canale corrente è 0 usiamo l'ultimo, quindi: sound.play # prima riproduciamo il BGS (vedi documentazione APU) for e in 0...FMod.bgs_DSP(@trem_chan) t = FModEx::FMOD_DSP_TYPES[FMod.bgs_getType(@trem_chan, e)] if t.downcase == "tremolo" # se tremolo esiste add_eff = false # non aggiungerlo break end end FMod::Audio.bgs_add_effect("tremolo", @trem_chan) if add_eff # aggiungiamo il DSP se necessario $game_variables[cv] = var if var < 1 # ripristiniamo il canale end end #Codename: ambisound ($imported ||= {})[:mikb89_ambisound] = true # Licenza: # - Puoi chiedermi di includere il supporto per altri script, a patto che usino # il $imported[script] = true; # - Puoi modificare e anche ripostare i miei script, dopo una mia risposta. Per # ripostarli, comunque, devi aver fatto pesanti modifiche o porting, non puoi # fare un post con lo script così com'è; # - Puoi usare i miei script per fare quel che vuoi, da giochi gratis a liberi # a commerciali. Apprezzerei comunque essere messo al corrente di quello che # stai creando; # - Devi creditarmi, se usi questo script o parte di esso. class Game_Event #class Game_Event#def get_audio(spn) def get_audio(spn) audio_eff = (spn[1] == "" || spn[2] <= 0) ? nil : case spn[0] when "BGM"; RPG::BGM.new(spn[1], spn[2], spn[3]) when "BGS"; RPG::BGS.new(spn[1], spn[2], spn[3]) when "ME"; RPG::ME.new(spn[1], spn[2], spn[3]) when "SE"; RPG::SE.new(spn[1], spn[2], spn[3]) end end alias_method(:clear_page_settings_b4_ambisound, :clear_page_settings) unless method_defined?(:clear_page_settings_b4_ambisound) #class Game_Event#def clear_page_settings() <- aliased def clear_page_settings clear_page_settings_b4_ambisound @sound_type = "" @last_volume = 0 end alias_method(:setup_page_settings_b4_ambisound, :setup_page_settings) unless method_defined?(:setup_page_settings_b4_ambisound) #class Game_Event#def setup_page_settings() <- aliased def setup_page_settings setup_page_settings_b4_ambisound @sound_type = "" @last_volume = 0 unless empty? for par in @list if [408, 108].include?(par.code) && AMBISOUND::EFFECTS.has_key?(par.parameters[0]) @sound_type = par.parameters[0] end end end end alias_method(:updateGE_b4_ambisound, :update) unless method_defined?(:updateGE_b4_ambisound) #class Game_Event#def update() <- aliased def update updateGE_b4_ambisound if (@sdelay ||= AMBISOUND::DELAY) == 0 @sdelay = nil var = nil if @sound_type != "" xv = $game_map.adjust_x(@real_x) - $game_map.adjust_x($game_player.real_x) yv = $game_map.adjust_y(@real_y) - $game_map.adjust_y($game_player.real_y) v = Math.hypot(xv, yv) if v <= AMBISOUND::EFFECTS[@sound_type][4] if @ae_playing spn = AMBISOUND::EFFECTS[@sound_type][0..3] spn[2] *= 1 - v/AMBISOUND::EFFECTS[@sound_type][4] met = AMBISOUND::EFFECTS[@sound_type][6] if @last_volume != spn[2] || met @last_volume = spn[2] if spn[2] >= AMBISOUND::EFFECTS[@sound_type][5] at = get_audio(spn) # REQUIRE Audio Pump Up - FMOD Ex if $imported[:mikb89_apu_fmod] && AMBISOUND::SOUND_CHANNEL > 0 var = $game_variables[APU::CURRENT_CHANNEL_VARIABLE] $game_variables[APU::CURRENT_CHANNEL_VARIABLE] = AMBISOUND::SOUND_CHANNEL end # END REQUIRE if at != nil if met AMBISOUND.method(met).call(at) else at.play # REQUIRE Audio Pump Up - FMOD Ex if $imported[:mikb89_apu_fmod] && AMBISOUND::USE_PAN && $game_variables[APU::CURRENT_CHANNEL_VARIABLE] > 0 pan = 1.0 * case $game_player.direction when 2; -xv; when 8; xv when 4; yv; when 6; -yv; else; 0; end pan /= AMBISOUND::EFFECTS[@sound_type][4] if pan != 0 case AMBISOUND::EFFECTS[@sound_type][0] when "BGM"; FMod.bgm_set_pan(pan, $game_variables[APU::CURRENT_CHANNEL_VARIABLE]) when "BGS"; FMod.bgs_set_pan(pan, $game_variables[APU::CURRENT_CHANNEL_VARIABLE]) when "ME"; FMod.me_set_pan(pan, $game_variables[APU::CURRENT_CHANNEL_VARIABLE]) when "SE"; FMod.se_set_pan(pan, $game_variables[APU::CURRENT_CHANNEL_VARIABLE], 0) end end end # END REQUIRE end end # REQUIRE Audio Pump Up - FMOD Ex $game_variables[APU::CURRENT_CHANNEL_VARIABLE] = var if var != nil # END REQUIRE end end else if @audiowait @audiowait -= 1 @ae_playing = !(@audiowait = false) if @audiowait == 0 else at = get_audio(AMBISOUND::EFFECTS[@sound_type]) # REQUIRE Audio Pump Up - FMOD Ex if $imported[:mikb89_apu_fmod] && AMBISOUND::SOUND_CHANNEL > 0 var = $game_variables[APU::CURRENT_CHANNEL_VARIABLE] $game_variables[APU::CURRENT_CHANNEL_VARIABLE] = AMBISOUND::SOUND_CHANNEL end # END REQUIRE if var != nil # REQUIRE Audio Pump Up - FMOD Ex FMod::Audio.bgm_fade(20*AMBISOUND::DELAY, AMBISOUND::SOUND_CHANNEL) if at.class == RPG::BGM FMod::Audio.bgs_fade(20*AMBISOUND::DELAY, AMBISOUND::SOUND_CHANNEL) if at.class == RPG::BGS # END REQUIRE else @ex_audio = at.class.last if [RPG::BGM, RPG::BGS].include?(at.class) end if @ex_audio != nil @ex_audio.class.fade(40*AMBISOUND::DELAY) @audiowait = 4 else @ae_playing = true end # REQUIRE Audio Pump Up - FMOD Ex $game_variables[APU::CURRENT_CHANNEL_VARIABLE] = var if var != nil # END REQUIRE end end else @ae_playing = false met = AMBISOUND::EFFECTS[@sound_type][6] # REQUIRE Audio Pump Up - FMOD Ex if $imported[:mikb89_apu_fmod] && AMBISOUND::SOUND_CHANNEL > 0 var = $game_variables[APU::CURRENT_CHANNEL_VARIABLE] $game_variables[APU::CURRENT_CHANNEL_VARIABLE] = AMBISOUND::SOUND_CHANNEL end # END REQUIRE if @ex_audio @ex_audio.replay if [RPG::BGM, RPG::BGS, RPG::ME].include?(@ex_audio.class) @ex_audio = nil AMBISOUND.method(met).call(nil) if met else AMBISOUND.method(met).call(nil) if met if !met && var != nil t = AMBISOUND::EFFECTS[@sound_type][0] # REQUIRE Audio Pump Up - FMOD Ex FMod::Audio.bgm_fade(20*AMBISOUND::DELAY, AMBISOUND::SOUND_CHANNEL) if t.upcase == "BGM" FMod::Audio.bgs_fade(20*AMBISOUND::DELAY, AMBISOUND::SOUND_CHANNEL) if t.upcase == "BGS" # END REQUIRE end end # REQUIRE Audio Pump Up - FMOD Ex $game_variables[APU::CURRENT_CHANNEL_VARIABLE] = var if var != nil # END REQUIRE end elsif @ae_playing @ae_playing = false # REQUIRE Audio Pump Up - FMOD Ex if $imported[:mikb89_apu_fmod] && AMBISOUND::SOUND_CHANNEL > 0 var = $game_variables[APU::CURRENT_CHANNEL_VARIABLE] $game_variables[APU::CURRENT_CHANNEL_VARIABLE] = AMBISOUND::SOUND_CHANNEL end # END REQUIRE if @ex_audio @ex_audio.replay if [RPG::BGM, RPG::BGS, RPG::ME].include?(@ex_audio.class) @ex_audio = nil end # REQUIRE Audio Pump Up - FMOD Ex $game_variables[APU::CURRENT_CHANNEL_VARIABLE] = var if var != nil # END REQUIRE end else @sdelay -= 1 end end end
Visibile anche su Pastebin
Bugs e Conflitti Noti
N/A
Altri Dettagli
Consiglio di usarlo in combinazione con quest'altro script.
Modificato da mikb89, 18 June 2012 - 18:54 PM.