[XP] Skill Use Limitation

Started by KK20, August 12, 2012, 06:17:22 pm

Previous topic - Next topic

KK20

Skill Use Limitation
Authors: KK20
Version: 1.00
Type: Custom Skill System
Key Term: Custom Skill System



Introduction

Certain skills cannot be used when the battler has a certain state applied to them or if a Game Switch is ON.
Likewise, certain skills cannot be used unless the actor has a certain state on or a Game Switch is ON.


Features


  • Option to make certain skills not be used if the battler is affected by a specific status ailment or if a Game Switch is on.

  • Option to make certain skills only be used if the battler is affected by a specific status ailment or if a Game Switch is on.




Screenshots

None.


Demo

None.


Script

Below the default scripts and above main. To be safe, place right before main.
Spoiler: ShowHide

=begin
===============================================================================
Skill Use Limitations                                                 Ver. 1.00
- By KK20                                                            [8/12/12]
===============================================================================

[Information]
  Certain skills cannot be used when the battler has a certain state applied to
  them or if a Game Switch is ON. Likewise, certain skills cannot be used
  unless the actor has a certain state on or a Game Switch is ON.
   
   
[How to Use]
  Configuration instructions can be found below. Examples also posted.
 
 
[Notes]
  * The script will check if the skill cannot be used BEFORE checking if a
    certain state/switch is on to allow the use of the skill
    (prevention takes higher priority than enabling)
  * If a skill can only be used when either applied with a certain state and if
    a certain switch is on, only one or the other must be satisfied to enable use
 
===============================================================================
Credits
- KK20        : For the script
- Raziel 0128 : For requesting/idea
===============================================================================
=end


#==============================================================================
# Class Game_Battler
#==============================================================================
class Game_Battler
 
  #~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
  #         B E G I N        C O N F I G U R A T I O N
  #~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
 
  def state_prevent_skill_use(skill_id)
    #----------------------------
    # Define an array of state IDs that prevent the skill in question from
    # being used.
    #    when skill_id then return [array of state IDs]
    #----------------------------
    case skill_id
    when 1 then return [4,5,6] #Can't use Heal if Dazzle,Mute,or Confused
    when 2 then return [5,6] #Can't use Greater Heal if Mute or Confused
    when 3 then return [5] #Can't use Mass Heal if Mute
    else
      return []
    end
  end
 
  def state_enable_skill_use(skill_id)
    #----------------------------
    # Define an array of state IDs that enables the skill in question to
    # be used.
    #    when skill_id then return [array of state IDs]
    #----------------------------
    case skill_id
    when 4 then return [14,15,16] #Can use Remedy if Barrier,Resist,or Blink
    when 5 then return [15,16] #Can use Greater Remedy if Resist or Blink
    when 6 then return [15] #Can use Raise if Resist
    else
      return []
    end
  end
 
  def switch_prevent_skill_use(skill_id)
    #----------------------------
    # Define an array of switch IDs that prevent the skill in question from
    # being used.
    #    when skill_id then return [array of switch IDs]
    #----------------------------
    case skill_id
    when 1 then return [1,2,3] #Heal can't be used if Switch 1,2,or 3 is ON
    when 2 then return [2,3] #Greater Heal can't be used if Switch 2 or 3 is ON
    when 3 then return [3] #Mass Heal can't be used if Switch 3 is ON
    else
      return []
    end
  end
 
  def switch_enable_skill_use(skill_id)
    #----------------------------
    # Define an array of switch IDs that enables the skill in question to
    # be used.
    #    when skill_id then return [array of switch IDs]
    #----------------------------
    case skill_id
    when 4 then return [4,5,6] #Remedy can be used if Switch 4,5,or 6 is ON
    when 5 then return [5,6] #Greater Remedy can be used if Switch 5 or 6 is ON
    when 6 then return [6] #Raise can be used if Switch 6 is ON
    else
      return []
    end
  end
 
  #~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
  #         E N D       C O N F I G U R A T I O N
  #~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
   
  alias call_skill_can_use_orig_method skill_can_use?
  #--------------------------------------------------------------------------
  # * Determine Usable Skills
  #     skill_id : skill ID
  #--------------------------------------------------------------------------
  def skill_can_use?(skill_id)
    # Check if a switch is on that prevents this skill from use
    unless switch_prevent_skill_use(skill_id) == []
      switch_prevent_skill_use(skill_id).each{|id| return false if $game_switches[id]}
    end
    # Check if a state is applied that prevents this skill from use
    unless state_prevent_skill_use(skill_id) == []
      state_prevent_skill_use(skill_id).each{|id| return false if self.state?(id)}
    end
    # Check if state or switch must be on to allow the skill's use
    unless switch_enable_skill_use(skill_id) == [] and state_enable_skill_use(skill_id) == []
      switch_enable_skill_use(skill_id).each{|id| return true if $game_switches[id]}
      state_enable_skill_use(skill_id).each{|id| return true if self.state?(id)}
      # Because neither a switch or state was on, the skill can't be used
      return false
    end
    # Call original 'skill_can_use?' method
    call_skill_can_use_orig_method(skill_id)
  end
 
end



Instructions

Instructions in the script. Configuration help is also there.


Compatibility

Alias of Game_Battler method skill_can_use?
Works with Blizz-ABS (and probably all other CBS's).
Should be highly compatible otherwise.


Credits and Thanks


  • KK20 - Creating the script

  • Raziel 0128 - For requesting/idea




Author's Notes

A quick browse through the database and I could only find one script that did half what this script does. Think of this as an add-on/revival script. Also quite surprised something like this doesn't exist around here despite being so easy...
Have fun! :)





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!