Display Battler outside of battle

Is there a way to display the battler of an enemy, just by specifying the enemy, x, and y value to display it in?  I am creating windows for a bestiary in my game, so that's why I ask.  I've looked at Sprite_Battler, and Spriteset_Battle, but I don't understand viewports, and I can see how a Spriteset_Battle gets which battlers to display.  Its initialize method doesn't have parameters.  Any help would be appreciated! 
If you want to draw it on a window, you can try to use this method:

Spoiler
Spoiler




class Bitmap

  def draw_enemy(id,x,y,opa=255,hue=nil)
    return if $data_enemies[id].nil?
    name = $data_enemies[id].battler_name
    hue = hue.nil? ? $data_enemies[id].battler_hue : hue
    bitmap = Cache.battler(filename, hue)
    rc = Rect.new(0,0,bitmap.width,bitmap.height)
    self.blt(x,y,bitmap,rc,opa) 
end
  
end



Enter this anywhere you want in your script editor.


After that, you can use the method inside window classes as:

Code:
contents.draw_enemy(enemy_id,x,y,opacity,hue)



The opacity and hue arguments are optional, so you can leave them out if you want.


The default value for opacity is 255, and the hue will take the default hue the enemy has in the database settings.


You can use this method on any bitmap, not just on windows (so sprites which use bitmaps can use it too) if needed as well.


The classes you mentioned use sprites to display them, but you don't need sprites if you are working with window classes (at least in most cases).


Ohh, and I did not test the method above, but it should work. If it doesn't, let me know.
Ohh, and I did not test the method above, but it should work. If it doesn't, let me know.

Actually, there is an error on the 7th line, 


"undefined local variable or method 'filename' for


#<Bitmap ..... >"


But it is fixed by changing 'filename' to just 'name'


Thanks a lot for the script!
Whoops, I forgot to change that when I copy/pasted the code bits together, sorry! 😀


You are welcome!

Original thread: https://forums.rpgmakerweb.com/threads/display-battler-outside-of-battle.55366/