|
@@ -3233,10 +3233,15 @@ TSubgoal CGoal::whatToDoToAchieve()
|
|
|
auto creature = VLC->creh->creatures[objid];
|
|
auto creature = VLC->creh->creatures[objid];
|
|
|
if (t->subID == creature->faction) //TODO: how to force AI to build unupgraded creatures? :O
|
|
if (t->subID == creature->faction) //TODO: how to force AI to build unupgraded creatures? :O
|
|
|
{
|
|
{
|
|
|
- auto creatures = t->town->creatures[creature->level];
|
|
|
|
|
- int upgradeNumber = std::find(creatures.begin(), creatures.end(), creature->idNumber) - creatures.begin();
|
|
|
|
|
|
|
+ auto creatures = vstd::tryAt(t->town->creatures, creature->level - 1);
|
|
|
|
|
+ if(!creatures)
|
|
|
|
|
+ continue;
|
|
|
|
|
|
|
|
- BuildingID bid(BuildingID::DWELL_FIRST + creature->level + upgradeNumber * GameConstants::CREATURES_PER_TOWN);
|
|
|
|
|
|
|
+ int upgradeNumber = vstd::find_pos(*creatures, creature->idNumber);
|
|
|
|
|
+ if(upgradeNumber < 0)
|
|
|
|
|
+ continue;
|
|
|
|
|
+
|
|
|
|
|
+ BuildingID bid(BuildingID::DWELL_FIRST + creature->level - 1 + upgradeNumber * GameConstants::CREATURES_PER_TOWN);
|
|
|
if (t->hasBuilt(bid)) //this assumes only creatures with dwellings are assigned to faction
|
|
if (t->hasBuilt(bid)) //this assumes only creatures with dwellings are assigned to faction
|
|
|
{
|
|
{
|
|
|
dwellings.push_back(t);
|
|
dwellings.push_back(t);
|