Chaos Project

RPG Maker => RPG Maker Scripts => Script Requests => Topic started by: crzyone9584 on February 25, 2010, 07:15:26 pm

Title: [Resolved]Item Rarity Colors
Post by: crzyone9584 on February 25, 2010, 07:15:26 pm
I know G_G has a item rarity script but it uses star. I found a script here:

http://rmvxp.com/showthread.php?tid=259

That does it color. The only problem it requires the SDK which i don't want to mess with. Since its like only about 90% compatible with RMX-OS. So could someone figure out a way to do this with out the sdk.
Title: Re: Item Rarity Colors
Post by: Jackolas on February 25, 2010, 09:14:59 pm
Spoiler: ShowHide

#==============================================================================
# ●● 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


and thats SDK removed
Title: Re: Item Rarity Colors
Post by: crzyone9584 on February 25, 2010, 10:59:57 pm
what. it looks pretty much the same. Did you only remove the line that said it required the sdk?
Title: Re: Item Rarity Colors
Post by: Aqua on February 25, 2010, 11:02:42 pm
Probably...
Lol
Title: Re: Item Rarity Colors
Post by: crzyone9584 on February 25, 2010, 11:07:41 pm
then whats the point of the sdk?
Title: Re: Item Rarity Colors
Post by: G_G on February 25, 2010, 11:11:39 pm
some scripts actually use methods from the sdk, this one didnt, some scripts you might be able to remove those lines. Others you wont.
Title: Re: Item Rarity Colors
Post by: crzyone9584 on February 25, 2010, 11:12:53 pm
Well ill let the professionals do it. or request for a similar script that doesnt need it like i just did lol
Title: Re: Item Rarity Colors
Post by: Aqua on February 25, 2010, 11:30:20 pm
Technically...
This belongs in Troubleshooting, not Requests...

But... too lazy to move it, especially since it's resolved
(Add the [Resolved] tag to your first post)
Title: Re: [Resolved]Item Rarity Colors
Post by: crzyone9584 on February 25, 2010, 11:33:45 pm
actually i was requesting someone to make a script like that one. But he just removed the SDK
Title: Re: [Resolved]Item Rarity Colors
Post by: Jackolas on February 26, 2010, 09:57:46 am
most scripts that require SDK do not really need it.
its just a cheap trick into forcing you to use SDK

btw.. all the scripts in the link you gave do not require SDK..
the only thing it is doing is log that you use the script, nothing more
remove that line and the script is still working fine.
Title: Re: [Resolved]Item Rarity Colors
Post by: crzyone9584 on February 26, 2010, 01:18:20 pm
i see i see. is there a easy way to know if it really does need the sdk?
Title: Re: [Resolved]Item Rarity Colors
Post by: Jackolas on February 26, 2010, 02:13:10 pm
remove the lines with SDK and check if it still works :P

so everything with SDK in it you remove... (most of the time also the last "end", that one is to close the SDK and is not needed any more)
Title: Re: [Resolved]Item Rarity Colors
Post by: crzyone9584 on February 26, 2010, 02:30:07 pm
sounds good to me. thanks a lot.