Advertisement
Vendily

auto hue v3

Aug 4th, 2017
1,002
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.81 KB | None | 0 0
  1. #===============================================================================
  2. # * Auto Hue Pokémon - by Vendily
  3. #===============================================================================
  4. # It allows you to color forms' sprites and icons. I made it for shadow pokémon
  5. #  originally. (For the curious the color is (67,0,255,113) for shadow pokémon)
  6. # Put it above Main (It's because it aliases methods in PSystem_Utilities/EBS
  7. #  and Pokemon_Sprites)
  8. #===============================================================================
  9. # If you want to use it, you can create a Multiple forms property called
  10. #  "bitmapColor", which returns a color object (Color.new)
  11. #  MultipleForms.register(:EEVEE,{
  12. #  "bitmapColor"=>proc{|pokemon|
  13. #    next if pokemon.form==0
  14. #    next Color.new(67,0,255)
  15. # }
  16. # })
  17. # You can also use it for shadow pokémon, thanks to conditional registration.
  18. # MultipleForms.registerIf(proc{|species| true},{
  19. # "bitmapColor"=>proc{|pokemon|
  20. #    next Color.new(67,0,255) if (pokemon.isShadow? rescue false)
  21. #    next
  22. # }
  23. # })
  24. #===============================================================================
  25. def drawShadowPoke(bitmap,color=nil)
  26.   blankcolor=bitmap.get_pixel(0,0)
  27.   shadowcolor=(color ? color : blankcolor)
  28.     colorlayer=Bitmap.new(bitmap.width,bitmap.height)
  29.   colorlayer.fill_rect(colorlayer.rect, shadowcolor)
  30.   bitmap.blt(0,0,colorlayer,colorlayer.rect,113)
  31.   shadowcolor=bitmap.get_pixel(0,0)
  32.   for x in 0...bitmap.width
  33.     for y in 0...bitmap.height
  34.       if bitmap.get_pixel(x,y)==shadowcolor
  35.         bitmap.set_pixel(x,y,blankcolor)
  36.       end
  37.     end
  38.   end
  39. end
  40.  
  41. alias _shadow_pbLoadPokemonBitmapSpecies pbLoadPokemonBitmapSpecies
  42. if defined?(EBUISTYLE)
  43.   def pbLoadPokemonBitmapSpecies(pokemon, species, back=false,scale=POKEMONSPRITESCALE)
  44.     ret=_shadow_pbLoadPokemonBitmapSpecies(pokemon, species, back,scale)
  45.     if ret
  46.       color=(MultipleForms.call("bitmapColor",pokemon))
  47.       ret.prepareStrip
  48.       for i in 0...ret.totalFrames
  49.         drawShadowPoke(ret.alterBitmap(i),color)
  50.       end
  51.       ret.compileStrip
  52.     end
  53.     return ret
  54.   end
  55. else
  56.     def pbLoadPokemonBitmapSpecies(pokemon, species, back=false)
  57.       ret=_shadow_pbLoadPokemonBitmapSpecies(pokemon, species, back)
  58.       if ret
  59.         color=(MultipleForms.call("bitmapColor",pokemon))
  60.         animatedBitmap=ret
  61.         copiedBitmap=animatedBitmap.copy
  62.         animatedBitmap.dispose
  63.         copiedBitmap.each {|bitmap|
  64.           drawShadowPoke(bitmap,color)
  65.         }
  66.         ret=copiedBitmap
  67.       end
  68.       return ret
  69.     end
  70. end
  71.  
  72. class PokemonIconSprite
  73.     alias _shadow_pokemon= pokemon=
  74.   def pokemon=(value)
  75.     self._shadow_pokemon=value
  76.     if pokemon
  77.       color=(MultipleForms.call("bitmapColor",pokemon))
  78.       drawShadowPoke(self.bitmap,color)
  79.     end
  80.   end
  81. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement