[XP] Item Quality

Started by G_G, January 16, 2011, 03:14:01 pm

Previous topic - Next topic

G_G

January 16, 2011, 03:14:01 pm Last Edit: June 10, 2011, 02:53:10 am by game_guy
Item Quality
Authors: game_guy
Version: 1.4
Type: Item Grouping
Key Term: Misc Add-on



Introduction

Changes the color of the items name according to the items quality. e.g. rare, common, etc.


Features


  • Unlimited Qualities
  • Any Color You Want



Screenshots

Spoiler: ShowHide



Demo

Self Extracting Archive (Outdated)
Zip Archive (Outdated)


Script

Spoiler: ShowHide

#===============================================================================
# Item Quality Colors
# Author game_guy
# Version 1.4
#-------------------------------------------------------------------------------
# Intro:
# Changes the color of the items name according to the items quality.
# e.g. rare, common, etc.
#
# Features:
# Unlimited Qualities
# Any Color You Want
#
# Instructions:
# Everything you need to configure for the script is below.
# -Setting the Items Quality:
#  Go into the database, click the items, weapons, or armors tab. Type this into
#  the name box after the name.
#  \qty[quality name]
#  e.g.
#  You have a quality like so
#  Quality['common'] = Color.new(255, 255, 0)
#  You type \qty[common] in the items name
#
# Compatibility:
# Not tested with SDK.
# Most likely will not work with custom menu systems/custom item systems.
# -IF you do use a CMS/CIS
#  -PM me at http://forum.chaos-project.com/index.php?action=profile;u=220
#  -Message me at http://youtube.com/GameGuysProjects
#  -Email me at gameguysprojects@hotmail.com
#   Use as a last resort, I rarely check my email.
# -Then let me know which custom script you're using and send a copy of it
#  and I'll whip up a compatibility patch if I have the time.
# There is some instructions on how to do it yourself in the topic.
#
# Update History:
# v1.0:
#  -Initial release
# v1.1:
#  -Added support for equip scene
# v1.2:
#  -Improved method of getting quality
# v1.3
#  -Added support for default shop scene
# v1.4
#  -Fixed display for equip scene
#  -Rewrote the script to make it more efficient
#
# Credits:
# game_guy ~ Creator of the script.
# mroedesigns ~ Requesting.
# Leongon ~ Original VX version.
#===============================================================================
module GG_QualityColors
 Quality = {}
 #================================================
 # Color used for all other items without a
 # quality or when a quality level does not exist
 #================================================
 Default_Color = Color.new(255, 255, 255)
 #================================================
 # Add a new line under the qualities already
 # given and type
 # Quality['quality name'] = Color.new(r, g, b)
 #  quality name - name of quality in quotes
 #  r - amount of red
 #  g - amount of green
 #  b - amount of blue
 # Examples below.
 #================================================
 Quality['common'] = Color.new(255, 255, 0)
 Quality['rare'] = Color.new(120, 20, 0)
 Quality['epic'] = Color.new(0, 255, 0)
 Quality['awesome'] = Color.new(80, 80, 240)
end
module RPG
 def self.get_item_name(t)
   text = t.clone
   text.gsub!(/\\[Qq][Tt][Yy]\[([0-9A-Za-z_]+)\]/) { "" }
   return text
 end
 def self.get_item_quality(t)
   text = t.clone
   quality = "gg_def"
   text.gsub!(/\\[Qq][Tt][Yy]\[([0-9A-Za-z_]+)\]/) do
     quality = $1.to_s
     ""
   end
   return quality
 end
 class Item
   def name
     return RPG.get_item_name(@name)
   end
   def quality
     return RPG.get_item_quality(@name)
   end
 end
 class Armor
   def name
     return RPG.get_item_name(@name)
   end
   def quality
     return RPG.get_item_quality(@name)
   end
 end
 class Weapon
   def name
     return RPG.get_item_name(@name)
   end
   def quality
     return RPG.get_item_quality(@name)
   end
 end
end
class Window_Item < Window_Selectable
 def draw_item(index)
   use = false
   item = @data[index]
   case item
   when RPG::Item
     number = $game_party.item_number(item.id)
   when RPG::Weapon
     number = $game_party.weapon_number(item.id)
   when RPG::Armor
     number = $game_party.armor_number(item.id)
   end
   if item.is_a?(RPG::Item) and
      $game_party.item_can_use?(item.id)
     use = true
   end
   if item.quality == "gg_def"
     self.contents.font.color = GG_QualityColors::Default_Color
   else
     self.contents.font.color = GG_QualityColors::Quality[item.quality]
   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(item.icon_name)
   opacity = use == true ? 255 : 128
   self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
   self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
   self.contents.font.color = Font.default_color
   self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
   self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
 end
end
class Window_Base < Window
 def draw_item_name(item, x, y)
   if item == nil
     return
   end
   bitmap = RPG::Cache.icon(item.icon_name)
   self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
   if item.quality == 'gg_def'
     self.contents.font.color = GG_QualityColors::Default_Color
   else
     self.contents.font.color = GG_QualityColors::Quality[item.quality]
   end
   self.contents.draw_text(x + 28, y, 212, 32, item.name)
   self.contents.font.color = Font.default_color
 end
end

class Window_ShopSell < Window_Selectable
 def draw_item(index)
   item = @data[index]
   case item
   when RPG::Item
     number = $game_party.item_number(item.id)
   when RPG::Weapon
     number = $game_party.weapon_number(item.id)
   when RPG::Armor
     number = $game_party.armor_number(item.id)
   end
   use = false
   if item.price > 0
     use = true
   end
   if item.quality == 'gg_def'
     self.contents.font.color = GG_QualityColors::Default_Color
   else
     self.contents.font.color = GG_QualityColors::Quality[item.quality]
   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(item.icon_name)
   opacity = use == true ? 255 : 128
   self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
   self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
   self.contents.font.color = Font.default_color
   self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
   self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
 end
end

class Window_ShopBuy < Window_Selectable
 def draw_item(index)
   item = @data[index]
   case item
   when RPG::Item
     number = $game_party.item_number(item.id)
   when RPG::Weapon
     number = $game_party.weapon_number(item.id)
   when RPG::Armor
     number = $game_party.armor_number(item.id)
   end
   if item.quality == 'gg_def'
     self.contents.font.color = GG_QualityColors::Default_Color
   else
     self.contents.font.color = GG_QualityColors::Quality[item.quality]
   end
   use = false
   if item.price <= $game_party.gold and number < 99
     use = true
   end
   x = 4
   y = index * 32
   rect = Rect.new(x, y, self.width - 32, 32)
   self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
   bitmap = RPG::Cache.icon(item.icon_name)
   opacity = use == true ? 255 : 128
   self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
   self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
   self.contents.font.color = Font.default_color
   self.contents.font.color = Font.default_color
   self.contents.draw_text(x + 240, y, 88, 32, item.price.to_s, 2)
 end
end

class Window_EquipItem < Window_Selectable
 def draw_item(index)
   item = @data[index]
   x = 4 + index % 2 * (288 + 32)
   y = index / 2 * 32
   case item
   when RPG::Weapon
     number = $game_party.weapon_number(item.id)
   when RPG::Armor
     number = $game_party.armor_number(item.id)
   end
   bitmap = RPG::Cache.icon(item.icon_name)
   self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
   if item.quality == 'gg_def'
     self.contents.font.color = GG_QualityColors::Default_Color
   else
     self.contents.font.color = GG_QualityColors::Quality[item.quality]
   end
   self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
   self.contents.font.color = Font.default_color
   self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
   self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
 end
end



Instructions

In the script.


Compatibility

Not tested with SDK.
Most likely will not work with custom item/menu systems.
If you are having troubles with the \qty tag not being removed, place this script below all others (but still above main) and then test it.

If you are using a custom item/menu system and the script conflicts with it try and follow these steps:
Spoiler: ShowHide
1. Locate your custom menu system's item window. Usually named Window_Item. CTRL + F - class Window_Item
2. Locate the method named draw_item.
3. Replace the lines as following:
Look for lines similiar to this.
    if item.is_a?(RPG::Item) and
      $game_party.item_can_use?(item.id)
     self.contents.font.color = normal_color
   else
     self.contents.font.color = disabled_color
   end

Replace them with this.
    if item.is_a?(RPG::Item) and
      $game_party.item_can_use?(item.id)
     use = true
   end

Note that you want to keep the same if statement for the replacement. e.g. in Stormtronics CMS the if statement is
if @data[i].is_a?(RPG::Item) && $game_party.item_can_use?(@data[i].id) ||
       @mode == nil

So when you replace the lines, keep the same if statement.
Right below the above code paste this code there.
    if item.quality == 'gg_def'
     self.contents.font.color = GG_QualityColors::Default_Color
   else
     self.contents.font.color = GG_QualityColors::Quality[item.quality]
   end

Then replace this line
opacity = self.contents.font.color == normal_color ? 255 : 128

with
opacity = use == true ? 255 : 128


If you cannot seem to figure out how to do this, post the custom menu system you're using and I'll see if I can whip up a patch if I have time.


Pre-Made patch for STCMS (Place script and patch below STCMS)
Spoiler: ShowHide
class Window_CMSItem < Window_Selectable
 def draw_item(i)
   use = false
   number = case @data[i]
   when RPG::Item then $game_party.item_number(@data[i].id)
   when RPG::Weapon then $game_party.weapon_number(@data[i].id)
   when RPG::Armor then $game_party.armor_number(@data[i].id)
   end
   if @data[i].is_a?(RPG::Item) && $game_party.item_can_use?(@data[i].id) ||
       @mode == nil
     use = true
   end
   if @data[i].quality == 'gg_def'
     self.contents.font.color = GG_QualityColors::Default_Color
   else
     self.contents.font.color = GG_QualityColors::Quality[@data[i].quality]
   end
   self.contents.fill_rect(4, i*32, 352, 32, Color.new(0, 0, 0, 0))
   bitmap = RPG::Cache.icon(@data[i].icon_name)
   opacity = use == true ? 255 : 128
   self.contents.blt(4, i*32 + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
   self.contents.draw_text(32, i*32, 212, 32, @data[i].name, 0)
   self.contents.draw_text(308, i*32, 16, 32, ':', 1)
   self.contents.draw_text(324, i*32, 24, 32, number.to_s, 2)
 end
end


This is a patch made for GUILLAUME777's Multi Slot Script. Place script and patch below Multi Slot.
Spoiler: ShowHide

class Window_EquipRight < Window_Selectable
 def draw_item_name(item, x, y, translucent = false)
   if item == nil
     return
   end
   bitmap = RPG::Cache.icon(item.icon_name)
   if item.cursed
     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
     self.contents.font.color = G7_MS_MOD::CURSED_COLOR
   elsif translucent
     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), 128)
     if item.quality == 'gg_def'
       self.contents.font.color = GG_QualityColors::Default_Color
     else
       self.contents.font.color = GG_QualityColors::Quality[item.quality]
     end
   else
     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
     self.contents.font.color = normal_color
     if item.quality == 'gg_def'
       self.contents.font.color = GG_QualityColors::Default_Color
     else
       self.contents.font.color = GG_QualityColors::Quality[item.quality]
     end
   end
   self.contents.draw_text(x + 28, y, 212, 32, item.name)
 end
end



Credits and Thanks


  • game_guy ~ Creator of the script.
  • mroedesigns ~ Requesting.
  • Leongon ~ Original VX version.



Author's Notes

Enjoy!

mroedesigns

Thanks a ton GG! Another level for you  :haha:

LiTTleDRAgo

found an error,
I get script error at this line saying something like unknown method

gg_init_qual_colors_lat


did you aliased them wrong?

Quotealias gg_init_qual_colors_itm_lat initialize
    def initialize
      @quality = ""
      gg_init_qual_colors_lat
    end

G_G

Updated the script. Not the demo. What seems to be the problem with the Active Action or whatever? (I read that you said it had problems with it)

LiTTleDRAgo

February 06, 2011, 10:39:40 pm #4 Last Edit: February 06, 2011, 10:52:37 pm by LiTTleDRAgo
actualy not only active action, this script messing up with message system, custom shop screen and many more

Spoiler: ShowHide

Spoiler: ShowHide



NB : It works with SDK (just let you know)

G_G

I'll look into it. Thanks for letting me know. :)

Xuroth

Hey game_guy, awesome script! I remember requesting this feature in your old Item rating and color, but the way this works is closer to what I wanted. Thanks a bunch! However, I am running into an error trying to merge this with scripts. I tried to follow your suggestions for compatibility, but it keeps throwing up an error.

I was able to get Blizz's Window_BattleResult (from Tons) to display colored items correctly, but I cant get the following scripts to work right:

Guillaume777's multi-slot equip 6.2.2
DerVVulfman's Grouping and Details 7.2
Blizzard's Chaos Rage Limit System 6.1b

Ive spent a few hours trying to modify these scripts to show the item's color in all the relevant windows. Most of the time I get an error saying it cant convert NilClass to Color. Do you have any advice or are you able to make a patch for these systems?

G_G

Upload the scripts and link em here. I'll take a look at them.

Xuroth

February 16, 2011, 04:41:55 pm #8 Last Edit: February 23, 2011, 04:22:05 pm by Xuroth
Here is a rar file that has all of the script components (unfortunately, Grouping and Details  & Multi-slot Equip are broken into several scripts, like Tons) they are numbered to show the order they are in the project. Thanks for taking a look game_guy.

Scripts link (.RAR) http://www.filedropper.com/scripts_1

EDIT: I went to DerVVulfman's website and worked with him on this issue. I switched to his multi slot system and he was able to make a patch for it. I looked at CRLS and made a patch (based off of 6.1b, though it should be compatible with 6.2b as well). In case anyone else is using this script and CRLS here is my patch:

Patch for Item Colors compatibility with CRLS: ShowHide

#==============================================================================
# ** Item Quality Colors patch for Chaos Rage Limit System
#------------------------------------------------------------------------------
#    CRLS by Blizzard
#    Item Quality by game_guy
#    patch by Xuroth
#    version 1.0
#    02-23-2011
#    (Had to re-write a method in Window_Base that CRLS added)
#------------------------------------------------------------------------------
#
# * INSTRUCTIONS:
#
#   Paste game_guy's Item Quality Colors below CRLS
#   Paste this patch below both.
#   Follow game_guy's instructions as normal to apply colors
#
#   This patch allows the Soul Rage menu in battle to properly
#   display custom item colors. This patch is plug and play
#   compatible, so just put the scripts in the order described
#   above, and enjoy!
#
#==============================================================================

class Window_Base
  def draw_item_name_srs(item, x, y, color)
    # stop if item doesn't exist
    return if item == nil
    opacity = self.contents.font.color == normal_color ? 255 : 128
       # cache icon
    bitmap = RPG::Cache.icon(item.icon_name)
    # draw icon
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.font.color = normal_color
        if item.quality == 'gg_def'
      self.contents.font.color = GG_QualityColors::Default_Color
    else
      self.contents.font.color = GG_QualityColors::Quality[item.quality]
    end     
    # draw item name
    self.contents.draw_text(x + 28, y, 288, 32, item.name)
  end
end


Thanks for the awesome script game_guy (and thanks so much for CRLS Blizzard!)

Now if I can get his Grouping and Details to work with Item Colors and CRLS...

G_G

Oh crap! Sorry! I completely forgot about this. Glad you got your problem fixed, I still need to find out some issues with it as well.

AliveDrive

How have I not seen this yet?

This will make item combination a snap!
Quote from: Blizzard on September 09, 2011, 02:26:33 am
The permanent solution for your problem would be to stop hanging out with stupid people.

G_G

I think I've fixed it. Not really much time to test it. The problem was that in RPG::Item I was setting quality to a string when it should have been nil.

AliveDrive

Hey so, me = huge fan of this.
Quote from: Blizzard on September 09, 2011, 02:26:33 am
The permanent solution for your problem would be to stop hanging out with stupid people.

Griver03

hey casn you make it compatible with the 777's multislot equipment ?
it works togehter but the color isnt shown at equipment as it was in normal equip scene  :(
that where great dude, thx in advance
My most wanted games...



Dweller

I notice that the different item color's didnĀ“t show on vendors.

Spoiler: ShowHide
Dwellercoc
Spoiler: ShowHide

G_G


Griver03

both ?!
when you fix the colors on shop can you pls make patch for fft shop too?
but 77's multi-equip is more important to me xD
thx in advance
My most wanted games...



G_G

Can I have a link to both of those scripts? It'll make it easier.

Griver03

Multi-Slot Demo
http://www.fileden.com/files/2008/10/3/2126590/Files/RPGMaker/RMXP/Demo/Others%20Western/Multi-Slot.zip

FFT Shop System
http://www.rmxpunlimited.net/resources/scripts/item/final-fantasy-tactics-advance-shop-system

like i said multi-equip is very important to me so pls help ^^
My most wanted games...



G_G

Updated to 1.3. Added default shop support. Added multi slot patch. Working on FFT Shop system now.

Do take note that for the multi slot, cursed weapons will keep the cursed color.