CArtHandler.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. #define VCMI_DLL
  2. #include "../stdafx.h"
  3. #include "CArtHandler.h"
  4. #include "CLodHandler.h"
  5. #include "CGeneralTextHandler.h"
  6. #include <boost/assign/std/vector.hpp>
  7. #include <boost/assign/list_of.hpp>
  8. #include <boost/lexical_cast.hpp>
  9. #include <boost/foreach.hpp>
  10. #include "../lib/VCMI_Lib.h"
  11. extern CLodHandler *bitmaph;
  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. const std::string & CArtifact::Name() const
  23. {
  24. if(name.size())
  25. return name;
  26. else
  27. return VLC->generaltexth->artifNames[id];
  28. }
  29. const std::string & CArtifact::Description() const
  30. {
  31. if(description.size())
  32. return description;
  33. else
  34. return VLC->generaltexth->artifDescriptions[id];
  35. }
  36. inline bool CArtifact::isBig () const
  37. {
  38. return VLC->arth->isBigArtifact(id);
  39. }
  40. /**
  41. * Checks whether the artifact fits at a given slot.
  42. * @param artifWorn A hero's set of worn artifacts.
  43. */
  44. bool CArtifact::fitsAt (const std::map<ui16, ui32> &artifWorn, ui16 slotID) const
  45. {
  46. if (!vstd::contains(possibleSlots, slotID))
  47. return false;
  48. // Can't put an artifact in a locked slot.
  49. std::map<ui16, ui32>::const_iterator it = artifWorn.find(slotID);
  50. if (it != artifWorn.end() && it->second == 145)
  51. return false;
  52. // Check if a combination artifact fits.
  53. // TODO: Might want a more general algorithm?
  54. // Assumes that misc & rings fits only in their slots, and others in only one slot and no duplicates.
  55. if (constituents != NULL) {
  56. std::map<ui16, ui32> tempArtifWorn = artifWorn;
  57. const ui16 ringSlots[] = {6, 7};
  58. const ui16 miscSlots[] = {9, 10, 11, 12, 18};
  59. int rings = 0;
  60. int misc = 0;
  61. VLC->arth->unequipArtifact(tempArtifWorn, slotID);
  62. BOOST_FOREACH(ui32 constituentID, *constituents) {
  63. const CArtifact& constituent = VLC->arth->artifacts[constituentID];
  64. const int slot = constituent.possibleSlots[0];
  65. if (slot == 6 || slot == 7)
  66. rings++;
  67. else if (slot >= 9 && slot <= 12 || slot == 18)
  68. misc++;
  69. else if (tempArtifWorn.find(slot) != tempArtifWorn.end())
  70. return false;
  71. }
  72. // Ensure enough ring slots are free
  73. for (int i = 0; i < sizeof(ringSlots)/sizeof(*ringSlots); i++) {
  74. if (tempArtifWorn.find(ringSlots[i]) == tempArtifWorn.end() || ringSlots[i] == slotID)
  75. rings--;
  76. }
  77. if (rings > 0)
  78. return false;
  79. // Ensure enough misc slots are free.
  80. for (int i = 0; i < sizeof(miscSlots)/sizeof(*miscSlots); i++) {
  81. if (tempArtifWorn.find(miscSlots[i]) == tempArtifWorn.end() || miscSlots[i] == slotID)
  82. misc--;
  83. }
  84. if (misc > 0)
  85. return false;
  86. }
  87. return true;
  88. }
  89. CArtHandler::CArtHandler()
  90. {
  91. VLC->arth = this;
  92. // War machines are the default big artifacts.
  93. for (ui32 i = 3; i <= 6; i++)
  94. bigArtifacts.insert(i);
  95. }
  96. void CArtHandler::loadArtifacts(bool onlyTxt)
  97. {
  98. std::vector<ui16> slots;
  99. slots += 17, 16, 15, 14, 13, 18, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0;
  100. static std::map<char, CArtifact::EartClass> classes =
  101. map_list_of('S',CArtifact::ART_SPECIAL)('T',CArtifact::ART_TREASURE)('N',CArtifact::ART_MINOR)('J',CArtifact::ART_MAJOR)('R',CArtifact::ART_RELIC);
  102. std::string buf = bitmaph->getTextFile("ARTRAITS.TXT"), dump, pom;
  103. int it=0;
  104. for(int i=0; i<2; ++i)
  105. {
  106. loadToIt(dump,buf,it,3);
  107. }
  108. VLC->generaltexth->artifNames.resize(ARTIFACTS_QUANTITY);
  109. VLC->generaltexth->artifDescriptions.resize(ARTIFACTS_QUANTITY);
  110. for (int i=0; i<ARTIFACTS_QUANTITY; i++)
  111. {
  112. CArtifact nart;
  113. nart.id=i;
  114. loadToIt(VLC->generaltexth->artifNames[i],buf,it,4);
  115. loadToIt(pom,buf,it,4);
  116. nart.price=atoi(pom.c_str());
  117. for(int j=0;j<slots.size();j++)
  118. {
  119. loadToIt(pom,buf,it,4);
  120. if(pom[0]=='x')
  121. nart.possibleSlots.push_back(slots[j]);
  122. }
  123. loadToIt(pom,buf,it,4);
  124. nart.aClass = classes[pom[0]];
  125. //load description and remove quotation marks
  126. std::string &desc = VLC->generaltexth->artifDescriptions[i];
  127. loadToIt(desc,buf,it,3);
  128. if(desc[0] == '\"' && desc[desc.size()-1] == '\"')
  129. desc = desc.substr(1,desc.size()-2);
  130. // Fill in information about combined artifacts. Should perhaps be moved to a config file?
  131. switch (nart.id) {
  132. case 129: // Angelic Alliance
  133. nart.constituents = new std::vector<ui32>();
  134. *nart.constituents += 31, 32, 33, 34, 35, 36;
  135. break;
  136. case 130: // Cloak of the Undead King
  137. nart.constituents = new std::vector<ui32>();
  138. *nart.constituents += 54, 55, 56;
  139. break;
  140. case 131: // Elixir of Life
  141. nart.constituents = new std::vector<ui32>();
  142. *nart.constituents += 94, 95, 96;
  143. break;
  144. case 132: // Armor of the Damned
  145. nart.constituents = new std::vector<ui32>();
  146. *nart.constituents += 8, 14, 20, 26;
  147. break;
  148. case 133: // Statue of Legion
  149. nart.constituents = new std::vector<ui32>();
  150. *nart.constituents += 118, 119, 120, 121, 122;
  151. break;
  152. case 134: // Power of the Dragon Father
  153. nart.constituents = new std::vector<ui32>();
  154. *nart.constituents += 37, 38, 39, 40, 41, 42, 43, 44, 45;
  155. break;
  156. case 135: // Titan's Thunder
  157. nart.constituents = new std::vector<ui32>();
  158. *nart.constituents += 12, 18, 24, 30;
  159. break;
  160. case 136: // Admiral's Hat
  161. nart.constituents = new std::vector<ui32>();
  162. *nart.constituents += 71, 123;
  163. break;
  164. case 137: // Bow of the Sharpshooter
  165. nart.constituents = new std::vector<ui32>();
  166. *nart.constituents += 60, 61, 62;
  167. break;
  168. case 138: // Wizards' Well
  169. nart.constituents = new std::vector<ui32>();
  170. *nart.constituents += 73, 74, 75;
  171. break;
  172. case 139: // Ring of the Magi
  173. nart.constituents = new std::vector<ui32>();
  174. *nart.constituents += 76, 77, 78;
  175. break;
  176. case 140: // Cornucopia
  177. nart.constituents = new std::vector<ui32>();
  178. *nart.constituents += 109, 110, 111, 113;
  179. break;
  180. // TODO: WoG combinationals
  181. default:
  182. nart.constituents = NULL;
  183. break;
  184. }
  185. if(!onlyTxt)
  186. artifacts.push_back(nart);
  187. }
  188. sortArts();
  189. if(!onlyTxt)
  190. addBonuses();
  191. }
  192. int CArtHandler::convertMachineID(int id, bool creToArt )
  193. {
  194. int dif = 142;
  195. if(creToArt)
  196. {
  197. switch (id)
  198. {
  199. case 147:
  200. dif--;
  201. break;
  202. case 148:
  203. dif++;
  204. break;
  205. }
  206. dif = -dif;
  207. }
  208. else
  209. {
  210. switch (id)
  211. {
  212. case 6:
  213. dif--;
  214. break;
  215. case 5:
  216. dif++;
  217. break;
  218. }
  219. }
  220. return id + dif;
  221. }
  222. void CArtHandler::sortArts()
  223. {
  224. for(int i=0;i<144;i++) //do 144, bo nie chcemy bzdurek
  225. {
  226. switch (artifacts[i].aClass)
  227. {
  228. case CArtifact::ART_TREASURE:
  229. treasures.push_back(&(artifacts[i]));
  230. break;
  231. case CArtifact::ART_MINOR:
  232. minors.push_back(&(artifacts[i]));
  233. break;
  234. case CArtifact::ART_MAJOR:
  235. majors.push_back(&(artifacts[i]));
  236. break;
  237. case CArtifact::ART_RELIC:
  238. relics.push_back(&(artifacts[i]));
  239. break;
  240. }
  241. }
  242. }
  243. void CArtHandler::giveArtBonus( int aid, HeroBonus::BonusType type, int val, int subtype )
  244. {
  245. artifacts[aid].bonuses.push_back(HeroBonus(HeroBonus::PERMANENT,type,HeroBonus::ARTIFACT,val,aid,subtype));
  246. if(type == HeroBonus::MORALE || HeroBonus::LUCK || HeroBonus::MORALE_AND_LUCK)
  247. artifacts[aid].bonuses.back().description = "\n" + artifacts[aid].Name() + (val > 0 ? " +" : " ")
  248. + boost::lexical_cast<std::string>(val);
  249. }
  250. void CArtHandler::addBonuses()
  251. {
  252. #define ART_PRIM_SKILL(ID, whichSkill, val) giveArtBonus(ID,HeroBonus::PRIMARY_SKILL,val,whichSkill)
  253. #define ART_MORALE(ID, val) giveArtBonus(ID,HeroBonus::MORALE,val)
  254. #define ART_LUCK(ID, val) giveArtBonus(ID,HeroBonus::LUCK,val)
  255. #define ART_MORALE_AND_LUCK(ID, val) giveArtBonus(ID,HeroBonus::MORALE_AND_LUCK,val)
  256. #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)
  257. #define ART_ATTACK_AND_DEFENSE(ID, val) ART_PRIM_SKILL(ID,0,val); ART_PRIM_SKILL(ID,1,val)
  258. #define ART_POWER_AND_KNOWLEDGE(ID, val) ART_PRIM_SKILL(ID,2,val); ART_PRIM_SKILL(ID,3,val)
  259. //Attack bonus artifacts (Weapons)
  260. ART_PRIM_SKILL(7,0,+2); //Centaur Axe
  261. ART_PRIM_SKILL(8,0,+3); //Blackshard of the Dead Knight
  262. ART_PRIM_SKILL(9,0,+4); //Greater Gnoll's Flail
  263. ART_PRIM_SKILL(10,0,+5); //Ogre's Club of Havoc
  264. ART_PRIM_SKILL(11,0,+6); //Sword of Hellfire
  265. ART_PRIM_SKILL(12,0,+12); //Titan's Gladius
  266. ART_PRIM_SKILL(12,1,-3); //Titan's Gladius
  267. //Defense bonus artifacts (Shields)
  268. ART_PRIM_SKILL(13,1,+2); //Shield of the Dwarven Lords
  269. ART_PRIM_SKILL(14,1,+3); //Shield of the Yawning Dead
  270. ART_PRIM_SKILL(15,1,+4); //Buckler of the Gnoll King
  271. ART_PRIM_SKILL(16,1,+5); //Targ of the Rampaging Ogre
  272. ART_PRIM_SKILL(17,1,+6); //Shield of the Damned
  273. ART_PRIM_SKILL(18,1,+12); //Sentinel's Shield
  274. ART_PRIM_SKILL(18,0,-3); //Sentinel's Shield
  275. //Knowledge bonus artifacts (Helmets)
  276. ART_PRIM_SKILL(19,3,+1); //Helm of the Alabaster Unicorn
  277. ART_PRIM_SKILL(20,3,+2); //Skull Helmet
  278. ART_PRIM_SKILL(21,3,+3); //Helm of Chaos
  279. ART_PRIM_SKILL(22,3,+4); //Crown of the Supreme Magi
  280. ART_PRIM_SKILL(23,3,+5); //Hellstorm Helmet
  281. ART_PRIM_SKILL(24,3,+10); //Thunder Helmet
  282. ART_PRIM_SKILL(24,2,-2); //Thunder Helmet
  283. //Spell power bonus artifacts (Armours)
  284. ART_PRIM_SKILL(25,2,+1); //Breastplate of Petrified Wood
  285. ART_PRIM_SKILL(26,2,+2); //Rib Cage
  286. ART_PRIM_SKILL(27,2,+3); //Scales of the Greater Basilisk
  287. ART_PRIM_SKILL(28,2,+4); //Tunic of the Cyclops King
  288. ART_PRIM_SKILL(29,2,+5); //Breastplate of Brimstone
  289. ART_PRIM_SKILL(30,2,+10); //Titan's Cuirass
  290. ART_PRIM_SKILL(30,3,-2); //Titan's Cuirass
  291. //All primary skills (various)
  292. ART_ALL_PRIM_SKILLS(31,+1); //Armor of Wonder
  293. ART_ALL_PRIM_SKILLS(32,+2); //Sandals of the Saint
  294. ART_ALL_PRIM_SKILLS(33,+3); //Celestial Necklace of Bliss
  295. ART_ALL_PRIM_SKILLS(34,+4); //Lion's Shield of Courage
  296. ART_ALL_PRIM_SKILLS(35,+5); //Sword of Judgement
  297. ART_ALL_PRIM_SKILLS(36,+6); //Helm of Heavenly Enlightenment
  298. //Attack and Defense (various)
  299. ART_ATTACK_AND_DEFENSE(37,+1); //Quiet Eye of the Dragon
  300. ART_ATTACK_AND_DEFENSE(38,+2); //Red Dragon Flame Tongue
  301. ART_ATTACK_AND_DEFENSE(39,+3); //Dragon Scale Shield
  302. ART_ATTACK_AND_DEFENSE(40,+4); //Dragon Scale Armor
  303. //Spell power and Knowledge (various)
  304. ART_POWER_AND_KNOWLEDGE(41,+1); //Dragonbone Greaves
  305. ART_POWER_AND_KNOWLEDGE(42,+2); //Dragon Wing Tabard
  306. ART_POWER_AND_KNOWLEDGE(43,+3); //Necklace of Dragonteeth
  307. ART_POWER_AND_KNOWLEDGE(44,+4); //Crown of Dragontooth
  308. //Luck and morale
  309. ART_MORALE(45,+1); //Still Eye of the Dragon
  310. ART_LUCK(45,+1); //Still Eye of the Dragon
  311. ART_LUCK(46,+1); //Clover of Fortune
  312. ART_LUCK(47,+1); //Cards of Prophecy
  313. ART_LUCK(48,+1); //Ladybird of Luck
  314. ART_MORALE(49,+1); //Badge of Courage -> +1 morale and immunity to hostile mind spells:
  315. giveArtBonus(49,HeroBonus::SPELL_IMMUNITY,50);//sorrow
  316. giveArtBonus(49,HeroBonus::SPELL_IMMUNITY,59);//berserk
  317. giveArtBonus(49,HeroBonus::SPELL_IMMUNITY,60);//hypnotize
  318. giveArtBonus(49,HeroBonus::SPELL_IMMUNITY,61);//forgetfulness
  319. giveArtBonus(49,HeroBonus::SPELL_IMMUNITY,62);//blind
  320. ART_MORALE(50,+1); //Crest of Valor
  321. ART_MORALE(51,+1); //Glyph of Gallantry
  322. giveArtBonus(52,HeroBonus::SIGHT_RADIOUS,+1);//Speculum
  323. giveArtBonus(53,HeroBonus::SIGHT_RADIOUS,+1);//Spyglass
  324. //necromancy bonus
  325. giveArtBonus(54,HeroBonus::SECONDARY_SKILL_PREMY,+5,12);//Amulet of the Undertaker
  326. giveArtBonus(55,HeroBonus::SECONDARY_SKILL_PREMY,+10,12);//Vampire's Cowl
  327. giveArtBonus(56,HeroBonus::SECONDARY_SKILL_PREMY,+15,12);//Dead Man's Boots
  328. giveArtBonus(57,HeroBonus::MAGIC_RESISTANCE,+5);//Garniture of Interference
  329. giveArtBonus(58,HeroBonus::MAGIC_RESISTANCE,+10);//Surcoat of Counterpoise
  330. giveArtBonus(59,HeroBonus::MAGIC_RESISTANCE,+15);//Boots of Polarity
  331. //archery bonus
  332. giveArtBonus(60,HeroBonus::SECONDARY_SKILL_PREMY,+5,1);//Bow of Elven Cherrywood
  333. giveArtBonus(61,HeroBonus::SECONDARY_SKILL_PREMY,+10,1);//Bowstring of the Unicorn's Mane
  334. giveArtBonus(62,HeroBonus::SECONDARY_SKILL_PREMY,+15,1);//Angel Feather Arrows
  335. //eagle eye bonus
  336. giveArtBonus(63,HeroBonus::SECONDARY_SKILL_PREMY,+5,11);//Bird of Perception
  337. giveArtBonus(64,HeroBonus::SECONDARY_SKILL_PREMY,+10,11);//Stoic Watchman
  338. giveArtBonus(65,HeroBonus::SECONDARY_SKILL_PREMY,+15,11);//Emblem of Cognizance
  339. //reducing cost of surrendering
  340. giveArtBonus(66,HeroBonus::SURRENDER_DISCOUNT,+10);//Statesman's Medal
  341. giveArtBonus(67,HeroBonus::SURRENDER_DISCOUNT,+10);//Diplomat's Ring
  342. giveArtBonus(68,HeroBonus::SURRENDER_DISCOUNT,+10);//Ambassador's Sash
  343. giveArtBonus(69,HeroBonus::STACKS_SPEED,+1);//Ring of the Wayfarer
  344. giveArtBonus(70,HeroBonus::LAND_MOVEMENT,+300);//Equestrian's Gloves
  345. giveArtBonus(71,HeroBonus::SEA_MOVEMENT,+1000);//Necklace of Ocean Guidance
  346. giveArtBonus(72,HeroBonus::FLYING_MOVEMENT,+1);//Angel Wings
  347. giveArtBonus(73,HeroBonus::MANA_REGENERATION,+1);//Charm of Mana
  348. giveArtBonus(74,HeroBonus::MANA_REGENERATION,+2);//Talisman of Mana
  349. giveArtBonus(75,HeroBonus::MANA_REGENERATION,+3);//Mystic Orb of Mana
  350. giveArtBonus(76,HeroBonus::SPELL_DURATION,+1);//Collar of Conjuring
  351. giveArtBonus(77,HeroBonus::SPELL_DURATION,+2);//Ring of Conjuring
  352. giveArtBonus(78,HeroBonus::SPELL_DURATION,+3);//Cape of Conjuring
  353. giveArtBonus(79,HeroBonus::AIR_SPELL_DMG_PREMY,+50);//Orb of the Firmament
  354. giveArtBonus(80,HeroBonus::EARTH_SPELL_DMG_PREMY,+50);//Orb of Silt
  355. giveArtBonus(81,HeroBonus::FIRE_SPELL_DMG_PREMY,+50);//Orb of Tempestuous Fire
  356. giveArtBonus(82,HeroBonus::WATER_SPELL_DMG_PREMY,+50);//Orb of Driving Rain
  357. giveArtBonus(83,HeroBonus::BLOCK_SPELLS_ABOVE_LEVEL,3);//Recanter's Cloak
  358. giveArtBonus(84,HeroBonus::BLOCK_MORALE,0);//Spirit of Oppression
  359. giveArtBonus(85,HeroBonus::BLOCK_LUCK,0);//Hourglass of the Evil Hour
  360. giveArtBonus(86,HeroBonus::FIRE_SPELLS,0);//Tome of Fire Magic
  361. giveArtBonus(87,HeroBonus::AIR_SPELLS,0);//Tome of Air Magic
  362. giveArtBonus(88,HeroBonus::WATER_SPELLS,0);//Tome of Water Magic
  363. giveArtBonus(89,HeroBonus::EARTH_SPELLS,0);//Tome of Earth Magic
  364. giveArtBonus(90,HeroBonus::WATER_WALKING,0);//Boots of Levitation
  365. giveArtBonus(91,HeroBonus::NO_SHOTING_PENALTY,0);//Golden Bow
  366. giveArtBonus(92,HeroBonus::SPELL_IMMUNITY,35);//Sphere of Permanence
  367. giveArtBonus(93,HeroBonus::NEGATE_ALL_NATURAL_IMMUNITIES,0);//Orb of Vulnerability
  368. giveArtBonus(94,HeroBonus::STACK_HEALTH,+1);//Ring of Vitality
  369. giveArtBonus(95,HeroBonus::STACK_HEALTH,+1);//Ring of Life
  370. giveArtBonus(96,HeroBonus::STACK_HEALTH,+2);//Vial of Lifeblood
  371. giveArtBonus(97,HeroBonus::STACKS_SPEED,+1);//Necklace of Swiftness
  372. giveArtBonus(98,HeroBonus::LAND_MOVEMENT,+600);//Boots of Speed
  373. giveArtBonus(99,HeroBonus::STACKS_SPEED,+2);//Cape of Velocity
  374. giveArtBonus(100,HeroBonus::SPELL_IMMUNITY,59);//Pendant of Dispassion
  375. giveArtBonus(101,HeroBonus::SPELL_IMMUNITY,62);//Pendant of Second Sight
  376. giveArtBonus(102,HeroBonus::SPELL_IMMUNITY,42);//Pendant of Holiness
  377. giveArtBonus(103,HeroBonus::SPELL_IMMUNITY,24);//Pendant of Life
  378. giveArtBonus(104,HeroBonus::SPELL_IMMUNITY,25);//Pendant of Death
  379. giveArtBonus(105,HeroBonus::SPELL_IMMUNITY,60);//Pendant of Free Will
  380. giveArtBonus(106,HeroBonus::SPELL_IMMUNITY,17);//Pendant of Negativity
  381. giveArtBonus(107,HeroBonus::SPELL_IMMUNITY,61);//Pendant of Total Recall
  382. giveArtBonus(108,HeroBonus::MORALE_AND_LUCK,+3);//Pendant of Courage
  383. giveArtBonus(109,HeroBonus::GENERATE_RESOURCE,+1,4); //Everflowing Crystal Cloak
  384. giveArtBonus(110,HeroBonus::GENERATE_RESOURCE,+1,5); //Ring of Infinite Gems
  385. giveArtBonus(111,HeroBonus::GENERATE_RESOURCE,+1,1); //Everpouring Vial of Mercury
  386. giveArtBonus(112,HeroBonus::GENERATE_RESOURCE,+1,2); //Inexhaustible Cart of Ore
  387. giveArtBonus(113,HeroBonus::GENERATE_RESOURCE,+1,3); //Eversmoking Ring of Sulfur
  388. giveArtBonus(114,HeroBonus::GENERATE_RESOURCE,+1,0); //Inexhaustible Cart of Lumber
  389. giveArtBonus(115,HeroBonus::GENERATE_RESOURCE,+1000,6); //Endless Sack of Gold
  390. giveArtBonus(116,HeroBonus::GENERATE_RESOURCE,+750,6); //Endless Bag of Gold
  391. giveArtBonus(117,HeroBonus::GENERATE_RESOURCE,+500,6); //Endless Purse of Gold
  392. giveArtBonus(118,HeroBonus::CREATURE_GROWTH,+5,1); //Legs of Legion
  393. giveArtBonus(119,HeroBonus::CREATURE_GROWTH,+4,2); //Loins of Legion
  394. giveArtBonus(120,HeroBonus::CREATURE_GROWTH,+3,3); //Torso of Legion
  395. giveArtBonus(121,HeroBonus::CREATURE_GROWTH,+2,4); //Arms of Legion
  396. giveArtBonus(122,HeroBonus::CREATURE_GROWTH,+1,5); //Head of Legion
  397. //Sea Captain's Hat
  398. giveArtBonus(123,HeroBonus::WHIRLPOOL_PROTECTION,0);
  399. giveArtBonus(123,HeroBonus::SEA_MOVEMENT,+500);
  400. giveArtBonus(123,HeroBonus::SPELL,3,0);
  401. giveArtBonus(123,HeroBonus::SPELL,3,1);
  402. giveArtBonus(124,HeroBonus::SPELLS_OF_LEVEL,3,1); //Spellbinder's Hat
  403. giveArtBonus(125,HeroBonus::ENEMY_CANT_ESCAPE,0); //Shackles of War
  404. giveArtBonus(126,HeroBonus::BLOCK_SPELLS_ABOVE_LEVEL,0);//Orb of Inhibition
  405. //Armageddon's Blade
  406. giveArtBonus(128, HeroBonus::SPELL, 3, 26);
  407. giveArtBonus(128, HeroBonus::SPELL_IMMUNITY, 26);
  408. ART_ATTACK_AND_DEFENSE(128, +3);
  409. ART_PRIM_SKILL(128, 2, +3);
  410. ART_PRIM_SKILL(128, 3, +6);
  411. //Angelic Alliance
  412. ART_ALL_PRIM_SKILLS(129, +21);
  413. giveArtBonus(129, HeroBonus::NONEVIL_ALIGNMENT_MIX, 0);
  414. giveArtBonus(129, HeroBonus::OPENING_BATTLE_SPELL, 10, 29); // Prayer
  415. //Cloak of the Undead King
  416. giveArtBonus(130, HeroBonus::SECONDARY_SKILL_PREMY, +30, 12);
  417. giveArtBonus(130, HeroBonus::SECONDARY_SKILL_PREMY, +30, 12);
  418. giveArtBonus(130, HeroBonus::IMPROVED_NECROMANCY, 0);
  419. //Elixir of Life
  420. giveArtBonus(131, HeroBonus::STACK_HEALTH, +4);
  421. giveArtBonus(131, HeroBonus::STACK_HEALTH_PERCENT, +25);
  422. giveArtBonus(131, HeroBonus::HP_REGENERATION, +50);
  423. //Armor of the Damned
  424. ART_ATTACK_AND_DEFENSE(132, +3);
  425. ART_POWER_AND_KNOWLEDGE(132, +2);
  426. giveArtBonus(132, HeroBonus::OPENING_BATTLE_SPELL, 50, 54); // Slow
  427. giveArtBonus(132, HeroBonus::OPENING_BATTLE_SPELL, 50, 47); // Disrupting Ray
  428. giveArtBonus(132, HeroBonus::OPENING_BATTLE_SPELL, 50, 45); // Weakness
  429. giveArtBonus(132, HeroBonus::OPENING_BATTLE_SPELL, 50, 52); // Misfortune
  430. // Statue of Legion - gives only 50% growth
  431. giveArtBonus(133, HeroBonus::CREATURE_GROWTH_PERCENT, 50);
  432. //Power of the Dragon Father
  433. ART_ALL_PRIM_SKILLS(134, +16);
  434. giveArtBonus(134, HeroBonus::MORALE_AND_LUCK, +1);
  435. giveArtBonus(134, HeroBonus::LEVEL_SPELL_IMMUNITY, 4);
  436. //Titan's Thunder
  437. ART_ATTACK_AND_DEFENSE(135, +9);
  438. ART_POWER_AND_KNOWLEDGE(135, +8);
  439. giveArtBonus(135, HeroBonus::SPELL, 3, 57);
  440. //Admiral's Hat
  441. giveArtBonus(136, HeroBonus::SEA_MOVEMENT, +1500);
  442. giveArtBonus(136, HeroBonus::WHIRLPOOL_PROTECTION, 0);
  443. giveArtBonus(136, HeroBonus::SPELL, 3, 0);
  444. giveArtBonus(136, HeroBonus::SPELL, 3, 1);
  445. giveArtBonus(136, HeroBonus::FREE_SHIP_BOARDING, 0);
  446. //Bow of the Sharpshooter
  447. giveArtBonus(137, HeroBonus::SECONDARY_SKILL_PREMY, +30, 1);
  448. giveArtBonus(137, HeroBonus::NO_SHOTING_PENALTY, 0);
  449. giveArtBonus(137, HeroBonus::FREE_SHOOTING, 0);
  450. //Wizard's Well
  451. giveArtBonus(138, HeroBonus::FULL_MANA_REGENERATION, 0);
  452. //Ring of the Magi
  453. giveArtBonus(139, HeroBonus::SPELL_DURATION, +56);
  454. //Cornucopia
  455. giveArtBonus(140, HeroBonus::GENERATE_RESOURCE, +5, 1);
  456. giveArtBonus(140, HeroBonus::GENERATE_RESOURCE, +5, 3);
  457. giveArtBonus(140, HeroBonus::GENERATE_RESOURCE, +5, 4);
  458. giveArtBonus(140, HeroBonus::GENERATE_RESOURCE, +5, 5);
  459. }
  460. void CArtHandler::clear()
  461. {
  462. artifacts.clear();
  463. treasures.clear();
  464. minors.clear();
  465. majors.clear();
  466. relics.clear();
  467. }
  468. /**
  469. * Locally equips an artifact to a hero's worn slots. Unequips an already present artifact.
  470. * Does not test if the operation is legal.
  471. * @param artifWorn A hero's set of worn artifacts.
  472. */
  473. void CArtHandler::equipArtifact (std::map<ui16, ui32> &artifWorn, ui16 slotID, ui32 artifactID)
  474. {
  475. unequipArtifact(artifWorn, slotID);
  476. const CArtifact &artifact = artifacts[artifactID];
  477. // Add artifact.
  478. artifWorn[slotID] = artifactID;
  479. // Add locks, in reverse order of being removed.
  480. if (artifact.constituents != NULL) {
  481. bool destConsumed = false; // Determines which constituent that will be counted for together with the artifact.
  482. BOOST_FOREACH(ui32 constituentID, *artifact.constituents) {
  483. const CArtifact &constituent = artifacts[constituentID];
  484. if (!destConsumed && vstd::contains(constituent.possibleSlots, slotID)) {
  485. destConsumed = true;
  486. } else {
  487. BOOST_FOREACH(ui16 slot, constituent.possibleSlots) {
  488. if (artifWorn.find(slot) == artifWorn.end()) {
  489. artifWorn[slot] = 145;
  490. break;
  491. }
  492. }
  493. }
  494. }
  495. }
  496. }
  497. /**
  498. * Locally unequips an artifact from a hero's worn slots.
  499. * Does not test if the operation is legal.
  500. * @param artifWorn A hero's set of worn artifacts.
  501. */
  502. void CArtHandler::unequipArtifact (std::map<ui16, ui32> &artifWorn, ui16 slotID)
  503. {
  504. if (artifWorn.find(slotID) == artifWorn.end())
  505. return;
  506. const CArtifact &artifact = artifacts[artifWorn[slotID]];
  507. // Remove artifact, if it's not already removed.
  508. artifWorn.erase(slotID);
  509. // Remove locks, in reverse order of being added.
  510. if (artifact.constituents != NULL) {
  511. bool destConsumed = false;
  512. BOOST_FOREACH(ui32 constituentID, *artifact.constituents) {
  513. const CArtifact &constituent = artifacts[constituentID];
  514. if (!destConsumed && vstd::contains(constituent.possibleSlots, slotID)) {
  515. destConsumed = true;
  516. } else {
  517. BOOST_REVERSE_FOREACH(ui16 slot, constituent.possibleSlots) {
  518. if (artifWorn.find(slot) != artifWorn.end() && artifWorn[slot] == 145) {
  519. artifWorn.erase(slot);
  520. break;
  521. }
  522. }
  523. }
  524. }
  525. }
  526. }