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->setOwner(player);
|
||||||
h->pos = tile;
|
h->pos = tile;
|
||||||
bool fresh = !h->isInitialized();
|
h->initObj(gs->getRandomGenerator());
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(h->id == ObjectInstanceID())
|
if(h->id == ObjectInstanceID())
|
||||||
{
|
{
|
||||||
@ -1414,16 +1403,10 @@ void HeroRecruited::applyGs(CGameState * gs) const
|
|||||||
gs->map->heroesOnMap.emplace_back(h);
|
gs->map->heroesOnMap.emplace_back(h);
|
||||||
p->heroes.emplace_back(h);
|
p->heroes.emplace_back(h);
|
||||||
h->attachTo(*p);
|
h->attachTo(*p);
|
||||||
if(fresh)
|
|
||||||
{
|
|
||||||
h->initObj(gs->getRandomGenerator());
|
|
||||||
}
|
|
||||||
gs->map->addBlockVisTiles(h);
|
gs->map->addBlockVisTiles(h);
|
||||||
|
|
||||||
if(t)
|
if(t)
|
||||||
{
|
|
||||||
t->setVisitingHero(h);
|
t->setVisitingHero(h);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GiveHero::applyGs(CGameState * gs) const
|
void GiveHero::applyGs(CGameState * gs) const
|
||||||
@ -2205,31 +2188,31 @@ void BattleResultAccepted::applyGs(CGameState * gs) const
|
|||||||
for(auto & res : heroResult)
|
for(auto & res : heroResult)
|
||||||
{
|
{
|
||||||
if(res.hero)
|
if(res.hero)
|
||||||
res.hero->removeBonusesRecursive(Bonus::OneBattle);
|
res.hero->removeBonusesRecursive(Bonus::OneBattle);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(winnerSide != 2)
|
if(winnerSide != 2)
|
||||||
{
|
{
|
||||||
// Grow up growing artifacts
|
// Grow up growing artifacts
|
||||||
const auto hero = heroResult[winnerSide].hero;
|
const auto hero = heroResult[winnerSide].hero;
|
||||||
|
|
||||||
if (hero)
|
if (hero)
|
||||||
{
|
{
|
||||||
if(hero->commander && hero->commander->alive)
|
if(hero->commander && hero->commander->alive)
|
||||||
{
|
{
|
||||||
for(auto & art : hero->commander->artifactsWorn)
|
for(auto & art : hero->commander->artifactsWorn)
|
||||||
art.second.artifact->growingUp();
|
art.second.artifact->growingUp();
|
||||||
}
|
}
|
||||||
for(auto & art : hero->artifactsWorn)
|
for(auto & art : hero->artifactsWorn)
|
||||||
{
|
{
|
||||||
art.second.artifact->growingUp();
|
art.second.artifact->growingUp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(VLC->settings()->getBoolean(EGameSettings::MODULE_STACK_EXPERIENCE))
|
if(VLC->settings()->getBoolean(EGameSettings::MODULE_STACK_EXPERIENCE))
|
||||||
{
|
{
|
||||||
if(heroResult[0].army)
|
if(heroResult[0].army)
|
||||||
heroResult[0].army->giveStackExp(heroResult[0].exp);
|
heroResult[0].army->giveStackExp(heroResult[0].exp);
|
||||||
if(heroResult[1].army)
|
if(heroResult[1].army)
|
||||||
heroResult[1].army->giveStackExp(heroResult[1].exp);
|
heroResult[1].army->giveStackExp(heroResult[1].exp);
|
||||||
|
@ -255,6 +255,7 @@ CGHeroInstance::CGHeroInstance():
|
|||||||
setNodeType(HERO);
|
setNodeType(HERO);
|
||||||
ID = Obj::HERO;
|
ID = Obj::HERO;
|
||||||
secSkills.emplace_back(SecondarySkill::DEFAULT, -1);
|
secSkills.emplace_back(SecondarySkill::DEFAULT, -1);
|
||||||
|
blockVisit = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerColor CGHeroInstance::getOwner() const
|
PlayerColor CGHeroInstance::getOwner() const
|
||||||
@ -364,8 +365,19 @@ void CGHeroInstance::initHero(CRandomGenerator & rand)
|
|||||||
commander->giveStackExp (exp); //after our exp is set
|
commander->giveStackExp (exp); //after our exp is set
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mana < 0)
|
skillsInfo.rand.setSeed(rand.nextInt());
|
||||||
mana = manaLimit();
|
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)
|
void CGHeroInstance::initArmy(CRandomGenerator & rand, IArmyDescriptor * dst)
|
||||||
@ -533,15 +545,9 @@ void CGHeroInstance::SecondarySkillsInfo::resetWisdomCounter()
|
|||||||
|
|
||||||
void CGHeroInstance::initObj(CRandomGenerator & rand)
|
void CGHeroInstance::initObj(CRandomGenerator & rand)
|
||||||
{
|
{
|
||||||
blockVisit = true;
|
|
||||||
|
|
||||||
if(!type)
|
if(!type)
|
||||||
initHero(rand); //TODO: set up everything for prison before specialties are configured
|
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)
|
if (ID != Obj::PRISON)
|
||||||
{
|
{
|
||||||
auto terrain = cb->gameState()->getTile(visitablePos())->terType->getId();
|
auto terrain = cb->gameState()->getTile(visitablePos())->terType->getId();
|
||||||
@ -549,15 +555,6 @@ void CGHeroInstance::initObj(CRandomGenerator & rand)
|
|||||||
if (customApp)
|
if (customApp)
|
||||||
appearance = 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()
|
void CGHeroInstance::recreateSecondarySkillsBonuses()
|
||||||
|
Reference in New Issue
Block a user