浏览代码

Autocalculate default AI value for dwellings

Dydzio 7 年之前
父节点
当前提交
f2ba500e90
共有 2 个文件被更改,包括 24 次插入85 次删除
  1. 23 2
      AI/VCAI/MapObjectsEvaluator.cpp
  2. 1 83
      config/objects/dwellings.json

+ 23 - 2
AI/VCAI/MapObjectsEvaluator.cpp

@@ -2,6 +2,9 @@
 #include "MapObjectsEvaluator.h"
 #include "../../lib/GameConstants.h"
 #include "../../lib/VCMI_Lib.h"
+#include "../../lib/CCreatureHandler.h"
+#include "../../lib/mapObjects/CGTownInstance.h"
+#include "../../lib/CRandomGenerator.h"
 
 MapObjectsEvaluator & MapObjectsEvaluator::getInstance()
 {
@@ -29,9 +32,27 @@ MapObjectsEvaluator::MapObjectsEvaluator()
 				{
 					objectDatabase[CompoundMapObjectID(primaryID, secondaryID)] = VLC->objtypeh->getObjGroupAiValue(primaryID).get();
 				}
-				else
+				else //some default handling when aiValue not found
 				{
-					objectDatabase[CompoundMapObjectID(primaryID, secondaryID)] = 0; //some default handling when aiValue not found
+					if(primaryID == Obj::CREATURE_GENERATOR1 || primaryID == Obj::CREATURE_GENERATOR4)
+					{
+						int aiValue = 0;
+						CGDwelling dwellingMock;
+						CRandomGenerator rngMock;
+						handler->configureObject(&dwellingMock, rngMock);
+						
+						for(auto & creLevel : dwellingMock.creatures)
+						{
+							for(auto & creatureID : creLevel.second)
+							{
+								auto creature = VLC->creh->creatures[creatureID];
+								aiValue += (creature->AIValue * creature->growth);
+							}
+						}
+						objectDatabase[CompoundMapObjectID(primaryID, secondaryID)] = aiValue;
+					}
+					else
+						objectDatabase[CompoundMapObjectID(primaryID, secondaryID)] = 0;
 				}
 			}
 		}	

+ 1 - 83
config/objects/dwellings.json

@@ -15,7 +15,6 @@
 		"types" : {
 			"basiliskPit": {
 				"index": 0,
-				"aiValue" : 2208,
 				"creatures": [["basilisk"]],
 				"sounds": {
 					"ambient": ["LOOPMONS"]
@@ -23,7 +22,6 @@
 			},
 			"behemothCrag": {
 				"index": 1,
-				"aiValue" : 3162,
 				"creatures": [["behemoth"]],
 				"sounds": {
 					"ambient": ["LOOPBEHE"]
@@ -31,7 +29,6 @@
 			},
 			"pillarOfEyes": {
 				"index": 2,
-				"aiValue" : 2352,
 				"creatures": [["beholder"]],
 				"sounds": {
 					"ambient": ["LOOPCAVE"]
@@ -39,7 +36,6 @@
 			},
 			"hallOfDarkness": {
 				"index": 3,
-				"aiValue" : 4174,
 				"creatures": [["blackKnight"]],
 				"sounds": {
 					"ambient": ["LOOPDEAD"]
@@ -47,7 +43,6 @@
 			},
 			"dragonVault": {
 				"index": 4,
-				"aiValue" : 3388,
 				"creatures": [["boneDragon"]],
 				"sounds": {
 					"ambient": ["LOOPDRAG"]
@@ -55,7 +50,6 @@
 			},
 			"trainingGrounds": {
 				"index": 5,
-				"aiValue" : 3892,
 				"creatures": [["cavalier"]],
 				"sounds": {
 					"ambient": ["LOOPHORS"]
@@ -63,7 +57,6 @@
 			},
 			"centaurStables": {
 				"index": 6,
-				"aiValue" : 1400,
 				"creatures": [["centaur"]],
 				"sounds": {
 					"ambient": ["LOOPHORS"]
@@ -71,7 +64,6 @@
 			},
 			"airConflux": {
 				"index": 7,
-				"aiValue" : 2136,
 				"creatures": [["airElemental"]],
 				"sounds": {
 					"ambient": ["LOOPAIR"]
@@ -79,7 +71,6 @@
 			},
 			"portalOfGlory": {
 				"index": 8,
-				"aiValue" : 5019,
 				"creatures": [["angel"]],
 				"sounds": {
 					"ambient": ["LOOPSANC"]
@@ -87,7 +78,6 @@
 			},
 			"cyclopsCave": {
 				"index": 9,
-				"aiValue" : 2532,
 				"creatures": [["cyclop"]],
 				"sounds": {
 					"ambient": ["LOOPCAVE"]
@@ -95,7 +85,6 @@
 			},
 			"forsakenPalace": {
 				"index": 10,
-				"aiValue" : 5101,
 				"creatures": [["devil"]],
 				"sounds": {
 					"ambient": ["LOOPDEVL"]
@@ -103,7 +92,6 @@
 			},
 			"serpentFlyHive": {
 				"index": 11,
-				"aiValue" : 2144,
 				"creatures": [["serpentFly"]],
 				"sounds": {
 					"ambient": ["LOOPLEAR"]
@@ -111,7 +99,6 @@
 			},
 			"dwarfCottage": {
 				"index": 12,
-				"aiValue" : 1104,
 				"creatures": [["dwarf"]],
 				"sounds": {
 					"ambient": ["LOOPDWAR"]
@@ -119,7 +106,6 @@
 			},
 			"earthConflux": {
 				"index": 13,
-				"aiValue" : 1320,
 				"creatures": [["earthElemental"]],
 				"sounds": {
 					"ambient": ["LOOPEART"]
@@ -127,7 +113,6 @@
 			},
 			"fireLake": {
 				"index": 14,
-				"aiValue" : 3340,
 				"creatures": [["efreet"]],
 				"sounds": {
 					"ambient": ["LOOPVENT"]
@@ -135,7 +120,6 @@
 			},
 			"homestead": {
 				"index": 15,
-				"aiValue" : 1638,
 				"creatures": [["woodElf"]],
 				"sounds": {
 					"ambient": ["LOOPELF"]
@@ -143,7 +127,6 @@
 			},
 			"fireConflux": {
 				"index": 16,
-				"aiValue" : 1725,
 				"creatures": [["fireElemental"]],
 				"sounds": {
 					"ambient": ["LOOPFIRE"]
@@ -151,7 +134,6 @@
 			},
 			"parapet": {
 				"index": 17,
-				"aiValue" : 1485,
 				"creatures": [["stoneGargoyle"]],
 				"sounds": {
 					"ambient": ["LOOPGRIF"]
@@ -159,7 +141,6 @@
 			},
 			"altarOfWishes": {
 				"index": 18,
-				"aiValue" : 2652,
 				"creatures": [["genie"]],
 				"sounds": {
 					"ambient": ["LOOPMAGI"]
@@ -167,7 +148,6 @@
 			},
 			"wolfPen": {
 				"index": 19,
-				"aiValue" : 1170,
 				"creatures": [["goblinWolfRider"]],
 				"sounds": {
 					"ambient": ["LOOPWOLF"]
@@ -175,7 +155,6 @@
 			},
 			"gnollHut": {
 				"index": 20,
-				"aiValue" : 672,
 				"creatures": [["gnoll"]],
 				"sounds": {
 					"ambient": ["LOOPORC"]
@@ -183,7 +162,6 @@
 			},
 			"goblinBarracks": {
 				"index": 21,
-				"aiValue" : 900,
 				"creatures": [["goblin"]],
 				"sounds": {
 					"ambient": ["LOOPGOBL"]
@@ -191,7 +169,6 @@
 			},
 			"hallOfSins": {
 				"index": 22,
-				"aiValue" : 1272,
 				"creatures": [["gog"]],
 				"sounds": {
 					"ambient": ["LOOPVENT"]
@@ -199,7 +176,6 @@
 			},
 			"gorgonLair": {
 				"index": 23,
-				"aiValue" : 2670,
 				"creatures": [["gorgon"]],
 				"sounds": {
 					"ambient": ["LOOPBEHE"]
@@ -207,7 +183,6 @@
 			},
 			"dragonCliffs": {
 				"index": 24,
-				"aiValue" : 4872,
 				"creatures": [["greenDragon"]],
 				"sounds": {
 					"ambient": ["LOOPDRAG"]
@@ -215,7 +190,6 @@
 			},
 			"griffinTower": {
 				"index": 25,
-				"aiValue" : 2457,
 				"creatures": [["griffin"]],
 				"sounds": {
 					"ambient": ["LOOPGRIF"]
@@ -223,7 +197,6 @@
 			},
 			"harpyLoft": {
 				"index": 26,
-				"aiValue" : 1232,
 				"creatures": [["harpy"]],
 				"sounds": {
 					"ambient": ["LOOPHARP"]
@@ -231,7 +204,6 @@
 			},
 			"kennels": {
 				"index": 27,
-				"aiValue" : 1785,
 				"creatures": [["hellHound"]],
 				"sounds": {
 					"ambient": ["LOOPDOG"]
@@ -239,7 +211,6 @@
 			},
 			"hydraPond": {
 				"index": 28,
-				"aiValue" : 4120,
 				"creatures": [["hydra"]],
 				"sounds": {
 					"ambient": ["LOOPHYDR"]
@@ -247,7 +218,6 @@
 			},
 			"impCrucible": {
 				"index": 29,
-				"aiValue" : 750,
 				"creatures": [["imp"]],
 				"sounds": {
 					"ambient": ["LOOPFIRE"]
@@ -255,7 +225,6 @@
 			},
 			"lizardDen": {
 				"index": 30,
-				"aiValue" : 1134,
 				"creatures": [["lizardman"]],
 				"sounds": {
 					"ambient": ["LOOPARCH"]
@@ -263,7 +232,6 @@
 			},
 			"mageTower": {
 				"index": 31,
-				"aiValue" : 2280,
 				"creatures": [["mage"]],
 				"sounds": {
 					"ambient": ["LOOPMAGI"]
@@ -271,7 +239,6 @@
 			},
 			"manticoreLair": {
 				"index": 32,
-				"aiValue" : 3094,
 				"creatures": [["manticore"]],
 				"sounds": {
 					"ambient": ["LOOPMANT"]
@@ -279,7 +246,6 @@
 			},
 			"medusaChapel": {
 				"index": 33,
-				"aiValue" : 2068,
 				"creatures": [["medusa"]],
 				"sounds": {
 					"ambient": ["LOOPMEDU"]
@@ -287,7 +253,6 @@
 			},
 			"labyrinth": {
 				"index": 34,
-				"aiValue" : 2505,
 				"creatures": [["minotaur"]],
 				"sounds": {
 					"ambient": ["LOOPANIM"]
@@ -295,7 +260,6 @@
 			},
 			"monastery": {
 				"index": 35,
-				"aiValue" : 1455,
 				"creatures": [["monk"]],
 				"sounds": {
 					"ambient": ["LOOPMONK"]
@@ -303,7 +267,6 @@
 			},
 			"goldenPavilion": {
 				"index": 36,
-				"aiValue" : 4032,
 				"creatures": [["naga"]],
 				"sounds": {
 					"ambient": ["LOOPNAGA"]
@@ -311,7 +274,6 @@
 			},
 			"demonGate": {
 				"index": 37,
-				"aiValue" : 1780,
 				"creatures": [["demon"]],
 				"sounds": {
 					"ambient": ["LOOPCAVE"]
@@ -319,7 +281,6 @@
 			},
 			"ogreFort": {
 				"index": 38,
-				"aiValue" : 1664,
 				"creatures": [["ogre"]],
 				"sounds": {
 					"ambient": ["LOOPOGRE"]
@@ -327,7 +288,6 @@
 			},
 			"orcTower": {
 				"index": 39,
-				"aiValue" : 1344,
 				"creatures": [["orc"]],
 				"sounds": {
 					"ambient": ["LOOPORC"]
@@ -335,7 +295,6 @@
 			},
 			"hellHole": {
 				"index": 40,
-				"aiValue" : 2295,
 				"creatures": [["pitFiend"]],
 				"sounds": {
 					"ambient": ["LOOPFIRE"]
@@ -343,7 +302,6 @@
 			},
 			"dragonCave": {
 				"index": 41,
-				"aiValue" : 4702,
 				"creatures": [["redDragon"]],
 				"sounds": {
 					"ambient": ["LOOPDRAG"]
@@ -351,7 +309,6 @@
 			},
 			"cliffNest": {
 				"index": 42,
-				"aiValue" : 3081,
 				"creatures": [["roc"]],
 				"sounds": {
 					"ambient": ["LOOPBIRD"]
@@ -359,7 +316,6 @@
 			},
 			"workshop": {
 				"index": 43,
-				"aiValue" : 704,
 				"creatures": [["gremlin"]],
 				"sounds": {
 					"ambient": ["LOOPGREM"]
@@ -367,7 +323,6 @@
 			},
 			"cloudTemple": {
 				"index": 44,
-				"aiValue" : 3718,
 				"creatures": [["giant"]],
 				"sounds": {
 					"ambient": ["LOOPTITA"]
@@ -375,7 +330,6 @@
 			},
 			"dendroidArches": {
 				"index": 45,
-				"aiValue" : 1551,
 				"creatures": [["dendroidGuard"]],
 				"sounds": {
 					"ambient": ["LOOPGARD"]
@@ -383,7 +337,6 @@
 			},
 			"warren": {
 				"index": 46,
-				"aiValue" : 826,
 				"creatures": [["troglodyte"]],
 				"sounds": {
 					"ambient": ["LOOPCAVE"]
@@ -391,7 +344,6 @@
 			},
 			"waterConflux": {
 				"index": 47,
-				"aiValue" : 1890,
 				"creatures": [["waterElemental"]],
 				"sounds": {
 					"ambient": ["LOOPFOUN"]
@@ -399,7 +351,6 @@
 			},
 			"tombOfSouls": {
 				"index": 48,
-				"aiValue" : 1764,
 				"creatures": [["wight"]],
 				"sounds": {
 					"ambient": ["LOOPDEAD"]
@@ -407,7 +358,6 @@
 			},
 			"wyvernNest": {
 				"index": 49,
-				"aiValue" : 2700,
 				"creatures": [["wyvern"]],
 				"sounds": {
 					"ambient": ["LOOPMONS"]
@@ -415,7 +365,6 @@
 			},
 			"enchantedSpring": {
 				"index": 50,
-				"aiValue" : 2590,
 				"creatures": [["pegasus"]],
 				"sounds": {
 					"ambient": ["LOOPPEGA"]
@@ -423,7 +372,6 @@
 			},
 			"unicornGladeBig": {
 				"index": 51,
-				"aiValue" : 3612,
 				"creatures": [["unicorn"]],
 				"sounds": {
 					"ambient": ["LOOPUNIC"]
@@ -431,7 +379,6 @@
 			},
 			"mausoleum": {
 				"index": 52,
-				"aiValue" : 2544,
 				"creatures": [["lich"]],
 				"sounds": {
 					"ambient": ["LOOPDEAD"]
@@ -439,7 +386,6 @@
 			},
 			"estate": {
 				"index": 53,
-				"aiValue" : 2220,
 				"creatures": [["vampire"]],
 				"sounds": {
 					"ambient": ["LOOPDEAD"]
@@ -447,7 +393,6 @@
 			},
 			"cursedTemple": {
 				"index": 54,
-				"aiValue" : 720,
 				"creatures": [["skeleton"]],
 				"sounds": {
 					"ambient": ["LOOPSKEL"]
@@ -455,7 +400,6 @@
 			},
 			"graveyard": {
 				"index": 55,
-				"aiValue" : 784,
 				"creatures": [["walkingDead"]],
 				"sounds": {
 					"ambient": ["LOOPDEAD"]
@@ -463,7 +407,6 @@
 			},
 			"guardhouse": {
 				"index": 56,
-				"aiValue" : 1120,
 				"creatures": [["pikeman"]],
 				"sounds": {
 					"ambient": ["LOOPPIKE"]
@@ -471,7 +414,6 @@
 			},
 			"archersTower": {
 				"index": 57,
-				"aiValue" : 1134,
 				"creatures": [["archer"]],
 				"sounds": {
 					"ambient": ["LOOPARCH"]
@@ -479,57 +421,46 @@
 			},
 			"barracks": {
 				"index": 58,
-				"aiValue" : 1780,
 				"creatures": [["swordsman"]]
 			},
 			"magicLantern": {
 				"index": 59,
-				"aiValue" : 1100,
 				"creatures": [["pixie"]]
 			},
 			"altarOfThought": {
 				"index": 60,
-				"aiValue" : 3338,
 				"creatures": [["psychicElemental"]]
 			},
 			"pyre": {
 				"index": 61,
-				"aiValue" : 9094,
 				"creatures": [["firebird"]]
 			},
 			"frozenCliffs": {
 				"index": 62,
-				"aiValue" : 78845,
 				"creatures": [["azureDragon"]]
 			},
 			"crystalCavern": {
 				"index": 63,
-				"aiValue" : 39338,
 				"creatures": [["crystalDragon"]]
 			},
 			"magicForest": {
 				"index": 64,
-				"aiValue" : 19580,
 				"creatures": [["fairieDragon"]]
 			},
 			"sulfurousLair": {
 				"index": 65,
-				"aiValue" : 26433,
 				"creatures": [["rustDragon"]]
 			},
 			"enchantersHollow": {
 				"index": 66,
-				"aiValue" : 2420,
 				"creatures": [["enchanter"]]
 			},
 			"treetopTower": {
 				"index": 67,
-				"aiValue" : 2340,
 				"creatures": [["sharpshooter"]]
 			},
 			"unicornGlade": {
 				"index": 68,
-				"aiValue" : 3612,
 				"creatures": [["unicorn"]],
 				"sounds": {
 					"ambient": ["LOOPUNIC"]
@@ -537,7 +468,6 @@
 			},
 			"altarOfAir": {
 				"index": 69,
-				"aiValue" : 2136,
 				"creatures": [["airElemental"]],
 				"sounds": {
 					"ambient": ["LOOPAIR"]
@@ -545,7 +475,6 @@
 			},
 			"altarOfEarth": {
 				"index": 70,
-				"aiValue" : 1320,
 				"creatures": [["earthElemental"]],
 				"sounds": {
 					"ambient": ["LOOPEART"]
@@ -553,7 +482,6 @@
 			},
 			"altarOfFire": {
 				"index": 71,
-				"aiValue" : 1725,
 				"creatures": [["fireElemental"]],
 				"sounds": {
 					"ambient": ["LOOPFIRE"]
@@ -561,7 +489,6 @@
 			},
 			"altarOfWater": {
 				"index": 72,
-				"aiValue" : 1890,
 				"creatures": [["waterElemental"]],
 				"sounds": {
 					"ambient": ["LOOPFOUN"]
@@ -569,37 +496,30 @@
 			},
 			"thatchedHut": {
 				"index": 73,
-				"aiValue" : 1125,
 				"creatures": [["halfling"]]
 			},
 			"hovel": {
 				"index": 74,
-				"aiValue" : 375,
 				"creatures": [["peasant"]]
 			},
 			"boarGlen": {
 				"index": 75,
-				"aiValue" : 1160,
 				"creatures": [["boar"]]
 			},
 			"tombOfCurses": {
 				"index": 76,
-				"aiValue" : 1890,
 				"creatures": [["mummy"]]
 			},
 			"nomadTent": {
 				"index": 77,
-				"aiValue" : 2415,
 				"creatures": [["nomad"]]
 			},
 			"rogueCavern": {
 				"index": 78,
-				"aiValue" : 1080,
 				"creatures": [["rogue"]]
 			},
 			"trollBridge": {
 				"index": 79,
-				"aiValue" : 3072,
 				"creatures": [["troll"]]
 			}
 		}
@@ -611,7 +531,6 @@
 		"types" : {
 			"elementalConflux" : {
 				"index" : 0,
-				"aiValue" : 7071,
 				"creatures" : [ // 4 separate "levels" to give them separate growth
 					[ "airElemental" ],
 					[ "waterElemental" ],
@@ -627,7 +546,6 @@
 			},
 			"golemFactory" : {
 				"index" : 1,
-				"aiValue" : 7322,
 				"creatures" : [ // 4 separate "levels" to give them separate growth
 					[ "ironGolem" ],
 					[ "stoneGolem" ],
@@ -643,5 +561,5 @@
 				}
 			}
 		}
-	}
+	},
 }