1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-23 00:28:08 +02:00

vcmi: massive refactoring v1

This commit is contained in:
Konstantin
2023-04-05 03:26:29 +03:00
parent ee489f18d2
commit 11b237a23c
129 changed files with 803 additions and 762 deletions

View File

@ -424,26 +424,26 @@ CGCreature * ObjectManager::chooseGuard(si32 strength, bool zoneGuard)
{
if(cre->special)
continue;
if(!cre->AIValue) //bug #2681
if(!cre->getAIValue()) //bug #2681
continue;
if(!vstd::contains(zone.getMonsterTypes(), cre->faction))
if(!vstd::contains(zone.getMonsterTypes(), cre->getFactionIndex()))
continue;
if((static_cast<si32>(cre->AIValue * (cre->ammMin + cre->ammMax) / 2) < strength) && (strength < static_cast<si32>(cre->AIValue) * 100)) //at least one full monster. size between average size of given stack and 100
if((static_cast<si32>(cre->getAIValue() * (cre->ammMin + cre->ammMax) / 2) < strength) && (strength < static_cast<si32>(cre->getAIValue()) * 100)) //at least one full monster. size between average size of given stack and 100
{
possibleCreatures.push_back(cre->idNumber);
possibleCreatures.push_back(cre->getId());
}
}
if(!possibleCreatures.empty())
{
creId = *RandomGeneratorUtil::nextItem(possibleCreatures, generator.rand);
amount = strength / VLC->creh->objects[creId]->AIValue;
amount = strength / VLC->creh->objects[creId]->getAIValue();
if (amount >= 4)
amount = static_cast<int>(amount * generator.rand.nextDouble(0.75, 1.25));
}
else //just pick any available creature
{
creId = CreatureID(132); //Azure Dragon
amount = strength / VLC->creh->objects[creId]->AIValue;
amount = strength / VLC->creh->objects[creId]->getAIValue();
}
auto guardFactory = VLC->objtypeh->getHandlerFor(Obj::MONSTER, creId);