Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Skill Shop for RMXP, Request by Kira-kun.^^
Nechi
post Feb 26 2008, 05:48 PM
Post #1


Certamen Promus
Group Icon

Group: Revolutionary
Posts: 117
Type: None
RM Skill: Beginner




From this reply :
http://www.rpgrevolution.com/forums/index....st&p=120662

Add this script before main script :
Ver 2.0
[codebox]
CODE
#==============================================================================
# Skill Shop for RMXP
#==============================================================================
# By Nechigawara Sanzenin
# WARNING!! : This script can use on RPG Maker XP Only!! (VX Not Support)
#==============================================================================
# Buy Skill Option For RMXP
#==============================================================================
=begin

How to Use:

You will add "$skill_shop =[Id of Skill]"  
To Call Script to set id of skill for sell.
You will add "$scene = Scene_Skill_Shop.new"  
To Call Skill Shop Windows.

Example:
$skill_shop = [1,2,3,6,7]
$scene = Scene_Skill_Shop.new

You can set text to use in Skill Shop under "# Learn Text".
You can set Skill Price under "# Price Data".
You can set Skill that the fighter each person can study under "# Hero Data".

You will setting look like this in Hero Data
[ID of skill, Level requirement for learn]

=end
#==============================================================================
#module SKILL_SHOP
#==============================================================================
module SKILL_SHOP
  # Learn Text
  How_Learn = "What 's hero can learn?"
  Can_Learn = "Can Learn"
  Can_Learn_Lv = "On Lv"
  Cant_Learn = "Can't Learn"
  Learnt = "Learnt"
  Teach = "Teach"
  Cancel = "Cancel"
  # Price Data
  PRICE = {
  # for No Set Price
  0 => 100,
  # Add Price Here
  1 => 150,
  2 => 550,
  3 => 450,
  # End
  }
  # Hero Data
  SKILL_BUY = {
  # Add what skill can hero buy Here
  # [ID of skill,Level]
  
  1 => [
  
  [1,4],[2,3],[3,1],[7,1],
  
  ],
  
  2 => [
  
  [1,4],[2,3],[3,1],[7,5],
  
  ],
  
  # End
  }
  # Add Price
  def self.skill_price(id)
    if PRICE.include?(id)
      return PRICE[id]
    else
      return PRICE[0]
    end
  end
  # Add Hero id
  def self.skill_buy(id)
    if SKILL_BUY.include?(id)
      return SKILL_BUY[id]
    else
      return []
    end
  end
end
#==============================================================================
#class Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
  def learn?(skill)
    learn = skill_learn?(skill.id)
    if learn
      return false
    else
      return true
    end
  end
end
#==============================================================================
#class Window_Skill_ShopCommand
#==============================================================================
class Window_Skill_ShopCommand < Window_Selectable
  #--------------------------------------------------------------------------
  def initialize
    super(0, 64, 480, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $fontface
    self.contents.font.size = $fontsize
    @item_max = 2
    @column_max = 2
    s1 = SKILL_SHOP::Teach
    s2 = SKILL_SHOP::Cancel
    @commands = [s1, s2]
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  def draw_item(index)
    x = 4 + index * 240
    self.contents.draw_text(x, 0, 128, 32, @commands[index])
  end
end
#==============================================================================
#class Window_Skill_ShopBuy
#==============================================================================
class Window_Skill_ShopBuy < Window_Selectable
  #--------------------------------------------------------------------------
  def initialize(shop_goods)
    super(0, 128, 368, 352)
    @skill_shop_goods = $skill_shop
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  def skill
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in 0...@skill_shop_goods.size
      skill = $data_skills[@skill_shop_goods[i]]
      if skill != nil
        @data.push(skill)
      end
    end
    # If the number of items is not 0, it draws up bit map, drawing all item
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      self.contents.font.name = $fontface
      self.contents.font.size = $fontsize
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  def draw_item(index)
    skill = @data[index]
    # Acquiring the frequency of possession of the item
    price = SKILL_SHOP.skill_price(skill.id)
    enabled = (price <= $game_party.gold)
    # If price is not below the money in hand, at the same time the frequency of possession 99, usually in letter color
    # So if is not, it sets to invalid letter color
    if enabled
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4
    y = index * 32
    rect = Rect.new(x, y, self.width - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(skill.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.draw_text(x + 28, y, 212, 32, skill.name, 0)
    self.contents.draw_text(x + 240, y, 88, 32, price.to_s, 2)
  end
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(skill == nil ? "" : skill.description)
  end
end
#==============================================================================
#class Window_Skill_ShopStatus
#==============================================================================
class Window_Skill_ShopStatus < Window_Selectable
  #--------------------------------------------------------------------------
  def initialize
    super(368, 128, 272, 352)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $fontface
    self.contents.font.size = $fontsize
    @item = nil
    refresh
    self.active = false
    self.index = -1
  end
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    @item_max = $game_party.actors.size
    if @item == nil
      return
    end
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, self.width - 32, 32, SKILL_SHOP::How_Learn)
    self.contents.font.color = normal_color
    # Equipment supplementary information
    for i in 0...$game_party.actors.size
      # Acquiring the actor
      can = false
      lv = false
      ac_lv = 0
      actor = $game_party.actors[i]
      can_learn = SKILL_SHOP.skill_buy(actor.id)
      id = @item.id
      for e in 0...can_learn.size
        if can_learn[e][0] == id
          can = true
          if can_learn[e][1] <= actor.level
            lv = true
          else
            lv = false
            ac_lv = can_learn[e][1]
          end
          break
        else
          can = false
        end
      end
      enabled = (can and lv and actor.learn?(@item))
      # If equipment possibility if usually in letter color, the impossibility, it sets to invalid letter color
      if enabled
        self.contents.font.color = normal_color
      else
        self.contents.font.color = disabled_color
      end
      #Draw Cha Pic
      bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
      cw = bitmap.rect.width / 4
      ch = bitmap.rect.height / 4
      src_rect = Rect.new(0, 0, cw, ch)
      cx = contents.text_size(actor.name).width
      self.contents.blt(cx, 64 + 64 * i, bitmap, src_rect)
      # Drawing the name of the actor
      self.contents.draw_text(4, 64 + 64 * i, 120, 32, actor.name)
      # Check Skill
      if can == false
        text = SKILL_SHOP::Cant_Learn
      elsif can == true and lv == false
        ac = ac_lv.to_s
        text = SKILL_SHOP::Can_Learn_Lv + " " + ac + "+"
      elsif actor.learn?(@item) == false
        text = SKILL_SHOP::Learnt
      else
        text = SKILL_SHOP::Can_Learn
      end
      # Drawing the item
      self.contents.draw_text(124, 64 + 64 * i, 112, 32, text, 2)
    end
  end
  #--------------------------------------------------------------------------
  def item=(item)
    if @item != item
      @item = item
      refresh
    end
  end
  #--------------------------------------------------------------------------
  def update_cursor_rect
    # Cursor position as for -1 all selection, -2 below independence selection (user himself)
    if @index < 0
      self.cursor_rect.empty
    else
      self.cursor_rect.set(0, 62 + @index * 64, self.width - 32, 50)
    end
  end
end
#==============================================================================
#class Scene_Skill_Shop
#==============================================================================
class Scene_Skill_Shop
  #--------------------------------------------------------------------------
  def main
    # Drawing up the help window
    @help_window = Window_Help.new
    # Drawing up the command window
    @command_window = Window_Skill_ShopCommand.new
    # Drawing up the Goldwyn dough
    @gold_window = Window_Gold.new
    @gold_window.x = 480
    @gold_window.y = 64
    # Drawing up the dummy window
    @dummy_window = Window_Base.new(0, 128, 640, 352)
    # Drawing up the purchase window
    @buy_window = Window_Skill_ShopBuy.new($game_temp.shop_goods)
    @buy_window.active = false
    @buy_window.visible = false
    @buy_window.help_window = @help_window
    # Drawing up the status window
    @status_window = Window_Skill_ShopStatus.new
    @status_window.visible = false
    @status_window.active
    # Transition execution
    Graphics.transition
    # Main loop
    loop do
      # Renewing the game picture
      Graphics.update
      # Updating the information of input
      Input.update
      # Frame renewal
      update
      # When the picture changes, discontinuing the loop
      if $scene != self
        break
      end
    end
    # Transition preparation
    Graphics.freeze
    # Releasing the window
    @help_window.dispose
    @command_window.dispose
    @gold_window.dispose
    @dummy_window.dispose
    @buy_window.dispose
    @status_window.dispose
  end
  #--------------------------------------------------------------------------
  def update
    # Renewing the window
    @help_window.update
    @command_window.update
    @gold_window.update
    @dummy_window.update
    @buy_window.update
    @status_window.update
    # When the command window is active,: Update_command is called
    if @command_window.active
      update_command
      return
    end
    # When the purchase window is active,: Update_buy is called
    if @buy_window.active
      update_buy
      return
    end
    # When the target window is active,: Update_target is called
    if @status_window.active
      update_target
      return
    end
  end
  #--------------------------------------------------------------------------
  def update_command
    # The B when button is pushed
    if Input.trigger?(Input::B)
      # Performing cancellation SE
      $game_system.se_play($data_system.cancel_se)
      # Change to map picture
      $scene = Scene_Map.new
      return
    end
    # When C button is pushed
    if Input.trigger?(Input::C)
      # Eliminating the help text
      @help_window.set_text("")
      # It diverges at cursor position of the command window
      case @command_window.index
      when 0  # It purchases
        # Performing decision SE
        $game_system.se_play($data_system.decision_se)
        # State of window to purchase mode
        @command_window.active = false
        @dummy_window.visible = false
        @buy_window.active = true
        @buy_window.visible = true
        @buy_window.refresh
        @status_window.visible = true
      when 1  # It stops
        # Performing decision SE
        $game_system.se_play($data_system.decision_se)
        # Change to map picture
        $scene = Scene_Map.new
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  def update_buy
    # Setting the item of the status window
    @status_window.item = @buy_window.skill
    # The B when button is pushed
    if Input.trigger?(Input::B)
      # Performing cancellation SE
      $game_system.se_play($data_system.cancel_se)
      # State of window to early mode
      @command_window.active = true
      @dummy_window.visible = true
      @buy_window.active = false
      @buy_window.visible = false
      @status_window.visible = false
      @status_window.item = nil
      # Eliminating the help text
      @help_window.set_text("")
      return
    end
    # When C button is pushed
    if Input.trigger?(Input::C)
      # Acquiring the item
      @item = @buy_window.skill
      @price = SKILL_SHOP.skill_price(@item.id)
      enabled = (@price <= $game_party.gold)
      # When the item is invalid, or when price it is on from the money in hand
      unless  enabled
        # Performing buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Performing decision SE
      $game_system.se_play($data_system.decision_se)
      @buy_window.active = false
      @status_window.active = true
      @status_window.index = 0
    end
  end
  #--------------------------------------------------------------------------
  def update_target
    # The B when button is pushed
    if Input.trigger?(Input::B)
      # Performing cancellation SE
      $game_system.se_play($data_system.cancel_se)
      # Eliminating the target window
      @buy_window.active = true
      @status_window.index =- 1
      @status_window.active = false
      return
    end
    # When C button is pushed
    if Input.trigger?(Input::C)
      @actor = $game_party.actors[@status_window.index]
      can = false
      lv = false
      can_learn = SKILL_SHOP.skill_buy(@actor.id)
      id = @item.id
      for i in 0...can_learn.size
        if can_learn[i][0] == id
          can = true
          if can_learn[i][1] <= @actor.level
            lv = true
          else
            lv = false
          end
          break
        else
          can = false
        end
      end
      enabled = (can and lv and @actor.learn?(@item))
      # When with SP and so on is cut off and it becomes not be able to use
      unless enabled
        # Performing buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Performing shop SE
      $game_system.se_play($data_system.shop_se)
      @actor.learn_skill(@item.id)
      $game_party.lose_gold(@price)
      @buy_window.refresh
      @gold_window.refresh
      @status_window.refresh
      @buy_window.active = true
      @status_window.index =- 1
      @status_window.active = false
     end
  end
end


[code]
#==============================================================================
# Skill Shop for RMXP
#==============================================================================
# By Nechigawara Sanzenin
# WARNING!! : This script can use on RPG Maker XP Only!! (VX Not Support)
#==============================================================================
# Buy Skill Option For RMXP
#==============================================================================
=begin

How to Use:

You will add "$skill_shop =[Id of Skill]"  
To Call Script to set id of skill for sell.
You will add "$scene = Scene_Skill_Shop.new"  
To Call Skill Shop Windows.

Example:
$skill_shop = [1,2,3,6,7]
$scene = Scene_Skill_Shop.new

You can set text to use in Skill Shop under "# Learn Text".
You can set Skill Price under "# Price Data".
You can set Skill that the fighter each person can study under "# Hero Data".

You will setting look like this in Hero Data
[ID of skill, Level requirement for learn]

=end
#==============================================================================
#module SKILL_SHOP
#==============================================================================
module SKILL_SHOP
  # Learn Text
  How_Learn = "What 's hero can learn?"
  Can_Learn = "Can Learn"
  Can_Learn_Lv = "On Lv"
  Cant_Learn = "Can't Learn"
  Learnt = "Learnt"
  Teach = "Teach"
  Cancel = "Cancel"
  # Price Data
  PRICE = {
  # for No Set Price
  0 => 100,
  # Add Price Here
  1 => 150,
  2 => 550,
  3 => 450,
  # End
  }
  # Hero Data
  SKILL_BUY = {
  # Add what skill can hero buy Here
  # [ID of skill,Level]
  
  1 => [
  
  [1,4],[2,3],[3,1],[7,1],
  
  ],
  
  2 => [
  
  [1,4],[2,3],[3,1],[7,5],
  
  ],
  
  # End
  }
  # Add Price
  def self.skill_price(id)
    if PRICE.include?(id)
      return PRICE[id]
    else
      return PRICE[0]
    end
  end
  # Add Hero id
  def self.skill_buy(id)
    if SKILL_BUY.include?(id)
      return SKILL_BUY[id]
    else
      return []
    end
  end
end
#==============================================================================
#class Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
  def learn?(skill)
    learn = skill_learn?(skill.id)
    if learn
      return false
    else
      return true
    end
  end
end
#==============================================================================
#class Window_Skill_ShopCommand
#==============================================================================
class Window_Skill_ShopCommand < Window_Selectable
  #--------------------------------------------------------------------------
  def initialize
    super(0, 64, 480, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $fontface
    self.contents.font.size = $fontsize
    @item_max = 2
    @column_max = 2
    s1 = SKILL_SHOP::Teach
    s2 = SKILL_SHOP::Cancel
    @commands = [s1, s2]
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  def draw_item(index)
    x = 4 + index * 240
    self.contents.draw_text(x, 0, 128, 32, @commands[index])
  end
end
#==============================================================================
#class Window_Skill_ShopBuy
#==============================================================================
class Window_Skill_ShopBuy < Window_Selectable
  #--------------------------------------------------------------------------
  def initialize(shop_goods)
    super(0, 128, 368, 352)
    @skill_shop_goods = $skill_shop
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  def skill
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in 0...@skill_shop_goods.size
      skill = $data_skills[@skill_shop_goods[i]]
      if skill != nil
        @data.push(skill)
      end
    end
    # If the number of items is not 0, it draws up bit map, drawing all item
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      self.contents.font.name = $fontface
      self.contents.font.size = $fontsize
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  def draw_item(index)
    skill = @data[index]
    # Acquiring the frequency of possession of the item
    price = SKILL_SHOP.skill_price(skill.id)
    enabled = (price <= $game_party.gold)
    # If price is not below the money in hand, at the same time the frequency of possession 99, usually in letter color
    # So if is not, it sets to invalid letter color
    if enabled
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4
    y = index * 32
    rect = Rect.new(x, y, self.width - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(skill.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.draw_text(x + 28, y, 212, 32, skill.name, 0)
    self.contents.draw_text(x + 240, y, 88, 32, price.to_s, 2)
  end
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(skill == nil ? "" : skill.description)
  end
end
#==============================================================================
#class Window_Skill_ShopStatus
#==============================================================================
class Window_Skill_ShopStatus < Window_Selectable
  #--------------------------------------------------------------------------
  def initialize
    super(368, 128, 272, 352)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $fontface
    self.contents.font.size = $fontsize
    @item = nil
    refresh
    self.active = false
    self.index = -1
  end
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    @item_max = $game_party.actors.size
    if @item == nil
      return
    end
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, self.width - 32, 32, SKILL_SHOP::How_Learn)
    self.contents.font.color = normal_color
    # Equipment supplementary information
    for i in 0...$game_party.actors.size
      # Acquiring the actor
      can = false
      lv = false
      ac_lv = 0
      actor = $game_party.actors[i]
      can_learn = SKILL_SHOP.skill_buy(actor.id)
      id = @item.id
      for e in 0...can_learn.size
        if can_learn[e][0] == id
          can = true
          if can_learn[e][1] <= actor.level
            lv = true
          else
            lv = false
            ac_lv = can_learn[e][1]
          end
          break
        else
          can = false
        end
      end
      enabled = (can and lv and actor.learn?(@item))
      # If equipment possibility if usually in letter color, the impossibility, it sets to invalid letter color
      if enabled
        self.contents.font.color = normal_color
      else
        self.contents.font.color = disabled_color
      end
      #Draw Cha Pic
      bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
      cw = bitmap.rect.width / 4
      ch = bitmap.rect.height / 4
      src_rect = Rect.new(0, 0, cw, ch)
      cx = contents.text_size(actor.name).width
      self.contents.blt(cx, 64 + 64 * i, bitmap, src_rect)
      # Drawing the name of the actor
      self.contents.draw_text(4, 64 + 64 * i, 120, 32, actor.name)
      # Check Skill
      if can == false
        text = SKILL_SHOP::Cant_Learn
      elsif can == true and lv == false
        ac = ac_lv.to_s
        text = SKILL_SHOP::Can_Learn_Lv + " " + ac + "+"
      elsif actor.learn?(@item) == false
        text = SKILL_SHOP::Learnt
      else
        text = SKILL_SHOP::Can_Learn
      end
      # Drawing the item
      self.contents.draw_text(124, 64 + 64 * i, 112, 32, text, 2)
    end
  end
  #--------------------------------------------------------------------------
  def item=(item)
    if @item != item
      @item = item
      refresh
    end
  end
  #--------------------------------------------------------------------------
  def update_cursor_rect
    # Cursor position as for -1 all selection, -2 below independence selection (user himself)
    if @index < 0
      self.cursor_rect.empty
    else
      self.cursor_rect.set(0, 62 + @index * 64, self.width - 32, 50)
    end
  end
end
#==============================================================================
#class Scene_Skill_Shop
#==============================================================================
class Scene_Skill_Shop
  #--------------------------------------------------------------------------
  def main
    # Drawing up the help window
    @help_window = Window_Help.new
    # Drawing up the command window
    @command_window = Window_Skill_ShopCommand.new
    # Drawing up the Goldwyn dough
    @gold_window = Window_Gold.new
    @gold_window.x = 480
    @gold_window.y = 64
    # Drawing up the dummy window
    @dummy_window = Window_Base.new(0, 128, 640, 352)
    # Drawing up the purchase window
    @buy_window = Window_Skill_ShopBuy.new($game_temp.shop_goods)
    @buy_window.active = false
    @buy_window.visible = false
    @buy_window.help_window = @help_window
    # Drawing up the status window
    @status_window = Window_Skill_ShopStatus.new
    @status_window.visible = false
    @status_window.active
    # Transition execution
    Graphics.transition
    # Main loop
    loop do
      # Renewing the game picture
      Graphics.update
      # Updating the information of input
      Input.update
      # Frame renewal
      update
      # When the picture changes, discontinuing the loop
      if $scene != self
        break
      end
    end
    # Transition preparation
    Graphics.freeze
    # Releasing the window
    @help_window.dispose
    @command_window.dispose
    @gold_window.dispose
    @dummy_window.dispose
    @buy_window.dispose
    @status_window.dispose
  end
  #--------------------------------------------------------------------------
  def update
    # Renewing the window
    @help_window.update
    @command_window.update
    @gold_window.update
    @dummy_window.update
    @buy_window.update
    @status_window.update
    # When the command window is active,: Update_command is called
    if @command_window.active
      update_command
      return
    end
    # When the purchase window is active,: Update_buy is called
    if @buy_window.active
      update_buy
      return
    end
    # When the target window is active,: Update_target is called
    if @status_window.active
      update_target
      return
    end
  end
  #--------------------------------------------------------------------------
  def update_command
    # The B when button is pushed
    if Input.trigger?(Input::B)
      # Performing cancellation SE
      $game_system.se_play($data_system.cancel_se)
      # Change to map picture
      $scene = Scene_Map.new
      return
    end
    # When C button is pushed
    if Input.trigger?(Input::C)
      # Eliminating the help text
      @help_window.set_text("")
      # It diverges at cursor position of the command window
      case @command_window.index
      when 0  # It purchases
        # Performing decision SE
        $game_system.se_play($data_system.decision_se)
        # State of window to purchase mode
        @command_window.active = false
        @dummy_window.visible = false
        @buy_window.active = true
        @buy_window.visible = true
        @buy_window.refresh
        @status_window.visible = true
      when 1  # It stops
        # Performing decision SE
        $game_system.se_play($data_system.decision_se)
        # Change to map picture
        $scene = Scene_Map.new
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  def update_buy
    # Setting the item of the status window
    @status_window.item = @buy_window.skill
    # The B when button is pushed
    if Input.trigger?(Input::B)
      # Performing cancellation SE
      $game_system.se_play($data_system.cancel_se)
      # State of window to early mode
      @command_window.active = true
      @dummy_window.visible = true
      @buy_window.active = false
      @buy_window.visible = false
      @status_window.visible = false
      @status_window.item = nil
      # Eliminating the help text
      @help_window.set_text("")
      return
    end
    # When C button is pushed
    if Input.trigger?(Input::C)
      # Acquiring the item
      @item = @buy_window.skill
      @price = SKILL_SHOP.skill_price(@item.id)
      enabled = (@price <= $game_party.gold)
      # When the item is invalid, or when price it is on from the money in hand
      unless  enabled
        # Performing buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Performing decision SE
      $game_system.se_play($data_system.decision_se)
      @buy_window.active = false
      @status_window.active = true
      @status_window.index = 0
    end
  end
  #--------------------------------------------------------------------------
  def update_target
    # The B when button is pushed
    if Input.trigger?(Input::B)
      # Performing cancellation SE
      $game_system.se_play($data_system.cancel_se)
      # Eliminating the target window
      @buy_window.active = true
      @status_window.index =- 1
      @status_window.active = false
      return
    end
    # When C button is pushed
    if Input.trigger?(Input::C)
      @actor = $game_party.actors[@status_window.index]
      can = false
      lv = false
      can_learn = SKILL_SHOP.skill_buy(@actor.id)
      id = @item.id
      for i in 0...can_learn.size
        if can_learn[i][0] == id
          can = true
          if can_learn[i][1] <= @actor.level
            lv = true
          else
            lv = false
          end
          break
        else
          can = false
        end
      end
      enabled = (can and lv and @actor.learn?(@item))
      # When with SP and so on is cut off and it becomes not be able to use
      unless enabled
        # Performing buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Performing shop SE
      $game_system.se_play($data_system.shop_se)
      @actor.learn_skill(@item.id)
      $game_party.lose_gold(@price)
      @buy_window.refresh
      @gold_window.refresh
      @status_window.refresh
      @buy_window.active = true
      @status_window.index =- 1
      @status_window.active = false
     end
  end
end



Ver 1.0
[codebox]
CODE
#==============================================================================
# Skill Shop for RMXP
#==============================================================================
# By Nechigawara Sanzenin
# WARNING!! : This script can use on RPG Maker XP Only!! (VX Not Support)
#==============================================================================
# Buy Skill Option For RMXP
#==============================================================================
=begin

How to Use:

You will add "$skill_shop =[Id of Skill]"  
To Call Script to set id of skill for sell.
You will add "$scene = Scene_Skill_Shop.new"  
To Call Skill Shop Windows.

Example:
$skill_shop = [1,2,3,6,7]
$scene = Scene_Skill_Shop.new

You can set text to use in Skill Shop under "# Learn Text".
You can set Skill Price under "# Price Data".
You can set Skill that the fighter each person can study under "# Hero Data".

=end
#==============================================================================
#module SKILL_SHOP
#==============================================================================
module SKILL_SHOP
  # Learn Text
  How_Learn = "What 's hero can learn?"
  Can_Learn = "Can Learn"
  Cant_Learn = "Can't Learn"
  Learnt = "Learnt"
  Teach = "Teach"
  Cancel = "Cancel"
  # Price Data
  PRICE = {
  # for No Set Price
  0 => 100,
  # Add Price Here
  1 => 150,
  2 => 550,
  3 => 450,
  # End
  }
  # Hero Data
  SKILL_BUY = {
  # Add what skill can hero buy Here
  1 => [1,2,3],
  2 => [1,6,7],
  # End
  }
  # Add Price
  def self.skill_price(id)
    if PRICE.include?(id)
      return PRICE[id]
    else
      return PRICE[0]
    end
  end
  # Add Hero id
  def self.skill_buy(id)
    if SKILL_BUY.include?(id)
      return SKILL_BUY[id]
    else
      return []
    end
  end
end
#==============================================================================
#class Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
  def learn?(skill)
    learn = skill_learn?(skill.id)
    if learn
      return false
    else
      return true
    end
  end
end
#==============================================================================
#class Window_Skill_ShopCommand
#==============================================================================
class Window_Skill_ShopCommand < Window_Selectable
  #--------------------------------------------------------------------------
  def initialize
    super(0, 64, 480, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $fontface
    self.contents.font.size = $fontsize
    @item_max = 2
    @column_max = 2
    s1 = SKILL_SHOP::Teach
    s2 = SKILL_SHOP::Cancel
    @commands = [s1, s2]
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  def draw_item(index)
    x = 4 + index * 240
    self.contents.draw_text(x, 0, 128, 32, @commands[index])
  end
end
#==============================================================================
#class Window_Skill_ShopBuy
#==============================================================================
class Window_Skill_ShopBuy < Window_Selectable
  #--------------------------------------------------------------------------
  def initialize(shop_goods)
    super(0, 128, 368, 352)
    @skill_shop_goods = $skill_shop
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  def skill
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in 0...@skill_shop_goods.size
      skill = $data_skills[@skill_shop_goods[i]]
      if skill != nil
        @data.push(skill)
      end
    end
    # If the number of items is not 0, it draws up bit map, drawing all item
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      self.contents.font.name = $fontface
      self.contents.font.size = $fontsize
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  def draw_item(index)
    skill = @data[index]
    # Acquiring the frequency of possession of the item
    price = SKILL_SHOP.skill_price(skill.id)
    enabled = (price <= $game_party.gold)
    # If price is not below the money in hand, at the same time the frequency of possession 99, usually in letter color
    # So if is not, it sets to invalid letter color
    if enabled
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4
    y = index * 32
    rect = Rect.new(x, y, self.width - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(skill.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.draw_text(x + 28, y, 212, 32, skill.name, 0)
    self.contents.draw_text(x + 240, y, 88, 32, price.to_s, 2)
  end
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(skill == nil ? "" : skill.description)
  end
end
#==============================================================================
#class Window_Skill_ShopStatus
#==============================================================================
class Window_Skill_ShopStatus < Window_Selectable
  #--------------------------------------------------------------------------
  def initialize
    super(368, 128, 272, 352)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $fontface
    self.contents.font.size = $fontsize
    @item = nil
    refresh
    self.active = false
    self.index = -1
  end
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    @item_max = $game_party.actors.size
    if @item == nil
      return
    end
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, 200, 32, SKILL_SHOP::How_Learn)
    self.contents.font.color = normal_color
    # Equipment supplementary information
    for i in 0...$game_party.actors.size
      # Acquiring the actor
      actor = $game_party.actors[i]
      can_learn = SKILL_SHOP.skill_buy(actor.id)
      id = @item.id
      enabled = (can_learn.include?(id) and actor.learn?(@item))
      # If equipment possibility if usually in letter color, the impossibility, it sets to invalid letter color
      if enabled
        self.contents.font.color = normal_color
      else
        self.contents.font.color = disabled_color
      end
      # Drawing the name of the actor
      self.contents.draw_text(4, 64 + 64 * i, 120, 32, actor.name)
      # Check Skill
      if can_learn.include?(id) == false
        text = SKILL_SHOP::Cant_Learn
      elsif actor.learn?(@item) == false
        text = SKILL_SHOP::Learnt
      else
        text = SKILL_SHOP::Can_Learn
      end
      # Drawing the item
      self.contents.draw_text(124, 64 + 64 * i, 112, 32, text, 2)
    end
  end
  #--------------------------------------------------------------------------
  def item=(item)
    if @item != item
      @item = item
      refresh
    end
  end
  #--------------------------------------------------------------------------
  def update_cursor_rect
    # Cursor position as for -1 all selection, -2 below independence selection (user himself)
    if @index < 0
      self.cursor_rect.empty
    else
      self.cursor_rect.set(0, 64 + @index * 64, self.width - 32, 32)
    end
  end
end
#==============================================================================
#class Scene_Skill_Shop
#==============================================================================
class Scene_Skill_Shop
  #--------------------------------------------------------------------------
  def main
    # Drawing up the help window
    @help_window = Window_Help.new
    # Drawing up the command window
    @command_window = Window_Skill_ShopCommand.new
    # Drawing up the Goldwyn dough
    @gold_window = Window_Gold.new
    @gold_window.x = 480
    @gold_window.y = 64
    # Drawing up the dummy window
    @dummy_window = Window_Base.new(0, 128, 640, 352)
    # Drawing up the purchase window
    @buy_window = Window_Skill_ShopBuy.new($game_temp.shop_goods)
    @buy_window.active = false
    @buy_window.visible = false
    @buy_window.help_window = @help_window
    # Drawing up the status window
    @status_window = Window_Skill_ShopStatus.new
    @status_window.visible = false
    @status_window.active
    # Transition execution
    Graphics.transition
    # Main loop
    loop do
      # Renewing the game picture
      Graphics.update
      # Updating the information of input
      Input.update
      # Frame renewal
      update
      # When the picture changes, discontinuing the loop
      if $scene != self
        break
      end
    end
    # Transition preparation
    Graphics.freeze
    # Releasing the window
    @help_window.dispose
    @command_window.dispose
    @gold_window.dispose
    @dummy_window.dispose
    @buy_window.dispose
    @status_window.dispose
  end
  #--------------------------------------------------------------------------
  def update
    # Renewing the window
    @help_window.update
    @command_window.update
    @gold_window.update
    @dummy_window.update
    @buy_window.update
    @status_window.update
    # When the command window is active,: Update_command is called
    if @command_window.active
      update_command
      return
    end
    # When the purchase window is active,: Update_buy is called
    if @buy_window.active
      update_buy
      return
    end
    # When the target window is active,: Update_target is called
    if @status_window.active
      update_target
      return
    end
  end
  #--------------------------------------------------------------------------
  def update_command
    # The B when button is pushed
    if Input.trigger?(Input::B)
      # Performing cancellation SE
      $game_system.se_play($data_system.cancel_se)
      # Change to map picture
      $scene = Scene_Map.new
      return
    end
    # When C button is pushed
    if Input.trigger?(Input::C)
      # Eliminating the help text
      @help_window.set_text("")
      # It diverges at cursor position of the command window
      case @command_window.index
      when 0  # It purchases
        # Performing decision SE
        $game_system.se_play($data_system.decision_se)
        # State of window to purchase mode
        @command_window.active = false
        @dummy_window.visible = false
        @buy_window.active = true
        @buy_window.visible = true
        @buy_window.refresh
        @status_window.visible = true
      when 1  # It stops
        # Performing decision SE
        $game_system.se_play($data_system.decision_se)
        # Change to map picture
        $scene = Scene_Map.new
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  def update_buy
    # Setting the item of the status window
    @status_window.item = @buy_window.skill
    # The B when button is pushed
    if Input.trigger?(Input::B)
      # Performing cancellation SE
      $game_system.se_play($data_system.cancel_se)
      # State of window to early mode
      @command_window.active = true
      @dummy_window.visible = true
      @buy_window.active = false
      @buy_window.visible = false
      @status_window.visible = false
      @status_window.item = nil
      # Eliminating the help text
      @help_window.set_text("")
      return
    end
    # When C button is pushed
    if Input.trigger?(Input::C)
      # Acquiring the item
      @item = @buy_window.skill
      @price = SKILL_SHOP.skill_price(@item.id)
      enabled = (@price <= $game_party.gold)
      # When the item is invalid, or when price it is on from the money in hand
      unless  enabled
        # Performing buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Performing decision SE
      $game_system.se_play($data_system.decision_se)
      @buy_window.active = false
      @status_window.active = true
      @status_window.index = 0
    end
  end
  #--------------------------------------------------------------------------
  def update_target
    # The B when button is pushed
    if Input.trigger?(Input::B)
      # Performing cancellation SE
      $game_system.se_play($data_system.cancel_se)
      # Eliminating the target window
      @buy_window.active = true
      @status_window.index =- 1
      @status_window.active = false
      return
    end
    # When C button is pushed
    if Input.trigger?(Input::C)
      @actor = $game_party.actors[@status_window.index]
      can_learn = SKILL_SHOP.skill_buy(@actor.id)
      id = @item.id
      enabled = (can_learn.include?(id) and @actor.learn?(@item))
      # When with SP and so on is cut off and it becomes not be able to use
      unless enabled
        # Performing buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Performing shop SE
      $game_system.se_play($data_system.shop_se)
      @actor.learn_skill(@item.id)
      $game_party.lose_gold(@price)
      @buy_window.refresh
      @gold_window.refresh
      @status_window.refresh
      @buy_window.active = true
      @status_window.index =- 1
      @status_window.active = false
     end
  end
end


How to Use:

You will add "$skill_shop =[Id of Skill]"
To Call Script to set id of skill for sell.
You will add "$scene = Scene_Skill_Shop.new"
To Call Skill Shop Windows.

Example:
$skill_shop = [1,2,3,6,7]
$scene = Scene_Skill_Shop.new

You can set text to use in Skill Shop under "# Learn Text".
You can set Skill Price under "# Price Data".
You can set Skill that the fighter each person can study under "# Hero Data".

This Line
CODE
0 => 100

Setting price for all skills that no set a price.(Standard price)
CODE
1 => 150

Setting price to 150 for skill id 1.

Demo :
Ver 1.0
http://www.mediafire.com/?2ji9xczs1jy
Ver 2.0
http://www.mediafire.com/?gytzsbmwyxx

Screen Shot :
Ver 1.0

Ver 2.0


This post has been edited by Nechi: Feb 27 2008, 10:02 PM

__________________________


Now, I 'm very busy.I'm work hard in the university. If you send me PM, sorry that I can't answer them at the moment.
Go to the top of the page
 
+Quote Post
   
Puppet Of Fate
post Mar 1 2008, 04:43 PM
Post #2


Please join my site!
Group Icon

Group: Revolutionary
Posts: 675
Type: Mapper
RM Skill: Advanced




THANK YOU! OMG YOUR AWESOME!


__________________________
Go to the top of the page
 
+Quote Post
   
D3wil666
post Mar 4 2008, 06:51 AM
Post #3


Level 3
Group Icon

Group: Member
Posts: 44
Type: None
RM Skill: Beginner




ho do skills for class example for Fighter cross cut
Go to the top of the page
 
+Quote Post
   
reaven
post Dec 29 2008, 09:59 AM
Post #4


Level 1
Group Icon

Group: Member
Posts: 7
Type: Developer
RM Skill: Beginner




i did copy the script from the demo and add it above the main etc
and i created a character thing with the script in it i did copy that 2 from the character in the demo
but when i talk to him i get this error:
script 'skill shop ***' line107: typeError occurred.
no implicit conversion from nil to integer

plz help me
Go to the top of the page
 
+Quote Post
   
nordique
post Jan 24 2009, 05:59 PM
Post #5



Group Icon

Group: Member
Posts: 2
Type: Event Designer
RM Skill: Intermediate




Sorry for kind of necropost, but I like your script and I was wondering, if there is some way to make it compatible with Large party scripts?
Go to the top of the page
 
+Quote Post
   
Michael
post Jan 24 2009, 07:11 PM
Post #6


Level 33
Group Icon

Group: Revolutionary
Posts: 838
Type: Writer
RM Skill: Skilled




Thanks,
I needed it. Also it's such a long script!
If you wrote that by scatch your a champ!
Go to the top of the page
 
+Quote Post
   
darks4ber
post May 22 2010, 07:56 AM
Post #7


Level 2
Group Icon

Group: Member
Posts: 16
Type: Musician
RM Skill: Beginner




can you edit the post that the script are in spoilers?
this page is HUGE!!!!!


__________________________
Skatanai......
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 24th May 2013 - 06:24 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker