--任务副本4
--进入副本→播放MOV→刷第一波小怪→击杀第一波小怪→副本完成→传出副本

x040004_g_scriptId = 040004

--副本参数
x040004_g_CSParamIdxCurStage = 0			  --大阶段	
x040004_g_CSParamIdxCurSubStage = 1           --小阶段
x040004_g_CSParamAnimationID = 5033           --mov动画ID

x040004_g_MonstorList={}
x040004_g_MonstorList[1]={120001, 120001, 120001, 120001, 120001}  --小怪

x040004_g_MonstorPosList={}
x040004_g_MonstorPosList[1]={{67.41,58.99,1},{62.96,55.83,1},{56.11,56.36,1},{51.75,61.98,1},{52.20,66.75,1}} --小怪坐标

--死亡回调
function x040004_OnObjDie( scene,objId,rolebaseId,killerId )
	local nCurStage = GetCopySceneParam(scene,x040004_g_CSParamIdxCurStage)
	local MonCount = GetHostileMonsterCount(scene)
	if MonCount == 0 then
		SetCopySceneParam(scene,x040004_g_CSParamIdxCurStage,nCurStage+1)
		SetCopySceneParam(scene,x040004_g_CSParamIdxCurSubStage,0)
	end
end

--动画/对话回调
function x040004_OnStoryEventEnd(scene,nStoryId,nAnimationId)
	if nAnimationId == x040004_g_CSParamAnimationID then
		local nCurStage = GetCopySceneParam(scene,x040004_g_CSParamIdxCurStage)
		local MonCount = GetHostileMonsterCount(scene)
		SetCopySceneParam(scene,x040004_g_CSParamIdxCurStage,nCurStage+1)
		SetCopySceneParam(scene,x040004_g_CSParamIdxCurSubStage,0)
	end
end

--副本Tick
function x040004_OnCopySceneTick(scene,tickCount)
	local curStage = GetCopySceneParam(scene,x040004_g_CSParamIdxCurStage)
	local curSubStage = GetCopySceneParam(scene,x040004_g_CSParamIdxCurSubStage)
	SetCopySceneParam(scene, x040004_g_CSParamIdxCurSubStage, curSubStage+1)
	if curStage == 0 then  
		x040004_Stage_0(scene, curStage, curSubStage)
	elseif curStage == 1 then
		x040004_Stage_1(scene, curStage, curSubStage)
	elseif curStage == 2 then
		SetCopySceneSuccess(scene)
	end
end

--第0阶段 播放MOV 刷第一波小怪
function x040004_Stage_0(scene ,stage,substage)
	if substage == 1 then
		StoryAnimation(scene, x040004_g_CSParamAnimationID)
	end
end

--第1阶段 刷第一波小怪
function x040004_Stage_1(scene ,stage,substage)
	if substage == 1 then
		TellPlayerAutoCombat(scene)
		local count = #x040004_g_MonstorList[1]
		for i = 1, count do
			CreateMonster(scene, x040004_g_MonstorList[1][i], x040004_g_MonstorPosList[1][i][3], x040004_g_MonstorPosList[1][i][1], x040004_g_MonstorPosList[1][i][2])
		end
	end
end

