Advertisement
Guest User

Untitled

a guest
Apr 20th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.97 KB | None | 0 0
  1. WILD_POKEMON_NAMES = [
  2.   %w|
  3.     Larry
  4.     Other Larry
  5.   |,
  6.  
  7.   %w|
  8.     Karen
  9.     Gretchen
  10.     Regina
  11.   |
  12. ]
  13.  
  14. class Array
  15.   def sample
  16.     self[rand(self.length)]
  17.   end
  18. end
  19.  
  20. class PokeBattle_Battler
  21.   attr_accessor :wild_name
  22. end
  23.  
  24. class PokemonDataBox
  25.   def get_battler_name
  26.     renamable =
  27.       (@battler.index & 1) == 1 &&
  28.       @battler.name == @battler.pokemon.name &&
  29.       pbGet(76) == 0
  30.    
  31.     if renamable
  32.       unless @battler.wild_name
  33.         @battler.wild_name = WILD_POKEMON_NAMES[@battler.displayGender].sample
  34.       end
  35.      
  36.       @battler.wild_name
  37.     else
  38.       @battler.name
  39.     end
  40.   end
  41.  
  42.   def refresh
  43.     self.bitmap.clear
  44.     return if !@battler.pokemon
  45.     self.bitmap.blt(0,0,@databox.bitmap,Rect.new(0,0,@databox.width,@databox.height))
  46.     base   = Color.new(72,72,72)
  47.     shadow = Color.new(184,184,184)
  48.     pbSetSystemFont(self.bitmap)
  49.     textpos = []
  50.     imagepos = []
  51.     # Draw Pokémon's name
  52.     textpos.push([get_battler_name,@spritebaseX+8,6,false,base,shadow])
  53.     # Draw Pokémon's gender symbol
  54.     genderX = self.bitmap.text_size(@battler.name).width
  55.     genderX += @spritebaseX+14
  56.     case @battler.displayGender
  57.     when 0 # Male
  58.       textpos.push([_INTL("♂"),genderX,6,false,Color.new(48,96,216),shadow])
  59.     when 1 # Female
  60.       textpos.push([_INTL("♀"),genderX,6,false,Color.new(248,88,40),shadow])
  61.     end
  62.     pbDrawTextPositions(self.bitmap,textpos)
  63.     # Draw Pokémon's level
  64.     pbSetSmallFont(self.bitmap)
  65.     imagepos.push(["Graphics/Pictures/Battle/overlay_lv",
  66.        @spritebaseX+180-self.bitmap.text_size(@battler.level.to_s).width,16,0,0,-1,-1])
  67.     textpos = [
  68.        [@battler.level.to_s,@spritebaseX+202,8,true,base,shadow]
  69.     ]
  70.     # Draw Pokémon's HP numbers
  71.     if @showhp
  72.       hpstring = _ISPRINTF("{1: 2d}/{2: 2d}",self.hp,@battler.totalhp)
  73.       textpos.push([hpstring,@spritebaseX+188,48,true,base,shadow])
  74.     end
  75.     pbDrawTextPositions(self.bitmap,textpos)
  76.     # Draw shiny icon
  77.     if @battler.isShiny?
  78.       shinyX = ((@battler.index&1)==0) ? -6 : 206   # Player's/foe's
  79.       imagepos.push(["Graphics/Pictures/shiny",@spritebaseX+shinyX,36,0,0,-1,-1])
  80.     end
  81.     # Draw Mega Evolution/Primal Reversion icon
  82.     if @battler.isMega?
  83.       imagepos.push(["Graphics/Pictures/Battle/icon_mega",@spritebaseX+8,34,0,0,-1,-1])
  84.     elsif @battler.isPrimal?
  85.       if isConst?(@battler.pokemon.species,PBSpecies,:KYOGRE)
  86.         imagepos.push(["Graphics/Pictures/Battle/icon_primal_Kyogre",@spritebaseX+140,4,0,0,-1,-1])
  87.       elsif isConst?(@battler.pokemon.species,PBSpecies,:GROUDON)
  88.         imagepos.push(["Graphics/Pictures/Battle/icon_primal_Groudon",@spritebaseX+140,4,0,0,-1,-1])
  89.       end
  90.     end
  91.     # Draw owned icon (foe Pokémon only)
  92.     if @battler.owned && (@battler.index&1)==1
  93.       imagepos.push(["Graphics/Pictures/Battle/icon_own",@spritebaseX+8,36,0,0,-1,-1])
  94.     end
  95.     # Draw status icon
  96.     if @battler.status>0
  97.       iconheight = 16
  98.       self.bitmap.blt(@spritebaseX+24,36,@statuses.bitmap,
  99.          Rect.new(0,(@battler.status-1)*iconheight,@statuses.bitmap.width,iconheight))
  100.     end
  101.     # Draw HP bar
  102.     hpgauge = (@battler.totalhp==0) ? 0 : self.hp*@hpbar.bitmap.width/@battler.totalhp
  103.     hpgauge = 2 if hpgauge<2 && self.hp>0
  104.     hpzone = 0
  105.     hpzone = 1 if self.hp<=(@battler.totalhp/2).floor
  106.     hpzone = 2 if self.hp<=(@battler.totalhp/4).floor
  107.     if @animatingHP && self.hp>0   # fill with black (shows what the HP used to be)
  108.       self.bitmap.fill_rect(@spritebaseX+102,40,
  109.          @starthp*@hpbar.bitmap.width/@battler.totalhp,@hpbar.bitmap.height/3,Color.new(0,0,0))
  110.     end
  111.     self.bitmap.blt(@spritebaseX+102,40,@hpbar.bitmap,
  112.        Rect.new(0,hpzone*@hpbar.bitmap.height/3,hpgauge,@hpbar.bitmap.height/3))
  113.     # Draw Exp bar
  114.     if @showexp
  115.       self.bitmap.blt(@spritebaseX+6,76,@expbar.bitmap,
  116.          Rect.new(0,0,self.exp,@expbar.bitmap.height))
  117.     end
  118.     pbDrawImagePositions(self.bitmap,imagepos)
  119.   end
  120. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement