插入这个脚本
#============================================================================== # ■ 获得随机物品 #------------------------------------------------------------------------------ # 使用方法: # 事件脚本gain_item(种类, 范围, 数量) # 种类 # 物品 => "i" 或 "物品" # 武器 => "w" 或 "武器" # 防具 => "a" 或 "防具" # 范围 # 可以是数组(Array)或范围(Range) # # 例 # 从1~4号中随机选一个物品,获得1个 => gain_item("物品", 1..4 , 1) # 从1,10~20号中随机选一个武器,获得2个 => gain_item("武器", [1, 10..20] , 2) # 从1,3,5号中随机选一个防具,获得3个 => gain_item("防具", [1,3,5], 3) #============================================================================== class Game_Interpreter def gain_item(category, range_or_array, value) p range_or_array range_or_array = range_or_array.to_a if range_or_array.is_a?(Range) id = range_or_array.sample id = id.to_a.sample while !id.is_a?(Fixnum) p id p category case category when "物品" ,"i" then data = $data_items when "武器" ,"w" then data = $data_weapons when "防具" ,"a" then data = $data_armors else raise "在事件脚本中使用脚本指令gain_item时指定的种类不正确!" end $game_party.gain_item(data[id], value) end end
#==============================================================================
# ■ 获得随机物品
#------------------------------------------------------------------------------
# 使用方法:
# 事件脚本gain_item(种类, 范围, 数量)
# 种类
# 物品 => "i" 或 "物品"
# 武器 => "w" 或 "武器"
# 防具 => "a" 或 "防具"
# 范围
# 可以是数组(Array)或范围(Range)
#
# 例
# 从1~4号中随机选一个物品,获得1个 => gain_item("物品", 1..4 , 1)
# 从1,10~20号中随机选一个武器,获得2个 => gain_item("武器", [1, 10..20] , 2)
# 从1,3,5号中随机选一个防具,获得3个 => gain_item("防具", [1,3,5], 3)
#==============================================================================
class Game_Interpreter
def gain_item(category, range_or_array, value)
p range_or_array
range_or_array = range_or_array.to_a if range_or_array.is_a?(Range)
id = range_or_array.sample
id = id.to_a.sample while !id.is_a?(Fixnum)
p id
p category
case category
when "物品" ,"i" then data = $data_items
when "武器" ,"w" then data = $data_weapons
when "防具" ,"a" then data = $data_armors
else raise "在事件脚本中使用脚本指令gain_item时指定的种类不正确!"
end
$game_party.gain_item(data[id], value)
end
end
新建工程测试通过
你用的时候就这样用
|