|
|
|
@@ -46,7 +46,6 @@ extern CLodHandler * bitmaph;
|
|
|
|
|
extern boost::rand48 ran;
|
|
|
|
|
std::map <ui8, std::set <ui8> > CGKeys::playerKeyMap;
|
|
|
|
|
std::map <si32, std::vector<si32> > CGMagi::eyelist;
|
|
|
|
|
BankConfig CGPyramid::pyramidConfig;
|
|
|
|
|
ui8 CGObelisk::obeliskCount; //how many obelisks are on map
|
|
|
|
|
std::map<ui8, ui8> CGObelisk::visited; //map: team_id => how many obelisks has been visited
|
|
|
|
|
|
|
|
|
@@ -130,67 +129,8 @@ static void readCreatures(std::istream & is, BankConfig & bc, bool guards) //hel
|
|
|
|
|
else //given creatures
|
|
|
|
|
bc.creatures.push_back(guardInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CObjectHandler::loadObjects()
|
|
|
|
|
void CObjectHandler::readConfigLine(std::ifstream &istr, int g)
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
tlog5 << "\t\tReading cregens \n";
|
|
|
|
|
cregens.resize(110); //TODO: hardcoded value - change
|
|
|
|
|
for(size_t i=0; i < cregens.size(); ++i)
|
|
|
|
|
{
|
|
|
|
|
cregens[i]=-1;
|
|
|
|
|
}
|
|
|
|
|
std::ifstream ifs(DATA_DIR "/config/cregens.txt");
|
|
|
|
|
while(!ifs.eof())
|
|
|
|
|
{
|
|
|
|
|
int dw, cr;
|
|
|
|
|
ifs >> dw >> cr;
|
|
|
|
|
cregens[dw]=cr;
|
|
|
|
|
}
|
|
|
|
|
tlog5 << "\t\tDone loading objects!\n";
|
|
|
|
|
|
|
|
|
|
ifs.close();
|
|
|
|
|
ifs.clear();
|
|
|
|
|
|
|
|
|
|
int k = -1;
|
|
|
|
|
ifs.open(DATA_DIR "/config/resources.txt");
|
|
|
|
|
ifs >> k;
|
|
|
|
|
int pom;
|
|
|
|
|
for(int i=0;i<k;i++)
|
|
|
|
|
{
|
|
|
|
|
ifs >> pom;
|
|
|
|
|
resVals.push_back(pom);
|
|
|
|
|
}
|
|
|
|
|
tlog5 << "\t\tDone loading resource prices!\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::ifstream istr;
|
|
|
|
|
istr.open(DATA_DIR "/config/bankconfig.txt", std::ios_base::binary);
|
|
|
|
|
if(!istr.is_open())
|
|
|
|
|
{
|
|
|
|
|
tlog1 << "No config/bankconfig.txt file !!!\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const int MAX_BUF = 5000;
|
|
|
|
|
char buffer[MAX_BUF + 1];
|
|
|
|
|
|
|
|
|
|
//omitting unnecessary lines
|
|
|
|
|
istr.getline(buffer, MAX_BUF);
|
|
|
|
|
istr.getline(buffer, MAX_BUF);
|
|
|
|
|
|
|
|
|
|
for(int g=0; g<21; ++g) //TODO: remove hardcoded value
|
|
|
|
|
{
|
|
|
|
|
//reading name
|
|
|
|
|
istr.getline(buffer, MAX_BUF, '\t');
|
|
|
|
|
creBanksNames[g] = std::string(buffer);
|
|
|
|
|
//remove trailing new line characters
|
|
|
|
|
while(creBanksNames[g][0] == 10 || creBanksNames[g][0] == 13)
|
|
|
|
|
creBanksNames[g].erase(creBanksNames[g].begin());
|
|
|
|
|
|
|
|
|
|
for(int i=0; i<4; ++i) //reading levels
|
|
|
|
|
{
|
|
|
|
|
banksInfo[g].push_back(new BankConfig);
|
|
|
|
|
|
|
|
|
|
BankConfig &bc = *banksInfo[g].back();
|
|
|
|
@@ -236,8 +176,75 @@ void CObjectHandler::loadObjects()
|
|
|
|
|
istr >> bc.rewardDifficulty;
|
|
|
|
|
istr >> buf;
|
|
|
|
|
bc.easiest = atoi(buf.c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CObjectHandler::loadObjects()
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
tlog5 << "\t\tReading cregens \n";
|
|
|
|
|
cregens.resize(110); //TODO: hardcoded value - change
|
|
|
|
|
for(size_t i=0; i < cregens.size(); ++i)
|
|
|
|
|
{
|
|
|
|
|
cregens[i]=-1;
|
|
|
|
|
}
|
|
|
|
|
std::ifstream ifs(DATA_DIR "/config/cregens.txt");
|
|
|
|
|
while(!ifs.eof())
|
|
|
|
|
{
|
|
|
|
|
int dw, cr;
|
|
|
|
|
ifs >> dw >> cr;
|
|
|
|
|
cregens[dw]=cr;
|
|
|
|
|
}
|
|
|
|
|
tlog5 << "\t\tDone loading objects!\n";
|
|
|
|
|
|
|
|
|
|
ifs.close();
|
|
|
|
|
ifs.clear();
|
|
|
|
|
|
|
|
|
|
int k = -1;
|
|
|
|
|
ifs.open(DATA_DIR "/config/resources.txt");
|
|
|
|
|
ifs >> k;
|
|
|
|
|
int pom;
|
|
|
|
|
for(int i=0;i<k;i++)
|
|
|
|
|
{
|
|
|
|
|
ifs >> pom;
|
|
|
|
|
resVals.push_back(pom);
|
|
|
|
|
}
|
|
|
|
|
tlog5 << "\t\tDone loading resource prices!\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::ifstream istr;
|
|
|
|
|
istr.open(DATA_DIR "/config/bankconfig.txt", std::ios_base::binary);
|
|
|
|
|
if(!istr.is_open())
|
|
|
|
|
{
|
|
|
|
|
tlog1 << "No config/bankconfig.txt file !!!\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const int MAX_BUF = 5000;
|
|
|
|
|
char buffer[MAX_BUF + 1];
|
|
|
|
|
|
|
|
|
|
//omitting unnecessary lines
|
|
|
|
|
istr.getline(buffer, MAX_BUF);
|
|
|
|
|
istr.getline(buffer, MAX_BUF);
|
|
|
|
|
|
|
|
|
|
for(int g=0; g<21; ++g) //TODO: remove hardcoded value
|
|
|
|
|
{
|
|
|
|
|
//reading name
|
|
|
|
|
istr.getline(buffer, MAX_BUF, '\t');
|
|
|
|
|
creBanksNames[g] = std::string(buffer);
|
|
|
|
|
//remove trailing new line characters
|
|
|
|
|
while(creBanksNames[g][0] == 10 || creBanksNames[g][0] == 13)
|
|
|
|
|
creBanksNames[g].erase(creBanksNames[g].begin());
|
|
|
|
|
|
|
|
|
|
for(int i=0; i<4; ++i) //reading levels
|
|
|
|
|
{
|
|
|
|
|
readConfigLine(istr,g);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//reading name
|
|
|
|
|
istr.getline(buffer, MAX_BUF, '\t');
|
|
|
|
|
creBanksNames[21] = std::string(buffer);
|
|
|
|
|
while(creBanksNames[21][0] == 10 || creBanksNames[21][0] == 13)
|
|
|
|
|
creBanksNames[21].erase(creBanksNames[21].begin());
|
|
|
|
|
readConfigLine(istr,21); //pyramid
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int CGObjectInstance::getOwner() const
|
|
|
|
@@ -5863,30 +5870,22 @@ void CBank::endBattle (const CGHeroInstance *h, const BattleResult *result) cons
|
|
|
|
|
|
|
|
|
|
void CGPyramid::initObj()
|
|
|
|
|
{
|
|
|
|
|
//would be nice to do that only once
|
|
|
|
|
if (!pyramidConfig.guards.size())
|
|
|
|
|
{
|
|
|
|
|
pyramidConfig.level = 1;
|
|
|
|
|
pyramidConfig.chance = 100;
|
|
|
|
|
pyramidConfig.upgradeChance = 0;
|
|
|
|
|
for (int i = 0; i < 2; ++i)
|
|
|
|
|
{
|
|
|
|
|
pyramidConfig.guards.push_back (std::pair <ui16, ui32>(116, 20));
|
|
|
|
|
pyramidConfig.guards.push_back (std::pair <ui16, ui32>(117, 10));
|
|
|
|
|
}
|
|
|
|
|
pyramidConfig.combatValue; //how hard are guards of this level
|
|
|
|
|
pyramidConfig.value; //overall value of given things
|
|
|
|
|
pyramidConfig.rewardDifficulty; //proportion of reward value to difficulty of guards; how profitable is this creature Bank config
|
|
|
|
|
pyramidConfig.easiest; //?!?
|
|
|
|
|
}
|
|
|
|
|
bc = &pyramidConfig;
|
|
|
|
|
std::vector<ui16> available;
|
|
|
|
|
cb->getAllowedSpells (available, 5);
|
|
|
|
|
if (available.size())
|
|
|
|
|
{
|
|
|
|
|
bc = VLC->objh->banksInfo[21].front(); //TODO: remove hardcoded value?
|
|
|
|
|
spell = (available[rand()%available.size()]);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tlog1 <<"No spells available for Pyramid! Object set to empty.\n";
|
|
|
|
|
}
|
|
|
|
|
setPropertyDer (17,ran()); //set guards at game start
|
|
|
|
|
}
|
|
|
|
|
const std::string & CGPyramid::getHoverText() const
|
|
|
|
|
{
|
|
|
|
|
hoverName = VLC->generaltexth->names[ID];
|
|
|
|
|
hoverName = VLC->objh->creBanksNames[21];
|
|
|
|
|
if (bc == NULL)
|
|
|
|
|
hoverName += " " + VLC->generaltexth->allTexts[352];
|
|
|
|
|
else
|
|
|
|
|