Guest User

Untitled

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