소스 검색

Fixed behaviour with extreme treasure values.

DjWarmonger 11 년 전
부모
커밋
fed2821a94
2개의 변경된 파일38개의 추가작업 그리고 11개의 파일을 삭제
  1. 1 1
      config/rmg.json
  2. 37 10
      lib/rmg/CRmgTemplateZone.cpp

+ 1 - 1
config/rmg.json

@@ -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}
 								]
 			},

+ 37 - 10
lib/rmg/CRmgTemplateZone.cpp

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