2007-06-09 05:32:43 +03:00
|
|
|
#include "stdafx.h"
|
2007-07-16 17:42:44 +03:00
|
|
|
#include "CGameInfo.h"
|
2007-06-08 22:56:35 +03:00
|
|
|
#include "CCreatureHandler.h"
|
|
|
|
|
|
|
|
void CCreatureHandler::loadCreatures()
|
|
|
|
{
|
2007-07-16 17:42:44 +03:00
|
|
|
std::string buf = CGameInfo::mainObj->bitmaph->getTextFile("ZCRTRAIT.TXT");
|
|
|
|
int andame = buf.size();
|
2007-06-10 21:04:15 +03:00
|
|
|
int i=0; //buf iterator
|
|
|
|
int hmcr=0;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\r')
|
|
|
|
++hmcr;
|
|
|
|
if(hmcr==2)
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
i+=2;
|
|
|
|
|
|
|
|
while(i<buf.size())
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(creatures.size()>190 && buf.substr(i, buf.size()-i).find('\r')==std::string::npos)
|
2007-06-18 13:49:06 +03:00
|
|
|
{
|
|
|
|
loadAnimationInfo();
|
2007-07-20 02:38:11 +03:00
|
|
|
//loadUnitAnimations();
|
2007-06-10 21:04:15 +03:00
|
|
|
break;
|
2007-06-18 13:49:06 +03:00
|
|
|
}
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
CCreature ncre;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
int befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.nameSing = buf.substr(befi, i-befi);
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.namePl = buf.substr(befi, i-befi);
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.wood = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.mercury = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.ore = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.sulfur = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.crystal = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.gems = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.gold = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.fightValue = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.AIValue = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.growth = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.hordeGrowth = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.hitPoints = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.speed = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.attack = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.defence = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.low1 = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.high1 = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.shots = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.spells = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.low2 = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.high2 = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.abilityText = buf.substr(befi, i-befi);
|
|
|
|
++i;
|
2007-06-08 22:56:35 +03:00
|
|
|
|
2007-06-10 21:04:15 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
2007-06-08 22:56:35 +03:00
|
|
|
{
|
2007-06-10 21:04:15 +03:00
|
|
|
if(buf[i]=='\r')
|
|
|
|
break;
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-06-10 21:04:15 +03:00
|
|
|
ncre.abilityRefs = buf.substr(befi, i-befi);
|
|
|
|
i+=2;
|
2007-06-13 23:17:48 +03:00
|
|
|
if(ncre.nameSing!=std::string("") && ncre.namePl!=std::string(""))
|
|
|
|
{
|
|
|
|
ncre.idNumber = creatures.size();
|
2007-07-12 21:04:02 +03:00
|
|
|
ncre.isDefinite = true;
|
2007-06-13 23:17:48 +03:00
|
|
|
creatures.push_back(ncre);
|
|
|
|
}
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
2007-07-12 21:04:02 +03:00
|
|
|
for(int bb=1; bb<8; ++bb)
|
|
|
|
{
|
|
|
|
CCreature ncre;
|
|
|
|
ncre.isDefinite = false;
|
|
|
|
ncre.indefLevel = bb;
|
|
|
|
ncre.indefUpgraded = false;
|
|
|
|
creatures.push_back(ncre);
|
|
|
|
ncre.indefUpgraded = true;
|
|
|
|
creatures.push_back(ncre);
|
|
|
|
}
|
2007-06-08 22:56:35 +03:00
|
|
|
}
|
|
|
|
|
2007-06-18 13:49:06 +03:00
|
|
|
void CCreatureHandler::loadAnimationInfo()
|
|
|
|
{
|
2007-07-16 17:42:44 +03:00
|
|
|
std::string buf = CGameInfo::mainObj->bitmaph->getTextFile("CRANIM.TXT");
|
|
|
|
int andame = buf.size();
|
2007-06-18 13:49:06 +03:00
|
|
|
int i=0; //buf iterator
|
|
|
|
int hmcr=0;
|
|
|
|
for(i; i<andame; ++i)
|
|
|
|
{
|
|
|
|
if(buf[i]=='\r')
|
|
|
|
++hmcr;
|
|
|
|
if(hmcr==2)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i+=2;
|
|
|
|
for(int dd=0; dd<creatures.size(); ++dd)
|
|
|
|
{
|
|
|
|
loadUnitAnimInfo(creatures[dd], buf, i);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCreatureHandler::loadUnitAnimInfo(CCreature & unit, std::string & src, int & i)
|
|
|
|
{
|
|
|
|
int befi=i;
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unit.timeBetweenFidgets = atof(src.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
|
|
|
|
while(unit.timeBetweenFidgets == 0.0)
|
|
|
|
{
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\r')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i+=2;
|
|
|
|
befi=i;
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unit.timeBetweenFidgets = atof(src.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unit.walkAnimationTime = atof(src.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unit.attackAnimationTime = atof(src.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unit.flightAnimationDistance = atof(src.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
|
|
|
|
///////////////////////
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unit.upperRightMissleOffsetX = atoi(src.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unit.upperRightMissleOffsetY = atoi(src.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unit.rightMissleOffsetX = atoi(src.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unit.rightMissleOffsetY = atoi(src.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unit.lowerRightMissleOffsetX = atoi(src.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unit.lowerRightMissleOffsetY = atoi(src.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
|
|
|
|
///////////////////////
|
|
|
|
|
|
|
|
for(int jjj=0; jjj<12; ++jjj)
|
|
|
|
{
|
|
|
|
befi=i;
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unit.missleFrameAngles[jjj] = atof(src.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unit.troopCountLocationOffset= atoi(src.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unit.attackClimaxFrame = atoi(src.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
|
|
|
|
for(i; i<src.size(); ++i)
|
|
|
|
{
|
|
|
|
if(src[i]=='\r')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i+=2;
|
|
|
|
}
|
2007-07-17 18:13:46 +03:00
|
|
|
|
|
|
|
void CCreatureHandler::loadUnitAnimations()
|
|
|
|
{
|
2007-08-01 17:06:04 +03:00
|
|
|
std::ifstream inp("CREDEFS.TXT", std::ios::in | std::ios::binary); //this file is not in lod
|
2007-07-17 18:13:46 +03:00
|
|
|
inp.seekg(0,std::ios::end); // na koniec
|
|
|
|
int andame = inp.tellg(); // read length
|
|
|
|
inp.seekg(0,std::ios::beg); // wracamy na poczatek
|
|
|
|
char * bufor = new char[andame]; // allocate memory
|
|
|
|
inp.read((char*)bufor, andame); // read map file to buffer
|
|
|
|
inp.close();
|
|
|
|
std::string buf = std::string(bufor);
|
|
|
|
delete [andame] bufor;
|
|
|
|
|
|
|
|
int i = 0; //buf iterator
|
|
|
|
int hmcr = 0;
|
|
|
|
for(i; i<andame; ++i) //omitting rubbish
|
|
|
|
{
|
|
|
|
if(buf[i]=='\r')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i+=2;
|
|
|
|
for(int s=0; s<creatures.size(); ++s)
|
|
|
|
{
|
|
|
|
int befi=i;
|
|
|
|
std::string rub;
|
|
|
|
for(i; i<andame; ++i)
|
|
|
|
{
|
|
|
|
if(buf[i]==' ')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
rub = buf.substr(befi, i-befi);
|
|
|
|
++i;
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
|
|
|
{
|
|
|
|
if(buf[i]=='\r')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
std::string defName = buf.substr(befi, i-befi);
|
|
|
|
if(defName != std::string("x"))
|
|
|
|
creatures[s].battleAnimation = CGameInfo::mainObj->spriteh->giveDef(defName);
|
|
|
|
else
|
|
|
|
creatures[s].battleAnimation = NULL;
|
|
|
|
i+=2;
|
|
|
|
}
|
|
|
|
}
|