mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Implemented #1379
+ added new flag for special spells. Special spells can be obtained only with BONUS::SPELL. * made Titans` thunder special.
This commit is contained in:
parent
33935ceb67
commit
afcb7072eb
@ -150,6 +150,10 @@
|
||||
"rising":{
|
||||
"type":"boolean",
|
||||
"description": "Rising spell (implicitly sets positive)"
|
||||
},
|
||||
"special":{
|
||||
"type": "boolean",
|
||||
"description": "Special spell. Can be given only by Bonus::SPELL"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -2170,7 +2170,8 @@
|
||||
"flags" : {
|
||||
"damage": true,
|
||||
"offensive": true,
|
||||
"negative": true
|
||||
"negative": true,
|
||||
"special": true
|
||||
}
|
||||
},
|
||||
"counterstrike" : {
|
||||
|
@ -1375,17 +1375,32 @@ bool CGHeroInstance::canCastThisSpell(const CSpell * spell) const
|
||||
if(!getArt(ArtifactPosition::SPELLBOOK)) //if hero has no spellbook
|
||||
return false;
|
||||
|
||||
if(vstd::contains(spells, spell->id) //hero has this spell in spellbook
|
||||
|| (spell->air && hasBonusOfType(Bonus::AIR_SPELLS)) // this is air spell and hero can cast all air spells
|
||||
|| (spell->fire && hasBonusOfType(Bonus::FIRE_SPELLS)) // this is fire spell and hero can cast all fire spells
|
||||
|| (spell->water && hasBonusOfType(Bonus::WATER_SPELLS)) // this is water spell and hero can cast all water spells
|
||||
|| (spell->earth && hasBonusOfType(Bonus::EARTH_SPELLS)) // this is earth spell and hero can cast all earth spells
|
||||
|| hasBonusOfType(Bonus::SPELL, spell->id)
|
||||
|| hasBonusOfType(Bonus::SPELLS_OF_LEVEL, spell->level)
|
||||
)
|
||||
return true;
|
||||
if (spell->isSpecialSpell())
|
||||
{
|
||||
if (vstd::contains(spells, spell->id))
|
||||
{//hero has this spell in spellbook
|
||||
logGlobal->errorStream() << "Special spell in spellbook "<<spell->name;
|
||||
}
|
||||
|
||||
return false;
|
||||
if (hasBonusOfType(Bonus::SPELL, spell->id))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(vstd::contains(spells, spell->id) //hero has this spell in spellbook
|
||||
|| (spell->air && hasBonusOfType(Bonus::AIR_SPELLS)) // this is air spell and hero can cast all air spells
|
||||
|| (spell->fire && hasBonusOfType(Bonus::FIRE_SPELLS)) // this is fire spell and hero can cast all fire spells
|
||||
|| (spell->water && hasBonusOfType(Bonus::WATER_SPELLS)) // this is water spell and hero can cast all water spells
|
||||
|| (spell->earth && hasBonusOfType(Bonus::EARTH_SPELLS)) // this is earth spell and hero can cast all earth spells
|
||||
|| hasBonusOfType(Bonus::SPELL, spell->id)
|
||||
|| hasBonusOfType(Bonus::SPELLS_OF_LEVEL, spell->level)
|
||||
)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -701,7 +701,7 @@ CSpell * CSpellHandler::loadFromJson(const JsonNode& json)
|
||||
logGlobal->errorStream() << "No positiveness specified, assumed NEUTRAL";
|
||||
}
|
||||
|
||||
|
||||
spell->isSpecial = readFlag(flags,"special");
|
||||
|
||||
auto find_in_map = [&](std::string name, std::vector<Bonus::BonusType> &vec)
|
||||
{
|
||||
|
@ -76,6 +76,8 @@ public:
|
||||
inline bool isDamageSpell() const;
|
||||
inline bool isOffensiveSpell() const;
|
||||
|
||||
inline bool isSpecialSpell() const;
|
||||
|
||||
inline bool hasEffects() const;
|
||||
void getEffects(std::vector<Bonus> &lst, const int level) const;
|
||||
|
||||
@ -110,6 +112,8 @@ public:
|
||||
h & effects & immunities & limiters;
|
||||
h & iconImmune;
|
||||
h & absoluteImmunities & defaultProbability;
|
||||
|
||||
h & isSpecial;
|
||||
}
|
||||
friend class CSpellHandler;
|
||||
|
||||
@ -127,6 +131,7 @@ private:
|
||||
bool isRising;
|
||||
bool isDamage;
|
||||
bool isOffensive;
|
||||
bool isSpecial;
|
||||
|
||||
std::string attributes; //reference only attributes //todo: remove or include in configuration format, currently unused
|
||||
|
||||
@ -189,6 +194,11 @@ bool CSpell::isOffensiveSpell() const
|
||||
return isOffensive;
|
||||
}
|
||||
|
||||
bool CSpell::isSpecialSpell() const
|
||||
{
|
||||
return isSpecial;
|
||||
}
|
||||
|
||||
bool CSpell::hasEffects() const
|
||||
{
|
||||
return effects.size() && effects[0].size();
|
||||
|
Loading…
Reference in New Issue
Block a user