1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Fixed behaviour with extreme treasure values.

This commit is contained in:
DjWarmonger 2014-06-07 22:27:36 +02:00
parent 81a64a8e67
commit fed2821a94
2 changed files with 38 additions and 11 deletions

View File

@ -61,7 +61,7 @@
"type" : "playerStart", "size" : 1, "owner" : 1,
"playerTowns" : { "castles" : 1 },
"treasure" : [
{"min" : 400, "max": 1000, "density" : 16},
{"min" : 400, "max": 1500, "density" : 16},
{"min" : 1500, "max": 2500, "density" : 4}
]
},

View File

@ -435,18 +435,28 @@ bool CRmgTemplateZone::addMonster(CMapGenerator* gen, int3 &pos, si32 strength)
CreatureID creId = CreatureID::NONE;
int amount = 0;
while (true)
std::vector<CreatureID> possibleCreatures;
for (auto cre : VLC->creh->creatures)
{
creId = VLC->creh->pickRandomMonster(gen->rand);
auto cre = VLC->creh->creatures[creId];
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->special)
continue;
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;
if (amount >= 4)
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();
guard->ID = Obj::MONSTER;
@ -947,12 +957,29 @@ ObjectInfo CRmgTemplateZone::getRandomObject (CMapGenerator* gen, ui32 value)
if (tresholds.empty())
{
ObjectInfo oi;
oi.generateObject = [gen]() -> CGObjectInstance *
if (minValue > 20000) //we don't have object valuable enough
{
return nullptr;
};
oi.value = 0;
oi.probability = 0;
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 *
{
return nullptr;
};
oi.value = 0;
oi.probability = 0;
}
return oi;
}
int r = gen->rand.nextInt (1, total);