HalestormXV

Earned Item Shop

Jul 6th, 2011
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.19 KB | None | 0 0
  1. class Game_Party < Game_Unit
  2.   attr_reader :earned_items_list #This makes the list readable only.
  3.   alias inti_gm_party_gained_items_list initialize unless $@
  4.   def initialize
  5.     inti_gm_party_gained_items_list
  6.     @earned_items_list = []
  7.   end
  8.   #--------------------------------------------------------------------------
  9.   # * Gain Items (or lose)
  10.   #     item          : Item
  11.   #     n             : Number
  12.   #     include_equip : Include equipped items
  13.   #--------------------------------------------------------------------------
  14.   alias gain_items_earned_items_list gain_item unless $@
  15.   def gain_item(item, n, include_equip = false)
  16.     gain_items_earned_items_list(item, n, include_equip)
  17.     type = nil
  18.     case item
  19.     when RPG::Item
  20.       type = 0
  21.     when RPG::Weapon
  22.       type = 1
  23.     when RPG::Armor
  24.       type = 2
  25.     end
  26.     #This will push the item in the list (array) unless it is already in it.
  27.     i_details = [type, item.id]
  28.     @earned_items_list << i_details unless @earned_items_list.include?(i_details)
  29.   end
  30. end
  31.    
  32.  
  33. class Earned_Item_Shop < Scene_Shop
  34.   def initialize
  35.     $game_temp.shop_goods = $game_party.earned_items_list
  36.     super
  37.   end
  38. end
Add Comment
Please, Sign In to add comment