1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-04-25 12:14:46 +02:00

Added 'useTroopsFromGarrisons' option to NKAI

This commit is contained in:
Ivan Savenko 2024-04-19 18:40:29 +03:00
parent d5d9b79b92
commit 20f323d83c
4 changed files with 14 additions and 8 deletions

@ -750,7 +750,7 @@ void AIGateway::showGarrisonDialog(const CArmedInstance * up, const CGHeroInstan
//you can't request action from action-response thread //you can't request action from action-response thread
requestActionASAP([=]() requestActionASAP([=]()
{ {
if(removableUnits && up->tempOwner == down->tempOwner) if(removableUnits && up->tempOwner == down->tempOwner && nullkiller->settings->isGarrisonTroopsUsageAllowed())
{ {
pickBestCreatures(down, up); pickBestCreatures(down, up);
} }

@ -28,7 +28,8 @@ namespace NKAI
scoutHeroTurnDistanceLimit(5), scoutHeroTurnDistanceLimit(5),
maxGoldPressure(0.3f), maxGoldPressure(0.3f),
maxpass(10), maxpass(10),
allowObjectGraph(false) allowObjectGraph(false),
useTroopsFromGarrisons(false)
{ {
ResourcePath resource("config/ai/nkai/nkai-settings", EResType::JSON); ResourcePath resource("config/ai/nkai/nkai-settings", EResType::JSON);
@ -80,5 +81,10 @@ namespace NKAI
{ {
allowObjectGraph = node.Struct()["allowObjectGraph"].Bool(); allowObjectGraph = node.Struct()["allowObjectGraph"].Bool();
} }
if(!node.Struct()["useTroopsFromGarrisons"].isNull())
{
useTroopsFromGarrisons = node.Struct()["useTroopsFromGarrisons"].Bool();
}
} }
} }

@ -27,6 +27,7 @@ namespace NKAI
int maxpass; int maxpass;
float maxGoldPressure; float maxGoldPressure;
bool allowObjectGraph; bool allowObjectGraph;
bool useTroopsFromGarrisons;
public: public:
Settings(); Settings();
@ -37,8 +38,6 @@ namespace NKAI
int getMainHeroTurnDistanceLimit() const { return mainHeroTurnDistanceLimit; } int getMainHeroTurnDistanceLimit() const { return mainHeroTurnDistanceLimit; }
int getScoutHeroTurnDistanceLimit() const { return scoutHeroTurnDistanceLimit; } int getScoutHeroTurnDistanceLimit() const { return scoutHeroTurnDistanceLimit; }
bool isObjectGraphAllowed() const { return allowObjectGraph; } bool isObjectGraphAllowed() const { return allowObjectGraph; }
bool isGarrisonTroopsUsageAllowed() const { return useTroopsFromGarrisons; }
private:
void loadFromMod(const std::string & modName, const ResourcePath & resource);
}; };
} }

@ -3,5 +3,6 @@
"maxpass" : 30, "maxpass" : 30,
"mainHeroTurnDistanceLimit" : 10, "mainHeroTurnDistanceLimit" : 10,
"scoutHeroTurnDistanceLimit" : 5, "scoutHeroTurnDistanceLimit" : 5,
"maxGoldPressure" : 0.3 "maxGoldPressure" : 0.3,
"useTroopsFromGarrisons" : false
} }