1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-01 00:45:26 +02:00

- support for new heroes and hero classes

- moved hero-specific data from text handler to CHero
- moved hero classes-specific data into heroClasses.json
This commit is contained in:
Ivan Savenko
2012-12-16 13:47:53 +00:00
parent 99e7177d57
commit e36bc50504
18 changed files with 572 additions and 430 deletions

View File

@ -708,19 +708,23 @@ void CGHeroInstance::initHero()
initHeroDefInfo();
if(!type)
type = VLC->heroh->heroes[subID];
if(!vstd::contains(spells, 0xffffffff) && type->startingSpell >= 0) //hero starts with a spell
spells.insert(type->startingSpell);
if(!vstd::contains(spells, 0xffffffff)) //hero starts with a spell
{
BOOST_FOREACH(auto spellID, type->spells)
spells.insert(spellID);
}
else //remove placeholder
spells -= 0xffffffff;
if(!getArt(ArtifactPosition::MACH4) && !getArt(ArtifactPosition::SPELLBOOK) && type->startingSpell >= 0) //no catapult means we haven't read pre-existent set -> use default rules for spellbook
if(!getArt(ArtifactPosition::MACH4) && !getArt(ArtifactPosition::SPELLBOOK) && !type->spells.empty()) //no catapult means we haven't read pre-existent set -> use default rules for spellbook
putArtifact(ArtifactPosition::SPELLBOOK, CArtifactInstance::createNewArtifactInstance(0));
if(!getArt(ArtifactPosition::MACH4))
putArtifact(ArtifactPosition::MACH4, CArtifactInstance::createNewArtifactInstance(3)); //everyone has a catapult
if(portrait < 0 || portrait == 255)
portrait = subID;
portrait = type->imageIndex;
if(!hasBonus(Selector::sourceType(Bonus::HERO_BASE_SKILL)))
{
for(int g=0; g<GameConstants::PRIMARY_SKILLS; ++g)
@ -781,6 +785,8 @@ void CGHeroInstance::initArmy(IArmyDescriptor *dst /*= NULL*/)
else
howManyStacks = 3;
vstd::amin(howManyStacks, type->initialArmy.size());
for(int stackNo=0; stackNo < howManyStacks; stackNo++)
{
auto & stack = type->initialArmy[stackNo];
@ -892,8 +898,7 @@ const std::string & CGHeroInstance::getBiography() const
{
if (biography.length())
return biography;
else
return VLC->generaltexth->hTxts[subID].biography;
return type->biography;
}
void CGHeroInstance::initObj()
{