quest main_quest_lv93 begin
	state start begin
	end
	state state0 begin
		when login or levelup or enter with pc.level >= 93 begin
			set_state (state1_1)
		end
	end
	------------------------------------내력강화1-1------------------------------------
	------------------------------------내력강화1-1------------------------------------
	------------------------------------내력강화1-1------------------------------------
	------------------------------------내력강화1-1------------------------------------
	------------------------------------내력강화1-1------------------------------------
	------------------------------------내력강화1-1------------------------------------
	------------------------------------내력강화1-1------------------------------------
	------------------------------------내력강화1-1------------------------------------
	------------------------------------내력강화1-1------------------------------------
	------------------------------------내력강화1-1------------------------------------
	------------------------------------내력강화1-1------------------------------------
	state state1_1 begin
	
		when letter begin
			send_letter(gameforge.main_quest_lv93._010_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_lv93._010_sendLetter)
			say(gameforge.main_quest_lv93._020_say)
			
		end
		
		when 20378.chat.gameforge.main_quest_lv93._010_sendLetter begin
			target.delete("__TARGET__")
			
			say_title(mob_name(20378))
			say(gameforge.main_quest_lv93._030_say)
			wait()
			
			say_title(mob_name(20378))
			say(gameforge.main_quest_lv93._040_say)
			wait()
			
			say_title(pc.getname())
			say(gameforge.main_quest_lv93._050_say)
			
			set_state (state1_2)
		end
	end
	state state1_2 begin
	
		when letter begin
			send_letter(gameforge.main_quest_lv93._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_lv93._010_sendLetter)
			say(gameforge.main_quest_lv93._130_say)
			
		end
		
		when 20380.chat.gameforge.main_quest_lv93._010_sendLetter begin
			target.delete("__TARGET__")
			
			say_title(mob_name(20380))
			say(gameforge.main_quest_lv93._060_say)
			wait()
			
			say_title(mob_name(20380))
			say(gameforge.main_quest_lv93._070_say)
			wait()
			
			say_title(pc.getname())
			say(gameforge.main_quest_lv93._080_say)
			
			set_state (state1_3)
		end
	end
	--퀘스트 수행--
	state state1_3 begin
		when letter begin
			send_letter(gameforge.main_quest_lv93._010_sendLetter)
		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_lv93._090_sayTitle)
			say(gameforge.main_quest_lv93._100_say)
			say_item_vnum(31029)
			
			-- say()
			-- say_reward(locale.main_quest_lv93.pos_info)
			-- select(gameforge.main_quest_lv90._950_say)
			-- setskin(NOWINDOW)
			-- clearmapsignal()
		end
		
		--클리어 전--
		when 20380.chat.gameforge.main_quest_lv93._010_sendLetter begin
			say_title(mob_name(20380))
			say(gameforge.main_quest_lv93._110_say)
		end
		
		when 3191.kill begin
			if number(1,1000) == 1 then
				if pc.count_item(31029) < 1 then
					pc.give_item2(31029, 1)
					
					if pc.count_item(31029) >= 1 then
						notice_multiline(gameforge.main_quest_lv93._120_1_notice,notice)
						set_state (state1_4)
					end
				end
			end
		end
	end
	state state1_4 begin
	
		when letter begin
			send_letter(gameforge.main_quest_lv93._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_lv93._010_sendLetter)
			say(gameforge.main_quest_lv93._130_say)
			
		end
		
		-- 중간에 퀘스트 아이템을 버릴 경우를 대비한 부분.
		when 3191.kill begin
			if number(1,1000) == 1 then
				if pc.count_item(31029) < 1 then
					pc.give_item2(31029, 1)
					
					if pc.count_item(31029) >= 1 then
						notice_multiline(gameforge.main_quest_lv93._120_1_notice,notice)
						set_state (state1_4)
					end
				end
			end
		end
		
		when 20380.chat.gameforge.main_quest_lv93._010_sendLetter begin
			target.delete("__TARGET__")
			
			if pc.count_item(31029) >= 1 then
				pc.remove_item ( 31029, pc.count_item(31029))	
				say_title(mob_name(20380))
				say(gameforge.main_quest_lv93._140_say)
				wait()
				
				--보상
				say_title(locale.reward)
				say_reward(string.format (gameforge.main_quest_lv60._190_sayReward, 27874422))
				--say_reward(string.format (gameforge.main_quest_lv60._200_sayReward, 0))
				say_reward(string.format (gameforge.main_quest_lv60._210_sayReward, item_name(27994),1,locale.count_postfix))
				say("")
				
				pc.give_exp2(27874422)
				--pc.change_money(0)
				pc.give_item2(27994, 1)
				
				set_state (state2_1)
			else
				say_title(mob_name(20380))
				say(gameforge.main_quest_lv93._110_say)
				
				set_state (state1_3)
			end
		end
	end
	
	------------------------------------내력강화1-2------------------------------------
	------------------------------------내력강화1-2------------------------------------
	------------------------------------내력강화1-2------------------------------------
	------------------------------------내력강화1-2------------------------------------
	------------------------------------내력강화1-2------------------------------------
	------------------------------------내력강화1-2------------------------------------
	------------------------------------내력강화1-2------------------------------------
	------------------------------------내력강화1-2------------------------------------
	------------------------------------내력강화1-2------------------------------------
	------------------------------------내력강화1-2------------------------------------
	------------------------------------내력강화1-2------------------------------------
	state state2_1 begin
		when letter begin
			send_letter(gameforge.main_quest_lv93._150_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_lv93._150_sendLetter)
			say(gameforge.main_quest_lv93._160_say)
			
		end
		
		when 20380.chat.gameforge.main_quest_lv93._150_sendLetter begin
			target.delete("__TARGET__")
			
			say_title(mob_name(20380))
			say(gameforge.main_quest_lv93._170_say)
			wait()
			
			say_title(pc.getname())
			say(gameforge.main_quest_lv93._180_say)
			
			set_state (state2_2)
		end
	end
	--퀘스트 수행--
	state state2_2 begin
		when letter begin
			send_letter(gameforge.main_quest_lv93._150_sendLetter)
		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_lv93._190_sayTitle)
			say(gameforge.main_quest_lv93._200_say)
			say_item_vnum(31030)

			-- say()
			-- say_reward(locale.main_quest_lv93.pos_info)
			-- select(gameforge.main_quest_lv90._950_say)
			-- setskin(NOWINDOW)
			-- clearmapsignal()
		end
		
		--클리어 전--
		when 20380.chat.gameforge.main_quest_lv93._150_sendLetter begin
			say_title(mob_name(20380))
			say(gameforge.main_quest_lv93._210_say)
		end
		
		when 3791.kill begin
			if number(1,1000) == 1 then
				if pc.count_item(31030) < 1 then
					pc.give_item2(31030, 1)
					if pc.count_item(31030) >= 1 then
						notice_multiline(gameforge.main_quest_lv93._220_1_notice,notice)
						notice_multiline(gameforge.main_quest_lv93._220_2_notice,notice)
						set_state (state2_3)
					end
				end
			end
		end
	end
	state state2_3 begin
		when letter begin
			send_letter(gameforge.main_quest_lv93._150_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_lv93._150_sendLetter)
			say(gameforge.main_quest_lv93._230_say)
			
		end
		
		-- 중간에 퀘스트 아이템을 버릴 경우를 대비한 부분.
		when 3791.kill begin
			if number(1,1000) == 1 then
				if pc.count_item(31030) < 1 then
					pc.give_item2(31030, 1)
					if pc.count_item(31030) >= 1 then
						notice_multiline(gameforge.main_quest_lv93._220_1_notice,notice)
						notice_multiline(gameforge.main_quest_lv93._220_2_notice,notice)
						set_state (state2_3)
					end
				end
			end
		end
		
		when 20380.chat.gameforge.main_quest_lv93._150_sendLetter begin
			target.delete("__TARGET__")
			
			if pc.count_item(31030) >= 1 then
				pc.remove_item ( 31030, pc.count_item(31030))	
				
				say_title(mob_name(20380))
				say(gameforge.main_quest_lv93._240_say)
				wait()
				
				--보상
				say_title(locale.reward)
				say_reward(string.format (gameforge.main_quest_lv60._190_sayReward, 28914020))
				say_reward(string.format (gameforge.main_quest_lv60._200_sayReward, 302000))
				say_reward(string.format (gameforge.main_quest_lv60._210_sayReward, item_name(30048),1,locale.count_postfix))
				say_reward(string.format (gameforge.main_quest_lv60._210_sayReward, item_name(50819),10,locale.count_postfix))
				say("")
				
				pc.give_exp2(28914020)
				pc.change_money(302000)
				pc.give_item2(30048, 1)
				pc.give_item2(50819, 10)
				
				set_state (state3_1)
			else
				say_title(mob_name(20380))
				say(gameforge.main_quest_lv93._210_say)
				
				set_state (state2_2)
			end
		end
	end
	------------------------------------내력강화1-3------------------------------------
	------------------------------------내력강화1-3------------------------------------
	------------------------------------내력강화1-3------------------------------------
	------------------------------------내력강화1-3------------------------------------
	------------------------------------내력강화1-3------------------------------------
	------------------------------------내력강화1-3------------------------------------
	------------------------------------내력강화1-3------------------------------------
	------------------------------------내력강화1-3------------------------------------
	------------------------------------내력강화1-3------------------------------------
	------------------------------------내력강화1-3------------------------------------
	------------------------------------내력강화1-3------------------------------------
	state state3_1 begin
		when letter begin
			send_letter(gameforge.main_quest_lv93._250_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_lv93._250_sendLetter)
			say(gameforge.main_quest_lv93._260_say)
			
		end
		when 20380.chat.gameforge.main_quest_lv93._250_sendLetter begin
			target.delete("__TARGET__")
			
			say_title(mob_name(20380 ))
			say(gameforge.main_quest_lv93._270_say)
			wait()
			
			say_title(pc.getname())
			say(gameforge.main_quest_lv93._280_say)
			wait()
			
			say_title(mob_name(20380 ))
			say(gameforge.main_quest_lv93._290_say)
			wait()
			
			say_title(pc.getname())
			say(gameforge.main_quest_lv93._300_say)
			
			set_state (state3_2)
		end
	end
	state state3_2 begin
		when letter begin
			send_letter(gameforge.main_quest_lv93._250_sendLetter)
			
			local v = find_npc_by_vnum(20008)
			if 0 != v then
				target.vid("__TARGET__", v, mob_name(20008))
			end
		end
		when button or info begin
			say_title(gameforge.main_quest_lv93._310_sayTitle)
			say(gameforge.main_quest_lv93._320_say)
			
		end
		when 20008.chat.gameforge.main_quest_lv93._250_sendLetter begin
			target.delete("__TARGET__")
		
			say_title(mob_name(20008))
			say(gameforge.main_quest_lv93._330_say)
			wait()
			
			say_title(pc.getname())
			say(gameforge.main_quest_lv93._340_say)
			wait()
		
			say_title(mob_name(20008))
			say(gameforge.main_quest_lv93._350_say)
			wait()
		
			say_title(pc.getname())
			say(gameforge.main_quest_lv93._360_say)
			wait()
		
			say_title(mob_name(20008))
			say(gameforge.main_quest_lv93._370_say)
			wait()

			--보상
			say_title(locale.reward)
			say_reward(string.format (gameforge.main_quest_lv60._190_sayReward, 17904600))
			say_reward(string.format (gameforge.main_quest_lv60._200_sayReward, 30000))
			say_reward(string.format (gameforge.main_quest_lv60._210_sayReward, item_name(71094),1,locale.count_postfix))
			say_reward(string.format (gameforge.main_quest_lv60._210_sayReward, item_name(72024),1,locale.count_postfix))
			say("")
			
			pc.give_exp2(17904600)
			pc.change_money(30000)
			pc.give_item2(71094, 1)
			pc.give_item2_select(72024)
			
			set_state (state3_3)
			clear_letter()
			local cur_t = get_global_time()
			pc.setf("main_quest_lv93","ockgu_access_time",cur_t)
		end
	end
	state state3_3 begin
		when login with get_global_time() - pc.getf("main_quest_lv93","ockgu_access_time") >= 24*60*60 begin
			set_state (state4_1)
		end
		when 20008.chat.gameforge.main_quest_lv93._400_npcChat begin
			if get_global_time() - pc.getf("main_quest_lv93","ockgu_access_time") >= 24*60*60 then
				set_state (state4_1)
			else
				say_title(mob_name(20008))
				say(gameforge.main_quest_lv93._390_say)
			end
		end
	end
	
	------------------------------------내력강화1-4-----------------------------------
	------------------------------------내력강화1-4-----------------------------------
	------------------------------------내력강화1-4-----------------------------------
	------------------------------------내력강화1-4-----------------------------------
	------------------------------------내력강화1-4-----------------------------------
	------------------------------------내력강화1-4-----------------------------------
	------------------------------------내력강화1-4-----------------------------------
	------------------------------------내력강화1-4-----------------------------------
	------------------------------------내력강화1-4-----------------------------------
	------------------------------------내력강화1-4-----------------------------------
	------------------------------------내력강화1-4-----------------------------------
	state state4_1 begin
		when letter begin
			send_letter(gameforge.main_quest_lv93._400_npcChat)
			
			local v = find_npc_by_vnum(20008)
			if 0 != v then
				target.vid("__TARGET__", v, mob_name(20008))
			end
		end
		when button or info begin
			say_title(gameforge.main_quest_lv93._400_npcChat)
			say(gameforge.main_quest_lv93._410_say)
			
		end
		
		when 20008.chat.gameforge.main_quest_lv93._400_npcChat begin
			target.delete("__TARGET__")
			
			say_title(mob_name(20008 ))
			say(gameforge.main_quest_lv93._420_say)
			wait()
			
			say_title(pc.getname())
			say(gameforge.main_quest_lv93._430_say)
			wait()
			
			say_title(mob_name(20008 ))
			say(gameforge.main_quest_lv93._440_say)
			wait()
			
			say_title(pc.getname())
			say(gameforge.main_quest_lv93._450_say)
			wait()
			
			say_title(mob_name(20008 ))
			say(gameforge.main_quest_lv93._460_say)
			wait()
			
			say_title(pc.getname())
			say(gameforge.main_quest_lv93._470_say)
			wait()
			
			say_title(mob_name(20008 ))
			say(gameforge.main_quest_lv93._480_say)
		
			set_state (state4_2)
		end
	end
	-- 퀘스트 진행 --
	state state4_2 begin
		when letter begin
			send_letter(gameforge.main_quest_lv93._400_npcChat)
			q.set_counter_name(gameforge.main_quest_lv94._1080_say)
		end
		when button or info begin
			say_title(gameforge.main_quest_lv93._490_sayTitle)
			say(gameforge.main_quest_lv93._500_say)
			say_item_vnum_inline(50724,0,3)
			say_item_vnum_inline(50726,1,3)
			say_item_vnum_inline(50707,2,3)
			
			local remain1 = 200 - pc.count_item(50724)
			local remain2 = 200 - pc.count_item(50726)
			local remain3 = 200 - pc.count_item(50707)
			if remain1 < 0 then
				remain1 = 0
			end
			if remain2 < 0 then
				remain2 = 0
			end
			if remain3 < 0 then
				remain3 = 0
			end
			
			say(string.format(gameforge.main_quest_lv93._630_say,item_name(50724) ,remain1,item_name(50726) ,remain2,item_name(50707) , remain3))

			q.set_counter_value(remain1 + remain2 + remain3)
			
			if remain1 + remain2 + remain3 == 0 then
				notice_multiline(gameforge.main_quest_lv93._650_1_notice,notice)
				notice_multiline(gameforge.main_quest_lv93._650_2_notice,notice)
			end
			
		end
		
		--[[
		when 50724.pick or 50724.take or 50726.pick or 50726.take or 50707.pick or 50707.take begin
		
			local remain1 = 200 - pc.count_item(50724)
			local remain2 = 200 - pc.count_item(50726)
			local remain3 = 200 - pc.count_item(50707)
			if remain1 < 0 then
				remain1 = 0
			end
			if remain2 < 0 then
				remain2 = 0
			end
			if remain3 < 0 then
				remain3 = 0
			end
			q.set_counter_value(remain1 + remain2 + remain3)
		end
		]]--
		
		when 20008.chat.gameforge.main_quest_lv93._400_npcChat begin
			if pc.count_item(50724) >= 200 and pc.count_item(50726) >= 200 and pc.count_item(50707) >= 200 then
				
				pc.remove_item ( 50724,200)	
				pc.remove_item ( 50726,200)	
				pc.remove_item ( 50707,200)	
				
				say_title(mob_name(20008 ))
				say(gameforge.main_quest_lv93._520_say)
				wait()
				
				say_title(pc.getname())
				say(gameforge.main_quest_lv93._530_say)
				
				set_state (state4_3)
				
				clear_letter()
				
				local cur_t = get_global_time()
				pc.setf("main_quest_lv93","item4_make_start_time",cur_t)
			else 
				say_title(mob_name(20008 ))
				say(gameforge.main_quest_lv93._640_say)
			end
		end	
	end
	state state4_3 begin
		when login with get_global_time() - pc.getf("main_quest_lv93","item4_make_start_time") >= 24*60*60 begin
			set_state (state4_4)
			q.set_counter_name("")
		end
		when 20008.chat.gameforge.main_quest_lv93._400_npcChat begin
			say_title(mob_name(20008 ))
			say(gameforge.main_quest_lv93._540_say)
		end
	end
	state state4_4 begin
		when letter begin
			send_letter(gameforge.main_quest_lv93._400_npcChat)
			
			local v = find_npc_by_vnum(20008)
			if 0 != v then
				target.vid("__TARGET__", v, mob_name(20008))
			end
		end
		when button or info begin
			say_title(gameforge.main_quest_lv93._400_npcChat)
			say(gameforge.main_quest_lv93._550_say)
			
		end
		
		when 20008.chat.gameforge.main_quest_lv93._400_npcChat begin
			target.delete("__TARGET__")
			
			say_title(mob_name(20008 ))
			say(gameforge.main_quest_lv93._560_say)
			wait()
			
			say_title(pc.getname())
			say(gameforge.main_quest_lv93._570_say)
			wait()
			
			--보상
			say_title(locale.reward)
			say_reward(string.format (gameforge.main_quest_lv60._190_sayReward, 31374000))
			--say_reward(string.format (gameforge.main_quest_lv60._200_sayReward, 0))
			say_reward(string.format (gameforge.main_quest_lv60._210_sayReward, item_name(31031),1,locale.count_postfix))
			say_reward(string.format (gameforge.main_quest_lv60._210_sayReward, item_name(50706),20,locale.count_postfix))
			say_reward(string.format (gameforge.main_quest_lv60._210_sayReward, item_name(72301),5,locale.count_postfix))
			say("")
			
			pc.give_exp2(31374000)
			--pc.change_money(0)
			pc.give_item2(31031, 1)
			pc.give_item2(50706, 20)
			pc.give_item2(72301, 1)
			pc.give_item2(72301, 1)
			pc.give_item2(72301, 1)
			pc.give_item2(72301, 1)
			pc.give_item2(72301, 1)
			
			set_state (state5_1)
		end
	end
	
	------------------------------------신약 제조1-1-----------------------------------
	------------------------------------신약 제조1-1-----------------------------------
	------------------------------------신약 제조1-1-----------------------------------
	------------------------------------신약 제조1-1-----------------------------------
	------------------------------------신약 제조1-1-----------------------------------
	------------------------------------신약 제조1-1-----------------------------------
	------------------------------------신약 제조1-1-----------------------------------
	------------------------------------신약 제조1-1-----------------------------------
	------------------------------------신약 제조1-1-----------------------------------
	------------------------------------신약 제조1-1-----------------------------------
	------------------------------------신약 제조1-1-----------------------------------
	state state5_1 begin
		when letter begin
			send_letter(gameforge.main_quest_lv93._580_sendLetter)
			
			local v = find_npc_by_vnum(20380)
			if 0 != v then
				target.vid("__TARGET__", v, mob_name(20380))
				target.vid("__TARGET__", v, mob_name(20380))
			end
		end
		when button or info begin
			say_title(gameforge.main_quest_lv93._580_sendLetter)
			say(gameforge.main_quest_lv93._590_say)
			
		end
		
		when 20380.chat.gameforge.main_quest_lv93._580_sendLetter begin
			target.delete("__TARGET__")
			
			pc.remove_item(31031,pc.count_item(31031))
			
			say_title(mob_name( 20380))
			say(gameforge.main_quest_lv93._600_say)
			wait()
			
			say_title(pc.getname())
			say(gameforge.main_quest_lv93._610_say)
			wait()

			--보상
			say_title(locale.reward)
			say_reward(string.format (gameforge.main_quest_lv60._190_sayReward, 19920820))
			say_reward(string.format (gameforge.main_quest_lv60._200_sayReward, 335000))
			say_reward(string.format (gameforge.main_quest_lv60._210_sayReward, item_name(72723),1,locale.count_postfix))
			say_reward(string.format (gameforge.main_quest_lv60._210_sayReward, item_name(70050),1,locale.count_postfix))
			say("")
			say_title(gameforge.main_quest_lv93._620_say)
			
			pc.give_exp2(19920820)
			pc.change_money(335000)
			pc.give_item2(72723, 1)
			pc.give_item2_select(70050)
			item.set_socket(2, 120)
			
			clear_letter()
			set_quest_state ("main_quest_lv94", "state0")
			set_state (__COMPLETE__)
		end
	end
	
	state __COMPLETE__ begin
		when enter begin
			q.done()
		end
	end
end
