1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Moved checks for campaign heroes to CGHeroInstance class

This commit is contained in:
Ivan Savenko 2024-01-30 23:33:58 +02:00
parent 5d8b65befd
commit 3abc26e789
5 changed files with 46 additions and 5 deletions

View File

@ -967,11 +967,7 @@ void CCastleBuildings::enterMagesGuild()
if(hero && !hero->hasSpellbook()) //hero doesn't have spellbok
{
const StartInfo *si = LOCPLINT->cb->getStartInfo();
// it would be nice to find a way to move this hack to config/mapOverrides.json
if(si && si->campState && // We're in campaign,
(si->campState->getFilename() == "DATA/YOG.H3C") && // which is "Birth of a Barbarian",
(hero->getHeroType() == 45)) // and the hero is Yog (based on Solmyr)
if(hero->isCampaignYog())
{
// "Yog has given up magic in all its forms..."
LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[736]);

View File

@ -53,6 +53,9 @@ const QueryID QueryID::NONE(-1);
const QueryID QueryID::CLIENT(-2);
const HeroTypeID HeroTypeID::NONE(-1);
const HeroTypeID HeroTypeID::RANDOM(-2);
const HeroTypeID HeroTypeID::GEM(27);
const HeroTypeID HeroTypeID::SOLMYR(45);
const ObjectInstanceID ObjectInstanceID::NONE(-1);
const SlotID SlotID::COMMANDER_SLOT_PLACEHOLDER(-2);

View File

@ -102,6 +102,8 @@ public:
static const HeroTypeID NONE;
static const HeroTypeID RANDOM;
static const HeroTypeID GEM; // aka Gem, Sorceress in campaign
static const HeroTypeID SOLMYR; // aka Young Yog in campaigns
bool isValid() const
{

View File

@ -1799,4 +1799,40 @@ void CGHeroInstance::fillUpgradeInfo(UpgradeInfo & info, const CStackInstance &s
}
}
bool CGHeroInstance::isCampaignYog() const
{
const StartInfo *si = cb->getStartInfo();
// it would be nice to find a way to move this hack to config/mapOverrides.json
if(!si || !si->campState)
return false;
std::string campaign = si->campState->getFilename();
if (!boost::starts_with(campaign, "DATA/YOG")) // "Birth of a Barbarian"
return false;
if (getHeroType() != HeroTypeID::SOLMYR) // Yog (based on Solmyr)
return false;
return true;
}
bool CGHeroInstance::isCampaignGem() const
{
const StartInfo *si = cb->getStartInfo();
// it would be nice to find a way to move this hack to config/mapOverrides.json
if(!si || !si->campState)
return false;
std::string campaign = si->campState->getFilename();
if (!boost::starts_with(campaign, "DATA/GEM") && !boost::starts_with(campaign, "DATA/FINAL")) // "New Beginning" and "Unholy Alliance"
return false;
if (getHeroType() != HeroTypeID::GEM) // Yog (based on Solmyr)
return false;
return true;
}
VCMI_LIB_NAMESPACE_END

View File

@ -305,6 +305,10 @@ public:
bool isCoastVisitable() const override;
bool isBlockedVisitable() const override;
BattleField getBattlefield() const override;
bool isCampaignYog() const;
bool isCampaignGem() const;
protected:
void setPropertyDer(ObjProperty what, ObjPropertyID identifier) override;//synchr
///common part of hero instance and hero definition