quest subquest_42 begin
	state start begin
		when login or levelup with pc.level >= 46 and pc.level <= 48 begin
			set_state(information)
		end
	end

	state information begin
		when letter begin
			
			local vnum=0

			if pc.get_empire() == 1 then
				vnum= 20306
			elseif pc.get_empire() == 2 then
				vnum= 20326
			elseif pc.get_empire() == 3 then
				vnum=20346
			end


			local v=find_npc_by_vnum(vnum)
			if 0==v then
			else
				target.vid("__TARGET__", v, gameforge.subquest_42._10_targetVid)
			end
		end

		when __TARGET__.target.click or 20306.chat.gameforge.subquest_42._10_targetVid  begin
			target.delete("__TARGET__")
			say_title(gameforge.subquest_42._20_sayTitle)
			say(gameforge.subquest_42._30_say)
			wait()
			say_title(gameforge.subquest_42._20_sayTitle)
			say(gameforge.subquest_42._40_say)
			wait()
			say_title(gameforge.subquest_42._20_sayTitle)
			say(gameforge.subquest_42._50_say)
		
			local s= select(gameforge.subquest_42._60_select, gameforge.subquest_42._70_select)
			if 2==s then
				say(gameforge.subquest_42._80_say)
				local a= select(gameforge.locale.guild.yes, gameforge.locale.guild.no)
				if 2==a then
					say_title(gameforge.subquest_42._20_sayTitle)
					say(gameforge.subquest_42._90_say)
					return
				end
				say_title(gameforge.subquest_42._20_sayTitle)
				say(gameforge.subquest_42._100_say)
				set_state(__GIVEUP__)
				return
			end
			say_title(gameforge.subquest_42._20_sayTitle)
			say(gameforge.subquest_42._110_say)
			set_state(for_the_die)

			end

		when __TARGET__.target.click or 20326.chat.gameforge.subquest_42._10_targetVid  begin
			target.delete("__TARGET__")
			say_title(gameforge.subquest_42._20_sayTitle)
			say(gameforge.subquest_42._120_say)
			wait()
			say_title(gameforge.subquest_42._20_sayTitle)
			say(gameforge.subquest_42._40_say)
			wait()
			say_title(gameforge.subquest_42._20_sayTitle)
			say(gameforge.subquest_42._130_say)
		
			local s= select(gameforge.subquest_42._60_select, gameforge.subquest_42._70_select)
			if 2==s then
				say(gameforge.subquest_42._80_say)
				local a= select(gameforge.locale.guild.yes, gameforge.locale.guild.no)
				if 2==a then
					say_title(gameforge.subquest_42._20_sayTitle)
					say(gameforge.subquest_42._90_say)
					return
				end
				say_title(gameforge.subquest_42._20_sayTitle)
				say(gameforge.subquest_42._100_say)
				set_state(__GIVEUP__)
				return
			end
			say_title(gameforge.subquest_42._20_sayTitle)
			say(gameforge.subquest_42._110_say)
			set_state(for_the_die)

			end



		when __TARGET__.target.click or 20346.chat.gameforge.subquest_42._10_targetVid  begin
			target.delete("__TARGET__")
			say_title(gameforge.subquest_42._20_sayTitle)
			say(gameforge.subquest_42._120_say)
			wait()
			say_title(gameforge.subquest_42._20_sayTitle)
			say(gameforge.subquest_42._40_say)
			wait()
			say_title(gameforge.subquest_42._20_sayTitle)
			say(gameforge.subquest_42._130_say)
		
			local s= select(gameforge.subquest_42._60_select, gameforge.subquest_42._70_select)
			if 2==s then
				say(gameforge.subquest_42._80_say)
				local a= select(gameforge.locale.guild.yes, gameforge.locale.guild.no)
				if 2==a then
					say_title(gameforge.subquest_42._20_sayTitle)
					say(gameforge.subquest_42._90_say)
					return
				end
				say_title(gameforge.subquest_42._20_sayTitle)
				say(gameforge.subquest_42._100_say)
				set_state(__GIVEUP__)
				return
			end
			say_title(gameforge.subquest_42._20_sayTitle)
			say(gameforge.subquest_42._110_say)
			set_state(for_the_die)

			end

		end


	state for_the_die begin

		when letter begin

			setskin(NOWINDOW)
			makequestbutton(gameforge.subquest_42._10_targetVid)
			q.set_title(gameforge.subquest_42._10_targetVid)
			q.start()
			
			if  pc.count_item("30147") >=1 and  pc.count_item("30148") >=1 then
					local vnum=0

					if pc.get_empire() == 1 then
						vnum= 20306
					elseif pc.get_empire() == 2 then
						vnum= 20326
					elseif pc.get_empire() == 3 then
						vnum= 20346
					end

					local v=find_npc_by_vnum(vnum)
					if 0!= v then
						target.vid("__TARGET__",v, "")
					end 
				end	

		end		
			
	
		when info or  button begin
			if  pc.count_item("30147") >=1 and  pc.count_item("30148") >=1 then
				say_title(gameforge.subquest_42._140_sayTitle)
				say(gameforge.subquest_42._150_say)
				return
			end
			
			say_title(gameforge.subquest_42._160_sayTitle)

			say(gameforge.subquest_42._170_say)
		end


					
		when 734.kill or 735.kill or 736.kill  begin
			local s = number(1, 100)
			
			if s <= 5 and pc.count_item(30147)==0 then
				pc.give_item2(30147, 1)
			end	
	
			local a = number(1, 100)
			if a <= 5 and pc.count_item(30148)==0 then
				pc.give_item2(30148, 1)
			end
			
						
		end
			
				
		when __TARGET__.target.click or	20306.chat.gameforge.subquest_42._180_npcChat with pc.count_item("30147") >=1 and  pc.count_item("30148") >=1 begin
		
			target.delete("__TARGET__")
			say_title(gameforge.subquest_42._20_sayTitle)
			say(gameforge.subquest_42._190_say)
			pc.remove_item("30147",1)
			pc.remove_item("30148",1)
			
			say_reward(gameforge.subquest_42._200_sayReward)
			pc.give_exp2(1700000)
			set_quest_state("levelup","run")


			say_reward(gameforge.subquest_42._210_sayReward)
			pc.give_item2(50621)
			pc.give_item2(50621)
			pc.give_item2(50621)
	
			say_reward(gameforge.subquest_42._220_sayReward)
			pc.change_money(30000)
			
			clear_letter()
			set_state(COMPLETE)

		end
	
		when __TARGET__.target.click or	20326.chat.gameforge.subquest_42._180_npcChat with pc.count_item("30147") >=1 and  pc.count_item("30148") >=1 begin
		
			target.delete("__TARGET__")
			say_title(gameforge.subquest_42._20_sayTitle)
			say(gameforge.subquest_42._230_say)
			pc.remove_item("30147",1)
			pc.remove_item("30148",1)
			
			say_reward(gameforge.subquest_42._200_sayReward)
			pc.give_exp2(1700000)
			set_quest_state("levelup","run")


			say_reward(gameforge.subquest_42._210_sayReward)
			pc.give_item2(50621)
			pc.give_item2(50621)
			pc.give_item2(50621)
	
			say_reward(gameforge.subquest_42._220_sayReward)
			pc.change_money(30000)
			
			clear_letter()
			set_state(COMPLETE)

		end
	
		when __TARGET__.target.click or	20346.chat.gameforge.subquest_42._180_npcChat with pc.count_item("30147") >=1 and  pc.count_item("30148") >=1 begin
		
			target.delete("__TARGET__")
			say_title(gameforge.subquest_42._20_sayTitle)
			say(gameforge.subquest_42._230_say)
			pc.remove_item("30147",1)
			pc.remove_item("30148",1)
			
			say_reward(gameforge.subquest_42._200_sayReward)
			pc.give_exp2(1700000)
			set_quest_state("levelup","run")


			say_reward(gameforge.subquest_42._210_sayReward)
			pc.give_item2(50621)
			pc.give_item2(50621)
			pc.give_item2(50621)
	
			say_reward(gameforge.subquest_42._220_sayReward)
			pc.change_money(30000)
			
			clear_letter()
			set_state(COMPLETE)

		end

end

	state __GIVEUP__ begin
	end

	state COMPLETE begin
		when enter begin
			q.done()
		end
	end


end
