CGDwelling.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. /*
  2. * CGDwelling.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 "CGDwelling.h"
  12. #include "../callback/IGameInfoCallback.h"
  13. #include "../callback/IGameEventCallback.h"
  14. #include "../callback/IGameRandomizer.h"
  15. #include "../serializer/JsonSerializeFormat.h"
  16. #include "../entities/faction/CTownHandler.h"
  17. #include "../mapping/CMap.h"
  18. #include "../mapObjectConstructors/AObjectTypeHandler.h"
  19. #include "../mapObjectConstructors/CObjectClassesHandler.h"
  20. #include "../mapObjectConstructors/DwellingInstanceConstructor.h"
  21. #include "../mapObjects/CGHeroInstance.h"
  22. #include "../mapObjects/CGTownInstance.h"
  23. #include "../networkPacks/StackLocation.h"
  24. #include "../networkPacks/PacksForClient.h"
  25. #include "../networkPacks/PacksForClientBattle.h"
  26. #include "../gameState/CGameState.h"
  27. #include "../CPlayerState.h"
  28. #include "../IGameSettings.h"
  29. #include "../CConfigHandler.h"
  30. #include "../texts/CGeneralTextHandler.h"
  31. #include <vstd/RNG.h>
  32. VCMI_LIB_NAMESPACE_BEGIN
  33. void CGDwellingRandomizationInfo::serializeJson(JsonSerializeFormat & handler)
  34. {
  35. handler.serializeString("sameAsTown", instanceId);
  36. handler.serializeIdArray("allowedFactions", allowedFactions);
  37. handler.serializeInt("minLevel", minLevel, static_cast<uint8_t>(1));
  38. handler.serializeInt("maxLevel", maxLevel, static_cast<uint8_t>(7));
  39. if(!handler.saving)
  40. {
  41. //todo: safely allow any level > 7
  42. vstd::abetween<uint8_t>(minLevel, 1, 7);
  43. vstd::abetween<uint8_t>(maxLevel, minLevel, 7);
  44. }
  45. }
  46. CGDwelling::CGDwelling(IGameInfoCallback *cb):
  47. CArmedInstance(cb)
  48. {}
  49. CGDwelling::~CGDwelling() = default;
  50. FactionID CGDwelling::randomizeFaction(IGameRandomizer & gameRandomizer)
  51. {
  52. if (ID == Obj::RANDOM_DWELLING_FACTION)
  53. return FactionID(subID.getNum());
  54. assert(ID == Obj::RANDOM_DWELLING || ID == Obj::RANDOM_DWELLING_LVL);
  55. assert(randomizationInfo.has_value());
  56. if (!randomizationInfo)
  57. return FactionID::CASTLE;
  58. CGTownInstance * linkedTown = nullptr;
  59. if (!randomizationInfo->instanceId.empty())
  60. {
  61. auto iter = cb->gameState().getMap().instanceNames.find(randomizationInfo->instanceId);
  62. if(iter == cb->gameState().getMap().instanceNames.end())
  63. logGlobal->error("Map object not found: %s", randomizationInfo->instanceId);
  64. linkedTown = dynamic_cast<CGTownInstance *>(iter->second.get());
  65. }
  66. if (randomizationInfo->identifier != 0)
  67. {
  68. for(auto & townID : cb->gameState().getMap().getAllTowns())
  69. {
  70. auto town = cb->gameState().getTown(townID);
  71. if(town && town->identifier == randomizationInfo->identifier)
  72. {
  73. linkedTown = town;
  74. break;
  75. }
  76. }
  77. }
  78. if (linkedTown)
  79. {
  80. if(linkedTown->ID==Obj::RANDOM_TOWN)
  81. linkedTown->pickRandomObject(gameRandomizer); //we have to randomize the castle first
  82. assert(linkedTown->ID == Obj::TOWN);
  83. if(linkedTown->ID==Obj::TOWN)
  84. return linkedTown->getFactionID();
  85. }
  86. if(!randomizationInfo->allowedFactions.empty())
  87. return *RandomGeneratorUtil::nextItem(randomizationInfo->allowedFactions, gameRandomizer.getDefault());
  88. std::vector<FactionID> potentialPicks;
  89. for (FactionID faction(0); faction < FactionID(LIBRARY->townh->size()); ++faction)
  90. if (LIBRARY->factions()->getById(faction)->hasTown())
  91. potentialPicks.push_back(faction);
  92. assert(!potentialPicks.empty());
  93. return *RandomGeneratorUtil::nextItem(potentialPicks, gameRandomizer.getDefault());
  94. }
  95. int CGDwelling::randomizeLevel(vstd::RNG & rand)
  96. {
  97. if (ID == Obj::RANDOM_DWELLING_LVL)
  98. return subID.getNum();
  99. assert(ID == Obj::RANDOM_DWELLING || ID == Obj::RANDOM_DWELLING_FACTION);
  100. assert(randomizationInfo.has_value());
  101. if (!randomizationInfo)
  102. return rand.nextInt(1, 7) - 1;
  103. if(randomizationInfo->minLevel == randomizationInfo->maxLevel)
  104. return randomizationInfo->minLevel - 1;
  105. return rand.nextInt(randomizationInfo->minLevel, randomizationInfo->maxLevel) - 1;
  106. }
  107. void CGDwelling::pickRandomObject(IGameRandomizer & gameRandomizer)
  108. {
  109. if (ID == Obj::RANDOM_DWELLING || ID == Obj::RANDOM_DWELLING_LVL || ID == Obj::RANDOM_DWELLING_FACTION)
  110. {
  111. FactionID faction = randomizeFaction(gameRandomizer);
  112. int level = randomizeLevel(gameRandomizer.getDefault());
  113. assert(faction != FactionID::NONE && faction != FactionID::NEUTRAL);
  114. assert(level >= 0 && level <= 6);
  115. randomizationInfo.reset();
  116. CreatureID cid = (*LIBRARY->townh)[faction]->town->creatures[level][0];
  117. //NOTE: this will pick last dwelling with this creature (Mantis #900)
  118. //check for block map equality is better but more complex solution
  119. auto testID = [&](const Obj & primaryID) -> MapObjectSubID
  120. {
  121. auto dwellingIDs = LIBRARY->objtypeh->knownSubObjects(primaryID);
  122. for (MapObjectSubID entry : dwellingIDs)
  123. {
  124. const auto * handler = dynamic_cast<const DwellingInstanceConstructor *>(LIBRARY->objtypeh->getHandlerFor(primaryID, entry).get());
  125. if (!handler->isBannedForRandomDwelling() && handler->producesCreature(cid.toCreature()))
  126. return MapObjectSubID(entry);
  127. }
  128. return MapObjectSubID();
  129. };
  130. ID = Obj::CREATURE_GENERATOR1;
  131. subID = testID(Obj::CREATURE_GENERATOR1);
  132. if (subID == MapObjectSubID())
  133. {
  134. ID = Obj::CREATURE_GENERATOR4;
  135. subID = testID(Obj::CREATURE_GENERATOR4);
  136. }
  137. if (subID == MapObjectSubID())
  138. {
  139. logGlobal->error("Error: failed to find dwelling for %s of level %d", (*LIBRARY->townh)[faction]->getNameTranslated(), int(level));
  140. ID = Obj::CREATURE_GENERATOR1;
  141. subID = *RandomGeneratorUtil::nextItem(LIBRARY->objtypeh->knownSubObjects(Obj::CREATURE_GENERATOR1), gameRandomizer.getDefault());
  142. }
  143. setType(ID, subID);
  144. }
  145. }
  146. void CGDwelling::initObj(IGameRandomizer & gameRandomizer)
  147. {
  148. switch(ID.toEnum())
  149. {
  150. case Obj::CREATURE_GENERATOR1:
  151. case Obj::CREATURE_GENERATOR4:
  152. case Obj::WAR_MACHINE_FACTORY:
  153. {
  154. getObjectHandler()->configureObject(this, gameRandomizer);
  155. assert(!creatures.empty());
  156. assert(!creatures[0].second.empty());
  157. break;
  158. }
  159. case Obj::REFUGEE_CAMP:
  160. //is handled within newturn func
  161. break;
  162. default:
  163. assert(0);
  164. break;
  165. }
  166. }
  167. void CGDwelling::setPropertyDer(ObjProperty what, ObjPropertyID identifier)
  168. {
  169. switch (what)
  170. {
  171. case ObjProperty::AVAILABLE_CREATURE:
  172. creatures.resize(1);
  173. creatures[0].second.resize(1);
  174. creatures[0].second[0] = identifier.as<CreatureID>();
  175. break;
  176. }
  177. }
  178. void CGDwelling::onHeroVisit(IGameEventCallback & gameEvents, const CGHeroInstance * h) const
  179. {
  180. if(ID == Obj::REFUGEE_CAMP && !creatures[0].first) //Refugee Camp, no available cres
  181. {
  182. InfoWindow iw;
  183. iw.type = EInfoWindowMode::AUTO;
  184. iw.player = h->tempOwner;
  185. iw.text.appendLocalString(EMetaText::ADVOB_TXT, 44); //{%s} \n\n The camp is deserted. Perhaps you should try next week.
  186. iw.text.replaceName(ID, subID);
  187. gameEvents.sendAndApply(iw);
  188. return;
  189. }
  190. PlayerRelations relations = cb->getPlayerRelations( h->tempOwner, tempOwner );
  191. if ( relations == PlayerRelations::ALLIES )
  192. return;//do not allow recruiting or capturing
  193. if(relations == PlayerRelations::ENEMIES && stacksCount() > 0) //object is guarded, owned by enemy
  194. {
  195. BlockingDialog bd(true,false);
  196. bd.player = h->tempOwner;
  197. bd.text.appendLocalString(EMetaText::GENERAL_TXT, 421); //Much to your dismay, the %s is guarded by %s %s. Do you wish to fight the guards?
  198. bd.text.replaceTextID(getObjectHandler()->getNameTextID());
  199. if(settings["gameTweaks"]["numericCreaturesQuantities"].Bool())
  200. bd.text.replaceRawString(CCreature::getQuantityRangeStringForId(Slots().begin()->second->getQuantityID()));
  201. else
  202. bd.text.replaceLocalString(EMetaText::ARRAY_TXT, 173 + (int)Slots().begin()->second->getQuantityID()*3);
  203. bd.text.replaceName(*Slots().begin()->second);
  204. gameEvents.showBlockingDialog(this, &bd);
  205. return;
  206. }
  207. // TODO this shouldn't be hardcoded
  208. if(relations == PlayerRelations::ENEMIES && ID != Obj::WAR_MACHINE_FACTORY && ID != Obj::REFUGEE_CAMP)
  209. {
  210. gameEvents.setOwner(this, h->tempOwner);
  211. }
  212. BlockingDialog bd (true,false);
  213. bd.player = h->tempOwner;
  214. if(ID == Obj::CREATURE_GENERATOR1 || ID == Obj::CREATURE_GENERATOR4)
  215. {
  216. const size_t count = std::min<size_t>(creatures.size(), 4);
  217. constexpr std::array dwellingVisitTextID = {
  218. "core.advevent.35", // 0 creatures, should not happen
  219. "core.advevent.35",
  220. "vcmi.adventureMap.dwelling2",
  221. "vcmi.adventureMap.dwelling3",
  222. "core.advevent.36"
  223. }
  224. bd.text.appendTextID(dwellingVisitTextID[count]);
  225. bd.text.replaceTextID(getObjectHandler()->getNameTextID());
  226. for(const auto & elem : creatures)
  227. bd.text.replaceNamePlural(elem.second[0]);
  228. }
  229. else if(ID == Obj::REFUGEE_CAMP)
  230. {
  231. bd.text.appendLocalString(EMetaText::ADVOB_TXT, 35); //{%s} Would you like to recruit %s?
  232. bd.text.replaceName(ID, subID);
  233. for(const auto & elem : creatures)
  234. bd.text.replaceNamePlural(elem.second[0]);
  235. }
  236. else if(ID == Obj::WAR_MACHINE_FACTORY)
  237. bd.text.appendLocalString(EMetaText::ADVOB_TXT, 157); //{War Machine Factory} Would you like to purchase War Machines?
  238. else
  239. throw std::runtime_error("Illegal dwelling!");
  240. if(ID == Obj::REFUGEE_CAMP || (ID == Obj::CREATURE_GENERATOR1 && LIBRARY->creatures()->getById(creatures[0].second[0])->getLevel() != 1))
  241. {
  242. bd.flags |= BlockingDialog::SAFE_TO_AUTOACCEPT;
  243. }
  244. gameEvents.showBlockingDialog(this, &bd);
  245. }
  246. void CGDwelling::newTurn(IGameEventCallback & gameEvents, IGameRandomizer & gameRandomizer) const
  247. {
  248. if(cb->getDate(Date::DAY_OF_WEEK) != 1) //not first day of week
  249. return;
  250. //town growths and War Machines Factories are handled separately
  251. if(ID == Obj::TOWN || ID == Obj::WAR_MACHINE_FACTORY)
  252. return;
  253. if(ID == Obj::REFUGEE_CAMP) //if it's a refugee camp, we need to pick an available creature
  254. {
  255. gameEvents.setObjPropertyID(id, ObjProperty::AVAILABLE_CREATURE, gameRandomizer.rollCreature());
  256. }
  257. bool change = false;
  258. SetAvailableCreatures sac;
  259. sac.creatures = creatures;
  260. sac.tid = id;
  261. for (size_t i = 0; i < creatures.size(); i++)
  262. {
  263. if(!creatures[i].second.empty())
  264. {
  265. bool creaturesAccumulate = false;
  266. if (tempOwner.isValidPlayer())
  267. creaturesAccumulate = cb->getSettings().getBoolean(EGameSettings::DWELLINGS_ACCUMULATE_WHEN_OWNED);
  268. else
  269. creaturesAccumulate = cb->getSettings().getBoolean(EGameSettings::DWELLINGS_ACCUMULATE_WHEN_NEUTRAL);
  270. const CCreature * cre =creatures[i].second[0].toCreature();
  271. TQuantity amount = cre->getGrowth() * (1 + cre->valOfBonuses(BonusType::CREATURE_GROWTH_PERCENT)/100) + cre->valOfBonuses(BonusType::CREATURE_GROWTH, BonusCustomSubtype::creatureLevel(cre->getLevel()));
  272. if (creaturesAccumulate && ID != Obj::REFUGEE_CAMP) //camp should not try to accumulate different kinds of creatures
  273. sac.creatures[i].first += amount;
  274. else
  275. sac.creatures[i].first = amount;
  276. change = true;
  277. }
  278. }
  279. if(change)
  280. gameEvents.sendAndApply(sac);
  281. updateGuards(gameEvents);
  282. }
  283. std::vector<Component> CGDwelling::getPopupComponents(PlayerColor player) const
  284. {
  285. bool visitedByOwner = getOwner() == player;
  286. std::vector<Component> result;
  287. if (ID == Obj::CREATURE_GENERATOR1 && !creatures.empty())
  288. {
  289. for (auto const & creature : creatures.front().second)
  290. {
  291. if (visitedByOwner)
  292. result.emplace_back(ComponentType::CREATURE, creature, creatures.front().first);
  293. else
  294. result.emplace_back(ComponentType::CREATURE, creature);
  295. }
  296. }
  297. if (ID == Obj::CREATURE_GENERATOR4)
  298. {
  299. for (auto const & creatureLevel : creatures)
  300. {
  301. if (!creatureLevel.second.empty())
  302. {
  303. if (visitedByOwner)
  304. result.emplace_back(ComponentType::CREATURE, creatureLevel.second.back(), creatureLevel.first);
  305. else
  306. result.emplace_back(ComponentType::CREATURE, creatureLevel.second.back());
  307. }
  308. }
  309. }
  310. return result;
  311. }
  312. void CGDwelling::updateGuards(IGameEventCallback & gameEvents) const
  313. {
  314. //TODO: store custom guard config and use it
  315. //TODO: store boolean flag for guards
  316. bool guarded = false;
  317. //default condition - creatures are of level 5 or higher
  318. for (auto creatureEntry : creatures)
  319. {
  320. if (LIBRARY->creatures()->getById(creatureEntry.second.at(0))->getLevel() >= 5 && ID != Obj::REFUGEE_CAMP)
  321. {
  322. guarded = true;
  323. break;
  324. }
  325. }
  326. if (guarded)
  327. {
  328. for (auto creatureEntry : creatures)
  329. {
  330. const CCreature * crea = creatureEntry.second.at(0).toCreature();
  331. SlotID slot = getSlotFor(crea->getId());
  332. if (hasStackAtSlot(slot)) //stack already exists, overwrite it
  333. {
  334. ChangeStackCount csc;
  335. csc.army = this->id;
  336. csc.slot = slot;
  337. csc.count = crea->getGrowth() * 3;
  338. csc.mode = ChangeValueMode::ABSOLUTE;
  339. gameEvents.sendAndApply(csc);
  340. }
  341. else //slot is empty, create whole new stack
  342. {
  343. InsertNewStack ns;
  344. ns.army = this->id;
  345. ns.slot = slot;
  346. ns.type = crea->getId();
  347. ns.count = crea->getGrowth() * 3;
  348. gameEvents.sendAndApply(ns);
  349. }
  350. }
  351. }
  352. }
  353. void CGDwelling::heroAcceptsCreatures(IGameEventCallback & gameEvents, const CGHeroInstance *h) const
  354. {
  355. CreatureID crid = creatures[0].second[0];
  356. auto *crs = crid.toCreature();
  357. TQuantity count = creatures[0].first;
  358. if(crs->getLevel() == 1 && ID != Obj::REFUGEE_CAMP) //first level - creatures are for free
  359. {
  360. if(count) //there are available creatures
  361. {
  362. if (cb->getSettings().getBoolean(EGameSettings::DWELLINGS_MERGE_ON_RECRUIT))
  363. {
  364. SlotID testSlot = h->getSlotFor(crid);
  365. if(!testSlot.validSlot()) //no available slot - try merging army of visiting hero
  366. {
  367. std::pair<SlotID, SlotID> toMerge;
  368. if (h->mergeableStacks(toMerge))
  369. {
  370. gameEvents.moveStack(StackLocation(h->id, toMerge.first), StackLocation(h->id, toMerge.second), -1); //merge toMerge.first into toMerge.second
  371. assert(!h->hasStackAtSlot(toMerge.first)); //we have now a new free slot
  372. }
  373. }
  374. }
  375. SlotID slot = h->getSlotFor(crid);
  376. if(!slot.validSlot()) //no available slot
  377. {
  378. InfoWindow iw;
  379. iw.type = EInfoWindowMode::AUTO;
  380. iw.player = h->tempOwner;
  381. iw.text.appendLocalString(EMetaText::GENERAL_TXT, 425);//The %s would join your hero, but there aren't enough provisions to support them.
  382. iw.text.replaceNamePlural(crid);
  383. gameEvents.showInfoDialog(&iw);
  384. }
  385. else //give creatures
  386. {
  387. SetAvailableCreatures sac;
  388. sac.tid = id;
  389. sac.creatures = creatures;
  390. sac.creatures[0].first = 0;
  391. InfoWindow iw;
  392. iw.type = EInfoWindowMode::AUTO;
  393. iw.player = h->tempOwner;
  394. iw.text.appendLocalString(EMetaText::GENERAL_TXT, 423); //%d %s join your army.
  395. iw.text.replaceNumber(count);
  396. iw.text.replaceNamePlural(crid);
  397. gameEvents.showInfoDialog(&iw);
  398. gameEvents.sendAndApply(sac);
  399. gameEvents.addToSlot(StackLocation(h->id, slot), crs, count);
  400. }
  401. }
  402. else //there no creatures
  403. {
  404. InfoWindow iw;
  405. iw.type = EInfoWindowMode::AUTO;
  406. iw.text.appendLocalString(EMetaText::GENERAL_TXT, 422); //There are no %s here to recruit.
  407. iw.text.replaceNamePlural(crid);
  408. iw.player = h->tempOwner;
  409. gameEvents.sendAndApply(iw);
  410. }
  411. }
  412. else
  413. {
  414. if(ID == Obj::WAR_MACHINE_FACTORY) //pick available War Machines
  415. {
  416. //there is 1 war machine available to recruit if hero doesn't have one
  417. SetAvailableCreatures sac;
  418. sac.tid = id;
  419. sac.creatures = creatures;
  420. for (auto & entry : sac.creatures)
  421. {
  422. CreatureID creature = entry.second.at(0);
  423. ArtifactID warMachine = creature.toCreature()->warMachine;
  424. if (h->hasArt(warMachine, true, false))
  425. entry.first = 0;
  426. else
  427. entry.first = 1;
  428. }
  429. gameEvents.sendAndApply(sac);
  430. }
  431. auto windowMode = (ID == Obj::CREATURE_GENERATOR1 || ID == Obj::REFUGEE_CAMP) ? EOpenWindowMode::RECRUITMENT_FIRST : EOpenWindowMode::RECRUITMENT_ALL;
  432. gameEvents.showObjectWindow(this, windowMode, h, true);
  433. }
  434. }
  435. void CGDwelling::battleFinished(IGameEventCallback & gameEvents, const CGHeroInstance *hero, const BattleResult &result) const
  436. {
  437. if (result.winner == BattleSide::ATTACKER)
  438. {
  439. onHeroVisit(gameEvents, hero);
  440. }
  441. }
  442. void CGDwelling::blockingDialogAnswered(IGameEventCallback & gameEvents, const CGHeroInstance *hero, int32_t answer) const
  443. {
  444. auto relations = cb->getPlayerRelations(getOwner(), hero->getOwner());
  445. if(stacksCount() > 0 && relations == PlayerRelations::ENEMIES) //guards present
  446. {
  447. if(answer)
  448. gameEvents.startBattle(hero, this);
  449. }
  450. else if(answer)
  451. {
  452. heroAcceptsCreatures(gameEvents, hero);
  453. }
  454. }
  455. void CGDwelling::serializeJsonOptions(JsonSerializeFormat & handler)
  456. {
  457. switch (ID.toEnum())
  458. {
  459. case Obj::WAR_MACHINE_FACTORY:
  460. case Obj::REFUGEE_CAMP:
  461. //do nothing
  462. break;
  463. case Obj::RANDOM_DWELLING:
  464. case Obj::RANDOM_DWELLING_LVL:
  465. case Obj::RANDOM_DWELLING_FACTION:
  466. if (!handler.saving)
  467. randomizationInfo = CGDwellingRandomizationInfo();
  468. randomizationInfo->serializeJson(handler);
  469. [[fallthrough]];
  470. default:
  471. serializeJsonOwner(handler);
  472. break;
  473. }
  474. }
  475. const IOwnableObject * CGDwelling::asOwnable() const
  476. {
  477. switch (ID.toEnum())
  478. {
  479. case Obj::WAR_MACHINE_FACTORY:
  480. case Obj::REFUGEE_CAMP:
  481. return nullptr; // can't be owned
  482. default:
  483. return this;
  484. }
  485. }
  486. ResourceSet CGDwelling::dailyIncome() const
  487. {
  488. return {};
  489. }
  490. std::vector<CreatureID> CGDwelling::providedCreatures() const
  491. {
  492. if (ID == Obj::WAR_MACHINE_FACTORY || ID == Obj::REFUGEE_CAMP)
  493. return {};
  494. std::vector<CreatureID> result;
  495. for (const auto & level : creatures)
  496. result.insert(result.end(), level.second.begin(), level.second.end());
  497. return result;
  498. }
  499. VCMI_LIB_NAMESPACE_END