Konstantin пре 2 година
родитељ
комит
9db2e2068e
3 измењених фајлова са 59 додато и 47 уклоњено
  1. 55 47
      lib/CCreatureHandler.cpp
  2. 3 0
      lib/CCreatureHandler.h
  3. 1 0
      lib/CModHandler.cpp

+ 55 - 47
lib/CCreatureHandler.cpp

@@ -667,6 +667,60 @@ std::vector<bool> CCreatureHandler::getDefaultAllowed() const
 	return ret;
 }
 
+void CCreatureHandler::loadCrExpMod()
+{
+	if (VLC->settings()->getBoolean(EGameSettings::MODULE_STACK_EXPERIENCE)) 	//reading default stack experience values
+	{
+		//Calculate rank exp values, formula appears complicated bu no parsing needed
+		expRanks.resize(8);
+		int dif = 0;
+		int it = 8000; //ignore name of this variable
+		expRanks[0].push_back(it);
+		for (int j = 1; j < 10; ++j) //used for tiers 8-10, and all other probably
+		{
+			expRanks[0].push_back(expRanks[0][j-1] + it + dif);
+			dif += it/5;
+		}
+		for (int i = 1; i < 8; ++i) //used for tiers 1-7
+		{
+			dif = 0;
+			it = 1000 * i;
+			expRanks[i].push_back(it);
+			for (int j = 1; j < 10; ++j)
+			{
+				expRanks[i].push_back(expRanks[i][j-1] + it + dif);
+				dif += it/5;
+			}
+		}
+
+		CLegacyConfigParser expBonParser("DATA/CREXPMOD.TXT");
+
+		expBonParser.endLine(); //header
+
+		maxExpPerBattle.resize(8);
+		for (int i = 1; i < 8; ++i)
+		{
+			expBonParser.readString(); //index
+			expBonParser.readString(); //float multiplier -> hardcoded
+			expBonParser.readString(); //ignore upgrade mod? ->hardcoded
+			expBonParser.readString(); //already calculated
+
+			maxExpPerBattle[i] = static_cast<ui32>(expBonParser.readNumber());
+			expRanks[i].push_back(expRanks[i].back() + static_cast<ui32>(expBonParser.readNumber()));
+
+			expBonParser.endLine();
+		}
+		//skeleton gets exp penalty
+		objects[56].get()->addBonus(-50, Bonus::EXP_MULTIPLIER, -1);
+		objects[57].get()->addBonus(-50, Bonus::EXP_MULTIPLIER, -1);
+		//exp for tier >7, rank 11
+		expRanks[0].push_back(147000);
+		expAfterUpgrade = 75; //percent
+		maxExpPerBattle[0] = maxExpPerBattle[7];
+	}
+}
+
+
 void CCreatureHandler::loadCrExpBon(CBonusSystemNode & globalEffects)
 {
 	if (VLC->settings()->getBoolean(EGameSettings::MODULE_STACK_EXPERIENCE)) 	//reading default stack experience bonuses
@@ -685,6 +739,7 @@ void CCreatureHandler::loadCrExpBon(CBonusSystemNode & globalEffects)
 			b->addLimiter(limiter);
 			globalEffects.addNewBonus(b);
 		};
+
 		CLegacyConfigParser parser("DATA/CREXPBON.TXT");
 
 		Bonus b; //prototype with some default properties
@@ -739,53 +794,6 @@ void CCreatureHandler::loadCrExpBon(CBonusSystemNode & globalEffects)
 		}
 		while (parser.endLine());
 
-		//Calculate rank exp values, formula appears complicated bu no parsing needed
-		expRanks.resize(8);
-		int dif = 0;
-		int it = 8000; //ignore name of this variable
-		expRanks[0].push_back(it);
-		for (int j = 1; j < 10; ++j) //used for tiers 8-10, and all other probably
-		{
-			expRanks[0].push_back(expRanks[0][j-1] + it + dif);
-			dif += it/5;
-		}
-		for (int i = 1; i < 8; ++i)
-		{
-			dif = 0;
-			it = 1000 * i;
-			expRanks[i].push_back(it);
-			for (int j = 1; j < 10; ++j)
-			{
-				expRanks[i].push_back(expRanks[i][j-1] + it + dif);
-				dif += it/5;
-			}
-		}
-
-		CLegacyConfigParser expBonParser("DATA/CREXPMOD.TXT");
-
-		expBonParser.endLine(); //header
-
-		maxExpPerBattle.resize(8);
-		for (int i = 1; i < 8; ++i)
-		{
-			expBonParser.readString(); //index
-			expBonParser.readString(); //float multiplier -> hardcoded
-			expBonParser.readString(); //ignore upgrade mod? ->hardcoded
-			expBonParser.readString(); //already calculated
-
-			maxExpPerBattle[i] = static_cast<ui32>(expBonParser.readNumber());
-			expRanks[i].push_back(expRanks[i].back() + static_cast<ui32>(expBonParser.readNumber()));
-
-			expBonParser.endLine();
-		}
-		//skeleton gets exp penalty
-		objects[56].get()->addBonus(-50, Bonus::EXP_MULTIPLIER, -1);
-		objects[57].get()->addBonus(-50, Bonus::EXP_MULTIPLIER, -1);
-		//exp for tier >7, rank 11
-		expRanks[0].push_back(147000);
-		expAfterUpgrade = 75; //percent
-		maxExpPerBattle[0] = maxExpPerBattle[7];
-
 	}//end of Stack Experience
 }
 

+ 3 - 0
lib/CCreatureHandler.h

@@ -304,6 +304,9 @@ public:
 	/// load all stack experience bonuses from H3 files
 	void loadCrExpBon(CBonusSystemNode & globalEffects);
 
+	/// load all stack modifier bonuses from H3 files. TODO: move this to json
+	void loadCrExpMod();
+
 	void afterLoadFinalization() override;
 
 	std::vector<JsonNode> loadLegacyData() override;

+ 1 - 0
lib/CModHandler.cpp

@@ -1170,6 +1170,7 @@ void CModHandler::load()
 			allMods[modName].validation = CModInfo::FAILED;
 
 	logMod->info("\tLoading mod data: %d ms", timer.getDiff());
+	VLC->creh->loadCrExpMod();
 	identifiers.finalize();
 	logMod->info("\tResolving identifiers: %d ms", timer.getDiff());