Browse Source

vcmi: convert intelligence

Intelligence is converted to both global effect and skill bonus

Bonus name HERO_MANA_PER_TEN_KNOWLEDGE is a little weird, but works
like old SECONDARY_SKILL_PREMY bonus
Konstantin 2 years ago
parent
commit
a0987313ba

+ 5 - 0
client/windows/CHeroWindow.cpp

@@ -61,6 +61,11 @@ int64_t CHeroWithMaybePickedArtifact::getTreeVersion() const
 	return hero->getTreeVersion();  //this assumes that hero and artifact belongs to main bonus tree
 }
 
+si32 CHeroWithMaybePickedArtifact::manaLimit() const
+{
+	return hero->manaLimit();
+}
+
 CHeroWithMaybePickedArtifact::CHeroWithMaybePickedArtifact(CWindowWithArtifacts * Cww, const CGHeroInstance * Hero)
 	: hero(Hero), cww(Cww)
 {

+ 2 - 0
client/windows/CHeroWindow.h

@@ -55,6 +55,8 @@ public:
 	TConstBonusListPtr getAllBonuses(const CSelector & selector, const CSelector & limit, const CBonusSystemNode * root = nullptr, const std::string & cachingStr = "") const override;
 
 	int64_t getTreeVersion() const override;
+
+	si32 manaLimit() const override;
 };
 
 class CHeroWindow : public CStatusbarWindow, public CGarrisonHolder, public CWindowWithArtifacts

+ 5 - 0
config/defaultMods.json

@@ -68,6 +68,11 @@
 			"type" : "HERO_EXPERIENCE_GAIN_PERCENT", //default hero xp
 			"val" : 100,
 			"valueType" : "BASE_NUMBER"
+		},
+		{
+			"type" : "MANA_PER_KNOWLEDGE", //10 knowledge to 100 mana is default
+			"val" : 10,
+			"valueType" : "BASE_NUMBER"
 		}
 	]
 }

+ 3 - 3
config/heroes/fortress.json

@@ -281,11 +281,11 @@
 		"specialty" : {
 			"bonuses" : {
 				"intelligence" : {
-					"subtype" : "skill.intelligence",
-					"type" : "SECONDARY_SKILL_PREMY",
+					"targetSourceType" : "SECONDARY_SKILL",
+					"type" : "MANA_PER_KNOWLEDGE",
 					"updater" : "TIMES_HERO_LEVEL",
 					"val" : 5,
-					"valueType" : "PERCENT_TO_BASE"
+					"valueType" : "PERCENT_TO_TARGET_TYPE"
 				}
 			}
 		}

+ 3 - 3
config/heroes/inferno.json

@@ -128,11 +128,11 @@
 		"specialty" : {
 			"bonuses" : {
 				"intelligence" : {
-					"subtype" : "skill.intelligence",
-					"type" : "SECONDARY_SKILL_PREMY",
+					"targetSourceType" : "SECONDARY_SKILL",
+					"type" : "MANA_PER_KNOWLEDGE",
 					"updater" : "TIMES_HERO_LEVEL",
 					"val" : 5,
-					"valueType" : "PERCENT_TO_BASE"
+					"valueType" : "PERCENT_TO_TARGET_TYPE"
 				}
 			}
 		}

+ 3 - 3
config/heroes/rampart.json

@@ -197,11 +197,11 @@
 		"specialty" : {
 			"bonuses" : {
 				"intelligence" : {
-					"subtype" : "skill.intelligence",
-					"type" : "SECONDARY_SKILL_PREMY",
+					"targetSourceType" : "SECONDARY_SKILL",
+					"type" : "MANA_PER_KNOWLEDGE",
 					"updater" : "TIMES_HERO_LEVEL",
 					"val" : 5,
-					"valueType" : "PERCENT_TO_BASE"
+					"valueType" : "PERCENT_TO_TARGET_TYPE"
 				}
 			}
 		}

+ 2 - 3
config/skills.json

@@ -708,9 +708,8 @@
 		"base" : {
 			"effects" : {
 				"main" : {
-					"subtype" : "skill.intelligence",
-					"type" : "SECONDARY_SKILL_PREMY",
-					"valueType" : "BASE_NUMBER"
+					"type" : "MANA_PER_KNOWLEDGE",
+					"valueType" : "PERCENT_TO_BASE"
 				}
 			}
 		},

+ 1 - 3
lib/HeroBonus.cpp

@@ -834,9 +834,7 @@ int IBonusBearer::getMaxDamage(bool ranged) const
 
 si32 IBonusBearer::manaLimit() const
 {
-	return si32(getPrimSkillLevel(PrimarySkill::KNOWLEDGE)
-		* (100.0 + valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::INTELLIGENCE))
-		/ 10.0);
+	return 0;
 }
 
 int IBonusBearer::getPrimSkillLevel(PrimarySkill::PrimarySkill id) const

+ 2 - 1
lib/HeroBonus.h

@@ -342,6 +342,7 @@ public:
 	BONUS_NAME(BEFORE_BATTLE_REPOSITION_BLOCK) /*skill-agnostic tactics, bonus for blocking opposite tactics. For now donble side tactics is TODO.*/\
 	BONUS_NAME(HERO_EXPERIENCE_GAIN_PERCENT) /*skill-agnostic learning, and we can use it as a global effect also*/\
 	BONUS_NAME(UNDEAD_RAISE_PERCENTAGE) /*Percentage of killed enemy creatures to be raised after battle as undead*/\
+	BONUS_NAME(MANA_PER_KNOWLEDGE) /*Rate of translating hero knowledge to mana, used for intelligence and as a global bonus*/\
 	/* end of list */
 
 
@@ -743,7 +744,7 @@ public:
 	virtual si32 magicResistance() const;
 	ui32 Speed(int turn = 0, bool useBind = false) const; //get speed of creature with all modificators
 
-	si32 manaLimit() const; //maximum mana value for this hero (basically 10*knowledge)
+	virtual si32 manaLimit() const; //maximum mana value for this hero (basically 10*knowledge)
 	int getPrimSkillLevel(PrimarySkill::PrimarySkill id) const;
 
 	virtual int64_t getTreeVersion() const = 0;

+ 6 - 0
lib/mapObjects/CGHeroInstance.cpp

@@ -988,6 +988,12 @@ std::string CGHeroInstance::nodeName() const
 	return "Hero " + getNameTextID();
 }
 
+si32 CGHeroInstance::manaLimit() const
+{
+	return si32(getPrimSkillLevel(PrimarySkill::KNOWLEDGE)
+		* (valOfBonuses(Bonus::MANA_PER_KNOWLEDGE)));
+}
+
 std::string CGHeroInstance::getNameTranslated() const
 {
 	if (!nameCustom.empty())

+ 1 - 0
lib/mapObjects/CGHeroInstance.h

@@ -256,6 +256,7 @@ public:
 	///IBonusBearer
 	CBonusSystemNode & whereShouldBeAttached(CGameState * gs) override;
 	std::string nodeName() const override;
+	si32 manaLimit() const override;
 
 	CBonusSystemNode * whereShouldBeAttachedOnSiege(const bool isBattleOutsideTown) const;
 	CBonusSystemNode * whereShouldBeAttachedOnSiege(CGameState * gs);