/// <summary> /// Generates the mission briefing. /// </summary> /// <param name="mission">Mission</param> /// <param name="template">Template from which the mission should be built</param> /// <param name="airbaseDB">Airbase player will take off from and land back on</param> /// <param name="coalitionsDB">Database entries for the mission coalitions</param> public void GenerateMissionBriefing(DCSMission mission, MissionTemplate template, DBEntryObjective objectiveDB, DBEntryTheaterAirbase airbaseDB, List <UnitFlightGroupBriefingDescription> flightGroups, DBEntryCoalition[] coalitionsDB) { DebugLog.Instance.WriteLine("Generating mission briefing...", 1); // Get mission features DBEntryMissionFeature[] features = Database.Instance.GetEntries <DBEntryMissionFeature>(objectiveDB.MissionFeatures); string description = objectiveDB.BriefingDescriptionByUnitFamily[(int)mission.Objectives[0].TargetFamily]; if (string.IsNullOrEmpty(description)) // No custom briefing for this target family, use the default { description = objectiveDB.BriefingDescription; } description = GeneratorTools.MakeBriefingStringReplacements(GeneratorTools.ParseRandomString(description), mission, coalitionsDB); description = GeneratorTools.SanitizeString(description); // Generate tasks string baseName = airbaseDB.Name; // TODO: this doesn't work for lots of carriers so simplifying for now List <string> tasks = new List <string> { $"Take off from {baseName}" }; string objectiveTask = GeneratorTools.ParseRandomString(objectiveDB.BriefingTask); for (int i = 0; i < mission.Objectives.Length; i++) { string taskString = GeneratorTools.MakeBriefingStringReplacements(objectiveTask, mission, coalitionsDB, i); tasks.Add(taskString); mission.CoreLuaScript += $"briefingRoom.mission.objectives[{i + 1}].task = \"{taskString}\"\r\n"; } tasks.Add($"Return to {baseName}"); DebugLog.Instance.WriteLine($"{tasks.Count} task(s)", 2); // Generate mission remarks... List <string> remarks = new List <string>(); remarks.AddRange( // ...from objective from string remark in objectiveDB.BriefingRemarks select GeneratorTools.MakeBriefingStringReplacements(GeneratorTools.ParseRandomString(remark), mission, coalitionsDB)); foreach (DBEntryMissionFeature feature in features) { remarks.AddRange( // ...from features from string remark in feature.BriefingRemarks select GeneratorTools.MakeBriefingStringReplacements(GeneratorTools.ParseRandomString(remark), mission, coalitionsDB)); } mission.BriefingHTML = CreateHTMLBriefing(mission, template, description, tasks, remarks, flightGroups, airbaseDB, coalitionsDB, objectiveDB); mission.BriefingTXT = CreateTXTBriefing(mission, description, tasks, remarks, flightGroups, airbaseDB); }
/// <summary> /// Generate a random mission name if none is provided in the template, or returns the provided name if there is one. /// </summary> /// <param name="mission">A mission</param> /// <param name="template">Mission template to use</param> public void GenerateMissionName(DCSMission mission, MissionTemplate template) { DebugLog.Instance.WriteLine("Generating mission name...", 1); string fixedName = GeneratorTools.SanitizeString(template.BriefingName); if (!string.IsNullOrEmpty(fixedName)) // A custom mission name has been provided, use it { mission.MissionName = fixedName; } else // No custom name? Generate one { mission.MissionName = Database.Instance.Common.MissionNameTemplate; for (int i = 0; i < DatabaseCommon.MISSION_NAMES_PART_COUNT; i++) { mission.MissionName = mission.MissionName.Replace($"$P{i + 1}$", Toolbox.RandomFrom(Database.Instance.Common.MissionNameParts[i])); } } DebugLog.Instance.WriteLine($"Mission name set to \"{mission.MissionName}\"", 2); }
/// <summary> /// Generates the mission briefing. /// </summary> /// <param name="mission">Mission</param> /// <param name="template">Template from which the mission should be built</param> /// <param name="airbaseDB">Airbase player will take off from and land back on</param> /// <param name="coalitionsDB">Database entries for the mission coalitions</param> public void GenerateMissionBriefing(DCSMission mission, MissionTemplate template, DBEntryObjective objectiveDB, DBEntryTheaterAirbase airbaseDB, List <UnitFlightGroupBriefingDescription> flightGroups, DBEntryCoalition[] coalitionsDB) { DebugLog.Instance.WriteLine("Generating mission briefing...", 1); // Get mission features DBEntryMissionFeature[] features = Database.Instance.GetEntries <DBEntryMissionFeature>(objectiveDB.MissionFeatures); string description = GeneratorTools.SanitizeString(template.BriefingDescription); if (string.IsNullOrEmpty(description)) // No custom mission description has been provided, generate one { description = objectiveDB.BriefingDescriptionByUnitFamily[(int)mission.Objectives[0].TargetFamily]; if (string.IsNullOrEmpty(description)) // No custom briefing for this target family, use the default { description = objectiveDB.BriefingDescription; } description = GeneratorTools.MakeBriefingStringReplacements(GeneratorTools.ParseRandomString(description), mission, coalitionsDB); } description = GeneratorTools.SanitizeString(description); // Generate tasks string baseName = airbaseDB.Name; // TODO: this doesn't work for lots of carriers so simplifying for now List <string> tasks = new List <string> { $"Take off from {baseName}" }; string objectiveTask = GeneratorTools.ParseRandomString(objectiveDB.BriefingTask); for (int i = 0; i < mission.Objectives.Length; i++) { string taskString = GeneratorTools.MakeBriefingStringReplacements(objectiveTask, mission, coalitionsDB, i); tasks.Add(taskString); mission.CoreLuaScript += $"briefingRoom.mission.objectives[{i + 1}].task = \"{taskString}\"\r\n"; } tasks.Add($"Return to {baseName}"); DebugLog.Instance.WriteLine($"{tasks.Count} task(s)", 2); // Generate mission remarks... List <string> remarks = new List <string>(); remarks.AddRange( // ...from objective from string remark in objectiveDB.BriefingRemarks select GeneratorTools.MakeBriefingStringReplacements(GeneratorTools.ParseRandomString(remark), mission, coalitionsDB)); foreach (DBEntryMissionFeature feature in features) { remarks.AddRange( // ...from features from string remark in feature.BriefingRemarks select GeneratorTools.MakeBriefingStringReplacements(GeneratorTools.ParseRandomString(remark), mission, coalitionsDB)); } /* * // Opposition Remarks * string airDefenseNumbers = template.OppositionAirDefense == AmountN.Random? "Unknown":template.OppositionAirDefense.ToString(); * string airDefenseSkill = template.OppositionSkillLevelGround == BRSkillLevel.Random? "Varied":template.OppositionSkillLevelGround.ToString(); * string airForceNumbers = template.OppositionAirForce == AmountN.Random? "Unknown":template.OppositionAirForce.ToString(); * string airForceSkill = template.OppositionSkillLevelAir == BRSkillLevel.Random? "Varied":template.OppositionSkillLevelAir.ToString(); * string allyAirDefenseNumbers = template.PlayerFriendlyAirDefense == AmountN.Random? "Unknown":template.PlayerFriendlyAirDefense.ToString(); * string allyAirDefenseSkill = template.PlayerAISkillLevel == BRSkillLevel.Random? "Varied":template.PlayerAISkillLevel.ToString(); * remarks.AddRange(new List<string>{ * $"Enemy Air Defenses are {airDefenseNumbers} and they are {airDefenseSkill} troops", * $"Expected Enemy Air Force response is {airForceNumbers} and they are {airForceSkill} pilots", * $"Our Air Defenses are {allyAirDefenseNumbers} and they are {allyAirDefenseSkill} troops",}); * remarks.Add("Use the \"F10/Other\" item in the comms for additional options"); * DebugLog.Instance.WriteLine($"{remarks.Count} remark(s)", 2); */ mission.BriefingHTML = CreateHTMLBriefing(mission, template, description, tasks, remarks, flightGroups, airbaseDB, coalitionsDB, objectiveDB); mission.BriefingTXT = CreateTXTBriefing(mission, description, tasks, remarks, flightGroups, airbaseDB); }