ShowMessage("新手任务加入门派 $Rev: 201 $")


--[[
[author]
descript=10级加入门派的任务
cmd0str=少林
cmd0=0
cmd1str=明教
cmd1=1
cmd2str=丐帮
cmd2=2
cmd3str=武当
cmd3=3
cmd4str=峨嵋
cmd4=4
cmd5str=星宿
cmd5=5
cmd6str=天龙
cmd6=6
cmd7str=天山
cmd7=7
cmd8str=逍遥
cmd8=8
cmd9str=慕容
cmd9=10
cmd10str=唐门
cmd10=11
cmd11str=鬼谷
cmd11=12
cmd_default=12
]]--
script_name="新手加入门派"


local g_UsherInfo = {
	[0] = {szNpcName="慧易", fX=154, fY=129, opt="门派-少林"},
	[1] = {szNpcName="石宝", fX=165, fY=138, opt="门派-明教"},
	[2] = {szNpcName="简宁", fX=154, fY=133, opt="门派-丐帮"},
	[3] = {szNpcName="张获", fX=154, fY=126, opt="门派-武当"},
	[4] = {szNpcName="路三娘", fX=154, fY=137, opt="门派-峨嵋"},
	[5] = {szNpcName="海风子", fX=166, fY=131, opt="门派-星宿"},
	[6] = {szNpcName="破贪", fX=166, fY=128, opt="门派-天龙"},
	[7] = {szNpcName="程青霜", fX=166, fY=135, opt="门派-天山"},
	[8] = {szNpcName="澹台子羽", fX=166, fY=124, opt="门派-逍遥"},
	[9] = {szNpcName="", fX=0, fY=0},
	[10] = {szNpcName="慕容传", fX=154, fY=140, opt="门派-慕容"},
	[11] = {szNpcName="唐昱", fX=166, fY=142, opt="门派-唐门"},
	[12] = {szNpcName="杨渐", fX=166, fY=142, opt="门派-鬼谷"},
}

local g_Master = {
	[0] = {szNpcName="玄寂", fX=89, fY=72, nSceneID=9},
	[1] = {szNpcName="吕师襄", fX=108, fY=56, nSceneID=11},
	[2] = {szNpcName="陈孤雁", fX=91, fY=98, nSceneID=10},
	[3] = {szNpcName="张玄素", fX=77, fY=85, nSceneID=12},
	[4] = {szNpcName="李十二娘", fX=96, fY=51, nSceneID=15},
	[5] = {szNpcName="韩世忠", fX=95, fY=75, nSceneID=16},
	[6] = {szNpcName="本因", fX=96, fY=66, nSceneID=13},
	[7] = {szNpcName="梅剑", fX=91, fY=44, nSceneID=17},
	[8] = {szNpcName="苏星河", fX=125, fY=144, nSceneID=14},
	[9] = {szNpcName="", fX=0, fY=0, nSceneID=0},
	[10] = {szNpcName="慕容杰", fX=48, fY=144, nSceneID=284},
	[11] = {szNpcName="唐亦风", fX=78, fY=35, nSceneID=615},
	[12] = {szNpcName="王禅一", fX=99, fY=56, nSceneID=678},
}

local g_Teacher = {
	[0] = {szNpcName="玄难", fX=91, fY=71, nSceneID=9},
	[1] = {szNpcName="庞万春", fX=109, fY=59, nSceneID=11},
	[2] = {szNpcName="奚三祁", fX=94, fY=99, nSceneID=10},
	[3] = {szNpcName="俞远山", fX=82, fY=84, nSceneID=12},
	[4] = {szNpcName="崔绿华", fX=98, fY=51, nSceneID=15},
	[5] = {szNpcName="施全", fX=87, fY=70, nSceneID=16},
	[6] = {szNpcName="本观", fX=97, fY=67, nSceneID=13},
	[7] = {szNpcName="兰剑", fX=88, fY=44, nSceneID=17},
	[8] = {szNpcName="康广陵", fX=125, fY=142, nSceneID=14},
	[9] = {szNpcName="", fX=0, fY=0, nSceneID=0},
	[10] = {szNpcName="慕容青山", fX=48, fY=134, nSceneID=284},
	[11] = {szNpcName="唐岳冲", fX=38, fY=75, nSceneID=615},
	[12] = {szNpcName="李继隆", fX=94, fY=56, nSceneID=678},	
}

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

	if g_UsherInfo[nMenPai] == nil or nMenPai == 9 then
		return false
	end

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

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

	if nSelIndex ~= -1 then

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

		if  DataPool:GetPlayerMission_Variable(nSelIndex, 0) == 1 then
			MoveToNPC(g_UsherInfo[nMenPai].fX, g_UsherInfo[nMenPai].fY, 2, g_UsherInfo[nMenPai].szNpcName)
			QuestFrameOptionClicked("加入门派", CMP_FULL_MATCH)
			QuestFrameMissionComplete()	-- 完成
			QuestFrameAcceptClicked()
		else
			MoveToNPC(g_UsherInfo[nMenPai].fX, g_UsherInfo[nMenPai].fY, 2, g_UsherInfo[nMenPai].szNpcName)
			QuestFrameOptionClicked("加入门派", CMP_PART_MATCH)
			QuestFrameOptionClicked("我确定要", CMP_PART_MATCH)
			QuestFrameMissionComplete()	-- 完成
			QuestFrameAcceptClicked()
		end
		return true
	end
	return false
end

-- 拜见前辈
function OnMission_890372()
	
	local strMission = "拜见前辈"
	local nMenPai = Player:GetData("MEMPAI")
	DbgPrintf("___%d", nMenPai)

	if DataPool:IsMissionOutline(strMission) then
		MoveToNPC(g_UsherInfo[nMenPai].fX, g_UsherInfo[nMenPai].fY, 2, g_UsherInfo[nMenPai].szNpcName)
		QuestFrameOptionClicked(strMission, CMP_PART_MATCH)
		QuestFrameAcceptClicked()
		return true
	end

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

	if nSelIndex ~= -1 then

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

		local nScene = GetActiveDataSceneID()

		if nScene == 2 then
			DbgPrintf("___%d %d %d", nMenPai, g_UsherInfo[nMenPai].fX, g_UsherInfo[nMenPai].fY)
			MoveToNPC(g_UsherInfo[nMenPai].fX, g_UsherInfo[nMenPai].fY, 2, g_UsherInfo[nMenPai].szNpcName)
			QuestFrameOptionClicked(g_UsherInfo[nMenPai].opt, CMP_PART_MATCH)
		else
			MoveToNPC(g_Master[nMenPai].fX, g_Master[nMenPai].fY, g_Master[nMenPai].nSceneID, g_Master[nMenPai].szNpcName)
			QuestFrameOptionClicked(strMission, CMP_PART_MATCH)
			QuestFrameMissionComplete()	-- 完成
			QuestFrameAcceptClicked()
		end
		return true
	end
	return false
end

-- 尊师尚武
function OnMission_890373()
	
	local strMission = "尊师尚武"
	local nMenPai = Player:GetData("MEMPAI")
	
	if DataPool:IsMissionOutline(strMission) then
		MoveToNPC(g_Master[nMenPai].fX, g_Master[nMenPai].fY, g_Master[nMenPai].nSceneID, g_Master[nMenPai].szNpcName)
		QuestFrameOptionClicked(strMission, CMP_PART_MATCH)
		QuestFrameAcceptClicked()
		return true
	end

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

	if nSelIndex ~= -1 then
		DbgPrintf("%d %d %d", nSelIndex, idMission, idScript)
		MoveToNPC(g_Teacher[nMenPai].fX, g_Teacher[nMenPai].fY, g_Teacher[nMenPai].nSceneID, g_Teacher[nMenPai].szNpcName)
		QuestFrameOptionClicked(strMission, CMP_PART_MATCH)
		QuestFrameMissionComplete()	-- 完成
		QuestFrameAcceptClicked()
		return true
	end
	return false
end

-- 武学奥秘
function OnMission_890374()
	
	local strMission = "武学奥秘"
	local nMenPai = Player:GetData("MEMPAI")

	if DataPool:IsMissionOutline(strMission) then
		MoveToNPC(g_Teacher[nMenPai].fX, g_Teacher[nMenPai].fY, g_Teacher[nMenPai].nSceneID, g_Teacher[nMenPai].szNpcName)
		QuestFrameOptionClicked(strMission, CMP_PART_MATCH)
		QuestFrameAcceptClicked()
		return true
	end

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

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

		if  DataPool:GetPlayerMission_Variable(nSelIndex, 0) == 1 then
			MoveToNPC(g_Teacher[nMenPai].fX, g_Teacher[nMenPai].fY, g_Teacher[nMenPai].nSceneID, g_Teacher[nMenPai].szNpcName)
			QuestFrameOptionClicked(strMission, CMP_PART_MATCH)
			QuestFrameMissionComplete()	-- 完成
			QuestFrameAcceptClicked()
		else
			MoveToNPC(g_Teacher[nMenPai].fX, g_Teacher[nMenPai].fY, g_Teacher[nMenPai].nSceneID, g_Teacher[nMenPai].szNpcName)
			QuestFrameOptionClicked("了解门派武学技能", CMP_PART_MATCH)
			QuestFrameOptionClicked("如何学习武功技能", CMP_PART_MATCH)
			QuestFrameOptionClicked("如何提升心法等级", CMP_PART_MATCH)
			QuestFrameOptionClicked("原来如此", CMP_PART_MATCH)
			QuestFrameMissionComplete()	-- 完成
			QuestFrameAcceptClicked()
		end
		return true
	end
	return false
end

-- 浩劫前夕
function OnMission_890376()
	
	local strMission = "浩劫前夕"
	local nMenPai = Player:GetData("MEMPAI")

	if DataPool:IsMissionOutline(strMission) then
		MoveToNPC(g_Teacher[nMenPai].fX, g_Teacher[nMenPai].fY, g_Teacher[nMenPai].nSceneID, g_Teacher[nMenPai].szNpcName)
		QuestFrameOptionClicked(strMission, CMP_PART_MATCH)
		QuestFrameAcceptClicked()
		return true
	end

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

	if nSelIndex ~= -1 then
		DbgPrintf("%d %d %d", nSelIndex, idMission, idScript)
		MoveToNPC(256, 273, 0, "周天师")
		QuestFrameOptionClicked(strMission, CMP_PART_MATCH)
		QuestFrameMissionComplete()	-- 完成
		QuestFrameAcceptClicked()
		return true
	end
	return false
end

function _SMain(...)

	local nMenPai = nil

	if _CommandLine ~= nil then
		nMenPai = tonumber( _CommandLine )
	end	

	local level = Player:GetData("LEVEL")

	if level > 11 and level < 10 then return end

	while true do
	
		DataPool:GetMissionOutline()

		if OnMission_890278(nMenPai) then
		elseif OnMission_890372() then
		elseif OnMission_890373() then
		elseif OnMission_890374() then
		elseif OnMission_890376() then
		else
			break
		end

		System:Sleep(500)
	end
end


_SMain()