Explorar o código

Merge pull request #3743 from dydzio0614/special-factions

Allow factions to be special
Ivan Savenko hai 1 ano
pai
achega
6e9f15c8e6

+ 4 - 0
config/schemas/faction.json

@@ -58,6 +58,10 @@
 			"type" : "boolean",
 			"description" : "Random map generator places player/cpu-owned towns underground if true is specified and on the ground otherwise. Parameter is unused for maps without underground."
 		},
+		"special" : {
+			"type" : "boolean",
+			"description" : "If true, faction is disabled from starting pick and in random map generation"
+		},
 		"creatureBackground" : {
 			"type" : "object",
 			"additionalProperties" : false,

+ 3 - 0
docs/modders/Entities_Format/Faction_Format.md

@@ -75,6 +75,9 @@ Each town requires a set of buildings (Around 30-45 buildings)
 	
 	// Random map generator places player/cpu-owned towns underground if true is specified and on the ground otherwise. Parameter is unused for maps without underground.
 	"preferUndergroundPlacement" : false
+	
+	// Optional, if set to true then faction cannot be selected on game start and will not be used for "random town" object
+	"special" : false
 
 	// Town puzzle map
 	"puzzleMap" :

+ 2 - 1
lib/CTownHandler.cpp

@@ -1058,6 +1058,7 @@ CFaction * CTownHandler::loadFromJson(const std::string & scope, const JsonNode
 	
 	auto preferUndergound = source["preferUndergroundPlacement"];
 	faction->preferUndergroundPlacement = preferUndergound.isNull() ? false : preferUndergound.Bool();
+	faction->special = source["special"].Bool();
 
 	// NOTE: semi-workaround - normally, towns are supposed to have native terrains.
 	// Towns without one are exceptions. So, vcmi requires nativeTerrain to be defined
@@ -1249,7 +1250,7 @@ std::set<FactionID> CTownHandler::getDefaultAllowed() const
 	std::set<FactionID> allowedFactions;
 
 	for(auto town : objects)
-		if (town->town != nullptr)
+		if (town->town != nullptr && !town->special)
 			allowedFactions.insert(town->getId());
 
 	return allowedFactions;

+ 1 - 0
lib/CTownHandler.h

@@ -168,6 +168,7 @@ public:
 	TerrainId nativeTerrain;
 	EAlignment alignment = EAlignment::NEUTRAL;
 	bool preferUndergroundPlacement = false;
+	bool special = false;
 
 	/// Boat that will be used by town shipyard (if any)
 	/// and for placing heroes directly on boat (in map editor, water prisons & taverns)