PDA

View Full Version : [Essentials tutorial] A better way to change battle music for AI's last Pokémon


zingzags
August 13th, 2012, 05:37 PM
Based on this TUT:
http://pokemonessentials.wikia.com/wiki/Tutorial:Last_sent_out_pokemon_BGM

I decided to make a better version so you do not have to put a switch each time for a gymleader.

First thing you want to do is name the event "SpecialTrainer",
then you have to replace this:

def pbSendOut(index,pokemon)
pbSetSeen(pokemon)
@peer.pbOnEnteringBattle(self,pokemon)
if pbIsOpposing?(index)
@scene.pbTrainerSendOut(index,pokemon)
else
@scene.pbSendOut(index,pokemon)
end
end

With this:

def pbSendOut(index,pokemon)
pbSetSeen(pokemon)
@peer.pbOnEnteringBattle(self,pokemon)
if pbIsOpposing?(index)
@scene.pbTrainerSendOut(index,pokemon)
if $game_switches[112]==true && pbPokemonCount(@party2)<2
pbBGMPlay("PokeCenter",100,100)
end
else
@scene.pbSendOut(index,pokemon)
end
end

Then in pokemonFeild

add this:

Events.onSpritesetCreate+=proc{|sender,e|
spriteset=e[0] # Spriteset being created
viewport=e[1] # Viewport used for tilemap and characters
map=spriteset.map # Map associated with the spriteset (not necessarily the current map).
for i in map.events.keys
if map.events[i].name=="SpecialTrainer"
$game_switches[112]=true
elsif map.events[i].name!="SpecialTrainer"
$game_switches[112]=false
end
end
}

under:

Events.onSpritesetCreate+=proc{|sender,e|
spriteset=e[0] # Spriteset being created
viewport=e[1] # Viewport used for tilemap and characters
map=spriteset.map # Map associated with the spriteset (not necessarily the current map).
for i in map.events.keys
if map.events[i].name=="OutdoorLight"
spriteset.addUserSprite(LightEffect_DayNight.new(map.events[i],map))
elsif map.events[i].name=="Light"
spriteset.addUserSprite(LightEffect_Basic.new(map.events[i],map))
end
end
spriteset.addUserSprite(Particle_Engine.new(viewport,map))
}

change:

def pbEndBattle(result)
@abortable=false
pbShowWindow(BLANK)
# Fade out all sprites
pbBGMFade(1.0)
pbFadeOutAndHide(@sprites)
pbDisposeSprites
end

to:

def pbEndBattle(result)
@abortable=false
pbShowWindow(BLANK)
# Fade out all sprites
pbBGMFade(1.0)
pbFadeOutAndHide(@sprites)
pbDisposeSprites
$game_switches[112]=false
end

And done, you can change the switch, and music to what ever you want.