浏览代码

Moved combo artifacts to config file, they are now handled by string id.
TODO: use same solution for new mod artifacts.

DjWarmonger 13 年之前
父节点
当前提交
d50f9c8d34
共有 3 个文件被更改,包括 125 次插入82 次删除
  1. 104 13
      config/artifacts.json
  2. 20 69
      lib/CArtHandler.cpp
  3. 1 0
      lib/CArtHandler.h

+ 104 - 13
config/artifacts.json

@@ -2324,7 +2324,16 @@
 				}
 				}
 			],
 			],
 			"id" : 129,
 			"id" : 129,
-			"type" : "Hero"
+			"type" : "Hero",
+			"components":
+			[
+				"armorOfWonder",
+				"sandalsOfTheSaint",
+				"celestialNecklaceOfBliss",
+				"lionsShieldOfCourage",
+				"swordOfJudgement",
+				"helmOfHeavenlyEnlightenment"
+			]
 		},
 		},
 		"cloakOfTheUndeadKing":
 		"cloakOfTheUndeadKing":
 		{
 		{
@@ -2340,7 +2349,13 @@
 				}
 				}
 			],
 			],
 			"id" : 130,
 			"id" : 130,
-			"type" : "Hero"
+			"type" : "Hero",
+			"components":
+			[
+				"amuletOfTheUndertaker",
+				"vampiresCowl",
+				"deadMansBoots"
+			]
 		},
 		},
 		"elixirOfLife":
 		"elixirOfLife":
 		{
 		{
@@ -2365,7 +2380,13 @@
 				}
 				}
 			],
 			],
 			"id" : 131,
 			"id" : 131,
-			"type" : "Hero"
+			"type" : "Hero",
+			"components":
+			[
+				"ringOfVitality",
+				"ringOfLife",
+				"vialOfLifeblood"
+			]
 		},
 		},
 		"armorOfTheDamned":
 		"armorOfTheDamned":
 		{
 		{
@@ -2408,12 +2429,27 @@
 				}
 				}
 			],
 			],
 			"id" : 132,
 			"id" : 132,
-			"type" : "Hero"
+			"type" : "Hero",
+			"components":
+			[
+				"blackshardOfTheDeadKnight",
+				"shieldOfTheYawningDead",
+				"skullHelmet",
+				"ribCage"
+			]
 		},
 		},
 		"statueOfLegion": //TODO: implement
 		"statueOfLegion": //TODO: implement
 		{
 		{
 			"id" : 133,
 			"id" : 133,
-			"type" : "Hero"
+			"type" : "Hero",
+			"components":
+			[
+				"legsOfLegion",
+				"loinsOfLegion",
+				"torsoOfLegion",
+				"armsOfLegion",
+				"headOfLegion"
+			]
 		},
 		},
 		"powerOfTheDragonFather": //TODO: add stat bonus
 		"powerOfTheDragonFather": //TODO: add stat bonus
 		{
 		{
@@ -2429,7 +2465,19 @@
 				}
 				}
 			],
 			],
 			"id" : 134,
 			"id" : 134,
-			"type" : "Hero"
+			"type" : "Hero",
+			"components":
+			[
+				"quietEyeOfTheDragon",
+				"redDragonFlameTongue",
+				"dragonScaleShield",
+				"dragonScaleArmor",
+				"dragonboneGreaves",
+				"dragonWingTabard",
+				"necklaceOfDragonteeth",
+				"crownOfDragontooth",
+				"stillEyeOfTheDragon"
+			]
 		},
 		},
 		"titansThunder":
 		"titansThunder":
 		{
 		{
@@ -2445,7 +2493,14 @@
 				}
 				}
 			],
 			],
 			"id" : 135,
 			"id" : 135,
-			"type" : "Hero"
+			"type" : "Hero",
+			"components":
+			[
+				"titansGladius",
+				"sentinelsShield",
+				"thunderHelmet",
+				"titansCuirass"
+			]
 		},
 		},
 		"admiralsHat":
 		"admiralsHat":
 		{
 		{
@@ -2461,7 +2516,12 @@
 				}
 				}
 			],
 			],
 			"id" : 136,
 			"id" : 136,
-			"type" : "Hero"
+			"type" : "Hero",
+			"components":
+			[
+				"necklaceOfOceanGuidance",
+				"seaCaptainsHat"
+			]
 		},
 		},
 		"bowOfTheSharpshooter": //TODO: limiters
 		"bowOfTheSharpshooter": //TODO: limiters
 		{
 		{
@@ -2498,7 +2558,13 @@
 				}
 				}
 			],
 			],
 			"id" : 137,
 			"id" : 137,
-			"type" : "Hero"
+			"type" : "Hero",
+			"components":
+			[
+				"bowOfElvenCherrywood",
+				"bowstringOfTheUnicornsMane",
+				"angelFeatherArrows"
+			]
 		},
 		},
 		"wizardsWell":
 		"wizardsWell":
 		{
 		{
@@ -2514,7 +2580,13 @@
 				}
 				}
 			],
 			],
 			"id" : 138,
 			"id" : 138,
-			"type" : "Hero"
+			"type" : "Hero",
+			"components":
+			[
+				"charmOfMana",
+				"talismanOfMana",
+				"mysticOrbOfMana"
+			]
 		},
 		},
 		"ringOfTheMagi":
 		"ringOfTheMagi":
 		{
 		{
@@ -2530,7 +2602,13 @@
 				}
 				}
 			],
 			],
 			"id" : 139,
 			"id" : 139,
-			"type" : "Hero"
+			"type" : "Hero",
+			"components":
+			[
+				"collarOfConjuring",
+				"ringOfConjuring",
+				"capeOfConjuring"
+			]
 		},
 		},
 		"cornucopia":
 		"cornucopia":
 		{
 		{
@@ -2573,7 +2651,13 @@
 				}
 				}
 			],
 			],
 			"id" : 140,
 			"id" : 140,
-			"type" : "Hero"
+			"type" : "Hero",
+			"components":
+			[
+				"everflowingCrystalCloak",
+				"ringOfInfiniteGems",
+				"everpouringVialOfMercury",
+				"inexhaustibleCartOfOre"			]
 		},
 		},
 		"magicWand":
 		"magicWand":
 		{
 		{
@@ -2988,7 +3072,14 @@
 		"barbarianLordsAxeOfFerocity": //TODO: implement
 		"barbarianLordsAxeOfFerocity": //TODO: implement
 		{
 		{
 			"id" : 158,
 			"id" : 158,
-			"type" : "Hero"
+			"type" : "Hero",
+			"components":
+			[
+				"ogresClubOfHavoc",
+				"targOfTheRampagingOgre",
+				"crownOfTheSupremeMagi",
+				"tunicOfTheCyclopsKing"
+			]
 		},
 		},
 		"dragonheart":
 		"dragonheart":
 		{
 		{

+ 20 - 69
lib/CArtHandler.cpp

@@ -334,75 +334,6 @@ void CArtHandler::loadArtifacts(bool onlyTxt)
 		if(onlyTxt)
 		if(onlyTxt)
 			continue;
 			continue;
 
 
-		// Fill in information about combined artifacts. Should perhaps be moved to a config file?
-		switch (nart.id)
-		{
-			case 129: // Angelic Alliance
-				nart.constituents = new std::vector<ui32>();
-				*nart.constituents += 31, 32, 33, 34, 35, 36;
-				break;
-
-			case 130: // Cloak of the Undead King
-				nart.constituents = new std::vector<ui32>();
-				*nart.constituents += 54, 55, 56;
-				break;
-
-			case 131: // Elixir of Life
-				nart.constituents = new std::vector<ui32>();
-				*nart.constituents += 94, 95, 96;
-				break;
-
-			case 132: // Armor of the Damned
-				nart.constituents = new std::vector<ui32>();
-				*nart.constituents += 8, 14, 20, 26;
-				break;
-
-			case 133: // Statue of Legion
-				nart.constituents = new std::vector<ui32>();
-				*nart.constituents += 118, 119, 120, 121, 122;
-				break;
-
-			case 134: // Power of the Dragon Father
-				nart.constituents = new std::vector<ui32>();
-				*nart.constituents += 37, 38, 39, 40, 41, 42, 43, 44, 45;
-				break;
-
-			case 135: // Titan's Thunder
-				nart.constituents = new std::vector<ui32>();
-				*nart.constituents += 12, 18, 24, 30;
-				break;
-
-			case 136: // Admiral's Hat
-				nart.constituents = new std::vector<ui32>();
-				*nart.constituents += 71, 123;
-				break;
-
-			case 137: // Bow of the Sharpshooter
-				nart.constituents = new std::vector<ui32>();
-				*nart.constituents += 60, 61, 62;
-				break;
-
-			case 138: // Wizards' Well
-				nart.constituents = new std::vector<ui32>();
-				*nart.constituents += 73, 74, 75;
-				break;
-
-			case 139: // Ring of the Magi
-				nart.constituents = new std::vector<ui32>();
-				*nart.constituents += 76, 77, 78;
-				break;
-
-			case 140: // Cornucopia
-				nart.constituents = new std::vector<ui32>();
-				*nart.constituents += 109, 110, 111, 113;
-				break;
-
-			// TODO: WoG combinationals
-
-			default:
-				break;
-		}
-
 		artifacts.push_back(&nart);
 		artifacts.push_back(&nart);
 	}
 	}
 	if (VLC->modh->modules.COMMANDERS)
 	if (VLC->modh->modules.COMMANDERS)
@@ -429,6 +360,7 @@ void CArtHandler::loadArtifacts(bool onlyTxt)
 	addBonuses();
 	addBonuses();
 
 
 	// Populate reverse mappings of combinational artifacts.
 	// Populate reverse mappings of combinational artifacts.
+	//TODO: do that also for new artifacts read from mods
 	BOOST_FOREACH(CArtifact *artifact, artifacts)
 	BOOST_FOREACH(CArtifact *artifact, artifacts)
 	{
 	{
 		if (artifact->constituents != NULL)
 		if (artifact->constituents != NULL)
@@ -553,6 +485,12 @@ CArtifact * CArtHandler::loadArtifact(const JsonNode & node)
 	return art;
 	return art;
 }
 }
 
 
+void CArtifact::addConstituent (ui32 component)
+{
+	assert (constituents);
+	constituents->push_back (component);
+}
+
 int CArtHandler::convertMachineID(int id, bool creToArt )
 int CArtHandler::convertMachineID(int id, bool creToArt )
 {
 {
 	int dif = 142;
 	int dif = 142;
@@ -764,6 +702,19 @@ void CArtHandler::addBonuses()
 		else if(artifact.second["type"].String() == "Commander")
 		else if(artifact.second["type"].String() == "Commander")
 			makeItCommanderArt(ga->id);
 			makeItCommanderArt(ga->id);
 
 
+		const JsonNode *value;
+		value = &artifact.second["components"];
+		if (!value->isNull())
+		{
+			ga->constituents = new std::vector<ui32>();
+			BOOST_FOREACH (auto component, value->Vector())
+			{
+				VLC->modh->identifiers.requestIdentifier(std::string("artifact.") + component.String(),
+					boost::bind (&CArtifact::addConstituent, ga, _1)
+				);
+			}
+		}
+
 		VLC->modh->identifiers.registerObject ("artifact." + artifact.first, ga->id);
 		VLC->modh->identifiers.registerObject ("artifact." + artifact.first, ga->id);
 	}
 	}
 }
 }

+ 1 - 0
lib/CArtHandler.h

@@ -87,6 +87,7 @@ public:
 	void setName (std::string desc);
 	void setName (std::string desc);
 	void setDescription (std::string desc);
 	void setDescription (std::string desc);
 	void setEventText (std::string desc);
 	void setEventText (std::string desc);
+	void addConstituent (ui32 component);
 
 
 	int getArtClassSerial() const; //0 - treasure, 1 - minor, 2 - major, 3 - relic, 4 - spell scroll, 5 - other
 	int getArtClassSerial() const; //0 - treasure, 1 - minor, 2 - major, 3 - relic, 4 - spell scroll, 5 - other
 	std::string nodeName() const OVERRIDE;
 	std::string nodeName() const OVERRIDE;