Vendily

checker

Jan 1st, 2019
490
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #===============================================================================
  2. # * One screen Day-Care Checker item - by FL (Credits will be apreciated)
  3. #===============================================================================
  4. #
  5. # This script is for Pokémon Essentials. It makes a One screen Day-Care Checker
  6. # (like in DPP) activated by item. This display the pokémon sprite, names,
  7. # levels, genders and if them generate an egg.
  8. #
  9. #===============================================================================
  10. #
  11. # To this script works, put it above main, put a 480x320 background in
  12. # DCCBACKPATH location and, like any item, you need to add in the "items.txt"
  13. # and in the script. There an example below using the name DAYCARESIGHT, but
  14. # you can use any other name changing the DDCITEM and the item that be added in
  15. # txt. You can change the internal number too:
  16. #
  17. # 631,DAYCARESIGHT,DayCare Sight,8,0,"A visor that can be use for see certains Pokémon in Day-Care to monitor their growth.",2,0,6
  18. #
  19. #===============================================================================
  20.  
  21. #DDCITEM=:DAYCARESIGHT # Change this and the item.txt if you wish another name
  22. DCCBACKPATH= "Graphics/Pictures/dccbackground" # You can change if you wish
  23. # If you wish that the pokémon is positioned like in battle (have the distance
  24. # defined in metadata, even the BattlerAltitude) change the below line to true
  25. DDCBATTLEPOSITION = false
  26.  
  27. class DayCareCheckerScene  
  28.  
  29. def startScene
  30.   @sprites={}
  31.   @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
  32.   @viewport.z=99999
  33.   @pkmn1=$PokemonGlobal.daycare[0][0]
  34.   @pkmn2=$PokemonGlobal.daycare[1][0]
  35.   # If you wish that if there only one pokémon, it became right
  36.   # positioned, them uncomment the four below lines
  37.   #if !@pkmn1 && @pkmn2
  38.   #  @pkmn1=@pkmn2
  39.   #  @pkmn2=nil
  40.   #end  
  41.   textPositions=[]
  42.   baseColor=Color.new(12*8,12*8,12*8)
  43.   shadowColor=Color.new(26*8,26*8,25*8)
  44.   @sprites["background"]=IconSprite.new(0,0,@viewport)
  45.   @sprites["background"].setBitmap(DCCBACKPATH)
  46.   pokemony=Graphics.height/2-32
  47.   pokemonyadjust=pokemony-32
  48.   if @pkmn1
  49.     @sprites["pokemon1"]=PokemonSprite.new(@viewport)
  50.     @sprites["pokemon1"].setPokemonBitmap(@pkmn1)
  51.     @sprites["pokemon1"].mirror=true
  52.    pbPositionPokemonSprite(@sprites["pokemon1"],32,pokemony)
  53.     @sprites["pokemon1"].y=pokemonyadjust + adjustBattleSpriteY(
  54.         @sprites["pokemon1"],@pkmn1.species,1) if DDCBATTLEPOSITION
  55.     textPositions.push([_INTL("{1} Lv{2}{3}",@pkmn1.name,@pkmn1.level.to_s,
  56.         genderString(@pkmn1.gender)),32,44,false,baseColor,shadowColor])
  57.   end
  58.   if @pkmn2
  59.     @sprites["pokemon2"]=PokemonSprite.new(@viewport)
  60.     @sprites["pokemon2"].setPokemonBitmap(@pkmn2)
  61.    pbPositionPokemonSprite(@sprites["pokemon2"],Graphics.width-168,pokemony)
  62.     @sprites["pokemon2"].y=pokemonyadjust + adjustBattleSpriteY(
  63.         @sprites["pokemon2"],@pkmn2.species,1) if DDCBATTLEPOSITION
  64.     textPositions.push([_INTL("{1} Lv{2}{3}",@pkmn2.name,@pkmn2.level.to_s,
  65.         genderString(@pkmn2.gender)),Graphics.width-16,44,true,baseColor,
  66.         shadowColor])
  67.   end
  68.   if Kernel.pbEggGenerated?
  69.     @sprites["egg"]=IconSprite.new(Graphics.width/2-68,pokemony+32,@viewport)
  70.     @sprites["egg"].setBitmap(getEggBitmap(getBabySpecies))
  71.     # To works with different egg sprite sizes
  72.     @sprites["egg"].x-=(@sprites["egg"].bitmap.width/8-16)*3
  73.     # Uncomment the below line to only a egg shadow be show
  74.     #@sprites["egg"].color=Color.new(0,0,0,255)    
  75.   end
  76.   @sprites["overlay"]=Sprite.new(@viewport)
  77.   @sprites["overlay"].bitmap=BitmapWrapper.new(Graphics.width,Graphics.height)
  78.   pbSetSystemFont(@sprites["overlay"].bitmap)
  79.   if !textPositions.empty?
  80.     pbDrawTextPositions(@sprites["overlay"].bitmap,textPositions)
  81.   end
  82.   pbFadeInAndShow(@sprites) { update }
  83. end
  84.  
  85. def getEggBitmap(pkmndata)
  86.   species,form = pkmndata
  87.   bitmapFileName=sprintf("Graphics/Battlers/%segg_%d",getConstantName(PBSpecies,species),form) rescue nil
  88.   bitmapFileName=sprintf("Graphics/Battlers/%segg",getConstantName(PBSpecies,species)) if !pbResolveBitmap(bitmapFileName)
  89.   bitmapFileName=sprintf("Graphics/Battlers/%03degg_%d",species,form) if !pbResolveBitmap(bitmapFileName)
  90.   bitmapFileName=sprintf("Graphics/Battlers/%03degg",species) if !pbResolveBitmap(bitmapFileName)
  91.   bitmapFileName=sprintf("Graphics/Battlers/egg") if !pbResolveBitmap(bitmapFileName)
  92.   bitmapFileName=pbResolveBitmap(bitmapFileName)
  93.   return bitmapFileName
  94. end
  95.  
  96. def getBabySpecies
  97.   pokemon0=$PokemonGlobal.daycare[0][0]
  98.   pokemon1=$PokemonGlobal.daycare[1][0]
  99.   mother=nil
  100.   father=nil
  101.   babyspecies=0
  102.   ditto0=pbIsDitto?(pokemon0)
  103.   ditto1=pbIsDitto?(pokemon1)
  104.   if (pokemon0.gender==1 || ditto0)
  105.     babyspecies=(ditto0) ? pokemon1.species : pokemon0.species
  106.     mother=pokemon0
  107.     father=pokemon1
  108.   else
  109.     babyspecies=(ditto1) ? pokemon0.species : pokemon1.species
  110.     mother=pokemon1
  111.     father=pokemon0
  112.   end
  113.   babyspecies=pbGetBabySpecies(babyspecies)
  114.   if isConst?(babyspecies,PBSpecies,:MANAPHY) && hasConst?(PBSpecies,:PHIONE)
  115.     babyspecies=getConst(PBSpecies,:PHIONE)
  116.   elsif isConst?(babyspecies,PBSpecies,:MISSINGNO) && hasConst?(PBSpecies,:KANGASKHAN)
  117.     babyspecies=getConst(PBSpecies,:KANGASKHAN)
  118.   end
  119.   if (isConst?(babyspecies,PBSpecies,:NIDORANfE) && (hasConst?(PBSpecies,:NIDORANmA) || hasConst?(PBSpecies,:NIDORINO) || hasConst?(PBSpecies,:NIDOKING))) ||
  120.         (isConst?(babyspecies,PBSpecies,:NIDORANmA) && (hasConst?(PBSpecies,:NIDORANfE) || hasConst?(PBSpecies,:NIDORINA) || hasConst?(PBSpecies,:NIDOQUEEN)))
  121.     babyspecies=[getConst(PBSpecies,:NIDORANmA),
  122.                  getConst(PBSpecies,:NIDORANfE)][rand(2)]
  123.   elsif isConst?(babyspecies,PBSpecies,:NIDORANmA) && hasConst?(PBSpecies,:NIDORANfE)
  124.     babyspecies=[getConst(PBSpecies,:NIDORANmA),
  125.                  getConst(PBSpecies,:NIDORANfE)][rand(2)]
  126.   elsif isConst?(babyspecies,PBSpecies,:VOLBEAT) && hasConst?(PBSpecies,:ILLUMISE)
  127.     babyspecies=[getConst(PBSpecies,:VOLBEAT),
  128.                  getConst(PBSpecies,:ILLUMISE)][rand(2)]
  129.   elsif isConst?(babyspecies,PBSpecies,:ILLUMISE) && hasConst?(PBSpecies,:VOLBEAT)
  130.     babyspecies=[getConst(PBSpecies,:VOLBEAT),
  131.                  getConst(PBSpecies,:ILLUMISE)][rand(2)]
  132.   elsif isConst?(babyspecies,PBSpecies,:TRIFOX) && mother.form==0 &&
  133.         !isConst?(mother.item,PBItems,:VOLCANICINCENSE) &&
  134.         !isConst?(father.item,PBItems,:VOLCANICINCENSE)
  135.     babyspecies=pbGetNonIncenseLowestSpecies(babyspecies)
  136.   elsif isConst?(babyspecies,PBSpecies,:TRIFOX) && mother.form==1 &&
  137.         !isConst?(mother.item,PBItems,:MINTINCENSE) &&
  138.         !isConst?(father.item,PBItems,:MINTINCENSE)
  139.     babyspecies=pbGetNonIncenseLowestSpecies(babyspecies)
  140.   elsif isConst?(babyspecies,PBSpecies,:MUNCHLAX) &&
  141.         !isConst?(mother.item,PBItems,:FULLINCENSE) &&
  142.         !isConst?(father.item,PBItems,:FULLINCENSE)
  143.     babyspecies=pbGetNonIncenseLowestSpecies(babyspecies)
  144.   elsif isConst?(babyspecies,PBSpecies,:WYNAUT) &&
  145.         !isConst?(mother.item,PBItems,:LAXINCENSE) &&
  146.         !isConst?(father.item,PBItems,:LAXINCENSE)
  147.     babyspecies=pbGetNonIncenseLowestSpecies(babyspecies)
  148.   elsif isConst?(babyspecies,PBSpecies,:HAPPINY) &&
  149.         !isConst?(mother.item,PBItems,:LUCKINCENSE) &&
  150.         !isConst?(father.item,PBItems,:LUCKINCENSE)
  151.     babyspecies=pbGetNonIncenseLowestSpecies(babyspecies)
  152.   elsif isConst?(babyspecies,PBSpecies,:MIMEJR) &&
  153.         !isConst?(mother.item,PBItems,:ODDINCENSE) &&
  154.         !isConst?(father.item,PBItems,:ODDINCENSE)
  155.     babyspecies=pbGetNonIncenseLowestSpecies(babyspecies)
  156.   elsif isConst?(babyspecies,PBSpecies,:CHINGLING) &&
  157.         !isConst?(mother.item,PBItems,:PUREINCENSE) &&
  158.         !isConst?(father.item,PBItems,:PUREINCENSE)
  159.     babyspecies=pbGetNonIncenseLowestSpecies(babyspecies)
  160.   elsif isConst?(babyspecies,PBSpecies,:BONSLY) &&
  161.         !isConst?(mother.item,PBItems,:ROCKINCENSE) &&
  162.         !isConst?(father.item,PBItems,:ROCKINCENSE)
  163.     babyspecies=pbGetNonIncenseLowestSpecies(babyspecies)
  164.   elsif isConst?(babyspecies,PBSpecies,:BUDEW) &&
  165.         !isConst?(mother.item,PBItems,:ROSEINCENSE) &&
  166.         !isConst?(father.item,PBItems,:ROSEINCENSE)
  167.     babyspecies=pbGetNonIncenseLowestSpecies(babyspecies)
  168.   elsif isConst?(babyspecies,PBSpecies,:AZURILL) &&
  169.         !isConst?(mother.item,PBItems,:SEAINCENSE) &&
  170.         !isConst?(father.item,PBItems,:SEAINCENSE)
  171.     babyspecies=pbGetNonIncenseLowestSpecies(babyspecies)
  172.   elsif isConst?(babyspecies,PBSpecies,:MANTYKE) &&
  173.         !isConst?(mother.item,PBItems,:WAVEINCENSE) &&
  174.         !isConst?(father.item,PBItems,:WAVEINCENSE)
  175.     babyspecies=pbGetNonIncenseLowestSpecies(babyspecies)
  176.   end
  177.   form=0
  178.   if !isConst?(babyspecies,PBSpecies,:ROTOM)
  179.     form=mother.form
  180.   end
  181.   return [babyspecies,form]
  182. end
  183.  
  184. def genderString(gender)
  185.   ret="  "
  186.   if gender==0
  187.     ret=" ♂"
  188.   elsif gender==1
  189.     ret=" ♀"
  190.   end
  191.   return ret
  192. end  
  193.  
  194. def middleScene
  195.   loop do
  196.     Graphics.update
  197.     Input.update
  198.     self.update
  199.     if Input.trigger?(Input::B) || Input.trigger?(Input::C)
  200.       break
  201.     end
  202.   end
  203. end
  204.  
  205. def update
  206.   pbUpdateSpriteHash(@sprites)
  207. end
  208.  
  209. def endScene
  210.   pbFadeOutAndHide(@sprites) { update }
  211.   pbDisposeSpriteHash(@sprites)
  212.   @viewport.dispose
  213. end
  214. end
  215.  
  216. class DayCareChecker
  217.  
  218. def initialize(scene)
  219.   @scene=scene
  220. end
  221.  
  222. def startScreen
  223.   @scene.startScene
  224.   @scene.middleScene
  225.   @scene.endScene
  226. end
  227. end
RAW Paste Data