设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 154|回复: 1
打印 上一主题 下一主题

[有事请教] 【图鉴脚本战内闪退】

[复制链接]

Lv1.梦旅人

梦石
0
星屑
92
在线时间
77 小时
注册时间
2024-1-8
帖子
21
跳转到指定楼层
1
40星屑
本帖最后由 神隐的主犯 于 2025-5-29 22:37 编辑

RUBY 代码复制
  1. # ----------------------------------------------------------------------------
  2. # ■ 作者注释 -
  3. # ----------------------------------------------------------------------------
  4. # 这是一个快速说明。这个脚本是为在以下网址找到的代码挑战赛编写的:
  5. # http://forums.rpgmakerweb.com/index.php?/forum/102-code-off-challenge/
  6. # ----------------------------------------------------------------------------
  7. # ■ 术语 -
  8. # ----------------------------------------------------------------------------
  9. # 本脚本可以商业或非商业使用。如果商业使用,我希望您能通过论坛私信我一个游戏链接,
  10. # 这样我可以跟进它的进度..但这不是必须的;) 这只是一个我想看看的类型的事情 :)
  11. # ----------------------------------------------------------------------------
  12. # ■ 介绍 -
  13. # ----------------------------------------------------------------------------
  14. # 这个脚本会给您一个场景,您可以在其中跟踪您已经发现和/或杀死的敌人。
  15. # 它将跟踪敌人的统计数据、技能、掉落物品、对元素和状态效果的抗性,
  16. # 同时显示敌人的描述和图像。
  17. # ----------------------------------------------------------------------------
  18. # ■ 使用说明 -
  19. # ----------------------------------------------------------------------------
  20. # 如果您将此脚本放入您的游戏项目中,它将起作用。了解注释标签的知识将有助于利用所有功能。
  21. # ----------------------------------------------------------------------------
  22. # ■ 敌人注释标签 -
  23. # ----------------------------------------------------------------------------
  24. # 您可以为每个敌人设置自定义描述。如果您跳过此注释标签,
  25. # 那么它将使用在 Default_Description 中设置的描述。文本将采用您在消息窗口中使用的相同代码,
  26. # 但您需要在每个代码前添加一个额外的 \ 。因此,\C[1] 将需要是 \\\C[1] 。
  27. # 您可以使用 KilloZapit 的单词包装器自动将文本适应框,或者如果您不想使用 KilloZapit 的单词包装器,
  28. # 则可以使用 | 来开始新的文本行。
  29. # 请参阅演示敌人注释标签框中的示例。
  30. #    <description1: 你的文本在这里>
  31. #
  32. # 当在 Bestiary 场景中时,敌人将出现在看起来像战斗背景图像的背景上。
  33. # 您可以设置默认图像的使用,并为每个设置的类别设置图像。
  34. # 但是,如果您希望某些敌人拥有非常自己的图像,与默认或类别图像不同,
  35. # 那么请使用以下标签:
  36. #    <bg_floor: 文件>   - 它将在 Battlebacks1 中查找文件,如果没有找到,
  37. #                         那么它将在 Pictures 文件夹中查找。
  38. #    <bg_wall: 文件>    - 它将在 Battlebacks2 中查找文件,如果没有找到,
  39. #                         那么它将在 Pictures 文件夹中查找。
  40. # 注意:不要在文件名周围放置 "" 的引号。如果您想使用单个文件,
  41. # 那么请将 bg_floor 或 bg_wall 设置为您想要使用的图像,并将另一个设置为 nil。
  42. #
  43. # 有时有些敌人您不想跟踪,或者如果您像我一样,您喜欢按部分对数据库进行排序并使用标签。
  44. # 为了确保这些数据库条目不会出现在 bestiary 场景中,请使用此标签:
  45. #    <skip>             - 当使用此标签时,将不会产生任何条目
  46. #
  47. # 有些游戏有同一个敌人的多个数据库条目,但它们稍微改变了统计数据以进行变化,
  48. # 或者改变了图形以进行变化。但它们仍然被认为是同一个敌人。在这种情况下,
  49. # 您可以使用此标签,以便无论您遇到哪一个,它都只会显示一个条目。
  50. #    <shown_id: x>      - x 是在 Bestiary 中使用的数据库 ID
  51. #
  52. # 类别标签将是使用最多的标签。您可以在自定义部分设置类别。
  53. # 您可以以任何您喜欢的方式对 Bestiary 场景进行排序。
  54. # 例如,可以按 Common Enemies, Rare Enemies, Boss Enemies, Elite 等进行分类,
  55. # 或按此演示中的地点分类。一个敌人可以出现在多个类别中。
  56. # 使用以下标签设置敌人的类别:
  57. #    <category: x>     - x 是下面定义的类别 ID
  58. #
  59. # 要使敌人对扫描免疫,请使用以下代码
  60. #    <no_scan>         - 敌人对扫描技能免疫
  61. #
  62. # ----------------------------------------------------------------------------
  63.  
  64. # ----------------------------------------------------------------------------
  65. # ■ 物品/技能注释标签 -
  66. # ----------------------------------------------------------------------------
  67. # 最后一个注释标签可以放在技能或物品的注释标签中。它允许您扫描敌人以了解有关它的信息。
  68. #    <scan>            - 当对敌人使用时,它会解锁信息
  69. #
  70. # ----------------------------------------------------------------------------
  71.  
  72. # ----------------------------------------------------------------------------
  73. # ■ 脚本调用 -
  74. # ----------------------------------------------------------------------------
  75. #                      - 手动添加 Bestiary 条目 -
  76. # 以防您需要手动添加 bestiary 条目,请使用以下内容:
  77. #     add_enemy_entry(enemy_id)   - enemy_id 是数据库中的 ID
  78. #
  79. #              - 通过脚本调用更改敌人的描述 -
  80. # 您可以通过脚本调用更改敌人的描述。当您通过脚本调用设置描述时,
  81. # 它将覆盖找到的任何其他描述文本(默认描述或按击杀自定义的描述)。
  82. # 要通过脚本调用设置描述,请使用以下格式:
  83. #     set_enemy_description(enemy_id, text)    - enemy_id 是数据库 ID
  84. #                                              - text 是显示的文本。
  85. # 文本遵循与其他所有描述文本相同的规则。您可以使用消息代码更改文本颜色、大小、使用图标等。使用 | 形成换行。如果您希望描述为空,则将文本设置为 ""。
  86. #
  87. # 要将描述文本重置为通常的内容,请使用:
  88. #     reset_enemy_description(enemy_id)        - enemy_id 是数据库 ID
  89. #
  90. #              - 获取敌人的击杀次数 -
  91. # 如果您需要进行条件检查或其他任何原因,可以获取您给定敌人的击杀次数。使用:
  92. #     enemy_kill_count(enemy_id)               - enemy_id 是数据库 ID
  93. # 注意:如果给定的 enemy_id 有 <shown_id: x>,在其中,则将转到注释标签指向的敌人 ID。
  94. # ==============================================================================
  95. # ■ 配置
  96. # ==============================================================================$imported ||= {}; $imported[:Venka_Bestiary] = true
  97. module Venka; module Bestiary
  98.  
  99. # 通用设置
  100. #----------------------------------------------------------------------------------------------------------------------
  101. Windowskin = "Window"    # 设置为 nil 以使用默认皮肤。
  102. Window_Opacity = 255        # 窗口的整体透明度。数字 0 - 255
  103. Window_BGOpacity = 180       # 窗口背景透明度(默认 192)
  104. Use_Dividers = true         # 是否绘制分隔线来分隔信息?
  105. Line_Color = [150, 150, 250, 225] # 分隔线的颜色,格式为 [红色, 蓝色, 绿色, Alpha]
  106. Frame_Image = false         # 是否绘制敌人图像周围的窗口边框?
  107. Menu_Access = true          # 是否可以从菜单访问 Bestiary?
  108. BG_Image = "Book"           # 在 Title1 或 Pictures 文件夹中找到
  109. Bestiary_BGM = ["Theme2", 80, 100] # ["文件", 音量, 音高]. 可以设置为 nil
  110. Scroll_Speed = 15            # 按 ↑↓ 时信息移动的速度
  111. Track_Progress = true       # 显示每个类别的完成度
  112. Track_Kills = true          # 跟踪杀死敌人的次数
  113. Show_Debuff_Info = false     # 显示减益信息部分
  114. Use_Wordwrapper = true      # 使用 KilloZapit 的自动换行脚本来处理文本
  115.  
  116. # 默认设置
  117. #----------------------------------------------------------------------------------------------------------------------
  118. # 您可以为每个敌人设置默认的背景图像和描述信息,如果您没有为每个敌人制作自定义信息。
  119. # 如果您只想使用一个背景图像,那么请在它的 Battleback 文件夹或 Pictures 文件夹中设置一个图像,
  120. # 并将另一个设置为 nil。
  121. #----------------------------------------------------------------------------------------------------------------------
  122. Default_BGFloor = "Dirt1"     # 默认使用的地面图像(Battlebacks1)
  123. Default_BGWall = "Forest1"     # 默认使用的墙面图像(Battlebacks2)
  124. # 描述文本可以使用消息代码(例如:\c[1] - 更改文本颜色)。
  125. # 使用 | 强制换行。
  126. Default_Description = "关于这个 | 敌人知之甚少。"
  127. # 随着击杀更多敌人,描述可以发展。这些描述必须通过注释标签设置。
  128. # 如果没有设置描述,则将跳过描述并显示较低的消息或默认消息。
  129. # 在此处设置击杀目标:
  130. Description1 = 0              # 0次击杀时显示此消息
  131. Description2 = 3              # 击杀3次后显示此消息
  132. Description3 = 8              # 击杀8次后显示此消息
  133.  
  134. # 按击杀显示设置
  135. #----------------------------------------------------------------------------------------------------------------------
  136. # 您可以设置根据击杀次数显示敌人的哪些信息。使用扫描技能也将解锁以下所有信息,
  137. # 无论给定敌人的击杀次数如何。
  138. #----------------------------------------------------------------------------------------------------------------------
  139. Show_BaseStats = 1          # 显示基础统计数据:攻击力、防御力、魔法攻击力等
  140. Show_Elements = 0            # 显示元素抗性
  141. Show_States = 0              # 显示状态抗性
  142. Show_DebuffStats = 0         # 显示减益比率
  143. Show_Abilities = 0          # 显示可以使用的能力列表
  144. Show_Loot = 0                # 显示敌人的掉落列表
  145.  
  146. # 文本设置
  147. #----------------------------------------------------------------------------------------------------------------------
  148. # 您可以设置在 Bestiary 场景中出现的所有文本。
  149. #----------------------------------------------------------------------------------------------------------------------
  150. Bestiary_Command = "境界图鉴"      # 菜单中场景的文本
  151. Category_Select = "选择一个类别"    # 选择类别的帮助文本
  152. Enemy_Select = "选择一个敌人"      # 选择敌人的帮助文本
  153. Discovered_Text = "已发现的敌人"    # 底部显示的文本
  154. Percent_Finished = "已完成"         # 完成百分比的文本
  155. Unknown_Loot = "未知掉落"           # 掉落未知时显示的文本
  156. Unknown_Skills = "未知能力"         # 技能未知时显示的文本
  157. View_Stats = "统计数据"             # 统计数据按钮文本
  158. View_More = "其他信息"             # 其他信息按钮文本
  159. View_Element = "元素"               # 元素信息按钮文本
  160. View_States = "状态"                # 状态信息按钮文本
  161. View_Debuff = "减益"                # 减益信息按钮文本
  162. Stats_Text = "基础统计"             # 基本统计数据的标题文本
  163. Element_Text = "元素抗性"           # 元素抗性的标题文本
  164. Status_Text = "状态抗性"            # 状态抗性的标题文本
  165. Debuff_Text = "减益比率"           # 减益比率的标题文本
  166. Loot_Text = "奖励"                  # 可获得物品的列表
  167. Skill_Text = "能力"                # 敌人使用的技能文本
  168. Immune_Text = "免疫"               # 敌人对状态免疫时出现的文本
  169. Absorb_Text = "吸收"               # 元素吸收(Yanfly 元素吸收脚本)的文本
  170. Unknown_Stat = "无法侦测"                # 未知抗性/统计数据的文本
  171. # 对于接下来的两个设置,如果您不想使用图标或文本,可以将其设置为 nil
  172. Exp_Text = ["经验:", 117]          # 经验和图标的文本和图标
  173. Gold_Text = ["魂:", 120]          # 金币和图标的文本和图标
  174. Kills_Text = "击杀次数"              # 显示敌人击杀数的文本
  175. Instructions_Text = "使用 PageUp 和 PageDown 更换敌人。"
  176. Battle_Instructions = "按 Shift 查看目标的更多信息。"
  177.  
  178. # 扫描技能设置
  179. #----------------------------------------------------------------------------------------------------------------------
  180. # 您可以在此处设置扫描技能的相关内容。这主要是设置在游戏中出现的文本。
  181. # 您还可以设置在敌人窗口中选择敌人时弹出窗口显示的按键。
  182. # 注意:窗口也会在成功扫描时弹出
  183. #
  184. # 按键选项为:                   :A  - 这是 Shift 键
  185. #   :X   - 这是 A 键         :Y  - 这是 S 键
  186. #   :Z   - 这是 D 键         :L  - 这是 PageUp/Q 键
  187. #   :R   - 这是 PageDw/W 键     :SHIFT, :CTRL, :ATL - shift, cntl, atl 键
  188. #----------------------------------------------------------------------------------------------------------------------
  189. Target_Scanned = "%s 已扫描!"   # 成功扫描时的战斗信息
  190. No_Scan = "%s 无法被扫描!"     # 目标无法被扫描时的战斗信息
  191. No_Info = "未找到信息"         # 当目标对扫描免疫时的文本。
  192. Scan_PopUp = :SHIFT             # 使窗口弹出的输入键
  193.  
  194. # 列表排序设置
  195. #----------------------------------------------------------------------------------------------------------------------
  196. # 您可以设置列表的排序方式。您可以按发现顺序(发现顺序应该是默认的)、按它们的数据库 ID 或名称进行排序。
  197. #----------------------------------------------------------------------------------------------------------------------
  198. Sort_Type = :id      # 选择有 :id, :name, 或 :default
  199.  
  200. # 字体设置
  201. #----------------------------------------------------------------------------------------------------------------------
  202. # :help_font    = 出现在顶部和底部窗口的字体
  203. # :list_font    = 列表窗口中的字体
  204. # :header_font  = 用于统计类型的字体
  205. # :stat_font    = 用于统计数据的字体
  206. # :description  = 敌人描述文本的字体。
  207. #
  208. # 对于每种文本类型,您需要设置字体、大小、粗体和颜色。
  209. # 使用以下格式:
  210. #   [["字体名称, 字体名称, 等"], 字体大小, 粗体?, 颜色]],
  211. #      字体名称 = 一个数组,保存字体选择。第一个是您首先使用的选择,
  212. #        但如果玩家的计算机上没有该字体,它将通过列表继续寻找可以使用的字体
  213. #      字体大小 = 您想使用的字体大小
  214. #      粗体? = 这应该是 true 用于粗体,false 关闭粗体
  215. #      颜色 = 这是与设置 Gauge Color 的颜色相同的格式。
  216. #        使用 [红色, 蓝色, 绿色, 不透明度] 或窗口皮肤颜色编号。
  217. #      轮廓? = 这将打开或关闭字体的轮廓
  218. #----------------------------------------------------------------------------------------------------------------------
  219. Fonts = {       # [["字体"]],           大小, 粗体?, 颜色, 轮廓?
  220.   :normal_font => [["Calibri", "Sylfaen"], 24, false,  0,      true],
  221.   :list_font   => [["Calibri", "Sylfaen"], 24, false,  0,      true],
  222.   :header_font => [["Calibri", "Sylfaen"], 23,  true,  1,      true],
  223.   :stat_name   => [["Calibri", "Sylfaen"], 20,  true,  0,      true],
  224.   :stats_font  => [["Calibri", "Sylfaen"], 20, false,  0,      true],
  225.   :description => [["Calibri", "Sylfaen"], 18, false,  0,      true],
  226. } # <—— 不要删除
  227. # 下面两个颜色设置可以是窗口皮肤颜色或 [红色, 蓝色, 绿色]
  228. High_Resist = 3       # 高抗性使用的颜色
  229. Low_Resist = 18       # 低抗性(弱点)使用的颜色
  230. Immunity_Color = 17   # 免疫/吸收文本使用的颜色
  231. # 战斗字体设置
  232. #----------------------------------------------------------------------------------------------------------------------
  233. # 战斗中的字体与窗口中出现的字体略有不同。
  234. # 对于这一个,颜色必须以 [红色, 蓝色, 绿色] 的格式。
  235. #----------------------------------------------------------------------------------------------------------------------
  236. #                   字体族,      大小, 粗体?,    颜色,     轮廓?
  237. Battle_Font = [["Calibri", "Sylfaen"], 24,  true, [255,255,255],   true]
  238.  
  239. # 基础统计设置
  240. #----------------------------------------------------------------------------------------------------------------------
  241. # 设置用于基础统计(HP, MP, 攻击, 等等)的文本和/或图标
  242. # 您可以将文本或图标设置为 nil 以省略它们。
  243. #----------------------------------------------------------------------------------------------------------------------
  244. Base_Stats = [] #["文本", 图标索引]
  245. Base_Stats[0] = ["生命",   122]  # 最大生命值
  246. Base_Stats[1] = ["灵力",   112]  # 最大魔法值
  247. Base_Stats[2] = ["攻击力",  116]  # 攻击
  248. Base_Stats[3] = ["防御",  161]  # 防御
  249. Base_Stats[4] = ["魔力", 113]  # 魔法攻击
  250. Base_Stats[5] = ["魔抗",  15]  # 魔法防御
  251. Base_Stats[6] = ["速度",   12]  # 敏捷
  252. Base_Stats[7] = ["幸运", 202]  # 幸运
  253.  
  254. # 元素设置
  255. #----------------------------------------------------------------------------------------------------------------------
  256. # 您想要跟踪的元素。按优先顺序列出元素。在默认游戏分辨率下,大约会显示 9 个图标。
  257. # 如果您使屏幕变宽,那么可能会显示更多。因此,按重要性顺序列出您想要显示的图标。
  258. #----------------------------------------------------------------------------------------------------------------------
  259. Elements = [
  260.   # [ID, 图标索引],金木水火土日月灵
  261.   [2,  858],   
  262.   [3,  859],   
  263.   [4,  860],   
  264.   [5,  861],   
  265.   [6,  862],  
  266.   [7,  863],   
  267.   [8,  864],
  268.   [9,  865],   
  269.  
  270.   ] # <-— 不要删除!!
  271.  
  272. # 状态设置
  273. #----------------------------------------------------------------------------------------------------------------------
  274. # 这就像设置元素一样,但是不需要定义图标,因为所有状态/状态在数据库中都设置了图标。
  275. # 所以对于这个,只需按优先顺序设置您想要跟踪的状态 ID。
  276. #----------------------------------------------------------------------------------------------------------------------
  277. States = [1, 2, 3, 4, 5, 6, 7, 10]
  278.  
  279. # 状态设置
  280. #----------------------------------------------------------------------------------------------------------------------
  281. # 这就像设置元素一样,但是不需要定义图标,因为所有状态/状态在数据库中都设置了图标。
  282. # 所以对于这个,只需按优先顺序设置您想要跟踪的状态 ID。
  283. #----------------------------------------------------------------------------------------------------------------------
  284. States = [1, 2, 3, 4, 5, 6, 7, 10]
  285.  
  286. # 类别设置
  287. #----------------------------------------------------------------------------------------------------------------------
  288. # 您可以设置敌人将被分类到的类别。这可以是您喜欢的任何方式。例如,您可以按种类(哺乳动物、
  289. # 鸟类、恶魔等)或按地区(森林、河流、山脉等)进行分类。您必须在此处设置所有类别,然后使用数据库的
  290. # 敌人标签页来设置它。
  291. #
  292. #   Category[ID] = {               # ID 必须是唯一的数字。
  293. #     :name => "Miscellaneous",     # 类别的名称,正如它在场景中出现的那样
  294. #     :bg_floor => "file",          # 如果不是默认的,使用此图像(可以省略)
  295. #     :bg_wall  => "file",          # 如果不是默认的,使用此图像(可以省略)
  296. #           文件 = 如果您想使用默认图像之外的图像,请使用此文件。如果您想使用
  297. #                 不使用图像,请将其设置为 ""。
  298. #   }
  299. #
  300. # 注意:地板和墙壁图像都可以省略以使用默认图像。如果使用单个图像,则将其中一个或另一个设置为您想要使用的图像
  301. # (在相应的战斗背景文件夹或图片文件夹中找到),然后将另一个设置为 ""(一个空文件)。不要将另一个图像设置为 nil,
  302. # 因为这将选择默认图像。
  303. #----------------------------------------------------------------------------------------------------------------------  Category ||= {}
  304.   Category ||= {}
  305. #----------------------------------------------------------------------------
  306.   Category[0] = {  # This is the default category. Enemies appear in this
  307.       # category if they don't have one assigned or there was a typo in the tag.
  308.       :name => "人类",
  309.       } # <-DO NOT REMOVE
  310.   #----------------------------------------------------------------------------
  311.   Category[1] = {  # Enemies found in the Forsaken Forest area
  312.       :name => "魔物",  # Name of Category
  313.       }
  314.   #----------------------------------------------------------------------------
  315.   Category[2] = {  # Enemies found in the Abandoned Mines area
  316.       :name => "机械",  # Name of Category
  317.       }
  318.   #----------------------------------------------------------------------------
  319.   Category[3] = {  # Enemies found in the Deep Space area
  320.       :name => "神明",       # Name of Category
  321.       }
  322.   #----------------------------------------------------------------------------
  323.   Category[4] = {  # Enemies found in the Nocturnal Plains area
  324.       :name => "亡魂",     # Name of Category
  325.       }
  326.   #----------------------------------------------------------------------------
  327.   Category[5] = {  # Undead Enemies
  328.       :name => "精英",               # Name of Category
  329.       }
  330.   #----------------------------------------------------------------------------
  331.   Category[6] = {  # Enemies found in the Nocturnal Plains area
  332.       :name => "首领",            # Name of Category
  333.       }
  334.   #----------------------------------------------------------------------------
  335.   Category[7] = {  # Enemies found in the Nocturnal Plains area
  336.       :name => "EXTRA",            # Name of Category
  337.       }
  338.   #----------------------------------------------------------------------------
  339.   Category[8] = {  # Enemies found in the Nocturnal Plains area
  340.       :name => "往昔",            # Name of Category
  341.       }
  342. #==============================================================================
  343. # ■ Edits should stop here unless you know what you're doing :)
  344. #==============================================================================
  345.   end
  346.   module Notetag
  347.     Skip_Enemy = /<skip>/i
  348.     Enemy_Category = /<category:\s*(\d+(?:\s*,\s*\d+)*)>/i
  349.     BG_Floor   = /<bg_floor:\s*(\w+)>/i
  350.     BG_Wall    = /<bg_wall:\s*(\w+)>/i
  351.     Enemy_Desc1 = /<description1:\s*(.*)>/i
  352.     Enemy_Desc2 = /<description2:\s*(.*)>/i
  353.     Enemy_Desc3 = /<description3:\s*(.*)>/i
  354.     Shown_ID   = /<shown_id:\s*(\d+)>/i
  355.     Scan_Skill = /<scan>/i
  356.     No_Scan    = /<no_scan>/i
  357.   end
  358. end
  359. #------------------------------------------------------------------------------
  360. # ○ Creating a way to store discovered info about the enemy with Struct.
  361. #------------------------------------------------------------------------------
  362. Bestiary_Entry = Struct.new(:enemy_id, :category, :elements, :states, :kills,
  363.     :quotes, :scanned)
  364. #==============================================================================
  365. # ■ Vocab
  366. #==============================================================================
  367. module Vocab
  368.   # Scan Skill
  369.   Scanned = Venka::Bestiary::Target_Scanned
  370.   No_Scan = Venka::Bestiary::No_Scan
  371. end
  372. #==============================================================================
  373. # ■ DataManager
  374. #==============================================================================
  375. module DataManager
  376.   #----------------------------------------------------------------------------
  377.   # ● alias method: load_database
  378.   #----------------------------------------------------------------------------
  379.   class << self;  alias bestiary_db_notetags load_database;   end
  380.   def self.load_database
  381.     bestiary_db_notetags
  382.     load_bestiary_notetags
  383.   end
  384.   #----------------------------------------------------------------------------
  385.   # ○ new method: load_bestiary_notetags
  386.   #----------------------------------------------------------------------------
  387.   def self.load_bestiary_notetags
  388.     ($data_enemies + $data_skills + $data_items).compact.each do |item|
  389.       item.load_bestiary_notetags
  390.     end
  391.   end
  392. end
  393. #==============================================================================
  394. # ■ RPG::UsableItem
  395. #==============================================================================
  396. class RPG::UsableItem
  397.   #----------------------------------------------------------------------------
  398.   # ♦ Public Instance Variables
  399.   #----------------------------------------------------------------------------
  400.   attr_accessor :scan
  401.   #----------------------------------------------------------------------------
  402.   # ○ new method: load_bestiary_notetags
  403.   #----------------------------------------------------------------------------
  404.   def load_bestiary_notetags
  405.     @scan = false
  406.     self.note.split(/[\r\n]+/).each do |line|
  407.       info = []
  408.       case line
  409.       when Venka::Notetag::Scan_Skill;        @scan = true
  410.       end
  411.     end
  412.   end
  413. end
  414. #==============================================================================
  415. # ■ RPG::Enemy
  416. #==============================================================================
  417. class RPG::Enemy
  418.   #----------------------------------------------------------------------------
  419.   # ♦ Public Instance Variables
  420.   #----------------------------------------------------------------------------
  421.   attr_accessor :skip, :category, :bg_floor, :bg_wall, :description, :shown_id
  422.   attr_accessor :no_scan, :descript1, :descript2, :descript3
  423.   #----------------------------------------------------------------------------
  424.   # ○ new method: load_bestiary_notetags
  425.   #----------------------------------------------------------------------------
  426.   def load_bestiary_notetags
  427.     @skip = false
  428.     @category = [0]
  429.     @bg_floor = @bg_wall = ""
  430.     @shown_id = @id
  431.     @no_scan = false
  432.     @description = nil
  433.     @descript1 = @descript2 = @descript3 = nil
  434.     self.note.split(/[\r\n]+/).each do |line|
  435.       info = []
  436.       case line
  437.       when Venka::Notetag::Skip_Enemy;        @skip = true
  438.       when Venka::Notetag::No_Scan;           @no_scan = true
  439.       when Venka::Notetag::Enemy_Category
  440.         $1.scan(/\d+/).each { |num| info.push(num.to_i) }
  441.         @category = info ? info : 0
  442.       when Venka::Notetag::BG_Floor;          @bg_floor = $1.to_s
  443.       when Venka::Notetag::BG_Wall;           @bg_wall = $1.to_s
  444.       when Venka::Notetag::Enemy_Desc1;       @descript1 = $1.to_s
  445.       when Venka::Notetag::Enemy_Desc2;       @descript2 = $1.to_s
  446.       when Venka::Notetag::Enemy_Desc3;       @descript3 = $1.to_s
  447.       when Venka::Notetag::Shown_ID;          @shown_id = $1.to_i
  448.       end
  449.     end
  450.   end
  451. end
  452. #==============================================================================
  453. # ■ BattleManager
  454. #==============================================================================
  455. module BattleManager
  456.   #----------------------------------------------------------------------------
  457.   # ● alias method: battle_start
  458.   #----------------------------------------------------------------------------
  459.   class << self;  alias bestiary_battle_start battle_start;   end
  460.   def self.battle_start
  461.     bestiary_battle_start
  462.     add_bestiary_enemies
  463.   end
  464.   #----------------------------------------------------------------------------
  465.   # ○ new method: add_bestiary_enemies
  466.   #----------------------------------------------------------------------------
  467.   def self.add_bestiary_enemies
  468.     $game_troop.members.each do |enemy|
  469.       rpg_enemy = $data_enemies[enemy.enemy_id]
  470.       next if rpg_enemy.nil? || rpg_enemy.skip
  471.       unless $game_party.bestiary_include?(rpg_enemy.shown_id)
  472.         $game_party.add_enemy($data_enemies[rpg_enemy.shown_id])
  473.       end
  474.     end
  475.   end
  476. end
  477. #==============================================================================
  478. # ■ Game_Enemy
  479. #==============================================================================
  480. class Game_Enemy < Game_Battler
  481.   #----------------------------------------------------------------------------
  482.   # ● upgraded method: add_state
  483.   #----------------------------------------------------------------------------
  484.   def add_state(state_id)
  485.     Venka::Bestiary::States.each_with_index do |id, i|
  486.       next unless state_id == id
  487.       $game_party.bestiary.each do |enemy|
  488.         next unless enemy.enemy_id == $data_enemies[@enemy_id].shown_id
  489.         enemy.states[i] = true
  490.       end
  491.     end
  492.     super
  493.   end
  494. end
  495. #==============================================================================
  496. # ■ Game_Troop
  497. #==============================================================================
  498. class Game_Troop < Game_Unit
  499.   #----------------------------------------------------------------------------
  500.   # ● alias method: battle_start
  501.   #----------------------------------------------------------------------------
  502.   alias bestiary_kill_count make_drop_items
  503.   def make_drop_items
  504.     add_encounter_count
  505.     bestiary_kill_count
  506.   end
  507.   #----------------------------------------------------------------------------
  508.   # ○ new method: add_encounter_count
  509.   #----------------------------------------------------------------------------
  510.   def add_encounter_count
  511.     dead_members.each do |enemy|
  512.       rpg_enemy = $data_enemies[enemy.enemy_id]
  513.       next if rpg_enemy.nil? || rpg_enemy.skip
  514.       $game_party.bestiary.each do |entry|
  515.         next unless entry.enemy_id == rpg_enemy.shown_id
  516.         entry.kills += 1
  517.         case entry.kills
  518.         when Venka::Bestiary::Show_Elements
  519.           entry.elements.size.times {|i| entry.elements[i] = true}
  520.         when Venka::Bestiary::Show_States
  521.           entry.states.size.times {|i| entry.states[i] = true}
  522.         end
  523.       end
  524.     end
  525.   end
  526. end
  527. #==============================================================================
  528. # ■ Game_Party
  529. #==============================================================================
  530. class Game_Party < Game_Unit
  531.   #----------------------------------------------------------------------------
  532.   # ♦ Public Instance Variables
  533.   #----------------------------------------------------------------------------
  534.   attr_accessor   :bestiary
  535.   #----------------------------------------------------------------------------
  536.   # ● alias method: initialize
  537.   #----------------------------------------------------------------------------
  538.   alias venka_bestiary_enounters_ini initialize
  539.   def initialize
  540.     venka_bestiary_enounters_ini
  541.     @bestiary = []
  542.   end
  543.   #----------------------------------------------------------------------------
  544.   # ○ new method: add_enemy
  545.   #----------------------------------------------------------------------------
  546.   # The entries are: EnemyID, BestiaryCategory, Array for Element info,
  547.   #   Array for State info, Kill Counter, Actor Quotes, and Scanned?
  548.   #----------------------------------------------------------------------------
  549.   def add_enemy(enemy)
  550.     @bestiary << Bestiary_Entry.new(enemy.id, enemy.category,
  551.         Array.new(Venka::Bestiary::Elements.size, false),
  552.         Array.new(Venka::Bestiary::States.size, false), 0, [], false)
  553.   end
  554.   #----------------------------------------------------------------------------
  555.   # ○ new method: reveal_resist
  556.   #----------------------------------------------------------------------------
  557.   def reveal_resist(enemy_id, reveal = true)
  558.     rpg_enemy = $data_enemies[enemy_id]
  559.     return if rpg_enemy.nil? || rpg_enemy.skip
  560.     @bestiary.each do |entry|
  561.       next unless entry.enemy_id == rpg_enemy.shown_id
  562.       next if rpg_enemy.no_scan && !reveal
  563.       entry.elements.size.times {|i| entry.elements[i] = true}
  564.       entry.states.size.times {|i| entry.states[i] = true}
  565.     end
  566.   end
  567.   #----------------------------------------------------------------------------
  568.   # ○ new method: bestiary_include?
  569.   #----------------------------------------------------------------------------
  570.   def bestiary_include?(id)
  571.     @bestiary.each do |entry|
  572.       return true if entry.enemy_id == id
  573.     end
  574.     return false
  575.   end
  576. end
  577. #==============================================================================
  578. # ■ Game_Interpreter
  579. #==============================================================================
  580. class Game_Interpreter
  581.   #----------------------------------------------------------------------------
  582.   # ○ new method: add_enemy_entry
  583.   #----------------------------------------------------------------------------
  584.   def add_enemy_entry(enemy_id)
  585.     rpg_enemy = $data_enemies[enemy_id]
  586.     return if rpg_enemy.nil? || rpg_enemy.skip
  587.     if $game_party.bestiary == []
  588.       $game_party.add_enemy($data_enemies[rpg_enemy.shown_id])
  589.     elsif !$game_party.bestiary_include?(rpg_enemy.shown_id)
  590.       $game_party.add_enemy($data_enemies[rpg_enemy.shown_id])
  591.     end
  592.   end
  593.   #----------------------------------------------------------------------------
  594.   # ○ new method: set_enemy_description
  595.   #----------------------------------------------------------------------------
  596.   def set_enemy_description(enemy_id, text)
  597.     id = $data_enemies[enemy_id].shown_id
  598.     $data_enemies[id].description = text
  599.   end
  600.   #----------------------------------------------------------------------------
  601.   # ○ new method: reset_enemy_description
  602.   #----------------------------------------------------------------------------
  603.   def reset_enemy_description(enemy_id)
  604.     id = $data_enemies[enemy_id].shown_id
  605.     $data_enemies[id].description = nil
  606.   end
  607.   #----------------------------------------------------------------------------
  608.   # ○ new method: enemy_kill_count(enemy_id)
  609.   #----------------------------------------------------------------------------
  610.   def enemy_kill_count(enemy_id)
  611.     kills = 0
  612.     $game_party.bestiary.each do |entry|
  613.       next unless entry.enemy_id == $data_enemies[enemy_id].shown_id
  614.       kills = entry.kills
  615.       case kills
  616.       when Venka::Bestiary::Show_Elements
  617.         entry.elements.size.times {|i| entry.elements[i] = true}
  618.       when Venka::Bestiary::Show_States
  619.         entry.states.size.times {|i| entry.states[i] = true}
  620.       end
  621.     end
  622.     return kills
  623.   end
  624. end
  625. #==============================================================================
  626. # ■ Window_Base
  627. #==============================================================================
  628. class Window_Base < Window
  629.   #----------------------------------------------------------------------------
  630.   # ○ new method: set_windowskin
  631.   #----------------------------------------------------------------------------
  632.   def set_windowskin
  633.     return unless Venka::Bestiary::Windowskin
  634.     self.windowskin = Cache.system(Venka::Bestiary::Windowskin)
  635.     self.opacity = Venka::Bestiary::Window_Opacity
  636.     self.back_opacity = Venka::Bestiary::Window_BGOpacity
  637.   end
  638.   #----------------------------------------------------------------------------
  639.   # ○ new method: get_color - method determines if text color or new color
  640.   #----------------------------------------------------------------------------
  641.   def get_color(input)
  642.     input.is_a?(Integer) ? text_color([[input, 0].max, 31].min) : Color.new(*input)
  643.   end
  644.   #----------------------------------------------------------------------------
  645.   # ○ new method: font_color
  646.   #----------------------------------------------------------------------------
  647.   def font_color(text_type)
  648.     f_color = Venka::Bestiary::Fonts[text_type][3]
  649.     color = f_color.is_a?(Integer) ? text_color(f_color) : Color.new(*f_color)
  650.   end
  651.   #----------------------------------------------------------------------------
  652.   # ○ new method: set_bestiary_font
  653.   #----------------------------------------------------------------------------
  654.   def set_bestiary_font(text_type, enabled = true)
  655.     font = Venka::Bestiary::Fonts[text_type]
  656.     contents.font.name = font[0]
  657.     contents.font.size = font[1]
  658.     contents.font.bold = font[2]
  659.     contents.font.outline = font[4]
  660.     change_color(font_color(text_type), enabled)
  661.   end
  662.   #----------------------------------------------------------------------------
  663.   # ○ new method: font_height
  664.   #----------------------------------------------------------------------------
  665.   def font_height
  666.     [contents.font.size, 24].max
  667.   end
  668.   #----------------------------------------------------------------------------
  669.   # ○ new method: draw_line
  670.   #----------------------------------------------------------------------------
  671.   def draw_line(y)
  672.     return unless Venka::Bestiary::Use_Dividers
  673.     color = get_color(Venka::Bestiary::Line_Color)
  674.     contents.fill_rect(4, y, contents_width - 8, 2, color)
  675.     contents.fill_rect(4, y + 2, contents_width - 8, 1, Color.new(16,16,16,100))
  676.   end
  677. end
  678. #==============================================================================
  679. # ■ Window_Message
  680. #==============================================================================
  681. class Window_Message
  682.   #----------------------------------------------------------------------------
  683.   # ♦ Public Instance Variables
  684.   #----------------------------------------------------------------------------
  685.   attr_accessor :wordwrap
  686. end
  687. #==============================================================================
  688. # ■ Window_MenuCommand
  689. #==============================================================================
  690. class Window_MenuCommand < Window_Command
  691.   #----------------------------------------------------------------------------
  692.   # ● alias method: add_original_commands
  693.   #----------------------------------------------------------------------------
  694.   alias bestiary_menu_access_aoc       add_original_commands
  695.   def add_original_commands
  696.     bestiary_menu_access_aoc
  697.     add_command(Venka::Bestiary::Bestiary_Command, :bestiary) if Venka::Bestiary::Menu_Access
  698.   end
  699. end
  700. #==============================================================================
  701. # ■ Window_BattleLog
  702. #==============================================================================
  703. class Window_BattleLog < Window_Selectable
  704.   #----------------------------------------------------------------------------
  705.   # ● alias method: display_failure
  706.   #----------------------------------------------------------------------------
  707.   alias bestiary_scan_fail_msg display_failure
  708.   def display_failure(target, item)
  709.     if item.scan && target.result.hit? && !target.result.success
  710.       text = $data_enemies[target.enemy_id].no_scan ? Vocab::No_Scan : Vocab::Scanned
  711.       add_text(sprintf(text, target.name))
  712.       wait
  713.     else
  714.       bestiary_scan_fail_msg(target, item)
  715.     end
  716.   end
  717. end
  718. #==============================================================================
  719. # ■ Window_BestiaryHelp
  720. #==============================================================================
  721. class Window_BestiaryHelp < Window_Base
  722.   #----------------------------------------------------------------------------
  723.   # ● upgraded method: initialize
  724.   #----------------------------------------------------------------------------
  725.   def initialize(x, y)
  726.     height = [Venka::Bestiary::Fonts[:normal_font][1], 24].max + 24
  727.     super(x, y, Graphics.width, height)
  728.     set_windowskin
  729.   end
  730.   #----------------------------------------------------------------------------
  731.   # ○ new method: set_text
  732.   #----------------------------------------------------------------------------
  733.   def set_text(text)
  734.     contents.clear
  735.     set_bestiary_font(:normal_font)
  736.     draw_text(0, 0, contents.width, font_height, text, 1)
  737.   end
  738.   #----------------------------------------------------------------------------
  739.   # ○ new method: draw_completion
  740.   #----------------------------------------------------------------------------
  741.   def draw_completion
  742.     contents.clear
  743.     draw_enemies_discovered
  744.   end
  745.   #----------------------------------------------------------------------------
  746.   # ○ new method: draw_enemies_discovered
  747.   #----------------------------------------------------------------------------
  748.   def draw_enemies_discovered
  749.     set_bestiary_font(:normal_font)
  750.     enemies_discovered = $game_party.bestiary.size
  751.     total = total_enemies
  752.     text = "#{enemies_discovered}/#{total} #{Venka::Bestiary::Discovered_Text}"
  753.     draw_text(0, 0, contents.width, font_height, text)
  754.     discovered = (enemies_discovered.to_f / total) * 100
  755.     text = "#{discovered.round(1)}% #{Venka::Bestiary::Percent_Finished}"
  756.     draw_text(0, 0, contents.width, font_height, text, 2)
  757.   end
  758.   #----------------------------------------------------------------------------
  759.   # ○ new method: total_enemies
  760.   #----------------------------------------------------------------------------
  761.   def total_enemies
  762.     total = 0
  763.     for i in 1...$data_enemies.size
  764.       next if $data_enemies[i].shown_id != $data_enemies[i].id
  765.       total += 1 unless $data_enemies[i].skip
  766.     end
  767.     total
  768.   end
  769.   #----------------------------------------------------------------------------
  770.   # ○ new method: draw_instructions
  771.   #----------------------------------------------------------------------------
  772.   def draw_instructions
  773.     contents.clear
  774.     set_bestiary_font(:normal_font)
  775.     text = Venka::Bestiary::Instructions_Text
  776.     draw_text(0, 0, contents.width, font_height, text, 1)
  777.   end
  778.   #----------------------------------------------------------------------------
  779.   # ○ new method: set_description
  780.   #----------------------------------------------------------------------------
  781.   def set_description(enemy)
  782.     contents.clear
  783.     create_contents             # Remake contents since the window size changed
  784.     get_description_text(enemy)
  785.     text = get_description_text(enemy)
  786.     if Venka::Bestiary::Use_Wordwrapper
  787.       wrapping = @wordwrap
  788.       @wordwrap = true
  789.       draw_text_ex(0, 0, text.gsub(/[|]/, ""))
  790.       @wordwrap = wrapping
  791.     else
  792.       draw_text_ex(0, 0, text.gsub(/[|]/, "\n"))
  793.     end
  794.   end
  795.   #----------------------------------------------------------------------------
  796.   # ○ new method: get_description_text
  797.   #----------------------------------------------------------------------------
  798.   def get_description_text(enemy)
  799.     if enemy.description
  800.       text = enemy.description
  801.     else
  802.       text = Venka::Bestiary::Default_Description
  803.       kills = 0
  804.       $game_party.bestiary.each do |foe|
  805.         kills = foe.kills if foe.enemy_id == enemy.shown_id
  806.       end
  807.       if kills >= Venka::Bestiary::Description3 && enemy.descript3
  808.         text = enemy.descript3
  809.       elsif kills >= Venka::Bestiary::Description2 && enemy.descript2
  810.         text = enemy.descript2
  811.       elsif kills >= Venka::Bestiary::Description1 && enemy.descript1
  812.         text = enemy.descript1
  813.       end
  814.     end
  815.     text
  816.   end
  817.   #----------------------------------------------------------------------------
  818.   # ● upgraded method: draw_text_ex
  819.   #----------------------------------------------------------------------------
  820.   def draw_text_ex(x, y, text)
  821.     set_bestiary_font(:description)
  822.     text = convert_escape_characters(text)
  823.     pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
  824.     process_character(text.slice!(0, 1), text, pos) until text.empty?
  825.   end
  826. end
  827. #==============================================================================
  828. # ■ Window_BestiaryCategory
  829. #==============================================================================
  830. class Window_BestiaryCategory < Window_Command
  831.   #----------------------------------------------------------------------------
  832.   # ● upgraded method: initialize
  833.   #----------------------------------------------------------------------------
  834.   def initialize(x, y)
  835.     @wy = y
  836.     @categories = Venka::Bestiary::Category
  837.     super(x, @wy)
  838.     set_windowskin
  839.   end
  840.   #----------------------------------------------------------------------------
  841.   # ● window settings
  842.   #----------------------------------------------------------------------------
  843.   def window_width;  Graphics.width * 0.5;                                end
  844.   def window_height; Graphics.height - (@wy * 2);                         end
  845.   def item_height;   [Venka::Bestiary::Fonts[:list_font][1], 24].max;     end
  846.   #----------------------------------------------------------------------------
  847.   # ● upgraded method: make_command_list
  848.   #----------------------------------------------------------------------------
  849.   def make_command_list
  850.     @categories.each{|key, info| add_command(info[:name], key)}
  851.   end
  852.   #----------------------------------------------------------------------------
  853.   # ● upgraded method: draw_item
  854.   #----------------------------------------------------------------------------
  855.   def draw_item(index)
  856.     set_bestiary_font(:normal_font)
  857.     @width = Venka::Bestiary::Track_Progress ? text_size("99.9%").width + 5 : 0
  858.     rect = item_rect_for_text(index)
  859.     set_bestiary_font(:list_font)
  860.     draw_text(rect.x, rect.y, rect.width - @width, rect.height, command_name(index))
  861.     found_text(index,  rect) if Venka::Bestiary::Track_Progress
  862.   end
  863.   #----------------------------------------------------------------------------
  864.   # ○ new method: found_text
  865.   #----------------------------------------------------------------------------
  866.   def found_text(index,  rect)
  867.     set_bestiary_font(:normal_font)
  868.     total = total_enemies(index)
  869.     discovered = total_found(index)
  870.     value = (total > 0) ? (discovered.to_f / total) * 100 : 0.0
  871.     text = (value > 0 && value < 100) ? value.round(1) : value.round
  872.     draw_text(rect.width - @width, rect.y, @width, rect.height, "#{text}%", 2)
  873.   end
  874.   #----------------------------------------------------------------------------
  875.   # ○ new method: total_enemies
  876.   #----------------------------------------------------------------------------
  877.   def total_enemies(index)
  878.     total = 0
  879.     for i in 1...$data_enemies.size
  880.       next unless $data_enemies[i].category.include?(index)
  881.       next if $data_enemies[i].shown_id != $data_enemies[i].id
  882.       total += 1 unless $data_enemies[i].skip
  883.     end
  884.     return total
  885.   end
  886.   #----------------------------------------------------------------------------
  887.   # ○ new method: total_found
  888.   #----------------------------------------------------------------------------
  889.   def total_found(index)
  890.     total = 0
  891.     $game_party.bestiary.each {|e| total += 1 if e.category.include?(index)}
  892.     return total
  893.   end
  894. end
  895. #==============================================================================
  896. # ■ Window_BestiaryEnemyList
  897. #==============================================================================
  898. class Window_BestiaryEnemyList < Window_Command
  899.   #----------------------------------------------------------------------------
  900.   # ♦ Public Instance Variables
  901.   #----------------------------------------------------------------------------
  902.   attr_reader   :category_window,    :stats_window
  903.   #----------------------------------------------------------------------------
  904.   # ● upgraded method: initialize
  905.   #----------------------------------------------------------------------------
  906.   def initialize(x, y)
  907.     @category = 0
  908.     @wy = y
  909.     super(x, @wy)
  910.     set_windowskin
  911.   end
  912.   #----------------------------------------------------------------------------
  913.   # ● window settings
  914.   #----------------------------------------------------------------------------
  915.   def window_width;  Graphics.width * 0.5;                                end
  916.   def window_height; Graphics.height - (@wy * 2);                         end
  917.   def item_height;   [Venka::Bestiary::Fonts[:list_font][1], 24].max;     end
  918.   #----------------------------------------------------------------------------
  919.   # ○ new method: category_window
  920.   #----------------------------------------------------------------------------
  921.   def category_window=(category_window)
  922.     if @category_window != category_window
  923.       @category_window = category_window
  924.       @category = category_window.current_symbol.to_s.to_i
  925.       refresh
  926.     end
  927.   end
  928.   #----------------------------------------------------------------------------
  929.   # ○ new method: stats_window
  930.   #----------------------------------------------------------------------------
  931.   def stats_window=(stats_window)
  932.     if @stats_window != stats_window
  933.       @stats_window = stats_window
  934.     end
  935.   end
  936.   #----------------------------------------------------------------------------
  937.   # ● upgraded method: make_command_list
  938.   #----------------------------------------------------------------------------
  939.   def make_command_list
  940.     @enemies = []
  941.     sort_list
  942.     @bestiary_list.each do |enemy|
  943.       next if enemy.nil?
  944.       next unless enemy.category.include?(@category)
  945.       @enemies << enemy
  946.       add_command($data_enemies[enemy.enemy_id].name, :ok, true, enemy.enemy_id)
  947.     end
  948.   end
  949.   #----------------------------------------------------------------------------
  950.   # ○ new method: sort_list
  951.   #----------------------------------------------------------------------------
  952.   def sort_list
  953.     @bestiary_list = $game_party.bestiary.clone
  954.     if Venka::Bestiary::Sort_Type == :id                # Sort by enemy id
  955.       @bestiary_list.sort!{|a, b| a.enemy_id <=> b.enemy_id}
  956.     elsif Venka::Bestiary::Sort_Type == :name           # Sort by name
  957.       @bestiary_list.sort!{|a, b|
  958.         $data_enemies[a.enemy_id].name <=> $data_enemies[b.enemy_id].name}
  959.     end
  960.   end
  961.   #----------------------------------------------------------------------------
  962.   # ● upgraded method: draw_item
  963.   #----------------------------------------------------------------------------
  964.   def draw_item(index)
  965.     set_bestiary_font(:normal_font)
  966.     @width = contents_width * 0.33
  967.     @width = 0 unless Venka::Bestiary::Track_Kills
  968.     rect = item_rect_for_text(index)
  969.     set_bestiary_font(:list_font)
  970.     draw_text(rect.x, rect.y, rect.width - @width, rect.height, command_name(index))
  971.     draw_kills(index) if Venka::Bestiary::Track_Kills
  972.   end
  973.   #----------------------------------------------------------------------------
  974.   # ○ new method: draw_kills
  975.   #----------------------------------------------------------------------------
  976.   def draw_kills(index)
  977.     set_bestiary_font(:normal_font)
  978.     text = "#{@enemies[index].kills} #{Venka::Bestiary::Kills_Text}"
  979.     draw_text(item_rect_for_text(index), text, 2)
  980.   end
  981.   #----------------------------------------------------------------------------
  982.   # ● upgraded method: update
  983.   #----------------------------------------------------------------------------
  984.   def update
  985.     super
  986.     if @category_window && @category != @category_window.current_symbol.to_s.to_i
  987.       @category = @category_window.current_symbol.to_s.to_i
  988.       refresh
  989.     end
  990.   end
  991. end
  992. #==============================================================================
  993. # ■ Window_BestiaryStatSelection
  994. #==============================================================================
  995. class Window_BestiaryStatSelection < Window_Selectable
  996.   #----------------------------------------------------------------------------
  997.   # ● upgraded method: initialize
  998.   #----------------------------------------------------------------------------
  999.   def initialize(x, y, width, height)
  1000.     super(x, y, width, height)
  1001.     set_windowskin
  1002.     select(0)
  1003.     hide
  1004.     refresh
  1005.   end
  1006.   #----------------------------------------------------------------------------
  1007.   # ● window settings;
  1008.   #----------------------------------------------------------------------------
  1009.   def col_max;     return item_max;                                         end
  1010.   def spacing;     return 5;                                                end
  1011.   def item_height; [Venka::Bestiary::Fonts[:normal_font][1].size, 24].max;  end
  1012.   #----------------------------------------------------------------------------
  1013.   # ● upgraded method: item_max
  1014.   #----------------------------------------------------------------------------
  1015.   def item_max
  1016.     if SceneManager.scene_is?(Scene_Battle)
  1017.       Venka::Bestiary::Show_Debuff_Info ? 4 : 3
  1018.     else
  1019.       return 2
  1020.     end
  1021.   end
  1022.   #----------------------------------------------------------------------------
  1023.   # ○ new method: enemy_id
  1024.   #----------------------------------------------------------------------------
  1025.   def enemy_id=(enemy_id)
  1026.     return @enemy = nil if enemy_id == 0
  1027.     if @enemy != $data_enemies[enemy_id]
  1028.       @enemy = $data_enemies[enemy_id]
  1029.       refresh
  1030.     end
  1031.   end
  1032.   #----------------------------------------------------------------------------
  1033.   # ● upgraded method: item_rect
  1034.   #----------------------------------------------------------------------------
  1035.   def item_rect(index)
  1036.     rect = super
  1037.     if SceneManager.scene_is?(Scene_Battle)
  1038.       rect.y += [Venka::Bestiary::Fonts[:normal_font][1], 24].max + 6
  1039.     end
  1040.     rect
  1041.   end
  1042.   #----------------------------------------------------------------------------
  1043.   # ● upgraded method: draw_item
  1044.   #----------------------------------------------------------------------------
  1045.   def draw_item(index)
  1046.     rect = item_rect_for_text(index)
  1047.     if SceneManager.scene_is?(Scene_Battle)
  1048.       text = [Venka::Bestiary::View_Stats, Venka::Bestiary::View_Element,
  1049.               Venka::Bestiary::View_States, Venka::Bestiary::View_Debuff]
  1050.     else
  1051.       text = [Venka::Bestiary::View_Stats, Venka::Bestiary::View_More]
  1052.     end
  1053.     set_bestiary_font(:normal_font)
  1054.     draw_text(rect, text[index], 1)
  1055.   end
  1056.   #----------------------------------------------------------------------------
  1057.   # ● upgraded method: refresh
  1058.   #----------------------------------------------------------------------------
  1059.   def refresh
  1060.     contents.clear
  1061.     if SceneManager.scene_is?(Scene_Battle)
  1062.       set_bestiary_font(:normal_font)
  1063.       @y = font_height
  1064.       draw_enemy_name if @enemy
  1065.     end
  1066.     draw_all_items
  1067.   end
  1068.   #----------------------------------------------------------------------------
  1069.   # ○ new method: draw_enemy_name
  1070.   #----------------------------------------------------------------------------
  1071.   def draw_enemy_name
  1072.     draw_text(0, 0, contents.width, font_height, @enemy.name, 1)
  1073.     draw_line(@y + 2)
  1074.     @y += 6
  1075.     draw_line(@y + item_height + 3)
  1076.   end
  1077.   #----------------------------------------------------------------------------
  1078.   # ● upgraded method: update_help
  1079.   #----------------------------------------------------------------------------
  1080.   def update_help
  1081.     @help_window.set_index(@index)
  1082.   end
  1083.   #----------------------------------------------------------------------------
  1084.   # ● upgraded method: select
  1085.   #----------------------------------------------------------------------------
  1086.   def select(index)
  1087.     super
  1088.     @help_window.oy = 0 if @help_window
  1089.   end
  1090.   #----------------------------------------------------------------------------
  1091.   # ● upgraded method: cursor_down
  1092.   #----------------------------------------------------------------------------
  1093.   def cursor_down(wrap = false)
  1094.     super
  1095.     if @help_window && display_window_oy < @help_window.total_height
  1096.       @help_window.oy += Venka::Bestiary::Scroll_Speed
  1097.     end
  1098.    #按下闪退 if @help_window && display_window_oy < @help_window.total_height
  1099.      # @help_window.oy += Venka::Bestiary::Scroll_Speed
  1100.    # end
  1101.   end
  1102.   #----------------------------------------------------------------------------
  1103.   # ○ new method: display_window_oy
  1104.   #----------------------------------------------------------------------------
  1105.   def display_window_oy
  1106.     @help_window.oy + @help_window.height - (@help_window.standard_padding * 2)
  1107.   end
  1108.   #----------------------------------------------------------------------------
  1109.   # ● upgraded method: cursor_up
  1110.   #----------------------------------------------------------------------------
  1111.   def cursor_up(wrap = false)
  1112.     super
  1113.     @help_window.oy -= Venka::Bestiary::Scroll_Speed if @help_window && @help_window.oy > 0
  1114.   end
  1115.   #----------------------------------------------------------------------------
  1116.   # ○ new method: wait_to_close
  1117.   #----------------------------------------------------------------------------
  1118.   def wait_to_close
  1119.     loop do
  1120.       Graphics.update
  1121.       Input.update
  1122.       update
  1123.       break if Input.trigger?(:C) || Input.trigger?(:B)
  1124.     end
  1125.     @help_window.hide
  1126.     deactivate
  1127.     self.hide
  1128.   end
  1129. end
  1130. #==============================================================================
  1131. # ■ Window_BestiaryStats
  1132. #==============================================================================
  1133. class Window_BestiaryStats < Window_Base
  1134.   #----------------------------------------------------------------------------
  1135.   # ♦ Public Instance Variables
  1136.   #----------------------------------------------------------------------------
  1137.   attr_accessor   :enemy, :total_height
  1138.   #----------------------------------------------------------------------------
  1139.   # ● upgraded method: initialize
  1140.   #----------------------------------------------------------------------------
  1141.   def initialize(x, y, width, height)
  1142.     @win_height = height
  1143.     super(x, y, width, height)
  1144.     self.opacity = 0
  1145.     @enemy = nil
  1146.     hide
  1147.   end
  1148.   #----------------------------------------------------------------------------
  1149.   # ○ new method: enemy_id
  1150.   #----------------------------------------------------------------------------
  1151.   def enemy_id=(enemy_id)
  1152.     return @enemy = nil if enemy_id == 0
  1153.     if @enemy != $data_enemies[enemy_id]
  1154.       @enemy = $data_enemies[enemy_id]
  1155.       refresh
  1156.     end
  1157.   end
  1158.   #----------------------------------------------------------------------------
  1159.   # ○ new method: set_index
  1160.   #----------------------------------------------------------------------------
  1161.   def set_index(index)
  1162.     if @index != index
  1163.       @index = index
  1164.       refresh
  1165.     end
  1166.   end
  1167.   #----------------------------------------------------------------------------
  1168.   # ● upgraded method: contents_height
  1169.   #----------------------------------------------------------------------------
  1170.   def contents_height
  1171.     @total_height ? @total_height : super
  1172.   end
  1173.   #----------------------------------------------------------------------------
  1174.   # ● upgraded method: refresh
  1175.   #----------------------------------------------------------------------------
  1176.   def refresh
  1177.     contents.clear
  1178.     return if @enemy.nil?
  1179.     if SceneManager.scene_is?(Scene_Bestiary)
  1180.       @index == 0 ? draw_basic_stats : draw_other_info
  1181.     end
  1182.   end
  1183.   #----------------------------------------------------------------------------
  1184.   # ○ new method: determine_window_height
  1185.   #----------------------------------------------------------------------------
  1186.   def determine_window_height(text_lines)
  1187.     set_bestiary_font(:header_font)
  1188.     @total_height = font_height * text_lines
  1189.     self.height = ([(@total_height + standard_padding * 2), @win_height].min)
  1190.     create_contents
  1191.   end
  1192.   #----------------------------------------------------------------------------
  1193.   # ○ new method: info_rect
  1194.   #----------------------------------------------------------------------------
  1195.   def info_rect(index)
  1196.     rect = Rect.new
  1197.     rect.width = contents.width * 0.5 - 3
  1198.     rect.height = [Venka::Bestiary::Fonts[:stat_name][1], 24].max
  1199.     rect.x = index % 2 * (rect.width + 3)
  1200.     rect.y = index / 2 * font_height
  1201.     rect
  1202.   end
  1203.   #----------------------------------------------------------------------------
  1204.   # ○ new method: draw_basic_stats
  1205.   #----------------------------------------------------------------------------
  1206.   def draw_basic_stats
  1207.     elements = Venka::Bestiary::Elements.size
  1208.     states = Venka::Bestiary::States.size
  1209.     # Get the total text lines to show
  1210.     height = (elements / 2 + elements % 2) + (states / 2 + states % 2) + 10
  1211.     height += 6 if Venka::Bestiary::Show_Debuff_Info
  1212.     determine_window_height(height)
  1213.     draw_line(5)
  1214.     @y = 12
  1215.     draw_main_stats
  1216.     draw_line(@y + 5)
  1217.     @y += 12
  1218.     get_revealed_resists
  1219.     draw_elements
  1220.     draw_line(@y + 5)
  1221.     @y += 12
  1222.     draw_states
  1223.     return unless Venka::Bestiary::Show_Debuff_Info
  1224.     draw_line(@y + 5)
  1225.     @y += 12
  1226.     draw_debuffs
  1227.   end
  1228.   #----------------------------------------------------------------------------
  1229.   # ○ new method: draw_main_stats
  1230.   #----------------------------------------------------------------------------
  1231.   def draw_main_stats
  1232.     set_bestiary_font(:header_font)
  1233.     draw_text(0, @y, contents.width, font_height, Venka::Bestiary::Stats_Text, 1)
  1234.     @y += font_height
  1235.     8.times {|stat| draw_stat(stat, :stat)}
  1236.     @y += info_rect(0).height * 4
  1237.   end
  1238.   #----------------------------------------------------------------------------
  1239.   # ○ new method: draw_stat
  1240.   #----------------------------------------------------------------------------
  1241.   def draw_stat(stat, stat_type)
  1242.     rect = info_rect(stat)
  1243.     rect.y += @y
  1244.     stat_info = Venka::Bestiary::Base_Stats[stat]
  1245.     if stat_info[1]
  1246.       draw_icon(stat_info[1], rect.x, rect.y)
  1247.       rect.x += 25;            rect.width -= 25
  1248.     end
  1249.     if stat_info[0]
  1250.       set_bestiary_font(:stat_name)
  1251.       draw_text(rect, stat_info[0])
  1252.       text_width = text_size(stat_info[0]).width + 5
  1253.       rect.x += text_width;    rect.width -= text_width
  1254.     end
  1255.     set_bestiary_font(:stats_font)
  1256.     text = Venka::Bestiary::Unknown_Stat
  1257.     $game_party.bestiary.each do |entry|
  1258.       next unless entry.enemy_id == @enemy.shown_id
  1259.       if stat_type == :stat && (entry.scanned ||
  1260.             entry.kills >= Venka::Bestiary::Show_BaseStats)
  1261.         text = Game_Enemy.new(0, @enemy.shown_id).param(stat)
  1262.       elsif stat_type == :debuff && (entry.scanned ||
  1263.             entry.kills >= Venka::Bestiary::Show_DebuffStats)
  1264.         rate = Game_Enemy.new(0, @enemy.shown_id).debuff_rate(stat)
  1265.         text = get_resist_info(stat, rate)
  1266.       end
  1267.     end
  1268.     draw_text(rect, text, 2)
  1269.   end
  1270.   #----------------------------------------------------------------------------
  1271.   # ○ new method: get_revealed_resists
  1272.   #----------------------------------------------------------------------------
  1273.   def get_revealed_resists
  1274.     $game_party.bestiary.each do |entry|
  1275.       @eles = entry.elements if entry.enemy_id == @enemy.shown_id
  1276.       @states = entry.states if entry.enemy_id == @enemy.shown_id
  1277.     end
  1278.   end
  1279.   #----------------------------------------------------------------------------
  1280.   # ○ new method: draw_elements
  1281.   #----------------------------------------------------------------------------
  1282.   def draw_elements
  1283.     set_bestiary_font(:header_font)
  1284.     draw_text(0, @y, contents.width, font_height, Venka::Bestiary::Element_Text, 1)
  1285.     @y += font_height
  1286.     elements = Venka::Bestiary::Elements
  1287.     (elements.size).times {|i| draw_ele_info(i, elements[i], info_rect(i))}
  1288.     @y += (info_rect(0).height) * (elements.size * 0.5 + elements.size % 2)
  1289.   end
  1290.   #----------------------------------------------------------------------------
  1291.   # ○ new method: draw_ele_info
  1292.   #----------------------------------------------------------------------------
  1293.   def draw_ele_info(i, element, rect)
  1294.     rect.y += @y
  1295.     if element[1]
  1296.       draw_icon(element[1], rect.x, rect.y)
  1297.       rect.x += 25;            rect.width -= 25
  1298.     end
  1299.     set_bestiary_font(:stat_name)
  1300.     tw = text_size(99).width + 5
  1301.     draw_text(rect, $data_system.elements[element[0]])
  1302.     text_width = text_size(element[0]).width + 5
  1303.     # Scale text so the value will fit as well in small resolutions
  1304.     rect.x = [(rect.x + text_width), (rect.x + rect.width - tw)].min
  1305.     rect.width = [(rect.width - text_width), tw].max
  1306.     set_bestiary_font(:stats_font)
  1307.     text = @eles[i] ? get_resist_info(element[0], 11) : Venka::Bestiary::Unknown_Stat
  1308.     draw_text(rect, text, 2)
  1309.   end
  1310.   #----------------------------------------------------------------------------
  1311.   # ○ new method: get_resist_info
  1312.   #----------------------------------------------------------------------------
  1313.   def get_resist_info(stat_id, code_id)
  1314.     case code_id
  1315.     when 11   # Element
  1316.       resist = Game_Enemy.new(0, @enemy.shown_id).element_rate(stat_id)
  1317.       if $imported["YEA-Element Absorb"] && Game_Enemy.new(0, @enemy.shown_id).element_absorb?(stat_id)
  1318.         set_resist_style(resist, Venka::Bestiary::Absorb_Text)
  1319.       else
  1320.         set_resist_style(resist)
  1321.       end
  1322.     when 13
  1323.       enemy = Game_Enemy.new(0, @enemy.shown_id)
  1324.       if enemy.features_with_id(14, stat_id).empty?
  1325.         resist = enemy.state_rate(stat_id)
  1326.         set_resist_style(resist)
  1327.       else
  1328.         set_resist_style(1.0, Venka::Bestiary::Immune_Text)
  1329.       end
  1330.     else
  1331.       set_resist_style(code_id)
  1332.     end
  1333.   end
  1334.   #----------------------------------------------------------------------------
  1335.   # ○ new method: set_resist_style
  1336.   #----------------------------------------------------------------------------
  1337.   def set_resist_style(resist, text = "")
  1338.     if text != ""
  1339.       color = Venka::Bestiary::Immunity_Color
  1340.     else
  1341.       color = Venka::Bestiary::Fonts[:stats_font][3]
  1342.       color = Venka::Bestiary::High_Resist if resist > 1.0
  1343.       color = Venka::Bestiary::Low_Resist  if resist < 1.0
  1344.       resist -= 1.0 if resist >= 1.0
  1345.       text = (resist * 100).round
  1346.     end
  1347.     new_color = color.is_a?(Integer) ? text_color(color) : Color.new(*color)
  1348.     change_color(new_color)
  1349.     return text
  1350.   end
  1351.   #----------------------------------------------------------------------------
  1352.   # ○ new method: draw_states
  1353.   #----------------------------------------------------------------------------
  1354.   def draw_states
  1355.     set_bestiary_font(:header_font)
  1356.     draw_text(0, @y, contents.width, font_height, Venka::Bestiary::Status_Text, 1)
  1357.     @y += font_height
  1358.     states = Venka::Bestiary::States
  1359.     (states.size).times {|i| draw_state_info(i, states[i], info_rect(i))}
  1360.     @y += (info_rect(0).height) * (states.size / 2).round
  1361.   end
  1362.   #----------------------------------------------------------------------------
  1363.   # ○ new method: draw_state_info
  1364.   #----------------------------------------------------------------------------
  1365.   def draw_state_info(i, state_id, rect)
  1366.     state = $data_states[state_id]
  1367.     rect.y += @y
  1368.     draw_icon(state.icon_index, rect.x, rect.y)
  1369.     rect.x += 25;            rect.width -= 25
  1370.     set_bestiary_font(:stat_name)
  1371.     tw = text_size(99).width + 5
  1372.     draw_text(rect.x, rect.y, rect.width - tw, rect.height, state.name)
  1373.     text_width = text_size(state.name).width + 5
  1374.     # Scale text so the value will fit as well in small resolutions
  1375.     rect.x = [(rect.x + text_width), (rect.x + rect.width - tw)].min
  1376.     rect.width = [(rect.width - text_width), tw].max
  1377.     set_bestiary_font(:stats_font)
  1378.     text = @states[i] ? get_resist_info(state_id, 13) : Venka::Bestiary::Unknown_Stat
  1379.     draw_text(rect, text, 2)
  1380.   end
  1381.   #----------------------------------------------------------------------------
  1382.   # ○ new method: draw_debuffs
  1383.   #----------------------------------------------------------------------------
  1384.   def draw_debuffs
  1385.     set_bestiary_font(:header_font)
  1386.     draw_text(0, @y, contents.width, font_height, Venka::Bestiary::Debuff_Text, 1)
  1387.     @y += font_height
  1388.     8.times do |stat|
  1389.       draw_stat(stat, :debuff)
  1390.     end
  1391.   end
  1392.   #----------------------------------------------------------------------------
  1393.   # ○ new method: draw_other_info
  1394.   #----------------------------------------------------------------------------
  1395.   def draw_other_info
  1396.     # Get the number of lines to display loot
  1397.     drops = @enemy.drop_items.select {|d| d.kind > 0 }
  1398.     # Get the number of lines to display enemy skills
  1399.     ids = []
  1400.     @enemy.actions.each do |action|
  1401.       ids << action.skill_id unless ids.include?(action.skill_id)
  1402.     end
  1403.     # Total number of lines to display with skills, loot, headers, etc
  1404.     height = 5 + drops.size + ids.size
  1405.     determine_window_height(height)
  1406.     draw_line(5)
  1407.     @y = 12
  1408.     set_bestiary_font(:header_font)
  1409.     draw_text(0, @y, contents.width, font_height, Venka::Bestiary::Loot_Text, 1)
  1410.     @y += font_height
  1411.     draw_exp_and_gold
  1412.     draw_drops
  1413.     draw_skills
  1414.   end
  1415.   #----------------------------------------------------------------------------
  1416.   # ○ new method: draw_exp
  1417.   #----------------------------------------------------------------------------
  1418.   def draw_exp_and_gold
  1419.     exp  = Venka::Bestiary::Exp_Text
  1420.     gold = Venka::Bestiary::Gold_Text
  1421.     width = contents.width
  1422.     width = ((@enemy.exp > 0 || @enemy.gold > 0) ? width * 0.5 : width).to_i
  1423.     draw_icon_text(exp, 0, width, @enemy.exp)   if @enemy.exp > 0
  1424.     x = @enemy.exp > 0 ? width : 0
  1425.     draw_icon_text(gold, x, width, @enemy.gold) if @enemy.gold > 0
  1426.     @y += font_height
  1427.   end
  1428.   #----------------------------------------------------------------------------
  1429.   # ○ new method: draw_icon_and_text
  1430.   #----------------------------------------------------------------------------
  1431.   def draw_icon_text(info, x, width, amount)
  1432.     draw_icon(info[1], x, @y) if info[1]
  1433.     dx = info[1] ? 25 : 0
  1434.     set_bestiary_font(:stat_name)
  1435.     draw_text(x + dx, @y, width - dx, font_height, info[0])
  1436.     set_bestiary_font(:stats_font)
  1437.     dx += text_size(info[0]).width + 10
  1438.     draw_text(x + dx, @y, width - dx, font_height, amount)
  1439.   end
  1440.   #----------------------------------------------------------------------------
  1441.   # ○ new method: draw_drops
  1442.   #----------------------------------------------------------------------------
  1443.   def draw_drops
  1444.     drops_revealed = false
  1445.     $game_party.bestiary.each do |entry|
  1446.       next unless entry.enemy_id == @enemy.shown_id
  1447.       if entry.scanned || entry.kills >= Venka::Bestiary::Show_Loot
  1448.         drops_revealed = true
  1449.       end
  1450.     end
  1451.     if drops_revealed
  1452.       @enemy.drop_items.each do |drop_info|
  1453.         next if drop_info.kind == 0
  1454.         item = $data_items[drop_info.data_id]   if drop_info.kind == 1
  1455.         item = $data_weapons[drop_info.data_id] if drop_info.kind == 2
  1456.         item = $data_armors[drop_info.data_id]  if drop_info.kind == 3
  1457.         set_bestiary_font(:stat_name)
  1458.         tw = text_size("100%").width + 5
  1459.         draw_item_name(item, 0, @y, contents.width - tw)
  1460.         chance = (1.to_f / drop_info.denominator) * 100
  1461.         chance = (chance > 0.9) ? chance.round : chance.round(1)
  1462.         set_bestiary_font(:stats_font)
  1463.         draw_text(0, @y, contents.width, font_height, "#{chance}%", 2)
  1464.         @y += font_height
  1465.       end
  1466.     else
  1467.       set_bestiary_font(:stat_name)
  1468.       draw_text(0, @y, contents.width, font_height, Venka::Bestiary::Unknown_Loot)
  1469.       @y += font_height
  1470.     end
  1471.     draw_line(@y + 5)
  1472.     @y += 12
  1473.   end
  1474.   #----------------------------------------------------------------------------
  1475.   # ○ new method: draw_skills
  1476.   #----------------------------------------------------------------------------
  1477.   def draw_skills
  1478.     set_bestiary_font(:header_font)
  1479.     draw_text(0, @y, contents.width, font_height, Venka::Bestiary::Skill_Text, 1)
  1480.     @y += font_height
  1481.     set_bestiary_font(:stat_name)
  1482.     skills_revealed = false
  1483.     $game_party.bestiary.each do |entry|
  1484.       next unless entry.enemy_id == @enemy.shown_id
  1485.       if entry.scanned || entry.kills >= Venka::Bestiary::Show_Abilities
  1486.         skills_revealed = true
  1487.       end
  1488.     end
  1489.     if skills_revealed
  1490.       skills.each do |id|
  1491.         draw_item_name($data_skills[id], 0, @y, contents.width)
  1492.         @y += font_height
  1493.       end
  1494.     else
  1495.       draw_text(0, @y, contents.width, font_height, Venka::Bestiary::Unknown_Skills)
  1496.     end
  1497.   end
  1498.   #----------------------------------------------------------------------------
  1499.   # ○ new method: skills
  1500.   #----------------------------------------------------------------------------
  1501.   def skills
  1502.     ids = []
  1503.     @enemy.actions.each do |action|
  1504.       ids << action.skill_id unless ids.include?(action.skill_id)
  1505.     end
  1506.     return ids
  1507.   end
  1508. end
  1509. #==============================================================================
  1510. # ■ Window_BattleScan
  1511. #==============================================================================
  1512. class Window_BattleScan < Window_BestiaryStats
  1513.   #----------------------------------------------------------------------------
  1514.   # ♦ Public Instance Variables
  1515.   #----------------------------------------------------------------------------
  1516.   attr_accessor    :show_stats
  1517.   #----------------------------------------------------------------------------
  1518.   # ● upgraded method: initialize
  1519.   #----------------------------------------------------------------------------
  1520.   def initialize(x, y, width, height)
  1521.     super(x, y, width, height)
  1522.   end
  1523.   #----------------------------------------------------------------------------
  1524.   # ● upgraded method: refresh
  1525.   #----------------------------------------------------------------------------
  1526.   def refresh
  1527.     contents.clear
  1528.     return if @enemy.nil?
  1529.     if $game_party.bestiary_include?(@enemy.shown_id)
  1530.       @y = 0
  1531.       case @index
  1532.       when 0; draw_basic_stats
  1533.       when 1; draw_enemy_resists
  1534.       when 2; draw_enemy_states
  1535.       when 3; draw_debuff_rates
  1536.       end
  1537.     else
  1538.       set_bestiary_font(:stat_name)
  1539.       text = Venka::Bestiary::No_Info
  1540.       draw_text(0, 0, contents.width, contents.height, text, 1)
  1541.     end
  1542.   end
  1543.   #----------------------------------------------------------------------------
  1544.   # ○ new method: draw_basic_stats
  1545.   #----------------------------------------------------------------------------
  1546.   def draw_basic_stats
  1547.     determine_window_height(4)
  1548.     8.times {|stat| draw_stat(stat, :stat)}
  1549.   end
  1550.   #----------------------------------------------------------------------------
  1551.   # ○ new method: draw_enemy_resists
  1552.   #----------------------------------------------------------------------------
  1553.   def draw_enemy_resists
  1554.     elements = Venka::Bestiary::Elements
  1555.     height = (elements.size / 2) + (elements.size % 2)
  1556.     determine_window_height(height)
  1557.     get_revealed_resists
  1558.     (elements.size).times {|i| draw_ele_info(i, elements[i], info_rect(i))}
  1559.   end
  1560.   #----------------------------------------------------------------------------
  1561.   # ○ new method: draw_enemy_states
  1562.   #----------------------------------------------------------------------------
  1563.   def draw_enemy_states
  1564.     states = Venka::Bestiary::States
  1565.     height = (states.size / 2) + (states.size % 2)
  1566.     determine_window_height(height)
  1567.     (states.size).times {|i| draw_state_info(i, states[i], info_rect(i))}
  1568.   end
  1569.   #----------------------------------------------------------------------------
  1570.   # ○ new method: draw_debuff_rates
  1571.   #----------------------------------------------------------------------------
  1572.   def draw_debuff_rates
  1573.     determine_window_height(4)
  1574.     8.times {|stat| draw_stat(stat, :debuff)}
  1575.   end
  1576. end
  1577. #==============================================================================
  1578. # ■ Scene_Menu
  1579. #==============================================================================
  1580. class Scene_Menu < Scene_MenuBase
  1581.   #----------------------------------------------------------------------------
  1582.   # ● alias method: create_command_window
  1583.   #----------------------------------------------------------------------------
  1584.   alias bestiary_menu_access_ccw       create_command_window
  1585.   def create_command_window
  1586.     bestiary_menu_access_ccw
  1587.     @command_window.set_handler(:bestiary,  method(:command_bestiary))
  1588.   end
  1589.   #----------------------------------------------------------------------------
  1590.   # ○ new method: command_bestiary
  1591.   #----------------------------------------------------------------------------
  1592.   def command_bestiary
  1593.     SceneManager.call(Scene_Bestiary)
  1594.   end
  1595. end
  1596. #==============================================================================
  1597. # ■ Scene_Battle
  1598. #==============================================================================
  1599. class Scene_Battle < Scene_Base
  1600.   #----------------------------------------------------------------------------
  1601.   # ● alias method: create_all_windows
  1602.   #----------------------------------------------------------------------------
  1603.   alias scan_window_caw create_all_windows
  1604.   def create_all_windows
  1605.     scan_window_caw
  1606.     create_info_instructions
  1607.     create_stats_selection
  1608.     create_stats_window
  1609.   end
  1610.   #----------------------------------------------------------------------------
  1611.   # ○ new method: create_stats_selection
  1612.   #----------------------------------------------------------------------------
  1613.   def create_stats_selection
  1614.     width = [Graphics.width * 0.6, 420].max
  1615.     x = (Graphics.width - width) * 0.5
  1616.     # Get total height of the window since it can change based on fonts used.
  1617.     height = 40 + ([Venka::Bestiary::Fonts[:normal_font][1], 24].max * 2) +
  1618.          ([Venka::Bestiary::Fonts[:stat_name][1], 24].max * 4)
  1619.     y = (Graphics.height - @status_window.height - height) * 0.5
  1620.     @stats_selection = Window_BestiaryStatSelection.new(x, y, width, height)
  1621.   end
  1622.   #----------------------------------------------------------------------------
  1623.   # ○ new method: create_stats_window
  1624.   #----------------------------------------------------------------------------
  1625.   def create_stats_window
  1626.     y = @stats_selection.y + @stats_selection.item_height + 15 +
  1627.         Venka::Bestiary::Fonts[:normal_font][1]
  1628.     # Make the info window the same height as the selection window minus the
  1629.     # header info and selection area.
  1630.     height = @stats_selection.height - @stats_selection.item_height - 15 -
  1631.         Venka::Bestiary::Fonts[:normal_font][1]
  1632.     @stats_window = Window_BattleScan.new(@stats_selection.x, y,
  1633.         @stats_selection.width, height)
  1634.     @stats_selection.help_window = @stats_window
  1635.   end
  1636.   #----------------------------------------------------------------------------
  1637.   # ○ new method: create_scan_window
  1638.   #----------------------------------------------------------------------------
  1639.   def create_info_instructions
  1640.     @info_instructions = Sprite.new
  1641.     @info_instructions.visible = false
  1642.     font = Venka::Bestiary::Battle_Font
  1643.     @info_instructions.bitmap = Bitmap.new(Graphics.width, font[1])
  1644.     @info_instructions.bitmap.font.name  = font[0]
  1645.     @info_instructions.bitmap.font.size  = font[1]
  1646.     @info_instructions.bitmap.font.bold  = font[2]
  1647.     @info_instructions.bitmap.font.color = Color.new(*font[3])
  1648.     @info_instructions.bitmap.font.outline = font[4]
  1649.     text = Venka::Bestiary::Battle_Instructions
  1650.     @info_instructions.bitmap.draw_text(0, 0, Graphics.width, font[1], text, 1)
  1651.     @info_instructions.y = @enemy_window.y - font[1]
  1652.   end
  1653.   #----------------------------------------------------------------------------
  1654.   # ● alias method: select_enemy_selection
  1655.   #----------------------------------------------------------------------------
  1656.   alias bestiary_info_enemy_select select_enemy_selection
  1657.   def select_enemy_selection
  1658.     @info_instructions.visible = true
  1659.     bestiary_info_enemy_select
  1660.   end
  1661.   #----------------------------------------------------------------------------
  1662.   # ● alias method: on_enemy_ok
  1663.   #----------------------------------------------------------------------------
  1664.   alias bestiary_info_enemy_ok on_enemy_ok
  1665.   def on_enemy_ok
  1666.     @info_instructions.visible = false
  1667.     bestiary_info_enemy_ok
  1668.   end
  1669.   #----------------------------------------------------------------------------
  1670.   # ● alias method: on_enemy_cancel
  1671.   #----------------------------------------------------------------------------
  1672.   alias bestiary_info_enemy_cancel on_enemy_cancel
  1673.   def on_enemy_cancel
  1674.     @info_instructions.visible = false
  1675.     bestiary_info_enemy_cancel
  1676.   end
  1677.   #----------------------------------------------------------------------------
  1678.   # ○ new method: show_enemy_info
  1679.   #----------------------------------------------------------------------------
  1680.   def show_enemy_info(enemy_id)
  1681.     @stats_window.show
  1682.     @stats_selection.enemy_id = enemy_id
  1683.     @stats_window.enemy_id = enemy_id
  1684.     @stats_selection.show.activate
  1685.     @stats_selection.wait_to_close
  1686.   end
  1687.   #----------------------------------------------------------------------------
  1688.   # ● alias method: update
  1689.   #----------------------------------------------------------------------------
  1690.   alias show_enemy_info_update update
  1691.   def update
  1692.     show_enemy_info_update
  1693.     if @enemy_window.active && Input.trigger?(Venka::Bestiary::Scan_PopUp)
  1694.       show_enemy_info(@enemy_window.enemy.enemy_id)
  1695.     end
  1696.   end
  1697.   #----------------------------------------------------------------------------
  1698.   # ● alias method: item_apply
  1699.   #----------------------------------------------------------------------------
  1700.   alias venka_scan_skill_used apply_item_effects
  1701.   def apply_item_effects(target, item)
  1702.     if target.is_a?(Game_Enemy)
  1703.       enemy = $data_enemies[target.enemy_id]
  1704.       $game_party.reveal_resist(enemy.id, false) if item.scan
  1705.       attack_element = item.damage.element_id
  1706.       Venka::Bestiary::Elements.size.times do |i|
  1707.         if Venka::Bestiary::Elements[i][0] == attack_element
  1708.           $game_party.bestiary.each do |entry|
  1709.             entry.elements[i] = true if entry.enemy_id == enemy.shown_id
  1710.           end
  1711.         end
  1712.       end
  1713.       if item.scan
  1714.         $game_party.bestiary.each do |entry|
  1715.           entry.scanned = true if entry.enemy_id == enemy.shown_id
  1716.         end
  1717.         show_enemy_info(target.enemy_id)
  1718.       end
  1719.     end
  1720.     venka_scan_skill_used(target, item)
  1721.   end
  1722.   #----------------------------------------------------------------------------
  1723.   # ● alias method: terminate
  1724.   #----------------------------------------------------------------------------
  1725.   alias :dispose_instructions_on_term :terminate
  1726.   def terminate
  1727.     dispose_instructions_on_term
  1728.     dispose_instructions
  1729.   end
  1730.   #----------------------------------------------------------------------------
  1731.   # ○ new method: dispose_instructions
  1732.   #----------------------------------------------------------------------------
  1733.   def dispose_instructions
  1734.     return if @info_instructions
  1735.     @info_instructions.bitmap.dispose
  1736.     @info_instructions.dispose
  1737.     @info_instructions = nil
  1738.   end
  1739. end
  1740. #==============================================================================
  1741. # ■ Scene_Bestiary
  1742. #==============================================================================
  1743. class Scene_Bestiary < Scene_MenuBase
  1744.   #----------------------------------------------------------------------------
  1745.   # ● upgraded method: start
  1746.   #----------------------------------------------------------------------------
  1747.   def start
  1748.     stop_music if Venka::Bestiary::Bestiary_BGM
  1749.     super
  1750.     bestiary_music if Venka::Bestiary::Bestiary_BGM
  1751.     @enemy = nil
  1752.     create_all_windows
  1753.   end
  1754.   #----------------------------------------------------------------------------
  1755.   # ○ new method: stop_music
  1756.   #----------------------------------------------------------------------------
  1757.   def stop_music
  1758.     @map_bgm = RPG::BGM.last
  1759.     fadeout_all(60)
  1760.   end
  1761.   #----------------------------------------------------------------------------
  1762.   # ○ new method: bestiary_music
  1763.   #----------------------------------------------------------------------------
  1764.   def bestiary_music
  1765.     RPG::BGM.new(*Venka::Bestiary::Bestiary_BGM).play
  1766.   end
  1767.   #----------------------------------------------------------------------------
  1768.   # ● upgraded method: create_background
  1769.   #----------------------------------------------------------------------------
  1770.   def create_background
  1771.     if Venka::Bestiary::BG_Image
  1772.       @background_sprite = Sprite.new
  1773.       @background_sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height)
  1774.       bitmap = bestiary_bgimage
  1775.       dest_rect = Rect.new(0, 0, Graphics.width, Graphics.height)
  1776.       @background_sprite.bitmap.stretch_blt(dest_rect, bitmap, bitmap.rect)
  1777.       @background_sprite.color.set(16, 16, 16, 128)
  1778.     else
  1779.       super
  1780.     end
  1781.   end
  1782.   #----------------------------------------------------------------------------
  1783.   # ○ new method: bestiary_bgimage
  1784.   #----------------------------------------------------------------------------
  1785.   def bestiary_bgimage
  1786.     file_info = Venka::Bestiary::BG_Image
  1787.     begin;      Cache.title1(file_info)
  1788.     rescue;     Cache.picture(file_info)
  1789.     end
  1790.   end
  1791.   #----------------------------------------------------------------------------
  1792.   # ○ new method: create_all_windows
  1793.   #----------------------------------------------------------------------------
  1794.   def create_all_windows
  1795.     create_help_window
  1796.     create_bottom_window
  1797.     create_category_window
  1798.     create_bestiary_list
  1799.     create_enemy_image
  1800.     create_stats_selection
  1801.     create_stats_window
  1802.     create_description_window
  1803.     create_image_frame if Venka::Bestiary::Frame_Image
  1804.   end
  1805.   #----------------------------------------------------------------------------
  1806.   # ● upgraded method: create_help_window
  1807.   #----------------------------------------------------------------------------
  1808.   def create_help_window
  1809.     @help_window = Window_BestiaryHelp.new(0, 0)
  1810.     @help_window.viewport = @viewport
  1811.     @help_window.y = 0
  1812.     @help_window.set_text(Venka::Bestiary::Category_Select)
  1813.   end
  1814.   #----------------------------------------------------------------------------
  1815.   # ○ new method: create_bottom_window
  1816.   #----------------------------------------------------------------------------
  1817.   def create_bottom_window
  1818.     y = Graphics.height - @help_window.height
  1819.     @bottom_window = Window_BestiaryHelp.new(0, y)
  1820.     @bottom_window.draw_completion
  1821.   end
  1822.   #----------------------------------------------------------------------------
  1823.   # ○ new method: create_category_window
  1824.   #----------------------------------------------------------------------------
  1825.   def create_category_window
  1826.     @category_window = Window_BestiaryCategory.new(0, @help_window.height)
  1827.     @category_window.viewport = @viewport
  1828.     @category_window.set_handler(:ok,     method(:command_list))
  1829.     @category_window.set_handler(:cancel, method(:return_scene))
  1830.   end
  1831.   #----------------------------------------------------------------------------
  1832.   # ○ new method: command_list
  1833.   #----------------------------------------------------------------------------
  1834.   def command_list
  1835.     @list_window.show.activate
  1836.     @help_window.set_text(Venka::Bestiary::Enemy_Select)
  1837.   end
  1838.   #----------------------------------------------------------------------------
  1839.   # ○ new method: create_bestiary_list
  1840.   #----------------------------------------------------------------------------
  1841.   def create_bestiary_list
  1842.     @list_window = Window_BestiaryEnemyList.new(@category_window.width,
  1843.           @help_window.height)
  1844.     @list_window.viewport = @viewport
  1845.     @list_window.category_window = @category_window
  1846.     @list_window.deactivate
  1847.     @list_window.set_handler(:ok,     method(:command_bestiary))
  1848.     @list_window.set_handler(:cancel, method(:command_category))
  1849.   end
  1850.   #----------------------------------------------------------------------------
  1851.   # ○ new method: command_category
  1852.   #----------------------------------------------------------------------------
  1853.   def command_category
  1854.     @category_window.activate
  1855.     @help_window.set_text(Venka::Bestiary::Category_Select)
  1856.   end
  1857.   #----------------------------------------------------------------------------
  1858.   # ○ new method: command_bestiary
  1859.   #----------------------------------------------------------------------------
  1860.   def command_bestiary
  1861.     @list_window.hide
  1862.     @category_window.hide
  1863.     @stats_selection.show.activate
  1864.     @stats_window.show
  1865.     @descript_window.show
  1866.     @frame_window.show if @frame_window
  1867.     @enemy_bg.visible = true
  1868.     update_enemy_info
  1869.   end
  1870.   #----------------------------------------------------------------------------
  1871.   # ○ new method: create_enemy_image
  1872.   #----------------------------------------------------------------------------
  1873.   def create_enemy_image
  1874.     width = (Graphics.width * 0.55).round;     height = Graphics.height * 0.55
  1875.     @enemy_bg = Sprite.new(@viewport)
  1876.     @enemy_bg.visible = false
  1877.     @enemy_bg.x = Graphics.width - (Graphics.width * 0.55).round
  1878.     @enemy_bg.y = @help_window.height
  1879.     @enemy_bg.bitmap = Bitmap.new(width, height)
  1880.   end
  1881.   #----------------------------------------------------------------------------
  1882.   # ○ new method: create_stats_selection
  1883.   #----------------------------------------------------------------------------
  1884.   def create_stats_selection
  1885.     height = Graphics.height - (@help_window.height * 2)
  1886.     @stats_selection = Window_BestiaryStatSelection.new(0, @help_window.height,
  1887.           Graphics.width - @enemy_bg.width, height)
  1888.     @stats_selection.viewport = @viewport
  1889.     @stats_selection.set_handler(:pageup,     method(:prev_enemy))
  1890.     @stats_selection.set_handler(:pagedown,   method(:next_enemy))
  1891.     @stats_selection.set_handler(:cancel,     method(:to_enemy_list))
  1892.   end
  1893.   #----------------------------------------------------------------------------
  1894.   # ○ new method: create_stats_window
  1895.   #----------------------------------------------------------------------------
  1896.   def create_stats_window
  1897.     y = @stats_selection.y + @stats_selection.item_height
  1898.     height = @stats_selection.height - @stats_selection.item_height
  1899.     @stats_window = Window_BestiaryStats.new(0, y, @stats_selection.width, height)
  1900.     @stats_window.viewport = @viewport
  1901.     @stats_selection.help_window = @stats_window
  1902.     @list_window.stats_window = @stats_window
  1903.   end
  1904.   #----------------------------------------------------------------------------
  1905.   # ○ new method: prev_enemy
  1906.   #----------------------------------------------------------------------------
  1907.   def prev_enemy
  1908.     if @list_window.index == 0
  1909.       @list_window.index = @list_window.item_max - 1
  1910.     else
  1911.       @list_window.index -= 1
  1912.     end
  1913.     update_enemy_info
  1914.     @stats_selection.activate
  1915.   end
  1916.   #----------------------------------------------------------------------------
  1917.   # ○ new method: next_enemy
  1918.   #----------------------------------------------------------------------------
  1919.   def next_enemy
  1920.     if @list_window.index == @list_window.item_max - 1
  1921.       @list_window.index = 0
  1922.     else
  1923.       @list_window.index += 1
  1924.     end
  1925.     update_enemy_info
  1926.     @stats_selection.activate
  1927.   end
  1928.   #----------------------------------------------------------------------------
  1929.   # ○ new method: to_enemy_list
  1930.   #----------------------------------------------------------------------------
  1931.   def to_enemy_list
  1932.     @help_window.set_text(Venka::Bestiary::Category_Select)
  1933.     @bottom_window.draw_completion
  1934.     @category_window.show
  1935.     @stats_selection.hide.deactivate
  1936.     @stats_window.hide
  1937.     @descript_window.hide
  1938.     @frame_window.hide if @frame_window
  1939.     @enemy_bg.visible = false
  1940.     command_list
  1941.   end
  1942.   #----------------------------------------------------------------------------
  1943.   # ○ new method: create_description_window
  1944.   #----------------------------------------------------------------------------
  1945.   def create_description_window
  1946.     y = (@help_window.height + @enemy_bg.height).to_i
  1947.     @descript_window = Window_BestiaryHelp.new(@stats_window.width, y)
  1948.     @descript_window.viewport = @viewport
  1949.     @descript_window.width = Graphics.width - @stats_window.width
  1950.     @descript_window.height = Graphics.height - y - @bottom_window.height
  1951.     @descript_window.hide
  1952.   end
  1953.   #----------------------------------------------------------------------------
  1954.   # ○ new method: create_image_frame
  1955.   #----------------------------------------------------------------------------
  1956.   def create_image_frame
  1957.     @frame_window = Window_Base.new(@enemy_bg.x, @enemy_bg.y, @enemy_bg.width,
  1958.         @enemy_bg.height)
  1959.     @frame_window.viewport = @viewport
  1960.     @frame_window.set_windowskin
  1961.     @frame_window.back_opacity = 0
  1962.     @frame_window.hide
  1963.   end
  1964.   #----------------------------------------------------------------------------
  1965.   # ○ new method: update_enemy_info
  1966.   #----------------------------------------------------------------------------
  1967.   def update_enemy_info
  1968.     enemy = $data_enemies[@list_window.current_ext]
  1969.     @help_window.set_text(enemy.name)
  1970. #    @bottom_window.draw_instructions
  1971.     @stats_window.enemy_id = @list_window.current_ext
  1972.     @descript_window.set_description(enemy)
  1973.     update_enemy_image(enemy)
  1974.   end
  1975.   #----------------------------------------------------------------------------
  1976.   # ○ new method: update_enemy_image
  1977.   #----------------------------------------------------------------------------
  1978.   def update_enemy_image(enemy)
  1979.     @enemy_bg.bitmap.clear
  1980.     enemy = $data_enemies[@list_window.current_ext]
  1981.     if floor_image(enemy)
  1982.       bg_floor = enemy_image(:floor, floor_image(enemy))
  1983.       draw_image(bg_floor, @enemy_bg.width, @enemy_bg.height)
  1984.     end
  1985.     if wall_image(enemy)
  1986.       bg_wall = enemy_image(:wall, wall_image(enemy))
  1987.       draw_image(bg_wall, @enemy_bg.width, @enemy_bg.height)
  1988.     end
  1989.     enemy = enemy_image(:battler, enemy.battler_name, enemy.battler_hue)
  1990.     draw_image(enemy, @enemy_bg.width, @enemy_bg.height)
  1991.   end
  1992.   #----------------------------------------------------------------------------
  1993.   # ○ new method: floor_image
  1994.   #----------------------------------------------------------------------------
  1995.   def floor_image(enemy)
  1996.     floor = enemy.bg_floor      # Get the enemie's wall image (high priority)
  1997.     if floor == ""              # If it's not set, then get category image
  1998.       floor = Venka::Bestiary::Category[@category_window.index][:bg_floor]
  1999.       # If the category image wasn't set, then use the default image
  2000.       floor = Venka::Bestiary::Default_BGFloor if floor.nil?
  2001.     end
  2002.     floor = nil if floor == ""  # Set to no image if category was set to ""
  2003.     return floor
  2004.   end
  2005.   #----------------------------------------------------------------------------
  2006.   # ○ new method: wall_image
  2007.   #----------------------------------------------------------------------------
  2008.   def wall_image(enemy)
  2009.     wall = enemy.bg_wall      # Get the enemie's wall image (high priority)
  2010.     if wall == ""             # If it's not set, then get category image
  2011.       wall = Venka::Bestiary::Category[@category_window.index][:bg_wall]
  2012.       # If the category image wasn't set, then use the default image
  2013.       wall = Venka::Bestiary::Default_BGWall if wall.nil?
  2014.     end
  2015.     wall = nil if wall == "" # Set to no image if category was set to ""
  2016.     return wall
  2017.   end
  2018.   #----------------------------------------------------------------------------
  2019.   # ○ new method: enemy_image
  2020.   #----------------------------------------------------------------------------
  2021.   def enemy_image(type, file, hue = 0)
  2022.     begin
  2023.       case type
  2024.       when :floor;      Cache.battleback1(file)
  2025.       when :wall;       Cache.battleback2(file)
  2026.       when :battler;    Cache.battler(file, hue)
  2027.       end
  2028.     rescue;             Cache.picture(file)
  2029.     end
  2030.   end
  2031.   #----------------------------------------------------------------------------
  2032.   # ○ new method: draw_image
  2033.   #----------------------------------------------------------------------------
  2034.   def draw_image(bitmap, width, height)
  2035.     x = (bitmap.width - width) * 0.5
  2036.     y = (bitmap.height - height) * 0.5
  2037.     src_rect = Rect.new(x, y, width, height)
  2038.     @enemy_bg.bitmap.blt(0, 0, bitmap, src_rect)
  2039.   end
  2040.   #----------------------------------------------------------------------------
  2041.   # ● upgraded method: terminate
  2042.   #----------------------------------------------------------------------------
  2043.   def terminate
  2044.     super
  2045.     fadeout_all(60)
  2046.     @map_bgm.replay
  2047.     dispose_enemy_image
  2048.   end
  2049.   #----------------------------------------------------------------------------
  2050.   # ○ new method: dispose_enemy_image
  2051.   #----------------------------------------------------------------------------
  2052.   def dispose_enemy_image
  2053.     return unless @enemy_bg
  2054.     @enemy_bg.bitmap.dispose if @enemy_bg.bitmap
  2055.     @enemy_bg.dispose
  2056.   end
  2057. end


直接放图鉴源代码和对应插件
RUBY 代码复制
  1. #==============================================================================
  2. # ▼ Venka's Bestiary Books Addon                            Updated: 08/14/2014
  3. #   author: Venka
  4. # ────────────────────────────────────────────────────────────
  5. # - 条款 -
  6. # ────────────────────────────────────────────────────────────
  7. # 本脚本可以商业或非商业用途使用。如果商业用途使用,
  8. # 我希望通过论坛给我发一条私信,附上游戏链接,这样我可以跟进它的进度..但这不是必须的;)
  9. # 这只是一个我想看一眼的事情
  10. #
  11. # ────────────────────────────────────────────────────────────
  12. # - 介绍 -
  13. # ────────────────────────────────────────────────────────────
  14. # 此脚本需要Venka的图鉴脚本才能工作。
  15. # 您可以在数据库中创建带有包含敌人ID的注释标签的项目。
  16. # 这些项目将教会您敌人的元素和状态抗性,如果您之前没有遇到过敌人,还将在图鉴中创建敌人的条目。
  17. # 这些项目可以在商店中出售或找到并使用。
  18. #
  19. # 当从商店购买项目时,它将立即使用,并且不会在您的库存中留下任何项目。
  20. # 如果在探索中找到该项目,则需要从库存中使用该项目。然后,您可以在数据库中设置是否要消耗该项目。
  21. #
  22. # ────────────────────────────────────────────────────────────
  23. # - 说明 -
  24. # ────────────────────────────────────────────────────────────
  25. # 您需要在项目注释框中放置一个注释标签。
  26. #     <enemy_id: x, y, z>    - x, y, z 是数据库中的敌人ID
  27. # 您可以让该项目只识别一个敌人或多个。
  28. #==============================================================================
  29. module Venka::Notetag
  30.   Enemy_IDs = /<enemy_id:\s*(\d+(?:\s*,\s*\d+)*)>/i
  31. end
  32. $imported[:Venka_Bestiary_Books] = true
  33. #==============================================================================
  34. # ■ DataManager
  35. #==============================================================================
  36. module DataManager
  37.   #----------------------------------------------------------------------------
  38.   # ● alias method: load_database
  39.   #----------------------------------------------------------------------------
  40.   class <<self; alias load_database_bestie_books load_database; end
  41.   def self.load_database
  42.     load_database_bestie_books
  43.     load_bestiary_book_notetags
  44.   end
  45.   #----------------------------------------------------------------------------
  46.   # ○ new method: load_bestiary_book_notetags
  47.   #----------------------------------------------------------------------------
  48.   def self.load_bestiary_book_notetags
  49.     $data_items.each do |item|
  50.       next if item.nil?
  51.       item.load_bestie_book_tags
  52.     end
  53.   end
  54. end
  55. #==============================================================================
  56. # ■ RPG::BaseItem
  57. #==============================================================================
  58. class RPG::BaseItem
  59.   #----------------------------------------------------------------------------
  60.   # ♦ Public Instance Variables
  61.   #----------------------------------------------------------------------------
  62.   attr_accessor :enemy_id
  63.   #----------------------------------------------------------------------------
  64.   # ○ new method: load_bestie_book_tags
  65.   #----------------------------------------------------------------------------
  66.   def load_bestie_book_tags
  67.     @enemy_id = nil
  68.     self.note.split(/[\r\n]+/).each { |line|
  69.       case line
  70.       when Venka::Notetag::Enemy_IDs
  71.         @enemy_id = []
  72.         $1.scan(/\d+/).each{|num| @enemy_id.push(num.to_i) if num.to_i >= 0}
  73.       end
  74.     }
  75.   end
  76. end
  77. #==============================================================================
  78. # ■ Window_ShopNumber
  79. #==============================================================================
  80. class Window_ShopNumber < Window_Selectable
  81.   #----------------------------------------------------------------------------
  82.   # ● alias method: set
  83.   #----------------------------------------------------------------------------
  84.   alias bestiary_shop_set set
  85.   def set(item, max, price, currency_unit = nil)
  86.     bestiary_shop_set(item, max, price, currency_unit = nil)
  87.     @max = (item.enemy_id.nil? ? max : 1)
  88.     refresh
  89.   end
  90. end
  91. #==============================================================================
  92. # ■ Window_ShopBuy
  93. #==============================================================================
  94. class Window_ShopBuy < Window_Selectable
  95.   #----------------------------------------------------------------------------
  96.   # ● alias method: enable?
  97.   #----------------------------------------------------------------------------
  98.   alias bestiary_shop_enable? enable?
  99.   def enable?(item)
  100.     if item.enemy_id.nil?
  101.       bestiary_shop_enable?(item)
  102.     else
  103.       result = bestiary_shop_enable?(item)
  104.       sell_info = false
  105.       item.enemy_id.each do |id|
  106.         sell_info = true unless $game_party.bestiary_include?(id)
  107.       end
  108.       result && sell_info
  109.     end
  110.   end
  111. end
  112. #==============================================================================
  113. # ■ Scene_Shop
  114. #==============================================================================
  115. class Scene_Shop < Scene_MenuBase
  116.   #----------------------------------------------------------------------------
  117.   # ● alias method: do_buy
  118.   #----------------------------------------------------------------------------
  119.   alias bestiary_shop_do_buy do_buy
  120.   def do_buy(number)
  121.     bestiary_shop_do_buy(number)
  122.     return if @item.enemy_id.nil?
  123.     @item.enemy_id.each do |id|
  124.       next if $game_party.bestiary_include?(id)
  125.       $game_party.add_enemy($data_enemies[id])
  126.       $game_party.reveal_resist(id)
  127.     end
  128.     $game_party.lose_item(@item, number) if @item.enemy_id
  129.   end
  130. end
  131. #==============================================================================
  132. # ■ Game_Battler
  133. #==============================================================================
  134. class Game_Battler < Game_BattlerBase
  135.   #----------------------------------------------------------------------------
  136.   # ● alias method: use_item
  137.   #----------------------------------------------------------------------------
  138.   alias bestiary_book_use_item use_item
  139.   def use_item(item)
  140.     bestiary_book_use_item(item)
  141.     if item.is_a?(RPG::Item) && item.enemy_id
  142.       item.enemy_id.each do |id|
  143.         next if $game_party.bestiary_include?(id)
  144.         $game_party.add_enemy($data_enemies[id])
  145.         $game_party.reveal_resist(id)
  146.       end
  147.     end
  148.   end
  149. end

下边是输入插件

RUBY 代码复制
  1. #==============================================================================
  2. # ▼ Bestiary Actor's Input Addon                           Updated: 10/14/2014
  3. #   author: Venka
  4. # ────────────────────────────────────────────────────────────
  5. # - 术语 -
  6. # ────────────────────────────────────────────────────────────
  7. # 无论是商业用途还是非商业用途都可以自由使用。使用时请给予Venka信用。
  8. #
  9. # ────────────────────────────────────────────────────────────
  10. # - 介绍 -
  11. # ────────────────────────────────────────────────────────────
  12. # 这个脚本允许在使用扫描技能时,演员或类别对敌人发表评论。你可以在图鉴中查看已解锁的评论。
  13. #
  14. # ────────────────────────────────────────────────────────────
  15. # - 说明 -
  16. # ────────────────────────────────────────────────────────────
  17. # 您需要在任何想要额外演员输入的敌人的注释框中放置注释标签。您可以设置一个类别来发表这段小贴士,或者特定的演员。他们需要在扫描敌人时在战斗队伍中,这样文本才会弹出并在图鉴中解锁。
  18. #    <quote: x, Text>  - x 是演员的ID,Text 是战斗中所说的消息
  19. #
  20. # 示例:
  21. #    <quote: 1, This is a slimy slime!>
  22. #       将使得演员1,Eric,在扫描标记的敌人时说 "This is a slimy slime!"。
  23. #==============================================================================
  24. module Venka::Bestiary
  25.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  26.   # - Key Settings -
  27.   #----------------------------------------------------------------------------
  28.   # Set the key you want to use to bring up the quotes window while in the
  29.   # bestiary.
  30.   # Options:  :A - Shift Key            :B - Esc/X Key
  31.   #           :C - Space/Enter/Z Key    :X - A key
  32.   #           :Y - S Key                :Z - D key
  33.   #           :L - Q/Page Up Key        :R - W/Page Down Key
  34.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  35.   Quotes_Key = :X
  36.   Quote_Instructions = "使用s和d上下滑动描述框"
  37.  
  38. end
  39. #==============================================================================
  40. # ■ Venka::Notetag
  41. #==============================================================================
  42. $imported[:Venka_Bestiary_Talk] = true
  43. module Venka::Notetag
  44.   Bestiary_Quotes = /<quote:\s*(\d+),\s*(.*)>/i
  45. end
  46. #==============================================================================
  47. # ■ DataManager
  48. #==============================================================================
  49. module DataManager
  50.   #----------------------------------------------------------------------------
  51.   # ● alias method: load_database
  52.   #----------------------------------------------------------------------------
  53.   class <<self; alias load_database_beast_talk load_database; end
  54.   def self.load_database
  55.     load_database_beast_talk
  56.     load_beast_talk_notes
  57.   end
  58.   #----------------------------------------------------------------------------
  59.   # ○ new method: load_beast_talk_notes
  60.   #----------------------------------------------------------------------------
  61.   def self.load_beast_talk_notes
  62.     $data_enemies.each{ |e| next if e.nil?; e.load_actor_talk }
  63.   end
  64. end
  65. #==============================================================================
  66. # ■ RPG::Enemy
  67. #==============================================================================
  68. class RPG::Enemy
  69.   #----------------------------------------------------------------------------
  70.   # ♦ Public Instance Variables
  71.   #----------------------------------------------------------------------------
  72.   attr_accessor :actor_quotes
  73.   #----------------------------------------------------------------------------
  74.   # ○ new method: load_actor_talk
  75.   #----------------------------------------------------------------------------
  76.   def load_actor_talk
  77.     @actor_quotes = []
  78.     self.note.split(/[\r\n]+/).each do |line|
  79.       case line
  80.       when Venka::Notetag::Bestiary_Quotes
  81.         i = $1.to_i;        quote = $2
  82.         @actor_quotes[i] ||= []
  83.         @actor_quotes[i] << quote
  84.       end
  85.     end
  86.   end
  87. end
  88. #==============================================================================
  89. # ■ Game_Party
  90. #==============================================================================
  91. class Game_Party < Game_Unit
  92.   #----------------------------------------------------------------------------
  93.   # ○ new method: add_quote
  94.   #----------------------------------------------------------------------------
  95.   def add_quote(enemy_id, actor_id, quote)
  96.     rpg_enemy = $data_enemies[enemy_id]
  97.     return if rpg_enemy.nil? || rpg_enemy.skip
  98.     @bestiary.each do |entry|
  99.       next unless entry.enemy_id == rpg_enemy.shown_id
  100.       next if rpg_enemy.no_scan
  101.       next if entry.quotes.include?([actor_id, quote])
  102.       entry.quotes << [actor_id, quote]
  103.       entry.quotes.sort! { |a, b| a[0] <=> b[0] }
  104.     end
  105.   end
  106. end
  107. #==============================================================================
  108. # ■ Window_BestiaryQuotes
  109. #==============================================================================
  110. class Window_BestiaryQuotes < Window_Selectable
  111.   #----------------------------------------------------------------------------
  112.   # ● upgraded method: initialize
  113.   #----------------------------------------------------------------------------
  114.   def initialize(x, y)
  115.     @quotes = []
  116.     super(x, y, window_width, window_height)
  117.     set_windowskin
  118.     select(0)
  119.     hide
  120.   end
  121.   #----------------------------------------------------------------------------
  122.   # ● window settings;
  123.   #----------------------------------------------------------------------------
  124.   def window_width;       (Graphics.width * 0.55).round;          end
  125.   def window_height;      Graphics.height * 0.55;                 end
  126.   def item_max;           @quotes.size;                           end
  127.   def item_height;        height - standard_padding * 2;          end
  128.   #----------------------------------------------------------------------------
  129.   # ○ new method: enemy_id
  130.   #----------------------------------------------------------------------------
  131.   def enemy_id=(enemy_id)
  132.     if @enemy_id != enemy_id
  133.       @enemy_id = enemy_id
  134.       quotes
  135.       refresh
  136.     end
  137.   end
  138.   #----------------------------------------------------------------------------
  139.   # ○ new method: quotes
  140.   #----------------------------------------------------------------------------
  141.   def quotes
  142.     $game_party.bestiary.each do |entry|
  143.       next unless entry.enemy_id == $data_enemies[@enemy_id].shown_id
  144.       @quotes = entry.quotes
  145.     end
  146.   end
  147.   #----------------------------------------------------------------------------
  148.   # ● upgraded method: refresh
  149.   #----------------------------------------------------------------------------
  150.   def refresh
  151.     contents.clear
  152.     create_contents
  153.     draw_all_items
  154.   end
  155.   #----------------------------------------------------------------------------
  156.   # ● upgraded method: draw_item
  157.   #----------------------------------------------------------------------------
  158.   def draw_item(index)
  159.     rect = item_rect_for_text(index)
  160.     actor = $game_actors[@quotes[index][0]]
  161.     quote = @quotes[index][1]
  162.     draw_face(actor.face_name, actor.face_index, rect.x, rect.y + 2)
  163.     draw_quote(rect, quote)
  164.   end
  165.   #----------------------------------------------------------------------------
  166.   # ○ new method: draw_quote
  167.   #----------------------------------------------------------------------------
  168.   def draw_quote(rect, quote)
  169.     if Venka::Bestiary::Use_Wordwrapper
  170.       wrapping = @wordwrap
  171.       @wordwrap = true
  172.       draw_text_ex(rect.x, rect.y + 96, quote.gsub(/[|]/, ""))
  173.       @wordwrap = wrapping
  174.     else
  175.       draw_text_ex(rect.x, rect.y + 96, quote)
  176.     end
  177.   end
  178.   #----------------------------------------------------------------------------
  179.   # ● upgraded method: draw_text_ex
  180.   #----------------------------------------------------------------------------
  181.   def draw_text_ex(x, y, text)
  182.     set_bestiary_font(:description)
  183.     text = convert_escape_characters(text)
  184.     pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
  185.     process_character(text.slice!(0, 1), text, pos) until text.empty?
  186.   end
  187. end
  188. #==============================================================================
  189. # ■ Scene_Battle
  190. #==============================================================================
  191. class Scene_Battle < Scene_Base
  192.   #----------------------------------------------------------------------------
  193.   # ● alias method: start
  194.   #----------------------------------------------------------------------------
  195.   alias :word_wrapping_start_setting :start
  196.   def start
  197.     word_wrapping_start_setting
  198.     @wrapper = @message_window.wordwrap
  199.   end
  200.   #----------------------------------------------------------------------------
  201.   # ○ new/aliased method: show_enemy_info - add pop up text here
  202.   #----------------------------------------------------------------------------
  203.   alias actor_input_show_info show_enemy_info
  204.   def show_enemy_info(enemy_id)
  205.     add_input_text(enemy_id)
  206.     actor_input_show_info(enemy_id)
  207.   end
  208.   #----------------------------------------------------------------------------
  209.   # ○ new method: add_input_text
  210.   #----------------------------------------------------------------------------
  211.   def add_input_text(enemy_id)
  212.     quotes = []
  213.     $game_party.members.each do |actor|
  214.       next if $data_enemies[enemy_id].actor_quotes[actor.id].nil?
  215.       quotes << [actor.id, $data_enemies[enemy_id].actor_quotes[actor.id]]
  216.     end
  217.     show_message_window(enemy_id, quotes) unless quotes.empty?
  218.   end
  219.   #----------------------------------------------------------------------------
  220.   # ○ new method: show_message_window
  221.   #----------------------------------------------------------------------------
  222.   def show_message_window(enemy_id, quotes)
  223.     quote = quotes.sample
  224.     actor = $game_actors[quote[0]]
  225.     $game_message.face_name  = actor.face_name
  226.     $game_message.face_index = actor.face_index
  227.     @text = quote[1].sample
  228.     $game_party.add_quote(enemy_id, actor.id, @text)
  229.     handle_word_wrapping
  230.     wait_to_close
  231.   end
  232.   #----------------------------------------------------------------------------
  233.   # ○ new method: handle_word_wrapping
  234.   #----------------------------------------------------------------------------
  235.   def handle_word_wrapping
  236.     if Venka::Bestiary::Use_Wordwrapper
  237.       @message_window.wordwrap = true
  238.       $game_message.add(@text.gsub(/[|]/, ""))
  239.     else
  240.       $game_message.add(@text.gsub(/[|]/, "\n"))
  241.     end
  242.   end
  243.   #----------------------------------------------------------------------------
  244.   # ○ new method: wait_to_close
  245.   #----------------------------------------------------------------------------
  246.   def wait_to_close
  247.     loop do
  248.       Graphics.update
  249.       Input.update
  250.       @message_window.update
  251.       unless $game_message.busy?
  252.         @message_window.update
  253.         $game_message.clear
  254.         break
  255.       end
  256.     end
  257.   end
  258.   #----------------------------------------------------------------------------
  259.   # ● alias method: terminate
  260.   #----------------------------------------------------------------------------
  261.   alias :word_wrapping_reset_term :terminate
  262.   def terminate
  263.     @message_window.wordwrap = @wrapper
  264.     word_wrapping_reset_term
  265.   end
  266. end
  267. #==============================================================================
  268. # ■ Scene_Bestiary
  269. #==============================================================================
  270. class Scene_Bestiary < Scene_MenuBase
  271.   #----------------------------------------------------------------------------
  272.   # ● alias method: create_all_windows
  273.   #----------------------------------------------------------------------------
  274.   alias :quotes_window_to_creation :create_all_windows
  275.   def create_all_windows
  276.     quotes_window_to_creation
  277.     create_quotes_window
  278.   end
  279.   #----------------------------------------------------------------------------
  280.   # ○ new method: create_quotes_window
  281.   #----------------------------------------------------------------------------
  282.   def create_quotes_window
  283.     x, y = @stats_selection.width, @help_window.height
  284.     @quotes_window = Window_BestiaryQuotes.new(x, y)
  285.     @quotes_window.viewport = @viewport
  286.     @quotes_window.set_handler(:ok,      method(:close_quotes))
  287.     @quotes_window.set_handler(:cancel,  method(:close_quotes))
  288.   end
  289.   #----------------------------------------------------------------------------
  290.   # ○ new method: close_quotes
  291.   #----------------------------------------------------------------------------
  292.   def close_quotes
  293.     @quotes_window.hide.deactivate
  294.     @stats_selection.activate
  295.   end
  296.   #----------------------------------------------------------------------------
  297.   # ○ new/alias method: create_enemy_image
  298.   #----------------------------------------------------------------------------
  299.   alias :quote_directions_on_image :create_enemy_image
  300.   def create_enemy_image
  301.     quote_directions_on_image
  302.     set_img_font
  303.   end
  304.   #----------------------------------------------------------------------------
  305.   # ○ new method: set_img_font
  306.   #----------------------------------------------------------------------------
  307.   def set_img_font
  308.     font = Venka::Bestiary::Battle_Font
  309.     img = @enemy_bg.bitmap
  310.     img.font.name  = font[0]
  311.     img.font.size  = font[1]
  312.     img.font.bold  = font[2]
  313.     img.font.color = Color.new(*font[3])
  314.     img.font.outline = font[4]
  315.   end
  316.   #----------------------------------------------------------------------------
  317.   # ○ new/alias method: update_enemy_info
  318.   #----------------------------------------------------------------------------
  319.   alias :quotes_window_update_info :update_enemy_info
  320.   def update_enemy_info
  321.     quotes_window_update_info
  322.     @quotes_window.enemy_id = @list_window.current_ext
  323.   end
  324.   #----------------------------------------------------------------------------
  325.   # ○ new/alias method: update_enemy_image
  326.   #----------------------------------------------------------------------------
  327.   alias :quotes_instructs_on_img :update_enemy_image
  328.   def update_enemy_image(enemy)
  329.     quotes_instructs_on_img(enemy)
  330.     draw_image_text(@enemy_bg.bitmap)
  331.   end
  332.   #----------------------------------------------------------------------------
  333.   # ○ new method: draw_image_text
  334.   #----------------------------------------------------------------------------
  335.   def draw_image_text(image)
  336.     font = Venka::Bestiary::Battle_Font
  337.     text = Venka::Bestiary::Quote_Instructions
  338.     image.draw_text(0, image.height - font[1], image.width, font[1], text, 1)
  339.   end
  340.   #----------------------------------------------------------------------------
  341.   # ● upgraded method: update
  342.   #----------------------------------------------------------------------------
  343.   def update
  344.     super
  345.     if @stats_selection.active && Input.trigger?(Venka::Bestiary::Quotes_Key)
  346.       @stats_selection.deactivate
  347.       @quotes_window.show.activate
  348.     end
  349.   end
  350. end



bug问题————当敌人应用<skip>脚本标注后

一旦在战斗页面中按下↓按钮就会闪退报错




上图为第一份代码的报错范围

对此我尝试的处理为将代码1095行开始的以下代码注释掉。
#按下闪退 if @help_window && display_window_oy < @help_window.total_height
     # @help_window.oy += Venka::Bestiary::Scroll_Speed
   # end

但是这样在战外的图鉴页面按住↓图鉴便不会滚动了。有没有大佬知道该怎么办?

Lv6.析梦学徒

老鹰

梦石
40
星屑
35164
在线时间
6751 小时
注册时间
2012-5-26
帖子
3245

极短24评委极短23参与极短22参与极短21评委老司机慢点开短篇十吟唱者组别冠军开拓者剧作品鉴家

2
发表于 5 天前 | 只看该作者
@help_window 哪里来的 total_height 方法,我看它也没有修改 Window_Help 啊
我看它的目的是让上下方向键移动帮助窗口,而帮助窗口有可能文本高度大于窗口显示高度,
那试试把 @help_window.total_height 改成 @help_window.contents_height ,这样判定也能成立,即 显示的oy + 窗口能显示的高度 < 窗口全部内容的高度 时,可以把帮助窗口内容往下移动显示
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2025-6-3 03:16

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表