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

-- 怪物
monsters = {
	{ config_id = 4001, monster_id = 20011001, pos = { x = 7.1, y = 0.1, z = -6.1 }, rot = { x = 0.0, y = 346.5, z = 0.0 }, level = 1, affix = { 1006, 1008 }, isElite = true, pose_id = 0 },
	{ config_id = 4002, monster_id = 20011001, pos = { x = -6.1, y = 0.1, z = -6.1 }, rot = { x = 0.0, y = 21.5, z = 0.0 }, level = 1, affix = { 1006, 1008 }, isElite = true, pose_id = 0 },
	{ config_id = 4003, monster_id = 20011001, pos = { x = -5.7, y = 0.1, z = -11.0 }, rot = { x = 0.0, y = 18.6, z = 0.0 }, level = 1, affix = { 1006, 1008 }, isElite = true, pose_id = 0 },
	{ config_id = 4004, monster_id = 20011001, pos = { x = 0.8, y = 0.1, z = -12.6 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1, affix = { 1006, 1008 }, isElite = true, pose_id = 0 },
	{ config_id = 4005, monster_id = 20011001, pos = { x = 8.7, y = 0.1, z = -12.8 }, rot = { x = 0.0, y = 343.7, z = 0.0 }, level = 1, affix = { 1006, 1008 }, isElite = true, pose_id = 0 },
	{ config_id = 4006, monster_id = 20010801, pos = { x = -10.4, y = 0.1, z = -2.2 }, rot = { x = 0.0, y = 64.8, z = 0.0 }, level = 1, affix = { 1006, 1008 }, isElite = true, pose_id = 0 },
	{ config_id = 4007, monster_id = 20010801, pos = { x = 12.7, y = 0.1, z = -1.9 }, rot = { x = 0.0, y = 270.1, z = 0.0 }, level = 1, affix = { 1006, 1008 }, isElite = true, pose_id = 0 },
	{ config_id = 4008, monster_id = 20010801, pos = { x = 1.1, y = 0.1, z = 6.4 }, rot = { x = 0.0, y = 182.8, z = 0.0 }, level = 1, affix = { 1006, 1008 }, isElite = true, pose_id = 0 },
	{ config_id = 4009, monster_id = 20010801, pos = { x = 5.3, y = 0.1, z = -8.4 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1, affix = { 1006, 1008 }, isElite = true, pose_id = 0 },
	{ config_id = 4010, monster_id = 20010801, pos = { x = -5.0, y = 0.1, z = -8.8 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1, affix = { 1006, 1008 }, isElite = true, pose_id = 0 },
	{ config_id = 4011, monster_id = 20011001, pos = { x = 12.9, y = 0.1, z = 0.5 }, rot = { x = 0.0, y = 315.3, z = 0.0 }, level = 1, affix = { 1006, 1008 }, isElite = true, pose_id = 0 },
	{ config_id = 4012, monster_id = 20011001, pos = { x = 12.4, y = 0.1, z = -9.2 }, rot = { x = 0.0, y = 322.1, z = 0.0 }, level = 1, affix = { 1006, 1008 }, isElite = true, pose_id = 0 },
	{ config_id = 4013, monster_id = 20011001, pos = { x = 0.4, y = 0.1, z = -11.1 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1, affix = { 1006, 1008 }, isElite = true, pose_id = 0 },
	{ config_id = 4014, monster_id = 20010801, pos = { x = -12.1, y = 0.1, z = -6.3 }, rot = { x = 0.0, y = 50.2, z = 0.0 }, level = 1, affix = { 1006, 1008 }, isElite = true, pose_id = 0 },
	{ config_id = 4015, monster_id = 20010801, pos = { x = -13.6, y = 0.1, z = 1.3 }, rot = { x = 0.0, y = 76.2, z = 0.0 }, level = 1, affix = { 1006, 1008 }, isElite = true, pose_id = 0 },
	{ config_id = 4016, monster_id = 22010301, pos = { x = 1.0, y = 0.1, z = -7.4 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1, affix = { 1014 }, isElite = true, pose_id = 0 },
	{ config_id = 4017, monster_id = 20011001, pos = { x = -10.6, y = 0.1, z = 0.6 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1, affix = { 1006, 1008 }, isElite = true, pose_id = 0 },
	{ config_id = 4018, monster_id = 20011001, pos = { x = 10.4, y = 0.1, z = -1.9 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1, affix = { 1006, 1008 }, isElite = true, pose_id = 0 },
	{ config_id = 4019, monster_id = 20011001, pos = { x = -0.8, y = 0.1, z = 8.2 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1, affix = { 1006, 1008 }, isElite = true, pose_id = 0 },
	{ config_id = 4020, monster_id = 20011001, pos = { x = 5.4, y = 0.1, z = 6.7 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1, affix = { 1006, 1008 }, isElite = true, pose_id = 0 },
	{ config_id = 4028, monster_id = 21010901, pos = { x = 15.1, y = 0.0, z = -7.8 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 4029, monster_id = 21010901, pos = { x = -11.2, y = 0.0, z = -9.1 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 4030, monster_id = 20010901, pos = { x = 17.1, y = 0.0, z = -2.6 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 4031, monster_id = 20010901, pos = { x = -11.6, y = 0.0, z = -3.0 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 4032, monster_id = 21030101, pos = { x = 4.7, y = 0.0, z = -11.7 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 4033, monster_id = 20011001, pos = { x = 13.6, y = 0.0, z = 3.1 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 4034, monster_id = 20011001, pos = { x = -10.2, y = 0.0, z = 3.8 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 4035, monster_id = 20010801, pos = { x = 10.3, y = 0.0, z = 4.1 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 4036, monster_id = 20010801, pos = { x = -6.9, y = 0.0, z = 6.9 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 4037, monster_id = 20010801, pos = { x = -2.1, y = 0.0, z = -8.0 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 }
}

-- NPC
npcs = {
}

-- 装置
gadgets = {
	{ config_id = 4021, gadget_id = 70900205, pos = { x = 7.1, y = -1.3, z = 2.1 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 }
}

-- 区域
regions = {
}

-- 触发器
triggers = {
	{ name = "ANY_MONSTER_LIVE_4022", event = EventType.EVENT_ANY_MONSTER_LIVE, source = "", condition = "condition_EVENT_ANY_MONSTER_LIVE_4022", action = "action_EVENT_ANY_MONSTER_LIVE_4022" },
	{ name = "MONSTER_TIDE_OVER_4023", event = EventType.EVENT_MONSTER_TIDE_OVER, source = "1", condition = "", action = "action_EVENT_MONSTER_TIDE_OVER_4023" },
	{ name = "CHALLENGE_SUCCESS_4026", event = EventType.EVENT_CHALLENGE_SUCCESS, source = "1", condition = "", action = "action_EVENT_CHALLENGE_SUCCESS_4026" },
	{ name = "CHALLENGE_FAIL_4027", event = EventType.EVENT_CHALLENGE_FAIL, source = "1", condition = "", action = "action_EVENT_CHALLENGE_FAIL_4027" }
}

-- 变量
variables = {
	{ name = "Key", value = 0, no_refresh = false }
}

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

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

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

suites = {
	{
		-- suite_id = 1,
		-- description = ,
		monsters = { },
		gadgets = { 4021 },
		regions = { },
		triggers = { "ANY_MONSTER_LIVE_4022", "MONSTER_TIDE_OVER_4023", "CHALLENGE_SUCCESS_4026", "CHALLENGE_FAIL_4027" },
		rand_weight = 100
	},
	{
		-- suite_id = 2,
		-- description = suite_2,
		monsters = { },
		gadgets = { 4021 },
		regions = { },
		triggers = { },
		rand_weight = 100
	},
	{
		-- suite_id = 3,
		-- description = suite_3,
		monsters = { },
		gadgets = { 4021 },
		regions = { },
		triggers = { },
		rand_weight = 100
	},
	{
		-- suite_id = 4,
		-- description = suite_4,
		monsters = { },
		gadgets = { 4021 },
		regions = { },
		triggers = { },
		rand_weight = 100
	},
	{
		-- suite_id = 5,
		-- description = suite_5,
		monsters = { 4016, 4017, 4018, 4019, 4020 },
		gadgets = { 4021 },
		regions = { },
		triggers = { "CHALLENGE_SUCCESS_4026", "CHALLENGE_FAIL_4027" },
		rand_weight = 100
	}
}

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

-- 触发条件
function condition_EVENT_ANY_MONSTER_LIVE_4022(context, evt)
	if 4001 ~= evt.param1 then
		return false
	end
	
	return true
end

-- 触发操作
function action_EVENT_ANY_MONSTER_LIVE_4022(context, evt)
	-- 创建编号为1（该挑战的识别id),挑战内容为191的区域挑战，具体参数填写方式，见DungeonChallengeData表中的注释，所有填写的值都必须是int类型
	if 0 ~= ScriptLib.ActiveChallenge(context, 1, 191, 300, 240502004, 30, 0) then
		return -1
	end
	
	return 0
end

-- 触发条件

-- 触发操作
function action_EVENT_MONSTER_TIDE_OVER_4023(context, evt)
	-- 延迟1秒刷怪
	if 0 ~= ScriptLib.CreateMonster(context, { config_id = 4016, delay_time = 1 }) then
	  return -1
	end
	
	-- 延迟1秒刷怪
	if 0 ~= ScriptLib.CreateMonster(context, { config_id = 4017, delay_time = 1 }) then
	  return -1
	end
	
	-- 延迟1秒刷怪
	if 0 ~= ScriptLib.CreateMonster(context, { config_id = 4018, delay_time = 1 }) then
	  return -1
	end
	
	-- 延迟1秒刷怪
	if 0 ~= ScriptLib.CreateMonster(context, { config_id = 4019, delay_time = 1 }) then
	  return -1
	end
	
	-- 延迟1秒刷怪
	if 0 ~= ScriptLib.CreateMonster(context, { config_id = 4020, delay_time = 1 }) then
	  return -1
	end
	
	return 0
end

-- 触发条件

-- 触发操作
function action_EVENT_CHALLENGE_SUCCESS_4026(context, evt)
	-- 改变指定group组240502002中， configid为2002的gadget的state
	if 0 ~= ScriptLib.SetGroupGadgetStateByConfigId(context, 240502002, 2002, GadgetState.GearStart) then
			return -1
		end 
	
	return 0
end

-- 触发条件

-- 触发操作
function action_EVENT_CHALLENGE_FAIL_4027(context, evt)
	-- 改变指定group组240502003中， configid为3001的gadget的state
	if 0 ~= ScriptLib.SetGroupGadgetStateByConfigId(context, 240502003, 3001, GadgetState.Default) then
			return -1
		end 
	
	-- 设置操作台选项
	if 0 ~= ScriptLib.SetWorktopOptionsByGroupId(context, 240502003, 3001, {7}) then
		return -1
	end
	
	-- 改变指定group组240502002中， configid为2001的gadget的state
	if 0 ~= ScriptLib.SetGroupGadgetStateByConfigId(context, 240502002, 2001, GadgetState.GearStart) then
			return -1
		end 
	
	-- 改变指定group组240502002中， configid为2002的gadget的state
	if 0 ~= ScriptLib.SetGroupGadgetStateByConfigId(context, 240502002, 2002, GadgetState.GearStart) then
			return -1
		end 
	
		-- 重新生成指定group，指定suite
		if 0 ~= ScriptLib.RefreshGroup(context, { group_id = 240502004, suite = 1 }) then
			return -1
		end
	
	return 0
end
