function I4530101_GiftBag(MapID, InstanceID, TypeID, TargetID) local r = math.random(1, 250) local temp = 0 local index = 1 local tbl = {} tbl[1] = {3040004, 1, 5, 50} tbl[2] = {3040009, 1, 5, 50} tbl[3] = {3040014, 1, 5, 50} tbl[4] = {3040019, 1, 5, 50} tbl[5] = {3040024, 1, 5, 50} for i = 1, 5 do temp = temp + tbl[i][4] if temp >= r then index = i break end end role.AddRoleItem(MapID, InstanceID, TargetID, tbl[index][1], tbl[index][2], tbl[index][3], 8, 420) end function I4530101_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 1 then bRet = 40 end return bRet, bIgnore end aux.RegisterItemEvent(4530101, 1, "I4530101_GiftBag") aux.RegisterItemEvent(4530101, 0, "I4530101_CanUseGiftBag") function I4530104_GiftBag(MapID, InstanceID, TypeID, TargetID) local r = math.random(1, 500) local temp = 0 local index = 1 local tbl = {} tbl[1] = {3040029, 1, 5, 50} tbl[2] = {3040034, 1, 5, 50} tbl[3] = {3040039, 1, 5, 50} tbl[4] = {3040044, 1, 5, 50} tbl[5] = {3040049, 1, 5, 50} tbl[6] = {3040054, 1, 5, 50} tbl[7] = {3040059, 1, 5, 50} for i = 1, 7 do temp = temp + tbl[i][4] if temp >= r then index = i break end end role.AddRoleItem(MapID, InstanceID, TargetID, tbl[index][1], tbl[index][2], tbl[index][3], 8, 420) end function I4530104_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 1 then bRet = 40 end return bRet, bIgnore end aux.RegisterItemEvent(4530104, 1, "I4530104_GiftBag") aux.RegisterItemEvent(4530104, 0, "I4530104_CanUseGiftBag") function I4530106_GiftBag(MapID, InstanceID, TypeID, TargetID) local a = math.random(1, 10000) if a >= 1 and a <= 1900 then role.AddRoleItem(MapID, InstanceID, TargetID, 4500002, 5, -1, 8, 420) elseif a > 1900 and a <= 3730 then role.AddRoleItem(MapID, InstanceID, TargetID, 4500002, 2, -1, 8, 420) elseif a > 3730 and a <= 5230 then role.AddRoleItem(MapID, InstanceID, TargetID, 3070052, 15, -1, 8, 420) elseif a > 5230 and a <= 6530 then role.AddRoleItem(MapID, InstanceID, TargetID, 3020052, 1, -1, 8, 420) elseif a > 6530 and a <= 7830 then role.AddRoleItem(MapID, InstanceID, TargetID, 3020010, 1, -1, 8, 420) elseif a > 7830 and a <= 8330 then role.AddRoleItem(MapID, InstanceID, TargetID, 3070051, 2, -1, 8, 420) elseif a > 8330 and a <= 8830 then role.AddRoleItem(MapID, InstanceID, TargetID, 3020053, 1, -1, 8, 420) elseif a > 8830 and a <= 9340 then role.AddRoleItem(MapID, InstanceID, TargetID, 3020011, 1, -1, 8, 420) elseif a > 9340 and a <= 9540 then role.AddRoleItem(MapID, InstanceID, TargetID, 3030118, 1, -1, 8, 420) elseif a > 9540 and a <= 9740 then role.AddRoleItem(MapID, InstanceID, TargetID, 3030067, 1, -1, 8, 420) elseif a > 9740 and a <= 9920 then role.AddRoleItem(MapID, InstanceID, TargetID, 3020012, 1, -1, 8, 420) elseif a > 9920 and a <= 9970 then role.AddRoleItem(MapID, InstanceID, TargetID, 3020012, 2, -1, 8, 420) elseif a > 9970 and a <= 9990 then role.AddRoleItem(MapID, InstanceID, TargetID, 3050110, 1, -1, 8, 420) elseif a > 9990 and a <= 9995 then role.AddRoleItem(MapID, InstanceID, TargetID, 4221208, 1, -1, 8, 420) elseif a > 9995 and a <= 10000 then role.AddRoleItem(MapID, InstanceID, TargetID, 3020033, 1, -1, 8, 420) end end function I4530106_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 2 then bRet = 40 end return bRet, bIgnore end aux.RegisterItemEvent(4530106, 1, "I4530106_GiftBag") aux.RegisterItemEvent(4530106, 0, "I4530106_CanUseGiftBag") function I4530107_GiftBag(MapID, InstanceID, TypeID, TargetID) if role.IsRoleHaveQuest(MapID, InstanceID, TargetID, 30813) == true then HuoDeLiLian(MapID, InstanceID, TargetID, 52) LiLian_CheakComplete(MapID, InstanceID, TargetID) end local a = math.random(1, 6) role.AddRoleItem(MapID, InstanceID, TargetID, 4400003 + 3 * a, 1, -1, 8, 420) end function I4530107_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 2 then bRet = 40 end return bRet, bIgnore end aux.RegisterItemEvent(4530107, 1, "I4530107_GiftBag") aux.RegisterItemEvent(4530107, 0, "I4530107_CanUseGiftBag") function I4530108_GiftBag(MapID, InstanceID, TypeID, TargetID) if role.IsRoleHaveQuest(MapID, InstanceID, TargetID, 30814) == true then HuoDeLiLian(MapID, InstanceID, TargetID, 10) LiLian_CheakComplete(MapID, InstanceID, TargetID) end local a = math.random(1, 6) role.AddRoleItem(MapID, InstanceID, TargetID, 4400004 + 3 * a, 1, -1, 8, 420) end function I4530108_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 2 then bRet = 40 end return bRet, bIgnore end aux.RegisterItemEvent(4530108, 1, "I4530108_GiftBag") aux.RegisterItemEvent(4530108, 0, "I4530108_CanUseGiftBag") function I4530109_GiftBag(MapID, InstanceID, TypeID, TargetID) local a = math.random(1, 6) role.AddRoleItem(MapID, InstanceID, TargetID, 4400005 + 3 * a, 1, -1, 8, 420) end function I4530109_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 2 then bRet = 40 end return bRet, bIgnore end aux.RegisterItemEvent(4530109, 1, "I4530109_GiftBag") aux.RegisterItemEvent(4530109, 0, "I4530109_CanUseGiftBag") function I6600642_GiftBag(MapID, InstanceID, TypeID, TargetID) local r = math.random(1, 600) local temp = 0 local index = 1 local tbl = {} tbl[1] = {8099089, 1, 6, 100} tbl[2] = {8099090, 1, 6, 100} tbl[3] = {8099091, 1, 6, 100} tbl[4] = {8099092, 1, 6, 100} tbl[5] = {8099093, 1, 6, 100} tbl[6] = {8099094, 1, 6, 100} for i = 1, 6 do temp = temp + tbl[i][4] if temp >= r then index = i break end end role.AddRoleItem(MapID, InstanceID, TargetID, tbl[index][1], tbl[index][2], tbl[index][3], 8, 420) end function I6600642_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 1 then bRet = 40 end return bRet, bIgnore end aux.RegisterItemEvent(6600642, 1, "I6600642_GiftBag") aux.RegisterItemEvent(6600642, 0, "I6600642_CanUseGiftBag") function I4820074_GiftBag(MapID, InstanceID, TypeID, TargetID) local class = role.GetRoleClass(TargetID) if class == 2 or class == 6 or class == 7 then --�ӧ�ڧ� role.AddRoleItem(MapID, InstanceID, TargetID, 9900013, 1, 6, 8, 420) elseif class == 3 or class == 8 or class == 9 then --����֧ݧ�� role.AddRoleItem(MapID, InstanceID, TargetID, 9900014, 1, 6, 8, 420) elseif class == 5 or class == 12 or class == 13 then --�ҧѧ�� role.AddRoleItem(MapID, InstanceID, TargetID, 9900016, 1, 6, 8, 420) elseif class == 4 or class == 10 or class == 11 then --�ާѧ� role.AddRoleItem(MapID, InstanceID, TargetID, 9900015, 1, 6, 8, 420) end end aux.RegisterItemEvent(4820074, 1, "I4820074_GiftBag") function I4820074_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 1 then bRet = 40 end local class = role.GetRoleClass(TargetID) if class == 1 then bRet = 46 end return bRet, bIgnore end aux.RegisterItemEvent(4820074, 0, "I4820074_CanUseGiftBag") function I4820077_GiftBag(MapID, InstanceID, TypeID, TargetID) local class = role.GetRoleClass(TargetID) if class == 2 or class == 6 or class == 7 then --�ӧ�ڧ� role.AddRoleItem(MapID, InstanceID, TargetID, 9900009, 1, 6, 8, 420) elseif class == 3 or class == 8 or class == 9 then --����֧ݧ�� role.AddRoleItem(MapID, InstanceID, TargetID, 9900010, 1, 6, 8, 420) elseif class == 5 or class == 12 or class == 13 then --�ҧѧ�� role.AddRoleItem(MapID, InstanceID, TargetID, 9900012, 1, 6, 8, 420) elseif class == 4 or class == 10 or class == 11 then --�ާѧ� role.AddRoleItem(MapID, InstanceID, TargetID, 9900011, 1, 6, 8, 420) end end aux.RegisterItemEvent(4820077, 1, "I4820077_GiftBag") function I4820077_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 1 then bRet = 40 end local class = role.GetRoleClass(TargetID) if class == 1 then bRet = 46 end return bRet, bIgnore end aux.RegisterItemEvent(4820077, 0, "I4820077_CanUseGiftBag") function I4010099_GiftBag(MapID, InstanceID, TypeID, TargetID) local r = math.random(1, 2) local temp = 0 local index = 1 local tbl = {} tbl[1] = {4222601, 1, 5, 1} tbl[2] = {4222701, 1, 5, 1} for i = 1, 2 do temp = temp + tbl[i][4] if temp >= r then index = i break end end role.AddRoleItem(MapID, InstanceID, TargetID, tbl[index][1], tbl[index][2], tbl[index][3], 8, 420) end aux.RegisterItemEvent(4010099, 1, "I4010099_GiftBag") function I4010099_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 1 then bRet = 40 end return bRet, bIgnore end aux.RegisterItemEvent(4010099, 0, "I4010099_CanUseGiftBag") function I4010100_GiftBag(MapID, InstanceID, TypeID, TargetID) local r = math.random(1, 2) local temp = 0 local index = 1 local tbl = {} tbl[1] = {4222401, 1, 5, 1} tbl[2] = {4222501, 1, 5, 1} for i = 1, 2 do temp = temp + tbl[i][4] if temp >= r then index = i break end end role.AddRoleItem(MapID, InstanceID, TargetID, tbl[index][1], tbl[index][2], tbl[index][3], 8, 420) end aux.RegisterItemEvent(4010100, 1, "I4010100_GiftBag") function I4010100_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 1 then bRet = 40 end return bRet, bIgnore end aux.RegisterItemEvent(4010100, 0, "I4010100_CanUseGiftBag") function I4010101_GiftBag(MapID, InstanceID, TypeID, TargetID) local class = role.GetRoleClass(TargetID) if class == 2 or class == 6 or class == 7 then --�ӧ�ڧ� role.AddRoleItem(MapID, InstanceID, TargetID, 9900005, 1, 6, 8, 420) elseif class == 3 or class == 8 or class == 9 then --����֧ݧ�� role.AddRoleItem(MapID, InstanceID, TargetID, 9900006, 1, 6, 8, 420) elseif class == 5 or class == 12 or class == 13 then --�ҧѧ�� role.AddRoleItem(MapID, InstanceID, TargetID, 9900008, 1, 6, 8, 420) elseif class == 4 or class == 10 or class == 11 then --�ާѧ� role.AddRoleItem(MapID, InstanceID, TargetID, 9900007, 1, 6, 8, 420) end end aux.RegisterItemEvent(4010101, 1, "I4010101_GiftBag") function I4010101_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 1 then bRet = 40 end local class = role.GetRoleClass(TargetID) if class == 1 then bRet = 46 end return bRet, bIgnore end aux.RegisterItemEvent(4010101, 0, "I4010101_CanUseGiftBag") function I4010102_GiftBag(MapID, InstanceID, TypeID, TargetID) local class = role.GetRoleClass(TargetID) if class == 2 or class == 6 or class == 7 then --�ӧ�ڧ� role.AddRoleItem(MapID, InstanceID, TargetID, 9900001, 1, 6, 8, 420) elseif class == 3 or class == 8 or class == 9 then --����֧ݧ�� role.AddRoleItem(MapID, InstanceID, TargetID, 9900002, 1, 6, 8, 420) elseif class == 5 or class == 12 or class == 13 then --�ҧѧ�� role.AddRoleItem(MapID, InstanceID, TargetID, 9900004, 1, 6, 8, 420) elseif class == 4 or class == 10 or class == 11 then --�ާѧ� role.AddRoleItem(MapID, InstanceID, TargetID, 9900003, 1, 6, 8, 420) end end aux.RegisterItemEvent(4010102, 1, "I4010102_GiftBag") function I4010102_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 1 then bRet = 40 end local class = role.GetRoleClass(TargetID) if class == 1 then bRet = 46 end return bRet, bIgnore end aux.RegisterItemEvent(4010102, 0, "I4010102_CanUseGiftBag") function I4010103_GiftBag(MapID, InstanceID, TypeID, TargetID) local class = role.GetRoleClass(TargetID) if class == 2 or class == 6 or class == 7 then --�ӧ�ڧ� role.AddRoleItem(MapID, InstanceID, TargetID, 9900009, 1, 6, 8, 420) elseif class == 3 or class == 8 or class == 9 then --����֧ݧ�� role.AddRoleItem(MapID, InstanceID, TargetID, 9900010, 1, 6, 8, 420) elseif class == 5 or class == 12 or class == 13 then --�ҧѧ�� role.AddRoleItem(MapID, InstanceID, TargetID, 9900012, 1, 6, 8, 420) elseif class == 4 or class == 10 or class == 11 then --�ާѧ� role.AddRoleItem(MapID, InstanceID, TargetID, 9900011, 1, 6, 8, 420) end end aux.RegisterItemEvent(4010103, 1, "I4010103_GiftBag") function I4010103_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 1 then bRet = 40 end local class = role.GetRoleClass(TargetID) if class == 1 then bRet = 46 end return bRet, bIgnore end aux.RegisterItemEvent(4010103, 0, "I4010103_CanUseGiftBag") function I4530242_GiftBag(MapID, InstanceID, TypeID, TargetID) local r = math.random(1, 600) local temp = 0 local index = 1 local tbl = {} tbl[1] = {4400059, 1, 5, 100} tbl[2] = {4400060, 1, 5, 100} tbl[3] = {4400061, 1, 5, 100} tbl[4] = {4400062, 1, 5, 100} tbl[5] = {4400063, 1, 5, 100} tbl[6] = {4400064, 1, 5, 100} for i = 1, 6 do temp = temp + tbl[i][4] if temp >= r then index = i break end end role.AddRoleItem(MapID, InstanceID, TargetID, tbl[index][1], tbl[index][2], tbl[index][3], 8, 420) end aux.RegisterItemEvent(4530242, 1, "I4530242_GiftBag") function I4530242_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 1 then bRet = 40 end return bRet, bIgnore end aux.RegisterItemEvent(4530242, 0, "I4530242_CanUseGiftBag") function I4530243_GiftBag(MapID, InstanceID, TypeID, TargetID) local r = math.random(1, 600) local temp = 0 local index = 1 local tbl = {} tbl[1] = {4400059, 1, 5, 100} tbl[2] = {4400060, 1, 5, 100} tbl[3] = {4400061, 1, 5, 100} tbl[4] = {4400062, 1, 5, 100} tbl[5] = {4400063, 1, 5, 100} tbl[6] = {4400064, 1, 5, 100} for i = 1, 6 do temp = temp + tbl[i][4] if temp >= r then index = i break end end role.AddRoleItem(MapID, InstanceID, TargetID, tbl[index][1], tbl[index][2], tbl[index][3], 8, 420) end aux.RegisterItemEvent(4530243, 1, "I4530243_GiftBag") function I4530243_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 1 then bRet = 40 end return bRet, bIgnore end aux.RegisterItemEvent(4530243, 0, "I4530243_CanUseGiftBag") function I4700048_GiftBag(MapID, InstanceID, TypeID, TargetID) local r = math.random(1, 600) local temp = 0 local index = 1 local tbl = {} tbl[1] = {4090022, 1, 1, 100} tbl[2] = {4400031, 1, 1, 100} tbl[3] = {4500002, 8, 1, 100} tbl[4] = {4820043, 5, 1, 100} tbl[5] = {3070052, 10, 1, 100} tbl[6] = {3020007, 2, 1, 100} for i = 1, 6 do temp = temp + tbl[i][4] if temp >= r then index = i break end end role.AddRoleItem(MapID, InstanceID, TargetID, tbl[index][1], tbl[index][2], tbl[index][3], 8, 420) end aux.RegisterItemEvent(4700048, 1, "I4700048_GiftBag") function I4700048_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 1 then bRet = 40 end return bRet, bIgnore end aux.RegisterItemEvent(4700048, 0, "I4700048_CanUseGiftBag") function I4700050_GiftBag(MapID, InstanceID, TypeID, TargetID) local r = math.random(1, 10000) local temp = 0 local index = 1 local tbl = {} tbl[1] = {4820029, 1, 1, 1800} tbl[2] = {4820029, 20, 1, 100} tbl[3] = {4820029, 100, 1, 25} tbl[4] = {3030119, 1, 1, 200} tbl[5] = {3070019, 3, 1, 1360} tbl[6] = {3070052, 15, 1, 1290} tbl[7] = {4080097, 1, 1, 1210} tbl[8] = {3070002, 20, 1, 1200} tbl[9] = {3070002, 1, 1, 500} tbl[10] = {4100615, 1, 1, 10} tbl[11] = {4530109, 1, 1, 700} tbl[12] = {4820043, 1, 1, 1000} tbl[13] = {4820043, 5, 1, 600} tbl[14] = {3020087, 1, 1, 4} tbl[15] = {3020090, 1, 1, 1} for i = 1, 15 do temp = temp + tbl[i][4] if temp >= r then index = i break end end role.AddRoleItem(MapID, InstanceID, TargetID, tbl[index][1], tbl[index][2], tbl[index][3], 8, 420) end aux.RegisterItemEvent(4700050, 1, "I4700050_GiftBag") function I4700050_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 1 then bRet = 40 end return bRet, bIgnore end aux.RegisterItemEvent(4700050, 0, "I4700050_CanUseGiftBag") function I4700229_GiftBag(MapID, InstanceID, TypeID, TargetID) local waigong = {8010018, 8020018, 8050018, 8060018, 8070018, 8080018, 8090018, 8100018, 8110018, 8121018, 8130018} local neigong = {8030018, 8040018, 8051018, 8061018, 8071018, 8081018, 8091018, 8100018, 8111018, 8122018, 8130018} local class = role.GetRoleClass(TargetID) if class == 1 or class == 2 or class == 6 or class == 7 then role.AddRoleItem(MapID, InstanceID, TargetID, waigong[math.random(1, 11)], 1, 4, 8, 420) elseif class == 3 or class == 8 or class == 9 then role.AddRoleItem(MapID, InstanceID, TargetID, waigong[math.random(1, 11)], 1, 4, 8, 420) elseif class == 4 or class == 10 or class == 11 then role.AddRoleItem(MapID, InstanceID, TargetID, neigong[math.random(1, 11)], 1, 4, 8, 420) elseif class == 5 or class == 12 or class == 13 then role.AddRoleItem(MapID, InstanceID, TargetID, neigong[math.random(1, 11)], 1, 4, 8, 420) end end aux.RegisterItemEvent(4700229, 1, "I4700229_GiftBag") function I4700229_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 1 then bRet = 40 end return bRet, bIgnore end aux.RegisterItemEvent(4700229, 0, "I4700229_CanUseGiftBag") function I4700230_GiftBag(MapID, InstanceID, TypeID, TargetID) local waigong = {8010018, 8020018, 8050018, 8060018, 8070018, 8080018, 8090018, 8100018, 8110018, 8121018, 8130018} local neigong = {8030018, 8040018, 8051018, 8061018, 8071018, 8081018, 8091018, 8100018, 8111018, 8122018, 8130018} local class = role.GetRoleClass(TargetID) if class == 1 or class == 2 or class == 6 or class == 7 then role.AddRoleItem(MapID, InstanceID, TargetID, waigong[math.random(1, 11)] + 1, 1, 4, 8, 420) elseif class == 3 or class == 8 or class == 9 then role.AddRoleItem(MapID, InstanceID, TargetID, waigong[math.random(1, 11)] + 1, 1, 4, 8, 420) elseif class == 4 or class == 10 or class == 11 then role.AddRoleItem(MapID, InstanceID, TargetID, neigong[math.random(1, 11)] + 1, 1, 4, 8, 420) elseif class == 5 or class == 12 or class == 13 then role.AddRoleItem(MapID, InstanceID, TargetID, neigong[math.random(1, 11)] + 1, 1, 4, 8, 420) end end aux.RegisterItemEvent(4700230, 1, "I4700230_GiftBag") function I4700230_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 1 then bRet = 40 end return bRet, bIgnore end aux.RegisterItemEvent(4700230, 0, "I4700230_CanUseGiftBag") function I4700231_GiftBag(MapID, InstanceID, TypeID, TargetID) local waigong = {8010018, 8020018, 8050018, 8060018, 8070018, 8080018, 8090018, 8100018, 8110018, 8121018, 8130018} local neigong = {8030018, 8040018, 8051018, 8061018, 8071018, 8081018, 8091018, 8100018, 8111018, 8122018, 8130018} local class = role.GetRoleClass(TargetID) if class == 1 or class == 2 or class == 6 or class == 7 then role.AddRoleItem(MapID, InstanceID, TargetID, waigong[math.random(1, 11)] + 2, 1, 4, 8, 420) elseif class == 3 or class == 8 or class == 9 then role.AddRoleItem(MapID, InstanceID, TargetID, waigong[math.random(1, 11)] + 2, 1, 4, 8, 420) elseif class == 4 or class == 10 or class == 11 then role.AddRoleItem(MapID, InstanceID, TargetID, neigong[math.random(1, 11)] + 2, 1, 4, 8, 420) elseif class == 5 or class == 12 or class == 13 then role.AddRoleItem(MapID, InstanceID, TargetID, neigong[math.random(1, 11)] + 2, 1, 4, 8, 420) end end function I4700231_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 1 then bRet = 40 end return bRet, bIgnore end aux.RegisterItemEvent(4700231, 1, "I4700231_GiftBag") aux.RegisterItemEvent(4700231, 0, "I4700231_CanUseGiftBag") function I4700295_GiftBag(MapID, InstanceID, TypeID, TargetID) local class = role.GetRoleClass(TargetID) if class == 1 or class == 2 or class == 3 or class == 6 or class == 7 or class == 8 or class == 9 then role.AddRoleItem(MapID, InstanceID, TargetID, 8161011, 1, 6, 8, 420) elseif class == 4 or class == 5 or class == 10 or class == 11 or class == 12 or class == 13 then role.AddRoleItem(MapID, InstanceID, TargetID, 8171011, 1, 6, 8, 420) end end function I4700295_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 1 then bRet = 40 end return bRet, bIgnore end aux.RegisterItemEvent(4700295, 1, "I4700295_GiftBag") aux.RegisterItemEvent(4700295, 0, "I4700295_CanUseGiftBag") function I4800153_GiftBag(MapID, InstanceID, TypeID, TargetID) local r = math.random(1, 400) local temp = 0 local index = 1 local tbl = {} tbl[1] = {3100097, 1, 5, 50} tbl[2] = {3100107, 1, 5, 50} tbl[3] = {3100117, 1, 5, 50} tbl[4] = {3100127, 1, 5, 50} tbl[5] = {3100137, 1, 5, 50} tbl[6] = {3100147, 1, 5, 50} tbl[7] = {3100157, 1, 5, 50} tbl[8] = {3100167, 1, 5, 50} for i = 1, 8 do temp = temp + tbl[i][4] if temp >= r then index = i break end end role.AddRoleItem(MapID, InstanceID, TargetID, tbl[index][1], tbl[index][2], tbl[index][3], 8, 420) end function I4800153_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 1 then bRet = 40 end return bRet, bIgnore end aux.RegisterItemEvent(4800153, 1, "I4800153_GiftBag") aux.RegisterItemEvent(4800153, 0, "I4800153_CanUseGiftBag") function I4800154_GiftBag(MapID, InstanceID, TypeID, TargetID) local r = math.random(1, 400) local temp = 0 local index = 1 local tbl = {} tbl[1] = {3100098, 1, 5, 50} tbl[2] = {3100108, 1, 5, 50} tbl[3] = {3100118, 1, 5, 50} tbl[4] = {3100128, 1, 5, 50} tbl[5] = {3100138, 1, 5, 50} tbl[6] = {3100148, 1, 5, 50} tbl[7] = {3100158, 1, 5, 50} tbl[8] = {3100168, 1, 5, 50} for i = 1, 8 do temp = temp + tbl[i][4] if temp >= r then index = i break end end role.AddRoleItem(MapID, InstanceID, TargetID, tbl[index][1], tbl[index][2], tbl[index][3], 8, 420) end function I4800154_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 1 then bRet = 40 end return bRet, bIgnore end aux.RegisterItemEvent(4800154, 1, "I4800154_GiftBag") aux.RegisterItemEvent(4800154, 0, "I4800154_CanUseGiftBag") function I6600301_GiftBag(MapID, InstanceID, TypeID, TargetID) local r = math.random(1, 500) local temp = 0 local index = 1 local tbl = {} tbl[1] = {5802609, 1, 5, 100} tbl[2] = {5802614, 1, 5, 100} tbl[3] = {5802619, 1, 5, 100} tbl[4] = {5802624, 1, 5, 100} tbl[5] = {5802629, 1, 5, 100} for i = 1, 5 do temp = temp + tbl[i][4] if temp >= r then index = i break end end role.AddRoleItem(MapID, InstanceID, TargetID, tbl[index][1], tbl[index][2], tbl[index][3], 8, 420) end function I6600301_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 1 then bRet = 40 end return bRet, bIgnore end aux.RegisterItemEvent(6600301, 1, "I6600301_GiftBag") aux.RegisterItemEvent(6600301, 0, "I6600301_CanUseGiftBag") function I6600302_GiftBag(MapID, InstanceID, TypeID, TargetID) local r = math.random(1, 500) local temp = 0 local index = 1 local tbl = {} tbl[1] = {5802610, 1, 5, 100} tbl[2] = {5802615, 1, 5, 100} tbl[3] = {5802620, 1, 5, 100} tbl[4] = {5802625, 1, 5, 100} tbl[5] = {5802630, 1, 5, 100} for i = 1, 5 do temp = temp + tbl[i][4] if temp >= r then index = i break end end role.AddRoleItem(MapID, InstanceID, TargetID, tbl[index][1], tbl[index][2], tbl[index][3], 8, 420) end function I6600302_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 1 then bRet = 40 end return bRet, bIgnore end aux.RegisterItemEvent(6600302, 1, "I6600302_GiftBag") aux.RegisterItemEvent(6600302, 0, "I6600302_CanUseGiftBag") function I6600303_GiftBag(MapID, InstanceID, TypeID, TargetID) local r = math.random(1, 700) local temp = 0 local index = 1 local tbl = {} tbl[1] = {5802634, 1, 5, 100} tbl[2] = {5802639, 1, 5, 100} tbl[3] = {5802644, 1, 5, 100} tbl[4] = {5802649, 1, 5, 100} tbl[5] = {5802654, 1, 5, 100} tbl[6] = {5802659, 1, 5, 100} tbl[7] = {5802664, 1, 5, 100} for i = 1, 7 do temp = temp + tbl[i][4] if temp >= r then index = i break end end role.AddRoleItem(MapID, InstanceID, TargetID, tbl[index][1], tbl[index][2], tbl[index][3], 8, 420) end function I6600303_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 1 then bRet = 40 end return bRet, bIgnore end aux.RegisterItemEvent(6600303, 1, "I6600303_GiftBag") aux.RegisterItemEvent(6600303, 0, "I6600303_CanUseGiftBag") function I6600304_GiftBag(MapID, InstanceID, TypeID, TargetID) local r = math.random(1, 700) local temp = 0 local index = 1 local tbl = {} tbl[1] = {5802635, 1, 5, 100} tbl[2] = {5802640, 1, 5, 100} tbl[3] = {5802645, 1, 5, 100} tbl[4] = {5802650, 1, 5, 100} tbl[5] = {5802655, 1, 5, 100} tbl[6] = {5802660, 1, 5, 100} tbl[7] = {5802665, 1, 5, 100} for i = 1, 7 do temp = temp + tbl[i][4] if temp >= r then index = i break end end role.AddRoleItem(MapID, InstanceID, TargetID, tbl[index][1], tbl[index][2], tbl[index][3], 8, 420) end function I6600304_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 1 then bRet = 40 end return bRet, bIgnore end aux.RegisterItemEvent(6600304, 1, "I6600304_GiftBag") aux.RegisterItemEvent(6600304, 0, "I6600304_CanUseGiftBag") function I6600587_GiftBag(MapID, InstanceID, TypeID, TargetID) local r = math.random(1, 2000) local temp = 0 local index = 1 local tbl = {} tbl[1] = {9990002, 1, 6, 1000} tbl[2] = {9990003, 1, 6, 1000} for i = 1, #tbl do temp = temp + tbl[i][4] if temp >= r then index = i break end end role.AddRoleItem(MapID, InstanceID, TargetID, tbl[index][1], tbl[index][2], tbl[index][3], 8, 420) end function I6600587_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 1 then bRet = 40 end return bRet, bIgnore end aux.RegisterItemEvent(6600587, 1, "I6600587_GiftBag") aux.RegisterItemEvent(6600587, 0, "I6600587_CanUseGiftBag") function I6600591_GiftBag(MapID, InstanceID, TypeID, TargetID) local r = math.random(1, 23000) local temp = 0 local index = 1 local tbl = {} tbl[1] = {8099029, 1, 6, 1000} tbl[2] = {8099030, 1, 6, 1000} tbl[3] = {8099031, 1, 6, 1000} tbl[4] = {8099032, 1, 6, 1000} tbl[5] = {8099033, 1, 6, 1000} tbl[6] = {8099034, 1, 6, 1000} tbl[7] = {8099035, 1, 6, 1000} tbl[8] = {8099036, 1, 6, 1000} tbl[9] = {8099037, 1, 6, 1000} tbl[10] = {8099038, 1, 6, 1000} tbl[11] = {8099039, 1, 6, 1000} tbl[12] = {8099040, 1, 6, 1000} tbl[13] = {8099041, 1, 6, 1000} tbl[14] = {8099042, 1, 6, 1000} tbl[15] = {8099043, 1, 6, 1000} tbl[16] = {8099044, 1, 6, 1000} tbl[17] = {8099045, 1, 6, 1000} tbl[18] = {8099046, 1, 6, 1000} tbl[19] = {8099047, 1, 6, 1000} tbl[20] = {8099048, 1, 6, 1000} tbl[21] = {8099049, 1, 6, 1000} tbl[22] = {8099050, 1, 6, 1000} tbl[23] = {8099051, 1, 6, 1000} for i = 1, #tbl do temp = temp + tbl[i][4] if temp >= r then index = i break end end role.AddRoleItem(MapID, InstanceID, TargetID, tbl[index][1], tbl[index][2], tbl[index][3], 8, 420) end function I6600591_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) if FreeSize < 1 then bRet = 40 end return bRet, bIgnore end aux.RegisterItemEvent(6600591, 1, "I6600591_GiftBag") aux.RegisterItemEvent(6600591, 0, "I6600591_CanUseGiftBag") function I6600318_GiftBag(MapID, InstanceID, TypeID, TargetID) local randomTable = { {itemID = 4530110, count = 5, chance = 140}, -- Зелье веры {itemID = 4500002, count = 5, chance = 130}, -- Заказ {itemID = 3020082, count = 1, chance = 120}, -- Магическое ожерелье +10 {itemID = 4400024, count = 1, chance = 110}, -- Камень истины {itemID = 3060005, count = 1, chance = 90}, -- Пыльца эльфов [Ур. 5] {itemID = 3070019, count = 1, chance = 80}, -- Свиток воскрешения {itemID = 3070023, count = 1, chance = 70}, -- Эликсир эльфов {itemID = 3060063, count = 1, chance = 60}, -- Пыльца эльфов [6 ур.] {itemID = 3020069, count = 1, chance = 50}, -- Руна стража [+16] {itemID = 3060059, count = 1, chance = 40}, -- Высший эликсир эльфов {itemID = 3020071, count = 1, chance = 30}, -- Руна стража [+19] {itemID = 3020032, count = 1, chance = 20}, -- Камень души +15 {itemID = 3020033, count = 1, chance = 15}, -- Камень души +16 {itemID = 3020034, count = 1, chance = 10}, -- Камень души +17 {itemID = 3020035, count = 1, chance = 5}, -- Камень души +18 {itemID = 3020036, count = 1, chance = 3}, -- Камень души +19 {itemID = 3020037, count = 1, chance = 2}, -- Камень души +20 {itemID = 4820180, count = 1, chance = 3}, -- Плейона {itemID = 3020139, count = 1, chance = 10}, -- Руна стража [+25][перс.] } local totalChance = 0 for _, entry in ipairs(randomTable) do totalChance = totalChance + entry.chance end if totalChance ~= 988 then -- Handle the error if totalChance is not as expected return end local r = math.random(1, 988) local cumulativeChance = 0 local index = 0 for i, entry in ipairs(randomTable) do cumulativeChance = cumulativeChance + entry.chance if r <= cumulativeChance then index = i break end end if index > 0 then local selectedItem = randomTable[index] role.AddRoleItem(MapID, InstanceID, TargetID, selectedItem.itemID, selectedItem.count, -1, 8, 420) role.RemoveFromRole(MapID, InstanceID, TargetID, 6600321, 1, 101) -- Золотой ключ end end function I6600318_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) local b = role.GetRoleItemNum(TargetID, 6600321) -- Золотой ключ if FreeSize < 1 then bRet = 40 end if b < 1 then bRet = 103 end return bRet, bIgnore end aux.RegisterItemEvent(6600318, 1, "I6600318_GiftBag") -- Сундук торговой гильдии aux.RegisterItemEvent(6600318, 0, "I6600318_CanUseGiftBag") -- Сундук торговой гильдии function I6600319_GiftBag(MapID, InstanceID, TypeID, TargetID) local randomTable = { {itemID = 4500002, count = 5, chance = 240}, -- Заказ [перс.] {itemID = 4530110, count = 5, chance = 230}, -- Зелье веры {itemID = 4400024, count = 1, chance = 70}, -- Камень истины {itemID = 3020082, count = 1, chance = 110}, -- Магическое ожерелье +10 {itemID = 3060005, count = 1, chance = 200}, -- Пыльца эльфов [Ур. 5] {itemID = 3060063, count = 1, chance = 90}, -- Пыльца эльфов [6 ур.] {itemID = 3070023, count = 1, chance = 40}, -- Эликсир эльфов {itemID = 3070019, count = 1, chance = 60}, -- Свиток воскрешения {itemID = 3060059, count = 1, chance = 30}, -- Высший эликсир эльфов {itemID = 3020069, count = 1, chance = 40}, -- Руна стража [+16] {itemID = 3020032, count = 1, chance = 30}, -- Камень души +15 {itemID = 4820180, count = 1, chance = 20}, -- Плейона {itemID = 3020033, count = 1, chance = 15}, -- Камень души +16 {itemID = 3020034, count = 1, chance = 5}, -- Камень души +17 {itemID = 3020035, count = 1, chance = 2}, -- Камень души +18 } local totalChance = 0 for _, entry in ipairs(randomTable) do totalChance = totalChance + entry.chance end if totalChance ~= 1182 then -- Handle the error if totalChance is not as expected return end local r = math.random(1, 1182) local cumulativeChance = 0 local index = 0 for i, entry in ipairs(randomTable) do cumulativeChance = cumulativeChance + entry.chance if r <= cumulativeChance then index = i break end end if index > 0 then local selectedItem = randomTable[index] role.AddRoleItem(MapID, InstanceID, TargetID, selectedItem.itemID, selectedItem.count, -1, 8, 420) role.RemoveFromRole(MapID, InstanceID, TargetID, 6600322, 1, 101) -- Серебряный ключ end end function I6600319_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) local b = role.GetRoleItemNum(TargetID, 6600322) -- Серебряный ключ if FreeSize < 1 then bRet = 40 end if b < 1 then bRet = 103 end return bRet, bIgnore end aux.RegisterItemEvent(6600319, 1, "I6600319_GiftBag") -- Сундук торгового каравана aux.RegisterItemEvent(6600319, 0, "I6600319_CanUseGiftBag") -- Сундук торгового каравана function I6600320_GiftBag(MapID, InstanceID, TypeID, TargetID) local randomTable = { {itemID = 4530110, count = 3, chance = 280}, -- Зелье веры {itemID = 4500002, count = 3, chance = 240}, -- Заказ {itemID = 3020082, count = 1, chance = 90}, -- Магическое ожерелье +10 {itemID = 3070019, count = 1, chance = 60}, -- Свиток воскрешения {itemID = 3070023, count = 1, chance = 50}, -- Эликсир эльфов {itemID = 4400024, count = 1, chance = 50}, -- Камень истины {itemID = 3060005, count = 1, chance = 80}, -- Пыльца эльфов [Ур. 5] {itemID = 3060063, count = 1, chance = 70}, -- Пыльца эльфов [6 ур.] {itemID = 3060059, count = 1, chance = 40}, -- Высший эликсир эльфов {itemID = 3020069, count = 1, chance = 40}, -- Руна стража [+16] {itemID = 4820180, count = 1, chance = 5}, -- Плейона {itemID = 3020032, count = 1, chance = 15}, -- Камень души +15 {itemID = 3020033, count = 1, chance = 5} -- Камень души +16 } local totalChance = 0 for _, entry in ipairs(randomTable) do totalChance = totalChance + entry.chance end if totalChance ~= 1025 then -- Handle the error if totalChance is not as expected return end local r = math.random(1, 1025) local cumulativeChance = 0 local index = 0 for i, entry in ipairs(randomTable) do cumulativeChance = cumulativeChance + entry.chance if r <= cumulativeChance then index = i break end end if index > 0 then local selectedItem = randomTable[index] role.AddRoleItem(MapID, InstanceID, TargetID, selectedItem.itemID, selectedItem.count, -1, 8, 420) role.RemoveFromRole(MapID, InstanceID, TargetID, 6600323, 1, 101) -- Бронзовый ключ end end function I6600320_CanUseGiftBag(MapID, InstanceID, TypeID, TargetID) local bRet, bIgnore = 0, false local FreeSize = role.GetBagFreeSize(TargetID) local b = role.GetRoleItemNum(TargetID, 6600323) -- Бронзовый ключ if FreeSize < 1 then bRet = 40 end if b < 1 then bRet = 103 end return bRet, bIgnore end aux.RegisterItemEvent(6600320, 1, "I6600320_GiftBag") -- Сундук торговца aux.RegisterItemEvent(6600320, 0, "I6600320_CanUseGiftBag") -- Сундук торговца