function MaskCollector_OnTalk(MapID, InstanceID, TargetID, TargetTypeID, RoleID, TalkIndex) local MaskDialogs = {} -- Название набора; Жетон на маски; Маски на жетон; Описание набора MaskDialogs[1] = {950463, 950471, 950472, 950473} MaskDialogs[2] = {950465, 950474, 950475, 950476} MaskDialogs[3] = {950524, 950525, 950526, 950527} MaskDialogs[4] = {950619, 950620, 950621, 950622} MaskDialogs[5] = {950732, 950733, 950734, 950735} MaskDialogs[6] = {951021, 951022, 951023, 951024} MaskDialogs[7] = {951025, 951026, 951027, 951028} MaskDialogs[8] = {951050, 951051, 951052, 951053} MaskDialogs[9] = {951233, 951234, 951235, 951236} MaskDialogs[10] = {951843, 951844, 951845, 951846} MaskDialogs[11] = {951863, 951864, 951865, 951866} if TalkIndex == -1 or TalkIndex == 7 then local MsgID = msg.BeginMsgEvent() msg.AddMsgEvent(MsgID, 20, 950461) msg.AddMsgEvent(MsgID, 9, CheckMaskCoupons(RoleID)) msg.AddMsgEvent(MsgID, 24, TargetID) msg.AddMsgEvent(MsgID, 21, 8) msg.AddMsgEvent(MsgID, 1, 950462) -- Получить бонус for i = 1, #MaskDialogs do msg.AddMsgEvent(MsgID, 21, i*10) msg.AddMsgEvent(MsgID, 1, MaskDialogs[i][1]) end msg.AddMsgEvent(MsgID, 21, 9999) -- Отмена msg.AddMsgEvent(MsgID, 1, 100002) msg.DispatchRoleMsgEvent(RoleID, MsgID) elseif TalkIndex == 8 then -- Выдача баффа local CouponsNum = CheckMaskCoupons(RoleID) local Requirements = {} Requirements[1] = 10 Requirements[2] = 20 Requirements[3] = 30 Requirements[4] = 40 Requirements[5] = 50 Requirements[6] = 65 Requirements[7] = 80 Requirements[8] = 100 local BuffLevel = 0 for i=1, 8 do if CouponsNum/20*100 >= Requirements[i] then BuffLevel = i end end if BuffLevel < 1 then local MsgID = msg.BeginMsgEvent() msg.AddMsgEvent(MsgID, 20, 950467) -- Недостаточно коллекций msg.AddMsgEvent(MsgID, 24, TargetID) msg.AddMsgEvent(MsgID, 21, 7) -- Назад msg.AddMsgEvent(MsgID, 1, 930314) msg.AddMsgEvent(MsgID, 21, 9999) -- Отмена msg.AddMsgEvent(MsgID, 1, 100002) msg.DispatchRoleMsgEvent(RoleID, MsgID) else local level = role.IsLearnedSkill(RoleID, 91019) if level ~= nil then role.RemoveSkill(RoleID, 91019) end role.AddSkill(RoleID, 9101900 + BuffLevel) end else local MsgID = msg.BeginMsgEvent() local SetID = math.floor(TalkIndex / 10) local Type = TalkIndex % 10 local MaskItems = {} -- Маски MaskItems[1] = {8099155, 8099156, 8099157} MaskItems[2] = {8099159, 8099160, 8099161} MaskItems[3] = {8099201, 8099202, 8099203} MaskItems[4] = {8099212, 8099213, 8099214} MaskItems[5] = {8099270, 8099271, 8099272} MaskItems[6] = {8099439, 8099440, 8099441} MaskItems[7] = {8099442, 8099443, 8099444} MaskItems[8] = {8099515, 8099516, 8099517} MaskItems[9] = {8099705, 8099706, 8099707} MaskItems[10] = {8099820, 8099821, 8099822} MaskItems[11] = {8099852, 8099853, 8099854} local MaskCoupons = {} -- Жетоны наборов масок MaskCoupons[1] = 6600681 MaskCoupons[2] = 6600682 MaskCoupons[3] = 6600687 MaskCoupons[4] = 6600688 MaskCoupons[5] = 6600689 MaskCoupons[6] = 6600690 MaskCoupons[7] = 6600691 MaskCoupons[8] = 6600692 MaskCoupons[9] = 6600693 MaskCoupons[10] = 6600694 MaskCoupons[11] = 6600695 if Type == 0 then if role.GetRoleItemNum(RoleID, MaskCoupons[SetID]) > 0 then msg.AddMsgEvent(MsgID, 20, MaskDialogs[SetID][2]) -- Жетон на маски msg.AddMsgEvent(MsgID, 24, TargetID) msg.AddMsgEvent(MsgID, 21, 7) msg.AddMsgEvent(MsgID, 1, 930314) msg.AddMsgEvent(MsgID, 21, SetID*10+1) msg.AddMsgEvent(MsgID, 1, 950468) elseif CheckMaskSet(SetID, RoleID) then msg.AddMsgEvent(MsgID, 20, MaskDialogs[SetID][3]) -- Маски на Жетоны msg.AddMsgEvent(MsgID, 24, TargetID) msg.AddMsgEvent(MsgID, 21, 7) msg.AddMsgEvent(MsgID, 1, 930314) msg.AddMsgEvent(MsgID, 21, SetID*10+2) msg.AddMsgEvent(MsgID, 1, 950470) else msg.AddMsgEvent(MsgID, 20, MaskDialogs[SetID][4]) -- Показываем инфо о наборе msg.AddMsgEvent(MsgID, 24, TargetID) msg.AddMsgEvent(MsgID, 21, 7) msg.AddMsgEvent(MsgID, 1, 930314) end elseif Type == 1 then if role.GetBagFreeSize(RoleID) < #MaskItems[SetID] then msg.AddMsgEvent(MsgID, 20, 950469) -- Недостаточно места msg.AddMsgEvent(MsgID, 24, TargetID) msg.AddMsgEvent(MsgID, 21, SetID*10) msg.AddMsgEvent(MsgID, 1, 930314) else if role.GetRoleItemNum(RoleID, MaskCoupons[SetID]) > 0 then role.RemoveFromRole(MapID, InstanceID, RoleID, MaskCoupons[SetID], 1, 420) for i =1, #MaskItems[SetID] do role.AddRoleItem(MapID, InstanceID, RoleID, MaskItems[SetID][i], 1, 6, 8, 420) end end end elseif Type == 2 then if CheckMaskSet(SetID, RoleID) then role.QuestAddRoleItem(MapID, InstanceID, RoleID, -1, MaskCoupons[SetID], 1, -1, 420) for i = 1, #MaskItems[SetID] do role.RemoveFromRole(MapID, InstanceID, RoleID, MaskItems[SetID][i], 1, 420) end end end msg.AddMsgEvent(MsgID, 21, 9999) -- Отмена msg.AddMsgEvent(MsgID, 1, 100002) msg.DispatchRoleMsgEvent(RoleID, MsgID) end end aux.RegisterCreatureEvent(9010401, 7, "MaskCollector_OnTalk") function CheckMaskSet (SetID, RoleID) local MaskItems = {} -- Маски MaskItems[1] = {8099155, 8099156, 8099157} MaskItems[2] = {8099159, 8099160, 8099161} MaskItems[3] = {8099201, 8099202, 8099203} MaskItems[4] = {8099212, 8099213, 8099214} MaskItems[5] = {8099270, 8099271, 8099272} MaskItems[6] = {8099439, 8099440, 8099441} MaskItems[7] = {8099442, 8099443, 8099444} MaskItems[8] = {8099515, 8099516, 8099517} MaskItems[9] = {8099705, 8099706, 8099707} MaskItems[10] = {8099820, 8099821, 8099822} MaskItems[11] = {8099852, 8099853, 8099854} for i = 1, #MaskItems[SetID] do if role.GetRoleItemNum(RoleID, MaskItems[SetID][i]) < 1 then return false end end return true end function CheckMaskCoupons (RoleID) local MaskCoupons = {} -- Жетоны наборов масок MaskCoupons[1] = 6600681 MaskCoupons[2] = 6600682 MaskCoupons[3] = 6600687 MaskCoupons[4] = 6600688 MaskCoupons[5] = 6600689 MaskCoupons[6] = 6600690 MaskCoupons[7] = 6600691 MaskCoupons[8] = 6600692 MaskCoupons[9] = 6600693 MaskCoupons[10] = 6600694 MaskCoupons[11] = 6600695 local CouponsNum = 0 for i = 1, #MaskCoupons do if role.GetRoleItemNum(RoleID, MaskCoupons[i]) > 0 then CouponsNum = CouponsNum + 1 end end return CouponsNum end