CArtHandler.cpp 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531
  1. #include "StdInc.h"
  2. #include "CArtHandler.h"
  3. #include "Filesystem/CResourceLoader.h"
  4. #include "CLodHandler.h"
  5. #include "CGeneralTextHandler.h"
  6. #include <boost/random/linear_congruential.hpp>
  7. #include "VCMI_Lib.h"
  8. #include "CSpellHandler.h"
  9. #include "CObjectHandler.h"
  10. #include "NetPacks.h"
  11. #include "JsonNode.h"
  12. using namespace boost::assign;
  13. /*
  14. * CArtHandler.cpp, part of VCMI engine
  15. *
  16. * Authors: listed in file AUTHORS in main folder
  17. *
  18. * License: GNU General Public License v2.0 or later
  19. * Full text of license available in license.txt file, in main folder
  20. *
  21. */
  22. extern boost::rand48 ran;
  23. extern Bonus * ParseBonus (const JsonVector &ability_vec);
  24. const std::string & CArtifact::Name() const
  25. {
  26. if(name.size())
  27. return name;
  28. else
  29. return VLC->generaltexth->artifNames[id];
  30. }
  31. const std::string & CArtifact::Description() const
  32. {
  33. if(description.size())
  34. return description;
  35. else
  36. return VLC->generaltexth->artifDescriptions[id];
  37. }
  38. bool CArtifact::isBig () const
  39. {
  40. return VLC->arth->isBigArtifact(id);
  41. }
  42. // /**
  43. // * Checks whether the artifact fits at a given slot.
  44. // * @param artifWorn A hero's set of worn artifacts.
  45. // */
  46. // bool CArtifact::fitsAt (const std::map<ui16, const CArtifact*> &artifWorn, ui16 slotID) const
  47. // {
  48. // if (!vstd::contains(possibleSlots, slotID))
  49. // return false;
  50. //
  51. // // Can't put an artifact in a locked slot.
  52. // std::map<ui16, const CArtifact*>::const_iterator it = artifWorn.find(slotID);
  53. // if (it != artifWorn.end() && it->second->id == 145)
  54. // return false;
  55. //
  56. // // Check if a combination artifact fits.
  57. // // TODO: Might want a more general algorithm?
  58. // // Assumes that misc & rings fits only in their slots, and others in only one slot and no duplicates.
  59. // if (constituents != NULL)
  60. // {
  61. // std::map<ui16, const CArtifact*> tempArtifWorn = artifWorn;
  62. // const ui16 ringSlots[] = {6, 7};
  63. // const ui16 miscSlots[] = {9, 10, 11, 12, 18};
  64. // int rings = 0;
  65. // int misc = 0;
  66. //
  67. // VLC->arth->unequipArtifact(tempArtifWorn, slotID);
  68. //
  69. // BOOST_FOREACH(ui32 constituentID, *constituents)
  70. // {
  71. // const CArtifact& constituent = *VLC->arth->artifacts[constituentID];
  72. // const int slot = constituent.possibleSlots[0];
  73. //
  74. // if (slot == 6 || slot == 7)
  75. // rings++;
  76. // else if ((slot >= 9 && slot <= 12) || slot == 18)
  77. // misc++;
  78. // else if (tempArtifWorn.find(slot) != tempArtifWorn.end())
  79. // return false;
  80. // }
  81. //
  82. // // Ensure enough ring slots are free
  83. // for (int i = 0; i < sizeof(ringSlots)/sizeof(*ringSlots); i++)
  84. // {
  85. // if (tempArtifWorn.find(ringSlots[i]) == tempArtifWorn.end() || ringSlots[i] == slotID)
  86. // rings--;
  87. // }
  88. // if (rings > 0)
  89. // return false;
  90. //
  91. // // Ensure enough misc slots are free.
  92. // for (int i = 0; i < sizeof(miscSlots)/sizeof(*miscSlots); i++)
  93. // {
  94. // if (tempArtifWorn.find(miscSlots[i]) == tempArtifWorn.end() || miscSlots[i] == slotID)
  95. // misc--;
  96. // }
  97. // if (misc > 0)
  98. // return false;
  99. // }
  100. //
  101. // return true;
  102. // }
  103. // bool CArtifact::canBeAssembledTo (const std::map<ui16, const CArtifact*> &artifWorn, ui32 artifactID) const
  104. // {
  105. // if (constituentOf == NULL || !vstd::contains(*constituentOf, artifactID))
  106. // return false;
  107. //
  108. // const CArtifact &artifact = *VLC->arth->artifacts[artifactID];
  109. // assert(artifact.constituents);
  110. //
  111. // BOOST_FOREACH(ui32 constituentID, *artifact.constituents)
  112. // {
  113. // bool found = false;
  114. // for (std::map<ui16, const CArtifact*>::const_iterator it = artifWorn.begin(); it != artifWorn.end(); ++it)
  115. // {
  116. // if (it->second->id == constituentID)
  117. // {
  118. // found = true;
  119. // break;
  120. // }
  121. // }
  122. // if (!found)
  123. // return false;
  124. // }
  125. //
  126. // return true;
  127. // }
  128. CArtifact::CArtifact()
  129. {
  130. setNodeType(ARTIFACT);
  131. }
  132. CArtifact::~CArtifact()
  133. {
  134. }
  135. int CArtifact::getArtClassSerial() const
  136. {
  137. if(id == 1)
  138. return 4;
  139. switch(aClass)
  140. {
  141. case ART_TREASURE:
  142. return 0;
  143. case ART_MINOR:
  144. return 1;
  145. case ART_MAJOR:
  146. return 2;
  147. case ART_RELIC:
  148. return 3;
  149. case ART_SPECIAL:
  150. return 5;
  151. }
  152. return -1;
  153. }
  154. std::string CArtifact::nodeName() const
  155. {
  156. return "Artifact: " + Name();
  157. }
  158. // void CArtifact::getParents(TCNodes &out, const CBonusSystemNode *root /*= NULL*/) const
  159. // {
  160. // //combined artifact carries bonuses from its parts
  161. // if(constituents)
  162. // {
  163. // BOOST_FOREACH(ui32 id, *constituents)
  164. // out.insert(VLC->arth->artifacts[id]);
  165. // }
  166. // }
  167. // void CScroll::Init()
  168. // {
  169. // // addNewBonus (Bonus (Bonus::PERMANENT, Bonus::SPELL, Bonus::ARTIFACT, 1, id, spellid, Bonus::INDEPENDENT_MAX));
  170. // // //boost::algorithm::replace_first(description, "[spell name]", VLC->spellh->spells[spellid].name);
  171. // }
  172. void CArtifact::setDescription (std::string desc)
  173. {
  174. description = desc;
  175. }
  176. void CGrowingArtifact::levelUpArtifact (CArtifactInstance * art)
  177. {
  178. Bonus b;
  179. b.type = Bonus::LEVEL_COUNTER;
  180. b.val = 1;
  181. b.duration = Bonus::COMMANDER_KILLED;
  182. art->accumulateBonus (b);
  183. BOOST_FOREACH (auto bonus, bonusesPerLevel)
  184. {
  185. if (art->valOfBonuses(Bonus::LEVEL_COUNTER) % bonus.first == 0) //every n levels
  186. {
  187. art->accumulateBonus (bonus.second);
  188. }
  189. }
  190. BOOST_FOREACH (auto bonus, thresholdBonuses)
  191. {
  192. if (art->valOfBonuses(Bonus::LEVEL_COUNTER) == bonus.first) //every n levels
  193. {
  194. art->addNewBonus (&bonus.second);
  195. }
  196. }
  197. }
  198. CArtHandler::CArtHandler()
  199. {
  200. VLC->arth = this;
  201. // War machines are the default big artifacts.
  202. for (ui32 i = 3; i <= 6; i++)
  203. bigArtifacts.insert(i);
  204. }
  205. CArtHandler::~CArtHandler()
  206. {
  207. for (std::vector< ConstTransitivePtr<CArtifact> >::iterator it = artifacts.begin(); it != artifacts.end(); ++it)
  208. {
  209. delete (*it)->constituents;
  210. delete (*it)->constituentOf;
  211. }
  212. }
  213. void CArtHandler::loadArtifacts(bool onlyTxt)
  214. {
  215. std::vector<ui16> slots;
  216. slots += 17, 16, 15, 14, 13, 18, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0;
  217. growingArtifacts += 146, 147, 148, 150, 151, 152, 153;
  218. static std::map<char, CArtifact::EartClass> classes =
  219. map_list_of('S',CArtifact::ART_SPECIAL)('T',CArtifact::ART_TREASURE)('N',CArtifact::ART_MINOR)('J',CArtifact::ART_MAJOR)('R',CArtifact::ART_RELIC);
  220. auto textFile = CResourceHandler::get()->loadData(ResourceID("DATA/ARTRAITS.TXT"));
  221. std::string buf((char*)textFile.first.get(), textFile.second);
  222. std::string dump, pom;
  223. int it=0;
  224. for(int i=0; i<2; ++i)
  225. {
  226. loadToIt(dump,buf,it,3);
  227. }
  228. VLC->generaltexth->artifNames.resize(GameConstants::ARTIFACTS_QUANTITY);
  229. VLC->generaltexth->artifDescriptions.resize(GameConstants::ARTIFACTS_QUANTITY);
  230. std::map<ui32,ui8>::iterator itr;
  231. for (int i=0; i<GameConstants::ARTIFACTS_QUANTITY; i++)
  232. {
  233. CArtifact *art;
  234. if (vstd::contains (growingArtifacts, i))
  235. {
  236. art = new CGrowingArtifact();
  237. }
  238. else
  239. {
  240. art = new CArtifact();
  241. }
  242. CArtifact &nart = *art;
  243. nart.id=i;
  244. loadToIt(VLC->generaltexth->artifNames[i],buf,it,4);
  245. loadToIt(pom,buf,it,4);
  246. nart.price=atoi(pom.c_str());
  247. nart.possibleSlots[ArtBearer::HERO]; //we want to generate map entry even if it will be empty
  248. nart.possibleSlots[ArtBearer::CREATURE]; //we want to generate map entry even if it will be empty
  249. nart.possibleSlots[ArtBearer::COMMANDER];
  250. for(int j=0;j<slots.size();j++)
  251. {
  252. loadToIt(pom,buf,it,4);
  253. if(pom.size() && pom[0]=='x')
  254. nart.possibleSlots[ArtBearer::HERO].push_back(slots[j]);
  255. }
  256. loadToIt(pom,buf,it,4);
  257. nart.aClass = classes[pom[0]];
  258. //load description and remove quotation marks
  259. std::string &desc = VLC->generaltexth->artifDescriptions[i];
  260. loadToIt(desc,buf,it,3);
  261. if(desc[0] == '\"' && desc[desc.size()-1] == '\"')
  262. desc = desc.substr(1,desc.size()-2);
  263. if(onlyTxt)
  264. continue;
  265. // Fill in information about combined artifacts. Should perhaps be moved to a config file?
  266. nart.constituentOf = NULL;
  267. switch (nart.id)
  268. {
  269. case 129: // Angelic Alliance
  270. nart.constituents = new std::vector<ui32>();
  271. *nart.constituents += 31, 32, 33, 34, 35, 36;
  272. break;
  273. case 130: // Cloak of the Undead King
  274. nart.constituents = new std::vector<ui32>();
  275. *nart.constituents += 54, 55, 56;
  276. break;
  277. case 131: // Elixir of Life
  278. nart.constituents = new std::vector<ui32>();
  279. *nart.constituents += 94, 95, 96;
  280. break;
  281. case 132: // Armor of the Damned
  282. nart.constituents = new std::vector<ui32>();
  283. *nart.constituents += 8, 14, 20, 26;
  284. break;
  285. case 133: // Statue of Legion
  286. nart.constituents = new std::vector<ui32>();
  287. *nart.constituents += 118, 119, 120, 121, 122;
  288. break;
  289. case 134: // Power of the Dragon Father
  290. nart.constituents = new std::vector<ui32>();
  291. *nart.constituents += 37, 38, 39, 40, 41, 42, 43, 44, 45;
  292. break;
  293. case 135: // Titan's Thunder
  294. nart.constituents = new std::vector<ui32>();
  295. *nart.constituents += 12, 18, 24, 30;
  296. break;
  297. case 136: // Admiral's Hat
  298. nart.constituents = new std::vector<ui32>();
  299. *nart.constituents += 71, 123;
  300. break;
  301. case 137: // Bow of the Sharpshooter
  302. nart.constituents = new std::vector<ui32>();
  303. *nart.constituents += 60, 61, 62;
  304. break;
  305. case 138: // Wizards' Well
  306. nart.constituents = new std::vector<ui32>();
  307. *nart.constituents += 73, 74, 75;
  308. break;
  309. case 139: // Ring of the Magi
  310. nart.constituents = new std::vector<ui32>();
  311. *nart.constituents += 76, 77, 78;
  312. break;
  313. case 140: // Cornucopia
  314. nart.constituents = new std::vector<ui32>();
  315. *nart.constituents += 109, 110, 111, 113;
  316. break;
  317. // TODO: WoG combinationals
  318. default:
  319. nart.constituents = NULL;
  320. break;
  321. }
  322. artifacts.push_back(&nart);
  323. }
  324. if (GameConstants::COMMANDERS)
  325. { //TODO: move all artifacts config to separate json file
  326. const JsonNode config(GameConstants::DATA_DIR + "/config/commanders.json");
  327. BOOST_FOREACH(const JsonNode &artifact, config["artifacts"].Vector())
  328. {
  329. auto ga = dynamic_cast <CGrowingArtifact *>(artifacts[artifact["id"].Float()].get());
  330. BOOST_FOREACH (auto b, artifact["bonusesPerLevel"].Vector())
  331. {
  332. ga->bonusesPerLevel.push_back (std::pair <ui16, Bonus> (b["level"].Float(), *ParseBonus (b["bonus"].Vector())));
  333. }
  334. BOOST_FOREACH (auto b, artifact["thresholdBonuses"].Vector())
  335. {
  336. ga->thresholdBonuses.push_back (std::pair <ui16, Bonus> (b["level"].Float(), *ParseBonus (b["bonus"].Vector())));
  337. }
  338. }
  339. }
  340. sortArts();
  341. if(onlyTxt)
  342. return;
  343. addBonuses();
  344. // Populate reverse mappings of combinational artifacts.
  345. BOOST_FOREACH(CArtifact *artifact, artifacts)
  346. {
  347. if (artifact->constituents != NULL)
  348. {
  349. BOOST_FOREACH(ui32 constituentID, *artifact->constituents)
  350. {
  351. if (artifacts[constituentID]->constituentOf == NULL)
  352. artifacts[constituentID]->constituentOf = new std::vector<ui32>();
  353. artifacts[constituentID]->constituentOf->push_back(artifact->id);
  354. }
  355. }
  356. }
  357. }
  358. int CArtHandler::convertMachineID(int id, bool creToArt )
  359. {
  360. int dif = 142;
  361. if(creToArt)
  362. {
  363. switch (id)
  364. {
  365. case 147:
  366. dif--;
  367. break;
  368. case 148:
  369. dif++;
  370. break;
  371. }
  372. dif = -dif;
  373. }
  374. else
  375. {
  376. switch (id)
  377. {
  378. case 6:
  379. dif--;
  380. break;
  381. case 5:
  382. dif++;
  383. break;
  384. }
  385. }
  386. return id + dif;
  387. }
  388. void CArtHandler::sortArts()
  389. {
  390. //for (int i=0; i<allowedArtifacts.size(); ++i) //do 144, bo nie chcemy bzdurek
  391. //{
  392. // switch (allowedArtifacts[i]->aClass)
  393. // {
  394. // case CArtifact::ART_TREASURE:
  395. // treasures.push_back(allowedArtifacts[i]);
  396. // break;
  397. // case CArtifact::ART_MINOR:
  398. // minors.push_back(allowedArtifacts[i]);
  399. // break;
  400. // case CArtifact::ART_MAJOR:
  401. // majors.push_back(allowedArtifacts[i]);
  402. // break;
  403. // case CArtifact::ART_RELIC:
  404. // relics.push_back(allowedArtifacts[i]);
  405. // break;
  406. // }
  407. //}
  408. }
  409. void CArtHandler::erasePickedArt (si32 id)
  410. {
  411. std::vector<CArtifact*>* ptr;
  412. CArtifact *art = artifacts[id];
  413. switch (art->aClass)
  414. {
  415. case CArtifact::ART_TREASURE:
  416. ptr = &treasures;
  417. break;
  418. case CArtifact::ART_MINOR:
  419. ptr = &minors;
  420. break;
  421. case CArtifact::ART_MAJOR:
  422. ptr = &majors;
  423. break;
  424. case CArtifact::ART_RELIC:
  425. ptr = &relics;
  426. break;
  427. default: //special artifacts should not be erased
  428. return;
  429. }
  430. ptr->erase (std::find(ptr->begin(), ptr->end(), art)); //remove the artifact from available list
  431. }
  432. ui16 CArtHandler::getRandomArt(int flags)
  433. {
  434. std::vector<ConstTransitivePtr<CArtifact> > out;
  435. getAllowed(out, flags);
  436. ui16 id = out[ran() % out.size()]->id;
  437. erasePickedArt (id);
  438. return id;
  439. }
  440. ui16 CArtHandler::getArtSync (ui32 rand, int flags)
  441. {
  442. std::vector<ConstTransitivePtr<CArtifact> > out;
  443. getAllowed(out, flags);
  444. CArtifact *art = out[rand % out.size()];
  445. return art->id;
  446. }
  447. void CArtHandler::getAllowed(std::vector<ConstTransitivePtr<CArtifact> > &out, int flags)
  448. {
  449. if (flags & CArtifact::ART_TREASURE)
  450. getAllowedArts (out, &treasures, CArtifact::ART_TREASURE);
  451. if (flags & CArtifact::ART_MINOR)
  452. getAllowedArts (out, &minors, CArtifact::ART_MINOR);
  453. if (flags & CArtifact::ART_MAJOR)
  454. getAllowedArts (out, &majors, CArtifact::ART_MAJOR);
  455. if (flags & CArtifact::ART_RELIC)
  456. getAllowedArts (out, &relics, CArtifact::ART_RELIC);
  457. if (!out.size()) //no artifact of specified rarity, we need to take another one
  458. {
  459. getAllowedArts (out, &treasures, CArtifact::ART_TREASURE);
  460. getAllowedArts (out, &minors, CArtifact::ART_MINOR);
  461. getAllowedArts (out, &majors, CArtifact::ART_MAJOR);
  462. getAllowedArts (out, &relics, CArtifact::ART_RELIC);
  463. }
  464. if (!out.size()) //no arts are available at all
  465. {
  466. out.resize (64);
  467. std::fill_n (out.begin(), 64, artifacts[2]); //Give Grail - this can't be banned (hopefully)
  468. }
  469. }
  470. void CArtHandler::getAllowedArts(std::vector<ConstTransitivePtr<CArtifact> > &out, std::vector<CArtifact*> *arts, int flag)
  471. {
  472. if (arts->empty()) //restock available arts
  473. {
  474. for (int i = 0; i < allowedArtifacts.size(); ++i)
  475. {
  476. if (allowedArtifacts[i]->aClass == flag)
  477. arts->push_back(allowedArtifacts[i]);
  478. }
  479. }
  480. for (int i = 0; i < arts->size(); ++i)
  481. {
  482. CArtifact *art = (*arts)[i];
  483. out.push_back(art);
  484. }
  485. }
  486. void CArtHandler::giveArtBonus( int aid, Bonus::BonusType type, int val, int subtype, int valType, ILimiter * limiter, int additionalInfo)
  487. {
  488. Bonus *added = new Bonus(Bonus::PERMANENT,type,Bonus::ARTIFACT,val,aid,subtype);
  489. added->additionalInfo = additionalInfo;
  490. added->valType = valType;
  491. added->limiter.reset(limiter);
  492. if(type == Bonus::MORALE || type == Bonus::LUCK)
  493. added->description = artifacts[aid]->Name() + (val > 0 ? " +" : " ") + boost::lexical_cast<std::string>(val);
  494. else
  495. added->description = artifacts[aid]->Name();
  496. artifacts[aid]->addNewBonus(added);
  497. }
  498. void CArtHandler::giveArtBonus(int aid, Bonus::BonusType type, int val, int subtype, IPropagator* propagator /*= NULL*/, int additionalInfo)
  499. {
  500. Bonus *added = new Bonus(Bonus::PERMANENT,type,Bonus::ARTIFACT,val,aid,subtype);
  501. added->additionalInfo = additionalInfo;
  502. added->valType = Bonus::BASE_NUMBER;
  503. added->propagator.reset(propagator);
  504. if(type == Bonus::MORALE || type == Bonus::LUCK)
  505. added->description = artifacts[aid]->Name() + (val > 0 ? " +" : " ") + boost::lexical_cast<std::string>(val);
  506. else
  507. added->description = artifacts[aid]->Name();
  508. artifacts[aid]->addNewBonus(added);
  509. }
  510. void CArtHandler::makeItCreatureArt (int aid, bool onlyCreature /*=true*/)
  511. {
  512. CArtifact *a = artifacts[aid];
  513. if (onlyCreature)
  514. {
  515. a->possibleSlots[ArtBearer::HERO].clear();
  516. a->possibleSlots[ArtBearer::COMMANDER].clear();
  517. }
  518. a->possibleSlots[ArtBearer::CREATURE].push_back(ArtifactPosition::CREATURE_SLOT);
  519. };
  520. void CArtHandler::makeItCommanderArt (int aid, bool onlyCommander /*=true*/)
  521. {
  522. CArtifact *a = artifacts[aid];
  523. if (onlyCommander)
  524. {
  525. a->possibleSlots[ArtBearer::HERO].clear();
  526. a->possibleSlots[ArtBearer::CREATURE].clear();
  527. }
  528. for (int i = ArtifactPosition::COMMANDER1; i <= ArtifactPosition::COMMANDER6; ++i)
  529. a->possibleSlots[ArtBearer::COMMANDER].push_back(i);
  530. };
  531. void CArtHandler::addBonuses()
  532. {
  533. #define ART_PRIM_SKILL(ID, whichSkill, val) giveArtBonus(ID,Bonus::PRIMARY_SKILL,val,whichSkill)
  534. #define ART_MORALE(ID, val) giveArtBonus(ID,Bonus::MORALE,val)
  535. #define ART_LUCK(ID, val) giveArtBonus(ID,Bonus::LUCK,val)
  536. #define ART_MORALE_AND_LUCK(ID, val) giveArtBonus(ID,Bonus::MORALE_AND_LUCK,val)
  537. #define ART_ALL_PRIM_SKILLS(ID, val) ART_PRIM_SKILL(ID,0,val); ART_PRIM_SKILL(ID,1,val); ART_PRIM_SKILL(ID,2,val); ART_PRIM_SKILL(ID,3,val)
  538. #define ART_ATTACK_AND_DEFENSE(ID, val) ART_PRIM_SKILL(ID,0,val); ART_PRIM_SKILL(ID,1,val)
  539. #define ART_POWER_AND_KNOWLEDGE(ID, val) ART_PRIM_SKILL(ID,2,val); ART_PRIM_SKILL(ID,3,val)
  540. //Attack bonus artifacts (Weapons)
  541. ART_PRIM_SKILL(7,0,+2); //Centaur Axe
  542. ART_PRIM_SKILL(8,0,+3); //Blackshard of the Dead Knight
  543. ART_PRIM_SKILL(9,0,+4); //Greater Gnoll's Flail
  544. ART_PRIM_SKILL(10,0,+5); //Ogre's Club of Havoc
  545. ART_PRIM_SKILL(11,0,+6); //Sword of Hellfire
  546. ART_PRIM_SKILL(12,0,+12); //Titan's Gladius
  547. ART_PRIM_SKILL(12,1,-3); //Titan's Gladius
  548. //Defense bonus artifacts (Shields)
  549. ART_PRIM_SKILL(13,1,+2); //Shield of the Dwarven Lords
  550. ART_PRIM_SKILL(14,1,+3); //Shield of the Yawning Dead
  551. ART_PRIM_SKILL(15,1,+4); //Buckler of the Gnoll King
  552. ART_PRIM_SKILL(16,1,+5); //Targ of the Rampaging Ogre
  553. ART_PRIM_SKILL(17,1,+6); //Shield of the Damned
  554. ART_PRIM_SKILL(18,1,+12); //Sentinel's Shield
  555. ART_PRIM_SKILL(18,0,-3); //Sentinel's Shield
  556. //Knowledge bonus artifacts (Helmets)
  557. ART_PRIM_SKILL(19,3,+1); //Helm of the Alabaster Unicorn
  558. ART_PRIM_SKILL(20,3,+2); //Skull Helmet
  559. ART_PRIM_SKILL(21,3,+3); //Helm of Chaos
  560. ART_PRIM_SKILL(22,3,+4); //Crown of the Supreme Magi
  561. ART_PRIM_SKILL(23,3,+5); //Hellstorm Helmet
  562. ART_PRIM_SKILL(24,3,+10); //Thunder Helmet
  563. ART_PRIM_SKILL(24,2,-2); //Thunder Helmet
  564. //Spell power bonus artifacts (Armours)
  565. ART_PRIM_SKILL(25,2,+1); //Breastplate of Petrified Wood
  566. ART_PRIM_SKILL(26,2,+2); //Rib Cage
  567. ART_PRIM_SKILL(27,2,+3); //Scales of the Greater Basilisk
  568. ART_PRIM_SKILL(28,2,+4); //Tunic of the Cyclops King
  569. ART_PRIM_SKILL(29,2,+5); //Breastplate of Brimstone
  570. ART_PRIM_SKILL(30,2,+10); //Titan's Cuirass
  571. ART_PRIM_SKILL(30,3,-2); //Titan's Cuirass
  572. //All primary skills (various)
  573. ART_ALL_PRIM_SKILLS(31,+1); //Armor of Wonder
  574. ART_ALL_PRIM_SKILLS(32,+2); //Sandals of the Saint
  575. ART_ALL_PRIM_SKILLS(33,+3); //Celestial Necklace of Bliss
  576. ART_ALL_PRIM_SKILLS(34,+4); //Lion's Shield of Courage
  577. ART_ALL_PRIM_SKILLS(35,+5); //Sword of Judgement
  578. ART_ALL_PRIM_SKILLS(36,+6); //Helm of Heavenly Enlightenment
  579. //Attack and Defense (various)
  580. ART_ATTACK_AND_DEFENSE(37,+1); //Quiet Eye of the Dragon
  581. ART_ATTACK_AND_DEFENSE(38,+2); //Red Dragon Flame Tongue
  582. ART_ATTACK_AND_DEFENSE(39,+3); //Dragon Scale Shield
  583. ART_ATTACK_AND_DEFENSE(40,+4); //Dragon Scale Armor
  584. //Spell power and Knowledge (various)
  585. ART_POWER_AND_KNOWLEDGE(41,+1); //Dragonbone Greaves
  586. ART_POWER_AND_KNOWLEDGE(42,+2); //Dragon Wing Tabard
  587. ART_POWER_AND_KNOWLEDGE(43,+3); //Necklace of Dragonteeth
  588. ART_POWER_AND_KNOWLEDGE(44,+4); //Crown of Dragontooth
  589. //Luck and morale
  590. ART_MORALE(45,+1); //Still Eye of the Dragon
  591. ART_LUCK(45,+1); //Still Eye of the Dragon
  592. ART_LUCK(46,+1); //Clover of Fortune
  593. ART_LUCK(47,+1); //Cards of Prophecy
  594. ART_LUCK(48,+1); //Ladybird of Luck
  595. ART_MORALE(49,+1); //Badge of Courage -> +1 morale
  596. giveArtBonus(49,Bonus::MIND_IMMUNITY,0); //immunity to hostile mind spells:
  597. ART_MORALE(50,+1); //Crest of Valor
  598. ART_MORALE(51,+1); //Glyph of Gallantry
  599. giveArtBonus(52,Bonus::SIGHT_RADIOUS,+1);//Speculum
  600. giveArtBonus(53,Bonus::SIGHT_RADIOUS,+1);//Spyglass
  601. //necromancy bonus
  602. giveArtBonus(54,Bonus::SECONDARY_SKILL_PREMY,+5, CGHeroInstance::NECROMANCY, Bonus::ADDITIVE_VALUE);//Amulet of the Undertaker
  603. giveArtBonus(55,Bonus::SECONDARY_SKILL_PREMY,+10, CGHeroInstance::NECROMANCY, Bonus::ADDITIVE_VALUE);//Vampire's Cowl
  604. giveArtBonus(56,Bonus::SECONDARY_SKILL_PREMY,+15, CGHeroInstance::NECROMANCY, Bonus::ADDITIVE_VALUE);//Dead Man's Boots
  605. giveArtBonus(57,Bonus::MAGIC_RESISTANCE,+5, 0);//Garniture of Interference
  606. giveArtBonus(58,Bonus::MAGIC_RESISTANCE,+10, 0);//Surcoat of Counterpoise
  607. giveArtBonus(59,Bonus::MAGIC_RESISTANCE,+15, 0);//Boots of Polarity
  608. //archery bonus
  609. giveArtBonus(60,Bonus::SECONDARY_SKILL_PREMY,+5, CGHeroInstance::ARCHERY, Bonus::ADDITIVE_VALUE);//Bow of Elven Cherrywood
  610. giveArtBonus(61,Bonus::SECONDARY_SKILL_PREMY,+10,CGHeroInstance::ARCHERY, Bonus::ADDITIVE_VALUE);//Bowstring of the Unicorn's Mane
  611. giveArtBonus(62,Bonus::SECONDARY_SKILL_PREMY,+15,CGHeroInstance::ARCHERY, Bonus::ADDITIVE_VALUE);//Angel Feather Arrows
  612. //eagle eye bonus
  613. giveArtBonus(63,Bonus::SECONDARY_SKILL_PREMY,+5, CGHeroInstance::EAGLE_EYE, Bonus::ADDITIVE_VALUE);//Bird of Perception
  614. giveArtBonus(64,Bonus::SECONDARY_SKILL_PREMY,+10, CGHeroInstance::EAGLE_EYE, Bonus::ADDITIVE_VALUE);//Stoic Watchman
  615. giveArtBonus(65,Bonus::SECONDARY_SKILL_PREMY,+15, CGHeroInstance::EAGLE_EYE, Bonus::ADDITIVE_VALUE);//Emblem of Cognizance
  616. //reducing cost of surrendering
  617. giveArtBonus(66,Bonus::SURRENDER_DISCOUNT,+10);//Statesman's Medal
  618. giveArtBonus(67,Bonus::SURRENDER_DISCOUNT,+10);//Diplomat's Ring
  619. giveArtBonus(68,Bonus::SURRENDER_DISCOUNT,+10);//Ambassador's Sash
  620. giveArtBonus(69,Bonus::STACKS_SPEED,+1);//Ring of the Wayfarer
  621. giveArtBonus(70,Bonus::LAND_MOVEMENT,+300);//Equestrian's Gloves
  622. giveArtBonus(71,Bonus::SEA_MOVEMENT,+1000);//Necklace of Ocean Guidance
  623. giveArtBonus(72,Bonus::FLYING_MOVEMENT, 0, 1);//Angel Wings
  624. giveArtBonus(73,Bonus::MANA_REGENERATION,+1);//Charm of Mana
  625. giveArtBonus(74,Bonus::MANA_REGENERATION,+2);//Talisman of Mana
  626. giveArtBonus(75,Bonus::MANA_REGENERATION,+3);//Mystic Orb of Mana
  627. giveArtBonus(76,Bonus::SPELL_DURATION,+1);//Collar of Conjuring
  628. giveArtBonus(77,Bonus::SPELL_DURATION,+2);//Ring of Conjuring
  629. giveArtBonus(78,Bonus::SPELL_DURATION,+3);//Cape of Conjuring
  630. giveArtBonus(79,Bonus::AIR_SPELL_DMG_PREMY,+50);//Orb of the Firmament
  631. giveArtBonus(80,Bonus::EARTH_SPELL_DMG_PREMY,+50);//Orb of Silt
  632. giveArtBonus(81,Bonus::FIRE_SPELL_DMG_PREMY,+50);//Orb of Tempestuous Fire
  633. giveArtBonus(82,Bonus::WATER_SPELL_DMG_PREMY,+50);//Orb of Driving Rain
  634. giveArtBonus(83,Bonus::LEVEL_SPELL_IMMUNITY,3,-1,Bonus::INDEPENDENT_MAX);//Recanter's Cloak
  635. giveArtBonus(84,Bonus::BLOCK_MORALE,0);//Spirit of Oppression
  636. giveArtBonus(85,Bonus::BLOCK_LUCK,0);//Hourglass of the Evil Hour
  637. giveArtBonus(86,Bonus::FIRE_SPELLS,0);//Tome of Fire Magic
  638. giveArtBonus(87,Bonus::AIR_SPELLS,0);//Tome of Air Magic
  639. giveArtBonus(88,Bonus::WATER_SPELLS,0);//Tome of Water Magic
  640. giveArtBonus(89,Bonus::EARTH_SPELLS,0);//Tome of Earth Magic
  641. giveArtBonus(90,Bonus::WATER_WALKING, 0, 1);//Boots of Levitation
  642. giveArtBonus(91,Bonus::NO_DISTANCE_PENALTY,0, 0, 0, new HasAnotherBonusLimiter(Bonus::SHOOTER));//Golden Bow
  643. giveArtBonus(91,Bonus::NO_WALL_PENALTY, 0, 0, 0, new HasAnotherBonusLimiter(Bonus::SHOOTER));
  644. giveArtBonus(92,Bonus::SPELL_IMMUNITY,0,35);//Sphere of Permanence
  645. giveArtBonus(93,Bonus::NEGATE_ALL_NATURAL_IMMUNITIES,0);//Orb of Vulnerability
  646. giveArtBonus(94,Bonus::STACK_HEALTH,+1);//Ring of Vitality
  647. giveArtBonus(95,Bonus::STACK_HEALTH,+1);//Ring of Life
  648. giveArtBonus(96,Bonus::STACK_HEALTH,+2);//Vial of Lifeblood
  649. giveArtBonus(97,Bonus::STACKS_SPEED,+1);//Necklace of Swiftness
  650. giveArtBonus(98,Bonus::LAND_MOVEMENT,+600);//Boots of Speed
  651. giveArtBonus(99,Bonus::STACKS_SPEED,+2);//Cape of Velocity
  652. giveArtBonus(100,Bonus::SPELL_IMMUNITY,0,59);//Pendant of Dispassion
  653. giveArtBonus(101,Bonus::SPELL_IMMUNITY,0,62);//Pendant of Second Sight
  654. giveArtBonus(102,Bonus::SPELL_IMMUNITY,0,42);//Pendant of Holiness
  655. giveArtBonus(103,Bonus::SPELL_IMMUNITY,0,24);//Pendant of Life
  656. giveArtBonus(104,Bonus::SPELL_IMMUNITY,0,25, 1, new HasAnotherBonusLimiter(Bonus::UNDEAD));//Pendant of Death does not display info for living stacks
  657. giveArtBonus(105,Bonus::SPELL_IMMUNITY,0,60);//Pendant of Free Will
  658. giveArtBonus(106,Bonus::SPELL_IMMUNITY,0,17);//Pendant of Negativity
  659. giveArtBonus(107,Bonus::SPELL_IMMUNITY,0,61);//Pendant of Total Recall
  660. giveArtBonus(108,Bonus::MORALE,+3);//Pendant of Courage
  661. giveArtBonus(108,Bonus::LUCK,+3);//Pendant of Courage
  662. giveArtBonus(109,Bonus::GENERATE_RESOURCE,+1,4); //Everflowing Crystal Cloak
  663. giveArtBonus(110,Bonus::GENERATE_RESOURCE,+1,5); //Ring of Infinite Gems
  664. giveArtBonus(111,Bonus::GENERATE_RESOURCE,+1,1); //Everpouring Vial of Mercury
  665. giveArtBonus(112,Bonus::GENERATE_RESOURCE,+1,2); //Inexhaustible Cart of Ore
  666. giveArtBonus(113,Bonus::GENERATE_RESOURCE,+1,3); //Eversmoking Ring of Sulfur
  667. giveArtBonus(114,Bonus::GENERATE_RESOURCE,+1,0); //Inexhaustible Cart of Lumber
  668. giveArtBonus(115,Bonus::GENERATE_RESOURCE,+1000, Res::GOLD); //Endless Sack of Gold
  669. giveArtBonus(116,Bonus::GENERATE_RESOURCE,+750, Res::GOLD); //Endless Bag of Gold
  670. giveArtBonus(117,Bonus::GENERATE_RESOURCE,+500, Res::GOLD); //Endless Purse of Gold
  671. giveArtBonus(118,Bonus::CREATURE_GROWTH,+5,1, new CPropagatorNodeType(CBonusSystemNode::TOWN_AND_VISITOR)); //Legs of Legion
  672. giveArtBonus(119,Bonus::CREATURE_GROWTH,+4,2, new CPropagatorNodeType(CBonusSystemNode::TOWN_AND_VISITOR)); //Loins of Legion
  673. giveArtBonus(120,Bonus::CREATURE_GROWTH,+3,3, new CPropagatorNodeType(CBonusSystemNode::TOWN_AND_VISITOR)); //Torso of Legion
  674. giveArtBonus(121,Bonus::CREATURE_GROWTH,+2,4, new CPropagatorNodeType(CBonusSystemNode::TOWN_AND_VISITOR)); //Arms of Legion
  675. giveArtBonus(122,Bonus::CREATURE_GROWTH,+1,5, new CPropagatorNodeType(CBonusSystemNode::TOWN_AND_VISITOR)); //Head of Legion
  676. //Sea Captain's Hat
  677. giveArtBonus(123,Bonus::WHIRLPOOL_PROTECTION,0);
  678. giveArtBonus(123,Bonus::SEA_MOVEMENT,+500);
  679. giveArtBonus(123,Bonus::SPELL,3,0, Bonus::INDEPENDENT_MAX);
  680. giveArtBonus(123,Bonus::SPELL,3,1, Bonus::INDEPENDENT_MAX);
  681. giveArtBonus(124,Bonus::SPELLS_OF_LEVEL,3,1); //Spellbinder's Hat
  682. giveArtBonus(125,Bonus::ENEMY_CANT_ESCAPE,0); //Shackles of War
  683. giveArtBonus(126,Bonus::LEVEL_SPELL_IMMUNITY,GameConstants::SPELL_LEVELS,-1,Bonus::INDEPENDENT_MAX);//Orb of Inhibition
  684. //vial of dragon blood
  685. giveArtBonus(127, Bonus::PRIMARY_SKILL, +5, PrimarySkill::ATTACK, Bonus::BASE_NUMBER, new HasAnotherBonusLimiter(Bonus::DRAGON_NATURE));
  686. giveArtBonus(127, Bonus::PRIMARY_SKILL, +5, PrimarySkill::DEFENSE, Bonus::BASE_NUMBER, new HasAnotherBonusLimiter(Bonus::DRAGON_NATURE));
  687. //Armageddon's Blade
  688. giveArtBonus(128, Bonus::SPELL, 3, 26, Bonus::INDEPENDENT_MAX);
  689. giveArtBonus(128, Bonus::SPELL_IMMUNITY,0, 26);
  690. ART_ATTACK_AND_DEFENSE(128, +3);
  691. ART_PRIM_SKILL(128, 2, +3);
  692. ART_PRIM_SKILL(128, 3, +6);
  693. //Angelic Alliance
  694. giveArtBonus(129, Bonus::NONEVIL_ALIGNMENT_MIX, 0);
  695. giveArtBonus(129, Bonus::OPENING_BATTLE_SPELL, 10, 48); // Prayer
  696. //Cloak of the Undead King
  697. giveArtBonus(130, Bonus::IMPROVED_NECROMANCY, 0);
  698. //Elixir of Life
  699. giveArtBonus(131, Bonus::STACK_HEALTH, +25, -1, Bonus::PERCENT_TO_BASE);
  700. giveArtBonus(131, Bonus::HP_REGENERATION, +50);
  701. //Armor of the Damned
  702. giveArtBonus(132, Bonus::OPENING_BATTLE_SPELL, 50, 54); // Slow
  703. giveArtBonus(132, Bonus::OPENING_BATTLE_SPELL, 50, 47); // Disrupting Ray
  704. giveArtBonus(132, Bonus::OPENING_BATTLE_SPELL, 50, 45); // Weakness
  705. giveArtBonus(132, Bonus::OPENING_BATTLE_SPELL, 50, 52); // Misfortune
  706. // Statue of Legion - gives only 50% growth
  707. giveArtBonus(133, Bonus::CREATURE_GROWTH_PERCENT, 50, -1, new CPropagatorNodeType(CBonusSystemNode::PLAYER));
  708. //Power of the Dragon Father
  709. giveArtBonus(134, Bonus::LEVEL_SPELL_IMMUNITY, 4, -1, Bonus::INDEPENDENT_MAX);
  710. //Titan's Thunder
  711. giveArtBonus(135, Bonus::SPELL, 3, 57);
  712. //Admiral's Hat
  713. giveArtBonus(136, Bonus::FREE_SHIP_BOARDING, 0);
  714. //Bow of the Sharpshooter
  715. giveArtBonus(137, Bonus::NO_DISTANCE_PENALTY, 0, 0, 0, new HasAnotherBonusLimiter(Bonus::SHOOTER));
  716. giveArtBonus(137, Bonus::NO_WALL_PENALTY, 0, 0, 0, new HasAnotherBonusLimiter(Bonus::SHOOTER));
  717. giveArtBonus(137, Bonus::FREE_SHOOTING, 0, 0, 0, new HasAnotherBonusLimiter(Bonus::SHOOTER));
  718. //Wizard's Well
  719. giveArtBonus(138, Bonus::FULL_MANA_REGENERATION, 0);
  720. //Ring of the Magi
  721. giveArtBonus(139, Bonus::SPELL_DURATION, +50);
  722. //Cornucopia
  723. giveArtBonus(140, Bonus::GENERATE_RESOURCE, +4, Res::MERCURY);
  724. giveArtBonus(140, Bonus::GENERATE_RESOURCE, +4, Res::SULFUR);
  725. giveArtBonus(140, Bonus::GENERATE_RESOURCE, +4, Res::CRYSTAL);
  726. giveArtBonus(140, Bonus::GENERATE_RESOURCE, +4, Res::GEMS);
  727. //Stack artifact test
  728. if (GameConstants::STACK_ARTIFACT)
  729. {
  730. makeItCreatureArt(141);
  731. makeItCreatureArt(142);
  732. makeItCreatureArt(143);
  733. makeItCreatureArt(156);
  734. //Magic Wand
  735. giveArtBonus(141, Bonus::CASTS, 10);
  736. giveArtBonus(141, Bonus::SPELLCASTER, 0, Spells::IMPLOSION);
  737. giveArtBonus(141, Bonus::SPELLCASTER, 0, Spells::FIREBALL);
  738. giveArtBonus(141, Bonus::RANDOM_SPELLCASTER, 0);
  739. giveArtBonus(141, Bonus::DAEMON_SUMMONING, 10, 63); //rise vampire lords
  740. giveArtBonus(141, Bonus::ENCHANTER, 0, Spells::LIGHTNING_BOLT, NULL, 2);
  741. giveArtBonus(141, Bonus::REBIRTH, 1, 1);
  742. giveArtBonus(141, Bonus::MANA_DRAIN, 10);
  743. giveArtBonus(141, Bonus::HEALER, 25);
  744. artifacts[141].get()->setDescription ("Casts Implosion / Fireball, random Genie spell, summons Vampire Lords from corpses, casts Lighthning Bolt every 2 turns, rebirths at least one creature, drains enemy mana and heals");
  745. //Tower Arrow
  746. giveArtBonus(142, Bonus::NO_DISTANCE_PENALTY, 0);
  747. giveArtBonus(142, Bonus::ADDITIONAL_ATTACK, 2);
  748. giveArtBonus(142, Bonus::SPELL_LIKE_ATTACK, 1, Spells::INFERNO);
  749. giveArtBonus(142, Bonus::CATAPULT, 0);
  750. giveArtBonus(142, Bonus::ACID_BREATH, 20);
  751. giveArtBonus(142, Bonus::SHOTS, 200, 0, Bonus::PERCENT_TO_BASE);
  752. giveArtBonus(142, Bonus::SPELL_BEFORE_ATTACK, 50, Spells::AGE, NULL, 1);
  753. giveArtBonus(142, Bonus::SPELL_AFTER_ATTACK, 50, Spells::BERSERK, NULL, 1);
  754. giveArtBonus(142, Bonus::SPELL_AFTER_ATTACK, 50, Spells::POISON, NULL, 1);
  755. giveArtBonus(142, Bonus::SPELL_AFTER_ATTACK, 50, Spells::DISRUPTING_RAY, NULL, 1);
  756. artifacts[142].get()->setDescription ("Tripple shots, tripple attack, casts various spells during attack, attacks have range of Inferno, no distance penalty, catapult");
  757. //Monster's Power
  758. giveArtBonus(143, Bonus::STACK_HEALTH, +100, -1, Bonus::PERCENT_TO_BASE);
  759. giveArtBonus(143, Bonus::CREATURE_DAMAGE, +100, 2, Bonus::PERCENT_TO_ALL);
  760. giveArtBonus(143, Bonus::HP_REGENERATION, 50);
  761. giveArtBonus(143, Bonus::NO_RETALIATION, 0);
  762. giveArtBonus(143, Bonus::RETURN_AFTER_STRIKE, 0);
  763. giveArtBonus(143, Bonus::ATTACKS_ALL_ADJACENT, 0);
  764. giveArtBonus(143, Bonus::SPELL_RESISTANCE_AURA, 100);
  765. giveArtBonus(143, Bonus::DIRECT_DAMAGE_IMMUNITY, 0);
  766. artifacts[143].get()->setDescription ("Double health, double max damage, hp regeneration, can't retaliate, return after strike, attack all around, 100% spell reisstance aura, immune to direct damage spells");
  767. //Warlord's banner
  768. giveArtBonus(156, Bonus::STACK_HEALTH, +2);
  769. artifacts[156].get()->setDescription ("+2 stack HP");
  770. }
  771. if (GameConstants::COMMANDERS)
  772. {
  773. for (int i = 146; i <= 155; ++i)
  774. {
  775. makeItCommanderArt (i);
  776. }
  777. ART_PRIM_SKILL (146, 0, +6); //Axe of Smashing
  778. giveArtBonus(147, Bonus::STACK_HEALTH, +12, -1, Bonus::PERCENT_TO_ALL); //Mithril Mail
  779. giveArtBonus(148, Bonus::CREATURE_DAMAGE, +12, 0, Bonus::PERCENT_TO_ALL); //Sword of Sharpness
  780. giveArtBonus(150, Bonus::CASTS, 1); //Pendant of Sorcery
  781. giveArtBonus(151, Bonus::STACKS_SPEED, 1); //Boots of haste
  782. ART_PRIM_SKILL (154, 0, +6); //Hardened Shield
  783. }
  784. }
  785. void CArtHandler::clear()
  786. {
  787. BOOST_FOREACH(CArtifact *art, artifacts)
  788. delete art;
  789. artifacts.clear();
  790. clearHlpLists();
  791. }
  792. // /**
  793. // * Locally equips an artifact to a hero's worn slots. Unequips an already present artifact.
  794. // * Does not test if the operation is legal.
  795. // * @param artifWorn A hero's set of worn artifacts.
  796. // * @param bonuses Optional list of bonuses to update.
  797. // */
  798. // void CArtHandler::equipArtifact( std::map<ui16, const CArtifact*> &artifWorn, ui16 slotID, const CArtifact* art ) const
  799. // {
  800. // unequipArtifact(artifWorn, slotID);
  801. //
  802. // if (art) //false when artifact is NULL -> slot set to empty
  803. // {
  804. // const CArtifact &artifact = *art;
  805. //
  806. // // Add artifact.
  807. // artifWorn[slotID] = art;
  808. //
  809. // // Add locks, in reverse order of being removed.
  810. // if (artifact.constituents != NULL)
  811. // {
  812. // bool destConsumed = false; // Determines which constituent that will be counted for together with the artifact.
  813. //
  814. // BOOST_FOREACH(ui32 constituentID, *artifact.constituents)
  815. // {
  816. // const CArtifact &constituent = *artifacts[constituentID];
  817. //
  818. // if (!destConsumed && vstd::contains(constituent.possibleSlots, slotID))
  819. // {
  820. // destConsumed = true;
  821. // }
  822. // else
  823. // {
  824. // BOOST_FOREACH(ui16 slot, constituent.possibleSlots)
  825. // {
  826. // if (!vstd::contains(artifWorn, slot))
  827. // {
  828. // artifWorn[slot] = VLC->arth->artifacts[145]; //lock
  829. // break;
  830. // }
  831. // }
  832. // }
  833. // }
  834. // }
  835. // }
  836. // }
  837. //
  838. // /**
  839. // * Locally unequips an artifact from a hero's worn slots.
  840. // * Does not test if the operation is legal.
  841. // * @param artifWorn A hero's set of worn artifacts.
  842. // * @param bonuses Optional list of bonuses to update.
  843. // */
  844. // void CArtHandler::unequipArtifact(std::map<ui16, const CArtifact*> &artifWorn, ui16 slotID) const
  845. // {
  846. // if (!vstd::contains(artifWorn, slotID))
  847. // return;
  848. //
  849. // const CArtifact &artifact = *artifWorn[slotID];
  850. //
  851. // // Remove artifact, if it's not already removed.
  852. // artifWorn.erase(slotID);
  853. //
  854. // // Remove locks, in reverse order of being added.
  855. // if (artifact.constituents != NULL)
  856. // {
  857. // bool destConsumed = false;
  858. //
  859. // BOOST_FOREACH(ui32 constituentID, *artifact.constituents)
  860. // {
  861. // const CArtifact &constituent = *artifacts[constituentID];
  862. //
  863. // if (!destConsumed && vstd::contains(constituent.possibleSlots, slotID))
  864. // {
  865. // destConsumed = true;
  866. // }
  867. // else
  868. // {
  869. // BOOST_REVERSE_FOREACH(ui16 slot, constituent.possibleSlots)
  870. // {
  871. // if (vstd::contains(artifWorn, slot) && artifWorn[slot]->id == 145)
  872. // {
  873. // artifWorn.erase(slot);
  874. // break;
  875. // }
  876. // }
  877. // }
  878. // }
  879. // }
  880. // }
  881. void CArtHandler::clearHlpLists()
  882. {
  883. treasures.clear();
  884. minors.clear();
  885. majors.clear();
  886. relics.clear();
  887. }
  888. void CArtHandler::initAllowedArtifactsList(const std::vector<ui8> &allowed)
  889. {
  890. allowedArtifacts.clear();
  891. clearHlpLists();
  892. for (int i=0; i<144; ++i) //yes, 144
  893. {
  894. if (allowed[i])
  895. allowedArtifacts.push_back(artifacts[i]);
  896. }
  897. if (GameConstants::COMMANDERS) //allow all commander artifacts for testing
  898. {
  899. for (int i = 146; i <= 155; ++i)
  900. {
  901. allowedArtifacts.push_back(artifacts[i]);
  902. }
  903. }
  904. }
  905. CArtifactInstance::CArtifactInstance()
  906. {
  907. init();
  908. }
  909. CArtifactInstance::CArtifactInstance( CArtifact *Art)
  910. {
  911. init();
  912. setType(Art);
  913. }
  914. // CArtifactInstance::CArtifactInstance(int aid)
  915. // {
  916. // init();
  917. // setType(VLC->arth->artifacts[aid]);
  918. // }
  919. void CArtifactInstance::setType( CArtifact *Art )
  920. {
  921. artType = Art;
  922. attachTo(Art);
  923. }
  924. std::string CArtifactInstance::nodeName() const
  925. {
  926. return "Artifact instance of " + (artType ? artType->Name() : std::string("uninitialized")) + " type";
  927. }
  928. CArtifactInstance * CArtifactInstance::createScroll( const CSpell *s)
  929. {
  930. CArtifactInstance *ret = new CArtifactInstance(VLC->arth->artifacts[1]);
  931. Bonus *b = new Bonus(Bonus::PERMANENT, Bonus::SPELL, Bonus::ARTIFACT_INSTANCE, -1, 1, s->id);
  932. ret->addNewBonus(b);
  933. return ret;
  934. }
  935. void CArtifactInstance::init()
  936. {
  937. id = -1;
  938. setNodeType(ARTIFACT_INSTANCE);
  939. }
  940. int CArtifactInstance::firstAvailableSlot(const CArtifactSet *h) const
  941. {
  942. BOOST_FOREACH(ui16 slot, artType->possibleSlots[h->bearerType()])
  943. {
  944. if(canBePutAt(h, slot)) //if(artType->fitsAt(h->artifWorn, slot))
  945. {
  946. //we've found a free suitable slot.
  947. return slot;
  948. }
  949. }
  950. //if haven't find proper slot, use backpack
  951. return firstBackpackSlot(h);
  952. }
  953. int CArtifactInstance::firstBackpackSlot(const CArtifactSet *h) const
  954. {
  955. if(!artType->isBig()) //discard big artifact
  956. return GameConstants::BACKPACK_START + h->artifactsInBackpack.size();
  957. return -1;
  958. }
  959. bool CArtifactInstance::canBePutAt(const ArtifactLocation al, bool assumeDestRemoved /*= false*/) const
  960. {
  961. return canBePutAt(al.getHolderArtSet(), al.slot, assumeDestRemoved);
  962. }
  963. bool CArtifactInstance::canBePutAt(const CArtifactSet *artSet, int slot, bool assumeDestRemoved /*= false*/) const
  964. {
  965. if(slot >= GameConstants::BACKPACK_START)
  966. {
  967. if(artType->isBig())
  968. return false;
  969. //TODO backpack limit
  970. return true;
  971. }
  972. auto possibleSlots = artType->possibleSlots.find(artSet->bearerType());
  973. if(possibleSlots == artType->possibleSlots.end())
  974. {
  975. tlog3 << "Warning: arrtifact " << artType->Name() << " doesn't have defined allowed slots for bearer of type "
  976. << artSet->bearerType() << std::endl;
  977. return false;
  978. }
  979. if(!vstd::contains(possibleSlots->second, slot))
  980. return false;
  981. return artSet->isPositionFree(slot, assumeDestRemoved);
  982. }
  983. void CArtifactInstance::putAt(ArtifactLocation al)
  984. {
  985. assert(canBePutAt(al));
  986. al.getHolderArtSet()->setNewArtSlot(al.slot, this, false);
  987. if(al.slot < GameConstants::BACKPACK_START)
  988. al.getHolderNode()->attachTo(this);
  989. }
  990. void CArtifactInstance::removeFrom(ArtifactLocation al)
  991. {
  992. assert(al.getHolderArtSet()->getArt(al.slot) == this);
  993. al.getHolderArtSet()->eraseArtSlot(al.slot);
  994. if(al.slot < GameConstants::BACKPACK_START)
  995. al.getHolderNode()->detachFrom(this);
  996. //TODO delete me?
  997. }
  998. bool CArtifactInstance::canBeDisassembled() const
  999. {
  1000. return artType->constituents && artType->constituentOf->size();
  1001. }
  1002. std::vector<const CArtifact *> CArtifactInstance::assemblyPossibilities(const CArtifactSet *h) const
  1003. {
  1004. std::vector<const CArtifact *> ret;
  1005. if(!artType->constituentOf //not a part of combined artifact
  1006. || artType->constituents) //combined artifact already: no combining of combined artifacts... for now.
  1007. return ret;
  1008. BOOST_FOREACH(ui32 possibleCombinedArt, *artType->constituentOf)
  1009. {
  1010. const CArtifact * const artifact = VLC->arth->artifacts[possibleCombinedArt];
  1011. assert(artifact->constituents);
  1012. bool possible = true;
  1013. BOOST_FOREACH(ui32 constituentID, *artifact->constituents) //check if all constituents are available
  1014. {
  1015. if(!h->hasArt(constituentID, true)) //constituent must be equipped
  1016. {
  1017. possible = false;
  1018. break;
  1019. }
  1020. }
  1021. if(possible)
  1022. ret.push_back(artifact);
  1023. }
  1024. return ret;
  1025. }
  1026. void CArtifactInstance::move(ArtifactLocation src, ArtifactLocation dst)
  1027. {
  1028. removeFrom(src);
  1029. putAt(dst);
  1030. }
  1031. CArtifactInstance * CArtifactInstance::createNewArtifactInstance(CArtifact *Art)
  1032. {
  1033. if(!Art->constituents)
  1034. {
  1035. auto ret = new CArtifactInstance(Art);
  1036. if (dynamic_cast<CGrowingArtifact *>(Art))
  1037. {
  1038. Bonus * bonus = new Bonus;
  1039. bonus->type = Bonus::LEVEL_COUNTER;
  1040. bonus->val = 0;
  1041. ret->addNewBonus (bonus);
  1042. }
  1043. return ret;
  1044. }
  1045. else
  1046. {
  1047. CCombinedArtifactInstance * ret = new CCombinedArtifactInstance(Art);
  1048. ret->createConstituents();
  1049. return ret;
  1050. }
  1051. }
  1052. CArtifactInstance * CArtifactInstance::createNewArtifactInstance(int aid)
  1053. {
  1054. return createNewArtifactInstance(VLC->arth->artifacts[aid]);
  1055. }
  1056. void CArtifactInstance::deserializationFix()
  1057. {
  1058. setType(artType);
  1059. }
  1060. int CArtifactInstance::getGivenSpellID() const
  1061. {
  1062. const Bonus * b = getBonus(Selector::type(Bonus::SPELL));
  1063. if(!b)
  1064. {
  1065. tlog3 << "Warning: " << nodeName() << " doesn't bear any spell!\n";
  1066. return -1;
  1067. }
  1068. return b->subtype;
  1069. }
  1070. bool CArtifactInstance::isPart(const CArtifactInstance *supposedPart) const
  1071. {
  1072. return supposedPart == this;
  1073. }
  1074. bool CCombinedArtifactInstance::canBePutAt(const CArtifactSet *artSet, int slot, bool assumeDestRemoved /*= false*/) const
  1075. {
  1076. bool canMainArtifactBePlaced = CArtifactInstance::canBePutAt(artSet, slot, assumeDestRemoved);
  1077. if(!canMainArtifactBePlaced)
  1078. return false; //no is no...
  1079. if(slot >= GameConstants::BACKPACK_START)
  1080. return true; //we can always remove combined art to the backapck
  1081. assert(artType->constituents);
  1082. std::vector<ConstituentInfo> constituentsToBePlaced = constituentsInfo; //we'll remove constituents from that list, as we find a suitable slot for them
  1083. //it may be that we picked a combined artifact in hero screen (though technically it's still there) to move it
  1084. //so we remove from the list all constituents that are already present on dst hero in the form of locks
  1085. BOOST_FOREACH(const ConstituentInfo &constituent, constituentsInfo)
  1086. {
  1087. if(constituent.art == artSet->getArt(constituent.slot, false)) //no need to worry about locked constituent
  1088. constituentsToBePlaced -= constituent;
  1089. }
  1090. //we iterate over all active slots and check if constituents fits them
  1091. for (int i = 0; i < GameConstants::BACKPACK_START; i++)
  1092. {
  1093. for(std::vector<ConstituentInfo>::iterator art = constituentsToBePlaced.begin(); art != constituentsToBePlaced.end(); art++)
  1094. {
  1095. if(art->art->canBePutAt(artSet, i, i == slot)) // i == al.slot because we can remove already worn artifact only from that slot that is our main destination
  1096. {
  1097. constituentsToBePlaced.erase(art);
  1098. break;
  1099. }
  1100. }
  1101. }
  1102. return constituentsToBePlaced.empty();
  1103. }
  1104. bool CCombinedArtifactInstance::canBeDisassembled() const
  1105. {
  1106. return true;
  1107. }
  1108. CCombinedArtifactInstance::CCombinedArtifactInstance(CArtifact *Art)
  1109. : CArtifactInstance(Art) //TODO: seems unued, but need to be written
  1110. {
  1111. }
  1112. CCombinedArtifactInstance::CCombinedArtifactInstance()
  1113. {
  1114. }
  1115. void CCombinedArtifactInstance::createConstituents()
  1116. {
  1117. assert(artType);
  1118. assert(artType->constituents);
  1119. BOOST_FOREACH(ui32 a, *artType->constituents)
  1120. {
  1121. addAsConstituent(CArtifactInstance::createNewArtifactInstance(a), -1);
  1122. }
  1123. }
  1124. void CCombinedArtifactInstance::addAsConstituent(CArtifactInstance *art, int slot)
  1125. {
  1126. assert(vstd::contains(*artType->constituents, art->artType->id));
  1127. assert(art->getParentNodes().size() == 1 && art->getParentNodes().front() == art->artType);
  1128. constituentsInfo.push_back(ConstituentInfo(art, slot));
  1129. attachTo(art);
  1130. }
  1131. void CCombinedArtifactInstance::putAt(ArtifactLocation al)
  1132. {
  1133. if(al.slot >= GameConstants::BACKPACK_START)
  1134. {
  1135. CArtifactInstance::putAt(al);
  1136. BOOST_FOREACH(ConstituentInfo &ci, constituentsInfo)
  1137. ci.slot = -1;
  1138. }
  1139. else
  1140. {
  1141. CArtifactInstance *mainConstituent = figureMainConstituent(al); //it'll be replaced with combined artifact, not a lock
  1142. CArtifactInstance::putAt(al); //puts combined art (this)
  1143. BOOST_FOREACH(ConstituentInfo &ci, constituentsInfo)
  1144. {
  1145. if(ci.art != mainConstituent)
  1146. {
  1147. const ArtifactLocation suggestedPos(al.artHolder, ci.slot);
  1148. const bool inActiveSlot = vstd::isbetween(ci.slot, 0, GameConstants::BACKPACK_START);
  1149. const bool suggestedPosValid = ci.art->canBePutAt(suggestedPos);
  1150. int pos = -1;
  1151. if(inActiveSlot && suggestedPosValid) //there is a valid suggestion where to place lock
  1152. pos = ci.slot;
  1153. else
  1154. ci.slot = pos = ci.art->firstAvailableSlot(al.getHolderArtSet());
  1155. assert(pos < GameConstants::BACKPACK_START);
  1156. al.getHolderArtSet()->setNewArtSlot(pos, ci.art, true); //sets as lock
  1157. }
  1158. else
  1159. {
  1160. ci.slot = -1;
  1161. }
  1162. }
  1163. }
  1164. }
  1165. void CCombinedArtifactInstance::removeFrom(ArtifactLocation al)
  1166. {
  1167. if(al.slot >= GameConstants::BACKPACK_START)
  1168. {
  1169. CArtifactInstance::removeFrom(al);
  1170. }
  1171. else
  1172. {
  1173. BOOST_FOREACH(ConstituentInfo &ci, constituentsInfo)
  1174. {
  1175. if(ci.slot >= 0)
  1176. {
  1177. al.getHolderArtSet()->eraseArtSlot(ci.slot);
  1178. ci.slot = -1;
  1179. }
  1180. else
  1181. {
  1182. //main constituent
  1183. CArtifactInstance::removeFrom(al);
  1184. }
  1185. }
  1186. }
  1187. }
  1188. CArtifactInstance * CCombinedArtifactInstance::figureMainConstituent(const ArtifactLocation al)
  1189. {
  1190. CArtifactInstance *mainConstituent = NULL; //it'll be replaced with combined artifact, not a lock
  1191. BOOST_FOREACH(ConstituentInfo &ci, constituentsInfo)
  1192. if(ci.slot == al.slot)
  1193. mainConstituent = ci.art;
  1194. if(!mainConstituent)
  1195. {
  1196. BOOST_FOREACH(ConstituentInfo &ci, constituentsInfo)
  1197. {
  1198. if(vstd::contains(ci.art->artType->possibleSlots[al.getHolderArtSet()->bearerType()], al.slot))
  1199. {
  1200. mainConstituent = ci.art;
  1201. }
  1202. }
  1203. }
  1204. return mainConstituent;
  1205. }
  1206. void CCombinedArtifactInstance::deserializationFix()
  1207. {
  1208. BOOST_FOREACH(ConstituentInfo &ci, constituentsInfo)
  1209. attachTo(ci.art);
  1210. }
  1211. bool CCombinedArtifactInstance::isPart(const CArtifactInstance *supposedPart) const
  1212. {
  1213. bool me = CArtifactInstance::isPart(supposedPart);
  1214. if(me)
  1215. return true;
  1216. //check for constituents
  1217. BOOST_FOREACH(const ConstituentInfo &constituent, constituentsInfo)
  1218. if(constituent.art == supposedPart)
  1219. return true;
  1220. return false;
  1221. }
  1222. CCombinedArtifactInstance::ConstituentInfo::ConstituentInfo(CArtifactInstance *Art /*= NULL*/, ui16 Slot /*= -1*/)
  1223. {
  1224. art = Art;
  1225. slot = Slot;
  1226. }
  1227. bool CCombinedArtifactInstance::ConstituentInfo::operator==(const ConstituentInfo &rhs) const
  1228. {
  1229. return art == rhs.art && slot == rhs.slot;
  1230. }
  1231. const CArtifactInstance* CArtifactSet::getArt(ui16 pos, bool excludeLocked /*= true*/) const
  1232. {
  1233. if(const ArtSlotInfo *si = getSlot(pos))
  1234. {
  1235. if(si->artifact && (!excludeLocked || !si->locked))
  1236. return si->artifact;
  1237. }
  1238. return NULL;
  1239. }
  1240. CArtifactInstance* CArtifactSet::getArt(ui16 pos, bool excludeLocked /*= true*/)
  1241. {
  1242. return const_cast<CArtifactInstance*>((const_cast<const CArtifactSet*>(this))->getArt(pos, excludeLocked));
  1243. }
  1244. si32 CArtifactSet::getArtPos(int aid, bool onlyWorn /*= true*/) const
  1245. {
  1246. for(std::map<ui16, ArtSlotInfo>::const_iterator i = artifactsWorn.begin(); i != artifactsWorn.end(); i++)
  1247. if(i->second.artifact->artType->id == aid)
  1248. return i->first;
  1249. if(onlyWorn)
  1250. return -1;
  1251. for(int i = 0; i < artifactsInBackpack.size(); i++)
  1252. if(artifactsInBackpack[i].artifact->artType->id == aid)
  1253. return GameConstants::BACKPACK_START + i;
  1254. return -1;
  1255. }
  1256. si32 CArtifactSet::getArtPos(const CArtifactInstance *art) const
  1257. {
  1258. for(std::map<ui16, ArtSlotInfo>::const_iterator i = artifactsWorn.begin(); i != artifactsWorn.end(); i++)
  1259. if(i->second.artifact == art)
  1260. return i->first;
  1261. for(int i = 0; i < artifactsInBackpack.size(); i++)
  1262. if(artifactsInBackpack[i].artifact == art)
  1263. return GameConstants::BACKPACK_START + i;
  1264. return -1;
  1265. }
  1266. const CArtifactInstance * CArtifactSet::getArtByInstanceId(int artInstId) const
  1267. {
  1268. for(std::map<ui16, ArtSlotInfo>::const_iterator i = artifactsWorn.begin(); i != artifactsWorn.end(); i++)
  1269. if(i->second.artifact->id == artInstId)
  1270. return i->second.artifact;
  1271. for(int i = 0; i < artifactsInBackpack.size(); i++)
  1272. if(artifactsInBackpack[i].artifact->id == artInstId)
  1273. return artifactsInBackpack[i].artifact;
  1274. return NULL;
  1275. }
  1276. bool CArtifactSet::hasArt(ui32 aid, bool onlyWorn /*= false*/) const
  1277. {
  1278. return getArtPos(aid, onlyWorn) != -1;
  1279. }
  1280. const ArtSlotInfo * CArtifactSet::getSlot(ui16 pos) const
  1281. {
  1282. if(vstd::contains(artifactsWorn, pos))
  1283. return &artifactsWorn[pos];
  1284. if(pos >= ArtifactPosition::AFTER_LAST )
  1285. {
  1286. int backpackPos = (int)pos - GameConstants::BACKPACK_START;
  1287. if(backpackPos < 0 || backpackPos >= artifactsInBackpack.size())
  1288. return NULL;
  1289. else
  1290. return &artifactsInBackpack[backpackPos];
  1291. }
  1292. return NULL;
  1293. }
  1294. bool CArtifactSet::isPositionFree(ui16 pos, bool onlyLockCheck /*= false*/) const
  1295. {
  1296. if(const ArtSlotInfo *s = getSlot(pos))
  1297. return (onlyLockCheck || !s->artifact) && !s->locked;
  1298. return true; //no slot means not used
  1299. }
  1300. si32 CArtifactSet::getArtTypeId(ui16 pos) const
  1301. {
  1302. const CArtifactInstance * const a = getArt(pos);
  1303. if(!a)
  1304. {
  1305. tlog2 << (dynamic_cast<const CGHeroInstance*>(this))->name << " has no artifact at " << pos << " (getArtTypeId)\n";
  1306. return -1;
  1307. }
  1308. return a->artType->id;
  1309. }
  1310. CArtifactSet::~CArtifactSet()
  1311. {
  1312. }
  1313. ArtSlotInfo & CArtifactSet::retreiveNewArtSlot(ui16 slot)
  1314. {
  1315. assert(!vstd::contains(artifactsWorn, slot));
  1316. ArtSlotInfo &ret = slot < GameConstants::BACKPACK_START
  1317. ? artifactsWorn[slot]
  1318. : *artifactsInBackpack.insert(artifactsInBackpack.begin() + (slot - GameConstants::BACKPACK_START), ArtSlotInfo());
  1319. return ret;
  1320. }
  1321. void CArtifactSet::setNewArtSlot(ui16 slot, CArtifactInstance *art, bool locked)
  1322. {
  1323. ArtSlotInfo &asi = retreiveNewArtSlot(slot);
  1324. asi.artifact = art;
  1325. asi.locked = locked;
  1326. }
  1327. void CArtifactSet::eraseArtSlot(ui16 slot)
  1328. {
  1329. if(slot < GameConstants::BACKPACK_START)
  1330. {
  1331. artifactsWorn.erase(slot);
  1332. }
  1333. else
  1334. {
  1335. slot -= GameConstants::BACKPACK_START;
  1336. artifactsInBackpack.erase(artifactsInBackpack.begin() + slot);
  1337. }
  1338. }
  1339. void CArtifactSet::artDeserializationFix(CBonusSystemNode *node)
  1340. {
  1341. for(bmap<ui16, ArtSlotInfo>::iterator i = artifactsWorn.begin(); i != artifactsWorn.end(); i++)
  1342. if(i->second.artifact && !i->second.locked)
  1343. node->attachTo(i->second.artifact);
  1344. }