mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
Merge pull request #3354 from dydzio0614/antimagic-garrison
Add missing antimagic functionality to antimagic garrisons
This commit is contained in:
commit
c8d024ae11
@ -557,6 +557,15 @@ void BattleWindow::bSpellf()
|
|||||||
LOCPLINT->showInfoDialog(boost::str(boost::format(CGI->generaltexth->allTexts[683])
|
LOCPLINT->showInfoDialog(boost::str(boost::format(CGI->generaltexth->allTexts[683])
|
||||||
% heroName % CGI->artifacts()->getByIndex(artID)->getNameTranslated()));
|
% heroName % CGI->artifacts()->getByIndex(artID)->getNameTranslated()));
|
||||||
}
|
}
|
||||||
|
else if(blockingBonus->source == BonusSource::OBJECT_TYPE)
|
||||||
|
{
|
||||||
|
if(blockingBonus->sid.as<MapObjectID>() == Obj::GARRISON || blockingBonus->sid.as<MapObjectID>() == Obj::GARRISON2)
|
||||||
|
LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[684]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logGlobal->warn("Unexpected problem with readiness to cast spell");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,8 +45,8 @@ CArmedInstance::CArmedInstance()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CArmedInstance::CArmedInstance(bool isHypotetic):
|
CArmedInstance::CArmedInstance(bool isHypothetic):
|
||||||
CBonusSystemNode(isHypotetic),
|
CBonusSystemNode(isHypothetic),
|
||||||
nonEvilAlignmentMix(this, nonEvilAlignmentMixSelector),
|
nonEvilAlignmentMix(this, nonEvilAlignmentMixSelector),
|
||||||
battle(nullptr)
|
battle(nullptr)
|
||||||
{
|
{
|
||||||
|
@ -43,7 +43,7 @@ public:
|
|||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
CArmedInstance();
|
CArmedInstance();
|
||||||
CArmedInstance(bool isHypotetic);
|
CArmedInstance(bool isHypothetic);
|
||||||
|
|
||||||
PlayerColor getOwner() const override
|
PlayerColor getOwner() const override
|
||||||
{
|
{
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "MiscObjects.h"
|
#include "MiscObjects.h"
|
||||||
|
|
||||||
#include "../ArtifactUtils.h"
|
#include "../ArtifactUtils.h"
|
||||||
|
#include "../bonuses/Propagators.h"
|
||||||
#include "../constants/StringConstants.h"
|
#include "../constants/StringConstants.h"
|
||||||
#include "../CConfigHandler.h"
|
#include "../CConfigHandler.h"
|
||||||
#include "../CGeneralTextHandler.h"
|
#include "../CGeneralTextHandler.h"
|
||||||
@ -1005,6 +1006,23 @@ void CGGarrison::serializeJsonOptions(JsonSerializeFormat& handler)
|
|||||||
CArmedInstance::serializeJsonOptions(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>();
|
||||||
|
bonus->type = BonusType::BLOCK_ALL_MAGIC;
|
||||||
|
bonus->source = BonusSource::OBJECT_TYPE;
|
||||||
|
bonus->sid = BonusSourceID(this->ID);
|
||||||
|
bonus->propagator = std::make_shared<CPropagatorNodeType>(CBonusSystemNode::BATTLE);
|
||||||
|
bonus->duration = BonusDuration::PERMANENT;
|
||||||
|
this->addNewBonus(bonus);
|
||||||
|
}
|
||||||
|
|
||||||
void CGMagi::initObj(CRandomGenerator & rand)
|
void CGMagi::initObj(CRandomGenerator & rand)
|
||||||
{
|
{
|
||||||
if (ID == Obj::EYE_OF_MAGI)
|
if (ID == Obj::EYE_OF_MAGI)
|
||||||
|
@ -60,6 +60,7 @@ class DLL_LINKAGE CGGarrison : public CArmedInstance
|
|||||||
public:
|
public:
|
||||||
bool removableUnits;
|
bool removableUnits;
|
||||||
|
|
||||||
|
void initObj(CRandomGenerator &rand) override;
|
||||||
bool passableFor(PlayerColor color) const override;
|
bool passableFor(PlayerColor color) const override;
|
||||||
void onHeroVisit(const CGHeroInstance * h) const override;
|
void onHeroVisit(const CGHeroInstance * h) const override;
|
||||||
void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const override;
|
void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const override;
|
||||||
@ -71,6 +72,7 @@ public:
|
|||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
void serializeJsonOptions(JsonSerializeFormat & handler) override;
|
void serializeJsonOptions(JsonSerializeFormat & handler) override;
|
||||||
|
void addAntimagicGarrisonBonus();
|
||||||
};
|
};
|
||||||
|
|
||||||
class DLL_LINKAGE CGArtifact : public CArmedInstance
|
class DLL_LINKAGE CGArtifact : public CArmedInstance
|
||||||
|
Loading…
Reference in New Issue
Block a user