function c9010386_Die(MapID, InstanceID, CreatureID, CreatureTypeID, KillerID) -- Таблица дропа: -- - announce = false => гарантированный дроп (все такие предметы падают) -- - announce = true => РАНДОМНЫЙ ДРОП: выбирается максимум 1 предмет из этой группы, -- и он падает только если прошёл шанс (chance = % от 0 до 100). local roland = { {id = 5802129, count = 1, chance = 5, announce = true}, -- Магическое ожерелье +38 {id = 5802128, count = 1, chance = 3, announce = true}, -- Магическое ожерелье +37 {id = 5802149, count = 1, chance = 1, announce = true}, -- Камень души +34 {id = 5802631, count = 1, chance = 100, announce = false}, -- Священное сияние [8 ур.] {id = 5802656, count = 1, chance = 100, announce = false}, -- Священная судьба [8 ур.] {id = 5802661, count = 1, chance = 100, announce = false}, -- Священная мудрость [8 ур.] {id = 4820256, count = 1, chance = 100, announce = false}, -- Книга Астролога {id = 4810154, count = 1, chance = 100, announce = false}, -- Сияющая золотая пыльца {id = 3060063, count = 1, chance = 100, announce = false}, -- Пыльца эльфов [6 ур.] {id = 6600618, count = 1, chance = 11, announce = true}, -- Темная башня: пояс {id = 6600619, count = 1, chance = 11, announce = true}, -- Темная башня: ожерелье {id = 6600620, count = 1, chance = 11, announce = true}, -- Темная башня: кольцо {id = 6600621, count = 1, chance = 11, announce = true}, -- Темная башня: перстень } local TeamID = role.IsRoleHaveTeam(MapID, InstanceID, KillerID) local hasTeam = (TeamID ~= nil and TeamID ~= -1 and TeamID ~= 4294967295 and TeamID ~= 0) -- Список кандидатов на получение награды (пати/соло) local candidates = {} if hasTeam then local Role = {} for i = 1, 6 do Role[i] = role.GetRoleTeamMemID(TeamID, i) end for i = 1, 6 do if Role[i] and Role[i] ~= 4294967295 then table.insert(candidates, Role[i]) end end else if KillerID ~= nil and KillerID ~= 4294967295 and KillerID ~= 0 then table.insert(candidates, KillerID) end end if #candidates == 0 then return end -- Достижение «Меткий стрелок Роланд» (trial 6043): титул за убийство босса — всем участникам расчёта for i = 1, #candidates do local rid = candidates[i] if rid ~= nil and rid ~= 0 and rid ~= 4294967295 then if role.GetTrialState(rid, 6043) == 0 then role.OpenTrain(rid, 6043) end if role.GetTrialState(rid, 6043) == 1 then local maxn = Trail_maxnum[6043] or 1 local cur = role.GetTrialCompleteNum(rid, 6043) if cur < maxn then role.SetTrialCompleteNum(rid, 6043, maxn) role.TrialComplete(rid, 6043) end end end end -- Кому выдаём лут: выбираем одного получателя из пати/соло local selectedRole = candidates[math.random(#candidates)] if not selectedRole then return end local function give(entry) local itemId = tonumber(entry and entry.id) local count = tonumber(entry and entry.count) or 1 if not itemId or itemId <= 0 then return end role.AddRoleItem(MapID, InstanceID, selectedRole, itemId, count, 6, 8, 420) -- Для announce=true делаем оповещение (как и раньше для "редких") if entry.announce == true then local MsgID = msg.BeginMsgEvent() msg.AddMsgEvent(MsgID, 100, 950401) msg.AddMsgEvent(MsgID, 2, selectedRole) msg.AddMsgEvent(MsgID, 4, itemId) msg.DispatchBroadcast(MsgID, -1, -1, -1) end end -- 1) Гарантированный дроп: все записи с announce=false for i = 1, #roland do local entry = roland[i] if entry and entry.announce == false then give(entry) end end -- 2) Рандомный дроп: максимум 1 предмет из announce=true (выбор взвешен по chance) local randomPool = {} local totalWeight = 0 for i = 1, #roland do local entry = roland[i] if entry and entry.announce == true then local w = tonumber(entry.chance) or 0 if w > 0 then totalWeight = totalWeight + w table.insert(randomPool, entry) end end end if #randomPool > 0 and totalWeight > 0 then local r = math.random(totalWeight) local picked = nil for i = 1, #randomPool do local w = tonumber(randomPool[i].chance) or 0 r = r - w if r <= 0 then picked = randomPool[i] break end end if picked then local chance = tonumber(picked.chance) or 0 if chance > 0 and math.random(100) <= chance then give(picked) end end end end aux.RegisterCreatureEvent(9010386, 4, "c9010386_Die")