def pbMissingTrainer(trainerid, trainername, trainerparty)
traineridstring="#{trainerid}"
traineridstring=getConstantName(PBTrainers,trainerid) rescue nil
if $DEBUG
Kernel.pbMessage(_INTL("Can't find trainer ({1}, {2}) in Trainer data file.\1",traineridstring,trainername))
if Kernel.pbConfirmMessage(_INTL("Would you like to add this Trainer now?"))
pbNewTrainer(trainerid,trainername,trainerparty)
end
else
raise _INTL("Can't find trainer ({1}, {2})",traineridstring,trainername)
end
end
def pbDoubleTrainerBattle(
trainerid1, trainername1, trainerparty1, endspeech1,
trainerid2, trainername2, trainerparty2, endspeech2,
canlose=false
)
trainer1=pbLoadTrainer(trainerid1,trainername1,trainerparty1)
if !trainer1
pbMissingTrainer(trainerid1,trainername1,trainerparty1)
end
trainer2=pbLoadTrainer(trainerid2,trainername2,trainerparty2)
if !trainer2
pbMissingTrainer(trainerid2,trainername2,trainerparty2)
end
if !trainer1 || !trainer2
return false
end
currentlevels=[]
for i in $Trainer.party
currentlevels.push(i.level)
end
if $PokemonMap.partner
othertrainer=PokeBattle_Trainer.new(
$PokemonMap.partner[1],
$PokemonMap.partner[0])
othertrainer.id=$PokemonMap.partner[2]
othertrainer.party=$PokemonMap.partner[3]
playerparty=[]
for i in othertrainer.party; i.heal; end
for i in 0...$Trainer.party.length
playerparty[i]=$Trainer.party[i]
end
for i in 0...othertrainer.party.length
playerparty[6+i]=othertrainer.party[i]
end
fullparty1=true
playertrainer=[$Trainer,othertrainer]
doublebattle=true
else
playerparty=$Trainer.party
playertrainer=$Trainer
fullparty1=false
end
combinedParty=[]
combinedParty2=[]
if trainer1[2].length>3
raise _INTL("Opponent 1's party has more than three Pokemon, which is not allowed")
end
if trainer2[2].length>3
raise _INTL("Opponent 2's party has more than three Pokemon, which is not allowed")
end
for i in 0...trainer1[2].length
combinedParty[i]=trainer1[2][i]
end
for i in 0...trainer2[2].length
combinedParty[3+i]=trainer2[2][i]
end
for i in 0...6
combinedParty2[i]=combinedParty[i].clone if combinedParty[i]
end
scene=PokeBattle_Scene.new
battle=PokeBattle_Battle.new(scene,
playerparty,
combinedParty,
playertrainer,
[trainer1[0],trainer2[0]]
)
trainerbgm=pbGetTrainerBattleBGM([trainer1[0],trainer2[0]])
battle.fullparty1=fullparty1
battle.doublebattle=true
battle.endspeech=endspeech1
battle.endspeech2=endspeech2
battle.items=[trainer1[1],trainer2[1]]
if Input.press?(Input::CTRL) && $DEBUG
Kernel.pbMessage(_INTL("SKIPPING BATTLE..."))
Kernel.pbMessage(_INTL("AFTER LOSING..."))
Kernel.pbMessage(battle.endspeech)
Kernel.pbMessage(battle.endspeech2) if battle.endspeech2
return true
end
battle.internalbattle=true
pbPrepareBattle(battle)
playingBGS=$game_system.getPlayingBGS
playingBGM=$game_system.getPlayingBGM
$game_system.bgm_pause
$game_system.bgs_pause
restorebgm=true
decision=0
pbBattleAnimation(trainerbgm) {
pbSceneStandby {
decision=battle.pbStartBattle
}
if $PokemonMap.partner
for i in $Trainer.party; i.heal; end
end
if decision==2
if canlose
for i in $Trainer.party; i.heal; end
for i in 0...10
Graphics.update
end
else
$game_system.bgm_unpause
$game_system.bgs_unpause
Kernel.pbStartOver
restorebgm=false
end
else
pbEvolutionCheck(currentlevels)
if decision==1
for pkmn in $Trainer.party
Kernel.pbPickup(pkmn)
end
end
end
}
if restorebgm
$game_system.bgm_resume(playingBGM)
$game_system.bgs_resume(playingBGS)
end
$PokemonGlobal.nextBattleBGM=nil
$PokemonGlobal.nextBattleME=nil
$PokemonEncounters.clearStepCount
Input.update
return (decision==1)
end