1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00

Don't remove zone guards in a zone with monsters: none, remove extra parentheses and add comments

This commit is contained in:
Warzyw647 2023-05-04 18:40:04 +02:00
parent 42d6cb4f8a
commit 05e72e2e7f
2 changed files with 5 additions and 6 deletions

View File

@ -409,8 +409,8 @@ CGCreature * ObjectManager::chooseGuard(si32 strength, bool zoneGuard)
//precalculate actual (randomized) monster strength based on this post
//http://forum.vcmi.eu/viewtopic.php?p=12426#12426
if(zone.zoneMonsterStrength == EMonsterStrength::ZONE_NONE)
return nullptr; //no guards in this zone
if(!zoneGuard && zone.zoneMonsterStrength == EMonsterStrength::ZONE_NONE)
return nullptr; //no guards inside this zone
int mapMonsterStrength = map.getMapGenOptions().getMonsterStrength();
int monsterStrength = (zoneGuard ? 0 : zone.zoneMonsterStrength) + mapMonsterStrength - 1; //array index from 0 to 4

View File

@ -527,8 +527,8 @@ size_t TreasurePlacer::getPossibleObjectsSize() const
}
bool TreasurePlacer::isGuardNeededForTreasure(int value)
{
return ((zone.zoneMonsterStrength != EMonsterStrength::ZONE_NONE) && (zone.getType() != ETemplateZoneType::WATER) && (value > minGuardedValue));
{// no guard in a zone with "monsters: none", in a water zone and for small treasures
return zone.zoneMonsterStrength != EMonsterStrength::ZONE_NONE && zone.getType() != ETemplateZoneType::WATER && value > minGuardedValue;
}
std::vector<ObjectInfo*> TreasurePlacer::prepareTreasurePile(const CTreasureInfo& treasureInfo)
@ -687,8 +687,7 @@ void TreasurePlacer::createTreasures(ObjectManager & manager)
const int maxAttempts = 2;
int mapMonsterStrength = map.getMapGenOptions().getMonsterStrength();
int monsterStrength = (zone.zoneMonsterStrength == EMonsterStrength::ZONE_NONE ? 0 : zone.zoneMonsterStrength + mapMonsterStrength - 1); //array index from 0 to 4
// pick any correct value for ZONE_NONE, minGuardedValue won't be used in this case anyway
int monsterStrength = (zone.zoneMonsterStrength == EMonsterStrength::ZONE_NONE ? 0 : zone.zoneMonsterStrength + mapMonsterStrength - 1); //array index from 0 to 4; pick any correct value for ZONE_NONE, minGuardedValue won't be used in this case anyway
static int minGuardedValues[] = { 6500, 4167, 3000, 1833, 1333 };
minGuardedValue = minGuardedValues[monsterStrength];