
quest subquest_19  begin
	state start begin
		when login or levelup with pc.level >= 13  and pc.level <=15 begin
			set_state(information)
		end
	end

	state information begin
		when letter begin
			local v=find_npc_by_vnum(9006)
			if 0==v then
			else
				target.vid("__TARGET__", v, gameforge.fortune_telling._100_sayTitle)
			end
		end

		when __TARGET__.target.click or	9006.chat.gameforge.subquest_19._10_npcChat  begin
			target.delete("__TARGET__")
			say_title(gameforge.fortune_telling._100_sayTitle)
			say(gameforge.subquest_19._20_say)
			local b= select(gameforge.subquest_19._30_select, gameforge.subquest_17._50_select)
			if 2==b then
				say_title(gameforge.couple_ring._20_sayTitle)
				say(gameforge.subquest_19._40_say)
			else	
				say_title(gameforge.fortune_telling._100_sayTitle)
				say(gameforge.subquest_19._50_say)
			end
			local r= select(gameforge.find_brother_article._90_select, gameforge.find_brother_article._100_select)
			if 2==r then
				say(gameforge.subquest_19._60_say)
				local a= select(gameforge.locale.guild.yes, gameforge.locale.guild.no)
				if 2==a then
					say_title(gameforge.couple_ring._20_sayTitle)
					say(gameforge.subquest_19._70_say)
					return
				end
				say_pc_name()
					say(gameforge.subquest_19._80_say)
				set_state(__GIVEUP__)
				return
			end
			say_pc_name()
			say(gameforge.subquest_19._90_say)
			set_state(find)
				
		end
	end
	state find begin
		when letter begin
			send_letter(gameforge.subquest_19._100_sendLetter)
		end
		when info or button begin
			say_title(gameforge.subquest_19._110_sayTitle)
			say(gameforge.subquest_19._120_sayReward)
		end

		when 106.kill begin
			local s = number(1, 100)
			if s <= 5 and pc.count_item("30151")==0  then 
				pc.give_item2("30151", 1)
				local v=find_npc_by_vnum(9006)
				if 0==v then
				else
					target.vid("__TARGET__",v, gameforge.subquest_19._130_targetVid)
				end
			end	
		end
		
		when 9006.chat.gameforge.subquest_19._140_npcChat with pc.count_item("30151") == 0 begin
			say(gameforge.subquest_19._150_say)
			say_item_vnum(30151)
			say(gameforge.subquest_19._160_say)

			local s= select(gameforge.subquest_19._170_select, gameforge.subquest_19._180_select)
			if 2==s then
				say(gameforge.subquest_19._190_say)
				local a= select(gameforge.locale.guild.yes, gameforge.locale.guild.no)
				if  2==a then
					say(gameforge.subquest_19._200_say)
					return
				end	
				say_title(gameforge.couple_ring._20_sayTitle)
				say(gameforge.subquest_19._210_say)
				set_state(__GIVEUP__)
				return
			end
				
			say_title(gameforge.couple_ring._20_sayTitle)
			say(gameforge.subquest_19._220_say)
			
		 end


		when __TARGET__.target.click or 9006.chat.gameforge.subquest_19._140_npcChat with pc.countitem("30151")>=1 begin 
			target.delete("__TARGET__")
			say_title(gameforge.fortune_telling._100_sayTitle)
			say(gameforge.subquest_19._230_say)
			wait()
			say_title(gameforge.couple_ring._20_sayTitle)
			say(gameforge.subquest_19._240_say)
			pc.removeitem("30151", 1) 
			setstate(reward)
		end
	end
	state reward begin
		when letter begin
			send_letter(gameforge.subquest_19._250_sendLetter)
		end
		when info or button begin
			say_title(gameforge.subquest_19._250_sendLetter)
			say(gameforge.subquest_19._260_say)
	
			local s=number(1, 3)
			if 1>=s then -- 33.33% (1/3)
					say_title(gameforge.buy_fishrod._210_sayTitle)
				say(gameforge.subquest_19._270_say)
				local r=number(1, 16)
				if r==1 then
					pc.give_item2("11204", 1)
				elseif r==2 then
					pc.give_item2("11214", 1)
				elseif r==3 then
					pc.give_item2("11404", 1)
				elseif r==4 then
					pc.give_item2("11414", 1)
				elseif r==5 then
					pc.give_item2("11604", 1)
				elseif r==6 then
					pc.give_item2("11614", 1)
				elseif r==7 then
					pc.give_item2("11804", 1)
				elseif r==8 then
					pc.give_item2("11814", 1)
				elseif r==9 then
					pc.give_item2("11203", 1)
				elseif r==10 then
					pc.give_item2("11213", 1)
				elseif r==11 then
					pc.give_item2("11403", 1)
				elseif r==12 then
					pc.give_item2("11413", 1)
				elseif r==13 then
					pc.give_item2("11603", 1)
				elseif r==14 then
					pc.give_item2("11613", 1)
				elseif r==15 then
					pc.give_item2("11803", 1)
				elseif r==16 then
					pc.give_item2("11813", 1)
				end
			elseif 2>=s then -- 33.33% (1/3)
					say_title(gameforge.buy_fishrod._210_sayTitle)
				say(gameforge.subquest_19._280_say)
				local r=number(1, 16)
				if r==1 then
					pc.give_item2("11202", 1)
				elseif r==2 then
					pc.give_item2("11212", 1)
				elseif r==3 then
					pc.give_item2("11402", 1)
				elseif r==4 then
					pc.give_item2("11412", 1)
				elseif r==5 then
					pc.give_item2("11602", 1)
				elseif r==6 then
					pc.give_item2("11612", 1)
				elseif r==7 then
					pc.give_item2("11802", 1)
				elseif r==8 then
					pc.give_item2("11812", 1)
				elseif r==9 then
					pc.give_item2("11201", 1)
				elseif r==10 then
					pc.give_item2("11211", 1)
				elseif r==11 then
					pc.give_item2("11401", 1)
				elseif r==12 then
					pc.give_item2("11411", 1)
				elseif r==13 then
					pc.give_item2("11601", 1)
				elseif r==14 then
					pc.give_item2("11611", 1)
				elseif r==15 then
					pc.give_item2("11801", 1)
				elseif r==16 then
					pc.give_item2("11811", 1)
				end
			elseif 3>=s then -- 33.33% (1/3)
					say_title(gameforge.buy_fishrod._210_sayTitle)
				say(gameforge.subquest_19._290_say)
				local r=number(1, 8)
				if r==1 then
					pc.give_item2("11200", 1)
				elseif r==2 then
					pc.give_item2("11210", 1)
				elseif r==3 then
					pc.give_item2("11400", 1)
				elseif r==4 then
					pc.give_item2("11410", 1)
				elseif r==5 then
					pc.give_item2("11600", 1)
				elseif r==6 then
					pc.give_item2("11610", 1)
				elseif r==7 then
					pc.give_item2("11800", 1)
				elseif r==8 then
					pc.give_item2("11810", 1)
				end
			end
			say_reward(gameforge.subquest_19._300_sayReward)
			pc.give_exp2(15000)
			clear_letter()
			set_state(__COMPLETE__)
		end
	end
	
	state __GIVEUP__ begin
	end
	
	state __COMPLETE__ begin
		when enter begin
			q.done()
		end
	end
end
