quest arne_test1 begin
	state start begin
function generate_unique_rand_table (SourceListDepth, TargetListDepth)
local Rand_List = {}
local Rand_Number
local current_length = 1
local conflict = false
local i
       
	repeat

    Rand_Number = math.random(1,SourceListDepth)
        --notice("Generated Number" .. Rand_Number)
    i = 1
    conflict = false

    while conflict == false do
        if Rand_List[i] == Rand_Number then
            conflict = true
        else
            if i == current_length then
                Rand_List[i] = Rand_Number
                current_length=current_length + 1
                conflict = true
            else
                i= i + 1
            end
        end

    end

	until current_length == TargetListDepth+1
	
	return Rand_List
	
end
		when letter begin 
				local temp = math.random(1,100)
				Temp_RandList ={}
				Temp_RandList = arne_test1.generate_unique_rand_table(8, 4) 

				Test_QestBlock = false                
				TestQuest_timeToWait = 5              
				pc.setqf("cooldown_timer", get_time())
				Test_Quest_LocTable_C1 =
				{
					[1]= {361, 478,},
					[2]= {347, 475,},
					[3]= {356, 461,},
					[4]= {336, 462,},
					[5]= {335, 447,},
					[6]= {363, 450,}, 
					[7]= {368, 479,}, 
					[8]= {380, 463,}, 
				}
				Test_Quest_LocTable_Temp = 
				{
				Test_Quest_LocTable_C1[Temp_RandList[1]],
				Test_Quest_LocTable_C1[Temp_RandList[2]],
				Test_Quest_LocTable_C1[Temp_RandList[3]],
				Test_Quest_LocTable_C1[Temp_RandList[4]],
				}
--				set_state(reach_marker)
		end		
	end

state reach_marker begin
	when letter begin
		target.pos("__TARGET8__", Test_Quest_LocTable_Temp[1][1], Test_Quest_LocTable_Temp[1][2], 41, "")
		target.pos("__TARGET9__", Test_Quest_LocTable_Temp[2][1], Test_Quest_LocTable_Temp[2][2], 41, "")
		target.pos("__TARGET10__", Test_Quest_LocTable_Temp[3][1], Test_Quest_LocTable_Temp[3][2], 41, "")
		target.pos("__TARGET11__", Test_Quest_LocTable_Temp[4][1], Test_Quest_LocTable_Temp[4][2], 41, "")
--		target.pos("__TARGET9__", 347, 475, 41, "")  
		notice("Markers should be there")
	end
	
	when __TARGET8__.target.arrive begin
		if Test_QestBlock == true then
			notice("Bool true")
			if get_time() - pc.getqf("cooldown_timer") >= TestQuest_timeToWait then
				notice("wait timer through")
				Test_QestBlock = false
			else
				notice("waiting for timer")
			end
		else
			target.delete("__TARGET8__")
			say_title("Gefrorene Tr�ne")
			say("Hier ist eine der geforenen Tr�nen des Drachengottes zur Erde gest�rtzt.")
			local s = select("Tr�ne aufnehmen", "Nach mehr graben", "Nichts tun")
			if s == 1 then			
				say_title("Gefrorene Tr�ne")
				say("Du erh�lst eine gefrorene Tr�ne.")
				mob.spawn(173, pc.get_local_x(), pc.get_local_y(), 1, 1, 1)
			end
			if s == 2 then
				say_title("Gefrorene Tr�ne")
				say("Du findest 2 gefroene Tr�nen.")
				mob.spawn(173, pc.get_local_x(), pc.get_local_y(), 1, 1, 3)
			end
			if s == 3 then 
				pc.setqf("cooldown_timer", get_time())
				affect.add(apply.CON, 120, 60)	
				TestQuest_timeToWait = 5
				Test_QestBlock = true	
				target.pos("__TARGET8__", Test_Quest_LocTable_Temp[1][1], Test_Quest_LocTable_Temp[1][2], 41, "")
				say_title("Gefrorene Tr�ne")
				say("Du l�sst die Tr�ne liegen.")
			end
		end
	end
	
	when __TARGET9__.target.arrive begin
		if Test_QestBlock == true then
			notice("Bool true")
			if get_time() - pc.getqf("cooldown_timer") >= TestQuest_timeToWait then
				notice("wait timer through")
				Test_QestBlock = false
			else
				notice("waiting for timer")
			end
		else
			target.delete("__TARGET9__")    
			say_title("Gefrorene Tr�ne")
			say("Hier ist eine der geforenen Tr�nen des Drachengottes zur Erde gest�rtzt.")
			local s = select("Tr�ne aufnehmen", "Nach mehr graben", "Nichts tun")
			if s == 1 then			
				say_title("Gefrorene Tr�ne")
				say("Du erh�lst eine gefrorene Tr�ne.")
				affect.add(apply.CON, 30, 60)		
				mob.spawn(173, pc.get_local_x(), pc.get_local_y(), 1, 1, 1)
			end
			if s == 2 then
				say_title("Gefrorene Tr�ne")
				say("Du findest 2 gefroene Tr�nen.")
				mob.spawn(173, pc.get_local_x(), pc.get_local_y(), 1, 1, 3)
			end
			if s == 3 then
				pc.setqf("cooldown_timer", get_time())
				affect.add(apply.CON, 120, 60)	
				TestQuest_timeToWait = 5
				Test_QestBlock = true				
				target.pos("__TARGET9__", Test_Quest_LocTable_Temp[2][1], Test_Quest_LocTable_Temp[2][2], 41, "")
				say_title("Gefrorene Tr�ne")
				say("Du l�sst die Tr�ne liegen.")
			end
		end
	end	
	
		when __TARGET10__.target.arrive begin
		if Test_QestBlock == true then
			notice("Bool true")
			if get_time() - pc.getqf("cooldown_timer") >= TestQuest_timeToWait then
				notice("wait timer through")
				Test_QestBlock = false
			else
				notice("waiting for timer")
			end
		else
			target.delete("__TARGET10__")    
			say_title("Gefrorene Tr�ne")
			say("Hier ist eine der geforenen Tr�nen des Drachengottes zur Erde gest�rtzt.")
			local s = select("Tr�ne aufnehmen", "Nach mehr graben", "Nichts tun")
			if s == 1 then			
				say_title("Gefrorene Tr�ne")
				say("Du erh�lst eine gefrorene Tr�ne.")
				affect.add(apply.CON, 30, 60)		
				mob.spawn(173, pc.get_local_x(), pc.get_local_y(), 1, 1, 1)
			end
			if s == 2 then
				say_title("Gefrorene Tr�ne")
				say("Du findest 2 gefroene Tr�nen.")
				mob.spawn(173, pc.get_local_x(), pc.get_local_y(), 1, 1, 3)
			end
			if s == 3 then
				pc.setqf("cooldown_timer", get_time())
				affect.add(apply.CON, 120, 60)	
				TestQuest_timeToWait = 5
				Test_QestBlock = true				
				target.pos("__TARGET10__", Test_Quest_LocTable_Temp[3][1], Test_Quest_LocTable_Temp[3][2], 41, "")
				say_title("Gefrorene Tr�ne")
				say("Du l�sst die Tr�ne liegen.")
			end
		end
	end	

	when __TARGET11__.target.arrive begin
		if Test_QestBlock == true then
			notice("Bool true")
			if get_time() - pc.getqf("cooldown_timer") >= TestQuest_timeToWait then
				notice("wait timer through")
				Test_QestBlock = false
			else
				notice("waiting for timer")
			end
		else
			target.delete("__TARGET11__")    
			say_title("Gefrorene Tr�ne")
			say("Hier ist eine der geforenen Tr�nen des Drachengottes zur Erde gest�rtzt.")
			local s = select("Tr�ne aufnehmen", "Nach mehr graben", "Nichts tun")
			if s == 1 then			
				say_title("Gefrorene Tr�ne")
				say("Du erh�lst eine gefrorene Tr�ne.")
				affect.add(apply.CON, 30, 60)		
				mob.spawn(173, pc.get_local_x(), pc.get_local_y(), 1, 1, 1)
			end
			if s == 2 then
				say_title("Gefrorene Tr�ne")
				say("Du findest 2 gefroene Tr�nen.")
				mob.spawn(173, pc.get_local_x(), pc.get_local_y(), 1, 1, 3)
			end
			if s == 3 then
				pc.setqf("cooldown_timer", get_time())
				affect.add(apply.CON, 120, 60)	
				TestQuest_timeToWait = 5
				Test_QestBlock = true				
				target.pos("__TARGET11__", Test_Quest_LocTable_Temp[4][1], Test_Quest_LocTable_Temp[4][2], 41, "")
				say_title("Gefrorene Tr�ne")
				say("Du l�sst die Tr�ne liegen.")
			end
		end
	end	
	
end
end