Advertisement
DimbusMaximus

Family Tree fix

Jul 8th, 2016
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.43 KB | None | 0 0
  1. #Fixes by Dimbus Maximus
  2. #email me @ max.dimby@gmail.com if further help or questions needed
  3. #===============================================================================
  4. # * Family Tree - by FL (Credits will be apreciated)
  5. #===============================================================================
  6. #
  7. # This script is for Pokémon Essentials. It displays a sixth page at pokémon
  8. # summary showing a little info about the pokémon mother, father, grandmothers
  9. # and grandfathers if the pokémon has any.
  10. #
  11. #===============================================================================
  12. #
  13. # To this script works, put it above main, put a 512x384 background for this
  14. # screen in "Graphics/Pictures/summary6" and in "Graphics/Pictures/summaryEgg6".
  15. # This last one is only necessary if SHOWFAMILYEGG is true. You also need to
  16. # update the below pictures in order to reflect the summary icon change:
  17. # - summary1
  18. # - summary2
  19. # - summary3
  20. # - summary4
  21. # - summary4details
  22. # - summary5
  23. #
  24. # -At PokemonDayCare, before line '$Trainer.party[$Trainer.party.length]=egg'
  25. # add line 'egg.family = PokemonFamily.new(egg, father, mother)'
  26. #
  27. # -At PokemonSummary, change both lines '@page=4 if @page>4'
  28. # to '@page=5 if @page>5'
  29. #
  30. # -Before line 'if Input.trigger?(Input::UP) && @partyindex>0'
  31. # add line 'handleInputsEgg'
  32. #
  33. # -Change line 'if @page!=0' to 'if @page!=0 && !(SHOWFAMILYEGG && @page==5)'
  34. #
  35. # -After line 'drawPageFive(@pokemon)' add
  36. #
  37. # when 5
  38. # drawPageSix(@pokemon)
  39. #
  40. #===============================================================================
  41.  
  42. class PokemonSummaryScene
  43. SHOWFAMILYEGG = true # when true, family tree is also showed in egg screen.
  44.  
  45. def drawPageSix(pokemon)
  46. overlay=@sprites["overlay"].bitmap
  47. overlay.clear
  48. @sprites["background"].setBitmap( pbHasEgg?(@pokemon.species)? #@pokemon.hasEgg?
  49. "Graphics/Pictures/summaryEgg6" : "Graphics/Pictures/summary6")
  50. imagepos=[]
  51. if pbPokerus(pokemon)==1 || pokemon.hp==0 || @pokemon.status>0
  52. status=6 if pbPokerus(pokemon)==1
  53. status=@pokemon.status-1 if @pokemon.status>0
  54. status=5 if pokemon.hp==0
  55. imagepos.push(["Graphics/Pictures/statuses",124,100,0,16*status,44,16])
  56. end
  57. if pokemon.isShiny?
  58. imagepos.push([sprintf("Graphics/Pictures/shiny"),2,134,0,0,-1,-1])
  59. end
  60. if pbPokerus(pokemon)==2
  61. imagepos.push([
  62. sprintf("Graphics/Pictures/summaryPokerus"),176,100,0,0,-1,-1])
  63. end
  64. ballused=@pokemon.ballused ? @pokemon.ballused : 0
  65. ballimage=sprintf("Graphics/Pictures/summaryball%02d",@pokemon.ballused)
  66. imagepos.push([ballimage,14,60,0,0,-1,-1])
  67. pbDrawImagePositions(overlay,imagepos)
  68. base=Color.new(248,248,248)
  69. shadow=Color.new(104,104,104)
  70. pbSetSystemFont(overlay)
  71. naturename=PBNatures.getName(pokemon.nature)
  72. itemname=pokemon.item==0 ? _INTL("None") : PBItems.getName(pokemon.item)
  73. pokename=@pokemon.name
  74. if @pokemon.name.split().last=="♂" || @pokemon.name.split().last=="♀"
  75. pokename=@pokemon.name[0..-2]
  76. end
  77. textpos=[
  78. [_INTL("FAMILY TREE"),26,16,0,base,shadow],
  79. [pokename,46,62,0,base,shadow],
  80. [_INTL("Item"),16,320,0,base,shadow],
  81. [itemname,16,352,0,Color.new(64,64,64),Color.new(176,176,176)],
  82. ]
  83. textpos.push([_INTL("{1}",pokemon.level),46,92,0,
  84. Color.new(64,64,64),Color.new(176,176,176)]) if !@pokemon.isEgg?
  85. if !@pokemon.isEgg?
  86. if pokemon.gender==0
  87. textpos.push([_INTL("♂"),178,62,0,
  88. Color.new(24,112,216),Color.new(136,168,208)])
  89. elsif pokemon.gender==1
  90. textpos.push([_INTL("♀"),178,62,0,
  91. Color.new(248,56,32),Color.new(224,152,144)])
  92. end
  93. end
  94. base=Color.new(248,248,248)
  95. shadow=Color.new(104,104,104)
  96. # Draw parents
  97. parentsY=[78,234]
  98. for i in 0...2
  99. parent = @pokemon.family && @pokemon.family[i] ? @pokemon.family[i] : nil
  100. iconParentParam = parent ? [parent.species,
  101. parent.gender==1,false,parent.form,false] : [0,0,false,0,false]
  102. iconParent=AnimatedBitmap.new(pbCheckPokemonIconFiles(iconParentParam))
  103. overlay.blt(234,parentsY[i],iconParent.bitmap,Rect.new(0,0,64,64))
  104. textpos.push([parent ? parent.name : _INTL("???"),
  105. 320,parentsY[i],0,base,shadow])
  106. parentSpecieName=parent ? PBSpecies.getName(parent.species) : _INTL("???")
  107. if (parentSpecieName.split().last=="♂" ||
  108. parentSpecieName.split().last=="♀")
  109. parentSpecieName=parentSpecieName[0..-2]
  110. end
  111. textpos.push([parentSpecieName,320,32+parentsY[i],0,base,shadow])
  112. if parent
  113. if parent.gender==0
  114. textpos.push([_INTL("♂"),500,32+parentsY[i],1,
  115. Color.new(24,112,216),Color.new(136,168,208)])
  116. elsif parent.gender==1
  117. textpos.push([_INTL("♀"),500,32+parentsY[i],1,
  118. Color.new(248,56,32),Color.new(224,152,144)])
  119. end
  120. end
  121. grandX = [380,448]
  122. for j in 0...2
  123. iconGrandParam = parent && parent[j] ? [parent[j].species,
  124. parent[j].gender==1,false,parent[j].form,false] :
  125. [0,0,false,0,false]
  126. iconGrand=AnimatedBitmap.new(pbCheckPokemonIconFiles(iconGrandParam))
  127. overlay.blt(
  128. grandX[j],68+parentsY[i],iconGrand.bitmap,Rect.new(0,0,64,64))
  129. end
  130. end
  131. pbDrawTextPositions(overlay,textpos)
  132. drawMarkings(overlay,15,291,72,20,pokemon.markings)
  133. end
  134.  
  135. def handleInputsEgg
  136. if SHOWFAMILYEGG && @pokemon.isEgg?
  137. if Input.trigger?(Input::LEFT) && @page==5
  138. @page=0
  139. pbPlayCursorSE()
  140. dorefresh=true
  141. end
  142. if Input.trigger?(Input::RIGHT) && @page==0
  143. @page=5
  144. pbPlayCursorSE()
  145. dorefresh=true
  146. end
  147. end
  148. if dorefresh
  149. case @page
  150. when 0
  151. drawPageOne(@pokemon)
  152. when 5
  153. drawPageSix(@pokemon)
  154. end
  155. end
  156. end
  157. end
  158.  
  159.  
  160. class PokemonFamily
  161. MAXGENERATIONS = 3 # Tree stored generation limit
  162.  
  163. attr_reader :mother # PokemonFamily object
  164. attr_reader :father # PokemonFamily object
  165.  
  166. attr_reader :species
  167. attr_reader :gender
  168. attr_reader :form
  169. attr_reader :name # nickname
  170. # You can add more data here and on initialize class. Just
  171. # don't store the entire pokémon object.
  172.  
  173. def initialize(pokemon, father=nil,mother=nil)
  174. initializedAsParent = !father || !mother
  175. if pokemon.family && pokemon.family.father
  176. @father = pokemon.family.father
  177. elsif father
  178. @father = PokemonFamily.new(father)
  179. end
  180. if pokemon.family && pokemon.family.mother
  181. @mother = pokemon.family.mother
  182. elsif mother
  183. @mother = PokemonFamily.new(mother)
  184. end
  185.  
  186. # This data is only initialized as a parent in a cub.
  187. if initializedAsParent
  188. @species=pokemon.species
  189. @gender=pokemon.gender
  190. @name=pokemon.name
  191. @form=pokemon.form
  192. end
  193.  
  194. applyGenerationLimit(MAXGENERATIONS)
  195. end
  196.  
  197. def applyGenerationLimit(generation)
  198. if generation>1
  199. father.applyGenerationLimit(generation-1) if @father
  200. mother.applyGenerationLimit(generation-1) if @mother
  201. else
  202. father=nil
  203. mother=nil
  204. end
  205. end
  206.  
  207. def [](value) # [0] = father, [1] = mother
  208. if value==0
  209. return @father
  210. elsif value==1
  211. return @mother
  212. end
  213. return nil
  214. end
  215. end
  216.  
  217. class PokeBattle_Pokemon
  218. attr_accessor :family
  219. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement