function I3030102_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) local b = role.GetRoleItemNum(TargetID, 3020054) -- В сундуке 4 разных предмета -> нужно минимум 4 свободных слота local needSlots = 4 if FreeSize < needSlots then bRet = 40 end if b == 0 then bRet = 103 end return bRet, bIgnore end function I3030102_GiftBag(MapID, InstanceID, TypeID, TargetID) local chunkSize = 1 local tbl = { {3030001, 1, 5, 2000}, {3030029, 1, 5, 2000}, {3030072, 1, 5, 2000}, {3030111, 3, 5, 4000} } local processed = 0 local b3030102 = role.GetRoleItemNum(TargetID, 3030102) local b3020054 = role.GetRoleItemNum(TargetID, 3020054) local skipBagRemoval = true while processed < b3030102 and b3020054 > 0 do local toProcess = math.min(b3030102 - processed, b3020054, chunkSize) if role.GetBagFreeSize(TargetID) < toProcess then break end local awarded = 0 for i = 1, toProcess do if role.GetRoleItemNum(TargetID, 3020054) <= 0 or role.GetRoleItemNum(TargetID, 3030102) <= 0 then break end local r = math.random(10000) local temp = 0 local index = 1 for j = 1, #tbl do temp = temp + tbl[j][4] if temp >= r then index = j break end end role.RemoveFromRole(MapID, InstanceID, TargetID, 3020054, 1, 101) if skipBagRemoval then skipBagRemoval = false else role.RemoveFromRole(MapID, InstanceID, TargetID, 3030102, 1, 101) end role.AddRoleItem(MapID, InstanceID, TargetID, tbl[index][1], tbl[index][2], tbl[index][3], 8, 35) awarded = awarded + 1 end if awarded == 0 then break end processed = processed + awarded b3020054 = role.GetRoleItemNum(TargetID, 3020054) b3030102 = role.GetRoleItemNum(TargetID, 3030102) break end end aux.RegisterItemEvent(3030102, 1, "I3030102_GiftBag") aux.RegisterItemEvent(3030102, 0, "I3030102_CanUseGiftBag") function I3030103_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) local b = role.GetRoleItemNum(TargetID, 3020054) -- В сундуке 4 разных предмета -> нужно минимум 4 свободных слота local needSlots = 4 if FreeSize < needSlots then bRet = 40 end if b == 0 then bRet = 103 end return bRet, bIgnore end function I3030103_GiftBag(MapID, InstanceID, TypeID, TargetID) local chunkSize = 1 local tbl = { {3030009, 1, 5, 2000}, {3030037, 1, 5, 2000}, {3030080, 1, 5, 2000}, {3030111, 3, 5, 4000} } local processed = 0 local b3030103 = role.GetRoleItemNum(TargetID, 3030103) local b3020054 = role.GetRoleItemNum(TargetID, 3020054) local skipBagRemoval = true while processed < b3030103 and b3020054 > 0 do local toProcess = math.min(b3030103 - processed, b3020054, chunkSize) if role.GetBagFreeSize(TargetID) < toProcess then break end local awarded = 0 for i = 1, toProcess do if role.GetRoleItemNum(TargetID, 3020054) <= 0 or role.GetRoleItemNum(TargetID, 3030103) <= 0 then break end local r = math.random(10000) local temp = 0 local index = 1 for j = 1, #tbl do temp = temp + tbl[j][4] if temp >= r then index = j break end end role.RemoveFromRole(MapID, InstanceID, TargetID, 3020054, 1, 101) if skipBagRemoval then skipBagRemoval = false else role.RemoveFromRole(MapID, InstanceID, TargetID, 3030103, 1, 101) end role.AddRoleItem(MapID, InstanceID, TargetID, tbl[index][1], tbl[index][2], tbl[index][3], 8, 35) awarded = awarded + 1 end if awarded == 0 then break end processed = processed + awarded b3020054 = role.GetRoleItemNum(TargetID, 3020054) b3030103 = role.GetRoleItemNum(TargetID, 3030103) break -- �������� �������� ��� ������ �������� ��� ���������� �������� �� ������ -- ��������, ����� ������������ ������ ��� ����������� ��������� end end aux.RegisterItemEvent(3030103, 1, "I3030103_GiftBag") aux.RegisterItemEvent(3030103, 0, "I3030103_CanUseGiftBag") function I3030104_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) local b = role.GetRoleItemNum(TargetID, 3020054) -- В сундуке 7 разных предметов -> нужно минимум 7 свободных слота local needSlots = 7 if FreeSize < needSlots then bRet = 40 end if b == 0 then bRet = 103 end return bRet, bIgnore end function I3030104_GiftBag(MapID, InstanceID, TypeID, TargetID) local chunkSize = 1 local tbl = { {3030001, 1, 5, 1500}, {3030002, 1, 5, 500}, {3030029, 1, 5, 1500}, {3030030, 1, 5, 500}, {3030072, 1, 5, 1500}, {3030073, 1, 5, 500}, {3030111, 3, 5, 4000} } local processed = 0 local b3030104 = role.GetRoleItemNum(TargetID, 3030104) local b3020054 = role.GetRoleItemNum(TargetID, 3020054) local skipBagRemoval = true while processed < b3030104 and b3020054 > 0 do local toProcess = math.min(b3030104 - processed, b3020054, chunkSize) if role.GetBagFreeSize(TargetID) < toProcess then break end local awarded = 0 for i = 1, toProcess do if role.GetRoleItemNum(TargetID, 3020054) <= 0 or role.GetRoleItemNum(TargetID, 3030104) <= 0 then break end local r = math.random(10000) local temp = 0 local index = 1 for j = 1, #tbl do temp = temp + tbl[j][4] if temp >= r then index = j break end end role.RemoveFromRole(MapID, InstanceID, TargetID, 3020054, 1, 101) if skipBagRemoval then skipBagRemoval = false else role.RemoveFromRole(MapID, InstanceID, TargetID, 3030104, 1, 101) end role.AddRoleItem(MapID, InstanceID, TargetID, tbl[index][1], tbl[index][2], tbl[index][3], 8, 35) awarded = awarded + 1 end if awarded == 0 then break end processed = processed + awarded b3020054 = role.GetRoleItemNum(TargetID, 3020054) b3030104 = role.GetRoleItemNum(TargetID, 3030104) break -- �������� �������� ��� ������ �������� ��� ���������� �������� �� ������ -- ��������, ����� ������������ ������ ��� ����������� ��������� end end aux.RegisterItemEvent(3030104, 1, "I3030104_GiftBag") aux.RegisterItemEvent(3030104, 0, "I3030104_CanUseGiftBag") function I3030105_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) local b = role.GetRoleItemNum(TargetID, 3020054) -- В сундуке 7 разных предметов -> нужно минимум 7 свободных слота local needSlots = 7 if FreeSize < needSlots then bRet = 40 end if b == 0 then bRet = 103 end return bRet, bIgnore end function I3030105_GiftBag(MapID, InstanceID, TypeID, TargetID) local chunkSize = 1 local tbl = { {3030009, 1, 5, 1500}, {3030010, 1, 5, 500}, {3030037, 1, 5, 1500}, {3030038, 1, 5, 500}, {3030080, 1, 5, 1500}, {3030081, 1, 5, 500}, {3030111, 3, 5, 4000} } local processed = 0 local b3030105 = role.GetRoleItemNum(TargetID, 3030105) local b3020054 = role.GetRoleItemNum(TargetID, 3020054) local skipBagRemoval = true while processed < b3030105 and b3020054 > 0 do local toProcess = math.min(b3030105 - processed, b3020054, chunkSize) if role.GetBagFreeSize(TargetID) < toProcess then break end local awarded = 0 for i = 1, toProcess do if role.GetRoleItemNum(TargetID, 3020054) <= 0 or role.GetRoleItemNum(TargetID, 3030105) <= 0 then break end local r = math.random(10000) local temp = 0 local index = 1 for j = 1, #tbl do temp = temp + tbl[j][4] if temp >= r then index = j break end end role.RemoveFromRole(MapID, InstanceID, TargetID, 3020054, 1, 101) if skipBagRemoval then skipBagRemoval = false else role.RemoveFromRole(MapID, InstanceID, TargetID, 3030105, 1, 101) end role.AddRoleItem(MapID, InstanceID, TargetID, tbl[index][1], tbl[index][2], tbl[index][3], 8, 35) awarded = awarded + 1 end if awarded == 0 then break end processed = processed + awarded b3020054 = role.GetRoleItemNum(TargetID, 3020054) b3030105 = role.GetRoleItemNum(TargetID, 3030105) break -- �������� �������� ��� ������ �������� ��� ���������� �������� �� ������ -- ��������, ����� ������������ ������ ��� ����������� ��������� end end aux.RegisterItemEvent(3030105, 1, "I3030105_GiftBag") aux.RegisterItemEvent(3030105, 0, "I3030105_CanUseGiftBag") function I3030106_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) local b = role.GetRoleItemNum(TargetID, 3020055) -- В сундуке 15 разных предметов -> нужно минимум 15 свободных слотов local needSlots = 15 if FreeSize < needSlots then bRet = 40 end if b == 0 then bRet = 103 end return bRet, bIgnore end function I3030106_GiftBag(MapID, InstanceID, TypeID, TargetID) local chunkSize = 1 local tbl = { {3030001, 1, 5, 400}, {3030002, 1, 5, 1000}, {3030003, 1, 5, 100}, {3030029, 1, 5, 600}, {3030030, 1, 5, 1200}, {3030031, 1, 5, 200}, {3030072, 1, 5, 400}, {3030073, 1, 5, 800}, {3030074, 1, 5, 200}, {3030023, 1, 5, 800}, {3030051, 1, 5, 800}, {3030093, 1, 5, 100}, {3030096, 1, 5, 100}, {3030099, 1, 5, 100}, {3030111, 3, 5, 3200} } local processed = 0 local b3030106 = role.GetRoleItemNum(TargetID, 3030106) local b3020055 = role.GetRoleItemNum(TargetID, 3020055) local skipBagRemoval = true while processed < b3030106 and b3020055 > 0 do local toProcess = math.min(b3030106 - processed, b3020055, chunkSize) if role.GetBagFreeSize(TargetID) < toProcess then break end local awarded = 0 for i = 1, toProcess do if role.GetRoleItemNum(TargetID, 3020055) <= 0 or role.GetRoleItemNum(TargetID, 3030106) <= 0 then break end local r = math.random(10000) local temp = 0 local index = 1 for j = 1, #tbl do temp = temp + tbl[j][4] if temp >= r then index = j break end end role.RemoveFromRole(MapID, InstanceID, TargetID, 3020055, 1, 101) if skipBagRemoval then skipBagRemoval = false else role.RemoveFromRole(MapID, InstanceID, TargetID, 3030106, 1, 101) end role.AddRoleItem(MapID, InstanceID, TargetID, tbl[index][1], tbl[index][2], tbl[index][3], 8, 35) awarded = awarded + 1 end if awarded == 0 then break end processed = processed + awarded b3020055 = role.GetRoleItemNum(TargetID, 3020055) b3030106 = role.GetRoleItemNum(TargetID, 3030106) break -- �������� �������� ��� ������ �������� ��� ���������� �������� �� ������ -- ��������, ����� ������������ ������ ��� ����������� ��������� end end aux.RegisterItemEvent(3030106, 1, "I3030106_GiftBag") aux.RegisterItemEvent(3030106, 0, "I3030106_CanUseGiftBag") function I3030107_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) local b = role.GetRoleItemNum(TargetID, 3020055) -- В сундуке 15 разных предметов -> нужно минимум 15 свободных слотов local needSlots = 15 if FreeSize < needSlots then bRet = 40 end if b == 0 then bRet = 103 end return bRet, bIgnore end function I3030107_GiftBag(MapID, InstanceID, TypeID, TargetID) local chunkSize = 1 local tbl = { {3030009, 1, 5, 400}, {3030010, 1, 5, 1000}, {3030011, 1, 5, 100}, {3030037, 1, 5, 600}, {3030038, 1, 5, 1200}, {3030039, 1, 5, 200}, {3030080, 1, 5, 400}, {3030081, 1, 5, 800}, {3030082, 1, 5, 200}, {3030017, 1, 5, 800}, {3030045, 1, 5, 800}, {3030093, 1, 5, 100}, {3030096, 1, 5, 100}, {3030099, 1, 5, 100}, {3030111, 3, 5, 3200} } local processed = 0 local b3030107 = role.GetRoleItemNum(TargetID, 3030107) local b3020055 = role.GetRoleItemNum(TargetID, 3020055) local skipBagRemoval = true while processed < b3030107 and b3020055 > 0 do local toProcess = math.min(b3030107 - processed, b3020055, chunkSize) if role.GetBagFreeSize(TargetID) < toProcess then break end local awarded = 0 for i = 1, toProcess do if role.GetRoleItemNum(TargetID, 3020055) <= 0 or role.GetRoleItemNum(TargetID, 3030107) <= 0 then break end local r = math.random(10000) local temp = 0 local index = 1 for j = 1, #tbl do temp = temp + tbl[j][4] if temp >= r then index = j break end end role.RemoveFromRole(MapID, InstanceID, TargetID, 3020055, 1, 101) if skipBagRemoval then skipBagRemoval = false else role.RemoveFromRole(MapID, InstanceID, TargetID, 3030107, 1, 101) end role.AddRoleItem(MapID, InstanceID, TargetID, tbl[index][1], tbl[index][2], tbl[index][3], 8, 35) awarded = awarded + 1 end if awarded == 0 then break end processed = processed + awarded b3020055 = role.GetRoleItemNum(TargetID, 3020055) b3030107 = role.GetRoleItemNum(TargetID, 3030107) break -- �������� �������� ��� ������ �������� ��� ���������� �������� �� ������ -- ��������, ����� ������������ ������ ��� ����������� ��������� end end aux.RegisterItemEvent(3030107, 1, "I3030107_GiftBag") aux.RegisterItemEvent(3030107, 0, "I3030107_CanUseGiftBag") function I3030108_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) local b = role.GetRoleItemNum(TargetID, 3020056) -- В сундуке 19 разных предметов -> нужно минимум 19 свободных слотов local needSlots = 19 if FreeSize < needSlots then bRet = 40 end if b == 0 then bRet = 103 end return bRet, bIgnore end function I3030108_GiftBag(MapID, InstanceID, TypeID, TargetID) local chunkSize = 1 local tbl = { {3030002, 1, 5, 600}, {3030003, 1, 5, 800}, {3030004, 1, 5, 100}, {3030030, 1, 5, 600}, {3030031, 1, 5, 1000}, {3030032, 1, 5, 200}, {3030073, 1, 5, 600}, {3030074, 1, 5, 800}, {3030075, 1, 5, 200}, {3030023, 1, 5, 800}, {3030024, 1, 5, 400}, {3030051, 1, 5, 800}, {3030052, 1, 5, 400}, {3030057, 1, 5, 200}, {3030067, 1, 5, 200}, {3030093, 1, 5, 100}, {3030096, 1, 5, 100}, {3030099, 1, 5, 100}, {3030111, 3, 5, 2000} } local processed = 0 local b3030108 = role.GetRoleItemNum(TargetID, 3030108) local b3020056 = role.GetRoleItemNum(TargetID, 3020056) local skipBagRemoval = true while processed < b3030108 and b3020056 > 0 do local toProcess = math.min(b3030108 - processed, b3020056, chunkSize) if role.GetBagFreeSize(TargetID) < toProcess then break end local awarded = 0 for i = 1, toProcess do if role.GetRoleItemNum(TargetID, 3020056) <= 0 or role.GetRoleItemNum(TargetID, 3030108) <= 0 then break end local r = math.random(10000) local temp = 0 local index = 1 for j = 1, #tbl do temp = temp + tbl[j][4] if temp >= r then index = j break end end role.RemoveFromRole(MapID, InstanceID, TargetID, 3020056, 1, 101) if skipBagRemoval then skipBagRemoval = false else role.RemoveFromRole(MapID, InstanceID, TargetID, 3030108, 1, 101) end role.AddRoleItem(MapID, InstanceID, TargetID, tbl[index][1], tbl[index][2], tbl[index][3], 8, 35) awarded = awarded + 1 end if awarded == 0 then break end processed = processed + awarded b3020056 = role.GetRoleItemNum(TargetID, 3020056) b3030108 = role.GetRoleItemNum(TargetID, 3030108) break -- �������� �������� ��� ������ �������� ��� ���������� �������� �� ������ -- ��������, ����� ������������ ������ ��� ����������� ��������� end end aux.RegisterItemEvent(3030108, 1, "I3030108_GiftBag") aux.RegisterItemEvent(3030108, 0, "I3030108_CanUseGiftBag") function I3030109_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) local b = role.GetRoleItemNum(TargetID, 3020056) -- В сундуке 19 разных предметов -> нужно минимум 19 свободных слотов local needSlots = 19 if FreeSize < needSlots then bRet = 40 end if b == 0 then bRet = 103 end return bRet, bIgnore end function I3030109_GiftBag(MapID, InstanceID, TypeID, TargetID) local chunkSize = 1 local tbl = { {3030010, 1, 5, 600}, {3030011, 1, 5, 800}, {3030012, 1, 5, 100}, {3030038, 1, 5, 600}, {3030039, 1, 5, 1000}, {3030040, 1, 5, 200}, {3030081, 1, 5, 600}, {3030082, 1, 5, 800}, {3030083, 1, 5, 200}, {3030017, 1, 5, 800}, {3030018, 1, 5, 400}, {3030045, 1, 5, 800}, {3030046, 1, 5, 400}, {3030062, 1, 5, 200}, {3030088, 1, 5, 200}, {3030093, 1, 5, 100}, {3030096, 1, 5, 100}, {3030099, 1, 5, 100}, {3030111, 3, 5, 2000} } local processed = 0 local b3030109 = role.GetRoleItemNum(TargetID, 3030109) local b3020056 = role.GetRoleItemNum(TargetID, 3020056) local skipBagRemoval = true while processed < b3030109 and b3020056 > 0 do local toProcess = math.min(b3030109 - processed, b3020056, chunkSize) if role.GetBagFreeSize(TargetID) < toProcess then break end local awarded = 0 for i = 1, toProcess do if role.GetRoleItemNum(TargetID, 3020056) <= 0 or role.GetRoleItemNum(TargetID, 3030109) <= 0 then break end local r = math.random(10000) local temp = 0 local index = 1 for j = 1, #tbl do temp = temp + tbl[j][4] if temp >= r then index = j break end end role.RemoveFromRole(MapID, InstanceID, TargetID, 3020056, 1, 101) if skipBagRemoval then skipBagRemoval = false else role.RemoveFromRole(MapID, InstanceID, TargetID, 3030109, 1, 101) end role.AddRoleItem(MapID, InstanceID, TargetID, tbl[index][1], tbl[index][2], tbl[index][3], 8, 35) awarded = awarded + 1 end if awarded == 0 then break end processed = processed + awarded b3020056 = role.GetRoleItemNum(TargetID, 3020056) b3030109 = role.GetRoleItemNum(TargetID, 3030109) break -- �������� �������� ��� ������ �������� ��� ���������� �������� �� ������ -- ��������, ����� ������������ ������ ��� ����������� ��������� end end aux.RegisterItemEvent(3030109, 1, "I3030109_GiftBag") aux.RegisterItemEvent(3030109, 0, "I3030109_CanUseGiftBag") function I3030110_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) local b = role.GetRoleItemNum(TargetID, 3020056) -- В сундуке 13 разных предметов -> нужно минимум 13 свободных слотов local needSlots = 13 if FreeSize < needSlots then bRet = 40 end if b == 0 then bRet = 103 end return bRet, bIgnore end function I3030110_GiftBag(MapID, InstanceID, TypeID, TargetID) local chunkSize = 1 local tbl = { {3030003, 1, 5, 800}, {3030004, 1, 5, 400}, {3030011, 1, 5, 1000}, {3030012, 1, 5, 600}, {3030031, 1, 5, 800}, {3030032, 1, 5, 400}, {3030039, 1, 5, 1000}, {3030040, 1, 5, 600}, {3030074, 1, 5, 800}, {3030075, 1, 5, 400}, {3030082, 1, 5, 1000}, {3030083, 1, 5, 600}, {3030111, 3, 5, 1600} } local processed = 0 local b3030110 = role.GetRoleItemNum(TargetID, 3030110) local b3020056 = role.GetRoleItemNum(TargetID, 3020056) local skipBagRemoval = true while processed < b3030110 and b3020056 > 0 do local freeSize = role.GetBagFreeSize(TargetID) if freeSize <= 0 then break end local toProcess = math.min(b3030110 - processed, b3020056, chunkSize, freeSize) local awarded = 0 for i = 1, toProcess do if role.GetRoleItemNum(TargetID, 3020056) <= 0 or role.GetRoleItemNum(TargetID, 3030110) <= 0 then break end local r = math.random(10000) local temp = 0 local index = 1 for j = 1, #tbl do temp = temp + tbl[j][4] if temp >= r then index = j break end end role.RemoveFromRole(MapID, InstanceID, TargetID, 3020056, 1, 101) if skipBagRemoval then skipBagRemoval = false else role.RemoveFromRole(MapID, InstanceID, TargetID, 3030110, 1, 101) end role.AddRoleItem(MapID, InstanceID, TargetID, tbl[index][1], tbl[index][2], tbl[index][3], 8, 35) awarded = awarded + 1 end if awarded == 0 then break end processed = processed + awarded b3020056 = role.GetRoleItemNum(TargetID, 3020056) b3030110 = role.GetRoleItemNum(TargetID, 3030110) break end end aux.RegisterItemEvent(3030110, 1, "I3030110_GiftBag") aux.RegisterItemEvent(3030110, 0, "I3030110_CanUseGiftBag")