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

Adding zoneMonserStrength: none

This commit is contained in:
Warzyw647 2023-05-03 12:07:00 +02:00
parent 3378a3c740
commit 8ebaa3fd6b
4 changed files with 9 additions and 4 deletions

View File

@ -380,6 +380,7 @@ void ZoneOptions::serializeJson(JsonSerializeFormat & handler)
//TODO: add support for std::map to serializeEnum
static const std::vector<std::string> STRENGTH =
{
"none",
"weak",
"normal",
"strong"

View File

@ -45,7 +45,8 @@ namespace EMonsterStrength
{
enum EMonsterStrength
{
RANDOM = -2,
RANDOM = -3,
ZONE_NONE = -2,
ZONE_WEAK = -1,
ZONE_NORMAL = 0,
ZONE_STRONG = 1,

View File

@ -409,6 +409,9 @@ 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
int mapMonsterStrength = map.getMapGenOptions().getMonsterStrength();
int monsterStrength = (zoneGuard ? 0 : zone.zoneMonsterStrength) + mapMonsterStrength - 1; //array index from 0 to 4
static const std::array<int, 5> value1{2500, 1500, 1000, 500, 0};

View File

@ -528,7 +528,7 @@ size_t TreasurePlacer::getPossibleObjectsSize() const
bool TreasurePlacer::isGuardNeededForTreasure(int value)
{
return zone.getType() != ETemplateZoneType::WATER && value > minGuardedValue;
return ((zone.zoneMonsterStrength != EMonsterStrength::ZONE_NONE) && (zone.getType() != ETemplateZoneType::WATER) && (value > minGuardedValue));
}
std::vector<ObjectInfo*> TreasurePlacer::prepareTreasurePile(const CTreasureInfo& treasureInfo)
@ -687,8 +687,8 @@ void TreasurePlacer::createTreasures(ObjectManager & manager)
const int maxAttempts = 2;
int mapMonsterStrength = map.getMapGenOptions().getMonsterStrength();
int monsterStrength = zone.zoneMonsterStrength + mapMonsterStrength - 1; //array index from 0 to 4
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];