All pastes #963699 Raw Edit

Mine

public text v1 · immutable
#963699 ·published 2008-03-30 19:21 UTC
rendered paste body
;oQuest - Active Questing
;Started by Ritz* 02/12/07

objectdef oQuest inherits oBase
{
variable string QuestDBFileName = "./config/QuestDB.xml"
variable string ItemLogFileName = "./config/settings/${ISXWoW.RealmName.Replace[',REMOVE,.,REMOVE]}${Me.Name}ItemLog.xml"
variable string QuestLogFileName = "./config/settings/${ISXWoW.RealmName.Replace[',REMOVE,.,REMOVE]}${Me.Name}QuestLog.xml"
variable settingsetref CurrentQuest
variable settingsetref CurrentQuestLog
variable settingsetref CurrentSet
variable settingsetref CurrentSetLog
variable string QuestgiverQuest
variable string QuestLocation
variable string LastTarget
variable string NewItem
variable int QuestCount
variable int ActiveQuest
variable int i
variable int j
variable int k
variable int NewIndex

	method Initialize()
	{
		LavishSettings:AddSet[Quests]
		LavishSettings:AddSet[Items]
		LavishSettings:AddSet[QuestLog]

		LavishSettings[Quests]:Import[${QuestDBFileName}]
		LavishSettings[QuestLog]:Import[${QuestLogFileName}]

		Quest:ItemsUpdate
	}

	method Shutdown()
	{
		Quest:ClearTrackers
		Quest:Save

		LavishSettings:Remove[Quests]
		LavishSettings:Remove[Items]
		LavishSettings:Remove[QuestLog]
	}

	method Save()
	{
		LavishSettings[Quests]:Export[${QuestDBFileName}]
		LavishSettings[QuestLog]:Export[${QuestLogFileName}]
	}

	method ItemsUpdate()
	{
		variable guidlist lstItemList
		variable int intTotalCount = 0
		variable int Index = 1
		lstItemList:Search[-items,-inventory]
		if ${lstItemList.Count}
		{
			do
			{
				if !${LavishSettings[Items].FindSet[${Item[${lstItemList.GUID[${Index}]}].Name}](exists)}
				{
					if ${QuestgiverQuest.Length} > 0
					{
						echo Quest Item Found for ${QuestgiverQuest}: ${Item[${lstItemList.GUID[${Index}]}].Name}
						NewItem:Set[${Item[${lstItemList.GUID[${Index}]}].Name}]
						return
					}
					else
					{
						echo New Item: ${QuestgiverQuest}: ${Item[${lstItemList.GUID[${Index}]}].Name}
						LavishSettings[Items]:AddSet[${Item[${lstItemList.GUID[${Index}]}].Name}]

					}
				}
			}
			while ${Index:Inc}<=${lstItemList.Count}
		}
		if ${QuestgiverQuest.Length} == 0
		{
			NewItem:Set[""]
		}
	}

	method EventPulse()
	{
		if ${WoWScript[GetQuestLogTitle(${ActiveQuest}),7]} != 1 && !${Me.InCombat} && !${Me.Dead}
		{
			if ${Quest.HasEvent}
			{
			}
		}
	}

	method QuestTimer()
	{
		if ${CurrentQuestLog.FindSetting[Timer](exists)}
		{
			CurrentQuestLog:AddSetting[Timer,${Math.Calc[${CurrentQuestLog:FindSetting[Timer]+1]}]
		}
		else
		{
			CurrentQuestLog:AddSetting[Timer,1]
		}
		if ${CurrentQuestLog.FindSetting[Timer]} > 5000
		{
			echo Gone too long without any progress, Blacklisting quest
			CurrentQuestLog:AddSetting[Blacklisted,TRUE]
		}
	}

	method Pulse()
	{
		if ${UIElement[chkEnableQuest@Quest@HumanPages@Human@Pages@openbot].Checked}
		{
			variable int i
			variable int k
			Quest:BestQuest
			Quest:GUIUpdate
			if !${Bot.PauseFlag}
			{
				Quest:QuestTimer
			}
			CurrentQuest:Set[${LavishSettings[Quests].FindSet[${Quest.QuestString[${ActiveQuest}]}]}]
			CurrentQuestLog:Set[${LavishSettings[QuestLog].FindSet[${Quest.QuestString[${ActiveQuest}]}]}]
			QuestLocation:Set[${Quest.QuestString[${ActiveQuest}]}]
			if ${Quest.HasQuest}
			{
		 		LavishSettings[QuestLog]:AddSet[${Quest.QuestString[${ActiveQuest}]}]
		 		for (i:Set[1]; ${i}<=${WoWScript[GetNumQuestLogEntries()]}; i:Inc)
		 		{
			 		CurrentQuest:Set[${LavishSettings[Quests].FindSet[${Quest.QuestString[${i}]}]}]
				 	CurrentQuestLog:Set[${LavishSettings[QuestLog].FindSet[${Quest.QuestString[${i}]}]}]
			 		if ${Quest.IsQuest[${i}]}
			 		{
				 		LavishSettings[Quest]:AddSet[${Quest.QuestString[${i}]}]
				 		LavishSettings[QuestLog]:AddSet[${Quest.QuestString[${i}]}]
				 		for (k:Set[1]; ${k}<=${WoWScript[GetNumQuestLeaderBoards(${i})]}; k:Inc)
						{
							CurrentQuestLog:AddSet[Objective ${k}]
							CurrentQuest:AddSet[Objective ${k}]
							CurrentSet:Set[${LavishSettings[Quests].FindSet[${Quest.QuestString[${i}]}].FindSet[Objective ${k}]}]
							CurrentSetLog:Set[${LavishSettings[QuestLog].FindSet[${Quest.QuestString[${i}]}].FindSet[Objective ${k}]}]
							if ${WoWScript["GetQuestLogLeaderBoard(${k},${i})",1].NotEqual[${CurrentSetLog.FindSetting[Progress]}]} || ${WoWScript["GetQuestLogLeaderBoard(${k},${i})",3].NotEqual[${CurrentSetLog.FindSetting[Completion]}]}
							{
								echo ${Quest.QuestType[${k},${i}]} Update: ${CurrentSetLog.FindSetting[Progress]} -> ${WoWScript["GetQuestLogLeaderBoard(${k},${i})",1]}
								CurrentQuestLog:AddSetting[Timer,1]
								WoWScript "AddQuestWatch(${i},300)"
								if ${CurrentSetLog.FindSetting[Progress](exists)}
								{
									echo Recording Event Details
									if ${LastTarget.Length} > 0
										{
											echo Recording what I was Targetting: ${LastTarget}
											CurrentSet:AddSetting[Objective ${k} Target,${LastTarget}]
										}
									if ${Quest.QuestType[${k},${i}].Equal["KILL"]} || ${Quest.QuestType[${k},${i}].Equal["ITEM"]} || ${Quest.QuestType[${k},${i}].Equal["OBJECT"]}
									{
										if !${Quest.TooClose}
										{
											Quest:AutoAddHotspot[${Quest.QuestString[${i}]}]
										}
									}
									elseif ${WoWScript["GetQuestLogLeaderBoard(${k},${i})",3]} == 1
									{
										echo Recording Location
										CurrentSet:AddSetting[Objective ${k} X,${Me.X}]
										CurrentSet:AddSetting[Objective ${k} Y,${Me.Y}]
										CurrentSet:AddSetting[Objective ${k} Z,${Me.Z}]
									}
								}
								else
								{
									CurrentSet:AddSetting[Description,${WoWScript["GetQuestLogLeaderBoard(${k},${i})",1]}]
								}
								CurrentSetLog:AddSetting[Progress,${WoWScript["GetQuestLogLeaderBoard(${k},${i})",1]}]
								CurrentSet:AddSetting[Type,${Quest.QuestType[${k},${i}]}]
								CurrentSetLog:AddSetting[Completion,${WoWScript["GetQuestLogLeaderBoard(${k},${i})",3]}]
							}
							if ${Me.Target(exists)}
							{
								LastTarget:Set[${Me.Target.Name}]
							}
							else
							{
								LastTarget:Set[""]
							}
					 	}
			 		}
		 		}
		 		QuestLocation:Set[${Quest.QuestString[${ActiveQuest}]}]
		 		CurrentQuest:Set[${LavishSettings[Quests].FindSet[${Quest.QuestString[${ActiveQuest}]}]}]
				CurrentQuestLog:Set[${LavishSettings[QuestLog].FindSet[${Quest.QuestString[${ActiveQuest}]}]}]
			}
			else
			{
				;echo GUI: No Active Quest.
			}
			if ${QuestgiverQuest.Length} > 0
			{
				for (i:Set[1]; ${i}<=${WoWScript[GetNumQuestLogEntries(),1]}; i:Inc)
				{
					if ${QuestgiverQuest.Equal[${Quest.QuestName[${i}]}]}
					{
						echo Matched ${QuestgiverQuest} with ${Quest.QuestString[${i}]}
						LavishSettings[Quests]:AddSet[${Quest.QuestString[${i}]}]
						LavishSettings[QuestLog]:AddSet[${Quest.QuestString[${i}]}]
						CurrentQuest:Set[${LavishSettings[Quests].FindSet[${Quest.QuestString[${i}]}]}]
						CurrentQuestLog:Set[${LavishSettings[QuestLog].FindSet[${Quest.QuestString[${i}]}]}]
						if ${Quest.HaveQuest.Equal[OLD]}
						{
							echo Completed a Quest
							Quest:AddEnd
							return
						}
						elseif ${Quest.HaveQuest.Equal[NEW]}
						{
							echo New Quest Found
							NewIndex:Set[${i}]
							Quest:AddStart
							return
						}
						else
						{
							echo Waiting for Quest Log to update... (Maybe completed a quest?)
						}
						return
					}
				}
				echo Waiting for Quest Log to update...
			}
		}
	}

	member QuestType(int ObjNumber,int QuestNumber)
	{
		if ${WoWScript["GetQuestLogLeaderBoard(${ObjNumber},${QuestNumber})",2].Equal["event"]} && ${WoWScript["GetQuestLogLeaderBoard(${ObjNumber},${QuestNumber})",1].Find["escort"]}
		{
			return ESCORT
		}
		if !${WoWScript["GetQuestLogLeaderBoard(${ObjNumber},${QuestNumber})",2](exists)} || ${WoWScript["GetQuestLogLeaderBoard(${ObjNumber},${QuestNumber})",2].Equal["event"]}
		{
			return EVENT
		}
		if ${WoWScript["GetQuestLogLeaderBoard(${ObjNumber},${QuestNumber})",2].Equal["monster"]}
		{
			return KILL
		}
		if ${WoWScript["GetQuestLogLeaderBoard(${ObjNumber},${QuestNumber})",2].Equal["item"]}
		{
			return ITEM
		}
		if ${WoWScript["GetQuestLogLeaderBoard(${ObjNumber},${QuestNumber})",2].Equal["reputation"]}
		{
			return REP
		}
		if ${WoWScript["GetQuestLogLeaderBoard(${ObjNumber},${QuestNumber})",2].Equal["object"]}
		{
			return OBJECT
		}
		echo Error: Quest Type not found for ${Quest.QuestName[${QuestNumber}]}
		return NULL
	}

	method ClearTrackers()
	{
		variable int i
		echo Removing Quest Trackers
		for (i:Set[1]; ${i}<=${WoWScript[GetNumQuestLogEntries(),1]}; i:Inc)
		{
			if ${Quest.IsQuest[${i}]}
			{
				CurrentQuestLog:Set[${LavishSettings[QuestLog].FindSet[${Quest.QuestString[${i}]}]}]
				for (k:Set[1]; ${k}<=${WoWScript[GetNumQuestLeaderBoards(${i})]}; k:Inc)
				{
					if ${CurrentQuestLog.FindSet[Objective ${k}](exists)}
					{
						CurrentQuestLog.FindSet[Objective ${k}]:Remove
					}
				}
			}
		}
	}

	member HasEvent()
	{
		for (k:Set[1]; ${k}<=${WoWScript[GetNumQuestLeaderBoards(${ActiveQuest})]}; k:Inc)
		{
			CurrentSet:Set[${LavishSettings[Quests].FindSet[${Quest.QuestString[${ActiveQuest}]}].FindSet[Objective ${k}]}]
			if ${CurrentSet.FindSetting[Objective ${k} X](exists)}
			{
				Quest:DoEvent[${k}]
				return TRUE
			}
		}
		return FALSE
	}

	method DoEvent(int LogNo)
	{
		variable int Wait
		variable guidlist Objects
		if ${Movement.Speed}
		{
			return
		}
		if ${CurrentSet.FindSetting[Objective ${LogNo} Target](exists)} && !${Me.Target(exists)}
		{
			echo Event Targetting ${CurrentSet.FindSetting[Objective ${LogNo} Target]}
			target ${CurrentSet.FindSetting[Objective ${LogNo} Target]}
		}
		if ${Me.Target.Name.Equal[${CurrentSet.FindSetting[Objective ${LogNo} Target]}]}
		{
			echo Found my quest target
			Navigator:MoveToMob[${Target.GUID}]
			if ${Target.Distance} < 5
			{
				move -stop
				Use -target
				WoWScript SelectGossipOption(1)
			}
		}
		else
		{
			WoWScript ClearTarget()
		}
		CurrentSet:Set[${LavishSettings[Quests].FindSet[${Quest.QuestString[${ActiveQuest}]}].FindSet[Objective ${LogNo}]}]
		if ${CurrentSet.FindSetting[Objective ${LogNo} X](exists)} && (!${Me.Target(exists)} || ${Me.Target.Name.NotEqual[${CurrentSet.FindSetting[Objective ${LogNo} Target]}]})
		{
			Objects:Search[-gameobjects, -nearest, -range 0-30]
			if ${Math.Distance[${Me.X},${Me.Y},${Me.Z},${CurrentSet.FindSetting[Objective ${LogNo} X]},${CurrentSet.FindSetting[Objective ${LogNo} Y]},${CurrentSet.FindSetting[Objective ${LogNo} Z]}]} > 20
			{
				echo Moving to Event Location (${Math.Distance[${Me.X},${Me.Y},${Me.Z},${CurrentSet.FindSetting[Objective ${LogNo} X]},${CurrentSet.FindSetting[Objective ${LogNo} Y]},${CurrentSet.FindSetting[Objective ${LogNo} Z]}].Round} to go)
				Navigator:MoveToLoc[${CurrentSet.FindSetting[Objective ${LogNo} X]},${CurrentSet.FindSetting[Objective ${LogNo} Y]},${CurrentSet.FindSetting[Objective ${LogNo} Z]}]
			}
			elseif ${Object[${Objects.GUID[1]}](exists)} && ${Math.Distance[${Me.X},${Me.Y},${Me.Z},${Object[${Objects.GUID[1]}].X},${Object[${Objects.GUID[1]}].Y},${Object[${Objects.GUID[1]}].Z}]} > 5
			{
				echo Moving to ${Object[${Objects.GUID[1]}].Name}
				Navigator:MoveToLoc[${Object[${Objects.GUID[1]}].Location}]
			}
			else
			{
				move -stop
				if ${CurrentQuest.FindSetting[Item](exists)} && !${Me.Casting} && ${LavishScript.RunningTime} > ${Wait}
				{
					echo Event Using Quest Item ${CurrentQuest.FindSetting[Item]}
					Item[${CurrentQuest.FindSetting[Item]}]:Use
					Wait:Set[${LavishScript.RunningTime}+5000]
				}
			}
		}
	}


	method AddStart()
	{
		echo ====================================================
		echo ADDING A NEW QUEST - ${QuestgiverQuest}
		echo ====================================================
		if ${Me.Target(exists)}
		{
			CurrentQuest:AddSetting[StartNPC,${Me.Target.Name}]
			CurrentQuest:AddSetting[StartX,${Target.X}]
			CurrentQuest:AddSetting[StartY,${Target.Y}]
			CurrentQuest:AddSetting[StartZ,${Target.Z}]
			if !${CurrentQuest.FindSetting[EndNPC](exists)}
			{
				CurrentQuest:AddSetting[EndNPC,${Me.Target.Name}]
			}
			if !${CurrentQuest.FindSetting[EndX](exists)}
			{
				CurrentQuest:AddSetting[EndX,${Target.X}]
			}
			if !${CurrentQuest.FindSetting[EndY](exists)}
			{
				CurrentQuest:AddSetting[EndY,${Target.Y}]
			}
			if !${CurrentQuest.FindSetting[EndZ](exists)}
			{
				CurrentQuest:AddSetting[EndZ,${Target.Z}]
			}
		}
		else
		{
			CurrentQuest:AddSetting[StartX,${Me.X}]
			CurrentQuest:AddSetting[StartY,${Me.Y}]
			CurrentQuest:AddSetting[StartZ,${Me.Z}]
			if !${CurrentQuest.FindSetting[EndX](exists)}
			{
				CurrentQuest:AddSetting[EndX,${Me.X}]
			}
			if !${CurrentQuest.FindSetting[EndY](exists)}
			{
				CurrentQuest:AddSetting[EndY,${Me.Y}]
			}
			if !${CurrentQuest.FindSetting[EndZ](exists)}
			{
				CurrentQuest:AddSetting[EndZ,${Me.Z}]
			}
		}
		if ${NewItem.Length} > 0
		{
			echo Linking Quest Item ${NewItem}
			CurrentQuest:AddSetting[Item,${NewItem}]
		}
		NewItem:Set[""]
		QuestgiverQuest:Set[""]
		CurrentQuestLog:AddSetting[Completed,FALSE]
		LavishSettings[Location].FindSet[Hunting].FindSet[${CurrentQuest.FindSetting[QuestLoc]}].FindSet[Attributes]:AddSetting[Active,TRUE]
		Grind:RefreshCurrent
		Quest:UpdateDetails[${NewIndex}]
	}

	method AddEnd()
	{
		variable string EndNPC = ${CurrentQuest.FindSetting[EndNPC]}
		echo ====================================================
		echo ENDING A QUEST - ${QuestgiverQuest}
		echo ====================================================
		if ${Me.Target(exists)}
		{
			if !${CurrentQuest.FindSetting[EndNPC](exists)} || ${EndNPC.Equal[${CurrentQuest.FindSetting[StartNPC]}]}
			{
				CurrentQuest:AddSetting[EndNPC,${Me.Target.Name}]
			}
		}
		if !${CurrentQuest.FindSetting[EndX](exists)} || ${CurrentQuest.FindSetting[EndX]} == ${CurrentQuest.FindSetting[StartX]}
		{
			CurrentQuest:AddSetting[EndX,${Me.X}]
		}
		if !${CurrentQuest.FindSetting[EndY](exists)} || ${CurrentQuest.FindSetting[EndY]} == ${CurrentQuest.FindSetting[StartY]}
		{
			CurrentQuest:AddSetting[EndY,${Me.Y}]
		}
		if !${CurrentQuest.FindSetting[EndZ](exists)} || ${CurrentQuest.FindSetting[EndZ]} == ${CurrentQuest.FindSetting[StartZ]}
		{
			CurrentQuest:AddSetting[EndZ,${Me.Z}]
		}
		CurrentQuestLog:AddSetting[Completed,TRUE]
		echo STABSTABSTABSTABSTABSTABSTABSTABSTABSTABSTABSTABSTABSTABSTABSTABSTABSTAB
		echo ${LavishSettings[Location].FindSet[Hunting].FindSet[${Quest.QuestString[${ActiveQuest}]}].FindSet[Attributes].FindSetting[HotspotsCount]}
		
		if ${LavishSettings[Location].FindSet[Hunting].FindSet[${Quest.QuestString[${ActiveQuest}]}].FindSet[Attributes].FindSetting[HotspotsCount]} == 0
		
		
	
		{
			echo Removing empty location set '${CurrentQuest.FindSetting[QuestLoc]}'
		/*	LavishSettings[Location].FindSet[Hunting].FindSet[${CurrentQuest.FindSetting[QuestLoc]}]:Remove */
			Location:populateLocations
			Location:populateHotspots
			Location:populateLocationAttributes
		}
	
		for (k:Set[1]; ${k}<=${WoWScript[GetNumQuestLeaderBoards(${i})]}; k:Inc)
		{
			if ${CurrentQuestLog.FindSetting[Objective ${k}](exists)}
			{
				CurrentQuestLog.FindSetting[Objective ${k}]:Remove
			}
		}
		CurrentQuestLog:AddSetting[Blacklisted,FALSE]
		QuestgiverQuest:Set[""]
		echo Deactivating Quest Location '${CurrentQuest.FindSetting[QuestLoc]}'
		LavishSettings[Location].FindSet[Hunting].FindSet[${CurrentQuest.FindSetting[QuestLoc]}].FindSet[Attributes]:AddSetting[Active,FALSE]
		Quest:Save
		Quest:ItemsUpdate
		NewItem:Set[""]
		Grind:RefreshCurrent
	}

	method QuestgiverUpdate()
	{
		if ${UIElement[chkEnableQuest@Quest@HumanPages@Human@Pages@openbot].Checked}
		{
			echo ${WoWScript[GetTitleText()]}
			QuestgiverQuest:Set[${WoWScript[GetTitleText()]}]
			This:Output["Hooked '${QuestgiverQuest}'"]
		}
	}

	member HaveQuest()
	{
		variable int i
		for (i:Set[1]; ${i}<=${WoWScript[GetNumQuestLogEntries(),1]}; i:Inc)
		{
			CurrentQuest:Set[${LavishSettings[Quests].FindSet[${Quest.QuestString[${i}]}]}]
			if ${Quest.IsQuest[${i}]} && ${Quest.IsComplete[${i}]} && ${CurrentQuestLog.FindSetting[Completed](exists)} && ${Quest.QuestName[${i}].Equal[${QuestgiverQuest}]}
			{
				return OLD
			}
			elseif ${Quest.IsQuest[${i}]} && ${Quest.QuestName[${i}].Equal[${QuestgiverQuest}]}
			{
				return NEW
			}
		}
		return NULL
	}

	method UpdateDetails(int QuestNo)
	{
		LavishSettings[Quests]:AddSet[${Quest.QuestString[${QuestNo}]}]
		LavishSettings[QuestLog]:AddSet[${Quest.QuestString[${QuestNo}]}]
		echo Adding Basic Details from Questlog for ${Quest.QuestString[${QuestNo}]}
		CurrentQuest:AddSetting[Name,${Quest.QuestName[${QuestNo}]}]
		CurrentQuest:AddSetting[Level,${Quest.QuestLevel[${QuestNo}]}]
		if !${CurrentQuestLog.FindSetting[Blacklisted]}
		{
			CurrentQuestLog:AddSetting[Blacklisted,FALSE]
		}
		CurrentQuest:AddSetting[QuestLoc,${Quest.QuestString[${QuestNo}]}]
		UIElement[tenLocations@Grind@Pages@openbot]:SetText[${Quest.QuestString[${QuestNo}]}]
		UIElement[cmbLocationLvlFrom@Grind@Pages@openbot]:SetSelection[${Math.Calc[${Quest.QuestLevel[${QuestNo}]} - 1]}]
		if ${UIElement[cmbLocationLvlFrom@Grind@Pages@openbot].Selection}<=0
		{
			UIElement[cmbLocationLvlFrom@Grind@Pages@openbot]:SetSelection[1]
		}
		if ${UIElement[cmbLocationLvlFrom@Grind@Pages@openbot].Selection} > 70
		{
			UIElement[cmbLocationLvlFrom@Grind@Pages@openbot]:SetSelection[70]
		}
		UIElement[cmbLocationLvlTo@Grind@Pages@openbot]:SetSelection[${Math.Calc[${Quest.QuestLevel[${QuestNo}]} + ${WoWScript[GetQuestGreenRange()]}]}]
		if ${UIElement[cmbLocationLvlTo@Grind@Pages@openbot].Selection} > 70
		{
			UIElement[cmbLocationLvlTo@Grind@Pages@openbot]:SetSelection[70]
		}
		UIElement[cmbLocationGrindRange@Grind@Pages@openbot]:SetSelection[50]
		UIElement[chkRandomHotSpots@Grind@Pages@openbot]:SetChecked
		UIElement[chkLocationActive@Grind@Pages@openbot]:SetChecked
		This:Output[${Quest.QuestString[${QuestNo}]}]
		Location:UpdateLvlFrom
		Location:UpdateLvlTo
		Location:addLocation
		echo Adding Location for ${Quest.QuestString[${QuestNo}]}
		UIElement[tenLocations@Grind@Pages@openbot]:SetText[]
	}

	member TooClose()
	{
		variable int i
		if ${Math.Distance[${Me.X},${Me.Y},${Me.Z},${CurrentQuest.FindSetting[EndX]},${CurrentQuest.FindSetting[EndY]},${CurrentQuest.FindSetting[EndZ]}]} < 15 || ${Math.Distance[${Me.X},${Me.Y},${Me.Z},${CurrentQuest.FindSetting[StartX]},${CurrentQuest.FindSetting[StartY]},${CurrentQuest.FindSetting[StartZ]}]} < 15
		{
			echo Too close to quest NPC
			return TRUE
		}
		for (i:Set[1]; ${i}<=${LavishSettings[Location].FindSet[Hunting].FindSet[${Quest.QuestString[${ActiveQuest}]}].FindSet[Attributes].FindSetting[HotspotsCount]}; i:Inc)
		{
			if ${Grind.HotSpotDistance} < 40
			{
				echo Too close to another Hotspot
				return TRUE
			}
			Grind:NextHotspot
		}
		return FALSE
	}

	method GUIUpdate()
	{
	}

	method Blacklist1()
	{
		echo Manually Blacklisting quest ${Quest.QuestName[${ActiveQuest}]}
		CurrentQuestLog:AddSetting[Blacklisted,TRUE]
	}

	method Blacklist2()
	{
		echo Global Blacklist:
		Quest:Blacklist1
		CurrentQuest:AddSetting[Blacklisted,TRUE]
	}

	member IsComplete(int QuestNumber)
	{
		if ${WoWScript[GetQuestLogTitle(${QuestNumber}),7]} == 1
		{
			return TRUE
		}
		if ${WoWScript[GetNumQuestLeaderBoards(${QuestNumber})]} == 0
		{
			return TRUE
		}
		return FALSE
	}

	member IsQuest(int QuestNumber)
	{
		if !${WoWScript[GetQuestLogTitle(${QuestNumber}),5]}
		{
			return TRUE
		}
		return FALSE
	}

	member QuestLevel(int QuestNumber)
	{
		return ${WoWScript[GetQuestLogTitle(${QuestNumber}),2]}
	}

	member QuestName(int QuestNumber)
	{
		return ${WoWScript[GetQuestLogTitle(${QuestNumber}),1]}
	}

	member QuestString(int QuestNumber)
	{
		variable string TempString
		if ${WoWScript["GetQuestLogLeaderBoard(1,${QuestNumber})",1].Token[1,:](exists)}
		{
			TempString:Set[(${Quest.QuestLevel[${QuestNumber}]})${Quest.QuestName[${QuestNumber}]} ${WoWScript["GetQuestLogLeaderBoard(1,${QuestNumber})",1].Token[1,:]} ${WoWScript["GetQuestLogLeaderBoard(1,${QuestNumber})",2]}]
		}
		else
		{
			TempString:Set[(${Quest.QuestLevel[${QuestNumber}]})${Quest.QuestName[${QuestNumber}]} Event]
		}
		return ${TempString}
	}

	member HasQuest()
	{
		if ${CurrentQuest.FindSetting[Level]} > 0 && ${CurrentQuestLog.FindSetting[Blacklisted]} == FALSE
		{
			return TRUE
		}
		return FALSE
	}

	method BestQuest()
	{
		variable int i
		variable int BestWeight
		variable int Weight

		ActiveQuest:Set[0]
		QuestCount:Set[0]
		BestWeight:Set[-1000]
		for (i:Set[1]; ${i}<=${WoWScript[GetNumQuestLogEntries(),1]}; i:Inc)
		{
			CurrentQuest:Set[${LavishSettings[Quests].FindSet[${Quest.QuestString[${i}]}]}]
			CurrentQuestLog:Set[${LavishSettings[QuestLog].FindSet[${Quest.QuestString[${i}]}]}]
			Weight:Set[0]
			if ${Quest.IsQuest[${i}]}
			{
				if ${Quest.IsComplete[${i}]}
				{
					Weight:Inc[100]
					if (${Me.Level} - ${Quest.QuestLevel[${i}]}) > (${WoWScript[GetQuestGreenRange()]}/2)
					{
						Weight:Inc[30]
					}
					if ${CurrentQuest.FindSetting[EndX](exists)} && ${Math.Distance[${Me.X},${Me.Y},${Me.Z},${CurrentQuest.FindSetting[EndX]},${CurrentQuest.FindSetting[EndY]},${CurrentQuest.FindSetting[EndZ]}]} < 1000
					{
						Weight:Inc[${Math.Calc[(1000 - ${Math.Distance[${Me.X},${Me.Y},${Me.Z},${CurrentQuest.FindSetting[EndX]},${CurrentQuest.FindSetting[EndY]},${CurrentQuest.FindSetting[EndZ]}]})/50]}]
					}
				}
				else
				{
					Weight:Inc[10]
				}
				if ${CurrentQuestLog.FindSetting[Blacklisted]} == TRUE
				{
					Weight:Dec[300]
				}
				if ${LavishSettings[Location].FindSet[Hunting].FindSet[${Quest.QuestString[${i}]}].FindSet[Attributes].FindSetting[HotspotsCount]} == 0
				{
					for (k:Set[1]; ${k}<=${WoWScript[GetNumQuestLeaderBoards(${i})]}; k:Inc)
					{
						if !${LavishSettings[Quests].FindSet[${Quest.QuestString[${i}]}].FindSet[Objective ${k}].FindSetting[Objective ${k} X](exists)}
						{
							Weight:Set[0]
							k:Set[1000]
						}
			 		}
				}
				if ${Quest.QuestString[${i}].Equal[${Grind.LocationSetName}]}
				{
					Weight:Inc[2]
				}
				Weight:Inc[(${Me.Level}+2) - ${Quest.QuestLevel[${i}]}]
				if ${Weight} >= 0
				{
					if ${Weight} > ${BestWeight}
					{
						ActiveQuest:Set[${i}]
						BestWeight:Set[${Weight}]
					}
					QuestCount:Inc
				}
			}
		}
	}

	method HandIn(int X, int Y, int Z)
	{
		if ${Movement.Speed}
		{
			return
		}
		if ${Math.Distance[${Me.X},${Me.Y},${Me.Z},${X},${Y},${Z}]} < 10
		{
			This.NPCsWithTurnIn:Search[-units, -nearest, -nonhostile, -questcomplete, -range 0-15]
			if ${This.NPCsWithTurnIn.Count} == 0
			{
				if ${Quest.HasEvent}
				{
					echo Trying to complete recorded Event.
				}
				echo At expected hand in location but the NPC I need to turn it in to isn't here. Blacklisting Quest.
				CurrentQuestLog:AddSetting[Blacklisted,TRUE]
			}
			return
		}
		if !${CurrentQuest.FindSetting[EndX](exists)}
		{
			CurrentQuestLog:AddSetting[Blacklisted,TRUE]
			if ${Quest.HasEvent}
			{
				echo Trying to complete recorded Event.
			}
			echo No Hand in loc found, Blacklisting
			return
		}
		echo ${CurrentQuest.FindSetting[Name]} Quest Complete! Moving to hand in > ${CurrentQuest.FindSetting[EndNPC]}
		Navigator:MoveToLoc[${X},${Y},${Z}]
	}

	member QuestLocation()
	{
		return ${CurrentQuest.FindSetting[QuestLoc]}
	}

	member Complete()
	{
		if ${Quest.HasQuest} && ${Quest.IsComplete[${ActiveQuest}]}
		{
			Quest:HandIn[${CurrentQuest.FindSetting[EndX]},${CurrentQuest.FindSetting[EndY]},${CurrentQuest.FindSetting[EndZ]}]
			return TRUE
		}
		return FALSE
	}

	member Explore()
	{
		return FALSE
			if ${Quest.QuestLocation(exists)} && ${LavishSettings[Location].FindSet[Hunting].FindSet[${QuestLocation}].FindSet[Attributes].FindSetting[HotspotsCount]} < 3
			{
				if ${LavishSettings[Location].FindSet[Hunting].FindSet[${QuestLocation}].FindSet[Attributes].FindSetting[HotspotsCount]} > 0
				{
					if ${Quest.QuestLocation.NotEqual[${Grind.LocationSetName}]}
					{
						Grind.CurrentGrind:Set[${QuestLocation}]
					}
					Explore:ExplorePoint[${Grind.CurrentGrind.X},${Grind.CurrentGrind.Y},${Grind.CurrentGrind.Z},200]
				}
				else
				{
					Explore:Explore
				}
				return TRUE
			}
		return FALSE
	}

	member ChangeLocation()
	{
		CurrentQuest:Set[${LavishSettings[Quests].FindSet[${Quest.QuestString[${ActiveQuest}]}]}]
		CurrentQuestLog:Set[${LavishSettings[QuestLog].FindSet[${Quest.QuestString[${ActiveQuest}]}]}]
		if ${Quest.HasQuest}
		{
			if ${LavishSettings[Location].FindSet[Hunting].FindSet[${Quest.QuestString[${ActiveQuest}]}].FindSet[Attributes].FindSetting[HotspotsCount]} > 0
			{
				if ${Quest.QuestLocation.NotEqual[${Grind.LocationSetName}]}
				{
					echo Switching location set to '${QuestLocation}' for Questing
					Grind.CurrentGrind:Set[${QuestLocation}]
					return TRUE
				}
			}
			else
			{
				echo  No Quest data for ${QuestLocation}
			}
		}
		return FALSE
	}

	member QuestExplore()
	{

	}


	method AutoAddHotspot(string QLocation)
	{
		echo Adding a new Hotspot for ${QLocation}
		Mapper:MapLocation[${QLocation}]
		variable settingsetref LS = ${LavishSettings[Location].FindSet[Hunting].FindSet[${QLocation}].FindSet[Hotspots]}
		variable string XYZ
		variable int X
		variable int Y
		variable int Z
		variable int Hd
		variable string HotspotName

		XYZ:Set[${Me.X}]
		X:Set[${XYZ.Token[1,.]}]
		XYZ:Set[${Me.Y}]
		Y:Set[${XYZ.Token[1,.]}]
		XYZ:Set[${Me.Z}]
		Z:Set[${XYZ.Token[1,.]}]
		XYZ:Set[${Me.Heading}]
		Hd:Set[${XYZ.Token[1,.]}]
		X:Inc
		Y:Inc
		Z:Inc
		Hd:Inc

		XYZ:Set["${X}:${Y}:${Z}:${Hd}"]

		variable int HC=${LavishSettings[Location].FindSet[Hunting].FindSet[${QLocation}].FindSet[Attributes].FindSetting[HotspotsCount]}
		HC:Inc
		HotspotName:Set[${QLocation}${HC}]
		variable iterator HotspotIterator1

		variable settingsetref LS1 = ${LavishSettings[Location].FindSet[Hunting].FindSet[${QLocation}].FindSet[Hotspots]}
		LS1:GetSettingIterator[HotspotIterator1]

		if ${HotspotIterator1:First(exists)}
		{
			do
			{
				if ${XYZ.Equal[${HotspotIterator1.Key}]}
				{
					Location:Output[You already have a Hotspot for this LocationSet here !]
					return
				}
				if ${HotspotName.Equal[${HotspotIterator1.Value}]}
				{
					Location:Output[You already have a Hotspot for this LocationSet with a similar Name !]
					return
				}
			}
			while ${HotspotIterator1:Next(exists)}
		}

		Location:QuickNote[${HotspotName}]
		LavishSettings[Location].FindSet[Hunting].FindSet[${QLocation}].FindSet[Attributes]:AddSetting[HotspotsCount,${HC}]
		LS:AddSetting[${XYZ},${HotspotName}]
		Location:addDropdown[${XYZ}]
		Location:populateHotspots
		Grind:RefreshCurrent
	}
}