1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Use absoluteLimit

* all "old" limits are now absolute
This commit is contained in:
AlexVinS 2014-05-18 17:55:26 +04:00
parent 3209114393
commit 950ca1156a
6 changed files with 23 additions and 15 deletions

View File

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

View File

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

View File

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

View File

@ -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"];

View File

@ -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

View File

@ -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;