Przeglądaj źródła

Allow learning banned spell from Scholars (H3 logic)

Ivan Savenko 2 lat temu
rodzic
commit
8f33fdcd83

+ 2 - 2
lib/mapObjects/CGHeroInstance.cpp

@@ -770,7 +770,7 @@ bool CGHeroInstance::canCastThisSpell(const spells::Spell * spell) const
 	}
 }
 
-bool CGHeroInstance::canLearnSpell(const spells::Spell * spell) const
+bool CGHeroInstance::canLearnSpell(const spells::Spell * spell, bool allowBanned) const
 {
 	if(!hasSpellbook())
 		return false;
@@ -793,7 +793,7 @@ bool CGHeroInstance::canLearnSpell(const spells::Spell * spell) const
 		return false;//creature abilities can not be learned
 	}
 
-	if(!IObjectInterface::cb->isAllowed(0, spell->getIndex()))
+	if(!allowBanned && !IObjectInterface::cb->isAllowed(0, spell->getIndex()))
 	{
 		logGlobal->warn("Hero %s try to learn banned spell %s", nodeName(), spell->getNameTranslated());
 		return false;//banned spells should not be learned

+ 1 - 1
lib/mapObjects/CGHeroInstance.h

@@ -172,7 +172,7 @@ public:
 	int getCurrentLuck(int stack=-1, bool town=false) const;
 	int32_t getSpellCost(const spells::Spell * sp) const; //do not use during battles -> bonuses from army would be ignored
 
-	bool canLearnSpell(const spells::Spell * spell) const;
+	bool canLearnSpell(const spells::Spell * spell,  bool allowBanned = false) const;
 	bool canCastThisSpell(const spells::Spell * spell) const; //determines if this hero can cast given spell; takes into account existing spell in spellbook, existing spellbook and artifact bonuses
 
 	/// convert given position between map position (CGObjectInstance::pos) and visitable position used for hero interactions

+ 1 - 1
lib/rewardable/Limiter.cpp

@@ -127,7 +127,7 @@ bool Rewardable::Limiter::heroAllowed(const CGHeroInstance * hero) const
 
 	for(const auto & spell : canLearnSpells)
 	{
-		if (!hero->canLearnSpell(spell.toSpell(VLC->spells())))
+		if (!hero->canLearnSpell(spell.toSpell(VLC->spells()), true))
 			return false;
 	}