Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #========================================================================
- # ++ Advanced Disable/Silence States v1.0 (10/29/11)
- #========================================================================
- # RMVX script by:
- # Mr. Bubble (http://mrbubblewand.wordpress.com/)
- #
- # Special thanks to:
- # Mithran (for Regexp examples and code design inspiration)
- # KGC (for Regexp examples)
- #
- # Please do not repost elsewhere without direct permission.
- #========================================================================
- # This is a rather simple script which expands upon silencing/disabling
- # skills from being used when inflicted by a state. In default RMVX, when
- # a state's "Restriction" setting is set to "Cannot Use Magic", it will
- # only silence/disable skills that have a spi_f (spirit factor) greater
- # than 0. That just isn't enough.
- # This script provides some more options for disable/silence states
- # and can hopefully help with providing more interesting battle mechanics.
- #------------------------------------------------------------------------
- # ++ Changelog ++
- # v1.0 - Initital release
- #------------------------------------------------------------------------
- # ++ How To Use ++
- #
- # This script uses state notetags exclusively. There is (currently) no
- # customization module in this script. Notetags are placed in the
- # "Note" box at the lower-right corner of the State tab in your
- # project's database.
- #------------------------------------------------------------------------
- # ++ State Notetag Info ++
- #
- # All references to the keyword "disable" is interchangable with the
- # keyword "silence". For example:
- #
- # <disable all skills>
- # or
- # <silence all skills>
- #
- # Using either of these tags will accomplish the same thing. For
- # simplicity's sake, I will simply use the keyword "disable" in the rest
- # this document.
- #
- # Rememeber that all notetags in this script are for State noteboxes only!
- #========================================================================
- # ++ State Notetags ++
- #========================================================================
- #
- # <disable all skills>
- #
- # -Disables all skills when inflicted by the state.
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- #
- # <disable physical skills>
- #
- # -Disables all skills that have the "Physical Attack" option checkmarked.
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- #
- # <disable non-physical skills>
- #
- # -Disables all skills that *DO NOT* have the "Physical Attack" option
- # checkmarked.
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- #
- # <disable elements: elem_ids>
- #
- # -Disables skills that have a specific element. elem_ids can be a list
- # of element ID numbers separated by commas. Element ID numbers can be
- # found under the "System" tab in your database.
- #
- # Example Notetag:
- # <disable elements: 9,10,11>
- #
- # This example tag will disable all skills with the element ID number
- # of 9, 10, or 11.
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- #
- # <disable skills: skill_ids>
- #
- # -Disables specific skill IDs from being used. skill_ids can be a list
- # of skill ID numbers separated by commas. Skill ID numbers can be
- # found under the "Skills" tab in your database.
- #
- # Example Notetag:
- # <disable skills: 33,34>
- #
- # This example tag will disable skill IDs 33 and 34 from being used
- # if the actor has them learned.
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- #
- # <disable "factor" skills>
- #
- # -Disables skills that have a "factor" of more than zero in a
- # certain stat. "factor" is the abbreviated name of the stat (do not
- # include quotes, see examples).
- #
- # Available factors are:
- # atk
- # spi
- #
- # More can be added by request.
- #
- # Example:
- # <disable atk skills>
- #
- # This example tag will disable skills that have an atk_f of
- # more than 0 (zero).
- #
- # Example:
- # <disable spi skills>
- #
- # This example tag will disable skills that have an spi_f of
- # more than 0 (zero). This replicates VX's default silence option.
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # Requires KGC_Overdrive installed in your project.
- #
- # <disable overdrive skills>
- # or
- # <disable od skills>
- #
- # -Disables skills tagged as Overdrive skills, preventing their use.
- #========================================================================
- # ++ Scripter Info ++
- #========================================================================
- # This script aliases the following default methods:
- #
- # Game_Battler#skill_can_use?(skill)
- #------------------------------------------------------------------------
- $imported = {} if $imported == nil
- $imported["BubsAdvancedDisableStates"] = true
- class Game_Battler
- #--------------------------------------------------------------------------
- # ++ Determine Usable Skills : alias
- # skill : skill
- #--------------------------------------------------------------------------
- alias skill_can_use_bubs_advanced_skill_disable skill_can_use? unless $@
- def skill_can_use?(skill)
- return false unless skill_can_use_bubs_advanced_skill_disable(skill) # alias
- return false if disabled?(skill) # advanced disable states check
- return true
- end
- #--------------------------------------------------------------------------
- # ++ Determine Disabled State Flags
- #--------------------------------------------------------------------------
- # returns true if the skill is unusable due to a state
- def disabled?(skill)
- disabled = false
- for state in states
- # all skills disabled check
- if state.all_skills_disabled?
- disabled = true
- # physical skills check
- elsif skill.physical_attack && state.physical_skills_disabled?
- disabled = true
- # non-physical skills check
- elsif !skill.physical_attack && state.non_physical_skills_disabled?
- disabled = true
- # element_set check
- elsif state.skill_element_disabled?(skill)
- disabled = true
- # skill id check
- elsif state.skill_id_disabled?(skill)
- disabled = true
- elsif state.skill_factor_disabled?(skill)
- disabled = true
- # overdrive check
- elsif $imported["OverDrive"]
- if skill.overdrive? && state.overdrive_skills_disabled?
- disabled = true
- end
- end
- break if disabled
- end # end for state in states
- return disabled
- end # end disabled?(skill)
- end
- #--------------------------------------------------------------------------
- # ++ Regexp
- #--------------------------------------------------------------------------
- module Bubs
- module AdvancedDisableStatesRegexp
- # <disable physical skills>
- DISABLE_PHYSICAL =
- /<(?:SILENCE|disable)[_\s]?(?:phys|physical)[_\s]?(?:skill[s]?)?\s?>/i
- # <disable non-physical skills>
- DISABLE_NON_PHYSICAL =
- /<(?:SILENCE|disable)[_\s]?non[-_\s]?(?:phys|physical)?[_\s]?(?:skill[s]?)?\s?>/i
- # <disable all skills>
- DISABLE_ALL =
- /<(?:SILENCE|disable)[_\s]?all[_\s]?(?:skill[s]?)?\s?>/i
- # <disable skill elem: ids>
- DISABLE_ELEMENTS =
- /<(?:SILENCE|disable)[_\s]?(?:skill[s]?)?[_\s]?(?:ele[m]?|element[s]?)\s?[:]?\s?(\d+(?:\s*,\s*\d+)*)\s?>/
- # <disable skill ids: ids>
- DISABLE_SKILLS =
- /<(?:SILENCE|disable)[_\s]?skill[s]?[_\s]?(?:id[s])?\s?[:]?\s?(\d+(?:\s*,\s*\d+)*)\s?>/
- # <disable overdrive skills>
- DISABLE_OVERDRIVE =
- /<(?:SILENCE|disable)[_\s]?(?:OD|over[_\s]?drive)[_\s]?(?:skill[s]?)?\s?>/
- # <disable factor skills>
- STAT_FACTORS =
- /(atk|spi|def|agi|dex|res)/
- DISABLE_STAT_FACTORS =
- /<(?:SILENCE|disable)[_\s]?#{STAT_FACTORS}[_\s]?skill[s]?\s?>/
- end # module Bubs
- end # module AdvancedDisableRegexp
- #--------------------------------------------------------------------------
- # ++ RPG::State
- #--------------------------------------------------------------------------
- class RPG::State
- include Bubs::AdvancedDisableStatesRegexp
- #--------------------------------------------------------------------------
- # ++ Create Advanced Disable Cache
- #--------------------------------------------------------------------------
- def create_advanced_disable_cache
- # Skill tag cache
- @disable_all_skills = false
- @disable_physical_skills = false
- @disable_non_physical_skills = false
- @disable_skill_elements = []
- @disable_skill_ids = []
- @disable_stat_factors = []
- @disable_overdrive_skills = false
- self.note.split(/[\r\n]+/).each { |line|
- case line
- when DISABLE_PHYSICAL
- @disable_physical_skills = true
- when DISABLE_NON_PHYSICAL
- @disable_non_physical_skills = true
- when DISABLE_ALL
- @disable_all_skills = true
- when DISABLE_ELEMENTS
- element_ids = $1.scan(/\d+/)
- element_ids.each { |id|
- @disable_skill_elements.push(id.to_i)
- }
- when DISABLE_SKILLS
- skill_ids = $1.scan(/\d+/)
- skill_ids.each { |id|
- @disable_skill_ids.push(id.to_i)
- }
- when DISABLE_STAT_FACTORS
- @disable_stat_factors.push($1)
- when DISABLE_OVERDRIVE
- @disable_overdrive_skills = true
- end
- } # <-
- @advanced_disable_cache = true
- end
- #--------------------------------------------------------------------------
- # ++ Determine Physical Skills Disable
- #--------------------------------------------------------------------------
- def physical_skills_disabled?
- create_advanced_disable_cache if @advanced_disable_cache.nil?
- return @disable_physical_skills
- end
- alias physical_skills_disable? physical_skills_disabled? unless $@
- #--------------------------------------------------------------------------
- # ++ Determine Non-Physical Skills Disable
- #--------------------------------------------------------------------------
- def non_physical_skills_disabled?
- create_advanced_disable_cache if @advanced_disable_cache.nil?
- return @disable_non_physical_skills
- end
- alias non_physical_skills_disable? non_physical_skills_disabled? unless $@
- #--------------------------------------------------------------------------
- # ++ Determine All Skills Disable
- #--------------------------------------------------------------------------
- def all_skills_disabled?
- create_advanced_disable_cache if @advanced_disable_cache.nil?
- return @disable_all_skills
- end
- alias all_skills_disable? all_skills_disabled? unless $@
- #--------------------------------------------------------------------------
- # ++ Determine Skill Elements Disable
- #--------------------------------------------------------------------------
- def skill_element_disabled?(skill)
- create_advanced_disable_cache if @advanced_disable_cache.nil?
- skill.element_set.each { |elem_id|
- return true if @disable_skill_elements.include?(elem_id)
- }
- return false
- end
- alias skill_element_disable? skill_element_disabled? unless $@
- #--------------------------------------------------------------------------
- # ++ Determine Skill IDs Disable
- #--------------------------------------------------------------------------
- def skill_id_disabled?(skill)
- create_advanced_disable_cache if @advanced_disable_cache.nil?
- return true if @disable_skill_ids.include?(skill.id)
- return false
- end
- alias skill_id_disable? skill_id_disabled? unless $@
- #--------------------------------------------------------------------------
- # ++ Determine Skill Factor Disable
- #--------------------------------------------------------------------------
- def skill_factor_disabled?(skill)
- create_advanced_disable_cache if @advanced_disable_cache.nil?
- return false if @disable_stat_factors.empty?
- for factor in @disable_stat_factors
- if factor == "atk"
- return true if skill.atk_f > 0
- elsif factor == "spi"
- return true if skill.spi_f > 0
- end
- end
- return false
- end
- alias skill_factor_disable? skill_factor_disabled? unless $@
- #--------------------------------------------------------------------------
- # ++ Determine Overdrive Disable : Requires KGC_Overdrive
- #--------------------------------------------------------------------------
- def overdrive_skills_disabled?(skill)
- create_advanced_disable_cache if @advanced_disable_cache.nil?
- return @disable_overdrive_skills
- end
- alias overdrive_skills_disable? overdrive_skills_disabled? unless $@
- end # RPG::State
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement