quest main_quest_lv94 begin
	state start begin
	end
	state state0 begin
		when login or levelup or enter with pc.level >= 94 begin
			set_state (state1_1)
		end
	end
	------------------------------------신약 복용------------------------------------
	------------------------------------신약 복용------------------------------------
	------------------------------------신약 복용------------------------------------
	------------------------------------신약 복용------------------------------------
	------------------------------------신약 복용------------------------------------
	------------------------------------신약 복용------------------------------------
	------------------------------------신약 복용------------------------------------
	------------------------------------신약 복용------------------------------------
	------------------------------------신약 복용------------------------------------
	------------------------------------신약 복용------------------------------------
	------------------------------------신약 복용------------------------------------
	state state1_1 begin
	
		when letter begin
			send_letter(gameforge.main_quest_lv94._010_sendLetter)
			
			local v = find_npc_by_vnum(20380)
			if 0 != v then
				target.vid("__TARGET__", v, mob_name(20380))
			end
		end
		
		when button or info begin
			say_title(gameforge.main_quest_lv94._010_sendLetter)
			say(gameforge.main_quest_lv94._020_say)
			
		end
		
		when 20380.chat.gameforge.main_quest_lv94._010_sendLetter begin
			target.delete("__TARGET__")
			
			say_title(mob_name(20380))
			say(gameforge.main_quest_lv94._030_say)
			wait()
			
			say_title(pc.getname())
			say(gameforge.main_quest_lv94._040_say)
			wait()
			
			say_title(mob_name(20380))
			say(gameforge.main_quest_lv94._050_say)
			wait()
			
			--보상
			say_title(locale.reward)
			say_reward(string.format (gameforge.main_quest_lv60._190_sayReward, 12904600))
			say_reward(string.format (gameforge.main_quest_lv60._200_sayReward, 346000))
			say_reward(string.format (gameforge.main_quest_lv60._210_sayReward, item_name(71001),3,locale.count_postfix))
			say_reward(string.format (gameforge.main_quest_lv60._210_sayReward, item_name(31032),1,locale.count_postfix))
			say("")
			
			pc.give_exp2(12904600)
			pc.change_money(346000)
			pc.give_item2(71001, 3)
			pc.give_item2(31032, 1)
				
			set_state (state1_2)
		end
	end
	--퀘스트 수행--
	state state1_2 begin
		when letter begin
			send_letter(gameforge.main_quest_lv94._010_sendLetter)
		end
		when button or info begin
			say_title(gameforge.main_quest_lv94._060_sayTitle)
			say(gameforge.main_quest_lv94._070_say)
			say_item_vnum(31032)
		end
		
		when 31032.use begin
			pc.remove_item ( 31032, pc.count_item(31032))	
			
			affect.add_collect_point(POINT_MAGIC_DEF_GRADE,10,60*30) --60년	
				
			set_state (state2_1)
		end
		
	end
	
	------------------------------------뇌성산 정찰------------------------------------
	------------------------------------뇌성산 정찰------------------------------------
	------------------------------------뇌성산 정찰------------------------------------
	------------------------------------뇌성산 정찰------------------------------------
	------------------------------------뇌성산 정찰------------------------------------
	------------------------------------뇌성산 정찰------------------------------------
	------------------------------------뇌성산 정찰------------------------------------
	------------------------------------뇌성산 정찰------------------------------------
	------------------------------------뇌성산 정찰------------------------------------
	------------------------------------뇌성산 정찰------------------------------------
	------------------------------------뇌성산 정찰------------------------------------
	state state2_1 begin
		when letter begin
			send_letter(gameforge.main_quest_lv94._080_sendLetter)
			
			local v = find_npc_by_vnum(20378)
			if 0 != v then
				target.vid("__TARGET__", v, mob_name(20378))
			end
		end
		when button or info begin
			say_title(gameforge.main_quest_lv94._080_sendLetter)
			say(gameforge.main_quest_lv94._090_say)
			
		end
		
		when 20378.chat.gameforge.main_quest_lv94._080_sendLetter begin
			target.delete("__TARGET__")
			
			say_title(mob_name(20378))
			say(gameforge.main_quest_lv94._100_say)
			wait()
			
			say_title(pc.getname())
			say(gameforge.main_quest_lv94._110_say)
			wait()
			
			say_title(mob_name(20378))
			say(gameforge.main_quest_lv94._120_say)
			wait()
			say_reward(string.format(gameforge.main_quest_lv94._140_say, 374,1261))
			
			set_state (state2_2)
		end
	end
	state state2_2 begin
		when letter begin
			send_letter(gameforge.main_quest_lv94._080_sendLetter)
			target.pos("__TARGET__", 374, 1261, 304, "")
		end
		when button or info begin
			-- if pc.get_map_index() == 304 then
				-- addmapsignal(374 * 100, 1261 * 100) 
			-- end
			say_title(gameforge.main_quest_lv94._150_sayTitle)
			say(gameforge.main_quest_lv94._160_say)
			say_reward(gameforge.main_quest_lv90._1170_posInfo)
			say_reward(string.format(gameforge.main_quest_lv94._180_say, 374,1261))
			
			-- say()
			-- select(gameforge.main_quest_lv90._950_say)
			-- setskin(NOWINDOW)
			-- clearmapsignal()
		end
		--클리어 전--
		when 20378.chat.gameforge.main_quest_lv94._080_sendLetter begin
			say_title(mob_name(20378))
			say(gameforge.main_quest_lv94._170_say)
		end
		
		when __TARGET__.target.arrive begin
			target.delete("__TARGET__")
			say_reward(string.format(gameforge.main_quest_lv94._220_say, 321,419))
			set_state (state2_3)
		end
	end
	state state2_3 begin
		when letter begin
			send_letter(gameforge.main_quest_lv94._080_sendLetter)
			target.pos("__TARGET__", 321, 419, 304, "")
		end
		when button or info begin
			-- if pc.get_map_index() == 304 then
				-- addmapsignal(321 * 100, 419 * 100) 
			-- end
			say_title(gameforge.main_quest_lv94._150_sayTitle)
			say(gameforge.main_quest_lv94._160_say)
			say_reward(gameforge.main_quest_lv90._1170_posInfo)
			say_reward(string.format(gameforge.main_quest_lv94._190_say, 321,419))
			-- say()
			-- select(gameforge.main_quest_lv90._950_say)
			-- setskin(NOWINDOW)
			-- clearmapsignal()
		end
		--클리어 전--
		when 20378.chat.gameforge.main_quest_lv94._080_sendLetter begin
			say_title(mob_name(20378))
			say(gameforge.main_quest_lv94._170_say)
		end
		
		when __TARGET__.target.arrive begin
			target.delete("__TARGET__")
			say_reward(string.format(gameforge.main_quest_lv94._230_say, 790,149))
			set_state (state2_5)
		end
	end
	-- state state2_4 begin
		-- when letter begin
			-- send_letter(gameforge.main_quest_lv94._080_sendLetter)
			-- target.pos("__TARGET__", RECON3_X, RECON3_Y, RECON3_MAPINDEX, "")
		-- end
		-- when button or info begin
			-- if pc.get_map_index() == RECON3_MAPINDEX then
				-- addmapsignal(RECON3_X * 100, RECON3_Y * 100) 
			-- end
			-- say_title(locale.main_quest_lv94.title_4)
			-- say(locale.main_quest_lv94.say_12)
			-- say_reward(gameforge.main_quest_lv90._1170_posInfo)
			-- say_reward(string.format(locale.main_quest_lv94.say_16, RECON3_X,RECON3_Y))
			-- say()
			-- select(gameforge.main_quest_lv90._950_say)
			-- setskin(NOWINDOW)
			-- clearmapsignal()
		-- end
		--클리어 전--
		-- when 20378.chat.gameforge.main_quest_lv94._080_sendLetter begin
			-- say_title(mob_name(20378))
			-- say(locale.main_quest_lv94.say_13)
		-- end
		
		-- when __TARGET__.target.arrive begin
			-- target.delete("__TARGET__")
			-- say_reward(string.format(locale.main_quest_lv94.say_20, 790,149))
			-- set_state (state2_5)
		-- end
	-- end
	state state2_5 begin
		when letter begin
			send_letter(gameforge.main_quest_lv94._080_sendLetter)
			target.pos("__TARGET__", 790, 149, 304, "")
		end
		when button or info begin
			-- if pc.get_map_index() == 304 then
				-- addmapsignal(790 * 100, 149 * 100) 
			-- end
			say_title(gameforge.main_quest_lv94._150_sayTitle)
			say(gameforge.main_quest_lv94._160_say)
			say_reward(gameforge.main_quest_lv90._1170_posInfo)
			say_reward(string.format(gameforge.main_quest_lv94._210_say, 790,149))
			say()
			-- select(gameforge.main_quest_lv90._950_say)
			-- setskin(NOWINDOW)
			-- clearmapsignal()
		end
		--클리어 전--
		when 20378.chat.gameforge.main_quest_lv94._080_sendLetter begin
			say_title(mob_name(20378))
			say(gameforge.main_quest_lv94._170_say)
		end
		
		when __TARGET__.target.arrive begin
			target.delete("__TARGET__")
			say_reward(gameforge.main_quest_lv94._250_say)
			set_state (state2_6)
		end
	end
	
	state state2_6 begin
		when letter begin
			send_letter(gameforge.main_quest_lv94._080_sendLetter)
			
			local v = find_npc_by_vnum(20378)
			if 0 != v then
				target.vid("__TARGET__", v, mob_name(20378))
			end
		end
		when button or info begin
			say_title(gameforge.main_quest_lv94._080_sendLetter)
			say(gameforge.main_quest_lv94._260_say)
			
		end
		
		when 20378.chat.gameforge.main_quest_lv94._080_sendLetter begin
			target.delete("__TARGET__")
			
			say_title(mob_name(20378))
			say(gameforge.main_quest_lv94._270_say)
			wait()
			
			say_title(mob_name(20378))
			say(gameforge.main_quest_lv94._280_say)
			wait()
			
			--보상
			say_title(locale.reward)
			say_reward(string.format (gameforge.main_quest_lv60._190_sayReward, 14074422))
			say_reward(string.format (gameforge.main_quest_lv60._200_sayReward, 357000))
			say_reward(string.format (gameforge.main_quest_lv60._210_sayReward, item_name(30033),3,locale.count_postfix))
			say("")
			
			pc.give_exp2(14074422)
			pc.change_money(357000)
			pc.give_item2(30033, 3)
			
			set_state (state3_1)
		end
	end
	------------------------------------도적단 세력 약화------------------------------------
	------------------------------------도적단 세력 약화------------------------------------
	------------------------------------도적단 세력 약화------------------------------------
	------------------------------------도적단 세력 약화------------------------------------
	------------------------------------도적단 세력 약화------------------------------------
	------------------------------------도적단 세력 약화------------------------------------
	------------------------------------도적단 세력 약화------------------------------------
	------------------------------------도적단 세력 약화------------------------------------
	------------------------------------도적단 세력 약화------------------------------------
	------------------------------------도적단 세력 약화------------------------------------
	------------------------------------도적단 세력 약화------------------------------------
	state state3_1 begin
		when letter begin
			send_letter(gameforge.main_quest_lv94._290_sendLetter)
			
			local v = find_npc_by_vnum(20378)
			if 0 != v then
				target.vid("__TARGET__", v, mob_name(20378))
			end
		end
		when button or info begin
			say_title(gameforge.main_quest_lv94._290_sendLetter)
			say(gameforge.main_quest_lv94._300_say)
			
		end
		when 20378.chat.gameforge.main_quest_lv94._290_sendLetter begin
			target.delete("__TARGET__")
			
			say_title(mob_name(20378 ))
			say(gameforge.main_quest_lv94._310_say)
			wait()
			
			say_title(mob_name(20378 ))
			say(gameforge.main_quest_lv94._320_say)
			wait()
			
			say_title(pc.getname())
			say(gameforge.main_quest_lv94._330_say)
			wait()
			
			say_title(mob_name(20378 ))
			say(gameforge.main_quest_lv94._340_say)
			wait()
			
			say_title(pc.getname())
			say(gameforge.main_quest_lv94._350_say)
			wait()
			
			say_title(mob_name(20378 ))
			say(gameforge.main_quest_lv94._360_say)
			
			set_state (state3_2)
		end
	end
	state state3_2 begin
		when letter begin
			send_letter(gameforge.main_quest_lv94._290_sendLetter)
		end
		when button or info begin
			say_title(gameforge.main_quest_lv94._370_sayTitle)
			say(gameforge.main_quest_lv94._380_say)
			say_item_vnum(31033)
		end
		
		--클리어 전--
		when 20378.chat.gameforge.main_quest_lv94._290_sendLetter begin
			say_title(mob_name(20378))
			say(gameforge.main_quest_lv94._390_say)
		end
		
		when 3596.kill begin
			if pc.count_item(31033) < 1 then
				notice_multiline(gameforge.main_quest_lv94._400_1_notice,notice)
				notice_multiline(gameforge.main_quest_lv94._400_2_notice,notice)
				pc.give_item2(31033, 1)
				set_state (state3_3)
			end
			
		end
	end
	
	state state3_3 begin
		when letter begin
			send_letter(gameforge.main_quest_lv94._290_sendLetter)
			
			local v = find_npc_by_vnum(20378)
			if 0 != v then
				target.vid("__TARGET__", v, mob_name(20378))
			end
		end
		when button or info begin
			say_title(gameforge.main_quest_lv94._290_sendLetter)
			say(gameforge.main_quest_lv94._410_say)
			
		end
		
		-- 중간에 퀘스트 아이템을 버릴 경우를 대비한 부분.
		when 3596.kill begin
			
			if pc.count_item(31033) < 1 then
				notice_multiline(gameforge.main_quest_lv94._400_1_notice,notice)
				notice_multiline(gameforge.main_quest_lv94._400_2_notice,notice)
				pc.give_item2(31033, 1)
			end
		end
		
		when 20378.chat.gameforge.main_quest_lv94._290_sendLetter begin
			target.delete("__TARGET__")
			
			if pc.count_item(31033) >= 1 then
				pc.remove_item ( 31033, pc.count_item(31033))	
			
				say_title(mob_name(20378))
				say(gameforge.main_quest_lv94._420_say)
				wait()
				
				--보상
				say_title(locale.reward)
				say_reward(string.format (gameforge.main_quest_lv60._190_sayReward, 16014020))
				--say_reward(string.format (gameforge.main_quest_lv60._200_sayReward, 0))
				say_reward(string.format (gameforge.main_quest_lv60._210_sayReward, item_name(70024),1,locale.count_postfix))
				say_reward(string.format (gameforge.main_quest_lv60._210_sayReward, item_name(30039),3,locale.count_postfix))
				say_reward(string.format (gameforge.main_quest_lv60._210_sayReward, item_name(50820),20,locale.count_postfix))
				say("")
				
				pc.give_exp2(16014020)
				--pc.change_money(0)
				pc.give_item2(70024, 1)
				pc.give_item2(30039, 3)
				pc.give_item2(50820, 20)
				
				set_state (state4_1)
			else
				say_title(mob_name(20378))
				say(gameforge.main_quest_lv94._390_say)
				
				set_state (state3_2)
			end
		end
	end
	
	------------------------------------외안투귀 세력 약화-----------------------------------
	------------------------------------외안투귀 세력 약화-----------------------------------
	------------------------------------외안투귀 세력 약화-----------------------------------
	------------------------------------외안투귀 세력 약화-----------------------------------
	------------------------------------외안투귀 세력 약화-----------------------------------
	------------------------------------외안투귀 세력 약화-----------------------------------
	------------------------------------외안투귀 세력 약화-----------------------------------
	------------------------------------외안투귀 세력 약화-----------------------------------
	------------------------------------외안투귀 세력 약화-----------------------------------
	------------------------------------외안투귀 세력 약화-----------------------------------
	------------------------------------외안투귀 세력 약화-----------------------------------
	state state4_1 begin
		when letter begin
			send_letter(gameforge.main_quest_lv94._430_sendLetter)
			
			local v = find_npc_by_vnum(20378)
			if 0 != v then
				target.vid("__TARGET__", v, mob_name(20378))
			end
		end
		when button or info begin
			say_title(gameforge.main_quest_lv94._430_sendLetter)
			say(gameforge.main_quest_lv94._440_say)
			
		end
		
		when 20378.chat.gameforge.main_quest_lv94._430_sendLetter begin
			target.delete("__TARGET__")
			
			say_title(mob_name(20378 ))
			say(gameforge.main_quest_lv94._450_say)
			wait()
			
			say_title(pc.getname())
			say(gameforge.main_quest_lv94._460_say)
			wait()
			
			say_title(mob_name(20378 ))
			say(string.format(gameforge.main_quest_lv94._470_say,30,3,1))
			wait()
			
			say_title(pc.getname())
			say(gameforge.main_quest_lv94._480_say)
			wait()
			
			say_title(mob_name(20378 ))
			say(gameforge.main_quest_lv94._490_say)
		
			set_state (state4_2)
		end
	end
	-- 퀘스트 진행 --
	state state4_2 begin
		when letter begin
			send_letter(gameforge.main_quest_lv94._430_sendLetter)
			q.set_counter_name(gameforge.main_quest_lv94._1080_say)
			local remain1 = 30 - pc.getqf("mob4_1_count")
			local remain2 = 3 - pc.getqf("mob4_2_count")
			local remain3 = 1 - pc.getqf("mob4_3_count")
			q.set_counter_value(remain1 + remain2 + remain3)
		end
		when button or info begin
			say_title(gameforge.main_quest_lv94._500_sayTitle)
			say(string.format(gameforge.main_quest_lv94._510_say,30,3,1))
			say("")
			say_title(gameforge.main_quest_lv94._1060_say)
			local remain1 = 30 - pc.getqf("mob4_1_count")
			local remain2 = 3 - pc.getqf("mob4_2_count")
			local remain3 = 1 - pc.getqf("mob4_3_count")
			q.set_counter_value(remain1 + remain2 + remain3)
			say_title(string.format(gameforge.main_quest_lv94._1070_say,mob_name(3105),remain1,mob_name(3190),remain2,mob_name(3191),remain3))
		end
		
		-- 클리어 전에 클릭 --
		when 20378.chat.gameforge.main_quest_lv94._430_sendLetter begin
			say_title(mob_name(20378 ))
			say(string.format(gameforge.main_quest_lv94._470_say,30,3,1))
		end
		
		when 3105.kill begin
			local mob4_1_count = pc.getqf("mob4_1_count")
			if mob4_1_count < 30 then
				pc.setqf("mob4_1_count", mob4_1_count + 1)
				
				local remain1 = 30 - pc.getqf("mob4_1_count")
				local remain2 = 3 - pc.getqf("mob4_2_count")
				local remain3 = 1 - pc.getqf("mob4_3_count")
				q.set_counter_value(remain1 + remain2 + remain3)
				
				if pc.getqf("mob4_1_count") >= 30 and pc.getqf("mob4_2_count") >= 3 and pc.getqf("mob4_3_count") >= 1 then
					notice_multiline(gameforge.main_quest_lv94._530_1_notice,notice)
					notice_multiline(gameforge.main_quest_lv94._530_2_notice,notice)
					set_state (state4_3)
				end
			end
		end
		
		when 3190.kill begin
			local mob4_2_count = pc.getqf("mob4_2_count")
			if mob4_2_count < 3 then
				pc.setqf("mob4_2_count", mob4_2_count + 1)
				
				local remain1 = 30 - pc.getqf("mob4_1_count")
				local remain2 = 3 - pc.getqf("mob4_2_count")
				local remain3 = 1 - pc.getqf("mob4_3_count")
				q.set_counter_value(remain1 + remain2 + remain3)
				
				
				if pc.getqf("mob4_1_count") >= 30 and pc.getqf("mob4_2_count") >= 3 and pc.getqf("mob4_3_count") >= 1 then
					notice_multiline(gameforge.main_quest_lv94._530_1_notice,notice)
					notice_multiline(gameforge.main_quest_lv94._530_2_notice,notice)
					set_state (state4_3)
				end
			end
		end
		
		when 3191.kill begin
			local mob4_3_count = pc.getqf("mob4_3_count")
			if mob4_3_count < 1 then
				pc.setqf("mob4_3_count", mob4_3_count + 1)
				
				local remain1 = 30 - pc.getqf("mob4_1_count")
				local remain2 = 3 - pc.getqf("mob4_2_count")
				local remain3 = 1 - pc.getqf("mob4_3_count")
				q.set_counter_value(remain1 + remain2 + remain3)
				
				
				if pc.getqf("mob4_1_count") >= 30 and pc.getqf("mob4_2_count") >= 3 and pc.getqf("mob4_3_count") >= 1 then
					notice_multiline(gameforge.main_quest_lv94._530_1_notice,notice)
					notice_multiline(gameforge.main_quest_lv94._530_2_notice,notice)
					set_state (state4_3)
				end
			end
		end
	end
	state state4_3 begin
		when letter begin
			send_letter(gameforge.main_quest_lv94._430_sendLetter)
			
			local v = find_npc_by_vnum(20378)
			if 0 != v then
				target.vid("__TARGET__", v, mob_name(20378))
			end
			q.set_counter_name("")
		end
		when button or info begin
			say_title(gameforge.main_quest_lv94._430_sendLetter)
			say(gameforge.main_quest_lv94._540_say)
			
		end
		
		when 20378.chat.gameforge.main_quest_lv94._430_sendLetter begin
			target.delete("__TARGET__")
			
			say_title(mob_name(20378 ))
			say(gameforge.main_quest_lv94._550_say)
			wait()
			
			--보상
			say_title(locale.reward)
			say_reward(string.format (gameforge.main_quest_lv60._190_sayReward, 21014020))
			say_reward(string.format (gameforge.main_quest_lv60._200_sayReward, 379000))
			say_reward(string.format (gameforge.main_quest_lv60._210_sayReward, item_name(72308),1,locale.count_postfix))
			say_reward(string.format (gameforge.main_quest_lv60._210_sayReward, item_name(76011),1,locale.count_postfix))
			say("")
			
			pc.give_exp2(21014020)
			pc.change_money(379000)
			pc.give_item2(72308, 1)
			pc.give_item2_select(76011)
			item.set_socket(2, 120)
			
			set_state (state5_1)
		end
	end
	
	------------------------------------거인족 세력 약화-----------------------------------
	------------------------------------거인족 세력 약화-----------------------------------
	------------------------------------거인족 세력 약화-----------------------------------
	------------------------------------거인족 세력 약화-----------------------------------
	------------------------------------거인족 세력 약화-----------------------------------
	------------------------------------거인족 세력 약화-----------------------------------
	------------------------------------거인족 세력 약화-----------------------------------
	------------------------------------거인족 세력 약화-----------------------------------
	------------------------------------거인족 세력 약화-----------------------------------
	------------------------------------거인족 세력 약화-----------------------------------
	------------------------------------거인족 세력 약화-----------------------------------
	state state5_1 begin
		when letter begin
			send_letter(gameforge.main_quest_lv94._560_sendLetter)
			
			local v = find_npc_by_vnum(20378)
			if 0 != v then
				target.vid("__TARGET__", v, mob_name(20378))
			end
		end
		when button or info begin
			say_title(gameforge.main_quest_lv94._560_sendLetter)
			say(gameforge.main_quest_lv94._570_say)
			
		end
		
		when 20378.chat.gameforge.main_quest_lv94._560_sendLetter begin
			target.delete("__TARGET__")
			
			say_title(mob_name(20378 ))
			say(gameforge.main_quest_lv94._580_say)
			wait()
			
			say_title(pc.getname())
			say(gameforge.main_quest_lv94._590_say)
			wait()
			
			say_title(mob_name(20378 ))
			say(gameforge.main_quest_lv94._600_say)
			wait()
			
			say_title(pc.getname())
			say(gameforge.main_quest_lv94._610_say)
			wait()
			
			say_title(mob_name(20378 ))
			say(string.format(gameforge.main_quest_lv94._620_say,9))
			wait()
			
			say_title(pc.getname())
			say(gameforge.main_quest_lv94._630_say)
		
			set_state (state5_2)
		end
	end
	-- 퀘스트 진행 --
	state state5_2 begin
		when letter begin
			send_letter(gameforge.main_quest_lv94._560_sendLetter)
			q.set_counter_name(gameforge.main_quest_lv94._1080_say)
			local remain1 = 9 - pc.count_item(31034)
			q.set_counter_value(remain1)
		end
		when button or info begin
			-- if pc.get_map_index() == 1 then
				-- addmapsignal(500 * 100, 500 * 100)
				-- addmapsignal(600 * 100, 500 * 100)
				-- addmapsignal(700 * 100, 300 * 100)
			-- end
			local remain1 = 9 - pc.count_item(31034)
			
			say_title(gameforge.main_quest_lv94._640_sayTitle)
			say(gameforge.main_quest_lv94._650_say)
			say_item_vnum(31034)
			say(gameforge.main_quest_lv94._1080_say)
			say_reward(string.format(gameforge.main_quest_lv94._1090_say,item_name(31034),remain1 ))

			say()
			-- say_reward(gameforge.main_quest_lv90._1170_posInfo)
			-- select(gameforge.main_quest_lv90._950_say)
			-- setskin(NOWINDOW)
			-- clearmapsignal()
		end
		
		-- 클리어 전에 클릭 --
		when 20378.chat.gameforge.main_quest_lv94._560_sendLetter begin
			say_title(mob_name(20378 ))
			say(string.format(gameforge.main_quest_lv94._660_say,9))
		end
		
		when 3791.kill begin
			local item5_1_count = pc.count_item(31034)
			if item5_1_count < 9 then
				if	number (1,10) == 1 then	
					pc.give_item2 ( 31034, 1 )
					local remain1 = 9 - pc.count_item(31034)
					q.set_counter_value(remain1)
					
					if pc.count_item(31034) >= 9 then
						notice_multiline(gameforge.main_quest_lv94._670_say_1_notice,notice)
						notice_multiline(gameforge.main_quest_lv94._670_say_2_notice,notice)
						set_state (state5_3)
					end
				end
			end
		end
	end
	
	state state5_3 begin
		when letter begin
			send_letter(gameforge.main_quest_lv94._560_sendLetter)
			
			local v = find_npc_by_vnum(20378)
			if 0 != v then
				target.vid("__TARGET__", v, mob_name(20378))
			end
			q.set_counter_name("")
		end
		when button or info begin
			say_title(gameforge.main_quest_lv94._560_sendLetter)
			say(gameforge.main_quest_lv94._670_say_1_notice)
			say(gameforge.main_quest_lv94._670_say_2_notice)
			
		end
		
		-- 중간에 퀘스트 아이템을 버릴 경우를 대비한 부분.
		when 3791.kill begin
			local item5_1_count = pc.count_item(31034)
			if item5_1_count < 9 then
				if	number (1,10) == 1 then	
					pc.give_item2 ( 31034, 1 )
					
					if pc.count_item(31034) >= 9 then
						notice_multiline(gameforge.main_quest_lv94._670_say_1_notice,notice)
						notice_multiline(gameforge.main_quest_lv94._670_say_2_notice,notice)
						set_state (state5_3)
					end
				end
			end
		end
		
		when 20378.chat.gameforge.main_quest_lv94._560_sendLetter begin
			target.delete("__TARGET__")
			
			if pc.count_item(31034) >= 9 then
				pc.remove_item ( 31034, pc.count_item(31034))	
				
				say_title(mob_name(20378 ))
				say(gameforge.main_quest_lv94._680_say)
				wait()
				
				--보상
				say_title(locale.reward)
				say_reward(string.format (gameforge.main_quest_lv60._190_sayReward, 25032586))
				say_reward(string.format (gameforge.main_quest_lv60._200_sayReward, 390000))
				say_reward(string.format (gameforge.main_quest_lv60._210_sayReward, item_name(71026),1,locale.count_postfix))
				say_reward(string.format (gameforge.main_quest_lv60._210_sayReward, item_name(71025),2,locale.count_postfix))
				say_reward(string.format (gameforge.main_quest_lv60._210_sayReward, item_name(70102),5,locale.count_postfix))
				say_reward(string.format (gameforge.main_quest_lv60._210_sayReward, item_name(50826),10,locale.count_postfix))
				say("")
				
				pc.give_exp2(25032586)
				pc.change_money(390000)
				pc.give_item2(71026, 1)
				pc.give_item2(71025, 1)
				pc.give_item2(71025, 1)
				pc.give_item2(70102, 1)
				pc.give_item2(70102, 1)
				pc.give_item2(70102, 1)
				pc.give_item2(70102, 1)
				pc.give_item2(70102, 1)
				pc.give_item2(50826, 10)
				
				set_state (state6_1)
			else
				say_title(mob_name(20378 ))
				say(string.format(gameforge.main_quest_lv94._660_say,9))
				
				set_state (state5_2)
			end
		end
	end
	------------------------------------뇌성산을 향해-----------------------------------
	------------------------------------뇌성산을 향해-----------------------------------
	------------------------------------뇌성산을 향해-----------------------------------
	------------------------------------뇌성산을 향해-----------------------------------
	------------------------------------뇌성산을 향해-----------------------------------
	------------------------------------뇌성산을 향해-----------------------------------
	------------------------------------뇌성산을 향해-----------------------------------
	------------------------------------뇌성산을 향해-----------------------------------
	------------------------------------뇌성산을 향해-----------------------------------
	------------------------------------뇌성산을 향해-----------------------------------
	------------------------------------뇌성산을 향해-----------------------------------
	state state6_1 begin
		when letter begin
			send_letter(gameforge.main_quest_lv94._690_sendLetter)
			
			local v = find_npc_by_vnum(20378)
			if 0 != v then
				target.vid("__TARGET__", v, mob_name(20378))
			end
		end
		when button or info begin
			say_title(gameforge.main_quest_lv94._690_sendLetter)
			say(gameforge.main_quest_lv94._700_say)
			
		end
		
		when 20378.chat.gameforge.main_quest_lv94._690_sendLetter begin
			target.delete("__TARGET__")
			
			say_title(mob_name(20378 ))
			say(gameforge.main_quest_lv94._710_say)
			wait()
			
			say_title(mob_name(20378 ))
			say(gameforge.main_quest_lv94._720_say)
			wait()
			
			say_title(pc.getname())
			say(gameforge.main_quest_lv94._730_say)
			wait()
		
			set_state (state6_2)
		end
	end
	-- 퀘스트 진행 --
	state state6_2 begin
		when letter begin
			send_letter(gameforge.main_quest_lv94._690_sendLetter)
			q.set_counter_name(gameforge.main_quest_lv94._1080_say)
			
			if pc.count_item(31035) >= 1 and pc.count_item(31013) >= 1 then
				notice_multiline(gameforge.main_quest_lv94._770_1_notice,notice)
				notice_multiline(gameforge.main_quest_lv94._770_2_notice,notice)
				set_state (state6_3)
			end
		end
		when button or info begin
			-- if pc.get_map_index() == 1 then
				-- addmapsignal(500 * 100, 500 * 100)
				-- addmapsignal(600 * 100, 500 * 100)
				-- addmapsignal(700 * 100, 300 * 100)
			-- end
			say_title(gameforge.main_quest_lv94._740_sayTitle)
			say(gameforge.main_quest_lv94._750_say)
			say_item_vnum(31035)
			say_item_vnum(31013)
			say(gameforge.main_quest_lv94._1080_say)
			local remain1 = 1 - pc.count_item(31035)
			if remain1 < 0 then
				remain1 = 0
			end
			local remain2 = 1 - pc.count_item(31013)
			if remain2 < 0 then
				remain2 = 0
			end
			say_reward(string.format(gameforge.main_quest_lv94._1090_say,item_name(31035),remain1))
			say_reward(string.format(gameforge.main_quest_lv94._1090_say,item_name(31013),remain2))
			q.set_counter_value(remain1 + remain2)

			-- say()
			-- say_reward(gameforge.main_quest_lv90._1170_posInfo)
			-- select(gameforge.main_quest_lv90._950_say)
			-- setskin(NOWINDOW)
			-- clearmapsignal()
		end
		
		-- 클리어 전에 클릭 --
		when 20378.chat.gameforge.main_quest_lv94._690_sendLetter begin
			say_title(mob_name(20378 ))
			say(gameforge.main_quest_lv94._760_say)
		end
		
		when 3101.kill or  3102.kill or  3103.kill or  3104.kill or  3105.kill or  3190.kill or  3191.kill begin
			if pc.count_item(31035) < 1 then
				if	number (1,3) == 1 then	
					pc.give_item2 ( 31035, 1 )
					
					if pc.count_item(31035) >= 1 and pc.count_item(31013) >= 1 then
						notice_multiline(gameforge.main_quest_lv94._770_1_notice,notice)
						notice_multiline(gameforge.main_quest_lv94._770_2_notice,notice)
						set_state (state6_3)
					end
				end
			end
			if pc.count_item(31013) < 1 then
				if	number (1,3) == 1 then	
					pc.give_item2 ( 31013, 1 )
					
					if pc.count_item(31035) >= 1 and pc.count_item(31013) >= 1 then
						notice_multiline(gameforge.main_quest_lv94._770_1_notice,notice)
						notice_multiline(gameforge.main_quest_lv94._770_2_notice,notice)
						set_state (state6_3)
					end
				end
			end
			
			local remain1 = 1 - pc.count_item(31035)
			if remain1 < 0 then
				remain1 = 0
			end
			local remain2 = 1 - pc.count_item(31013)
			if remain2 < 0 then
				remain2 = 0
			end
			q.set_counter_value(remain1 + remain2)
		end
	end
	
	state state6_3 begin
		when letter begin
			send_letter(gameforge.main_quest_lv94._690_sendLetter)
			
			local v = find_npc_by_vnum(20378)
			if 0 != v then
				target.vid("__TARGET__", v, mob_name(20378))
			end
			q.set_counter_name("")
		end
		when button or info begin
			say_title(gameforge.main_quest_lv94._690_sendLetter)
			say(gameforge.main_quest_lv94._780_say)
			
		end
		
		-- 중간에 퀘스트 아이템을 버릴 경우를 대비한 부분.
		when 3101.kill or  3102.kill or  3103.kill or  3104.kill or  3105.kill or  3190.kill or  3191.kill   begin
			if pc.count_item(31035) < 1 then
				if	number (1,3) == 1 then	
					pc.give_item2 ( 31035, 1 )
					
					if pc.count_item(31035) >= 1 and pc.count_item(31013) >= 1 then
						notice_multiline(gameforge.main_quest_lv94._770_1_notice,notice)
						notice_multiline(gameforge.main_quest_lv94._770_2_notice,notice)
					end
				end
			end
			if pc.count_item(31013) < 1 then
				if	number (1,3) == 1 then	
					pc.give_item2 ( 31013, 1 )
					
					if pc.count_item(31035) >= 1 and pc.count_item(31013) >= 1 then
						notice_multiline(gameforge.main_quest_lv94._770_1_notice,notice)
						notice_multiline(gameforge.main_quest_lv94._770_2_notice,notice)
					end
				end
			end
		end
		
		when 20378.chat.gameforge.main_quest_lv94._690_sendLetter begin
			target.delete("__TARGET__")
			
			if pc.count_item(31035) >= 1 and pc.count_item(31013) >= 1 then
				pc.remove_item ( 31035, pc.count_item(31035))	
				pc.remove_item ( 31013, pc.count_item(31013))	
				
				say_title(mob_name(20378 ))
				say(gameforge.main_quest_lv94._790_say)
				wait()
				
				say_title(pc.getname())
				say(gameforge.main_quest_lv94._800_say)
				wait()
				
				say_title(gameforge.main_quest_lv94._840_say)
				say_reward(gameforge.main_quest_lv94._810_say)
				wait()
				
				say_title(mob_name(20378 ))
				say(gameforge.main_quest_lv94._820_say)
				wait()
				
				say_title(mob_name(20378 ))
				say(gameforge.main_quest_lv94._830_say)
				wait()
				
				--보상
				say_title(locale.reward)
				say_reward(string.format (gameforge.main_quest_lv60._190_sayReward, 23074000))
				--say_reward(string.format (gameforge.main_quest_lv60._200_sayReward, 0))
				say_reward(string.format (gameforge.main_quest_lv60._210_sayReward, item_name(70024),3,locale.count_postfix))
				say("")
				
				pc.give_exp2(23074000)
				--pc.change_money(0)
				pc.give_item2(70024, 1)
				pc.give_item2(70024, 1)
				pc.give_item2(70024, 1)
				
				set_state (state7_1)
			else
				say_title(mob_name(20378 ))
				say(gameforge.main_quest_lv94._760_say)
				
				set_state (state6_2)
			end
		end
	end
	------------------------------------검은 황금-----------------------------------
	------------------------------------검은 황금----------------------------------
	------------------------------------검은 황금----------------------------------
	------------------------------------검은 황금----------------------------------
	------------------------------------검은 황금----------------------------------
	------------------------------------검은 황금----------------------------------
	------------------------------------검은 황금----------------------------------
	------------------------------------검은 황금----------------------------------
	------------------------------------검은 황금----------------------------------
	------------------------------------검은 황금----------------------------------
	------------------------------------검은 황금----------------------------------
	state state7_1 begin
		when letter begin
			send_letter(gameforge.main_quest_lv94._850_sendLetter)
			
			local v = find_npc_by_vnum(20378)
			if 0 != v then
				target.vid("__TARGET__", v, mob_name(20378))
			end
		end
		when button or info begin
			say_title(gameforge.main_quest_lv94._850_sendLetter)
			say(gameforge.main_quest_lv94._860_say)
			
		end
		
		when 20378.chat.gameforge.main_quest_lv94._850_sendLetter begin
			target.delete("__TARGET__")
			
			say_title(mob_name(20378))
			say(gameforge.main_quest_lv94._870_say)
			wait()
			
			say_title(mob_name(20378))
			say(gameforge.main_quest_lv94._880_say)
		
			set_state (state7_2)
		end
	end
	state state7_2 begin
		when letter begin
			send_letter(gameforge.main_quest_lv94._850_sendLetter)
			
			local v = find_npc_by_vnum(20001)
			if 0 != v then
				target.vid("__TARGET__", v, mob_name(20001))
			end
		end
		when button or info begin
			say_title(gameforge.main_quest_lv94._950_sayTitle)
			say(gameforge.main_quest_lv94._890_say)
			
		end
		
		when 20001.chat.gameforge.main_quest_lv94._850_sendLetter begin
			target.delete("__TARGET__")
			
			say_title(mob_name(20001 ))
			say(gameforge.main_quest_lv94._900_say)
			wait()
			
			say_title(pc.getname())
			say(gameforge.main_quest_lv94._910_say)
			wait()
			
			say_title(mob_name(20001 ))
			say(string.format(gameforge.main_quest_lv94._920_say,30))
			wait()
			
			say_title(pc.getname())
			say(gameforge.main_quest_lv94._930_say)
		
			set_state (state7_3)
		end
	end
	-- 퀘스트 진행 --
	state state7_3 begin
		when letter begin
			send_letter(gameforge.main_quest_lv94._850_sendLetter)
			q.set_counter_name(gameforge.main_quest_lv94._1080_say)
		end
		when button or info begin
			-- if pc.get_map_index() == 1 then
				-- addmapsignal(500 * 100, 500 * 100)
				-- addmapsignal(600 * 100, 500 * 100)
				-- addmapsignal(700 * 100, 300 * 100)
			-- end
			say_title(gameforge.main_quest_lv94._940_sayTitle)
			say(gameforge.main_quest_lv94._960_say)
			say_item_vnum(31036)
			say(gameforge.main_quest_lv94._1080_say)
			local remain = 30 - pc.getqf("total_item7_1_checked")
			if remain < 0 then
				remain = 0
			end
			say_reward(string.format(gameforge.main_quest_lv94._1090_say,item_name(31036),remain))
			q.set_counter_value(remain)

			-- say()
			-- say_reward(gameforge.main_quest_lv90._1170_posInfo)
			-- select(gameforge.main_quest_lv90._950_say)
			-- setskin(NOWINDOW)
			-- clearmapsignal()
		end
		
		when 3101.kill or  3102.kill or  3103.kill or  3104.kill or  3105.kill or  3190.kill or  3191.kill begin
			if	number (1,2) == 1 then	
				pc.give_item2 ( 31036, 1 )
				
				notice_multiline(gameforge.main_quest_lv94._970_1_notice,notice)
				notice_multiline(gameforge.main_quest_lv94._970_2_notice,notice)

			end
		end
		
		when 20001.chat.gameforge.main_quest_lv94._850_sendLetter begin
			local cur_t = get_global_time() - 60 * 60 * 9
			local today_date = cur_t - math.mod(cur_t,86400)
			
			local last_checked_date = pc.getqf("last_checked_date")
			
			if today_date ~= last_checked_date then
				pc.setqf("last_checked_date", today_date)
				pc.setqf("today_item7_1_checked",0)
			end
			
			
			if pc.count_item(31036) > 0 then
				local today_item7_1_checked = pc.getqf("today_item7_1_checked")
				if today_item7_1_checked >= 10 then --1일 납품 갯수 초과
					say_title(mob_name(20001 ))
					say(gameforge.main_quest_lv94._1000_say)
				else
					if number (1,100) <= 70 then -- 납품 성공
						pc.remove_item ( 31036, 1)	
						local today_item7_1_checked = pc.getqf("today_item7_1_checked")
						pc.setqf("today_item7_1_checked",today_item7_1_checked + 1)
						local total_item7_1_checked = pc.getqf("total_item7_1_checked")
						pc.setqf("total_item7_1_checked",total_item7_1_checked+1)
						
						local remain = 30 - pc.getqf("total_item7_1_checked")
						if remain < 0 then
							remain = 0
						end
						q.set_counter_value(remain)
						
						if pc.getqf("total_item7_1_checked") >= 30 then -- 납품 갯수 모두 달성
							say_title(mob_name(20001 ))
							say(gameforge.main_quest_lv94._1010_say)
							
							set_state (state7_4)
						else
							say_title(mob_name(20001 ))
							say(string.format(gameforge.main_quest_lv94._980_say,30-pc.getqf("total_item7_1_checked") ))
						end
					else -- 납품 실패
						pc.remove_item ( 31036, 1)	
						say_title(mob_name(20001 ))
						say(gameforge.main_quest_lv94._990_say)
					end
				end
			else
				say_title(mob_name(20001 ))
				say(gameforge.main_quest_lv94._1040_say)
			end
		end
		
	end
	
	state state7_4 begin
		when letter begin
			send_letter(gameforge.main_quest_lv94._850_sendLetter)
			
			local v = find_npc_by_vnum(20378)
			if 0 != v then
				target.vid("__TARGET__", v, mob_name(20378))
			end
			q.set_counter_name("")
		end
		when button or info begin
			say_title(gameforge.main_quest_lv94._850_sendLetter)
			say(gameforge.main_quest_lv94._1020_say)
			
		end
		
		when 20378.chat.gameforge.main_quest_lv94._850_sendLetter begin
			target.delete("__TARGET__")
				
			say_title(mob_name(20378 ))
			say(gameforge.main_quest_lv94._1030_say)
			wait()
			
			--보상
			say_title(locale.reward)
			say_reward(string.format (gameforge.main_quest_lv60._190_sayReward, 26473000))
			--say_reward(string.format (gameforge.main_quest_lv60._200_sayReward, 0))
			say_reward(string.format (gameforge.main_quest_lv60._210_sayReward, item_name(71001),5,locale.count_postfix))
			say("")
			say_title(gameforge.main_quest_lv94._1050_say)
			
			pc.give_exp2(26473000)
			--pc.change_money(0)
			pc.give_item2(71001, 5)
			
			clear_letter()
			set_quest_state ("main_quest_lv95", "state0")
			set_state (__COMPLETE__)
		end
	end
	
	state __COMPLETE__ begin
		when enter begin
			q.done()
		end
	end
end
