Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Conditional Skills and Equipment

Conditional Skills and Equipment VX
Version: 2.6.1


Introduction

I was inspired by a request to make this script. It allows you to set special use conditions to any skills or equipement you want. I meant to post this here ages ago, but never did xD

Read Instructions Before Using

Features

Allows you to make skills and equipment that require special conditions to be used.
  • Whether certain states are inflicted
  • Whether certain weapons are equipped
  • Whether certain armours are equipped
  • Whether certain items are in your inventory (which the skill can use up)
  • Whether HP is MORE or LESS than a percent of the MAXHP
  • Whether the LEVEL is MORE or LESS than a certain point
  • Whether the actor is a certain class
  • Whether you have a certain amount of gold (which can be used up)
  • Whether a certain actor is in your party (and alive)
  • Whether a certain amount of actors are in your party (and alive)
  • Whether you have 1 or 2 free hands
  • Whether the actor has a certain amount of ATK
  • Whether the actor has a certain amount of DEF
  • Whether the actor has a certain amount of SPI
  • Whether the actor has a certain amount of AGI
You can set the script to remove equipment when they don't meet their requirements anymore
eg. A Begginers Below Level 5 Sword will be removed when you reach level 5​
The script can also hide any skills you want when they can't be used.

Screenshots

Can't really take a screenshot....

Script

Code:
#==============================================================================
# ** Conditional Skills And Equipment
#------------------------------------------------------------------------------
# By Syvkal
# Version 2.6.1
# 05-09-08
#==============================================================================
#
#  - INTRODUCTION -
#
# This script can be used to set special use conditions to skills and equipment
# There are a number of different ones you can check:
#
#------------------------------------------------------------------------------
#
#  - FEATURES - 
#
#  There are a number of different Conditional features that can be used
#  These include:
#
#  STATE  - Whether certain states are inflicted
#  WEAPON - Whether certain weapons are equipped
#  ARMOUR - Whether certain armours are equipped
#  ITEM   - Whether certain items are in your inventory (which can be used up)
#  HP	 - Whether HP is MORE or LESS than a percent of the MAXHP
#  GOLD   - Whether the party has a certain amount of gold (which can be used up)
#  LEVEL  - Whether the LEVEL is MORE or LESS than a certain point
#  CLASS  - Whether the actor is a certain class
#  PARTYMEMBER - Whether a certain actor is in your party (and alive)
#  PARTYNUMBER - Whether a certain amount of actors are in your party (and alive)
#  FREEHAND	- Whether the actor has 1 or 2 free hands
#  ATK  -  Whether the actor has a certain amount of ATK
#  DEF  -  Whether the actor has a certain amount of DEF
#  SPI  -  Whether the actor has a certain amount of SPI
#  AGI  -  Whether the actor has a certain amount of AGI
#
#  NOSHOW - Add this to make a skill not appear when it can't be used
#
#  More than one can be used on any skill or equipement
#  However only some can be used for skills and only some for equipement
#
#------------------------------------------------------------------------------
#
#  - USAGE -
#
#  First make a skill/equipment in the Database and in it's note box place this:
#
#		<skill>				  <equip>
#		 .....		 or		 .....
#		<skill>				  <equip>
#
#  You must place any necessary Coding or tags in there
#  Anything you place in there must be on a separate line
#
#  Condition tags must be followed by a number, multiple numbers can be entered
#  these must be separated by a comma ','
#  Some conditions can use the '&' feature
#
#  See EXAMPLES if you are unsure  
#
#------------------------------------------------------------------------------
#
#  - SKILLS -
#
#   The special conditions that can be set to skills are as follows:
#
#		   STATE  WEAPON  ARMOUR  HPLESS  HPMORE
#		   FREEHAND  ITEM  ITEMUSE  GOLD  GOLDUSE
#				LEVELLESS  LEVELMORE  CLASS
#				 PARTYNUMBER  PARTYMEMBER
#
#------------------------------------------------------------------------------
#
# - EQUIPMENT - 
#
#   The special conditions that can be set to equipment are as follows:
#
#		   LEVELLESS  LEVELMORE  WEAPON  ARMOUR
#					ATK  DEF  SPI  AGI
#
#------------------------------------------------------------------------------
#
#  - EXAMPLES -
#
#   Here is a list of examples to show you how to use each condition:
#
#   STATE12	-  State 12 must be inflicted to use the skill
#   WEAPON1	-  Weapon 1 must be equipped to use the skill
#   ARMOUR2,9  -  Both armours 2 and 9 must be equipped to use the skill
#   FREEHAND2  -  Both of the actors hands must be free to use the skill
#   HPLESS25   -  Health must be below 25% to use the skill
#   HPMORE50   -  Health must be above 50% to use the skill
#   ITEM1,2	-  Must have items 1, 2 and 3 to use the skill
#   ITEMUSE1,2 -  Must have and will use 1 of items 1 and 2 to use the skill
#   ITEM1&3,2  -  Must have 3 of item 1 and 1 of item 2 to use the skill
#   ITEMUSE1&3 -  Must have and will use 3 of item 1 to use the skill
#   GOLD1000   -  Must have 1000 Gold to use the skill
#   GOLDUSE100 -  Must have and will use 100 Gold to use the skill
#   CLASS1,2   -  Must be Class 1 or 2 (RTP : Paladin, Warrior) to use the skill
#   LEVELLESS5 -  Must be under Level 5 to use the skill
#   LEVELMORE9 -  Must be over level 9 to use the skill
#   PARTYMEMBER4 -  Must have Actor 4 (RTP : Ylva) to use the skill
#   PARTYNUMBER3 -  Must have 3 or more actors in the party to use the skill
#   ATK100  -  Must have ATK greater than or equal to 100
#   DEF100  -  Must have DEF greater than or equal to 100
#   SPI100  -  Must have SPI greater than or equal to 100
#   AGI100  -  Must have AGI greater than or equal to 100
#
#==============================================================================

   #===================================================#
   #  **  C O N F I G U R A T I O N   S Y S T E M  **  #
   #===================================================#
   
 # Remove Equipment when conditions don't apply anymore?
 REMOVE_EQUIP  = true
 # Show a message saying that the equipment has been removed?
 SHOW_MESSAGE  = true
 # Speed at which the message will disappear
 MESSAGE_SPEED = 2	 # 1 = Slow	 2 = Medium	 3+ = Very Fast
 # Amount of frames the message will stay for
 MESSAGE_STAY = 20	 # 20 is average - You want it lower if the speed is slow
 # Use an Icon in the message?
 USE_ICON	  = true
 # Message that tells you what has been removed
 EQUIP_REMOVE  = "%s unequipped"
 # Message explain's why
 EQUIP_MESSAGE = "%s can't use it anymore"

   #===================================================#
   #  **	 E N D   C O N F I G U R A T I O N	 **  #
   #===================================================#

#==============================================================================
# ** Script Import
#------------------------------------------------------------------------------
#  Added to make it work with or without Conditional Skills
#==============================================================================
  
  $imported = {} if $imported == nil
  $imported["ConditionalSkill"] = true
   
#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
#  Added Checks for Conditional Skills And Equipment
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------  
  alias skill_use_original skill_can_use?
  #--------------------------------------------------------------------------
  # * Includes The NOTES Module
  #--------------------------------------------------------------------------  
  include NOTES
  #--------------------------------------------------------------------------
  # * Determine Usable Skills
  #--------------------------------------------------------------------------
  def skill_can_use?(skill)
	return false unless skill_condition_can_use?(skill)
	skill_use_original(skill)
  end
  #--------------------------------------------------------------------------
  # * Determine Usable Skill Conditions
  #--------------------------------------------------------------------------
  def skill_condition_can_use?(skill)
	if has_tag?(skill.note, '<skill>')
	  @conditions = get_tag_area(skill.note, '<skill>')
	  if has_tag?(@conditions,'STATE')
		@tags = get_tag(@conditions,'STATE')
		for i in 0...@tags.size
		  return false unless state?(@tags[i].to_i)
		end
	  end
	  if has_tag?(@conditions,'WEAPON')
		@tags = get_tag(@conditions,'WEAPON')
		for i in 0...@tags.size
		  return false unless weapons.include?($data_weapons[@tags[i].to_i])
		end
	  end
	  if has_tag?(@conditions,'ARMOUR')
		@tags = get_tag(@conditions,'ARMOUR')
		for i in 0...@tags.size
		  return false unless armors.include?($data_armors[@tags[i].to_i])
		end
	  end 
	  if has_tag?(@conditions,'ITEM')
		@tags = get_multiple_tag(@conditions,'ITEM','USE')
		for i in 0...@tags.size
		  if @tags[i].is_a?(Array)
			return false unless $game_party.item_number($data_items[@tags[i][0].to_i]) >= @tags[i][1].to_i
		  else
			return false unless $game_party.item_number($data_items[@tags[i].to_i]) >= 1
		  end
		end  
	  end
	  if has_tag?(@conditions,'ITEM','USE')
		@tags = get_multiple_tag(@conditions,'ITEM','USE')
		for i in 0...@tags.size
		  if @tags[i].is_a?(Array)
			return false unless $game_party.item_number($data_items[@tags[i][0].to_i]) >= @tags[i][1].to_i
		  else
			return false unless $game_party.item_number($data_items[@tags[i].to_i]) >= 1
		  end
		end  
	  end
	  if has_tag?(@conditions,'HP','LESS')
		@tags = get_tag(@conditions,'HP','LESS')
		return false unless hp <= maxhp / (100 / @tags[0].to_i)
	  end
	  if has_tag?(@conditions,'HP','MORE')
		@tags = get_tag(@conditions,'HP','MORE')
		return false unless hp >= maxhp / (100 / @tags[0].to_i)
	  end
	  if has_tag?(@conditions,'LEVEL','LESS')
		@tags = get_tag(@conditions,'LEVEL','LESS')
		return false unless @level < @tags[0].to_i
	  end
	  if has_tag?(@conditions,'LEVEL','MORE')
		@tags = get_tag(@conditions,'LEVEL','MORE')
		return false unless @level > @tags[0].to_i
	  end
	  if has_tag?(@conditions,'CLASS')
		@tags = get_tag(@conditions,'CLASS')
		return false unless @class_id == @tags[0].to_i or @tags[1].to_i
	  end
	  if has_tag?(@conditions,'GOLD')
		@tags = get_multiple_tag(@conditions,'GOLD','USE')
		return false unless $game_party.gold >= @tags[0].to_i
	  end
	  if has_tag?(@conditions,'GOLD','USE')
		@tags = get_multiple_tag(@conditions,'GOLD','USE')
		return false unless $game_party.gold >= @tags[0].to_i
	  end
	  if has_tag?(@conditions,'PARTY','NUMBER')
		@tags = get_multiple_tag(@conditions,'PARTY','NUMBER')
		return false unless $game_party.existing_members.size >= @tags[0].to_i
	  end
	  if has_tag?(@conditions,'PARTY','MEMBER')
		@tags = get_multiple_tag(@conditions,'PARTY','MEMBER')
		return false unless $game_party.existing_members.include?($game_actors[@tags[0].to_i])
	  end
	  if has_tag?(@conditions,'FREEHAND')
		@tags = get_tag(@conditions,'FREEHAND')
		return false unless free_hands >= @tags[0].to_i
	  end
	end
	return true
  end
  #--------------------------------------------------------------------------
  # * Determine Usable Equipment Conditions
  #--------------------------------------------------------------------------
  def equipment_can_use?(equip)
	if equip != nil
	  if has_tag?(equip.note, '<equip>')
		@conditions = get_tag_area(equip.note, '<equip>')
		if has_tag?(@conditions,'LEVEL','LESS')
		  @tags = get_tag(@conditions,'LEVEL','LESS')
		  return false unless @level < @tags[0].to_i
		end
		if has_tag?(@conditions,'LEVEL','MORE')
		  @tags = get_tag(@conditions,'LEVEL','MORE')
		  return false unless @level > @tags[0].to_i
		end
		if has_tag?(@conditions,'WEAPON')
		  @tags = get_tag(@conditions,'WEAPON')
		  for i in 0...@tags.size
			return false unless weapons.include?($data_weapons[@tags[i].to_i])
		  end
		end
		if has_tag?(@conditions,'ARMOUR')
		  @tags = get_tag(@conditions,'ARMOUR')
		  for i in 0...@tags.size
			return false unless armors.include?($data_armors[@tags[i].to_i])
		  end
		end 
		if has_tag?(@conditions,'ATK')
		  @tags = get_tag(@conditions,'ATK')
		  return false unless actor.parameters[2, @level] >= @tags[0].to_i
		end
		if has_tag?(@conditions,'DEF')
		  @tags = get_tag(@conditions,'DEF')
		  return false unless actor.parameters[3, @level] >= @tags[0].to_i
		end
		if has_tag?(@conditions,'SPI')
		  @tags = get_tag(@conditions,'SPI')
		  return false unless actor.parameters[4, @level] >= @tags[0].to_i
		end
		if has_tag?(@conditions,'AGI')
		  @tags = get_tag(@conditions,'AGI')
		  return false unless actor.parameters[5, @level] >= @tags[0].to_i
		end
	  end
	end
	return true
  end
  #--------------------------------------------------------------------------
  # * Determine Hidden Skills
  #--------------------------------------------------------------------------
  def show_skill?(skill)
	return true if skill_can_use?(skill)
	if has_tag?(skill.note,'NOSHOW')
	  return skill_condition_can_use?(skill)
	end
	return true
  end
  #--------------------------------------------------------------------------
  # * Check For Free Hands
  #--------------------------------------------------------------------------
  def free_hands
	@free_hands = 0
	@free_hands += @weapon_id==0 ? 1 : 0
	@free_hands += @armor1_id==0 ? 1 : 0
	return @free_hands
  end
end

#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  Added removal of necessary skill components
#==============================================================================

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------  
  alias execute_skill_original execute_action_skill
  #--------------------------------------------------------------------------
  # * Includes The NOTES Module
  #--------------------------------------------------------------------------  
  include NOTES
  #--------------------------------------------------------------------------
  # * Execute Battle Action: Skill
  #--------------------------------------------------------------------------
  def execute_action_skill
	execute_skill_original
	skill = @active_battler.action.skill
	if has_tag?(skill.note, '<skill>')
	  @conditions = get_tag_area(skill.note, '<skill>')
	  if has_tag?(@conditions,'ITEM','USE')
		@tags = get_multiple_tag(@conditions,'ITEM','USE')
		for i in 0...@tags.size
		  if @tags[i].is_a?(Array)
			$game_party.lose_item($data_items[@tags[i][0].to_i],@tags[i][1].to_i,true)
		  else
			$game_party.lose_item($data_items[@tags[i].to_i],1,true)
		  end
		end
	  end
	  if has_tag?(@conditions,'GOLD','USE')
		@tags = get_tag(@conditions,'GOLD','USE')
		$game_party.lose_gold(@tags[0].to_i)
	  end
	end  
  end
end

#==============================================================================
# ** Scene_Skill
#------------------------------------------------------------------------------
#  Added removal of necessary skill components
#==============================================================================

class Scene_Skill < Scene_Base
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------  
  alias use_skill_original use_skill_nontarget
  #--------------------------------------------------------------------------
  # * Includes The NOTES Module
  #--------------------------------------------------------------------------  
  include NOTES
  #--------------------------------------------------------------------------
  # * Use Skill (apply effects to non-ally targets)
  #--------------------------------------------------------------------------
  def use_skill_nontarget
	if has_tag?(@skill.note, '<skill>')
	  @conditions = get_tag_area(@skill.note, '<skill>')
	  if has_tag?(@conditions,'ITEM','USE')
		@tags = get_multiple_tag(@conditions,'ITEM','USE')
		for i in 0...@tags.size
		  if @tags[i].is_a?(Array)
			$game_party.lose_item($data_items[@tags[i][0].to_i],@tags[i][1].to_i,true)
		  else
			$game_party.lose_item($data_items[@tags[i].to_i],1,true)
		  end
		end
	  end
	  if has_tag?(@conditions,'GOLD','USE')
		@tags = get_tag(@conditions,'GOLD','USE')
		$game_party.lose_gold(@tags[0].to_i)
	  end  
	  use_skill_original
	end
  end
end

#==============================================================================
# ** Window_EquipItem
#------------------------------------------------------------------------------
#  Added Check for Conditional Equipment
#==============================================================================

class Window_EquipItem < Window_Item
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------  
  alias enable_original enable?
  #--------------------------------------------------------------------------
  # * Whether to display item in enabled state
  #--------------------------------------------------------------------------
  def enable?(item)
	return false unless @actor.equipment_can_use?(item)
	enable_original(item)
  end
end

#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  Added removal of Equipment when conditions don't apply anymore
#==============================================================================

class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------  
  alias update_original update
  alias terminate_original terminate
  alias start_original start
  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  def start
	start_original
	@stay = MESSAGE_STAY
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
	terminate_original
	@notify_window.dispose if @notify_window
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
	update_original
	if @notify_window
	  @notify_window.update
	  @stay -= 1
	  if @stay <= 0
		@notify_window.opacity -= MESSAGE_SPEED
		@notify_window.contents_opacity -= MESSAGE_SPEED
	  end
	  if @notify_window.opacity == 0
		@notify_window.dispose
		@notify_window = nil
	  end
	end
	if REMOVE_EQUIP
	  update_equipment
	end
  end
  #--------------------------------------------------------------------------
  # * Update Equipment
  #--------------------------------------------------------------------------
  def update_equipment
	for actor in $game_party.members
	  for i in 0...actor.equips.size
		unless actor.equipment_can_use?(actor.equips[i])
		  if SHOW_MESSAGE
			unless @notify_window
			  @notify_window = Window_Base.new(0, 0, 320, 80)
			  w = @notify_window.width-32; h = @notify_window.height-32
			  @notify_window.contents = Bitmap.new(w, h)
			  @notify_window.x = (544 - @notify_window.width) / 2
			  @notify_window.y = (416 - @notify_window.height) / 2
			  @notify_window.z = 9998
			  icon_index = actor.equips[i].icon_index
			  if USE_ICON
				@notify_window.draw_icon(icon_index, 0, 4,true)
			  end
			  @notify_window.contents.draw_text(USE_ICON ? 24 : 0, 0, w, 24, sprintf(EQUIP_REMOVE, actor.equips[i].name), 0)
			  @notify_window.contents.draw_text(0, 24, w, 24, sprintf(EQUIP_MESSAGE, actor.name), 2)
			  @stay = MESSAGE_STAY
			  actor.change_equip(i, nil)
			end
		  end
		end
	  end	  
	end
  end
end

#==============================================================================
# ** Scene_Equip
#------------------------------------------------------------------------------
#  Edited to add 'equipment_can_use?' function
#==============================================================================

class Scene_Equip < Scene_Base
  #--------------------------------------------------------------------------
  # * Update Item Selection
  #--------------------------------------------------------------------------
  def update_item_selection
	if Input.trigger?(Input::B)
	  Sound.play_cancel
	  @equip_window.active = true
	  @item_window.active = false
	  @item_window.index = -1
	elsif Input.trigger?(Input::C)
	  if @actor.equipment_can_use?(@item_window.item) # Added 'equipment_can_use?'
		Sound.play_equip
		@actor.change_equip(@equip_window.index, @item_window.item)
		@equip_window.active = true
		@item_window.active = false
		@item_window.index = -1
		@equip_window.refresh
		for item_window in @item_windows
		  item_window.refresh
		end
	  else
		Sound.play_buzzer
	  end
	end
  end
end

#==============================================================================
# ** Window_Skill
#------------------------------------------------------------------------------
#  Edited to hide certain skills
#==============================================================================

class Window_Skill < Window_Selectable
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
	@data = []
	for skill in @actor.skills
	  @data.push(skill) if @actor.show_skill?(skill) # Added 'If' statement
	  if skill.id == @actor.last_skill_id
		self.index = @data.size - 1
	  end
	end
	@item_max = @data.size
	create_contents
	for i in 0...@item_max
	  draw_item(i)
	end
  end
end
Instructions

Put it under the Materials Section
Place my 'Notes Field System' above this script:
Code:
#==============================================================================
 # ** Notes Field System
 #------------------------------------------------------------------------------
 # By Syvkal
 # Version 1.5
 # 05-29-08
 #==============================================================================
 
 module NOTES
   
   def get_tag(field, tag, extra_tag = "")
	 note = ""+field
	 note = note.split("\r\n")
	 for i in 0...note.size
	   if note[i].include?(tag + extra_tag)
		 tags = note[i]
		 tags.slice!(tag)
		 if extra_tag != ""
		   tags.slice!(extra_tag)
		 end
		 tags = tags.split(/,\s*/)
		 return tags
	   end
	 end
	 return nil
   end
   
   def get_multiple_tag(field, tag, extra_tag = "")
	 note = ""+field
	 note = note.split("\r\n")
	 for i in 0...note.size
	   if note[i].include?(tag + extra_tag)
		 tags = note[i]
		 tags.slice!(tag)
		 if extra_tag != ""
		   tags.slice!(extra_tag)
		 end
		 tags = tags.split(/,\s*/)
		 for i in 0...tags.size
		   if tags[i].include?('&')
			 tags[i] = tags[i].split(/\s*\&\s*/)
		   end
		 end
		 return tags
	   end
	 end
	 return nil
   end
   
   def has_tag?(field, tag, extra_tag = "")
	 note = ""+field
	 if note.include?(tag + extra_tag)
	   return true
	 end
	 return false
   end
   
   def get_tag_area(field, area_tags)
	 note = ""+field
	 if note.include?(area_tags)
	   @yes = false
	   note = note.split(/#{area_tags}/)
	   note = note[1]
	   return note
	 else
	   return ""
	 end
   end
   
 end
Further instructions can be found in the script header.

Compatibility

Compatible with most things I hope. However, this script is under development, so bugs may occur. The script also changes 'Window_Skill's 'refresh' command and 'Scene_Equip's 'update_item_selection' command. However the small pieces of coding can easily be added where you need it.
 
Well the script really isn't that hard to set up, I'm sure you can figure it out.

It would be nice if you tried it out yourself instead of getting me to do all the work xD
 
I have made the script through VXs Notes Box.
I probably could make this for XP, however it would require a lot more input by the user (you would have to set up each skill in a separate place eg. text file or in the script itself)

I haven't worked with XP for a while, but I might consider it... might...
 

ikos

Member

Is there a way to make it to where any of a few weapons can be equipped?
Here's the most precise example I can conjure. In my project, characters have two weapon types.
This being said, I wouldn't expect someone to be able to use an archery based skill with a melee weapon.
I was thinking it you could have it to where any of the bows (IDs 23-35) would enable the skill access
 
Hey Syvkal, I have an error that pops up. However, only during a specific skill. The others are fine. Here's the text:

Script 'Syvkal's Conditional Skills' line 341: NoMethodError occured.
undefined method 'note' for nil:NilClass

I'm using the Tankentai SBS. Could that be a factor? However, it's only during that one skill. Even if I move the skill to another slot the error persists. HELP!
 
Sorry I have been really busy and still am. Currently I'm also on holiday so I won't be posting. However, its very unlikely that'll be updated on this sight - sorry - because I don't go on this one that much xD
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top