mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +02:00
Fixed behaviour with extreme treasure values.
This commit is contained in:
@ -61,7 +61,7 @@
|
|||||||
"type" : "playerStart", "size" : 1, "owner" : 1,
|
"type" : "playerStart", "size" : 1, "owner" : 1,
|
||||||
"playerTowns" : { "castles" : 1 },
|
"playerTowns" : { "castles" : 1 },
|
||||||
"treasure" : [
|
"treasure" : [
|
||||||
{"min" : 400, "max": 1000, "density" : 16},
|
{"min" : 400, "max": 1500, "density" : 16},
|
||||||
{"min" : 1500, "max": 2500, "density" : 4}
|
{"min" : 1500, "max": 2500, "density" : 4}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -435,18 +435,28 @@ bool CRmgTemplateZone::addMonster(CMapGenerator* gen, int3 &pos, si32 strength)
|
|||||||
|
|
||||||
CreatureID creId = CreatureID::NONE;
|
CreatureID creId = CreatureID::NONE;
|
||||||
int amount = 0;
|
int amount = 0;
|
||||||
while (true)
|
std::vector<CreatureID> possibleCreatures;
|
||||||
|
for (auto cre : VLC->creh->creatures)
|
||||||
{
|
{
|
||||||
creId = VLC->creh->pickRandomMonster(gen->rand);
|
if (cre->special)
|
||||||
auto cre = VLC->creh->creatures[creId];
|
continue;
|
||||||
if ((cre->AIValue * (cre->ammMin + cre->ammMax) / 2 < strength) && (strength < cre->AIValue * 100)) //at leats one full monster. size between minimum size of given stack and 100
|
if ((cre->AIValue * (cre->ammMin + cre->ammMax) / 2 < strength) && (strength < cre->AIValue * 100)) //at least one full monster. size between minimum size of given stack and 100
|
||||||
{
|
{
|
||||||
amount = strength / cre->AIValue;
|
amount = strength / cre->AIValue;
|
||||||
if (amount >= 4)
|
if (amount >= 4)
|
||||||
amount *= gen->rand.nextDouble(0.75, 1.25);
|
amount *= gen->rand.nextDouble(0.75, 1.25);
|
||||||
break;
|
|
||||||
|
possibleCreatures.push_back(cre->idNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (possibleCreatures.size())
|
||||||
|
creId = *RandomGeneratorUtil::nextItem(possibleCreatures, gen->rand);
|
||||||
|
else //just pick any available creature
|
||||||
|
{
|
||||||
|
creId = CreatureID(132); //Azure Dragon
|
||||||
|
amount = strength / VLC->creh->creatures[creId]->AIValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
auto guard = new CGCreature();
|
auto guard = new CGCreature();
|
||||||
guard->ID = Obj::MONSTER;
|
guard->ID = Obj::MONSTER;
|
||||||
@ -947,6 +957,21 @@ ObjectInfo CRmgTemplateZone::getRandomObject (CMapGenerator* gen, ui32 value)
|
|||||||
if (tresholds.empty())
|
if (tresholds.empty())
|
||||||
{
|
{
|
||||||
ObjectInfo oi;
|
ObjectInfo oi;
|
||||||
|
if (minValue > 20000) //we don't have object valuable enough
|
||||||
|
{
|
||||||
|
oi.generateObject = [minValue]() -> CGObjectInstance *
|
||||||
|
{
|
||||||
|
auto obj = new CGPandoraBox();
|
||||||
|
obj->ID = Obj::PANDORAS_BOX;
|
||||||
|
obj->subID = 0;
|
||||||
|
obj->resources[Res::GOLD] = minValue;
|
||||||
|
return obj;
|
||||||
|
};
|
||||||
|
oi.value = minValue;
|
||||||
|
oi.probability = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
oi.generateObject = [gen]() -> CGObjectInstance *
|
oi.generateObject = [gen]() -> CGObjectInstance *
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -954,6 +979,8 @@ ObjectInfo CRmgTemplateZone::getRandomObject (CMapGenerator* gen, ui32 value)
|
|||||||
oi.value = 0;
|
oi.value = 0;
|
||||||
oi.probability = 0;
|
oi.probability = 0;
|
||||||
}
|
}
|
||||||
|
return oi;
|
||||||
|
}
|
||||||
|
|
||||||
int r = gen->rand.nextInt (1, total);
|
int r = gen->rand.nextInt (1, total);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user