Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: G_G on May 24, 2009, 12:00:03 pm

Title: [XP] Item Rarity/Rating
Post by: G_G on May 24, 2009, 12:00:03 pm
Item Rarity/Rating
Authors: game_guy
Version: 1.5
Type: Item Rating Script
Key Term: Custom Item System



Introduction

In some games I've seen Item Ratings or Rarity's etc. This script mimics that.
I use this for item rarity on how hard it is to find an item. It can be used to
rate items though on how good they are.


Features




Screenshots

Spoiler: ShowHide
(http://i307.photobucket.com/albums/nn318/bahumat27/items.png)



Demo

NEW DEMO 1.5
Demo 1.5 (http://www.sendspace.com/file/gzagg2)


Script

Spoiler: ShowHide

#==============================================================================#
# Item Rarity/rating Script
# By: game_guy
# Data: May 24th, 2009
#==============================================================================#
=begin
Intro:
In some games I've seen Item Ratings or Rarity's etc. This script mimics that.
I use this for item rarity on how hard it is to find an item. It can be used to
rate items though on how good they are.

Instructions:
And do change the name of the icon to your liking where it says
IconName = "icon name here between quotes"

Go to # BEGIN CONFIG and type this below that line
when item_id then return rarity/rating

Features:
Gives items "Stars" times the amount of its rating/rarity

Credits:
game_guy - for making it
ryexander - helping me understand the bitmap better
=end
#======================================#
# ICONNAME = "Icon name here" # name of icon to display rating
# RARITYNAME = "Rarity name here" # word you want to call the rarity/rating
#======================================#
ICONNAME = "star"
RARITYNAME = "Rating"

module RPG
  class Item
    def rarity
      case id
      #======================================#
      # BEGIN CONFIG
      #======================================#
      when 1 then return 1
      when 2 then return 3
      when 32 then return 5
      when 8 then return 2
      #======================================#
      # END CONFIG
      #======================================#
      end
      return 1
    end
  end
  class Weapon
    def rarity
      case id
      #======================================#
      # BEGIN CONFIG
      #======================================#
      when 1 then return 1
      when 2 then return 3
      when 32 then return 5
      when 8 then return 2
      #======================================#
      # END CONFIG
      #======================================#
      end
      return 1
    end
  end
  class Armor
    def rarity
      case id
      #======================================#
      # BEGIN CONFIG
      #======================================#
      when 1 then return 1
      when 2 then return 3
      when 32 then return 5
      when 8 then return 2
      #======================================#
      # END CONFIG
      #======================================#
      end
      return 1
    end
  end
end
class Window_Item < Window_Selectable
  def initialize
    super(0, 64, 640, 352)
    @column_max = 1
    refresh
    self.index = 0
    if $game_temp.in_battle
      self.y = 64
      self.height = 256
      self.back_opacity = 160
    end
  end
  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.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
    x = 4 + index % 1 * (288 + 32)
    y = index / 1 * 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 = self.contents.font.color == normal_color ? 255 : 128
    item.rarity.times do |i|
      src_rect = Rect.new(0, 0, 24, 24)
      self.contents.blt(300 + 32 * i + 16, y + 3, RPG::Cache.icon(ICONNAME.to_s), src_rect)
    end
    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.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_ItemName < Window_Base
  def initialize
    super(0, 0, 320, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, 640, 32, "Item Name", 0)
  end
end
class Window_Rating < Window_Base
  def initialize
    super(320, 0, 320, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, 640, 32, RARITYNAME, 0)
  end
end
class Scene_Item
  def main
    @help_window = Window_Help.new
    @help_window.y = 416
    @xtrinfo = Window_ItemName.new
    @rare = Window_Rating.new
    @item_window = Window_Item.new
    @item_window.help_window = @help_window
    @target_window = Window_Target.new
    @target_window.visible = false
    @target_window.active = false
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @help_window.dispose
    @rare.dispose
    @xtrinfo.dispose
    @item_window.dispose
    @target_window.dispose
  end
end





Instructions

And do change the name of the icon to your liking where it says
IconName = "icon name here between quotes"

Go to # BEGIN CONFIG and type this below that line
when item_id then return rarity/rating

Make sure to do it for each type: Items, Weapons, and Armors

Icon Used in Screenie if you want it
(http://i307.photobucket.com/albums/nn318/bahumat27/star.png)


Compatibility

Not tested with SDK. Wont work with other Custom Item Systems.


Credits and Thanks




Author's Notes

Give credits if used and enjoy!
Title: Re: [XP] Item Rarity/Rating
Post by: Sally on May 24, 2009, 12:46:35 pm
just like fable! is it easy to set-up?
Title: Re: [XP] Item Rarity/Rating
Post by: G_G on May 24, 2009, 12:47:34 pm
Its easy as long as you read the instructions and its pretty easy just gotta define the items.

when item_id then rating/rarity

EDIT:
Updated it and fixed a major bug I found
Title: Re: [XP] Item Rarity/Rating
Post by: Xuroth on May 25, 2009, 01:25:34 pm
It would be cool if you could display both or have each (rarity AND rating) built into the script as toggled functions. basically, my idea is this: The name of the object is colored to indicate rarity (and have option in script to turn this part off) while the user can either use the icons like you, or use a icon for each rating(have ability to turn this part off, too) for example, i fry a boss in your game, and get a Gold Spear its better than other Spears because its stats so it would have a higher rating. It would also be much more rare than an average spear. and the name displayed would just be 'Spear' but in gold coloring... just an idea, i doubt you'll like it
Title: Re: [XP] Item Rarity/Rating
Post by: G_G on May 25, 2009, 01:57:57 pm
I might do it for my next update. Good idea by teh way!
Title: Re: [XP] Item Rarity/Rating
Post by: Xuroth on May 25, 2009, 02:10:02 pm
ty cant wait to try out those features (if you do decide to use them)



Title: Re: [XP] Item Rarity/Rating
Post by: Calintz on May 25, 2009, 05:25:35 pm
Hey Game_Guy ...
Can I make a request for an aesthetics upgrade for this script?
Title: Re: [XP] Item Rarity/Rating
Post by: G_G on May 25, 2009, 05:29:32 pm
Depends. Last time you said that in my script I tried it and was never able to do it xD

Post your idea.
Title: Re: [XP] Item Rarity/Rating
Post by: Calintz on May 25, 2009, 05:30:20 pm
Nah, this is different. Just adding windows, and moving windows.
Title: Re: [XP] Item Rarity/Rating
Post by: G_G on May 25, 2009, 05:39:46 pm
Well go ahead and post your idea
Title: Re: [XP] Item Rarity/Rating
Post by: Calintz on May 25, 2009, 06:19:53 pm
Okay, start by putting the help window at the bottom of the screen, and where the help window currently is ... add a new window(the same size) and if you wanted to, split it in half. 2windows at 240, or one at 480, it doesn't really matter.

Anyway, in the top window to the left, add the text "Item" or "Item Name," and on the right side, directly above where the stars begin, add the text "Rarity" or whatever.

Finally ... Slide the stars over like 32pixels, and to the left of them, add the abbreviation "LV" to all of them, and so on ...

I think these few things would help the appearance of the script.
Title: Re: [XP] Item Rarity/Rating
Post by: G_G on May 25, 2009, 06:28:18 pm
Well I'll work on it when I have time. I do agree it would help thnx calintz.
Title: Re: [XP] Item Rarity/Rating
Post by: Calintz on May 25, 2009, 06:31:23 pm
Of course.
No problem ...

I look forward to seeing it if you decide to do it.

BTW:
I on the other hand must go work on the Well in the Woods.
Title: Re: [XP] Item Rarity/Rating
Post by: G_G on July 22, 2009, 04:43:14 pm
@calintz: Added it the way you said except the level.

Updated to 1.5