mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-03 13:01:33 +02:00
Fix Pandora Box creature amounts to match OH3 exactly.
This commit is contained in:
parent
1e18887c9c
commit
f1c52f501d
@ -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)
|
||||
float creaturesAmount = std::floor((static_cast<float>(tierValues[actualTier])) / creature->AIValue);
|
||||
if (creaturesAmount < 1)
|
||||
{
|
||||
creaturesAmount = boost::math::round(creaturesAmount); //allow single monsters
|
||||
if(creaturesAmount < 1)
|
||||
return 0;
|
||||
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)
|
||||
{
|
||||
@ -556,6 +560,7 @@ std::vector<ObjectInfo*> TreasurePlacer::prepareTreasurePile(const CTreasureInfo
|
||||
//remove from possible objects
|
||||
assert(oi->maxPerZone);
|
||||
oi->maxPerZone--;
|
||||
//FIXME: restore the counter if teh object is not placed successfuly?
|
||||
|
||||
currentValue += oi->value;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user