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:
@@ -254,19 +254,23 @@ void TreasurePlacer::addAllPossibleObjects()
|
|||||||
if(!creature->AIValue || tierValues.empty()) //bug #2681
|
if(!creature->AIValue || tierValues.empty()) //bug #2681
|
||||||
return 0; //this box won't be generated
|
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() ?
|
int actualTier = creature->level > tierValues.size() ?
|
||||||
tierValues.size() - 1 :
|
tierValues.size() - 1 :
|
||||||
creature->level - 1;
|
creature->level - 1;
|
||||||
float creaturesAmount = (static_cast<float>(tierValues[actualTier])) / creature->AIValue;
|
float creaturesAmount = std::floor((static_cast<float>(tierValues[actualTier])) / creature->AIValue);
|
||||||
if(creaturesAmount <= 5)
|
if (creaturesAmount < 1)
|
||||||
{
|
{
|
||||||
creaturesAmount = boost::math::round(creaturesAmount); //allow single monsters
|
return 0;
|
||||||
if(creaturesAmount < 1)
|
}
|
||||||
return 0;
|
else if(creaturesAmount <= 5)
|
||||||
|
{
|
||||||
|
//No change
|
||||||
}
|
}
|
||||||
else if(creaturesAmount <= 12)
|
else if(creaturesAmount <= 12)
|
||||||
{
|
{
|
||||||
(creaturesAmount /= 2) *= 2;
|
creaturesAmount = std::ceil(creaturesAmount / 2) * 2;
|
||||||
}
|
}
|
||||||
else if(creaturesAmount <= 50)
|
else if(creaturesAmount <= 50)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user