1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Seer Huts part 2.

This commit is contained in:
DjWarmonger 2015-02-28 22:37:04 +01:00
parent 607375a9bc
commit 4f1d96e5e8
3 changed files with 94 additions and 81 deletions

View File

@ -79,11 +79,10 @@ void CMapGenerator::initPrisonsRemaining()
void CMapGenerator::initQuestArtsRemaining()
{
questArtsRemaining = 0;
for (auto art : VLC->arth->artifacts)
{
if (art->aClass == CArtifact::ART_TREASURE && art->constituentOf.empty()) //don't use parts of combined artifacts
questArtsRemaining++;
questArtifacts.push_back(art->id);
}
}
@ -497,13 +496,14 @@ void CMapGenerator::decreasePrisonsRemaining()
prisonsRemaining = std::max (0, prisonsRemaining - 1);
}
int CMapGenerator::getQuestArtsRemaning() const
std::vector<ArtifactID> CMapGenerator::getQuestArtsRemaning() const
{
return questArtsRemaining;
return questArtifacts;
}
void CMapGenerator::decreaseQuestArtsRemaining()
void CMapGenerator::banQuestArt(ArtifactID id)
{
questArtsRemaining = std::max(0, questArtsRemaining - 1);
map->allowedArtifact[id] = false;
vstd::erase_if_present (questArtifacts, id);
}
void CMapGenerator::registerZone (TFaction faction)

View File

@ -80,8 +80,8 @@ public:
int getNextMonlithIndex();
int getPrisonsRemaning() const;
void decreasePrisonsRemaining();
int getQuestArtsRemaning() const;
void decreaseQuestArtsRemaining();
std::vector<ArtifactID> getQuestArtsRemaning() const;
void banQuestArt(ArtifactID id);
void registerZone (TFaction faction);
ui32 getZoneCount(TFaction faction);
@ -97,6 +97,7 @@ private:
int prisonsRemaining;
int questArtsRemaining;
int monolithIndex;
std::vector<ArtifactID> questArtifacts;
/// Generation methods
std::string getMapDescription() const;

View File

@ -2261,7 +2261,7 @@ void CRmgTemplateZone::addAllPossibleObjects (CMapGenerator* gen)
static const int genericSeerHuts = 8;
int seerHutsPerType = 0;
const int questArtsRemaining = gen->getQuestArtsRemaning();
const int questArtsRemaining = gen->getQuestArtsRemaning().size();
std::vector<CCreature *> creatures;
@ -2286,6 +2286,8 @@ void CRmgTemplateZone::addAllPossibleObjects (CMapGenerator* gen)
RandomGeneratorUtil::randomShuffle(creatures, gen->rand);
for (int loops = 0; loops < seerHutsPerType; loops++) //in case there are many arties available
{
for (int i = 0; i < std::min<int>(creatures.size(), questArtsRemaining - genericSeerHuts); i++)
{
auto creature = creatures[i];
@ -2294,8 +2296,8 @@ void CRmgTemplateZone::addAllPossibleObjects (CMapGenerator* gen)
if (!creaturesAmount)
continue;
//int randomAppearance = *RandomGeneratorUtil::nextItem(VLC->objtypeh->knownSubObjects(Obj::SEER_HUT), gen->rand); //FIXME: empty subids?
int randomAppearance = 0;
int randomAppearance = *RandomGeneratorUtil::nextItem(VLC->objtypeh->knownSubObjects(Obj::SEER_HUT), gen->rand);
oi.generateObject = [creature, creaturesAmount, randomAppearance, gen]() -> CGObjectInstance *
{
auto obj = new CGSeerHut();
@ -2304,16 +2306,26 @@ void CRmgTemplateZone::addAllPossibleObjects (CMapGenerator* gen)
obj->rewardType = CGSeerHut::CREATURE;
obj->rID = creature->idNumber;
obj->rVal = creaturesAmount;
gen->decreaseQuestArtsRemaining();
obj->quest->missionType = CQuest::MISSION_ART;
ArtifactID artid = *RandomGeneratorUtil::nextItem(gen->getQuestArtsRemaning(), gen->rand);
obj->quest->m5arts.push_back(artid);
gen->banQuestArt(artid);
obj->quest->lastDay = -1;
obj->quest->isCustomFirst = false;
obj->quest->isCustomNext = false;
obj->quest->isCustomComplete = false;
return obj;
//TODO: place required artifact in next zone
};
oi.setTemplate(Obj::PANDORAS_BOX, randomAppearance, terrainType);
oi.setTemplate(Obj::SEER_HUT, randomAppearance, terrainType);
oi.value = ((2 * (creature->AIValue) * creaturesAmount * (1 + (float)(gen->getZoneCount(creature->faction)) / gen->getTotalZoneCount())) - 4000) / 3;
oi.probability = 3;
possibleObjects.push_back(oi);
}
}
}
void ObjectInfo::setTemplate (si32 type, si32 subtype, ETerrainType terrainType)
{