The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: cozziekuns on June 26, 2010, 06:47:38 PM

Title: Simple Sort Skill Inventory
Post by: cozziekuns on June 26, 2010, 06:47:38 PM
Simple Sort Skill Inventory
Version: 1.1
Author: cozziekuns
Date: June 26, 2010

Version History



Planned Future Versions


Description


This skill inventory allows you to sort your items in the categories: All, Damage, Healing and Status. You can even make your own categories, if that's how you roll.

Features


Screenshots

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi50.tinypic.com%2F34oemb7.png&hash=37b23b7b6436c1ca4267387e24bd619e88f6ac48)

Instructions

See header.

Script


Code: [Select]
#===============================================================================
#
# Cozziekuns Simple Skill Sort Inventory
# Last Date Updated: 6/01/2010
#
# This skill inventory allows you to sort your items in the categories: All,
# Damage, Healing and Status. You can even make your own categories, if that's
# how you roll.
#
#===============================================================================
# Updates
# -----------------------------------------------------------------------------
# o 06/26/10 - Created Script.
# o 10/17/10 - Added the virutally infinite commands function, and cleaned up
#              the script.
#===============================================================================
# What's to come?
# -----------------------------------------------------------------------------
# o Nothing! Suggest something.
#===============================================================================
# Instructions
# -----------------------------------------------------------------------------
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ? Materials but above ? Main. Remember to save.
#
# Change the modules to your liking. The "hard" parts have instructions of their
# own.
#===============================================================================

$imported = {} if $imported == nil
$imported["CozSimplSortSkillInvent"] = true

module COZZIEKUNS
  module SSSI
    CATEGORY_TEXT = "Category:"
   
#===============================================================================
# Extra Skill Categories
# ------------------------------------------------------------------------------
# Each item in the hash represents a certain category. For example, the first
# hash we see here is:
#
#  0 => [21, "All", false],
#
# The syntax of this is:
#
# Category ID => [Icon Number, Text, Prime],
#
# Probably the most important part, the category ID is the number you want to
# put into the notebox that the item contains. For example, if you wanted to
# make the skill "Teleport" into the category 4, you would put:
#
# \skill_category[4]
#
# into the notebox. Note that numbers 0, 1, 2, and 3 are special. They're prime
# categories. Sound special right? Not really, this just means you have to have
# them in the inventory for this script to work. I could've gotten rid of them,
# but that would've just given more work on your part (and mine), so bear with
# them, please. Icon Numbers and Text are pretty self explanatory.
#
# Last, but not least, is the "Prime" function. Setting this to "true" means
# that anything in the prime category will not show up in the item, weapon or
# armour categories. You can set if you want it to show up in all.
#===============================================================================
    SKILL_CATEGORIES = {
   
      0 => [21, "All", false],
      1 => [132, "Damage", false],
      2 => [128, "Healing", false],
      3 => [113, "Status", false],
      4 => [80, "Special", true],
      5 => [90, "Specialer", true],
      6 => [100, "Specialest", true],
    }
   
    SKILL_CATEGORY_WIDTH = 220 # How wide you want your text window.
    ALL_CATEOGRY_PRIME = false # If you want prime key items to show up in the all window.
    MAX_NUMBER = (544 - SKILL_CATEGORY_WIDTH) / 54 # The maximum number of icons that will fit.
  end
end

#==============================================================================
# ** RPG::Skill
#------------------------------------------------------------------------------
#  The superclass of all skills.
#==============================================================================

class RPG::Skill
  #--------------------------------------------------------------------------
  # * Cozziekuns Category Index
  #--------------------------------------------------------------------------
  def coz_kyriaki_category_index
    @coz_kyriaki_category_index = 0
    if self.note[/\\skill_category\[(\d+)]/i] != nil
      @coz_kyriaki_category_index = $1.to_i
    end
    return @coz_kyriaki_category_index
  end
end

#==============================================================================
# ** Window_Skill
#------------------------------------------------------------------------------
#  This window displays a list of usable skills on the skill screen, etc.
#==============================================================================

class Window_Skill < Window_Selectable
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh(sort_index = 0)
    @sort_index = sort_index
    @data = []
    for skill in @actor.skills
      next unless include?(skill)
      @data.push(skill)
      if skill.id == @actor.last_skill_id
        self.index = @data.size - 1
      end
    end
    @item_max = @data.size
    create_contents
    for i in 0...@item_max
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  # * Whether or not to include in skill list
  #     skill : skill
  #--------------------------------------------------------------------------
  def include?(skill)
    return case @sort_index
    when 0
      unless COZZIEKUNS::SSSI::ALL_CATEOGRY_PRIME
        if COZZIEKUNS::SSSI::SKILL_CATEGORIES[skill.coz_kyriaki_category_index][2]
          return false
        else
          return true
        end
      else
        return true
      end
    when 1
      if COZZIEKUNS::SSSI::SKILL_CATEGORIES[skill.coz_kyriaki_category_index][2]
        return false
      else
        return skill.base_damage > 0
      end
    when 2
      if COZZIEKUNS::SSSI::SKILL_CATEGORIES[skill.coz_kyriaki_category_index][2]
        return false
      else
        return skill.base_damage < 0
      end
    when 3
      if COZZIEKUNS::SSSI::SKILL_CATEGORIES[skill.coz_kyriaki_category_index][2]
        return false
      elsif skill.plus_state_set.size != 0
        return true
      else
        return skill.minus_state_set.size != 0
      end
    when 4..999
      return skill.coz_kyriaki_category_index == @sort_index
    end
  end
end

#==============================================================================
# ** Window_SkillCategory
#------------------------------------------------------------------------------
#  This window displays what type of skill is being displayed.
#==============================================================================

class Window_SkillCategory < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x : window X coordinate
  #     y : window Y coordinate
  #--------------------------------------------------------------------------
  def initialize(x, y, width)
    super(x, y, width, WLH + 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh(sort_index = 0)
    @sort_index = sort_index
    @skill_categories = COZZIEKUNS::SSSI::SKILL_CATEGORIES
    @skill_categories_width = COZZIEKUNS::SSSI::SKILL_CATEGORY_WIDTH
    @category_string = COZZIEKUNS::SSSI::CATEGORY_TEXT
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, @skill_categories_width - 40, WLH, @category_string, 0)
    self.contents.font.color = normal_color
    for i in 0...@skill_categories.size
      if @sort_index == i
        self.contents.draw_text(4, 0, @skill_categories_width - 40, WLH, @skill_categories[i][1], 2)
      end
    end
  end
end

#==============================================================================
# ** Window_SkillSort
#------------------------------------------------------------------------------
#  This window displays what type of skill is being displayed.
#==============================================================================

class Window_SkillSort < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x : window X coordinate
  #     y : window Y coordinate
  #--------------------------------------------------------------------------
  def initialize(x, y, width)
    super(x, y, width, WLH + 32)
    @ox = 0
    if COZZIEKUNS::SSSI::MAX_NUMBER < COZZIEKUNS::SSSI::SKILL_CATEGORIES.size
      self.contents = Bitmap.new(self.width - 32 + ((COZZIEKUNS::SSSI::SKILL_CATEGORIES.size - COZZIEKUNS::SSSI::MAX_NUMBER) * 54), self.height - 32)
    end
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh(sort_index = 0)
    @sort_index = sort_index
    @item_categories = COZZIEKUNS::SSSI::SKILL_CATEGORIES
    @item_categories_width = COZZIEKUNS::SSSI::SKILL_CATEGORY_WIDTH
    self.contents.clear
    for i in 0...@item_categories.size
      @icon_x = 0 + (i * ((544 - @item_categories_width) / @item_categories.size))
      if @item_categories.size < COZZIEKUNS::SSSI::MAX_NUMBER
        draw_item(i)
      else
        draw_items(i)
      end
      if @sort_index == i
        if @item_categories.size < COZZIEKUNS::SSSI::MAX_NUMBER
          draw_icon(@item_categories[i][0], @icon_x, 0, true)
        else
          draw_icon(@item_categories[i][0], i * 54, 0, true)
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    icons_x = (544 - @item_categories_width) / @item_categories.size
    draw_icon(@item_categories[index][0], index * icons_x, 0, false)
  end
  #--------------------------------------------------------------------------
  # * Draw Items
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_items(index)
    draw_icon(@item_categories[index][0], index * 54, 0, false)
  end
end

#==============================================================================
# ** Scene_Skill
#------------------------------------------------------------------------------
#  This class performs the skill screen processing.
#==============================================================================

class Scene_Skill < Scene_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor_index : actor index
  #--------------------------------------------------------------------------
  def initialize(actor_index = 0, equip_index = 0)
    @actor_index = actor_index
    @sort_index = 0
  end
  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  def start
    super
    create_menu_background
    @actor = $game_party.members[@actor_index]
    @viewport = Viewport.new(0, 0, 544, 416)
    @help_window = Window_Help.new
    @help_window.viewport = @viewport
    @status_window = Window_SkillStatus.new(0, 56, @actor)
    @status_window.viewport = @viewport
    @skill_window = Window_Skill.new(0, 168, 544, 248, @actor)
    @skill_window.viewport = @viewport
    @skill_window.help_window = @help_window
    @category_width = COZZIEKUNS::SSSI::SKILL_CATEGORY_WIDTH
    @category_window = Window_SkillCategory.new(544 - @category_width, 112, @category_width)
    @sort_window = Window_SkillSort.new(0, 112, 544 - @category_width)
    @target_window = Window_MenuStatus.new(0, 0)
    @skill_categories = COZZIEKUNS::SSSI::SKILL_CATEGORIES
    hide_target_window
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  alias coz_kyriaki_sssi_ss_terminate terminate
  def terminate
    coz_kyriaki_sssi_ss_terminate
    @category_window.dispose
    @sort_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    update_menu_background
    @help_window.update
    @status_window.update
    @skill_window.update
    @target_window.update
    if @skill_window.active
      update_skill_selection
    elsif @target_window.active
      update_target_selection
    end
  end
  #--------------------------------------------------------------------------
  # * Update Skill Selection
  #--------------------------------------------------------------------------
  def update_skill_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      return_scene
    elsif Input.trigger?(Input::A)
      @sort_index -= 1
      @sort_index %= @skill_categories.size
      if @sort_index + 1 == @skill_categories.size
        @sort_window.ox += 54 * (@skill_categories.size - COZZIEKUNS::SSSI::MAX_NUMBER)
      else
        if @skill_categories.size > COZZIEKUNS::SSSI::MAX_NUMBER and @sort_index > COZZIEKUNS::SSSI::MAX_NUMBER - 2
          @sort_window.ox -= 54
        end
      end
      @category_window.refresh(@sort_index)
      @sort_window.refresh(@sort_index)
      @skill_window.refresh(@sort_index)
      @skill_window.index = 0
      Sound.play_cursor
    elsif Input.trigger?(Input::Y)
      @sort_index += 1
      @sort_index %= @skill_categories.size
      if @sort_index != 0
        if @skill_categories.size > COZZIEKUNS::SSSI::MAX_NUMBER and @sort_index > COZZIEKUNS::SSSI::MAX_NUMBER - 1
          @sort_window.ox += 54
        end
      else
        @sort_window.ox = 0
      end
      @category_window.refresh(@sort_index)
      @sort_window.refresh(@sort_index)
      @skill_window.refresh(@sort_index)
      @skill_window.index = 0
      Sound.play_cursor
    elsif Input.trigger?(Input::R)
      Sound.play_cursor
      next_actor
    elsif Input.trigger?(Input::L)
      Sound.play_cursor
      prev_actor
    elsif Input.trigger?(Input::C)
      @skill = @skill_window.skill
      if @skill != nil
        @actor.last_skill_id = @skill.id
      end
      if @actor.skill_can_use?(@skill)
        Sound.play_decision
        determine_skill
      else
        Sound.play_buzzer
      end
    end
  end
end

Credit



Thanks


Support


Just post down here.

Known Compatibility Issues

Obviously won't work with any custom skill inventory scripts.

Demo


See attached.

Restrictions

:ccby:
Title: Re: Simple Sort Skill Inventory
Post by: Kyriaki on June 29, 2010, 02:21:31 AM
Thank you very much once again, it works perfectly. :)
Title: Re: Simple Sort Skill Inventory
Post by: cozziekuns on October 17, 2010, 07:00:29 PM
Bump of a relatively old and dead script.

Updated to v. 1.1, something I've been procrastinating and forgot about till Kyraiki reminded me. Thanks Kyraiki.
Title: Re: Simple Sort Skill Inventory
Post by: Kyriaki on October 17, 2010, 07:38:54 PM
Thank you!! It might be old and dead to the forum but I love it very much!
Title: Re: Simple Sort Skill Inventory
Post by: Seiryuki on February 20, 2011, 04:31:39 PM
Hi cozziekuns,

Is it possible to have this Skill-Sorting feature applied to the Skills Screen in Battle?
E.g. When I select "Skills" in the command window in battle, the Skills screen shows up but with the 'Categories section' of your script fitted somewhere above the Skills-list.

Thanks, if it can be done.
Title: Re: Simple Sort Skill Inventory
Post by: Seiryuki on February 20, 2011, 07:51:40 PM
Never mind, I managed to do it.
I think I'm supposed to create a script instead of modifying the default ones...but...I don't know how to script and this is my first modification.

Anyways, this is what I did to Scene_Battle around line 403 (additions/removals in green/red respectively):
Quote
  #--------------------------------------------------------------------------
  # * Start Skill Selection
  #--------------------------------------------------------------------------
  def start_skill_selection
    @help_window = Window_Help.new
    #@skill_window = Window_Skill.new(0, 56, 544, 232, @active_battler)
    @skill_window = Window_Skill.new(0, 112, 544, 304, @active_battler)
    @category_width = COZZIEKUNS::SSSI::SKILL_CATEGORY_WIDTH
    @category_window = Window_SkillCategory.new(544 - @category_width, 56, @category_width)
    @sort_window = Window_SkillSort.new(0, 56, 544 - @category_width)
    @skill_window.help_window = @help_window
    @actor_command_window.active = false
  end
  #--------------------------------------------------------------------------
  # * End Skill Selection
  #--------------------------------------------------------------------------
  def end_skill_selection
    if @skill_window != nil
      @skill_window.dispose
      @skill_window = nil
     
      @category_window.dispose
      @category_window = nil
      @sort_window.dispose
      @sort_window = nil
     
      @help_window.dispose
      @help_window = nil
    end
    @actor_command_window.active = true
  end

The modifications above allows the Skill Category to be shown in the Battle menu when selecting Skill.
Thanks for this amazing script cozziekuns.

Btw, it'll be nice if someone can tell me what to do to get the same effect without modifying the RMVX default Scene_Battle script. I do have tags that let me know what I added, but I know it is poor scripting.
Title: Re: Simple Sort Skill Inventory
Post by: cozziekuns on February 20, 2011, 09:03:43 PM
Well sorry for getting to you a bit late, but I'm glad you could figure it out yourself. There probably is a way to get the same effect, but I'm pretty sure that you'll have to change Scene_Battle regardless.
Title: Re: Simple Sort Skill Inventory
Post by: Seiryuki on February 20, 2011, 10:53:20 PM
Well, I finally figured out how to place the changes I made into your script and it worked great. I had to $category/sort_window.dispose and set to nil to remove the windows.
Title: Re: Simple Sort Skill Inventory
Post by: Seiryuki on March 03, 2011, 04:19:47 AM
I need some help with the same Scene_Battle modifications I did to the Skill Inventory. I believe I left out the ability to toggle through the categories! Lol.
I'm wondering if someone (maybe Cozziekuns) can add the Scene_Battle properly please? I tried on my own, but I can't program with Ruby.

Also, I'm pretty sure someone here has heard of Ziifee's Wait Gauge Battle system. I'm trying to get rid if the default skill_window that shows up with Ziifee's system and use Cozziekuns' Skill Inventory instead.
Can someone help me with that please? (I can post a link to his system if anyone wants). I guess if it can work with YEM Battle Engine Melody I may use that instead of Ziifee's WGB.

Thanks,
Seiryuki
Title: Re: Simple Sort Skill Inventory
Post by: whofreak97 on May 04, 2011, 09:20:06 PM
If anyone is here, i am having a problem. I will tell you the error:

Script 'Item Categories' (what i called it) error Line 315 SyntaxError

I need someone to tell me how to fix it.
Title: Re: Simple Sort Skill Inventory
Post by: pacdiggity on May 05, 2011, 08:14:06 AM
Copy the script again or post what YOU have here in code tags. [-code-][-/code-] without the dashes.
If you didn't edit it, it's very odd because nobody else got the error. It may be an incompatibility error, but it's unlikely for a syntax error. Line 315 should be:
Code: [Select]
def update
Make sure you have that there. If you don't recopy the script from the original post.