赞 | 45 |
VIP | 0 |
好人卡 | 2 |
积分 | 137 |
经验 | 67210 |
最后登录 | 2024-11-24 |
在线时间 | 3854 小时 |
Lv4.逐梦者
- 梦石
- 0
- 星屑
- 13652
- 在线时间
- 3854 小时
- 注册时间
- 2013-7-18
- 帖子
- 2314
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 y967 于 2017-2-8 11:26 编辑
如何实现一个怪物掉多个道具,这个已经有多格掉宝脚本了,问题是如何实现一个道具掉多个数量。
class Scene_Battle #-------------------------------------------------------------------------- # ● 开始结束战斗回合 #-------------------------------------------------------------------------- def start_phase5 # 转移到回合 5 @phase = 5 # 演奏战斗结束 ME $game_system.me_play($game_system.battle_end_me) # 还原为战斗开始前的 BGM $game_system.bgm_play($game_temp.map_bgm) # 初始化 EXP、金钱、宝物 exp = 0 gold = 0 treasures = [] for enemy in $game_troop.enemies unless enemy.hidden exp += $game_variables[13] * enemy.exp gold += $game_variables[14] *enemy.gold if rand(100) < enemy.treasure_prob if enemy.item_id > 0 treasures.push($data_items[enemy.item_id]) end if enemy.weapon_id > 0 treasures.push($data_weapons[enemy.weapon_id]) end if enemy.armor_id > 0 treasures.push($data_armors[enemy.armor_id]) end end end end 多格掉宝 = {} # 初始化 # --------------------------- # 多格掉宝 设置 # --------------------------- # 多格掉宝[敌人id] = [掉宝类型,id以及概率的数组] # 掉宝类型,id以及概率的数组 说明: # 索引为 0 的值 # 0 是 物品 1 是武器 2 是防具 # 索引为 1 的值 # 物品 武器 防具 的 id # 索引为 2 的值 # 概率 # 设置范例 多格掉宝[1] = [[0, 1, 18], [0, 2, 18]] 多格掉宝[2] = [[0, 27, 25]] 多格掉宝[3] = [[0, 1, 18], [0, 2, 18]] 多格掉宝[4] = [[0, 27, 30]] 多格掉宝[5] = [[0, 35, 18]] 多格掉宝[6] = [[0, 35, 18]] 多格掉宝[7] = [[0, 35, 18]] 多格掉宝[8] = [[0, 35, 18]] 多格掉宝[9] = [[0, 35, 18],[0, 27, 18]] 多格掉宝[10] = [[0, 35, 18],[0, 27, 18]] 多格掉宝[12] = [[0, 35, 18]] 多格掉宝[13] = [[0, 35, 18]] 多格掉宝[14] = [[0, 35, 18],[0, 27, 18]] 多格掉宝[15] = [[0, 35, 18]] 多格掉宝[16] = [[0, 35, 18]] 多格掉宝[19] = [[0, 35, 18],[0, 27, 16]] 多格掉宝[20] = [[0, 35, 18],[0, 27, 16]] 多格掉宝[21] = [[0, 35, 18],[0, 27, 16]] 多格掉宝[22] = [[0, 35, 18],[0, 27, 16]] 多格掉宝[23] = [[0, 35, 18],[0, 27, 16]] 多格掉宝[24] = [[0, 27, 42],[1, 23, 36],[0, 35, 18],[2, 40, 30]] 多格掉宝[26] = [[0, 35, 18],[0, 27, 16]] 多格掉宝[27] = [[0, 35, 18],[0, 27, 16]] 多格掉宝[28] = [[0, 35, 18],[0, 27, 16]] 多格掉宝[29] = [[0, 35, 18],[0, 27, 16]] 多格掉宝[30] = [[0, 35, 18],[0, 27, 16]] 多格掉宝[31] = [[0, 35, 18],[0, 27, 16]] 多格掉宝[32] = [[0, 35, 18],[0, 27, 16]] 多格掉宝[36] = [[0, 35, 18],[0, 27, 16]] 多格掉宝[37] = [[0, 35, 18],[0, 27, 16]] 多格掉宝[38] = [[0, 35, 18],[0, 27, 16]] 多格掉宝[39] = [[0, 35, 18],[0, 27, 16]] 多格掉宝[40] = [[0, 35, 18],[0, 27, 16]] 多格掉宝[41] = [[0, 35, 18],[0, 27, 16]] 多格掉宝[42] = [[0, 35, 18],[0, 27, 16]] 多格掉宝[43] = [[0, 35, 18],[0, 27, 16]] 多格掉宝[45] = [[0, 35, 18],[0, 27, 16]] 多格掉宝[46] = [[0, 35, 18],[0, 27, 16]] case $game_variables[4] when 0 多格掉宝[17] = [[0, 35, 18],[0, 27, 18],[0, 46, 33]] 多格掉宝[33] = [[1, 40, 40],[0, 52, 26],[2, 59, 40],[2, 62, 40],[0, 79, 26],[0, 80, 26],[0, 48, 20]] 多格掉宝[34] = [[1, 43, 40],[0, 53, 26],[2, 65, 40],[0, 81, 26],[0, 75, 26]] 多格掉宝[47] = [[1, 49, 40],[0, 77, 26],[2, 68, 40],[0, 82, 26]] 多格掉宝[48] = [[1, 46, 40],[0, 76, 26],[0, 111, 50]] when 4 多格掉宝[17] = [[0, 35, 18],[0, 27, 18],[0, 47, 33]] 多格掉宝[33] = [[1, 40, 40],[0, 52, 26],[2, 59, 40],[2, 62, 40],[0, 79, 26],[0, 80, 26],[0, 113, 26],[0, 48, 20]] 多格掉宝[34] = [[1, 43, 40],[0, 53, 26],[2, 65, 40],[0, 81, 26],[0, 110, 26]] 多格掉宝[47] = [[1, 49, 40],[0, 77, 26],[2, 68, 40],[0, 82, 26],[0, 90, 20]] 多格掉宝[48] = [[1, 46, 40],[0, 76, 26],[0, 112, 50]] end # ---------------------------------------- for enemy in $game_troop.enemies unless enemy.hidden if 多格掉宝[enemy.id] != nil for i in 多格掉宝[enemy.id] 概率 = i[2] case i[0] when 0 # 物品 if rand(100) < 概率 if $data_items[i[1]] != nil treasures.push($data_items[i[1]]) end end when 1 # 武器 if rand(100) < 概率 if $data_weapons[i[1]] != nil treasures.push($data_weapons[i[1]]) end end when 2 # 防具 if rand(100) < 概率 if $data_armors[i[1]] != nil treasures.push($data_armors[i[1]]) end end end end end end end # ---------------------------------------- for i in 0...$game_party.actors.size actor = $game_party.actors[i] if actor.cant_get_exp? == false last_level = actor.level actor.exp += exp if actor.level > last_level @status_window.level_up(i) end end end # 获得金钱 $game_party.gain_gold(gold) # 获得宝物 for item in treasures case item when RPG::Item $game_party.gain_item(item.id, 1) when RPG::Weapon $game_party.gain_weapon(item.id, 1) when RPG::Armor $game_party.gain_armor(item.id, 1) end end # 生成战斗结果窗口 @result_window = Window_BattleResult.new(exp, gold, treasures) # 设置等待计数 @phase5_wait_count = 0 end end
class Scene_Battle
#--------------------------------------------------------------------------
# ● 开始结束战斗回合
#--------------------------------------------------------------------------
def start_phase5
# 转移到回合 5
@phase = 5
# 演奏战斗结束 ME
$game_system.me_play($game_system.battle_end_me)
# 还原为战斗开始前的 BGM
$game_system.bgm_play($game_temp.map_bgm)
# 初始化 EXP、金钱、宝物
exp = 0
gold = 0
treasures = []
for enemy in $game_troop.enemies
unless enemy.hidden
exp += $game_variables[13] * enemy.exp
gold += $game_variables[14] *enemy.gold
if rand(100) < enemy.treasure_prob
if enemy.item_id > 0
treasures.push($data_items[enemy.item_id])
end
if enemy.weapon_id > 0
treasures.push($data_weapons[enemy.weapon_id])
end
if enemy.armor_id > 0
treasures.push($data_armors[enemy.armor_id])
end
end
end
end
多格掉宝 = {} # 初始化
# ---------------------------
# 多格掉宝 设置
# ---------------------------
# 多格掉宝[敌人id] = [掉宝类型,id以及概率的数组]
# 掉宝类型,id以及概率的数组 说明:
# 索引为 0 的值
# 0 是 物品 1 是武器 2 是防具
# 索引为 1 的值
# 物品 武器 防具 的 id
# 索引为 2 的值
# 概率
# 设置范例
多格掉宝[1] = [[0, 1, 18], [0, 2, 18]]
多格掉宝[2] = [[0, 27, 25]]
多格掉宝[3] = [[0, 1, 18], [0, 2, 18]]
多格掉宝[4] = [[0, 27, 30]]
多格掉宝[5] = [[0, 35, 18]]
多格掉宝[6] = [[0, 35, 18]]
多格掉宝[7] = [[0, 35, 18]]
多格掉宝[8] = [[0, 35, 18]]
多格掉宝[9] = [[0, 35, 18],[0, 27, 18]]
多格掉宝[10] = [[0, 35, 18],[0, 27, 18]]
多格掉宝[12] = [[0, 35, 18]]
多格掉宝[13] = [[0, 35, 18]]
多格掉宝[14] = [[0, 35, 18],[0, 27, 18]]
多格掉宝[15] = [[0, 35, 18]]
多格掉宝[16] = [[0, 35, 18]]
多格掉宝[19] = [[0, 35, 18],[0, 27, 16]]
多格掉宝[20] = [[0, 35, 18],[0, 27, 16]]
多格掉宝[21] = [[0, 35, 18],[0, 27, 16]]
多格掉宝[22] = [[0, 35, 18],[0, 27, 16]]
多格掉宝[23] = [[0, 35, 18],[0, 27, 16]]
多格掉宝[24] = [[0, 27, 42],[1, 23, 36],[0, 35, 18],[2, 40, 30]]
多格掉宝[26] = [[0, 35, 18],[0, 27, 16]]
多格掉宝[27] = [[0, 35, 18],[0, 27, 16]]
多格掉宝[28] = [[0, 35, 18],[0, 27, 16]]
多格掉宝[29] = [[0, 35, 18],[0, 27, 16]]
多格掉宝[30] = [[0, 35, 18],[0, 27, 16]]
多格掉宝[31] = [[0, 35, 18],[0, 27, 16]]
多格掉宝[32] = [[0, 35, 18],[0, 27, 16]]
多格掉宝[36] = [[0, 35, 18],[0, 27, 16]]
多格掉宝[37] = [[0, 35, 18],[0, 27, 16]]
多格掉宝[38] = [[0, 35, 18],[0, 27, 16]]
多格掉宝[39] = [[0, 35, 18],[0, 27, 16]]
多格掉宝[40] = [[0, 35, 18],[0, 27, 16]]
多格掉宝[41] = [[0, 35, 18],[0, 27, 16]]
多格掉宝[42] = [[0, 35, 18],[0, 27, 16]]
多格掉宝[43] = [[0, 35, 18],[0, 27, 16]]
多格掉宝[45] = [[0, 35, 18],[0, 27, 16]]
多格掉宝[46] = [[0, 35, 18],[0, 27, 16]]
case $game_variables[4]
when 0
多格掉宝[17] = [[0, 35, 18],[0, 27, 18],[0, 46, 33]]
多格掉宝[33] = [[1, 40, 40],[0, 52, 26],[2, 59, 40],[2, 62, 40],[0, 79, 26],[0, 80, 26],[0, 48, 20]]
多格掉宝[34] = [[1, 43, 40],[0, 53, 26],[2, 65, 40],[0, 81, 26],[0, 75, 26]]
多格掉宝[47] = [[1, 49, 40],[0, 77, 26],[2, 68, 40],[0, 82, 26]]
多格掉宝[48] = [[1, 46, 40],[0, 76, 26],[0, 111, 50]]
when 4
多格掉宝[17] = [[0, 35, 18],[0, 27, 18],[0, 47, 33]]
多格掉宝[33] = [[1, 40, 40],[0, 52, 26],[2, 59, 40],[2, 62, 40],[0, 79, 26],[0, 80, 26],[0, 113, 26],[0, 48, 20]]
多格掉宝[34] = [[1, 43, 40],[0, 53, 26],[2, 65, 40],[0, 81, 26],[0, 110, 26]]
多格掉宝[47] = [[1, 49, 40],[0, 77, 26],[2, 68, 40],[0, 82, 26],[0, 90, 20]]
多格掉宝[48] = [[1, 46, 40],[0, 76, 26],[0, 112, 50]]
end
# ----------------------------------------
for enemy in $game_troop.enemies
unless enemy.hidden
if 多格掉宝[enemy.id] != nil
for i in 多格掉宝[enemy.id]
概率 = i[2]
case i[0]
when 0 # 物品
if rand(100) < 概率
if $data_items[i[1]] != nil
treasures.push($data_items[i[1]])
end
end
when 1 # 武器
if rand(100) < 概率
if $data_weapons[i[1]] != nil
treasures.push($data_weapons[i[1]])
end
end
when 2 # 防具
if rand(100) < 概率
if $data_armors[i[1]] != nil
treasures.push($data_armors[i[1]])
end
end
end
end
end
end
end
# ----------------------------------------
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
if actor.cant_get_exp? == false
last_level = actor.level
actor.exp += exp
if actor.level > last_level
@status_window.level_up(i)
end
end
end
# 获得金钱
$game_party.gain_gold(gold)
# 获得宝物
for item in treasures
case item
when RPG::Item
$game_party.gain_item(item.id, 1)
when RPG::Weapon
$game_party.gain_weapon(item.id, 1)
when RPG::Armor
$game_party.gain_armor(item.id, 1)
end
end
# 生成战斗结果窗口
@result_window = Window_BattleResult.new(exp, gold, treasures)
# 设置等待计数
@phase5_wait_count = 0
end
end
|
|