--================================================================
-- 
-- 配置
-- 
--================================================================

-- 怪物
monsters = {
	{ config_id = 2003, monster_id = 21010501, pos = { x = 44.0, y = 0.8, z = 5.7 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 3, disableWander = true, pose_id = 32 },
	{ config_id = 2004, monster_id = 21010501, pos = { x = 33.7, y = 0.5, z = -3.8 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 3, disableWander = true, pose_id = 32 },
	{ config_id = 2005, monster_id = 21010401, pos = { x = 65.9, y = 3.9, z = 0.5 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 1, disableWander = true, pose_id = 402 },
	{ config_id = 2006, monster_id = 21010501, pos = { x = 67.7, y = 3.9, z = 2.1 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 1, disableWander = true, pose_id = 32 },
	{ config_id = 2007, monster_id = 21010401, pos = { x = 65.5, y = 3.9, z = 3.6 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 1, disableWander = true, pose_id = 402 },
	{ config_id = 2008, monster_id = 21010501, pos = { x = 35.0, y = 0.5, z = -5.5 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 3, disableWander = true, pose_id = 32 },
	{ config_id = 2009, monster_id = 21010501, pos = { x = 43.5, y = 4.7, z = -8.0 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1, disableWander = true, pose_id = 32 },
	{ config_id = 2010, monster_id = 21011001, pos = { x = 26.7, y = 5.3, z = 10.1 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 1, disableWander = true, pose_id = 32 },
	{ config_id = 2011, monster_id = 21011001, pos = { x = 44.6, y = 4.9, z = 18.8 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 3, disableWander = true, pose_id = 32 },
	{ config_id = 2012, monster_id = 21011001, pos = { x = 43.6, y = 0.6, z = 9.6 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 1, disableWander = true, pose_id = 32 },
	{ config_id = 2013, monster_id = 21010501, pos = { x = 28.2, y = 4.1, z = -8.2 }, rot = { x = 0.0, y = 65.3, z = 0.0 }, level = 3, disableWander = true, pose_id = 32 },
	{ config_id = 2014, monster_id = 21010401, pos = { x = 16.2, y = 1.7, z = -2.9 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 1, disableWander = true, pose_id = 402 },
	{ config_id = 2015, monster_id = 21010401, pos = { x = 17.4, y = 0.6, z = -0.2 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 1, disableWander = true, pose_id = 402 },
	{ config_id = 2016, monster_id = 21010901, pos = { x = 16.1, y = 1.7, z = 2.7 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 1, disableWander = true, pose_id = 32 },
	{ config_id = 2017, monster_id = 21010501, pos = { x = 19.9, y = 0.6, z = -1.5 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 1, disableWander = true, pose_id = 32 },
	{ config_id = 2018, monster_id = 21011001, pos = { x = 19.1, y = 0.6, z = 3.7 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 1, disableWander = true, pose_id = 32 },
	{ config_id = 2019, monster_id = 21010901, pos = { x = 45.9, y = 0.9, z = 7.0 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 3, disableWander = true, pose_id = 32 },
	{ config_id = 2020, monster_id = 21010501, pos = { x = 36.2, y = 0.5, z = -3.0 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 3, disableWander = true, pose_id = 32 },
	{ config_id = 2021, monster_id = 21010401, pos = { x = 64.4, y = 0.6, z = 17.6 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 1, disableWander = true, pose_id = 402 },
	{ config_id = 2022, monster_id = 21011001, pos = { x = 65.6, y = 0.6, z = 20.0 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 1, disableWander = true, pose_id = 32 }
}

-- NPC
npcs = {
}

-- 装置
gadgets = {
	{ config_id = 2023, gadget_id = 70350002, pos = { x = 6.2, y = 2.7, z = 0.5 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 1 },
	{ config_id = 2024, gadget_id = 70900201, pos = { x = -82.5, y = 30.1, z = 37.3 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 2025, gadget_id = 70710005, pos = { x = -38.4, y = -2.8, z = 2.5 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 2026, gadget_id = 70710005, pos = { x = -70.3, y = 12.0, z = 11.0 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 2027, gadget_id = 70690001, pos = { x = 3.8, y = 9.3, z = 2.0 }, rot = { x = 346.4, y = 270.0, z = 13.7 }, level = 1 },
	{ config_id = 2028, gadget_id = 70690001, pos = { x = -13.6, y = 13.5, z = 1.9 }, rot = { x = 346.4, y = 269.6, z = 13.7 }, level = 1 },
	{ config_id = 2029, gadget_id = 70690001, pos = { x = -4.9, y = 11.4, z = 1.9 }, rot = { x = 346.4, y = 269.6, z = 13.7 }, level = 1 },
	{ config_id = 2030, gadget_id = 70900201, pos = { x = 7.2, y = 6.4, z = 0.5 }, rot = { x = 0.0, y = 90.1, z = 0.0 }, level = 1 }
}

-- 区域
regions = {
	{ config_id = 2001, shape = RegionShape.CUBIC, size = { x = 10.0, y = 30.0, z = 50.0 }, pos = { x = 86.7, y = 3.9, z = 0.3 } }
}

-- 触发器
triggers = {
	{ name = "ANY_MONSTER_DIE_1", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "condition_EVENT_ANY_MONSTER_DIE_1", action = "action_EVENT_ANY_MONSTER_DIE_1" },
	{ name = "ENTER_REGION_2001", event = EventType.EVENT_ENTER_REGION, source = "", condition = "condition_EVENT_ENTER_REGION_2001", action = "action_EVENT_ENTER_REGION_2001", forbid_guest = false }
}

-- 变量
variables = {
}

--================================================================
-- 
-- 初始化配置
-- 
--================================================================

-- 初始化时创建
init_config = {
	suite = 1,
	end_suite = 0,
	rand_suite = false
}

--================================================================
-- 
-- 小组配置
-- 
--================================================================

suites = {
	{
		-- suite_id = 1,
		-- description = ,
		monsters = { 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022 },
		gadgets = { 2023 },
		regions = { 2001 },
		triggers = { "ANY_MONSTER_DIE_1", "ENTER_REGION_2001" },
		rand_weight = 100
	}
}

--================================================================
-- 
-- 触发器
-- 
--================================================================

-- 触发条件
function condition_EVENT_ANY_MONSTER_DIE_1(context, evt)
	-- 判断指定group组剩余怪物数量是否是0 
	if ScriptLib.GetGroupMonsterCountByGroupId(context, 201015002) ~= 0 then
		return false
	end
	
	return true
end

-- 触发操作
function action_EVENT_ANY_MONSTER_DIE_1(context, evt)
	-- 将configid为 2023 的物件更改为状态 GadgetState.GearStart
	if 0 ~= ScriptLib.SetGadgetStateByConfigId(context, 2023, GadgetState.GearStart) then
			return -1
		end 
	
	-- 创建id为2024的gadget
	if 0 ~= ScriptLib.CreateGadget(context, { config_id = 2024 }) then
	  return -1
	end
	
	-- 创建id为2025的gadget
	if 0 ~= ScriptLib.CreateGadget(context, { config_id = 2025 }) then
	  return -1
	end
	
	-- 创建id为2026的gadget
	if 0 ~= ScriptLib.CreateGadget(context, { config_id = 2026 }) then
	  return -1
	end
	
	-- 创建id为2027的gadget
	if 0 ~= ScriptLib.CreateGadget(context, { config_id = 2027 }) then
	  return -1
	end
	
	-- 创建id为2028的gadget
	if 0 ~= ScriptLib.CreateGadget(context, { config_id = 2028 }) then
	  return -1
	end
	
	-- 创建id为2029的gadget
	if 0 ~= ScriptLib.CreateGadget(context, { config_id = 2029 }) then
	  return -1
	end
	
		-- 杀死Group内指定的monster和gadget
		if 0 ~= ScriptLib.KillGroupEntity(context, { group_id = 201015002, monsters = {}, gadgets = {2030} }) then
			return -1
		end
	
	return 0
end

-- 触发条件
function condition_EVENT_ENTER_REGION_2001(context, evt)
	if evt.param1 ~= 2001 then return false end
	
	-- 判断角色数量不少于1
	if ScriptLib.GetRegionEntityCount(context, { region_eid = evt.source_eid, entity_type = EntityType.AVATAR }) < 1 then
		return false
	end
	
	return true
end

-- 触发操作
function action_EVENT_ENTER_REGION_2001(context, evt)
	-- 创建id为2030的gadget
	if 0 ~= ScriptLib.CreateGadget(context, { config_id = 2030 }) then
	  return -1
	end
	
	return 0
end
