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.

[VX] Skill Requirements

Hi,

I'm looking for a VX script that's similar to SephirothSpawn's old Skill Requirements script; that is, a script that makes certain skills need x in order to be usable.

What I'm mainly looking for is to have skills that can only be used if certain weapon types/shields are equipped. For example, I want a skill like Leg Sweep to only be usable if spears are equipped, but not usable when that character is using a sword.

I did some searching, but all I found were the old scripts, so if anyone can point me in the right direction or make something like this, I'd really appreciate it. Thanks!
 

poccil

Sponsor

Such skills can be implemented by adding an extra check to the skill_can_use? method.  Insert the code below after all other scripts in the Materials section of the script editor.

To use it, add the tag "[RequiresWeaponElement: X]" to the skill's notes, where X is the weapon element ID (e.g.  element ID 1 is Melee), and/or the tag "[RequiresArmorElement: X]", where X is the armor element ID (e.g.  element ID 1 is Melee).  (Don't include the quotation marks.)

Code:
# Helper function to parse the skill notes from the database
def parseSkillNotes(tag)
 ret={}
 rgex=/\[#{tag}\:\s*(\d+)\]/i
 for skill in $data_skills
  next if !skill
  skill.note.gsub!(rgex){|o|
   ret[skill.id]=$1.to_i
  }
 end
 return ret
end

class Game_Actor
 @@_WeaponReq=nil
 @@_ArmorReq=nil
 alias :petero_SkillReq_skill_can_use? :skill_can_use?
 def skill_can_use?(skill)
  if petero_SkillReq_skill_can_use?(skill)
   if !@@_WeaponReq
    @@_WeaponReq=parseSkillNotes("RequiresWeaponElement")
    @@_ArmorReq=parseSkillNotes("RequiresArmorElement")
   end
   weaponreq=@@_WeaponReq[skill.id]
   if weaponreq
    found=false
    for weapon in self.weapons
     found=true if weapon && weapon.element_set.include?(weaponreq)
    end
    return false if !found
   end
   armorreq=@@_ArmorReq[skill.id]
   if armorreq
    found=false
    for armor in self.armors
     found=true if armor && armor.element_set.include?(armorreq)
    end
    return false if !found
   end
   return true
  end
  return false
 end
end
 
Hey poccil,

Thanks for the quick reply, but it's not working for me. I placed the script correctly and am not getting any errors, but I can still use the skills when I'm not supposed to be able to.

I set Dual Hit to be an attack that requires a slashing weapon (element 2) and inserted into the notes exactly as follows:

[RequiresWeaponElement: 2]

I also tried without the brackets, but I'm still able to use Dual Hit even with an item like a Long Bow.


EDIT: Nevermind, I got it to work somehow. I'm not really sure what I did, but I just recopied the script in and it worked okay. Thanks, poccil!
 

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