internal UnitMakerGroupInfo?AddUnitGroup( string[] units, Side side, UnitFamily unitFamily, string groupTypeLua, string unitTypeLua, Coordinates coordinates, UnitMakerGroupFlags unitMakerGroupFlags = 0, params KeyValuePair <string, object>[] extraSettings) { if (units.Length == 0) { return(null); } Coalition coalition = (side == Side.Ally) ? PlayerCoalition : PlayerCoalition.GetEnemy(); Country country = (coalition == Coalition.Blue) ? Country.CJTFBlue : Country.CJTFRed; if (extraSettings.Any(x => x.Key == "Country")) { country = (Country)extraSettings.First(x => x.Key == "Country").Value; } var skill = GeneratorTools.GetDefaultSkillLevel(Template, side); if (extraSettings.Any(x => x.Key == "Skill")) { skill = (DCSSkillLevel)extraSettings.First(x => x.Key == "Skill").Value; } var isUsingSkynet = Template.MissionFeatures.Contains("SkynetIADS"); string groupName; UnitCallsign?callsign = null; if (unitFamily.GetUnitCategory().IsAircraft()) { callsign = CallsignGenerator.GetCallsign(unitFamily, coalition, side, isUsingSkynet); groupName = callsign.Value.GroupName; if (extraSettings.Any(x => x.Key == "PlayerStartingType") && extraSettings.First(x => x.Key == "PlayerStartingType").Value.ToString() == "TakeOffParking") { groupName += "(C)"; } } else { groupName = GeneratorTools.GetGroupName(GroupID, unitFamily, side, isUsingSkynet); } if (unitFamily.GetUnitCategory() == UnitCategory.Static || unitFamily.GetUnitCategory() == UnitCategory.Cargo && unitFamily != UnitFamily.FOB) { return(AddStaticGroup( country, coalition, skill, unitFamily, side, units, groupName, callsign, groupTypeLua, coordinates, unitMakerGroupFlags, extraSettings )); } var groupLua = CreateGroup( groupTypeLua, coordinates, groupName, extraSettings ); int firstUnitID = UnitID; var(unitsLuaTable, unitsIDList) = AddUnits( units, groupName, callsign, unitTypeLua, coordinates, unitMakerGroupFlags, extraSettings ); if (unitsIDList.Count == 0) { return(null); // No valid units added to this group } GeneratorTools.ReplaceKey(ref groupLua, "Units", unitsLuaTable); DBEntryUnit firstUnitDB = units.Select(x => Database.Instance.GetEntry <DBEntryUnit>(x)).First(x => x != null); var aircraftCategories = new UnitCategory[] { UnitCategory.Helicopter, UnitCategory.Plane }; var isAircraft = firstUnitDB != null && aircraftCategories.Contains(firstUnitDB.Category); if (isAircraft) { groupLua = ApplyAircraftFields(groupLua, firstUnitDB, extraSettings); if (unitMakerGroupFlags.HasFlag(UnitMakerGroupFlags.ImmediateAircraftSpawn)) { Mission.AppendValue("AircraftActivatorCurrentQueue", $"{GroupID},"); } else if (unitMakerGroupFlags.HasFlag(UnitMakerGroupFlags.RadioAircraftSpawn)) { Mission.AppendValue("AircraftRadioActivator", $"{{{GroupID}, \"{groupName}\"}},"); } else if (groupTypeLua != "GroupAircraftParkedUncontrolled") { Mission.AppendValue("AircraftActivatorReserveQueue", $"{GroupID},"); } } GeneratorTools.ReplaceKey(ref groupLua, "UnitID", firstUnitID); // Must be after units are added GeneratorTools.ReplaceKey(ref groupLua, "Skill", skill); // Must be after units are added, because skill is set as a unit level GeneratorTools.ReplaceKey(ref groupLua, "Hidden", GeneratorTools.GetHiddenStatus(Template.OptionsFogOfWar, side, unitMakerGroupFlags)); // If "hidden" was not set through custom values AddUnitGroupToTable(country, unitFamily.GetUnitCategory(), groupLua); BriefingRoom.PrintToLog($"Added group of {units.Length} {coalition} {unitFamily} at {coordinates}"); GroupID++; if (firstUnitDB == null) { return(new UnitMakerGroupInfo(GroupID - 1, coordinates, unitsIDList, groupName)); } return(new UnitMakerGroupInfo(GroupID - 1, coordinates, unitsIDList, groupName, firstUnitDB.AircraftData.RadioFrequency, firstUnitDB)); }