-- Набор 6601201 «Зачарованное снаряжение 100 ур.» -- При открытии: один случайный предмет зачар. снаряжения 100 ур. под класс персонажа. -- Пулы по loot_item_set 854–855 и разделению классов как в standart skript offi.lua / veshi.lua. local ENCHANTED_100_BY_CLASS = { -- Воин (клинок) + стрелок: 2, 6, 7, 3, 8, 9 { 8013011, 8023011, 8050311, 8060311, 8070311, 8080311, 8090311, 8050411, 8060411, 8070411, 8080411, 8090411, 8100311, 8100411, 8110311, 8121311, 8130311, }, -- Воин (сила): 4, 10, 11 { 8013011, 8050311, 8060311, 8070311, 8080311, 8090311, 8100311, 8111311, 8122311, 8130411, }, -- Маг + бард: 5, 12, 13 { 8033011, 8043011, 8051311, 8061311, 8071311, 8081311, 8091311, 8051411, 8061411, 8071411, 8081411, 8091411, 8100511, 8100611, 8111311, 8122311, 8130411, }, } local function enchanted100_class_index(class) if class == 2 or class == 6 or class == 7 or class == 3 or class == 8 or class == 9 then return 1 end if class == 4 or class == 10 or class == 11 then return 2 end if class == 5 or class == 12 or class == 13 then return 3 end return 0 end local function enchanted100_pick_item(TargetID, poolIndex) local pool = ENCHANTED_100_BY_CLASS[poolIndex] if pool == nil or #pool < 1 then return nil end local maxCount = 0 local candidates = {} for i = 1, #pool do local itemId = pool[i] local num = role.GetRoleItemNum(TargetID, itemId) if num > maxCount then maxCount = num end end for i = 1, #pool do local itemId = pool[i] if role.GetRoleItemNum(TargetID, itemId) < maxCount then candidates[#candidates + 1] = itemId end end if #candidates < 1 then candidates = pool end return candidates[math.random(1, #candidates)] end function I6601201_GiftBag(MapID, InstanceID, TypeID, TargetID) local class = role.GetRoleClass(TargetID) local poolIndex = enchanted100_class_index(class) if poolIndex < 1 then return end local itemId = enchanted100_pick_item(TargetID, poolIndex) if itemId == nil then return end role.AddRoleItem(MapID, InstanceID, TargetID, itemId, 1, 5, 8, 420) end function I6601201_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local class = role.GetRoleClass(TargetID) if class == 1 or enchanted100_class_index(class) < 1 then bRet = 46 return bRet, bIgnore end if role.GetBagFreeSize(TargetID) < 1 then bRet = 40 end return bRet, bIgnore end aux.RegisterItemEvent(6601201, 0, "I6601201_CanUseGiftBag") aux.RegisterItemEvent(6601201, 1, "I6601201_GiftBag")