设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 3690|回复: 5
打印 上一主题 下一主题

[RMVX发布] 限量贩售商店

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
72 小时
注册时间
2010-10-18
帖子
104
跳转到指定楼层
1
发表于 2010-11-11 11:21:47 | 只看该作者 回帖奖励 |正序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 迷路子 于 2010-11-12 15:25 编辑

早先就有這個想法了
只是之前一直沒有想到合適的寫法
昨天靈光閃現
花了一些時間終於寫出來了
而基於原本的內建商店畫面不是那麼的華麗
因此結合了億萬星辰前輩的個性化商店腳本
在其腳本上加入了我寫的限量商店腳本
因為限量販售載圖看不出來
就直接放代碼啦
  1. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  2. #_/    ◆ 限量商店物品腳本◆ VX ◆
  3. #_/
  4. #_/    ◇ 項目分類 : 商店強化
  5. #_/    ◇ 項目版本 : 1.0.1111
  6. #_/    ◇ 建立日期 : 2010/11/11
  7. #_/    ◇ 最後更新 : 2010/11/11 ◇
  8. #_/----------------------------------------------------------------------------
  9. #_/  腳本作者:迷路子
  10. #_/  結合腳本:個性化商店   作者:億萬星辰
  11. #_/============================================================================
  12. #_/ 【基本機能】
  13. #_/  1. 可設定道具、武器、防具的限量販售
  14. #_/  2. 可設定能隨著時間或步數增加而再生的商品
  15. #_/  3. 可分別設定可再生和不可再生的商品
  16. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/


  17. module Miluko
  18.   #使用的開關編號
  19.   SW_SBS = 1
  20.   
  21.   #哪些物品分別為限量
  22.   #1為item   2為weapon  3為armor
  23.   #[]中為物品在數據庫中的編號  以逗號為分隔
  24.   SHOP_BUY_SPECIAL = {
  25.   1 => [1,2,3,4],
  26.   2 => [1],
  27.   3 => [],
  28.   }
  29.   
  30.   #物品限制的數量   分別對應至SHOP_BUY_SPECIAL中的物品
  31.   #以範例來說   
  32.   #表示道具編號為1  2  3  4的四樣道具
  33.   #分別的限制購買數量為10  5  7  3
  34.   #當該道具的購買總量達到SHOP_BUY_SPECIAL_NUM中設定的數量時
  35.   #便不可繼續購買
  36.   #只有賣回給商店才能消除已購買的數量  賣回一個就可再購買一個
  37.   SHOP_BUY_SPECIAL_NUM = {
  38.   1 => [10,5,7,3],
  39.   2 => [1],
  40.   3 => [],
  41.   }
  42.   
  43.   #商店道具是否可自動再生
  44.   #0為不自動再生  1為依據遊戲經過秒數自動再生  2為依據行走步數自動再生
  45.   #範例為2
  46.   SHOP_AUTO_REFRESH = 2
  47.   
  48.   #商店道具回覆的時間
  49.   #當SHOP_AUTO_REFRESH為1時使用  單位為秒
  50.   SHOP_REFRESH_SEC = 10
  51.   
  52.   #商店道具回覆的時間
  53.   #當SHOP_AUTO_REFRESH為2時使用  單位為人物行走步數
  54.   SHOP_REFRESH_STEP = 10
  55.   
  56.   #當SHOP_AUTO_REFRESH設定為1或2時使用
  57.   #數組內的值為數據庫中的道具編號
  58.   #列在數組內的道具將不具有回覆性  可藉此設定可自動再生和不可自動再生的物品
  59.   #以範例而言  便是道具編號2號和武器編號1號這兩樣道具不可再生
  60.   #而2號道具在前面設定為只能購買5個  因此此遊戲的商店便只會販賣5個2號道具
  61.   #當全部買完後  除非賣回給商店  否則商店便不再刷新該道具
  62.   SHOP_NOT_AUTOREFRESH = {
  63.   1 => [2],
  64.   2 => [1],
  65.   3 => [],
  66.   }
  67. end

  68. #==============================================================================
  69. # ■ Scene_Title
  70. #------------------------------------------------------------------------------
  71. #  標題菜單。
  72. #==============================================================================

  73. class Scene_Title < Scene_Base
  74.   
  75.   #--------------------------------------------------------------------------
  76.   # ● 新遊戲開始時設定
  77.   #--------------------------------------------------------------------------
  78.   def command_new_game
  79.     confirm_player_location
  80.     Sound.play_decision
  81.     $game_party.setup_starting_members            
  82.     $game_map.setup($data_system.start_map_id)   
  83.     $game_player.moveto($data_system.start_x, $data_system.start_y)
  84.     $game_player.refresh
  85.     $shop_buy_special_item = []
  86.     $shop_buy_special_weapon = []
  87.     $shop_buy_special_armor = []
  88.     $shop_sec = 0
  89.     $shop_step = 0
  90.     $scene = Scene_Map.new
  91.     RPG::BGM.fade(1500)
  92.     close_command_window
  93.     Graphics.fadeout(60)
  94.     Graphics.wait(40)
  95.     Graphics.frame_count = 0
  96.     RPG::BGM.stop
  97.     $game_map.autoplay
  98.   end
  99. end

  100. #==============================================================================
  101. # ■ Scene_File
  102. #------------------------------------------------------------------------------
  103. #  存讀檔。
  104. #==============================================================================

  105. class Scene_File < Scene_Base
  106.   #--------------------------------------------------------------------------
  107.   # ● 存檔時將變數儲存
  108.   #--------------------------------------------------------------------------
  109.   def write_save_data(file)
  110.     characters = []
  111.     for actor in $game_party.members
  112.       characters.push([actor.character_name, actor.character_index])
  113.     end
  114.     $game_system.save_count += 1
  115.     $game_system.version_id = $data_system.version_id
  116.     @last_bgm = RPG::BGM::last
  117.     @last_bgs = RPG::BGS::last
  118.     Marshal.dump(characters,           file)
  119.     Marshal.dump(Graphics.frame_count, file)
  120.     Marshal.dump(@last_bgm,            file)
  121.     Marshal.dump(@last_bgs,            file)
  122.     Marshal.dump($game_system,         file)
  123.     Marshal.dump($game_message,        file)
  124.     Marshal.dump($game_switches,       file)
  125.     Marshal.dump($game_variables,      file)
  126.     Marshal.dump($game_self_switches,  file)
  127.     Marshal.dump($game_actors,         file)
  128.     Marshal.dump($game_party,          file)
  129.     Marshal.dump($game_troop,          file)
  130.     Marshal.dump($game_map,            file)
  131.     Marshal.dump($game_player,         file)
  132.     Marshal.dump($shop_buy_special_item,  file)
  133.     Marshal.dump($shop_buy_special_weapon,file)
  134.     Marshal.dump($shop_buy_special_armor, file)
  135.     Marshal.dump($shop_sec,            file)
  136.     Marshal.dump($shop_step,           file)
  137.   end
  138.   #--------------------------------------------------------------------------
  139.   # ● 讀檔時將變數讀出
  140.   #--------------------------------------------------------------------------
  141.   def read_save_data(file)
  142.     characters           = Marshal.load(file)
  143.     Graphics.frame_count = Marshal.load(file)
  144.     @last_bgm            = Marshal.load(file)
  145.     @last_bgs            = Marshal.load(file)
  146.     $game_system         = Marshal.load(file)
  147.     $game_message        = Marshal.load(file)
  148.     $game_switches       = Marshal.load(file)
  149.     $game_variables      = Marshal.load(file)
  150.     $game_self_switches  = Marshal.load(file)
  151.     $game_actors         = Marshal.load(file)
  152.     $game_party          = Marshal.load(file)
  153.     $game_troop          = Marshal.load(file)
  154.     $game_map            = Marshal.load(file)
  155.     $game_player         = Marshal.load(file)
  156.     $shop_buy_special_item = Marshal.load(file)
  157.     $shop_buy_special_weapon = Marshal.load(file)
  158.     $shop_buy_special_armor = Marshal.load(file)
  159.     $shop_sec            = Marshal.load(file)
  160.     $shop_step           = Marshal.load(file)
  161.     if $game_system.version_id != $data_system.version_id
  162.       $game_map.setup($game_map.map_id)
  163.       $game_player.center($game_player.x, $game_player.y)
  164.     end
  165.   end
  166. end

  167. #==============================================================================
  168. # ■ Window_ShopBuy
  169. #------------------------------------------------------------------------------
  170. #  購買窗口。
  171. #==============================================================================

  172. class Window_ShopBuy < Window_Selectable
  173.   #--------------------------------------------------------------------------
  174.   # ● 初始化
  175.   #     x : X 坐標
  176.   #     y : Y 坐標
  177.   #--------------------------------------------------------------------------
  178.   def initialize(x, y)
  179.     super(x, y, 384, 256)
  180.     @shop_goods = $game_temp.shop_goods
  181.     refresh
  182.     self.index = 0
  183.   end
  184.   #--------------------------------------------------------------------------
  185.   # ● 幫助文字更新
  186.   #--------------------------------------------------------------------------
  187.   def update_help
  188.     @help_window.set_item(item)
  189.   end
  190.   
  191.   #--------------------------------------------------------------------------
  192.   # ● 顯示商店販售物品
  193.   #--------------------------------------------------------------------------
  194.   def draw_item(index)
  195.     item = @data[index]
  196.     number = $game_party.item_number(item)
  197.     enabled = (item.price <= $game_party.gold and number < 99)
  198.     if $game_switches[Miluko::SW_SBS]
  199.       if item.is_a?(RPG::Item)
  200.         for i in 0..Miluko::SHOP_BUY_SPECIAL.size
  201.           if item.id == Miluko::SHOP_BUY_SPECIAL[1][i] && $shop_buy_special_item[i].to_i < Miluko::SHOP_BUY_SPECIAL_NUM[1][i]
  202.             enabled = true
  203.           elsif item.id == Miluko::SHOP_BUY_SPECIAL[1][i] && $shop_buy_special_item[i].to_i >= Miluko::SHOP_BUY_SPECIAL_NUM[1][i]
  204.             enabled = false
  205.           end
  206.         end
  207.       elsif item.is_a?(RPG::Weapon)
  208.         for i in 0..Miluko::SHOP_BUY_SPECIAL.size
  209.           if item.id == Miluko::SHOP_BUY_SPECIAL[2][i] && $shop_buy_special_weapon[i].to_i < Miluko::SHOP_BUY_SPECIAL_NUM[2][i]
  210.             enabled = true
  211.           elsif item.id == Miluko::SHOP_BUY_SPECIAL[2][i] && $shop_buy_special_weapon[i].to_i >= Miluko::SHOP_BUY_SPECIAL_NUM[2][i]
  212.             enabled = false
  213.           end
  214.         end
  215.       elsif item.is_a?(RPG::Item)
  216.         for i in 0..Miluko::SHOP_BUY_SPECIAL.size
  217.           if item.id == Miluko::SHOP_BUY_SPECIAL[3][i] && $shop_buy_special_armor[i].to_i < Miluko::SHOP_BUY_SPECIAL_NUM[3][i]
  218.             enabled = true
  219.           elsif item.id == Miluko::SHOP_BUY_SPECIAL[3][i] && $shop_buy_special_armor[i].to_i >= Miluko::SHOP_BUY_SPECIAL_NUM[3][i]
  220.             enabled = false
  221.           end
  222.         end
  223.       end
  224.     end
  225.     rect = item_rect(index)
  226.     self.contents.clear_rect(rect)
  227.     draw_item_name(item, rect.x, rect.y, enabled)
  228.     rect.width -= 4
  229.     self.contents.draw_text(rect, item.price, 2)
  230.   end
  231. end

  232. #==============================================================================
  233. # ■ Window_ShopSell
  234. #------------------------------------------------------------------------------
  235. #  出售窗口。
  236. #==============================================================================

  237. class Window_ShopSell < Window_Item
  238.   #--------------------------------------------------------------------------
  239.   # ● 初始化
  240.   #     x      : X 坐標
  241.   #     y      : Y 坐標
  242.   #     width  : 窗口寬度
  243.   #     height : 窗口高度
  244.   #--------------------------------------------------------------------------
  245.   def initialize(x, y, width, height)
  246.     super(x, y, width, height)
  247.     @column_max = 1
  248.   end
  249.   #--------------------------------------------------------------------------
  250.   # ● 幫助文字更新
  251.   #--------------------------------------------------------------------------
  252.   def update_help
  253.     @help_window.set_item(item)
  254.   end
  255. end

  256. #==============================================================================
  257. # ■ Window_ShopNumber
  258. #------------------------------------------------------------------------------
  259. #  買賣輸入個數窗口。
  260. #==============================================================================

  261. class Window_ShopNumber < Window_Base
  262.   #--------------------------------------------------------------------------
  263.   # ● 初始化
  264.   #     x : 窗口 X 坐標
  265.   #     y : 窗口 Y 坐標
  266.   #--------------------------------------------------------------------------
  267.   def initialize(x, y)
  268.     super(x, y, 384, 256)
  269.     @item = nil
  270.     @max = 1
  271.     @price = 0
  272.     @number = 1
  273.   end
  274. end

  275. #==============================================================================
  276. # ■ Window_ShopHelp
  277. #------------------------------------------------------------------------------
  278. #  商店說明。
  279. #==============================================================================

  280. class Window_ShopHelp < Window_Base
  281.   #--------------------------------------------------------------------------
  282.   # ● 初始化
  283.   #--------------------------------------------------------------------------
  284.   def initialize
  285.     super(0, 312, 544, 104)
  286.   end
  287.   #--------------------------------------------------------------------------
  288.   # ● 文字設定
  289.   #     item  : 物品
  290.   #--------------------------------------------------------------------------
  291.   def set_item(item)
  292.     if item.nil?
  293.       self.contents.clear
  294.       self.contents.font.color = normal_color
  295.       self.contents.draw_text(0, 0, 512, 24, $game_temp.shop_word)
  296.       @item = nil
  297.       return
  298.     end
  299.     if item != @item
  300.       @item = item
  301.       self.contents.clear
  302.       self.contents.font.color = normal_color
  303.       self.contents.draw_text(0, 0, 512, 24, @item.description)
  304.       if @item.is_a?(RPG::Item)
  305.         # 物品範圍描述
  306.         scope = "[對象] : "
  307.         case @item.scope
  308.         when 0;  scope += "無"
  309.         when 1;  scope += "敵單體"
  310.         when 2;  scope += "敵全體"
  311.         when 3;  scope += "敵單體 連續"
  312.         when 4;  scope += "敵單體 隨機"
  313.         when 5;  scope += "敵二體 隨機"
  314.         when 6;  scope += "敵三體 隨機"
  315.         when 7;  scope += "我方單體"
  316.         when 8;  scope += "我方全體"
  317.         when 9;  scope += "我方單體 (陣亡)"
  318.         when 10; scope += "我方全體 (陣亡)"
  319.         when 11; scope += "使用者"
  320.         end
  321.         self.contents.draw_text(0, 24, 512, 24, scope)
  322.         # 物品範圍描述結束
  323.         # 物品恢復效果描述
  324.         effection = "[效果] : "
  325.         if @item.hp_recovery_rate > 0
  326.           effection += "#{Vocab.hp}+#{@item.hp_recovery_rate}% "
  327.         elsif @item.hp_recovery_rate < 0
  328.           effection += "#{Vocab.hp}-#{@item.hp_recovery_rate}% "
  329.         elsif @item.hp_recovery > 0
  330.           effection += "#{Vocab.hp}+#{@item.hp_recovery} "
  331.         elsif @item.hp_recovery < 0
  332.           effection += "#{Vocab.hp}-#{@item.hp_recovery} "
  333.         end
  334.         if @item.mp_recovery_rate > 0
  335.           effection += "#{Vocab.mp}+#{@item.mp_recovery_rate}% "
  336.         elsif @item.mp_recovery_rate < 0
  337.           effection += "#{Vocab.mp}-#{@item.mp_recovery_rate}% "
  338.         elsif @item.mp_recovery > 0
  339.           effection += "#{Vocab.mp}+#{@item.mp_recovery} "
  340.         elsif @item.mp_recovery < 0
  341.           effection += "#{Vocab.mp}-#{@item.mp_recovery} "
  342.         end
  343.         effection += "傷害#{@item.base_damage} " if @item.base_damage != 0
  344.         case @item.parameter_type
  345.         when 1
  346.           effection += "最大#{Vocab.hp}+#{@item.parameter_points}"
  347.         when 2
  348.           effection += "最大#{Vocab.mp}+#{@item.parameter_points}"
  349.         when 3
  350.           effection += "#{Vocab.atk}+#{@item.parameter_points}"
  351.         when 4
  352.           effection += "#{Vocab.def}+#{@item.parameter_points}"
  353.         when 5
  354.           effection += "#{Vocab.spi}+#{@item.parameter_points}"
  355.         when 6
  356.           effection += "#{Vocab.agi}+#{@item.parameter_points}"
  357.         end
  358.         self.contents.draw_text(0, 48, 512, 24, effection)
  359.         # 物品恢復效果描述結束
  360.       else
  361.         # 武器防具可裝備人員描述
  362.         equip = "[可裝備] : "
  363.         for actor in $game_party.members
  364.           if actor.equippable?(@item)
  365.             equip += "、" if equip != "[可裝備] : "
  366.             equip += actor.name
  367.           end
  368.         end
  369.         equip += "無" if equip == "[可裝備] : "
  370.         self.contents.draw_text(0, 24, 512, 24, equip)
  371.         # 武器防具可裝備人員描述結束
  372.         # 武器防具攻防增減描述
  373.         effection = "[屬性] : "
  374.         if @item.atk != 0
  375.           effection += "攻擊力+#{@item.atk} "
  376.         end
  377.         if @item.def != 0
  378.           effection += "防禦力+#{@item.def} "
  379.         end
  380.         if @item.spi != 0
  381.           effection += "精神力+#{@item.spi} "
  382.         end
  383.         if @item.agi != 0
  384.           effection += "敏捷性+#{@item.agi} "
  385.         end
  386.         # 武器防具攻防增減描述結束
  387.         if @item.is_a?(RPG::Armor)
  388.           # 防具特殊屬性描述
  389.           if @item.prevent_critical
  390.             effection += "防止會心一擊 "
  391.           end
  392.           if @item.half_mp_cost
  393.             effection += "消費MP減半 "
  394.           end
  395.           if @item.double_exp_gain
  396.             effection += "雙倍經驗 "
  397.           end
  398.           if @item.auto_hp_recover
  399.             effection += "自動恢復HP "
  400.           end
  401.           # 防具特殊屬性描述結束
  402.         else
  403.           # 武器特殊屬性描述
  404.           if @item.two_handed
  405.             effection += "雙手持 "
  406.           end
  407.           if @item.fast_attack
  408.             effection += "先發制人 "
  409.           end
  410.           if @item.dual_attack
  411.             effection += "連擊 "
  412.           end
  413.           if @item.critical_bonus
  414.             effection += "頻發會心一擊 "
  415.           end
  416.           # 武器特殊屬性描述結束
  417.         end
  418.         unless @item.element_set.empty?
  419.           # 武器防具屬性描述(左邊那一欄需要打勾的)
  420.           effection += @item.is_a?(RPG::Armor) ? "  [防具狀態] : " : "  [武器屬性] : "
  421.           for state in @item.element_set
  422.             effection += $data_system.elements[state] + " "
  423.           end
  424.           # 武器防具屬性描述結束
  425.         end
  426.         unless @item.state_set.empty?
  427.           # 武器防具狀態描述(右邊那一欄需要打勾的)
  428.           effection += @item.is_a?(RPG::Armor) ? "  [無效化屬性] : " : "  [附加狀態] : "
  429.           for state in @item.state_set
  430.             effection += $data_states[state].name + " "
  431.           end
  432.           # 武器防具狀態描述結束
  433.         end
  434.         self.contents.draw_text(0, 48, 512, 24, effection)
  435.       end
  436.     end
  437.   end
  438. end

  439. class Game_Temp
  440.   attr_accessor :shop_name
  441.   attr_accessor :shop_word
  442.   attr_accessor :shop_mm
  443.   alias old_ini initialize
  444.   def initialize
  445.     old_ini
  446.     @shop_name = ""
  447.     @shop_word = ""
  448.     @shop_mm = ""
  449.   end
  450. end
  451. #==============================================================================
  452. # ■ Scene_Shop
  453. #------------------------------------------------------------------------------
  454. #  商店畫面的處理。
  455. #==============================================================================

  456. class Scene_Shop < Scene_Base
  457.   #--------------------------------------------------------------------------
  458.   # ● 開始
  459.   #--------------------------------------------------------------------------
  460.   def start
  461.     super
  462.     create_menu_background
  463.     create_command_window
  464.     @help_window = Window_ShopHelp.new
  465.     @gold_window = Window_Gold.new(384, 56)
  466.     @title_window = Window_Base.new(0, 0, @command_window.x, 56)
  467.     @title_window.contents.draw_text(0, 0, @title_window.width - 32, 24, $game_temp.shop_name)
  468.     @buy_window = Window_ShopBuy.new(0, 56)
  469.     @buy_window.active = false
  470.     @buy_window.visible = false
  471.     @buy_window.help_window = @help_window
  472.     @sell_window = Window_ShopSell.new(0, 56, 384, 256)
  473.     @sell_window.active = false
  474.     @sell_window.visible = false
  475.     @sell_window.help_window = @help_window
  476.     @number_window = Window_ShopNumber.new(0, 56)
  477.     @number_window.active = false
  478.     @number_window.visible = false
  479.     @loli_sprite = Sprite.new
  480.     @loli_sprite.x = 384
  481.     @loli_sprite.y = 112
  482.     @loli_sprite.bitmap = Cache.picture($game_temp.shop_mm)
  483.     @help_window.set_item(nil)
  484.     if Miluko::SHOP_AUTO_REFRESH == 1
  485.       @total_sec = Graphics.frame_count / Graphics.frame_rate
  486.       if $shop_sec != 0 && @total_sec - $shop_sec > Miluko::SHOP_REFRESH_SEC
  487.         for i in 1..Miluko::SHOP_BUY_SPECIAL.size
  488.           for j in 0..Miluko::SHOP_BUY_SPECIAL[i].size
  489.             if i == 1 && $shop_buy_special_item[j].to_i > 0 && !Miluko::SHOP_NOT_AUTOREFRESH[1].include?(@item.id)
  490.               $shop_buy_special_item[j] -= (@total_sec - $shop_sec)/Miluko::SHOP_REFRESH_SEC
  491.               $shop_buy_special_item[j] = 0 if $shop_buy_special_item[j] < 0
  492.             elsif i == 2 && $shop_buy_special_weapon[j].to_i > 0 && !Miluko::SHOP_NOT_AUTOREFRESH[2].include?(@item.id)
  493.               $shop_buy_special_weapon[j] -= (@total_sec - $shop_sec)/Miluko::SHOP_REFRESH_SEC
  494.               $shop_buy_special_item[j] = 0 if $shop_buy_special_item[j] < 0
  495.             elsif i == 3 && $shop_buy_special_armor[j].to_i > 0 && !Miluko::SHOP_NOT_AUTOREFRESH[3].include?(@item.id)
  496.               $shop_buy_special_armor[j] -= (@total_sec - $shop_sec)/Miluko::SHOP_REFRESH_SEC
  497.               $shop_buy_special_item[j] = 0 if $shop_buy_special_item[j] < 0
  498.             end
  499.           end
  500.         end
  501.       end
  502.     elsif Miluko::SHOP_AUTO_REFRESH == 2
  503.       @total_step = $game_party.steps
  504.       if $shop_step != 0 && @total_step - $shop_step > Miluko::SHOP_REFRESH_STEP
  505.         for i in 1..Miluko::SHOP_BUY_SPECIAL.size
  506.           for j in 0..Miluko::SHOP_BUY_SPECIAL[i].size
  507.             if i == 1 && $shop_buy_special_item[j].to_i > 0 && !Miluko::SHOP_NOT_AUTOREFRESH[1].include?(Miluko::SHOP_BUY_SPECIAL[i][j])
  508.               $shop_buy_special_item[j] -= (@total_step - $shop_step)/Miluko::SHOP_REFRESH_STEP
  509.               $shop_buy_special_item[j] = 0 if $shop_buy_special_item[j] < 0
  510.             elsif i == 2 && $shop_buy_special_weapon[j].to_i > 0 && !Miluko::SHOP_NOT_AUTOREFRESH[2].include?(Miluko::SHOP_BUY_SPECIAL[i][j])
  511.               $shop_buy_special_weapon[j] -= (@total_step - $shop_step)/Miluko::SHOP_REFRESH_STEP
  512.               $shop_buy_special_item[j] = 0 if $shop_buy_special_item[j] < 0
  513.             elsif i == 3 && $shop_buy_special_armor[j].to_i > 0 && !Miluko::SHOP_NOT_AUTOREFRESH[3].include?(Miluko::SHOP_BUY_SPECIAL[i][j])
  514.               $shop_buy_special_armor[j] -= (@total_step - $shop_step)/Miluko::SHOP_REFRESH_STEP
  515.               $shop_buy_special_item[j] = 0 if $shop_buy_special_item[j] < 0
  516.             end
  517.           end
  518.         end
  519.       end
  520.     end
  521.   end
  522.   #--------------------------------------------------------------------------
  523.   # ● 結束處理
  524.   #--------------------------------------------------------------------------
  525.   def terminate
  526.     super
  527.     dispose_menu_background
  528.     dispose_command_window
  529.     @help_window.dispose
  530.     @gold_window.dispose
  531.     @title_window.dispose
  532.     @buy_window.dispose
  533.     @sell_window.dispose
  534.     @number_window.dispose
  535.     @loli_sprite.bitmap.dispose
  536.     @loli_sprite.dispose
  537.     $shop_sec = @total_sec if Miluko::SHOP_AUTO_REFRESH == 1 && @total_sec - $shop_sec > Miluko::SHOP_REFRESH_SEC
  538.     $shop_step = @total_step if Miluko::SHOP_AUTO_REFRESH == 2 && @total_step - $shop_step > Miluko::SHOP_REFRESH_STEP
  539.   end
  540.   #--------------------------------------------------------------------------
  541.   # ● 畫面更新
  542.   #--------------------------------------------------------------------------
  543.   def update
  544.     super
  545.     update_menu_background
  546.     @help_window.update
  547.     @command_window.update
  548.     @gold_window.update
  549.     @buy_window.update
  550.     @sell_window.update
  551.     @number_window.update
  552.     if @command_window.active
  553.       update_command_selection
  554.     elsif @buy_window.active
  555.       update_buy_selection
  556.     elsif @sell_window.active
  557.       update_sell_selection
  558.     elsif @number_window.active
  559.       update_number_input
  560.     end
  561.   end
  562.   #--------------------------------------------------------------------------
  563.   # ● 創建命令窗口
  564.   #--------------------------------------------------------------------------
  565.   def create_command_window
  566.     s1 = Vocab::ShopBuy
  567.     s2 = Vocab::ShopSell
  568.     s3 = Vocab::ShopCancel
  569.     @command_window = Window_Command.new(384, [s1, s2, s3], 3)
  570.     @command_window.x = Graphics.width - @command_window.width
  571.     if $game_temp.shop_purchase_only
  572.       @command_window.draw_item(1, false)
  573.     end
  574.   end
  575.   #--------------------------------------------------------------------------
  576.   # ● 命令窗口釋放
  577.   #--------------------------------------------------------------------------
  578.   def dispose_command_window
  579.     @command_window.dispose
  580.   end
  581.   #--------------------------------------------------------------------------
  582.   # ● 命令列選擇的更新
  583.   #--------------------------------------------------------------------------
  584.   def update_command_selection
  585.     if Input.trigger?(Input::B)
  586.       Sound.play_cancel
  587.       $scene = Scene_Map.new
  588.       $game_switches[Miluko::SW_SBS] = false if $game_switches[Miluko::SW_SBS]
  589.     elsif Input.trigger?(Input::C)
  590.       case @command_window.index
  591.       when 0  # 購入する
  592.         Sound.play_decision
  593.         @command_window.active = false
  594.         @buy_window.active = true
  595.         @buy_window.visible = true
  596.         @buy_window.refresh
  597.         @buy_window.update_help
  598.       when 1  # 売卻する
  599.         if $game_temp.shop_purchase_only
  600.           Sound.play_buzzer
  601.         else
  602.           Sound.play_decision
  603.           @command_window.active = false
  604.           @sell_window.active = true
  605.           @sell_window.visible = true
  606.           @sell_window.refresh
  607.           @sell_window.update_help
  608.         end
  609.       when 2  # やめる
  610.         Sound.play_decision
  611.         $scene = Scene_Map.new
  612.         $game_switches[Miluko::SW_SBS] = false if $game_switches[Miluko::SW_SBS]
  613.       end
  614.     end
  615.   end
  616.   #--------------------------------------------------------------------------
  617.   # ● 購入物品選擇的更新
  618.   #--------------------------------------------------------------------------
  619.   def update_buy_selection
  620.     if Input.trigger?(Input::B)
  621.       Sound.play_cancel
  622.       @command_window.active = true
  623.       @buy_window.active = false
  624.       @buy_window.visible = false
  625.       @help_window.set_item(nil)
  626.       return
  627.     end
  628.     if Input.trigger?(Input::C)
  629.       @item = @buy_window.item
  630.       number = $game_party.item_number(@item)
  631.       if @item == nil or @item.price > $game_party.gold or number == 99
  632.         Sound.play_buzzer
  633.       elsif $game_switches[Miluko::SW_SBS]
  634.         if @item.is_a?(RPG::Item)
  635.           if Miluko::SHOP_BUY_SPECIAL[1].include?(@item.id)
  636.             for i in 0..Miluko::SHOP_BUY_SPECIAL[1].size
  637.               if @item.id == Miluko::SHOP_BUY_SPECIAL[1][i] && $shop_buy_special_item[i].to_i < Miluko::SHOP_BUY_SPECIAL_NUM[1][i]
  638.                 max = @item.price == 0 ? Miluko::SHOP_BUY_SPECIAL_NUM[1][i] : $game_party.gold / @item.price
  639.                 max = [max, Miluko::SHOP_BUY_SPECIAL_NUM[1][i] - $shop_buy_special_item[i].to_i].min
  640.                 Sound.play_decision
  641.                 @buy_window.active = false
  642.                 @buy_window.visible = false
  643.                 @number_window.set(@item, max, @item.price)
  644.                 @number_window.active = true
  645.                 @number_window.visible = true
  646.               elsif @item.id == Miluko::SHOP_BUY_SPECIAL[1][i] && $shop_buy_special_item[i].to_i >= Miluko::SHOP_BUY_SPECIAL_NUM[1][i]
  647.                 Sound.play_buzzer
  648.               end
  649.             end
  650.           else
  651.             max = @item.price == 0 ? 99 : $game_party.gold / @item.price
  652.             max = [max, 99 - number].min
  653.             Sound.play_decision
  654.             @buy_window.active = false
  655.             @buy_window.visible = false
  656.             @number_window.set(@item, max, @item.price)
  657.             @number_window.active = true
  658.             @number_window.visible = true
  659.           end
  660.         elsif @item.is_a?(RPG::Weapon)
  661.           if Miluko::SHOP_BUY_SPECIAL[2].include?(@item.id)
  662.             for i in 0..Miluko::SHOP_BUY_SPECIAL[2].size
  663.               if @item.id == Miluko::SHOP_BUY_SPECIAL[2][i] && $shop_buy_special_weapon[i].to_i < Miluko::SHOP_BUY_SPECIAL_NUM[2][i]
  664.                 max = @item.price == 0 ? Miluko::SHOP_BUY_SPECIAL_NUM[2][i] : $game_party.gold / @item.price
  665.                 max = [max, Miluko::SHOP_BUY_SPECIAL_NUM[2][i] - $shop_buy_special_weapon[i].to_i].min
  666.                 Sound.play_decision
  667.                 @buy_window.active = false
  668.                 @buy_window.visible = false
  669.                 @number_window.set(@item, max, @item.price)
  670.                 @number_window.active = true
  671.                 @number_window.visible = true
  672.               elsif @item.id == Miluko::SHOP_BUY_SPECIAL[2][i] && $shop_buy_special_weapon[i].to_i >= Miluko::SHOP_BUY_SPECIAL_NUM[2][i]
  673.                 Sound.play_buzzer
  674.               end
  675.             end
  676.           else
  677.             max = @item.price == 0 ? 99 : $game_party.gold / @item.price
  678.             max = [max, 99 - number].min
  679.             Sound.play_decision
  680.             @buy_window.active = false
  681.             @buy_window.visible = false
  682.             @number_window.set(@item, max, @item.price)
  683.             @number_window.active = true
  684.             @number_window.visible = true
  685.           end
  686.         elsif @item.is_a?(RPG::Armor)
  687.           if Miluko::SHOP_BUY_SPECIAL[3].include?(@item.id)
  688.             for i in 0..Miluko::SHOP_BUY_SPECIAL[3].size
  689.               if @item.id == Miluko::SHOP_BUY_SPECIAL[3][i] && $shop_buy_special_armor[i].to_i < Miluko::SHOP_BUY_SPECIAL_NUM[3][i]
  690.                 max = @item.price == 0 ? Miluko::SHOP_BUY_SPECIAL_NUM[3][i] : $game_party.gold / @item.price
  691.                 max = [max, Miluko::SHOP_BUY_SPECIAL_NUM[3][i] - $shop_buy_special_armor[i].to_i].min
  692.                 Sound.play_decision
  693.                 @buy_window.active = false
  694.                 @buy_window.visible = false
  695.                 @number_window.set(@item, max, @item.price)
  696.                 @number_window.active = true
  697.                 @number_window.visible = true
  698.               elsif @item.id == Miluko::SHOP_BUY_SPECIAL[3][i] && $shop_buy_special_armor[i].to_i >= Miluko::SHOP_BUY_SPECIAL_NUM[3][i]
  699.                 Sound.play_buzzer
  700.               end
  701.             end
  702.           else
  703.             max = @item.price == 0 ? 99 : $game_party.gold / @item.price
  704.             max = [max, 99 - number].min
  705.             Sound.play_decision
  706.             @buy_window.active = false
  707.             @buy_window.visible = false
  708.             @number_window.set(@item, max, @item.price)
  709.             @number_window.active = true
  710.             @number_window.visible = true
  711.           end
  712.         end
  713.       else
  714.         max = @item.price == 0 ? 99 : $game_party.gold / @item.price
  715.         max = [max, 99 - number].min
  716.         Sound.play_decision
  717.         @buy_window.active = false
  718.         @buy_window.visible = false
  719.         @number_window.set(@item, max, @item.price)
  720.         @number_window.active = true
  721.         @number_window.visible = true
  722.       end
  723.     end
  724.   end
  725.   #--------------------------------------------------------------------------
  726.   # ● 售出物品選擇的更新
  727.   #--------------------------------------------------------------------------
  728.   def update_sell_selection
  729.     if Input.trigger?(Input::B)
  730.       Sound.play_cancel
  731.       @command_window.active = true
  732.       @sell_window.active = false
  733.       @sell_window.visible = false
  734.       @help_window.set_item(nil)
  735.     elsif Input.trigger?(Input::C)
  736.       @item = @sell_window.item
  737.       if @item == nil or @item.price == 0
  738.         Sound.play_buzzer
  739.       else
  740.         Sound.play_decision
  741.         max = $game_party.item_number(@item)
  742.         @sell_window.active = false
  743.         @sell_window.visible = false
  744.         @number_window.set(@item, max, @item.price / 2)
  745.         @number_window.active = true
  746.         @number_window.visible = true
  747.       end
  748.     end
  749.   end
  750.   #--------------------------------------------------------------------------
  751.   # ● 買賣個數輸入更新
  752.   #--------------------------------------------------------------------------
  753.   def update_number_input
  754.     if Input.trigger?(Input::B)
  755.       cancel_number_input
  756.     elsif Input.trigger?(Input::C)
  757.       decide_number_input
  758.     end
  759.   end
  760.   #--------------------------------------------------------------------------
  761.   # ● 買賣個數輸入的取消
  762.   #--------------------------------------------------------------------------
  763.   def cancel_number_input
  764.     Sound.play_cancel
  765.     @number_window.active = false
  766.     @number_window.visible = false
  767.     case @command_window.index
  768.     when 0  # 購入する
  769.       @buy_window.active = true
  770.       @buy_window.visible = true
  771.     when 1  # 売卻する
  772.       @sell_window.active = true
  773.       @sell_window.visible = true
  774.     end
  775.   end
  776.   #--------------------------------------------------------------------------
  777.   # ● 買賣個數輸入的決定
  778.   #--------------------------------------------------------------------------
  779.   def decide_number_input
  780.     Sound.play_shop
  781.     @number_window.active = false
  782.     @number_window.visible = false
  783.     case @command_window.index
  784.     when 0  # 購入する
  785.       if $game_switches[Miluko::SW_SBS]
  786.         if @item.is_a?(RPG::Item)
  787.           for i in 0..Miluko::SHOP_BUY_SPECIAL[1].size
  788.             if @item.id == Miluko::SHOP_BUY_SPECIAL[1][i]
  789.               $shop_buy_special_item[i] = $shop_buy_special_item[i].to_i + @number_window.number
  790.             end
  791.           end
  792.         elsif @item.is_a?(RPG::Weapon)
  793.           for i in 0..Miluko::SHOP_BUY_SPECIAL[2].size
  794.             if @item.id == Miluko::SHOP_BUY_SPECIAL[2][i]
  795.               $shop_buy_special_weapon[i] = $shop_buy_special_weapon[i].to_i + @number_window.number
  796.             end
  797.           end
  798.         elsif @item.is_a?(RPG::Armor)
  799.           for i in 0..Miluko::SHOP_BUY_SPECIAL[3].size
  800.             if @item.id == Miluko::SHOP_BUY_SPECIAL[3][i]
  801.               $shop_buy_special_armor[i] = $shop_buy_special_armor[i].to_i + @number_window.number
  802.             end
  803.           end
  804.         end
  805.       end
  806.       $game_party.lose_gold(@number_window.number * @item.price)
  807.       $game_party.gain_item(@item, @number_window.number)
  808.       @gold_window.refresh
  809.       @buy_window.refresh
  810.       @buy_window.active = true
  811.       @buy_window.visible = true
  812.     when 1  # 売卻する
  813.       if $game_switches[Miluko::SW_SBS]
  814.         if @item.is_a?(RPG::Item)
  815.           for i in 0..Miluko::SHOP_BUY_SPECIAL[1].size
  816.             if @item.id == Miluko::SHOP_BUY_SPECIAL[1][i]
  817.               $shop_buy_special_item[i] -= @number_window.number
  818.             end
  819.           end
  820.         elsif @item.is_a?(RPG::Weapon)
  821.           for i in 0..Miluko::SHOP_BUY_SPECIAL[2].size
  822.             if @item.id == Miluko::SHOP_BUY_SPECIAL[2][i]
  823.               $shop_buy_special_weapon[i] -= @number_window.number
  824.             end
  825.           end
  826.         elsif @item.is_a?(RPG::Armor)
  827.           for i in 0..Miluko::SHOP_BUY_SPECIAL[3].size
  828.             if @item.id == Miluko::SHOP_BUY_SPECIAL[3][i]
  829.               $shop_buy_special_armor[i] -= @number_window.number
  830.             end
  831.           end
  832.         end
  833.       end
  834.       $game_party.gain_gold(@number_window.number * (@item.price / 2))
  835.       $game_party.lose_item(@item, @number_window.number)
  836.       @gold_window.refresh
  837.       @sell_window.refresh
  838.       @sell_window.active = true
  839.       @sell_window.visible = true
  840.     end
  841.   end
  842. end
复制代码
MS很長的腳本   其實大多數是前輩的腳本
我只是基於其基礎加強罷了
  1.   
  2. 設定方法大多寫在腳本開頭了
  3.   SW_SBS可設定開關  只在要開啟限量販售商店再打開即可
  4.   
  5. 限量道具的列表在這裡定義   1為道具   2為武器    3為防具
  6. 因為數據庫分開   所以不得不分開定義
  7. 若要1  3   5  6 四樣道具和11號武器以及3  4兩個防具為限量販售
  8. 便如下設定    兩兩之間需以逗號隔開
  9.   SHOP_BUY_SPECIAL = {
  10.   1 => [1,3,5,6],
  11.   2 => [11],
  12.   3 => [3,4],
  13.   }
  14.   
  15. 限量自然需要設定限制的數量
  16. 注意    此設定需將SHOP_BUY_SPECIAL互相對照
  17. SHOP_BUY_SPECIAL中定義幾樣道具   此設定便需定義幾個
  18. 依照上面的定義設定
  19.   SHOP_BUY_SPECIAL_NUM = {
  20.   1 => [10,5,7,3],           #1號道具只賣10個   3號道具賣5個   依此類推
  21.   2 => [1],                  #11號武器只賣1個
  22.   3 => [4,1],                #3號防具只賣4個    4號防具只賣1個
  23.   }
  24.   
  25. 商店道具可設定是否要自動再生   
  26. 例如藥水一次只能買10罐   買完需過一段時間才能再買
  27. 再生為全道具再生   只要是被設定為限量且未獨立設定成不可再生的道具便會再生
  28. 再生時最多只會再生至SHOP_BUY_SPECIAL_NUM設定的數量   也就是1號道具每次最多只能買10個
  29. 有三種模式   分別對應  0   1   2
  30. 0為不再生    1為依據時間經過再生    2為依據人物移動步數再生
  31.   SHOP_AUTO_REFRESH = 2
  32.   
  33. 當SHOP_AUTO_REFRESH為1時使用    單位為秒
  34. 以下設定便是每10秒會刷新1個道具
  35. 也就是經過50秒再去買便會刷新5個
  36.   SHOP_REFRESH_SEC = 10
  37.   
  38. 當SHOP_AUTO_REFRESH為2時使用  單位為人物行走步數
  39. 以下設定是每十步會刷新1次道具
  40. 走30步後再去買就是刷新3個
  41.   SHOP_REFRESH_STEP = 10
  42.   
  43. 當SHOP_AUTO_REFRESH設定為1或2時使用
  44. 列在數組內的道具將不具有回覆性  可藉此設定可自動再生和不可自動再生的物品
  45. 以範例而言  便是道具編號3號和武器編號11號這兩樣道具不可再生
  46. 而3號道具在前面設定為只能購買5個  因此此遊戲的商店便只會販賣5個3號道具
  47. 全部買完後  除非賣回給商店  否則商店便不再刷新該道具
  48.   SHOP_NOT_AUTOREFRESH = {
  49.   1 => [3],
  50.   2 => [11],
  51.   3 => [],
  52.   }
复制代码
大概是如此
目前測試結果是無錯(應該吧)
如果有啥錯誤麻煩回報一下
我會儘量修正的
新功能我也想不到啥了
所以這腳本應該就這樣吧
祝大家遊戲製作愉快!

發現做了蠢事   忘了發工程了~(汗)
Project2.rar (336.64 KB, 下载次数: 1003)

评分

参与人数 1+2 收起 理由
夕阳武士 + 2 原创鼓励

查看全部评分

Lv2.观梦者

花开堪折直须折

梦石
0
星屑
671
在线时间
943 小时
注册时间
2010-7-17
帖子
4963

贵宾

6
发表于 2010-12-5 14:20:30 | 只看该作者
为何迷路大系统变成繁体了的说....

点评

咦?我记得我是用简体版做的 我也不知咋回事了……  发表于 2010-12-6 21:27
大家好,我叫节操,有一天,我被吃了。
http://forever-dream.5d6d.com
永恒の梦制作组论坛

129993099
永恒の梦制作组QQ群
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1323
在线时间
831 小时
注册时间
2007-12-25
帖子
1558
5
发表于 2010-11-12 20:38:42 | 只看该作者
本帖最后由 九夜神尊 于 2010-11-12 20:54 编辑

献上思路一枚,不知道前辈是否愿意一试。
以一个空商店为(没有卖任何物品)的商店为开始标志标志。
其后所有的获得(失去)武器,防具,物品事件均为物品上架(下架)。
然后任然以空商店处理为结束标志。
这样设置你觉得怎么样呢?
如果要打开商店。至少要在商店里放一样东西(当然这完全可以通过放特殊物品脚本判断解决。)
商店中所包含的物品为无限物品。

如果为了灵活性更强,可以采用一个开关,当开关打开的时候,物品操作均为商品上下架。

点评

不过用得失物品判断似乎让使用者灵活性更大 我晚点再试著修改看看  发表于 2010-11-13 19:18
这是指说使用得失物品来判断限量物品回覆吗? 这也是一种回复方式 但我的想法是 物品卖回商店 相当於商店收购了该物品 所以自然就重新上架了  发表于 2010-11-13 19:17
精卫赤龙腾   
总是存在一种强大,去完成似乎不可能的事情.
无畏战乾程   
或是需要一种勇气,去挑战几乎不存在的胜利.
一味玄真魂     
这是拥有一种恒心,去化解根本没有解的困难.
烈卫开天径    
只是带着一种决心,去争取残存的最后的希望。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
55
在线时间
254 小时
注册时间
2010-3-21
帖子
334
4
发表于 2010-11-12 13:09:08 | 只看该作者
写的很不错,但你的范例是不是卖的有点贵了..

点评

⊙_⊙  发表于 2013-9-5 04:01
自由,是火一般的梦想。
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
14 小时
注册时间
2010-10-19
帖子
66
3
发表于 2010-11-11 18:26:17 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
518 小时
注册时间
2010-6-16
帖子
1073
2
发表于 2010-11-11 11:43:08 | 只看该作者
嗯嗯~好东西~希望迷路子能写出更多更好的脚本~
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-9-29 21:19

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表