1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +02:00

Merge pull request #2123 from Warzyw647/rmg-split-enum-monster-strength

Refactor enums and add zone monster strength "none" in rmg
This commit is contained in:
DjWarmonger
2023-06-06 20:40:35 +02:00
committed by GitHub
8 changed files with 66 additions and 59 deletions

View File

@@ -449,8 +449,11 @@ 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(!zoneGuard && zone.monsterStrength == EMonsterStrength::ZONE_NONE)
return nullptr; //no guards inside this zone except for zone guards
int mapMonsterStrength = map.getMapGenOptions().getMonsterStrength();
int monsterStrength = (zoneGuard ? 0 : zone.zoneMonsterStrength) + mapMonsterStrength - 1; //array index from 0 to 4
int monsterStrength = (zoneGuard ? 0 : zone.monsterStrength - EMonsterStrength::ZONE_NORMAL) + mapMonsterStrength - 1; //array index from 0 to 4
static const std::array<int, 5> value1{2500, 1500, 1000, 500, 0};
static const std::array<int, 5> value2{7500, 7500, 7500, 5000, 5000};
static const std::array<float, 5> multiplier1{0.5, 0.75, 1.0, 1.5, 1.5};

View File

@@ -546,8 +546,8 @@ size_t TreasurePlacer::getMaxPrisons() const
}
bool TreasurePlacer::isGuardNeededForTreasure(int value)
{
return zone.getType() != ETemplateZoneType::WATER && value > minGuardedValue;
{// no guard in a zone with "monsters: none" and for small treasures; water zones cen get monster strength ZONE_NONE elsewhere if needed
return zone.monsterStrength != EMonsterStrength::ZONE_NONE && value > minGuardedValue;
}
std::vector<ObjectInfo*> TreasurePlacer::prepareTreasurePile(const CTreasureInfo& treasureInfo)
@@ -706,8 +706,7 @@ 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.monsterStrength == EMonsterStrength::ZONE_NONE ? 0 : zone.monsterStrength + 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];