浏览代码

Added string identifiers to artifacts.
Some of them have lost some abilities, needs more work.

DjWarmonger 13 年之前
父节点
当前提交
743a0fc3f4
共有 3 个文件被更改,包括 143 次插入9 次删除
  1. 133 1
      config/artifacts.json
  2. 7 5
      lib/CArtHandler.cpp
  3. 3 3
      lib/CObjectHandler.cpp

文件差异内容过多而无法显示
+ 133 - 1
config/artifacts.json


+ 7 - 5
lib/CArtHandler.cpp

@@ -749,20 +749,22 @@ void CArtHandler::makeItCommanderArt( TArtifactInstanceID aid, bool onlyCommande
 void CArtHandler::addBonuses()
 {
 	const JsonNode config(ResourceID("config/artifacts.json"));
-	BOOST_FOREACH(const JsonNode &artifact, config["artifacts"].Vector())
+	BOOST_FOREACH (auto & artifact, config["artifacts"].Struct()) //pair <string, JsonNode> (id, properties)
 	{
-		auto ga = artifacts[artifact["id"].Float()].get();
+		auto ga = artifacts[artifact.second["id"].Float()].get();
 		
-		BOOST_FOREACH (auto b, artifact["bonuses"].Vector())
+		BOOST_FOREACH (auto b, artifact.second["bonuses"].Vector())
 		{
 			auto bonus = JsonUtils::parseBonus (b);
 			bonus->sid = ga->id;
 			ga->addNewBonus (bonus);
 		}
-		if(artifact["type"].String() == "Creature")
+		if(artifact.second["type"].String() == "Creature")
 			makeItCreatureArt(ga->id);
-		else if(artifact["type"].String() == "Commander")
+		else if(artifact.second["type"].String() == "Commander")
 			makeItCommanderArt(ga->id);
+
+		VLC->modh->identifiers.registerObject ("artifact." + artifact.first, ga->id);
 	}
 }
 

+ 3 - 3
lib/CObjectHandler.cpp

@@ -905,7 +905,7 @@ const std::string & CGHeroInstance::getBiography() const
 		return biography;
 	return type->biography;
 }
-void CGHeroInstance::initObj()
+void CGHeroInstance::initObj() //TODO: use bonus system
 {
 	blockVisit = true;
 	speciality.growthsWithLevel = false;
@@ -929,7 +929,7 @@ void CGHeroInstance::initObj()
 					const CCreature &specCreature = *VLC->creh->creatures[it->additionalinfo]; //creature in which we have specialty
 
 					int creLevel = specCreature.level;
-					if(!creLevel) //TODO: set fixed level for War Machines
+					if(!creLevel)
 					{
 						if(it->additionalinfo == 146)
 							creLevel = 5; //treat ballista as 5-level
@@ -1094,7 +1094,7 @@ void CGHeroInstance::initObj()
 	mana = manaLimit(); //after all bonuses are taken into account, make sure this line is the last one
 	type->name = name;
 }
-void CGHeroInstance::UpdateSpeciality()
+void CGHeroInstance::UpdateSpeciality() //TODO: calculate special value of bonuses on-the-fly?
 {
 	if (speciality.growthsWithLevel)
 	{

部分文件因为文件数量过多而无法显示