1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +02:00

Added separate bonus for native terrain check

This commit is contained in:
Ivan Savenko
2023-10-28 17:54:39 +03:00
parent ab7caa0777
commit 1459006916
3 changed files with 8 additions and 4 deletions

View File

@@ -62,6 +62,10 @@ Eliminates terrain penalty on certain terrain types for affected heroes (Nomads
- subtype: type of terrain - subtype: type of terrain
### TERRAIN_NATIVE
Affected units will view any terrain as native
### PRIMARY_SKILL ### PRIMARY_SKILL
Changes selected primary skill for affected heroes and units Changes selected primary skill for affected heroes and units

View File

@@ -33,14 +33,13 @@ bool INativeTerrainProvider::isNativeTerrain(TerrainId terrain) const
TerrainId AFactionMember::getNativeTerrain() const TerrainId AFactionMember::getNativeTerrain() const
{ {
constexpr auto any = TerrainId(ETerrainId::ANY_TERRAIN); const std::string cachingStringNoTerrainPenalty = "type_TERRAIN_NATIVE_NONE";
const std::string cachingStringNoTerrainPenalty = "type_NO_TERRAIN_PENALTY_sANY"; static const auto selectorNoTerrainPenalty = Selector::typeSubtype(BonusType::TERRAIN_NATIVE, BonusSubtypeID());
static const auto selectorNoTerrainPenalty = Selector::typeSubtype(BonusType::NO_TERRAIN_PENALTY, BonusSubtypeID(any));
//this code is used in the CreatureTerrainLimiter::limit to setup battle bonuses //this code is used in the CreatureTerrainLimiter::limit to setup battle bonuses
//and in the CGHeroInstance::getNativeTerrain() to setup movement bonuses or/and penalties. //and in the CGHeroInstance::getNativeTerrain() to setup movement bonuses or/and penalties.
return getBonusBearer()->hasBonus(selectorNoTerrainPenalty, cachingStringNoTerrainPenalty) return getBonusBearer()->hasBonus(selectorNoTerrainPenalty, cachingStringNoTerrainPenalty)
? any : VLC->factions()->getById(getFaction())->getNativeTerrain(); ? TerrainId::ANY_TERRAIN : VLC->factions()->getById(getFaction())->getNativeTerrain();
} }
int32_t AFactionMember::magicResistance() const int32_t AFactionMember::magicResistance() const

View File

@@ -169,6 +169,7 @@ class JsonNode;
BONUS_NAME(MAX_LEARNABLE_SPELL_LEVEL) /*This can work as wisdom before. val = max learnable spell level*/\ BONUS_NAME(MAX_LEARNABLE_SPELL_LEVEL) /*This can work as wisdom before. val = max learnable spell level*/\
BONUS_NAME(SPELL_SCHOOL_IMMUNITY) /*This bonus will work as spell school immunity for all spells, subtype - spell school: 0 - air, 1 - fire, 2 - water, 3 - earth. Any is not handled for reducing overlap from LEVEL_SPELL_IMMUNITY*/\ BONUS_NAME(SPELL_SCHOOL_IMMUNITY) /*This bonus will work as spell school immunity for all spells, subtype - spell school: 0 - air, 1 - fire, 2 - water, 3 - earth. Any is not handled for reducing overlap from LEVEL_SPELL_IMMUNITY*/\
BONUS_NAME(NEGATIVE_EFFECTS_IMMUNITY) /*This bonus will work as spell school immunity for negative effects from spells of school, subtype - spell school: -1 - any, 0 - air, 1 - fire, 2 - water, 3 - earth*/\ BONUS_NAME(NEGATIVE_EFFECTS_IMMUNITY) /*This bonus will work as spell school immunity for negative effects from spells of school, subtype - spell school: -1 - any, 0 - air, 1 - fire, 2 - water, 3 - earth*/\
BONUS_NAME(TERRAIN_NATIVE)
/* end of list */ /* end of list */