quest new_christmas_gift_box begin
	state start begin
	
		function give_item_with_log(vnum, amount,item_id)
			if vnum == 1 then 
				pc.changegold(amount)
			else
				pc.give_item2(vnum,amount)
			end
			char_log(tonumber(item_id), "XMAS_BOX","reward vnum: "..vnum.." reward amount: "..amount);
		end
		
		function gift(item_id)
			local n = number (1,100)
			if n <= 4 then
				new_christmas_gift_box.give_item_with_log(25100,1,item_id)
			elseif n <= 8 then
				new_christmas_gift_box.give_item_with_log(71084,1,item_id)
			elseif n <= 12 then
				new_christmas_gift_box.give_item_with_log(71085,1,item_id)
			elseif n <= 16 then
				new_christmas_gift_box.give_item_with_log(71109,1,item_id)
			elseif n <= 21 then
				new_christmas_gift_box.give_item_with_log(25040,1,item_id)
			elseif n <= 26 then
				new_christmas_gift_box.give_item_with_log(71101,3,item_id)
			elseif n <= 31 then
				new_christmas_gift_box.give_item_with_log(71107,1,item_id)
			elseif n <= 40 then
				new_christmas_gift_box.give_item_with_log(50513,1,item_id)
			elseif n <= 50 then
				new_christmas_gift_box.give_item_with_log(1,100000,item_id)
			elseif n <= 61 then
				new_christmas_gift_box.give_item_with_log(1,50000,item_id)
			elseif n <= 73 then
				new_christmas_gift_box.give_item_with_log(1,30000,item_id)
			elseif n <= 86 then
				new_christmas_gift_box.give_item_with_log(1,20000,item_id)
			else
				new_christmas_gift_box.give_item_with_log(1,10000,item_id)
			end

		end

		-- ũ�������� ���� ���� : 71144
		when 71144.use begin
			local t = get_global_time() - item.get_socket(1)
			local n = item.get_socket (0)
			if t >= 1800 then
			--if t >= 60 then
				new_christmas_gift_box.gift(item.get_id())
				item.set_socket(1, get_global_time())
				if n == 9 then
					item.remove()
				else
					item.set_socket(0, n + 1)
				end
				syschat(string.format(gameforge.new_christmas_gift_box._010_say, 10, 9 - n))
			else
				syschat(string.format(gameforge.new_christmas_gift_box._020_say, 31 - t / 60))
			end
		end
	end
end