diff --git a/scripts/shiptemplates/40k/Croiseurs.lua b/scripts/shiptemplates/40k/Croiseurs.lua index 48cff1e7fb..1b6dc09b4c 100644 --- a/scripts/shiptemplates/40k/Croiseurs.lua +++ b/scripts/shiptemplates/40k/Croiseurs.lua @@ -1098,6 +1098,7 @@ template:registerSquadronComposition("Ch", 5, 15, "Chasseur Mk2", "Chasseur", "C template:registerSquadronComposition("Ch2", 5, 15, "Chasseur Mk2", "Chasseur", "Chasseur","Chasseur") template:registerSquadronComposition("Ch3", 5, 15, "Chasseur Mk2", "Chasseur", "Chasseur","Chasseur") template:registerSquadronComposition("Ch4", 5, 15, "Chasseur Mk2", "Chasseur", "Chasseur","Chasseur") +template:setBlueprintAvailable("Ch", "Ch3") --Dock/balise de renfort de la marine diff --git a/src/shipTemplate.cpp b/src/shipTemplate.cpp index 5712d13245..516c150914 100644 --- a/src/shipTemplate.cpp +++ b/src/shipTemplate.cpp @@ -349,12 +349,16 @@ REGISTER_SCRIPT_CLASS(ShipTemplate) /// Defaults to true. /// Example: template:setCanLaunchProbe(false) REGISTER_SCRIPT_CLASS_FUNCTION(ShipTemplate, setCanLaunchProbe); - ///Registers a new squandron type + ///Registers a new squandron type (this is a kind of Blueprint) ///First argument registers the name of the squadron, this is an identifier (for instance "Interceptors") ///Second argument is maximum number of squadrons (ex: 5) ///Third argument is creation duration in seconds (ex : 30) ///Other arguments register the ship class name (for instance "Light Fighter Defiant class", "Viper", ...) REGISTER_SCRIPT_CLASS_FUNCTION(ShipTemplate, registerSquadronComposition); + ///Sets a blueprint available. By default, all blueprints are deactivated and not available for player + ///You can specify a SquadronComposition name here, or any list. + ///ex : setBlueprintAvailable("Ch", "Ch1", "Interceptors") + REGISTER_SCRIPT_CLASS_FUNCTION(ShipTemplate, setBlueprintAvailable); /// Returns an exact copy of this ShipTemplate and sets the new copy's reference name to the given name, as ShipTemplate:setName(). /// The copy retains all other traits of the copied ShipTemplate. diff --git a/src/shipTemplate.h b/src/shipTemplate.h index ab4a5e93a9..79f221ad89 100644 --- a/src/shipTemplate.h +++ b/src/shipTemplate.h @@ -285,6 +285,19 @@ class ShipTemplate : public PObject squadrons_compositions.push_back(sqt); } + void setBlueprintAvailable(const std::vector& squadron_name) + { + std::unordered_set template_names(squadron_name.begin(), squadron_name.end()); + for(auto &sqt : squadrons_compositions) + { + if(template_names.find(sqt.template_name) != template_names.end()) + { + sqt.available = true; + template_names.erase(sqt.template_name); + } + } + } + public: static P getTemplate(string name); static std::vector getAllTemplateNames();