mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-15 01:24:45 +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
|
||||
@ -2205,31 +2188,31 @@ void BattleResultAccepted::applyGs(CGameState * gs) const
|
||||
for(auto & res : heroResult)
|
||||
{
|
||||
if(res.hero)
|
||||
res.hero->removeBonusesRecursive(Bonus::OneBattle);
|
||||
}
|
||||
|
||||
if(winnerSide != 2)
|
||||
{
|
||||
// Grow up growing artifacts
|
||||
const auto hero = heroResult[winnerSide].hero;
|
||||
|
||||
if (hero)
|
||||
{
|
||||
if(hero->commander && hero->commander->alive)
|
||||
{
|
||||
for(auto & art : hero->commander->artifactsWorn)
|
||||
art.second.artifact->growingUp();
|
||||
}
|
||||
for(auto & art : hero->artifactsWorn)
|
||||
{
|
||||
art.second.artifact->growingUp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(VLC->settings()->getBoolean(EGameSettings::MODULE_STACK_EXPERIENCE))
|
||||
{
|
||||
if(heroResult[0].army)
|
||||
res.hero->removeBonusesRecursive(Bonus::OneBattle);
|
||||
}
|
||||
|
||||
if(winnerSide != 2)
|
||||
{
|
||||
// Grow up growing artifacts
|
||||
const auto hero = heroResult[winnerSide].hero;
|
||||
|
||||
if (hero)
|
||||
{
|
||||
if(hero->commander && hero->commander->alive)
|
||||
{
|
||||
for(auto & art : hero->commander->artifactsWorn)
|
||||
art.second.artifact->growingUp();
|
||||
}
|
||||
for(auto & art : hero->artifactsWorn)
|
||||
{
|
||||
art.second.artifact->growingUp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(VLC->settings()->getBoolean(EGameSettings::MODULE_STACK_EXPERIENCE))
|
||||
{
|
||||
if(heroResult[0].army)
|
||||
heroResult[0].army->giveStackExp(heroResult[0].exp);
|
||||
if(heroResult[1].army)
|
||||
heroResult[1].army->giveStackExp(heroResult[1].exp);
|
||||
|
Reference in New Issue
Block a user