1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

Reworked and fixed gendered hero sprites on adventure map

This commit is contained in:
Ivan Savenko
2024-11-03 18:50:47 +00:00
parent 8cd19f639f
commit 697d63d2b8
8 changed files with 93 additions and 34 deletions

View File

@ -336,6 +336,11 @@ void CGHeroInstance::setHeroType(HeroTypeID heroType)
subID = heroType;
}
void CGHeroInstance::initObj(vstd::RNG & rand)
{
updateAppearance();
}
void CGHeroInstance::initHero(vstd::RNG & rand, const HeroTypeID & SUBID)
{
subID = SUBID.getNum();
@ -350,12 +355,27 @@ TObjectTypeHandler CGHeroInstance::getObjectHandler() const
return VLC->objtypeh->getHandlerFor(ID, 0);
}
void CGHeroInstance::updateAppearance()
{
auto handler = VLC->objtypeh->getHandlerFor(Obj::HERO, getHeroClass()->getIndex());;
auto terrain = cb->gameState()->getTile(visitablePos())->terType->getId();
auto app = handler->getOverride(terrain, this);
if (app)
appearance = app;
}
void CGHeroInstance::initHero(vstd::RNG & rand)
{
assert(validTypes(true));
if (gender == EHeroGender::DEFAULT)
gender = getHeroType()->gender;
if (ID == Obj::HERO)
appearance = getObjectHandler()->getTemplates().front();
{
auto handler = VLC->objtypeh->getHandlerFor(Obj::HERO, getHeroClass()->getIndex());;
appearance = handler->getTemplates().front();
}
if(!vstd::contains(spells, SpellID::PRESET))
{
@ -394,9 +414,6 @@ void CGHeroInstance::initHero(vstd::RNG & rand)
if(secSkills.size() == 1 && secSkills[0] == std::pair<SecondarySkill,ui8>(SecondarySkill::NONE, -1)) //set secondary skills to default
secSkills = getHeroType()->secSkillsInit;
if (gender == EHeroGender::DEFAULT)
gender = getHeroType()->gender;
setFormation(EArmyFormation::LOOSE);
if (!stacksCount()) //standard army//initial army
{