1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Pyramid fixes: #287, #403, #572, #575. It's config is now stored in bankconfig.txt

This commit is contained in:
DjWarmonger
2010-08-18 13:42:46 +00:00
parent 7e5b675cbf
commit 3f31f6d33d
6 changed files with 72 additions and 73 deletions

View File

@@ -85,3 +85,4 @@ Grotto 1 30% 3 Harpy 0 3 Beholder 3 Harpy 3 Beholder 200 20 1000 0 None 0 0
2 30% 4 Harpy 0 4 Beholder 4 Harpy 4 Beholder 300 25 1000 0 None 0 0 0 0 3000 20 150% 2 30% 4 Harpy 0 4 Beholder 4 Harpy 4 Beholder 300 25 1000 0 None 0 0 0 0 3000 20 150%
3 30% 5 Harpy 0 5 Beholder 5 Harpy 5 Beholder 400 30 1500 0 None 0 0 0 0 4000 20 200% 3 30% 5 Harpy 0 5 Beholder 5 Harpy 5 Beholder 400 30 1500 0 None 0 0 0 0 4000 20 200%
4 10% 6 Harpy 0 6 Beholder 6 Harpy 6 Beholder 500 35 2000 0 None 0 0 0 0 5000 20 250% 4 10% 6 Harpy 0 6 Beholder 6 Harpy 6 Beholder 500 35 2000 0 None 0 0 0 0 5000 20 250%
Pyramid 1 100% 20 Gold Golem 0% 10 Diamond Golem 20 Gold Golem 10 Diamond Golem 786 15000 19 100%

View File

@@ -46,7 +46,6 @@ extern CLodHandler * bitmaph;
extern boost::rand48 ran; extern boost::rand48 ran;
std::map <ui8, std::set <ui8> > CGKeys::playerKeyMap; std::map <ui8, std::set <ui8> > CGKeys::playerKeyMap;
std::map <si32, std::vector<si32> > CGMagi::eyelist; std::map <si32, std::vector<si32> > CGMagi::eyelist;
BankConfig CGPyramid::pyramidConfig;
ui8 CGObelisk::obeliskCount; //how many obelisks are on map ui8 CGObelisk::obeliskCount; //how many obelisks are on map
std::map<ui8, ui8> CGObelisk::visited; //map: team_id => how many obelisks has been visited 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 else //given creatures
bc.creatures.push_back(guardInfo); bc.creatures.push_back(guardInfo);
} }
void CObjectHandler::readConfigLine(std::ifstream &istr, int g)
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
{
banksInfo[g].push_back(new BankConfig); banksInfo[g].push_back(new BankConfig);
BankConfig &bc = *banksInfo[g].back(); BankConfig &bc = *banksInfo[g].back();
@@ -236,8 +176,75 @@ void CObjectHandler::loadObjects()
istr >> bc.rewardDifficulty; istr >> bc.rewardDifficulty;
istr >> buf; istr >> buf;
bc.easiest = atoi(buf.c_str()); 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 int CGObjectInstance::getOwner() const
@@ -5863,30 +5870,22 @@ void CBank::endBattle (const CGHeroInstance *h, const BattleResult *result) cons
void CGPyramid::initObj() 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; std::vector<ui16> available;
cb->getAllowedSpells (available, 5); cb->getAllowedSpells (available, 5);
if (available.size())
{
bc = VLC->objh->banksInfo[21].front(); //TODO: remove hardcoded value?
spell = (available[rand()%available.size()]); 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 const std::string & CGPyramid::getHoverText() const
{ {
hoverName = VLC->generaltexth->names[ID]; hoverName = VLC->objh->creBanksNames[21];
if (bc == NULL) if (bc == NULL)
hoverName += " " + VLC->generaltexth->allTexts[352]; hoverName += " " + VLC->generaltexth->allTexts[352];
else else

View File

@@ -1079,7 +1079,6 @@ class DLL_EXPORT CBank : public CArmedInstance
class DLL_EXPORT CGPyramid : public CBank class DLL_EXPORT CGPyramid : public CBank
{ {
public: public:
static BankConfig pyramidConfig;
ui16 spell; ui16 spell;
void initObj(); void initObj();
@@ -1247,6 +1246,7 @@ public:
std::vector<ui32> resVals; //default values of resources in gold std::vector<ui32> resVals; //default values of resources in gold
void loadObjects(); void loadObjects();
void readConfigLine(std::ifstream &istr, int g);
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> void serialize(Handler &h, const int version)
{ {

View File

@@ -342,7 +342,6 @@ struct DLL_EXPORT Mapa : public CMapHeader
h & CGTeleport::gates; h & CGTeleport::gates;
h & CGKeys::playerKeyMap; h & CGKeys::playerKeyMap;
h & CGMagi::eyelist; h & CGMagi::eyelist;
h & CGPyramid::pyramidConfig;
h & CGObelisk::obeliskCount & CGObelisk::visited; h & CGObelisk::obeliskCount & CGObelisk::visited;
h & CGTownInstance::merchantArtifacts; h & CGTownInstance::merchantArtifacts;

View File

@@ -625,15 +625,15 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance *hero1, const CGHer
if(battleResult.data->exp[1] && hero2) if(battleResult.data->exp[1] && hero2)
changePrimSkill(hero2->id,4,battleResult.data->exp[1]); changePrimSkill(hero2->id,4,battleResult.data->exp[1]);
if(battleEndCallback && *battleEndCallback) sendAndApply(&resultsApplied);
if(battleEndCallback && *battleEndCallback) //TODO: object interaction after level dialog is handled
{ {
(*battleEndCallback)(battleResult.data); (*battleEndCallback)(battleResult.data);
delete battleEndCallback; delete battleEndCallback;
battleEndCallback = 0; battleEndCallback = 0;
} }
sendAndApply(&resultsApplied);
// Necromancy if applicable. // Necromancy if applicable.
const CGHeroInstance *winnerHero = battleResult.data->winner != 0 ? hero2 : hero1; const CGHeroInstance *winnerHero = battleResult.data->winner != 0 ? hero2 : hero1;
const CGHeroInstance *loserHero = battleResult.data->winner != 0 ? hero1 : hero2; const CGHeroInstance *loserHero = battleResult.data->winner != 0 ? hero1 : hero2;