Settings.cpp 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Settings.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include <limits>
  12. #include "Settings.h"
  13. #include "../../../lib/constants/StringConstants.h"
  14. #include "../../../lib/mapObjectConstructors/AObjectTypeHandler.h"
  15. #include "../../../lib/mapObjectConstructors/CObjectClassesHandler.h"
  16. #include "../../../lib/mapObjects/MapObjects.h"
  17. #include "../../../lib/modding/CModHandler.h"
  18. #include "../../../lib/GameLibrary.h"
  19. #include "../../../lib/filesystem/Filesystem.h"
  20. #include "../../../lib/json/JsonUtils.h"
  21. namespace NK2AI
  22. {
  23. Settings::Settings(int difficultyLevel):
  24. maxRoamingHeroes(8),
  25. maxRoamingHeroesPerTown(0),
  26. mainHeroTurnDistanceLimit(10),
  27. scoutHeroTurnDistanceLimit(5),
  28. threatTurnDistanceLimit(5),
  29. maxGoldPressure(0.3f),
  30. retreatThresholdRelative(0.3),
  31. retreatThresholdAbsolute(10000),
  32. safeAttackRatio(1.1),
  33. maxPass(10),
  34. maxPriorityPass(10),
  35. pathfinderBucketsCount(1),
  36. pathfinderBucketSize(32),
  37. allowObjectGraph(true),
  38. useOneWayMonoliths(false),
  39. useTroopsFromGarrisons(false),
  40. updateHitmapOnTileReveal(false),
  41. openMap(true),
  42. useFuzzy(false)
  43. {
  44. const std::string & difficultyName = GameConstants::DIFFICULTY_NAMES[difficultyLevel];
  45. const JsonNode & rootNode = JsonUtils::assembleFromFiles("config/ai/nk2ai/nkai-settings");
  46. const JsonNode & node = rootNode[difficultyName];
  47. maxRoamingHeroes = node["maxRoamingHeroes"].Integer();
  48. maxRoamingHeroesPerTown = node["maxRoamingHeroesPerTown"].Integer();
  49. mainHeroTurnDistanceLimit = node["mainHeroTurnDistanceLimit"].Integer();
  50. scoutHeroTurnDistanceLimit = node["scoutHeroTurnDistanceLimit"].Integer();
  51. maxPass = node["maxPass"].Integer();
  52. maxPriorityPass = node["maxPriorityPass"].Integer();
  53. pathfinderBucketsCount = node["pathfinderBucketsCount"].Integer();
  54. pathfinderBucketSize = node["pathfinderBucketSize"].Integer();
  55. maxGoldPressure = node["maxGoldPressure"].Float();
  56. retreatThresholdRelative = node["retreatThresholdRelative"].Float();
  57. retreatThresholdAbsolute = node["retreatThresholdAbsolute"].Float();
  58. maxArmyLossTarget = node["maxArmyLossTarget"].Float();
  59. safeAttackRatio = node["safeAttackRatio"].Float();
  60. allowObjectGraph = node["allowObjectGraph"].Bool();
  61. updateHitmapOnTileReveal = node["updateHitmapOnTileReveal"].Bool();
  62. openMap = node["openMap"].Bool();
  63. useFuzzy = node["useFuzzy"].Bool();
  64. useTroopsFromGarrisons = node["useTroopsFromGarrisons"].Bool();
  65. useOneWayMonoliths = node["useOneWayMonoliths"].Bool();
  66. }
  67. }