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

-- 怪物
monsters = {
	{ config_id = 49, monster_id = 20011301, pos = { x = 190.5, y = 42.1, z = 120.9 }, rot = { x = 0.0, y = 270.4, z = 0.0 }, level = 2, disableWander = true },
	{ config_id = 96, monster_id = 20011201, pos = { x = 148.9, y = 39.5, z = 125.6 }, rot = { x = 0.0, y = 259.1, z = 0.0 }, level = 1 },
	{ config_id = 97, monster_id = 20011201, pos = { x = 151.6, y = 39.5, z = 121.1 }, rot = { x = 0.0, y = 268.5, z = 0.0 }, level = 1 },
	{ config_id = 98, monster_id = 20011201, pos = { x = 147.7, y = 39.6, z = 116.1 }, rot = { x = 0.0, y = 312.6, z = 0.0 }, level = 1 }
}

-- NPC
npcs = {
}

-- 装置
gadgets = {
	{ config_id = 85, gadget_id = 70220002, pos = { x = 190.1, y = 42.1, z = 122.4 }, rot = { x = 0.0, y = 157.9, z = 0.0 }, level = 1 },
	{ config_id = 86, gadget_id = 70220002, pos = { x = 190.8, y = 42.0, z = 124.3 }, rot = { x = 0.0, y = 46.2, z = 0.0 }, level = 1 },
	{ config_id = 87, gadget_id = 70220002, pos = { x = 191.8, y = 42.1, z = 122.4 }, rot = { x = 0.0, y = 301.0, z = 0.0 }, level = 1 },
	{ config_id = 88, gadget_id = 70220002, pos = { x = 189.8, y = 42.0, z = 124.0 }, rot = { x = 0.0, y = 14.5, z = 0.0 }, level = 1 },
	{ config_id = 89, gadget_id = 70220002, pos = { x = 189.8, y = 42.1, z = 125.8 }, rot = { x = 0.0, y = 97.9, z = 0.0 }, level = 1 },
	{ config_id = 90, gadget_id = 70220002, pos = { x = 189.8, y = 42.0, z = 127.3 }, rot = { x = 0.0, y = 147.8, z = 0.0 }, level = 1 },
	{ config_id = 91, gadget_id = 70220002, pos = { x = 191.0, y = 42.1, z = 126.1 }, rot = { x = 0.0, y = 170.0, z = 0.0 }, level = 1 },
	{ config_id = 92, gadget_id = 70220002, pos = { x = 190.3, y = 42.0, z = 119.4 }, rot = { x = 0.0, y = 20.2, z = 0.0 }, level = 1 },
	{ config_id = 93, gadget_id = 70220002, pos = { x = 189.2, y = 42.0, z = 119.4 }, rot = { x = 0.0, y = 75.0, z = 0.0 }, level = 1 },
	{ config_id = 94, gadget_id = 70220002, pos = { x = 189.0, y = 42.1, z = 120.3 }, rot = { x = 0.0, y = 168.1, z = 0.0 }, level = 1 },
	{ config_id = 95, gadget_id = 70220002, pos = { x = 189.8, y = 42.0, z = 117.5 }, rot = { x = 0.0, y = 217.7, z = 0.0 }, level = 1 },
	{ config_id = 96, gadget_id = 70220002, pos = { x = 189.8, y = 42.1, z = 116.1 }, rot = { x = 0.0, y = 219.8, z = 0.0 }, level = 1 },
	{ config_id = 97, gadget_id = 70220002, pos = { x = 190.1, y = 42.0, z = 114.7 }, rot = { x = 0.0, y = 239.6, z = 0.0 }, level = 1 },
	{ config_id = 98, gadget_id = 70220002, pos = { x = 190.3, y = 42.0, z = 116.8 }, rot = { x = 0.0, y = 309.4, z = 0.0 }, level = 1 },
	{ config_id = 99, gadget_id = 70220002, pos = { x = 191.9, y = 42.1, z = 120.4 }, rot = { x = 0.0, y = 84.2, z = 0.0 }, level = 1 },
	{ config_id = 100, gadget_id = 70220002, pos = { x = 193.4, y = 42.0, z = 119.7 }, rot = { x = 0.0, y = 265.7, z = 0.0 }, level = 1 },
	{ config_id = 101, gadget_id = 70220002, pos = { x = 194.5, y = 42.0, z = 120.1 }, rot = { x = 0.0, y = 46.3, z = 0.0 }, level = 1 },
	{ config_id = 102, gadget_id = 70220002, pos = { x = 195.5, y = 42.1, z = 121.2 }, rot = { x = 0.0, y = 121.7, z = 0.0 }, level = 1 },
	{ config_id = 103, gadget_id = 70220002, pos = { x = 196.4, y = 42.0, z = 119.9 }, rot = { x = 0.0, y = 240.7, z = 0.0 }, level = 1 },
	{ config_id = 104, gadget_id = 70220002, pos = { x = 197.3, y = 42.0, z = 120.6 }, rot = { x = 0.0, y = 102.1, z = 0.0 }, level = 1 },
	{ config_id = 105, gadget_id = 70220002, pos = { x = 188.2, y = 42.0, z = 121.0 }, rot = { x = 0.0, y = 272.8, z = 0.0 }, level = 1 },
	{ config_id = 106, gadget_id = 70220002, pos = { x = 186.6, y = 42.0, z = 120.9 }, rot = { x = 0.0, y = 2.0, z = 0.0 }, level = 1 },
	{ config_id = 107, gadget_id = 70220002, pos = { x = 185.2, y = 42.0, z = 120.6 }, rot = { x = 0.0, y = 335.0, z = 0.0 }, level = 1 },
	{ config_id = 108, gadget_id = 70220002, pos = { x = 185.2, y = 42.1, z = 121.7 }, rot = { x = 0.0, y = 72.9, z = 0.0 }, level = 1 },
	{ config_id = 109, gadget_id = 70220002, pos = { x = 183.8, y = 42.0, z = 120.8 }, rot = { x = 0.0, y = 143.3, z = 0.0 }, level = 1 },
	{ config_id = 110, gadget_id = 70220002, pos = { x = 182.6, y = 42.0, z = 121.3 }, rot = { x = 0.0, y = 101.3, z = 0.0 }, level = 1 },
	{ config_id = 111, gadget_id = 70220002, pos = { x = 198.7, y = 42.0, z = 120.5 }, rot = { x = 0.0, y = 57.0, z = 0.0 }, level = 1 },
	{ config_id = 112, gadget_id = 70220002, pos = { x = 198.2, y = 42.0, z = 121.8 }, rot = { x = 0.0, y = 121.2, z = 0.0 }, level = 1 },
	{ config_id = 113, gadget_id = 70220002, pos = { x = 190.1, y = 42.0, z = 113.6 }, rot = { x = 0.0, y = 350.1, z = 0.0 }, level = 1 },
	{ config_id = 114, gadget_id = 70220002, pos = { x = 191.2, y = 42.0, z = 113.1 }, rot = { x = 0.0, y = 63.6, z = 0.0 }, level = 1 },
	{ config_id = 115, gadget_id = 70220002, pos = { x = 190.6, y = 42.0, z = 112.0 }, rot = { x = 0.0, y = 303.1, z = 0.0 }, level = 1 },
	{ config_id = 116, gadget_id = 70220002, pos = { x = 191.1, y = 42.1, z = 115.8 }, rot = { x = 0.0, y = 0.9, z = 0.0 }, level = 1 },
	{ config_id = 117, gadget_id = 70220002, pos = { x = 190.4, y = 42.0, z = 128.6 }, rot = { x = 0.0, y = 45.4, z = 0.0 }, level = 1 },
	{ config_id = 118, gadget_id = 70220002, pos = { x = 191.0, y = 42.0, z = 130.1 }, rot = { x = 0.0, y = 348.0, z = 0.0 }, level = 1 },
	{ config_id = 119, gadget_id = 70220002, pos = { x = 199.9, y = 42.0, z = 122.0 }, rot = { x = 0.0, y = 40.8, z = 0.0 }, level = 1 },
	{ config_id = 120, gadget_id = 70220002, pos = { x = 201.7, y = 42.0, z = 122.1 }, rot = { x = 0.0, y = 105.9, z = 0.0 }, level = 1 },
	{ config_id = 121, gadget_id = 70220002, pos = { x = 190.8, y = 42.0, z = 110.6 }, rot = { x = 0.0, y = 39.6, z = 0.0 }, level = 1 },
	{ config_id = 122, gadget_id = 70220002, pos = { x = 181.2, y = 42.0, z = 121.2 }, rot = { x = 0.0, y = 218.5, z = 0.0 }, level = 1 },
	{ config_id = 123, gadget_id = 70220002, pos = { x = 193.8, y = 42.0, z = 122.8 }, rot = { x = 0.0, y = 149.5, z = 0.0 }, level = 1 },
	{ config_id = 124, gadget_id = 70220002, pos = { x = 192.5, y = 42.0, z = 124.3 }, rot = { x = 0.0, y = 239.7, z = 0.0 }, level = 1 },
	{ config_id = 125, gadget_id = 70220002, pos = { x = 188.0, y = 42.0, z = 123.6 }, rot = { x = 0.0, y = 88.3, z = 0.0 }, level = 1 },
	{ config_id = 126, gadget_id = 70220002, pos = { x = 187.4, y = 42.0, z = 122.6 }, rot = { x = 0.0, y = 205.5, z = 0.0 }, level = 1 },
	{ config_id = 127, gadget_id = 70220002, pos = { x = 187.3, y = 42.0, z = 119.4 }, rot = { x = 0.0, y = 316.8, z = 0.0 }, level = 1 },
	{ config_id = 128, gadget_id = 70220002, pos = { x = 187.8, y = 42.0, z = 117.7 }, rot = { x = 0.0, y = 300.8, z = 0.0 }, level = 1 },
	{ config_id = 129, gadget_id = 70220002, pos = { x = 192.2, y = 42.0, z = 117.3 }, rot = { x = 0.0, y = 15.6, z = 0.0 }, level = 1 },
	{ config_id = 130, gadget_id = 70220002, pos = { x = 193.3, y = 42.0, z = 118.3 }, rot = { x = 0.0, y = 93.1, z = 0.0 }, level = 1 },
	{ config_id = 166, gadget_id = 70350002, pos = { x = 173.9, y = 41.9, z = 120.9 }, rot = { x = 0.0, y = 270.0, z = 0.0 }, level = 1, state = GadgetState.GearStart },
	{ config_id = 167, gadget_id = 70350002, pos = { x = 190.5, y = 42.0, z = 137.6 }, rot = { x = 0.0, y = 180.0, z = 0.0 }, level = 1, state = GadgetState.GearStart },
	{ config_id = 168, gadget_id = 70360002, pos = { x = 170.5, y = 42.0, z = 123.5 }, rot = { x = 0.0, y = 222.6, z = 0.0 }, level = 1 }
}

-- 区域
regions = {
	{ config_id = 43, shape = RegionShape.SPHERE, radius = 15.19, pos = { x = 195.0, y = 42.0, z = 123.4 } },
	{ config_id = 44, shape = RegionShape.SPHERE, radius = 15.6, pos = { x = 190.3, y = 42.1, z = 122.2 } },
	{ config_id = 45, shape = RegionShape.SPHERE, radius = 12.2, pos = { x = 121.9, y = 39.5, z = 121.2 } },
	{ config_id = 46, shape = RegionShape.SPHERE, radius = 14.98, pos = { x = 156.5, y = 39.5, z = 120.5 } },
	{ config_id = 47, shape = RegionShape.SPHERE, radius = 5, pos = { x = 172.3, y = 42.0, z = 119.8 } },
	{ config_id = 48, shape = RegionShape.SPHERE, radius = 5, pos = { x = 170.6, y = 42.1, z = 120.5 } },
	{ config_id = 49, shape = RegionShape.SPHERE, radius = 5, pos = { x = 180.1, y = 42.0, z = 120.4 } },
	{ config_id = 51, shape = RegionShape.SPHERE, radius = 5, pos = { x = 169.1, y = 42.0, z = 120.2 } },
	{ config_id = 52, shape = RegionShape.SPHERE, radius = 5, pos = { x = 182.3, y = 42.1, z = 118.7 } }
}

-- 触发器
triggers = {
	{ name = "ENTER_REGION_43", event = EventType.EVENT_ENTER_REGION, source = "", condition = "condition_EVENT_ENTER_REGION_43", action = "action_EVENT_ENTER_REGION_43" },
	{ name = "ANY_MONSTER_DIE_44", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "condition_EVENT_ANY_MONSTER_DIE_44", action = "action_EVENT_ANY_MONSTER_DIE_44", trigger_count = 0 },
	{ name = "ENTER_REGION_45", event = EventType.EVENT_ENTER_REGION, source = "", condition = "condition_EVENT_ENTER_REGION_45", action = "action_EVENT_ENTER_REGION_45" },
	{ name = "ENTER_REGION_46", event = EventType.EVENT_ENTER_REGION, source = "", condition = "condition_EVENT_ENTER_REGION_46", action = "action_EVENT_ENTER_REGION_46" },
	{ name = "GADGET_CREATE_47", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "condition_EVENT_GADGET_CREATE_47", action = "action_EVENT_GADGET_CREATE_47" },
	{ name = "SELECT_OPTION_48", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "condition_EVENT_SELECT_OPTION_48", action = "action_EVENT_SELECT_OPTION_48", trigger_count = 0 },
	{ name = "ANY_MONSTER_DIE_49", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "condition_EVENT_ANY_MONSTER_DIE_49", action = "action_EVENT_ANY_MONSTER_DIE_49", trigger_count = 0 },
	{ name = "SELECT_OPTION_51", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "condition_EVENT_SELECT_OPTION_51", action = "action_EVENT_SELECT_OPTION_51", trigger_count = 0 },
	{ name = "SELECT_OPTION_52", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "condition_EVENT_SELECT_OPTION_52", action = "action_EVENT_SELECT_OPTION_52", trigger_count = 0 }
}

-- 变量
variables = {
}

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

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

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

suites = {
	{
		-- suite_id = 0,
		-- description = suite_1,
		monsters = { 49 },
		gadgets = { 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 166, 167, 168 },
		regions = { 43, 44, 45, 46, 47, 48, 49, 51, 52 },
		triggers = { "ENTER_REGION_43", "ANY_MONSTER_DIE_44", "ENTER_REGION_45", "ENTER_REGION_46", "GADGET_CREATE_47", "SELECT_OPTION_48", "ANY_MONSTER_DIE_49", "SELECT_OPTION_51", "SELECT_OPTION_52" },
		rand_weight = 100
	}
}

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

-- 触发条件
function condition_EVENT_ENTER_REGION_43(context, evt)
	if evt.param1 ~= 43 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_43(context, evt)
	-- 将configid为 166 的物件更改为状态 GadgetState.Default
	if 0 ~= ScriptLib.SetGadgetStateByConfigId(context, 166, GadgetState.Default) then
			return -1
		end 
	
	-- 将configid为 167 的物件更改为状态 GadgetState.Default
	if 0 ~= ScriptLib.SetGadgetStateByConfigId(context, 167, GadgetState.Default) then
			return -1
		end 
	
	-- 将configid为 168 的物件更改为状态 GadgetState.Default
	if 0 ~= ScriptLib.SetGadgetStateByConfigId(context, 168, GadgetState.Default) then
			return -1
		end 
	
	return 0
end

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

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

-- 触发条件
function condition_EVENT_ENTER_REGION_45(context, evt)
	if evt.param1 ~= 45 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_45(context, evt)
	-- 将configid为 166 的物件更改为状态 GadgetState.GearStart
	if 0 ~= ScriptLib.SetGadgetStateByConfigId(context, 166, GadgetState.GearStart) then
			return -1
		end 
	
	return 0
end

-- 触发条件
function condition_EVENT_ENTER_REGION_46(context, evt)
	if evt.param1 ~= 46 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_46(context, evt)
	-- 延迟0秒刷怪
	if 0 ~= ScriptLib.CreateMonster(context, { config_id = 96, delay_time = 0 }) then
	  return -1
	end
	
	-- 延迟0秒刷怪
	if 0 ~= ScriptLib.CreateMonster(context, { config_id = 97, delay_time = 0 }) then
	  return -1
	end
	
	-- 延迟0秒刷怪
	if 0 ~= ScriptLib.CreateMonster(context, { config_id = 98, delay_time = 0 }) then
	  return -1
	end
	
	-- 将configid为 166 的物件更改为状态 GadgetState.Default
	if 0 ~= ScriptLib.SetGadgetStateByConfigId(context, 166, GadgetState.Default) then
			return -1
		end 
	
	return 0
end

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

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

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

-- 触发操作
function action_EVENT_SELECT_OPTION_48(context, evt)
	-- 根据不同的选项做不同的操作
	if 1 == evt.param2 then
		if 0 ~= ScriptLib.SetGadgetStateByConfigId(context, 166, GadgetState.GearStart) then
			return -1
		end 
		return 0
	end
	
	return 0
end

-- 触发条件
function condition_EVENT_ANY_MONSTER_DIE_49(context, evt)
	-- 判断角色数量不少于0
	if evt.type == EventType.EVENT_ANY_MONSTER_DIE and evt.param1 == 49  then
		return true
	end
	
	return false
end

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

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

-- 触发操作
function action_EVENT_SELECT_OPTION_51(context, evt)
	-- 根据不同的选项做不同的操作
	if 1 == evt.param2 then
		if 0 ~= ScriptLib.SetGadgetStateByConfigId(context, 168, GadgetState.GearStart) then
			return -1
		end 
		return 0
	end
	
	return 0
end

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

-- 触发操作
function action_EVENT_SELECT_OPTION_52(context, evt)
	-- 根据不同的选项做不同的操作
	if 1 == evt.param2 then
		if 0 ~= ScriptLib.SetGadgetStateByConfigId(context, 167, GadgetState.GearStart) then
			return -1
		end 
		return 0
	end
	
	return 0
end
