--主线剧情<24-2>
--剧情起始点：璇光殿幻境1/4
--调用条件：主线旗标==(242)时碰撞事件点(x,z,r:2452,6890,100)
--旗标变更：变更为(243)
--脚本id：7462
function m024_2()

local	xz=flag.GetValue(6001)	--主线旗标
local	xz1=flag.GetValue(6100)	--主线副旗标

if	xz==242	and	xz1==0	then


	func_start(0,0,0)
	--变更脚本
	flag.SetValue(6001,243)
	global.PlayMusic(71,100,200)
	
	--修改行程
	ui.FinishQuest(598)
	ui.AddQuest(599)	
	
	
	--###############
	--#本段用到的npc#
	--###############
	local nXiaHou = 1
	local nXia = 2
	local nLan = 3
	local nLing = 4 --凌波
	local nLong = 5 --龙溟
	local nMon = 6 --被龙溟杀死的怪
	
	--###@@@设置镜头，龙溟秒怪
	camera.ResetLerp(0)
	camera.ChangeCameraStatic(2118,48,6832,2059,31,6754)
	camera.ResetLerp(10000)
	camera.ChangeCameraStatic(2136,48,6819,2076,31,6741)
	effect.FadeIn(1,0.7)
	
	-- npc.Create(7,nLong,2076,6746)
	-- npc.SetAtPos(nLong,2025,6728)
	-- npc.Create(635,nMon,2022,6730)
	-- npc.SetAtPos(nMon,2076,6746)
	npc.SetAnim(nLong,101)
	-- npc_weapon(nLong,7)
	npc.AddRefItem(nLong,49,6046)
	
	
	local mStepX = 2413-2491
	local mStepZ = 6891-6921
	local mStep2X = 2125-2491
	local mStep2Z = 6774-6921
	npc.Create(8,nLing,2413,6891)
	npc.Create(1,nXiaHou,2514+mStepX,6909+mStepZ)
	npc.Create(2,nXia,2509+mStepX,6890+mStepZ)
	npc.Create(4,nLan,2493+mStepX,6941+mStepZ)
	--龙溟攻击
	npc.SetAnim(nLong,106)
	npc.AddAnimChain(nLong,106,101)
	global.Wait(1.3)
	global.PlaySound(536,80)
	npc.SetAnim(nMon,11,1)
	npc.SetAnim(nMon,28)
	wt(1)
	--怪物消失
	npc.SetAppear(nMon,0)
	global.Wait(1.5)
	npc_weapon(nLong,0)
	npc.SetAnim(nLong,200)
	global.Wait(1)
	npc.SetHeadRot(nLong,30,0,1,70)
	global.Wait(1)
	ui.Dialog(80712,629,0,nLong,0,0)--（只有四个人啊……）
	global.Wait(0.3)
	npc.RunTo(nLing,2125,6774)
	wt(0.1)
	npc.RunTo(nXiaHou,2514+mStep2X,6909+mStep2Z)
	wt(0.1)
	npc.RunTo(nXia,2509+mStep2X,6890+mStep2Z)
	wt(0.1)
	npc.RunTo(nLan,2493+mStep2X,6941+mStep2Z)
	--==========
	
	--###@@@切镜头
	camera.ResetLerp(0)
	camera.ChangeCameraStatic(2045,54,6670,2099,26,6749)
	camera.ResetLerp(25000)
	camera.ChangeCameraStatic(2050,48,6695,2111,23,6769)
	global.Wait(1.5)
	npc.SetHeadRot(nLong,0,0)
	npc.TurnToPos(nLong,2128,6763,1)
	npc.SetHeadRot(nLan,-30,0,0,30)
	npc.SetHeadRot(nLing,-15,0,0,30)
	npc.SetHeadRot(nXia,30,0,0,30)
	npc.SetHeadRot(nXiaHou,15,0,0,30)
	global.WaitForNpcPos(nXia,2509+mStep2X,6890+mStep2Z)
	npc.SetHeadRot(nXia,0,-10,0,100)
	npc.TurnToNpc(nXia,nLong)
	global.WaitForNpcPos(nLan,2493+mStep2X,6941+mStep2Z)
	npc.SetHeadRot(nLan,0,0,0,100)
	npc.TurnToNpc(nLan,nLong)
	ui.Dialog(80713,185,0,nXia,0,0)--龙公子？！
	global.Wait(0.3)
	--龙溟左右看
	head_lr(nLong)
	--龙溟行礼
	npc.SetAnim(nLong,213,2)
	global.Wait(1)
	ui.Dialog(80714,629,0,nLong,0,0)--夏侯公子，暮姑娘，瑕姑娘，又见面了。
	global.Wait(0.3)
	npc.SetHeadRot(nLong,10,0,0,40)
	npc.MoveTo(nXiaHou,2121,6754,1)
	ui.Dialog(80715,523,0,nXiaHou,0,0)--龙公子，怎会是你？
	global.Wait(0.6)
	--==========
	
	--###@@@切镜头
	camera.ResetLerp(0)
	camera.ChangeCameraStatic(2213,46,6801,2122,32,6760)
	camera.ResetLerp(15000)
	camera.ChangeCameraStatic(2197,44,6797,2107,27,6757)
	wt(0.3)
	npc.SetHeadRot(nXiaHou,30,0,0,100)
	npc.TurnToPos(nXiaHou,2109,6789)
	npc.TurnToNpc(nXia,nLing)
	npc.SetHeadRot(nXia,0,0,0,100)
	npc.SetHeadRot(nLan,-45,0,0,100)
	npc.SetHeadRot(nLing,-35,0,0,70)
	global.Wait(1)
 	ui.Dialog(80716,525,0,nXiaHou,0,0)--道长？
	global.Wait(0.3)
	--凌波低头
	npc.SetHeadRot(nLing,10,20,1,50)
	global.Wait(0.8)
	ui.Dialog(80717,157,0,nLing,0,0)--……
	global.Wait(0.5)
	ui.Dialog(80718,162,0,nLan,0,0)--……
	global.Wait(0.3)
	npc.SetHeadRot(nLan,0,0,0,100)
	npc.MoveTo(nLan,2104,6777)
	--==========
	
	--###@@@切镜头
	camera.ResetLerp(0)
	camera.ChangeCameraStatic(2017,44,6766,2114,26,6754)
	camera.ResetLerp(25000)
	camera.ChangeCameraStatic(2034,41,6763,2132,24,6751)
	global.WaitForNpcPos(nLan,2104,6777)
	npc.TurnToNpc(nLan,nLong,1)
npc.SetHeadRot(nXiaHou,0,0,0,100)
	npc.TurnToNpc(nXiaHou,nLong,1)
	npc.TurnToNpc(nXia,nLong)
	npc.SetHeadRot(nLong,-30,0,0,70)
	global.Wait(0.5)
	npc.SetAnim(nLan,217,2)
	global.Wait(0.5)
	ui.Dialog(80719,165,2,nLan,0,0)--龙公子，这璇光殿据说是蜀山派重地，寻常弟子都不准进来，不知阁下为何会在这里？
	global.Wait(0.5)
	ui.Dialog(80720,629,0,nLong,0,0)--……
	global.Wait(0.3)
	ui.Dialog(80721,165,2,nLan,0,0)--而且，我们刚才发现了几名昏迷的巡夜弟子，打晕他们的，莫非就是阁下？
	global.Wait(0.3)
	--==========
	
	--###@@@切镜头，龙溟
	camera.ResetLerp(0)
	camera.ChangeCameraStatic(2095,42,6776,2055,27,6685)
	camera.ResetLerp(15000)
	camera.ChangeCameraStatic(2091,42,6777,2051,27,6687)
	global.Wait(0.3)
	ui.Dialog(80722,629,2,nLong,0,0)--大家都是旧识，暮姑娘何必如此戒备？何况此刻也不是对我寻根究底的时候。
	global.Wait(0.3)
	ui.Dialog(80723,165,2,nLan,0,0)--？
	global.Wait(0.3)
	ui.Dialog(80724,629,0,nLong,0,0)--我们进入璇光殿后，已触发其中阵法，如今各位同我其实已被困在这幻境中。若不尽速将其破除，便又会如当日在楼兰城中一般，再难出去。
	global.Wait(0.3)
	--==========
	
	--###@@@切镜头
	camera.ResetLerp(0)
	camera.ChangeCameraStatic(2017,44,6766,2114,26,6754)
	camera.ResetLerp(25000)
	camera.ChangeCameraStatic(2034,41,6763,2132,24,6751)
	global.Wait(0.3)
	npc.TurnToNpc(nLan,nLing)
	npc.TurnToNpc(nXiaHou,nLing)
	npc.TurnToNpc(nXia,nLing,1)
	ui.Dialog(80725,523,2,nXiaHou,0,0)--！凌波道长，此话当真？
	global.Wait(0.6)
	npc.SetHeadRot(nLing,-30,0,1,50)
	global.Wait(0.3)
	ui.Dialog(80726,150,2,nLing,0,0)--……是。
	global.Wait(0.3)
	npc.TurnToNpc(nLan,nLing,1)
	global.Wait(0.5)
	ui.Dialog(80727,164,2,nLan,0,0)--……
	global.Wait(1.5)
	ui.Dialog(80728,161,2,nLan,0,0)--（龙溟擅闯禁地，不知有什么阴谋。要是蜀山以为我们跟他是同党，不肯再帮我们寻找药方，那哥哥和村人——）
	global.Wait(0.3)
	npc.TurnToNpc(nLan,nLong,1)
	npc.SetHeadRot(nXiaHou,-40,0,0,70)
	npc.SetHeadRot(nXia,-30,0,0,70)
	npc.SetHeadRot(nLing,30,0,0,70)
	--暮菖兰备战动作
global.PlaySound(4110,60)--抽剑
	npc.SetAnim(nLan,228)
	npc_weapon(nLan,4)
	global.Wait(3)
	ui.Dialog(80729,629,0,nLong,0,0)--暮姑娘，这是何意？
	global.Wait(0.3)
	npc.SetHeadRot(nLan,-60,0,1,70)
	ui.Dialog(80730,165,2,nLan,0,0)--龙溟私闯蜀山禁地，我们看住他，夏侯少主你即刻返回入口处向外呼救，让外面的人解开阵法。
	global.Wait(0.3)
	npc.SetHeadRot(nLan,0,0,0,70)
	ui.Dialog(80731,629,0,nLong,0,0)--暮姑娘果然急智，不过，我们如今已是处于与世隔绝的幻境之中，无论如何呼喊，殿外之人也无法得知。
	global.Wait(0.3)
	--==========
	
	--###@@@切镜头
	camera.ResetLerp(0)
	camera.ChangeCameraStatic(2160,44,6825,2111,25,6740)
	camera.ResetLerp(20000)
	camera.ChangeCameraStatic(2177,45,6815,2109,22,6745)
	npc.SetHeadRot(nXia,0,0,0,100)
	npc.SetAnim(nXia,217,2)
	global.Wait(0.5)
	ui.Dialog(80732,196,2,nXia,0,0)--道长，他说的是真的吗？
	global.Wait(0.3)
	npc.SetHeadRot(nLong,0,0,0,70)
	npc.SetHeadRot(nLing,0,0,0,100)
	npc.TurnToNpc(nLing,nXia,1)
	npc.SetHeadRot(nXiaHou,20,0,0,70)
	global.Wait(0.5)
	ui.Dialog(80733,151,0,nLing,0,0)--……
	global.Wait(0.3)
	ui.Dialog(80734,151,0,nLing,0,0)--璇光殿中藏有本派至宝，阵法设得十分严密，一旦有人擅闯必会被困其中，除非破阵，否则绝无法离开此地。
	npc.SetHeadRot(nLan,-30,0,1,80)
--	npc_weapon(nLan,0)
--	npc.TurnToNpc(nLan,nLing,1)
	--暮菖兰生气
	-- npc.SetAnim(nLan,210,2)
	-- global.Wait(1)
	ui.Dialog(80735,181,0,nLan,0,0)--那你竟然还带我们进来！好啊，道长还真是够朋友！
	npc.TurnToNpc(nLing,nLan,1)
	global.Wait(0.5)
	ui.Dialog(80736,151,0,nLing,0,0)--……
	wt(1.3)
	npc.SetHeadRot(nXiaHou,0,0,0,100)
	npc.TurnToNpc(nXiaHou,nLong,1)
	npc.SetHeadRot(nXia,0,0,0,100)
	npc.TurnToNpc(nXia,nLong)
	npc.SetHeadRot(nLan,0,0,1,80)
	npc.SetHeadRot(nLong,20,0,0,70)
	global.Wait(1.3)
	ui.Dialog(80737,525,2,nXiaHou,0,0)--……龙公子，你私闯蜀山重地，凌波道长不愿惊动弟子，而带我们几个旧识进殿，便是有心袒护于你。眼下我们一同遭困，依你之见该当如何？
	global.Wait(0.3)
	--==========
	
	--###@@@切镜头
	camera.ResetLerp(0)
	camera.ChangeCameraStatic(2045,54,6670,2099,26,6749)
	camera.ResetLerp(25000)
	camera.ChangeCameraStatic(2050,48,6695,2111,23,6769)
	npc.TurnToNpc(nLing,nLong)
--	npc.TurnToNpc(nLan,nLong)
	ui.Dialog(80738,629,2,nLong,0,0)--几位想必也不愿坐以待毙，我们不妨先握手言和，等脱困之后再做计较，如何？
	global.Wait(0.6)
	npc.SetAnim(nXiaHou,216)
	global.Wait(1)
	npc.SetHeadRotTo(nXia,nXiaHou,1,70)
	npc.SetAnim(nXia,217,2)
	global.Wait(0.5)
	ui.Dialog(80739,188,0,nXia,0,0)--那……我们要是把阵法毁了，会不会给蜀山带来麻烦？那就太对不起草谷道长他们了。
	global.Wait(1.5)
	npc_weapon(nLan,0)
	npc.SetAnim(nLan,200)
	global.Wait(1)
	npc.TurnToNpc(nLan,nXia,1)
	npc.SetAnim(nLan,217,2)
	global.Wait(0.5)
	npc.SetHeadRot(nXia,50,0,0,70)
	ui.Dialog(80740,163,0,nLan,0,0)--妹子，凌波道长身为蜀山弟子都没提出异议，我们又何必替他们操心？
	npc.SetHeadRot(nLing,30,10,0,30)
	global.Wait(0.3)
	npc.SetHeadRot(nLan,20,0,0,70)
	npc.TurnToPos(nLan,2079,6717,1)
	ui.Dialog(80741,165,0,nLan,0,0)--眼下还是像龙公子所说，先合力离开这个幻境，反正出口只有一处，谁也别想逃。
	global.Wait(1)
	npc.SetAnim(nXiaHou,200)
	global.Wait(0.3)
	npc.TurnToNpc(nXiaHou,nXia,1)
	npc.SetHeadRotTo(nXia,nXiaHou,1,70)
	head_nod(nXiaHou)
	global.Wait(0.5)
	camera.ResetLerp(0)
	camera.ChangeCameraStatic(2245,66,6764,2149,37,6757)
	ui.Dialog(80742,629,2,nLong,0,0)--呵呵，观此阵势，破阵的关键应该就在这幻境的尽头。
	global.Wait(0.3)
	npc.TurnToNpc(nXiaHou,nLong,1)
	npc.SetHeadRotTo(nXia,nLong,1,70)
	--龙溟行礼
	npc.SetHeadRot(nLong,0,0,0,70)
	npc.SetAnim(nLong,213,2)
	global.Wait(1)
	ui.Dialog(80743,629,2,nLong,0,0)--那么几位，这一路还请多多关照了。
	global.Wait(0.5)
	camera.ChangeCameraStatic(2160,41,6783,2066,27,6751)
	ui.Dialog(80744,157,0,nLing,0,0)--……
	global.Wait(0.3)
	
	global.Wait(0.5)
	player.AddMagic(3042)--欺骗
	ui.Message(170724)--龙溟习得绝技：欺骗
	global.Wait(0.5)
	
	effect.FadeOut(1,0.7)
	global.Wait(1.5)
	--删除npc
	npc.Destroy(nXiaHou)
	npc.Destroy(nXia)
	npc.Destroy(nLing)
	npc.Destroy(nLan)
	npc.Destroy(nLong)
	--==========
	
	
	--龙溟入队
	player.Add(p_id(7),1)		
	
	--调整最终镜头方向
	camera.ResetLerp(0)
	camera.ChangeCameraStatic(2309,132,6827,2224,88,6799)
	player.SetAt(-3,-1)
	
	func_end(2119,6764,1,0.7)
	
	--龙溟换武器
	player.SetWeapon(2135,64)
	player.AddEquip(2114,-1,0)
	
	
end	
	
end