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

-- 怪物
monsters = {
}

-- NPC
npcs = {
}

-- 装置
gadgets = {
	{ config_id = 434, gadget_id = 70900007, pos = { x = 132.1, y = 0.5, z = 386.1 }, rot = { x = 0.0, y = 0.8, z = 0.0 }, level = 1, persistent = true },
	{ config_id = 435, gadget_id = 70220020, pos = { x = 131.9, y = 0.5, z = 379.7 }, rot = { x = 0.0, y = 3.1, z = 0.0 }, level = 1 },
	{ config_id = 436, gadget_id = 70220020, pos = { x = 127.9, y = 0.5, z = 380.1 }, rot = { x = 0.0, y = 3.1, z = 0.0 }, level = 1 },
	{ config_id = 437, gadget_id = 70220020, pos = { x = 134.9, y = 0.5, z = 393.3 }, rot = { x = 0.0, y = 3.1, z = 0.0 }, level = 1 },
	{ config_id = 438, gadget_id = 70220020, pos = { x = 131.0, y = 0.5, z = 393.7 }, rot = { x = 0.0, y = 3.1, z = 0.0 }, level = 1 },
	{ config_id = 439, gadget_id = 70220020, pos = { x = 129.0, y = 0.5, z = 391.1 }, rot = { x = 0.0, y = 93.2, z = 0.0 }, level = 1 },
	{ config_id = 440, gadget_id = 70220020, pos = { x = 126.9, y = 0.5, z = 383.0 }, rot = { x = 0.0, y = 336.6, z = 0.0 }, level = 1 },
	{ config_id = 441, gadget_id = 70220020, pos = { x = 126.4, y = 0.5, z = 387.3 }, rot = { x = 0.0, y = 271.2, z = 0.0 }, level = 1 },
	{ config_id = 442, gadget_id = 70220020, pos = { x = 126.4, y = 0.5, z = 391.6 }, rot = { x = 0.0, y = 271.2, z = 0.0 }, level = 1 },
	{ config_id = 443, gadget_id = 70220020, pos = { x = 134.9, y = 0.5, z = 381.5 }, rot = { x = 0.0, y = 287.2, z = 0.0 }, level = 1 },
	{ config_id = 444, gadget_id = 70220020, pos = { x = 137.8, y = 0.5, z = 383.5 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 1 },
	{ config_id = 445, gadget_id = 70220020, pos = { x = 136.8, y = 0.4, z = 388.8 }, rot = { x = 3.0, y = 67.3, z = 8.7 }, level = 1 },
	{ config_id = 446, gadget_id = 70220020, pos = { x = 138.3, y = 0.5, z = 393.9 }, rot = { x = 0.0, y = 131.4, z = 0.0 }, level = 1 },
	{ config_id = 447, gadget_id = 70220020, pos = { x = 122.1, y = 0.5, z = 391.9 }, rot = { x = 0.0, y = 94.9, z = 0.0 }, level = 1 },
	{ config_id = 448, gadget_id = 70220020, pos = { x = 120.9, y = 0.5, z = 387.8 }, rot = { x = 0.0, y = 38.0, z = 0.0 }, level = 1 },
	{ config_id = 449, gadget_id = 70220020, pos = { x = 122.6, y = 0.5, z = 383.3 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 1 },
	{ config_id = 450, gadget_id = 70220020, pos = { x = 122.0, y = 0.5, z = 378.9 }, rot = { x = 0.0, y = 104.1, z = 0.0 }, level = 1 },
	{ config_id = 451, gadget_id = 70220020, pos = { x = 123.0, y = 0.5, z = 396.5 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 1 },
	{ config_id = 452, gadget_id = 70220020, pos = { x = 125.5, y = 0.5, z = 398.1 }, rot = { x = 0.0, y = 175.2, z = 0.0 }, level = 1 },
	{ config_id = 453, gadget_id = 70220020, pos = { x = 129.5, y = 0.5, z = 399.4 }, rot = { x = 0.0, y = 144.7, z = 0.0 }, level = 1 },
	{ config_id = 454, gadget_id = 70220020, pos = { x = 133.6, y = 0.5, z = 398.2 }, rot = { x = 0.0, y = 207.2, z = 0.0 }, level = 1 },
	{ config_id = 455, gadget_id = 70220020, pos = { x = 136.9, y = 0.5, z = 397.5 }, rot = { x = 0.0, y = 175.2, z = 0.0 }, level = 1 },
	{ config_id = 456, gadget_id = 70220020, pos = { x = 140.2, y = 0.5, z = 398.6 }, rot = { x = 0.0, y = 155.0, z = 0.0 }, level = 1 },
	{ config_id = 457, gadget_id = 70220020, pos = { x = 141.8, y = 0.5, z = 394.5 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 1 },
	{ config_id = 458, gadget_id = 70220020, pos = { x = 141.6, y = 0.5, z = 390.7 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 1 },
	{ config_id = 459, gadget_id = 70220020, pos = { x = 144.2, y = 0.5, z = 385.6 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 1 },
	{ config_id = 460, gadget_id = 70220020, pos = { x = 141.3, y = 0.5, z = 381.3 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 1 },
	{ config_id = 461, gadget_id = 70220020, pos = { x = 137.0, y = 0.5, z = 377.6 }, rot = { x = 0.0, y = 146.8, z = 0.0 }, level = 1 },
	{ config_id = 462, gadget_id = 70220020, pos = { x = 140.3, y = 0.5, z = 375.7 }, rot = { x = 0.0, y = 315.0, z = 0.0 }, level = 1 },
	{ config_id = 463, gadget_id = 70220020, pos = { x = 133.3, y = 0.5, z = 374.9 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 464, gadget_id = 70220020, pos = { x = 128.8, y = 0.5, z = 375.2 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 465, gadget_id = 70220020, pos = { x = 126.4, y = 0.5, z = 377.2 }, rot = { x = 0.0, y = 32.6, z = 0.0 }, level = 1 },
	{ config_id = 466, gadget_id = 70220020, pos = { x = 124.7, y = 0.5, z = 386.5 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 467, gadget_id = 70220020, pos = { x = 139.7, y = 0.5, z = 386.1 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 468, gadget_id = 70220020, pos = { x = 131.6, y = 0.5, z = 377.3 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 1 },
	{ config_id = 469, gadget_id = 70220020, pos = { x = 131.9, y = 0.5, z = 396.1 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 1 },
	{ config_id = 470, gadget_id = 70900255, pos = { x = 132.0, y = 0.5, z = 386.2 }, rot = { x = 0.0, y = 63.0, z = 0.0 }, level = 1 },
	{ config_id = 471, gadget_id = 70211001, pos = { x = 132.3, y = 0.5, z = 389.6 }, rot = { x = 0.0, y = 265.6, z = 0.0 }, level = 1, drop_tag = "战斗低级蒙德", showcutscene = true, type = GadgetType.GADGET_DUNGEON_SECRET_CHEST },
	{ config_id = 472, gadget_id = 70900016, pos = { x = 143.5, y = 0.2, z = 382.1 }, rot = { x = 0.0, y = 248.9, z = 0.0 }, level = 1 },
	{ config_id = 473, gadget_id = 70900016, pos = { x = 123.9, y = 0.5, z = 375.4 }, rot = { x = 0.0, y = 248.9, z = 0.0 }, level = 1 },
	{ config_id = 474, gadget_id = 70900016, pos = { x = 137.1, y = 0.5, z = 374.5 }, rot = { x = 0.0, y = 248.9, z = 0.0 }, level = 1 },
	{ config_id = 475, gadget_id = 70900016, pos = { x = 133.3, y = 0.5, z = 401.5 }, rot = { x = 0.0, y = 248.9, z = 0.0 }, level = 1 },
	{ config_id = 476, gadget_id = 70900016, pos = { x = 119.8, y = 0.5, z = 391.0 }, rot = { x = 0.0, y = 248.9, z = 0.0 }, level = 1 },
	{ config_id = 477, gadget_id = 70220020, pos = { x = 142.2, y = 0.5, z = 397.8 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 1 },
	{ config_id = 478, gadget_id = 70220020, pos = { x = 143.8, y = 0.5, z = 389.4 }, rot = { x = 0.0, y = 50.6, z = 0.0 }, level = 1 },
	{ config_id = 479, gadget_id = 70220020, pos = { x = 142.9, y = 0.5, z = 378.4 }, rot = { x = 0.0, y = 114.7, z = 0.0 }, level = 1 },
	{ config_id = 480, gadget_id = 70220001, pos = { x = 130.0, y = 0.5, z = 377.3 }, rot = { x = 0.0, y = 288.0, z = 0.0 }, level = 1 },
	{ config_id = 481, gadget_id = 70220001, pos = { x = 121.9, y = 0.5, z = 388.9 }, rot = { x = 0.0, y = 107.1, z = 0.0 }, level = 1 },
	{ config_id = 482, gadget_id = 70220001, pos = { x = 133.6, y = 0.5, z = 395.8 }, rot = { x = 0.0, y = 19.9, z = 0.0 }, level = 1 },
	{ config_id = 483, gadget_id = 70220001, pos = { x = 139.5, y = 0.5, z = 377.0 }, rot = { x = 0.0, y = 260.0, z = 0.0 }, level = 1 }
}

-- 区域
regions = {
}

-- 触发器
triggers = {
	{ name = "GADGET_STATE_CHANGE_135", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "condition_EVENT_GADGET_STATE_CHANGE_135", action = "action_EVENT_GADGET_STATE_CHANGE_135" },
	{ name = "GADGET_STATE_CHANGE_136", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "", trigger_count = 0, tag = "666" },
	{ name = "CHALLENGE_SUCCESS_137", event = EventType.EVENT_CHALLENGE_SUCCESS, source = "888", condition = "condition_EVENT_CHALLENGE_SUCCESS_137", action = "action_EVENT_CHALLENGE_SUCCESS_137" },
	{ name = "CHALLENGE_FAIL_138", event = EventType.EVENT_CHALLENGE_FAIL, source = "888", condition = "", action = "action_EVENT_CHALLENGE_FAIL_138", trigger_count = 0 }
}

-- 变量
variables = {
}

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

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

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

suites = {
	{
		-- suite_id = 1,
		-- description = ,
		monsters = { },
		gadgets = { 434, 472, 473, 474, 475, 476 },
		regions = { },
		triggers = { "GADGET_STATE_CHANGE_135" },
		rand_weight = 100
	},
	{
		-- suite_id = 2,
		-- description = suite_2,
		monsters = { },
		gadgets = { 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483 },
		regions = { },
		triggers = { "GADGET_STATE_CHANGE_136", "CHALLENGE_SUCCESS_137", "CHALLENGE_FAIL_138" },
		rand_weight = 100
	}
}

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

-- 触发条件
function condition_EVENT_GADGET_STATE_CHANGE_135(context, evt)
	if 434 ~= evt.param2 or GadgetState.GearStart ~= evt.param1 then
		return false
	end
	
	return true
end

-- 触发操作
function action_EVENT_GADGET_STATE_CHANGE_135(context, evt)
		-- 重新生成指定group，指定suite
		if 0 ~= ScriptLib.RefreshGroup(context, { group_id = 220000068, suite = 2 }) then
			return -1
		end
	
	-- 创建编号为888（该挑战的识别id),挑战内容为165的区域挑战，具体参数填写方式，见DungeonChallengeData表中的注释，所有填写的值都必须是int类型
	if 0 ~= ScriptLib.ActiveChallenge(context, 888, 165, 45, 7, 666, 4) then
		return -1
	end
	
	return 0
end

-- 触发条件

-- 触发操作

-- 触发条件
function condition_EVENT_CHALLENGE_SUCCESS_137(context, evt)
	-- 判断指定group组剩余gadget数量是否是45 
	if ScriptLib.CheckRemainGadgetCountByGroupId(context, {group_id = 220000068}) ~= 45 then
		return false
	end
	
	return true
end

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

-- 触发条件

-- 触发操作
function action_EVENT_CHALLENGE_FAIL_138(context, evt)
		-- 重新生成指定group，指定suite
		if 0 ~= ScriptLib.RefreshGroup(context, { group_id = 220000068, suite = 1 }) then
			return -1
		end
	
	return 0
end
