查看: 4740|回复: 8

[已经解决] 关于VA的怪物图鉴

[复制链接]
梦石
0
星屑
239
在线时间
33 小时
注册时间
2018-11-9
回帖
9
发表于 2018-11-17 15:18:46 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
最近在论坛里捞到了怪物图鉴脚本,当然,找遍了论坛与贴吧,VA的怪物图鉴脚本我也只找到了这么一个。我想的是在图鉴里增加一下自己手写的怪物说明,希望有大佬能教教我。以下是脚本
核心部分
[pre lang="ruby"]
module Snstar
  module EnemyList
    # 敌人类型      0       1       2       3       4       5
    ENEMY_TYPE = ["异兽", "魔物", "精怪", "人形", "其他", "首领"]
    ENEMY_TYPE_DEFAULT = 4       # 敌人的默认类型
    ENCOUNTER_PERCENT = 1        # 敌人现身所提升的辨识度
    DEFEAT_PERCENT = 5           # 敌人战败所提升的辨识度
    TEST_PERCENT = 5             # 测试用调整的辨识度
    INCLUDE_ALL_CATEGORY = true  # 是否包含“全部”类型
    ALL_CATEGORY_TEXT = "全部"   # “全部”类型的文字
    ENEMY_MORE_INFO_BUTTON = :b  # 显示敌人更多资讯的按键
    ENEMY_MORE_INFO = true      # 是否显示更多讯息(扩充用)
   
    DRAW_ENEMY_ICON = false # 需要使用绘制单张图标才能使用
   
    # 敌人图像大小限定
    ENEMY_IMAGE_MAX_WIDTH = 170  # 敌人图像宽度限定
    ENEMY_IMAGE_MAX_HEIGHT = 192 # 敌人图像高度限定
    ENEMY_IMAGE_FOLDER = "Graphics/EnemyImages/" # 敌人指定图像资料夹
    ENEMY_HUE_SYNC_DB = false # 敌人指定图像是否使用资料库设定的色相
   
    # 文字设定
    ENEMY_LIST_COMMAND_TEXT = "真理图鉴" # 主选单命令用字
    ENEMY_LIST_SWITCH_ID    = 0        # 主选单命令显示的控制开关
    ENEMY_LIST_ENABLE_ID    = 0        # 主选单命令有效的控制开关
   
    ENEMY_PERCENT_VOCAB = "辨识度"   # 辨识度用字
    ENEMY_PERCENT_BASE_COLOR = Color.new(0, 255, 0)#Color.new(0, 0, 0)
    ENEMY_PERCENT_FILL_COLOR = Color.new(255, 255, 0)
    NO_DISPLAY_MASK = "??"         # 无法显示时的替代文字
    EST_DISPLAY_MASK = "大约是%s"    # 显示估算数值时的文字
    DROP_GOLD_VOCAB  = "携带金钱"
    DROP_ITEM_VOCAB  = "掉落物"
    FEA_WEAK_ELE_RATE = "弱点"    # 属性有效度 > 100% 的文字
    FEA_RES_ELE_RATE  = "抵抗"    # 属性有效度 < 100% 的文字
    FEA_DEBUFF_RATE   = "弱化属性"    # 弱化属性的文字
    FEA_ATK_ELEMENT   = "属性"    # 攻击附带属性的文字
   
    # 辨识度提升数值
    PERCENTAGE_ON_ENCOUNTER = 1 # 敌人现身时提升辨识度
    PERCENTAGE_ON_DEFEAT    =10 # 敌人落败时提升辨识度
   
    # 辨识度显示参数数值
    NAME_DISPLAY_PERC   = 1   # 名称显示百分比
    HP_EST_DISPLAY_PERC = 1   # HP估算显示百分比
    HP_DISPLAY_PERC     = 1  # HP显示百分比
    MP_EST_DISPLAY_PERC = 1  # MP估算显示百分比
    MP_DISPLAY_PERC     = 1  # MP显示百分比
    ATK_DISPLAY_PERC    = 50  # 攻击力显示百分比
    DEF_DISPLAY_PERC    = 50  # 防御力显示百分比
    MAT_DISPLAY_PERC    = 75  # 魔法攻击显示百分比
    MDF_DISPLAY_PERC    = 75  # 魔法防御显示百分比
    AGI_DISPLAY_PERC    = 75  # 敏捷显示百分比
    Level_DISPLAY_PERC    = 1  # 等级显示百分比
    GOLD_DISPLAY_PERC   = 100 # 掉落金钱显示百分比
    ITEM_DISPLAY_PERC   = 100 # 掉落物显示百分比
    #TYPE_BOSS
  end
end
class RPG::Enemy < RPG::BaseItem
  include Snstar::EnemyList
  def list_type
    self.note.split(/[\r\n]+/).each{ |line|
      if line =~ /\[(?:ltype) (\d+)\]/
        return $1 ? $1.to_i : ENEMY_TYPE_DEFAULT
      end}
    return ENEMY_TYPE_DEFAULT
  end
  def list_image
    self.note.split(/[\r\n]+/).each{ |line|
      if line =~ /\[(?:limage) (\S+)\]/
        return $1
      end}
    return nil # battler_name
  end
  def no_list?
    self.note.split(/[\r\n]+/).each{ |line|
      return true if line =~ /\[no_list\]/
      }
    return false
  end
end
class Game_Party < Game_Unit
  include Snstar::EnemyList
  #--------------------------------------------------------------------------
  # ● 初始化
  #--------------------------------------------------------------------------
  alias enemy_list_initialize initialize
  def initialize
    enemy_list_initialize
    @enemy_know_percentage=[]
    $data_enemies.each{ |e|
      next unless e
      set_enemy_percentage(e.id, 0)
    }
  end
  #--------------------------------------------------------------------------
  # ● 设置敌人百分比
  #--------------------------------------------------------------------------
  def set_enemy_percentage(e_id, percentage=100)
    temp_p = [[0, percentage].max ,100].min
    @enemy_know_percentage[e_id] = temp_p
  end
  #--------------------------------------------------------------------------
  # ● 获取敌人百分比
  #--------------------------------------------------------------------------
  def enemy_percent(e_id)
    return 0 unless seen_enemy?(e_id)
    return @enemy_know_percentage[e_id]
  end
  #--------------------------------------------------------------------------
  # ● 提升敌人百分比
  #--------------------------------------------------------------------------
  def see_enemy(e_id, percentage = 1)
    temp_p = @enemy_know_percentage[e_id] + percentage
    set_enemy_percentage(e_id, temp_p)
  end
  def know_enemy(e_id)
    set_enemy_percentage(e_id, 100)
  end
  #--------------------------------------------------------------------------
  # ● 判断是否见过敌人
  #--------------------------------------------------------------------------
  def seen_enemy?(e_id)
    return @enemy_know_percentage[e_id] > 0
  end
  #--------------------------------------------------------------------------
  # ● 判断是否熟知敌人
  #--------------------------------------------------------------------------
  def known_enemy?(e_id, percentage=100)
    return false unless seen_enemy?(e_id)
    return enemy_percent(e_id) == percentage
  end
  #--------------------------------------------------------------------------
  # ● 战斗开始提升辨识度
  #--------------------------------------------------------------------------
  alias enemy_list_on_battle_start on_battle_start
  def on_battle_start
    enemy_list_on_battle_start
    $game_troop.members.each{ |m|
      e_id = m.enemy.id
      see_enemy(e_id, ENCOUNTER_PERCENT)
    }
  end
end
class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # ● 敌人战败提升辨识度
  #--------------------------------------------------------------------------
  alias enemy_list_perform_collapse_effect perform_collapse_effect
  def perform_collapse_effect
    enemy_list_perform_collapse_effect
    $game_party.see_enemy(@enemy_id, Snstar::EnemyList::DEFEAT_PERCENT)
  end
end
class Game_Interpreter
  #--------------------------------------------------------------------------
  # ● 呼叫敌人图鉴场景
  #--------------------------------------------------------------------------
  def call_enemy_list
    SceneManager.call(Scene_List)
  end
  #--------------------------------------------------------------------------
  # ● 提升敌人辨识度
  #--------------------------------------------------------------------------
  def gain_enemy_percentage(e_id, per)
    $game_party.see_enemy(e_id, per)
  end
end
[/pre]
窗口部分
[pre lang="ruby"]
class Window_EnemyType < Window_HorzCommand
  include Snstar::EnemyList
  #--------------------------------------------------------------------------
  # ● 初始化
  #--------------------------------------------------------------------------
  def initialize(x, y, min_height=48)
    super(x, y)
    @min_height = min_height
    @max_height = window_height
  end
  #--------------------------------------------------------------------------
  # ● 定义窗口宽度
  #--------------------------------------------------------------------------
  def window_width
    Graphics.width
  end
  #--------------------------------------------------------------------------
  # ● 定义栏数
  #--------------------------------------------------------------------------
  def col_max
    return 6
  end
  #--------------------------------------------------------------------------
  # ● 窗口更新
  #--------------------------------------------------------------------------
  def update
    super
    @item_window.category = current_symbol if @item_window
  end
  #--------------------------------------------------------------------------
  # ● 绘制敌人类型列表
  #--------------------------------------------------------------------------
  def make_command_list
    add_command(ALL_CATEGORY_TEXT, :all) if INCLUDE_ALL_CATEGORY
    ENEMY_TYPE.each{ |type|
      add_command(type, type.to_sym)
    }
  end
  #--------------------------------------------------------------------------
  # ● 设置敌人列表窗口
  #--------------------------------------------------------------------------
  def item_window=(item_window)
    @item_window = item_window
    update
  end
  #--------------------------------------------------------------------------
  # ● 窗口有效化
  #--------------------------------------------------------------------------
  def activate
    super
    return unless @max_height
    self.height = @max_height
  end
  #--------------------------------------------------------------------------
  # ● 窗口失效
  #--------------------------------------------------------------------------
  def deactivate
    super
    return unless @min_height
    self.height = @min_height
    @item_window.select_last_index
  end
end
class Window_EnemyList < Window_ItemList
  include Snstar::EnemyList
  #--------------------------------------------------------------------------
  # ● 初始化
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    super(x, y, width, height)
    @last_index = {}
  end
  #--------------------------------------------------------------------------
  # ● 选择上次索引
  #--------------------------------------------------------------------------
  def select_last_index
    select(@last_index[@category])
  end
  def select(index)
    super(index)
    @info_window.enemy = @data[@index]
  end
  #--------------------------------------------------------------------------
  # ● 窗口失效
  #--------------------------------------------------------------------------
  def deactivate
    super
    return unless @last_index
    @last_index[@category] = @index # 纪录当前敌人类型的索引
  end
  #--------------------------------------------------------------------------
  # ● 最大栏数
  #--------------------------------------------------------------------------
  def col_max
    return 1
  end
  #--------------------------------------------------------------------------
  # ● 生成敌人列表
  #--------------------------------------------------------------------------
  def make_item_list
    @data = []
    @last_index[@category] = 0 if @last_index[@category].nil?
    selected_type = ENEMY_TYPE.index(@category.to_s)
    $data_enemies.each{ |enemy|
      next if enemy.nil?
      next if enemy.name == "" # 名字为空的敌人跳过
      next if enemy.no_list? # 指定不列入的敌人跳过
      if @category == :all or (enemy.list_type == selected_type)
        @data.push(enemy)
      end
    }
  end
  #--------------------------------------------------------------------------
  # ● 绘制敌人项目
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    if item
      rect = item_rect(index)
      rect.width -= 4
      draw_item_name(item, rect.x, rect.y)
    end
  end
  #--------------------------------------------------------------------------
  # ● 绘制敌人名称
  #--------------------------------------------------------------------------
  def draw_item_name(item, x, y, enabled = true, width = 172)
    return unless item
    if DRAW_ENEMY_ICON
      draw_icon(item.icon_index, x, y, enabled)
      x += 24
    end
    change_color(normal_color, enabled)
    per = $game_party.enemy_percent(item.id)
    if  per >= NAME_DISPLAY_PERC
      text = item.name
    else
      text = NO_DISPLAY_MASK
    end
    draw_text(x, y, width, line_height, text)
  end
  #--------------------------------------------------------------------------
  # ● 资讯窗口更新
  #--------------------------------------------------------------------------
  def update_info
    @info_window.set_item(item)
  end
  #--------------------------------------------------------------------------
  # ● 设置资讯窗口
  #--------------------------------------------------------------------------
  def info_window=(info_window)
    @info_window = info_window
    #call_update_info
  end
end
class Window_EnemyDetail < Window_Base
  include Snstar::EnemyList
  attr_reader :enemy
  #--------------------------------------------------------------------------
  # ● 初始化
  #--------------------------------------------------------------------------
  def initialize
    super(160, 48, Graphics.width-160, Graphics.height-48)
    @enemy = nil
  end
  #--------------------------------------------------------------------------
  # ● 设置当前敌人
  #--------------------------------------------------------------------------
  def enemy=(e)
    @enemy = e
    if enemy
      @percentage = $game_party.enemy_percent(e.id) # 获取当前敌人辨识度
    else
      @percentage = 0
    end
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 检查当前辨识度百分比
  #--------------------------------------------------------------------------
  def checkPercent?(per)
    return @percentage >= per
  end
  #--------------------------------------------------------------------------
  # ● 窗口刷新
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    return unless @enemy # 无敌人时返回
    return unless checkPercent?(NAME_DISPLAY_PERC) # 不显示名称时返回
    @partial = false
    draw_enemy_image(0, 0) # 绘制敌人图像
    draw_enemy_name(0, ENEMY_IMAGE_MAX_HEIGHT) # 绘制敌人名称
    draw_enemy_features(0, ENEMY_IMAGE_MAX_HEIGHT+line_height)
    draw_enemy_percentage(0, ENEMY_IMAGE_MAX_HEIGHT+line_height*5) # 绘制敌人辨识度
    partial_refresh
  end
  #--------------------------------------------------------------------------
  # ● 窗口半刷新
  #--------------------------------------------------------------------------
  def partial_refresh
    return unless @enemy # 无敌人时返回
    rect = Rect.new(ENEMY_IMAGE_MAX_WIDTH+8, 0,
      contents.width-(ENEMY_IMAGE_MAX_WIDTH+8), contents.height-line_height)
    contents.clear_rect(rect)
    if ENEMY_MORE_INFO && @partial
      Sound.play_cursor
      draw_other_info
      @partial = false
    else
      draw_enemy_hp(ENEMY_IMAGE_MAX_WIDTH+8, 0) # 绘制敌人体力
      draw_enemy_mp(ENEMY_IMAGE_MAX_WIDTH+8, line_height) # 绘制敌人魔力
      2.upto(7){ |n|
        draw_enemy_param(ENEMY_IMAGE_MAX_WIDTH+8, line_height*n, n) # 绘制敌人能力
      }
      draw_enemy_gold(ENEMY_IMAGE_MAX_WIDTH+8, line_height*8) # 绘制敌人掉落金
      draw_enemy_item(ENEMY_IMAGE_MAX_WIDTH+8, line_height*9) # 绘制敌人掉落物
      @partial = true
    end
  end
  #--------------------------------------------------------------------------
  # ● 绘制敌人特征
  #--------------------------------------------------------------------------
  def draw_enemy_features(x, y)
    fy = y
    for i in 0..4 do
      feature = @enemy.features
      next unless feature
      label, value = get_feature(feature)
      next if label==""
      change_color(system_color)
      draw_text(x, fy, text_width(label), line_height, label)
      change_color(normal_color)
      draw_text(x+72, fy, text_width(value), line_height, value)
      fy+=line_height
    end
  end
  #--------------------------------------------------------------------------
  # ● 获取敌人特征
  #--------------------------------------------------------------------------
  def get_feature(feature)
    code = feature.code
    id = feature.data_id
    value = feature.value
    return "", 0 unless [11, 31].include?(code)
    if code == 11
      if value < 1.0
        label = FEA_RES_ELE_RATE
      elsif value > 1.0
        label = FEA_WEAK_ELE_RATE
      else
        return "", 0
      end
      element = $data_system.elements[id]
      return_value = element + " #{value.truncate}倍"
    elsif code == 31
      label = FEA_ATK_ELEMENT
      return_value = $data_system.elements[id]
    end
    return label, return_value
  end
  #--------------------------------------------------------------------------
  # ● 绘制敌人图像
  #--------------------------------------------------------------------------
  def draw_enemy_image(x, y)
    image_name = @enemy.list_image # 获取指定图像
    if image_name.nil? # 指定图像为空时
      image = Cache.battler(@enemy.battler_name, @enemy.battler_hue) # 获取战斗图
    else
      hue = ENEMY_HUE_SYNC_DB ? @enemy.battler_hue : 0
      image = Cache.load_bitmap(ENEMY_IMAGE_FOLDER, image_name, hue) # 获取战斗图
    end
   
    ix = (image.width/2-ENEMY_IMAGE_MAX_WIDTH/2).abs  # 获取中心点
    # 敌人图像宽度在显示范围外
    if image.width > ENEMY_IMAGE_MAX_WIDTH
      # 居中对齐
      rx = ix
      cx = x
    # 敌人图像宽度在显示范围外
    else
      # 居中对齐
      rx = 0
      cx = ix
    end
    # 敌人图像高度在显示范围外
    if image.height > ENEMY_IMAGE_MAX_HEIGHT
      cy = y
    # 敌人图像高度在显示范围内
    else
      cy = ENEMY_IMAGE_MAX_HEIGHT - image.height - 8 # 向下对齐
    end
    rect = Rect.new(rx, 0, ENEMY_IMAGE_MAX_WIDTH, ENEMY_IMAGE_MAX_HEIGHT)
    contents.blt(cx, cy, image, rect, 255)
  end
  #--------------------------------------------------------------------------
  # ● 绘制敌人辨识度
  #--------------------------------------------------------------------------
  def draw_enemy_percentage(x, y)
    width = contents.width
    change_color(system_color)
    text = ENEMY_PERCENT_VOCAB
    draw_text(x, y, text_width(text), line_height, text)
    # 绘制辨识度进度槽
    draw_gauge(x+96, y, width - 96, @percentage.to_f/100,
      ENEMY_PERCENT_BASE_COLOR, ENEMY_PERCENT_FILL_COLOR)
    # 绘制百分比
    change_color(normal_color)
    text = "#{@percentage}%"
    draw_text(x+96, y, text_width(text), line_height, text)
  end
  #--------------------------------------------------------------------------
  # ● 绘制敌人名称
  #--------------------------------------------------------------------------
  def draw_enemy_name(x, y)
    change_color(system_color)
    text = "名称"
    draw_text(x, y, text_width(text), line_height, text)
    # 绘制名称
    change_color(normal_color)
    text = @enemy.name
    draw_text(x+72, y, text_width(text), line_height, text)
  end
  #--------------------------------------------------------------------------
  # ● 绘制敌人体力
  #--------------------------------------------------------------------------
  def draw_enemy_hp(x, y)
    change_color(system_color)
    text = Vocab::hp
    draw_text(x, y, 108, line_height, text)
    change_color(normal_color)
    hp = @enemy.params[0]
    # 判断显示百分比
    if checkPercent?(HP_DISPLAY_PERC)
      text = hp
    elsif checkPercent?(HP_EST_DISPLAY_PERC)
      # 计算体力约值
      ahp = [(hp/10) * 10 - @enemy.params[3], 10].max
      text = sprintf(EST_DISPLAY_MASK, ahp)
    else
      text = NO_DISPLAY_MASK
    end
    draw_text(x+72, y, text_width(text), line_height, text)
  end
  #--------------------------------------------------------------------------
  # ● 绘制敌人魔力
  #--------------------------------------------------------------------------
  def draw_enemy_mp(x, y)
    change_color(system_color)
    text = Vocab::mp
    draw_text(x, y, 108, line_height, text)
    change_color(normal_color)
    mp = @enemy.params[1]
    # 判断显示百分比
    if checkPercent?(MP_DISPLAY_PERC)
      text = mp
    elsif checkPercent?(MP_EST_DISPLAY_PERC)
      # 计算魔力约值
      amp = [(mp/10) * 10 - @enemy.params[5], @enemy.params[4], 5].max
      text = sprintf(EST_DISPLAY_MASK, amp)
    else
      text = NO_DISPLAY_MASK
    end
    draw_text(x+72, y, text_width(text), line_height, text)
  end
  #--------------------------------------------------------------------------
  # ● 绘制敌人能力值
  #--------------------------------------------------------------------------
  def draw_enemy_param(x, y, param_id)
    # 能力值ID为1或2时,调用绘制体力/魔力方法
    draw_enemy_hp(x, y) if param_id==0
    draw_enemy_mp(x, y) if param_id==1
    return if param_id < 2
    change_color(system_color)
    # 绘制能力值名称
    draw_text(x, y, 108, line_height, Vocab::param(param_id))
    change_color(normal_color)
    # 获取能力值百分比
    param_percent = [ATK_DISPLAY_PERC, DEF_DISPLAY_PERC, MAT_DISPLAY_PERC,
                     MDF_DISPLAY_PERC, AGI_DISPLAY_PERC, Level_DISPLAY_PERC ]
    # 判断显示百分比
    if checkPercent?(param_percent[param_id-2])
      text = @enemy.params[param_id]
    else
      text = NO_DISPLAY_MASK
    end
    draw_text(x+72, y, text_width(text), line_height, text)
  end
  #--------------------------------------------------------------------------
  # ● 绘制敌人掉落金钱
  #--------------------------------------------------------------------------
  def draw_enemy_gold(x, y)
    change_color(system_color)
    draw_text(x, y, 96, line_height, DROP_GOLD_VOCAB)
    change_color(normal_color)
    # 判断显示百分比
    if checkPercent?(GOLD_DISPLAY_PERC)
      draw_currency_value(@enemy.gold, Vocab.currency_unit, x+12, y, 108)
    else
      draw_text(x+72, y, 96, line_height, NO_DISPLAY_MASK)
    end
  end
  #--------------------------------------------------------------------------
  # ● 绘制敌人掉落物
  #--------------------------------------------------------------------------
  def draw_enemy_item(x, y)
    change_color(system_color)
    draw_text(x, y, 96, line_height, DROP_ITEM_VOCAB)
    change_color(normal_color)
    # 判断显示百分比
    if checkPercent?(ITEM_DISPLAY_PERC)
      nn_di = 0
      for i in 0..2 do
        di = item_object(@enemy.drop_items) # 获取掉落物物件
        if di
          ly = y+line_height*(nn_di+1) # 计算绘制高度
          draw_item_name(di, x+24, ly)
          nn_di += 1 # 计数器+1
        end
      end
      return if nn_di > 0 # 计数器大于0时返回
      draw_text(x+80, y, 96, line_height, "无")
    else
      draw_text(x+24, y+line_height, 96, line_height, NO_DISPLAY_MASK)
    end
  end
  #--------------------------------------------------------------------------
  # ● 计算敌人掉落物
  #--------------------------------------------------------------------------
  def item_object(drop_item)
    kind = drop_item.kind
    data_id = drop_item.data_id
    return $data_items  [data_id] if kind == 1
    return $data_weapons[data_id] if kind == 2
    return $data_armors [data_id] if kind == 3
    return nil
  end
  #--------------------------------------------------------------------------
  # ● 绘制其他资讯
  #--------------------------------------------------------------------------
  def draw_other_info
   
  end
  #--------------------------------------------------------------------------
  # ● 获得文字宽度
  #--------------------------------------------------------------------------
  def text_width(text)
    return text_size(text).width + 5
  end
end[/pre]
场景部分
[pre lang="ruby"]
class Scene_List < Scene_Base
  include Snstar::EnemyList
  #--------------------------------------------------------------------------
  # ● 场景开始
  #--------------------------------------------------------------------------
  def start
    super
    create_category_window
    create_list_window
    create_detail_window
  end
  #--------------------------------------------------------------------------
  # ● 创建敌人类型窗口
  #--------------------------------------------------------------------------
  def create_category_window
    @category_window = Window_EnemyType.new(0, 0)
    @category_window.set_handler(:ok,     method(:on_category_ok))
    @category_window.set_handler(:cancel, method(:return_scene))
    @category_window.viewport = @viewport
  end
  #--------------------------------------------------------------------------
  # ● 创建敌人列表窗口
  #--------------------------------------------------------------------------
  def create_list_window
    @list_window = Window_EnemyList.new(0, 48, 160, Graphics.height-48)
    @list_window.set_handler(:cancel, method(:on_list_cancel))
    @list_window.viewport = @viewport
    @category_window.item_window = @list_window
  end
  #--------------------------------------------------------------------------
  # ● 创建敌人讯息窗口
  #--------------------------------------------------------------------------
  def create_detail_window
    @detail_window = Window_EnemyDetail.new
    @list_window.info_window = @detail_window
  end
  #--------------------------------------------------------------------------
  # ● 选择类型完成
  #--------------------------------------------------------------------------
  def on_category_ok
    @list_window.activate
    @list_window.select_last
  end
  #--------------------------------------------------------------------------
  # ● 离开敌人列表
  #--------------------------------------------------------------------------
  def on_list_cancel
    @list_window.unselect
    @category_window.activate
  end
  #--------------------------------------------------------------------------
  # ● 场景更新
  #--------------------------------------------------------------------------
  def update
    super
    on_list_partial_refersh if Input.trigger?(ENEMY_MORE_INFO_BUTTON)
    enemy_percent_change(:left) if Input.trigger?(:LEFT)
    enemy_percent_change(:right) if Input.trigger?(:RIGHT)
  end
  #--------------------------------------------------------------------------
  # ● 敌人讯息半刷新
  #--------------------------------------------------------------------------
  def on_list_partial_refersh
    @detail_window.partial_refresh
  end
  #--------------------------------------------------------------------------
  # ● 更改敌人辨识度百分比(仅游戏测试时可用)
  #--------------------------------------------------------------------------
  def enemy_percent_change(sym)
    return unless $TEST
    return unless @list_window.active
    enemy = @detail_window.enemy
    return unless enemy
    $game_party.see_enemy(enemy.id, TEST_PERCENT) if sym == :right
    $game_party.see_enemy(enemy.id, -TEST_PERCENT) if sym == :left
    @list_window.refresh
    @detail_window.enemy = enemy
  end
end
class Window_MenuCommand < Window_Command
  include Snstar::EnemyList
  #--------------------------------------------------------------------------
  # ● 加入敌人图鉴命令
  #--------------------------------------------------------------------------
  alias enemy_list_add_original_commands add_original_commands
  def add_original_commands
    enemy_list_add_original_commands
    return unless ENEMY_LIST_SWITCH_ID==0 || $game_switches[ENEMY_LIST_SWITCH_ID]
    enabled = ENEMY_LIST_ENABLE_ID == 0 || $game_switches[ENEMY_LIST_ENABLE_ID]
    add_command(ENEMY_LIST_COMMAND_TEXT, :enemy_list, enabled)
  end
end
class Scene_Menu < Scene_MenuBase
  #--------------------------------------------------------------------------
  # ● 创建命令窗口
  #--------------------------------------------------------------------------
  alias enemy_list_create_command_window create_command_window
  def create_command_window
    enemy_list_create_command_window
    @command_window.set_handler(:enemy_list, method(:enemy_list_display))
  end
  #--------------------------------------------------------------------------
  # ● 呼叫敌人图鉴场景
  #--------------------------------------------------------------------------
  def enemy_list_display
    SceneManager.call(Scene_List)
  end
end[/pre]
梦石
0
星屑
600
在线时间
1118 小时
注册时间
2012-12-24
回帖
761
发表于 2018-11-17 16:21:54 | 显示全部楼层
本帖最后由 江户川洛奇 于 2018-11-17 16:44 编辑

不知道怎么传图片
是像附件这样的吗?
怪物说明什么的写在敌人的备注里
第一行用<note1:巴拉巴拉>
第二行用<note2:巴拉巴拉>
当然可以自己改用法啦
按A就可以切换到说明部分


核心脚本
[pre lang="ruby"]
module Snstar
  module EnemyList
    # 敌人类型          0              1          2      3        4          5   
    ENEMY_TYPE = ["异兽", "魔物", "精怪", "人形", "其他", "首领"]
    ENEMY_TYPE_DEFAULT = 4       # 敌人的默认类型
    ENCOUNTER_PERCENT = 1        # 敌人现身所提升的辨识度
    DEFEAT_PERCENT = 5           # 敌人战败所提升的辨识度
    TEST_PERCENT = 5             # 测试用调整的辨识度
    INCLUDE_ALL_CATEGORY = true  # 是否包含“全部”类型
    ALL_CATEGORY_TEXT = "全部"   # “全部”类型的文字
    ENEMY_MORE_INFO_BUTTON = :X  # 显示敌人更多资讯的按键
    ENEMY_MORE_INFO = true      # 是否显示更多讯息(扩充用)
   
    DRAW_ENEMY_ICON = false # 需要使用绘制单张图标才能使用
   
    # 敌人图像大小限定
    ENEMY_IMAGE_MAX_WIDTH = 170  # 敌人图像宽度限定
    ENEMY_IMAGE_MAX_HEIGHT = 192 # 敌人图像高度限定
    ENEMY_IMAGE_FOLDER = "Graphics/EnemyImages/" # 敌人指定图像资料夹
    ENEMY_HUE_SYNC_DB = false # 敌人指定图像是否使用资料库设定的色相
   
    # 文字设定
    ENEMY_LIST_COMMAND_TEXT = "敌人图鉴" # 主选单命令用字
    ENEMY_LIST_SWITCH_ID    = 0        # 主选单命令显示的控制开关
    ENEMY_LIST_ENABLE_ID    = 0        # 主选单命令有效的控制开关
   
    ENEMY_PERCENT_VOCAB = "辨识度"   # 辨识度用字
    ENEMY_PERCENT_BASE_COLOR = Color.new(0, 255, 0)#Color.new(0, 0, 0)
    ENEMY_PERCENT_FILL_COLOR = Color.new(255, 255, 0)
    NO_DISPLAY_MASK = "???"         # 无法显示时的替代文字
    EST_DISPLAY_MASK = "约%s"    # 显示估算数值时的文字
    DROP_GOLD_VOCAB  = "携带金钱"
    DROP_ITEM_VOCAB  = "掉落物"
    FEA_WEAK_ELE_RATE = "弱点"    # 属性有效度 > 100% 的文字
    FEA_RES_ELE_RATE  = "抵抗"    # 属性有效度 < 100% 的文字
    FEA_DEBUFF_RATE   = "弱化属性"    # 弱化属性的文字
    FEA_ATK_ELEMENT   = "属性"    # 攻击附带属性的文字

   
    # 辨识度提升数值
    PERCENTAGE_ON_ENCOUNTER = 1 # 敌人现身时提升辨识度
    PERCENTAGE_ON_DEFEAT    = 5 # 敌人落败时提升辨识度
   
    # 辨识度显示参数数值
    NAME_DISPLAY_PERC   = 1   # 名称显示百分比
    HP_EST_DISPLAY_PERC = 5   # HP估算显示百分比
    HP_DISPLAY_PERC     = 10  # HP显示百分比
    MP_EST_DISPLAY_PERC = 10  # MP估算显示百分比
    MP_DISPLAY_PERC     = 15  # MP显示百分比
    ATK_DISPLAY_PERC    = 50  # 攻击力显示百分比
    DEF_DISPLAY_PERC    = 50  # 防御力显示百分比
    MAT_DISPLAY_PERC    = 75  # 魔法攻击显示百分比
    MDF_DISPLAY_PERC    = 75  # 魔法防御显示百分比
    AGI_DISPLAY_PERC    = 75  # 敏捷显示百分比
    LUK_DISPLAY_PERC    = 75  # 幸运显示百分比
    GOLD_DISPLAY_PERC   = 100 # 掉落金钱显示百分比
    ITEM_DISPLAY_PERC   = 100 # 掉落物显示百分比
    #TYPE_BOSS
  end
end
class RPG::Enemy < RPG::BaseItem
  include Snstar::EnemyList
  def list_type
    self.note.split(/[\r\n]+/).each{ |line|
      if line =~ /\[(?:ltype) (\d+)\]/
        return $1 ? $1.to_i : ENEMY_TYPE_DEFAULT
      end}
    return ENEMY_TYPE_DEFAULT
  end
  def list_image
    self.note.split(/[\r\n]+/).each{ |line|
      if line =~ /\[(?:limage) (\S+)\]/
        return $1
      end}
    return nil # battler_name
  end
  def no_list?
    self.note.split(/[\r\n]+/).each{ |line|
      return true if line =~ /\[no_list\]/
      }
    return false
  end
end
class Game_Party < Game_Unit
  include Snstar::EnemyList
  #--------------------------------------------------------------------------
  # ● 初始化
  #--------------------------------------------------------------------------
  alias enemy_list_initialize initialize
  def initialize
    enemy_list_initialize
    @enemy_know_percentage=[]
    $data_enemies.each{ |e|
      next unless e
      set_enemy_percentage(e.id, 0)
    }
  end
  #--------------------------------------------------------------------------
  # ● 设置敌人百分比
  #--------------------------------------------------------------------------
  def set_enemy_percentage(e_id, percentage=100)
    temp_p = [[0, percentage].max ,100].min
    @enemy_know_percentage[e_id] = temp_p
  end
  #--------------------------------------------------------------------------
  # ● 获取敌人百分比
  #--------------------------------------------------------------------------
  def enemy_percent(e_id)
    return 0 unless seen_enemy?(e_id)
    return @enemy_know_percentage[e_id]
  end
  #--------------------------------------------------------------------------
  # ● 提升敌人百分比
  #--------------------------------------------------------------------------
  def see_enemy(e_id, percentage = 1)
    temp_p = @enemy_know_percentage[e_id] + percentage
    set_enemy_percentage(e_id, temp_p)
  end
  def know_enemy(e_id)
    set_enemy_percentage(e_id, 100)
  end
  #--------------------------------------------------------------------------
  # ● 判断是否见过敌人
  #--------------------------------------------------------------------------
  def seen_enemy?(e_id)
    return @enemy_know_percentage[e_id] > 0
  end
  #--------------------------------------------------------------------------
  # ● 判断是否熟知敌人
  #--------------------------------------------------------------------------
  def known_enemy?(e_id, percentage=100)
    return false unless seen_enemy?(e_id)
    return enemy_percent(e_id) == percentage
  end
  #--------------------------------------------------------------------------
  # ● 战斗开始提升辨识度
  #--------------------------------------------------------------------------
  alias enemy_list_on_battle_start on_battle_start
  def on_battle_start
    enemy_list_on_battle_start
    $game_troop.members.each{ |m|
      e_id = m.enemy.id
      see_enemy(e_id, ENCOUNTER_PERCENT)
    }
  end
end
class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # ● 敌人战败提升辨识度
  #--------------------------------------------------------------------------
  alias enemy_list_perform_collapse_effect perform_collapse_effect
  def perform_collapse_effect
    enemy_list_perform_collapse_effect
    $game_party.see_enemy(@enemy_id, Snstar::EnemyList::DEFEAT_PERCENT)
  end
end
class Game_Interpreter
  #--------------------------------------------------------------------------
  # ● 呼叫敌人图鉴场景
  #--------------------------------------------------------------------------
  def call_enemy_list
    SceneManager.call(Scene_List)
  end
  #--------------------------------------------------------------------------
  # ● 提升敌人辨识度
  #--------------------------------------------------------------------------
  def gain_enemy_percentage(e_id, per)
    $game_party.see_enemy(e_id, per)
  end
end


[/pre]

窗口部分
[pre lang="ruby"]
class Window_EnemyType < Window_HorzCommand
  include Snstar::EnemyList
  #--------------------------------------------------------------------------
  # ● 初始化
  #--------------------------------------------------------------------------
  def initialize(x, y, min_height=48)
    super(x, y)
    @min_height = min_height
    @max_height = window_height
  end
  #--------------------------------------------------------------------------
  # ● 定义窗口宽度
  #--------------------------------------------------------------------------
  def window_width
    Graphics.width
  end
  #--------------------------------------------------------------------------
  # ● 定义栏数
  #--------------------------------------------------------------------------
  def col_max
    return 6
  end
  #--------------------------------------------------------------------------
  # ● 窗口更新
  #--------------------------------------------------------------------------
  def update
    super
    @item_window.category = current_symbol if @item_window
  end
  #--------------------------------------------------------------------------
  # ● 绘制敌人类型列表
  #--------------------------------------------------------------------------
  def make_command_list
    add_command(ALL_CATEGORY_TEXT, :all) if INCLUDE_ALL_CATEGORY
    ENEMY_TYPE.each{ |type|
      add_command(type, type.to_sym)
    }
  end
  #--------------------------------------------------------------------------
  # ● 设置敌人列表窗口
  #--------------------------------------------------------------------------
  def item_window=(item_window)
    @item_window = item_window
    update
  end
  #--------------------------------------------------------------------------
  # ● 窗口有效化
  #--------------------------------------------------------------------------
  def activate
    super
    return unless @max_height
    self.height = @max_height
  end
  #--------------------------------------------------------------------------
  # ● 窗口失效
  #--------------------------------------------------------------------------
  def deactivate
    super
    return unless @min_height
    self.height = @min_height
    @item_window.select_last_index
  end
end
class Window_EnemyList < Window_ItemList
  include Snstar::EnemyList
  #--------------------------------------------------------------------------
  # ● 初始化
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    super(x, y, width, height)
    @last_index = {}
  end
  #--------------------------------------------------------------------------
  # ● 选择上次索引
  #--------------------------------------------------------------------------
  def select_last_index
    select(@last_index[@category])
  end
  def select(index)
    super(index)
    @info_window.enemy = @data[@index]
  end
  #--------------------------------------------------------------------------
  # ● 窗口失效
  #--------------------------------------------------------------------------
  def deactivate
    super
    return unless @last_index
    @last_index[@category] = @index # 纪录当前敌人类型的索引
  end
  #--------------------------------------------------------------------------
  # ● 最大栏数
  #--------------------------------------------------------------------------
  def col_max
    return 1
  end
  #--------------------------------------------------------------------------
  # ● 生成敌人列表
  #--------------------------------------------------------------------------
  def make_item_list
    @data = []
    @last_index[@category] = 0 if @last_index[@category].nil?
    selected_type = ENEMY_TYPE.index(@category.to_s)
    $data_enemies.each{ |enemy|
      next if enemy.nil?
      next if enemy.name == "" # 名字为空的敌人跳过
      next if enemy.no_list? # 指定不列入的敌人跳过
      if @category == :all or (enemy.list_type == selected_type)
        @data.push(enemy)
      end
    }
  end
  #--------------------------------------------------------------------------
  # ● 绘制敌人项目
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    if item
      rect = item_rect(index)
      rect.width -= 4
      draw_item_name(item, rect.x, rect.y)
    end
  end
  #--------------------------------------------------------------------------
  # ● 绘制敌人名称
  #--------------------------------------------------------------------------
  def draw_item_name(item, x, y, enabled = true, width = 172)
    return unless item
    if DRAW_ENEMY_ICON
      draw_icon(item.icon_index, x, y, enabled)
      x += 24
    end
    change_color(normal_color, enabled)
    per = $game_party.enemy_percent(item.id)
    if  per >= NAME_DISPLAY_PERC
      text = item.name
    else
      text = NO_DISPLAY_MASK
    end
    draw_text(x, y, width, line_height, text)
  end
  #--------------------------------------------------------------------------
  # ● 资讯窗口更新
  #--------------------------------------------------------------------------
  def update_info
    @info_window.set_item(item)
  end
  #--------------------------------------------------------------------------
  # ● 设置资讯窗口
  #--------------------------------------------------------------------------
  def info_window=(info_window)
    @info_window = info_window
    #call_update_info
  end
end
class Window_EnemyDetail < Window_Base
  include Snstar::EnemyList
  attr_reader :enemy
  #--------------------------------------------------------------------------
  # ● 初始化
  #--------------------------------------------------------------------------
  def initialize
    super(160, 48, Graphics.width-160, Graphics.height-48)
    @enemy = nil
  end
  #--------------------------------------------------------------------------
  # ● 设置当前敌人
  #--------------------------------------------------------------------------
  def enemy=(e)
    @enemy = e
    if enemy
      @percentage = $game_party.enemy_percent(e.id) # 获取当前敌人辨识度
    else
      @percentage = 0
    end
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 检查当前辨识度百分比
  #--------------------------------------------------------------------------
  def checkPercent?(per)
    return @percentage >= per
  end
  #--------------------------------------------------------------------------
  # ● 窗口刷新
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    return unless @enemy # 无敌人时返回
    return unless checkPercent?(NAME_DISPLAY_PERC) # 不显示名称时返回
    @partial = false
    draw_enemy_image(0, 0) # 绘制敌人图像
    draw_background_text
    draw_enemy_name(0, ENEMY_IMAGE_MAX_HEIGHT) # 绘制敌人名称
    draw_enemy_features(0, ENEMY_IMAGE_MAX_HEIGHT+line_height)
    draw_enemy_percentage(0, ENEMY_IMAGE_MAX_HEIGHT+line_height*5) # 绘制敌人辨识度
    partial_refresh
  end
  #--------------------------------------------------------------------------
  # ● 窗口半刷新
  #--------------------------------------------------------------------------
  def partial_refresh
    return unless @enemy # 无敌人时返回
    rect = Rect.new(ENEMY_IMAGE_MAX_WIDTH+8, 0,
      contents.width-(ENEMY_IMAGE_MAX_WIDTH+8), contents.height-line_height)
    contents.clear_rect(rect)
    if ENEMY_MORE_INFO && @partial
      Sound.play_cursor
      draw_other_info

      @partial = false
    else
      draw_enemy_hp(ENEMY_IMAGE_MAX_WIDTH+8, 0) # 绘制敌人体力
       draw_enemy_mp(ENEMY_IMAGE_MAX_WIDTH+8, line_height) # 绘制敌人魔力
       2.upto(7){ |n|
         draw_enemy_param(ENEMY_IMAGE_MAX_WIDTH+8, line_height*n, n) # 绘制敌人能力
       }
       draw_enemy_gold(ENEMY_IMAGE_MAX_WIDTH+8, line_height*8) # 绘制敌人掉落金
       draw_enemy_item(ENEMY_IMAGE_MAX_WIDTH+8, line_height*9) # 绘制敌人掉落物

      @partial = true
    end
  end
  #--------------------------------------------------------------------------
  # ● 绘制敌人特征
  #--------------------------------------------------------------------------
  def draw_enemy_features(x, y)
    fy = y
    for i in 0..4 do
      feature = @enemy.features
      next unless feature
      label, value = get_feature(feature)
      next if label==""
      change_color(system_color)
      draw_text(x, fy, text_width(label), line_height, label)
      change_color(normal_color)
      draw_text(x+72, fy, text_width(value), line_height, value)
      fy+=line_height
    end
  end
  #--------------------------------------------------------------------------
  # ● 获取敌人特征
  #--------------------------------------------------------------------------
  def get_feature(feature)
    code = feature.code
    id = feature.data_id
    value = feature.value
    return "", 0 unless [11, 31].include?(code)
    if code == 11
      if value < 1.0
        label = FEA_RES_ELE_RATE
      elsif value > 1.0
        label = FEA_WEAK_ELE_RATE
      else
        return "", 0
      end
      element = $data_system.elements[id]
      return_value = element + " #{value.truncate}倍"
    elsif code == 31
      label = FEA_ATK_ELEMENT
      return_value = $data_system.elements[id]
    end
    return label, return_value
  end
  #--------------------------------------------------------------------------
  # ● 绘制敌人图像
  #--------------------------------------------------------------------------
  def draw_enemy_image(x, y)
    image_name = @enemy.list_image # 获取指定图像
    if image_name.nil? # 指定图像为空时
      image = Cache.battler(@enemy.battler_name, @enemy.battler_hue) # 获取战斗图
    else
      hue = ENEMY_HUE_SYNC_DB ? @enemy.battler_hue : 0
      image = Cache.load_bitmap(ENEMY_IMAGE_FOLDER, image_name, hue) # 获取战斗图
    end
   
    ix = (image.width/2-ENEMY_IMAGE_MAX_WIDTH/2).abs  # 获取中心点
    # 敌人图像宽度在显示范围外
    if image.width > ENEMY_IMAGE_MAX_WIDTH
      # 居中对齐
      rx = ix
      cx = x
    # 敌人图像宽度在显示范围外
    else
      # 居中对齐
      rx = 0
      cx = ix
    end
    # 敌人图像高度在显示范围外
    if image.height > ENEMY_IMAGE_MAX_HEIGHT
      cy = y
    # 敌人图像高度在显示范围内
    else
      cy = ENEMY_IMAGE_MAX_HEIGHT - image.height - 8 # 向下对齐
    end
    rect = Rect.new(rx, 0, ENEMY_IMAGE_MAX_WIDTH, ENEMY_IMAGE_MAX_HEIGHT)
    contents.blt(cx, cy, image, rect, 255)
  end
  #--------------------------------------------------------------------------
  # ● 绘制敌人辨识度
  #--------------------------------------------------------------------------
  def draw_enemy_percentage(x, y)
    width = contents.width
    change_color(system_color)
    text = ENEMY_PERCENT_VOCAB
    draw_text(x, y, text_width(text), line_height, text)
    # 绘制辨识度进度槽
    draw_gauge(x+96, y, width - 96, @percentage.to_f/100,
      ENEMY_PERCENT_BASE_COLOR, ENEMY_PERCENT_FILL_COLOR)
    # 绘制百分比
    change_color(normal_color)
    text = "#{@percentage}%"
    draw_text(x+96, y, text_width(text), line_height, text)
  end
  #--------------------------------------------------------------------------
  # ● 绘制敌人名称
  #--------------------------------------------------------------------------
  def draw_enemy_name(x, y)
    change_color(system_color)
    text = "名称"
    draw_text(x, y, text_width(text), line_height, text)
    # 绘制名称
    change_color(normal_color)
    text = @enemy.name
    draw_text(x+72, y, text_width(text), line_height, text)
  end
  #--------------------------------------------------------------------------
  # ● 绘制敌人体力
  #--------------------------------------------------------------------------
  def draw_enemy_hp(x, y)
    change_color(system_color)
    text = Vocab::hp
    draw_text(x, y, 108, line_height, text)
    change_color(normal_color)
    hp = @enemy.params[0]
    # 判断显示百分比
    if checkPercent?(HP_DISPLAY_PERC)
      text = hp
    elsif checkPercent?(HP_EST_DISPLAY_PERC)
      # 计算体力约值
      ahp = [(hp/10) * 10 - @enemy.params[3], 10].max
      text = sprintf(EST_DISPLAY_MASK, ahp)
    else
      text = NO_DISPLAY_MASK
    end
    draw_text(x+72, y, text_width(text), line_height, text)
  end
  #--------------------------------------------------------------------------
  # ● 绘制敌人魔力
  #--------------------------------------------------------------------------
  def draw_enemy_mp(x, y)
    change_color(system_color)
    text = Vocab::mp
    draw_text(x, y, 108, line_height, text)
    change_color(normal_color)
    mp = @enemy.params[1]
    # 判断显示百分比
    if checkPercent?(MP_DISPLAY_PERC)
      text = mp
    elsif checkPercent?(MP_EST_DISPLAY_PERC)
      # 计算魔力约值
      amp = [(mp/10) * 10 - @enemy.params[5], @enemy.params[4], 5].max
      text = sprintf(EST_DISPLAY_MASK, amp)
    else
      text = NO_DISPLAY_MASK
    end
    draw_text(x+72, y, text_width(text), line_height, text)
  end
  #--------------------------------------------------------------------------
  # ● 绘制敌人能力值
  #--------------------------------------------------------------------------
  def draw_enemy_param(x, y, param_id)
    # 能力值ID为1或2时,调用绘制体力/魔力方法
    draw_enemy_hp(x, y) if param_id==0
    draw_enemy_mp(x, y) if param_id==1
    return if param_id < 2
    change_color(system_color)
    # 绘制能力值名称
    draw_text(x, y, 108, line_height, Vocab::param(param_id))
    change_color(normal_color)
    # 获取能力值百分比
    param_percent = [ATK_DISPLAY_PERC, DEF_DISPLAY_PERC, MAT_DISPLAY_PERC,
                     MDF_DISPLAY_PERC, AGI_DISPLAY_PERC, LUK_DISPLAY_PERC ]
    # 判断显示百分比
    if checkPercent?(param_percent[param_id-2])
      text = @enemy.params[param_id]
    else
      text = NO_DISPLAY_MASK
    end
    draw_text(x+72, y, text_width(text), line_height, text)
  end
  #--------------------------------------------------------------------------
  # ● 绘制敌人掉落金钱
  #--------------------------------------------------------------------------
  def draw_enemy_gold(x, y)
    change_color(system_color)
    draw_text(x, y, 96, line_height, DROP_GOLD_VOCAB)
    change_color(normal_color)
    # 判断显示百分比
    if checkPercent?(GOLD_DISPLAY_PERC)
      draw_currency_value(@enemy.gold, Vocab.currency_unit, x+12, y, 108)
    else
      draw_text(x+72, y, 96, line_height, NO_DISPLAY_MASK)
    end
  end
  #--------------------------------------------------------------------------
  # ● 绘制敌人掉落物
  #--------------------------------------------------------------------------
  def draw_enemy_item(x, y)
    change_color(system_color)
    draw_text(x, y, 96, line_height, DROP_ITEM_VOCAB)
    change_color(normal_color)
    # 判断显示百分比
    if checkPercent?(ITEM_DISPLAY_PERC)
      nn_di = 0
      for i in 0..2 do
        di = item_object(@enemy.drop_items) # 获取掉落物物件
        if di
          ly = y+line_height*(nn_di+1) # 计算绘制高度
          draw_item_name(di, x+24, ly)
          nn_di += 1 # 计数器+1
        end
      end
      return if nn_di > 0 # 计数器大于0时返回
      draw_text(x+80, y, 96, line_height, "无")
    else
      draw_text(x+24, y+line_height, 96, line_height, NO_DISPLAY_MASK)
    end
  end
  #--------------------------------------------------------------------------
  # ● 计算敌人掉落物
  #--------------------------------------------------------------------------
  def item_object(drop_item)
    kind = drop_item.kind
    data_id = drop_item.data_id
    return $data_items  [data_id] if kind == 1
    return $data_weapons[data_id] if kind == 2
    return $data_armors [data_id] if kind == 3
    return nil
  end
  #--------------------------------------------------------------------------
  # ● 绘制敌人简介
  #--------------------------------------------------------------------------
  def draw_other_info
    if checkPercent?(NAME_DISPLAY_PERC)
    x = 200
      y = 0
      e_na = $1.to_s if enemy.note =~ /<note1:\s*(.*?)>/i
      e_nb = $1.to_s if enemy.note =~ /<note2:\s*(.*?)>/i
      e_nc = $1.to_s if enemy.note =~ /<note3:\s*(.*?)>/i
      e_nd = $1.to_s if enemy.note =~ /<note4:\s*(.*?)>/i
      e_ne = $1.to_s if enemy.note =~ /<note5:\s*(.*?)>/i
      e_nf = $1.to_s if enemy.note =~ /<note6:\s*(.*?)>/i
      change_color(system_color)
      draw_text(x, y, 500, line_height, "简介:")
      change_color(normal_color)
      draw_text(x+46, y + line_height * 0, 500, line_height, e_na)
      draw_text(x,    y + line_height * 1, 500, line_height, e_nb)
      draw_text(x,    y + line_height * 2, 500, line_height, e_nc)
      draw_text(x,    y + line_height * 3, 500, line_height, e_nd)
      draw_text(x,    y + line_height * 4, 500, line_height, e_ne)
      draw_text(x,    y + line_height * 5, 500, line_height, e_nf)
    end
  end
  #--------------------------------------------------------------------------
  # ● 绘制提示
  #--------------------------------------------------------------------------
  def draw_background_text
    draw_text(0, 0, 500, line_height, "A键切换")
  end
  #--------------------------------------------------------------------------
  # ● 获得文字宽度
  #--------------------------------------------------------------------------
  def text_width(text)
    return text_size(text).width + 5
  end
end

[/pre]


场景部分
[pre lang="ruby"]
class Scene_List < Scene_Base
  include Snstar::EnemyList
  #--------------------------------------------------------------------------
  # ● 场景开始
  #--------------------------------------------------------------------------
  def start
    super
    create_category_window
    create_list_window
    create_detail_window
  end
  #--------------------------------------------------------------------------
  # ● 创建敌人类型窗口
  #--------------------------------------------------------------------------
  def create_category_window
    @category_window = Window_EnemyType.new(0, 0)
    @category_window.set_handler(:ok,     method(:on_category_ok))
    @category_window.set_handler(:cancel, method(:return_scene))
    @category_window.viewport = @viewport
  end
  #--------------------------------------------------------------------------
  # ● 创建敌人列表窗口
  #--------------------------------------------------------------------------
  def create_list_window
    @list_window = Window_EnemyList.new(0, 48, 160, Graphics.height-48)
    @list_window.set_handler(:cancel, method(:on_list_cancel))
    @list_window.viewport = @viewport
    @category_window.item_window = @list_window
  end
  #--------------------------------------------------------------------------
  # ● 创建敌人讯息窗口
  #--------------------------------------------------------------------------
  def create_detail_window
    @detail_window = Window_EnemyDetail.new
    @list_window.info_window = @detail_window
  end
  #--------------------------------------------------------------------------
  # ● 选择类型完成
  #--------------------------------------------------------------------------
  def on_category_ok
    @list_window.activate
    @list_window.select_last
  end
  #--------------------------------------------------------------------------
  # ● 离开敌人列表
  #--------------------------------------------------------------------------
  def on_list_cancel
    @list_window.unselect
    @category_window.activate
  end
  #--------------------------------------------------------------------------
  # ● 场景更新
  #--------------------------------------------------------------------------
  def update
    super
    on_list_partial_refersh if Input.trigger?(ENEMY_MORE_INFO_BUTTON)
    enemy_percent_change(:left) if Input.trigger?(:LEFT)
    enemy_percent_change(:right) if Input.trigger?(:RIGHT)
  end
  #--------------------------------------------------------------------------
  # ● 敌人讯息半刷新
  #--------------------------------------------------------------------------
  def on_list_partial_refersh
    @detail_window.partial_refresh
  end
  #--------------------------------------------------------------------------
  # ● 更改敌人辨识度百分比(仅游戏测试时可用)
  #--------------------------------------------------------------------------
  def enemy_percent_change(sym)
    return unless $TEST
    return unless @list_window.active
    enemy = @detail_window.enemy
    return unless enemy
    $game_party.see_enemy(enemy.id, TEST_PERCENT) if sym == :right
    $game_party.see_enemy(enemy.id, -TEST_PERCENT) if sym == :left
    @list_window.refresh
    @detail_window.enemy = enemy
  end
end
class Window_MenuCommand < Window_Command
  include Snstar::EnemyList
  #--------------------------------------------------------------------------
  # ● 加入敌人图鉴命令
  #--------------------------------------------------------------------------
  alias enemy_list_add_original_commands add_original_commands
  def add_original_commands
    enemy_list_add_original_commands
    return unless ENEMY_LIST_SWITCH_ID==0 || $game_switches[ENEMY_LIST_SWITCH_ID]
    enabled = ENEMY_LIST_ENABLE_ID == 0 || $game_switches[ENEMY_LIST_ENABLE_ID]
    add_command(ENEMY_LIST_COMMAND_TEXT, :enemy_list, enabled)
  end
end
class Scene_Menu < Scene_MenuBase
  #--------------------------------------------------------------------------
  # ● 创建命令窗口
  #--------------------------------------------------------------------------
  alias enemy_list_create_command_window create_command_window
  def create_command_window
    enemy_list_create_command_window
    @command_window.set_handler(:enemy_list, method(:enemy_list_display))
  end
  #--------------------------------------------------------------------------
  # ● 呼叫敌人图鉴场景
  #--------------------------------------------------------------------------
  def enemy_list_display
    SceneManager.call(Scene_List)
  end
end[/pre]








另外还有一个是根据角色图鉴改的,没那么方便使用就是了
OW[H{668WPR1FA(8W)@YO4N.png
IRBCOFIT~_R3Q9~`F[W%FP3.png
RJX$L]1GCQ]6_E]2MWNXL}F.png

评分

参与人数 1星屑 +20 收起 理由
VIPArcher + 20 认可答案

查看全部评分


点击签名档去一个神奇的地方
回复

使用道具 举报

梦石
0
星屑
239
在线时间
33 小时
注册时间
2018-11-9
回帖
9
 楼主| 发表于 2018-11-17 17:24:33 | 显示全部楼层
江户川洛奇 发表于 2018-11-17 16:21
不知道怎么传图片
是像附件这样的吗?
怪物说明什么的写在敌人的备注里

没错,效果达到了,感谢大佬!

点评

我不是大佬a  发表于 2018-11-19 10:14
回复

使用道具 举报

梦石
0
星屑
239
在线时间
33 小时
注册时间
2018-11-9
回帖
9
 楼主| 发表于 2018-11-17 17:39:17 | 显示全部楼层
江户川洛奇 发表于 2018-11-17 16:21
不知道怎么传图片
是像附件这样的吗?
怪物说明什么的写在敌人的备注里

另外,萌新可以再问你两个问题吗?第一个是破限插件的问题,插件里都改了最大值是几万,但像攻击、防御等在数据库里都只能是999,这是我使用的方法不对吗?第二个问题是,怎么才能够把比如10000金币显示成1w,1000血量显示成1k这种……
回复

使用道具 举报

梦石
0
星屑
30
在线时间
2 小时
注册时间
2019-4-2
回帖
1
发表于 2019-4-2 16:50:17 | 显示全部楼层
江户川洛奇 发表于 2018-11-17 16:21
不知道怎么传图片
是像附件这样的吗?
怪物说明什么的写在敌人的备注里

前辈,想请问一下,这个脚本使用之后,可简介里根本还是一片空白,就是这个情况。
简介:
然而,对应的怪物备注里面其实是有内容的,但哪怕辨识度到100,简介依然是空的,请问怎么回事?
回复

使用道具 举报

梦石
0
星屑
390
在线时间
50 小时
注册时间
2021-8-10
回帖
7
发表于 2021-9-20 14:40:40 | 显示全部楼层
江户川洛奇 发表于 2018-11-17 16:21
不知道怎么传图片
是像附件这样的吗?
怪物说明什么的写在敌人的备注里

为啥我按A键没有用啊
回复

使用道具 举报

梦石
0
星屑
390
在线时间
50 小时
注册时间
2021-8-10
回帖
7
发表于 2021-9-20 14:44:15 | 显示全部楼层
江户川洛奇 发表于 2018-11-17 16:21
不知道怎么传图片
是像附件这样的吗?
怪物说明什么的写在敌人的备注里

自己解决了
回复

使用道具 举报

梦石
0
星屑
1964
在线时间
217 小时
注册时间
2009-11-10
回帖
202
发表于 2022-1-7 13:52:24 | 显示全部楼层

请问这个图鉴 里面 EnemyImages 这个文件夹 里 的图片要怎么编辑名字 才能用到啊.
因为 我的横版战斗是用敌人的行走图  当做战斗图用 所以 我的Battlers 文件夹里都是行走图。
所以造成 怪物图鉴里显示的是行走图。
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部