CCreatureHandler.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  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. bool CCreature::isMyUpgrade(const CCreature *anotherCre) const
  116. {
  117. //TODO upgrade of upgrade?
  118. return vstd::contains(upgrades, anotherCre->idNumber);
  119. }
  120. int readNumber(int & befi, int & i, int andame, std::string & buf) //helper function for void CCreatureHandler::loadCreatures() and loadUnitAnimInfo()
  121. {
  122. befi=i;
  123. for(i; i<andame; ++i)
  124. {
  125. if(buf[i]=='\t')
  126. break;
  127. }
  128. std::string tmp = buf.substr(befi, i-befi);
  129. int ret = atoi(buf.substr(befi, i-befi).c_str());
  130. ++i;
  131. return ret;
  132. }
  133. float readFloat(int & befi, int & i, int andame, std::string & buf) //helper function for void CCreatureHandler::loadUnitAnimInfo()
  134. {
  135. befi=i;
  136. for(i; i<andame; ++i)
  137. {
  138. if(buf[i]=='\t')
  139. break;
  140. }
  141. std::string tmp = buf.substr(befi, i-befi);
  142. float ret = atof(buf.substr(befi, i-befi).c_str());
  143. ++i;
  144. return ret;
  145. }
  146. /**
  147. * Determines if a faction is good.
  148. * @param ID of the faction.
  149. * @return true if the faction is good, false otherwise.
  150. */
  151. bool CCreatureHandler::isGood (si8 faction) const
  152. {
  153. return faction != -1 && factionAlignments[faction] == 1;
  154. }
  155. /**
  156. * Determines if a faction is evil.
  157. * @param ID of the faction.
  158. * @return true if the faction is evil, false otherwise.
  159. */
  160. bool CCreatureHandler::isEvil (si8 faction) const
  161. {
  162. return faction != -1 && factionAlignments[faction] == -1;
  163. }
  164. void CCreatureHandler::loadCreatures()
  165. {
  166. 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;
  167. tlog5 << "\t\tReading config/cr_abils.txt and ZCRTRAIT.TXT" << std::endl;
  168. bool useCreAbilsFromZCRTRAIT = true;
  169. ////////////reading cr_abils.txt ///////////////////
  170. std::ifstream abils(DATA_DIR "/config/cr_abils.txt", std::ios::in | std::ios::binary); //this file is not in lod
  171. const int MAX_LINE_SIZE = 1000;
  172. char abilLine[MAX_LINE_SIZE+1];
  173. for(int i=0; i<5; ++i) //removing 5 comment lines
  174. {
  175. abils.getline(abilLine, MAX_LINE_SIZE);
  176. }
  177. //reading first line (determining if we should use creature abilities from ZCRTRAIT.TXT)
  178. abils.getline(abilLine, MAX_LINE_SIZE);
  179. useCreAbilsFromZCRTRAIT = atoi(abilLine);
  180. ////////////reading ZCRTRAIT.TXT ///////////////////
  181. std::string buf = bitmaph->getTextFile("ZCRTRAIT.TXT");
  182. int andame = buf.size();
  183. int i=0; //buf iterator
  184. int hmcr=0;
  185. for(i; i<andame; ++i)
  186. {
  187. if(buf[i]=='\r')
  188. ++hmcr;
  189. if(hmcr==2)
  190. break;
  191. }
  192. i+=2;
  193. while(i<buf.size())
  194. {
  195. CCreature &ncre = *new CCreature;
  196. ncre.idNumber = creatures.size();
  197. ncre.cost.resize(RESOURCE_QUANTITY);
  198. ncre.level=0;
  199. int befi=i;
  200. for(i; i<andame; ++i)
  201. {
  202. if(buf[i]=='\t')
  203. break;
  204. }
  205. ncre.nameSing = buf.substr(befi, i-befi);
  206. ++i;
  207. befi=i;
  208. for(i; i<andame; ++i)
  209. {
  210. if(buf[i]=='\t')
  211. break;
  212. }
  213. ncre.namePl = buf.substr(befi, i-befi);
  214. ++i;
  215. for(int v=0; v<7; ++v)
  216. {
  217. ncre.cost[v] = readNumber(befi, i, andame, buf);
  218. }
  219. ncre.fightValue = readNumber(befi, i, andame, buf);
  220. ncre.AIValue = readNumber(befi, i, andame, buf);
  221. ncre.growth = readNumber(befi, i, andame, buf);
  222. ncre.hordeGrowth = readNumber(befi, i, andame, buf);
  223. ncre.hitPoints = readNumber(befi, i, andame, buf);
  224. ncre.addBonus(ncre.hitPoints, Bonus::STACK_HEALTH);
  225. ncre.speed = readNumber(befi, i, andame, buf);
  226. ncre.addBonus(ncre.speed, Bonus::STACKS_SPEED);
  227. ncre.attack = readNumber(befi, i, andame, buf);
  228. ncre.addBonus(ncre.attack, Bonus::PRIMARY_SKILL, PrimarySkill::ATTACK);
  229. ncre.defence = readNumber(befi, i, andame, buf);
  230. ncre.addBonus(ncre.defence, Bonus::PRIMARY_SKILL, PrimarySkill::DEFENSE);
  231. ncre.damageMin = readNumber(befi, i, andame, buf);
  232. ncre.damageMax = readNumber(befi, i, andame, buf);
  233. ncre.shots = readNumber(befi, i, andame, buf);
  234. ncre.spells = readNumber(befi, i, andame, buf);
  235. ncre.ammMin = readNumber(befi, i, andame, buf);
  236. ncre.ammMax = readNumber(befi, i, andame, buf);
  237. befi=i;
  238. for(i; i<andame; ++i)
  239. {
  240. if(buf[i]=='\t')
  241. break;
  242. }
  243. ncre.abilityText = buf.substr(befi, i-befi);
  244. ++i;
  245. befi=i;
  246. for(i; i<andame; ++i)
  247. {
  248. if(buf[i]=='\r')
  249. break;
  250. }
  251. ncre.abilityRefs = buf.substr(befi, i-befi);
  252. i+=2;
  253. if(useCreAbilsFromZCRTRAIT)
  254. { //adding abilities from ZCRTRAIT.TXT
  255. if(boost::algorithm::find_first(ncre.abilityRefs, "DOUBLE_WIDE"))
  256. ncre.doubleWide = true;
  257. if(boost::algorithm::find_first(ncre.abilityRefs, "FLYING_ARMY"))
  258. ncre.addBonus(0, Bonus::FLYING);
  259. if(boost::algorithm::find_first(ncre.abilityRefs, "SHOOTING_ARMY"))
  260. ncre.addBonus(0, Bonus::SHOOTER);
  261. if(boost::algorithm::find_first(ncre.abilityRefs, "SIEGE_WEAPON"))
  262. ncre.addBonus(0, Bonus::SIEGE_WEAPON);
  263. if(boost::algorithm::find_first(ncre.abilityRefs, "const_two_attacks"))
  264. ncre.addBonus(1, Bonus::ADDITIONAL_ATTACK);
  265. if(boost::algorithm::find_first(ncre.abilityRefs, "const_free_attack"))
  266. ncre.addBonus(0, Bonus::BLOCKS_RETALIATION);
  267. if(boost::algorithm::find_first(ncre.abilityRefs, "IS_UNDEAD"))
  268. ncre.addBonus(0, Bonus::UNDEAD);
  269. if(boost::algorithm::find_first(ncre.abilityRefs, "const_no_melee_penalty"))
  270. ncre.addBonus(0, Bonus::NO_MELEE_PENALTY);
  271. if(boost::algorithm::find_first(ncre.abilityRefs, "const_jousting"))
  272. ncre.addBonus(0, Bonus::JOUSTING);
  273. if(boost::algorithm::find_first(ncre.abilityRefs, "const_raises_morale"))
  274. {
  275. ncre.addBonus(+1, Bonus::MORALE);;
  276. ncre.bonuses.back().effectRange = Bonus::ONLY_ALLIED_ARMY;
  277. }
  278. if(boost::algorithm::find_first(ncre.abilityRefs, "const_lowers_morale"))
  279. {
  280. ncre.addBonus(-1, Bonus::MORALE);;
  281. ncre.bonuses.back().effectRange = Bonus::ONLY_ENEMY_ARMY;
  282. }
  283. if(boost::algorithm::find_first(ncre.abilityRefs, "KING_1"))
  284. ncre.addBonus(0, Bonus::KING1);
  285. if(boost::algorithm::find_first(ncre.abilityRefs, "KING_2"))
  286. ncre.addBonus(0, Bonus::KING2);
  287. if(boost::algorithm::find_first(ncre.abilityRefs, "KING_3"))
  288. ncre.addBonus(0, Bonus::KING3);
  289. if(boost::algorithm::find_first(ncre.abilityRefs, "const_no_wall_penalty"))
  290. ncre.addBonus(0, Bonus::NO_WALL_PENALTY);
  291. if(boost::algorithm::find_first(ncre.abilityRefs, "CATAPULT"))
  292. ncre.addBonus(0, Bonus::CATAPULT);
  293. if(boost::algorithm::find_first(ncre.abilityRefs, "MULTI_HEADED"))
  294. ncre.addBonus(0, Bonus::ATTACKS_ALL_ADJACENT);
  295. if(boost::algorithm::find_first(ncre.abilityRefs, "IMMUNE_TO_MIND_SPELLS"))
  296. {
  297. std::vector<int> mindSpells = getMindSpells();
  298. for(int g=0; g<mindSpells.size(); ++g)
  299. ncre.addBonus(0, Bonus::SPELL_IMMUNITY, mindSpells[g]); //giants are immune to mind spells
  300. }
  301. if(boost::algorithm::find_first(ncre.abilityRefs, "IMMUNE_TO_FIRE_SPELLS"))
  302. ncre.addBonus(0, Bonus::FIRE_IMMUNITY);
  303. if(boost::algorithm::find_first(ncre.abilityRefs, "HAS_EXTENDED_ATTACK"))
  304. ncre.addBonus(0, Bonus::TWO_HEX_ATTACK_BREATH);;
  305. }
  306. if(ncre.nameSing!=std::string("") && ncre.namePl!=std::string(""))
  307. {
  308. ncre.idNumber = creatures.size();
  309. creatures.push_back(&ncre);
  310. }
  311. }
  312. ////second part of reading cr_abils.txt////
  313. bool contReading = true;
  314. while(contReading) //main reading loop
  315. {
  316. abils.getline(abilLine, MAX_LINE_SIZE);
  317. std::istringstream reader(abilLine);
  318. char command;
  319. reader >> command;
  320. switch(command)
  321. {
  322. case '+': //add new ability
  323. {
  324. int creatureID;
  325. Bonus nsf;
  326. si32 buf;
  327. std::string type;
  328. reader >> creatureID;
  329. reader >> type;
  330. std::map<std::string, int>::const_iterator it = bonusNameMap.find(type);
  331. CCreature *cre = creatures[creatureID];
  332. if (it == bonusNameMap.end())
  333. {
  334. if(type == "DOUBLE_WIDE")
  335. cre->doubleWide = true;
  336. else if(type == "ENEMY_MORALE_DECREASING")
  337. {
  338. cre->addBonus(-1, Bonus::MORALE);;
  339. cre->bonuses.back().effectRange = Bonus::ONLY_ENEMY_ARMY;
  340. }
  341. else if(type == "ENEMY_LUCK_DECREASING")
  342. {
  343. cre->addBonus(-1, Bonus::LUCK);;
  344. cre->bonuses.back().effectRange = Bonus::ONLY_ENEMY_ARMY;
  345. }
  346. else
  347. tlog1 << "Error: invalid type " << type << " in cr_abils.txt" << std::endl;
  348. break;
  349. }
  350. nsf.type = it->second;
  351. reader >> buf; nsf.val = buf;
  352. reader >> buf; nsf.subtype = buf;
  353. reader >> buf; nsf.additionalInfo = buf;
  354. nsf.source = Bonus::CREATURE_ABILITY;
  355. nsf.id = cre->idNumber;
  356. nsf.duration = Bonus::ONE_BATTLE;
  357. nsf.turnsRemain = 0;
  358. cre->bonuses += nsf;
  359. break;
  360. }
  361. case '-': //remove ability
  362. {
  363. int creatureID;
  364. std::string type;
  365. reader >> creatureID;
  366. reader >> type;
  367. std::map<std::string, int>::const_iterator it = bonusNameMap.find(type);
  368. if (it == bonusNameMap.end())
  369. {
  370. if(type == "DOUBLE_WIDE")
  371. creatures[creatureID]->doubleWide = false;
  372. else
  373. tlog1 << "Error: invalid type " << type << " in cr_abils.txt" << std::endl;
  374. break;
  375. }
  376. int typeNo = it->second;
  377. Bonus::BonusType ecf = static_cast<Bonus::BonusType>(typeNo);
  378. creatures[creatureID]->bonuses -= ecf;
  379. break;
  380. }
  381. case '0': //end reading
  382. {
  383. contReading = false;
  384. break;
  385. }
  386. default: //invalid command
  387. {
  388. tlog1 << "Parse error in file config/cr_abils.txt" << std::endl;
  389. break;
  390. }
  391. }
  392. }
  393. abils.close();
  394. tlog5 << "\t\tReading config/crerefnam.txt" << std::endl;
  395. //loading reference names
  396. std::ifstream ifs(DATA_DIR "/config/crerefnam.txt");
  397. int tempi;
  398. std::string temps;
  399. for (;;)
  400. {
  401. ifs >> tempi >> temps;
  402. if (tempi>=creatures.size())
  403. break;
  404. boost::assign::insert(nameToID)(temps,tempi);
  405. creatures[tempi]->nameRef=temps;
  406. }
  407. ifs.close();
  408. ifs.clear();
  409. for(int i=1;i<=10;i++)
  410. levelCreatures.insert(std::pair<int,std::vector<CCreature*> >(i,std::vector<CCreature*>()));
  411. tlog5 << "\t\tReading config/monsters.txt" << std::endl;
  412. ifs.open(DATA_DIR "/config/monsters.txt");
  413. {
  414. while(!ifs.eof())
  415. {
  416. int id, lvl;
  417. ifs >> id >> lvl;
  418. if(lvl>0)
  419. {
  420. creatures[id]->level = lvl;
  421. levelCreatures[lvl].push_back(creatures[id]);
  422. }
  423. }
  424. }
  425. ifs.close();
  426. ifs.clear();
  427. tlog5 << "\t\tReading config/cr_factions.txt" << std::endl;
  428. ifs.open(DATA_DIR "/config/cr_factions.txt");
  429. while(!ifs.eof())
  430. {
  431. int id, fact;
  432. ifs >> id >> fact;
  433. creatures[id]->faction = fact;
  434. }
  435. ifs.close();
  436. ifs.clear();
  437. tlog5 << "\t\tReading config/cr_upgrade_list.txt" << std::endl;
  438. ifs.open(DATA_DIR "/config/cr_upgrade_list.txt");
  439. while(!ifs.eof())
  440. {
  441. int id, up;
  442. ifs >> id >> up;
  443. creatures[id]->upgrades.insert(up);
  444. }
  445. ifs.close();
  446. ifs.clear();
  447. //loading unit animation def names
  448. tlog5 << "\t\tReading config/CREDEFS.TXT" << std::endl;
  449. std::ifstream inp(DATA_DIR "/config/CREDEFS.TXT", std::ios::in | std::ios::binary); //this file is not in lod
  450. inp.seekg(0,std::ios::end); // na koniec
  451. int andame2 = inp.tellg(); // read length
  452. inp.seekg(0,std::ios::beg); // wracamy na poczatek
  453. char * bufor = new char[andame2+1]; // allocate memory
  454. inp.read((char*)bufor, andame2); // read map file to buffer
  455. inp.close();
  456. bufor[andame2] = 0;
  457. buf = std::string(bufor);
  458. delete [] bufor;
  459. i = 0; //buf iterator
  460. hmcr = 0;
  461. for(i; i<andame2; ++i) //omitting rubbish
  462. {
  463. if(buf[i]=='\r')
  464. break;
  465. }
  466. i+=2;
  467. tlog5 << "We have "<<creatures.size() << " creatures\n";
  468. for(int s=0; s<creatures.size(); ++s)
  469. {
  470. //tlog5 <<"\t\t\t" << s <<". Reading defname. \n";
  471. int befi=i;
  472. std::string rub;
  473. for(i; i<andame2; ++i)
  474. {
  475. if(buf[i]==' ')
  476. break;
  477. }
  478. rub = buf.substr(befi, i-befi);
  479. ++i;
  480. befi=i;
  481. for(i; i<andame2; ++i)
  482. {
  483. if(buf[i]=='\r')
  484. break;
  485. }
  486. std::string defName = buf.substr(befi, i-befi);
  487. creatures[s]->animDefName = defName;
  488. }
  489. tlog5 << "\t\tReading CRANIM.TXT.txt" << std::endl;
  490. loadAnimationInfo();
  491. //loading id to projectile mapping
  492. tlog5 << "\t\tReading config/cr_shots.txt" << std::endl;
  493. std::ifstream inp2(DATA_DIR "/config/cr_shots.txt", std::ios::in | std::ios::binary); //this file is not in lod
  494. char dump [200];
  495. inp2.getline(dump, 200);
  496. while(true)
  497. {
  498. int id;
  499. std::string name;
  500. bool spin;
  501. inp2>>id;
  502. if(id == -1)
  503. break;
  504. inp2>>name;
  505. idToProjectile[id] = name;
  506. inp2>>spin;
  507. idToProjectileSpin[id] = spin;
  508. }
  509. inp2.close();
  510. //reading factionToTurretCreature
  511. tlog5 << "\t\tReading config/cr_to_turret.txt" << std::endl;
  512. std::ifstream inp3(DATA_DIR "/config/cr_to_turret.txt", std::ios::in | std::ios::binary); //this file is not in lod
  513. std::string dump2;
  514. inp3 >> dump2 >> dump2;
  515. for(int g=0; g<F_NUMBER; ++g)
  516. {
  517. inp3 >> factionToTurretCreature[g];
  518. }
  519. inp3.close();
  520. }
  521. void CCreatureHandler::loadAnimationInfo()
  522. {
  523. std::string buf = bitmaph->getTextFile("CRANIM.TXT");
  524. int andame = buf.size();
  525. int i=0; //buf iterator
  526. int hmcr=0;
  527. for(i; i<andame; ++i)
  528. {
  529. if(buf[i]=='\r')
  530. ++hmcr;
  531. if(hmcr==2)
  532. break;
  533. }
  534. i+=2;
  535. for(int dd=0; dd<creatures.size(); ++dd)
  536. {
  537. //tlog5 << "\t\t\tReading animation info for creature " << dd << std::endl;
  538. loadUnitAnimInfo(*creatures[dd], buf, i);
  539. }
  540. return;
  541. }
  542. void CCreatureHandler::loadUnitAnimInfo(CCreature & unit, std::string & src, int & i)
  543. {
  544. int befi=i;
  545. unit.timeBetweenFidgets = readFloat(befi, i, src.size(), src);
  546. while(unit.timeBetweenFidgets == 0.0)
  547. {
  548. for(i; i<src.size(); ++i)
  549. {
  550. if(src[i]=='\r')
  551. break;
  552. }
  553. i+=2;
  554. unit.timeBetweenFidgets = readFloat(befi, i, src.size(), src);
  555. }
  556. unit.walkAnimationTime = readFloat(befi, i, src.size(), src);
  557. unit.attackAnimationTime = readFloat(befi, i, src.size(), src);
  558. unit.flightAnimationDistance = readFloat(befi, i, src.size(), src);
  559. ///////////////////////
  560. unit.upperRightMissleOffsetX = readNumber(befi, i, src.size(), src);
  561. unit.upperRightMissleOffsetY = readNumber(befi, i, src.size(), src);
  562. unit.rightMissleOffsetX = readNumber(befi, i, src.size(), src);
  563. unit.rightMissleOffsetY = readNumber(befi, i, src.size(), src);
  564. unit.lowerRightMissleOffsetX = readNumber(befi, i, src.size(), src);
  565. unit.lowerRightMissleOffsetY = readNumber(befi, i, src.size(), src);
  566. ///////////////////////
  567. for(int jjj=0; jjj<12; ++jjj)
  568. {
  569. unit.missleFrameAngles[jjj] = readFloat(befi, i, src.size(), src);
  570. }
  571. unit.troopCountLocationOffset= readNumber(befi, i, src.size(), src);
  572. unit.attackClimaxFrame = readNumber(befi, i, src.size(), src);
  573. for(i; i<src.size(); ++i)
  574. {
  575. if(src[i]=='\r')
  576. break;
  577. }
  578. i+=2;
  579. }
  580. CCreatureHandler::~CCreatureHandler()
  581. {
  582. }