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

Merge pull request #1904 from vcmi/fix_pandora_amounts

Fix pandora amounts
This commit is contained in:
Ivan Savenko
2023-04-11 11:10:05 +03:00
committed by GitHub

View File

@@ -254,19 +254,23 @@ void TreasurePlacer::addAllPossibleObjects()
if(!creature->AIValue || tierValues.empty()) //bug #2681
return 0; //this box won't be generated
//Follow the rules from https://heroes.thelazy.net/index.php/Pandora%27s_Box
int actualTier = creature->level > tierValues.size() ?
tierValues.size() - 1 :
creature->level - 1;
float creaturesAmount = (static_cast<float>(tierValues[actualTier])) / creature->AIValue;
if(creaturesAmount <= 5)
{
creaturesAmount = boost::math::round(creaturesAmount); //allow single monsters
float creaturesAmount = std::floor((static_cast<float>(tierValues[actualTier])) / creature->AIValue);
if (creaturesAmount < 1)
{
return 0;
}
else if(creaturesAmount <= 5)
{
//No change
}
else if(creaturesAmount <= 12)
{
(creaturesAmount /= 2) *= 2;
creaturesAmount = std::ceil(creaturesAmount / 2) * 2;
}
else if(creaturesAmount <= 50)
{