define checker 20001
define level_limit 50
quest dragon_soul_daily_gift begin
	state start begin
		function is_event_on()
			-- 지금 시각이 dragon_soul_daily_gift_mgr.quest에서 셋팅한 시간 대역인지 확인.
			local s_time = game.get_event_flag("ds_dg_st")
			local e_time = game.get_event_flag("ds_dg_et")
			local now = os.time()
			return now > s_time and now < e_time
		end

		when checker.chat.gameforge.dragon_soul_daily_gift._010_npcChat with dragon_soul_daily_gift.is_event_on() begin
			local event_id = game.get_event_flag("ds_dg_id")
			if pc.getqf("event_id") != event_id then
				say_title(mob_name(checker))
				if pc.level < level_limit then
					say(gameforge.dragon_soul_daily_gift._020_say)
					return
				elseif 0 == ds.is_qualified() then
					say(gameforge.dragon_soul_daily_gift._030_say)
					return
				else
					say(gameforge.dragon_soul_daily_gift._040_say)
					pc.setqf("event_id", event_id)
					wait()
				end
			end

			say_title(mob_name(checker))
			if 0 == get_today_count("dragon_soul_daily_gift", "gift") then
				-- 오늘치 선물 증정.
				say(gameforge.dragon_soul_daily_gift._050_say)
				local gift_vnum = game.get_event_flag("ds_dg_item")
				pc.give_item2(gift_vnum)
				inc_today_count("dragon_soul_daily_gift", "gift")
			else
				-- 선물은 이미 줌.
				say(gameforge.dragon_soul_daily_gift._060_say)
			end
		end
	end
end
