mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Templates can now use multiple configurations of treasure piles.
This commit is contained in:
parent
b3a39f4920
commit
81a64a8e67
@ -10,7 +10,10 @@
|
||||
{
|
||||
"type" : "playerStart", "size" : 1, "owner" : 1,
|
||||
"playerTowns" : { "castles" : 1 }, "neutralTowns" : { "towns" : 1 }, "townsAreSameType" : true,
|
||||
"treasure" : {"min" : 1500, "max": 3000}
|
||||
"treasure" : [
|
||||
{"min" : 2100, "max": 3000, "density" : 5},
|
||||
{"min" : 300, "max": 1500, "density" : 10}
|
||||
]
|
||||
},
|
||||
"2" :
|
||||
{
|
||||
@ -33,7 +36,10 @@
|
||||
"5" :
|
||||
{
|
||||
"type" : "treasure", "size" : 2, "terrainTypes" : [ "sand" ], "neutralTowns" : { "castles" : 1 },
|
||||
"treasure" : {"min" : 9000, "max": 10000}
|
||||
"treasure" : [
|
||||
{"min" : 9000, "max": 10000, "density" : 3},
|
||||
{"min" : 6000, "max": 10000, "density" : 15}
|
||||
]
|
||||
}
|
||||
},
|
||||
"connections" :
|
||||
@ -54,7 +60,10 @@
|
||||
{
|
||||
"type" : "playerStart", "size" : 1, "owner" : 1,
|
||||
"playerTowns" : { "castles" : 1 },
|
||||
"treasure" : {"min" : 500, "max": 2000}
|
||||
"treasure" : [
|
||||
{"min" : 400, "max": 1000, "density" : 16},
|
||||
{"min" : 1500, "max": 2500, "density" : 4}
|
||||
]
|
||||
},
|
||||
"2" :
|
||||
{
|
||||
@ -65,7 +74,10 @@
|
||||
"3" :
|
||||
{
|
||||
"type" : "treasure", "size" : 2, "neutralTowns" : { "towns" : 1 }, "townTypeLikeZone" : "1",
|
||||
"treasure" : {"min" : 2000, "max": 4000}
|
||||
"treasure" : [
|
||||
{"min" : 2000, "max": 4000, "density" : 15},
|
||||
{"min" : 4000, "max": 5000, "density" : 5}
|
||||
]
|
||||
},
|
||||
"4" :
|
||||
{
|
||||
@ -75,7 +87,10 @@
|
||||
"5" :
|
||||
{
|
||||
"type" : "treasure", "size" : 3, "neutralTowns" : { "castles" : 1 }, "terrainTypes" : [ "sand" ],
|
||||
"treasure" : {"min" : 11000, "max": 12000}
|
||||
"treasure" : [
|
||||
{"min" : 11000, "max": 12000, "density" : 5},
|
||||
{"min" : 6000, "max": 11000, "density" : 10}
|
||||
]
|
||||
}
|
||||
},
|
||||
"connections" :
|
||||
@ -98,7 +113,10 @@
|
||||
{
|
||||
"type" : "playerStart", "size" : 3, "owner" : 1,
|
||||
"playerTowns" : { "castles" : 1 },
|
||||
"treasure" : {"min" : 1000, "max": 2000}
|
||||
"treasure" : [
|
||||
{"min" : 300, "max": 2000, "density": 15},
|
||||
{"min" : 2100, "max": 2500, "density": 5}
|
||||
]
|
||||
},
|
||||
"2" :
|
||||
{
|
||||
@ -112,13 +130,19 @@
|
||||
"playerTowns" : { "castles" : 1 },
|
||||
"treasureLikeZone" : 1
|
||||
},
|
||||
"4" : { "type" : "treasure", "size" : 1, "terrainTypeLikeZone" : "1", "treasure" : {"min" : 3000, "max": 10000} },
|
||||
"4" : { "type" : "treasure", "size" : 1, "terrainTypeLikeZone" : "1", "treasure" : [
|
||||
{"min" : 3000, "max": 10000, "density" : 12},
|
||||
{"min" : 6000, "max": 10000, "density" : 6}
|
||||
]},
|
||||
"5" : { "type" : "treasure", "size" : 1, "terrainTypeLikeZone" : "1", "treasureLikeZone" : 4},
|
||||
"6" : { "type" : "treasure", "size" : 1, "terrainTypeLikeZone" : "2", "treasureLikeZone" : 4 },
|
||||
"7" : { "type" : "treasure", "size" : 1, "terrainTypeLikeZone" : "2", "treasureLikeZone" : 4 },
|
||||
"8" : { "type" : "treasure", "size" : 1, "terrainTypeLikeZone" : "3", "treasureLikeZone" : 4 },
|
||||
"9" : { "type" : "treasure", "size" : 1, "terrainTypeLikeZone" : "3", "treasureLikeZone" : 4 },
|
||||
"10" : { "type" : "treasure", "size" : 1, "neutralTowns" : { "towns" : 1 }, "treasure" : {"min" : 21000, "max": 25000} },
|
||||
"10" : { "type" : "treasure", "size" : 1, "neutralTowns" : { "towns" : 1 }, "treasure" : [
|
||||
{"min" : 21000, "max": 25000, "density" : 3},
|
||||
{"min" : 10000, "max": 21000, "density" : 10}
|
||||
]},
|
||||
"11" : { "type" : "treasure", "size" : 1, "neutralTowns" : { "towns" : 1 }, "treasureLikeZone" : 10 },
|
||||
"12" : { "type" : "treasure", "size" : 1, "neutralTowns" : { "towns" : 1 }, "treasureLikeZone" : 10 }
|
||||
},
|
||||
|
@ -68,13 +68,27 @@ void CJsonRmgTemplateLoader::loadTemplates()
|
||||
if (!zoneNode["treasure"].isNull())
|
||||
{
|
||||
//TODO: parse vector of different treasure settings
|
||||
auto treasureInfo = zoneNode["treasure"].Struct();
|
||||
if (zoneNode["treasure"].getType() == JsonNode::DATA_STRUCT)
|
||||
{
|
||||
CTreasureInfo ti;
|
||||
ti.min = treasureInfo["min"].Float();
|
||||
ti.max = treasureInfo["max"].Float();
|
||||
ti.density = 1; //TODO: use me
|
||||
zone->addTreasureInfo(ti);
|
||||
auto treasureInfo = zoneNode["treasure"].Struct();
|
||||
{
|
||||
CTreasureInfo ti;
|
||||
ti.min = treasureInfo["min"].Float();
|
||||
ti.max = treasureInfo["max"].Float();
|
||||
ti.density = treasureInfo["density"].Float(); //TODO: use me
|
||||
zone->addTreasureInfo(ti);
|
||||
}
|
||||
}
|
||||
else if (zoneNode["treasure"].getType() == JsonNode::DATA_VECTOR)
|
||||
{
|
||||
for (auto treasureInfo : zoneNode["treasure"].Vector())
|
||||
{
|
||||
CTreasureInfo ti;
|
||||
ti.min = treasureInfo["min"].Float();
|
||||
ti.max = treasureInfo["max"].Float();
|
||||
ti.density = treasureInfo["density"].Float();
|
||||
zone->addTreasureInfo(ti);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -471,11 +471,29 @@ bool CRmgTemplateZone::createTreasurePile (CMapGenerator* gen, int3 &pos)
|
||||
int maxValue = 5000;
|
||||
int minValue = 1500;
|
||||
|
||||
//TODO: choose random treasure info based on density
|
||||
if (treasureInfo.size())
|
||||
{
|
||||
maxValue = treasureInfo.front().max;
|
||||
minValue = treasureInfo.front().min;
|
||||
//roulette wheel
|
||||
std::vector<std::pair<ui16, CTreasureInfo>> tresholds;
|
||||
ui16 total = 0;
|
||||
//TODO: precalculate density chance for entire zone
|
||||
for (auto ti : treasureInfo)
|
||||
{
|
||||
total += ti.density;
|
||||
tresholds.push_back (std::make_pair (total, ti));
|
||||
}
|
||||
|
||||
int r = gen->rand.nextInt (1, total);
|
||||
|
||||
for (auto t : tresholds)
|
||||
{
|
||||
if (r <= t.first)
|
||||
{
|
||||
maxValue = t.second.max;
|
||||
minValue = t.second.min;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int currentValue = 0;
|
||||
@ -1094,37 +1112,37 @@ void CRmgTemplateZone::addAllPossibleObjects (CMapGenerator* gen)
|
||||
}
|
||||
|
||||
//non-removable object for test
|
||||
oi.generateObject = [gen]() -> CGObjectInstance *
|
||||
{
|
||||
auto obj = new CGMagicWell();
|
||||
obj->ID = Obj::MAGIC_WELL;
|
||||
obj->subID = 0;
|
||||
return obj;
|
||||
};
|
||||
oi.value = 250;
|
||||
oi.probability = 100;
|
||||
possibleObjects.push_back (oi);
|
||||
//oi.generateObject = [gen]() -> CGObjectInstance *
|
||||
//{
|
||||
// auto obj = new CGMagicWell();
|
||||
// obj->ID = Obj::MAGIC_WELL;
|
||||
// obj->subID = 0;
|
||||
// return obj;
|
||||
//};
|
||||
//oi.value = 250;
|
||||
//oi.probability = 100;
|
||||
//possibleObjects.push_back (oi);
|
||||
|
||||
oi.generateObject = [gen]() -> CGObjectInstance *
|
||||
{
|
||||
auto obj = new CGObelisk();
|
||||
obj->ID = Obj::OBELISK;
|
||||
obj->subID = 0;
|
||||
return obj;
|
||||
};
|
||||
oi.value = 3500;
|
||||
oi.probability = 200;
|
||||
possibleObjects.push_back (oi);
|
||||
//oi.generateObject = [gen]() -> CGObjectInstance *
|
||||
//{
|
||||
// auto obj = new CGObelisk();
|
||||
// obj->ID = Obj::OBELISK;
|
||||
// obj->subID = 0;
|
||||
// return obj;
|
||||
//};
|
||||
//oi.value = 3500;
|
||||
//oi.probability = 200;
|
||||
//possibleObjects.push_back (oi);
|
||||
|
||||
oi.generateObject = [gen]() -> CGObjectInstance *
|
||||
{
|
||||
auto obj = new CBank();
|
||||
obj->ID = Obj::CREATURE_BANK;
|
||||
obj->subID = 5; //naga bank
|
||||
return obj;
|
||||
};
|
||||
oi.value = 3000;
|
||||
oi.probability = 100;
|
||||
possibleObjects.push_back (oi);
|
||||
//oi.generateObject = [gen]() -> CGObjectInstance *
|
||||
//{
|
||||
// auto obj = new CBank();
|
||||
// obj->ID = Obj::CREATURE_BANK;
|
||||
// obj->subID = 5; //naga bank
|
||||
// return obj;
|
||||
//};
|
||||
//oi.value = 3000;
|
||||
//oi.probability = 100;
|
||||
//possibleObjects.push_back (oi);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user