Vendily

separate egggen manual

Feb 13th, 2018
268
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def pbManualGenerateEgg(poke0,poke1,gettext=nil)
  2.   if $Trainer.party.length>=6
  3.     raise _INTL("Can't store the egg")
  4.   end
  5.   pokemon0=poke0
  6.   pokemon1=poke1
  7.   mother=nil
  8.   father=nil
  9.   babyspecies=0
  10.   ditto0=pbIsDitto?(pokemon0)
  11.   ditto1=pbIsDitto?(pokemon1)
  12.   if pokemon0.isFemale? || ditto0
  13.     babyspecies=(ditto0) ? pokemon1.species : pokemon0.species
  14.     mother=pokemon0
  15.     father=pokemon1
  16.   else
  17.     babyspecies=(ditto1) ? pokemon0.species : pokemon1.species
  18.     mother=pokemon1
  19.     father=pokemon0
  20.   end
  21.   babyspecies=pbGetBabySpecies(babyspecies,mother.item,father.item)
  22.   if isConst?(babyspecies,PBSpecies,:MANAPHY) && hasConst?(PBSpecies,:PHIONE)
  23.     babyspecies=getConst(PBSpecies,:PHIONE)
  24.   elsif (isConst?(babyspecies,PBSpecies,:NIDORANfE) && hasConst?(PBSpecies,:NIDORANmA)) ||
  25.         (isConst?(babyspecies,PBSpecies,:NIDORANmA) && hasConst?(PBSpecies,:NIDORANfE))
  26.     babyspecies=[getConst(PBSpecies,:NIDORANmA),
  27.                  getConst(PBSpecies,:NIDORANfE)][rand(2)]
  28.   elsif (isConst?(babyspecies,PBSpecies,:VOLBEAT) && hasConst?(PBSpecies,:ILLUMISE)) ||
  29.         (isConst?(babyspecies,PBSpecies,:ILLUMISE) && hasConst?(PBSpecies,:VOLBEAT))
  30.     babyspecies=[getConst(PBSpecies,:VOLBEAT),
  31.                  getConst(PBSpecies,:ILLUMISE)][rand(2)]
  32.   end
  33.   # Generate egg
  34.   egg=PokeBattle_Pokemon.new(babyspecies,EGGINITIALLEVEL,$Trainer)
  35.   # Randomise personal ID
  36.   pid=rand(65536)
  37.   pid|=(rand(65536)<<16)
  38.   egg.personalID=pid
  39.   # Inheriting form
  40.   if isConst?(babyspecies,PBSpecies,:BURMY) ||
  41.      isConst?(babyspecies,PBSpecies,:SHELLOS) ||
  42.      isConst?(babyspecies,PBSpecies,:BASCULIN) ||
  43.      isConst?(babyspecies,PBSpecies,:FLABEBE) ||
  44.      isConst?(babyspecies,PBSpecies,:PUMPKABOO) ||
  45.      isConst?(babyspecies,PBSpecies,:ORICORIO) ||
  46.      isConst?(babyspecies,PBSpecies,:MINIOR)
  47.     egg.form=mother.form
  48.   end
  49.   # Inheriting Moves
  50.   moves=[]
  51.   othermoves=[]
  52.   movefather=father; movemother=mother
  53.   if pbIsDitto?(movefather) && !mother.isFemale?
  54.     movefather=mother; movemother=father
  55.   end
  56.   # Initial Moves
  57.   initialmoves=egg.getMoveList
  58.   for k in initialmoves
  59.     if k[0]<=EGGINITIALLEVEL
  60.       moves.push(k[1])
  61.     else
  62.       othermoves.push(k[1]) if mother.hasMove?(k[1]) && father.hasMove?(k[1])
  63.     end
  64.   end
  65.   # Inheriting Natural Moves
  66.   for move in othermoves
  67.     moves.push(move)
  68.   end
  69.   # Inheriting Machine Moves
  70.   if !USENEWBATTLEMECHANICS
  71.     for i in 0...$ItemData.length
  72.       next if !$ItemData[i]
  73.       atk=$ItemData[i][ITEMMACHINE]
  74.       next if !atk || atk==0
  75.       if egg.isCompatibleWithMove?(atk)
  76.         moves.push(atk) if movefather.hasMove?(atk)
  77.       end
  78.     end
  79.   end
  80.   # Inheriting Egg Moves
  81.   if movefather.isMale?
  82.     pbRgssOpen("Data/eggEmerald.dat","rb"){|f|
  83.        f.pos=(egg.fSpecies-1)*8
  84.        offset=f.fgetdw
  85.        length=f.fgetdw
  86.        if length>0
  87.          f.pos=offset
  88.          i=0; loop do break unless i<length
  89.            atk=f.fgetw
  90.            moves.push(atk) if movefather.hasMove?(atk)
  91.            i+=1
  92.          end
  93.        end
  94.     }
  95.   end
  96.   if USENEWBATTLEMECHANICS
  97.     pbRgssOpen("Data/eggEmerald.dat","rb"){|f|
  98.        f.pos=(egg.fSpecies-1)*8
  99.        offset=f.fgetdw
  100.        length=f.fgetdw
  101.        if length>0
  102.          f.pos=offset
  103.          i=0; loop do break unless i<length
  104.            atk=f.fgetw
  105.            moves.push(atk) if movemother.hasMove?(atk)
  106.            i+=1
  107.          end
  108.        end
  109.     }
  110.   end
  111.   # Volt Tackle
  112.   lightball=false
  113.   if (isConst?(father.species,PBSpecies,:PIKACHU) ||
  114.       isConst?(father.species,PBSpecies,:RAICHU)) &&
  115.       isConst?(father.item,PBItems,:LIGHTBALL)
  116.     lightball=true
  117.   end
  118.   if (isConst?(mother.species,PBSpecies,:PIKACHU) ||
  119.       isConst?(mother.species,PBSpecies,:RAICHU)) &&
  120.       isConst?(mother.item,PBItems,:LIGHTBALL)
  121.     lightball=true
  122.   end
  123.   if lightball && isConst?(babyspecies,PBSpecies,:PICHU) &&
  124.      hasConst?(PBMoves,:VOLTTACKLE)
  125.     moves.push(getConst(PBMoves,:VOLTTACKLE))
  126.   end
  127.   moves|=[] # remove duplicates
  128.   # Assembling move list
  129.   finalmoves=[]
  130.   listend=moves.length-4
  131.   listend=0 if listend<0
  132.   j=0
  133.   for i in listend..listend+3
  134.     moveid=(i>=moves.length) ? 0 : moves[i]
  135.     finalmoves[j]=PBMove.new(moveid)
  136.     j+=1
  137.   end
  138.   # Inheriting Individual Values
  139.   ivs=[]
  140.   for i in 0...6
  141.     ivs[i]=rand(32)
  142.   end
  143.   ivinherit=[]
  144.   for i in 0...2
  145.     parent=[mother,father][i]
  146.     ivinherit[i]=PBStats::HP if isConst?(parent.item,PBItems,:POWERWEIGHT)
  147.     ivinherit[i]=PBStats::ATTACK if isConst?(parent.item,PBItems,:POWERBRACER)
  148.     ivinherit[i]=PBStats::DEFENSE if isConst?(parent.item,PBItems,:POWERBELT)
  149.     ivinherit[i]=PBStats::SPEED if isConst?(parent.item,PBItems,:POWERANKLET)
  150.     ivinherit[i]=PBStats::SPATK if isConst?(parent.item,PBItems,:POWERLENS)
  151.     ivinherit[i]=PBStats::SPDEF if isConst?(parent.item,PBItems,:POWERBAND)
  152.   end
  153.   num=0; r=rand(2)
  154.   for i in 0...2
  155.     if ivinherit[r]!=nil
  156.       parent=[mother,father][r]
  157.       ivs[ivinherit[r]]=parent.iv[ivinherit[r]]
  158.       num+=1
  159.       break
  160.     end
  161.     r=(r+1)%2
  162.   end
  163.   stats=[PBStats::HP,PBStats::ATTACK,PBStats::DEFENSE,
  164.          PBStats::SPEED,PBStats::SPATK,PBStats::SPDEF]
  165.   limit=(USENEWBATTLEMECHANICS && (isConst?(mother.item,PBItems,:DESTINYKNOT) ||
  166.          isConst?(father.item,PBItems,:DESTINYKNOT))) ? 5 : 3
  167.   loop do
  168.     freestats=[]
  169.     for i in stats
  170.       freestats.push(i) if !ivinherit.include?(i)
  171.     end
  172.     break if freestats.length==0
  173.     r=freestats[rand(freestats.length)]
  174.     parent=[mother,father][rand(2)]
  175.     ivs[r]=parent.iv[r]
  176.     ivinherit.push(r)
  177.     num+=1
  178.     break if num>=limit
  179.   end
  180.   # Inheriting nature
  181.   newnatures=[]
  182.   newnatures.push(mother.nature) if isConst?(mother.item,PBItems,:EVERSTONE)
  183.   newnatures.push(father.nature) if isConst?(father.item,PBItems,:EVERSTONE)
  184.   if newnatures.length>0
  185.     egg.setNature(newnatures[rand(newnatures.length)])
  186.   end
  187.   # Masuda method and Shiny Charm
  188.   shinyretries=0
  189.   shinyretries+=5 if father.language!=mother.language
  190.   shinyretries+=2 if hasConst?(PBItems,:SHINYCHARM) &&
  191.                      $PokemonBag.pbHasItem?(:SHINYCHARM)
  192.   if shinyretries>0
  193.     for i in 0...shinyretries
  194.       break if egg.isShiny?
  195.       egg.personalID=rand(65536)|(rand(65536)<<16)
  196.     end
  197.   end
  198.   # Inheriting ability from the mother
  199.   if (!ditto0 && !ditto1)
  200.     if mother.hasHiddenAbility?
  201.       egg.setAbility(mother.abilityIndex) if rand(10)<6
  202.     else
  203.       if rand(10)<8
  204.         egg.setAbility(mother.abilityIndex)
  205.       else
  206.         egg.setAbility((mother.abilityIndex+1)%2)
  207.       end
  208.     end
  209.   elsif ((!ditto0 && ditto1) || (!ditto1 && ditto0)) && USENEWBATTLEMECHANICS
  210.     parent=(!ditto0) ? mother : father
  211.     if parent.hasHiddenAbility?
  212.       egg.setAbility(parent.abilityIndex) if rand(10)<6
  213.     end
  214.   end
  215.   # Inheriting Poké Ball from the mother
  216.   if mother.isFemale? &&
  217.      !isConst?(pbBallTypeToBall(mother.ballused),PBItems,:MASTERBALL) &&
  218.      !isConst?(pbBallTypeToBall(mother.ballused),PBItems,:CHERISHBALL)
  219.     egg.ballused=mother.ballused
  220.   end
  221.   egg.iv[0]=ivs[0]
  222.   egg.iv[1]=ivs[1]
  223.   egg.iv[2]=ivs[2]
  224.   egg.iv[3]=ivs[3]
  225.   egg.iv[4]=ivs[4]
  226.   egg.iv[5]=ivs[5]
  227.   egg.moves[0]=finalmoves[0]
  228.   egg.moves[1]=finalmoves[1]
  229.   egg.moves[2]=finalmoves[2]
  230.   egg.moves[3]=finalmoves[3]
  231.   egg.calcStats
  232.   egg.obtainText=gettext ? gettext : _INTL("Day-Care Couple")
  233.   egg.name=_INTL("Egg")
  234.   dexdata=pbOpenDexData
  235.   pbDexDataOffset(dexdata,babyspecies,21)
  236.   eggsteps=dexdata.fgetw
  237.   dexdata.close
  238.   egg.eggsteps=eggsteps
  239.   if rand(65536)<POKERUSCHANCE
  240.     egg.givePokerus
  241.   end
  242.   $Trainer.party[$Trainer.party.length]=egg
  243. end
RAW Paste Data