加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 radiational 于 2013-12-31 01:29 编辑
在這個腳本中
無法添加D以上禮物組
有辦法擴大嗎
=begin 說明: 事件中執行腳本呼叫來獲取隨機物品 random_gift(group, number) 例:隨機獲得組:A中的三件物品: random_gift(:A, 3) =end class Game_Interpreter Random_Gifts = { #隨機獎品列表 :A => [:i1, :i2, :i3, :w1, :w2, :a1, :a3], #i物品,w武器,每個組用逗號隔開 :B => [:i1_10, :w1_12, :a5_9], #這樣代表物品1~10,武器1~12,護甲5~9 :C => [:w1_60] } # 設置開關號碼,當開關開啟時一定會獲取到不同的幾件物品 # 設置為 nil 的話則總是有可能獲取到相同的物品 Diff_Gift_Swth = 1 def display_gift_text(name) $game_message.add("獲得:" + name) end # def random_gift(group, num) gifts = [] Random_Gifts[group].each {|g| g = g.to_s type = g[0]=="i" ? 0 : g[0]=="w" ? 1 : 2 if g.include?("_") a, b = g.scan(/\d+/) for i in a.to_i..b.to_i gift = which_random_gift(type)[i] gift ? gifts.push(gift) : (return report_random_gifts_crash(group, g)) end else g =~ /(\d+)/ gift = which_random_gift(type)[$1.to_i] gift ? gifts.push(gift) : (return report_random_gifts_crash(group, g)) end } wait_for_message if Diff_Gift_Swth && $game_switches[Diff_Gift_Swth] gifts.sample(num).each {|g| $game_party.gain_item(g, 1) display_gift_text(g.name) } else num.times { g = gifts[rand(gifts.size)] $game_party.gain_item(g, 1) display_gift_text(g.name) } end $game_message.face_name = '' $game_message.face_index = 0 $game_message.background = 0 $game_message.position = 2 wait_for_message end # def which_random_gift(type) case type when 0; $data_items when 1; $data_weapons when 2; $data_armors end end # def report_random_gifts_crash(group, g) msgbox("隨機禮物發生錯誤:Group :#{group} Element :#{g}") if $TEST end end
=begin
說明:
事件中執行腳本呼叫來獲取隨機物品
random_gift(group, number)
例:隨機獲得組:A中的三件物品: random_gift(:A, 3)
=end
class Game_Interpreter
Random_Gifts = { #隨機獎品列表
:A => [:i1, :i2, :i3, :w1, :w2, :a1, :a3], #i物品,w武器,每個組用逗號隔開
:B => [:i1_10, :w1_12, :a5_9], #這樣代表物品1~10,武器1~12,護甲5~9
:C => [:w1_60]
}
# 設置開關號碼,當開關開啟時一定會獲取到不同的幾件物品
# 設置為 nil 的話則總是有可能獲取到相同的物品
Diff_Gift_Swth = 1
def display_gift_text(name)
$game_message.add("獲得:" + name)
end
#
def random_gift(group, num)
gifts = []
Random_Gifts[group].each {|g|
g = g.to_s
type = g[0]=="i" ? 0 : g[0]=="w" ? 1 : 2
if g.include?("_")
a, b = g.scan(/\d+/)
for i in a.to_i..b.to_i
gift = which_random_gift(type)[i]
gift ? gifts.push(gift) : (return report_random_gifts_crash(group, g))
end
else
g =~ /(\d+)/
gift = which_random_gift(type)[$1.to_i]
gift ? gifts.push(gift) : (return report_random_gifts_crash(group, g))
end
}
wait_for_message
if Diff_Gift_Swth && $game_switches[Diff_Gift_Swth]
gifts.sample(num).each {|g|
$game_party.gain_item(g, 1)
display_gift_text(g.name)
}
else
num.times {
g = gifts[rand(gifts.size)]
$game_party.gain_item(g, 1)
display_gift_text(g.name)
}
end
$game_message.face_name = ''
$game_message.face_index = 0
$game_message.background = 0
$game_message.position = 2
wait_for_message
end
#
def which_random_gift(type)
case type
when 0; $data_items
when 1; $data_weapons
when 2; $data_armors
end
end
#
def report_random_gifts_crash(group, g)
msgbox("隨機禮物發生錯誤:Group :#{group} Element :#{g}") if $TEST
end
end
|