mirror of
https://github.com/vcmi/vcmi.git
synced 2025-09-16 09:26:28 +02:00
simplified CGScholar::onHeroVisit
This commit is contained in:
@@ -1702,16 +1702,12 @@ void CGSignBottle::serializeJsonOptions(JsonSerializeFormat& handler)
|
|||||||
|
|
||||||
void CGScholar::onHeroVisit( const CGHeroInstance * h ) const
|
void CGScholar::onHeroVisit( const CGHeroInstance * h ) const
|
||||||
{
|
{
|
||||||
|
|
||||||
EBonusType type = bonusType;
|
EBonusType type = bonusType;
|
||||||
int bid = bonusID;
|
int bid = bonusID;
|
||||||
//check if the bonus if applicable, if not - give primary skill (always possible)
|
//check if the bonus if applicable, if not - give primary skill (always possible)
|
||||||
int ssl = h->getSecSkillLevel(SecondarySkill(bid)); //current sec skill level, used if bonusType == 1
|
int ssl = h->getSecSkillLevel(SecondarySkill(bid)); //current sec skill level, used if bonusType == 1
|
||||||
if((type == SECONDARY_SKILL
|
if((type == SECONDARY_SKILL && ((ssl == 3) || (!ssl && !h->canLearnSkill()))) ////hero already has expert level in the skill or (don't know skill and doesn't have free slot)
|
||||||
&& ((ssl == 3) || (!ssl && !h->canLearnSkill()))) ////hero already has expert level in the skill or (don't know skill and doesn't have free slot)
|
|| (type == SPELL && !h->canLearnSpell(SpellID(bid).toSpell())))
|
||||||
|| (type == SPELL && (!h->getArt(ArtifactPosition::SPELLBOOK) || vstd::contains(h->spells, (ui32) bid)
|
|
||||||
|| ( SpellID(bid).toSpell()->level > h->getSecSkillLevel(SecondarySkill::WISDOM) + 2)
|
|
||||||
))) //hero doesn't have a spellbook or already knows the spell or doesn't have Wisdom
|
|
||||||
{
|
{
|
||||||
type = PRIM_SKILL;
|
type = PRIM_SKILL;
|
||||||
bid = CRandomGenerator::getDefault().nextInt(GameConstants::PRIMARY_SKILLS - 1);
|
bid = CRandomGenerator::getDefault().nextInt(GameConstants::PRIMARY_SKILLS - 1);
|
||||||
|
Reference in New Issue
Block a user