GO_FIGHT_YOURSELF = 69 # Change this!
module GameData
class Trainer
alias old_to_trainer to_trainer
def to_trainer
return to_trainer_mirror if $game_switches[GO_FIGHT_YOURSELF]
return old_to_trainer
end
def to_trainer_mirror
# Determine trainer's name
tr_name = self.name
Settings::RIVAL_NAMES.each do |rival|
next if rival[0] != @trainer_type || !$game_variables[rival[1]].is_a?(String)
tr_name = $game_variables[rival[1]]
break
end
# Create trainer object
trainer = NPCTrainer.new(tr_name, @trainer_type, @version)
trainer.id = $player.make_foreign_ID
trainer.items = @items.clone
trainer.lose_text = self.lose_text
for p in $player.party
level = p.level + 10
pkmn = Pokemon.new(p.species, level, trainer, false)
pkmn.form_simple = p.form_simple
pkmn.item = pkmn.item
pkmn.moves = p.moves.clone
pkmn.ability = p.ability
pkmn.gender = p.gender
pkmn.shiny = p.shiny?
pkmn.super_shiny = p.super_shiny?
pkmn.nature = p.nature
pkmn.iv = p.iv.clone
pkmn.ev = p.ev.clone
pkmn.happiness = p.happiness
pkmn.name = p.name
# NOTE: Not included shadow here!
pkmn.poke_ball = p.poke_ball
pkmn.calc_stats
end
return trainer
end
end
end