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.

list learned skils in one color, list other skills in other color

S0L0

Member

My idea is, to show a list of ALL avaliable skills at a specific type, but show only the learned skills (not the usable ...) in one color and the ones not learned yet in another color, heres the code I'm currently using:

Code:
class Window_Skill < Window_ModifiedSelectable

  def initialize(actor)
    super(32, 50, 420, 512)
    @actor = actor
    @column_max = 1
    self.z = 100
    refresh(0)
    self.index = 0
  end

  def skill
    return @data[self.index]
  end

  def refresh(type)
    @type = type
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in 0...$data_skills.size#@actor.skills.size
      skill = $data_skills[i]#[@actor.skills[i]]
      if skill != nil
        case @type
        when 0
          if $light_skills_ids.include?(i)
            @data.push(skill)
          end
        when 1
          if $dark_skills_ids.include?(i)
            @data.push(skill)
          end
        when 2
          if $elemental_skills_ids.include?(i)
            @data.push(skill)
          end
        when 3
          if $summon_skills_ids.include?(i)
            @data.push(skill)
          end
        end
      end
    end
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 60)
      self.contents.font.name = "Comic Sans MS"
      self.contents.font.size = 20
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end

  def draw_item(index)
    skill = @data[index]
    x = 4 + index % @column_max * (288 + 60)
    y = index / @column_max * 60
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(skill.icon_name)      
#    opacity = self.contents.font.color = normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 48, 48))#, opacity
    if @actor.skill_can_use?(skill.id)
      bitmap = RPG::Cache.icon(skill.icon_name)
      self.contents.font.color = shadow_color
      self.contents.draw_text(x + 54, y + 2, 204, 32, skill.name, 0)
      self.contents.font.color = normal_color
      self.contents.draw_text(x + 52, y, 204, 32, skill.name, 0)
      self.contents.font.color = shadow_color
      self.contents.draw_text(x + 246, y + 2, 48, 32, skill.sp_cost.to_s, 2)
      self.contents.font.color = normal_color
      self.contents.draw_text(x + 244, y, 48, 32, skill.sp_cost.to_s, 2)
    else
      bitmap = RPG::Cache.icon(skill.icon_name+"_disabled")
      self.contents.font.color = shadow_color
      self.contents.draw_text(x + 50, y + 2, 204, 32, skill.name, 0)
      self.contents.font.color = disabled_color
      self.contents.draw_text(x + 52, y, 204, 32, skill.name, 0)
      self.contents.font.color = shadow_color
      self.contents.draw_text(x + 246, y + 2, 48, 32, skill.sp_cost.to_s, 2)
      self.contents.font.color = disabled_color
      self.contents.draw_text(x + 244, y, 48, 32, skill.sp_cost.to_s, 2)
    end
  end

  def update_help
    @help_window.set_text(self.skill == nil ? "" : self.skill.description)
  end
  
end

As you may see, I made the skill to be "pushed" from ALL the avaliable skills, but now I want to show only the learned ones in normal_color with normal icon and the not learned yet in disabled_color with icon+"_disabled"

So I searched on the Scripts for any definition of style /skill_learn or something, but all I found was the /skill_can_use?, but this method dont' work for my idea, since the skil_can_use means if a skill can be used in batle, menu, never or always, and this is not my point, my point is show skills wich we already learned in one color and the not learned yet in a different color

Any ideas?

thanks
 
http://www.phylomortis.com/resource/script/class/class-ga.html said:
Skill_Learn?

Arguments:
Skill_ID: The ID of the skill to be checked.

Local Variables: None

How it Works: Returns true if the skill with the specified ID is included in the actor's array of learned skills.
Replace the
Code:
@actor.skill_can_use?(skill.id)
for
Code:
@actor.skill_learn?(skill.id)
 

S0L0

Member

man... I searched for the def of skill_learn? and didn't found it yesterday ..., and now tested it and works good... lol, dunno why but i got a feeling was bad wrote :P

thanks

PS: if depend of me, you are free for "close" this topic
 

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