浏览代码

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

Warzyw647 2 年之前
父节点
当前提交
05e72e2e7f
共有 2 个文件被更改,包括 5 次插入6 次删除
  1. 2 2
      lib/rmg/ObjectManager.cpp
  2. 3 4
      lib/rmg/TreasurePlacer.cpp

+ 2 - 2
lib/rmg/ObjectManager.cpp

@@ -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

+ 3 - 4
lib/rmg/TreasurePlacer.cpp

@@ -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];