Browse Source

Use absoluteLimit
* all "old" limits are now absolute

AlexVinS 11 năm trước cách đây
mục cha
commit
950ca1156a

+ 1 - 1
config/spells/offensive.json

@@ -362,7 +362,7 @@
 			"offensive": true,
 			"negative": true
 		},
-		"limit" : {
+		"absoluteLimit" : {
 			"UNDEAD": true
 		},
 		"immunity" : {

+ 1 - 1
config/spells/other.json

@@ -241,7 +241,7 @@
 			"rising": true,
 			"positive": true
 		},
-		"limit" : {
+		"absoluteLimit" : {
 			"UNDEAD": true
 		}
 	},

+ 2 - 2
config/spells/timed.json

@@ -781,7 +781,7 @@
 				}
 			}
 		},
-		"limit" : {
+		"absoluteLimit" : {
 			"SHOOTER": true
 		},
 		"flags" : {
@@ -1846,7 +1846,7 @@
 				}
 			}
 		},
-		"limit" : {
+		"absoluteLimit" : {
 			"SHOOTER": true
 		},
 		"immunity" : {

+ 15 - 8
lib/CSpellHandler.cpp

@@ -413,15 +413,14 @@ void CSpell::getEffects(std::vector<Bonus>& lst, const int level) const
 bool CSpell::isImmuneBy(const IBonusBearer* obj) const
 {
 	//todo: use new bonus API
-	//1. Check limiters
-	for(auto b : limiters)
+	//1. Check absolute limiters
+	for(auto b : absoluteLimiters)
 	{
 		if (!obj->hasBonusOfType(b))
 			return true;
 	}
 
 	//2. Check absolute immunities
-	//todo: check config: some creatures are unaffected always, for example undead to resurrection.
 	for(auto b : absoluteImmunities)
 	{
 		if (obj->hasBonusOfType(b))
@@ -429,10 +428,19 @@ bool CSpell::isImmuneBy(const IBonusBearer* obj) const
 	}
 
 	//3. Check negation
+	//FIXME: Orb of vulnerability mechanics is not such trivial
 	if(obj->hasBonusOfType(Bonus::NEGATE_ALL_NATURAL_IMMUNITIES)) //Orb of vulnerability
 		return false;
+		
+	//4. Check negatable limit
+	for(auto b : limiters)
+	{
+		if (!obj->hasBonusOfType(b))
+			return true;
+	}
+
 
-	//4. Check negatable immunities
+	//5. Check negatable immunities
 	for(auto b : immunities)
 	{
 		if (obj->hasBonusOfType(b))
@@ -451,7 +459,7 @@ bool CSpell::isImmuneBy(const IBonusBearer* obj) const
 		return false;
 	};
 
-	//4. Check elemental immunities
+	//6. Check elemental immunities
 	if(fire)
 	{
 		if(battleTestElementalImmunity(Bonus::FIRE_IMMUNITY))
@@ -786,10 +794,9 @@ CSpell * CSpellHandler::loadFromJson(const JsonNode& json)
 	};
 
 	readBonusStruct("immunity", spell->immunities);
-
 	readBonusStruct("absoluteImmunity", spell->absoluteImmunities);
-
-	readBonusStruct("limit", spell->limiters);
+	readBonusStruct("limit", spell->limiters);	
+	readBonusStruct("absoluteLimit", spell->absoluteLimiters);
 
 
 	const JsonNode & graphicsNode = json["graphics"];

+ 3 - 2
lib/CSpellHandler.h

@@ -138,9 +138,9 @@ public:
 		  & probabilities  & attributes & combatSpell & creatureAbility & positiveness & counteredSpells & mainEffectAnim;
 		h & isRising & isDamage & isOffensive;
 		h & targetType;
-		h & immunities & limiters;
+		h & immunities & limiters & absoluteImmunities & absoluteLimiters;
 		h & iconImmune;
-		h & absoluteImmunities & defaultProbability;
+		h & defaultProbability;
 
 		h & isSpecial;
 
@@ -171,6 +171,7 @@ private:
 	std::vector<Bonus::BonusType> immunities; //any of these grants immunity
 	std::vector<Bonus::BonusType> absoluteImmunities; //any of these grants immunity, can't be negated
 	std::vector<Bonus::BonusType> limiters; //all of them are required to be affected
+	std::vector<Bonus::BonusType> absoluteLimiters; //all of them are required to be affected, can't be negated
 
 	///graphics related stuff
 

+ 1 - 1
lib/Connection.h

@@ -28,7 +28,7 @@
 #include "mapping/CCampaignHandler.h" //for CCampaignState
 #include "rmg/CMapGenerator.h" // for CMapGenOptions
 
-const ui32 version = 748;
+const ui32 version = 749;
 const ui32 minSupportedVersion = version;
 
 class CConnection;