CCreatureHandler.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. #define VCMI_DLL
  2. #include "../stdafx.h"
  3. #include "CCreatureHandler.h"
  4. #include "CLodHandler.h"
  5. #include <sstream>
  6. #include <boost/assign/std/set.hpp>
  7. #include <boost/assign/std/vector.hpp>
  8. #include <boost/assign/std/list.hpp>
  9. #include <boost/assign/list_of.hpp>
  10. #include <boost/algorithm/string.hpp>
  11. #include <boost/algorithm/string/find.hpp>
  12. #include <boost/algorithm/string/replace.hpp>
  13. #include "../lib/VCMI_Lib.h"
  14. using namespace boost::assign;
  15. extern CLodHandler * bitmaph;
  16. /*
  17. * CCreatureHandler.cpp, part of VCMI engine
  18. *
  19. * Authors: listed in file AUTHORS in main folder
  20. *
  21. * License: GNU General Public License v2.0 or later
  22. * Full text of license available in license.txt file, in main folder
  23. *
  24. */
  25. static std::vector<int> getMindSpells()
  26. {
  27. std::vector<int> ret;
  28. ret.push_back(50); //sorrow
  29. ret.push_back(59); //berserk
  30. ret.push_back(60); //hypnotize
  31. ret.push_back(61); //forgetfulness
  32. ret.push_back(62); //blind
  33. return ret;
  34. }
  35. CCreatureHandler::CCreatureHandler()
  36. {
  37. VLC->creh = this;
  38. // Set the faction alignments to the defaults:
  39. // Good: Castle, Rampart, Tower // Evil: Inferno, Necropolis, Dungeon
  40. // Neutral: Stronghold, Fortess, Conflux
  41. factionAlignments += 1, 1, 1, -1, -1, -1, 0, 0, 0;
  42. }
  43. int CCreature::getQuantityID(const int & quantity)
  44. {
  45. if (quantity<5)
  46. return 0;
  47. if (quantity<10)
  48. return 1;
  49. if (quantity<20)
  50. return 2;
  51. if (quantity<50)
  52. return 3;
  53. if (quantity<100)
  54. return 4;
  55. if (quantity<250)
  56. return 5;
  57. if (quantity<500)
  58. return 5;
  59. if (quantity<1000)
  60. return 6;
  61. if (quantity<4000)
  62. return 7;
  63. return 8;
  64. }
  65. bool CCreature::isDoubleWide() const
  66. {
  67. return doubleWide;
  68. }
  69. bool CCreature::isFlying() const
  70. {
  71. return vstd::contains(bonuses, Bonus::FLYING);
  72. }
  73. bool CCreature::isShooting() const
  74. {
  75. return vstd::contains(bonuses, Bonus::SHOOTER);
  76. }
  77. bool CCreature::isUndead() const
  78. {
  79. return vstd::contains(bonuses, Bonus::UNDEAD);
  80. }
  81. /**
  82. * Determines if the creature is of a good alignment.
  83. * @return true if the creture is good, false otherwise.
  84. */
  85. bool CCreature::isGood () const
  86. {
  87. return VLC->creh->isGood(faction);
  88. }
  89. /**
  90. * Determines if the creature is of an evil alignment.
  91. * @return true if the creature is evil, false otherwise.
  92. */
  93. bool CCreature::isEvil () const
  94. {
  95. return VLC->creh->isEvil(faction);
  96. }
  97. si32 CCreature::maxAmount(const std::vector<si32> &res) const //how many creatures can be bought
  98. {
  99. int ret = 2147483645;
  100. int resAmnt = std::min(res.size(),cost.size());
  101. for(int i=0;i<resAmnt;i++)
  102. if(cost[i])
  103. ret = std::min(ret,(int)(res[i]/cost[i]));
  104. return ret;
  105. }
  106. CCreature::CCreature()
  107. {
  108. doubleWide = false;
  109. }
  110. void CCreature::addBonus(int val, int type, int subtype /*= -1*/)
  111. {
  112. Bonus added(Bonus::PERMANENT, type, Bonus::CREATURE_ABILITY, val, idNumber, subtype, Bonus::BASE_NUMBER);
  113. bonuses.push_back(added);
  114. }
  115. int readNumber(int & befi, int & i, int andame, std::string & buf) //helper function for void CCreatureHandler::loadCreatures() and loadUnitAnimInfo()
  116. {
  117. befi=i;
  118. for(i; i<andame; ++i)
  119. {
  120. if(buf[i]=='\t')
  121. break;
  122. }
  123. std::string tmp = buf.substr(befi, i-befi);
  124. int ret = atoi(buf.substr(befi, i-befi).c_str());
  125. ++i;
  126. return ret;
  127. }
  128. float readFloat(int & befi, int & i, int andame, std::string & buf) //helper function for void CCreatureHandler::loadUnitAnimInfo()
  129. {
  130. befi=i;
  131. for(i; i<andame; ++i)
  132. {
  133. if(buf[i]=='\t')
  134. break;
  135. }
  136. std::string tmp = buf.substr(befi, i-befi);
  137. float ret = atof(buf.substr(befi, i-befi).c_str());
  138. ++i;
  139. return ret;
  140. }
  141. /**
  142. * Determines if a faction is good.
  143. * @param ID of the faction.
  144. * @return true if the faction is good, false otherwise.
  145. */
  146. bool CCreatureHandler::isGood (si8 faction) const
  147. {
  148. return faction != -1 && factionAlignments[faction] == 1;
  149. }
  150. /**
  151. * Determines if a faction is evil.
  152. * @param ID of the faction.
  153. * @return true if the faction is evil, false otherwise.
  154. */
  155. bool CCreatureHandler::isEvil (si8 faction) const
  156. {
  157. return faction != -1 && factionAlignments[faction] == -1;
  158. }
  159. void CCreatureHandler::loadCreatures()
  160. {
  161. notUsedMonsters += 122,124,126,128,145,146,147,148,149,160,161,162,163,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191;
  162. tlog5 << "\t\tReading config/cr_abils.txt and ZCRTRAIT.TXT" << std::endl;
  163. bool useCreAbilsFromZCRTRAIT = true;
  164. ////////////reading cr_abils.txt ///////////////////
  165. std::ifstream abils(DATA_DIR "/config/cr_abils.txt", std::ios::in | std::ios::binary); //this file is not in lod
  166. const int MAX_LINE_SIZE = 1000;
  167. char abilLine[MAX_LINE_SIZE+1];
  168. for(int i=0; i<5; ++i) //removing 5 comment lines
  169. {
  170. abils.getline(abilLine, MAX_LINE_SIZE);
  171. }
  172. //reading first line (determining if we should use creature abilities from ZCRTRAIT.TXT)
  173. abils.getline(abilLine, MAX_LINE_SIZE);
  174. useCreAbilsFromZCRTRAIT = atoi(abilLine);
  175. ////////////reading ZCRTRAIT.TXT ///////////////////
  176. std::string buf = bitmaph->getTextFile("ZCRTRAIT.TXT");
  177. int andame = buf.size();
  178. int i=0; //buf iterator
  179. int hmcr=0;
  180. for(i; i<andame; ++i)
  181. {
  182. if(buf[i]=='\r')
  183. ++hmcr;
  184. if(hmcr==2)
  185. break;
  186. }
  187. i+=2;
  188. while(i<buf.size())
  189. {
  190. CCreature &ncre = *new CCreature;
  191. ncre.idNumber = creatures.size();
  192. ncre.cost.resize(RESOURCE_QUANTITY);
  193. ncre.level=0;
  194. int befi=i;
  195. for(i; i<andame; ++i)
  196. {
  197. if(buf[i]=='\t')
  198. break;
  199. }
  200. ncre.nameSing = buf.substr(befi, i-befi);
  201. ++i;
  202. befi=i;
  203. for(i; i<andame; ++i)
  204. {
  205. if(buf[i]=='\t')
  206. break;
  207. }
  208. ncre.namePl = buf.substr(befi, i-befi);
  209. ++i;
  210. for(int v=0; v<7; ++v)
  211. {
  212. ncre.cost[v] = readNumber(befi, i, andame, buf);
  213. }
  214. ncre.fightValue = readNumber(befi, i, andame, buf);
  215. ncre.AIValue = readNumber(befi, i, andame, buf);
  216. ncre.growth = readNumber(befi, i, andame, buf);
  217. ncre.hordeGrowth = readNumber(befi, i, andame, buf);
  218. ncre.hitPoints = readNumber(befi, i, andame, buf);
  219. ncre.addBonus(ncre.hitPoints, Bonus::STACK_HEALTH);
  220. ncre.speed = readNumber(befi, i, andame, buf);
  221. ncre.addBonus(ncre.speed, Bonus::STACKS_SPEED);
  222. ncre.attack = readNumber(befi, i, andame, buf);
  223. ncre.addBonus(ncre.attack, Bonus::PRIMARY_SKILL, PrimarySkill::ATTACK);
  224. ncre.defence = readNumber(befi, i, andame, buf);
  225. ncre.addBonus(ncre.defence, Bonus::PRIMARY_SKILL, PrimarySkill::DEFENSE);
  226. ncre.damageMin = readNumber(befi, i, andame, buf);
  227. ncre.damageMax = readNumber(befi, i, andame, buf);
  228. ncre.shots = readNumber(befi, i, andame, buf);
  229. ncre.spells = readNumber(befi, i, andame, buf);
  230. ncre.ammMin = readNumber(befi, i, andame, buf);
  231. ncre.ammMax = readNumber(befi, i, andame, buf);
  232. befi=i;
  233. for(i; i<andame; ++i)
  234. {
  235. if(buf[i]=='\t')
  236. break;
  237. }
  238. ncre.abilityText = buf.substr(befi, i-befi);
  239. ++i;
  240. befi=i;
  241. for(i; i<andame; ++i)
  242. {
  243. if(buf[i]=='\r')
  244. break;
  245. }
  246. ncre.abilityRefs = buf.substr(befi, i-befi);
  247. i+=2;
  248. if(useCreAbilsFromZCRTRAIT)
  249. { //adding abilities from ZCRTRAIT.TXT
  250. if(boost::algorithm::find_first(ncre.abilityRefs, "DOUBLE_WIDE"))
  251. ncre.doubleWide = true;
  252. if(boost::algorithm::find_first(ncre.abilityRefs, "FLYING_ARMY"))
  253. ncre.addBonus(0, Bonus::FLYING);
  254. if(boost::algorithm::find_first(ncre.abilityRefs, "SHOOTING_ARMY"))
  255. ncre.addBonus(0, Bonus::SHOOTER);
  256. if(boost::algorithm::find_first(ncre.abilityRefs, "SIEGE_WEAPON"))
  257. ncre.addBonus(0, Bonus::SIEGE_WEAPON);
  258. if(boost::algorithm::find_first(ncre.abilityRefs, "const_two_attacks"))
  259. ncre.addBonus(1, Bonus::ADDITIONAL_ATTACK);
  260. if(boost::algorithm::find_first(ncre.abilityRefs, "const_free_attack"))
  261. ncre.addBonus(0, Bonus::BLOCKS_RETALIATION);
  262. if(boost::algorithm::find_first(ncre.abilityRefs, "IS_UNDEAD"))
  263. ncre.addBonus(0, Bonus::UNDEAD);
  264. if(boost::algorithm::find_first(ncre.abilityRefs, "const_no_melee_penalty"))
  265. ncre.addBonus(0, Bonus::NO_MELEE_PENALTY);
  266. if(boost::algorithm::find_first(ncre.abilityRefs, "const_jousting"))
  267. ncre.addBonus(0, Bonus::JOUSTING);
  268. if(boost::algorithm::find_first(ncre.abilityRefs, "const_raises_morale"))
  269. {
  270. ncre.addBonus(+1, Bonus::MORALE);;
  271. ncre.bonuses.back().effectRange = Bonus::ONLY_ALLIED_ARMY;
  272. }
  273. if(boost::algorithm::find_first(ncre.abilityRefs, "const_lowers_morale"))
  274. {
  275. ncre.addBonus(-1, Bonus::MORALE);;
  276. ncre.bonuses.back().effectRange = Bonus::ONLY_ENEMY_ARMY;
  277. }
  278. if(boost::algorithm::find_first(ncre.abilityRefs, "KING_1"))
  279. ncre.addBonus(0, Bonus::KING1);
  280. if(boost::algorithm::find_first(ncre.abilityRefs, "KING_2"))
  281. ncre.addBonus(0, Bonus::KING2);
  282. if(boost::algorithm::find_first(ncre.abilityRefs, "KING_3"))
  283. ncre.addBonus(0, Bonus::KING3);
  284. if(boost::algorithm::find_first(ncre.abilityRefs, "const_no_wall_penalty"))
  285. ncre.addBonus(0, Bonus::NO_WALL_PENALTY);
  286. if(boost::algorithm::find_first(ncre.abilityRefs, "CATAPULT"))
  287. ncre.addBonus(0, Bonus::CATAPULT);
  288. if(boost::algorithm::find_first(ncre.abilityRefs, "MULTI_HEADED"))
  289. ncre.addBonus(0, Bonus::ATTACKS_ALL_ADJACENT);
  290. if(boost::algorithm::find_first(ncre.abilityRefs, "IMMUNE_TO_MIND_SPELLS"))
  291. {
  292. std::vector<int> mindSpells = getMindSpells();
  293. for(int g=0; g<mindSpells.size(); ++g)
  294. ncre.addBonus(0, Bonus::SPELL_IMMUNITY, mindSpells[g]); //giants are immune to mind spells
  295. }
  296. if(boost::algorithm::find_first(ncre.abilityRefs, "IMMUNE_TO_FIRE_SPELLS"))
  297. ncre.addBonus(0, Bonus::FIRE_IMMUNITY);
  298. if(boost::algorithm::find_first(ncre.abilityRefs, "HAS_EXTENDED_ATTACK"))
  299. ncre.addBonus(0, Bonus::TWO_HEX_ATTACK_BREATH);;
  300. }
  301. if(ncre.nameSing!=std::string("") && ncre.namePl!=std::string(""))
  302. {
  303. ncre.idNumber = creatures.size();
  304. creatures.push_back(&ncre);
  305. }
  306. }
  307. // Map types names
  308. #define BONUS_NAME(x) ( #x, Bonus::x )
  309. static const std::map<std::string, int> type_list = map_list_of BONUS_LIST;
  310. #undef BONUS_NAME
  311. ////second part of reading cr_abils.txt////
  312. bool contReading = true;
  313. while(contReading) //main reading loop
  314. {
  315. abils.getline(abilLine, MAX_LINE_SIZE);
  316. std::istringstream reader(abilLine);
  317. char command;
  318. reader >> command;
  319. switch(command)
  320. {
  321. case '+': //add new ability
  322. {
  323. int creatureID;
  324. Bonus nsf;
  325. si32 buf;
  326. std::string type;
  327. reader >> creatureID;
  328. reader >> type;
  329. std::map<std::string, int>::const_iterator it = type_list.find(type);
  330. CCreature *cre = creatures[creatureID];
  331. if (it == type_list.end())
  332. {
  333. if(type == "DOUBLE_WIDE")
  334. cre->doubleWide = true;
  335. else if(type == "ENEMY_MORALE_DECREASING")
  336. {
  337. cre->addBonus(-1, Bonus::MORALE);;
  338. cre->bonuses.back().effectRange = Bonus::ONLY_ENEMY_ARMY;
  339. }
  340. else if(type == "ENEMY_LUCK_DECREASING")
  341. {
  342. cre->addBonus(-1, Bonus::LUCK);;
  343. cre->bonuses.back().effectRange = Bonus::ONLY_ENEMY_ARMY;
  344. }
  345. else
  346. tlog1 << "Error: invalid type " << type << " in cr_abils.txt" << std::endl;
  347. break;
  348. }
  349. nsf.type = it->second;
  350. reader >> buf; nsf.val = buf;
  351. reader >> buf; nsf.subtype = buf;
  352. reader >> buf; nsf.additionalInfo = buf;
  353. nsf.source = Bonus::CREATURE_ABILITY;
  354. nsf.id = cre->idNumber;
  355. nsf.duration = Bonus::ONE_BATTLE;
  356. nsf.turnsRemain = 0;
  357. cre->bonuses += nsf;
  358. break;
  359. }
  360. case '-': //remove ability
  361. {
  362. int creatureID;
  363. std::string type;
  364. reader >> creatureID;
  365. reader >> type;
  366. std::map<std::string, int>::const_iterator it = type_list.find(type);
  367. if (it == type_list.end())
  368. {
  369. if(type == "DOUBLE_WIDE")
  370. creatures[creatureID]->doubleWide = false;
  371. else
  372. tlog1 << "Error: invalid type " << type << " in cr_abils.txt" << std::endl;
  373. break;
  374. }
  375. int typeNo = it->second;
  376. Bonus::BonusType ecf = static_cast<Bonus::BonusType>(typeNo);
  377. creatures[creatureID]->bonuses -= ecf;
  378. break;
  379. }
  380. case '0': //end reading
  381. {
  382. contReading = false;
  383. break;
  384. }
  385. default: //invalid command
  386. {
  387. tlog1 << "Parse error in file config/cr_abils.txt" << std::endl;
  388. break;
  389. }
  390. }
  391. }
  392. abils.close();
  393. tlog5 << "\t\tReading config/crerefnam.txt" << std::endl;
  394. //loading reference names
  395. std::ifstream ifs(DATA_DIR "/config/crerefnam.txt");
  396. int tempi;
  397. std::string temps;
  398. for (;;)
  399. {
  400. ifs >> tempi >> temps;
  401. if (tempi>=creatures.size())
  402. break;
  403. boost::assign::insert(nameToID)(temps,tempi);
  404. creatures[tempi]->nameRef=temps;
  405. }
  406. ifs.close();
  407. ifs.clear();
  408. for(int i=1;i<=10;i++)
  409. levelCreatures.insert(std::pair<int,std::vector<CCreature*> >(i,std::vector<CCreature*>()));
  410. tlog5 << "\t\tReading config/monsters.txt" << std::endl;
  411. ifs.open(DATA_DIR "/config/monsters.txt");
  412. {
  413. while(!ifs.eof())
  414. {
  415. int id, lvl;
  416. ifs >> id >> lvl;
  417. if(lvl>0)
  418. {
  419. creatures[id]->level = lvl;
  420. levelCreatures[lvl].push_back(creatures[id]);
  421. }
  422. }
  423. }
  424. ifs.close();
  425. ifs.clear();
  426. tlog5 << "\t\tReading config/cr_factions.txt" << std::endl;
  427. ifs.open(DATA_DIR "/config/cr_factions.txt");
  428. while(!ifs.eof())
  429. {
  430. int id, fact;
  431. ifs >> id >> fact;
  432. creatures[id]->faction = fact;
  433. }
  434. ifs.close();
  435. ifs.clear();
  436. tlog5 << "\t\tReading config/cr_upgrade_list.txt" << std::endl;
  437. ifs.open(DATA_DIR "/config/cr_upgrade_list.txt");
  438. while(!ifs.eof())
  439. {
  440. int id, up;
  441. ifs >> id >> up;
  442. creatures[id]->upgrades.insert(up);
  443. }
  444. ifs.close();
  445. ifs.clear();
  446. //loading unit animation def names
  447. tlog5 << "\t\tReading config/CREDEFS.TXT" << std::endl;
  448. std::ifstream inp(DATA_DIR "/config/CREDEFS.TXT", std::ios::in | std::ios::binary); //this file is not in lod
  449. inp.seekg(0,std::ios::end); // na koniec
  450. int andame2 = inp.tellg(); // read length
  451. inp.seekg(0,std::ios::beg); // wracamy na poczatek
  452. char * bufor = new char[andame2+1]; // allocate memory
  453. inp.read((char*)bufor, andame2); // read map file to buffer
  454. inp.close();
  455. bufor[andame2] = 0;
  456. buf = std::string(bufor);
  457. delete [] bufor;
  458. i = 0; //buf iterator
  459. hmcr = 0;
  460. for(i; i<andame2; ++i) //omitting rubbish
  461. {
  462. if(buf[i]=='\r')
  463. break;
  464. }
  465. i+=2;
  466. tlog5 << "We have "<<creatures.size() << " creatures\n";
  467. for(int s=0; s<creatures.size(); ++s)
  468. {
  469. //tlog5 <<"\t\t\t" << s <<". Reading defname. \n";
  470. int befi=i;
  471. std::string rub;
  472. for(i; i<andame2; ++i)
  473. {
  474. if(buf[i]==' ')
  475. break;
  476. }
  477. rub = buf.substr(befi, i-befi);
  478. ++i;
  479. befi=i;
  480. for(i; i<andame2; ++i)
  481. {
  482. if(buf[i]=='\r')
  483. break;
  484. }
  485. std::string defName = buf.substr(befi, i-befi);
  486. creatures[s]->animDefName = defName;
  487. }
  488. tlog5 << "\t\tReading CRANIM.TXT.txt" << std::endl;
  489. loadAnimationInfo();
  490. //loading id to projectile mapping
  491. tlog5 << "\t\tReading config/cr_shots.txt" << std::endl;
  492. std::ifstream inp2(DATA_DIR "/config/cr_shots.txt", std::ios::in | std::ios::binary); //this file is not in lod
  493. char dump [200];
  494. inp2.getline(dump, 200);
  495. while(true)
  496. {
  497. int id;
  498. std::string name;
  499. bool spin;
  500. inp2>>id;
  501. if(id == -1)
  502. break;
  503. inp2>>name;
  504. idToProjectile[id] = name;
  505. inp2>>spin;
  506. idToProjectileSpin[id] = spin;
  507. }
  508. inp2.close();
  509. //reading factionToTurretCreature
  510. tlog5 << "\t\tReading config/cr_to_turret.txt" << std::endl;
  511. std::ifstream inp3(DATA_DIR "/config/cr_to_turret.txt", std::ios::in | std::ios::binary); //this file is not in lod
  512. std::string dump2;
  513. inp3 >> dump2 >> dump2;
  514. for(int g=0; g<F_NUMBER; ++g)
  515. {
  516. inp3 >> factionToTurretCreature[g];
  517. }
  518. inp3.close();
  519. }
  520. void CCreatureHandler::loadAnimationInfo()
  521. {
  522. std::string buf = bitmaph->getTextFile("CRANIM.TXT");
  523. int andame = buf.size();
  524. int i=0; //buf iterator
  525. int hmcr=0;
  526. for(i; i<andame; ++i)
  527. {
  528. if(buf[i]=='\r')
  529. ++hmcr;
  530. if(hmcr==2)
  531. break;
  532. }
  533. i+=2;
  534. for(int dd=0; dd<creatures.size(); ++dd)
  535. {
  536. //tlog5 << "\t\t\tReading animation info for creature " << dd << std::endl;
  537. loadUnitAnimInfo(*creatures[dd], buf, i);
  538. }
  539. return;
  540. }
  541. void CCreatureHandler::loadUnitAnimInfo(CCreature & unit, std::string & src, int & i)
  542. {
  543. int befi=i;
  544. unit.timeBetweenFidgets = readFloat(befi, i, src.size(), src);
  545. while(unit.timeBetweenFidgets == 0.0)
  546. {
  547. for(i; i<src.size(); ++i)
  548. {
  549. if(src[i]=='\r')
  550. break;
  551. }
  552. i+=2;
  553. unit.timeBetweenFidgets = readFloat(befi, i, src.size(), src);
  554. }
  555. unit.walkAnimationTime = readFloat(befi, i, src.size(), src);
  556. unit.attackAnimationTime = readFloat(befi, i, src.size(), src);
  557. unit.flightAnimationDistance = readFloat(befi, i, src.size(), src);
  558. ///////////////////////
  559. unit.upperRightMissleOffsetX = readNumber(befi, i, src.size(), src);
  560. unit.upperRightMissleOffsetY = readNumber(befi, i, src.size(), src);
  561. unit.rightMissleOffsetX = readNumber(befi, i, src.size(), src);
  562. unit.rightMissleOffsetY = readNumber(befi, i, src.size(), src);
  563. unit.lowerRightMissleOffsetX = readNumber(befi, i, src.size(), src);
  564. unit.lowerRightMissleOffsetY = readNumber(befi, i, src.size(), src);
  565. ///////////////////////
  566. for(int jjj=0; jjj<12; ++jjj)
  567. {
  568. unit.missleFrameAngles[jjj] = readFloat(befi, i, src.size(), src);
  569. }
  570. unit.troopCountLocationOffset= readNumber(befi, i, src.size(), src);
  571. unit.attackClimaxFrame = readNumber(befi, i, src.size(), src);
  572. for(i; i<src.size(); ++i)
  573. {
  574. if(src[i]=='\r')
  575. break;
  576. }
  577. i+=2;
  578. }
  579. CCreatureHandler::~CCreatureHandler()
  580. {
  581. }