|
@@ -46,6 +46,11 @@ void TreasurePlacer::setQuestArtZone(Zone * otherZone)
|
|
|
questArtZone = otherZone;
|
|
|
}
|
|
|
|
|
|
+void TreasurePlacer::addObjectToRandomPool(const ObjectInfo& oi)
|
|
|
+{
|
|
|
+ possibleObjects.push_back(oi);
|
|
|
+}
|
|
|
+
|
|
|
void TreasurePlacer::addAllPossibleObjects()
|
|
|
{
|
|
|
ObjectInfo oi;
|
|
@@ -59,6 +64,14 @@ void TreasurePlacer::addAllPossibleObjects()
|
|
|
auto handler = VLC->objtypeh->getHandlerFor(primaryID, secondaryID);
|
|
|
if(!handler->isStaticObject() && handler->getRMGInfo().value)
|
|
|
{
|
|
|
+ auto rmgInfo = handler->getRMGInfo();
|
|
|
+ if (rmgInfo.mapLimit)
|
|
|
+ {
|
|
|
+ //Skip objects with per-map limit here
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ //TODO: Also check if the object value is within zone max value
|
|
|
for(const auto & temp : handler->getTemplates())
|
|
|
{
|
|
|
if(temp->canBePlacedAt(zone.getTerrainType()))
|
|
@@ -67,15 +80,12 @@ void TreasurePlacer::addAllPossibleObjects()
|
|
|
{
|
|
|
return VLC->objtypeh->getHandlerFor(temp->id, temp->subid)->create(temp);
|
|
|
};
|
|
|
- auto rmgInfo = handler->getRMGInfo();
|
|
|
oi.value = rmgInfo.value;
|
|
|
oi.probability = rmgInfo.rarity;
|
|
|
oi.templ = temp;
|
|
|
oi.maxPerZone = rmgInfo.zoneLimit;
|
|
|
- vstd::amin(oi.maxPerZone, rmgInfo.mapLimit / numZones); //simple, but should distribute objects evenly on large maps
|
|
|
- possibleObjects.push_back(oi);
|
|
|
+ addObjectToRandomPool(oi);
|
|
|
|
|
|
- break; //Place only one template per zone
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -116,7 +126,7 @@ void TreasurePlacer::addAllPossibleObjects()
|
|
|
oi.value = generator.getConfig().prisonValues[i];
|
|
|
oi.probability = 30;
|
|
|
oi.maxPerZone = generator.getPrisonsRemaning() / 5; //probably not perfect, but we can't generate more prisons than hereos.
|
|
|
- possibleObjects.push_back(oi);
|
|
|
+ addObjectToRandomPool(oi);
|
|
|
}
|
|
|
|
|
|
//all following objects are unlimited
|
|
@@ -172,7 +182,7 @@ void TreasurePlacer::addAllPossibleObjects()
|
|
|
};
|
|
|
|
|
|
oi.templ = tmplate;
|
|
|
- possibleObjects.push_back(oi);
|
|
|
+ addObjectToRandomPool(oi);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -201,7 +211,7 @@ void TreasurePlacer::addAllPossibleObjects()
|
|
|
oi.setTemplate(Obj::SPELL_SCROLL, 0, zone.getTerrainType());
|
|
|
oi.value = generator.getConfig().scrollValues[i];
|
|
|
oi.probability = 30;
|
|
|
- possibleObjects.push_back(oi);
|
|
|
+ addObjectToRandomPool(oi);
|
|
|
}
|
|
|
|
|
|
//pandora box with gold
|
|
@@ -217,7 +227,7 @@ void TreasurePlacer::addAllPossibleObjects()
|
|
|
oi.setTemplate(Obj::PANDORAS_BOX, 0, zone.getTerrainType());
|
|
|
oi.value = i * generator.getConfig().pandoraMultiplierGold;
|
|
|
oi.probability = 5;
|
|
|
- possibleObjects.push_back(oi);
|
|
|
+ addObjectToRandomPool(oi);
|
|
|
}
|
|
|
|
|
|
//pandora box with experience
|
|
@@ -233,7 +243,7 @@ void TreasurePlacer::addAllPossibleObjects()
|
|
|
oi.setTemplate(Obj::PANDORAS_BOX, 0, zone.getTerrainType());
|
|
|
oi.value = i * generator.getConfig().pandoraMultiplierExperience;
|
|
|
oi.probability = 20;
|
|
|
- possibleObjects.push_back(oi);
|
|
|
+ addObjectToRandomPool(oi);
|
|
|
}
|
|
|
|
|
|
//pandora box with creatures
|
|
@@ -286,7 +296,7 @@ void TreasurePlacer::addAllPossibleObjects()
|
|
|
oi.setTemplate(Obj::PANDORAS_BOX, 0, zone.getTerrainType());
|
|
|
oi.value = static_cast<ui32>((2 * (creature->AIValue) * creaturesAmount * (1 + static_cast<float>(map.getZoneCount(creature->faction)) / map.getTotalZoneCount())) / 3);
|
|
|
oi.probability = 3;
|
|
|
- possibleObjects.push_back(oi);
|
|
|
+ addObjectToRandomPool(oi);
|
|
|
}
|
|
|
|
|
|
//Pandora with 12 spells of certain level
|
|
@@ -315,7 +325,7 @@ void TreasurePlacer::addAllPossibleObjects()
|
|
|
oi.setTemplate(Obj::PANDORAS_BOX, 0, zone.getTerrainType());
|
|
|
oi.value = (i + 1) * generator.getConfig().pandoraMultiplierSpells; //5000 - 15000
|
|
|
oi.probability = 2;
|
|
|
- possibleObjects.push_back(oi);
|
|
|
+ addObjectToRandomPool(oi);
|
|
|
}
|
|
|
|
|
|
//Pandora with 15 spells of certain school
|
|
@@ -344,7 +354,7 @@ void TreasurePlacer::addAllPossibleObjects()
|
|
|
oi.setTemplate(Obj::PANDORAS_BOX, 0, zone.getTerrainType());
|
|
|
oi.value = generator.getConfig().pandoraSpellSchool;
|
|
|
oi.probability = 2;
|
|
|
- possibleObjects.push_back(oi);
|
|
|
+ addObjectToRandomPool(oi);
|
|
|
}
|
|
|
|
|
|
// Pandora box with 60 random spells
|
|
@@ -372,7 +382,7 @@ void TreasurePlacer::addAllPossibleObjects()
|
|
|
oi.setTemplate(Obj::PANDORAS_BOX, 0, zone.getTerrainType());
|
|
|
oi.value = generator.getConfig().pandoraSpell60;
|
|
|
oi.probability = 2;
|
|
|
- possibleObjects.push_back(oi);
|
|
|
+ addObjectToRandomPool(oi);
|
|
|
|
|
|
//seer huts with creatures or generic rewards
|
|
|
|
|
@@ -438,14 +448,14 @@ void TreasurePlacer::addAllPossibleObjects()
|
|
|
generator.banQuestArt(artid);
|
|
|
|
|
|
|
|
|
- this->questArtZone->getModificator<TreasurePlacer>()->possibleObjects.push_back(generateArtInfo(artid));
|
|
|
+ this->questArtZone->getModificator<TreasurePlacer>()->addObjectToRandomPool(generateArtInfo(artid));
|
|
|
|
|
|
return obj;
|
|
|
};
|
|
|
oi.setTemplate(Obj::SEER_HUT, randomAppearance, zone.getTerrainType());
|
|
|
oi.value = static_cast<ui32>(((2 * (creature->AIValue) * creaturesAmount * (1 + static_cast<float>(map.getZoneCount(creature->faction)) / map.getTotalZoneCount())) - 4000) / 3);
|
|
|
oi.probability = 3;
|
|
|
- possibleObjects.push_back(oi);
|
|
|
+ addObjectToRandomPool(oi);
|
|
|
}
|
|
|
|
|
|
static int seerLevels = std::min(generator.getConfig().questValues.size(), generator.getConfig().questRewardValues.size());
|
|
@@ -474,12 +484,12 @@ void TreasurePlacer::addAllPossibleObjects()
|
|
|
|
|
|
generator.banQuestArt(artid);
|
|
|
|
|
|
- this->questArtZone->getModificator<TreasurePlacer>()->possibleObjects.push_back(generateArtInfo(artid));
|
|
|
+ this->questArtZone->getModificator<TreasurePlacer>()->addObjectToRandomPool(generateArtInfo(artid));
|
|
|
|
|
|
return obj;
|
|
|
};
|
|
|
|
|
|
- possibleObjects.push_back(oi);
|
|
|
+ addObjectToRandomPool(oi);
|
|
|
|
|
|
oi.generateObject = [i, randomAppearance, this, generateArtInfo]() -> CGObjectInstance *
|
|
|
{
|
|
@@ -497,16 +507,21 @@ void TreasurePlacer::addAllPossibleObjects()
|
|
|
|
|
|
generator.banQuestArt(artid);
|
|
|
|
|
|
- this->questArtZone->getModificator<TreasurePlacer>()->possibleObjects.push_back(generateArtInfo(artid));
|
|
|
+ this->questArtZone->getModificator<TreasurePlacer>()->addObjectToRandomPool(generateArtInfo(artid));
|
|
|
|
|
|
return obj;
|
|
|
};
|
|
|
|
|
|
- possibleObjects.push_back(oi);
|
|
|
+ addObjectToRandomPool(oi);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+size_t TreasurePlacer::getPossibleObjectsSize() const
|
|
|
+{
|
|
|
+ return possibleObjects.size();
|
|
|
+}
|
|
|
+
|
|
|
bool TreasurePlacer::isGuardNeededForTreasure(int value)
|
|
|
{
|
|
|
return zone.getType() != ETemplateZoneType::WATER && value > minGuardedValue;
|