Advertisement
DimbusMaximus

Family Tree fix

Jul 8th, 2016
192
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 @ [email protected] 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. [email protected] 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. [email protected] ? @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. if @pokemon.name.split().last=="♂" || @pokemon.name.split().last=="♀"
  74. end
  75. textpos=[
  76. [_INTL("FAMILY TREE"),26,16,0,base,shadow],
  77. [pokename,46,62,0,base,shadow],
  78. [_INTL("Item"),16,320,0,base,shadow],
  79. [itemname,16,352,0,Color.new(64,64,64),Color.new(176,176,176)],
  80. ]
  81. textpos.push([_INTL("{1}",pokemon.level),46,92,0,
  82. Color.new(64,64,64),Color.new(176,176,176)]) if [email protected]?
  83. if pokemon.gender==0
  84. textpos.push([_INTL("♂"),178,62,0,
  85. Color.new(24,112,216),Color.new(136,168,208)])
  86. elsif pokemon.gender==1
  87. textpos.push([_INTL("♀"),178,62,0,
  88. Color.new(248,56,32),Color.new(224,152,144)])
  89. end
  90. end
  91. base=Color.new(248,248,248)
  92. shadow=Color.new(104,104,104)
  93. # Draw parents
  94. parentsY=[78,234]
  95. for i in 0...2
  96. parent = @pokemon.family && @pokemon.family[i] ? @pokemon.family[i] : nil
  97. iconParentParam = parent ? [parent.species,
  98. parent.gender==1,false,parent.form,false] : [0,0,false,0,false]
  99. iconParent=AnimatedBitmap.new(pbCheckPokemonIconFiles(iconParentParam))
  100. overlay.blt(234,parentsY[i],iconParent.bitmap,Rect.new(0,0,64,64))
  101. textpos.push([parent ? parent.name : _INTL("???"),
  102. 320,parentsY[i],0,base,shadow])
  103. parentSpecieName=parent ? PBSpecies.getName(parent.species) : _INTL("???")
  104. if (parentSpecieName.split().last=="♂" ||
  105. parentSpecieName.split().last=="♀")
  106. parentSpecieName=parentSpecieName[0..-2]
  107. end
  108. textpos.push([parentSpecieName,320,32+parentsY[i],0,base,shadow])
  109. if parent
  110. if parent.gender==0
  111. textpos.push([_INTL("♂"),500,32+parentsY[i],1,
  112. Color.new(24,112,216),Color.new(136,168,208)])
  113. elsif parent.gender==1
  114. textpos.push([_INTL("♀"),500,32+parentsY[i],1,
  115. Color.new(248,56,32),Color.new(224,152,144)])
  116. end
  117. end
  118. grandX = [380,448]
  119. for j in 0...2
  120. iconGrandParam = parent && parent[j] ? [parent[j].species,
  121. parent[j].gender==1,false,parent[j].form,false] :
  122. [0,0,false,0,false]
  123. iconGrand=AnimatedBitmap.new(pbCheckPokemonIconFiles(iconGrandParam))
  124. overlay.blt(
  125. grandX[j],68+parentsY[i],iconGrand.bitmap,Rect.new(0,0,64,64))
  126. end
  127. end
  128. pbDrawTextPositions(overlay,textpos)
  129. drawMarkings(overlay,15,291,72,20,pokemon.markings)
  130. end
  131.  
  132. def handleInputsEgg
  133. if SHOWFAMILYEGG && @pokemon.isEgg?
  134. if Input.trigger?(Input::LEFT) && @page==5
  135. @page=0
  136. pbPlayCursorSE()
  137. dorefresh=true
  138. end
  139. if Input.trigger?(Input::RIGHT) && @page==0
  140. @page=5
  141. pbPlayCursorSE()
  142. dorefresh=true
  143. end
  144. end
  145. if dorefresh
  146. case @page
  147. when 0
  148. drawPageOne(@pokemon)
  149. when 5
  150. drawPageSix(@pokemon)
  151. end
  152. end
  153. end
  154. end
  155.  
  156.  
  157. class PokemonFamily
  158. MAXGENERATIONS = 3 # Tree stored generation limit
  159.  
  160. attr_reader :mother # PokemonFamily object
  161. attr_reader :father # PokemonFamily object
  162.  
  163. attr_reader :species
  164. attr_reader :gender
  165. attr_reader :form
  166. attr_reader :name # nickname
  167. # You can add more data here and on initialize class. Just
  168. # don't store the entire pokémon object.
  169.  
  170. def initialize(pokemon, father=nil,mother=nil)
  171. initializedAsParent = !father || !mother
  172. if pokemon.family && pokemon.family.father
  173. @father = pokemon.family.father
  174. elsif father
  175. @father = PokemonFamily.new(father)
  176. end
  177. if pokemon.family && pokemon.family.mother
  178. @mother = pokemon.family.mother
  179. elsif mother
  180. @mother = PokemonFamily.new(mother)
  181. end
  182.  
  183. # This data is only initialized as a parent in a cub.
  184. if initializedAsParent
  185. @species=pokemon.species
  186. @gender=pokemon.gender
  187. @name=pokemon.name
  188. @form=pokemon.form
  189. end
  190.  
  191. applyGenerationLimit(MAXGENERATIONS)
  192. end
  193.  
  194. def applyGenerationLimit(generation)
  195. if generation>1
  196. father.applyGenerationLimit(generation-1) if @father
  197. mother.applyGenerationLimit(generation-1) if @mother
  198. else
  199. father=nil
  200. mother=nil
  201. end
  202. end
  203.  
  204. def [](value) # [0] = father, [1] = mother
  205. if value==0
  206. return @father
  207. elsif value==1
  208. return @mother
  209. end
  210. return nil
  211. end
  212. end
  213.  
  214. class PokeBattle_Pokemon
  215. attr_accessor :family
  216. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement