mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-09 14:14:59 +00:00
Split PokeBattle_Trainer into PlayerTrainer and NPCTrainer
This commit is contained in:
@@ -208,12 +208,12 @@ Events.onStartBattle += proc { |_sender|
|
||||
}
|
||||
|
||||
def pbCanDoubleBattle?
|
||||
return $PokemonGlobal.partner || $Trainer.ablePokemonCount>=2
|
||||
return $PokemonGlobal.partner || $Trainer.able_pokemon_count >= 2
|
||||
end
|
||||
|
||||
def pbCanTripleBattle?
|
||||
return true if $Trainer.ablePokemonCount>=3
|
||||
return $PokemonGlobal.partner && $Trainer.ablePokemonCount>=2
|
||||
return true if $Trainer.able_pokemon_count >= 3
|
||||
return $PokemonGlobal.partner && $Trainer.able_pokemon_count >= 2
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
@@ -223,8 +223,8 @@ def pbWildBattleCore(*args)
|
||||
outcomeVar = $PokemonTemp.battleRules["outcomeVar"] || 1
|
||||
canLose = $PokemonTemp.battleRules["canLose"] || false
|
||||
# Skip battle if the player has no able Pokémon, or if holding Ctrl in Debug mode
|
||||
if $Trainer.ablePokemonCount==0 || ($DEBUG && Input.press?(Input::CTRL))
|
||||
pbMessage(_INTL("SKIPPING BATTLE...")) if $Trainer.pokemonCount>0
|
||||
if $Trainer.able_pokemon_count == 0 || ($DEBUG && Input.press?(Input::CTRL))
|
||||
pbMessage(_INTL("SKIPPING BATTLE...")) if $Trainer.pokemon_count > 0
|
||||
pbSet(outcomeVar,1) # Treat it as a win
|
||||
$PokemonTemp.clearBattleRules
|
||||
$PokemonGlobal.nextBattleBGM = nil
|
||||
@@ -266,7 +266,7 @@ def pbWildBattleCore(*args)
|
||||
room_for_partner = true
|
||||
end
|
||||
if $PokemonGlobal.partner && !$PokemonTemp.battleRules["noPartner"] && room_for_partner
|
||||
ally = PokeBattle_Trainer.new($PokemonGlobal.partner[1],$PokemonGlobal.partner[0])
|
||||
ally = NPCTrainer.new($PokemonGlobal.partner[1],$PokemonGlobal.partner[0])
|
||||
ally.id = $PokemonGlobal.partner[2]
|
||||
ally.party = $PokemonGlobal.partner[3]
|
||||
playerTrainers.push(ally)
|
||||
@@ -360,16 +360,16 @@ def pbTrainerBattleCore(*args)
|
||||
outcomeVar = $PokemonTemp.battleRules["outcomeVar"] || 1
|
||||
canLose = $PokemonTemp.battleRules["canLose"] || false
|
||||
# Skip battle if the player has no able Pokémon, or if holding Ctrl in Debug mode
|
||||
if $Trainer.ablePokemonCount==0 || ($DEBUG && Input.press?(Input::CTRL))
|
||||
if $Trainer.able_pokemon_count == 0 || ($DEBUG && Input.press?(Input::CTRL))
|
||||
pbMessage(_INTL("SKIPPING BATTLE...")) if $DEBUG
|
||||
pbMessage(_INTL("AFTER WINNING...")) if $DEBUG && $Trainer.ablePokemonCount>0
|
||||
pbSet(outcomeVar,($Trainer.ablePokemonCount==0) ? 0 : 1) # Treat it as undecided/a win
|
||||
pbMessage(_INTL("AFTER WINNING...")) if $DEBUG && $Trainer.able_pokemon_count > 0
|
||||
pbSet(outcomeVar,($Trainer.able_pokemon_count == 0) ? 0 : 1) # Treat it as undecided/a win
|
||||
$PokemonTemp.clearBattleRules
|
||||
$PokemonGlobal.nextBattleBGM = nil
|
||||
$PokemonGlobal.nextBattleME = nil
|
||||
$PokemonGlobal.nextBattleCaptureME = nil
|
||||
$PokemonGlobal.nextBattleBack = nil
|
||||
return ($Trainer.ablePokemonCount==0) ? 0 : 1 # Treat it as undecided/a win
|
||||
return ($Trainer.able_pokemon_count == 0) ? 0 : 1 # Treat it as undecided/a win
|
||||
end
|
||||
# Record information about party Pokémon to be used at the end of battle (e.g.
|
||||
# comparing levels for an evolution check)
|
||||
@@ -382,24 +382,23 @@ def pbTrainerBattleCore(*args)
|
||||
foePartyStarts = []
|
||||
for arg in args
|
||||
raise _INTL("Expected an array of trainer data, got {1}.",arg) if !arg.is_a?(Array)
|
||||
if arg[0].is_a?(PokeBattle_Trainer)
|
||||
# [trainer object, party, end speech, items]
|
||||
foeTrainers.push(arg[0])
|
||||
if arg.is_a?(NPCTrainer)
|
||||
foeTrainers.push(arg)
|
||||
foePartyStarts.push(foeParty.length)
|
||||
arg[1].each { |pkmn| foeParty.push(pkmn) }
|
||||
foeEndSpeeches.push(arg[2])
|
||||
foeItems.push(arg[3])
|
||||
arg.party.each { |pkmn| foeParty.push(pkmn) }
|
||||
foeEndSpeeches.push(arg.lose_text)
|
||||
foeItems.push(arg.items)
|
||||
else
|
||||
# [trainer type, trainer name, ID, speech (optional)]
|
||||
trainer = pbLoadTrainer(arg[0],arg[1],arg[2])
|
||||
pbMissingTrainer(arg[0],arg[1],arg[2]) if !trainer
|
||||
return 0 if !trainer
|
||||
Events.onTrainerPartyLoad.trigger(nil,trainer)
|
||||
foeTrainers.push(trainer[0])
|
||||
foeTrainers.push(trainer)
|
||||
foePartyStarts.push(foeParty.length)
|
||||
trainer[2].each { |pkmn| foeParty.push(pkmn) }
|
||||
foeEndSpeeches.push(arg[3] || trainer[3])
|
||||
foeItems.push(trainer[1])
|
||||
trainer.party.each { |pkmn| foeParty.push(pkmn) }
|
||||
foeEndSpeeches.push(arg[3] || trainer.lose_text)
|
||||
foeItems.push(trainer.items)
|
||||
end
|
||||
end
|
||||
# Calculate who the player trainer(s) and their party are
|
||||
@@ -412,7 +411,7 @@ def pbTrainerBattleCore(*args)
|
||||
room_for_partner = true
|
||||
end
|
||||
if $PokemonGlobal.partner && !$PokemonTemp.battleRules["noPartner"] && room_for_partner
|
||||
ally = PokeBattle_Trainer.new($PokemonGlobal.partner[1],$PokemonGlobal.partner[0])
|
||||
ally = NPCTrainer.new($PokemonGlobal.partner[1], $PokemonGlobal.partner[0])
|
||||
ally.id = $PokemonGlobal.partner[2]
|
||||
ally.party = $PokemonGlobal.partner[3]
|
||||
playerTrainers.push(ally)
|
||||
@@ -469,8 +468,8 @@ def pbTrainerBattle(trainerID, trainerName, endSpeech=nil,
|
||||
# then trigger and cause the battle to happen against this first trainer and
|
||||
# themselves.
|
||||
if !$PokemonTemp.waitingTrainer && pbMapInterpreterRunning? &&
|
||||
($Trainer.ablePokemonCount>1 ||
|
||||
($Trainer.ablePokemonCount>0 && $PokemonGlobal.partner))
|
||||
($Trainer.able_pokemon_count > 1 ||
|
||||
($Trainer.able_pokemon_count > 0 && $PokemonGlobal.partner))
|
||||
thisEvent = pbMapInterpreter.get_character(0)
|
||||
# Find all other triggered trainer events
|
||||
triggeredEvents = $game_player.pbTriggeredTrainerEvents([2],false)
|
||||
@@ -488,8 +487,9 @@ def pbTrainerBattle(trainerID, trainerName, endSpeech=nil,
|
||||
# If there is exactly 1 other triggered trainer event, and this trainer has
|
||||
# 6 or fewer Pokémon, record this trainer for a double battle caused by the
|
||||
# other triggered trainer event
|
||||
if otherEvent.length==1 && trainer[2].length<=6
|
||||
$PokemonTemp.waitingTrainer = [trainer,endSpeech || trainer[3],thisEvent.id]
|
||||
if otherEvent.length == 1 && trainer.party.length <= MAX_PARTY_SIZE
|
||||
trainer.lose_text = endSpeech if endSpeech && !endSpeech.empty?
|
||||
$PokemonTemp.waitingTrainer = [trainer, thisEvent.id]
|
||||
return false
|
||||
end
|
||||
end
|
||||
@@ -500,8 +500,7 @@ def pbTrainerBattle(trainerID, trainerName, endSpeech=nil,
|
||||
# Perform the battle
|
||||
if $PokemonTemp.waitingTrainer
|
||||
waitingTrainer = $PokemonTemp.waitingTrainer
|
||||
decision = pbTrainerBattleCore(
|
||||
[waitingTrainer[0][0],waitingTrainer[0][2],waitingTrainer[1],waitingTrainer[0][1]],
|
||||
decision = pbTrainerBattleCore($PokemonTemp.waitingTrainer,
|
||||
[trainerID,trainerName,trainerPartyID,endSpeech]
|
||||
)
|
||||
else
|
||||
@@ -509,7 +508,7 @@ def pbTrainerBattle(trainerID, trainerName, endSpeech=nil,
|
||||
end
|
||||
# Finish off the recorded waiting trainer, because they have now been battled
|
||||
if decision==1 && $PokemonTemp.waitingTrainer # Win
|
||||
pbMapInterpreter.pbSetSelfSwitch($PokemonTemp.waitingTrainer[2],"A",true)
|
||||
pbMapInterpreter.pbSetSelfSwitch($PokemonTemp.waitingTrainer[1], "A", true)
|
||||
end
|
||||
$PokemonTemp.waitingTrainer = nil
|
||||
# Return true if the player won the battle, and false if any other result
|
||||
@@ -560,7 +559,7 @@ def pbAfterBattle(decision,canLose)
|
||||
pkmn.makeUnprimal
|
||||
end
|
||||
if $PokemonGlobal.partner
|
||||
pbHealAll
|
||||
$Trainer.heal_party
|
||||
$PokemonGlobal.partner[3].each do |pkmn|
|
||||
pkmn.heal
|
||||
pkmn.makeUnmega
|
||||
@@ -588,7 +587,7 @@ Events.onEndBattle += proc { |_sender,e|
|
||||
end
|
||||
case decision
|
||||
when 1, 4 # Win, capture
|
||||
$Trainer.pokemonParty.each do |pkmn|
|
||||
$Trainer.pokemon_party.each do |pkmn|
|
||||
pbPickup(pkmn)
|
||||
pbHoneyGather(pkmn)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user