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

-- 怪物
monsters = {
	{ config_id = 21, monster_id = 21030301, pos = { x = 57.9, y = 0.5, z = -95.3 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 0 },
	{ config_id = 22, monster_id = 21010201, pos = { x = 61.1, y = 0.5, z = -92.0 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 0 },
	{ config_id = 23, monster_id = 21010201, pos = { x = 56.1, y = 0.5, z = -92.1 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 0 },
	{ config_id = 24, monster_id = 21010401, pos = { x = 55.5, y = 0.5, z = -95.7 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 0 },
	{ config_id = 25, monster_id = 21030101, pos = { x = 49.1, y = 0.5, z = -94.8 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 0 },
	{ config_id = 26, monster_id = 21010301, pos = { x = 51.1, y = 0.5, z = -91.8 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 0 },
	{ config_id = 27, monster_id = 21010301, pos = { x = 48.6, y = 0.5, z = -91.8 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 0 },
	{ config_id = 28, monster_id = 21010901, pos = { x = 45.9, y = 0.5, z = -94.3 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 0 },
	{ config_id = 29, monster_id = 21030201, pos = { x = 71.4, y = 0.5, z = -95.7 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 0 },
	{ config_id = 30, monster_id = 21010201, pos = { x = 73.4, y = 0.5, z = -92.1 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 0 },
	{ config_id = 31, monster_id = 21010201, pos = { x = 68.6, y = 0.5, z = -92.0 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 0 },
	{ config_id = 32, monster_id = 21010501, pos = { x = 68.1, y = 0.5, z = -95.6 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 0 },
	{ config_id = 33, monster_id = 21030301, pos = { x = 59.5, y = 0.5, z = -94.5 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 0 },
	{ config_id = 34, monster_id = 21010901, pos = { x = 72.1, y = 0.5, z = -94.1 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 0 },
	{ config_id = 35, monster_id = 21010301, pos = { x = 63.0, y = 0.5, z = -88.8 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 0 },
	{ config_id = 36, monster_id = 21010301, pos = { x = 54.2, y = 0.5, z = -89.2 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 0 }
}

-- NPC
npcs = {
}

-- 装置
gadgets = {
	{ config_id = 2, gadget_id = 70360002, pos = { x = 52.2, y = 0.5, z = -62.1 }, rot = { x = 0.0, y = 165.2, z = 0.0 }, level = 1 }
}

-- 区域
regions = {
	{ config_id = 7, shape = RegionShape.SPHERE, radius = 5, pos = { x = 51.6, y = 0.5, z = -62.9 } },
	{ config_id = 8, shape = RegionShape.SPHERE, radius = 5, pos = { x = 48.1, y = 0.5, z = -63.9 } },
	{ config_id = 9, shape = RegionShape.SPHERE, radius = 5, pos = { x = 50.5, y = 0.5, z = -65.5 } },
	{ config_id = 10, shape = RegionShape.SPHERE, radius = 5, pos = { x = 47.5, y = 0.5, z = -62.0 } },
	{ config_id = 11, shape = RegionShape.SPHERE, radius = 5, pos = { x = 53.0, y = 0.5, z = -64.2 } }
}

-- 触发器
triggers = {
	{ name = "GADGET_CREATE_7", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "condition_EVENT_GADGET_CREATE_7", action = "action_EVENT_GADGET_CREATE_7" },
	{ name = "SELECT_OPTION_8", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "condition_EVENT_SELECT_OPTION_8", action = "action_EVENT_SELECT_OPTION_8", trigger_count = 0 },
	{ name = "SELECT_OPTION_9", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "condition_EVENT_SELECT_OPTION_9", action = "action_EVENT_SELECT_OPTION_9", trigger_count = 0 },
	{ name = "SELECT_OPTION_10", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "condition_EVENT_SELECT_OPTION_10", action = "action_EVENT_SELECT_OPTION_10", trigger_count = 0 },
	{ name = "SELECT_OPTION_11", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "condition_EVENT_SELECT_OPTION_11", action = "action_EVENT_SELECT_OPTION_11", trigger_count = 0 }
}

-- 变量
variables = {
}

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

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

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

suites = {
	{
		-- suite_id = 0,
		-- description = ,
		monsters = { 21, 22, 23, 24 },
		gadgets = { 2 },
		regions = { 7, 8, 9, 10, 11 },
		triggers = { "GADGET_CREATE_7", "SELECT_OPTION_8", "SELECT_OPTION_9", "SELECT_OPTION_10", "SELECT_OPTION_11" },
		rand_weight = 100
	},
	{
		-- suite_id = 1,
		-- description = suite_2,
		monsters = { 25, 26, 27, 28 },
		gadgets = { 2 },
		regions = { 7, 8, 9, 10, 11 },
		triggers = { "GADGET_CREATE_7", "SELECT_OPTION_8", "SELECT_OPTION_9", "SELECT_OPTION_10", "SELECT_OPTION_11" },
		rand_weight = 0
	},
	{
		-- suite_id = 2,
		-- description = suite_3,
		monsters = { 29, 30, 31, 32 },
		gadgets = { 2 },
		regions = { 7, 8, 9, 10, 11 },
		triggers = { "GADGET_CREATE_7", "SELECT_OPTION_8", "SELECT_OPTION_9", "SELECT_OPTION_10", "SELECT_OPTION_11" },
		rand_weight = 0
	},
	{
		-- suite_id = 3,
		-- description = suite_4,
		monsters = { 33, 34, 35, 36 },
		gadgets = { 2 },
		regions = { 7, 8, 9, 10, 11 },
		triggers = { "GADGET_CREATE_7", "SELECT_OPTION_8", "SELECT_OPTION_9", "SELECT_OPTION_10", "SELECT_OPTION_11" },
		rand_weight = 0
	}
}

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

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

-- 触发操作
function action_EVENT_GADGET_CREATE_7(context, evt)
	-- 设置操作台选项
	if 0 ~= ScriptLib.SetWorktopOptions(context, {135,136,137,138}) then
		return -1
	end
	
	return 0
end

-- 触发条件
function condition_EVENT_SELECT_OPTION_8(context, evt)
	-- 判断是gadgetid 2
	if 2 ~= evt.param1 then
			return false
		end
	
	return true
end

-- 触发操作
function action_EVENT_SELECT_OPTION_8(context, evt)
	
	-- 根据不同的选项做不同的操作
	if 135 == evt.param2 then
	
		-- 重新生成指定group，指定suite
		if 0 ~= ScriptLib.RefreshGroup(context, { group_id = 201011002, suite = 1 }) then
			return -1
		end
	
		if 0 ~= ScriptLib.SetGadgetStateByConfigId(context, 2, GadgetState.GearStart) then
			return -1
		end 
		return 0
	end
	
	return 0
end

-- 触发条件
function condition_EVENT_SELECT_OPTION_9(context, evt)
	-- 判断是gadgetid 2
	if 2 ~= evt.param1 then
			return false
		end
	
	return true
end

-- 触发操作
function action_EVENT_SELECT_OPTION_9(context, evt)
	
	-- 根据不同的选项做不同的操作
	if 136 == evt.param2 then
	
		-- 重新生成指定group，指定suite
		if 0 ~= ScriptLib.RefreshGroup(context, { group_id = 201011002, suite = 2 }) then
			return -1
		end
	
		if 0 ~= ScriptLib.SetGadgetStateByConfigId(context, 2, GadgetState.GearStart) then
			return -1
		end 
		return 0
	end
	
	return 0
end

-- 触发条件
function condition_EVENT_SELECT_OPTION_10(context, evt)
	-- 判断是gadgetid 2
	if 2 ~= evt.param1 then
			return false
		end
	
	return true
end

-- 触发操作
function action_EVENT_SELECT_OPTION_10(context, evt)
	
	-- 根据不同的选项做不同的操作
	if 137 == evt.param2 then
	
		-- 重新生成指定group，指定suite
		if 0 ~= ScriptLib.RefreshGroup(context, { group_id = 201011002, suite = 3 }) then
			return -1
		end
	
		if 0 ~= ScriptLib.SetGadgetStateByConfigId(context, 2, GadgetState.GearStart) then
			return -1
		end 
		return 0
	end
	
	return 0
end

-- 触发条件
function condition_EVENT_SELECT_OPTION_11(context, evt)
	-- 判断是gadgetid 2
	if 2 ~= evt.param1 then
			return false
		end
	
	return true
end

-- 触发操作
function action_EVENT_SELECT_OPTION_11(context, evt)
	
	-- 根据不同的选项做不同的操作
	if 138 == evt.param2 then
	
		-- 重新生成指定group，指定suite
		if 0 ~= ScriptLib.RefreshGroup(context, { group_id = 201011002, suite = 4 }) then
			return -1
		end
	
		if 0 ~= ScriptLib.SetGadgetStateByConfigId(context, 2, GadgetState.GearStart) then
			return -1
		end 
		return 0
	end
	
	return 0
end
