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

-- 怪物
monsters = {
}

-- NPC
npcs = {
}

-- 装置
gadgets = {
	{ config_id = 42, gadget_id = 70380001, pos = { x = 380.4, y = -41.2, z = 25.0 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1, route_id = 20010009, start_route = false },
	{ config_id = 43, gadget_id = 70350004, pos = { x = 380.5, y = -34.5, z = 15.7 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 44, gadget_id = 70350004, pos = { x = 388.8, y = -34.6, z = 3.4 }, rot = { x = 0.0, y = 90.0, z = 0.0 }, level = 1 },
	{ config_id = 46, gadget_id = 70360016, pos = { x = 388.4, y = -31.9, z = 28.1 }, rot = { x = 0.0, y = 0.0, z = 90.0 }, level = 1 },
	{ config_id = 47, gadget_id = 70360016, pos = { x = 388.7, y = -32.0, z = 25.2 }, rot = { x = 0.0, y = 0.0, z = 90.0 }, level = 1 },
	{ config_id = 48, gadget_id = 70360019, pos = { x = 386.8, y = -31.1, z = 15.6 }, rot = { x = 90.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 50, gadget_id = 70360016, pos = { x = 387.0, y = -27.5, z = 0.4 }, rot = { x = 86.5, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 51, gadget_id = 70360016, pos = { x = 384.7, y = -27.5, z = 0.3 }, rot = { x = 90.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 53, gadget_id = 70360019, pos = { x = 389.5, y = -27.1, z = 1.7 }, rot = { x = 90.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 54, gadget_id = 70900023, pos = { x = 379.2, y = -42.2, z = 26.4 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 84, gadget_id = 70360016, pos = { x = 377.3, y = -32.4, z = 7.2 }, rot = { x = 0.0, y = 180.0, z = 90.0 }, level = 1 },
	{ config_id = 85, gadget_id = 70360016, pos = { x = 375.8, y = -29.8, z = 5.6 }, rot = { x = 0.0, y = 180.0, z = 90.0 }, level = 1 },
	{ config_id = 89, gadget_id = 70360016, pos = { x = 388.3, y = -32.0, z = 21.5 }, rot = { x = 270.0, y = 90.0, z = 0.0 }, level = 1 },
	{ config_id = 91, gadget_id = 70360016, pos = { x = 376.8, y = -32.2, z = 7.4 }, rot = { x = 0.0, y = 270.0, z = 90.0 }, level = 1 },
	{ config_id = 92, gadget_id = 70360016, pos = { x = 388.7, y = -32.5, z = 18.2 }, rot = { x = 0.0, y = 0.0, z = 90.0 }, level = 1 },
	{ config_id = 95, gadget_id = 70360019, pos = { x = 388.6, y = -27.8, z = 3.4 }, rot = { x = 90.0, y = 270.0, z = 0.0 }, level = 1 },
	{ config_id = 96, gadget_id = 70900023, pos = { x = 389.0, y = -42.2, z = 26.4 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 97, gadget_id = 70900023, pos = { x = 384.1, y = -42.2, z = 26.4 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 98, gadget_id = 70900023, pos = { x = 379.2, y = -42.2, z = 21.4 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 99, gadget_id = 70900023, pos = { x = 384.1, y = -42.2, z = 21.5 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 100, gadget_id = 70900023, pos = { x = 389.1, y = -42.2, z = 21.4 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 101, gadget_id = 70900023, pos = { x = 388.1, y = -42.2, z = 16.5 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 102, gadget_id = 70900023, pos = { x = 381.3, y = -42.2, z = 16.5 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 103, gadget_id = 70900023, pos = { x = 381.3, y = -42.2, z = 11.5 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 104, gadget_id = 70900023, pos = { x = 381.3, y = -42.2, z = 6.6 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 105, gadget_id = 70900023, pos = { x = 381.3, y = -42.2, z = 1.6 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 106, gadget_id = 70900023, pos = { x = 386.3, y = -42.2, z = 1.4 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 107, gadget_id = 70900023, pos = { x = 391.4, y = -42.2, z = 1.4 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 108, gadget_id = 70900023, pos = { x = 396.3, y = -42.2, z = 1.4 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 109, gadget_id = 70900023, pos = { x = 396.0, y = -42.2, z = 6.4 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 110, gadget_id = 70900023, pos = { x = 391.2, y = -42.2, z = 6.4 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 111, gadget_id = 70900023, pos = { x = 386.3, y = -42.2, z = 6.4 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 112, gadget_id = 70900023, pos = { x = 386.2, y = -42.2, z = 11.3 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 113, gadget_id = 70900023, pos = { x = 378.5, y = -42.2, z = 1.7 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 114, gadget_id = 70900023, pos = { x = 378.5, y = -42.2, z = 6.6 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 115, gadget_id = 70900023, pos = { x = 378.6, y = -42.2, z = 11.5 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 116, gadget_id = 70900023, pos = { x = 378.6, y = -42.2, z = 16.5 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 190, gadget_id = 70900202, pos = { x = 387.5, y = -27.3, z = 3.5 }, rot = { x = 0.0, y = 90.1, z = 0.0 }, level = 1 },
	{ config_id = 6001, gadget_id = 70360016, pos = { x = 376.5, y = -32.6, z = 3.9 }, rot = { x = 0.0, y = 180.0, z = 90.0 }, level = 1 },
	{ config_id = 6002, gadget_id = 70360016, pos = { x = 377.5, y = -32.2, z = 1.0 }, rot = { x = 0.0, y = 180.0, z = 90.0 }, level = 1 },
	{ config_id = 6003, gadget_id = 70360016, pos = { x = 377.5, y = -28.8, z = 1.0 }, rot = { x = 0.0, y = 180.0, z = 90.0 }, level = 1 },
	{ config_id = 6004, gadget_id = 70360016, pos = { x = 381.2, y = -27.8, z = 0.3 }, rot = { x = 90.0, y = 0.0, z = 0.0 }, level = 1 },
	{ config_id = 6005, gadget_id = 70380001, pos = { x = 380.4, y = -40.9, z = 18.7 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1, route_id = 20010018, start_route = false },
	{ config_id = 6012, gadget_id = 70380001, pos = { x = 393.5, y = -35.6, z = 3.3 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, level = 1, route_id = 20010019, start_route = false }
}

-- 区域
regions = {
	{ config_id = 11, shape = RegionShape.CUBIC, size = { x = 5.0, y = 5.0, z = 5.0 }, pos = { x = 380.3, y = -33.9, z = 25.8 } }
}

-- 触发器
triggers = {
	{ name = "GADGET_STATE_CHANGE_9", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "condition_EVENT_GADGET_STATE_CHANGE_9", action = "action_EVENT_GADGET_STATE_CHANGE_9" },
	{ name = "GADGET_STATE_CHANGE_10", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "condition_EVENT_GADGET_STATE_CHANGE_10", action = "action_EVENT_GADGET_STATE_CHANGE_10" },
	{ name = "ENTER_REGION_11", event = EventType.EVENT_ENTER_REGION, source = "", condition = "condition_EVENT_ENTER_REGION_11", action = "action_EVENT_ENTER_REGION_11", forbid_guest = false },
	{ name = "CLIENT_EXECUTE_49", event = EventType.EVENT_CLIENT_EXECUTE, source = "ElectricSwitch_Hit", condition = "condition_EVENT_CLIENT_EXECUTE_49", action = "action_EVENT_CLIENT_EXECUTE_49" }
}

-- 变量
variables = {
}

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

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

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

suites = {
	{
		-- suite_id = 1,
		-- description = ,
		monsters = { },
		gadgets = { 42, 43, 44, 46, 47, 48, 50, 51, 53, 54, 84, 85, 89, 91, 92, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 6001, 6002, 6003, 6004, 6005, 6012 },
		regions = { 11 },
		triggers = { "GADGET_STATE_CHANGE_9", "GADGET_STATE_CHANGE_10", "ENTER_REGION_11", "CLIENT_EXECUTE_49" },
		rand_weight = 100
	}
}

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

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

-- 触发操作
function action_EVENT_GADGET_STATE_CHANGE_9(context, evt)
	-- 将configid为 43 的物件更改为状态 GadgetState.GearStart
	if 0 ~= ScriptLib.SetGadgetStateByConfigId(context, 43, GadgetState.GearStart) then
			return -1
		end 
	
		-- 杀死Group内指定的monster和gadget
		if 0 ~= ScriptLib.KillGroupEntity(context, { group_id = 220010005, monsters = {}, gadgets = {189} }) then
			return -1
		end
	
	-- 创建id为190的gadget
	if 0 ~= ScriptLib.CreateGadget(context, { config_id = 190 }) then
	  return -1
	end
	
	-- 启动移动平台
	if 0 ~= ScriptLib.StartPlatform(context, 42) then
	  return -1
	end
	
	-- 启动移动平台
	if 0 ~= ScriptLib.StartPlatform(context, 6005) then
	  return -1
	end
	
	return 0
end

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

-- 触发操作
function action_EVENT_GADGET_STATE_CHANGE_10(context, evt)
	-- 将configid为 44 的物件更改为状态 GadgetState.GearStart
	if 0 ~= ScriptLib.SetGadgetStateByConfigId(context, 44, GadgetState.GearStart) then
			return -1
		end 
	
		-- 杀死Group内指定的monster和gadget
		if 0 ~= ScriptLib.KillGroupEntity(context, { group_id = 220010006, monsters = {}, gadgets = {190} }) then
			return -1
		end
	
	-- 创建id为0的gadget
	if 0 ~= ScriptLib.CreateGadget(context, { config_id = 0 }) then
	  return -1
	end
	
	return 0
end

-- 触发条件
function condition_EVENT_ENTER_REGION_11(context, evt)
	if evt.param1 ~= 11 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_11(context, evt)
	-- 启动移动平台
	if 0 ~= ScriptLib.StartPlatform(context, 42) then
	  return -1
	end
	
	return 0
end

-- 触发条件
function condition_EVENT_CLIENT_EXECUTE_49(context, evt)
	if 95 == ScriptLib.GetGadgetConfigId(context, { gadget_eid = evt.source_eid }) then
	
	return true
	
	end
end

-- 触发操作
function action_EVENT_CLIENT_EXECUTE_49(context, evt)
	-- 将configid为 44 的物件更改为状态 GadgetState.GearStart
	if 0 ~= ScriptLib.SetGadgetStateByConfigId(context, 44, GadgetState.GearStart) then
			return -1
		end 
	
	return 0
end
