Categorized Skills Script?

Started by dvkrane, February 17, 2013, 06:28:53 pm

Previous topic - Next topic

dvkrane

Could someone point me in the right direction? I need a categorized skill window, or even better, a skill window that only shows skills of a certain element. I'm okay when it comes to scripting but I'm sure if someone explained how to do it, I could get it done. I've looked at the script for albertfish's Categorized Items Menu and it somewhat accomplishes what I'm looking for, except I need it for skills. Could someone help me?

KK20

February 17, 2013, 08:22:57 pm #1 Last Edit: February 17, 2013, 08:36:46 pm by KK20
You should know that the proper edits are to be done in the Window_Skill class. The actual drawing of the skill names and such occurs under the method refresh:

   @data = []
   for i in 0...@actor.skills.size
     skill = $data_skills[@actor.skills[i]]
     if skill != nil
       @data.push(skill)
     end
   end

You can use the method element_set to see the array of elements the skill uses. It's then a matter of checking what elements you want to display using include?.

   @data = []
   for i in 0...@actor.skills.size
     skill = $data_skills[@actor.skills[i]]
     if skill != nil and skill.element_set.include?(1) #=> If the skill contains the element 'Fire'
       @data.push(skill)
     end
   end

As for determining what elements you want to display each time, you should create an instance variable (such as @element_to_display) that you can access to change its value. Just be sure to call refresh again.

def initialize(actor)
 ...
 @element_to_display = 0 #=> A value of zero means it will draw all learned skills regardless of element
  ...
end
def refresh
 ...
   @data = []
   for i in 0...@actor.skills.size
     skill = $data_skills[@actor.skills[i]]
     if skill != nil and (@element_to_display == 0 or skill.element_set.include?(@element_to_display))
       @data.push(skill)
     end
   end
 ...
end
def element_to_display=(value)
 return if @element_to_display == value
 @element_to_display = value
 refresh
end

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!

Blizzard

Or just use Skill Separation System from Tons of Add-ons.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.