CGCreature.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. /*
  2. * CGCreature.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 "CGCreature.h"
  12. #include "CGHeroInstance.h"
  13. #include "../CGeneralTextHandler.h"
  14. #include "../CConfigHandler.h"
  15. #include "../GameSettings.h"
  16. #include "../IGameCallback.h"
  17. #include "../networkPacks/PacksForClient.h"
  18. #include "../networkPacks/PacksForClientBattle.h"
  19. #include "../networkPacks/StackLocation.h"
  20. #include "../serializer/JsonSerializeFormat.h"
  21. VCMI_LIB_NAMESPACE_BEGIN
  22. std::string CGCreature::getHoverText(PlayerColor player) const
  23. {
  24. if(stacks.empty())
  25. {
  26. //should not happen...
  27. logGlobal->error("Invalid stack at tile %s: subID=%d; id=%d", pos.toString(), getCreature(), id.getNum());
  28. return "INVALID_STACK";
  29. }
  30. std::string hoverName;
  31. MetaString ms;
  32. CCreature::CreatureQuantityId monsterQuantityId = stacks.begin()->second->getQuantityID();
  33. int quantityTextIndex = 172 + 3 * (int)monsterQuantityId;
  34. if(settings["gameTweaks"]["numericCreaturesQuantities"].Bool())
  35. ms.appendRawString(CCreature::getQuantityRangeStringForId(monsterQuantityId));
  36. else
  37. ms.appendLocalString(EMetaText::ARRAY_TXT, quantityTextIndex);
  38. ms.appendRawString(" ");
  39. ms.appendLocalString(EMetaText::CRE_PL_NAMES, getCreature());
  40. hoverName = ms.toString();
  41. return hoverName;
  42. }
  43. std::string CGCreature::getHoverText(const CGHeroInstance * hero) const
  44. {
  45. std::string hoverName;
  46. if(hero->hasVisions(this, BonusCustomSubtype::visionsMonsters))
  47. {
  48. MetaString ms;
  49. ms.appendNumber(stacks.begin()->second->count);
  50. ms.appendRawString(" ");
  51. ms.appendLocalString(EMetaText::CRE_PL_NAMES, getCreature());
  52. ms.appendRawString("\n\n");
  53. int decision = takenAction(hero, true);
  54. switch (decision)
  55. {
  56. case FIGHT:
  57. ms.appendLocalString(EMetaText::GENERAL_TXT,246);
  58. break;
  59. case FLEE:
  60. ms.appendLocalString(EMetaText::GENERAL_TXT,245);
  61. break;
  62. case JOIN_FOR_FREE:
  63. ms.appendLocalString(EMetaText::GENERAL_TXT,243);
  64. break;
  65. default: //decision = cost in gold
  66. ms.appendRawString(boost::str(boost::format(VLC->generaltexth->allTexts[244]) % decision));
  67. break;
  68. }
  69. hoverName = ms.toString();
  70. }
  71. else
  72. {
  73. hoverName = getHoverText(hero->tempOwner);
  74. }
  75. hoverName += VLC->generaltexth->translate("vcmi.adventureMap.monsterThreat.title");
  76. int choice;
  77. double ratio = (static_cast<double>(getArmyStrength()) / hero->getTotalStrength());
  78. if (ratio < 0.1) choice = 0;
  79. else if (ratio < 0.25) choice = 1;
  80. else if (ratio < 0.6) choice = 2;
  81. else if (ratio < 0.9) choice = 3;
  82. else if (ratio < 1.1) choice = 4;
  83. else if (ratio < 1.3) choice = 5;
  84. else if (ratio < 1.8) choice = 6;
  85. else if (ratio < 2.5) choice = 7;
  86. else if (ratio < 4) choice = 8;
  87. else if (ratio < 8) choice = 9;
  88. else if (ratio < 20) choice = 10;
  89. else choice = 11;
  90. hoverName += VLC->generaltexth->translate("vcmi.adventureMap.monsterThreat.levels." + std::to_string(choice));
  91. return hoverName;
  92. }
  93. void CGCreature::onHeroVisit( const CGHeroInstance * h ) const
  94. {
  95. //show message
  96. if(!message.empty())
  97. {
  98. InfoWindow iw;
  99. iw.player = h->tempOwner;
  100. iw.text = message;
  101. iw.type = EInfoWindowMode::MODAL;
  102. cb->showInfoDialog(&iw);
  103. }
  104. int action = takenAction(h);
  105. switch( action ) //decide what we do...
  106. {
  107. case FIGHT:
  108. fight(h);
  109. break;
  110. case FLEE:
  111. {
  112. flee(h);
  113. break;
  114. }
  115. case JOIN_FOR_FREE: //join for free
  116. {
  117. BlockingDialog ynd(true,false);
  118. ynd.player = h->tempOwner;
  119. ynd.text.appendLocalString(EMetaText::ADVOB_TXT, 86);
  120. ynd.text.replaceLocalString(EMetaText::CRE_PL_NAMES, getCreature());
  121. cb->showBlockingDialog(&ynd);
  122. break;
  123. }
  124. default: //join for gold
  125. {
  126. assert(action > 0);
  127. //ask if player agrees to pay gold
  128. BlockingDialog ynd(true,false);
  129. ynd.player = h->tempOwner;
  130. std::string tmp = VLC->generaltexth->advobtxt[90];
  131. boost::algorithm::replace_first(tmp, "%d", std::to_string(getStackCount(SlotID(0))));
  132. boost::algorithm::replace_first(tmp, "%d", std::to_string(action));
  133. boost::algorithm::replace_first(tmp,"%s",VLC->creatures()->getById(getCreature())->getNamePluralTranslated());
  134. ynd.text.appendRawString(tmp);
  135. cb->showBlockingDialog(&ynd);
  136. break;
  137. }
  138. }
  139. }
  140. CreatureID CGCreature::getCreature() const
  141. {
  142. return CreatureID(getObjTypeIndex().getNum());
  143. }
  144. void CGCreature::pickRandomObject(CRandomGenerator & rand)
  145. {
  146. switch(ID)
  147. {
  148. case MapObjectID::RANDOM_MONSTER:
  149. subID = VLC->creh->pickRandomMonster(rand);
  150. break;
  151. case MapObjectID::RANDOM_MONSTER_L1:
  152. subID = VLC->creh->pickRandomMonster(rand, 1);
  153. break;
  154. case MapObjectID::RANDOM_MONSTER_L2:
  155. subID = VLC->creh->pickRandomMonster(rand, 2);
  156. break;
  157. case MapObjectID::RANDOM_MONSTER_L3:
  158. subID = VLC->creh->pickRandomMonster(rand, 3);
  159. break;
  160. case MapObjectID::RANDOM_MONSTER_L4:
  161. subID = VLC->creh->pickRandomMonster(rand, 4);
  162. break;
  163. case MapObjectID::RANDOM_MONSTER_L5:
  164. subID = VLC->creh->pickRandomMonster(rand, 5);
  165. break;
  166. case MapObjectID::RANDOM_MONSTER_L6:
  167. subID = VLC->creh->pickRandomMonster(rand, 6);
  168. break;
  169. case MapObjectID::RANDOM_MONSTER_L7:
  170. subID = VLC->creh->pickRandomMonster(rand, 7);
  171. break;
  172. }
  173. ID = MapObjectID::MONSTER;
  174. setType(ID, subID);
  175. }
  176. void CGCreature::initObj(CRandomGenerator & rand)
  177. {
  178. blockVisit = true;
  179. switch(character)
  180. {
  181. case 0:
  182. character = -4;
  183. break;
  184. case 1:
  185. character = rand.nextInt(1, 7);
  186. break;
  187. case 2:
  188. character = rand.nextInt(1, 10);
  189. break;
  190. case 3:
  191. character = rand.nextInt(4, 10);
  192. break;
  193. case 4:
  194. character = 10;
  195. break;
  196. }
  197. stacks[SlotID(0)]->setType(getCreature());
  198. TQuantity &amount = stacks[SlotID(0)]->count;
  199. const Creature * c = VLC->creatures()->getById(getCreature());
  200. if(amount == 0)
  201. {
  202. amount = rand.nextInt(c->getAdvMapAmountMin(), c->getAdvMapAmountMax());
  203. if(amount == 0) //armies with 0 creatures are illegal
  204. {
  205. logGlobal->warn("Stack cannot have 0 creatures. Check properties of %s", c->getJsonKey());
  206. amount = 1;
  207. }
  208. }
  209. temppower = stacks[SlotID(0)]->count * static_cast<ui64>(1000);
  210. refusedJoining = false;
  211. }
  212. void CGCreature::newTurn(CRandomGenerator & rand) const
  213. {//Works only for stacks of single type of size up to 2 millions
  214. if (!notGrowingTeam)
  215. {
  216. if (stacks.begin()->second->count < VLC->settings()->getInteger(EGameSettings::CREATURES_WEEKLY_GROWTH_CAP) && cb->getDate(Date::DAY_OF_WEEK) == 1 && cb->getDate(Date::DAY) > 1)
  217. {
  218. ui32 power = static_cast<ui32>(temppower * (100 + VLC->settings()->getInteger(EGameSettings::CREATURES_WEEKLY_GROWTH_PERCENT)) / 100);
  219. cb->setObjProperty(id, ObjProperty::MONSTER_COUNT, std::min<uint32_t>(power / 1000, VLC->settings()->getInteger(EGameSettings::CREATURES_WEEKLY_GROWTH_CAP))); //set new amount
  220. cb->setObjProperty(id, ObjProperty::MONSTER_POWER, power); //increase temppower
  221. }
  222. }
  223. if (VLC->settings()->getBoolean(EGameSettings::MODULE_STACK_EXPERIENCE))
  224. cb->setObjProperty(id, ObjProperty::MONSTER_EXP, VLC->settings()->getInteger(EGameSettings::CREATURES_DAILY_STACK_EXPERIENCE)); //for testing purpose
  225. }
  226. void CGCreature::setPropertyDer(ui8 what, ui32 val)
  227. {
  228. switch (what)
  229. {
  230. case ObjProperty::MONSTER_COUNT:
  231. stacks[SlotID(0)]->count = val;
  232. break;
  233. case ObjProperty::MONSTER_POWER:
  234. temppower = val;
  235. break;
  236. case ObjProperty::MONSTER_EXP:
  237. giveStackExp(val);
  238. break;
  239. case ObjProperty::MONSTER_RESTORE_TYPE:
  240. formation.basicType = val;
  241. break;
  242. case ObjProperty::MONSTER_REFUSED_JOIN:
  243. refusedJoining = val;
  244. break;
  245. }
  246. }
  247. int CGCreature::takenAction(const CGHeroInstance *h, bool allowJoin) const
  248. {
  249. //calculate relative strength of hero and creatures armies
  250. double relStrength = static_cast<double>(h->getTotalStrength()) / getArmyStrength();
  251. int powerFactor;
  252. if(relStrength >= 7)
  253. powerFactor = 11;
  254. else if(relStrength >= 1)
  255. powerFactor = static_cast<int>(2 * (relStrength - 1));
  256. else if(relStrength >= 0.5)
  257. powerFactor = -1;
  258. else if(relStrength >= 0.333)
  259. powerFactor = -2;
  260. else
  261. powerFactor = -3;
  262. std::set<CreatureID> myKindCres; //what creatures are the same kind as we
  263. const CCreature * myCreature = VLC->creh->objects[getCreature().getNum()];
  264. myKindCres.insert(myCreature->getId()); //we
  265. myKindCres.insert(myCreature->upgrades.begin(), myCreature->upgrades.end()); //our upgrades
  266. for(ConstTransitivePtr<CCreature> &crea : VLC->creh->objects)
  267. {
  268. if(vstd::contains(crea->upgrades, myCreature->getId())) //it's our base creatures
  269. myKindCres.insert(crea->getId());
  270. }
  271. int count = 0; //how many creatures of similar kind has hero
  272. int totalCount = 0;
  273. for(const auto & elem : h->Slots())
  274. {
  275. if(vstd::contains(myKindCres,elem.second->type->getId()))
  276. count += elem.second->count;
  277. totalCount += elem.second->count;
  278. }
  279. int sympathy = 0; // 0 if hero have no similar creatures
  280. if(count)
  281. sympathy++; // 1 - if hero have at least 1 similar creature
  282. if(count*2 > totalCount)
  283. sympathy++; // 2 - hero have similar creatures more that 50%
  284. int diplomacy = h->valOfBonuses(BonusType::WANDERING_CREATURES_JOIN_BONUS);
  285. int charisma = powerFactor + diplomacy + sympathy;
  286. if(charisma < character)
  287. return FIGHT;
  288. if (allowJoin)
  289. {
  290. if(diplomacy + sympathy + 1 >= character)
  291. return JOIN_FOR_FREE;
  292. else if(diplomacy * 2 + sympathy + 1 >= character)
  293. return VLC->creatures()->getById(getCreature())->getRecruitCost(EGameResID::GOLD) * getStackCount(SlotID(0)); //join for gold
  294. }
  295. //we are still here - creatures have not joined hero, flee or fight
  296. if (charisma > character && !neverFlees)
  297. return FLEE;
  298. else
  299. return FIGHT;
  300. }
  301. void CGCreature::fleeDecision(const CGHeroInstance *h, ui32 pursue) const
  302. {
  303. if(refusedJoining)
  304. cb->setObjProperty(id, ObjProperty::MONSTER_REFUSED_JOIN, false);
  305. if(pursue)
  306. {
  307. fight(h);
  308. }
  309. else
  310. {
  311. cb->removeObject(this, h->getOwner());
  312. }
  313. }
  314. void CGCreature::joinDecision(const CGHeroInstance *h, int cost, ui32 accept) const
  315. {
  316. if(!accept)
  317. {
  318. if(takenAction(h,false) == FLEE)
  319. {
  320. cb->setObjProperty(id, ObjProperty::MONSTER_REFUSED_JOIN, true);
  321. flee(h);
  322. }
  323. else //they fight
  324. {
  325. h->showInfoDialog(87, 0, EInfoWindowMode::MODAL);//Insulted by your refusal of their offer, the monsters attack!
  326. fight(h);
  327. }
  328. }
  329. else //accepted
  330. {
  331. if (cb->getResource(h->tempOwner, EGameResID::GOLD) < cost) //player don't have enough gold!
  332. {
  333. InfoWindow iw;
  334. iw.player = h->tempOwner;
  335. iw.text.appendLocalString(EMetaText::GENERAL_TXT,29); //You don't have enough gold
  336. cb->showInfoDialog(&iw);
  337. //act as if player refused
  338. joinDecision(h,cost,false);
  339. return;
  340. }
  341. //take gold
  342. if(cost)
  343. cb->giveResource(h->tempOwner,EGameResID::GOLD,-cost);
  344. giveReward(h);
  345. cb->tryJoiningArmy(this, h, true, true);
  346. }
  347. }
  348. void CGCreature::fight( const CGHeroInstance *h ) const
  349. {
  350. //split stacks
  351. //TODO: multiple creature types in a stack?
  352. int basicType = stacks.begin()->second->type->getId();
  353. cb->setObjProperty(id, ObjProperty::MONSTER_RESTORE_TYPE, basicType); //store info about creature stack
  354. int stacksCount = getNumberOfStacks(h);
  355. //source: http://heroescommunity.com/viewthread.php3?TID=27539&PID=1266335#focus
  356. int amount = getStackCount(SlotID(0));
  357. int m = amount / stacksCount;
  358. int b = stacksCount * (m + 1) - amount;
  359. int a = stacksCount - b;
  360. SlotID sourceSlot = stacks.begin()->first;
  361. for (int slotID = 1; slotID < a; ++slotID)
  362. {
  363. int stackSize = m + 1;
  364. cb->moveStack(StackLocation(this, sourceSlot), StackLocation(this, SlotID(slotID)), stackSize);
  365. }
  366. for (int slotID = a; slotID < stacksCount; ++slotID)
  367. {
  368. int stackSize = m;
  369. if (slotID) //don't do this when a = 0 -> stack is single
  370. cb->moveStack(StackLocation(this, sourceSlot), StackLocation(this, SlotID(slotID)), stackSize);
  371. }
  372. if (stacksCount > 1)
  373. {
  374. if (containsUpgradedStack()) //upgrade
  375. {
  376. SlotID slotID = SlotID(static_cast<si32>(std::floor(static_cast<float>(stacks.size()) / 2.0f)));
  377. const auto & upgrades = getStack(slotID).type->upgrades;
  378. if(!upgrades.empty())
  379. {
  380. auto it = RandomGeneratorUtil::nextItem(upgrades, CRandomGenerator::getDefault());
  381. cb->changeStackType(StackLocation(this, slotID), VLC->creh->objects[*it]);
  382. }
  383. }
  384. }
  385. cb->startBattleI(h, this);
  386. }
  387. void CGCreature::flee( const CGHeroInstance * h ) const
  388. {
  389. BlockingDialog ynd(true,false);
  390. ynd.player = h->tempOwner;
  391. ynd.text.appendLocalString(EMetaText::ADVOB_TXT,91);
  392. ynd.text.replaceLocalString(EMetaText::CRE_PL_NAMES, getCreature());
  393. cb->showBlockingDialog(&ynd);
  394. }
  395. void CGCreature::battleFinished(const CGHeroInstance *hero, const BattleResult &result) const
  396. {
  397. if(result.winner == 0)
  398. {
  399. giveReward(hero);
  400. cb->removeObject(this, hero->getOwner());
  401. }
  402. else if(result.winner > 1) // draw
  403. {
  404. // guarded reward is lost forever on draw
  405. cb->removeObject(this, hero->getOwner());
  406. }
  407. else
  408. {
  409. //merge stacks into one
  410. TSlots::const_iterator i;
  411. CCreature * cre = VLC->creh->objects[formation.basicType];
  412. for(i = stacks.begin(); i != stacks.end(); i++)
  413. {
  414. if(cre->isMyUpgrade(i->second->type))
  415. {
  416. cb->changeStackType(StackLocation(this, i->first), cre); //un-upgrade creatures
  417. }
  418. }
  419. //first stack has to be at slot 0 -> if original one got killed, move there first remaining stack
  420. if(!hasStackAtSlot(SlotID(0)))
  421. cb->moveStack(StackLocation(this, stacks.begin()->first), StackLocation(this, SlotID(0)), stacks.begin()->second->count);
  422. while(stacks.size() > 1) //hopefully that's enough
  423. {
  424. // TODO it's either overcomplicated (if we assume there'll be only one stack) or buggy (if we allow multiple stacks... but that'll also cause troubles elsewhere)
  425. i = stacks.end();
  426. i--;
  427. SlotID slot = getSlotFor(i->second->type);
  428. if(slot == i->first) //no reason to move stack to its own slot
  429. break;
  430. else
  431. cb->moveStack(StackLocation(this, i->first), StackLocation(this, slot), i->second->count);
  432. }
  433. cb->setObjProperty(id, ObjProperty::MONSTER_POWER, stacks.begin()->second->count * 1000); //remember casualties
  434. }
  435. }
  436. void CGCreature::blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const
  437. {
  438. auto action = takenAction(hero);
  439. if(!refusedJoining && action >= JOIN_FOR_FREE) //higher means price
  440. joinDecision(hero, action, answer);
  441. else if(action != FIGHT)
  442. fleeDecision(hero, answer);
  443. else
  444. assert(0);
  445. }
  446. bool CGCreature::containsUpgradedStack() const
  447. {
  448. //source http://heroescommunity.com/viewthread.php3?TID=27539&PID=830557#focus
  449. float a = 2992.911117f;
  450. float b = 14174.264968f;
  451. float c = 5325.181015f;
  452. float d = 32788.727920f;
  453. int val = static_cast<int>(std::floor(a * pos.x + b * pos.y + c * pos.z + d));
  454. return ((val % 32768) % 100) < 50;
  455. }
  456. int CGCreature::getNumberOfStacks(const CGHeroInstance *hero) const
  457. {
  458. //source http://heroescommunity.com/viewthread.php3?TID=27539&PID=1266094#focus
  459. double strengthRatio = static_cast<double>(hero->getArmyStrength()) / getArmyStrength();
  460. int split = 1;
  461. if (strengthRatio < 0.5f)
  462. split = 7;
  463. else if (strengthRatio < 0.67f)
  464. split = 6;
  465. else if (strengthRatio < 1)
  466. split = 5;
  467. else if (strengthRatio < 1.5f)
  468. split = 4;
  469. else if (strengthRatio < 2)
  470. split = 3;
  471. else
  472. split = 2;
  473. ui32 a = 1550811371u;
  474. ui32 b = 3359066809u;
  475. ui32 c = 1943276003u;
  476. ui32 d = 3174620878u;
  477. ui32 R1 = a * static_cast<ui32>(pos.x) + b * static_cast<ui32>(pos.y) + c * static_cast<ui32>(pos.z) + d;
  478. ui32 R2 = (R1 >> 16) & 0x7fff;
  479. int R4 = R2 % 100 + 1;
  480. if (R4 <= 20)
  481. split -= 1;
  482. else if (R4 >= 80)
  483. split += 1;
  484. vstd::amin(split, getStack(SlotID(0)).count); //can't divide into more stacks than creatures total
  485. vstd::amin(split, 7); //can't have more than 7 stacks
  486. return split;
  487. }
  488. void CGCreature::giveReward(const CGHeroInstance * h) const
  489. {
  490. InfoWindow iw;
  491. iw.player = h->tempOwner;
  492. if(!resources.empty())
  493. {
  494. cb->giveResources(h->tempOwner, resources);
  495. for(auto const & res : GameResID::ALL_RESOURCES())
  496. {
  497. if(resources[res] > 0)
  498. iw.components.emplace_back(ComponentType::RESOURCE, res, resources[res]);
  499. }
  500. }
  501. if(gainedArtifact != ArtifactID::NONE)
  502. {
  503. cb->giveHeroNewArtifact(h, VLC->arth->objects[gainedArtifact], ArtifactPosition::FIRST_AVAILABLE);
  504. iw.components.emplace_back(ComponentType::ARTIFACT, gainedArtifact);
  505. }
  506. if(!iw.components.empty())
  507. {
  508. iw.type = EInfoWindowMode::AUTO;
  509. iw.text.appendLocalString(EMetaText::ADVOB_TXT, 183); // % has found treasure
  510. iw.text.replaceRawString(h->getNameTranslated());
  511. cb->showInfoDialog(&iw);
  512. }
  513. }
  514. static const std::vector<std::string> CHARACTER_JSON =
  515. {
  516. "compliant", "friendly", "aggressive", "hostile", "savage"
  517. };
  518. void CGCreature::serializeJsonOptions(JsonSerializeFormat & handler)
  519. {
  520. handler.serializeEnum("character", character, CHARACTER_JSON);
  521. if(handler.saving)
  522. {
  523. if(hasStackAtSlot(SlotID(0)))
  524. {
  525. si32 amount = getStack(SlotID(0)).count;
  526. handler.serializeInt("amount", amount, 0);
  527. }
  528. }
  529. else
  530. {
  531. si32 amount = 0;
  532. handler.serializeInt("amount", amount);
  533. auto * hlp = new CStackInstance();
  534. hlp->count = amount;
  535. //type will be set during initialization
  536. putStack(SlotID(0), hlp);
  537. }
  538. resources.serializeJson(handler, "rewardResources");
  539. handler.serializeId("rewardArtifact", gainedArtifact, ArtifactID(ArtifactID::NONE));
  540. handler.serializeBool("noGrowing", notGrowingTeam);
  541. handler.serializeBool("neverFlees", neverFlees);
  542. handler.serializeStruct("rewardMessage", message);
  543. }
  544. VCMI_LIB_NAMESPACE_END