2024-02-25 12:39:19 +02:00
|
|
|
/*
|
|
|
|
* Settings.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include "StdInc.h"
|
|
|
|
#include <limits>
|
|
|
|
|
|
|
|
#include "Settings.h"
|
2024-11-27 23:26:06 +02:00
|
|
|
|
|
|
|
#include "../../../lib/constants/StringConstants.h"
|
2024-02-25 12:39:19 +02:00
|
|
|
#include "../../../lib/mapObjectConstructors/AObjectTypeHandler.h"
|
|
|
|
#include "../../../lib/mapObjectConstructors/CObjectClassesHandler.h"
|
|
|
|
#include "../../../lib/mapObjectConstructors/CBankInstanceConstructor.h"
|
|
|
|
#include "../../../lib/mapObjects/MapObjects.h"
|
|
|
|
#include "../../../lib/modding/CModHandler.h"
|
|
|
|
#include "../../../lib/VCMI_Lib.h"
|
|
|
|
#include "../../../lib/filesystem/Filesystem.h"
|
2024-04-19 17:40:47 +02:00
|
|
|
#include "../../../lib/json/JsonUtils.h"
|
2024-02-25 12:39:19 +02:00
|
|
|
|
|
|
|
namespace NKAI
|
|
|
|
{
|
2024-11-27 23:26:06 +02:00
|
|
|
Settings::Settings(int difficultyLevel)
|
2024-02-25 12:39:19 +02:00
|
|
|
: maxRoamingHeroes(8),
|
|
|
|
mainHeroTurnDistanceLimit(10),
|
|
|
|
scoutHeroTurnDistanceLimit(5),
|
2024-11-28 13:39:36 +02:00
|
|
|
maxGoldPressure(0.3f),
|
|
|
|
retreatThresholdRelative(0.3),
|
2024-11-28 16:44:12 +02:00
|
|
|
retreatThresholdAbsolute(10000),
|
2024-11-28 13:53:51 +02:00
|
|
|
safeAttackRatio(1.1),
|
2024-04-21 10:13:37 +02:00
|
|
|
maxpass(10),
|
2024-11-26 20:58:34 +02:00
|
|
|
pathfinderBucketsCount(1),
|
|
|
|
pathfinderBucketSize(32),
|
2024-05-19 09:04:45 +02:00
|
|
|
allowObjectGraph(true),
|
|
|
|
useTroopsFromGarrisons(false),
|
2024-12-01 23:50:28 +02:00
|
|
|
updateHitmapOnTileReveal(false),
|
2024-07-07 22:44:52 +02:00
|
|
|
openMap(true),
|
|
|
|
useFuzzy(false)
|
2024-02-25 12:39:19 +02:00
|
|
|
{
|
2024-11-27 23:26:06 +02:00
|
|
|
const std::string & difficultyName = GameConstants::DIFFICULTY_NAMES[difficultyLevel];
|
|
|
|
const JsonNode & rootNode = JsonUtils::assembleFromFiles("config/ai/nkai/nkai-settings");
|
|
|
|
const JsonNode & node = rootNode[difficultyName];
|
2024-02-25 12:39:19 +02:00
|
|
|
|
2024-11-26 20:58:34 +02:00
|
|
|
maxRoamingHeroes = node["maxRoamingHeroes"].Integer();
|
|
|
|
mainHeroTurnDistanceLimit = node["mainHeroTurnDistanceLimit"].Integer();
|
|
|
|
scoutHeroTurnDistanceLimit = node["scoutHeroTurnDistanceLimit"].Integer();
|
|
|
|
maxpass = node["maxpass"].Integer();
|
|
|
|
pathfinderBucketsCount = node["pathfinderBucketsCount"].Integer();
|
|
|
|
pathfinderBucketSize = node["pathfinderBucketSize"].Integer();
|
|
|
|
maxGoldPressure = node["maxGoldPressure"].Float();
|
2024-11-28 13:39:36 +02:00
|
|
|
retreatThresholdRelative = node["retreatThresholdRelative"].Float();
|
2024-11-28 16:44:12 +02:00
|
|
|
retreatThresholdAbsolute = node["retreatThresholdAbsolute"].Float();
|
2024-11-29 17:57:23 +02:00
|
|
|
maxArmyLossTarget = node["maxArmyLossTarget"].Float();
|
2024-11-28 13:53:51 +02:00
|
|
|
safeAttackRatio = node["safeAttackRatio"].Float();
|
2024-11-26 20:58:34 +02:00
|
|
|
allowObjectGraph = node["allowObjectGraph"].Bool();
|
2024-12-01 23:50:28 +02:00
|
|
|
updateHitmapOnTileReveal = node["updateHitmapOnTileReveal"].Bool();
|
2024-11-26 20:58:34 +02:00
|
|
|
openMap = node["openMap"].Bool();
|
|
|
|
useFuzzy = node["useFuzzy"].Bool();
|
|
|
|
useTroopsFromGarrisons = node["useTroopsFromGarrisons"].Bool();
|
2024-02-25 12:39:19 +02:00
|
|
|
}
|
2024-04-19 17:40:29 +02:00
|
|
|
}
|