Final Fantasy Tactics Advance Shop System
#1
FFTA Shop Menu
Version 0.87

Introduction
Hello everbody and welcome to the Final Fantasy Tactics Advance Shop, i have recently just upgraded and messed around with it to make it look even more like the FFTA shop, there is still quiet a bit more to do but i have almost completely finished it, but to finish this completely i'm going to have to create my own skill equipment system -_-...a challenge! ^_^
Enjoy!

Bugs/Errors
Unknown Crashing Buy Item Error - FIXED
Sell Number Item Error - FIXED
Any more bugs? Please report them.

Script
Add above main.
Code:
#----------------------------------------------------------------------------
# Final Fantasy Tactics Advance Shop System By Mac      v. 0.7
#----------------------------------------------------------------------------
# Basically as it says in the title, this makes your shop system just like
# that of FFTA but due to being aliased you have the option at any point to
# switch it too and from the default system whenever you see fit.
#----------------------------------------------------------------------------
# Firstly to make this active in game you need to do a call script and call this:-
# $game_temp.call_fftshopsystem = true
#
# Then at any point you can call it again but with false to return it to the
# default shop system, or if you want this system to always stay on simply
# change the line:-
#
# @call_fftshopsystem = false
#
# Too:-
#
# @call_fftshopsystem = true
#----------------------------------------------------------------------------
#==============================================================================
# ** Game_Temp
#==============================================================================
class Game_Temp
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :call_fftshopsystem
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias_method :mac_fftshop_init, :initialize
  def initialize
    # Original Initialization
    mac_fftshop_init
    # Set Call FFT Shop False
    @call_fftshopsystem = false
  end
end
#==============================================================================
# ** Game_Party
#==============================================================================
class Game_Party
  #--------------------------------------------------------------------------
  # * Total Weapon Number
  #--------------------------------------------------------------------------
  def total_weapon_number(weapon_id)
    n = weapon_number(weapon_id)
    n += equipped_weapon_number(weapon_id)
    return n
  end
  #--------------------------------------------------------------------------
  # * Equipped Weapon Number
  #--------------------------------------------------------------------------
  def equipped_weapon_number(weapon_id)
    n = 0
    @actors.each do |actor|
      n += 1 if actor.weapon_id == weapon_id
    end
    return n
  end
  #--------------------------------------------------------------------------
  # * Total Armor Number
  #--------------------------------------------------------------------------
  def total_armor_number(armor_id)
    n = armor_number(armor_id)
    n += equipped_armor_number(armor_id)
    return n
  end
  #--------------------------------------------------------------------------
  # * Equipped Armor Number
  #--------------------------------------------------------------------------
  def equipped_armor_number(armor_id)
    n = 0
    @actors.each do |actor|
      n += 1 if actor.armor1_id == armor_id
      n += 1 if actor.armor2_id == armor_id
      n += 1 if actor.armor3_id == armor_id
      n += 1 if actor.armor4_id == armor_id
    end
    return n
  end
end
#==============================================================================
# ** Scene_Shop
#==============================================================================
class Scene_Shop
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  alias_method :mac_fftshop_main, :main
  def main
    # If Call FFT Shop
    if $game_temp.call_fftshopsystem
      # Change to FFT Shop
      $scene = FFT_ShopSystem::Scene_Shop.new
      # Turn call FFT Shop off
      $game_temp.call_fftshopsystem = false
      # End Method
      return
    end
    # Original Method
    mac_fftshop_main
  end
end
#==============================================================================
# ** FFT_ShopSystem
#==============================================================================
module FFT_ShopSystem
  #============================================================================
  # ** Window_ShopCommand
  #============================================================================
  class Window_ShopCommand < ::Window_Command
    #--------------------------------------------------------------------------
    # * Object Initialization
    #--------------------------------------------------------------------------
    def initialize
      super(180, ['Buy', 'Sell', 'Exit'])
      # Reassign Window Parameters
      self.x, self.y, self.opacity = 16, 336, 0
      # Creates Background Graphic
      @command_graphic = Sprite.new
      @command_graphic.bitmap = RPG::Cache.picture('Shop Command')
      @command_graphic.x = self.x + 1
      @command_graphic.y = self.y + 7
      @command_graphic.z = self.z - 1
      @command_graphic.visible = true
      @gold_graphic = Sprite.new
      @gold_graphic.bitmap = RPG::Cache.picture('Gold Window')
      @gold_graphic.x = self.x + 480
      @gold_graphic.y = self.y + 104
      @gold_graphic.z = self.z - 2
      @gold_graphic.visible = true
    end
    #--------------------------------------------------------------------------
    # * Frame Update
    #--------------------------------------------------------------------------
    def update
      super
      @command_graphic.visible = self.visible
      @gold_graphic.visible = self.visible
    end
    #--------------------------------------------------------------------------
    # * Dispose
    #--------------------------------------------------------------------------
    def dispose
      super
      @command_graphic.dispose
      @gold_graphic.dispose
    end
  end

  #============================================================================
  # ** Window_ShopBuy
  #============================================================================
  class Window_ShopBuy < ::Window_ShopBuy
    #--------------------------------------------------------------------------
    # * Object Initialization
    #--------------------------------------------------------------------------
    def initialize(shop_goods)
      super(shop_goods)
      # Reassign Window Parameters
      self.x, self.y, self.width, self.height = 16, 20, 600, 228
      self.opacity, self.visible, self.active = 0, false, false
      # Creates Showback Graphic
      @showback_graphic = Sprite.new
      @showback_graphic.bitmap = RPG::Cache.picture('Shop Window')
      @showback_graphic.x = self.x + 1
      @showback_graphic.y = self.y + 1
      @showback_graphic.z = self.z - 1
      @showback_graphic.visible = self.visible
    end
    #--------------------------------------------------------------------------
    # * Draw Item
    #--------------------------------------------------------------------------
    def draw_item(index)
      # Gets item Number
      item = @data[index]
      # Gets Number Owned & Equipped
      case item
      when RPG::Item
        number = $game_party.item_number(item.id)
        equipped_number = 0
      when RPG::Weapon
        number = $game_party.weapon_number(item.id)
        equipped_number = $game_party.equipped_weapon_number(item.id)
      when RPG::Armor
        number = $game_party.armor_number(item.id)
        equipped_number = $game_party.equipped_armor_number(item.id)
      end
      # Adjust Color By Price
      if item.price <= $game_party.gold and number < 99
        self.contents.font.color = normal_color
      else
        self.contents.font.color = disabled_color
      end
      # Clears Area
      rect = Rect.new(0, index * 32, contents.width, 32)
      self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
      # Draws Icon
      bitmap = RPG::Cache.icon(item.icon_name)
      opacity = self.contents.font.color == normal_color ? 255 : 128
      self.contents.blt(4, index * 32 + 4, bitmap, Rect.new(0, 0, 24, 24),
        opacity)
      # Draws Item Name, Total, Equipped and Price
      self.contents.draw_text(32, index * 32, 212, 32, item.name, 0)
      self.contents.draw_text(374, index * 32, 88, 32,
        (number + equipped_number).to_s, 2)
      self.contents.draw_text(294, index * 32, 88, 32, equipped_number.to_s, 2)
      self.contents.draw_text(464, index * 32, 88, 32, item.price.to_s, 2)
    end
    #--------------------------------------------------------------------------
    # * Update
    #--------------------------------------------------------------------------
    def update
      super
      @showback_graphic.visible = self.visible
    end
    #--------------------------------------------------------------------------
    # * Dispose
    #--------------------------------------------------------------------------
    def dispose
      super
      @showback_graphic.dispose
    end
  end

  #============================================================================
  # ** Window_ShopSell
  #============================================================================
  class Window_ShopSell < ::Window_ShopSell
    #--------------------------------------------------------------------------
    # * Object Initialization
    #--------------------------------------------------------------------------
    def initialize
      super
      # Reassign Window Parameters
      self.x, self.y, self.width, self.height = 16, 20, 600, 228
      self.opacity, self.visible, self.active = 0, false, false
      # Creates Showback Graphic
      @showback_graphic = Sprite.new
      @showback_graphic.bitmap = RPG::Cache.picture('Shop Window')
      @showback_graphic.x = self.x + 1
      @showback_graphic.y = self.y + 1
      @showback_graphic.z = self.z - 1
      @showback_graphic.visible = self.visible
      # Adjust Column Max
      @column_max = 1
    end
    #--------------------------------------------------------------------------
    # * Draw Item
    #--------------------------------------------------------------------------
    def draw_item(index)
      # Gets Item Data
      item = @data[index]
      # Gets Number & Equipped Number
      case item
      when RPG::Item
        number = $game_party.item_number(item.id)
        equipped_number = 0
      when RPG::Weapon
        number = $game_party.weapon_number(item.id)
        equipped_number = $game_party.equipped_weapon_number(item.id)
      when RPG::Armor
        number = $game_party.armor_number(item.id)
        equipped_number = $game_party.equipped_armor_number(item.id)
      end
      # Adjust Font Color By Price
      if item.price > 0
        self.contents.font.color = normal_color
      else
        self.contents.font.color = disabled_color
      end
      # Clears Area
      rect = Rect.new(0, index * 32, contents.width, 32)
      self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
      # Draws Icon
      bitmap = RPG::Cache.icon(item.icon_name)
      opacity = self.contents.font.color == normal_color ? 255 : 128
      self.contents.blt(4, index * 32 + 4, bitmap, Rect.new(0, 0, 24, 24),
        opacity)
      # Draws Item Name, Total Owned, Equipped and Price
      self.contents.draw_text(32, index * 32, 212, 32, item.name, 0)
      self.contents.draw_text(374, index * 32, 88, 32,
        (number + equipped_number).to_s, 2)
      self.contents.draw_text(294, index * 32, 88, 32, equipped_number.to_s, 2)
      self.contents.draw_text(464, index * 32, 88, 32,
        (item.price / 2).to_s, 2)
    end
    #--------------------------------------------------------------------------
    # * Update
    #--------------------------------------------------------------------------
    def update
      super
      @showback_graphic.visible = self.visible
    end
    #--------------------------------------------------------------------------
    # * Dispose
    #--------------------------------------------------------------------------
    def dispose
      super
      @showback_graphic.dispose
    end
  end

  #============================================================================
  # ** Window_ShopNumber
  #============================================================================
  class Window_ShopNumber < ::Window_ShopNumber
    #--------------------------------------------------------------------------
    # * Object Initialization
    #--------------------------------------------------------------------------
    def initialize
      super
      # Reassign Window Parameters
      self.x, self.y, self.width, self.height, self.opacity = 450, 242, 65, 64, 0
      # Recreates Window Contents
      @number_graphic = Sprite.new
      @number_graphic.bitmap = RPG::Cache.picture('Shop Number')
      @number_graphic.x = self.x + 3
      @number_graphic.y = self.y + 14
      @number_graphic.z = self.z - 1
      @number_graphic.visible = false
      self.contents = Bitmap.new(width - 32, height - 32)
      self.visible, self.active = false, false
    end
    #--------------------------------------------------------------------------
    # * Update
    #--------------------------------------------------------------------------
      def update
      super
      @number_graphic.visible = self.visible
    end
    #--------------------------------------------------------------------------
    # * Dispose
    #--------------------------------------------------------------------------
    def dispose
      super
      @number_graphic.dispose
    end
    #--------------------------------------------------------------------------
    # * Refresh
    #--------------------------------------------------------------------------
    def refresh
      self.contents.clear
      self.contents.font.color = Color.new(0, 0, 0, 255)
      self.contents.draw_text(0, 0, 25, 32, "?")
      self.contents.draw_text(-25, 0, 56, 32, "#{@number}", 2)
      self.cursor_rect.set(256, 0, 64, 32)
      end
  end

  #==============================================================================
  # ** FFT_ShopSystem
  #==============================================================================

  class Scene_Shop
    #--------------------------------------------------------------------------
    # * Main Processing
    #--------------------------------------------------------------------------
    def main
      # Memorize BGM & Play Shop Music
      $game_temp.map_bgm = $game_system.playing_bgm
#      Audio.bgm_play("Audio/BGM/31 - Mysterious Shop", 100, 100)
      # Create Command Window
      @command_window = Window_ShopCommand.new
      # Create Spriteset
      @spriteset = Spriteset_Map.new
      # Create Gold Window
      @gold_window = Window_Gold.new
      @gold_window.opacity = 0
      @gold_window.x = 650 - @gold_window.width - 16
      @gold_window.y = 500 - @gold_window.height - 16
      # Create Buy Window
      @buy_window = FFT_ShopSystem::Window_ShopBuy.new($game_temp.shop_goods)
      @buy_window.help_window = @help_window
      # Create Sell Window
      @sell_window = FFT_ShopSystem::Window_ShopSell.new
      @sell_window.help_window = @help_window
      # Create Number Window
      @number_window = FFT_ShopSystem::Window_ShopNumber.new
      # Transition run
      Graphics.transition
      # Main loop
      loop do
        # Update game screen
        Graphics.update
        # Update input information
        Input.update
        # Frame update
        update
        # Abort loop if screen is changed
        if $scene != self
          break
        end
      end
      # Prepare for transition
      Graphics.freeze
      # Dispose Scene Objects
      @spriteset.dispose
      @command_window.dispose
      @gold_window.dispose
      @buy_window.dispose
      @sell_window.dispose
      @number_window.dispose
    end
    #--------------------------------------------------------------------------
    # * Frame Update
    #--------------------------------------------------------------------------
    def update
      # Update windows
      @command_window.update
      @gold_window.update
      @buy_window.update
      @sell_window.update
      @number_window.update
      # If command window is active: call update_command
      if @command_window.active
        update_command
        return
      # If buy window is active: call update_buy
      elsif @buy_window.active
        update_buy
        return
      # If sell window is active: call update_sell
      elsif @sell_window.active
        update_sell
        return
      # If quantity input window is active: call update_number
      elsif @number_window.active
        update_number
        return
      end
    end
    #--------------------------------------------------------------------------
    # * Frame Update (when command window is active)
    #--------------------------------------------------------------------------
    def update_command
      # If B button was pressed
      if Input.trigger?(Input::B)
        # Play cancel SE
        $game_system.se_play($data_system.cancel_se)
        # Switch to map screen
        $scene = Scene_Map.new
        return
      end
      # If C button was pressed
      if Input.trigger?(Input::C)
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Branch by command window cursor position
        case @command_window.index
        when 0  # buy
          # Change windows to buy mode
          @command_window.active = false
          @buy_window.active = true
          @buy_window.visible = true
          @buy_window.refresh
        when 1  # sell
          # Change windows to sell mode
          @command_window.active = false
          @sell_window.active = true
          @sell_window.visible = true
          @sell_window.refresh
        when 2  # quit
          # Switch to map screen
          $scene = Scene_Map.new
        end
        return
      end
    end
    #--------------------------------------------------------------------------
    # * Frame Update (when buy window is active)
    #--------------------------------------------------------------------------
    def update_buy
      # If B button was pressed
      if Input.trigger?(Input::B)
        # Play cancel SE
        $game_system.se_play($data_system.cancel_se)
        # Change windows to initial mode
        @command_window.active = true
        @buy_window.active = false
        @buy_window.visible = false
        return
      end
      # If C button was pressed
      if Input.trigger?(Input::C)
        # Get item
        @item = @buy_window.item
        # If item is invalid, or price is higher than money possessed
        if @item == nil or @item.price > $game_party.gold
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # Get items in possession count
        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 99 items are already in possession
        if number == 99
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Calculate maximum amount possible to buy
        max = @item.price == 0 ? 99 : $game_party.gold / @item.price
        max = [max, 99 - number].min
        # Turn Buy Window Off
        @buy_window.active = false
        # Change windows to quantity input mode
        @number_window.set(@item, max, @item.price)
        @number_window.active = true
        @number_window.visible = true
      end
    end
    #--------------------------------------------------------------------------
    # * Frame Update (when sell window is active)
    #--------------------------------------------------------------------------
    def update_sell
      # If B button was pressed
      if Input.trigger?(Input::B)
        # Play cancel SE
        $game_system.se_play($data_system.cancel_se)
        # Change windows to initial mode
        @command_window.active = true
        @sell_window.active = false
        @sell_window.visible = false
        return
      end
      # If C button was pressed
      if Input.trigger?(Input::C)
        # Get item
        @item = @sell_window.item
        # If item is invalid, or item price is 0 (unable to sell)
        if @item == nil or @item.price == 0
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Get items in possession count
        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
        # Maximum quanitity to sell = number of items in possession
        max = number
        # Turn Sell Window Off
        @sell_window.active = false
        # Change windows to quantity input mode
        @number_window.set(@item, max, @item.price / 2)
        @number_window.active = true
        @number_window.visible = true
      end
    end
    #--------------------------------------------------------------------------
    # * Frame Update (when quantity input window is active)
    #--------------------------------------------------------------------------
    def update_number
      # If B button was pressed
      if Input.trigger?(Input::B)
        # Play cancel SE
        $game_system.se_play($data_system.cancel_se)
        # Set quantity input window to inactive / invisible
        case @command_window.index
        when 0
        @buy_window.active = true
        @number_window.active = false
        @number_window.visible = false
        when 1
        @sell_window.active = true
        @number_window.active = false
        @number_window.visible = false
        return
      end
      end
      # If C button was pressed
      if Input.trigger?(Input::C)
        # Play shop SE
        $game_system.se_play($data_system.shop_se)
        # Set quantity input window to inactive / invisible
        @number_window.active = false
        @number_window.visible = false
        # Branch by command window cursor position
        case @command_window.index
        when 0  # buy
          # Buy process
          $game_party.lose_gold(@number_window.number * @item.price)
          case @item
          when RPG::Item
            $game_party.gain_item(@item.id, @number_window.number)
          when RPG::Weapon
            $game_party.gain_weapon(@item.id, @number_window.number)
          when RPG::Armor
            $game_party.gain_armor(@item.id, @number_window.number)
          end
          # Refresh each window
          @gold_window.refresh
          @buy_window.refresh
          # Change windows to buy mode
          @buy_window.active = true
          @buy_window.visible = true
        when 1  # sell
          # Sell process
          $game_party.gain_gold(@number_window.number * (@item.price / 2))
          case @item
          when RPG::Item
            $game_party.lose_item(@item.id, @number_window.number)
          when RPG::Weapon
            $game_party.lose_weapon(@item.id, @number_window.number)
          when RPG::Armor
            $game_party.lose_armor(@item.id, @number_window.number)
          end
          # Refresh each window
          @gold_window.refresh
          @sell_window.refresh
          # Change windows to sell mode
          @sell_window.active = true
          @sell_window.visible = true
        end
        return
      end
    end
  end
end
To call on it, call this script and then after it call on the shop as you usually would do.
Code:
$game_temp.call_fftshopsystem = true
Screenshots
[Image: fftaalm1.png]
Required Images
Dont import these just place them in your pictures folder, remember to rename them correctly as i have labelled above the image, you have a choice of three colours
Shop Number
[Image: shopnumberio3.png]
Gold Window
[Image: goldwindowiq9.png]
Shop Command
[Image: shopcommandzr0.png]
[Image: shopcommand2tl6.png]
[Image: shopcommand3bb3.png]
Shop Window
[Image: shopwindowkb0.png]
[Image: shopwindow2vh7.png]
[Image: shopwindow3wd8.png]

Authors Notes
Credits to Bluescope for helping me with a String Error
Credits to SephirothSpawn for helping me tidy the code up
Reply }
#2
there are some images missing ? can someone help me set this up please

Thread closed. Report the thread next time. - PK8
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   The Wanderers: The Customizable Encounters System DerVVulfman 0 370 08-24-2024, 07:12 PM
Last Post: DerVVulfman
   Super Simple Vehicle System - Enhanced DerVVulfman 65 96,107 06-02-2023, 06:16 PM
Last Post: Sujabes467
   Zenith Tactical Battle System Plus (ZTBS+) DerVVulfman 0 2,980 05-10-2022, 10:42 PM
Last Post: DerVVulfman
   Shop : Change Prices Kain Nobel 0 1,526 04-04-2022, 11:24 AM
Last Post: Kain Nobel
Star  Shop : Command Help Kain Nobel 0 1,613 04-04-2022, 10:46 AM
Last Post: Kain Nobel
   Commercial System Package DerVVulfman 11 14,703 01-04-2020, 12:37 AM
Last Post: Pelip
   KSkill Shop XP kyonides 7 16,119 12-23-2019, 05:57 AM
Last Post: kyonides
   ACBS - Atoa Custom Battle System 3.2 Victor Sant 150 259,691 03-02-2019, 04:47 AM
Last Post: dragonprincess44
   Skyla's Unique Item Shop DerVVulfman 2 6,039 01-19-2018, 04:18 AM
Last Post: DerVVulfman
   DerVV's Simple Popup System DerVVulfman 4 12,430 10-08-2017, 04:53 PM
Last Post: DerVVulfman



Users browsing this thread: 1 Guest(s)