mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +02:00
Fixed initialization of heroes in taverns
This commit is contained in:
@ -1390,18 +1390,7 @@ void HeroRecruited::applyGs(CGameState * gs) const
|
||||
|
||||
h->setOwner(player);
|
||||
h->pos = tile;
|
||||
bool fresh = !h->isInitialized();
|
||||
if(fresh)
|
||||
{ // this is a fresh hero who hasn't appeared yet
|
||||
if (boatId >= 0) //Hero spawns on water
|
||||
{
|
||||
h->setMovementPoints(h->movementPointsLimit(false));
|
||||
}
|
||||
else
|
||||
{
|
||||
h->setMovementPoints(h->movementPointsLimit(true));
|
||||
}
|
||||
}
|
||||
h->initObj(gs->getRandomGenerator());
|
||||
|
||||
if(h->id == ObjectInstanceID())
|
||||
{
|
||||
@ -1414,16 +1403,10 @@ void HeroRecruited::applyGs(CGameState * gs) const
|
||||
gs->map->heroesOnMap.emplace_back(h);
|
||||
p->heroes.emplace_back(h);
|
||||
h->attachTo(*p);
|
||||
if(fresh)
|
||||
{
|
||||
h->initObj(gs->getRandomGenerator());
|
||||
}
|
||||
gs->map->addBlockVisTiles(h);
|
||||
|
||||
if(t)
|
||||
{
|
||||
t->setVisitingHero(h);
|
||||
}
|
||||
}
|
||||
|
||||
void GiveHero::applyGs(CGameState * gs) const
|
||||
|
@ -255,6 +255,7 @@ CGHeroInstance::CGHeroInstance():
|
||||
setNodeType(HERO);
|
||||
ID = Obj::HERO;
|
||||
secSkills.emplace_back(SecondarySkill::DEFAULT, -1);
|
||||
blockVisit = true;
|
||||
}
|
||||
|
||||
PlayerColor CGHeroInstance::getOwner() const
|
||||
@ -364,8 +365,19 @@ void CGHeroInstance::initHero(CRandomGenerator & rand)
|
||||
commander->giveStackExp (exp); //after our exp is set
|
||||
}
|
||||
|
||||
if (mana < 0)
|
||||
mana = manaLimit();
|
||||
skillsInfo.rand.setSeed(rand.nextInt());
|
||||
skillsInfo.resetMagicSchoolCounter();
|
||||
skillsInfo.resetWisdomCounter();
|
||||
|
||||
//copy active (probably growing) bonuses from hero prototype to hero object
|
||||
for(const std::shared_ptr<Bonus> & b : type->specialty)
|
||||
addNewBonus(b);
|
||||
|
||||
//initialize bonuses
|
||||
recreateSecondarySkillsBonuses();
|
||||
|
||||
movement = movementPointsLimit(true);
|
||||
mana = manaLimit(); //after all bonuses are taken into account, make sure this line is the last one
|
||||
}
|
||||
|
||||
void CGHeroInstance::initArmy(CRandomGenerator & rand, IArmyDescriptor * dst)
|
||||
@ -533,15 +545,9 @@ void CGHeroInstance::SecondarySkillsInfo::resetWisdomCounter()
|
||||
|
||||
void CGHeroInstance::initObj(CRandomGenerator & rand)
|
||||
{
|
||||
blockVisit = true;
|
||||
|
||||
if(!type)
|
||||
initHero(rand); //TODO: set up everything for prison before specialties are configured
|
||||
|
||||
skillsInfo.rand.setSeed(rand.nextInt());
|
||||
skillsInfo.resetMagicSchoolCounter();
|
||||
skillsInfo.resetWisdomCounter();
|
||||
|
||||
if (ID != Obj::PRISON)
|
||||
{
|
||||
auto terrain = cb->gameState()->getTile(visitablePos())->terType->getId();
|
||||
@ -549,15 +555,6 @@ void CGHeroInstance::initObj(CRandomGenerator & rand)
|
||||
if (customApp)
|
||||
appearance = customApp;
|
||||
}
|
||||
|
||||
//copy active (probably growing) bonuses from hero prototype to hero object
|
||||
for(const std::shared_ptr<Bonus> & b : type->specialty)
|
||||
addNewBonus(b);
|
||||
|
||||
//initialize bonuses
|
||||
recreateSecondarySkillsBonuses();
|
||||
|
||||
mana = manaLimit(); //after all bonuses are taken into account, make sure this line is the last one
|
||||
}
|
||||
|
||||
void CGHeroInstance::recreateSecondarySkillsBonuses()
|
||||
|
Reference in New Issue
Block a user