1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-17 01:32:21 +02:00
+ added new flag for special spells. Special spells can be obtained only with BONUS::SPELL.
* made Titans` thunder special.
This commit is contained in:
alexvins
2014-03-07 16:10:20 +00:00
parent 33935ceb67
commit afcb7072eb
5 changed files with 42 additions and 12 deletions

View File

@ -150,6 +150,10 @@
"rising":{ "rising":{
"type":"boolean", "type":"boolean",
"description": "Rising spell (implicitly sets positive)" "description": "Rising spell (implicitly sets positive)"
},
"special":{
"type": "boolean",
"description": "Special spell. Can be given only by Bonus::SPELL"
} }
} }
}, },

View File

@ -2170,7 +2170,8 @@
"flags" : { "flags" : {
"damage": true, "damage": true,
"offensive": true, "offensive": true,
"negative": true "negative": true,
"special": true
} }
}, },
"counterstrike" : { "counterstrike" : {

View File

@ -1375,6 +1375,20 @@ bool CGHeroInstance::canCastThisSpell(const CSpell * spell) const
if(!getArt(ArtifactPosition::SPELLBOOK)) //if hero has no spellbook if(!getArt(ArtifactPosition::SPELLBOOK)) //if hero has no spellbook
return false; return false;
if (spell->isSpecialSpell())
{
if (vstd::contains(spells, spell->id))
{//hero has this spell in spellbook
logGlobal->errorStream() << "Special spell in spellbook "<<spell->name;
}
if (hasBonusOfType(Bonus::SPELL, spell->id))
return true;
return false;
}
else
{
if(vstd::contains(spells, spell->id) //hero has this spell in spellbook 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->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->fire && hasBonusOfType(Bonus::FIRE_SPELLS)) // this is fire spell and hero can cast all fire spells
@ -1386,6 +1400,7 @@ bool CGHeroInstance::canCastThisSpell(const CSpell * spell) const
return true; return true;
return false; return false;
}
} }
/** /**

View File

@ -701,7 +701,7 @@ CSpell * CSpellHandler::loadFromJson(const JsonNode& json)
logGlobal->errorStream() << "No positiveness specified, assumed NEUTRAL"; logGlobal->errorStream() << "No positiveness specified, assumed NEUTRAL";
} }
spell->isSpecial = readFlag(flags,"special");
auto find_in_map = [&](std::string name, std::vector<Bonus::BonusType> &vec) auto find_in_map = [&](std::string name, std::vector<Bonus::BonusType> &vec)
{ {

View File

@ -76,6 +76,8 @@ public:
inline bool isDamageSpell() const; inline bool isDamageSpell() const;
inline bool isOffensiveSpell() const; inline bool isOffensiveSpell() const;
inline bool isSpecialSpell() const;
inline bool hasEffects() const; inline bool hasEffects() const;
void getEffects(std::vector<Bonus> &lst, const int level) const; void getEffects(std::vector<Bonus> &lst, const int level) const;
@ -110,6 +112,8 @@ public:
h & effects & immunities & limiters; h & effects & immunities & limiters;
h & iconImmune; h & iconImmune;
h & absoluteImmunities & defaultProbability; h & absoluteImmunities & defaultProbability;
h & isSpecial;
} }
friend class CSpellHandler; friend class CSpellHandler;
@ -127,6 +131,7 @@ private:
bool isRising; bool isRising;
bool isDamage; bool isDamage;
bool isOffensive; bool isOffensive;
bool isSpecial;
std::string attributes; //reference only attributes //todo: remove or include in configuration format, currently unused 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; return isOffensive;
} }
bool CSpell::isSpecialSpell() const
{
return isSpecial;
}
bool CSpell::hasEffects() const bool CSpell::hasEffects() const
{ {
return effects.size() && effects[0].size(); return effects.size() && effects[0].size();