mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-17 20:58:07 +02:00
Merge pull request #5105 from Xilmi/develop
AI is now able to deal with Coven and Factory special building-behavior's.
This commit is contained in:
commit
c401eca7c4
@ -36,7 +36,7 @@ void BuildAnalyzer::updateTownDwellings(TownDevelopmentInfo & developmentInfo)
|
|||||||
logAi->trace("Checking dwelling level %d", level);
|
logAi->trace("Checking dwelling level %d", level);
|
||||||
BuildingInfo nextToBuild = BuildingInfo();
|
BuildingInfo nextToBuild = BuildingInfo();
|
||||||
|
|
||||||
for(int upgradeIndex : {1, 0})
|
for(int upgradeIndex : {2, 1, 0})
|
||||||
{
|
{
|
||||||
BuildingID building = BuildingID(BuildingID::getDwellingFromLevel(level, upgradeIndex));
|
BuildingID building = BuildingID(BuildingID::getDwellingFromLevel(level, upgradeIndex));
|
||||||
if(!vstd::contains(buildings, building))
|
if(!vstd::contains(buildings, building))
|
||||||
@ -212,7 +212,7 @@ BuildingInfo BuildAnalyzer::getBuildingOrPrerequisite(
|
|||||||
int creatureLevel = -1;
|
int creatureLevel = -1;
|
||||||
int creatureUpgrade = 0;
|
int creatureUpgrade = 0;
|
||||||
|
|
||||||
if(BuildingID::DWELL_FIRST <= toBuild && toBuild <= BuildingID::DWELL_UP_LAST)
|
if(toBuild.IsDwelling())
|
||||||
{
|
{
|
||||||
creatureLevel = BuildingID::getLevelFromDwelling(toBuild);
|
creatureLevel = BuildingID::getLevelFromDwelling(toBuild);
|
||||||
creatureUpgrade = BuildingID::getUpgradedFromDwelling(toBuild);
|
creatureUpgrade = BuildingID::getUpgradedFromDwelling(toBuild);
|
||||||
@ -271,7 +271,7 @@ BuildingInfo BuildAnalyzer::getBuildingOrPrerequisite(
|
|||||||
|
|
||||||
auto otherDwelling = [](const BuildingID & id) -> bool
|
auto otherDwelling = [](const BuildingID & id) -> bool
|
||||||
{
|
{
|
||||||
return BuildingID::DWELL_FIRST <= id && id <= BuildingID::DWELL_UP_LAST;
|
return id.IsDwelling();
|
||||||
};
|
};
|
||||||
|
|
||||||
if(vstd::contains_if(missingBuildings, otherDwelling))
|
if(vstd::contains_if(missingBuildings, otherDwelling))
|
||||||
@ -420,7 +420,7 @@ BuildingInfo::BuildingInfo(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(BuildingID::DWELL_FIRST <= id && id <= BuildingID::DWELL_UP_LAST)
|
if(id.IsDwelling())
|
||||||
{
|
{
|
||||||
creatureGrows = creature->getGrowth();
|
creatureGrows = creature->getGrowth();
|
||||||
|
|
||||||
|
@ -97,6 +97,10 @@ Goals::TGoalVec RecruitHeroBehavior::decompose(const Nullkiller * ai) const
|
|||||||
|
|
||||||
for(auto hero : availableHeroes)
|
for(auto hero : availableHeroes)
|
||||||
{
|
{
|
||||||
|
if ((town->visitingHero || town->garrisonHero)
|
||||||
|
&& closestThreat < 1
|
||||||
|
&& hero->getArmyCost() < GameConstants::HERO_GOLD_COST / 3.0)
|
||||||
|
continue;
|
||||||
auto score = ai->heroManager->evaluateHero(hero);
|
auto score = ai->heroManager->evaluateHero(hero);
|
||||||
if(score > minScoreToHireMain)
|
if(score > minScoreToHireMain)
|
||||||
{
|
{
|
||||||
|
@ -306,6 +306,7 @@ public:
|
|||||||
DWELL_LVL_7_UP = DWELL_UP_LAST,
|
DWELL_LVL_7_UP = DWELL_UP_LAST,
|
||||||
|
|
||||||
DWELL_UP2_FIRST = DWELL_LVL_7_UP + 1,
|
DWELL_UP2_FIRST = DWELL_LVL_7_UP + 1,
|
||||||
|
DWELL_LVL_1_UP2 = DWELL_UP2_FIRST, DWELL_LVL_2_UP2, DWELL_LVL_3_UP2, DWELL_LVL_4_UP2, DWELL_LVL_5_UP2, DWELL_LVL_6_UP2, DWELL_LVL_7_UP2, DWELL_LVL_8_UP2,
|
||||||
|
|
||||||
// //Special buildings for towns.
|
// //Special buildings for towns.
|
||||||
CASTLE_GATE = SPECIAL_3, //Inferno
|
CASTLE_GATE = SPECIAL_3, //Inferno
|
||||||
@ -319,7 +320,8 @@ private:
|
|||||||
{
|
{
|
||||||
std::vector<Type> dwellings = { DWELL_LVL_1, DWELL_LVL_2, DWELL_LVL_3, DWELL_LVL_4, DWELL_LVL_5, DWELL_LVL_6, DWELL_LVL_7, DWELL_LVL_8 };
|
std::vector<Type> dwellings = { DWELL_LVL_1, DWELL_LVL_2, DWELL_LVL_3, DWELL_LVL_4, DWELL_LVL_5, DWELL_LVL_6, DWELL_LVL_7, DWELL_LVL_8 };
|
||||||
std::vector<Type> dwellingsUp = { DWELL_LVL_1_UP, DWELL_LVL_2_UP, DWELL_LVL_3_UP, DWELL_LVL_4_UP, DWELL_LVL_5_UP, DWELL_LVL_6_UP, DWELL_LVL_7_UP, DWELL_LVL_8_UP };
|
std::vector<Type> dwellingsUp = { DWELL_LVL_1_UP, DWELL_LVL_2_UP, DWELL_LVL_3_UP, DWELL_LVL_4_UP, DWELL_LVL_5_UP, DWELL_LVL_6_UP, DWELL_LVL_7_UP, DWELL_LVL_8_UP };
|
||||||
return {dwellings, dwellingsUp};
|
std::vector<Type> dwellingsUp2 = { DWELL_UP2_FIRST, DWELL_LVL_2_UP2, DWELL_LVL_3_UP2, DWELL_LVL_4_UP2, DWELL_LVL_5_UP2 , DWELL_LVL_6_UP2 , DWELL_LVL_7_UP2, DWELL_LVL_8_UP2 };
|
||||||
|
return {dwellings, dwellingsUp, dwellingsUp2 };
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -339,6 +341,8 @@ public:
|
|||||||
}
|
}
|
||||||
if(dwelling >= BuildingIDBase::DWELL_LVL_8 && dwelling < BuildingIDBase::DWELL_LVL_8 + 5)
|
if(dwelling >= BuildingIDBase::DWELL_LVL_8 && dwelling < BuildingIDBase::DWELL_LVL_8 + 5)
|
||||||
return 7;
|
return 7;
|
||||||
|
else if (dwelling >= BuildingIDBase::DWELL_UP2_FIRST)
|
||||||
|
return (dwelling - DWELL_UP2_FIRST) % (GameConstants::CREATURES_PER_TOWN - 1);
|
||||||
else
|
else
|
||||||
return (dwelling - DWELL_FIRST) % (GameConstants::CREATURES_PER_TOWN - 1);
|
return (dwelling - DWELL_FIRST) % (GameConstants::CREATURES_PER_TOWN - 1);
|
||||||
}
|
}
|
||||||
@ -354,6 +358,8 @@ public:
|
|||||||
}
|
}
|
||||||
if(dwelling >= BuildingIDBase::DWELL_LVL_8 && dwelling < BuildingIDBase::DWELL_LVL_8 + 5)
|
if(dwelling >= BuildingIDBase::DWELL_LVL_8 && dwelling < BuildingIDBase::DWELL_LVL_8 + 5)
|
||||||
return dwelling - BuildingIDBase::DWELL_LVL_8;
|
return dwelling - BuildingIDBase::DWELL_LVL_8;
|
||||||
|
else if (dwelling >= BuildingIDBase::DWELL_UP2_FIRST)
|
||||||
|
return (dwelling - DWELL_UP2_FIRST) / (GameConstants::CREATURES_PER_TOWN - 1);
|
||||||
else
|
else
|
||||||
return (dwelling - DWELL_FIRST) / (GameConstants::CREATURES_PER_TOWN - 1);
|
return (dwelling - DWELL_FIRST) / (GameConstants::CREATURES_PER_TOWN - 1);
|
||||||
}
|
}
|
||||||
@ -366,6 +372,11 @@ public:
|
|||||||
dwelling.advance(GameConstants::CREATURES_PER_TOWN - 1);
|
dwelling.advance(GameConstants::CREATURES_PER_TOWN - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsDwelling() const
|
||||||
|
{
|
||||||
|
return (DWELL_FIRST <= num && num <= DWELL_UP_LAST) || (DWELL_LVL_8 <= num && num <= DWELL_LVL_8_UP) || (num >= DWELL_UP2_FIRST && num < DWELL_LVL_8);
|
||||||
|
}
|
||||||
|
|
||||||
bool IsSpecialOrGrail() const
|
bool IsSpecialOrGrail() const
|
||||||
{
|
{
|
||||||
return num == SPECIAL_1 || num == SPECIAL_2 || num == SPECIAL_3 || num == SPECIAL_4 || num == GRAIL;
|
return num == SPECIAL_1 || num == SPECIAL_2 || num == SPECIAL_3 || num == SPECIAL_4 || num == GRAIL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user