Jelajahi Sumber

Added separate bonus for native terrain check

Ivan Savenko 2 tahun lalu
induk
melakukan
1459006916
3 mengubah file dengan 8 tambahan dan 4 penghapusan
  1. 4 0
      docs/modders/Bonus/Bonus_Types.md
  2. 3 4
      lib/BasicTypes.cpp
  3. 1 0
      lib/bonuses/BonusEnum.h

+ 4 - 0
docs/modders/Bonus/Bonus_Types.md

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

+ 3 - 4
lib/BasicTypes.cpp

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

+ 1 - 0
lib/bonuses/BonusEnum.h

@@ -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(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(TERRAIN_NATIVE)
 	/* end of list */