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

-- 怪物
monsters = {
	{ config_id = 1001, monster_id = 20011201, pos = { x = 340.8, y = -29.0, z = 431.6 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 1002, monster_id = 20011201, pos = { x = 345.8, y = -29.0, z = 431.7 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 1003, monster_id = 20011301, pos = { x = 343.4, y = -29.0, z = 434.7 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 1004, monster_id = 21010401, pos = { x = 345.5, y = -28.9, z = 425.8 }, rot = { x = 0.0, y = 271.1, z = 0.0 }, level = 1, pose_id = 402 },
	{ config_id = 1005, monster_id = 21010301, pos = { x = 340.7, y = -29.0, z = 426.2 }, rot = { x = 0.0, y = 27.3, z = 0.0 }, level = 1, pose_id = 9003 }
}

-- NPC
npcs = {
}

-- 装置
gadgets = {
	{ config_id = 1006, gadget_id = 70360002, pos = { x = 343.3, y = -28.9, z = 430.9 }, rot = { x = 0.0, y = 0.5, z = 0.0 }, level = 1 },
	{ config_id = 1009, gadget_id = 70220010, pos = { x = 348.4, y = -28.8, z = 425.6 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 1010, gadget_id = 70220010, pos = { x = 338.3, y = -28.8, z = 425.6 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 1011, gadget_id = 70350003, pos = { x = 353.2, y = -27.7, z = 404.7 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 1012, gadget_id = 70350003, pos = { x = 343.2, y = -28.0, z = 404.5 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 1013, gadget_id = 70350003, pos = { x = 333.2, y = -27.7, z = 404.7 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 1017, gadget_id = 70220013, pos = { x = 349.5, y = -27.8, z = 470.6 }, rot = { x = 0.0, y = 325.7, z = 0.0 }, level = 1 },
	{ config_id = 1018, gadget_id = 70220013, pos = { x = 348.1, y = -27.8, z = 468.1 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 1019, gadget_id = 70220014, pos = { x = 349.9, y = -27.8, z = 467.7 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 1020, gadget_id = 70220014, pos = { x = 350.5, y = -27.8, z = 469.0 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 1021, gadget_id = 70220025, pos = { x = 340.8, y = -28.8, z = 426.0 }, rot = { x = 271.2, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 1022, gadget_id = 70310004, pos = { x = 343.4, y = -28.9, z = 426.0 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1, state = GadgetState.GearStart },
	{ config_id = 1023, gadget_id = 70220013, pos = { x = 353.5, y = -29.0, z = 441.5 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 1024, gadget_id = 70220013, pos = { x = 354.7, y = -29.0, z = 439.2 }, rot = { x = 0.0, y = 324.4, z = 0.0 }, level = 1 },
	{ config_id = 1025, gadget_id = 70220014, pos = { x = 352.6, y = -29.0, z = 439.9 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 1026, gadget_id = 70220014, pos = { x = 351.7, y = -29.0, z = 441.5 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 1027, gadget_id = 70220016, pos = { x = 356.2, y = -28.1, z = 437.6 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 1028, gadget_id = 70220025, pos = { x = 353.6, y = -28.9, z = 439.6 }, rot = { x = 270.0, y = 180.0, z = 0.0 }, level = 1 },
	{ config_id = 1029, gadget_id = 70220013, pos = { x = 331.3, y = -29.0, z = 421.0 }, rot = { x = 0.0, y = 40.1, z = 0.0 }, level = 1 },
	{ config_id = 1030, gadget_id = 70220014, pos = { x = 330.2, y = -29.0, z = 423.0 }, rot = { x = 0.0, y = 22.7, z = 0.0 }, level = 1 },
	{ config_id = 1031, gadget_id = 70211011, pos = { x = 343.4, y = -29.0, z = 420.7 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1, drop_tag = "战斗中级蒙德", persistent = true, type = GadgetType.GADGET_DUNGEON_SECRET_CHEST },
	{ config_id = 1032, gadget_id = 70211001, pos = { x = 356.1, y = -28.7, z = 440.6 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1, drop_tag = "战斗低级蒙德", isOneoff = true, persistent = true, type = GadgetType.GADGET_DUNGEON_SECRET_CHEST }
}

-- 区域
regions = {
	{ config_id = 1007, shape = RegionShape.CUBIC, size = { x = 10.0, y = 10.0, z = 4.0 }, pos = { x = 343.5, y = -27.8, z = 444.3 } }
}

-- 触发器
triggers = {
	{ name = "ENTER_REGION_1007", event = EventType.EVENT_ENTER_REGION, source = "", condition = "condition_EVENT_ENTER_REGION_1007", action = "action_EVENT_ENTER_REGION_1007" },
	{ name = "SELECT_OPTION_1008", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "condition_EVENT_SELECT_OPTION_1008", action = "action_EVENT_SELECT_OPTION_1008" },
	{ name = "ANY_MONSTER_DIE_1014", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "condition_EVENT_ANY_MONSTER_DIE_1014", action = "action_EVENT_ANY_MONSTER_DIE_1014" },
	{ name = "SELECT_OPTION_1015", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "condition_EVENT_SELECT_OPTION_1015", action = "action_EVENT_SELECT_OPTION_1015" },
	{ name = "SELECT_OPTION_1016", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "condition_EVENT_SELECT_OPTION_1016", action = "action_EVENT_SELECT_OPTION_1016" }
}

-- 变量
variables = {
}

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

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

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

suites = {
	{
		-- suite_id = 1,
		-- description = ,
		monsters = { 1004, 1005 },
		gadgets = { 1006, 1009, 1010, 1011, 1012, 1013, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1032 },
		regions = { 1007 },
		triggers = { "ENTER_REGION_1007", "SELECT_OPTION_1008", "ANY_MONSTER_DIE_1014", "SELECT_OPTION_1015", "SELECT_OPTION_1016" },
		rand_weight = 100
	},
	{
		-- suite_id = 2,
		-- description = suite_2,
		monsters = { },
		gadgets = { 1031 },
		regions = { },
		triggers = { },
		rand_weight = 100
	},
	{
		-- suite_id = 3,
		-- description = suite_3,
		monsters = { 1001, 1002, 1003 },
		gadgets = { },
		regions = { },
		triggers = { },
		rand_weight = 100
	}
}

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

-- 触发条件
function condition_EVENT_ENTER_REGION_1007(context, evt)
	if evt.param1 ~= 1007 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_1007(context, evt)
	-- 将configid为 1006 的物件更改为状态 GadgetState.GearStop
	if 0 ~= ScriptLib.SetGadgetStateByConfigId(context, 1006, GadgetState.GearStop) then
			return -1
		end 
	
	-- 添加suite3的新内容
	    ScriptLib.AddExtraGroupSuite(context, 240008001, 3)
	
	return 0
end

-- 触发条件
function condition_EVENT_SELECT_OPTION_1008(context, evt)
	-- 判断是gadgetid 1006 option_id 178
	if 1006 ~= evt.param1 then
		return false	
	end
	
	if 178 ~= evt.param2 then
		return false
	end
	
	
	return true
end

-- 触发操作
function action_EVENT_SELECT_OPTION_1008(context, evt)
	-- 将configid为 1006 的物件更改为状态 GadgetState.GearStart
	if 0 ~= ScriptLib.SetGadgetStateByConfigId(context, 1006, GadgetState.GearStart) then
			return -1
		end 
	
	-- 将configid为 1011 的物件更改为状态 GadgetState.GearStart
	if 0 ~= ScriptLib.SetGadgetStateByConfigId(context, 1011, GadgetState.GearStart) then
			return -1
		end 
	
	-- 添加suite2的新内容
	    ScriptLib.AddExtraGroupSuite(context, 240008002, 2)
	
	-- 删除指定group： 240008001 ；指定config：1006；物件身上指定option：178；
	if 0 ~= ScriptLib.DelWorktopOptionByGroupId(context, 240008001, 1006, 178) then
		return -1
	end
	
	-- 删除指定group： 240008001 ；指定config：1006；物件身上指定option：179；
	if 0 ~= ScriptLib.DelWorktopOptionByGroupId(context, 240008001, 1006, 179) then
		return -1
	end
	
	-- 删除指定group： 240008001 ；指定config：1006；物件身上指定option：180；
	if 0 ~= ScriptLib.DelWorktopOptionByGroupId(context, 240008001, 1006, 180) then
		return -1
	end
	
	-- 触发镜头注目，注目位置为坐标（353，-27，404），持续时间为2秒，并且为强制注目形式，不广播其他玩家
		local pos = {x=353, y=-27, z=404}
	    if 0 ~= ScriptLib.BeginCameraSceneLook(context, { look_pos = pos, duration = 2, is_force = true, is_broadcast = false, is_recover_keep_current = true, delay = 0 }) then
					return -1
				end 
	
	return 0
end

-- 触发条件
function condition_EVENT_ANY_MONSTER_DIE_1014(context, evt)
	-- 判断剩余怪物数量是否是0
	if ScriptLib.GetGroupMonsterCount(context) ~= 0 then
		return false
	end
	
	return true
end

-- 触发操作
function action_EVENT_ANY_MONSTER_DIE_1014(context, evt)
	-- 设置操作台选项
	if 0 ~= ScriptLib.SetWorktopOptionsByGroupId(context, 240008001, 1006, {178,179,180}) then
		return -1
	end
	
	-- 将configid为 1006 的物件更改为状态 GadgetState.Default
	if 0 ~= ScriptLib.SetGadgetStateByConfigId(context, 1006, GadgetState.Default) then
			return -1
		end 
	
	-- 添加suite2的新内容
	    ScriptLib.AddExtraGroupSuite(context, 240008001, 2)
	
	return 0
end

-- 触发条件
function condition_EVENT_SELECT_OPTION_1015(context, evt)
	-- 判断是gadgetid 1006 option_id 179
	if 1006 ~= evt.param1 then
		return false	
	end
	
	if 179 ~= evt.param2 then
		return false
	end
	
	
	return true
end

-- 触发操作
function action_EVENT_SELECT_OPTION_1015(context, evt)
	-- 将configid为 1006 的物件更改为状态 GadgetState.GearStart
	if 0 ~= ScriptLib.SetGadgetStateByConfigId(context, 1006, GadgetState.GearStart) then
			return -1
		end 
	
	-- 将configid为 1012 的物件更改为状态 GadgetState.GearStart
	if 0 ~= ScriptLib.SetGadgetStateByConfigId(context, 1012, GadgetState.GearStart) then
			return -1
		end 
	
	-- 添加suite3的新内容
	    ScriptLib.AddExtraGroupSuite(context, 240008002, 3)
	
	-- 删除指定group： 240008001 ；指定config：1006；物件身上指定option：178；
	if 0 ~= ScriptLib.DelWorktopOptionByGroupId(context, 240008001, 1006, 178) then
		return -1
	end
	
	-- 删除指定group： 240008001 ；指定config：1006；物件身上指定option：179；
	if 0 ~= ScriptLib.DelWorktopOptionByGroupId(context, 240008001, 1006, 179) then
		return -1
	end
	
	-- 删除指定group： 240008001 ；指定config：1006；物件身上指定option：180；
	if 0 ~= ScriptLib.DelWorktopOptionByGroupId(context, 240008001, 1006, 180) then
		return -1
	end
	
	-- 触发镜头注目，注目位置为坐标（343，-28，404），持续时间为2秒，并且为强制注目形式，不广播其他玩家
		local pos = {x=343, y=-28, z=404}
	    if 0 ~= ScriptLib.BeginCameraSceneLook(context, { look_pos = pos, duration = 2, is_force = true, is_broadcast = false, is_recover_keep_current = true, delay = 0 }) then
					return -1
				end 
	
	return 0
end

-- 触发条件
function condition_EVENT_SELECT_OPTION_1016(context, evt)
	-- 判断是gadgetid 1006 option_id 180
	if 1006 ~= evt.param1 then
		return false	
	end
	
	if 180 ~= evt.param2 then
		return false
	end
	
	
	return true
end

-- 触发操作
function action_EVENT_SELECT_OPTION_1016(context, evt)
	-- 将configid为 1006 的物件更改为状态 GadgetState.GearStart
	if 0 ~= ScriptLib.SetGadgetStateByConfigId(context, 1006, GadgetState.GearStart) then
			return -1
		end 
	
	-- 将configid为 1013 的物件更改为状态 GadgetState.GearStart
	if 0 ~= ScriptLib.SetGadgetStateByConfigId(context, 1013, GadgetState.GearStart) then
			return -1
		end 
	
	-- 添加suite4的新内容
	    ScriptLib.AddExtraGroupSuite(context, 240008002, 4)
	
	-- 删除指定group： 240008001 ；指定config：1006；物件身上指定option：178；
	if 0 ~= ScriptLib.DelWorktopOptionByGroupId(context, 240008001, 1006, 178) then
		return -1
	end
	
	-- 删除指定group： 240008001 ；指定config：1006；物件身上指定option：179；
	if 0 ~= ScriptLib.DelWorktopOptionByGroupId(context, 240008001, 1006, 179) then
		return -1
	end
	
	-- 删除指定group： 240008001 ；指定config：1006；物件身上指定option：180；
	if 0 ~= ScriptLib.DelWorktopOptionByGroupId(context, 240008001, 1006, 180) then
		return -1
	end
	
	-- 触发镜头注目，注目位置为坐标（333，-28，404），持续时间为2秒，并且为强制注目形式，不广播其他玩家
		local pos = {x=333, y=-28, z=404}
	    if 0 ~= ScriptLib.BeginCameraSceneLook(context, { look_pos = pos, duration = 2, is_force = true, is_broadcast = false, is_recover_keep_current = true, delay = 0 }) then
					return -1
				end 
	
	return 0
end
