def pbDoubleTrainerBattle(trainerid1, trainername1, trainerparty1, endspeech1,
trainerid2, trainername2, trainerparty2, endspeech2,
canlose=false,variable=nil,skybattle=false,inverse=false[COLOR="red"],noItems=false[/COLOR])
# Sky battle eligibility for player
if skybattle
count=0
for poke in $Trainer.party
count+=1 if pbCanSkyBattle?(poke)
end
if count==0
Kernel.pbMessage(_INTL("You don't have any eligible pokemon for a sky battle"))
return false
end
end
trainer1=pbLoadTrainer(trainerid1,trainername1,trainerparty1)
Events.onTrainerPartyLoad.trigger(nil,trainer1)
if !trainer1
pbMissingTrainer(trainerid1,trainername1,trainerparty1)
end
trainer2=pbLoadTrainer(trainerid2,trainername2,trainerparty2)
Events.onTrainerPartyLoad.trigger(nil,trainer2)
if !trainer2
pbMissingTrainer(trainerid2,trainername2,trainerparty2)
end
if !trainer1 || !trainer2
return false
end
if $PokemonGlobal.partner
othertrainer=PokeBattle_Trainer.new($PokemonGlobal.partner[1],
$PokemonGlobal.partner[0])
othertrainer.id=$PokemonGlobal.partner[2]
othertrainer.party=$PokemonGlobal.partner[3]
playerparty=[]
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]
else
playerparty=$Trainer.party
playertrainer=$Trainer
fullparty1=false
end
combinedParty=[]
for i in 0...trainer1[2].length
combinedParty[i]=trainer1[2][i]
end
for i in 0...trainer2[2].length
combinedParty[6+i]=trainer2[2][i]
end
#Sky battle eligibility for opponent
if skybattle
count=0
for poke in combinedParty
count+=1 if pbCanSkyBattle?(poke)
end
if count==0
Kernel.pbMessage(_INTL("The opponents don't have any eligible pokemon for a sky battle"))
return false
end
end
scene=pbNewBattleScene
battle=PokeBattle_Battle.new(scene,
playerparty,combinedParty,playertrainer,[trainer1[0],trainer2[0]],skybattle,inverse[COLOR="red"],noItems[/COLOR])
trainerbgm=pbGetTrainerBattleBGM([trainer1[0],trainer2[0]])
battle.fullparty1=fullparty1
battle.fullparty2=true
battle.doublebattle=battle.pbDoubleBattleAllowed?()
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 && battle.endspeech2!=""
return true
end
Events.onStartBattle.trigger(nil,nil)
battle.internalbattle=true
pbPrepareBattle(battle)
restorebgm=true
decision=0
pbBattleAnimation(trainerbgm) {
pbSceneStandby {
decision=battle.pbStartBattle(canlose)
}
for i in $Trainer.party; (i.makeUnmega rescue nil); end
if $PokemonGlobal.partner
pbHealAll
for i in $PokemonGlobal.partner[3]
i.heal
i.makeUnmega rescue nil
end
end
if decision==2 || decision==5
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
end
end
Events.onEndBattle.trigger(nil,decision)
}
Input.update
pbSet(variable,decision)
return (decision==1)
end
def pbTrainerBattle(trainerid,trainername,endspeech,
doublebattle=false,trainerparty=0,canlose=false,variable=nil,
skybattle=false,inverse=false[COLOR="red"],noItems=false[/COLOR])
if $Trainer.pokemonCount==0
Kernel.pbMessage(_INTL("SKIPPING BATTLE...")) if $DEBUG
return false
end
# Sky battle eligibility for player
if skybattle
count=0
for poke in $Trainer.party
count+=1 if pbCanSkyBattle?(poke)
end
if count==0
Kernel.pbMessage(_INTL("You don't have any eligible pokemon for a sky battle"))
return false
end
end
if !$PokemonTemp.waitingTrainer && $Trainer.ablePokemonCount>1 &&
pbMapInterpreterRunning?
thisEvent=pbMapInterpreter.get_character(0)
triggeredEvents=$game_player.pbTriggeredTrainerEvents([2],false)
otherEvent=[]
for i in triggeredEvents
if i.id!=thisEvent.id && !$game_self_switches[[$game_map.map_id,i.id,"A"]]
otherEvent.push(i)
end
end
if otherEvent.length==1
trainer=pbLoadTrainer(trainerid,trainername,trainerparty)
Events.onTrainerPartyLoad.trigger(nil,trainer)
if !trainer
pbMissingTrainer(trainerid,trainername,trainerparty)
return false
end
if trainer[2].length<=6 # 3
$PokemonTemp.waitingTrainer=[trainer,thisEvent.id,endspeech]
return false
end
end
end
trainer=pbLoadTrainer(trainerid,trainername,trainerparty)
Events.onTrainerPartyLoad.trigger(nil,trainer)
if !trainer
pbMissingTrainer(trainerid,trainername,trainerparty)
return false
end
if $PokemonGlobal.partner && ($PokemonTemp.waitingTrainer || doublebattle)
othertrainer=PokeBattle_Trainer.new(
$PokemonGlobal.partner[1],$PokemonGlobal.partner[0])
othertrainer.id=$PokemonGlobal.partner[2]
othertrainer.party=$PokemonGlobal.partner[3]
playerparty=[]
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
#Sky battle eligibility for opponent
if skybattle
if $PokemonTemp.waitingTrainer
count=0
for poke in $PokemonTemp.waitingTrainer[0][2]
count+=1 if pbCanSkyBattle?(poke)
end
end
if count==0
Kernel.pbMessage(_INTL("Opponent 1 doesn't have any eligible pokemon for a sky battle"))
return false
end
count=0
for poke in trainer[2]
count+=1 if pbCanSkyBattle?(poke)
end
if count==0
Kernel.pbMessage(_INTL("Opponent 2 doesn't have any eligible pokemon for a sky battle"))
return false
end
end
if $PokemonTemp.waitingTrainer
combinedParty=[]
fullparty2=false
if false
if $PokemonTemp.waitingTrainer[0][2].length>3
raise _INTL("Opponent 1's party has more than three Pokémon, which is not allowed")
end
if trainer[2].length>3
raise _INTL("Opponent 2's party has more than three Pokémon, which is not allowed")
end
elsif $PokemonTemp.waitingTrainer[0][2].length>3 || trainer[2].length>3
for i in 0...$PokemonTemp.waitingTrainer[0][2].length
combinedParty[i]=$PokemonTemp.waitingTrainer[0][2][i]
end
for i in 0...trainer[2].length
combinedParty[6+i]=trainer[2][i]
end
fullparty2=true
else
for i in 0...$PokemonTemp.waitingTrainer[0][2].length
combinedParty[i]=$PokemonTemp.waitingTrainer[0][2][i]
end
for i in 0...trainer[2].length
combinedParty[3+i]=trainer[2][i]
end
fullparty2=false
end
scene=pbNewBattleScene
battle=PokeBattle_Battle.new(scene,playerparty,combinedParty,playertrainer,
[$PokemonTemp.waitingTrainer[0][0],trainer[0]],skybattle,inverse[COLOR="red"],noItems[/COLOR])
trainerbgm=pbGetTrainerBattleBGM(
[$PokemonTemp.waitingTrainer[0][0],trainer[0]])
battle.fullparty1=fullparty1
battle.fullparty2=fullparty2
battle.doublebattle=battle.pbDoubleBattleAllowed?()
battle.endspeech=$PokemonTemp.waitingTrainer[2]
battle.endspeech2=endspeech
battle.items=[$PokemonTemp.waitingTrainer[0][1],trainer[1]]
else
scene=pbNewBattleScene
battle=PokeBattle_Battle.new(scene,playerparty,trainer[2],playertrainer,trainer[0],skybattle,inverse[COLOR="red"],noItems[/COLOR])
battle.fullparty1=fullparty1
battle.doublebattle=doublebattle ? battle.pbDoubleBattleAllowed?() : false
battle.endspeech=endspeech
battle.items=trainer[1]
trainerbgm=pbGetTrainerBattleBGM(trainer[0])
end
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
if $PokemonTemp.waitingTrainer
pbMapInterpreter.pbSetSelfSwitch($PokemonTemp.waitingTrainer[1],"A",true)
$PokemonTemp.waitingTrainer=nil
end
return true
end
Events.onStartBattle.trigger(nil,nil)
battle.internalbattle=true
pbPrepareBattle(battle)
restorebgm=true
decision=0
Audio.me_stop
pbBattleAnimation(trainerbgm,trainer[0].trainertype,trainer[0].name) {
pbSceneStandby {
decision=battle.pbStartBattle(canlose)
}
for i in $Trainer.party; (i.makeUnmega rescue nil); end
if $PokemonGlobal.partner
pbHealAll
for i in $PokemonGlobal.partner[3]
i.heal
i.makeUnmega rescue nil
i.makeUnprimal rescue nil
end
end
if decision==2 || decision==5
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
end
else
Events.onEndBattle.trigger(nil,decision)
if decision==1 || decision==6
$game_variables[26]=decision
if $PokemonTemp.waitingTrainer
pbMapInterpreter.pbSetSelfSwitch($PokemonTemp.waitingTrainer[1],"A",true)
end
end
end
}
Input.update
pbSet(variable,decision)
$PokemonTemp.waitingTrainer=nil
return decision==1
end