查看: 1558|回复: 3

[已经解决] 如何实现持有一个特定物品时才出现特定技能?

[复制链接]
梦石
0
星屑
88
在线时间
19 小时
注册时间
2021-7-6
回帖
3
发表于 2023-5-13 07:47:58 | 显示全部楼层 |阅读模式
悬赏5星屑已解决
如题

比如只有持有“子弹”时才会出现“开枪”技能

最佳答案

查看完整内容

[fold][pre lang="ruby"]#============================================================================== # # ▼ Yanfly Engine Ace - Hide Menu Skills v1.01 # -- Last Updated: 2011.12.11 # -- Level: Normal # -- Requires: n/a # #============================================================================== $imported = {} if $imported.nil? $imported["YEA-HideMenuSkills"] = true #==================== ...
做出来了!做出来了!rpg!你感觉如何,如何呀!
梦石
0
星屑
29896
在线时间
5733 小时
注册时间
2016-3-8
回帖
1653
发表于 2023-5-13 07:47:59 | 显示全部楼层
本帖最后由 alexncf125 于 2023-5-13 10:41 编辑

[fold][pre lang="ruby"]#==============================================================================
#
# ▼ Yanfly Engine Ace - Hide Menu Skills v1.01
# -- Last Updated: 2011.12.11
# -- Level: Normal
# -- Requires: n/a
#
#==============================================================================

$imported = {} if $imported.nil?
$imported["YEA-HideMenuSkills"] = true

#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2011.12.11 - Started Script and Finished.
#            - Added <hide eval> notetags.
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Have some skills you want hidden until certain conditions are met? Well, now
# you can! This script will only hide the skills from the default skill list
# menus. Anything that displays otherwise may or may not hide them depending on
# the script and what it bases off of.
#
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
#
# -----------------------------------------------------------------------------
# Skill Notetags - These notetags go in the skills notebox in the database.
# -----------------------------------------------------------------------------
# <hide always>
# This skill will always be hidden from the default skill list windows.
#
# <hide in battle>
# This skill will always be hidden from the default skill window in battle.
#
# <hide until usable>
# This will require the skill to be usable before it appears in the window.
#
# <hide if switch: x>
# This skill will be hidden if switch x is on. The skill will be shown if
# switch x is off. This switch is considered part of the "any" category.
#
# <hide any switch: x>
# <hide any switch: x, x>
# This skill will be hidden if any of the switches x is on. Use multiple tags
# or separate the switch ID's with commas.
#
# <hide all switch: x>
# <hide all switch: x, x>
# This skill will be hidden until all of the switches x are on. Use multiple
# tags or separate the switch ID's with commas.
#
# <hide eval>
#  string
#  string
# </hide eval>
# For the more advanced users, replace string with lines of code to check for
# whether or not to hide the skill. If multiple lines are used, they are all
# considered part of the same line.
#
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================

module YEA
  module REGEXP
  module SKILL
   
    HIDE_ALWAYS     = /<(?:HIDE_ALWAYS|hide always)>/i
    HIDE_IN_BATTLE  = /<(?:HIDE_IN_BATTLE|hide in battle)>/i
    HIDE_IF_SWITCH  = /<(?:HIDE_IF_SWITCH|hide if switch):[ ](\d+)>/i
    HIDE_UNTIL_USABLE = /<(?:HIDE_UNTIL_USABLE|hide until usable)>/i
   
    HIDE_ANY_SWITCH =
      /<(?:HIDE_ANY_SWITCH|hide any switch):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
    HIDE_ALL_SWITCH =
      /<(?:HIDE_ALL_SWITCH|hide all switch):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
   
    HIDE_EVAL_ON  = /<(?:HIDE_EVAL|hide eval)>/i
    HIDE_EVAL_OFF = /<\/(?:HIDE_EVAL|hide eval)>/i
   
  end # SKILL
  end # REGEXP
end # YEA

#==============================================================================
# ■ DataManager
#==============================================================================

module DataManager
  
  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  class <<self; alias load_database_hms load_database; end
  def self.load_database
    load_database_hms
    load_notetags_hms
  end
  
  #--------------------------------------------------------------------------
  # new method: load_notetags_hms
  #--------------------------------------------------------------------------
  def self.load_notetags_hms
    groups = [$data_skills]
    for group in groups
      for obj in group
        next if obj.nil?
        obj.load_notetags_hms
      end
    end
  end
  
end # DataManager

#==============================================================================
# ■ RPG::Skill
#==============================================================================

class RPG::Skill < RPG::UsableItem
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :hide_always
  attr_accessor :hide_in_battle
  attr_accessor :hide_any_switch
  attr_accessor :hide_all_switch
  attr_accessor :hide_until_usable
  attr_accessor :hide_eval
  
  #--------------------------------------------------------------------------
  # common cache: load_notetags_hms
  #--------------------------------------------------------------------------
  def load_notetags_hms
    @hide_eval = nil
    @hide_any_switch = []
    @hide_all_switch = []
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEA::REGEXP::SKILL::HIDE_ALWAYS
        @hide_always = true
      when YEA::REGEXP::SKILL::HIDE_IN_BATTLE
        @hide_in_battle = true
      when YEA::REGEXP::SKILL::HIDE_UNTIL_USABLE
        @hide_until_usable = true
      when YEA::REGEXP::SKILL::HIDE_IF_SWITCH
        @hide_any_switch.push($1.to_i)
      when YEA::REGEXP::SKILL::HIDE_ANY_SWITCH
        $1.scan(/\d+/).each { |num|
        @hide_any_switch.push(num.to_i) if num.to_i > 0 }
      when YEA::REGEXP::SKILL::HIDE_ALL_SWITCH
        $1.scan(/\d+/).each { |num|
        @hide_all_switch.push(num.to_i) if num.to_i > 0 }
      when YEA::REGEXP::SKILL::HIDE_EVAL_ON
        @hide_eval_on = true
      when YEA::REGEXP::SKILL::HIDE_EVAL_OFF
        @hide_eval_on = false
      else
        next unless @hide_eval_on
        @hide_eval = "" if @hide_eval.nil?
        @hide_eval += line.to_s
      #---
      end
    } # self.note.split
    #---
  end
  
end # RPG::Skill

#==============================================================================
# ■ Window_SkillList
#==============================================================================

class Window_SkillList < Window_Selectable
  
  #--------------------------------------------------------------------------
  # overwrite method: include?
  #--------------------------------------------------------------------------
  def include?(item)
    return false if hide_eval?(item)
    return false if item.hide_always
    return false if item.hide_in_battle && $game_party.in_battle
    return false if hide_any_switch?(item)
    return false if hide_all_switch?(item)
    unless @actor.nil?
      return false if item.hide_until_usable && !@actor.usable?(item)
    end
    return item && item.stype_id == @stype_id
  end
  
  #--------------------------------------------------------------------------
  # new method: hide_eval?
  #--------------------------------------------------------------------------
  def hide_eval?(item)
    return false if item.hide_eval.nil?
    return eval(item.hide_eval)
  end
  
  #--------------------------------------------------------------------------
  # new method: hide_any_switch?
  #--------------------------------------------------------------------------
  def hide_any_switch?(item)
    for switch_id in item.hide_any_switch
      return true if $game_switches[switch_id]
    end
    return false
  end
  
  #--------------------------------------------------------------------------
  # new method: hide_all_switch?
  #--------------------------------------------------------------------------
  def hide_all_switch?(item)
    return false if item.hide_all_switch == []
    for switch_id in item.hide_all_switch
      return false unless $game_switches[switch_id]
    end
    return true
  end
  
end # Window_SkillList

#==============================================================================
#
# ▼ End of File
#
#==============================================================================[/pre][/fold]
<hide eval>
$game_party.item_number($data_items[子弹ID]) == 0
</hide eval>

(你上个提问帖解决了没有?
回复

使用道具 举报

梦石
0
星屑
88
在线时间
19 小时
注册时间
2021-7-6
回帖
3
 楼主| 发表于 2023-5-13 08:47:00 | 显示全部楼层
alexncf125 发表于 2023-5-13 05:52
https://yanflychannel.wordpress.com/rmvxa/menu-scripts/hide-menu-skills/

因为没有梯子所以一直没点进去看..

点评

已编辑  发表于 2023-5-13 10:41
做出来了!做出来了!rpg!你感觉如何,如何呀!
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部