quest collect_quest_lv70  begin
	state start begin
	end
	state run begin
		when login or levelup with pc.level >= 70 begin
			set_state(information)
		end
	end

	state information begin
		when letter begin
			local v = find_npc_by_vnum(20084)
			if v != 0 then
				target.vid("__TARGET__", v, gameforge.collect_herb_lv10._10_targetVid)
			end
			send_letter(gameforge.collect_quest_lv60._10_sendLetter)
		end

		when button or info begin
			say_title(gameforge.collect_quest_lv70._10_sayTitle)
			say(gameforge.collect_quest_lv60._30_say)
		end

		when __TARGET__.target.click or	20084.chat.gameforge.collect_quest_lv60._40_npcChat begin
			target.delete("__TARGET__")
			say_title(gameforge.collect_quest_lv60._50_sayTitle)
			say(gameforge.collect_quest_lv70._20_say)
			wait()
			say_title(gameforge.collect_quest_lv60._50_sayTitle)
			say(gameforge.collect_quest_lv70._30_say)
			wait()
			say_title(gameforge.collect_quest_lv60._50_sayTitle)
			say(gameforge.collect_quest_lv70._40_say)
			set_state(go_to_disciple)
			pc.setqf("duration",0)  -- Versuchszeit
			pc.setqf("collect_count",0)--gesammte Zahl der Artikel
			pc.setqf("drink_drug",0) --1Punkt, wenn man das Verwirrungsasser trinkt
			end
	end

	state go_to_disciple begin
		when letter begin
			send_letter(gameforge.collect_quest_lv60._220_sendLetter)

		end
		when button or info begin
			say_title(gameforge.collect_quest_lv70._50_sayTitle)
			say(gameforge.collect_quest_lv70._60_say)
			say_item_vnum(30165)
			say_reward(string.format(gameforge.collect_quest_lv70._70_sayReward, pc.getqf("collect_count")))
					end

		when 71035.use begin --DasVerwirrungswasser
			if get_time() < pc.getqf("duration") then
				say(gameforge.collect_quest_lv70._80_say)
				return
			end
			if pc.getqf("drink_drug")==1 then
				say(gameforge.collect_quest_lv70._90_say)
				return
			end
			if pc.count_item(30165)==0 then
				say_title(gameforge.collect_quest_lv60._140_sayTitle)
				say(gameforge.collect_quest_lv70._100_say)
				return
			end

			pc.remove_item(71035, 1)
			pc.setqf("drink_drug",1)
		end
		when 2301.kill or  2302.kill or 2303.kill or 2304.kill or 2305.kill or  2311.kill or  2312.kill or  2313.kill or 2314.kill or 2315.kill  begin
			local s = number(1, 200)
			if s == 1 and pc.count_item(30165)==0 then
				pc.give_item2(30165)
				--send_letter(string.format(gameforge.collect_quest_lv70._110_sendLetter, item_name(30165)))
				send_letter(gameforge.collect_quest_lv70._110_sendLetter)
			end	
		end



		when 20084.chat.gameforge.collect_quest_lv70._120_npcChat with pc.count_item(30165) >0   begin
			if get_time() > pc.getqf("duration") then
				if  pc.count_item(30165) >0 then
					say_title(gameforge.collect_quest_lv60._50_sayTitle)
					say(gameforge.collect_quest_lv70._130_say)
					pc.remove_item(30165, 1)
					pc.setqf("duration",get_time()+60*60*22)------------------22Stunden
					wait()

					local pass_percent
					if pc.getqf("drink_drug")==0 then
						pass_percent=60
					else
						pass_percent=90
					end

					local s= number(1,100)
					if s<= pass_percent  then
						if pc.getqf("collect_count")< 24 then     --weniger als 25
							local index =pc.getqf("collect_count")+1
							pc.setqf("collect_count",index)     --Da du noch einen besorgst, macht man plus eins
							say_title(gameforge.collect_quest_lv60._50_sayTitle)
							say(string.format(gameforge.collect_quest_lv70._140_say, 25-pc.getqf("collect_count")))
							pc.setqf("drink_drug",0)	 --Anfang mit dem Wunderwasser
							return
						end
						say_title(gameforge.collect_quest_lv60._50_sayTitle)
						say(gameforge.collect_quest_lv70._150_say)
						pc.setqf("collect_count",0)
						pc.setqf("drink_drug",0)
						pc.setqf("duration",0)
						set_state(key_item)
						return
					else
						say_title(gameforge.collect_quest_lv60._50_sayTitle)
						say(gameforge.collect_quest_lv70._160_say)
						pc.setqf("drink_drug",0)	 --Anfang mit dem Verwirrungswasser
						return
					end
				else
					say_title(gameforge.collect_quest_lv60._50_sayTitle)
					--say(string.format(gameforge.collect_quest_lv0._190_say, item_name(30165)))
					say(gameforge.collect_quest_lv70._165_say)
					return
				end
			else
				say_title(gameforge.collect_quest_lv60._50_sayTitle)
				say(gameforge.collect_quest_lv70._170_say)
				return
			end

		end
	end


	state key_item begin
		when letter begin
			send_letter(gameforge.collect_quest_lv60._220_sendLetter)

			if pc.count_item(30224)>0 then
				local v = find_npc_by_vnum(20084)
				if v != 0 then
					target.vid("__TARGET__", v, gameforge.collect_quest_lv40._210_targetVid)
				end
			end

		end
		when button or info begin
			if pc.count_item(30224) >0 then
				say_title(gameforge.collect_quest_lv70._180_sayTitle)
				say(gameforge.collect_quest_lv70._190_say)
				return
			end

			say_title(gameforge.collect_quest_lv70._200_sayTitle)
			say(gameforge.collect_quest_lv70._210_say)
			say_item_vnum(30224)----------Das Geiststein
			say(gameforge.collect_quest_lv70._220_say)
		end



		when 2301.kill or 2302.kill or 2303.kill or 2304.kill or 2305.kill or 2311.kill or 2312.kill or 2313.kill or 2314.kill or 2315.kill  begin
			local s = number(1, 500)
			if s == 1 and pc.count_item(30224)==0 then
				pc.give_item2(30224)
				send_letter(gameforge.collect_quest_lv70._230_sendLetter)
			end
		end



		when __TARGET__.target.click  or	20084.chat.gameforge.collect_quest_lv70._240_npcChat with pc.count_item(30224) > 0  begin
			target.delete("__TARGET__")
			if pc.count_item(30224) > 0 then 
				say_title(gameforge.collect_quest_lv60._50_sayTitle)
				say(gameforge.collect_quest_lv70._250_say)
				pc.remove_item(30224,1)
				set_state(__reward)
			else
				say_title(gameforge.collect_quest_lv60._50_sayTitle)
				--say(string.format(gameforge.collect_quest_lv30._290_say, item_name(30224)))
				say(gameforge.collect_quest_lv70._255_say)
				return
			end
		end

	end

	state __reward begin
		when letter begin
			send_letter(gameforge.collect_quest_lv40._300_sendLetter)

			local v = find_npc_by_vnum(20018)
			if v != 0 then
				target.vid("__TARGET__", v, gameforge.collect_quest_lv30._310_targetVid)
			end

		end
		when button or info begin
			say_title(gameforge.collect_quest_lv40._300_sendLetter)
			say(gameforge.collect_quest_lv70._260_say)
		end

		when __TARGET__.target.click  or	20018.chat.gameforge.collect_quest_lv30._330_npcChat  begin
		    target.delete("__TARGET__")
			say_title(gameforge.collect_quest_lv30._340_sayTitle)
			say(gameforge.collect_quest_lv70._270_say)
			wait()
			say_title(gameforge.collect_quest_lv30._340_sayTitle)
			say(gameforge.collect_quest_lv70._280_say)
			say_reward(gameforge.collect_quest_lv70._290_sayReward)
						affect.add_collect(apply.MOV_SPEED,11,60*60*24*365*60)	
			affect.add_collect_point(POINT_DEF_BONUS,10,60*60*24*365*60) --60³â		
			pc.give_item2(50113)
			clear_letter()
			set_quest_state("collect_quest_lv80", "run")
			set_state(__complete)
		end

	end


	state __complete begin
	end
end



