From 438ec08d72e2fafe8179691e75e0843b408405f5 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sat, 20 Apr 2024 17:30:50 +0300 Subject: [PATCH] AI will only ignore garrisons in 'Steadwick Fall' mission (H3 logic) --- AI/Nullkiller/AIGateway.cpp | 3 ++- AI/VCAI/VCAI.cpp | 3 ++- config/ai/nkai/nkai-settings.json | 2 +- lib/StartInfo.cpp | 14 ++++++++++++++ lib/StartInfo.h | 3 +++ 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/AI/Nullkiller/AIGateway.cpp b/AI/Nullkiller/AIGateway.cpp index c4b43855c..8fd9f2d16 100644 --- a/AI/Nullkiller/AIGateway.cpp +++ b/AI/Nullkiller/AIGateway.cpp @@ -11,6 +11,7 @@ #include "../../lib/ArtifactUtils.h" #include "../../lib/UnlockGuard.h" +#include "../../lib/StartInfo.h" #include "../../lib/mapObjects/MapObjects.h" #include "../../lib/mapObjects/ObjectTemplate.h" #include "../../lib/mapObjects/CGHeroInstance.h" @@ -750,7 +751,7 @@ void AIGateway::showGarrisonDialog(const CArmedInstance * up, const CGHeroInstan //you can't request action from action-response thread requestActionASAP([=]() { - if(removableUnits && up->tempOwner == down->tempOwner && nullkiller->settings->isGarrisonTroopsUsageAllowed()) + if(removableUnits && up->tempOwner == down->tempOwner && nullkiller->settings->isGarrisonTroopsUsageAllowed() && !cb->getStartInfo()->isSteadwickFallCampaignMission()) { pickBestCreatures(down, up); } diff --git a/AI/VCAI/VCAI.cpp b/AI/VCAI/VCAI.cpp index 4c9ba1c7d..e395f1b3c 100644 --- a/AI/VCAI/VCAI.cpp +++ b/AI/VCAI/VCAI.cpp @@ -16,6 +16,7 @@ #include "../../lib/ArtifactUtils.h" #include "../../lib/UnlockGuard.h" +#include "../../lib/StartInfo.h" #include "../../lib/mapObjects/MapObjects.h" #include "../../lib/mapObjects/ObjectTemplate.h" #include "../../lib/CConfigHandler.h" @@ -732,7 +733,7 @@ void VCAI::showGarrisonDialog(const CArmedInstance * up, const CGHeroInstance * //you can't request action from action-response thread requestActionASAP([=]() { - if(removableUnits) + if(removableUnits && !cb->getStartInfo()->isSteadwickFallCampaignMission()) pickBestCreatures(down, up); answerQuery(queryID, 0); diff --git a/config/ai/nkai/nkai-settings.json b/config/ai/nkai/nkai-settings.json index ac182d554..a7dd1ec08 100644 --- a/config/ai/nkai/nkai-settings.json +++ b/config/ai/nkai/nkai-settings.json @@ -4,5 +4,5 @@ "mainHeroTurnDistanceLimit" : 10, "scoutHeroTurnDistanceLimit" : 5, "maxGoldPressure" : 0.3, - "useTroopsFromGarrisons" : false + "useTroopsFromGarrisons" : true } \ No newline at end of file diff --git a/lib/StartInfo.cpp b/lib/StartInfo.cpp index 73b896716..e9f9c40bb 100644 --- a/lib/StartInfo.cpp +++ b/lib/StartInfo.cpp @@ -89,6 +89,20 @@ std::string StartInfo::getCampaignName() const return VLC->generaltexth->allTexts[508]; } +bool StartInfo::isSteadwickFallCampaignMission() const +{ + if (!campState) + return false; + + if (campState->getFilename() != "DATA/EVIL1") + return false; + + if (campState->currentScenario() != CampaignScenarioID(2)) + return false; + + return true; +} + void LobbyInfo::verifyStateBeforeStart(bool ignoreNoHuman) const { if(!mi || !mi->mapHeader) diff --git a/lib/StartInfo.h b/lib/StartInfo.h index 4067124a8..c221e4521 100644 --- a/lib/StartInfo.h +++ b/lib/StartInfo.h @@ -136,6 +136,9 @@ struct DLL_LINKAGE StartInfo // TODO: Must be client-side std::string getCampaignName() const; + /// Controls hardcoded check for "Steadwick's Fall" scenario from "Dungeon and Devils" campaign + bool isSteadwickFallCampaignMission() const; + template void serialize(Handler &h) {