Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Comment Function for Momo's Beastiary: I Figured it Out!

Status
Not open for further replies.

Teej

Member

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.
Code:
#魔物図鑑
#
#エネミーの遭遇情報は、戦闘終了時(経験値などを獲得する所)で追加されます。
#よって、敵から逃げた場合や負けイベントでの戦闘敗北などでは
#図鑑に登録されません。
#このタイミングを変えたい場合は各自書き換えて下さい。
#(class Scene_Battle の start_phase5 で追加してます。)
#
#また、所々「アナライズ」という単語がありますが、
#現在、この魔物辞典だけでは機能しておりません。(自ゲームでの名残)
#Window_MonsterBook_Info の DROP_ITEM_NEED_ANALYZE が true になっていると
#ドロップアイテムが表示されなくなりますので、通常は false にしておいて下さい。
#
#注意
#このまま使うと、データベースのトループの1番に
#何も設定していないと、エラー吐きます。
#対処策としては
#1.素直にデータベースのトループの1番に何でもいいから設定する。
#2.Game_Enemy_Book の 「super(1, 0)#ダミー」 の左側の数字の部分を
#  存在するトループIDに書き換える。
#のどちらかになります。
#
#2005.2.6 機能追加
#図鑑完成度の表示機能を追加
#SHOW_COMPLETE_TYPE で設定できます。
#イベントコマンドの「スクリプト」で
#$game_party.enemy_book_max で図鑑の総魔物数(最大数)
#$game_party.enemy_book_now で図鑑の現在登録数(現在数)
#$game_party.complete_percentage で図鑑の完成率(小数点切捨て)
#を取得できます。
#
#2005.2.17
#complete_percentageのメソッド名を
#enemy_book_complete_percentageに変更(他の図鑑と区別できるように)
#イベントコマンドの「スクリプト」で最大数等の取得を短縮できるようになりました。
#enemy_book_max で図鑑の総魔物数(最大数)
#enemy_book_now で図鑑の現在登録数(現在数)
#enemy_book_compで図鑑の完成率(小数点切捨て)
#
#2005.2.18 バグ修正
#complete_percentageのメソッド名を
#enemy_book_complete_percentageに変更したのに
#complete_percentageって呼び出してました。(単なる書き換え漏れですね)
#
#2005.7.4 機能追加
#コメント機能に対応。
#全体的に色々いじりました。
#
#2005.7.4 バグ修正
#細かいバグを修正。


module Enemy_Book_Config
  #ドロップアイテム表示にアナライズが必要かどうか
  DROP_ITEM_NEED_ANALYZE = false 
  #回避修正の名前
  EVA_NAME = "回避"              
  #図鑑完成率の表示方法
  #0:表示なし 1:現在数/最大数 2:%表示 3:両方
  SHOW_COMPLETE_TYPE = 3         
  #コメント機能を使うかどうか(要・コメント追加スクリプト導入)
  COMMENT_SYSTEM = true
end

class Game_Temp
  attr_accessor :enemy_book_data
  alias temp_enemy_book_data_initialize initialize
  def initialize
    temp_enemy_book_data_initialize
    @enemy_book_data = Data_MonsterBook.new
  end
end

class Game_Party
  attr_accessor :enemy_info               # 出会った敵情報(図鑑用)
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  alias book_info_initialize initialize
  def initialize
    book_info_initialize
    @enemy_info = {}
  end
  #--------------------------------------------------------------------------
  # ● エネミー情報の追加(図鑑用)
  #     type : 通常遭遇かアナライズか 0:通常 1:アナライズ -1:情報削除
  #     0:無遭遇 1:遭遇済 2:アナライズ済
  #--------------------------------------------------------------------------
  def add_enemy_info(enemy_id, type = 0)
    case type
    when 0
      if @enemy_info[enemy_id] == 2
        return false
      end
      @enemy_info[enemy_id] = 1
    when 1
      @enemy_info[enemy_id] = 2
    when -1
      @enemy_info[enemy_id] = 0
    end
  end
  #--------------------------------------------------------------------------
  # ● 魔物図鑑の最大登録数を取得
  #--------------------------------------------------------------------------
  def enemy_book_max
    return $game_temp.enemy_book_data.id_data.size - 1
  end
  #--------------------------------------------------------------------------
  # ● 魔物図鑑の現在登録数を取得
  #--------------------------------------------------------------------------
  def enemy_book_now
    now_enemy_info = @enemy_info.keys
    # 登録無視の属性IDを取得
    no_add = $game_temp.enemy_book_data.no_add_element
    new_enemy_info = []
    for i in now_enemy_info
      enemy = $data_enemies[i]
      next if enemy.name == ""
      if enemy.element_ranks[no_add] == 1
        next
      end
      new_enemy_info.push(enemy.id)
    end
    return new_enemy_info.size
  end
  #--------------------------------------------------------------------------
  # ● 魔物図鑑の完成率を取得
end

class Interpreter
  def enemy_book_max
    return $game_party.enemy_book_max
  end
  def enemy_book_now
    return $game_party.enemy_book_now
  end
  def enemy_book_comp
    return $game_party.enemy_book_complete_percentage
  end
end

class Scene_Battle
  alias add_enemy_info_start_phase5 start_phase5
  def start_phase5
    for enemy in $game_troop.enemies
      # エネミーが隠れ状態でない場合
      unless enemy.hidden
        # 敵遭遇情報追加
        $game_party.add_enemy_info(enemy.id, 0)
      end
    end
    add_enemy_info_start_phase5
  end
end

class Window_Base < Window
  #--------------------------------------------------------------------------
  # ● エネミーの戦闘後獲得アイテムの描画
  #--------------------------------------------------------------------------
  def draw_enemy_drop_item(enemy, x, y)
    self.contents.font.color = normal_color
    treasures = []
    if enemy.item_id > 0
      treasures.push($data_items[enemy.item_id])
    end
    if enemy.weapon_id > 0
      treasures.push($data_weapons[enemy.weapon_id])
    end
    if enemy.armor_id > 0
      treasures.push($data_armors[enemy.armor_id])
    end
    # 現状ではとりあえず1つのみ描画
    if treasures.size > 0
      item = treasures[0]
      bitmap = RPG::Cache.icon(item.icon_name)
      opacity = 255
      self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
      name = treasures[0].name
    else
      self.contents.font.color = disabled_color
      name = "No Item"
    end
    self.contents.draw_text(x+28, y, 212, 32, name)
  end
  #--------------------------------------------------------------------------
  # ● エネミーの図鑑IDの描画
  #--------------------------------------------------------------------------
  def draw_enemy_book_id(enemy, x, y)
    self.contents.font.color = normal_color
    id = $game_temp.enemy_book_data.id_data.index(enemy.id)
    self.contents.draw_text(x, y, 32, 32, id.to_s)
  end
  #--------------------------------------------------------------------------
  # ● エネミーの名前の描画
  #     enemy : エネミー
  #     x     : 描画先 X 座標
  #     y     : 描画先 Y 座標
  #--------------------------------------------------------------------------
  def draw_enemy_name(enemy, x, y)
    self.contents.font.color = normal_color
    self.contents.draw_text(x, y, 152, 32, enemy.name)
  end
  #--------------------------------------------------------------------------
  # ● エネミーグラフィックの描画(アナライズ)
  #     enemy : エネミー
  #     x     : 描画先 X 座標
  #     y     : 描画先 Y 座標
  #--------------------------------------------------------------------------
  def draw_enemy_graphic(enemy, x, y, opacity = 255)
    bitmap = RPG::Cache.battler(enemy.battler_name, enemy.battler_hue)
    cw = bitmap.width
    ch = bitmap.height
    src_rect = Rect.new(0, 0, cw, ch)
    x = x + (cw / 2 - x) if cw / 2 > x
    self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect, opacity)
  end
  #--------------------------------------------------------------------------
  # ● エネミーの獲得EXPの描画
  #     enemy : エネミー
  #     x     : 描画先 X 座標
  #     y     : 描画先 Y 座標
  #--------------------------------------------------------------------------
  def draw_enemy_exp(enemy, x, y)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 120, 32, "EXP")
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 120, y, 36, 32, enemy.exp.to_s, 2)
  end
  #--------------------------------------------------------------------------
  # ● エネミーの獲得GOLDの描画
  #     enemy : エネミー
  #     x     : 描画先 X 座標
  #     y     : 描画先 Y 座標
  #--------------------------------------------------------------------------
  def draw_enemy_gold(enemy, x, y)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 120, 32, $data_system.words.gold)
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 120, y, 36, 32, enemy.gold.to_s, 2)
  end
end

class Game_Enemy_Book < Game_Enemy
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(enemy_id)
    super(1, 0)#ダミー
    @enemy_id = enemy_id
    enemy = $data_enemies[@enemy_id]
    @battler_name = enemy.battler_name
    @battler_hue = enemy.battler_hue
    @hp = maxhp
    @sp = maxsp
  end
end

class Data_MonsterBook
  attr_reader :id_data
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    @id_data = enemy_book_id_set
  end
  #--------------------------------------------------------------------------
  # ● 図鑑用登録無視属性取得
  #--------------------------------------------------------------------------
  def no_add_element
    no_add = 0
    # 登録無視の属性IDを取得
    for i in 1...$data_system.elements.size
      if $data_system.elements[i] =~ /図鑑登録無効/
        no_add = i
        break
      end
    end
    return no_add
  end
  #--------------------------------------------------------------------------
  # ● 図鑑用敵ID設定
  #--------------------------------------------------------------------------
  def enemy_book_id_set
    data = [0]
    no_add = no_add_element
    # 登録無視の属性IDを取得
    for i in 1...$data_enemies.size
      enemy = $data_enemies[i]
      next if enemy.name == ""
      if enemy.element_ranks[no_add] == 1
        next
      end
      data.push(enemy.id)
    end
    return data
  end
end


class Window_MonsterBook < Window_Selectable
  attr_reader   :data
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(index=0)
    super(0, 64, 640, 416)
    @column_max = 2
    @book_data = $game_temp.enemy_book_data
    @data = @book_data.id_data.dup
    @data.shift
    #@data.sort!
    @item_max = @data.size
    self.index = 0
    refresh if @item_max > 0
  end
  #--------------------------------------------------------------------------
  # ● 遭遇データを取得
  #--------------------------------------------------------------------------
  def data_set
    data = $game_party.enemy_info.keys
    data.sort!
    newdata = []
    for i in data
      next if $game_party.enemy_info[i] == 0
      # 図鑑登録無視を考慮
      if book_id(i) != nil
        newdata.push(i)
      end
    end
    return newdata
  end
  #--------------------------------------------------------------------------
  # ● 表示許可取得
  #--------------------------------------------------------------------------
  def show?(id)
    if $game_party.enemy_info[id] == 0 or $game_party.enemy_info[id] == nil
      return false
    else
      return true
    end
  end
  #--------------------------------------------------------------------------
  # ● 図鑑用ID取得
  #--------------------------------------------------------------------------
  def book_id(id)
    return @book_data.index(id)
  end
  #--------------------------------------------------------------------------
  # ● エネミー取得
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    self.contents = Bitmap.new(width - 32, row_max * 32)
    #項目数が 0 でなければビットマップを作成し、全項目を描画
    if @item_max > 0
      for i in 0...@item_max
       draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 項目の描画
  #     index : 項目番号
  #--------------------------------------------------------------------------
  def draw_item(index)
    enemy = $data_enemies[@data[index]]
    return if enemy == nil
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.font.color = normal_color
    draw_enemy_book_id(enemy, x, y)
    if show?(enemy.id)
      self.contents.draw_text(x + 28+16, y, 212, 32, enemy.name, 0)
    else
      self.contents.draw_text(x + 28+16, y, 212, 32, "-----", 0)
      return
    end
    if analyze?(@data[index])
      self.contents.font.color = text_color(3)
      self.contents.draw_text(x + 256, y, 24, 32, "済", 2)
    end
  end
  #--------------------------------------------------------------------------
  # ● アナライズ済かどうか
  #--------------------------------------------------------------------------
  def analyze?(enemy_id)
    if $game_party.enemy_info[enemy_id] == 2
      return true
    else
      return false
    end
  end
end


class Window_MonsterBook_Info < Window_Base
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0+64, 640, 480-64)
    self.contents = Bitmap.new(width - 32, height - 32)
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh(enemy_id)
    self.contents.clear
    self.contents.font.size = 22
    enemy = Game_Enemy_Book.new(enemy_id)
    draw_enemy_graphic(enemy, 96, 240+48+64, 200)
    draw_enemy_book_id(enemy, 4, 0)
    draw_enemy_name(enemy, 48, 0)
    draw_actor_hp(enemy, 288, 0)
    draw_actor_sp(enemy, 288+160, 0)
    draw_actor_parameter(enemy, 288    ,  32, 0)
    self.contents.font.color = system_color
    self.contents.draw_text(288+160, 32, 120, 32, Enemy_Book_Config::EVA_NAME)
    self.contents.font.color = normal_color
    self.contents.draw_text(288+160 + 120, 32, 36, 32, enemy.eva.to_s, 2)
    draw_actor_parameter(enemy, 288    ,  64, 3)
    draw_actor_parameter(enemy, 288+160,  64, 4)
    draw_actor_parameter(enemy, 288    ,  96, 5)
    draw_actor_parameter(enemy, 288+160,  96, 6)
    draw_actor_parameter(enemy, 288    , 128, 1)
    draw_actor_parameter(enemy, 288+160, 128, 2)
    draw_enemy_exp(enemy, 288, 160)
    draw_enemy_gold(enemy, 288+160, 160)
    if analyze?(enemy.id) or !Enemy_Book_Config::DROP_ITEM_NEED_ANALYZE
      self.contents.draw_text(288, 192, 96, 32, "Drop Item")
      draw_enemy_drop_item(enemy, 288+96+4, 192)
      self.contents.font.color = normal_color
      #draw_element_guard(enemy, 320-32, 160-16+96)
    end
  end
  #--------------------------------------------------------------------------
  # ● アナライズ済かどうか
  #--------------------------------------------------------------------------
  def analyze?(enemy_id)
    if $game_party.enemy_info[enemy_id] == 2
      return true
    else
      return false
    end
  end
end


class Scene_MonsterBook
  #--------------------------------------------------------------------------
  # ● メイン処理
  #--------------------------------------------------------------------------
  def main
    $game_temp.enemy_book_data = Data_MonsterBook.new
    # ウィンドウを作成
    @title_window = Window_Base.new(0, 0, 640, 64)
    @title_window.contents = Bitmap.new(640 - 32, 64 - 32)
    @title_window.contents.draw_text(4, 0, 320, 32, "Monster Information", 0)
    @main_window = Window_MonsterBook.new
    @main_window.active = true
    # インフォウィンドウを作成 (不可視・非アクティブに設定)
    @info_window = Window_MonsterBook_Info.new
    @info_window.z = 110
    @info_window.visible = false
    @info_window.active = false
    @visible_index = 0
    if Enemy_Book_Config::COMMENT_SYSTEM
      # コメントウィンドウを作成 (不可視・非アクティブに設定)
      @comment_window = Window_Monster_Book_Comment.new
      @comment_window.z = 120
      @comment_window.visible = false
      @comment_on = false # コメントフラグ
    end
    # トランジション実行
    Graphics.transition
    # メインループ
    loop do
      # ゲーム画面を更新
      Graphics.update
      # 入力情報を更新
      Input.update
      # フレーム更新
      update
      # 画面が切り替わったらループを中断
      if $scene != self
        break
      end
    end
    # トランジション準備
    Graphics.freeze
    # ウィンドウを解放
    @main_window.dispose
    @info_window.dispose
    @title_window.dispose
    @comment_window.dispose if @comment_window != nil
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    # ウィンドウを更新
    @main_window.update
    @info_window.update
    if @info_window.active
      update_info
      return
    end
    # メインウィンドウがアクティブの場合: update_target を呼ぶ
    if @main_window.active
      update_main
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (メインウィンドウがアクティブの場合)
  #--------------------------------------------------------------------------
  def update_main
    # B ボタンが押された場合
    if Input.trigger?(Input::B)
      # キャンセル SE を演奏
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
      return
    end
    # C ボタンが押された場合
    if Input.trigger?(Input::C)
      if @main_window.item == nil or @main_window.show?(@main_window.item) == false
        # ブザー SE を演奏
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # 決定 SE を演奏
      $game_system.se_play($data_system.decision_se)
      @main_window.active = false
      @info_window.active = true
      @info_window.visible = true
      @visible_index = @main_window.index
      @info_window.refresh(@main_window.item)
      if @comment_window != nil
        @comment_window.refresh(@main_window.item)
        if @comment_on
          @comment_window.visible = true
        else
          @comment_window.visible = false
        end
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (インフォウィンドウがアクティブの場合)
  #--------------------------------------------------------------------------
  def update_info
    # B ボタンが押された場合
    if Input.trigger?(Input::B)
      # キャンセル SE を演奏
      $game_system.se_play($data_system.cancel_se)
      @main_window.active = true
      @info_window.active = false
      @info_window.visible = false
      @comment_window.visible = false if @comment_window != nil
      return
    end
    # C ボタンが押された場合
    if Input.trigger?(Input::C)
      if @comment_window != nil
        # 決定 SE を演奏
        $game_system.se_play($data_system.decision_se)
        if @comment_on
          @comment_on = false
          @comment_window.visible = false
        else
          @comment_on = true
          @comment_window.visible = true
        end
        return
      end
    end
    if Input.trigger?(Input::L)
      # 決定 SE を演奏
      $game_system.se_play($data_system.decision_se)
      loop_end = false
      while loop_end == false
        if @visible_index != 0
          @visible_index -= 1
        else
          @visible_index = @main_window.data.size - 1
        end
        loop_end = true if @main_window.show?(@main_window.data[@visible_index])
      end
      id = @main_window.data[@visible_index]
      @info_window.refresh(id)
      @comment_window.refresh(id) if @comment_window != nil
      return
    end
    if Input.trigger?(Input::R)
      # 決定 SE を演奏
      $game_system.se_play($data_system.decision_se)
      loop_end = false
      while loop_end == false
        if @visible_index != @main_window.data.size - 1
          @visible_index += 1
        else
          @visible_index = 0
        end
        loop_end = true if @main_window.show?(@main_window.data[@visible_index])
      end
      id = @main_window.data[@visible_index]
      @info_window.refresh(id)
      @comment_window.refresh(id) if @comment_window != nil
      return
    end
  end
end

This is the Book Comment function itself.
Code:
# 図鑑コメント機能追加(基本)
#
# 図鑑にコメント機能を使いするのに必須です。
#
# 2005.9.19
# ウィンドウの不透明度、フォントと文字色を指定可能に。

class Window_Book_Comment < Window_Base
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    super(x, y, width, height)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = self.window_opa
    self.contents.font.name = self.font_name
    self.contents.font.color = self.font_color
  end
  #--------------------------------------------------------------------------
  # ● 文字列変換
  #--------------------------------------------------------------------------
  def transfer(str)
    text = str.clone
    # 制御文字処理
    begin
    text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
    end
    text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
      $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
    end
    # 便宜上、"\\\\" を "\000" に変換
    text.gsub!(/\\\\/) { "\000" }
    # "\\C" を "\001" に、"\\G" を "\002" に変換
    text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
    text.gsub!(/\\[Gg]/) { "\002" }
    # 不透明度
    text.gsub!(/\\[Oo]\[([0-9]+)\]/) { "\200[#{$1}]" }
    # 文字サイズ
    text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "\201[#{$1}]" }
    # ルビ
    text.gsub!(/\\[Rr]\[(.+?),(.+?)\]/) { "\202[#{$1},#{$2}]" }
    # ピクチャ表示
    text.gsub!(/\\[Pp]ic\[([0-9]+),([0-9]+),([^,\]]+)\]/) { "\250[#{$1},#{$2},#{$3}]" }
    # バトラー表示
    text.gsub!(/\\[Bb]at\[([0-9]+),([0-9]+),([^,\]]+),([0-9]+)\]/) { "\251[#{$1},#{$2},#{$3},#{$4}]" }
    # キャラグラフィック表示
    text.gsub!(/\\[Cc]ha\[([0-9]+),([0-9]+),([^,\]]+),([0-9]+),([0-9]+),([0-9]+)\]/) { "\252[#{$1},#{$2},#{$3},#{$4},#{$5},#{$6}]" }
    
    return text
  end
  #--------------------------------------------------------------------------
  # ● 変換した文字列を描画
  #--------------------------------------------------------------------------
  def draw_ex_text(ox, oy, str, align=0)
    text = str.clone
    x = 0
    y = 0
    # c に 1 文字を取得 (文字が取得できなくなるまでループ)
    while ((c = text.slice!(/./m)) != nil)
      # \\ の場合
      if c == "\000"
        # 本来の文字に戻す
        c = "\\"
      end
      # \C[n] の場合
      if c == "\001"
        # 文字色を変更
        text.sub!(/\[([0-9]+)\]/, "")
        color = $1.to_i
        if color >= 0 and color <= 7
          self.contents.font.color = text_color(color)
        end
        # 次の文字へ
        next
      end
      # \G の場合
      if c == "\002"
        # 所持ゴールドに変換
        c = $game_party.gold.to_s
        # 文字を描画
        self.contents.draw_text(ox+4+x, oy+4+ 32 * y, self.contents.text_size(c).width, 32, c)
        # x に描画した文字の幅を加算
        x += self.contents.text_size(c).width
        # 次の文字へ
        next
      end
      
      # \O の場合
      if c == "\200"
        text.sub!(/\[([0-9]+)\]/, "")
        opacity = $1.to_i
        temp = self.contents.font.color
        self.contents.font.color = Color.new(temp.red, temp.green, temp.blue, opacity)
        # 次の文字へ
        next
      end
      # \H の場合
      if c == "\201"
        text.sub!(/\[([0-9]+)\]/, "")
        self.contents.font.size = [[$1.to_i, 6].max, 32].min
        # 次の文字へ
        next
      end
      # \R の場合
      if c == "\202"
        text.sub!(/\[(.+?),(.+?)\]/, "")
        x += ruby_set(ox+x,oy+(y*32),$1,$2)
        # 次の文字へ
        next
      end
      # \Pic の場合
      if c == "\250"
        text.sub!(/\[([0-9]+),([0-9]+),([^,\]]+)\]/, "")
        ope = self.contents.font.color.alpha
        set_picture($1.to_i, $2.to_i, $3, ope)
        # 次の文字へ
        next
      end
      # \Bat の場合
      if c == "\251"
        text.sub!(/\[([0-9]+),([0-9]+),([^,\]]+),([0-9]+)\]/, "")
        ope = self.contents.font.color.alpha
        set_battler($1.to_i, $2.to_i, $3, $4.to_i, ope)
        # 次の文字へ
        next
      end
      # \Cha の場合
      if c == "\252"
        text.sub!(/\[([0-9]+),([0-9]+),([^,\]]+),([0-9]+),([0-9]+),([0-9]+)\]/, "")
        ope = self.contents.font.color.alpha
        set_character($1.to_i, $2.to_i, $3, $4.to_i, $5.to_i, $6.to_i, ope)
        # 次の文字へ
        next
      end
      # 改行文字の場合
      if c == "\n"
        # y に 1 を加算
        y += 1
        x = 0
        # 次の文字へ
        next
      end
      # 文字を描画
      self.contents.draw_text(ox+4+x, 4+oy+ 32 * y, 40, 32, c)
      # x に描画した文字の幅を加算
      x += self.contents.text_size(c).width
    end
  end
  #--------------------------------------------------------------------------
  # ● ルビ描画
  #--------------------------------------------------------------------------
  def ruby_set(x,y,str,ruby)
    text_w = self.contents.text_size(str).width
    text_h = self.contents.text_size(str).height
    f_size_back = self.contents.font.size
    ruby_size = 10
    self.contents.font.size = ruby_size
    ruby_w = self.contents.text_size(ruby).width
    self.contents.draw_text(4+x, 4+4+y-ruby_size+1, text_w, ruby_size, ruby, 1)
    self.contents.font.size = f_size_back
    self.contents.draw_text(4+x, 4+4+y, text_w, text_h, str)
    return text_w
  end
  #--------------------------------------------------------------------------
  # ● ピクチャー描画
  #--------------------------------------------------------------------------
  def set_picture(x, y, filename, opacity=255)
    bitmap = RPG::Cache.picture(filename)
    self.contents.blt(x, y, bitmap, bitmap.rect, opacity) 
  end
  #--------------------------------------------------------------------------
  # ● バトラー描画
  #--------------------------------------------------------------------------
  def set_battler(x, y, filename, hue, opacity=255)
    bitmap =RPG::Cache.battler(filename, hue)
    self.contents.blt(x, y, bitmap, bitmap.rect, opacity) 
  end
  #--------------------------------------------------------------------------
  # ● キャラクター描画
  #--------------------------------------------------------------------------
  def set_character(x, y, filename, hue, dir, pat, opacity=255)
    bitmap = RPG::Cache.character(filename, hue)
    cw = bitmap.width / 4
    ch = bitmap.height / 4
    cy = ch * (dir / 2 - 1)
    cx = cw * (pat - 1)
    src_rect = Rect.new(cx, cy, cw, ch)
    self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect, opacity)
  end
  def window_opa
  end
  def font_name
  end
  def font_color
  end
end

This is where you put your comments for monsters. Change
Code:
# 図鑑コメント機能追加(魔物図鑑)
#
# コメントには冒険日記と同様の制御文字が使用可能です。
# 詳しくは冒険日記の方をご覧下さい。
#
# 2005.9.19
# ウィンドウの不透明度、フォントと文字色を指定可能に。

module MoMo_M_Book_Comment
  # コメントウィンドウの横幅
  C_WINDOW_WIDTH = 640
  # コメントウィンドウの縦幅
  C_WINDOW_HEIGHT = 128
  # コメントウィンドウのX座標
  C_WINDOW_X = 0
  # コメントウィンドウのY座標
  C_WINDOW_Y = 352
  # コメントウィンドウの不透明度
  C_WINDOW_OPA = 255
  # 使用するフォント名(希望順に配列に追加してください)
  C_WINDOW_FONT_NAME = ["Tahoma"]
  # 使用する文字色
  # Color.new(赤の値, 緑の値, 青の値, 不透明度) ※0~255まで
  C_WINDOW_FONT_COLOR = Color.new(255, 255, 255, 255)
end

class Window_Monster_Book_Comment < Window_Book_Comment
  def initialize
    x = MoMo_M_Book_Comment::C_WINDOW_X
    y = MoMo_M_Book_Comment::C_WINDOW_Y
    width = MoMo_M_Book_Comment::C_WINDOW_WIDTH
    height = MoMo_M_Book_Comment::C_WINDOW_HEIGHT
    super(x, y, width, height)
  end
  def draw_comment(id)
    self.contents.clear
    comment = get_comment(id)
    draw_ex_text(0, 0, transfer(comment))
  end
  def get_comment(id)
    return comment_set[0] if comment_set[id] == nil
    return comment_set[id]
  end
  def comment_set
    return MoMo_M_Book_Comment::M_BOOK_COMMENT
  end
  def refresh(id)
    draw_comment(id)
  end
  def window_opa
    return MoMo_M_Book_Comment::C_WINDOW_OPA
  end
  def font_name
    return MoMo_M_Book_Comment::C_WINDOW_FONT_NAME
  end
  def font_color
    return MoMo_M_Book_Comment::C_WINDOW_FONT_COLOR
  end
end

module MoMo_M_Book_Comment
  str = []
    # str[エネミーID]
    str[0] = <<-EOS #デフォ(コメント未設定時用、通常は使用しない)
コメントな~し!
    EOS
    str[1] = <<-EOS #ゴースト
Put your monster comment here!
    EOS
    str[2] = <<-EOS #ゴースト
Put your next monster comment here!
    EOS

    M_BOOK_COMMENT = str
end

See? Each number next to "str" is your monster's number in the database. To call the beastiary, use this in an event:

Code:
$scene = Scene_MonsterBook.new

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.
 
I haven't tried it out yet, but congrats on figuring it out. Nice work Teej. I'll try it later, and if I have a problem, or any difficulty, I'll let you know. :)
 
I don't get how you write the comments. Can you show an example please? I know that str[0] would be the first enemy in the database, but where exactly do you put the comment?
 

Teej

Member

kaze950;110114 said:
I don't get how you write the comments. Can you show an example please? I know that str[0] would be the first enemy in the database, but where exactly do you put the comment?

str[0] is there for some other odd reason. Each number in the brackets corresponds to that monster's number in the database.

I almost forgot! For those who didn't know this, all the little squares in there are characters that your computer does not understand (Japanese). If you want to see what it says, you can copy/paste it into Babelfish at http://babelfish.altavista.com
 
Nice little extra feature I knew nothing about! I've been using this Bestiary script for a while, and having this added on is neat.

But it seems the total percentage is gone. It was whacked out on my project, saying stuff like 5/1240% or something, so it's not missed that much.

Anyway, it took me a little while to figure out how this stuff worked. First, I tried putting the second and third parts of the script above the main part, which didn't work, it seems they had to be below the main Bestiary script. Also, I didn't know how to display the enemy data...turns out you have to press C!
 

Teej

Member

Yeah, I had to remove the percentage thing, cause for some reason, the thing messed it up. I don't know why.
 

Vang

Member

Sorry, this may seem like a stupid question, but in the original demon book, how do you view it. Meaning, were in the game do you actauly see the information? In the esc menu?
 
Momomo's famous 'Bestiary' script (aka Demon Picture Book... literal translation) can be called from a map event or from a menu call if code it into your custom menu.

The actual call for it would be
Code:
$scene = Scene_MonsterBook.new

Now, when you use THIS script with Bestiary/Demon Picture Book, or a number of other 'Book' scripts by Momomo, when you have the page on screen (like looking at the 'Ghost' page for it's stats), pressing [Enter/Return] one more time brings up the comment window with the additional texts for the monster in question.

You DO have to turn the COMMENT_SYSTEM switch in Bestiary (or other Momomo scripts) to use this script.
 

Teej

Member

I don't know. I think if you change the amount of monsters in the database, it should change. Also, you have to start a new game to apply the changes. But I found it a little buggy, so I removed it from my final game.
 
The text does not appear for me with the use of this Bestiary. The Comment text DOES appear when I use of that feature, but the ordinary Beastiary information which includes the names and the stats do not appear. The only information that makes appearance is the enemy's picture and the item icon of whatever item is dropped.

I have tried SDK and without SDK so far.
 
Thanks Man I've been looking for somfin' Likes This!
Thnx To whoever Made it and thnx to whoeva publised it  :grin: :thumb: :thumb: :lol: and i Hope that this was the rite fourm (newbie)
 

Jason

Awesome Bro

Apparently, you've necroposted by over a year... why the bloody hell don't the new members read the rules ? o.O... They're getting stupider as they go along.
 
Status
Not open for further replies.

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top