LOGIN
SEARCH
PROFILE
keys: ↑ ↓
LOGOUT
INDEX
MEMBERS
keys: ↑ ↓
HOME
PORTAL
PLAY ALONG
PLAY with WORDS
PLAY with GRAPHICS
PLAY with SOUNDS
PLAY with CODES
PLAY with PROJECTS
keys: ← →
Guest Access
Register:
Members:



View previous topic View next topic Go down Message [Page 1 of 1]

EVENTALIST
EVENTALIST
#1 default Wiggles Dynamic Shopping
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
Wiggles Dynamic Shop
Version: 1.5
Author: Mr_Wiggles
Date: January 28, 2012

Version History


  • 1.5 - Original release.


Planned Future Versions

  • Shop keepers have limited money.


Description


This script allows you to have more realistic shopping in your game.


Features

  • Shops will gain and lose stock as the player plays.
  • Individual item control.
  • Set the resale value for the items.


Screenshots
[You must be registered and logged in to see this link.]

Instructions
Copy the code bellow and paste it in the script database below the default and above main.



Code:

#===============================================================================
#                  ** Wiggles Dynamic Shop **
#===============================================================================
# By Mr Wiggles
# Version 1.5
# 1-28-12
#-------------------------------------------------------------------------------
# Based on sections from Tidloc's Dynamic shop.
#-------------------------------------------------------------------------------
# Instructions:
#      In the item, weapon, or armor's name use these tags:
#
#  g[#]  : Max gain for shop item's stock. | Item's name = Potion a[5] i[10]
#  a[#]  : Min starting shop item's stock. | Potion's stock will start between
#  i[#]  : Max starting shop item's stock. | 10 and 5.
#===============================================================================
module WDS
  VAR = 1    # Varaible used for shop id
  TS  = 90  # Number of seconds before restocking shops.
  VAL = 0.55 # Re-sale value. (full price 1 <=> 0 nothing)
  MG  = [15, 2, 2] # Default maximum gain  [item, weapon, armor]
  DMS = [10, 1, 1] # Default minimum start quantity [item, weapon, armor]
  MMS = [50, 4, 4] # Default maximum start quantity [item, weapon, armor]
end
#===============================================================================
#                  *** END CONFIG AREA ***
#===============================================================================
class Scene_Shop
#---------------------------------------------------------------------------
# Main
#---------------------------------------------------------------------------
  def main
    # create/ load shop items
    @shopnum = $game_variables[WDS::VAR]
    if !$game_system.shop_exist?(@shopnum)
      $game_system.shop_add_shop(@shopnum, $game_temp.shop_goods)
    end
    @shop = $game_system.shops[@shopnum]
    $game_system.shops[@shopnum].update_goods?($game_temp.shop_goods)
    # create blank window
    @dummy_window = Window_Base.new(0, 64, 640, 352)
    # create help window assoisation
    @help_window = Window_Help.new; @help_window.y = 416
    # create main command window
    commands = ["Buy Items", "Sell Items", "Leave"]
    @command_window = Window_Shop_Command.new(commands)
    @command_window.active = true
    # create gold window
    @gold_window  = Window_Gold.new(true)
    @gold_window.width = 240; @gold_window.x = 400
    # create buy window
    @buy_window = Window_ShopBuy.new(@shop)
    @buy_window.z          = 250
    @buy_window.active      = false
    @buy_window.help_window = @help_window
    # create sell window
    @sell_window = Window_ShopSell.new
    @sell_window.z          = 250
    @sell_window.active      = false
    @sell_window.visible    = false
    @sell_window.help_window = @help_window
    # create number window
    @number_window = Window_ShopNumber.new
    @number_window.z        = 300
    @number_window.active  = false
    @number_window.visible  = false
    # Main Loop
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    # dispose windows
    @number_window.dispose
    @sell_window.dispose
    @buy_window.dispose
    @command_window.dispose
    @help_window.dispose
    @gold_window.dispose
    @dummy_window.dispose
  end
#---------------------------------------------------------------------------
# Update
#--------------------------------------------------------------------------- 
  def update
    @number_window.update
    @sell_window.update
    @buy_window.update
    @command_window.update
    @gold_window.update
    @help_window.update
    if @command_window.active
      update_command
      return
    elsif @buy_window.active
      update_buy
      return
    elsif @sell_window.active
      update_sell
      return
    elsif @number_window.active
      update_number
    end
  end
#---------------------------------------------------------------------------
# Update Main Commands
#--------------------------------------------------------------------------- 
  def update_command
    case @command_window.index
    when 0
      @help_window.set_text("Buying of the regular stock of the shop")
    when 1
      @help_window.set_text("Selling items you own")
    when 2
      @help_window.set_text("Leaving shop")
    end
    case @command_window.index
    when 0
      @buy_window.visible    = true
      @sell_window.visible  = false
    when 1
      @sell_window.visible  = true
      @buy_window.visible    = false
    when 2
      @sell_window.visible  = false
      @buy_window.visible    = false
    end
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
    elsif Input.trigger?(Input::C)
      case @command_window.index
      when 0
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @buy_window.active    = true
      when 1
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @sell_window.active    = true
      when 2
        $game_system.se_play($data_system.cancel_se)
        $scene = Scene_Map.new
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when buy window is active)
  #--------------------------------------------------------------------------
  def update_buy
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @command_window.active = true
      @buy_window.active    = false
      return
    end
    if Input.trigger?(Input::C)
      @item = @buy_window.item
      if @item.nil?
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # item priced on barter skill level
      if @item.price > $game_party.gold
        @item = nil
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      case @item
      when RPG::Item
        number = $game_party.item_number(@item.id)
        shop_stock = $game_system.shops[@shop.id].item_number(@item.id)
      when RPG::Weapon
        number = $game_party.weapon_number(@item.id)
        shop_stock = $game_system.shops[@shop.id].weapon_number(@item.id)
      when RPG::Armor
        number = $game_party.armor_number(@item.id)
        shop_stock = $game_system.shops[@shop.id].armor_number(@item.id)
      end
      if number == 99
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      max = @item.price == 0 ? 99 : $game_party.gold / @item.price
      max = [max, 99 - number, shop_stock].min
      @buy_window.active    = false
      @number_window.set(@item, max, @item.price)
      @number_window.active  = true
      @number_window.visible = true
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when buy 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
      @help_window.set_text("")
      return
    end
    if Input.trigger?(Input::C)
      @item = @sell_window.item
      if @item.nil?
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      if @item.price == 0
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      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
      max = number
      @sell_window.active = false
      @number_window.set(@item, max, (@item.price.to_f * WDS::VAL).round)
      @number_window.active = true
      @number_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 @command_window.index
      when 0
        @buy_window.active  = true
      when 1
        @sell_window.active = true
      end
      return
    end
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.shop_se)
      @number_window.active  = false
      @number_window.visible = false
      case @command_window.index
      when 0
        $game_party.lose_gold(@number_window.number * @item.price)
        number = @number_window.number
        case @item
        when RPG::Item
          $game_system.shops[@shop.id].gain_item(@item.id, -number)
          $game_party.gain_item(@item.id, number)
        when RPG::Weapon
          $game_system.shops[@shop.id].gain_weapon(@item.id, -number)
          $game_party.gain_weapon(@item.id, number)
        when RPG::Armor
          $game_system.shops[@shop.id].gain_armor(@item.id, -number)
          $game_party.gain_armor(@item.id, number)
        end
        @gold_window.refresh
        @buy_window.refresh
        @sell_window.refresh
        @buy_window.active  = true
      when 1
        number = @number_window.number
        $game_party.gain_gold(number * (@item.price.to_f * WDS::VAL).round)
        case @item
        when RPG::Item
          $game_system.shops[@shop.id].gain_item(@item.id, number)
          $game_party.lose_item(@item.id, number)
        when RPG::Weapon
          $game_system.shops[@shop.id].gain_weapon(@item.id, number)
          $game_party.lose_weapon(@item.id, number)
        when RPG::Armor
          $game_system.shops[@shop.id].gain_armor(@item.id, number)
          $game_party.lose_armor(@item.id, number)
        end
        @gold_window.refresh
        @sell_window.refresh
        @buy_window.refresh
        @sell_window.active = true
      end
      return
    end
  end
end

#===============================================================================
# * Scene Map
#===============================================================================
class Scene_Map
  #---------------------------------------------------------------------------
  # Main
  #---------------------------------------------------------------------------
  alias shop_main main
  def main
    @shop_time = Graphics.frame_count / Graphics.frame_rate
    shop_main
  end
  #---------------------------------------------------------------------------
  # Update
  #--------------------------------------------------------------------------- 
  alias shop_update update
  def update
    shop_update
    ps = (Graphics.frame_count / Graphics.frame_rate)
    if (@shop_time + WDS::TS) < ps
      @shop_time = (Graphics.frame_count / Graphics.frame_rate)
      $game_system.shops.each_value{|shop| shop.restock}
    end
  end
end

#===============================================================================
# * Game System
#===============================================================================
class Game_System
  attr_accessor :shops, :starting_items
  #---------------------------------------------------------------------------
  # Initialize
  #---------------------------------------------------------------------------
  alias shop_init initialize
  def initialize
    shop_init
    @shops = {}
    @starting_items = []
  end
  #---------------------------------------------------------------------------
  # Add shop
  #--------------------------------------------------------------------------- 
  def shop_add_shop(id, items)
    if !shop_exist?(id)
      @shops[id] = Dynamic_Shop.new(id)
      shop_starting_items(id, items)
    end
  end
  #---------------------------------------------------------------------------
  # Shop exsists check
  #--------------------------------------------------------------------------- 
  def shop_exist?(id)
    return true if !@shops[id].nil?
    return false
  end
  #---------------------------------------------------------------------------
  # Setup starting shop items
  #---------------------------------------------------------------------------
  def shop_starting_items(shop_id, items)
    shop = @shops[shop_id]
    for item in items
      case item[0]
      when 0 then data = $data_items[item[1]]
      when 1 then data = $data_weapons[item[1]]
      when 2 then data = $data_armors[item[1]]
      end
      next if data.nil?
      if !@starting_items.include?(data)
        start  = data.maxstart - data.minstart
        srand(Time.now.to_i)
        ammount = data.minstart + rand(start / 2) + rand(start / 2)
        case item[0]
        when 0 then shop.gain_item(item[1], ammount.round)
        when 1 then shop.gain_weapon(item[1], ammount.round)
        when 2 then shop.gain_armor(item[1], ammount.round)
        end
      end
      @shops[shop_id].starting_items.push(data)
    end
  end
end

#===============================================================================
# * Dynamic Shop
#===============================================================================
class Dynamic_Shop
  attr_accessor :id
  attr_accessor :starting_items
  #---------------------------------------------------------------------------
  # Initialize
  #---------------------------------------------------------------------------
  def initialize(id)
    @id            = id
    @starting_items = []
    @items          = {}
    @weapons        = {}
    @armors        = {}
  end
  #--------------------------------------------------------------------------
  # * Get Number of Items Possessed
  #--------------------------------------------------------------------------
  def item_number(item_id)
    item_id = 0 if item_id.nil?
    num = @items[item_id].nil? ? 0 : @items[item_id]
    return num
  end
  #--------------------------------------------------------------------------
  # * Get Number of Weapons Possessed
  #--------------------------------------------------------------------------
  def weapon_number(weapon_id)
    weapon_id = 0 if weapon_id.nil?
    num = @weapons[weapon_id].nil? ? 0 : @weapons[weapon_id]
    return num
  end
  #--------------------------------------------------------------------------
  # * Get Amount of Armor Possessed
  #--------------------------------------------------------------------------
  def armor_number(armor_id)
    armor_id = 0 if armor_id.nil?
    num = @armors[armor_id].nil? ? 0 : @armors[armor_id]
    return num
  end
  #--------------------------------------------------------------------------
  # * Gain Items (or lose)
  #--------------------------------------------------------------------------
  def gain_item(item_id, n)
    if item_id > 0
      @items[item_id] = [item_number(item_id) + n, 0].max
    end
  end
  #--------------------------------------------------------------------------
  # * Gain Weapons (or lose)
  #--------------------------------------------------------------------------
  def gain_weapon(weapon_id, n)
    if weapon_id > 0
      @weapons[weapon_id] = [weapon_number(weapon_id) + n, 0].max
    end
  end
  #--------------------------------------------------------------------------
  # * Gain Armor (or lose)
  #--------------------------------------------------------------------------
  def gain_armor(armor_id, n)
    if armor_id > 0
      @armors[armor_id] = [armor_number(armor_id) + n, 0].max
    end
  end
  #--------------------------------------------------------------------------
  # * Restock Shop
  #--------------------------------------------------------------------------
  def restock
    for item in $data_items
      next if !@starting_items.include?(item)
      ammount = rand(2 * item.maxgain) - item.maxgain
      gain_item(item.id, ammount)
    end
    for weapon in $data_weapons
      next if !@starting_items.include?(weapon)
      ammount = rand(2 * weapon.maxgain) - weapon.maxgain
      gain_weapon(weapon.id, ammount)
    end
    for armor in $data_armors
      next if !@starting_items.include?(armor)
      ammount = rand(2 * armor.maxgain) - armor.maxgain
      gain_armor(armor.id, ammount)
    end
  end
  #--------------------------------------------------------------------------
  # * Update New Goods
  #--------------------------------------------------------------------------
  def update_goods?(new_goods)
    for item in new_goods
      case item[0]
      when 0 then data = $data_items[item[1]]
      when 1 then data = $data_weapons[item[1]]
      when 2 then data = $data_armors[item[1]]
      end
      next if data.nil?
      if !@starting_items.include?(data)
        start  = data.maxstart - data.minstart
        srand(Time.now.to_i)
        ammount = data.minstart + rand(start / 2) + rand(start / 2)
        case item[0]
        when 0 then gain_item(item[1], ammount)
        when 1 then gain_weapon(item[1], ammount)
        when 2 then gain_armor(item[1], ammount)
        end
      end
      @starting_items.push(data)
    end
  end
end

#==============================================================================
# ** Window_ShopBuy
#------------------------------------------------------------------------------
# By Wiggles
# Version 1.5
# 11-29-10
#==============================================================================
class Window_ShopBuy < Window_Selectable
  #--------------------------------------------------------------------------
  # * Initialize
  #--------------------------------------------------------------------------
  def initialize(shop)
    @shop = shop
    super(0, 64, 640, 352)
    @column_max = 2
    self.index = 0
    refresh
  end
  #--------------------------------------------------------------------------
  # * Item Acquisition
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    # Add Items
    for i in 1...$data_items.size
      num = $game_system.shops[@shop.id].item_number(i)
      if $game_system.shops[@shop.id].item_number(i) > 0
        @data.push($data_items[i])
      end
    end
    # Add Weapons
    for i in 1...$data_weapons.size
      if $game_system.shops[@shop.id].weapon_number(i) > 0
        @data.push($data_weapons[i])
      end
    end
    # Add Armors
    for i in 1...$data_armors.size
      if $game_system.shops[@shop.id].armor_number(i) > 0
        @data.push($data_armors[i])
      end
    end
    # 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 * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    case item
    when RPG::Item
      number = $game_system.shops[@shop.id].item_number(item.id)
    when RPG::Weapon
      number = $game_system.shops[@shop.id].weapon_number(item.id)
    when RPG::Armor
      number = $game_system.shops[@shop.id].armor_number(item.id)
    end
    if item.price <= $game_party.gold and number != 999
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    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)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    # draw item name
    self.contents.font.size = 22
    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    # draw item quantity
    self.contents.font.size = 14
    self.contents.draw_text(x + 246, y - 6, 64, 32, "x " + number.to_s, 0)
    # draw item price
    self.contents.draw_text(x + 214, y + 6, 64, 32, "$ " + item.price.to_s, 2)
    # draw item weight
    self.contents.font.size = 22
    self.contents.draw_text(x + 196, y, 16, 32, "|", 1)
  end
  #--------------------------------------------------------------------------
  # * Help Text Update
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
end

#==============================================================================
# ** Window_ShopSell
#==============================================================================
class Window_ShopSell < Window_Selectable
  #--------------------------------------------------------------------------
  # * Initialize
  #--------------------------------------------------------------------------
  def initialize
    super(0, 64, 640, 352)
    @column_max = 2
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Getting Items
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    # Add Items
    for i in 1...$data_items.size
      if $game_party.item_number(i) > 0
        @data.push($data_items[i])
      end
    end
    # Add Weapons
    for i in 1...$data_weapons.size
      if $game_party.weapon_number(i) > 0
        @data.push($data_weapons[i])
      end
    end
    # Add Armors
    for i in 1...$data_armors.size
      if $game_party.armor_number(i) > 0
        @data.push($data_armors[i])
      end
    end
    # 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 * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * 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
    # If items are sellable, set to valid text color. If not, set to invalid
    # text color.
    self.contents.font.color = item.price > 0 ? normal_color : disabled_color 
    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)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.font.size = 22
    # draw item name
    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    # draw item quantity
    self.contents.font.size = 14
    self.contents.draw_text(x + 246, y - 6, 64, 32, "x " + number.to_s, 0)
    # draw item price
    price = (item.price.to_f * WDS::VAL).round
    self.contents.draw_text(x + 214, y + 6, 64, 32, "$ " + price.to_s, 2)
    # draw item weight
    self.contents.font.size = 22
    self.contents.draw_text(x + 196, y, 16, 32, "|", 1)
  end
  #--------------------------------------------------------------------------
  # * Help Text Update
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
end

#==============================================================================
# ** Window_ShopNumber
#==============================================================================
class Window_ShopNumber < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(140, 148, 360, 164)
    self.contents = Bitmap.new(width - 32, height - 32)
    @item  = nil
    @max    = 1
    @price  = 0
    @number = 1
  end
  #--------------------------------------------------------------------------
  # * Set Items, Max Quantity, and Price
  #--------------------------------------------------------------------------
  def set(item, max, price)
    @item  = item
    @max    = max
    @price  = price
    @number = 1
    refresh
  end
  #--------------------------------------------------------------------------
  # * Set Inputted Quantity
  #--------------------------------------------------------------------------
  def number
    return @number
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    return if @item.nil?
    bitmap = RPG::Cache.icon(@item.icon_name)
    self.contents.blt(4, 20, bitmap, Rect.new(0, 0, 24, 24))
    self.contents.draw_text( 32, 16, 212, 32, @item.name)
    # show item price and show total cost calculation
    x = 230; y = 16 # pos of calculation table
    self.contents.draw_text(  x,    y,  96, 32, "$ " + @price.to_s, 2)
    self.contents.draw_text(x+24, y+16,  32, 32, "x")
    self.contents.draw_text(x+32, y+32,  64, 32, @number.to_s, 2)
    self.cursor_rect.set(x+56, y+32, 46, 32)
    total_cost = (@price * @number).to_s
    cx = contents.text_size(total_cost).width
    self.contents.draw_text(x-32, y+80, 128, 32, total_cost, 2)
    self.contents.font.color = system_color
    self.contents.draw_text(  x+14, y+46, 96, 32, "___________", 2)
    self.contents.draw_text(x+56-cx, y+80, 32, 32, $data_system.words.gold, 2)
    # show party's gold
    party_gold = $game_party.gold.to_s
    cx = contents.text_size(party_gold).width
    self.contents.draw_text(84-cx, y+80, 32, 32, $data_system.words.gold, 2)
    self.contents.font.color = normal_color
    self.contents.draw_text(-24, y+80, 256, 32, party_gold, 1)
    # show detailed item information
    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)
      self.contents.font.color = system_color
      self.contents.draw_text(  4, y+40, 200, 32, "Number in possession")
      self.contents.font.color = normal_color
      self.contents.draw_text(172, y+40, 64, 32, number.to_s, 2)
      return
    end
    # Equipment information
    # If weapon
    if @item.is_a?(RPG::Weapon)
      atk = !@item.nil? ? @item.atk : 0
      self.contents.draw_text(-16, y+40, 112, 32, atk.to_s, 2)
      self.contents.font.color = system_color
      self.contents.draw_text(-70, y+40, 112, 32, "Dmg", 2)
    end
    # If armor
    if @item.is_a?(RPG::Armor)
      pdef  = !@item.nil? ? @item.pdef : 0
      mdef  = !@item.nil? ? @item.mdef : 0
      self.contents.draw_text(-16, y+40, 112, 32, pdef.to_s, 2)
      self.contents.draw_text(-16, y+60, 112, 32, mdef.to_s, 2)
      self.contents.font.color = system_color
      self.contents.draw_text(-60, y+40, 112, 32, "PDef", 2)
      self.contents.draw_text(-60, y+60, 112, 32, "MDef", 2)
    end
    self.contents.font.color = normal_color
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    if self.active
      # Cursor right (+1)
      if Input.repeat?(Input::RIGHT) and @number < @max
        $game_system.se_play($data_system.cursor_se)
        @number += 1
        refresh
      end
      # Cursor left (-1)
      if Input.repeat?(Input::LEFT) and @number > 1
        $game_system.se_play($data_system.cursor_se)
        @number -= 1
        refresh
      end
      # Cursdr up (+10)
      if Input.repeat?(Input::UP) and @number < @max
        $game_system.se_play($data_system.cursor_se)
        @number = [@number + 10, @max].min
        refresh
      end
      # Cursor down (-10)
      if Input.repeat?(Input::DOWN) and @number > 1
        $game_system.se_play($data_system.cursor_se)
        @number = [@number - 10, 1].max
        refresh
      end
    end
  end
end

#==============================================================================
# ** Window_Shop_Command
#==============================================================================
class Window_Shop_Command < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(commands)
    super(0, 0, 400, 64)
    @item_max    = commands.size
    @column_max  = @item_max
    @commands    = commands
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i, normal_color)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #--------------------------------------------------------------------------
  def draw_item(index, color)
    self.contents.font.color = color
    rect = Rect.new(125 * index + 6, 0, 145, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    case index
    when 0 then rect = Rect.new(6, 0, 145, 32)
    when 1 then rect = Rect.new(140, 0, 145, 32)
    when 2 then rect = Rect.new(290, 0, 145, 32)
    end
    self.contents.draw_text(rect, @commands[index])
  end
  #--------------------------------------------------------------------------
  # * Disable Item
  #--------------------------------------------------------------------------
  def disable_item(index)
    draw_item(index, disabled_color)
  end
end

#==============================================================================
# ** Window_Gold
#==============================================================================
class Window_Gold < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(in_shop = false)
    super(0, 0, 160, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    @in_shop = in_shop
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    cx = contents.text_size($data_system.words.gold).width
    if @in_shop
      self.contents.font.color = normal_color
      self.contents.draw_text(cx, 0, 120, 32, $game_party.gold.to_s, 1)
      self.contents.font.color = system_color
      self.contents.draw_text(4, 0, cx, 32, $data_system.words.gold, 1)
    else
      self.contents.font.color = normal_color
      self.contents.draw_text(4, 0, 120-cx-2, 32, $game_party.gold.to_s, 2)
      self.contents.font.color = system_color
      self.contents.draw_text(124-cx, 0, cx, 32, $data_system.words.gold, 2)
    end
  end
end

#===============================================================================
# ** Item Modules
#===============================================================================
class RPG::Item
  #-----------------------------------------------------------------------
  def name
    name = @name.gsub(/g\[([0-9]+)\]/) {""}
    name = name.gsub(/a\[([0-9]+)\]/) {""}
    name = name.gsub(/i\[([0-9]+)\]/) {""}
    return name
  end
  #-----------------------------------------------------------------------
  def maxgain
    @name.gsub(/g\[([0-9]+)\]/) {"\1[#{$1}]"}
    value = $1.to_i
    return value <= 0 ? WDS::MG[0] : value
  end
  #-----------------------------------------------------------------------
  def minstart
    @name.gsub(/a\[([0-9]+)\]/) {"\1[#{$1}]"}
    value = $1.to_i
    return value <= 0 ? [WDS::DMS[0], WDS::MMS[0]].min : value
  end
  #-----------------------------------------------------------------------
  def maxstart
    @name.gsub(/i\[([0-9]+)\]>/) {"\1[#{$1}]"}
    value = $1.to_i
    return value <= 0 ? [WDS::DMS[0], WDS::MMS[0]].max : value
  end
end
#===============================================================================
class RPG::Weapon
  #-----------------------------------------------------------------------
  def name
    name = @name.gsub(/g\[([0-9]+)\]/) {""}
    name = name.gsub(/a\[([0-9]+)\]/) {""}
    name = name.gsub(/i\[([0-9]+)\]/) {""}
    return name
  end
  #-----------------------------------------------------------------------
  def maxgain
    @name.gsub(/g\[([0-9]+)\]/) {"\1[#{$1}]"}
    value = $1.to_i
    return value <= 0 ? WDS::MG[1] : value
  end
  #-----------------------------------------------------------------------
  def minstart
    @name.gsub(/a\[([0-9]+)\]/) {"\1[#{$1}]"}
    value = $1.to_i
    return value <= 0 ? [WDS::DMS[1], WDS::MMS[1]].min : value
  end
  #-----------------------------------------------------------------------
  def maxstart
    @name.gsub(/i\[([0-9]+)\]>/) {"\1[#{$1}]"}
    value = $1.to_i
    return value <= 0 ? [WDS::DMS[1], WDS::MMS[1]].max : value
  end
end
#===============================================================================
class RPG::Armor
  #-----------------------------------------------------------------------
  def name
    name = @name.gsub(/g\[([0-9]+)\]/) {""}
    name = name.gsub(/a\[([0-9]+)\]/) {""}
    name = name.gsub(/i\[([0-9]+)\]/) {""}
    return name
  end
  #-----------------------------------------------------------------------
  def maxgain
    @name.gsub(/g\[([0-9]+)\]/) {"\1[#{$1}]"}
    value = $1.to_i
    return value <= 0 ? WDS::MG[2] : value
  end
  #-----------------------------------------------------------------------
  def minstart
    @name.gsub(/a\[([0-9]+)\]/) {"\1[#{$1}]"}
    value = $1.to_i
    return value <= 0 ? [WDS::DMS[2], WDS::MMS[2]].min : value
  end
  #-----------------------------------------------------------------------
  def maxstart
    @name.gsub(/i\[([0-9]+)\]>/) {"\1[#{$1}]"}
    value = $1.to_i
    return value <= 0 ? [WDS::DMS[2], WDS::MMS[2]].max : value
  end
end
Demo: [You must be registered and logged in to see this link.]

Known Compatibility Issues
none.

Restrictions
Do not post this script anywhere with out my permission.


Like my scripts? Check my signature for a complete catalog.
EVENTALIST
Show Signature
EVENTALIST
The only one
The only one
#2 default Re: Wiggles Dynamic Shopping
Loading

NuKa_BuBble

NuKa_BuBble
The only one
The only one
profile
Nice script. I'll try to make my own shop with the Actions Points of XAS when I'll have finish with the bank script. Maybe of this kind.

Yeah... G@MeF@Ce is better to comment the scripts. lol!
The only one
Show Signature


___________________________________________________________________________

Booyah!

...._
._|_|_
. ( ')>
The only one
http://nukabubble.deviantart.com/ http://soundcloud.com/nuka_bubble https://www.youtube.com/user/NuKaBuBble?feature=mhee
EVENTALIST
EVENTALIST
#3 default Re: Wiggles Dynamic Shopping
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
Any comment is a good one, i like to see what people think about my scripts, fuels my inspiration and drive to make new ones.
EVENTALIST
Show Signature
EVENTALIST
C.O.R.N.
C.O.R.N.
#4 default Re: Wiggles Dynamic Shopping
Loading

BluE

BluE
C.O.R.N.
C.O.R.N.
C.O.R.N.
profile
wiggles, you are a ****ing genius. This is really cool. I didn't think there was anything else to be scripted.
I'm going to have to add this to the catalogue. I might have to start from scratch (though this might be easier) cos I don't know if I can find the original fla.
++++++++epic kudos++++++
C.O.R.N.
Show Signature


Want a real challenge? Try [You must be registered and logged in to see this link.]

If you read this message, please PM me. this is a test. And I'm serious, this isnt just some lousy time wasting paragraph that I wrote just to fill in my signature. It's here for a reason. PM ME.
C.O.R.N.
http://51s-seedy-masteroogway.blogspot.com
The only one
The only one
#5 default Re: Wiggles Dynamic Shopping
Loading

NuKa_BuBble

NuKa_BuBble
The only one
The only one
profile
Something to add in this script! The player can equip his/her new equipments when he/she buy something.
The only one
Show Signature


___________________________________________________________________________

Booyah!

...._
._|_|_
. ( ')>
The only one
http://nukabubble.deviantart.com/ http://soundcloud.com/nuka_bubble https://www.youtube.com/user/NuKaBuBble?feature=mhee
EVENTALIST
EVENTALIST
#6 default Re: Wiggles Dynamic Shopping
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
equipping might have to be in a plug in. Seeing that each battle system that the user could have would have unique commands for equipping things.

Nice idea, you could make the add on for XAS if you want, it would be good practice for coding.
EVENTALIST
Show Signature
EVENTALIST
The only one
The only one
#7 default Re: Wiggles Dynamic Shopping
Loading

NuKa_BuBble

NuKa_BuBble
The only one
The only one
profile
Not now, I'm still updating my bank. But, why the equip change with the battle system? Just put a link in the shop that point to the Scene_Equip.
The only one
Show Signature


___________________________________________________________________________

Booyah!

...._
._|_|_
. ( ')>
The only one
http://nukabubble.deviantart.com/ http://soundcloud.com/nuka_bubble https://www.youtube.com/user/NuKaBuBble?feature=mhee
EVENTALIST
EVENTALIST
#8 default Re: Wiggles Dynamic Shopping
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
You could actually just link to the an actor list and then link that to the @actor.equip(0, item_id).

you could even get fancy and make it show the changes in the current actors stats. I just dont have the time to add features tho.
EVENTALIST
Show Signature
EVENTALIST
C.O.R.N.
C.O.R.N.
#9 default Re: Wiggles Dynamic Shopping
Loading

BluE

BluE
C.O.R.N.
C.O.R.N.
C.O.R.N.
profile
I've got flash. I'm making a new wiggles catalog
C.O.R.N.
Show Signature


Want a real challenge? Try [You must be registered and logged in to see this link.]

If you read this message, please PM me. this is a test. And I'm serious, this isnt just some lousy time wasting paragraph that I wrote just to fill in my signature. It's here for a reason. PM ME.
C.O.R.N.
http://51s-seedy-masteroogway.blogspot.com
Administrator
Administrator
#10 default Re: Wiggles Dynamic Shopping
Loading

G@MeF@Ce

G@MeF@Ce
Administrator
Administrator
Administrator
profile
@wiggles - I think the shop to the left is the better shop ^,^

as always quality work, thank you for sharing <3

just wondering, would you be interested in making a 'scene' specially for the dynamic shop?
Administrator
Show Signature


Hey Guest, check out my demos!
[You must be registered and logged in to see this link.]
[You must be registered and logged in to see this link.]
[You must be registered and logged in to see this link.]
[You must be registered and logged in to see this link.]
[You must be registered and logged in to see this link.]
[You must be registered and logged in to see this link.]




G101's theme colors
[You must be registered and logged in to see this image.]
[You must be registered and logged in to see this link.]

[You must be registered and logged in to see this image.]


shhh.... [You must be registered and logged in to see this link.]



[You must be registered and logged in to see this link.]
Administrator
https://www.dropbox.com/sh/i47rig99qhrvn8s/4m5HvsM2fD http://g4m3f4c3.deviantart.com https://www.facebook.com//pages/Gameface101/332331300127008 https://twitter.com//mr_gameface101 https://soundcloud.com/schurr https://www.youtube.com/user/MrGameface101?feature=watch
EVENTALIST
EVENTALIST
#11 default Re: Wiggles Dynamic Shopping
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
What do you mean?
EVENTALIST
Show Signature
EVENTALIST
Administrator
Administrator
#12 default Re: Wiggles Dynamic Shopping
Loading

G@MeF@Ce

G@MeF@Ce
Administrator
Administrator
Administrator
profile
so instead of just a menu, it will show the character sprite of the merchant and the hero along with a background graphic (panorama) that goes along with the tile set. like a scene ~ let me know if you would like a mockup Cool
Administrator
Show Signature


Hey Guest, check out my demos!
[You must be registered and logged in to see this link.]
[You must be registered and logged in to see this link.]
[You must be registered and logged in to see this link.]
[You must be registered and logged in to see this link.]
[You must be registered and logged in to see this link.]
[You must be registered and logged in to see this link.]




G101's theme colors
[You must be registered and logged in to see this image.]
[You must be registered and logged in to see this link.]

[You must be registered and logged in to see this image.]


shhh.... [You must be registered and logged in to see this link.]



[You must be registered and logged in to see this link.]
Administrator
https://www.dropbox.com/sh/i47rig99qhrvn8s/4m5HvsM2fD http://g4m3f4c3.deviantart.com https://www.facebook.com//pages/Gameface101/332331300127008 https://twitter.com//mr_gameface101 https://soundcloud.com/schurr https://www.youtube.com/user/MrGameface101?feature=watch
EVENTALIST
EVENTALIST
#13 default Re: Wiggles Dynamic Shopping
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
Yea think i need a mock up, idk if i'll have the time but i can revisit this script later to add it. Been busy with the ABS and Torque 2D. :/
EVENTALIST
Show Signature
EVENTALIST

Sponsored content

profile

View previous topic View next topic Back to top Message [Page 1 of 1]

 

Chatbox system disabled
Personal messaging disabled