x020058_g_scriptId=020058


x020058_g_MonsterId ={}
x020058_g_MonsterId[1]={480202, 480201 ,480202}
x020058_g_MonsterId[2]={480202, 480201 ,480202}
x020058_g_MonsterId[3]={480203}
x020058_g_MonsterPos ={}
x020058_g_MonsterPos[1] = {{59.12, 68.17, -1.57},{64.92, 67.97, -1.57},{71.14,68.25, -1.57}}
x020058_g_MonsterPos[2] = {{59.12, 68.17, -1.57},{64.92, 67.97, -1.57},{71.14,68.25, -1.57}}
x020058_g_MonsterPos[3] = {{64.92, 67.97, -1.57}}

x020058_g_CSParamIdxStage = 0


function x020058_OnCopySceneOpen(scene)
	local stage = 0
	SetCopySceneParam(scene, x020058_g_CSParamIdxStage, stage)
	x020058_CreateMonsterOnStage(scene,stage)
end

function x020058_OnCopySceneTick(scene, tickCount)
	
end
function x020058_OnObjEnter(scene,objId)
	--CopySceneNPC(scene,1001101,51001,6,152,1,"XXX")--场景、角色ID、CharModel表ID、势力、出现的场景SceneID、等级、名称
	AutoCombat(scene,objId,true)
end
function x020058_OnObjDie(scene, objId, rolebaseId, killerId)

	if objId == GetUserObjIdByIdx(scene, 0) then
		x020058_EndCopyScene(scene,false)
	else 
		
	local curStage = GetCopySceneParam(scene,x020058_g_CSParamIdxStage) 
	local count =  GetHostileMonsterCount(scene)
	if count == 0 then
		if curStage+1== #x020058_g_MonsterId then
			x020058_EndCopyScene(scene,true)
		else
			local  nextStage = curStage+1
			SetCopySceneParam(scene, x020058_g_CSParamIdxStage, nextStage)
			x020058_CreateMonsterOnStage(scene,nextStage)
		end
	end	

	end

end

function  x020058_CreateMonsterOnStage(scene,stage)
	local monsterIndex=stage+1
	if monsterIndex < 1 then
		monsterIndex = 1
	elseif monsterIndex > #x020058_g_MonsterId then
		monsterIndex = #x020058_g_MonsterId
	end

	local  monsters = x020058_g_MonsterId[monsterIndex]
	local  pos = x020058_g_MonsterPos[monsterIndex]
	for i=1,#monsters do
		CreateMonster(scene, monsters[i], pos[i][3], pos[i][1], pos[i][2])
	end
end


function x020058_OnCopySceneTimeOut(scene)
	x020058_EndCopyScene(scene,false)
end

function x020058_EndCopyScene(scene,win)
	ChangeJobCopyEnd(scene,win)
	if win then
		SetCopySceneSuccess(scene)
	else
		SetCopySceneFail(scene)	
	end 
end