mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +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:
@ -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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -2170,7 +2170,8 @@
|
|||||||
"flags" : {
|
"flags" : {
|
||||||
"damage": true,
|
"damage": true,
|
||||||
"offensive": true,
|
"offensive": true,
|
||||||
"negative": true
|
"negative": true,
|
||||||
|
"special": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"counterstrike" : {
|
"counterstrike" : {
|
||||||
|
@ -1375,17 +1375,32 @@ 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(vstd::contains(spells, spell->id) //hero has this spell in spellbook
|
if (spell->isSpecialSpell())
|
||||||
|| (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
|
if (vstd::contains(spells, spell->id))
|
||||||
|| (spell->water && hasBonusOfType(Bonus::WATER_SPELLS)) // this is water spell and hero can cast all water spells
|
{//hero has this spell in spellbook
|
||||||
|| (spell->earth && hasBonusOfType(Bonus::EARTH_SPELLS)) // this is earth spell and hero can cast all earth spells
|
logGlobal->errorStream() << "Special spell in spellbook "<<spell->name;
|
||||||
|| hasBonusOfType(Bonus::SPELL, spell->id)
|
}
|
||||||
|| hasBonusOfType(Bonus::SPELLS_OF_LEVEL, spell->level)
|
|
||||||
)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
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";
|
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)
|
||||||
{
|
{
|
||||||
|
@ -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();
|
||||||
|
Reference in New Issue
Block a user