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

Project1

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

[已经解决] 怪物图鉴和新获得道具提示脚本冲突求教怎么改

[复制链接]

Lv2.观梦者

梦石
0
星屑
809
在线时间
176 小时
注册时间
2017-1-15
帖子
81
跳转到指定楼层
1
发表于 2019-7-4 19:40:26 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
40星屑
附件是范例工程




这是新获得道具提示脚本
RUBY 代码复制
  1. #===============================================================================
  2. # ■ 新获得道具提示
  3. # by :VIPArcher [email: [email protected]]
  4. #  -- Project1 论坛:[url]https://rpg.blue/[/url] 使用或转载请保留以上信息。
  5. #==============================================================================
  6. # ■ 使用说明:
  7. #   使新获得的道具在物品栏列表中添加一个 New 的小图标
  8. #   可以使用自定素材或者 Icon 里的图标
  9. #==============================================================================
  10. $VIPArcherScript ||= {};$VIPArcherScript[:new_item] = 20181226
  11. #==============================================================================
  12. # ★ 设定部分 ★
  13. #==============================================================================
  14. module VIPArcher end
  15. module VIPArcher::NEW_ITEM
  16.   # 配置部分
  17.   Icon = "NewIcon" # 125
  18.   # 注:Icon 填文件名使用对应文件,填数字则使用 IconSet 对应位置的图标
  19.   Switch = 0 # 该开关开启时获得新道具不做记录
  20.   Icon_X = 0 # New图标相对位置的 X 坐标偏移
  21.   Icon_Y = 0 # New图标相对位置的 Y 坐标偏移
  22.   # 配置结束
  23. end
  24. class Game_Party < Game_Unit
  25.   #--------------------------------------------------------------------------
  26.   # ● 初始化新获得道具列表
  27.   #--------------------------------------------------------------------------
  28.   alias new_icon_init_all_items init_all_items
  29.   def init_all_items
  30.     new_icon_init_all_items
  31.     @new_icon_list = { RPG::Item => [],RPG::Armor => [],RPG::Weapon => [] }
  32.   end
  33.   #--------------------------------------------------------------------------
  34.   # ● 设置新获得道具
  35.   #--------------------------------------------------------------------------
  36.   def set_new_icon(item)
  37.     return unless item
  38.     return if item_is_new?(item)
  39.     @new_icon_list[item.class].push(item.id)
  40.   end
  41.   #--------------------------------------------------------------------------
  42.   # ● 移除新道具
  43.   #--------------------------------------------------------------------------
  44.   def remove_new_icon(item)
  45.     return unless item
  46.     @new_icon_list[item.class].delete(item.id)
  47.   end
  48.   #--------------------------------------------------------------------------
  49.   # ● 是否新道具
  50.   #--------------------------------------------------------------------------
  51.   def item_is_new?(item)
  52.     return unless item
  53.     @new_icon_list[item.class].include?(item.id)
  54.   end
  55.   #--------------------------------------------------------------------------
  56.   # ● 获取道具时设置 Icon 标志
  57.   #--------------------------------------------------------------------------
  58.   alias new_icon_gain_item gain_item
  59.   def gain_item(item, amount, include_equip = false)
  60.     new_icon_gain_item(item, amount, include_equip)
  61.     return if $game_switches[VIPArcher::NEW_ITEM::Switch]
  62.     set_new_icon(item) if amount > 0
  63.   end
  64. end
  65. class Window_ItemList < Window_Selectable
  66.   include VIPArcher::NEW_ITEM
  67.   #--------------------------------------------------------------------------
  68.   # ● 绘制新获得道具 Icon
  69.   #--------------------------------------------------------------------------
  70.   def draw_item_new_flag(rect, item)
  71.     if (Icon.is_a?(Integer))
  72.       draw_icon(Icon, rect.x + Icon_X, rect.y + Icon_Y, enable?(item))
  73.     else
  74.       bitmap = Cache.system(Icon)
  75.       contents.blt(rect.x + Icon_X, rect.y + Icon_Y, bitmap, bitmap.rect,
  76.         enable?(item) ? 255 : translucent_alpha)
  77.     end
  78.   end
  79.   #--------------------------------------------------------------------------
  80.   # ● 绘制项目
  81.   #--------------------------------------------------------------------------
  82.   alias new_icon_draw_item draw_item
  83.   def draw_item(index)
  84.     new_icon_draw_item(index)
  85.     item = @data[index]
  86.     return unless item && $game_party.item_is_new?(item)
  87.     rect = item_rect(index)
  88.     rect.width -= 4
  89.     draw_item_new_flag(rect, item)
  90.   end
  91.   #--------------------------------------------------------------------------
  92.   # ● 移除新道具 Icon
  93.   #--------------------------------------------------------------------------
  94.   def remove_new_icon(item)
  95.     return unless $game_party.item_is_new?(item)
  96.     $game_party.remove_new_icon(item)
  97.     redraw_item(@index)
  98.   end
  99.   #--------------------------------------------------------------------------
  100.   # ● 光标滑过移除 New Icon 标志
  101.   #--------------------------------------------------------------------------
  102.   def index=(index)
  103.     remove_new_icon(@data[@index]) unless @index < 0
  104.     super
  105.   end
  106.   #--------------------------------------------------------------------------
  107.   # ● 确定时消除 New Icon 标志
  108.   #--------------------------------------------------------------------------
  109.   def call_ok_handler
  110.     super
  111.     remove_new_icon(@data[@index])
  112.   end
  113. end
  114. class Game_Actor < Game_Battler
  115.   #--------------------------------------------------------------------------
  116.   # ● 交换物品(修正替换装备也提示 New)
  117.   #--------------------------------------------------------------------------
  118.   alias new_icon_trade_item_with_party trade_item_with_party
  119.   def trade_item_with_party(new_item, old_item)
  120.     result = new_icon_trade_item_with_party(new_item, old_item)
  121.     $game_party.remove_new_icon(old_item)
  122.     return result
  123.   end
  124. end




下面是怪物图鉴脚本
RUBY 代码复制
  1. # 事件中使用脚本打开怪物信息,第一行是遇到怪物,第二行是打开信息
  2. # $game_system.m_dic_encount_sw[87] = true
  3. # $game_system.m_dic_victory_sw[87] = true
  4.  
  5.  
  6.  
  7.  
  8. #在敌人的备注里面填写 [ltype 类型代号],不填则默认ENEMY_TYPE_DEFAULT
  9. module Snstar
  10.   module EnemyList
  11.     # 敌人类型      0       1       2       3       4       5     6
  12.     ENEMY_TYPE = ["野兽", "魔物", "精怪", "人形",  "龙形", "亡灵","首领"]
  13.     ENEMY_TYPE_DEFAULT = 1       # 敌人的默认类型
  14.     ENCOUNTER_PERCENT = 1        # 敌人现身所提升的辨识度
  15.     DEFEAT_PERCENT = 5           # 敌人战败所提升的辨识度
  16.     TEST_PERCENT = 5             # 测试用调整的辨识度
  17.     INCLUDE_ALL_CATEGORY = false  # 是否包含“全部”类型
  18.     ALL_CATEGORY_TEXT = "全部"   # “全部”类型的文字
  19.     ENEMY_MORE_INFO_BUTTON = #:X  # 显示敌人更多资讯的按键
  20.     ENEMY_MORE_INFO = true      # 是否显示更多讯息(扩充用)
  21.  
  22.     DRAW_ENEMY_ICON = false # 需要使用绘制单张图标才能使用
  23.  
  24.     # 敌人图像大小限定
  25.     ENEMY_IMAGE_MAX_WIDTH = 170  # 敌人图像宽度限定
  26.     ENEMY_IMAGE_MAX_HEIGHT = 192 # 敌人图像高度限定
  27.     ENEMY_IMAGE_FOLDER = "Graphics/EnemyImages/" # 敌人指定图像资料夹
  28.     ENEMY_HUE_SYNC_DB = true # 敌人指定图像是否使用资料库设定的色相,如果要显示默认战斗图则设置为true
  29.  
  30.     # 文字设定
  31.     ENEMY_LIST_COMMAND_TEXT = "怪物图鉴" # 主选单命令用字
  32.     ENEMY_LIST_SWITCH_ID    = 0        # 主选单命令显示的控制开关
  33.     ENEMY_LIST_ENABLE_ID    = 0        # 主选单命令有效的控制开关
  34.  
  35.     ENEMY_PERCENT_VOCAB = "辨识度"   # 辨识度用字
  36.     ENEMY_PERCENT_BASE_COLOR = Color.new(0, 255, 0)#Color.new(0, 0, 0)
  37.     ENEMY_PERCENT_FILL_COLOR = Color.new(255, 255, 0)
  38.     NO_DISPLAY_MASK = "??"         # 无法显示时的替代文字
  39.     EST_DISPLAY_MASK = "%s左右"    # 显示估算数值时的文字
  40.     DROP_GOLD_VOCAB  = "金钱"
  41.     DROP_ITEM_VOCAB  = "战利品"
  42.     FEA_WEAK_ELE_RATE = "弱点"    # 属性有效度 > 100% 的文字
  43.     FEA_RES_ELE_RATE  = "抵抗"    # 属性有效度 < 100% 的文字
  44.     FEA_DEBUFF_RATE   = "弱化属性"    # 弱化属性的文字
  45.     FEA_ATK_ELEMENT   = "属性"    # 攻击附带属性的文字
  46.     ENEMY_EXP  = "经验"
  47.     ENEMY_DIE  = "击杀数量"
  48.     # 辨识度提升数值
  49.     PERCENTAGE_ON_ENCOUNTER = 0 # 敌人现身时提升辨识度
  50.     PERCENTAGE_ON_DEFEAT    = 5 # 敌人落败时提升辨识度
  51.  
  52.     # 辨识度显示参数数值
  53.     NAME_DISPLAY_PERC   = 1   # 名称显示百分比
  54.     HP_EST_DISPLAY_PERC = 5   # HP估算显示百分比
  55.     HP_DISPLAY_PERC     = 10  # HP显示百分比
  56.     MP_EST_DISPLAY_PERC = 10  # MP估算显示百分比
  57.     MP_DISPLAY_PERC     = 15  # MP显示百分比
  58.     ATK_DISPLAY_PERC    = 50  # 攻击力显示百分比
  59.     DEF_DISPLAY_PERC    = 50  # 防御力显示百分比
  60.     MAT_DISPLAY_PERC    = 75  # 魔法攻击显示百分比
  61.     MDF_DISPLAY_PERC    = 75  # 魔法防御显示百分比
  62.     AGI_DISPLAY_PERC    = 75  # 敏捷显示百分比
  63.     LUK_DISPLAY_PERC    = 75  # 幸运显示百分比
  64.     GOLD_DISPLAY_PERC   = 100 # 掉落金钱显示百分比
  65.     ITEM_DISPLAY_PERC   = 100 # 掉落物显示百分比
  66.     EXP_DISPLAY_PERC   = 100 # 掉落金钱显示百分比
  67.     #TYPE_BOSS
  68.   end
  69. end
  70. class RPG::Enemy < RPG::BaseItem
  71.   include Snstar::EnemyList
  72.   def list_type
  73.     self.note.split(/[\r\n]+/).each{ |line|
  74.       if line =~ /\[(?:ltype) (\d+)\]/
  75.         return $1 ? $1.to_i : ENEMY_TYPE_DEFAULT
  76.       end}
  77.     return ENEMY_TYPE_DEFAULT
  78.   end
  79.   def list_image
  80.     self.note.split(/[\r\n]+/).each{ |line|
  81.       if line =~ /\[(?:limage) (\S+)\]/
  82.         return $1
  83.       end}
  84.     return nil # battler_name
  85.   end
  86.   def no_list?
  87.     self.note.split(/[\r\n]+/).each{ |line|
  88.       return true if line =~ /\[no_list\]/
  89.       }
  90.     return false
  91.   end
  92. end
  93. class Game_Party < Game_Unit
  94.   include Snstar::EnemyList
  95.   #--------------------------------------------------------------------------
  96.   # ● 初始化
  97.   #--------------------------------------------------------------------------
  98.   alias enemy_list_initialize initialize
  99.   def initialize
  100.     enemy_list_initialize
  101.     @enemy_know_percentage=[]
  102.     $data_enemies.each{ |e|
  103.       next unless e
  104.       set_enemy_percentage(e.id, 0)
  105.     }
  106.   end
  107.   #--------------------------------------------------------------------------
  108.   # ● 设置敌人百分比
  109.   #--------------------------------------------------------------------------
  110.   def set_enemy_percentage(e_id, percentage=100)
  111.     temp_p = [[0, percentage].max ,100].min
  112.     @enemy_know_percentage[e_id] = temp_p
  113.   end
  114.   #--------------------------------------------------------------------------
  115.   # ● 获取敌人百分比
  116.   #--------------------------------------------------------------------------
  117.   def enemy_percent(e_id)
  118.     return 0 unless seen_enemy?(e_id)
  119.     return @enemy_know_percentage[e_id]
  120.   end
  121.   #--------------------------------------------------------------------------
  122.   # ● 提升敌人百分比
  123.   #--------------------------------------------------------------------------
  124.   def see_enemy(e_id, percentage = 1)
  125.     temp_p = @enemy_know_percentage[e_id] + percentage
  126.     set_enemy_percentage(e_id, temp_p)
  127.   end
  128.   def know_enemy(e_id)
  129.     set_enemy_percentage(e_id, 100)
  130.   end
  131.   #--------------------------------------------------------------------------
  132.   # ● 判断是否见过敌人
  133.   #--------------------------------------------------------------------------
  134.   def seen_enemy?(e_id)
  135.     return @enemy_know_percentage[e_id] > 0
  136.   end
  137.   #--------------------------------------------------------------------------
  138.   # ● 判断是否熟知敌人
  139.   #--------------------------------------------------------------------------
  140.   def known_enemy?(e_id, percentage=100)
  141.     return false unless seen_enemy?(e_id)
  142.     return enemy_percent(e_id) == percentage
  143.   end
  144.   #--------------------------------------------------------------------------
  145.   # ● 战斗开始提升辨识度
  146.   #--------------------------------------------------------------------------
  147.   alias enemy_list_on_battle_start on_battle_start
  148.   def on_battle_start
  149.     enemy_list_on_battle_start
  150.     $game_troop.members.each{ |m|
  151.       e_id = m.enemy.id
  152.       see_enemy(e_id, ENCOUNTER_PERCENT)
  153.     }
  154.   end
  155. end
  156. class Game_Enemy < Game_Battler
  157.   #--------------------------------------------------------------------------
  158.   # ● 敌人战败提升辨识度
  159.   #--------------------------------------------------------------------------
  160.   alias enemy_list_perform_collapse_effect perform_collapse_effect
  161.   def perform_collapse_effect
  162.     enemy_list_perform_collapse_effect
  163.     $game_party.see_enemy(@enemy_id, Snstar::EnemyList::DEFEAT_PERCENT)
  164.   end
  165. end
  166. class Game_Interpreter
  167.   #--------------------------------------------------------------------------
  168.   # ● 呼叫敌人图鉴场景
  169.   #--------------------------------------------------------------------------
  170.   def call_enemy_list
  171.     SceneManager.call(Scene_List)
  172.   end
  173.   #--------------------------------------------------------------------------
  174.   # ● 提升敌人辨识度
  175.   #--------------------------------------------------------------------------
  176.   def gain_enemy_percentage(e_id, per)
  177.     $game_party.see_enemy(e_id, per)
  178.   end
  179. end



RUBY 代码复制
  1. class Window_EnemyType < Window_HorzCommand
  2.   include Snstar::EnemyList
  3.   #--------------------------------------------------------------------------
  4.   # ● 初始化
  5.   #--------------------------------------------------------------------------
  6.   def initialize(x, y, min_height=48)
  7.     super(x, y)
  8.     @min_height = min_height
  9.     @max_height = window_height
  10.   end
  11.   #--------------------------------------------------------------------------
  12.   # ● 定义窗口宽度
  13.   #--------------------------------------------------------------------------
  14.   def window_width
  15.     Graphics.width
  16.   end
  17.   #--------------------------------------------------------------------------
  18.   # ● 定义栏数
  19.   #--------------------------------------------------------------------------
  20.   def col_max
  21.     return 7
  22.   end
  23.   #--------------------------------------------------------------------------
  24.   # ● 窗口更新
  25.   #--------------------------------------------------------------------------
  26.   def update
  27.     super
  28.     @item_window.category = current_symbol if @item_window
  29.   end
  30.   #--------------------------------------------------------------------------
  31.   # ● 绘制敌人类型列表
  32.   #--------------------------------------------------------------------------
  33.   def make_command_list
  34.     add_command(ALL_CATEGORY_TEXT, :all) if INCLUDE_ALL_CATEGORY
  35.     ENEMY_TYPE.each{ |type|
  36.       add_command(type, type.to_sym)
  37.     }
  38.   end
  39.   #--------------------------------------------------------------------------
  40.   # ● 设置敌人列表窗口
  41.   #--------------------------------------------------------------------------
  42.   def item_window=(item_window)
  43.     @item_window = item_window
  44.     update
  45.   end
  46.   #--------------------------------------------------------------------------
  47.   # ● 窗口有效化
  48.   #--------------------------------------------------------------------------
  49.   def activate
  50.     super
  51.     return unless @max_height
  52.     self.height = @max_height
  53.   end
  54.   #--------------------------------------------------------------------------
  55.   # ● 窗口失效
  56.   #--------------------------------------------------------------------------
  57.   def deactivate
  58.     super
  59.     return unless @min_height
  60.     self.height = @min_height
  61.     @item_window.select_last_index
  62.   end
  63. end
  64. class Window_EnemyList < Window_ItemList
  65.   include Snstar::EnemyList
  66.   #--------------------------------------------------------------------------
  67.   # ● 初始化
  68.   #--------------------------------------------------------------------------
  69.   def initialize(x, y, width, height)
  70.     super(x, y, width, height)
  71.     @last_index = {}
  72.   end
  73.   #--------------------------------------------------------------------------
  74.   # ● 选择上次索引
  75.   #--------------------------------------------------------------------------
  76.   def select_last_index
  77.     select(@last_index[@category])
  78.   end
  79.   def select(index)
  80.     super(index)
  81.     @info_window.enemy = @data[@index]
  82.   end
  83.   #--------------------------------------------------------------------------
  84.   # ● 窗口失效
  85.   #--------------------------------------------------------------------------
  86.   def deactivate
  87.     super
  88.     return unless @last_index
  89.     @last_index[@category] = @index # 纪录当前敌人类型的索引
  90.   end
  91.   #--------------------------------------------------------------------------
  92.   # ● 最大栏数
  93.   #--------------------------------------------------------------------------
  94.   def col_max
  95.     return 1
  96.   end
  97.   #--------------------------------------------------------------------------
  98.   # ● 生成敌人列表
  99.   #--------------------------------------------------------------------------
  100.   def make_item_list
  101.     @data = []
  102.     @last_index[@category] = 0 if @last_index[@category].nil?
  103.     selected_type = ENEMY_TYPE.index(@category.to_s)
  104.     $data_enemies.each{ |enemy|
  105.       next if enemy.nil?
  106.       next if enemy.name == "" # 名字为空的敌人跳过
  107.       next if enemy.no_list? # 指定不列入的敌人跳过
  108.       if @category == :all or (enemy.list_type == selected_type)
  109.         @data.push(enemy)
  110.       end
  111.     }
  112.   end
  113.   #--------------------------------------------------------------------------
  114.   # ● 绘制敌人项目
  115.   #--------------------------------------------------------------------------
  116.   def draw_item(index)
  117.     item = @data[index]
  118.     if item
  119.       rect = item_rect(index)
  120.       rect.width -= 4
  121.       draw_item_name(item, rect.x, rect.y)
  122.     end
  123.   end
  124.   #--------------------------------------------------------------------------
  125.   # ● 绘制敌人名称
  126.   #--------------------------------------------------------------------------
  127.   def draw_item_name(item, x, y, enabled = true, width = 172)
  128.     return unless item
  129.     if DRAW_ENEMY_ICON
  130.       draw_icon(item.icon_index, x, y, enabled)
  131.       x += 24
  132.     end
  133.     change_color(normal_color, enabled)
  134.     per = $game_party.enemy_percent(item.id)
  135.     if  per >= NAME_DISPLAY_PERC
  136.       text = item.name
  137.     else
  138.       text = NO_DISPLAY_MASK
  139.     end
  140.     draw_text(x, y, width, line_height, text)
  141.   end
  142.   #--------------------------------------------------------------------------
  143.   # ● 资讯窗口更新
  144.   #--------------------------------------------------------------------------
  145.   def update_info
  146.     @info_window.set_item(item)
  147.   end
  148.   #--------------------------------------------------------------------------
  149.   # ● 设置资讯窗口
  150.   #--------------------------------------------------------------------------
  151.   def info_window=(info_window)
  152.     @info_window = info_window
  153.     #call_update_info
  154.   end
  155. end
  156. class Window_EnemyDetail < Window_Base
  157.   include Snstar::EnemyList
  158.   attr_reader :enemy
  159.   #--------------------------------------------------------------------------
  160.   # ● 初始化
  161.   #--------------------------------------------------------------------------
  162.   def initialize
  163.     super(160, 48, Graphics.width-160, Graphics.height-48)
  164.     @enemy = nil
  165.   end
  166.   #--------------------------------------------------------------------------
  167.   # ● 设置当前敌人
  168.   #--------------------------------------------------------------------------
  169.   def enemy=(e)
  170.     @enemy = e
  171.     if enemy
  172.       @percentage = $game_party.enemy_percent(e.id) # 获取当前敌人辨识度
  173.     else
  174.       @percentage = 0
  175.     end
  176.     refresh
  177.   end
  178.   #--------------------------------------------------------------------------
  179.   # ● 检查当前辨识度百分比
  180.   #--------------------------------------------------------------------------
  181.   def checkPercent?(per)
  182.     return @percentage >= per
  183.   end
  184.   #--------------------------------------------------------------------------
  185.   # ● 窗口刷新
  186.   #--------------------------------------------------------------------------
  187.   def refresh
  188.     contents.clear
  189.     return unless @enemy # 无敌人时返回
  190.     return unless checkPercent?(NAME_DISPLAY_PERC) # 不显示名称时返回
  191.     @partial = false
  192.     draw_enemy_image(0, 0) # 绘制敌人图像
  193.     draw_enemy_name(0, ENEMY_IMAGE_MAX_HEIGHT) # 绘制敌人名称
  194.     draw_enemy_features(0, ENEMY_IMAGE_MAX_HEIGHT+line_height)
  195.     draw_enemy_percentage(0, ENEMY_IMAGE_MAX_HEIGHT+line_height*5) # 绘制敌人辨识度
  196.     e_na = $1.to_s if enemy.note =~ /<note1:\s*(.*?)>/i
  197.     e_nb = $1.to_s if enemy.note =~ /<note2:\s*(.*?)>/i
  198.     e_nc = $1.to_s if enemy.note =~ /<note3:\s*(.*?)>/i
  199.     draw_text(0, y + line_height * 12, 600, line_height, e_na)
  200.     draw_text(0, y + line_height * 13, 600, line_height, e_nb)
  201.     draw_text(0, y + line_height * 14, 600, line_height, e_nc)
  202.     partial_refresh
  203.   end
  204.   #--------------------------------------------------------------------------
  205.   # ● 窗口半刷新
  206.   #--------------------------------------------------------------------------
  207.   def partial_refresh
  208.     return unless @enemy # 无敌人时返回
  209.     rect = Rect.new(ENEMY_IMAGE_MAX_WIDTH+10, 0,
  210.       contents.width-(ENEMY_IMAGE_MAX_WIDTH+10), contents.height-125)
  211.     contents.clear_rect(rect)
  212.     if ENEMY_MORE_INFO && @partial
  213.       Sound.play_cursor
  214.       draw_other_info
  215.       @partial = false
  216.     else
  217.       draw_enemy_hp(ENEMY_IMAGE_MAX_WIDTH+10, 0) # 绘制敌人体力
  218.       draw_enemy_mp(ENEMY_IMAGE_MAX_WIDTH+10, line_height) # 绘制敌人魔力
  219.       2.upto(7){ |n|
  220.         draw_enemy_param(ENEMY_IMAGE_MAX_WIDTH+10, line_height*n, n) # 绘制敌人能力
  221.       }
  222.       draw_enemy_gold(ENEMY_IMAGE_MAX_WIDTH+10, line_height*8) # 绘制敌人掉落金
  223.       draw_enemy_exp(ENEMY_IMAGE_MAX_WIDTH+10, line_height*9) # 绘制敌人掉落金
  224.       draw_enemy_item(ENEMY_IMAGE_MAX_WIDTH+10, line_height*10) # 绘制敌人掉落物
  225.       draw_enemy_die(ENEMY_IMAGE_MAX_WIDTH+10, line_height*13) # 绘制击杀数
  226.       @partial = true
  227.     end
  228.   end
  229.   #--------------------------------------------------------------------------
  230.   # ● 绘制敌人特征
  231.   #--------------------------------------------------------------------------
  232.   def draw_enemy_features(x, y)
  233.     fy = y
  234.     for i in 0..4 do
  235.       feature = @enemy.features[i]
  236.       next unless feature
  237.       label, value = get_feature(feature)
  238.       next if label==""
  239.       change_color(system_color)
  240.       draw_text(x, fy, text_width(label), line_height, label)
  241.       change_color(normal_color)
  242.       draw_text(x+72, fy, text_width(value), line_height, value)
  243.       fy+=line_height
  244.     end
  245.   end
  246.   #--------------------------------------------------------------------------
  247.   # ● 获取敌人特征
  248.   #--------------------------------------------------------------------------
  249.   def get_feature(feature)
  250.     code = feature.code
  251.     id = feature.data_id
  252.     value = feature.value
  253.     return "", 0 unless [11, 31].include?(code)
  254.     if code == 11
  255.       if value < 1.0
  256.         label = FEA_RES_ELE_RATE
  257.       elsif value > 1.0
  258.         label = FEA_WEAK_ELE_RATE
  259.       else
  260.         return "", 0
  261.       end
  262.       element = $data_system.elements[id]
  263. #      return_value = element + " #{value.truncate}倍"
  264.       return_value = element# + " #{value.truncate}倍"
  265.     elsif code == 31
  266.       label = FEA_ATK_ELEMENT
  267.       return_value = $data_system.elements[id]
  268.     end
  269.     return label, return_value
  270.   end
  271.   #--------------------------------------------------------------------------
  272.   # ● 绘制敌人图像
  273.   #--------------------------------------------------------------------------
  274.   def draw_enemy_image(x, y)
  275.     image_name = @enemy.list_image # 获取指定图像
  276.     if image_name.nil? # 指定图像为空时
  277.       image = Cache.battler(@enemy.battler_name, @enemy.battler_hue) # 获取战斗图
  278.     else
  279.       hue = ENEMY_HUE_SYNC_DB ? @enemy.battler_hue : 0
  280.       image = Cache.load_bitmap(ENEMY_IMAGE_FOLDER, image_name, hue) # 获取战斗图
  281.     end
  282.  
  283.     ix = (image.width/2-ENEMY_IMAGE_MAX_WIDTH/2).abs  # 获取中心点
  284.     # 敌人图像宽度在显示范围外
  285.     if image.width > ENEMY_IMAGE_MAX_WIDTH
  286.       # 居中对齐
  287.       rx = ix
  288.       cx = x
  289.     # 敌人图像宽度在显示范围外
  290.     else
  291.       # 居中对齐
  292.       rx = 0
  293.       cx = ix
  294.     end
  295.     # 敌人图像高度在显示范围外
  296.     if image.height > ENEMY_IMAGE_MAX_HEIGHT
  297.       cy = y
  298.     # 敌人图像高度在显示范围内
  299.     else
  300.       cy = ENEMY_IMAGE_MAX_HEIGHT - image.height - 8 # 向下对齐
  301.     end
  302.     rect = Rect.new(rx, 0, ENEMY_IMAGE_MAX_WIDTH, ENEMY_IMAGE_MAX_HEIGHT)
  303.     contents.blt(cx, cy, image, rect, 255)
  304.   end
  305.   #--------------------------------------------------------------------------
  306.   # ● 绘制敌人辨识度
  307.   #--------------------------------------------------------------------------
  308.   def draw_enemy_percentage(x, y)
  309.     width = contents.width
  310.     change_color(system_color)
  311.     text = ENEMY_PERCENT_VOCAB
  312.     draw_text(x, y, text_width(text), line_height, text)
  313.     # 绘制辨识度进度槽
  314.     draw_gauge(x+96, y, width - 350, @percentage.to_f/100,
  315.       ENEMY_PERCENT_BASE_COLOR, ENEMY_PERCENT_FILL_COLOR)
  316.     # 绘制百分比
  317.     change_color(normal_color)
  318.     text = "#{@percentage}%"
  319.     draw_text(x+96, y, text_width(text), line_height, text)
  320.   end
  321.   #--------------------------------------------------------------------------
  322.   # ● 绘制敌人名称
  323.   #--------------------------------------------------------------------------
  324.   def draw_enemy_name(x, y)
  325.     change_color(system_color)
  326.     text = "名称"
  327.     draw_text(x, y, text_width(text), line_height, text)
  328.     # 绘制名称
  329.     change_color(normal_color)
  330.     text = @enemy.name
  331.     draw_text(x+72, y, text_width(text), line_height, text)
  332.    end
  333.   #--------------------------------------------------------------------------
  334.   # ● 绘制敌人体力
  335.   #--------------------------------------------------------------------------
  336.   def draw_enemy_hp(x, y)
  337.     change_color(system_color)
  338.     text = Vocab::hp
  339.     draw_text(x + 45, y, 108, line_height, text)
  340.     change_color(normal_color)
  341.     hp = a.to_i
  342.  
  343.     # 判断显示百分比
  344.     if checkPercent?(HP_DISPLAY_PERC)
  345.       text = hp
  346.     elsif checkPercent?(HP_EST_DISPLAY_PERC)
  347.       # 计算体力约值
  348.       ahp = [(hp/10) * 10 - @enemy.params[3], 10].max
  349.       text = sprintf(EST_DISPLAY_MASK, ahp)
  350.     else
  351.       text = NO_DISPLAY_MASK
  352.     end
  353.     draw_text(x+152, y, text_width(text), line_height, text)
  354.   end
  355.   #--------------------------------------------------------------------------
  356.   # ● 绘制敌人魔力
  357.   #--------------------------------------------------------------------------
  358.   def draw_enemy_mp(x, y)
  359.     change_color(system_color)
  360.     text = Vocab::mp
  361.     draw_text(x + 45, y, 108, line_height, text)
  362.     change_color(normal_color)
  363.     mp = a.to_i      
  364.     # 判断显示百分比
  365.     if checkPercent?(MP_DISPLAY_PERC)
  366.       text = mp
  367.     elsif checkPercent?(MP_EST_DISPLAY_PERC)
  368.       # 计算魔力约值
  369.       amp = [(mp/10) * 10 - @enemy.params[5], @enemy.params[4], 5].max
  370.       text = sprintf(EST_DISPLAY_MASK, amp)
  371.     else
  372.       text = NO_DISPLAY_MASK
  373.     end
  374.     draw_text(x+152, y, text_width(text), line_height, text)
  375.   end
  376.   #--------------------------------------------------------------------------
  377.   # ● 绘制敌人能力值
  378.   #--------------------------------------------------------------------------
  379.   def draw_enemy_param(x, y, param_id)
  380.     # 能力值ID为1或2时,调用绘制体力/魔力方法
  381.     draw_enemy_hp(x, y) if param_id==0
  382.     draw_enemy_mp(x, y) if param_id==1
  383.     return if param_id < 2
  384.     change_color(system_color)
  385.     # 绘制能力值名称
  386.     text = Vocab::param(param_id)
  387.     draw_text(x + 45, y, 108, line_height, text)
  388.     change_color(normal_color)
  389.     # 获取能力值百分比
  390.     param_percent = [ATK_DISPLAY_PERC, DEF_DISPLAY_PERC, MAT_DISPLAY_PERC,
  391.                      MDF_DISPLAY_PERC, AGI_DISPLAY_PERC, LUK_DISPLAY_PERC ]
  392.     # 判断显示百分比
  393.     if checkPercent?(param_percent[param_id-2])
  394.       text = a.to_i         
  395.     else
  396.       text = NO_DISPLAY_MASK
  397.     end
  398.     draw_text(x+152, y, text_width(text), line_height, text)
  399.   end
  400.   #--------------------------------------------------------------------------
  401.   # ● 绘制敌人掉落金钱
  402.   #--------------------------------------------------------------------------
  403.   def draw_enemy_gold(x, y)
  404.     change_color(system_color)
  405.     draw_text(x + 45, y, 96, line_height, DROP_GOLD_VOCAB)
  406.     change_color(normal_color)
  407.     # 判断显示百分比
  408.     if checkPercent?(GOLD_DISPLAY_PERC)
  409.      draw_currency_value(@enemy.gold, Vocab.currency_unit, x+92, y, 108)
  410.     else
  411.       draw_text(x+152, y, 96, line_height, NO_DISPLAY_MASK)
  412.     end
  413.   end
  414.   #--------------------------------------------------------------------------
  415.   # ● 绘制敌人经验
  416.   #--------------------------------------------------------------------------
  417.   def draw_enemy_exp(x, y)
  418.     change_color(system_color)
  419.     draw_text(x + 45, y, 96, line_height, ENEMY_EXP)
  420.     change_color(normal_color)
  421.     # 判断显示百分比
  422.     if checkPercent?(EXP_DISPLAY_PERC)
  423.       a=@enemy.exp
  424. #     draw_currency_value(@enemy.exp, Vocab.currency_unit, x+92, y, 108)
  425.      draw_currency_value(a,"", x + 92, y, 80)
  426.     else
  427.       draw_text(x+152, y, 96, line_height, NO_DISPLAY_MASK)
  428.     end
  429.   end
  430.  
  431.  
  432.   #击杀数
  433.  
  434.   def draw_enemy_die(x, y)
  435.     change_color(system_color)
  436.     draw_text(x + 45, y, 96, line_height, ENEMY_DIE)
  437.     change_color(normal_color)
  438.    case enemy.id
  439.       when 1
  440.         text = $game_variables[710].to_i
  441.       when 2
  442.         text = $game_variables[711].to_i
  443.       when 3
  444.         text = $game_variables[712].to_i
  445.       when 4
  446.         text = $game_variables[713].to_i
  447.       when 5
  448.         text = $game_variables[714].to_i
  449.     end
  450.       draw_text(x+152, y, 96, line_height, text)
  451.   end
  452.   #--------------------------------------------------------------------------
  453.   # ● 绘制敌人掉落物
  454.   #--------------------------------------------------------------------------
  455.   def draw_enemy_item(x, y)
  456.     change_color(system_color)
  457.     draw_text(x + 45, y, 200, line_height, DROP_ITEM_VOCAB)
  458.     change_color(normal_color)
  459.     # 判断显示百分比
  460.     if checkPercent?(ITEM_DISPLAY_PERC)
  461.       nn_di = 0
  462.       for i in 0..2 do
  463.         di = item_object(@enemy.drop_items[i]) # 获取掉落物物件
  464.         if di
  465.           ly = y +line_height*(nn_di+1)-line_height  # 计算绘制高度
  466.           draw_item_name(di, x+116, ly)
  467.           nn_di += 1 # 计数器+1
  468.         end
  469.       end
  470.       return if nn_di > 0 # 计数器大于0时返回
  471.       draw_text(x+152, y, 200, line_height, "无")
  472.     else
  473.       draw_text(x+152, y, 200, line_height, NO_DISPLAY_MASK)
  474.     end
  475.   end
  476.  
  477.   #--------------------------------------------------------------------------
  478.   # ● 计算敌人掉落物
  479.   #--------------------------------------------------------------------------
  480.   def item_object(drop_item)
  481.     kind = drop_item.kind
  482.     data_id = drop_item.data_id
  483.     return $data_items  [data_id] if kind == 1
  484.     return $data_weapons[data_id] if kind == 2
  485.     return $data_armors [data_id] if kind == 3
  486.     return nil
  487.   end
  488.   #--------------------------------------------------------------------------
  489.   # ● 绘制其他资讯
  490.   #--------------------------------------------------------------------------
  491.   def draw_other_info     
  492.   end
  493.   #--------------------------------------------------------------------------
  494.   # ● 获得文字宽度
  495.   #--------------------------------------------------------------------------
  496.   def text_width(text)
  497.     return text_size(text).width + 5
  498.   end
  499. end




RUBY 代码复制
  1. class Scene_List < Scene_MenuBase
  2.   include Snstar::EnemyList
  3.   #--------------------------------------------------------------------------
  4.   # ● 场景开始
  5.   #--------------------------------------------------------------------------
  6.   def start
  7.     super
  8.     create_category_window
  9.     create_list_window
  10.     create_detail_window
  11.   end
  12.   #--------------------------------------------------------------------------
  13.   # ● 创建敌人类型窗口
  14.   #--------------------------------------------------------------------------
  15.   def create_category_window
  16.     @category_window = Window_EnemyType.new(0, 0)
  17.     @category_window.set_handler(:ok,     method(:on_category_ok))
  18.     @category_window.set_handler(:cancel, method(:return_scene))
  19.     @category_window.viewport = @viewport
  20.   end
  21.   #--------------------------------------------------------------------------
  22.   # ● 创建敌人列表窗口
  23.   #--------------------------------------------------------------------------
  24.   def create_list_window
  25.     @list_window = Window_EnemyList.new(0, 48, 160, Graphics.height-48)
  26.     @list_window.set_handler(:cancel, method(:on_list_cancel))
  27.     @list_window.viewport = @viewport
  28.     @category_window.item_window = @list_window
  29.   end
  30.   #--------------------------------------------------------------------------
  31.   # ● 创建敌人讯息窗口
  32.   #--------------------------------------------------------------------------
  33.   def create_detail_window
  34.     @detail_window = Window_EnemyDetail.new
  35.     @list_window.info_window = @detail_window
  36.   end
  37.   #--------------------------------------------------------------------------
  38.   # ● 选择类型完成
  39.   #--------------------------------------------------------------------------
  40.   def on_category_ok
  41.     @list_window.activate
  42.     @list_window.select_last
  43.   end
  44.   #--------------------------------------------------------------------------
  45.   # ● 离开敌人列表
  46.   #--------------------------------------------------------------------------
  47.   def on_list_cancel
  48.     @list_window.unselect
  49.     @category_window.activate
  50.   end
  51.   #--------------------------------------------------------------------------
  52.   # ● 场景更新
  53.   #--------------------------------------------------------------------------
  54.   def update
  55.     super
  56.     on_list_partial_refersh if Input.trigger?(ENEMY_MORE_INFO_BUTTON)
  57.     enemy_percent_change(:left) if Input.trigger?(:LEFT)
  58.     enemy_percent_change(:right) if Input.trigger?(:RIGHT)
  59.   end
  60.   #--------------------------------------------------------------------------
  61.   # ● 敌人讯息半刷新
  62.   #--------------------------------------------------------------------------
  63.   def on_list_partial_refersh
  64.     @detail_window.partial_refresh
  65.   end
  66.   #--------------------------------------------------------------------------
  67.   # ● 更改敌人辨识度百分比(仅游戏测试时可用)
  68.   #--------------------------------------------------------------------------
  69.   def enemy_percent_change(sym)
  70.     return unless $TEST
  71.     return unless @list_window.active
  72.     enemy = @detail_window.enemy
  73.     return unless enemy
  74.     $game_party.see_enemy(enemy.id, TEST_PERCENT) if sym == :right
  75.     $game_party.see_enemy(enemy.id, -TEST_PERCENT) if sym == :left
  76.     @list_window.refresh
  77.     @detail_window.enemy = enemy
  78.   end
  79. end
  80.  
  81. class Window_MenuCommand < Window_Command #纵向排列菜单
  82.   include Snstar::EnemyList
  83.   #--------------------------------------------------------------------------
  84.   # ● 加入敌人图鉴命令
  85.   #--------------------------------------------------------------------------
  86. alias enemy_list_add_original_commands add_original_commands
  87.   def add_original_commands
  88.     enemy_list_add_original_commands
  89.     return unless ENEMY_LIST_SWITCH_ID==0 || $game_switches[ENEMY_LIST_SWITCH_ID]
  90.     enabled = ENEMY_LIST_ENABLE_ID == 0 || $game_switches[ENEMY_LIST_ENABLE_ID]
  91.     add_command(ENEMY_LIST_COMMAND_TEXT, :enemy_list, enabled)
  92.   end
  93. end
  94. class Scene_Menu < Scene_MenuBase
  95.   #--------------------------------------------------------------------------
  96.   # ● 创建命令窗口
  97.   #--------------------------------------------------------------------------
  98.   alias enemy_list_create_command_window create_command_window
  99.   def create_command_window
  100.     enemy_list_create_command_window
  101.     @command_window.set_handler(:enemy_list, method(:enemy_list_display))
  102.   end
  103.   #--------------------------------------------------------------------------
  104.   # ● 呼叫敌人图鉴场景
  105.   #--------------------------------------------------------------------------
  106.   def enemy_list_display
  107.     SceneManager.call(Scene_List)
  108.   end
  109.  
  110. end

Project1.rar

1.43 MB, 下载次数: 93

最佳答案

查看完整内容

因为怪物图鉴中的敌人列表,借用了物品列表…… 获得道具提示中的45~46行之间加一句判定, 一次性解决任何其他可能的借用

Lv6.析梦学徒

老鹰

梦石
40
星屑
33417
在线时间
6553 小时
注册时间
2012-5-26
帖子
3178

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

2
发表于 2019-7-4 19:40:27 | 只看该作者
本帖最后由 百里_飞柳 于 2019-7-5 14:31 编辑

因为怪物图鉴中的敌人列表,借用了物品列表……
获得道具提示中的45~46行之间加一句判定,
一次性解决任何其他可能的借用
  1.   #--------------------------------------------------------------------------
  2.   # ● 移除新道具
  3.   #--------------------------------------------------------------------------
  4.   def remove_new_icon(item)
  5.     return unless item
  6.     return if @new_icon_list.nil? || @new_icon_list[item.class].nil? # 新增
  7.     @new_icon_list[item.class].delete(item.id)
  8.   end
复制代码

点评

打错了……应该是 return if @new_icon_list.nil? || @new_icon_list[item.class].nil?  发表于 2019-7-5 14:31
return if @new_icon_list.nil? || [item.class].nil? # 新增  发表于 2019-7-5 14:30
试了一下加入了这一句还是会报错呀~  发表于 2019-7-5 11:54
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-29 03:57

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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