ShowMessage("新手任务1-10级 $Rev: 199 $")

-- 缘起无量
function OnMission_890251()

	local strMission = "缘起无量"

	local index, idMission, idScript = DataPool:GetPlayerMission(strMission)

	if index ~= -1 then
	
		DbgPrintf("%d %d %d", index, idMission, idScript)
		MoveToNPC(187, 205, DataBase:GetSceneID("无量山"), "受伤的山民")
		QuestFrameOptionClicked(strMission, CMP_PART_MATCH)
		QuestFrameMissionComplete()
		QuestFrameAcceptClicked()
		return true
	end
	return false
end

-- 路见不平
function OnMission_890252()
	
	local strMission = "路见不平"

	if DataPool:IsMissionOutline(strMission) then
		MoveToNPC(187, 205, DataBase:GetSceneID("无量山"), "受伤的山民")
		QuestFrameOptionClicked(strMission, CMP_PART_MATCH)
		QuestFrameAcceptClicked()
		return true
	end

	local index, idMission, idScript = DataPool:GetPlayerMission(strMission)

	if index ~= -1 then

		DbgPrintf("%d %d %d", index, idMission, idScript)

		if DataPool:IsMissionCanCommit(idMission) then
			MoveToNPC(194, 174, DataBase:GetSceneID("无量山"), "遇险的钟灵")
			QuestFrameOptionClicked(strMission, CMP_PART_MATCH)
			QuestFrameMissionContinue()	-- 继续
			QuestFrameMissionComplete()	-- 完成
			QuestFrameAcceptClicked()
		else
			MoveTo(159, 180, DataBase:GetSceneID("无量山"))
			-- 设置AI为杀怪
			AI:SetAI("杀怪")
			-- 设置采集对象名称
			AI:SetParameter("目标", "添加", "神农帮喽啰")
			-- 开始AI
			AI:Start(false)
			while DataPool:IsMissionCanCommit(idMission) == false do
				System:Sleep(200)
			end
			AI:Stop()
		end
		return true
	end
	return false
end

-- 武功招式
function OnMission_890254()

	local strMission = "武功招式"

	if DataPool:IsMissionOutline(strMission) then
		MoveToNPC(194, 174, DataBase:GetSceneID("无量山"), "遇险的钟灵")
		QuestFrameOptionClicked(strMission, CMP_PART_MATCH)
		QuestFrameAcceptClicked()
		return true
	end

	local index, idMission, idScript = DataPool:GetPlayerMission(strMission)

	if index ~= -1 then
		DbgPrintf("%d %d %d", index, idMission, idScript)

		if DataPool:IsMissionCanCommit(idMission) then
			MoveToNPC(238, 133, DataBase:GetSceneID("无量山"), "剑湖宫的钟灵")
			QuestFrameOptionClicked(strMission, CMP_PART_MATCH)
			QuestFrameMissionContinue()	-- 继续
			QuestFrameMissionComplete()	-- 完成
			QuestFrameAcceptClicked()
		else
			MoveTo(227, 156, DataBase:GetSceneID("无量山"))
			-- 设置AI为杀怪
			AI:SetAI("杀怪")
			-- 设置采集对象名称
			AI:SetParameter("目标", "添加", "神农帮精英")
			-- 开始AI
			AI:Start(false)
			while DataPool:IsMissionCanCommit(idMission) == false do
				System:Sleep(200)
			end
			AI:Stop()
		end
		return true
	end
	return false
end

-- 并肩作战
function OnMission_890255()
	
	local strMission = "并肩作战"

	if DataPool:IsMissionOutline(strMission) then
		MoveToNPC(238, 133, DataBase:GetSceneID("无量山"), "剑湖宫的钟灵")
		QuestFrameOptionClicked(strMission, CMP_PART_MATCH)
		QuestFrameAcceptClicked()
		return true
	end

	local index, idMission, idScript = DataPool:GetPlayerMission(strMission)

	if index ~= -1 then

		DbgPrintf("%d %d %d", index, idMission, idScript)

		if DataPool:IsMissionCanCommit(idMission) then
			MoveToNPC(238, 133, DataBase:GetSceneID("无量山"), "剑湖宫的钟灵")
			QuestFrameOptionClicked(strMission, CMP_PART_MATCH)
			QuestFrameMissionContinue()	-- 继续
			QuestFrameMissionComplete()	-- 完成
			QuestFrameAcceptClicked()
		else
			Pet:Go_Fight(0)	-- 宠物出战，此时只有一个宠物，直接写0
			MoveTo(255, 149, DataBase:GetSceneID("无量山"))
			-- 设置AI为杀怪
			AI:SetAI("杀怪")
			-- 设置采集对象名称
			AI:SetParameter("目标", "添加", "神农帮堂主")
			-- 开始AI
			AI:Start(false)
			while DataPool:IsMissionCanCommit(idMission) == false do
				System:Sleep(200)
			end
			AI:Stop()
		end
		return true
	end
	return false
end

-- 寡不敌众
function OnMission_890256()

	local strMission = "寡不敌众"
	local nSceneID = DataBase:GetSceneID("无量山")

	if DataPool:IsMissionOutline(strMission) then
		MoveToNPC(238, 133, nSceneID, "剑湖宫的钟灵")
		QuestFrameOptionClicked(strMission, CMP_PART_MATCH)
		QuestFrameAcceptClicked()
		return true
	end

	local index, idMission, idScript = DataPool:GetPlayerMission(strMission)

	if index ~= -1 then

		DbgPrintf("%d %d %d", index, idMission, idScript)

		if DataPool:IsMissionCanCommit(idMission) then
			MoveToNPC(276, 94, nSceneID, "木婉清")
			QuestFrameOptionClicked(strMission, CMP_PART_MATCH)
			QuestFrameMissionContinue()	-- 继续
			QuestFrameMissionComplete()	-- 完成
			QuestFrameAcceptClicked()
		else
			MoveTo(275, 98, nSceneID)
		end
		return true
	end
	return false
end

-- 无量玉壁
function OnMission_890257()

	local strMission = "无量玉壁"

	if DataPool:IsMissionOutline(strMission) then
		MoveToNPC(276, 94, DataBase:GetSceneID("无量山"), "木婉清")
		QuestFrameOptionClicked(strMission, CMP_PART_MATCH)
		QuestFrameAcceptClicked()
		return true
	end

	local index, idMission, idScript = DataPool:GetPlayerMission(strMission)

	if index ~= -1 then
		DbgPrintf("%d %d %d", index, idMission, idScript)

		if DataPool:IsMissionCanCommit(idMission) then
			MoveToNPC(276, 94, DataBase:GetSceneID("无量山"), "木婉清")
			QuestFrameOptionClicked(strMission, CMP_PART_MATCH)
			QuestFrameMissionContinue()	-- 继续
			QuestFrameMissionComplete()	-- 完成
			QuestFrameAcceptClicked()
		else
			MoveTo(204, 59, DataBase:GetSceneID("无量山"))
			Dismount()
			Player_UseSkill_Collect(3, "不起眼的土堆")
		end
		return true
	end
	return false
end

-- 尔虞我诈
function OnMission_890258()

	local strMission = "尔虞我诈"

	if DataPool:IsMissionOutline(strMission) then
		MoveToNPC(276, 94, DataBase:GetSceneID("无量山"), "木婉清")
		QuestFrameOptionClicked(strMission, CMP_PART_MATCH)
		QuestFrameAcceptClicked()
		return true
	end

	local index, idMission, idScript = DataPool:GetPlayerMission(strMission)

	if index ~= -1 then
		DbgPrintf("%d %d %d", index, idMission, idScript)

		if DataPool:IsMissionCanCommit(idMission) then
			MoveToNPC(209, 106, DataBase:GetSceneID("无量山"), "被俘的段誉")
			QuestFrameOptionClicked(strMission, CMP_FULL_MATCH)
			QuestFrameMissionComplete()	-- 完成
			QuestFrameAcceptClicked()
		else
			Dismount()
			UseItem("灵鹫圣使的衣帽", "")
			MoveToNPC(200, 104, DataBase:GetSceneID("无量山"), "司空玄")
			QuestFrameOptionClicked("索取解毒药", CMP_FULL_MATCH)
		end
		return true
	end
	return false
end

-- 城外相会
function OnMission_890261()

	local strMission = "城外相会"

	if DataPool:IsMissionOutline(strMission) then
		MoveToNPC(209, 106, DataBase:GetSceneID("无量山"), "被俘的段誉")
		QuestFrameOptionClicked(strMission, CMP_FULL_MATCH)
		QuestFrameAcceptClicked()
		return true
	end

	local index, idMission, idScript = DataPool:GetPlayerMission(strMission)

	if index ~= -1 then
		DbgPrintf("%d %d %d", index, idMission, idScript)

		if DataPool:IsMissionCanCommit(idMission) then
			MoveToNPC(63, 172, DataBase:GetSceneID("无量山"), "城外的段誉")
			QuestFrameOptionClicked(strMission, CMP_FULL_MATCH)
			QuestFrameMissionComplete()	-- 完成
			QuestFrameAcceptClicked()
		end
		return true
	end
	return false
end

-- 珍兽商店
function OnMission_890262()

	local strMission = "珍兽商店"

	if DataPool:IsMissionOutline(strMission) then
		MoveToNPC(63, 172, DataBase:GetSceneID("无量山"), "城外的段誉")
		QuestFrameOptionClicked(strMission, CMP_PART_MATCH)
		QuestFrameAcceptClicked()
		return true
	end

	local index, idMission, idScript = DataPool:GetPlayerMission(strMission)

	if index ~= -1 then

		DbgPrintf("%d %d %d", index, idMission, idScript)

		MissionMoveToNPC("云飘飘")
		QuestFrameOptionClicked(strMission, CMP_PART_MATCH)
		QuestFrameMissionComplete()
		QuestFrameAcceptClicked()
		System:Sleep(2000)	-- 这里接任务会骑鸟
		return true
	end
	return false
end

-- 武器商店
function OnMission_890263()

	local strMission = "武器商店"

	if DataPool:IsMissionOutline(strMission) then
		MissionMoveToNPC("云飘飘")
		QuestFrameOptionClicked(strMission, CMP_PART_MATCH)
		QuestFrameAcceptClicked()
		return true
	end

	local index, idMission, idScript = DataPool:GetPlayerMission(strMission)

	if index ~= -1 then

		DbgPrintf("%d %d %d", index, idMission, idScript)

		MissionMoveToNPC("蒲良")
		QuestFrameOptionClicked(strMission, CMP_PART_MATCH)
		QuestFrameMissionComplete()
		QuestFrameAcceptClicked()
		return true
	end
	return false
end

-- 防具商店
function OnMission_890264()

	local strMission = "防具商店"

	if DataPool:IsMissionOutline(strMission) then
		DbgPrintf("@@")
		MissionMoveToNPC("蒲良")
		QuestFrameOptionClicked(strMission, CMP_PART_MATCH)
		QuestFrameAcceptClicked()
		return true
	end

	local index, idMission, idScript = DataPool:GetPlayerMission(strMission)

	if index ~= -1 then
		DbgPrintf("%d %d %d", index, idMission, idScript)
		MissionMoveToNPC("黄公道")
		QuestFrameOptionClicked(strMission, CMP_PART_MATCH)
		QuestFrameMissionComplete()
		QuestFrameAcceptClicked()
		System:Sleep(1000)
		return true
	end
	return false
end

-- 拜访天师
function OnMission_890265()
	
	local strMission = "拜访天师"

	if DataPool:IsMissionOutline(strMission) then
		MissionMoveToNPC("黄公道")
		QuestFrameOptionClicked(strMission, CMP_PART_MATCH)
		QuestFrameAcceptClicked()
		System:Sleep(1000)
		return true
	end

	local index, idMission, idScript = DataPool:GetPlayerMission(strMission)

	if index ~= -1 then

		DbgPrintf("%d %d %d", index, idMission, idScript)

		MissionMoveToNPC("赵天师")
		QuestFrameOptionClicked(strMission, CMP_PART_MATCH)
		QuestFrameMissionComplete()
		QuestFrameAcceptClicked()
		return true
	end
	return false
end

-- 加入门派
function OnMission_890278()
	
	local strMission = "加入门派"

	if DataPool:IsMissionOutline(strMission) then
		MissionMoveToNPC("赵天师")
		QuestFrameOptionClicked(strMission, CMP_PART_MATCH)
		QuestFrameAcceptClicked()
		return true
	end

	return false
end

function _SMain(...)

	if Player:GetData("LEVEL") > 10 then return end

	while true do

		DataPool:GetMissionOutline()

		if OnMission_890251() then
		elseif OnMission_890252() then
		elseif OnMission_890254() then
		elseif OnMission_890255() then
		elseif OnMission_890256() then
		elseif OnMission_890257() then
		elseif OnMission_890258() then
		elseif OnMission_890261() then
		elseif OnMission_890262() then
		elseif OnMission_890263() then
		elseif OnMission_890264() then
		elseif OnMission_890265() then
		elseif OnMission_890278() then
		elseif DataPool:GetPlayerMission("加入门派") ~= -1 then
			break
		else
			break
		end

		System:Sleep(200)
	end
end


_SMain()
