[XP] Conditions Disabling Skills

Started by Raziel 0128, January 08, 2012, 08:49:45 am

Previous topic - Next topic

Raziel 0128

Hello I have what is hopefully a relatively simple request.

Can someone make a script where you can disable (so the skills grey out and are unusable). Ideally if under X state or if Y switch is on. I know the mute status does this to an extent, but I'd like to further diversify my skills. So that some conditions disable certain skill "types." So it's easier to selectively disable skills when under a state rather than just based on which attributes they use. With different states disabling different skills.

I was also hoping to use switch or variables to designate battle "conditions/environments" like "You can't use X skilltype."

As far as I'm aware there's no script that does this. So if anyone feels like making one I'd be very grateful.

KK20

Game_Battler: ShowHide
#==============================================================================
# Class Game_Battler
#  << Edit by KK20 >>
#==============================================================================
class Game_Battler
  #~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
  #         C O N F I G U R A T I O N
  #~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
  def switch_limits(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 state_limits(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
  #~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
  #         E N D       C O N F I G U R A T I O N
  #~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
 
  alias skill_can_use_orig 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_limits(skill_id) == []
      switch_limits(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_limits(skill_id) == []
      state_limits(skill_id).each{|id| return false if self.state?(id)}
    end
    # Call original 'skill_can_use?' method
    skill_can_use_orig(skill_id)
  end
end

Configuration is located inside the script. Place anywhere after Game_Battler and before Main (duh...). Did this pretty quick.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

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

Join the CP Discord Server!

Raziel 0128

Quote from: KK20 on January 10, 2012, 05:44:27 pm
Game_Battler: ShowHide
#==============================================================================
# Class Game_Battler
#  << Edit by KK20 >>
#==============================================================================
class Game_Battler
  #~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
  #         C O N F I G U R A T I O N
  #~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
  def switch_limits(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 state_limits(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
  #~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
  #         E N D       C O N F I G U R A T I O N
  #~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
 
  alias skill_can_use_orig 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_limits(skill_id) == []
      switch_limits(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_limits(skill_id) == []
      state_limits(skill_id).each{|id| return false if self.state?(id)}
    end
    # Call original 'skill_can_use?' method
    skill_can_use_orig(skill_id)
  end
end

Configuration is located inside the script. Place anywhere after Game_Battler and before Main (duh...). Did this pretty quick.


Thanks I tried it and it worked perfectly, thanks a lot.  :)