Momo's Bestiary Script & How to add enemy data w/o battle?

Quote:
I don't know how I did it, but with a combination of DerVVulfman's help, and Babelfish, I managed to figure out Momo's comment function for his beastiary, or Demon Book. If anyone wants it, here it be!

This script adds a function to Momo's Demon Book wherein you can create comments on the monsters in your game that can be viewed by the player.

Note: I DID NOT MAKE THIS SCRIPT! Ahem. Sorry. Momo made this script, not me. Please don't ask me about how it works, I don't know. I figured this out by a combination of beginner's and dumb luck. If you want to know HOW to use it, ask me. That I may be able to help with :D .

This is the main Beastiary. Put this above main, yada yada.
  1. #魔物図鑑
  2. #
  3. #ã‚¨ãƒãƒŸãƒ¼ã®é­é‡æƒ…å ±ã¯ã€æˆ¦é—˜çµ‚äº†æ™‚(経験値などを獲得する所)ã§è¿½åŠ ã•ã‚Œã¾ã™ã€‚
  4. #ã‚ˆã£ã¦ã€æ•µã‹ã‚‰é€ƒã’ãŸå ´åˆã‚„è² ã‘ã‚¤ãƒ™ãƒ³ãƒˆã§ã®æˆ¦é—˜æ•—åŒ—ãªã©ã§ã¯
  5. #図鑑に登録されません。
  6. #ã“ã®ã‚¿ã‚¤ãƒŸãƒ³ã‚°ã‚’å¤‰ãˆãŸã„å ´åˆã¯å„è‡ªæ›¸ãæ›ãˆã¦ä¸‹ã•ã„ã€‚
  7. #(class Scene_Battle の start_phase5 ã§è¿½åŠ ã—ã¦ã¾ã™ã€‚)
  8. #
  9. #また、所々「アナライズ」という単語がありますが、
  10. #現在、この魔物辞典だけでは機能しておりません。(自ゲームでの名残)
  11. #Window_MonsterBook_Info の DROP_ITEM_NEED_ANALYZE が true になっていると
  12. #ドロップアイテムが表示されなくなりますので、通常は false にしておいて下さい。
  13. #
  14. #注意
  15. #このまま使うと、データベースのトループの1番に
  16. #何も設定していないと、エラー吐きます。
  17. #対処策としては
  18. #1.ç´ ç›´ã«ãƒ‡ãƒ¼ã‚¿ãƒ™ãƒ¼ã‚¹ã®ãƒˆãƒ«ãƒ¼ãƒ—ã®1番に何でもいいから設定する。
  19. #2.Game_Enemy_Book の 「super(1, 0)#ダミー」 の左側の数字の部分を
  20. #  å­˜åœ¨ã™ã‚‹ãƒˆãƒ«ãƒ¼ãƒ—IDに書き換える。
  21. #のどちらかになります。
  22. #
  23. #2005.2.6 機能追åŠ
  24. #図鑑完成度の表示機能を追åŠ
  25. #SHOW_COMPLETE_TYPE で設定できます。
  26. #イベントコマンドの「スクリプト」で
  27. #$game_party.enemy_book_max で図鑑の総魔物数(最大数)
  28. #$game_party.enemy_book_now で図鑑の現在登録数(現在数)
  29. #$game_party.complete_percentage で図鑑の完成率(小数点切捨て)
  30. #を取得できます。
  31. #
  32. #2005.2.17
  33. #complete_percentageのメソッド名を
  34. #enemy_book_complete_percentageに変更(他の図鑑と区別できるように)
  35. #イベントコマンドの「スクリプト」で最大数等の取得を短縮できるようになりました。
  36. #enemy_book_max で図鑑の総魔物数(最大数)
  37. #enemy_book_now で図鑑の現在登録数(現在数)
  38. #enemy_book_compで図鑑の完成率(小数点切捨て)
  39. #
  40. #2005.2.18 バグ修正
  41. #complete_percentageのメソッド名を
  42. #enemy_book_complete_percentageに変更したのに
  43. #complete_percentageって呼び出してました。(単なる書き換え漏れですね)
  44. #
  45. #2005.7.4 機能追åŠ
  46. #コメント機能に対応。
  47. #全体的に色々いじりました。
  48. #
  49. #2005.7.4 バグ修正
  50. #細かいバグを修正。
  51.  
  52.  
  53. module Enemy_Book_Config
  54.   #ドロップアイテム表示にアナライズが必要かどうか
  55.   DROP_ITEM_NEED_ANALYZE = false
  56.   #回避修正の名前
  57.   EVA_NAME = "回避"            
  58.   #図鑑完成率の表示方法
  59.   #0:表示なし 1:現在数/最大数 2:%表示 3:両方
  60.   SHOW_COMPLETE_TYPE = 3        
  61.   #コメント機能を使うかどうか(è¦ãƒ»ã‚³ãƒ¡ãƒ³ãƒˆè¿½åŠ ã‚¹ã‚¯ãƒªãƒ—ãƒˆå°Žå…¥)
  62.   COMMENT_SYSTEM = true
  63. end
  64.  
  65. class Game_Temp
  66.   attr_accessor :enemy_book_data
  67.   alias temp_enemy_book_data_initialize initialize
  68.   def initialize
  69.     temp_enemy_book_data_initialize
  70.     @enemy_book_data = Data_MonsterBook.new
  71.   end
  72. end
  73.  
  74. class Game_Party
  75.   attr_accessor :enemy_info               # å‡ºä¼šã£ãŸæ•µæƒ…å ±(図鑑用)
  76.   #--------------------------------------------------------------------------
  77.   #  — オブジェクト初期化
  78.   #--------------------------------------------------------------------------
  79.   alias book_info_initialize initialize
  80.   def initialize
  81.     book_info_initialize
  82.     @enemy_info = {}
  83.   end
  84.   #--------------------------------------------------------------------------
  85.   #  — ã‚¨ãƒãƒŸãƒ¼æƒ…å ±ã®è¿½åŠ (図鑑用)
  86.   #     type : 通常遭遇かアナライズか 0:通常 1:アナライズ -1:æƒ…å ±å‰Šé™¤
  87.   #     0:無遭遇 1:遭遇済 2:アナライズ済
  88.   #--------------------------------------------------------------------------
  89.   def add_enemy_info(enemy_id, type = 0)
  90.     case type
  91.     when 0
  92.       if @enemy_info[enemy_id] == 2
  93.         return false
  94.       end
  95.       @enemy_info[enemy_id] = 1
  96.     when 1
  97.       @enemy_info[enemy_id] = 2
  98.     when -1
  99.       @enemy_info[enemy_id] = 0
  100.     end
  101.   end
  102.   #--------------------------------------------------------------------------
  103.   #  — 魔物図鑑の最大登録数を取得
  104.   #--------------------------------------------------------------------------
  105.   def enemy_book_max
  106.     return $game_temp.enemy_book_data.id_data.size - 1
  107.   end
  108.   #--------------------------------------------------------------------------
  109.   #  — 魔物図鑑の現在登録数を取得
  110.   #--------------------------------------------------------------------------
  111.   def enemy_book_now
  112.     now_enemy_info = @enemy_info.keys
  113.     # 登録無視の属性IDを取得
  114.     no_add = $game_temp.enemy_book_data.no_add_element
  115.     new_enemy_info = []
  116.     for i in now_enemy_info
  117.       enemy = $data_enemies[i]
  118.       next if enemy.name == ""
  119.       if enemy.element_ranks[no_add] == 1
  120.         next
  121.       end
  122.       new_enemy_info.push(enemy.id)
  123.     end
  124.     return new_enemy_info.size
  125.   end
  126.   #--------------------------------------------------------------------------
  127.   #  — 魔物図鑑の完成率を取得
  128. end
  129.  
  130. class Interpreter
  131.   def enemy_book_max
  132.     return $game_party.enemy_book_max
  133.   end
  134.   def enemy_book_now
  135.     return $game_party.enemy_book_now
  136.   end
  137.   def enemy_book_comp
  138.     return $game_party.enemy_book_complete_percentage
  139.   end
  140. end
  141.  
  142. class Scene_Battle
  143.   alias add_enemy_info_start_phase5 start_phase5
  144.   def start_phase5
  145.     for enemy in $game_troop.enemies
  146.       # ã‚¨ãƒãƒŸãƒ¼ãŒéš ã‚ŒçŠ¶æ…‹ã§ãªã„å ´åˆ
  147.       unless enemy.hidden
  148.         # æ•µé­é‡æƒ…å ±è¿½åŠ
  149.         $game_party.add_enemy_info(enemy.id, 0)
  150.       end
  151.     end
  152.     add_enemy_info_start_phase5
  153.   end
  154. end
  155.  
  156. class Window_Base < Window
  157.   #--------------------------------------------------------------------------
  158.   #  — エネミーの戦闘後獲得アイテムの描画
  159.   #--------------------------------------------------------------------------
  160.   def draw_enemy_drop_item(enemy, x, y)
  161.     self.contents.font.color = normal_color
  162.     treasures = []
  163.     if enemy.item_id > 0
  164.       treasures.push($data_items[enemy.item_id])
  165.     end
  166.     if enemy.weapon_id > 0
  167.       treasures.push($data_weapons[enemy.weapon_id])
  168.     end
  169.     if enemy.armor_id > 0
  170.       treasures.push($data_armors[enemy.armor_id])
  171.     end
  172.     # 現状ではとりあえず1つのみ描画
  173.     if treasures.size > 0
  174.       item = treasures[0]
  175.       bitmap = RPG::Cache.icon(item.icon_name)
  176.       opacity = 255
  177.       self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  178.       name = treasures[0].name
  179.     else
  180.       self.contents.font.color = disabled_color
  181.       name = "No Item"
  182.     end
  183.     self.contents.draw_text(x+28, y, 212, 32, name)
  184.   end
  185.   #--------------------------------------------------------------------------
  186.   #  — エネミーの図鑑IDの描画
  187.   #--------------------------------------------------------------------------
  188.   def draw_enemy_book_id(enemy, x, y)
  189.     self.contents.font.color = normal_color
  190.     id = $game_temp.enemy_book_data.id_data.index(enemy.id)
  191.     self.contents.draw_text(x, y, 32, 32, id.to_s)
  192.   end
  193.   #--------------------------------------------------------------------------
  194.   #  — エネミーの名前の描画
  195.   #     enemy : エネミー
  196.   #     x     : 描画先 X 座標
  197.   #     y     : 描画先 Y 座標
  198.   #--------------------------------------------------------------------------
  199.   def draw_enemy_name(enemy, x, y)
  200.     self.contents.font.color = normal_color
  201.     self.contents.draw_text(x, y, 152, 32, enemy.name)
  202.   end
  203.   #--------------------------------------------------------------------------
  204.   #  — エネミーグラフィックの描画(アナライズ)
  205.   #     enemy : エネミー
  206.   #     x     : 描画先 X 座標
  207.   #     y     : 描画先 Y 座標
  208.   #--------------------------------------------------------------------------
  209.   def draw_enemy_graphic(enemy, x, y, opacity = 255)
  210.     bitmap = RPG::Cache.battler(enemy.battler_name, enemy.battler_hue)
  211.     cw = bitmap.width
  212.     ch = bitmap.height
  213.     src_rect = Rect.new(0, 0, cw, ch)
  214.     x = x + (cw / 2 - x) if cw / 2 > x
  215.     self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect, opacity)
  216.   end
  217.   #--------------------------------------------------------------------------
  218.   #  — エネミーの獲得EXPの描画
  219.   #     enemy : エネミー
  220.   #     x     : 描画先 X 座標
  221.   #     y     : 描画先 Y 座標
  222.   #--------------------------------------------------------------------------
  223.   def draw_enemy_exp(enemy, x, y)
  224.     self.contents.font.color = system_color
  225.     self.contents.draw_text(x, y, 120, 32, "EXP")
  226.     self.contents.font.color = normal_color
  227.     self.contents.draw_text(x + 120, y, 36, 32, enemy.exp.to_s, 2)
  228.   end
  229.   #--------------------------------------------------------------------------
  230.   #  — エネミーの獲得GOLDの描画
  231.   #     enemy : エネミー
  232.   #     x     : 描画先 X 座標
  233.   #     y     : 描画先 Y 座標
  234.   #--------------------------------------------------------------------------
  235.   def draw_enemy_gold(enemy, x, y)
  236.     self.contents.font.color = system_color
  237.     self.contents.draw_text(x, y, 120, 32, $data_system.words.gold)
  238.     self.contents.font.color = normal_color
  239.     self.contents.draw_text(x + 120, y, 36, 32, enemy.gold.to_s, 2)
  240.   end
  241. end
  242.  
  243. class Game_Enemy_Book < Game_Enemy
  244.   #--------------------------------------------------------------------------
  245.   #  — オブジェクト初期化
  246.   #--------------------------------------------------------------------------
  247.   def initialize(enemy_id)
  248.     super(1, 0)#ダミー
  249.     @enemy_id = enemy_id
  250.     enemy = $data_enemies[@enemy_id]
  251.     @battler_name = enemy.battler_name
  252.     @battler_hue = enemy.battler_hue
  253.     @hp = maxhp
  254.     @sp = maxsp
  255.   end
  256. end
  257.  
  258. class Data_MonsterBook
  259.   attr_reader :id_data
  260.   #--------------------------------------------------------------------------
  261.   #  — オブジェクト初期化
  262.   #--------------------------------------------------------------------------
  263.   def initialize
  264.     @id_data = enemy_book_id_set
  265.   end
  266.   #--------------------------------------------------------------------------
  267.   #  — 図鑑用登録無視属性取得
  268.   #--------------------------------------------------------------------------
  269.   def no_add_element
  270.     no_add = 0
  271.     # 登録無視の属性IDを取得
  272.     for i in 1...$data_system.elements.size
  273.       if $data_system.elements[i] =~ /図鑑登録無効/
  274.         no_add = i
  275.         break
  276.       end
  277.     end
  278.     return no_add
  279.   end
  280.   #--------------------------------------------------------------------------
  281.   #  — 図鑑用敵ID設定
  282.   #--------------------------------------------------------------------------
  283.   def enemy_book_id_set
  284.     data = [0]
  285.     no_add = no_add_element
  286.     # 登録無視の属性IDを取得
  287.     for i in 1...$data_enemies.size
  288.       enemy = $data_enemies[i]
  289.       next if enemy.name == ""
  290.       if enemy.element_ranks[no_add] == 1
  291.         next
  292.       end
  293.       data.push(enemy.id)
  294.     end
  295.     return data
  296.   end
  297. end
  298.  
  299.  
  300. class Window_MonsterBook < Window_Selectable
  301.   attr_reader   :data
  302.   #--------------------------------------------------------------------------
  303.   #  — オブジェクト初期化
  304.   #--------------------------------------------------------------------------
  305.   def initialize(index=0)
  306.     super(0, 64, 640, 416)
  307.     @column_max = 2
  308.     @book_data = $game_temp.enemy_book_data
  309.     @data = @book_data.id_data.dup
  310.     @data.shift
  311.     #@data.sort!
  312.     @item_max = @data.size
  313.     self.index = 0
  314.     refresh if @item_max > 0
  315.   end
  316.   #--------------------------------------------------------------------------
  317.   #  — 遭遇データを取得
  318.   #--------------------------------------------------------------------------
  319.   def data_set
  320.     data = $game_party.enemy_info.keys
  321.     data.sort!
  322.     newdata = []
  323.     for i in data
  324.       next if $game_party.enemy_info[i] == 0
  325.       # 図鑑登録無視を考慮
  326.       if book_id(i) != nil
  327.         newdata.push(i)
  328.       end
  329.     end
  330.     return newdata
  331.   end
  332.   #--------------------------------------------------------------------------
  333.   #  — 表示許可取得
  334.   #--------------------------------------------------------------------------
  335.   def show?(id)
  336.     if $game_party.enemy_info[id] == 0 or $game_party.enemy_info[id] == nil
  337.       return false
  338.     else
  339.       return true
  340.     end
  341.   end
  342.   #--------------------------------------------------------------------------
  343.   #  — 図鑑用ID取得
  344.   #--------------------------------------------------------------------------
  345.   def book_id(id)
  346.     return @book_data.index(id)
  347.   end
  348.   #--------------------------------------------------------------------------
  349.   #  — エネミー取得
  350.   #--------------------------------------------------------------------------
  351.   def item
  352.     return @data[self.index]
  353.   end
  354.   #--------------------------------------------------------------------------
  355.   #  — リフレッシュ
  356.   #--------------------------------------------------------------------------
  357.   def refresh
  358.     if self.contents != nil
  359.       self.contents.dispose
  360.       self.contents = nil
  361.     end
  362.     self.contents = Bitmap.new(width - 32, row_max * 32)
  363.     #é …ç›®æ•°ãŒ 0 ã§ãªã‘ã‚Œã°ãƒ“ãƒƒãƒˆãƒžãƒƒãƒ—ã‚’ä½œæˆã—ã€å…¨é …ç›®ã‚’æç”»
  364.     if @item_max > 0
  365.       for i in 0...@item_max
  366.        draw_item(i)
  367.       end
  368.     end
  369.   end
  370.   #--------------------------------------------------------------------------
  371.   #  — é …ç›®ã®æç”»
  372.   #     index : é …ç›®ç•ªå·
  373.   #--------------------------------------------------------------------------
  374.   def draw_item(index)
  375.     enemy = $data_enemies[@data[index]]
  376.     return if enemy == nil
  377.     x = 4 + index % 2 * (288 + 32)
  378.     y = index / 2 * 32
  379.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  380.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  381.     self.contents.font.color = normal_color
  382.     draw_enemy_book_id(enemy, x, y)
  383.     if show?(enemy.id)
  384.       self.contents.draw_text(x + 28+16, y, 212, 32, enemy.name, 0)
  385.     else
  386.       self.contents.draw_text(x + 28+16, y, 212, 32, "-----", 0)
  387.       return
  388.     end
  389.     if analyze?(@data[index])
  390.       self.contents.font.color = text_color(3)
  391.       self.contents.draw_text(x + 256, y, 24, 32, "済", 2)
  392.     end
  393.   end
  394.   #--------------------------------------------------------------------------
  395.   #  — アナライズ済かどうか
  396.   #--------------------------------------------------------------------------
  397.   def analyze?(enemy_id)
  398.     if $game_party.enemy_info[enemy_id] == 2
  399.       return true
  400.     else
  401.       return false
  402.     end
  403.   end
  404. end
  405.  
  406.  
  407. class Window_MonsterBook_Info < Window_Base
  408.   #--------------------------------------------------------------------------
  409.   #  — オブジェクト初期化
  410.   #--------------------------------------------------------------------------
  411.   def initialize
  412.     super(0, 0+64, 640, 480-64)
  413.     self.contents = Bitmap.new(width - 32, height - 32)
  414.   end
  415.   #--------------------------------------------------------------------------
  416.   #  — リフレッシュ
  417.   #--------------------------------------------------------------------------
  418.   def refresh(enemy_id)
  419.     self.contents.clear
  420.     self.contents.font.size = 22
  421.     enemy = Game_Enemy_Book.new(enemy_id)
  422.     draw_enemy_graphic(enemy, 96, 240+48+64, 200)
  423.     draw_enemy_book_id(enemy, 4, 0)
  424.     draw_enemy_name(enemy, 48, 0)
  425.     draw_actor_hp(enemy, 288, 0)
  426.     draw_actor_sp(enemy, 288+160, 0)
  427.     draw_actor_parameter(enemy, 288    ,  32, 0)
  428.     self.contents.font.color = system_color
  429.     self.contents.draw_text(288+160, 32, 120, 32, Enemy_Book_Config::EVA_NAME)
  430.     self.contents.font.color = normal_color
  431.     self.contents.draw_text(288+160 + 120, 32, 36, 32, enemy.eva.to_s, 2)
  432.     draw_actor_parameter(enemy, 288    ,  64, 3)
  433.     draw_actor_parameter(enemy, 288+160,  64, 4)
  434.     draw_actor_parameter(enemy, 288    ,  96, 5)
  435.     draw_actor_parameter(enemy, 288+160,  96, 6)
  436.     draw_actor_parameter(enemy, 288    , 128, 1)
  437.     draw_actor_parameter(enemy, 288+160, 128, 2)
  438.     draw_enemy_exp(enemy, 288, 160)
  439.     draw_enemy_gold(enemy, 288+160, 160)
  440.     if analyze?(enemy.id) or !Enemy_Book_Config::DROP_ITEM_NEED_ANALYZE
  441.       self.contents.draw_text(288, 192, 96, 32, "Drop Item")
  442.       draw_enemy_drop_item(enemy, 288+96+4, 192)
  443.       self.contents.font.color = normal_color
  444.       #draw_element_guard(enemy, 320-32, 160-16+96)
  445.     end
  446.   end
  447.   #--------------------------------------------------------------------------
  448.   #  — アナライズ済かどうか
  449.   #--------------------------------------------------------------------------
  450.   def analyze?(enemy_id)
  451.     if $game_party.enemy_info[enemy_id] == 2
  452.       return true
  453.     else
  454.       return false
  455.     end
  456.   end
  457. end
  458.  
  459.  
  460. class Scene_MonsterBook
  461.   #--------------------------------------------------------------------------
  462.   #  — メイン処理
  463.   #--------------------------------------------------------------------------
  464.   def main
  465.     $game_temp.enemy_book_data = Data_MonsterBook.new
  466.     # ウィンドウを作成
  467.     @title_window = Window_Base.new(0, 0, 640, 64)
  468.     @title_window.contents = Bitmap.new(640 - 32, 64 - 32)
  469.     @title_window.contents.draw_text(4, 0, 320, 32, "Monster Information", 0)
  470.     @main_window = Window_MonsterBook.new
  471.     @main_window.active = true
  472.     # インフォウィンドウを作成 (不可視・非アクティブに設定)
  473.     @info_window = Window_MonsterBook_Info.new
  474.     @info_window.z = 110
  475.     @info_window.visible = false
  476.     @info_window.active = false
  477.     @visible_index = 0
  478.     if Enemy_Book_Config::COMMENT_SYSTEM
  479.       # コメントウィンドウを作成 (不可視・非アクティブに設定)
  480.       @comment_window = Window_Monster_Book_Comment.new
  481.       @comment_window.z = 120
  482.       @comment_window.visible = false
  483.       @comment_on = false # コメントフラグ
  484.     end
  485.     # トランジション実行
  486.     Graphics.transition
  487.     # メインループ
  488.     loop do
  489.       # ゲーム画面を更新
  490.       Graphics.update
  491.       # å…¥åŠ›æƒ…å ±ã‚’æ›´æ–°
  492.       Input.update
  493.       # フレーム更新
  494.       update
  495.       # 画面が切り替わったらループを中断
  496.       if $scene != self
  497.         break
  498.       end
  499.     end
  500.     # トランジション準備
  501.     Graphics.freeze
  502.     # ウィンドウを解放
  503.     @main_window.dispose
  504.     @info_window.dispose
  505.     @title_window.dispose
  506.     @comment_window.dispose if @comment_window != nil
  507.   end
  508.   #--------------------------------------------------------------------------
  509.   #  — フレーム更新
  510.   #--------------------------------------------------------------------------
  511.   def update
  512.     # ウィンドウを更新
  513.     @main_window.update
  514.     @info_window.update
  515.     if @info_window.active
  516.       update_info
  517.       return
  518.     end
  519.     # ãƒ¡ã‚¤ãƒ³ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ãŒã‚¢ã‚¯ãƒ†ã‚£ãƒ–ã®å ´åˆ: update_target を呼ぶ
  520.     if @main_window.active
  521.       update_main
  522.       return
  523.     end
  524.   end
  525.   #--------------------------------------------------------------------------
  526.   #  — フレーム更新 (ãƒ¡ã‚¤ãƒ³ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ãŒã‚¢ã‚¯ãƒ†ã‚£ãƒ–ã®å ´åˆ)
  527.   #--------------------------------------------------------------------------
  528.   def update_main
  529.     # B ãƒœã‚¿ãƒ³ãŒæŠ¼ã•ã‚ŒãŸå ´åˆ
  530.     if Input.trigger?(Input::B)
  531.       # キャンセル SE を演奏
  532.       $game_system.se_play($data_system.cancel_se)
  533.       $scene = Scene_Map.new
  534.       return
  535.     end
  536.     # C ãƒœã‚¿ãƒ³ãŒæŠ¼ã•ã‚ŒãŸå ´åˆ
  537.     if Input.trigger?(Input::C)
  538.       if @main_window.item == nil or @main_window.show?(@main_window.item) == false
  539.         # ブザー SE を演奏
  540.         $game_system.se_play($data_system.buzzer_se)
  541.         return
  542.       end
  543.       # 決定 SE を演奏
  544.       $game_system.se_play($data_system.decision_se)
  545.       @main_window.active = false
  546.       @info_window.active = true
  547.       @info_window.visible = true
  548.       @visible_index = @main_window.index
  549.       @info_window.refresh(@main_window.item)
  550.       if @comment_window != nil
  551.         @comment_window.refresh(@main_window.item)
  552.         if @comment_on
  553.           @comment_window.visible = true
  554.         else
  555.           @comment_window.visible = false
  556.         end
  557.       end
  558.       return
  559.     end
  560.   end
  561.   #--------------------------------------------------------------------------
  562.   #  — フレーム更新 (ã‚¤ãƒ³ãƒ•ã‚©ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ãŒã‚¢ã‚¯ãƒ†ã‚£ãƒ–ã®å ´åˆ)
  563.   #--------------------------------------------------------------------------
  564.   def update_info
  565.     # B ãƒœã‚¿ãƒ³ãŒæŠ¼ã•ã‚ŒãŸå ´åˆ
  566.     if Input.trigger?(Input::B)
  567.       # キャンセル SE を演奏
  568.       $game_system.se_play($data_system.cancel_se)
  569.       @main_window.active = true
  570.       @info_window.active = false
  571.       @info_window.visible = false
  572.       @comment_window.visible = false if @comment_window != nil
  573.       return
  574.     end
  575.     # C ãƒœã‚¿ãƒ³ãŒæŠ¼ã•ã‚ŒãŸå ´åˆ
  576.     if Input.trigger?(Input::C)
  577.       if @comment_window != nil
  578.         # 決定 SE を演奏
  579.         $game_system.se_play($data_system.decision_se)
  580.         if @comment_on
  581.           @comment_on = false
  582.           @comment_window.visible = false
  583.         else
  584.           @comment_on = true
  585.           @comment_window.visible = true
  586.         end
  587.         return
  588.       end
  589.     end
  590.     if Input.trigger?(Input::L)
  591.       # 決定 SE を演奏
  592.       $game_system.se_play($data_system.decision_se)
  593.       loop_end = false
  594.       while loop_end == false
  595.         if @visible_index != 0
  596.           @visible_index -= 1
  597.         else
  598.           @visible_index = @main_window.data.size - 1
  599.         end
  600.         loop_end = true if @main_window.show?(@main_window.data[@visible_index])
  601.       end
  602.       id = @main_window.data[@visible_index]
  603.       @info_window.refresh(id)
  604.       @comment_window.refresh(id) if @comment_window != nil
  605.       return
  606.     end
  607.     if Input.trigger?(Input::R)
  608.       # 決定 SE を演奏
  609.       $game_system.se_play($data_system.decision_se)
  610.       loop_end = false
  611.       while loop_end == false
  612.         if @visible_index != @main_window.data.size - 1
  613.           @visible_index += 1
  614.         else
  615.           @visible_index = 0
  616.         end
  617.         loop_end = true if @main_window.show?(@main_window.data[@visible_index])
  618.       end
  619.       id = @main_window.data[@visible_index]
  620.       @info_window.refresh(id)
  621.       @comment_window.refresh(id) if @comment_window != nil
  622.       return
  623.     end
  624.   end
  625. end
Expand to see the code.



This is the Book Comment function itself.
  1. # å›³é‘‘ã‚³ãƒ¡ãƒ³ãƒˆæ©Ÿèƒ½è¿½åŠ (基本)
  2. #
  3. # å›³é‘‘ã«ã‚³ãƒ¡ãƒ³ãƒˆæ©Ÿèƒ½ã‚’ä½¿ã„ã™ã‚‹ã®ã«å¿…é ˆã§ã™ã€‚
  4. #
  5. # 2005.9.19
  6. # ウィンドウの不透明度、フォントと文字色を指定可能に。
  7.  
  8. class Window_Book_Comment < Window_Base
  9.   #--------------------------------------------------------------------------
  10.   #  — オブジェクト初期化
  11.   #--------------------------------------------------------------------------
  12.   def initialize(x, y, width, height)
  13.     super(x, y, width, height)
  14.     self.contents = Bitmap.new(width - 32, height - 32)
  15.     self.opacity = self.window_opa
  16.     self.contents.font.name = self.font_name
  17.     self.contents.font.color = self.font_color
  18.   end
  19.   #--------------------------------------------------------------------------
  20.   #  — 文字列変換
  21.   #--------------------------------------------------------------------------
  22.   def transfer(str)
  23.     text = str.clone
  24.     # 制御文字処理
  25.     begin
  26.     text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  27.     end
  28.     text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  29.       $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  30.     end
  31.     # 便宜上、"\\\\" ã‚’ "\000" に変換
  32.     text.gsub!(/\\\\/) { "\000" }
  33.     # "\\C" ã‚’ "\001" に、"\\G" ã‚’ "\002" に変換
  34.     text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  35.     text.gsub!(/\\[Gg]/) { "\002" }
  36.     # 不透明度
  37.     text.gsub!(/\\[Oo]\[([0-9]+)\]/) { "\200[#{$1}]" }
  38.     # 文字サイズ
  39.     text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "\201[#{$1}]" }
  40.     # ルビ
  41.     text.gsub!(/\\[Rr]\[(.+?),(.+?)\]/) { "\202[#{$1},#{$2}]" }
  42.     # ピクチャ表示
  43.     text.gsub!(/\\[Pp]ic\[([0-9]+),([0-9]+),([^,\]]+)\]/) { "\250[#{$1},#{$2},#{$3}]" }
  44.     # バトラー表示
  45.     text.gsub!(/\\[Bb]at\[([0-9]+),([0-9]+),([^,\]]+),([0-9]+)\]/) { "\251[#{$1},#{$2},#{$3},#{$4}]" }
  46.     # キャラグラフィック表示
  47.     text.gsub!(/\\[Cc]ha\[([0-9]+),([0-9]+),([^,\]]+),([0-9]+),([0-9]+),([0-9]+)\]/) { "\252[#{$1},#{$2},#{$3},#{$4},#{$5},#{$6}]" }
  48.    
  49.     return text
  50.   end
  51.   #--------------------------------------------------------------------------
  52.   #  — 変換した文字列を描画
  53.   #--------------------------------------------------------------------------
  54.   def draw_ex_text(ox, oy, str, align=0)
  55.     text = str.clone
  56.     x = 0
  57.     y = 0
  58.     # c に 1 文字を取得 (文字が取得できなくなるまでループ)
  59.     while ((c = text.slice!(/./m)) != nil)
  60.       # \\ ã®å ´åˆ
  61.       if c == "\000"
  62.         # 本来の文字に戻す
  63.         c = "\\"
  64.       end
  65.       # \C[n] ã®å ´åˆ
  66.       if c == "\001"
  67.         # 文字色を変更
  68.         text.sub!(/\[([0-9]+)\]/, "")
  69.         color = $1.to_i
  70.         if color >= 0 and color <= 7
  71.           self.contents.font.color = text_color(color)
  72.         end
  73.         # 次の文字へ
  74.         next
  75.       end
  76.       # \G ã®å ´åˆ
  77.       if c == "\002"
  78.         # 所持ゴールドに変換
  79.         c = $game_party.gold.to_s
  80.         # 文字を描画
  81.         self.contents.draw_text(ox+4+x, oy+4+ 32 * y, self.contents.text_size(c).width, 32, c)
  82.         # x ã«æç”»ã—ãŸæ–‡å­—ã®å¹…ã‚’åŠ ç®—
  83.         x += self.contents.text_size(c).width
  84.         # 次の文字へ
  85.         next
  86.       end
  87.      
  88.       # \O ã®å ´åˆ
  89.       if c == "\200"
  90.         text.sub!(/\[([0-9]+)\]/, "")
  91.         opacity = $1.to_i
  92.         temp = self.contents.font.color
  93.         self.contents.font.color = Color.new(temp.red, temp.green, temp.blue, opacity)
  94.         # 次の文字へ
  95.         next
  96.       end
  97.       # \H ã®å ´åˆ
  98.       if c == "\201"
  99.         text.sub!(/\[([0-9]+)\]/, "")
  100.         self.contents.font.size = [[$1.to_i, 6].max, 32].min
  101.         # 次の文字へ
  102.         next
  103.       end
  104.       # \R ã®å ´åˆ
  105.       if c == "\202"
  106.         text.sub!(/\[(.+?),(.+?)\]/, "")
  107.         x += ruby_set(ox+x,oy+(y*32),$1,$2)
  108.         # 次の文字へ
  109.         next
  110.       end
  111.       # \Pic ã®å ´åˆ
  112.       if c == "\250"
  113.         text.sub!(/\[([0-9]+),([0-9]+),([^,\]]+)\]/, "")
  114.         ope = self.contents.font.color.alpha
  115.         set_picture($1.to_i, $2.to_i, $3, ope)
  116.         # 次の文字へ
  117.         next
  118.       end
  119.       # \Bat ã®å ´åˆ
  120.       if c == "\251"
  121.         text.sub!(/\[([0-9]+),([0-9]+),([^,\]]+),([0-9]+)\]/, "")
  122.         ope = self.contents.font.color.alpha
  123.         set_battler($1.to_i, $2.to_i, $3, $4.to_i, ope)
  124.         # 次の文字へ
  125.         next
  126.       end
  127.       # \Cha ã®å ´åˆ
  128.       if c == "\252"
  129.         text.sub!(/\[([0-9]+),([0-9]+),([^,\]]+),([0-9]+),([0-9]+),([0-9]+)\]/, "")
  130.         ope = self.contents.font.color.alpha
  131.         set_character($1.to_i, $2.to_i, $3, $4.to_i, $5.to_i, $6.to_i, ope)
  132.         # 次の文字へ
  133.         next
  134.       end
  135.       # æ”¹è¡Œæ–‡å­—ã®å ´åˆ
  136.       if c == "\n"
  137.         # y に 1 ã‚’åŠ ç®—
  138.         y += 1
  139.         x = 0
  140.         # 次の文字へ
  141.         next
  142.       end
  143.       # 文字を描画
  144.       self.contents.draw_text(ox+4+x, 4+oy+ 32 * y, 40, 32, c)
  145.       # x ã«æç”»ã—ãŸæ–‡å­—ã®å¹…ã‚’åŠ ç®—
  146.       x += self.contents.text_size(c).width
  147.     end
  148.   end
  149.   #--------------------------------------------------------------------------
  150.   #  — ルビ描画
  151.   #--------------------------------------------------------------------------
  152.   def ruby_set(x,y,str,ruby)
  153.     text_w = self.contents.text_size(str).width
  154.     text_h = self.contents.text_size(str).height
  155.     f_size_back = self.contents.font.size
  156.     ruby_size = 10
  157.     self.contents.font.size = ruby_size
  158.     ruby_w = self.contents.text_size(ruby).width
  159.     self.contents.draw_text(4+x, 4+4+y-ruby_size+1, text_w, ruby_size, ruby, 1)
  160.     self.contents.font.size = f_size_back
  161.     self.contents.draw_text(4+x, 4+4+y, text_w, text_h, str)
  162.     return text_w
  163.   end
  164.   #--------------------------------------------------------------------------
  165.   #  — ピクチャー描画
  166.   #--------------------------------------------------------------------------
  167.   def set_picture(x, y, filename, opacity=255)
  168.     bitmap = RPG::Cache.picture(filename)
  169.     self.contents.blt(x, y, bitmap, bitmap.rect, opacity)
  170.   end
  171.   #--------------------------------------------------------------------------
  172.   #  — バトラー描画
  173.   #--------------------------------------------------------------------------
  174.   def set_battler(x, y, filename, hue, opacity=255)
  175.     bitmap =RPG::Cache.battler(filename, hue)
  176.     self.contents.blt(x, y, bitmap, bitmap.rect, opacity)
  177.   end
  178.   #--------------------------------------------------------------------------
  179.   #  — キャラクター描画
  180.   #--------------------------------------------------------------------------
  181.   def set_character(x, y, filename, hue, dir, pat, opacity=255)
  182.     bitmap = RPG::Cache.character(filename, hue)
  183.     cw = bitmap.width / 4
  184.     ch = bitmap.height / 4
  185.     cy = ch * (dir / 2 - 1)
  186.     cx = cw * (pat - 1)
  187.     src_rect = Rect.new(cx, cy, cw, ch)
  188.     self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect, opacity)
  189.   end
  190.   def window_opa
  191.   end
  192.   def font_name
  193.   end
  194.   def font_color
  195.   end
  196. end
Expand to see the code.


This is where you put your comments for monsters. Change
  1. # å›³é‘‘ã‚³ãƒ¡ãƒ³ãƒˆæ©Ÿèƒ½è¿½åŠ (魔物図鑑)
  2. #
  3. # コメントには冒険日記と同様の制御文字が使用可能です。
  4. # 詳しくは冒険日記の方をご覧下さい。
  5. #
  6. # 2005.9.19
  7. # ウィンドウの不透明度、フォントと文字色を指定可能に。
  8.  
  9. module MoMo_M_Book_Comment
  10.   # コメントウィンドウの横幅
  11.   C_WINDOW_WIDTH = 640
  12.   # コメントウィンドウの縦幅
  13.   C_WINDOW_HEIGHT = 128
  14.   # コメントウィンドウのX座標
  15.   C_WINDOW_X = 0
  16.   # コメントウィンドウのY座標
  17.   C_WINDOW_Y = 352
  18.   # コメントウィンドウの不透明度
  19.   C_WINDOW_OPA = 255
  20.   # 使用するフォント名(å¸Œæœ›é †ã«é…åˆ—ã«è¿½åŠ ã—ã¦ãã ã•ã„)
  21.   C_WINDOW_FONT_NAME = ["Tahoma"]
  22.   # 使用する文字色
  23.   # Color.new(赤の値, 緑の値, 青の値, 不透明度)  €»0~255まで
  24.   C_WINDOW_FONT_COLOR = Color.new(255, 255, 255, 255)
  25. end
  26.  
  27. class Window_Monster_Book_Comment < Window_Book_Comment
  28.   def initialize
  29.     x = MoMo_M_Book_Comment::C_WINDOW_X
  30.     y = MoMo_M_Book_Comment::C_WINDOW_Y
  31.     width = MoMo_M_Book_Comment::C_WINDOW_WIDTH
  32.     height = MoMo_M_Book_Comment::C_WINDOW_HEIGHT
  33.     super(x, y, width, height)
  34.   end
  35.   def draw_comment(id)
  36.     self.contents.clear
  37.     comment = get_comment(id)
  38.     draw_ex_text(0, 0, transfer(comment))
  39.   end
  40.   def get_comment(id)
  41.     return comment_set[0] if comment_set[id] == nil
  42.     return comment_set[id]
  43.   end
  44.   def comment_set
  45.     return MoMo_M_Book_Comment::M_BOOK_COMMENT
  46.   end
  47.   def refresh(id)
  48.     draw_comment(id)
  49.   end
  50.   def window_opa
  51.     return MoMo_M_Book_Comment::C_WINDOW_OPA
  52.   end
  53.   def font_name
  54.     return MoMo_M_Book_Comment::C_WINDOW_FONT_NAME
  55.   end
  56.   def font_color
  57.     return MoMo_M_Book_Comment::C_WINDOW_FONT_COLOR
  58.   end
  59. end
  60.  
  61. module MoMo_M_Book_Comment
  62.   str = []
  63.     # str[エネミーID]
  64.     str[0] = <<-EOS #デフォ(コメント未設定時用、通常は使用しない)
  65. コメントな~し!
  66.     EOS
  67.     str[1] = <<-EOS #ゴースト
  68. Put your monster comment here!
  69.     EOS
  70.     str[2] = <<-EOS #ゴースト
  71. Put your next monster comment here!
  72.     EOS
  73.  
  74.     M_BOOK_COMMENT = str
  75. end
Expand to see the code.


See? Each number next to "str" is your monster's number in the database. To call the beastiary, use this in an event:
  1. $scene = Scene_MonsterBook.new
Expand to see the code.


Also, to change the name of the Beastiary, just go to Line 468 in the first script, and change the words in quotes to whatever you want.

That's about it! You can post questions on this here! I must have some kind of coding angel or something, cause I can't script for beans, and I figured out this thing! Even I don't know how I did it! If I forgot anything, I'm sorry. This is the first script I've posted.


How do you use the Call Script event command to add an enemy's info into the in-game Bestiary without having to battle and defeat that enemy?

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=69468