1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-17 20:58:07 +02:00

Ban Navigation on maps without water

This commit is contained in:
Tomasz Zieliński 2023-07-18 10:54:36 +02:00
parent 025b0814c8
commit 03b3771f19
5 changed files with 24 additions and 1 deletions

View File

@ -164,7 +164,8 @@
"effects" : {
"main" : { "val" : 150 }
}
}
},
"onlyOnWaterMap" : true
},
"leadership" : {
"index" : 6,

View File

@ -199,6 +199,8 @@ CSkill * CSkillHandler::loadFromJson(const std::string & scope, const JsonNode &
auto * skill = new CSkill(SecondarySkill((si32)index), identifier, major, minor);
skill->modScope = scope;
skill->onlyOnWaterMap = json["onlyOnWaterMap"].Bool();
VLC->generaltexth->registerString(scope, skill->getNameTextID(), json["name"].String());
switch(json["gainChance"].getType())
{

View File

@ -80,6 +80,8 @@ public:
void updateFrom(const JsonNode & data);
void serializeJson(JsonSerializeFormat & handler);
bool onlyOnWaterMap;
template <typename Handler> void serialize(Handler & h, const int version)
{
h & id;
@ -88,6 +90,7 @@ public:
h & levels;
h & obligatoryMajor;
h & obligatoryMinor;
h & onlyOnWaterMap;
}
friend class CSkillHandler;

View File

@ -585,6 +585,7 @@ void CMap::banWaterContent()
banWaterHeroes();
banWaterArtifacts();
banWaterSpells();
banWaterSkills();
}
void CMap::banWaterSpells()
@ -617,6 +618,21 @@ void CMap::banWaterArtifacts()
}
}
void CMap::banWaterSkills()
{
for (int j = 0; j < allowedAbilities.size(); j++)
{
if (allowedAbilities[j])
{
auto* skill = dynamic_cast<const CSkill*>(VLC->skills()->getByIndex(j));
if (skill->onlyOnWaterMap && !isWaterMap())
{
allowedAbilities[j] = false;
}
}
}
}
void CMap::banWaterHeroes()
{
for (int j = 0; j < allowedHeroes.size(); j++)

View File

@ -112,6 +112,7 @@ public:
void banWaterHeroes();
void banHero(const HeroTypeID& id);
void banWaterSpells();
void banWaterSkills();
void banWaterContent();
/// Gets object of specified type on requested position