roninator2

Venka Bestiary v1.8.2 - fixed bugs

Dec 4th, 2024
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 97.68 KB | None | 0 0
  1. #==============================================================================
  2. # ▼ Venka's Bestiary v1.8.2                                Updated: 01/21/2014
  3. #   author: Venka
  4. #==============================================================================
  5. # - Changelog -
  6. #------------------------------------------------------------------------------
  7. # 01/21/2014 - Added in a section for debuff resistances.
  8. #            - Fixed display issue when a resistance was set to 120%
  9. #            - Added compatibility with Yanfly's Element Absorb script
  10. #            - Added a spot to set the text color for Immunity and Absorbtion
  11. #            - Fixed a bug that wasn't displaying state immunities.
  12. # 12/05/2014 - Stats will now correct if passive stats boost them for states
  13. #              and elements as well.
  14. # 12/03/2014 - Stats will now correct if passive stats boost them
  15. # 11/30/2014 - Fixed issue with manually adding enemy entries.
  16. # 11/09/2014 - Added in a scroll speed setting so you can speed up the scroll
  17. #              when viewing information about an enemy.
  18. #            - Added in stats revealed by kill counts. You can set what
  19. #              information will be shown after you kill an enemy x amount of
  20. #              times
  21. # 10/27/2014 - Forgot to dispose of the instructions on the battle scene.
  22. # 10/14/2014 - Added ability to store quotes for the Actor's Input addon.
  23. #            - Added KilloZapit's Word Wrapper support
  24. # 09/24/2014 - Adjusted the contents of the bestiary stat windows so be able
  25. #              to show large amounts of elements and states. The window panes
  26. #              are now scrollable to view all the information.
  27. #            - The scan window in battle was also updated in the above way.
  28. # 09/21/2014 - Fixed a bug if no categories are set up in the enemy note tags.
  29. # 09/14/2014 - changed the name of one of the methods so it's compatiable with
  30. #              some of my other scripts.
  31. # 08/14/2014 - Released for code off challenge
  32. # 10/13/2022 - Fixed crashes and memory leaks - Roninator2
  33. #------------------------------------------------------------------------------
  34. # - Author's Note -
  35. #------------------------------------------------------------------------------
  36. # Just a quick note. This script was written for the Code Off Challenge found
  37. # here: http://forums.rpgmakerweb.com/index.php?/forum/102-code-off-challenge/
  38. #------------------------------------------------------------------------------
  39. # - Terms -
  40. #------------------------------------------------------------------------------
  41. # This script can be used commercially or non-commercially. If it's used
  42. # commercially, I'd like a PM via the forums with a link to the game so I can
  43. # follow it's progress.. but this isn't required ;) Just a I'd like to take a
  44. # peak type of thing :)
  45. #------------------------------------------------------------------------------
  46. # - Introduction -
  47. #------------------------------------------------------------------------------
  48. # This script will give you a scene that you can track the enemies you've
  49. # discovered and/or killed. It will keep track of the enemy's stats, skills,
  50. # drops, resistances to elements and status effects as well as showing a
  51. # description and image of the enemy.
  52. #------------------------------------------------------------------------------
  53. # - Instructions -
  54. #------------------------------------------------------------------------------
  55. # This script will work if you drop it into your game project. Knowledge of
  56. # note tagging will help take advantage of all the features.
  57. #
  58. #------------------------------------------------------------------------------
  59. # - Enemy Note Tags -
  60. #------------------------------------------------------------------------------
  61. # You can set a custom description for each enemy. If you skip this notetag,
  62. # then it'll use the description set at Default_Description. The text will
  63. # take the same codes you use in message windows but you'll need to add an
  64. # extra \ before each. So \C[1] will need to be \\C[1]. You can use KilloZapit's
  65. # word wrapper to auto fit the text into the box for you or use | to start a
  66. # new line of text if you don't want to use KilloZapit's Word Wrapper.
  67. # See the demo enemy note tag boxes for examples.
  68. #    <description1: your text goes here>
  69. #
  70. # When in the Bestiary Scene, enemies will appear on a background that looks
  71. # the battleback images. You can set the default images used and set images to
  72. # use for each Category you set up. However, if you'd like certain enemies to
  73. # have their very own images that's different from the default or category
  74. # images then use the following tags:
  75. #    <bg_floor: file>   - It'll look for the file in Battlebacks1 and if not
  76. #                         found, then it'll look in the Pictures folder.
  77. #    <bg_wall: file>    - It'll look for the file in Battlebacks2 and if not
  78. #                         found, then it'll look in the Pictures folder.
  79. # NOTE: Do not put ""'s around the file's name. If you want to use a single
  80. # file, then set either the bg_floor or bg_wall to the image you want to use
  81. # and set the other one to nil.
  82. #
  83. # Sometimes there are enemies that you do not want to track or if you are like
  84. # me, you like to sort your database in sections and use labels. To make sure
  85. # none of these database entries make it into the bestiary scene, use this tag:
  86. #    <skip>             - when this tag is used, no entry will be made
  87. #
  88. # Some games have multiple database entries of the same enemy but they change
  89. # the stats a little for variance or change the graphic for varity. But they
  90. # are all still considered the same enemy. In this case you can use this tag
  91. # so no matter which one you encounter, it'll only show one entry.
  92. #    <shown_id: x>      - x is the database ID to use in the Bestiary
  93. #
  94. # The category tag will be the most used tag. You can set up categories in
  95. # the customize section. You can sort your Bestiary Scene any way you like.
  96. # For example could have Common Enemies, Rare Enemies, Boss Enemies, Elite, etc
  97. # or by location like in this demo. An enemy can appear in multiple categories.
  98. # Use the following tag to set the enemy's category:
  99. #    <category: x>     - x is the Category ID defined below.
  100. #
  101. # To make an enemy immune to scans, use the following code
  102. #    <no_scan>         - enemy is immune to scan skill
  103. #
  104. #------------------------------------------------------------------------------
  105. # - Item/Skill Note Tags -
  106. #------------------------------------------------------------------------------
  107. # The last note tag can go in a skill or items note tag. It allows you to scan
  108. # an emeny to learn information about it.
  109. #    <scan>            - When used on an enemy, it unlocks information
  110. #
  111. #------------------------------------------------------------------------------
  112. # - Script Call -
  113. #------------------------------------------------------------------------------
  114. #                      - Manually Add Bestiary Entry -
  115. # Just incase you need to manually add a bestiary entry, use the following:
  116. #     add_enemy_entry(enemy_id)   - enemy_id is the id in the Database
  117. #
  118. #              - Changing Enemy's Description via script call -
  119. # You can change an enemy's description with a script call. When you set a
  120. # description with the script call it will override any other description text
  121. # that is found (the default description or custom descriptions by kills).
  122. # To set the description by script call use the following format:
  123. #     set_enemy_description(enemy_id, text)    - enemy_id is the database id
  124. #                                              - text is text shown.
  125. # The text follows the same rules as all the other description text. You can
  126. # use message codes to change text color, size, use icons.. etc. Use | to form
  127. # a line break. If you want the description to be blank, then set text to "".
  128. #
  129. # To reset the description text back to what it'd normally be use:
  130. #     reset_enemy_description(enemy_id)        - enemy_id is the database id
  131. #
  132. #              - Getting the kill count for an Enemy -
  133. # You can get the amount of times you've killed a given enemy should you need
  134. # it for a conditional check or whatever reason. Use:
  135. #     enemy_kill_count(enemy_id)               - enemy_id is the database id
  136. #
  137. # NOTE: If the enemy_id given has the <shown_id: x> in it, then it'll go to
  138. #       the enemy id pointed to by the note tag.
  139. #==============================================================================
  140. # ■ Configuration
  141. #==============================================================================
  142. $imported ||= {}; $imported[:Venka_Bestiary] = true
  143. module Venka; module Bestiary
  144.  
  145.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  146.   # - General Settings -
  147.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  148.   Windowskin       = "Window"    # Set to nil for default skin.
  149.   Window_Opacity   = 255         # Window's over all opacity. Number 0 - 255
  150.   Window_BGOpacity = 180         # Window's background opacity (default 192)
  151.   Use_Dividers = true            # Draw divider lines to break up info?
  152.   Line_Color = [150, 150, 250, 225] # [Red, Blue, Green, Alpha] color for lines
  153.   Frame_Image = false            # Draw window border around the enemy image?
  154.   Menu_Access = true             # Access to Bestiary from the menu?
  155.   BG_Image = "Book"              # Found in Title1 or Pictures Folder
  156.   Bestiary_BGM = ["Theme2", 80, 100] # ["File", Volume, Pitch]. Can set to nil
  157.   Scroll_Speed = 6               # The speed the info moves when ↑↓ pressed
  158.   Track_Progress = true          # This shows completion for each category
  159.   Track_Kills = true             # Track the times you've killed an enemy
  160.   Show_Debuff_Info = true        # Show the debuff info section
  161.   Use_Wordwrapper = true         # Use KilloZapit's word wrapping script to
  162.                                  # handle text
  163.  
  164.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  165.   # - Default Settings -
  166.   #----------------------------------------------------------------------------
  167.   # You can set the default info for the back ground images used for each
  168.   # enemy and the enemy's description if you don't make custom info for each.
  169.   # If you only want to use one background image, then set one to an image
  170.   # found in it's Battleback folder or the Pictures folder and set the other to
  171.   # nil.
  172.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  173.   Default_BGFloor = "Dirt1"      # Default ground image used (Battlebacks1)
  174.   Default_BGWall  = "Forest1"    # Default wall image used (Battlebacks2)
  175.   # The description text can use message codes (ex: \c[1] - changes text color).
  176.   # Use | to force a line break.
  177.   Default_Description = "Not much is known about this |enemy."
  178.   # Descriptions can evolve as you kill more enemies. These descriptions must
  179.   # be set via the note tags. If the description isn't set, then it will skip
  180.   # the description and show the lower message or default message instead.
  181.   # Set the kill goals here:
  182.   Description1 = 0               # This message will show at 0 kills
  183.   Description2 = 3               # This message will show after 3 kills
  184.   Description3 = 8               # This message will show after 8 kills
  185.  
  186.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  187.   # - Reveal by Kill Settings -
  188.   #----------------------------------------------------------------------------
  189.   # You can set what information will be shown for enemies by the amount of
  190.   # times they have been killed. Using the scan skill will also unlock all of
  191.   # the following information regardless of the kills for a given enemy.
  192.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  193.   Show_BaseStats   = 3             # Shows base stats: Atk, Def, Mdf, Mat, etc
  194.   Show_Elements    = 3             # Shows elemental resistances
  195.   Show_States      = 5             # Shows state resistances
  196.   Show_DebuffStats = 1             # Shows debuff rates
  197.   Show_Abilities   = 7             # Shows a list of abilities that can be used
  198.   Show_Loot        = 5             # Shows the drop list for the enemy
  199.  
  200.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  201.   # - Text Settings -
  202.   #----------------------------------------------------------------------------
  203.   # You can set all text that appears in the Bestiary scene.
  204.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  205.   Bestiary_Command = "Bestiary"           # Text for the scene in the menu
  206.   Category_Select  = "Select a category"  # Help text for picking a category
  207.   Enemy_Select     = "Select an Enemy"    # Help text for picking an enemy
  208.   Discovered_Text  = "Enemies Discovered" # Text that appears at the bottom
  209.   Percent_Finished = "Completed"          # Percentage completed text
  210.   Unknown_Loot = "Loot Unknown"           # Text to show when loot is unknown
  211.   Unknown_Skills = "Abilities Unkown"     # Text to show when skills are unknown
  212.   View_Stats   = "Statistics"             # Button text for stats
  213.   View_More    = "Other Info"             # Button text for other info
  214.   View_Element = "Elements"               # Button text for element info
  215.   View_States  = "States"                 # Button text for state info
  216.   View_Debuff  = "Debuffs"                # Button text for debuff info
  217.   Stats_Text   = "Base Stats"             # Header text for basic stats
  218.   Element_Text = "Elemental Resistances"  # Header text for element resists
  219.   Status_Text  = "Status Resistances"     # Header text for status resists
  220.   Debuff_Text  = "Debuff Rates"           # Header text for debuff rates
  221.   Loot_Text    = "Rewards"                # List of items you can get
  222.   Skill_Text   = "Abilities"              # Text for skills enemy uses
  223.   Immune_Text  = "Imm"      # Text that appears when enemy is immune to a state
  224.   Absorb_Text  = "Abs"      # Text for element absorbtion (Yanfly Element Absorb Script)
  225.   Unknown_Stat = "??"       # Text for unkown resistance/stat
  226.   # For the next two settings, you can set the icon or text to nil if you don't
  227.   # want to use the icon or text
  228.   Exp_Text  = ["Exp:",  117]              # Text and Icon for Exp
  229.   Gold_Text = ["Gold:", 262]              # Text and Icon for Gold
  230.   Kills_Text = "Kills"                    # Text shown from enemies killed
  231.   Instructions_Text = "Use PageUp and PageDown to change enemies."
  232.   Battle_Instructions = "Press Shift to see more info about the target."
  233.  
  234.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  235.   # - Scan Skill Setting -
  236.   #----------------------------------------------------------------------------
  237.   # You can set stuff for the scan skill here. Mostly this is setting text
  238.   # that appears in the game. You can also set the key that is pressed to
  239.   # make the pop up window show when you select an enemy in the enemy window.
  240.   # NOTE: The window will pop up on a successful scan as well
  241.   #
  242.   # Key options are:                   :A  - this is the Shift key
  243.   #   :X   - this is the A key         :Y  - this is the S key
  244.   #   :Z   - this is the D key         :L  - this is PageUp/Q Keys
  245.   #   :R   - this is PageDw/W keys     :SHIFT, :CTRL, :ATL - shift, cntl, atl keys
  246.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  247.   Target_Scanned = "%s scanned!"   # Battle message when successfully scanned
  248.   No_Scan = "%s can't be scanned!" # Battle message when target can't be scanned
  249.   No_Info = "No information found" # Text when the target is immune to scans.
  250.   Scan_PopUp = :SHIFT              # Input key to make the window pop up
  251.  
  252.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  253.   # - List Sort Setting -
  254.   #----------------------------------------------------------------------------
  255.   # You can set how the list will sort. You can sort it by order discovered
  256.   # (discovery order should be the default), by their database id, or name.
  257.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  258.   Sort_Type = :id      # choices are :id, :name, or :default
  259.  
  260.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  261.   # - Font Settings -
  262.   #----------------------------------------------------------------------------
  263.   # :help_font    = font that appears in the top and bottom windows
  264.   # :list_font    = font in the list windows
  265.   # :header_font  = font used for statistic types
  266.   # :stat_font    = font used for statistics
  267.   # :description  = font for enemy description text.
  268.   #
  269.   # For each text type you need to set up the Fonts, Size, Boldness and Color.
  270.   # Use the following format:
  271.   #   [["Font_Name, Font_Name, etc], Font_Size, Bold?, Color]],
  272.   #      Font_Name = an array holding font choices. The fist one is your first
  273.   #         choice to use, but if the player doesn't have that font on their
  274.   #         computer, it will go through the list until it finds one it can use
  275.   #      Font_Size = the size font you want to use
  276.   #      Bold? = this should be true for bold, false to turn bold off
  277.   #      Color = This is the same format as setting colors for Gauge Color.
  278.   #         Use [red, blue, green, opacity] or window skin color number.
  279.   #      Outline? = this turns the font's outline on or off
  280.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  281.   Fonts = {       # [["Fonts"]],           Size, Bold?, Color, Outline?
  282.     :normal_font => [["Calibri", "Sylfaen"], 24, false,  0,      true],
  283.     :list_font   => [["Calibri", "Sylfaen"], 24, false,  0,      true],
  284.     :header_font => [["Calibri", "Sylfaen"], 23,  true,  1,      true],
  285.     :stat_name   => [["Calibri", "Sylfaen"], 20,  true,  0,      true],
  286.     :stats_font  => [["Calibri", "Sylfaen"], 20, false,  0,      true],
  287.     :description => [["Calibri", "Sylfaen"], 22, false,  0,      true],
  288.     } # <- DO NOT REMOVE
  289.   # The two color settings below can be windowskin colors or [red, blue, green]
  290.   High_Resist = 3       # Color used for high resistances
  291.   Low_Resist  = 18      # Color used for low resistances (weaknesses)
  292.   Immunity_Color = 17   # Color used for immunity/absorb text
  293.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  294.   # - Battle Font Settings -
  295.   #----------------------------------------------------------------------------
  296.   # The battle font is slightly different then the font that appears in windows.
  297.   # For this one, colors MUST be in [red, blue, green] format.
  298.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  299.   #                   Font Family,      Size, Bold?,    Color,     Outline?]
  300.   Battle_Font = [["Calibri", "Sylfaen"], 24,  true, [255,255,255],   true]
  301.  
  302.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  303.   # - Base Stat Settings -
  304.   #----------------------------------------------------------------------------
  305.   # Set the text and/or Icon used for base stats (HP, MP, Attack, etc)
  306.   # You can set either the text or the icon to nil to omit them.
  307.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  308.   Base_Stats = [] #["Text", IconIndex]
  309.   Base_Stats[0] = ["HP",   122]  # Max Health
  310.   Base_Stats[1] = ["MP",   112]  # Max Mana
  311.   Base_Stats[2] = ["Atk",  116]  # Attack
  312.   Base_Stats[3] = ["Def",  161]  # Defense
  313.   Base_Stats[4] = ["MAtk", 113]  # Magical Attack
  314.   Base_Stats[5] = ["MDef",  15]  # Magical Defense
  315.   Base_Stats[6] = ["Agi",   12]  # Agility
  316.   Base_Stats[7] = ["Luck", 202]  # Luck
  317.  
  318.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  319.   # - Element Settings -
  320.   #----------------------------------------------------------------------------
  321.   # Elements you want to track. Prioritize the elements. In the default game
  322.   # resolution, about 9 icons will show. If you make the screen wider, then
  323.   # more could be shown. So list the icons you want to show in order of
  324.   # importance.
  325.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  326.   Elements = [
  327.   # [ID, IconIndex],
  328.     [3,  104],   # Fire
  329.     [4,  105],   # Ice
  330.     [5,  106],   # Thunder
  331.     [6,  107],   # Water
  332.     [7,  108],   # Earth
  333.     [8,  109],   # Wind
  334.     [9,  110],   # Holy
  335.     [10, 111],   # Dark
  336.     ] # <- DO NOT REMOVE!!
  337.    
  338.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  339.   # - State Settings -
  340.   #----------------------------------------------------------------------------
  341.   # This is just like setting the Elements, but there is no need to define an
  342.   # icon because all that status/states have an icon set in the database.
  343.   # So for this one, just set the status id's that you want to track in order
  344.   # of priority.
  345.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  346.   States = [1, 2, 3, 4, 5, 6, 7, 8]
  347.  
  348.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  349.   # - Category Settings -
  350.   #----------------------------------------------------------------------------
  351.   # You can set up categories that the enemies will be sorted into. This can
  352.   # be by whatever you like. For example you could sort them by breed (mammal,
  353.   # avian, demon, etc) or by region (Forest, River, Mountains, etc). You must
  354.   # set up all the categories here and then use a note tag Enemies Tab of the
  355.   # database to set it.
  356.   #
  357.   #   Category[ID] = {               # ID must be a unique number.
  358.   #    :name => "Miscellaneous",     # Name of Category as it appears in scene
  359.   #    :bg_floor => "file",          # Image used if not default (can omit)
  360.   #    :bg_wall  => "file",          # Image used if not default (can omit)
  361.   #           file = file used instead of the default image. Set to "" if you
  362.   #                  want to use no image.
  363.   #    }
  364.   #
  365.   # NOTE: both the floor and wall images can be omited to use the default
  366.   # images. If using a single image, then set one or the other to the image
  367.   # you want to use (found in the corrosponding battleback folder or the
  368.   # picture's folder) and then set the other to "" (a blank file). Do not set
  369.   # the other image to nil as this will pick up the default image.
  370.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  371.   Category ||= {}
  372.   #----------------------------------------------------------------------------
  373.   Category[0] = {  # This is the default category. Enemies appear in this
  374.       # category if they don't have one assigned or there was a typo in the tag.
  375.       :name => "Miscellaneous",
  376.       } # <-DO NOT REMOVE
  377.   #----------------------------------------------------------------------------
  378.   Category[1] = {  # Enemies found in the Forsaken Forest area
  379.       :name => "Forsaken Forest",  # Name of Category
  380.       :bg_floor => "Meadow",       # Floor image used
  381.       :bg_wall  => "Forest2",      # Wall image used
  382.       }
  383.   #----------------------------------------------------------------------------
  384.   Category[2] = {  # Enemies found in the Abandoned Mines area
  385.       :name => "Abandoned Mines",  # Name of Category
  386.       :bg_floor => "DirtCave",     # Floor image used
  387.       :bg_wall  => "Mine",         # Wall image used
  388.       }
  389.   #----------------------------------------------------------------------------
  390.   Category[3] = {  # Enemies found in the Deep Space area
  391.       :name => "Deep Space",       # Name of Category
  392.       :bg_floor => "DarkSpace",    # Floor image used (Single image used)
  393.       :bg_wall  => "",             # Wall image used
  394.       }
  395.   #----------------------------------------------------------------------------
  396.   Category[4] = {  # Enemies found in the Nocturnal Plains area
  397.       :name => "Nocturnal Plains",     # Name of Category
  398.       :bg_floor => "GrassMaze",        # Floor image used
  399.       :bg_wall  => "PoisonSwamp",      # Wall image used
  400.       }
  401.   #----------------------------------------------------------------------------
  402.   Category[5] = {  # Undead Enemies
  403.       :name => "Undead",               # Name of Category
  404.       :bg_floor => "DemonCastle",      # Floor image used
  405.       :bg_wall  => "DemonCastle1",     # Wall image used
  406.       }
  407.   #----------------------------------------------------------------------------
  408.   Category[6] = {  # Enemies found in the Nocturnal Plains area
  409.       :name => "Bosses",            # Name of Category
  410.       :bg_floor => "Cobblestones3", # Floor image used
  411.       :bg_wall  => "Cliff",         # Wall image used
  412.       }
  413. #==============================================================================
  414. # ■ Edits should stop here unless you know what you're doing :)
  415. #==============================================================================
  416.   end
  417.   module Notetag
  418.     Skip_Enemy = /<skip>/i
  419.     Enemy_Category = /<category:\s*(\d+(?:\s*,\s*\d+)*)>/i
  420.     BG_Floor   = /<bg_floor:\s*(\w+)>/i
  421.     BG_Wall    = /<bg_wall:\s*(\w+)>/i
  422.     Enemy_Desc1 = /<description1:\s*(.*)>/i
  423.     Enemy_Desc2 = /<description2:\s*(.*)>/i
  424.     Enemy_Desc3 = /<description3:\s*(.*)>/i
  425.     Shown_ID   = /<shown_id:\s*(\d+)>/i
  426.     Scan_Skill = /<scan>/i
  427.     No_Scan    = /<no_scan>/i
  428.   end
  429. end
  430. #------------------------------------------------------------------------------
  431. # ○ Creating a way to store discovered info about the enemy with Struct.
  432. #------------------------------------------------------------------------------
  433. Bestiary_Entry = Struct.new(:enemy_id, :category, :elements, :states, :kills,
  434.     :quotes, :scanned)
  435. #==============================================================================
  436. # ■ Vocab
  437. #==============================================================================
  438. module Vocab
  439.   # Scan Skill
  440.   Scanned = Venka::Bestiary::Target_Scanned
  441.   No_Scan = Venka::Bestiary::No_Scan
  442. end
  443. #==============================================================================
  444. # ■ DataManager
  445. #==============================================================================
  446. module DataManager
  447.   #----------------------------------------------------------------------------
  448.   # ● alias method: load_database
  449.   #----------------------------------------------------------------------------
  450.   class << self;  alias bestiary_db_notetags load_database;   end
  451.   def self.load_database
  452.     bestiary_db_notetags
  453.     load_bestiary_notetags
  454.   end
  455.   #----------------------------------------------------------------------------
  456.   # ○ new method: load_bestiary_notetags
  457.   #----------------------------------------------------------------------------
  458.   def self.load_bestiary_notetags
  459.     ($data_enemies + $data_skills + $data_items).compact.each do |item|
  460.       item.load_bestiary_notetags
  461.     end
  462.   end
  463. end
  464. #==============================================================================
  465. # ■ RPG::UsableItem
  466. #==============================================================================
  467. class RPG::UsableItem
  468.   #----------------------------------------------------------------------------
  469.   # ♦ Public Instance Variables
  470.   #----------------------------------------------------------------------------
  471.   attr_accessor :scan
  472.   #----------------------------------------------------------------------------
  473.   # ○ new method: load_bestiary_notetags
  474.   #----------------------------------------------------------------------------
  475.   def load_bestiary_notetags
  476.     @scan = false
  477.     self.note.split(/[\r\n]+/).each do |line|
  478.       info = []
  479.       case line
  480.       when Venka::Notetag::Scan_Skill;        @scan = true
  481.       end
  482.     end
  483.   end
  484. end
  485. #==============================================================================
  486. # ■ RPG::Enemy
  487. #==============================================================================
  488. class RPG::Enemy
  489.   #----------------------------------------------------------------------------
  490.   # ♦ Public Instance Variables
  491.   #----------------------------------------------------------------------------
  492.   attr_accessor :skip, :category, :bg_floor, :bg_wall, :description, :shown_id
  493.   attr_accessor :no_scan, :descript1, :descript2, :descript3
  494.   #----------------------------------------------------------------------------
  495.   # ○ new method: load_bestiary_notetags
  496.   #----------------------------------------------------------------------------
  497.   def load_bestiary_notetags
  498.     @skip = false
  499.     @category = [0]
  500.     @bg_floor = @bg_wall = ""
  501.     @shown_id = @id
  502.     @no_scan = false
  503.     @description = nil
  504.     @descript1 = @descript2 = @descript3 = nil
  505.     self.note.split(/[\r\n]+/).each do |line|
  506.       info = []
  507.       case line
  508.       when Venka::Notetag::Skip_Enemy;        @skip = true
  509.       when Venka::Notetag::No_Scan;           @no_scan = true
  510.       when Venka::Notetag::Enemy_Category
  511.         $1.scan(/\d+/).each { |num| info.push(num.to_i) }
  512.         @category = info ? info : 0
  513.       when Venka::Notetag::BG_Floor;          @bg_floor = $1.to_s
  514.       when Venka::Notetag::BG_Wall;           @bg_wall = $1.to_s
  515.       when Venka::Notetag::Enemy_Desc1;       @descript1 = $1.to_s
  516.       when Venka::Notetag::Enemy_Desc2;       @descript2 = $1.to_s
  517.       when Venka::Notetag::Enemy_Desc3;       @descript3 = $1.to_s
  518.       when Venka::Notetag::Shown_ID;          @shown_id = $1.to_i
  519.       end
  520.     end
  521.   end
  522. end
  523. #==============================================================================
  524. # ■ BattleManager
  525. #==============================================================================
  526. module BattleManager
  527.   #----------------------------------------------------------------------------
  528.   # ● alias method: battle_start
  529.   #----------------------------------------------------------------------------
  530.   class << self;  alias bestiary_battle_start battle_start;   end
  531.   def self.battle_start
  532.     bestiary_battle_start
  533.     add_bestiary_enemies
  534.   end
  535.   #----------------------------------------------------------------------------
  536.   # ○ new method: add_bestiary_enemies
  537.   #----------------------------------------------------------------------------
  538.   def self.add_bestiary_enemies
  539.     $game_troop.members.each do |enemy|
  540.       rpg_enemy = $data_enemies[enemy.enemy_id]
  541.       next if rpg_enemy.nil? || rpg_enemy.skip
  542.       unless $game_party.bestiary_include?(rpg_enemy.shown_id)
  543.         $game_party.add_enemy($data_enemies[rpg_enemy.shown_id])
  544.       end
  545.     end
  546.   end
  547. end
  548. #==============================================================================
  549. # ■ Game_Enemy
  550. #==============================================================================
  551. class Game_Enemy < Game_Battler
  552.   #----------------------------------------------------------------------------
  553.   # ● upgraded method: add_state
  554.   #----------------------------------------------------------------------------
  555.   def add_state(state_id)
  556.     Venka::Bestiary::States.each_with_index do |id, i|
  557.       next unless state_id == id
  558.       $game_party.bestiary.each do |enemy|
  559.         next unless enemy.enemy_id == $data_enemies[@enemy_id].shown_id
  560.         enemy.states[i] = true
  561.       end
  562.     end
  563.     super
  564.   end
  565. end
  566. #==============================================================================
  567. # ■ Game_Troop
  568. #==============================================================================
  569. class Game_Troop < Game_Unit
  570.   #----------------------------------------------------------------------------
  571.   # ● alias method: battle_start
  572.   #----------------------------------------------------------------------------
  573.   alias bestiary_kill_count make_drop_items
  574.   def make_drop_items
  575.     add_encounter_count
  576.     bestiary_kill_count
  577.   end
  578.   #----------------------------------------------------------------------------
  579.   # ○ new method: add_encounter_count
  580.   #----------------------------------------------------------------------------
  581.   def add_encounter_count
  582.     dead_members.each do |enemy|
  583.       rpg_enemy = $data_enemies[enemy.enemy_id]
  584.       next if rpg_enemy.nil? || rpg_enemy.skip
  585.       $game_party.bestiary.each do |entry|
  586.         next unless entry.enemy_id == rpg_enemy.shown_id
  587.         entry.kills += 1
  588.         if entry.kills >= Venka::Bestiary::Show_Elements
  589.           entry.elements.size.times {|i| entry.elements[i] = true}
  590.         end
  591.         if entry.kills >= Venka::Bestiary::Show_States
  592.           entry.states.size.times {|i| entry.states[i] = true}
  593.         end
  594.       end
  595.     end
  596.   end
  597. end
  598. #==============================================================================
  599. # ■ Game_Party
  600. #==============================================================================
  601. class Game_Party < Game_Unit
  602.   #----------------------------------------------------------------------------
  603.   # ♦ Public Instance Variables
  604.   #----------------------------------------------------------------------------
  605.   attr_accessor   :bestiary
  606.   #----------------------------------------------------------------------------
  607.   # ● alias method: initialize
  608.   #----------------------------------------------------------------------------
  609.   alias venka_bestiary_enounters_ini initialize
  610.   def initialize
  611.     venka_bestiary_enounters_ini
  612.     @bestiary = []
  613.   end
  614.   #----------------------------------------------------------------------------
  615.   # ○ new method: add_enemy
  616.   #----------------------------------------------------------------------------
  617.   # The entries are: EnemyID, BestiaryCategory, Array for Element info,
  618.   #   Array for State info, Kill Counter, Actor Quotes, and Scanned?
  619.   #----------------------------------------------------------------------------
  620.   def add_enemy(enemy)
  621.     @bestiary << Bestiary_Entry.new(enemy.id, enemy.category,
  622.         Array.new(Venka::Bestiary::Elements.size, false),
  623.         Array.new(Venka::Bestiary::States.size, false), 0, [], false)
  624.   end
  625.   #----------------------------------------------------------------------------
  626.   # ○ new method: reveal_resist
  627.   #----------------------------------------------------------------------------
  628.   def reveal_resist(enemy_id, reveal = true)
  629.     rpg_enemy = $data_enemies[enemy_id]
  630.     return if rpg_enemy.nil? || rpg_enemy.skip
  631.     @bestiary.each do |entry|
  632.       next unless entry.enemy_id == rpg_enemy.shown_id
  633.       next if rpg_enemy.no_scan && !reveal
  634.       entry.elements.size.times {|i| entry.elements[i] = true}
  635.       entry.states.size.times {|i| entry.states[i] = true}
  636.     end
  637.   end
  638.   #----------------------------------------------------------------------------
  639.   # ○ new method: bestiary_include?
  640.   #----------------------------------------------------------------------------
  641.   def bestiary_include?(id)
  642.     @bestiary.each do |entry|
  643.       return true if entry.enemy_id == id
  644.     end
  645.     return false
  646.   end
  647. end
  648. #==============================================================================
  649. # ■ Game_Interpreter
  650. #==============================================================================
  651. class Game_Interpreter
  652.   #----------------------------------------------------------------------------
  653.   # ○ new method: add_enemy_entry
  654.   #----------------------------------------------------------------------------
  655.   def add_enemy_entry(enemy_id)
  656.     rpg_enemy = $data_enemies[enemy_id]
  657.     return if rpg_enemy.nil? || rpg_enemy.skip
  658.     if $game_party.bestiary == []
  659.       $game_party.add_enemy($data_enemies[rpg_enemy.shown_id])
  660.     elsif !$game_party.bestiary_include?(rpg_enemy.shown_id)
  661.       $game_party.add_enemy($data_enemies[rpg_enemy.shown_id])
  662.     end
  663.   end
  664.   #----------------------------------------------------------------------------
  665.   # ○ new method: set_enemy_description
  666.   #----------------------------------------------------------------------------
  667.   def set_enemy_description(enemy_id, text)
  668.     id = $data_enemies[enemy_id].shown_id
  669.     $data_enemies[id].description = text
  670.   end
  671.   #----------------------------------------------------------------------------
  672.   # ○ new method: reset_enemy_description
  673.   #----------------------------------------------------------------------------
  674.   def reset_enemy_description(enemy_id)
  675.     id = $data_enemies[enemy_id].shown_id
  676.     $data_enemies[id].description = nil
  677.   end
  678.   #----------------------------------------------------------------------------
  679.   # ○ new method: enemy_kill_count(enemy_id)
  680.   #----------------------------------------------------------------------------
  681.   def enemy_kill_count(enemy_id)
  682.     kills = 0
  683.     $game_party.bestiary.each do |entry|
  684.       next unless entry.enemy_id == $data_enemies[enemy_id].shown_id
  685.       kills = entry.kills
  686.       if entry.kills >= Venka::Bestiary::Show_Elements
  687.         entry.elements.size.times {|i| entry.elements[i] = true}
  688.       end
  689.       if entry.kills >= Venka::Bestiary::Show_States
  690.         entry.states.size.times {|i| entry.states[i] = true}
  691.       end
  692.     end
  693.     return kills
  694.   end
  695. end
  696. #==============================================================================
  697. # ■ Window_Base
  698. #==============================================================================
  699. class Window_Base < Window
  700.   #----------------------------------------------------------------------------
  701.   # ○ new method: set_windowskin
  702.   #----------------------------------------------------------------------------
  703.   def set_windowskin
  704.     return unless Venka::Bestiary::Windowskin
  705.     self.windowskin = Cache.system(Venka::Bestiary::Windowskin)
  706.     self.opacity = Venka::Bestiary::Window_Opacity
  707.     self.back_opacity = Venka::Bestiary::Window_BGOpacity
  708.   end
  709.   #----------------------------------------------------------------------------
  710.   # ○ new method: get_color - method determines if text color or new color
  711.   #----------------------------------------------------------------------------
  712.   def get_color(input)
  713.     input.is_a?(Integer) ? text_color([[input, 0].max, 31].min) : Color.new(*input)
  714.   end
  715.   #----------------------------------------------------------------------------
  716.   # ○ new method: font_color
  717.   #----------------------------------------------------------------------------
  718.   def font_color(text_type)
  719.     f_color = Venka::Bestiary::Fonts[text_type][3]
  720.     color = f_color.is_a?(Integer) ? text_color(f_color) : Color.new(*f_color)
  721.   end
  722.   #----------------------------------------------------------------------------
  723.   # ○ new method: set_bestiary_font
  724.   #----------------------------------------------------------------------------
  725.   def set_bestiary_font(text_type, enabled = true)
  726.     font = Venka::Bestiary::Fonts[text_type]
  727.     contents.font.name = font[0]
  728.     contents.font.size = font[1]
  729.     contents.font.bold = font[2]
  730.     contents.font.outline = font[4]
  731.     change_color(font_color(text_type), enabled)
  732.   end
  733.   #----------------------------------------------------------------------------
  734.   # ○ new method: font_height
  735.   #----------------------------------------------------------------------------
  736.   def font_height
  737.     [contents.font.size, 24].max
  738.   end
  739.   #----------------------------------------------------------------------------
  740.   # ○ new method: draw_line
  741.   #----------------------------------------------------------------------------
  742.   def draw_line(y)
  743.     return unless Venka::Bestiary::Use_Dividers
  744.     color = get_color(Venka::Bestiary::Line_Color)
  745.     contents.fill_rect(4, y, contents_width - 8, 2, color)
  746.     contents.fill_rect(4, y + 2, contents_width - 8, 1, Color.new(16,16,16,100))
  747.   end
  748. end
  749. #==============================================================================
  750. # ■ Window_Message
  751. #==============================================================================
  752. class Window_Message
  753.   #----------------------------------------------------------------------------
  754.   # ♦ Public Instance Variables
  755.   #----------------------------------------------------------------------------
  756.   attr_accessor :wordwrap
  757. end
  758. #==============================================================================
  759. # ■ Window_MenuCommand
  760. #==============================================================================
  761. class Window_MenuCommand < Window_Command
  762.   #----------------------------------------------------------------------------
  763.   # ● alias method: add_original_commands
  764.   #----------------------------------------------------------------------------
  765.   alias bestiary_menu_access_aoc       add_original_commands
  766.   def add_original_commands
  767.     bestiary_menu_access_aoc
  768.     add_command(Venka::Bestiary::Bestiary_Command, :bestiary) if Venka::Bestiary::Menu_Access
  769.   end
  770. end
  771. #==============================================================================
  772. # ■ Window_BattleLog
  773. #==============================================================================
  774. class Window_BattleLog < Window_Selectable
  775.   #----------------------------------------------------------------------------
  776.   # ● alias method: display_failure
  777.   #----------------------------------------------------------------------------
  778.   alias bestiary_scan_fail_msg display_failure
  779.   def display_failure(target, item)
  780.     if item.scan && target.result.hit? && !target.result.success
  781.       text = $data_enemies[target.enemy_id].no_scan ? Vocab::No_Scan : Vocab::Scanned
  782.       add_text(sprintf(text, target.name))
  783.       wait
  784.     else
  785.       bestiary_scan_fail_msg(target, item)
  786.     end
  787.   end
  788. end
  789. #==============================================================================
  790. # ■ Window_BestiaryHelp
  791. #==============================================================================
  792. class Window_BestiaryHelp < Window_Base
  793.   #----------------------------------------------------------------------------
  794.   # ● upgraded method: initialize
  795.   #----------------------------------------------------------------------------
  796.   def initialize(x, y)
  797.     height = [Venka::Bestiary::Fonts[:normal_font][1], 24].max + 24
  798.     super(x, y, Graphics.width, height)
  799.     set_windowskin
  800.   end
  801.   #----------------------------------------------------------------------------
  802.   # ○ new method: set_text
  803.   #----------------------------------------------------------------------------
  804.   def set_text(text)
  805.     contents.clear
  806.     set_bestiary_font(:normal_font)
  807.     draw_text(0, 0, contents.width, font_height, text, 1)
  808.   end
  809.   #----------------------------------------------------------------------------
  810.   # ○ new method: draw_completion
  811.   #----------------------------------------------------------------------------
  812.   def draw_completion
  813.     contents.clear
  814.     draw_enemies_discovered
  815.   end
  816.   #----------------------------------------------------------------------------
  817.   # ○ new method: draw_enemies_discovered
  818.   #----------------------------------------------------------------------------
  819.   def draw_enemies_discovered
  820.     set_bestiary_font(:normal_font)
  821.     enemies_discovered = $game_party.bestiary.size
  822.     total = total_enemies
  823.     text = "#{enemies_discovered}/#{total} #{Venka::Bestiary::Discovered_Text}"
  824.     draw_text(0, 0, contents.width, font_height, text)
  825.     discovered = (enemies_discovered.to_f / total) * 100
  826.     text = "#{discovered.round(1)}% #{Venka::Bestiary::Percent_Finished}"
  827.     draw_text(0, 0, contents.width, font_height, text, 2)
  828.   end
  829.   #----------------------------------------------------------------------------
  830.   # ○ new method: total_enemies
  831.   #----------------------------------------------------------------------------
  832.   def total_enemies
  833.     total = 0
  834.     for i in 1...$data_enemies.size
  835.       next if $data_enemies[i].shown_id != $data_enemies[i].id
  836.       total += 1 unless $data_enemies[i].skip
  837.     end
  838.     total
  839.   end
  840.   #----------------------------------------------------------------------------
  841.   # ○ new method: draw_instructions
  842.   #----------------------------------------------------------------------------
  843.   def draw_instructions
  844.     contents.clear
  845.     set_bestiary_font(:normal_font)
  846.     text = Venka::Bestiary::Instructions_Text
  847.     draw_text(0, 0, contents.width, font_height, text, 1)
  848.   end
  849.   #----------------------------------------------------------------------------
  850.   # ○ new method: set_description
  851.   #----------------------------------------------------------------------------
  852.   def set_description(enemy)
  853.     contents.clear
  854.     create_contents             # Remake contents since the window size changed
  855.     get_description_text(enemy)
  856.     text = get_description_text(enemy)
  857.     if Venka::Bestiary::Use_Wordwrapper
  858.       wrapping = @wordwrap
  859.       @wordwrap = true
  860.       draw_text_ex(0, 0, text.gsub(/[|]/, ""))
  861.       @wordwrap = wrapping
  862.     else
  863.       draw_text_ex(0, 0, text.gsub(/[|]/, "\n"))
  864.     end
  865.   end
  866.   #----------------------------------------------------------------------------
  867.   # ○ new method: get_description_text
  868.   #----------------------------------------------------------------------------
  869.   def get_description_text(enemy)
  870.     if enemy.description
  871.       text = enemy.description
  872.     else
  873.       text = Venka::Bestiary::Default_Description
  874.       kills = 0
  875.       $game_party.bestiary.each do |foe|
  876.         kills = foe.kills if foe.enemy_id == enemy.shown_id
  877.       end
  878.       if kills >= Venka::Bestiary::Description3 && enemy.descript3
  879.         text = enemy.descript3
  880.       elsif kills >= Venka::Bestiary::Description2 && enemy.descript2
  881.         text = enemy.descript2
  882.       elsif kills >= Venka::Bestiary::Description1 && enemy.descript1
  883.         text = enemy.descript1
  884.       end
  885.     end
  886.     text
  887.   end
  888.   #----------------------------------------------------------------------------
  889.   # ● upgraded method: draw_text_ex
  890.   #----------------------------------------------------------------------------
  891.   def draw_text_ex(x, y, text)
  892.     set_bestiary_font(:description)
  893.     text = convert_escape_characters(text)
  894.     pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
  895.     process_character(text.slice!(0, 1), text, pos) until text.empty?
  896.   end
  897. end
  898. #==============================================================================
  899. # ■ Window_BestiaryCategory
  900. #==============================================================================
  901. class Window_BestiaryCategory < Window_Command
  902.   #----------------------------------------------------------------------------
  903.   # ● upgraded method: initialize
  904.   #----------------------------------------------------------------------------
  905.   def initialize(x, y)
  906.     @wy = y
  907.     @categories = Venka::Bestiary::Category
  908.     super(x, @wy)
  909.     set_windowskin
  910.   end
  911.   #----------------------------------------------------------------------------
  912.   # ● window settings
  913.   #----------------------------------------------------------------------------
  914.   def window_width;  Graphics.width * 0.5;                                end
  915.   def window_height; Graphics.height - (@wy * 2);                         end
  916.   def item_height;   [Venka::Bestiary::Fonts[:list_font][1], 24].max;     end
  917.   #----------------------------------------------------------------------------
  918.   # ● upgraded method: make_command_list
  919.   #----------------------------------------------------------------------------
  920.   def make_command_list
  921.     @categories.each{|key, info| add_command(info[:name], key)}
  922.   end
  923.   #----------------------------------------------------------------------------
  924.   # ● upgraded method: draw_item
  925.   #----------------------------------------------------------------------------
  926.   def draw_item(index)
  927.     set_bestiary_font(:normal_font)
  928.     @width = Venka::Bestiary::Track_Progress ? text_size("99.9%").width + 5 : 0
  929.     rect = item_rect_for_text(index)
  930.     set_bestiary_font(:list_font)
  931.     draw_text(rect.x, rect.y, rect.width - @width, rect.height, command_name(index))
  932.     found_text(index,  rect) if Venka::Bestiary::Track_Progress
  933.   end
  934.   #----------------------------------------------------------------------------
  935.   # ○ new method: found_text
  936.   #----------------------------------------------------------------------------
  937.   def found_text(index,  rect)
  938.     set_bestiary_font(:normal_font)
  939.     total = total_enemies(index)
  940.     discovered = total_found(index)
  941.     value = (total > 0) ? (discovered.to_f / total) * 100 : 0.0
  942.     text = (value > 0 && value < 100) ? value.round(1) : value.round
  943.     draw_text(rect.width - @width, rect.y, @width, rect.height, "#{text}%", 2)
  944.   end
  945.   #----------------------------------------------------------------------------
  946.   # ○ new method: total_enemies
  947.   #----------------------------------------------------------------------------
  948.   def total_enemies(index)
  949.     total = 0
  950.     for i in 1...$data_enemies.size
  951.       next unless $data_enemies[i].category.include?(index)
  952.       next if $data_enemies[i].shown_id != $data_enemies[i].id
  953.       total += 1 unless $data_enemies[i].skip
  954.     end
  955.     return total
  956.   end
  957.   #----------------------------------------------------------------------------
  958.   # ○ new method: total_found
  959.   #----------------------------------------------------------------------------
  960.   def total_found(index)
  961.     total = 0
  962.     $game_party.bestiary.each {|e| total += 1 if e.category.include?(index)}
  963.     return total
  964.   end
  965. end
  966. #==============================================================================
  967. # ■ Window_BestiaryEnemyList
  968. #==============================================================================
  969. class Window_BestiaryEnemyList < Window_Command
  970.   #----------------------------------------------------------------------------
  971.   # ♦ Public Instance Variables
  972.   #----------------------------------------------------------------------------
  973.   attr_reader   :category_window,    :stats_window
  974.   #----------------------------------------------------------------------------
  975.   # ● upgraded method: initialize
  976.   #----------------------------------------------------------------------------
  977.   def initialize(x, y)
  978.     @category = 0
  979.     @wy = y
  980.     super(x, @wy)
  981.     set_windowskin
  982.   end
  983.   #----------------------------------------------------------------------------
  984.   # ● window settings
  985.   #----------------------------------------------------------------------------
  986.   def window_width;  Graphics.width * 0.5;                                end
  987.   def window_height; Graphics.height - (@wy * 2);                         end
  988.   def item_height;   [Venka::Bestiary::Fonts[:list_font][1], 24].max;     end
  989.   #----------------------------------------------------------------------------
  990.   # ○ new method: category_window
  991.   #----------------------------------------------------------------------------
  992.   def category_window=(category_window)
  993.     if @category_window != category_window
  994.       @category_window = category_window
  995.       @category = category_window.current_symbol.to_s.to_i
  996.       refresh
  997.     end
  998.   end
  999.   #----------------------------------------------------------------------------
  1000.   # ○ new method: stats_window
  1001.   #----------------------------------------------------------------------------
  1002.   def stats_window=(stats_window)
  1003.     if @stats_window != stats_window
  1004.       @stats_window = stats_window
  1005.     end
  1006.   end
  1007.   #----------------------------------------------------------------------------
  1008.   # ● upgraded method: make_command_list
  1009.   #----------------------------------------------------------------------------
  1010.   def make_command_list
  1011.     @enemies = []
  1012.     sort_list
  1013.     @bestiary_list.each do |enemy|
  1014.       next if enemy.nil?
  1015.       next unless enemy.category.include?(@category)
  1016.       @enemies << enemy
  1017.       add_command($data_enemies[enemy.enemy_id].name, :ok, true, enemy.enemy_id)
  1018.     end
  1019.   end
  1020.   #----------------------------------------------------------------------------
  1021.   # ○ new method: sort_list
  1022.   #----------------------------------------------------------------------------
  1023.   def sort_list
  1024.     @bestiary_list = $game_party.bestiary.clone
  1025.     if Venka::Bestiary::Sort_Type == :id                # Sort by enemy id
  1026.       @bestiary_list.sort!{|a, b| a.enemy_id <=> b.enemy_id}
  1027.     elsif Venka::Bestiary::Sort_Type == :name           # Sort by name
  1028.       @bestiary_list.sort!{|a, b|
  1029.         $data_enemies[a.enemy_id].name <=> $data_enemies[b.enemy_id].name}
  1030.     end
  1031.   end
  1032.   #----------------------------------------------------------------------------
  1033.   # ● upgraded method: draw_item
  1034.   #----------------------------------------------------------------------------
  1035.   def draw_item(index)
  1036.     set_bestiary_font(:normal_font)
  1037.     @width = contents_width * 0.33
  1038.     @width = 0 unless Venka::Bestiary::Track_Kills
  1039.     rect = item_rect_for_text(index)
  1040.     set_bestiary_font(:list_font)
  1041.     draw_text(rect.x, rect.y, rect.width - @width, rect.height, command_name(index))
  1042.     draw_kills(index) if Venka::Bestiary::Track_Kills
  1043.   end
  1044.   #----------------------------------------------------------------------------
  1045.   # ○ new method: draw_kills
  1046.   #----------------------------------------------------------------------------
  1047.   def draw_kills(index)
  1048.     set_bestiary_font(:normal_font)
  1049.     text = "#{@enemies[index].kills} #{Venka::Bestiary::Kills_Text}"
  1050.     draw_text(item_rect_for_text(index), text, 2)
  1051.   end
  1052.   #----------------------------------------------------------------------------
  1053.   # ● upgraded method: update
  1054.   #----------------------------------------------------------------------------
  1055.   def update
  1056.     super
  1057.     if @category_window && @category != @category_window.current_symbol.to_s.to_i
  1058.       @category = @category_window.current_symbol.to_s.to_i
  1059.       refresh
  1060.     end
  1061.   end
  1062. end
  1063. #==============================================================================
  1064. # ■ Window_BestiaryStatSelection
  1065. #==============================================================================
  1066. class Window_BestiaryStatSelection < Window_Selectable
  1067.   #----------------------------------------------------------------------------
  1068.   # ● upgraded method: initialize
  1069.   #----------------------------------------------------------------------------
  1070.   def initialize(x, y, width, height)
  1071.     super(x, y, width, height)
  1072.     set_windowskin
  1073.     select(0)
  1074.     hide
  1075.     refresh
  1076.   end
  1077.   #----------------------------------------------------------------------------
  1078.   # ● window settings;
  1079.   #----------------------------------------------------------------------------
  1080.   def col_max;     return item_max;                                         end
  1081.   def spacing;     return 5;                                                end
  1082.   def item_height; [Venka::Bestiary::Fonts[:normal_font][1].size, 24].max;  end
  1083.   #----------------------------------------------------------------------------
  1084.   # ● upgraded method: item_max
  1085.   #----------------------------------------------------------------------------
  1086.   def item_max
  1087.     if SceneManager.scene_is?(Scene_Battle)
  1088.       Venka::Bestiary::Show_Debuff_Info ? 4 : 3
  1089.     else
  1090.       return 2
  1091.     end
  1092.   end
  1093.   #----------------------------------------------------------------------------
  1094.   # ○ new method: enemy_id
  1095.   #----------------------------------------------------------------------------
  1096.   def enemy_id=(enemy_id)
  1097.     return @enemy = nil if enemy_id == 0
  1098.     if @enemy != $data_enemies[enemy_id]
  1099.       @enemy = $data_enemies[enemy_id]
  1100.       refresh
  1101.     end
  1102.   end
  1103.   #----------------------------------------------------------------------------
  1104.   # ● upgraded method: item_rect
  1105.   #----------------------------------------------------------------------------
  1106.   def item_rect(index)
  1107.     rect = super
  1108.     if SceneManager.scene_is?(Scene_Battle)
  1109.       rect.y += [Venka::Bestiary::Fonts[:normal_font][1], 24].max + 6
  1110.     end
  1111.     rect
  1112.   end
  1113.   #----------------------------------------------------------------------------
  1114.   # ● upgraded method: draw_item
  1115.   #----------------------------------------------------------------------------
  1116.   def draw_item(index)
  1117.     rect = item_rect_for_text(index)
  1118.     if SceneManager.scene_is?(Scene_Battle)
  1119.       text = [Venka::Bestiary::View_Stats, Venka::Bestiary::View_Element,
  1120.               Venka::Bestiary::View_States, Venka::Bestiary::View_Debuff]
  1121.     else
  1122.       text = [Venka::Bestiary::View_Stats, Venka::Bestiary::View_More]
  1123.     end
  1124.     set_bestiary_font(:normal_font)
  1125.     draw_text(rect, text[index], 1)
  1126.   end
  1127.   #----------------------------------------------------------------------------
  1128.   # ● upgraded method: refresh
  1129.   #----------------------------------------------------------------------------
  1130.   def refresh
  1131.     contents.clear
  1132.     if SceneManager.scene_is?(Scene_Battle)
  1133.       set_bestiary_font(:normal_font)
  1134.       @y = font_height
  1135.       draw_enemy_name if @enemy
  1136.     end
  1137.     draw_all_items
  1138.   end
  1139.   #----------------------------------------------------------------------------
  1140.   # ○ new method: draw_enemy_name
  1141.   #----------------------------------------------------------------------------
  1142.   def draw_enemy_name
  1143.     draw_text(0, 0, contents.width, font_height, @enemy.name, 1)
  1144.     draw_line(@y + 2)
  1145.     @y += 6
  1146.     draw_line(@y + item_height + 3)
  1147.   end
  1148.   #----------------------------------------------------------------------------
  1149.   # ● upgraded method: update_help
  1150.   #----------------------------------------------------------------------------
  1151.   def update_help
  1152.     @help_window.set_index(@index)
  1153.   end
  1154.   #----------------------------------------------------------------------------
  1155.   # ● upgraded method: select
  1156.   #----------------------------------------------------------------------------
  1157.   def select(index)
  1158.     super
  1159.     @help_window.oy = 0 if @help_window
  1160.   end
  1161.   #----------------------------------------------------------------------------
  1162.   # ● upgraded method: cursor_down
  1163.   #----------------------------------------------------------------------------
  1164.   def cursor_down(wrap = false)
  1165.     super
  1166.     if @help_window && display_window_oy < @help_window.total_height
  1167.       @help_window.oy += Venka::Bestiary::Scroll_Speed
  1168.     end
  1169.   end
  1170.   #----------------------------------------------------------------------------
  1171.   # ○ new method: display_window_oy
  1172.   #----------------------------------------------------------------------------
  1173.   def display_window_oy
  1174.     @help_window.oy + @help_window.height - (@help_window.standard_padding * 2)
  1175.   end
  1176.   #----------------------------------------------------------------------------
  1177.   # ● upgraded method: cursor_up
  1178.   #----------------------------------------------------------------------------
  1179.   def cursor_up(wrap = false)
  1180.     super
  1181.     @help_window.oy -= Venka::Bestiary::Scroll_Speed if @help_window && @help_window.oy > 0
  1182.   end
  1183.   #----------------------------------------------------------------------------
  1184.   # ○ new method: wait_to_close
  1185.   #----------------------------------------------------------------------------
  1186.   def wait_to_close
  1187.     loop do
  1188.       Graphics.update
  1189.       Input.update
  1190.       update
  1191.       break if Input.trigger?(:C) || Input.trigger?(:B)
  1192.     end
  1193.     @help_window.hide
  1194.     deactivate
  1195.     self.hide
  1196.   end
  1197. end
  1198. #==============================================================================
  1199. # ■ Window_BestiaryStats
  1200. #==============================================================================
  1201. class Window_BestiaryStats < Window_Base
  1202.   #----------------------------------------------------------------------------
  1203.   # ♦ Public Instance Variables
  1204.   #----------------------------------------------------------------------------
  1205.   attr_accessor   :enemy, :total_height
  1206.   #----------------------------------------------------------------------------
  1207.   # ● upgraded method: initialize
  1208.   #----------------------------------------------------------------------------
  1209.   def initialize(x, y, width, height)
  1210.     @win_height = height
  1211.     super(x, y, width, height)
  1212.     self.opacity = 0
  1213.     @enemy = nil
  1214.     hide
  1215.   end
  1216.   #----------------------------------------------------------------------------
  1217.   # ○ new method: enemy_id
  1218.   #----------------------------------------------------------------------------
  1219.   def enemy_id=(enemy_id)
  1220.     return @enemy = nil if enemy_id == 0
  1221.     if @enemy != $data_enemies[enemy_id]
  1222.       @enemy = $data_enemies[enemy_id]
  1223.     end
  1224.     refresh
  1225.   end
  1226.   #----------------------------------------------------------------------------
  1227.   # ○ new method: set_index
  1228.   #----------------------------------------------------------------------------
  1229.   def set_index(index)
  1230.     if @index != index
  1231.       @index = index
  1232.       refresh
  1233.     end
  1234.   end
  1235.   #----------------------------------------------------------------------------
  1236.   # ● upgraded method: contents_height
  1237.   #----------------------------------------------------------------------------
  1238.   def contents_height
  1239.     @total_height ? @total_height : super
  1240.   end
  1241.   #----------------------------------------------------------------------------
  1242.   # ● upgraded method: refresh
  1243.   #----------------------------------------------------------------------------
  1244.   def refresh
  1245.     contents.clear
  1246.     return if @enemy.nil?
  1247.     if SceneManager.scene_is?(Scene_Bestiary)
  1248.       @index == 0 ? draw_basic_stats : draw_other_info
  1249.     end
  1250.   end
  1251.   #----------------------------------------------------------------------------
  1252.   # ○ new method: determine_window_height
  1253.   #----------------------------------------------------------------------------
  1254.   def determine_window_height(text_lines)
  1255.     set_bestiary_font(:header_font)
  1256.     @total_height = font_height * text_lines
  1257.     self.height = ([(@total_height + standard_padding * 2), @win_height].min)
  1258.     create_contents
  1259.   end
  1260.   #----------------------------------------------------------------------------
  1261.   # ○ new method: info_rect
  1262.   #----------------------------------------------------------------------------
  1263.   def info_rect(index)
  1264.     rect = Rect.new
  1265.     rect.width = contents.width * 0.5 - 3
  1266.     rect.height = [Venka::Bestiary::Fonts[:stat_name][1], 24].max
  1267.     rect.x = index % 2 * (rect.width + 3)
  1268.     rect.y = index / 2 * font_height
  1269.     rect
  1270.   end
  1271.   #----------------------------------------------------------------------------
  1272.   # ○ new method: draw_basic_stats
  1273.   #----------------------------------------------------------------------------
  1274.   def draw_basic_stats
  1275.     elements = Venka::Bestiary::Elements.size
  1276.     states = Venka::Bestiary::States.size
  1277.     # Get the total text lines to show
  1278.     height = (elements / 2 + elements % 2) + (states / 2 + states % 2) + 10
  1279.     height += 6 if Venka::Bestiary::Show_Debuff_Info
  1280.     determine_window_height(height)
  1281.     draw_line(5)
  1282.     @y = 12
  1283.     draw_main_stats
  1284.     draw_line(@y + 5)
  1285.     @y += 12
  1286.     get_revealed_resists
  1287.     draw_elements
  1288.     draw_line(@y + 5)
  1289.     @y += 12
  1290.     draw_states
  1291.     return unless Venka::Bestiary::Show_Debuff_Info
  1292.     draw_line(@y + 5)
  1293.     @y += 12
  1294.     draw_debuffs
  1295.   end
  1296.   #----------------------------------------------------------------------------
  1297.   # ○ new method: draw_main_stats
  1298.   #----------------------------------------------------------------------------
  1299.   def draw_main_stats
  1300.     set_bestiary_font(:header_font)
  1301.     draw_text(0, @y, contents.width, font_height, Venka::Bestiary::Stats_Text, 1)
  1302.     @y += font_height
  1303.     8.times {|stat| draw_stat(stat, :stat)}
  1304.     @y += info_rect(0).height * 4
  1305.   end
  1306.   #----------------------------------------------------------------------------
  1307.   # ○ new method: draw_stat
  1308.   #----------------------------------------------------------------------------
  1309.   def draw_stat(stat, stat_type)
  1310.     rect = info_rect(stat)
  1311.     rect.y += @y
  1312.     stat_info = Venka::Bestiary::Base_Stats[stat]
  1313.     if stat_info[1]
  1314.       draw_icon(stat_info[1], rect.x, rect.y)
  1315.       rect.x += 25;            rect.width -= 25
  1316.     end
  1317.     if stat_info[0]
  1318.       set_bestiary_font(:stat_name)
  1319.       draw_text(rect, stat_info[0])
  1320.       text_width = text_size(stat_info[0]).width + 5
  1321.       rect.x += text_width;    rect.width -= text_width
  1322.     end
  1323.     set_bestiary_font(:stats_font)
  1324.     text = Venka::Bestiary::Unknown_Stat
  1325.     $game_party.bestiary.each do |entry|
  1326.       next unless entry.enemy_id == @enemy.shown_id
  1327.       if stat_type == :stat && (entry.scanned ||
  1328.             entry.kills >= Venka::Bestiary::Show_BaseStats)
  1329.         text = Game_Enemy.new(0, @enemy.shown_id).param(stat)
  1330.       elsif stat_type == :debuff && (entry.scanned ||
  1331.             entry.kills >= Venka::Bestiary::Show_DebuffStats)
  1332.         rate = Game_Enemy.new(0, @enemy.shown_id).debuff_rate(stat)
  1333.         text = get_resist_info(stat, rate)
  1334.       end
  1335.     end
  1336.     draw_text(rect, text, 2)
  1337.   end
  1338.   #----------------------------------------------------------------------------
  1339.   # ○ new method: get_revealed_resists
  1340.   #----------------------------------------------------------------------------
  1341.   def get_revealed_resists
  1342.     $game_party.bestiary.each do |entry|
  1343.       @eles = entry.elements if entry.enemy_id == @enemy.shown_id
  1344.       @states = entry.states if entry.enemy_id == @enemy.shown_id
  1345.     end
  1346.   end
  1347.   #----------------------------------------------------------------------------
  1348.   # ○ new method: draw_elements
  1349.   #----------------------------------------------------------------------------
  1350.   def draw_elements
  1351.     set_bestiary_font(:header_font)
  1352.     draw_text(0, @y, contents.width, font_height, Venka::Bestiary::Element_Text, 1)
  1353.     @y += font_height
  1354.     elements = Venka::Bestiary::Elements
  1355.     (elements.size).times {|i| draw_ele_info(i, elements[i], info_rect(i))}
  1356.     @y += (info_rect(0).height) * (elements.size * 0.5 + elements.size % 2)
  1357.   end
  1358.   #----------------------------------------------------------------------------
  1359.   # ○ new method: draw_ele_info
  1360.   #----------------------------------------------------------------------------
  1361.   def draw_ele_info(i, element, rect)
  1362.     rect.y += @y
  1363.     if element[1]
  1364.       draw_icon(element[1], rect.x, rect.y)
  1365.       rect.x += 25;            rect.width -= 25
  1366.     end
  1367.     set_bestiary_font(:stat_name)
  1368.     tw = text_size(99).width + 5
  1369.     draw_text(rect, $data_system.elements[element[0]])
  1370.     text_width = text_size(element[0]).width + 5
  1371.     # Scale text so the value will fit as well in small resolutions
  1372.     rect.x = [(rect.x + text_width), (rect.x + rect.width - tw)].min
  1373.     rect.width = [(rect.width - text_width), tw].max
  1374.     set_bestiary_font(:stats_font)
  1375.     text = @eles[i] ? get_resist_info(element[0], 11) : Venka::Bestiary::Unknown_Stat
  1376.     draw_text(rect, text, 2)
  1377.   end
  1378.   #----------------------------------------------------------------------------
  1379.   # ○ new method: get_resist_info
  1380.   #----------------------------------------------------------------------------
  1381.   def get_resist_info(stat_id, code_id)
  1382.     case code_id
  1383.     when 11   # Element
  1384.       resist = Game_Enemy.new(0, @enemy.shown_id).element_rate(stat_id)
  1385.       if $imported["YEA-Element Absorb"] && Game_Enemy.new(0, @enemy.shown_id).element_absorb?(stat_id)
  1386.         set_resist_style(resist, Venka::Bestiary::Absorb_Text)
  1387.       else
  1388.         set_resist_style(resist)
  1389.       end
  1390.     when 13
  1391.       enemy = Game_Enemy.new(0, @enemy.shown_id)
  1392.       if enemy.features_with_id(14, stat_id).empty?
  1393.         resist = enemy.state_rate(stat_id)
  1394.         set_resist_style(resist)
  1395.       else
  1396.         set_resist_style(1.0, Venka::Bestiary::Immune_Text)
  1397.       end
  1398.     else
  1399.       set_resist_style(code_id)
  1400.     end
  1401.   end
  1402.   #----------------------------------------------------------------------------
  1403.   # ○ new method: set_resist_style
  1404.   #----------------------------------------------------------------------------
  1405.   def set_resist_style(resist, text = "")
  1406.     if text != ""
  1407.       color = Venka::Bestiary::Immunity_Color
  1408.     else
  1409.       color = Venka::Bestiary::Fonts[:stats_font][3]
  1410.       color = Venka::Bestiary::High_Resist if resist > 1.0
  1411.       color = Venka::Bestiary::Low_Resist  if resist < 1.0
  1412.       resist -= 1.0 if resist >= 1.0
  1413.       text = (resist * 100).round
  1414.     end
  1415.     new_color = color.is_a?(Integer) ? text_color(color) : Color.new(*color)
  1416.     change_color(new_color)
  1417.     return text
  1418.   end
  1419.   #----------------------------------------------------------------------------
  1420.   # ○ new method: draw_states
  1421.   #----------------------------------------------------------------------------
  1422.   def draw_states
  1423.     set_bestiary_font(:header_font)
  1424.     draw_text(0, @y, contents.width, font_height, Venka::Bestiary::Status_Text, 1)
  1425.     @y += font_height
  1426.     states = Venka::Bestiary::States
  1427.     (states.size).times {|i| draw_state_info(i, states[i], info_rect(i))}
  1428.     @y += (info_rect(0).height) * (states.size / 2).round
  1429.   end
  1430.   #----------------------------------------------------------------------------
  1431.   # ○ new method: draw_state_info
  1432.   #----------------------------------------------------------------------------
  1433.   def draw_state_info(i, state_id, rect)
  1434.     state = $data_states[state_id]
  1435.     rect.y += @y
  1436.     draw_icon(state.icon_index, rect.x, rect.y)
  1437.     rect.x += 25;            rect.width -= 25
  1438.     set_bestiary_font(:stat_name)
  1439.     tw = text_size(99).width + 5
  1440.     draw_text(rect.x, rect.y, rect.width - tw, rect.height, state.name)
  1441.     text_width = text_size(state.name).width + 5
  1442.     # Scale text so the value will fit as well in small resolutions
  1443.     rect.x = [(rect.x + text_width), (rect.x + rect.width - tw)].min
  1444.     rect.width = [(rect.width - text_width), tw].max
  1445.     set_bestiary_font(:stats_font)
  1446.     text = @states[i] ? get_resist_info(state_id, 13) : Venka::Bestiary::Unknown_Stat
  1447.     draw_text(rect, text, 2)
  1448.   end
  1449.   #----------------------------------------------------------------------------
  1450.   # ○ new method: draw_debuffs
  1451.   #----------------------------------------------------------------------------
  1452.   def draw_debuffs
  1453.     set_bestiary_font(:header_font)
  1454.     draw_text(0, @y, contents.width, font_height, Venka::Bestiary::Debuff_Text, 1)
  1455.     @y += font_height
  1456.     8.times do |stat|
  1457.       draw_stat(stat, :debuff)
  1458.     end
  1459.   end
  1460.   #----------------------------------------------------------------------------
  1461.   # ○ new method: draw_other_info
  1462.   #----------------------------------------------------------------------------
  1463.   def draw_other_info
  1464.     # Get the number of lines to display loot
  1465.     drops = @enemy.drop_items.select {|d| d.kind > 0 }
  1466.     # Get the number of lines to display enemy skills
  1467.     ids = []
  1468.     @enemy.actions.each do |action|
  1469.       ids << action.skill_id unless ids.include?(action.skill_id)
  1470.     end
  1471.     # Total number of lines to display with skills, loot, headers, etc
  1472.     height = 5 + drops.size + ids.size
  1473.     determine_window_height(height)
  1474.     draw_line(5)
  1475.     @y = 12
  1476.     set_bestiary_font(:header_font)
  1477.     draw_text(0, @y, contents.width, font_height, Venka::Bestiary::Loot_Text, 1)
  1478.     @y += font_height
  1479.     draw_exp_and_gold
  1480.     draw_drops
  1481.     draw_skills
  1482.   end
  1483.   #----------------------------------------------------------------------------
  1484.   # ○ new method: draw_exp
  1485.   #----------------------------------------------------------------------------
  1486.   def draw_exp_and_gold
  1487.     exp  = Venka::Bestiary::Exp_Text
  1488.     gold = Venka::Bestiary::Gold_Text
  1489.     width = contents.width
  1490.     width = ((@enemy.exp > 0 || @enemy.gold > 0) ? width * 0.5 : width).to_i
  1491.     draw_icon_text(exp, 0, width, @enemy.exp)   if @enemy.exp > 0
  1492.     x = @enemy.exp > 0 ? width : 0
  1493.     draw_icon_text(gold, x, width, @enemy.gold) if @enemy.gold > 0
  1494.     @y += font_height
  1495.   end
  1496.   #----------------------------------------------------------------------------
  1497.   # ○ new method: draw_icon_and_text
  1498.   #----------------------------------------------------------------------------
  1499.   def draw_icon_text(info, x, width, amount)
  1500.     draw_icon(info[1], x, @y) if info[1]
  1501.     dx = info[1] ? 25 : 0
  1502.     set_bestiary_font(:stat_name)
  1503.     draw_text(x + dx, @y, width - dx, font_height, info[0])
  1504.     set_bestiary_font(:stats_font)
  1505.     dx += text_size(info[0]).width + 10
  1506.     draw_text(x + dx, @y, width - dx, font_height, amount)
  1507.   end
  1508.   #----------------------------------------------------------------------------
  1509.   # ○ new method: draw_drops
  1510.   #----------------------------------------------------------------------------
  1511.   def draw_drops
  1512.     drops_revealed = false
  1513.     $game_party.bestiary.each do |entry|
  1514.       next unless entry.enemy_id == @enemy.shown_id
  1515.       if entry.scanned || entry.kills >= Venka::Bestiary::Show_Loot
  1516.         drops_revealed = true
  1517.       end
  1518.     end
  1519.     if drops_revealed
  1520.       @enemy.drop_items.each do |drop_info|
  1521.         next if drop_info.kind == 0
  1522.         item = $data_items[drop_info.data_id]   if drop_info.kind == 1
  1523.         item = $data_weapons[drop_info.data_id] if drop_info.kind == 2
  1524.         item = $data_armors[drop_info.data_id]  if drop_info.kind == 3
  1525.         set_bestiary_font(:stat_name)
  1526.         tw = text_size("100%").width + 5
  1527.         draw_item_name(item, 0, @y, contents.width - tw)
  1528.         chance = (1.to_f / drop_info.denominator) * 100
  1529.         chance = (chance > 0.9) ? chance.round : chance.round(1)
  1530.         set_bestiary_font(:stats_font)
  1531.         draw_text(0, @y, contents.width, font_height, "#{chance}%", 2)
  1532.         @y += font_height
  1533.       end
  1534.     else
  1535.       set_bestiary_font(:stat_name)
  1536.       draw_text(0, @y, contents.width, font_height, Venka::Bestiary::Unknown_Loot)
  1537.       @y += font_height
  1538.     end
  1539.     draw_line(@y + 5)
  1540.     @y += 12
  1541.   end
  1542.   #----------------------------------------------------------------------------
  1543.   # ○ new method: draw_skills
  1544.   #----------------------------------------------------------------------------
  1545.   def draw_skills
  1546.     set_bestiary_font(:header_font)
  1547.     draw_text(0, @y, contents.width, font_height, Venka::Bestiary::Skill_Text, 1)
  1548.     @y += font_height
  1549.     set_bestiary_font(:stat_name)
  1550.     skills_revealed = false
  1551.     $game_party.bestiary.each do |entry|
  1552.       next unless entry.enemy_id == @enemy.shown_id
  1553.       if entry.scanned || entry.kills >= Venka::Bestiary::Show_Abilities
  1554.         skills_revealed = true
  1555.       end
  1556.     end
  1557.     if skills_revealed
  1558.       skills.each do |id|
  1559.         draw_item_name($data_skills[id], 0, @y, contents.width)
  1560.         @y += font_height
  1561.       end
  1562.     else
  1563.       draw_text(0, @y, contents.width, font_height, Venka::Bestiary::Unknown_Skills)
  1564.     end
  1565.   end
  1566.   #----------------------------------------------------------------------------
  1567.   # ○ new method: skills
  1568.   #----------------------------------------------------------------------------
  1569.   def skills
  1570.     ids = []
  1571.     @enemy.actions.each do |action|
  1572.       ids << action.skill_id unless ids.include?(action.skill_id)
  1573.     end
  1574.     return ids
  1575.   end
  1576. end
  1577. #==============================================================================
  1578. # ■ Window_BattleScan
  1579. #==============================================================================
  1580. class Window_BattleScan < Window_BestiaryStats
  1581.   #----------------------------------------------------------------------------
  1582.   # ♦ Public Instance Variables
  1583.   #----------------------------------------------------------------------------
  1584.   attr_accessor    :show_stats
  1585.   #----------------------------------------------------------------------------
  1586.   # ● upgraded method: initialize
  1587.   #----------------------------------------------------------------------------
  1588.   def initialize(x, y, width, height)
  1589.     super(x, y, width, height)
  1590.   end
  1591.   #----------------------------------------------------------------------------
  1592.   # ● upgraded method: refresh
  1593.   #----------------------------------------------------------------------------
  1594.   def refresh
  1595.     contents.clear
  1596.     return if @enemy.nil?
  1597.     if $game_party.bestiary_include?(@enemy.shown_id)
  1598.       @y = 0
  1599.       case @index
  1600.       when 0; draw_basic_stats
  1601.       when 1; draw_enemy_resists
  1602.       when 2; draw_enemy_states
  1603.       when 3; draw_debuff_rates
  1604.       end
  1605.     else
  1606.       set_bestiary_font(:stat_name)
  1607.       text = Venka::Bestiary::No_Info
  1608.       draw_text(0, 0, contents.width, contents.height, text, 1)
  1609.     end
  1610.   end
  1611.   #----------------------------------------------------------------------------
  1612.   # ○ new method: draw_basic_stats
  1613.   #----------------------------------------------------------------------------
  1614.   def draw_basic_stats
  1615.     determine_window_height(4)
  1616.     8.times {|stat| draw_stat(stat, :stat)}
  1617.   end
  1618.   #----------------------------------------------------------------------------
  1619.   # ○ new method: draw_enemy_resists
  1620.   #----------------------------------------------------------------------------
  1621.   def draw_enemy_resists
  1622.     elements = Venka::Bestiary::Elements
  1623.     height = (elements.size / 2) + (elements.size % 2)
  1624.     determine_window_height(height)
  1625.     get_revealed_resists
  1626.     (elements.size).times {|i| draw_ele_info(i, elements[i], info_rect(i))}
  1627.   end
  1628.   #----------------------------------------------------------------------------
  1629.   # ○ new method: draw_enemy_states
  1630.   #----------------------------------------------------------------------------
  1631.   def draw_enemy_states
  1632.     states = Venka::Bestiary::States
  1633.     height = (states.size / 2) + (states.size % 2)
  1634.     determine_window_height(height)
  1635.     (states.size).times {|i| draw_state_info(i, states[i], info_rect(i))}
  1636.   end
  1637.   #----------------------------------------------------------------------------
  1638.   # ○ new method: draw_debuff_rates
  1639.   #----------------------------------------------------------------------------
  1640.   def draw_debuff_rates
  1641.     determine_window_height(4)
  1642.     8.times {|stat| draw_stat(stat, :debuff)}
  1643.   end
  1644. end
  1645. #==============================================================================
  1646. # ■ Scene_Menu
  1647. #==============================================================================
  1648. class Scene_Menu < Scene_MenuBase
  1649.   #----------------------------------------------------------------------------
  1650.   # ● alias method: create_command_window
  1651.   #----------------------------------------------------------------------------
  1652.   alias bestiary_menu_access_ccw       create_command_window
  1653.   def create_command_window
  1654.     bestiary_menu_access_ccw
  1655.     @command_window.set_handler(:bestiary,  method(:command_bestiary))
  1656.   end
  1657.   #----------------------------------------------------------------------------
  1658.   # ○ new method: command_bestiary
  1659.   #----------------------------------------------------------------------------
  1660.   def command_bestiary
  1661.     SceneManager.call(Scene_Bestiary)
  1662.   end
  1663. end
  1664. #==============================================================================
  1665. # ■ Scene_Battle
  1666. #==============================================================================
  1667. class Scene_Battle < Scene_Base
  1668.   #----------------------------------------------------------------------------
  1669.   # ● alias method: create_all_windows
  1670.   #----------------------------------------------------------------------------
  1671.   alias scan_window_caw create_all_windows
  1672.   def create_all_windows
  1673.     scan_window_caw
  1674.     create_info_instructions
  1675.     create_stats_selection
  1676.     create_stats_window
  1677.   end
  1678.   #----------------------------------------------------------------------------
  1679.   # ○ new method: create_stats_selection
  1680.   #----------------------------------------------------------------------------
  1681.   def create_stats_selection
  1682.     width = [Graphics.width * 0.6, 420].max
  1683.     x = (Graphics.width - width) * 0.5
  1684.     # Get total height of the window since it can change based on fonts used.
  1685.     height = 40 + ([Venka::Bestiary::Fonts[:normal_font][1], 24].max * 2) +
  1686.          ([Venka::Bestiary::Fonts[:stat_name][1], 24].max * 4)
  1687.     y = (Graphics.height - @status_window.height - height) * 0.5
  1688.     @stats_selection = Window_BestiaryStatSelection.new(x, y, width, height)
  1689.   end
  1690.   #----------------------------------------------------------------------------
  1691.   # ○ new method: create_stats_window
  1692.   #----------------------------------------------------------------------------
  1693.   def create_stats_window
  1694.     y = @stats_selection.y + @stats_selection.item_height + 15 +
  1695.         Venka::Bestiary::Fonts[:normal_font][1]
  1696.     # Make the info window the same height as the selection window minus the
  1697.     # header info and selection area.
  1698.     height = @stats_selection.height - @stats_selection.item_height - 15 -
  1699.         Venka::Bestiary::Fonts[:normal_font][1]
  1700.     @stats_window = Window_BattleScan.new(@stats_selection.x, y,
  1701.         @stats_selection.width, height)
  1702.     @stats_selection.help_window = @stats_window
  1703.   end
  1704.   #----------------------------------------------------------------------------
  1705.   # ○ new method: create_scan_window
  1706.   #----------------------------------------------------------------------------
  1707.   def create_info_instructions
  1708.     @info_instructions = Sprite.new
  1709.     @info_instructions.visible = false
  1710.     font = Venka::Bestiary::Battle_Font
  1711.     @info_instructions.bitmap = Bitmap.new(Graphics.width, font[1])
  1712.     @info_instructions.bitmap.font.name  = font[0]
  1713.     @info_instructions.bitmap.font.size  = font[1]
  1714.     @info_instructions.bitmap.font.bold  = font[2]
  1715.     @info_instructions.bitmap.font.color = Color.new(*font[3])
  1716.     @info_instructions.bitmap.font.outline = font[4]
  1717.     text = Venka::Bestiary::Battle_Instructions
  1718.     @info_instructions.bitmap.draw_text(0, 0, Graphics.width, font[1], text, 1)
  1719.     @info_instructions.y = @enemy_window.y - font[1]
  1720.   end
  1721.   #----------------------------------------------------------------------------
  1722.   # ● alias method: select_enemy_selection
  1723.   #----------------------------------------------------------------------------
  1724.   alias bestiary_info_enemy_select select_enemy_selection
  1725.   def select_enemy_selection
  1726.     @info_instructions.visible = true
  1727.     bestiary_info_enemy_select
  1728.   end
  1729.   #----------------------------------------------------------------------------
  1730.   # ● alias method: on_enemy_ok
  1731.   #----------------------------------------------------------------------------
  1732.   alias bestiary_info_enemy_ok on_enemy_ok
  1733.   def on_enemy_ok
  1734.     @info_instructions.visible = false
  1735.     bestiary_info_enemy_ok
  1736.   end
  1737.   #----------------------------------------------------------------------------
  1738.   # ● alias method: on_enemy_cancel
  1739.   #----------------------------------------------------------------------------
  1740.   alias bestiary_info_enemy_cancel on_enemy_cancel
  1741.   def on_enemy_cancel
  1742.     @info_instructions.visible = false
  1743.     bestiary_info_enemy_cancel
  1744.   end
  1745.   #----------------------------------------------------------------------------
  1746.   # ○ new method: show_enemy_info
  1747.   #----------------------------------------------------------------------------
  1748.   def show_enemy_info(enemy_id)
  1749.     @stats_window.show
  1750.     @stats_selection.enemy_id = enemy_id
  1751.     @stats_window.enemy_id = enemy_id
  1752.     @stats_selection.show.activate
  1753.     @stats_selection.wait_to_close
  1754.   end
  1755.   #----------------------------------------------------------------------------
  1756.   # ● alias method: update
  1757.   #----------------------------------------------------------------------------
  1758.   alias show_enemy_info_update update
  1759.   def update
  1760.     show_enemy_info_update
  1761.     if @enemy_window.active && Input.trigger?(Venka::Bestiary::Scan_PopUp)
  1762.       show_enemy_info(@enemy_window.enemy.enemy_id)
  1763.     end
  1764.   end
  1765.   #----------------------------------------------------------------------------
  1766.   # ● alias method: item_apply
  1767.   #----------------------------------------------------------------------------
  1768.   alias venka_scan_skill_used apply_item_effects
  1769.   def apply_item_effects(target, item)
  1770.     if target.is_a?(Game_Enemy)
  1771.       enemy = $data_enemies[target.enemy_id]
  1772.       $game_party.reveal_resist(enemy.id, false) if item.scan
  1773.       attack_element = item.damage.element_id
  1774.       Venka::Bestiary::Elements.size.times do |i|
  1775.         if Venka::Bestiary::Elements[i][0] == attack_element
  1776.           $game_party.bestiary.each do |entry|
  1777.             entry.elements[i] = true if entry.enemy_id == enemy.shown_id
  1778.           end
  1779.         end
  1780.       end
  1781.       if item.scan
  1782.         $game_party.bestiary.each do |entry|
  1783.           entry.scanned = true if entry.enemy_id == enemy.shown_id
  1784.         end
  1785.         show_enemy_info(target.enemy_id)
  1786.       end
  1787.     end
  1788.     venka_scan_skill_used(target, item)
  1789.   end
  1790.   #----------------------------------------------------------------------------
  1791.   # ● alias method: terminate
  1792.   #----------------------------------------------------------------------------
  1793.   alias :dispose_instructions_on_term :terminate
  1794.   def terminate
  1795.     dispose_instructions_on_term
  1796.     dispose_instructions
  1797.   end
  1798.   #----------------------------------------------------------------------------
  1799.   # ○ new method: dispose_instructions
  1800.   #----------------------------------------------------------------------------
  1801.   def dispose_instructions
  1802.     return if @info_instructions
  1803.     @info_instructions.bitmap.dispose
  1804.     @info_instructions.dispose
  1805.     @info_instructions = nil
  1806.   end
  1807. end
  1808. #==============================================================================
  1809. # ■ Scene_Bestiary
  1810. #==============================================================================
  1811. class Scene_Bestiary < Scene_MenuBase
  1812.   #----------------------------------------------------------------------------
  1813.   # ● upgraded method: start
  1814.   #----------------------------------------------------------------------------
  1815.   def start
  1816.     stop_music if Venka::Bestiary::Bestiary_BGM
  1817.     super
  1818.     bestiary_music if Venka::Bestiary::Bestiary_BGM
  1819.     @enemy = nil
  1820.     create_all_windows
  1821.   end
  1822.   #----------------------------------------------------------------------------
  1823.   # ○ new method: stop_music
  1824.   #----------------------------------------------------------------------------
  1825.   def stop_music
  1826.     @map_bgm = RPG::BGM.last
  1827.     fadeout_all(60)
  1828.   end
  1829.   #----------------------------------------------------------------------------
  1830.   # ○ new method: bestiary_music
  1831.   #----------------------------------------------------------------------------
  1832.   def bestiary_music
  1833.     RPG::BGM.new(*Venka::Bestiary::Bestiary_BGM).play
  1834.   end
  1835.   #----------------------------------------------------------------------------
  1836.   # ● upgraded method: create_background
  1837.   #----------------------------------------------------------------------------
  1838.   def create_background
  1839.     if Venka::Bestiary::BG_Image
  1840.       @background_sprite = Sprite.new
  1841.       @background_sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height)
  1842.       bitmap = bestiary_bgimage
  1843.       dest_rect = Rect.new(0, 0, Graphics.width, Graphics.height)
  1844.       @background_sprite.bitmap.stretch_blt(dest_rect, bitmap, bitmap.rect)
  1845.       @background_sprite.color.set(16, 16, 16, 128)
  1846.     else
  1847.       super
  1848.     end
  1849.   end
  1850.   #----------------------------------------------------------------------------
  1851.   # ○ new method: bestiary_bgimage
  1852.   #----------------------------------------------------------------------------
  1853.   def bestiary_bgimage
  1854.     file_info = Venka::Bestiary::BG_Image
  1855.     begin;      Cache.title1(file_info)
  1856.     rescue;     Cache.picture(file_info)
  1857.     end
  1858.   end
  1859.   #----------------------------------------------------------------------------
  1860.   # ○ new method: create_all_windows
  1861.   #----------------------------------------------------------------------------
  1862.   def create_all_windows
  1863.     create_help_window
  1864.     create_bottom_window
  1865.     create_category_window
  1866.     create_bestiary_list
  1867.     create_enemy_image
  1868.     create_stats_selection
  1869.     create_stats_window
  1870.     create_description_window
  1871.     create_image_frame if Venka::Bestiary::Frame_Image
  1872.   end
  1873.   #----------------------------------------------------------------------------
  1874.   # ● upgraded method: create_help_window
  1875.   #----------------------------------------------------------------------------
  1876.   def create_help_window
  1877.     @help_window = Window_BestiaryHelp.new(0, 0)
  1878.     @help_window.viewport = @viewport
  1879.     @help_window.y = 0
  1880.     @help_window.set_text(Venka::Bestiary::Category_Select)
  1881.   end
  1882.   #----------------------------------------------------------------------------
  1883.   # ○ new method: create_bottom_window
  1884.   #----------------------------------------------------------------------------
  1885.   def create_bottom_window
  1886.     y = Graphics.height - @help_window.height
  1887.     @bottom_window = Window_BestiaryHelp.new(0, y)
  1888.     @bottom_window.draw_completion
  1889.   end
  1890.   #----------------------------------------------------------------------------
  1891.   # ○ new method: create_category_window
  1892.   #----------------------------------------------------------------------------
  1893.   def create_category_window
  1894.     @category_window = Window_BestiaryCategory.new(0, @help_window.height)
  1895.     @category_window.viewport = @viewport
  1896.     @category_window.set_handler(:ok,     method(:command_list))
  1897.     @category_window.set_handler(:cancel, method(:return_scene))
  1898.   end
  1899.   #----------------------------------------------------------------------------
  1900.   # ○ new method: command_list
  1901.   #----------------------------------------------------------------------------
  1902.   def command_list
  1903.     @list_window.show.activate
  1904.     @help_window.set_text(Venka::Bestiary::Enemy_Select)
  1905.   end
  1906.   #----------------------------------------------------------------------------
  1907.   # ○ new method: create_bestiary_list
  1908.   #----------------------------------------------------------------------------
  1909.   def create_bestiary_list
  1910.     @list_window = Window_BestiaryEnemyList.new(@category_window.width,
  1911.           @help_window.height)
  1912.     @list_window.viewport = @viewport
  1913.     @list_window.category_window = @category_window
  1914.     @list_window.deactivate
  1915.     @list_window.set_handler(:ok,     method(:command_bestiary))
  1916.     @list_window.set_handler(:cancel, method(:command_category))
  1917.   end
  1918.   #----------------------------------------------------------------------------
  1919.   # ○ new method: command_category
  1920.   #----------------------------------------------------------------------------
  1921.   def command_category
  1922.     @category_window.activate
  1923.     @help_window.set_text(Venka::Bestiary::Category_Select)
  1924.   end
  1925.   #----------------------------------------------------------------------------
  1926.   # ○ new method: command_bestiary
  1927.   #----------------------------------------------------------------------------
  1928.   def command_bestiary
  1929.     @list_window.hide
  1930.     @category_window.hide
  1931.     @stats_selection.show.activate
  1932.     @stats_window.show
  1933.     @descript_window.show
  1934.     @frame_window.show if @frame_window
  1935.     @enemy_bg.visible = true
  1936.     update_enemy_info
  1937.   end
  1938.   #----------------------------------------------------------------------------
  1939.   # ○ new method: create_enemy_image
  1940.   #----------------------------------------------------------------------------
  1941.   def create_enemy_image
  1942.     width = (Graphics.width * 0.55).round;     height = Graphics.height * 0.55
  1943.     @enemy_bg = Sprite.new(@viewport)
  1944.     @enemy_bg.visible = false
  1945.     @enemy_bg.x = Graphics.width - (Graphics.width * 0.55).round
  1946.     @enemy_bg.y = @help_window.height
  1947.     @enemy_bg.bitmap = Bitmap.new(width, height)
  1948.   end
  1949.   #----------------------------------------------------------------------------
  1950.   # ○ new method: create_stats_selection
  1951.   #----------------------------------------------------------------------------
  1952.   def create_stats_selection
  1953.     height = Graphics.height - (@help_window.height * 2)
  1954.     @stats_selection = Window_BestiaryStatSelection.new(0, @help_window.height,
  1955.           Graphics.width - @enemy_bg.width, height)
  1956.     @stats_selection.viewport = @viewport
  1957.     @stats_selection.set_handler(:pageup,     method(:prev_enemy))
  1958.     @stats_selection.set_handler(:pagedown,   method(:next_enemy))
  1959.     @stats_selection.set_handler(:cancel,     method(:to_enemy_list))
  1960.   end
  1961.   #----------------------------------------------------------------------------
  1962.   # ○ new method: create_stats_window
  1963.   #----------------------------------------------------------------------------
  1964.   def create_stats_window
  1965.     y = @stats_selection.y + @stats_selection.item_height
  1966.     height = @stats_selection.height - @stats_selection.item_height
  1967.     @stats_window = Window_BestiaryStats.new(0, y, @stats_selection.width, height)
  1968.     @stats_window.viewport = @viewport
  1969.     @stats_selection.help_window = @stats_window
  1970.     @list_window.stats_window = @stats_window
  1971.   end
  1972.   #----------------------------------------------------------------------------
  1973.   # ○ new method: prev_enemy
  1974.   #----------------------------------------------------------------------------
  1975.   def prev_enemy
  1976.     if @list_window.index == 0
  1977.       @list_window.index = @list_window.item_max - 1
  1978.     else
  1979.       @list_window.index -= 1
  1980.     end
  1981.     update_enemy_info
  1982.     @stats_selection.activate
  1983.   end
  1984.   #----------------------------------------------------------------------------
  1985.   # ○ new method: next_enemy
  1986.   #----------------------------------------------------------------------------
  1987.   def next_enemy
  1988.     if @list_window.index == @list_window.item_max - 1
  1989.       @list_window.index = 0
  1990.     else
  1991.       @list_window.index += 1
  1992.     end
  1993.     update_enemy_info
  1994.     @stats_selection.activate
  1995.   end
  1996.   #----------------------------------------------------------------------------
  1997.   # ○ new method: to_enemy_list
  1998.   #----------------------------------------------------------------------------
  1999.   def to_enemy_list
  2000.     @help_window.set_text(Venka::Bestiary::Category_Select)
  2001.     @bottom_window.draw_completion
  2002.     @category_window.show
  2003.     @stats_selection.hide.deactivate
  2004.     @stats_window.hide
  2005.     @descript_window.hide
  2006.     @frame_window.hide if @frame_window
  2007.     @enemy_bg.visible = false
  2008.     command_list
  2009.   end
  2010.   #----------------------------------------------------------------------------
  2011.   # ○ new method: create_description_window
  2012.   #----------------------------------------------------------------------------
  2013.   def create_description_window
  2014.     y = (@help_window.height + @enemy_bg.height).to_i
  2015.     @descript_window = Window_BestiaryHelp.new(@stats_window.width, y)
  2016.     @descript_window.viewport = @viewport
  2017.     @descript_window.width = Graphics.width - @stats_window.width
  2018.     @descript_window.height = Graphics.height - y - @bottom_window.height
  2019.     @descript_window.hide
  2020.   end
  2021.   #----------------------------------------------------------------------------
  2022.   # ○ new method: create_image_frame
  2023.   #----------------------------------------------------------------------------
  2024.   def create_image_frame
  2025.     @frame_window = Window_Base.new(@enemy_bg.x, @enemy_bg.y, @enemy_bg.width,
  2026.         @enemy_bg.height)
  2027.     @frame_window.viewport = @viewport
  2028.     @frame_window.set_windowskin
  2029.     @frame_window.back_opacity = 0
  2030.     @frame_window.hide
  2031.   end
  2032.   #----------------------------------------------------------------------------
  2033.   # ○ new method: update_enemy_info
  2034.   #----------------------------------------------------------------------------
  2035.   def update_enemy_info
  2036.     enemy = $data_enemies[@list_window.current_ext]
  2037.     @help_window.set_text(enemy.name)
  2038.     @bottom_window.draw_instructions
  2039.     @stats_window.enemy_id = @list_window.current_ext
  2040.     @descript_window.set_description(enemy)
  2041.     update_enemy_image(enemy)
  2042.   end
  2043.   #----------------------------------------------------------------------------
  2044.   # ○ new method: update_enemy_image
  2045.   #----------------------------------------------------------------------------
  2046.   def update_enemy_image(enemy)
  2047.     @enemy_bg.bitmap.clear
  2048.     enemy = $data_enemies[@list_window.current_ext]
  2049.     if floor_image(enemy)
  2050.       bg_floor = enemy_image(:floor, floor_image(enemy))
  2051.       draw_image(bg_floor, @enemy_bg.width, @enemy_bg.height)
  2052.     end
  2053.     if wall_image(enemy)
  2054.       bg_wall = enemy_image(:wall, wall_image(enemy))
  2055.       draw_image(bg_wall, @enemy_bg.width, @enemy_bg.height)
  2056.     end
  2057.     enemy = enemy_image(:battler, enemy.battler_name, enemy.battler_hue)
  2058.     draw_image(enemy, @enemy_bg.width, @enemy_bg.height)
  2059.   end
  2060.   #----------------------------------------------------------------------------
  2061.   # ○ new method: floor_image
  2062.   #----------------------------------------------------------------------------
  2063.   def floor_image(enemy)
  2064.     floor = enemy.bg_floor      # Get the enemie's wall image (high priority)
  2065.     if floor == ""              # If it's not set, then get category image
  2066.       floor = Venka::Bestiary::Category[@category_window.index][:bg_floor]
  2067.       # If the category image wasn't set, then use the default image
  2068.       floor = Venka::Bestiary::Default_BGFloor if floor.nil?
  2069.     end
  2070.     floor = nil if floor == ""  # Set to no image if category was set to ""
  2071.     return floor
  2072.   end
  2073.   #----------------------------------------------------------------------------
  2074.   # ○ new method: wall_image
  2075.   #----------------------------------------------------------------------------
  2076.   def wall_image(enemy)
  2077.     wall = enemy.bg_wall      # Get the enemie's wall image (high priority)
  2078.     if wall == ""             # If it's not set, then get category image
  2079.       wall = Venka::Bestiary::Category[@category_window.index][:bg_wall]
  2080.       # If the category image wasn't set, then use the default image
  2081.       wall = Venka::Bestiary::Default_BGWall if wall.nil?
  2082.     end
  2083.     wall = nil if wall == "" # Set to no image if category was set to ""
  2084.     return wall
  2085.   end
  2086.   #----------------------------------------------------------------------------
  2087.   # ○ new method: enemy_image
  2088.   #----------------------------------------------------------------------------
  2089.   def enemy_image(type, file, hue = 0)
  2090.     begin
  2091.       case type
  2092.       when :floor;      Cache.battleback1(file)
  2093.       when :wall;       Cache.battleback2(file)
  2094.       when :battler;    Cache.battler(file, hue)
  2095.       end
  2096.     rescue;             Cache.picture(file)
  2097.     end
  2098.   end
  2099.   #----------------------------------------------------------------------------
  2100.   # ○ new method: draw_image
  2101.   #----------------------------------------------------------------------------
  2102.   def draw_image(bitmap, width, height)
  2103.     x = (bitmap.width - width) * 0.5
  2104.     y = (bitmap.height - height) * 0.5
  2105.     src_rect = Rect.new(x, y, width, height)
  2106.     @enemy_bg.bitmap.blt(0, 0, bitmap, src_rect)
  2107.   end
  2108.   #----------------------------------------------------------------------------
  2109.   # ● upgraded method: terminate
  2110.   #----------------------------------------------------------------------------
  2111.   def terminate
  2112.     super
  2113.     dispose_enemy_image
  2114.     fadeout_all(60)
  2115.     @map_bgm.replay
  2116.   end
  2117.   #----------------------------------------------------------------------------
  2118.   # ○ new method: dispose_enemy_image
  2119.   #----------------------------------------------------------------------------
  2120.   def dispose_enemy_image
  2121.     return unless @enemy_bg
  2122.     @enemy_bg.bitmap.dispose if @enemy_bg.bitmap
  2123.     @enemy_bg.dispose
  2124.   end
  2125. end
Add Comment
Please, Sign In to add comment