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.

A very simple but useful script needed

I need a script that a skill in certain element ( for example : "Fire" element ) will have different colour of text...
What I mean when battle, choose skill and the skill with the element will appear in a Yellow colour...
 
Like this?

Code:
class Window_Skill < Window_Selectable
  # Skill color by element
  # Don't forget to specify skill color for each element,
  # else normal color will be used.
  # Format:
  #
  # element_id => my_color
  #
  # where:
  # - element_id is element ID as specified in the game database
  #   (without any trailing zeroes).
  # - my_color is any color you wish to use.
  # Predefined colors are normal_color, disabled_color, system_color,
  # crisis_color, knockout_color, and text_color(n) where n = 0 to 7
  # (this is the same color code you use to color text in message windows).
  # Or, define your own color by using 
  #
  # Color.new(red, green, blue)
  #
  # where red, green, blue are red/green/blue intensity, ranged from 0 to 255,
  # being 0 is the least intensity and 255 is the highest intensity.
  # E.g. white is Color.new(255, 255, 255) and black is Color.new(0, 0, 0).
  # Examples as follows:
  SKILL_COLOR =
  {
  1 => Color.new(255, 0, 0),
  6 => Color.new(158, 234, 125),
  9 => Color.new(0, 0, 0)
  }
  # If a skill has more than one element, specify which element will have
  # the highest priority
  # Format:
  #
  # skill_id => element_id_with_highest_priority
  #
  # where:
  # - skill_id is the skill ID as specified in the game database
  #   without any trailing zeroes).
  # - element_id_with_highest_priority is self-explanatory
  #   (don't forget to exclude the trailing zeroes).
  # Examples as follows:
  SKILL_ELEMENT_HIGHEST_PRIORITY =
  {
  57 => 9
  }
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    skill = @data[index]
    if @actor.skill_can_use?(skill.id)
      # Determine text color by element
      # Have more than one element?
      if skill.element_set.size > 1
        # Pick the most preferred element to pick
        if SKILL_ELEMENT_HIGHEST_PRIORITY.include?(skill.id)
          element = SKILL_ELEMENT_HIGHEST_PRIORITY[skill.id]
        end
      else
        # Pick the first and the only element
        element = skill.element_set[0]
      end
      # Has element?
      unless element == nil
        # Has color?
        if SKILL_COLOR.include?(element)
          self.contents.font.color = SKILL_COLOR[element]
        else
          self.contents.font.color = normal_color
        end
      else
        self.contents.font.color = normal_color
      end
    else
      self.contents.font.color = disabled_color
    end
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 32
    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, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
    self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
  end  
end

Just copy the code and paste it in a new page above Main. It should not interfere with any other script. Not tested with SDK.
 

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