示例#1
0
        //----------------SUB TASK SUPPORT FUNCTIONS-------------------------------

        private static void GetSubTaskData(MissionTemplateSubTask objectiveTemplate, out DBEntryObjectiveTarget targetDB, out DBEntryObjectiveTargetBehavior targetBehaviorDB, out DBEntryObjectiveTask taskDB, out ObjectiveOption[] objectiveOptions)
        {
            targetDB         = Database.Instance.GetEntry <DBEntryObjectiveTarget>(objectiveTemplate.Target);
            targetBehaviorDB = Database.Instance.GetEntry <DBEntryObjectiveTargetBehavior>(objectiveTemplate.TargetBehavior);
            taskDB           = Database.Instance.GetEntry <DBEntryObjectiveTask>(objectiveTemplate.Task);
            objectiveOptions = objectiveTemplate.Options.ToArray();

            if (targetDB == null)
            {
                throw new BriefingRoomException($"Target \"{targetDB.UIDisplayName}\" not found for objective.");
            }
            if (targetBehaviorDB == null)
            {
                throw new BriefingRoomException($"Target behavior \"{targetBehaviorDB.UIDisplayName}\" not found for objective.");
            }
            if (taskDB == null)
            {
                throw new BriefingRoomException($"Task \"{taskDB.UIDisplayName}\" not found for objective.");
            }
            if (!taskDB.ValidUnitCategories.Contains(targetDB.UnitCategory))
            {
                throw new BriefingRoomException($"Task \"{taskDB.UIDisplayName}\" not valid for objective targets, which belong to category \"{targetDB.UnitCategory}\".");
            }
        }
示例#2
0
        private void AddEmbeddedAirDefenseUnits(MissionTemplateRecord template, DBEntryObjectiveTarget targetDB, DBEntryObjectiveTargetBehavior targetBehaviorDB, DBEntryObjectiveTask taskDB, ObjectiveOption[] objectiveOptions, Coordinates objectiveCoordinates, UnitMakerGroupFlags groupFlags, List <KeyValuePair <string, object> > extraSettings)
        {
            // Static targets (aka buildings) need to have their "embedded" air defenses spawned in another group
            string[] airDefenseUnits = GeneratorTools.GetEmbeddedAirDefenseUnits(template, taskDB.TargetSide);

            if (airDefenseUnits.Length > 0)
            {
                UnitMaker.AddUnitGroup(
                    airDefenseUnits,
                    taskDB.TargetSide, UnitFamily.VehicleAAA,
                    targetBehaviorDB.GroupLua[(int)targetDB.UnitCategory], targetBehaviorDB.UnitLua[(int)targetDB.UnitCategory],
                    objectiveCoordinates + Coordinates.CreateRandom(100, 500),
                    groupFlags,
                    extraSettings.ToArray());
            }
        }
示例#3
0
        private static void CreateLua(DCSMission mission, MissionTemplateRecord template, DBEntryObjectiveTarget targetDB, DBEntryObjectiveTask taskDB, int objectiveIndex, string objectiveName, UnitMakerGroupInfo?targetGroupInfo, string taskString)
        {
            // Add Lua table for this objective
            string objectiveLua = $"briefingRoom.mission.objectives[{objectiveIndex + 1}] = {{ ";

            objectiveLua += $"complete = false, ";
            objectiveLua += $"groupID = {targetGroupInfo.Value.GroupID}, ";
            objectiveLua += $"hideTargetCount = false, ";
            objectiveLua += $"name = \"{objectiveName}\", ";
            objectiveLua += $"targetCategory = Unit.Category.{targetDB.UnitCategory.ToLuaName()}, ";
            objectiveLua += $"taskType = \"{taskDB.ID}\", ";
            objectiveLua += $"task = \"{taskString}\", ";
            objectiveLua += $"unitsCount = {targetGroupInfo.Value.UnitsID.Length}, ";
            objectiveLua += $"unitsID = {{ {string.Join(", ", targetGroupInfo.Value.UnitsID)} }} ";
            objectiveLua += "}\n";

            // Add F10 sub-menu for this objective
            objectiveLua += $"briefingRoom.f10Menu.objectives[{objectiveIndex + 1}] = missionCommands.addSubMenuForCoalition(coalition.side.{template.ContextPlayerCoalition.ToString().ToUpperInvariant()}, \"Objective {objectiveName}\", nil)\n";
            mission.AppendValue("ScriptObjectives", objectiveLua);

            // Add objective trigger Lua for this objective
            string triggerLua = Toolbox.ReadAllTextIfFileExists($"{BRPaths.INCLUDE_LUA_OBJECTIVETRIGGERS}{taskDB.CompletionTriggerLua}");

            GeneratorTools.ReplaceKey(ref triggerLua, "ObjectiveIndex", objectiveIndex + 1);
            mission.AppendValue("ScriptObjectivesTriggers", triggerLua);
        }
示例#4
0
        private static void GetObjectiveData(MissionTemplateObjectiveRecord objectiveTemplate, bool useObjectivePreset, out string[] featuresID, out DBEntryObjectiveTarget targetDB, out DBEntryObjectiveTargetBehavior targetBehaviorDB, out DBEntryObjectiveTask taskDB, out ObjectiveOption[] objectiveOptions)
        {
            featuresID       = objectiveTemplate.Features.ToArray();
            targetDB         = Database.Instance.GetEntry <DBEntryObjectiveTarget>(objectiveTemplate.Target);
            targetBehaviorDB = Database.Instance.GetEntry <DBEntryObjectiveTargetBehavior>(objectiveTemplate.TargetBehavior);
            taskDB           = Database.Instance.GetEntry <DBEntryObjectiveTask>(objectiveTemplate.Task);
            objectiveOptions = objectiveTemplate.Options.ToArray();
            if (useObjectivePreset && objectiveTemplate.Preset != "Custom")
            {
                DBEntryObjectivePreset presetDB = Database.Instance.GetEntry <DBEntryObjectivePreset>(objectiveTemplate.Preset);
                if (presetDB != null)
                {
                    featuresID       = presetDB.Features.ToArray();
                    targetDB         = Database.Instance.GetEntry <DBEntryObjectiveTarget>(Toolbox.RandomFrom(presetDB.Targets));
                    targetBehaviorDB = Database.Instance.GetEntry <DBEntryObjectiveTargetBehavior>(Toolbox.RandomFrom(presetDB.TargetsBehaviors));
                    taskDB           = Database.Instance.GetEntry <DBEntryObjectiveTask>(Toolbox.RandomFrom(presetDB.Tasks));
                    objectiveOptions = presetDB.Options.ToArray();
                }
            }

            if (targetDB == null)
            {
                throw new BriefingRoomException($"Target \"{targetDB.UIDisplayName}\" not found for objective.");
            }
            if (targetBehaviorDB == null)
            {
                throw new BriefingRoomException($"Target behavior \"{targetBehaviorDB.UIDisplayName}\" not found for objective.");
            }
            if (taskDB == null)
            {
                throw new BriefingRoomException($"Task \"{taskDB.UIDisplayName}\" not found for objective.");
            }
            if (!taskDB.ValidUnitCategories.Contains(targetDB.UnitCategory))
            {
                throw new BriefingRoomException($"Task \"{taskDB.UIDisplayName}\" not valid for objective targets, which belong to category \"{targetDB.UnitCategory}\".");
            }
        }