x003014_g_scriptId=003014

x003014_g_ActivityId=1

x003014_g_ZhuQueRoleId=40009 --朱雀ID
x003014_g_ZhuQueRoleAnimationId=822 --朱雀动画ID
x003014_g_ZhuQuePos={} --朱雀坐标
x003014_g_ZhuQuePos[1]={113.3,85.2,3.14} --朱雀坐标

x003014_g_NPCRoleId={} --NPCID
x003014_g_NPCRoleId[1]={40010,40011,40012,40013}
x003014_g_NPCRolePos={} --NPC坐标
x003014_g_NPCRolePos[1]={{103.1,68,3.14},{90.2,85.8,3.14},{113,109.1,3.14},{136.1,85.8,3.14}}

x003014_g_MonsterRoleId={} --怪物ID
x003014_g_MonsterRoleId[1]={40014,40015,40015,40015,40016,40016,40016,40016,40016,40017,40017,40017,40017,40017}
x003014_g_MonsterRolePos={} --怪物坐标
x003014_g_MonsterRolePos[1]={{101.8,169.9,3.14},{113.3,136.4,3.14},{109.1,134.3,3.14},{116.9,134.3,3.14},{70.7,134.3,3.14},{67.6,140.3,3.14},{61.7,140,3.14},{70.4,126.6,3.14},{65.6,136.2,3.14},{120.6,166.1,3.14},{123.1,170,3.14},{127.4,171.2,3.14},{121.8,171.7,3.14},{119.9,164.3,3.14}} 

x003014_g_MonsterInfo={{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}} --怪物状态objId,state,time
x003014_g_MonsterReliveTime=5 --怪物重生时间 单位秒
x003014_g_Tick=0

x003014_g_BossRoleId={} --BossID
x003014_g_BossRoleId[1]={40018,40019,40020,40021,40022}
x003014_g_BossFakeId={} --BossFakeID
x003014_g_BossFakeId[1]={60701,60701,60701,60701,60701}
x003014_g_BossMessageId={} --Boss喊话字典ID
x003014_g_BossMessageId[1]={3525,3525,3525,3525,3525}
x003014_g_BossPos={} --Boss坐标
x003014_g_BossPos[1]={113,69,3.14}
x003014_g_BossMovePos={} --Boss移动目的地坐标
x003014_g_BossMovePos[1]={113,76}

x003014_g_MissionEnergy=5 --完成相关任务增长的进度值
x003014_g_BoxEnergy={}
x003014_g_BoxEnergy[1]={20,40,60,80} --生成宝箱所需的进度值
x003014_g_BoxId=4300 --宝箱ID
x003014_g_RandomBoxNum=10 --随机生成的宝箱数量
x003014_g_BossEnergy=20 --召唤BOSS所需的进度值

--活动开始
function x003014_OnActivityStart(scene,curTime,idx)
    SetGuildActivity(scene, x003014_g_ActivityId, x003014_g_scriptId)
	CreateMonster(scene,x003014_g_ZhuQueRoleId,x003014_g_ZhuQuePos[1][3],x003014_g_ZhuQuePos[1][1],x003014_g_ZhuQuePos[1][2])
	MonsterPlayAnimaByRoleBaseId(scene,x003014_g_ZhuQueRoleId,x003014_g_ZhuQueRoleAnimationId)
	local countNPC = #x003014_g_NPCRoleId[1]
	for i = 1, countNPC do
		CreateMonster(scene,x003014_g_NPCRoleId[1][i],x003014_g_NPCRolePos[1][i][3],x003014_g_NPCRolePos[1][i][1],x003014_g_NPCRolePos[1][i][2])
	end
	
	local countMonster = #x003014_g_MonsterRoleId[1]
	for i = 1, countMonster do
		x003014_g_MonsterInfo[i][1] = CreateMonster(scene,x003014_g_MonsterRoleId[1][i],x003014_g_MonsterRolePos[1][i][3],x003014_g_MonsterRolePos[1][i][1],x003014_g_MonsterRolePos[1][i][2])
		x003014_g_MonsterInfo[i][2] = 1
		x003014_g_MonsterInfo[i][3] = 0
	end
	GuildFormationControl(scene,2)
end

--任务触发
function x003014_OnTriggerEvent(scene,level,playerName,broadCast)
	if (x003014_g_Energy == nil) then
		x003014_g_Energy = 0
	end
	x003014_g_Energy = x003014_g_Energy + x003014_g_MissionEnergy
	if (boradCast == 1) then
		SendChannalMessageParam(scene,3,3524,-1,playerName,tostring(x003014_g_Energy))
	end
	
	--随机生成宝箱	
	local count = #x003014_g_BoxEnergy[1]
	for i = 1, count do
		if (x003014_g_Energy == x003014_g_BoxEnergy[1][i]) then
			CreateRandomBox(scene,x003014_g_BoxId,x003014_g_RandomBoxNum)
			SendChannalMessage(scene,3,3526,-1,tostring(x003014_g_Energy))
		end
	end
	
	--生成BOSS
	if (x003014_g_Energy == x003014_g_BossEnergy) then
		CreateMonster(scene,x003014_g_BossRoleId[1][level],x003014_g_BossPos[1][3],x003014_g_BossPos[1][1],x003014_g_BossPos[1][2])
		CommandRBIDMoveTo(scene,x003014_g_BossRoleId[1][level],x003014_g_ZhuQuePos[1][1],x003014_g_ZhuQuePos[1][2])
		SendChannalMessage(scene,3,3525,-1)
		local nUserCount = GetSceneUserCount(scene)
		for i=0,nUserCount-1 do
			local nUserObjId = GetUserObjIdByIdx(scene,i)
			ShowBossTips(scene,nUserObjId,x003014_g_BossFakeId[1][level],x003014_g_BossMessageId[1][level],x003014_g_BossRoleId[1][level],3)
		end
	end
end

function x003014_OnActivityTick(scene,tickCount)
	x003014_g_Tick = tickCount
	
	for i = 1, #x003014_g_MonsterInfo do
		if (x003014_g_MonsterInfo[i][2] == 0) and (x003014_g_MonsterInfo[i][3] == tickCount) then
			x003014_g_MonsterInfo[i][1] = CreateMonster(scene,x003014_g_MonsterRoleId[1][i],x003014_g_MonsterRolePos[1][i][3],x003014_g_MonsterRolePos[1][i][1],x003014_g_MonsterRolePos[1][i][2])
			x003014_g_MonsterInfo[i][2] = 1
			x003014_g_MonsterInfo[i][3] = 0
		end
	end
end

function x003014_OnObjDie(scene,objId,rolebaseId,killerId)

	for i = 1, #x003014_g_MonsterInfo do
		if (x003014_g_MonsterInfo[i][1] == objId) then
			x003014_g_MonsterInfo[i][2] = 0
			x003014_g_MonsterInfo[i][3] = x003014_g_Tick + x003014_g_MonsterReliveTime
			return
		end
	end
end

--活动结束
function x003014_Clear(scene)	
	x003014_g_Energy = 0
end
