Advertisement
TechSkylander1518

Rival Starter

Apr 21st, 2022
1,432
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.33 KB | None | 0 0
  1. module Settings
  2.   #The game variable that stores the player's choice of starter
  3.   STARTER_CHOICE = 7
  4.   #The starters used by the rival, depending on the variable.
  5.   #Remember, it starts at 0.
  6.   RIVAL_STARTERS = [:CHARMANDER,:BULBASAUR,:SQUIRTLE]
  7.   #The starter uses pbBalancedLevel to get its level.
  8.   #pbBalancedLevel is the average level of the party +2.
  9.   #LEVEL_BOOST will be added to increase it further.
  10.   LEVEL_BOOST = 50
  11. end
  12.  
  13. def pbRivalStarter(pkmn)
  14.   GameData::Stat.each_main do |s|
  15.     pkmn.iv[s.id] = 31
  16.   end
  17.   case $game_variables[Settings::STARTER_CHOICE]
  18.     when 0
  19.       pkmn.item = :CHARCOAL if pkmn.level > 30
  20.     when 1
  21.       pkmn.item = :MYSTICWATER if pkmn.level > 30
  22.     when 2
  23.       pkmn.item = :MIRACLESEED if pkmn.level > 30
  24.   end
  25. end
  26.  
  27. Events.onTrainerPartyLoad += proc { |_sender, trainer|
  28. if trainer
  29.   party = trainer[0].party
  30.   if party.length < 6
  31.     species = Settings::RIVAL_STARTERS[$game_variables[Settings::STARTER_CHOICE]]
  32.     level = pbBalancedLevel(party) + Settings::LEVEL_BOOST
  33.     pkmn = Pokemon.new(species,level)
  34.     loop do
  35.       newspecies = pkmn.check_evolution_on_level_up
  36.       if newspecies
  37.         pkmn.species = newspecies
  38.       else
  39.         break
  40.       end
  41.     end
  42.     pkmn.reset_moves
  43.     pkmn.calc_stats
  44.     pbRivalStarter(pkmn)
  45.     party.push(pkmn)
  46.   end
  47. end
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement