tower_mob_point = { {462, 332}, {1277, 332}, {248, 332} } drop_tower = { -- k=1: Дроп с мобов 63-77 { {id=3060004, count=2, chance=100, announce=false}, -- Пыльца эльфов [Ур. 4] {id=4810154, count=2, chance=100, announce=false}, -- Сияющая золотая пыльца {id=5802631, count=1, chance=50, announce=false}, -- Священное сияние [8 ур.] {id=5802656, count=1, chance=50, announce=false}, -- Священная судьба [8 ур.] {id=5802661, count=1, chance=50, announce=false}, -- Священная мудрость [8 ур.] {id=4820256, count=1, chance=50, announce=false}, -- Книга Астролога {id=3020001, count=2, chance=100, announce=false}, -- Камень усиления {id=3020058, count=2, chance=100, announce=false}, -- Бессмертный кристалл {id=4820257, count=1, chance=30, announce=false}, -- Руна тройной награды [перс.] }, -- k=2: Дроп с мобов 83-97 { {id=5802125, count=1, chance=1, announce=true}, -- Магическое ожерелье +34 {id=4810154, count=2, chance=100, announce=false}, -- Сияющая золотая пыльца {id=5802631, count=1, chance=50, announce=false}, -- Священное сияние [8 ур.] {id=5802656, count=1, chance=50, announce=false}, -- Священная судьба [8 ур.] {id=5802661, count=1, chance=50, announce=false}, -- Священная мудрость [8 ур.] {id=4820256, count=1, chance=40, announce=false}, -- Книга Астролога {id=3020059, count=1, chance=100, announce=false}, -- Богоподобный кристалл {id=3020060, count=1, chance=80, announce=false}, -- Священная кровь [1 ур.] {id=5802142, count=1, chance=70, announce=false}, -- Священная кровь [2 ур.] {id=5802143, count=1, chance=50, announce=false}, -- Священная кровь [3 ур] {id=3060005, count=1, chance=100, announce=false}, -- Пыльца эльфов [Ур. 5] {id=6600347, count=1, chance=1, announce=true}, -- Хранитель бездны Асмодей {id=6600346, count=1, chance=1, announce=true}, -- Лесной дух Мирта {id=3010164, count=1, chance=10, announce=false}, -- Пламенный инкуб[7дн.] {id=3010167, count=1, chance=10, announce=false}, -- Пламенный суккуб[7дн.] {id=6600617, count=1, chance=100, announce=false}, -- Философский камень }, -- k=3: 103-110 { {id=5802127, count=1, chance=1, announce=true}, -- Магическое ожерелье +36 {id=5802126, count=1, chance=1, announce=true}, -- Магическое ожерелье +35 {id=5802631, count=1, chance=80, announce=false}, -- Священное сияние [8 ур.] {id=5802656, count=1, chance=80, announce=false}, -- Священная судьба [8 ур.] {id=5802661, count=1, chance=80, announce=false}, -- Священная мудрость [8 ур.] {id=4820256, count=1, chance=50, announce=false}, -- Книга Астролога {id=6600617, count=1, chance=100, announce=false}, -- Философский камень {id=4820265, count=1, chance=50, announce=false}, -- Камень девяти звезд {id=6600541, count=1, chance=1, announce=true}, -- Дух войны Градозор {id=6600473, count=1, chance=1, announce=true}, -- Ледяной страж Адриэль {id=3060063, count=1, chance=100, announce=false}, -- Пыльца эльфов [6 ур.] {id=4810154, count=1, chance=100, announce=false}, -- Сияющая золотая пыльца }, -- k=4: Роланд (если используется) { {id=3060004, count=1, chance=100, announce=false}, -- Пыльца эльфов [Ур. 4] } } function tower_Die(MapID, InstanceID, CreatureID, CreatureTypeID, KillerID) local monsterNum = map.GetMapScriptData(3911351072, InstanceID, 1, 4) local TeamID = role.IsRoleHaveTeam(MapID, InstanceID, KillerID) local creatureTypeToK = { [9010365] = 1, [9010366] = 1, [9010367] = 1, [9010368] = 1, [9010369] = 1, [9010370] = 1, [9010371] = 1, [9010372] = 1, [9010373] = 2, [9010374] = 2, [9010375] = 2, [9010376] = 2, [9010377] = 2, [9010378] = 2, [9010379] = 2, [9010380] = 2, [9010381] = 3, [9010382] = 3, [9010383] = 3, [9010384] = 3, [9010385] = 3 -- доп. монстр, использует лут 103-110 } local k = creatureTypeToK[CreatureTypeID] if not k then return end -- ВАЖНО: IsRoleHaveTeam может возвращать -1 для "без команды". local hasTeam = (TeamID ~= nil and TeamID ~= -1 and TeamID ~= 4294967295 and TeamID ~= 0) local validRoles = {} if hasTeam then local Role = {} Role[1], Role[2], Role[3], Role[4], Role[5], Role[6] = role.GetRoleTeamMemID(TeamID) for i = 1, 6 do if Role[i] and Role[i] ~= 4294967295 then table.insert(validRoles, Role[i]) end end else -- Соло: выдаём на убийцу if KillerID ~= nil and KillerID ~= 4294967295 and KillerID ~= 0 then table.insert(validRoles, KillerID) end end -- Фоллбек: если KillerID не является RoleID (пет/призыв/прочее) — возьмём ближайших игроков if #validRoles == 0 and cre and cre.GetAroundRole then local around = cre.GetAroundRole(MapID, InstanceID, CreatureID, 100000, 100000) if around then for _, rid in pairs(around) do if rid and rid ~= 4294967295 and rid ~= 0 then table.insert(validRoles, rid) end end end end -- Гарантия: с каждого моба должен упасть хотя бы 1 предмет. -- Логика: пытаемся несколько раз прокинуть шанс для случайного предмета, -- если не прокнуло — выдаём предмет с максимальным шансом принудительно. local receiver = nil if #validRoles > 0 then receiver = validRoles[math.random(#validRoles)] else -- крайний фоллбек: любой игрок в инстансе local all = map.GetMapAllRoleID(MapID, InstanceID) if all and #all > 0 then receiver = all[math.random(#all)] end end local function doDrop(entry, force) local itemId = tonumber(entry and entry.id) local count = tonumber(entry and entry.count) or 1 if not itemId or itemId <= 0 then return false end local chance = tonumber(entry and entry.chance) or 0 if force ~= true then if chance <= 0 or math.random(100) > chance then return false end end role.AddRoleItem(MapID, InstanceID, receiver, itemId, count, 6, 8, 420) if entry.announce == true then local MsgID = msg.BeginMsgEvent() msg.AddMsgEvent(MsgID, 100, 950401) msg.AddMsgEvent(MsgID, 2, receiver) msg.AddMsgEvent(MsgID, 4, itemId) msg.DispatchBroadcast(MsgID, -1, -1, -1) end return true end local dropped = false if receiver ~= nil and receiver ~= 4294967295 and receiver ~= 0 then local pool = drop_tower[k] local c = (type(pool) == "table") and #pool or 0 if c > 0 then -- пытаемся поймать удачный ролл local maxAttempts = math.min(10, c) for _ = 1, maxAttempts do local entry = pool[math.random(c)] if doDrop(entry, false) then dropped = true break end end -- если не выпало — выдаём самый "вероятный" предмет принудительно if dropped == false then local best = pool[1] local bestChance = tonumber(best and best.chance) or 0 for i = 2, c do local ch = tonumber(pool[i] and pool[i].chance) or 0 if ch > bestChance then best = pool[i] bestChance = ch end end doDrop(best, true) dropped = true end end end -- 9010385 должен только дропать (не участвует в логике счётчика/спавна телепорта) if CreatureTypeID == 9010385 then return end if not monsterNum or monsterNum < 0 then monsterNum = 0 end local num = 8 - monsterNum if num > 0 then map.SetMapScriptData(3911351072, InstanceID, 1, 4, monsterNum + 1) else local creatureTypeToIJ = { [9010365] = {1, 1}, [9010366] = {1, 1}, [9010367] = {2, 2}, [9010368] = {2, 2}, [9010369] = {3, 3}, [9010370] = {3, 3}, [9010371] = {4, 1}, [9010372] = {4, 1}, [9010373] = {5, 2}, [9010374] = {5, 2}, [9010375] = {6, 3}, [9010376] = {6, 3}, [9010377] = {7, 1}, [9010378] = {7, 1}, [9010379] = {8, 2}, [9010380] = {8, 2}, [9010381] = {9, 3}, [9010382] = {9, 3}, [9010383] = {10, 1}, [9010384] = {10, 1} } local ij = creatureTypeToIJ[CreatureTypeID] if ij then local i, j = ij[1], ij[2] local teleport = map.MapCreateColCreature(3911351072, InstanceID, 9010387, tower_mob_point[j][1], 2608, tower_mob_point[j][2], 1) map.SetMapScriptData(3911351072, InstanceID, 1, 1, teleport) map.SetMapScriptData(3911351072, InstanceID, 1, 3, i) map.SetMapScriptData(3911351072, InstanceID, 1, 4, 0) end end end aux.RegisterCreatureEvent(9010365, 4, "tower_Die") aux.RegisterCreatureEvent(9010366, 4, "tower_Die") aux.RegisterCreatureEvent(9010367, 4, "tower_Die") aux.RegisterCreatureEvent(9010368, 4, "tower_Die") aux.RegisterCreatureEvent(9010369, 4, "tower_Die") aux.RegisterCreatureEvent(9010370, 4, "tower_Die") aux.RegisterCreatureEvent(9010371, 4, "tower_Die") aux.RegisterCreatureEvent(9010372, 4, "tower_Die") aux.RegisterCreatureEvent(9010373, 4, "tower_Die") aux.RegisterCreatureEvent(9010374, 4, "tower_Die") aux.RegisterCreatureEvent(9010375, 4, "tower_Die") aux.RegisterCreatureEvent(9010376, 4, "tower_Die") aux.RegisterCreatureEvent(9010377, 4, "tower_Die") aux.RegisterCreatureEvent(9010378, 4, "tower_Die") aux.RegisterCreatureEvent(9010379, 4, "tower_Die") aux.RegisterCreatureEvent(9010380, 4, "tower_Die") aux.RegisterCreatureEvent(9010381, 4, "tower_Die") aux.RegisterCreatureEvent(9010382, 4, "tower_Die") aux.RegisterCreatureEvent(9010383, 4, "tower_Die") aux.RegisterCreatureEvent(9010384, 4, "tower_Die") aux.RegisterCreatureEvent(9010385, 4, "tower_Die")