diff --git a/client/battle/BattleWindow.cpp b/client/battle/BattleWindow.cpp index c5f1734d9..9e24e7ff5 100644 --- a/client/battle/BattleWindow.cpp +++ b/client/battle/BattleWindow.cpp @@ -557,6 +557,15 @@ void BattleWindow::bSpellf() LOCPLINT->showInfoDialog(boost::str(boost::format(CGI->generaltexth->allTexts[683]) % heroName % CGI->artifacts()->getByIndex(artID)->getNameTranslated())); } + else if(blockingBonus->source == BonusSource::OBJECT_TYPE) + { + if(blockingBonus->sid.as() == Obj::GARRISON || blockingBonus->sid.as() == Obj::GARRISON2) + LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[684]); + } + } + else + { + logGlobal->warn("Unexpected problem with readiness to cast spell"); } } diff --git a/lib/mapObjects/CArmedInstance.cpp b/lib/mapObjects/CArmedInstance.cpp index 1420b24bd..3f92fe5dd 100644 --- a/lib/mapObjects/CArmedInstance.cpp +++ b/lib/mapObjects/CArmedInstance.cpp @@ -45,8 +45,8 @@ CArmedInstance::CArmedInstance() { } -CArmedInstance::CArmedInstance(bool isHypotetic): - CBonusSystemNode(isHypotetic), +CArmedInstance::CArmedInstance(bool isHypothetic): + CBonusSystemNode(isHypothetic), nonEvilAlignmentMix(this, nonEvilAlignmentMixSelector), battle(nullptr) { diff --git a/lib/mapObjects/CArmedInstance.h b/lib/mapObjects/CArmedInstance.h index 95cb59d43..815e250dc 100644 --- a/lib/mapObjects/CArmedInstance.h +++ b/lib/mapObjects/CArmedInstance.h @@ -43,7 +43,7 @@ public: ////////////////////////////////////////////////////////////////////////// CArmedInstance(); - CArmedInstance(bool isHypotetic); + CArmedInstance(bool isHypothetic); PlayerColor getOwner() const override { diff --git a/lib/mapObjects/MiscObjects.cpp b/lib/mapObjects/MiscObjects.cpp index 872e57ba4..0b70fac9c 100644 --- a/lib/mapObjects/MiscObjects.cpp +++ b/lib/mapObjects/MiscObjects.cpp @@ -12,6 +12,7 @@ #include "MiscObjects.h" #include "../ArtifactUtils.h" +#include "../bonuses/Propagators.h" #include "../constants/StringConstants.h" #include "../CConfigHandler.h" #include "../CGeneralTextHandler.h" @@ -1005,6 +1006,23 @@ void CGGarrison::serializeJsonOptions(JsonSerializeFormat& handler) CArmedInstance::serializeJsonOptions(handler); } +void CGGarrison::initObj(CRandomGenerator &rand) +{ + if(this->subID == MapObjectSubID::decode(this->ID, "antiMagic")) + addAntimagicGarrisonBonus(); +} + +void CGGarrison::addAntimagicGarrisonBonus() +{ + auto bonus = std::make_shared(); + bonus->type = BonusType::BLOCK_ALL_MAGIC; + bonus->source = BonusSource::OBJECT_TYPE; + bonus->sid = BonusSourceID(this->ID); + bonus->propagator = std::make_shared(CBonusSystemNode::BATTLE); + bonus->duration = BonusDuration::PERMANENT; + this->addNewBonus(bonus); +} + void CGMagi::initObj(CRandomGenerator & rand) { if (ID == Obj::EYE_OF_MAGI) diff --git a/lib/mapObjects/MiscObjects.h b/lib/mapObjects/MiscObjects.h index b3fbe421b..365d13abe 100644 --- a/lib/mapObjects/MiscObjects.h +++ b/lib/mapObjects/MiscObjects.h @@ -60,6 +60,7 @@ class DLL_LINKAGE CGGarrison : public CArmedInstance public: bool removableUnits; + void initObj(CRandomGenerator &rand) override; bool passableFor(PlayerColor color) const override; void onHeroVisit(const CGHeroInstance * h) const override; void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const override; @@ -71,6 +72,7 @@ public: } protected: void serializeJsonOptions(JsonSerializeFormat & handler) override; + void addAntimagicGarrisonBonus(); }; class DLL_LINKAGE CGArtifact : public CArmedInstance