關於部落格
RPG製作大師XP腳本為主要更新

RPG製作大師VX腳本為其次更新

RPG製作大師VX_Ace目前不考慮

RPG製作大師MV腳本完全沒打算

留言完建議重新整理看看是否顯示

目前不處理本舖外腳本的相關問題

其他相關事項請觀看規定注意事項

本舖未來的經營計畫與VA的支援




var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-37462754-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

  • 303700

    累積人氣

  • 67

    今日人氣

    0

    追蹤人氣

【腳本】當舖系統


使用方法
打開腳本編輯器,對腳本「Main」按下右鍵,選擇插入,會出現1個空白腳本
在空白腳本內貼上以下腳本:
RPG Maker XP 適用

module Sword
#=======================================
#★ 魔劍工舖 - 當舖系統1.01
# 轉貼腳本請著名出處:http://blog.yam.com/a870053jjkj/
# 如果採用在遊戲中,看你高興是否顯示腳本出處,但嚴禁說是自己寫的腳本!!
#=======================================
#● 使用者自定設置
SWORD_PAWN_COMM = ['點當', '贖回', '離開'] # 設定當舖選項的文字 [當, 贖, 離開]
SWORD_PAWN_PAWN = 50 # 設定 點當 時,當掉的價錢百分比,原價值為100
SWORD_PAWN_REDE = 150 #  設定 贖回 時,贖回的價錢百分比,原價值為100
#=======================================
#● 設置方法
# 呼叫方法:$scene = Sword_Pawnshop.new(當舖編號)
#--------------------------------------------------------------
  $Sword ? $Sword[6] = true : $Sword = {6=>true} # 腳本使用標誌
end
#詳細設置說明請參考:http://blog.yam.com/a870053jjkj/article/25226026
#=======================================
#■ 處理同伴的類別
class Game_Party
  attr_accessor :pawnshop # 當舖空間
  #● 初始化物件
  alias sword6_initialize initialize
  def initialize
    @pawnshop = [nil]
    sword6_initialize
  end
end
#=======================================
#■ 贖回用語窗口
class WSword_PawnshopWords < Window_Base
  def initialize
    super(0, 128, 368, 352)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  #-------------------------------------------------------------
  #● 更新
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(4 , 0, 212, 32, '物品名稱')
    self.contents.draw_text(4 + 184, 0, 88, 32, '存貨', 1)
    self.contents.draw_text(4 + 240, 0, 88, 32, '價錢', 2)
  end
end
#=======================================
#■ 贖回窗口
class WSword_PawnshopBuy < Window_Selectable
  include Sword
  #● 初始化物件
  def initialize(shop_goods, pawnshop)
    super(0, 160, 368, 320)
    @shop_goods = shop_goods ; @pawnshop = pawnshop
    refresh
    self.opacity = 0 # 窗口不透明度
    self.index = 0 # 選項位置
    self.z = 120
  end
  #-------------------------------------------------------------
  #● 獲取物品
  def item
    return @data[self.index]
  end
  #-------------------------------------------------------------
  #● 更新內容
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    # 設置擺設的道具
    @data = []
    for i in 0..2
      for ii in 1...@shop_goods[i].size
        case i
        when 0 ; @data.push($data_items[ii]) if @shop_goods[0][ii] > 0
        when 1 ; @data.push($data_weapons[ii]) if @shop_goods[1][ii] > 0
        when 2 ; @data.push($data_armors[ii]) if @shop_goods[2][ii] > 0
        end
      end
    end
    # 如果項目數不是 0 就產生點陣圖、描繪全部項目
    @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
  #-------------------------------------------------------------
  # ● 描繪項目
  def draw_item(index)
    item = @data[index]
    # 獲取物品所持數
    case item
    when RPG::Item # 物品
      number = $game_party.item_number(item.id)
      numpaw = $game_party.pawnshop[@pawnshop][0][item.id]
    when RPG::Weapon # 武器
      number = $game_party.weapon_number(item.id)
      numpaw = $game_party.pawnshop[@pawnshop][1][item.id]
    when RPG::Armor # 防具
      number = $game_party.armor_number(item.id)
      numpaw = $game_party.pawnshop[@pawnshop][2][item.id]
    end
    # 價格在所持金額以下、並且所持數不是 99 的情況下為普通文字色彩
    # 除此之外的情況設定為無效文字色彩
    ((item.price / 100.0 * SWORD_PAWN_REDE).to_i <= $game_party.gold and number < 99) ?
    self.contents.font.color = normal_color : self.contents.font.color = disabled_color
    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(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.draw_text(x + 28, y, 212, 32, item.name, 0) # 物品名稱
    self.contents.draw_text(x + 184, y, 88, 32, numpaw.to_s, 1) # 存貨
    self.contents.draw_text(x + 240, y, 88, 32,
    (item.price / 100.0 * SWORD_PAWN_REDE).to_i.to_s, 2) # 價錢
  end
  #-------------------------------------------------------------
  #● 更新說明文字
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
end
#=======================================
#■ 當鋪選項窗口
class WSword_PawnshopCommand < Window_Selectable
  include Sword
  #● 初始化物件
  def initialize
    super(0, 64, 480, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    @item_max = 3
    @column_max = 3
    @commands = SWORD_PAWN_COMM
    refresh
    self.index = 0
  end
  #-------------------------------------------------------------
  #● 更新內容
  def refresh
    self.contents.clear
    for i in 0...@item_max
      x = 4 + i* 160
      self.contents.draw_text(x, 0, 128, 32, @commands[i])
    end
  end
end
#=======================================
#■ 當鋪系統畫面
class Sword_Pawnshop
  include Sword
  #● 初始化物件
  def initialize(pawnshop)
    @pawnshop = pawnshop # 獲取當舖編號
    if $game_party.pawnshop[@pawnshop] == nil # 如未開通當舖空間的場合
      pawn = [{}, {}, {}] # 暫存當舖空間變量
      for i in 1..$data_items.size # 物品
        pawn[0][i] = 0
      end
      for i in 1..$data_weapons.size # 武器
        pawn[1][i] = 0
      end
      for i in 1..$data_armors.size # 防具
        pawn[2][i] = 0
      end
      $game_party.pawnshop[@pawnshop] = pawn
    end
  end
  #-------------------------------------------------------------
  #● 主處理
  def main
    #○ 產生窗口
    @help_window = Window_Help.new # 產生幫助視窗
    @pawnshopcommand_wsword = WSword_PawnshopCommand.new # 產生商店選項視窗
    @gold_window = Window_Gold.new # 產生金錢視窗
    @gold_window.x = 480
    @gold_window.y = 64
    @dummy_window = Window_Base.new(0, 128, 640, 352) # 產生空窗口
    @buy_wsword = WSword_PawnshopBuy.new(
    $game_party.pawnshop[@pawnshop], @pawnshop) # 產生贖回窗口
    @buy_wsword.active = false
    @buy_wsword.visible = false
    @buy_wsword.help_window = @help_window
    @sell_window = Window_ShopSell.new # 產生點當窗口
    @sell_window.active = false
    @sell_window.visible = false
    @sell_window.help_window = @help_window
    @number_window = Window_ShopNumber.new # 產生個數輸入窗口
    @number_window.active = false
    @number_window.visible = false
    @status_window = Window_ShopStatus.new # 產生商店狀態窗口
    @status_window.visible = false
    @pawnshopwoeds_wsword = WSword_PawnshopWords.new # 贖回用語窗口
    @pawnshopwoeds_wsword.visible = false
    #○ 主循環
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    #○ 釋放視窗
    @help_window.dispose
    @pawnshopcommand_wsword.dispose
    @gold_window.dispose
    @dummy_window.dispose
    @buy_wsword.dispose
    @sell_window.dispose
    @number_window.dispose
    @status_window.dispose
    @pawnshopwoeds_wsword.dispose
  end
  #-------------------------------------------------------------
  #● 更新
  def update
    #○ 更新視窗
    @help_window.update
    @pawnshopcommand_wsword.update
    @gold_window.update
    @dummy_window.update
    @buy_wsword.update
    @sell_window.update
    @number_window.update
    #○ 窗口活動分歧
    if @pawnshopcommand_wsword.active ; update_command # 當舖選項窗口活動時
    elsif @buy_wsword.active ; update_buy # 購買窗口活動時
    elsif @sell_window.active ; update_sell # 賣出窗口活動時
    elsif @number_window.active ; update_number # 個數輸入窗口活動時
    end
  end
  #-------------------------------------------------------------
  # ● 更新(當舖選項窗口)
  def update_command
    if Input.trigger?(Input::B) # 按下取消鍵就回到地圖
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
    elsif Input.trigger?(Input::C) # 按下確定鍵選擇
      case @pawnshopcommand_wsword.index
      when 0 # 點當
        $game_system.se_play($data_system.decision_se)
        @pawnshopcommand_wsword.active = false
        @dummy_window.visible = false
        @sell_window.active = true
        @sell_window.visible = true
        @sell_window.refresh
      when 1  # 贖回
        $game_system.se_play($data_system.decision_se)
        @pawnshopcommand_wsword.active = false
        @dummy_window.visible = false
        @buy_wsword.active = true
        @buy_wsword.visible = true
        @buy_wsword.refresh
        @status_window.visible = true
        @pawnshopwoeds_wsword.visible = true
      when 2  # 離開
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Map.new
      end
    end
  end
  #-------------------------------------------------------------
  # ● 更新 (當舖點當窗口)
  def update_sell
    if Input.trigger?(Input::B) # 按下取消鍵回到當舖選項窗口
      $game_system.se_play($data_system.cancel_se)
      @pawnshopcommand_wsword.active = true
      @dummy_window.visible = true
      @sell_window.active = false
      @sell_window.visible = false
      @status_window.item = nil
      @help_window.set_text("")
    elsif Input.trigger?(Input::C) # 按下確定鍵選擇
      @item = @sell_window.item # 獲取物品
      @status_window.item = @item
      # 物品無效的情況下、或者價格為 0 (不能賣出) 的情況下
      if @item == nil or @item.price == 0
        # 演奏凍結 SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # 演奏確定 SE
      $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
      @sell_window.visible = false
      @number_window.set(@item,max,(@item.price / 100.0 * SWORD_PAWN_PAWN).to_i)
      @number_window.active = true
      @number_window.visible = true
      @status_window.visible = true
    end
  end
  #-------------------------------------------------------------
  # ● 更新 (當舖贖回窗口)
  def update_buy
    @status_window.item = @buy_wsword.item
    # 按下 B 鍵的情況下
    if Input.trigger?(Input::B)
      # 演奏取消 SE
      $game_system.se_play($data_system.cancel_se)
      # 視窗狀態轉向初期模式
      @pawnshopcommand_wsword.active = true
      @dummy_window.visible = true
      @buy_wsword.active = false
      @buy_wsword.visible = false
      @status_window.visible = false
      @status_window.item = nil
      @pawnshopwoeds_wsword.visible = false
      # 刪除說明文字
      @help_window.set_text("")
      return
    end
    # 按下 C 鍵的情況下
    if Input.trigger?(Input::C)
      # 獲取物品
      @item = @buy_wsword.item
      # 物品無效的情況下、或者價格在所持金以上的情況下
      if @item == nil or
      (@item.price / 100.0 * SWORD_PAWN_REDE).to_i > $game_party.gold
        # 演奏凍結 SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      case @item # 獲取身上與當舖的該道具數量
      when RPG::Item # 物品
        number = $game_party.item_number(@item.id)
        numpaw = $game_party.pawnshop[@pawnshop][0][@item.id]
      when RPG::Weapon # 武器
        number = $game_party.weapon_number(@item.id)
        numpaw = $game_party.pawnshop[@pawnshop][1][@item.id]
      when RPG::Armor # 防具
        number = $game_party.armor_number(@item.id)
        numpaw = $game_party.pawnshop[@pawnshop][2][@item.id]
      end
      if number == 99 # 如果已經擁有了 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 / 100.0 * SWORD_PAWN_REDE).to_i
      max = [[max, 99 - number].min, numpaw].min
      # 視窗狀態轉向數值輸入模式
      @buy_wsword.active = false
      @buy_wsword.visible = false
      @pawnshopwoeds_wsword.visible = false
      @number_window.set(@item, max, (@item.price / 100.0 * SWORD_PAWN_REDE).to_i)
      @number_window.active = true
      @number_window.visible = true
    end
  end
  #-------------------------------------------------------------
  #● 更新 (個數輸入窗口)
  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 @pawnshopcommand_wsword.index
      when 0  # 點當
        @sell_window.active = true
        @sell_window.visible = true
        @status_window.visible = false
      when 1  #贖回
        @buy_wsword.active = true
        @buy_wsword.visible = true
        @pawnshopwoeds_wsword.visible = true
      end
    elsif Input.trigger?(Input::C) # 按下確定鍵輸出數值
      $game_system.se_play($data_system.shop_se)
      @number_window.active = false
      @number_window.visible = false
      case @pawnshopcommand_wsword.index
      when 0  # 點當
        $game_party.gain_gold(@number_window.number *
        (@item.price / 100.0 * SWORD_PAWN_PAWN).to_i)
        case @item
        when RPG::Item
          $game_party.lose_item(@item.id, @number_window.number)
          $game_party.pawnshop[@pawnshop][0][@item.id] += @number_window.number
        when RPG::Weapon
          $game_party.lose_weapon(@item.id, @number_window.number)
          $game_party.pawnshop[@pawnshop][1][@item.id] += @number_window.number
        when RPG::Armor
          $game_party.lose_armor(@item.id, @number_window.number)
          $game_party.pawnshop[@pawnshop][2][@item.id] += @number_window.number
        end
        # 更新窗口內容
        @gold_window.refresh
        @sell_window.refresh
        @status_window.refresh
        # 回到點當窗口
        @sell_window.active = true
        @sell_window.visible = true
        @status_window.visible = false
      when 1  # 贖回
        $game_party.lose_gold(@number_window.number *
        (@item.price / 100.0 * SWORD_PAWN_REDE).to_i)
        case @item
        when RPG::Item
          $game_party.gain_item(@item.id, @number_window.number)
          $game_party.pawnshop[@pawnshop][0][@item.id] -= @number_window.number
        when RPG::Weapon
          $game_party.gain_weapon(@item.id, @number_window.number)
          $game_party.pawnshop[@pawnshop][1][@item.id] -= @number_window.number
        when RPG::Armor
          $game_party.gain_armor(@item.id, @number_window.number)
          $game_party.pawnshop[@pawnshop][2][@item.id] -= @number_window.number
        end
        # 更新窗口內容
        @gold_window.refresh
        @buy_wsword.refresh
        @status_window.refresh
        # 回到贖回窗口
        @buy_wsword.active = true
        @buy_wsword.visible = true
        @pawnshopwoeds_wsword.visible = true
      end
    end
  end
end

 
 
設置方法
呼叫當舖畫面
$scene = Sword_Pawnshop.new(當舖編號)
不同的當舖編號表示不同的當舖,簡單來說...
當你點當1個東西到當舖編號為6的當舖時,如果要贖回這個物品
就必須到當舖編號為6的當舖才能購買贖回來
 
 
使用者自定設置說明
SWORD_PAWN_COMM = ['點當', '贖回', '離開']
設定上方3個選項的文字內容
 
SWORD_PAWN_PAWN = 50
設定玩家點當道具時,當掉所獲得的錢的百分比,如果原價的話設為100(表示100%)
如果設成50,則當出道具所獲得的錢只會得到原價的50%,依此類推
 
SWORD_PAWN_REDE = 150
設定玩家贖回道具時,贖回所需的錢的百分比,如果原價的話設為100(表示100%)
如果設成150,則贖回道具所需的錢會多增加50%,依此類推
 
相簿設定
標籤設定
相簿狀態