Chaos Project

RPG Maker => General Discussion => Topic started by: dvkrane on February 17, 2013, 06:28:53 pm

Title: Categorized Skills Script?
Post by: dvkrane on February 17, 2013, 06:28:53 pm
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?
Title: Re: Categorized Skills Script?
Post by: KK20 on February 17, 2013, 08:22:57 pm
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
Title: Re: Categorized Skills Script?
Post by: Blizzard on February 18, 2013, 02:18:45 am
Or just use Skill Separation System from Tons of Add-ons.