#==============================================================================
# ●● Item Rarities
#------------------------------------------------------------------------------
# Trickster (tricksterguy@hotmail.com)
# Version 1.1
# Date 8/5/07
# Goto RMXP.org for updates/bug reports/comments
#------------------------------------------------------------------------------
# This script allows you to set the color of an item in the menu scenes.
#==============================================================================
module Rarity
#--------------------------------------------------------------------------
# * Colors
# syntax: rarity => color
#--------------------------------------------------------------------------
Colors = {0 => Color.new(255, 255, 255), 1 => Color.new(0, 0, 255),
2 => Color.new(255, 224, 128)}
#--------------------------------------------------------------------------
# * Items
# syntax: item_id => rarity
#--------------------------------------------------------------------------
Items = {2 => 1, 3 => 2}
#--------------------------------------------------------------------------
# * Default Rarity Items
#--------------------------------------------------------------------------
Items.default = 0
#--------------------------------------------------------------------------
# * Weapons
#--------------------------------------------------------------------------
Weapons = {}
#--------------------------------------------------------------------------
# * Default Rarity Weapons
#--------------------------------------------------------------------------
Weapons.default = 0
#--------------------------------------------------------------------------
# * Armors
#--------------------------------------------------------------------------
Armors = {}
#--------------------------------------------------------------------------
# * Default Rarity Armors
#--------------------------------------------------------------------------
Armors.default = 0
end
module RPG
class Item
#--------------------------------------------------------------------------
# * Rarity
#--------------------------------------------------------------------------
def rarity
return Rarity::Items[id]
end
#--------------------------------------------------------------------------
# * Item Color
#--------------------------------------------------------------------------
def item_color
return Rarity::Colors[rarity]
end
end
class Weapon
#--------------------------------------------------------------------------
# * Rarity
#--------------------------------------------------------------------------
def rarity
return Rarity::Weapons[id]
end
#--------------------------------------------------------------------------
# * Item Color
#--------------------------------------------------------------------------
def item_color
return Rarity::Colors[rarity]
end
end
class Armor
#--------------------------------------------------------------------------
# * Rarity
#--------------------------------------------------------------------------
def rarity
return Rarity::Armors[id]
end
#--------------------------------------------------------------------------
# * Item Color
#--------------------------------------------------------------------------
def item_color
return Rarity::Colors[rarity]
end
end
end
class Window_Base
#--------------------------------------------------------------------------
# * Draw Item Name
# item : item
# x : draw spot x-coordinate
# y : draw spot y-coordinate
#--------------------------------------------------------------------------
def draw_item_name(item, x, y)
return if item == nil
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.font.color = item.item_color
self.contents.draw_text(x + 28, y, 212, 32, item.name)
self.contents.font.color = normal_color
end
end
class Window_Item
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
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
color = item.item_color
red, green, blue = color.red, color.green, color.blue
if item.is_a?(RPG::Item) and $game_party.item_can_use?(item.id)
opacity = 255
else
opacity = 128
end
self.contents.font.color = Color.new(red, green, blue, opacity)
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)
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 = opacity == 255 ? normal_color : disabled_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_ShopSell
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
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
color = item.item_color
red, green, blue = color.red, color.green, color.blue
# If items are sellable, set to valid text color. If not, set to invalid
# text color.
opacity = item.price > 0 ? 255 : 128
self.contents.font.color = Color.new(red, green, blue, opacity)
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)
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 = opacity == 255 ? normal_color : disabled_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