Project1
标题:
限量贩售商店
[打印本页]
作者:
迷路子
时间:
2010-11-11 11:21
标题:
限量贩售商店
本帖最后由 迷路子 于 2010-11-12 15:25 编辑
早先就有這個想法了
只是之前一直沒有想到合適的寫法
昨天靈光閃現
花了一些時間終於寫出來了
而基於原本的內建商店畫面不是那麼的華麗
因此結合了億萬星辰前輩的個性化商店腳本
在其腳本上加入了我寫的限量商店腳本
因為限量販售載圖看不出來
就直接放代碼啦
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/ ◆ 限量商店物品腳本◆ VX ◆
#_/
#_/ ◇ 項目分類 : 商店強化
#_/ ◇ 項目版本 : 1.0.1111
#_/ ◇ 建立日期 : 2010/11/11
#_/ ◇ 最後更新 : 2010/11/11 ◇
#_/----------------------------------------------------------------------------
#_/ 腳本作者:迷路子
#_/ 結合腳本:個性化商店 作者:億萬星辰
#_/============================================================================
#_/ 【基本機能】
#_/ 1. 可設定道具、武器、防具的限量販售
#_/ 2. 可設定能隨著時間或步數增加而再生的商品
#_/ 3. 可分別設定可再生和不可再生的商品
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
module Miluko
#使用的開關編號
SW_SBS = 1
#哪些物品分別為限量
#1為item 2為weapon 3為armor
#[]中為物品在數據庫中的編號 以逗號為分隔
SHOP_BUY_SPECIAL = {
1 => [1,2,3,4],
2 => [1],
3 => [],
}
#物品限制的數量 分別對應至SHOP_BUY_SPECIAL中的物品
#以範例來說
#表示道具編號為1 2 3 4的四樣道具
#分別的限制購買數量為10 5 7 3
#當該道具的購買總量達到SHOP_BUY_SPECIAL_NUM中設定的數量時
#便不可繼續購買
#只有賣回給商店才能消除已購買的數量 賣回一個就可再購買一個
SHOP_BUY_SPECIAL_NUM = {
1 => [10,5,7,3],
2 => [1],
3 => [],
}
#商店道具是否可自動再生
#0為不自動再生 1為依據遊戲經過秒數自動再生 2為依據行走步數自動再生
#範例為2
SHOP_AUTO_REFRESH = 2
#商店道具回覆的時間
#當SHOP_AUTO_REFRESH為1時使用 單位為秒
SHOP_REFRESH_SEC = 10
#商店道具回覆的時間
#當SHOP_AUTO_REFRESH為2時使用 單位為人物行走步數
SHOP_REFRESH_STEP = 10
#當SHOP_AUTO_REFRESH設定為1或2時使用
#數組內的值為數據庫中的道具編號
#列在數組內的道具將不具有回覆性 可藉此設定可自動再生和不可自動再生的物品
#以範例而言 便是道具編號2號和武器編號1號這兩樣道具不可再生
#而2號道具在前面設定為只能購買5個 因此此遊戲的商店便只會販賣5個2號道具
#當全部買完後 除非賣回給商店 否則商店便不再刷新該道具
SHOP_NOT_AUTOREFRESH = {
1 => [2],
2 => [1],
3 => [],
}
end
#==============================================================================
# ■ Scene_Title
#------------------------------------------------------------------------------
# 標題菜單。
#==============================================================================
class Scene_Title < Scene_Base
#--------------------------------------------------------------------------
# ● 新遊戲開始時設定
#--------------------------------------------------------------------------
def command_new_game
confirm_player_location
Sound.play_decision
$game_party.setup_starting_members
$game_map.setup($data_system.start_map_id)
$game_player.moveto($data_system.start_x, $data_system.start_y)
$game_player.refresh
$shop_buy_special_item = []
$shop_buy_special_weapon = []
$shop_buy_special_armor = []
$shop_sec = 0
$shop_step = 0
$scene = Scene_Map.new
RPG::BGM.fade(1500)
close_command_window
Graphics.fadeout(60)
Graphics.wait(40)
Graphics.frame_count = 0
RPG::BGM.stop
$game_map.autoplay
end
end
#==============================================================================
# ■ Scene_File
#------------------------------------------------------------------------------
# 存讀檔。
#==============================================================================
class Scene_File < Scene_Base
#--------------------------------------------------------------------------
# ● 存檔時將變數儲存
#--------------------------------------------------------------------------
def write_save_data(file)
characters = []
for actor in $game_party.members
characters.push([actor.character_name, actor.character_index])
end
$game_system.save_count += 1
$game_system.version_id = $data_system.version_id
@last_bgm = RPG::BGM::last
@last_bgs = RPG::BGS::last
Marshal.dump(characters, file)
Marshal.dump(Graphics.frame_count, file)
Marshal.dump(@last_bgm, file)
Marshal.dump(@last_bgs, file)
Marshal.dump($game_system, file)
Marshal.dump($game_message, file)
Marshal.dump($game_switches, file)
Marshal.dump($game_variables, file)
Marshal.dump($game_self_switches, file)
Marshal.dump($game_actors, file)
Marshal.dump($game_party, file)
Marshal.dump($game_troop, file)
Marshal.dump($game_map, file)
Marshal.dump($game_player, file)
Marshal.dump($shop_buy_special_item, file)
Marshal.dump($shop_buy_special_weapon,file)
Marshal.dump($shop_buy_special_armor, file)
Marshal.dump($shop_sec, file)
Marshal.dump($shop_step, file)
end
#--------------------------------------------------------------------------
# ● 讀檔時將變數讀出
#--------------------------------------------------------------------------
def read_save_data(file)
characters = Marshal.load(file)
Graphics.frame_count = Marshal.load(file)
@last_bgm = Marshal.load(file)
@last_bgs = Marshal.load(file)
$game_system = Marshal.load(file)
$game_message = Marshal.load(file)
$game_switches = Marshal.load(file)
$game_variables = Marshal.load(file)
$game_self_switches = Marshal.load(file)
$game_actors = Marshal.load(file)
$game_party = Marshal.load(file)
$game_troop = Marshal.load(file)
$game_map = Marshal.load(file)
$game_player = Marshal.load(file)
$shop_buy_special_item = Marshal.load(file)
$shop_buy_special_weapon = Marshal.load(file)
$shop_buy_special_armor = Marshal.load(file)
$shop_sec = Marshal.load(file)
$shop_step = Marshal.load(file)
if $game_system.version_id != $data_system.version_id
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
end
end
end
#==============================================================================
# ■ Window_ShopBuy
#------------------------------------------------------------------------------
# 購買窗口。
#==============================================================================
class Window_ShopBuy < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化
# x : X 坐標
# y : Y 坐標
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, 384, 256)
@shop_goods = $game_temp.shop_goods
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● 幫助文字更新
#--------------------------------------------------------------------------
def update_help
@help_window.set_item(item)
end
#--------------------------------------------------------------------------
# ● 顯示商店販售物品
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
number = $game_party.item_number(item)
enabled = (item.price <= $game_party.gold and number < 99)
if $game_switches[Miluko::SW_SBS]
if item.is_a?(RPG::Item)
for i in 0..Miluko::SHOP_BUY_SPECIAL.size
if item.id == Miluko::SHOP_BUY_SPECIAL[1][i] && $shop_buy_special_item[i].to_i < Miluko::SHOP_BUY_SPECIAL_NUM[1][i]
enabled = true
elsif item.id == Miluko::SHOP_BUY_SPECIAL[1][i] && $shop_buy_special_item[i].to_i >= Miluko::SHOP_BUY_SPECIAL_NUM[1][i]
enabled = false
end
end
elsif item.is_a?(RPG::Weapon)
for i in 0..Miluko::SHOP_BUY_SPECIAL.size
if item.id == Miluko::SHOP_BUY_SPECIAL[2][i] && $shop_buy_special_weapon[i].to_i < Miluko::SHOP_BUY_SPECIAL_NUM[2][i]
enabled = true
elsif item.id == Miluko::SHOP_BUY_SPECIAL[2][i] && $shop_buy_special_weapon[i].to_i >= Miluko::SHOP_BUY_SPECIAL_NUM[2][i]
enabled = false
end
end
elsif item.is_a?(RPG::Item)
for i in 0..Miluko::SHOP_BUY_SPECIAL.size
if item.id == Miluko::SHOP_BUY_SPECIAL[3][i] && $shop_buy_special_armor[i].to_i < Miluko::SHOP_BUY_SPECIAL_NUM[3][i]
enabled = true
elsif item.id == Miluko::SHOP_BUY_SPECIAL[3][i] && $shop_buy_special_armor[i].to_i >= Miluko::SHOP_BUY_SPECIAL_NUM[3][i]
enabled = false
end
end
end
end
rect = item_rect(index)
self.contents.clear_rect(rect)
draw_item_name(item, rect.x, rect.y, enabled)
rect.width -= 4
self.contents.draw_text(rect, item.price, 2)
end
end
#==============================================================================
# ■ Window_ShopSell
#------------------------------------------------------------------------------
# 出售窗口。
#==============================================================================
class Window_ShopSell < Window_Item
#--------------------------------------------------------------------------
# ● 初始化
# x : X 坐標
# y : Y 坐標
# width : 窗口寬度
# height : 窗口高度
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super(x, y, width, height)
@column_max = 1
end
#--------------------------------------------------------------------------
# ● 幫助文字更新
#--------------------------------------------------------------------------
def update_help
@help_window.set_item(item)
end
end
#==============================================================================
# ■ Window_ShopNumber
#------------------------------------------------------------------------------
# 買賣輸入個數窗口。
#==============================================================================
class Window_ShopNumber < Window_Base
#--------------------------------------------------------------------------
# ● 初始化
# x : 窗口 X 坐標
# y : 窗口 Y 坐標
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, 384, 256)
@item = nil
@max = 1
@price = 0
@number = 1
end
end
#==============================================================================
# ■ Window_ShopHelp
#------------------------------------------------------------------------------
# 商店說明。
#==============================================================================
class Window_ShopHelp < Window_Base
#--------------------------------------------------------------------------
# ● 初始化
#--------------------------------------------------------------------------
def initialize
super(0, 312, 544, 104)
end
#--------------------------------------------------------------------------
# ● 文字設定
# item : 物品
#--------------------------------------------------------------------------
def set_item(item)
if item.nil?
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(0, 0, 512, 24, $game_temp.shop_word)
@item = nil
return
end
if item != @item
@item = item
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(0, 0, 512, 24, @item.description)
if @item.is_a?(RPG::Item)
# 物品範圍描述
scope = "[對象] : "
case @item.scope
when 0; scope += "無"
when 1; scope += "敵單體"
when 2; scope += "敵全體"
when 3; scope += "敵單體 連續"
when 4; scope += "敵單體 隨機"
when 5; scope += "敵二體 隨機"
when 6; scope += "敵三體 隨機"
when 7; scope += "我方單體"
when 8; scope += "我方全體"
when 9; scope += "我方單體 (陣亡)"
when 10; scope += "我方全體 (陣亡)"
when 11; scope += "使用者"
end
self.contents.draw_text(0, 24, 512, 24, scope)
# 物品範圍描述結束
# 物品恢復效果描述
effection = "[效果] : "
if @item.hp_recovery_rate > 0
effection += "#{Vocab.hp}+#{@item.hp_recovery_rate}% "
elsif @item.hp_recovery_rate < 0
effection += "#{Vocab.hp}-#{@item.hp_recovery_rate}% "
elsif @item.hp_recovery > 0
effection += "#{Vocab.hp}+#{@item.hp_recovery} "
elsif @item.hp_recovery < 0
effection += "#{Vocab.hp}-#{@item.hp_recovery} "
end
if @item.mp_recovery_rate > 0
effection += "#{Vocab.mp}+#{@item.mp_recovery_rate}% "
elsif @item.mp_recovery_rate < 0
effection += "#{Vocab.mp}-#{@item.mp_recovery_rate}% "
elsif @item.mp_recovery > 0
effection += "#{Vocab.mp}+#{@item.mp_recovery} "
elsif @item.mp_recovery < 0
effection += "#{Vocab.mp}-#{@item.mp_recovery} "
end
effection += "傷害#{@item.base_damage} " if @item.base_damage != 0
case @item.parameter_type
when 1
effection += "最大#{Vocab.hp}+#{@item.parameter_points}"
when 2
effection += "最大#{Vocab.mp}+#{@item.parameter_points}"
when 3
effection += "#{Vocab.atk}+#{@item.parameter_points}"
when 4
effection += "#{Vocab.def}+#{@item.parameter_points}"
when 5
effection += "#{Vocab.spi}+#{@item.parameter_points}"
when 6
effection += "#{Vocab.agi}+#{@item.parameter_points}"
end
self.contents.draw_text(0, 48, 512, 24, effection)
# 物品恢復效果描述結束
else
# 武器防具可裝備人員描述
equip = "[可裝備] : "
for actor in $game_party.members
if actor.equippable?(@item)
equip += "、" if equip != "[可裝備] : "
equip += actor.name
end
end
equip += "無" if equip == "[可裝備] : "
self.contents.draw_text(0, 24, 512, 24, equip)
# 武器防具可裝備人員描述結束
# 武器防具攻防增減描述
effection = "[屬性] : "
if @item.atk != 0
effection += "攻擊力+#{@item.atk} "
end
if @item.def != 0
effection += "防禦力+#{@item.def} "
end
if @item.spi != 0
effection += "精神力+#{@item.spi} "
end
if @item.agi != 0
effection += "敏捷性+#{@item.agi} "
end
# 武器防具攻防增減描述結束
if @item.is_a?(RPG::Armor)
# 防具特殊屬性描述
if @item.prevent_critical
effection += "防止會心一擊 "
end
if @item.half_mp_cost
effection += "消費MP減半 "
end
if @item.double_exp_gain
effection += "雙倍經驗 "
end
if @item.auto_hp_recover
effection += "自動恢復HP "
end
# 防具特殊屬性描述結束
else
# 武器特殊屬性描述
if @item.two_handed
effection += "雙手持 "
end
if @item.fast_attack
effection += "先發制人 "
end
if @item.dual_attack
effection += "連擊 "
end
if @item.critical_bonus
effection += "頻發會心一擊 "
end
# 武器特殊屬性描述結束
end
unless @item.element_set.empty?
# 武器防具屬性描述(左邊那一欄需要打勾的)
effection += @item.is_a?(RPG::Armor) ? " [防具狀態] : " : " [武器屬性] : "
for state in @item.element_set
effection += $data_system.elements[state] + " "
end
# 武器防具屬性描述結束
end
unless @item.state_set.empty?
# 武器防具狀態描述(右邊那一欄需要打勾的)
effection += @item.is_a?(RPG::Armor) ? " [無效化屬性] : " : " [附加狀態] : "
for state in @item.state_set
effection += $data_states[state].name + " "
end
# 武器防具狀態描述結束
end
self.contents.draw_text(0, 48, 512, 24, effection)
end
end
end
end
class Game_Temp
attr_accessor :shop_name
attr_accessor :shop_word
attr_accessor :shop_mm
alias old_ini initialize
def initialize
old_ini
@shop_name = ""
@shop_word = ""
@shop_mm = ""
end
end
#==============================================================================
# ■ Scene_Shop
#------------------------------------------------------------------------------
# 商店畫面的處理。
#==============================================================================
class Scene_Shop < Scene_Base
#--------------------------------------------------------------------------
# ● 開始
#--------------------------------------------------------------------------
def start
super
create_menu_background
create_command_window
@help_window = Window_ShopHelp.new
@gold_window = Window_Gold.new(384, 56)
@title_window = Window_Base.new(0, 0, @command_window.x, 56)
@title_window.contents.draw_text(0, 0, @title_window.width - 32, 24, $game_temp.shop_name)
@buy_window = Window_ShopBuy.new(0, 56)
@buy_window.active = false
@buy_window.visible = false
@buy_window.help_window = @help_window
@sell_window = Window_ShopSell.new(0, 56, 384, 256)
@sell_window.active = false
@sell_window.visible = false
@sell_window.help_window = @help_window
@number_window = Window_ShopNumber.new(0, 56)
@number_window.active = false
@number_window.visible = false
@loli_sprite = Sprite.new
@loli_sprite.x = 384
@loli_sprite.y = 112
@loli_sprite.bitmap = Cache.picture($game_temp.shop_mm)
@help_window.set_item(nil)
if Miluko::SHOP_AUTO_REFRESH == 1
@total_sec = Graphics.frame_count / Graphics.frame_rate
if $shop_sec != 0 && @total_sec - $shop_sec > Miluko::SHOP_REFRESH_SEC
for i in 1..Miluko::SHOP_BUY_SPECIAL.size
for j in 0..Miluko::SHOP_BUY_SPECIAL[i].size
if i == 1 && $shop_buy_special_item[j].to_i > 0 && !Miluko::SHOP_NOT_AUTOREFRESH[1].include?(@item.id)
$shop_buy_special_item[j] -= (@total_sec - $shop_sec)/Miluko::SHOP_REFRESH_SEC
$shop_buy_special_item[j] = 0 if $shop_buy_special_item[j] < 0
elsif i == 2 && $shop_buy_special_weapon[j].to_i > 0 && !Miluko::SHOP_NOT_AUTOREFRESH[2].include?(@item.id)
$shop_buy_special_weapon[j] -= (@total_sec - $shop_sec)/Miluko::SHOP_REFRESH_SEC
$shop_buy_special_item[j] = 0 if $shop_buy_special_item[j] < 0
elsif i == 3 && $shop_buy_special_armor[j].to_i > 0 && !Miluko::SHOP_NOT_AUTOREFRESH[3].include?(@item.id)
$shop_buy_special_armor[j] -= (@total_sec - $shop_sec)/Miluko::SHOP_REFRESH_SEC
$shop_buy_special_item[j] = 0 if $shop_buy_special_item[j] < 0
end
end
end
end
elsif Miluko::SHOP_AUTO_REFRESH == 2
@total_step = $game_party.steps
if $shop_step != 0 && @total_step - $shop_step > Miluko::SHOP_REFRESH_STEP
for i in 1..Miluko::SHOP_BUY_SPECIAL.size
for j in 0..Miluko::SHOP_BUY_SPECIAL[i].size
if i == 1 && $shop_buy_special_item[j].to_i > 0 && !Miluko::SHOP_NOT_AUTOREFRESH[1].include?(Miluko::SHOP_BUY_SPECIAL[i][j])
$shop_buy_special_item[j] -= (@total_step - $shop_step)/Miluko::SHOP_REFRESH_STEP
$shop_buy_special_item[j] = 0 if $shop_buy_special_item[j] < 0
elsif i == 2 && $shop_buy_special_weapon[j].to_i > 0 && !Miluko::SHOP_NOT_AUTOREFRESH[2].include?(Miluko::SHOP_BUY_SPECIAL[i][j])
$shop_buy_special_weapon[j] -= (@total_step - $shop_step)/Miluko::SHOP_REFRESH_STEP
$shop_buy_special_item[j] = 0 if $shop_buy_special_item[j] < 0
elsif i == 3 && $shop_buy_special_armor[j].to_i > 0 && !Miluko::SHOP_NOT_AUTOREFRESH[3].include?(Miluko::SHOP_BUY_SPECIAL[i][j])
$shop_buy_special_armor[j] -= (@total_step - $shop_step)/Miluko::SHOP_REFRESH_STEP
$shop_buy_special_item[j] = 0 if $shop_buy_special_item[j] < 0
end
end
end
end
end
end
#--------------------------------------------------------------------------
# ● 結束處理
#--------------------------------------------------------------------------
def terminate
super
dispose_menu_background
dispose_command_window
@help_window.dispose
@gold_window.dispose
@title_window.dispose
@buy_window.dispose
@sell_window.dispose
@number_window.dispose
@loli_sprite.bitmap.dispose
@loli_sprite.dispose
$shop_sec = @total_sec if Miluko::SHOP_AUTO_REFRESH == 1 && @total_sec - $shop_sec > Miluko::SHOP_REFRESH_SEC
$shop_step = @total_step if Miluko::SHOP_AUTO_REFRESH == 2 && @total_step - $shop_step > Miluko::SHOP_REFRESH_STEP
end
#--------------------------------------------------------------------------
# ● 畫面更新
#--------------------------------------------------------------------------
def update
super
update_menu_background
@help_window.update
@command_window.update
@gold_window.update
@buy_window.update
@sell_window.update
@number_window.update
if @command_window.active
update_command_selection
elsif @buy_window.active
update_buy_selection
elsif @sell_window.active
update_sell_selection
elsif @number_window.active
update_number_input
end
end
#--------------------------------------------------------------------------
# ● 創建命令窗口
#--------------------------------------------------------------------------
def create_command_window
s1 = Vocab::ShopBuy
s2 = Vocab::ShopSell
s3 = Vocab::ShopCancel
@command_window = Window_Command.new(384, [s1, s2, s3], 3)
@command_window.x = Graphics.width - @command_window.width
if $game_temp.shop_purchase_only
@command_window.draw_item(1, false)
end
end
#--------------------------------------------------------------------------
# ● 命令窗口釋放
#--------------------------------------------------------------------------
def dispose_command_window
@command_window.dispose
end
#--------------------------------------------------------------------------
# ● 命令列選擇的更新
#--------------------------------------------------------------------------
def update_command_selection
if Input.trigger?(Input::B)
Sound.play_cancel
$scene = Scene_Map.new
$game_switches[Miluko::SW_SBS] = false if $game_switches[Miluko::SW_SBS]
elsif Input.trigger?(Input::C)
case @command_window.index
when 0 # 購入する
Sound.play_decision
@command_window.active = false
@buy_window.active = true
@buy_window.visible = true
@buy_window.refresh
@buy_window.update_help
when 1 # 売卻する
if $game_temp.shop_purchase_only
Sound.play_buzzer
else
Sound.play_decision
@command_window.active = false
@sell_window.active = true
@sell_window.visible = true
@sell_window.refresh
@sell_window.update_help
end
when 2 # やめる
Sound.play_decision
$scene = Scene_Map.new
$game_switches[Miluko::SW_SBS] = false if $game_switches[Miluko::SW_SBS]
end
end
end
#--------------------------------------------------------------------------
# ● 購入物品選擇的更新
#--------------------------------------------------------------------------
def update_buy_selection
if Input.trigger?(Input::B)
Sound.play_cancel
@command_window.active = true
@buy_window.active = false
@buy_window.visible = false
@help_window.set_item(nil)
return
end
if Input.trigger?(Input::C)
@item = @buy_window.item
number = $game_party.item_number(@item)
if @item == nil or @item.price > $game_party.gold or number == 99
Sound.play_buzzer
elsif $game_switches[Miluko::SW_SBS]
if @item.is_a?(RPG::Item)
if Miluko::SHOP_BUY_SPECIAL[1].include?(@item.id)
for i in 0..Miluko::SHOP_BUY_SPECIAL[1].size
if @item.id == Miluko::SHOP_BUY_SPECIAL[1][i] && $shop_buy_special_item[i].to_i < Miluko::SHOP_BUY_SPECIAL_NUM[1][i]
max = @item.price == 0 ? Miluko::SHOP_BUY_SPECIAL_NUM[1][i] : $game_party.gold / @item.price
max = [max, Miluko::SHOP_BUY_SPECIAL_NUM[1][i] - $shop_buy_special_item[i].to_i].min
Sound.play_decision
@buy_window.active = false
@buy_window.visible = false
@number_window.set(@item, max, @item.price)
@number_window.active = true
@number_window.visible = true
elsif @item.id == Miluko::SHOP_BUY_SPECIAL[1][i] && $shop_buy_special_item[i].to_i >= Miluko::SHOP_BUY_SPECIAL_NUM[1][i]
Sound.play_buzzer
end
end
else
max = @item.price == 0 ? 99 : $game_party.gold / @item.price
max = [max, 99 - number].min
Sound.play_decision
@buy_window.active = false
@buy_window.visible = false
@number_window.set(@item, max, @item.price)
@number_window.active = true
@number_window.visible = true
end
elsif @item.is_a?(RPG::Weapon)
if Miluko::SHOP_BUY_SPECIAL[2].include?(@item.id)
for i in 0..Miluko::SHOP_BUY_SPECIAL[2].size
if @item.id == Miluko::SHOP_BUY_SPECIAL[2][i] && $shop_buy_special_weapon[i].to_i < Miluko::SHOP_BUY_SPECIAL_NUM[2][i]
max = @item.price == 0 ? Miluko::SHOP_BUY_SPECIAL_NUM[2][i] : $game_party.gold / @item.price
max = [max, Miluko::SHOP_BUY_SPECIAL_NUM[2][i] - $shop_buy_special_weapon[i].to_i].min
Sound.play_decision
@buy_window.active = false
@buy_window.visible = false
@number_window.set(@item, max, @item.price)
@number_window.active = true
@number_window.visible = true
elsif @item.id == Miluko::SHOP_BUY_SPECIAL[2][i] && $shop_buy_special_weapon[i].to_i >= Miluko::SHOP_BUY_SPECIAL_NUM[2][i]
Sound.play_buzzer
end
end
else
max = @item.price == 0 ? 99 : $game_party.gold / @item.price
max = [max, 99 - number].min
Sound.play_decision
@buy_window.active = false
@buy_window.visible = false
@number_window.set(@item, max, @item.price)
@number_window.active = true
@number_window.visible = true
end
elsif @item.is_a?(RPG::Armor)
if Miluko::SHOP_BUY_SPECIAL[3].include?(@item.id)
for i in 0..Miluko::SHOP_BUY_SPECIAL[3].size
if @item.id == Miluko::SHOP_BUY_SPECIAL[3][i] && $shop_buy_special_armor[i].to_i < Miluko::SHOP_BUY_SPECIAL_NUM[3][i]
max = @item.price == 0 ? Miluko::SHOP_BUY_SPECIAL_NUM[3][i] : $game_party.gold / @item.price
max = [max, Miluko::SHOP_BUY_SPECIAL_NUM[3][i] - $shop_buy_special_armor[i].to_i].min
Sound.play_decision
@buy_window.active = false
@buy_window.visible = false
@number_window.set(@item, max, @item.price)
@number_window.active = true
@number_window.visible = true
elsif @item.id == Miluko::SHOP_BUY_SPECIAL[3][i] && $shop_buy_special_armor[i].to_i >= Miluko::SHOP_BUY_SPECIAL_NUM[3][i]
Sound.play_buzzer
end
end
else
max = @item.price == 0 ? 99 : $game_party.gold / @item.price
max = [max, 99 - number].min
Sound.play_decision
@buy_window.active = false
@buy_window.visible = false
@number_window.set(@item, max, @item.price)
@number_window.active = true
@number_window.visible = true
end
end
else
max = @item.price == 0 ? 99 : $game_party.gold / @item.price
max = [max, 99 - number].min
Sound.play_decision
@buy_window.active = false
@buy_window.visible = false
@number_window.set(@item, max, @item.price)
@number_window.active = true
@number_window.visible = true
end
end
end
#--------------------------------------------------------------------------
# ● 售出物品選擇的更新
#--------------------------------------------------------------------------
def update_sell_selection
if Input.trigger?(Input::B)
Sound.play_cancel
@command_window.active = true
@sell_window.active = false
@sell_window.visible = false
@help_window.set_item(nil)
elsif Input.trigger?(Input::C)
@item = @sell_window.item
if @item == nil or @item.price == 0
Sound.play_buzzer
else
Sound.play_decision
max = $game_party.item_number(@item)
@sell_window.active = false
@sell_window.visible = false
@number_window.set(@item, max, @item.price / 2)
@number_window.active = true
@number_window.visible = true
end
end
end
#--------------------------------------------------------------------------
# ● 買賣個數輸入更新
#--------------------------------------------------------------------------
def update_number_input
if Input.trigger?(Input::B)
cancel_number_input
elsif Input.trigger?(Input::C)
decide_number_input
end
end
#--------------------------------------------------------------------------
# ● 買賣個數輸入的取消
#--------------------------------------------------------------------------
def cancel_number_input
Sound.play_cancel
@number_window.active = false
@number_window.visible = false
case @command_window.index
when 0 # 購入する
@buy_window.active = true
@buy_window.visible = true
when 1 # 売卻する
@sell_window.active = true
@sell_window.visible = true
end
end
#--------------------------------------------------------------------------
# ● 買賣個數輸入的決定
#--------------------------------------------------------------------------
def decide_number_input
Sound.play_shop
@number_window.active = false
@number_window.visible = false
case @command_window.index
when 0 # 購入する
if $game_switches[Miluko::SW_SBS]
if @item.is_a?(RPG::Item)
for i in 0..Miluko::SHOP_BUY_SPECIAL[1].size
if @item.id == Miluko::SHOP_BUY_SPECIAL[1][i]
$shop_buy_special_item[i] = $shop_buy_special_item[i].to_i + @number_window.number
end
end
elsif @item.is_a?(RPG::Weapon)
for i in 0..Miluko::SHOP_BUY_SPECIAL[2].size
if @item.id == Miluko::SHOP_BUY_SPECIAL[2][i]
$shop_buy_special_weapon[i] = $shop_buy_special_weapon[i].to_i + @number_window.number
end
end
elsif @item.is_a?(RPG::Armor)
for i in 0..Miluko::SHOP_BUY_SPECIAL[3].size
if @item.id == Miluko::SHOP_BUY_SPECIAL[3][i]
$shop_buy_special_armor[i] = $shop_buy_special_armor[i].to_i + @number_window.number
end
end
end
end
$game_party.lose_gold(@number_window.number * @item.price)
$game_party.gain_item(@item, @number_window.number)
@gold_window.refresh
@buy_window.refresh
@buy_window.active = true
@buy_window.visible = true
when 1 # 売卻する
if $game_switches[Miluko::SW_SBS]
if @item.is_a?(RPG::Item)
for i in 0..Miluko::SHOP_BUY_SPECIAL[1].size
if @item.id == Miluko::SHOP_BUY_SPECIAL[1][i]
$shop_buy_special_item[i] -= @number_window.number
end
end
elsif @item.is_a?(RPG::Weapon)
for i in 0..Miluko::SHOP_BUY_SPECIAL[2].size
if @item.id == Miluko::SHOP_BUY_SPECIAL[2][i]
$shop_buy_special_weapon[i] -= @number_window.number
end
end
elsif @item.is_a?(RPG::Armor)
for i in 0..Miluko::SHOP_BUY_SPECIAL[3].size
if @item.id == Miluko::SHOP_BUY_SPECIAL[3][i]
$shop_buy_special_armor[i] -= @number_window.number
end
end
end
end
$game_party.gain_gold(@number_window.number * (@item.price / 2))
$game_party.lose_item(@item, @number_window.number)
@gold_window.refresh
@sell_window.refresh
@sell_window.active = true
@sell_window.visible = true
end
end
end
复制代码
MS很長的腳本 其實大多數是前輩的腳本
我只是基於其基礎加強罷了
設定方法大多寫在腳本開頭了
SW_SBS可設定開關 只在要開啟限量販售商店再打開即可
限量道具的列表在這裡定義 1為道具 2為武器 3為防具
因為數據庫分開 所以不得不分開定義
若要1 3 5 6 四樣道具和11號武器以及3 4兩個防具為限量販售
便如下設定 兩兩之間需以逗號隔開
SHOP_BUY_SPECIAL = {
1 => [1,3,5,6],
2 => [11],
3 => [3,4],
}
限量自然需要設定限制的數量
注意 此設定需將SHOP_BUY_SPECIAL互相對照
SHOP_BUY_SPECIAL中定義幾樣道具 此設定便需定義幾個
依照上面的定義設定
SHOP_BUY_SPECIAL_NUM = {
1 => [10,5,7,3], #1號道具只賣10個 3號道具賣5個 依此類推
2 => [1], #11號武器只賣1個
3 => [4,1], #3號防具只賣4個 4號防具只賣1個
}
商店道具可設定是否要自動再生
例如藥水一次只能買10罐 買完需過一段時間才能再買
再生為全道具再生 只要是被設定為限量且未獨立設定成不可再生的道具便會再生
再生時最多只會再生至SHOP_BUY_SPECIAL_NUM設定的數量 也就是1號道具每次最多只能買10個
有三種模式 分別對應 0 1 2
0為不再生 1為依據時間經過再生 2為依據人物移動步數再生
SHOP_AUTO_REFRESH = 2
當SHOP_AUTO_REFRESH為1時使用 單位為秒
以下設定便是每10秒會刷新1個道具
也就是經過50秒再去買便會刷新5個
SHOP_REFRESH_SEC = 10
當SHOP_AUTO_REFRESH為2時使用 單位為人物行走步數
以下設定是每十步會刷新1次道具
走30步後再去買就是刷新3個
SHOP_REFRESH_STEP = 10
當SHOP_AUTO_REFRESH設定為1或2時使用
列在數組內的道具將不具有回覆性 可藉此設定可自動再生和不可自動再生的物品
以範例而言 便是道具編號3號和武器編號11號這兩樣道具不可再生
而3號道具在前面設定為只能購買5個 因此此遊戲的商店便只會販賣5個3號道具
全部買完後 除非賣回給商店 否則商店便不再刷新該道具
SHOP_NOT_AUTOREFRESH = {
1 => [3],
2 => [11],
3 => [],
}
复制代码
大概是如此
目前測試結果是無錯(應該吧)
如果有啥錯誤麻煩回報一下
我會儘量修正的
新功能我也想不到啥了
所以這腳本應該就這樣吧
祝大家遊戲製作愉快!
發現做了蠢事 忘了發工程了~(汗)
Project2.rar
(336.64 KB, 下载次数: 1003)
2010-11-11 11:27 上传
点击文件名下载附件
作者:
Rion幻音
时间:
2010-11-11 11:43
嗯嗯~好东西~希望迷路子能写出更多更好的脚本~
作者:
ka66rpg
时间:
2010-11-11 18:26
提示:
作者被禁止或删除 内容自动屏蔽
作者:
y3333269
时间:
2010-11-12 13:09
写的很不错,但你的范例是不是卖的有点贵了..
作者:
九夜神尊
时间:
2010-11-12 20:38
本帖最后由 九夜神尊 于 2010-11-12 20:54 编辑
献上思路一枚,不知道前辈是否愿意一试。
以一个空商店为(没有卖任何物品)的商店为开始标志标志。
其后所有的获得(失去)武器,防具,物品事件均为物品上架(下架)。
然后任然以空商店处理为结束标志。
这样设置你觉得怎么样呢?
如果要打开商店。至少要在商店里放一样东西(当然这完全可以通过放特殊物品脚本判断解决。)
商店中所包含的物品为无限物品。
如果为了灵活性更强,可以采用一个开关,当开关打开的时候,物品操作均为商品上下架。
作者:
冰舞蝶恋
时间:
2010-12-5 14:20
为何迷路大系统变成繁体了的说....
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1