Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Shop Issues :P
#3
Ah I see, sorry about that hadn't though to post the code since the changes are mainly just for size, position and visibility. Would ya believe me when I say for some reason I've had to attempt this post several times cause my browser either crashed or connection had issues, lol >_<  Oh and thanks for the windowskin suggestion I'll give it a shot.
Here's the current code ^^

Code:
#==============================================================================
# ** DRG - Limited Shop
# Version : 2.00
# Author : LiTTleDRAgo
#==============================================================================
#
# How To Use :
#
# Use Script Command :
#
# Script :
#  Script :
#    $limited_shop = {
#      0 => ['i1','i2','i3','i4'], # This means item 1,2,3,4 didn't have limit
#      1 => ['w1','w2','a1'],      # This means weapon 1,2 and armor 1 can only
#                                  # bought 1 times
#      2 => ['a2']                 # This means armor 2 can be bought 2 times
#  
#      # This option won't do anything if SHOP_HAS_GOLD is false
#      "G" => 3000                 # This means the shop is have 3000 gold
#                                  # you can't sell anything if shop have 0 gold
#                                  # if ommitted, the shop gold is set as 0
#    }
#
#  To change the item inside the shop
# Script :
#    shop = [@map_id, @event_id]
#    item = $data_items[x]         # set 'Gold' to change the shop gold
#    limit = 90                    # set '-' for unlimited
#    limit_shop_item(shop,item,limit)
#
#==============================================================================
module LiTTleDRAgo
 
 SCENE_LIMITED_SHOP = {
                    #  Command , Condition for Enabled  
                  0 => ['Buy',   '$game_party.gold > 0'],
                  1 => ['Sell',],
                  }
 
 SHOP_HAS_GOLD = true
 # basically if false, you can sell anything as you please
 GET_SOLD_ITEM = 1
 # 0 : Item sold won't be added into buy list
 # 1 : Item sold will added into buy list
 #     (you sold x items outside the list and that item will appeared in the
 #      buy list with limit of x)
 # 2 : Item sold will added into buy list unlimitedly
 #     (you sold  at least 1 items outside the list and that item will appeared
 #      in the buy list without limit and can be bought as many as possible)
 SHOP_LAYOUT = 'Item_Lay'
 SHOP_BACK   = 'Mn_Back'
 # Image Related Constant
 # (all images must be in Graphics/Pictures or Graphics/Windowskin
 SHOP_GOLD_TEXT = "Seller's Gold"
 OWN_TEXT       = "Own %02d"
 
 #---------------------------------------------------------------------------
 # From Falcon's Tax Script
 #---------------------------------------------------------------------------
 TAXRATE_TEXT   = "Tax Rate"
 DISCOUNT_TEXT  = "Discount Rate"
 TAX_COLOR      = Color.new(0,25,228)
 # String Related Constant
 STARTING_TAX   = 0
 # Tax in the shop
 # can be changed by $game_system.tax = (Numeric)
 
end
#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
#  This class handles data surrounding the system. Backround music, etc.
#  is managed here as well. Refer to "$game_system" for the instance of
#  this class.
#==============================================================================
class Game_System
 #--------------------------------------------------------------------------
 # * Public Instance Variables
 #--------------------------------------------------------------------------
 attr_accessor :tax
 #--------------------------------------------------------------------------
 # * Alias Method
 #--------------------------------------------------------------------------
 alias init_tax initialize
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize
   init_tax
   @tax = LiTTleDRAgo::STARTING_TAX
 end
end
#==============================================================================
# ** Scene_Shop
#------------------------------------------------------------------------------
#  This class performs shop screen processing.
#==============================================================================

class Scene_LimitedShop
 #--------------------------------------------------------------------------
 # * Main Processing
 #--------------------------------------------------------------------------
 def main
   create_arrow
   create_layout
   create_background
   create_menu
   create_windows
   Graphics.transition
   update_premenu
   update while $scene == self
   dispose_premenu
   Graphics.freeze
   @all_windows.flatten.each {|s| s.dispose if !s.disposed?}
   @all_sprite.flatten.each {|s| s.dispose if !s.disposed?}
   @spriteset.dispose
 end
 #--------------------------------------------------------------------------
 # ● update_premenu
 #--------------------------------------------------------------------------
 def update_premenu
   while @sprite_menu[-1].x < 50 && $scene == self
     @sprite_menu.each {|s| s.x = [s.x+40,50].min }
     @sprite_arrow.x = [@sprite_arrow.x+3,5].min
     @sprite_arrow.y = 130
     update_grafis
   end
   update_arrow
 end
 #--------------------------------------------------------------------------
 # ● dispose_premenu
 #--------------------------------------------------------------------------
 def dispose_premenu
   while @sprite_menu[-1].x > -200
     @sprite_menu.each_with_index {|s,i| s.x = s.x-(40+i*10) }
     @sprite_arrow.x -= 15
     @buy_window.x = [@buy_window.x+10,@resolution[0]].min
     @sell_window.x = [@sell_window.x+10,@resolution[0]].min
     update_grafis
   end
 end
 #--------------------------------------------------------------------------
 # ● create_layout
 #--------------------------------------------------------------------------
 def create_layout
   @spriteset = Spriteset_Map.new
   @layout = Sprite.new
   @layout.bitmap = RPG::Cache.picture(LiTTleDRAgo::SHOP_LAYOUT).dup rescue
       RPG::Cache.windowskin(LiTTleDRAgo::SHOP_BACK).dup
   s = Window_Help.new
   tax = ($game_system.tax||0).to_s+"%"
   w = @layout.bitmap.text_size(tax).width
   if tax.to_f > 0 # If there is tax
     @layout.bitmap.font.color = LiTTleDRAgo::TAX_COLOR
     @layout.bitmap.draw_text(0,44,@resolution[0]-(28+w),32,LiTTleDRAgo::TAXRATE_TEXT,2)
     @layout.bitmap.font.color = s.normal_color
     @layout.bitmap.draw_text(0,44,@resolution[0]-24,32,tax,2)
   elsif tax.to_f < 0 # If there is a discount rate
     @layout.bitmap.font.color = LiTTleDRAgo::TAX_COLOR
     @layout.bitmap.draw_text(0,44,@resolution[0]-(28+w),32,LiTTleDRAgo::DISCOUNT_TEXT,2)
     @layout.bitmap.font.color = s.normal_color
     @layout.bitmap.draw_text(0,44,@resolution[0]-24,32,tax,2)
   end
   s.dispose
   @layout.z = 100
   @all_sprite << [@layout]
 end
 #--------------------------------------------------------------------------
 # ● Draw Hemming Text
 #--------------------------------------------------------------------------
 def draw_hemming_text(obj, x, y, w, h, text, align = 0)
   original_color = obj.font.color.dup
   obj.font.color = Color.new(0,0,0,255)
   obj.draw_text(x  , y  , w, h, text.to_s, align)
   obj.draw_text(x  , y+2, w, h, text.to_s, align)
   obj.draw_text(x+2, y+2, w, h, text.to_s, align)
   obj.draw_text(x+2, y  , w, h, text.to_s, align)
   obj.font.color = original_color
   obj.draw_text(x+1, y+1, w, h, text.to_s, align)
 end
 #--------------------------------------------------------------------------
 # ● create_background
 #--------------------------------------------------------------------------
 def create_background
   @mnback = Plane.new
   @mnback.bitmap = RPG::Cache.picture(LiTTleDRAgo::SHOP_BACK) rescue
       RPG::Cache.windowskin(LiTTleDRAgo::SHOP_BACK)
   @mnback.opacity = 255
   @mnback.blend_type = 0
   @all_sprite << [@mnback]
 end
 #--------------------------------------------------------------------------
 # * Create Menu
 #--------------------------------------------------------------------------
 def create_menu(type = 0)
   @sprite_menu.each {|s| s.dispose } if !@sprite_menu.nil?
   @sprite_menu = []
   temp = @index
   @index = 0
   @column_max = 1
   @menu = LiTTleDRAgo::SCENE_LIMITED_SHOP
   @menu.each {|a| b = @menu[@index]
      @sprite_menu[@index] = type == 1 ? Window_Base.new(50,(48*@index)+120,160,48) :
                Window_Base.new(-200-50*@index,(48*@index)+120,160,48)
      @sprite_menu[@index].contents = Bitmap.new(160-32,16)
      @sprite_menu[@index].back_opacity = 180
      @sprite_menu[@index].contents.font.size = 20
      @sprite_menu[@index].contents.font.bold = true
      @sprite_menu[@index].contents.font.color =
      @sprite_menu[@index].disabled_color if (b[1] && !condition_eval(b[1]))
      @sprite_menu[@index].contents.draw_text(0,0,160-32,16,b[0].to_s,1)
      @sprite_menu[@index].z = @layout.z + 100
      @index += 1}
   @index = (temp||0)
   @column_max = 1
   @item_max =  @sprite_menu.size
   @all_sprite << [@sprite_menu]
 end
 #--------------------------------------------------------------------------
 # * Create Windows
 #--------------------------------------------------------------------------
 def create_windows
    @all_windows = [
     @help_window = Window_Help.new,
     @gold_window = Window_Gold.new,
     #@dummy_window = Window_Base.new(0, 128, 640, 352),
     @buy_window = Window_ShopBuyLimited.new,
     @sell_window = Window_ShopSellLimited.new,
     @number_window = Window_ShopNumber.new,
     @status_window = Window_ShopStatusLimited.new]
   @help_window.opacity = 0
   @help_window.y = 420
   @help_window.x = -200
   @gold_window.x = 480
   @gold_window.y = 0
   @gold_window.opacity = 0
   @gold_window.back_opacity = 0
   @buy_window.x = @resolution[0]-@buy_window.width
   @sell_window.x = @resolution[0]-@sell_window.width
   @number_window.x = @buy_window.x
   @number_window.y = @buy_window.y
   @buy_window.x = @resolution[0]
   @sell_window.x = @resolution[0]
   @all_windows.each_with_index {|s,i|
     s.z = @layout.z - 2
     s.active = false if [2,3,4].include?(i)
     s.visible = false if [4].include?(i)}
   @status_window.visible = false
   @buy_window.help_window = @help_window
   @sell_window.help_window = @help_window
   @command_window_active = true
 end
 #--------------------------------------------------------------------------
 # * Create Arrow
 #--------------------------------------------------------------------------
 VX = false
 def create_arrow
   @resolution = VX ? [Graphics.width,Graphics.height] : [640,480]  
   @all_sprite = []
   @sprite_arrow = Sprite.new
   if $arrow_drg_menu.nil? || $arrow_drg_menu.disposed?
     bit = $game_system.windowskin_name                if !VX
     bit = [RPG::Cache.windowskin(bit),Rect.new(160,96,32,32)]  if !VX
     bit = [Cache.system("Window"),Rect.new(96,80,16,16)] if VX
     @sprite_arrow.bitmap = Bitmap.new(40, 40)
     @sprite_arrow.bitmap.stretch_blt(@sprite_arrow.bitmap.rect,bit[0],bit[1])
     bit = @sprite_arrow.bitmap
     copy = bit.clone
     (0...bit.height).each{|i|(0...bit.width).each{|j|
         bit.set_pixel(bit.width-i-1,j,copy.get_pixel(j,i))}}
     $arrow_drg_menu = bit.dup
   else
     @sprite_arrow.bitmap = $arrow_drg_menu.dup
   end
   @sprite_arrow.mirror = true if VX
   @sprite_arrow.x -= 100
   @sprite_arrow.z = 7
   @all_sprite << @sprite_arrow
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
   update_layout_position
   update_arrow
   update_grafis
   @all_windows.flatten.each {|s| s.update}
   return update_index   if @command_window_active
   return update_buy     if @buy_window.active
   return update_sell    if @sell_window.active
   return update_number  if @number_window.active
 end
 #--------------------------------------------------------------------------
 # * Update Grafis
 #--------------------------------------------------------------------------
 def update_grafis
   [Graphics,Input].each {|s|s.update}
 end
 #--------------------------------------------------------------------------
 # * Update Layout Position
 #--------------------------------------------------------------------------
 def update_layout_position
   @help_window.x = [@help_window.x+10,0].min
   @sprite_menu.each {|s| s.y -= 10} if @sprite_arrow.y > @resolution[1]-(40+34)
   @sprite_menu.each {|s| s.y += 10} if @sprite_arrow.y < 0+10
   @buy_window.visible = @sell_window.visible = !@number_window.visible
   if @buy_window.active
     @buy_window.x = [@buy_window.x-10,@resolution[0]-@buy_window.width].max
     @buy_window.x = @resolution[0] if @number_window.visible
   elsif !@number_window.visible
     @buy_window.x = [@buy_window.x+10,@resolution[0]].min
   end
   if @sell_window.active
     @sell_window.x = [@sell_window.x-10,@resolution[0]-@sell_window.width].max
     @sell_window.x = @resolution[0] if @number_window.visible
   elsif !@number_window.visible
     @sell_window.x = [@sell_window.x+10,@resolution[0]].min
   end
   # this is to make the background scroll/panorama
   @mnback.ox -= 0
   @mnback.oy -= 0
 end
 #--------------------------------------------------------------------------
 # * Update Arrow
 #--------------------------------------------------------------------------
 def update_arrow
   @sprite_arrow.x = [@sprite_arrow.x-10, 5].max
   @sprite_arrow.y = @sprite_menu[@index].y + 10
 end
 #--------------------------------------------------------------------------
 # ● condition_eval
 #--------------------------------------------------------------------------
 def condition_eval(ev='')
   return true if ev.nil?
   return ev if !ev.is_a?(String)
   return eval (ev)
 end
 #--------------------------------------------------------------------------
 # ● update_index
 #--------------------------------------------------------------------------
 def update_index
   if Input.repeat?(Input::DOWN)
     if (@column_max == 1 && Input.trigger?(Input::DOWN)) ||
         @index < @item_max - @column_max
       se_play(:cursor)
       @index = (@index + @column_max) % @item_max
     end
     return
   end
   if Input.repeat?(Input::UP)
     if (@column_max == 1 && Input.trigger?(Input::UP)) ||
         @index >= @column_max
       se_play(:cursor)
       @index = (@index - @column_max) % @item_max
     end
     return
   end
   if Input.trigger?(Input::B)
     se_play(:cancel)
     $limited_shop = nil
     $scene = Scene_Map.new
   end
   if Input.trigger?(Input::C)
     return se_play(:buzzer) if !condition_eval(@menu[@index][1])
     case @index
     when 0
       se_play(:decision)
       @command_window_active = false
       @buy_window.active = true
       @buy_window.refresh
       @status_window.visible = true
     when 1
       se_play(:decision)
       @command_window_active = false
       @sell_window.active = true
       @sell_window.refresh
     end
   end
 end
 #--------------------------------------------------------------------------
 # ● se_play
 #--------------------------------------------------------------------------
 def se_play(type)
   a = [$game_system,$data_system]
   case type
   when :cursor   : VX ? Sound.play_cursor   : a[0].se_play(a[1].cursor_se)
   when :decision : VX ? Sound.play_decision : a[0].se_play(a[1].decision_se)
   when :cancel   : VX ? Sound.play_cancel   : a[0].se_play(a[1].cancel_se)
   when :buzzer   : VX ? Sound.play_buzzer   : a[0].se_play(a[1].buzzer_se)
   end
 end
 #--------------------------------------------------------------------------
 # * Frame Update (when buy window is active)
 #--------------------------------------------------------------------------
 def update_buy
   @status_window.item = @buy_window.item
   if Input.trigger?(Input::B)
     $game_system.se_play($data_system.cancel_se)
     @command_window_active = true
     @buy_window.active = false
     @status_window.visible = false
     @status_window.item = nil
     @help_window.set_text("")
     return
   end
   if Input.trigger?(Input::C)
     @item = @buy_window.item
     price = @item.is_a?(RPG::Skill) ? @item.sp_cost : @item.price if !@item.nil?
     if @item.nil? or price > $game_party.gold
       return $game_system.se_play($data_system.buzzer_se)
     end
     number = case @item
     when RPG::Item then $game_party.item_number(@item.id)
     when RPG::Weapon then $game_party.weapon_number(@item.id)
     when RPG::Armor then $game_party.armor_number(@item.id)
     end || 0
     return $game_system.se_play($data_system.buzzer_se) if number == 99
     $game_system.se_play($data_system.decision_se)
     t = @item.is_a?(RPG::Weapon) ? 1 : @item.is_a?(RPG::Armor) ? 2 :
            @item.is_a?(RPG::Item) ? 0 : -1    
     lim = @buy_window.item_bought(@item)
     d = (@buy_window.limited_shopping["#{t} #{@item.id}"]||{})['#3x53d323']||0
     s = (!d.nil? && lim.nil? ? d - lim : d) || 99
     max = price == 0 ? s : $game_party.gold / price
     max =  [max, s].min if d.abs != 999999999
     max = [max, 99 - number].min
     max = 1 if @item.is_a?(RPG::Skill)
     @buy_window.active = false
     @number_window.set(@item, max, price)
     @number_window.active = true
     @number_window.visible = true
   end
 end
 #--------------------------------------------------------------------------
 # * Frame Update (when sell window is active)
 #--------------------------------------------------------------------------
 def update_sell
   if Input.trigger?(Input::B)
     $game_system.se_play($data_system.cancel_se)
     @command_window_active = true
     @sell_window.active = false
     @status_window.item = nil
     @help_window.set_text("")
     @sell_window.instance_variable_set(:@gold, '')
     return
   end
   if Input.trigger?(Input::C)
     @item = @sell_window.item
     @status_window.item = @item
     gold = @buy_window.item_bought('Gold')
     price = @item.nil? ? 0 : @item.price / 2
     cond = LiTTleDRAgo::SHOP_HAS_GOLD ? gold < price : false
     if @item == nil or @item.price == 0 || cond
       return $game_system.se_play($data_system.buzzer_se)
     end
     $game_system.se_play($data_system.decision_se)
     number = case @item
     when RPG::Item then $game_party.item_number(@item.id)
     when RPG::Weapon then $game_party.weapon_number(@item.id)
     when RPG::Armor then $game_party.armor_number(@item.id)
     end
     max = number
     @sell_window.active = false
     (0..max).each  {|s| @can_sell = s if s*price <= gold  }
     max = [max, @can_sell].min if LiTTleDRAgo::SHOP_HAS_GOLD
     @number_window.set(@item, max, price)
     @number_window.active = true
     @number_window.visible = true
     @status_window.visible = true
   end
 end
 #--------------------------------------------------------------------------
 # * Frame Update (when quantity input window is active)
 #--------------------------------------------------------------------------
 def update_number
   if Input.trigger?(Input::B)
     $game_system.se_play($data_system.cancel_se)
     @number_window.active = false
     @number_window.visible = false
     case @index
     when 0
       @buy_window.active = true
     when 1
       @sell_window.active = true
       @status_window.visible = false
     end
     return
   end
   if Input.trigger?(Input::C)
     $game_system.se_play($data_system.shop_se)
     @number_window.active = false
     @number_window.visible = false
     number = @number_window.number
     case @index
     when 0  # buy
       price = @item.is_a?(RPG::Skill) ? @item.sp_cost : @item.price if !@item.nil?
       $game_party.lose_gold(number * price)
       case @item
       when RPG::Item : $game_party.gain_item(@item.id, number)
       when RPG::Weapon : $game_party.gain_weapon(@item.id, number)
       when RPG::Armor : $game_party.gain_armor(@item.id, number)
       when RPG::Skill : $game_party.actors[0].learn_skill(@item.id)
       end
       t = @item.is_a?(RPG::Weapon) ? 1 : @item.is_a?(RPG::Armor) ? 2 :
              @item.is_a?(RPG::Item) ? 0 : -1
       d = (@buy_window.limited_shopping["#{t} #{@item.id}"]||{})['#3x53d323']||0
       number.times {@buy_window.item_bought(@item,1)} if  d != -999999999
       @buy_window.item_bought('Gold',number*price)
       @gold_window.refresh
       @buy_window.refresh
       @status_window.refresh
       @buy_window.active = true
       create_menu(1)
     when 1  # sell
       $game_party.gain_gold(number * (@item.price / 2))
       case @item
       when RPG::Item : $game_party.lose_item(@item.id, number)
       when RPG::Weapon : $game_party.lose_weapon(@item.id, number)
       when RPG::Armor : $game_party.lose_armor(@item.id, number)
       end
       t = @item.is_a?(RPG::Weapon) ? 1 : @item.is_a?(RPG::Armor) ? 2 :
              @item.is_a?(RPG::Item) ? 0 : -1
       d = (@buy_window.limited_shopping["#{t} #{@item.id}"]||{})['#3x53d323']||0
       number.times {@buy_window.item_bought(@item,-1)} if  d != -999999999
       @buy_window.item_bought('Gold',-number*@item.price/2)
       @gold_window.refresh
       @sell_window.refresh
       @status_window.refresh
       @sell_window.active = true
       create_menu(1)
       @status_window.visible = false
     end
     return
   end
 end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs map screen processing.
#==============================================================================

class Scene_Map
 alias drg1732013_update update
 def update
   drg1732013_update
   unless $game_player.moving?
     if !$limited_shop.nil?
       all = []
       $game_system.class.send(:attr_accessor ,:limited_shop)
        $limited_shop.dup.each_pair {|t,i|
          r = []
          i = i.split(/,/) if i.is_a?(String)
          i.collect.each {|s|
             d = s[/i(\d+)/i] ? $data_items[$1.to_i]  :
             s[/w(\d+)/i] ? $data_weapons[$1.to_i] :
             s[/a(\d+)/i] ? $data_armors[$1.to_i] :
             s[/s(\d+)/i] ? $data_skills[$1.to_i] : 0
             r << d} if i.is_a?(Array)
         all << r.unshift (t)}
       $limited_shop_process = all
       $scene = Scene_LimitedShop.new
     end
   end
 end
end
#==============================================================================
# ** Interpreter
#------------------------------------------------------------------------------
#  This interpreter runs event commands. This class is used within the
#  Game_System class and the Game_Event class.
#==============================================================================

class Interpreter
 #--------------------------------------------------------------------------
 # * limit_shop_item
 #--------------------------------------------------------------------------
 def limit_shop_item(shop,item,limit=nil)
   $game_system.class.send(:attr_accessor ,:limited_shop)
   map = [[@map_id, @event_id]]
   map = shop if shop.is_a?(Array)
   t = item.is_a?(RPG::Weapon) ? 1 : item.is_a?(RPG::Armor) ? 2 :
       item.is_a?(RPG::Item)   ? 0 : -1
   t = item.is_a?(String)     ? item : "#{t} #{item.id}"
   $game_system.limited_shop = {} if $game_system.limited_shop.nil?
   $game_system.limited_shop[map] = {} if $game_system.limited_shop[map].nil?
   $game_system.limited_shop[map]["#{t}"] = {} if
     $game_system.limited_shop[map]["#{t}"].nil?
   result = $game_system.limited_shop[map]["#{t}"]
   return result['Get']||0 if limit.nil?
   return result['Get'] = -limit if limit.is_a?(Integer)
   return result['Get'] = 999999999
 end
end


#==============================================================================
# ** Window_ShopStatus
#------------------------------------------------------------------------------
#  This window displays number of items in possession and the actor's equipment
#  on the shop screen.
#==============================================================================

class Window_ShopStatusLimited < Window_Base
 
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize
   super(0, 200, 272, 352)
   self.contents = Bitmap.new(width - 32, height - 32)
   @item = nil
   self.opacity = 0
   self.back_opacity = 0
   refresh
 end
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh
   self.contents.clear
   return if @item == nil
   return if @item.is_a?(RPG::Skill)
   return if @item.is_a?(RPG::Item)
   $game_party.actors.each_with_index {|actor,i|
     if actor.equippable?(@item)
       self.contents.font.color = normal_color
     else
       self.contents.font.color = disabled_color
     end
     face = sprite_character(actor)
     self.contents.blt(4,64-60+face.height*i,face,face.rect)
     if @item.is_a?(RPG::Weapon)
       item1 = $data_weapons[actor.weapon_id]
     elsif @item.kind == 0
       item1 = $data_armors[actor.armor1_id]
     elsif @item.kind == 1
       item1 = $data_armors[actor.armor2_id]
     elsif @item.kind == 2
       item1 = $data_armors[actor.armor3_id]
     elsif @item.kind == 3
       item1 = $data_armors[actor.armor4_id]
     else
       return
     end
     if actor.equippable?(@item)
       if @item.is_a?(RPG::Weapon)
         atk1 = item1 != nil ? item1.atk : 0
         atk2 = @item != nil ? @item.atk : 0
         change = atk2 - atk1
       end
       if @item.is_a?(RPG::Armor)
         pdef1 = item1 != nil ? item1.pdef : 0
         mdef1 = item1 != nil ? item1.mdef : 0
         pdef2 = @item != nil ? @item.pdef : 0
         mdef2 = @item != nil ? @item.mdef : 0
         change = pdef2 - pdef1 + mdef2 - mdef1
       end
       a= self.contents.font.color
       self.contents.font.color = change > 0 ? Color.new(128,255,128) :
        change < 0 ? Color.new(255,28,28) : normal_color  
       self.contents.draw_text(110, 42-32 + face.height * i, 112, 32,
         sprintf("%+d", change), 2)
     end
     if item1 != nil
       x = 4+face.width
       y = 42 -64+ face.height * i + 32
       bitmap = RPG::Cache.icon(item1.icon_name)
       opacity = self.contents.font.color == normal_color ? 255 : 128
       self.contents.blt(x, y - 9, bitmap, Rect.new(0, 0, 80, 80), opacity)
#        self.contents.draw_text(x + 45, y, 212, 32, item1.name)
     end }
 end
 #--------------------------------------------------------------------------
 # ● sprite_character
 #--------------------------------------------------------------------------
 def sprite_character(actor)
   if false
     bit = cache.character(actor.character_name)  
     sign = actor.character_name[/^[\!\$]./]
     if sign != nil and sign.include?('$')
       cw = [bit.width / 3,bit.height / 4]
     else
       cw = [bit.width / 12,bit.height / 8]
     end
     index = actor.character_index
     pattern = (@pattern||0) < 3 ? (@pattern||0) : 1
     sx = [(index % 4 * 3 + pattern) * cw[0],
       (index / 4 * 4 + (2 - 2) / 2) * cw[1]]
     rect = Rect.new(sx[0], sx[1], cw[0], cw[1])
     bitmap = Bitmap.new(*cw)
     bitmap.blt(0,0,bit,rect)
     return bitmap
   end
   bit = RPG::Cache.character(actor.character_name,0)
   cw = [bit.width / 4, bit.height / 4]
   sx = [(@pattern||0) * cw[0], (2 - 2) / 2 * cw[1]]
   rect = Rect.new(sx[0], sx[1], cw[0], cw[1])
   bitmap = Bitmap.new(*cw)
   bitmap.blt(0,0,bit,rect)
   return bitmap
 end
 #--------------------------------------------------------------------------
 # * Set Item
 #     item : new item
 #--------------------------------------------------------------------------
 def item=(item)
   if @item != item
     @item = item
     refresh
   end
 end
end
#==============================================================================
# ** Window_ShopBuyLimited
#------------------------------------------------------------------------------
#  This window displays buyable goods on the shop screen.
#==============================================================================

class Window_ShopBuyLimited < Window_Selectable
 #--------------------------------------------------------------------------
 # * Object Initialization
 #     shop_goods : goods
 #--------------------------------------------------------------------------
 def initialize
   super(0, 295, 310, 195)
   @column_max = 3
   self.opacity = 0
   self.back_opacity = 0
   @shop_goods = $limited_shop_process.dup
   @get_sold = LiTTleDRAgo::GET_SOLD_ITEM
   @shop_goods.each {|s| t = s[0]
     next if limited_shopping['#3x53d324']
     if t == 'G'
       limited_shopping['#3x53d324'] = true
       item_bought('Gold',$limited_shop[t])
       next
     end
     s.each {|i| next if i.is_a?(Integer) || !t.is_a?(Integer)
       d = i.is_a?(RPG::Weapon) ? 1 :  i.is_a?(RPG::Armor) ? 2 :
              i.is_a?(RPG::Item) ? 0 : -1
       limited_shopping["#{d} #{i.id}"] = {} if limited_shopping["#{d} #{i.id}"].nil?
       limited_shopping["#{d} #{i.id}"]['Get'] = -t
       limited_shopping["#{d} #{i.id}"]['Get'] = 999999999 if t == 0}}
   refresh
   self.index = 0
 end
 #--------------------------------------------------------------------------
 # * Item Acquisition
 #--------------------------------------------------------------------------
 def item
   return @data[self.index]
 end
 #--------------------------------------------------------------------------
 # * update_item
 #--------------------------------------------------------------------------
 def item_bought(item,val=nil)
   t = item.is_a?(RPG::Weapon) ? 1 : item.is_a?(RPG::Armor) ? 2 :
       item.is_a?(RPG::Item) ? 0 : -1
   t = item.is_a?(String) ? item : "#{t} #{item.id}"
   limited_shopping[t] = {} if limited_shopping[t].nil?
   limited_shopping[t]['Get'] = 0 if limited_shopping[t]['Get'].nil?
   return limited_shopping[t]['Get'] += val if !val.nil?
   return limited_shopping[t]['Get']
 end
 #--------------------------------------------------------------------------
 # * limited_shopping
 #--------------------------------------------------------------------------
 def limited_shopping
   int = $game_system.map_interpreter.instance_variable_get(:@event_id)
   map = $game_system.map_interpreter.instance_variable_get(:@map_id)
   lin = [map,int]#,"#{$limited_shop}"]
   $game_system.limited_shop = {} if $game_system.limited_shop.nil?
   lim = $game_system.limited_shop[lin]
   $game_system.limited_shop[lin] = {} if lim.nil?
   return $game_system.limited_shop[lin]
 end
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh
   if self.contents != nil
     self.contents.dispose
     self.contents = nil
   end
   @data = Array.new(4){[]}
   limited_shopping.each_pair {|k,r| d = k.split(' ')
       d.size != 2 ? next : d.map! {|s| s.to_i}
       i = d[0] == 0 ? $data_items[d[1]]  : d[0] == 1 ? $data_weapons[d[1]] :
           d[0] == 2 ? $data_armors[d[1]] : $data_skills[d[1]]
       r.each_pair {|m,v|
         next if m != 'Get' || i.nil? || (v.to_i >= 0 && v != 999999999)
           r['#3x53d323']= -v    
           r['#3x53d323']= -999999999 if v == 999999999 || @get_sold == 2  
         @data[d[0]+1] << i }} if @get_sold != 0
   @data = @data.each {|s|s.sort!{|b,c|b.id<=>c.id}}.flatten.collect {|s|s}
   @item_max = @data.size
   return unless @item_max > 0
   self.contents = Bitmap.new(width - 32, row_max * 80)
   @data.each_index {|i| draw_item(i)}
 end
 #--------------------------------------------------------------------------
 # * Draw Item
 #     index : item number
 #--------------------------------------------------------------------------
 def draw_item(index)
   item = @data[index]
   t = item.is_a?(RPG::Weapon) ? 1 : item.is_a?(RPG::Armor) ? 2 :
       item.is_a?(RPG::Item)   ? 0 : -1
   number = case t
   when 0 : $game_party.item_number(item.id)
   when 1 : $game_party.weapon_number(item.id)
   when 2 : $game_party.armor_number(item.id)
   end || 0
   can_buy = (limited_shopping["#{t} #{item.id}"]||{})['#3x53d323']||0
   can_buy = '' if can_buy <= 0
   price = item.is_a?(RPG::Skill) ? item.sp_cost : item.price
   conds = (price <= $game_party.gold && number.to_i < 99)
   self.contents.font.color = conds ? normal_color : disabled_color
   number = number > 0 ? sprintf(LiTTleDRAgo::OWN_TEXT, number) : ''
   number.gsub!(' 0','  ')
   pos = [4 + index % @column_max * (95),index / @column_max * 50]
   rect = Rect.new(x, y, self.width / @column_max - 80, 80)
   self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
   bit = RPG::Cache.icon(item.icon_name)
   opc = self.contents.font.color == normal_color ? 255 : 128
   con = self.contents.font.size
   self.contents.blt(pos[0], pos[1], bit, Rect.new(0, 0, 80, 80), opc)
#    self.contents.draw_text(pos[0]+58, pos[1], 212, 32, item.name, 0)
#    self.contents.draw_text(pos[0]+25, pos[1], 88, 35, price.to_s, 2)
#    self.contents.font.size = 18
#    self.contents.draw_text(pos[0]+30, pos[1], 88, 32, number.to_s, 2)
#    self.contents.font.size = 25
#    self.contents.font.bold = true
#    self.contents.draw_text(pos[0]+15, pos[1]+25, 80, 80, can_buy.to_s, 2)
#    self.contents.font.size = con
#    self.contents.font.bold = false
 end
 #--------------------------------------------------------------------------
 # * Help Text Update
 #--------------------------------------------------------------------------
 def update_help
   @help_window.set_text(self.item == nil ? "" : self.item.description)
 end
end
#==============================================================================
# ** Window_ShopSellLimited
#------------------------------------------------------------------------------
#  This window displays items in possession for selling on the shop screen.
#==============================================================================

class Window_ShopSellLimited < Window_ShopBuyLimited
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh
   if self.contents != nil
     self.contents.dispose
     self.contents = nil
   end
   @data = []
   @data = $data_items.map{|i| i if $game_party.item_number(i.id) > 0 }.compact
   @data += $data_weapons.map{|i| i if $game_party.weapon_number(i.id) > 0 }.compact
   @data += $data_armors.map{|i| i if $game_party.armor_number(i.id) > 0 }.compact

   # If item count is not 0, make a bitmap and draw all items
   @item_max = @data.size
   if @item_max > 0
     self.contents = Bitmap.new(width - 32, row_max * 80)
     for i in 0...@item_max
       draw_item(i)
     end
   end
 end
 #--------------------------------------------------------------------------
 # * Draw Item
 #     index : item number
 #--------------------------------------------------------------------------
 def draw_item(index)
   item = @data[index]
   t = item.is_a?(RPG::Weapon) ? 1 : item.is_a?(RPG::Armor) ? 2 :
          item.is_a?(RPG::Item) ? 0 : -1
   number = case t
   when 0 : $game_party.item_number(item.id)
   when 1 : $game_party.weapon_number(item.id)
   when 2 : $game_party.armor_number(item.id)
   end || 0
   gold = item_bought('Gold')
   gold = gold >= item.price/2 if LiTTleDRAgo::SHOP_HAS_GOLD
   gold = (item.price>0&&gold)
   self.contents.font.color = gold ? normal_color : disabled_color
   pos = [4 + index % @column_max * (95),index / @column_max * 50]
   rect = Rect.new(x, y, self.width / @column_max - 80, 80)
#    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
   bit = RPG::Cache.icon(item.icon_name)
   opc = self.contents.font.color == normal_color ? 255 : 128
   self.contents.blt(pos[0], pos[1]+4, bit, Rect.new(0, 0, 80, 80), opc)
#   self.contents.draw_text(pos[0]+28, pos[1], 212, 32, item.name, 0)
   self.contents.draw_text(pos[0]+70, pos[1], 16, 80, "x", 1)
   self.contents.draw_text(pos[0]+75, pos[1], 24, 80, number.to_s, 2)
 end
 #--------------------------------------------------------------------------
 # * Help Text Update
 #--------------------------------------------------------------------------
 def update_help
   @help_window.set_text(self.item == nil ? "" : self.item.description)
   return if @gold == item_bought('Gold') && @old_item == self.item
   return unless LiTTleDRAgo::SHOP_HAS_GOLD
   @old_item = self.item
   @gold = item_bought('Gold')
   s = @help_window.width - 40
   @help_window.contents.fill_rect(Rect.new(420,0,s,32),Color.new(0,0,0,0))
   @help_window.contents.font.size -= 4
   @help_window.contents.draw_text(420, 0, s, 32, LiTTleDRAgo::SHOP_GOLD_TEXT)
   @help_window.contents.draw_text(4, 0, s, 32, item_bought('Gold').to_s, 2)
   @help_window.contents.font.size += 4
 end
end

#==============================================================================
# ** RPG::Something
#------------------------------------------------------------------------------
#  This module handles data item, weapon, and armor
#==============================================================================

['Item','Weapon','Armor'].each {|clas| eval "
module RPG
 class #{clas}
   alias tax price unless method_defined?(:tax)
   def price() (tax + tax*($game_system.tax||0) / 100).to_i end
 end
end#"}
______・*。☆彡Ƹ̵̡Ӝ̵̨̄Ʒ*~゚・。 )O( 。・゚~*Ƹ̵̡Ӝ̵̨̄Ʒミ☆。*・______
MoonFaerie Studio: (Formerly LunarBerry Studio)
http://www.moonfaeriestudio.com

Deviantart gallery: https://www.deviantart.com/moonfaeriestudio
--------------・*。☆*~゚・。Ƹ̵̡Ӝ̵̨̄Ʒ。・゚~*☆。*・--------------

Current Game Project(s):
In collaboration w/Siletrea:
[Image: 55e3faa432d9efb86b8f19a6f25c0126-dawz35x.png]
----------------------------------
My Personal Project(s):
[Image: banner_by_lunarberry-dbi9fm7.png]

I do all sorts of arts and crafts :P ... and randomly too
Reply }


Messages In This Thread
Shop Issues :P - by LunarBerry - 11-21-2016, 03:24 PM
RE: Shop Issues :P - by kyonides - 11-21-2016, 10:13 PM
RE: Shop Issues :P - by LunarBerry - 11-22-2016, 02:19 AM
RE: Shop Issues :P - by kyonides - 11-22-2016, 03:15 AM
RE: Shop Issues :P - by LunarBerry - 11-23-2016, 02:53 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
   Sorting Items in Shop Window Melana 13 15,481 01-18-2018, 05:49 AM
Last Post: DerVVulfman
   Dargor's Large Party script and shop menu Simon Greedwell 2 6,023 08-28-2013, 10:12 PM
Last Post: Simon Greedwell
   Help with Shop Menu [RPG Maker XP] JackMonty 6 11,766 05-23-2013, 10:14 AM
Last Post: JackMonty
   Something I noticed about the Advanced Shop Status Window yamina-chan 5 9,080 08-21-2011, 09:16 PM
Last Post: yamina-chan



Users browsing this thread: