Hello, I have been at this for a while and honestly I’m stumped.
I’m trying to script a RMS land map that has shallow ponds that units can walk on, but also have fish in it. I know that having shallow water with fish is possible because of the map Kerlauger having exactly that, but despite looking at its code I am having a hard time replicating it.
Fish and ponds do spawn exactly the way I want them if I use the ID of any river or ocean, but the second I swap over to a shallow ID it does not work. I have tried adjusting the height using rmAreaDefSetHeight(pondID, 0.0) to both raise sea levels and lower shallow water levels to no avail.
Here’s my code:
// Ponds.
int pondClassID = rmClassCreate();
int numPondsPerPlayer = 1 * getMapAreaSizeFactor();
if(gameIs1v1() == true)
{
numPondsPerPlayer = xsRandInt(1 * getMapAreaSizeFactor(), 2 * getMapAreaSizeFactor());
}
float minPondSize = rmTilesToAreaFraction(370);
float maxPondSize = rmTilesToAreaFraction(399);
int pondAvoidPond = rmCreateClassDistanceConstraint(pondClassID, 40.0);
int pondAvoidEdge = createSymmetricBoxConstraint(rmXMetersToFraction(16.0), rmZMetersToFraction(16.0));
int pondAvoidSettlement = rmCreateTypeDistanceConstraint(cUnitTypeSettlement, 40.0);
int pondAvoidStartingLoc = createPlayerLocDistanceConstraint(60.0);
for(int j = 0; j < numPondsPerPlayer; j++)
{
for(int i = 1; i <= cNumberPlayers; i++)
{
int p = vDefaultTeamPlayerOrder[i];
int pondID = rmAreaCreate("pond " + p + " " + j);
rmAreaSetParent(pondID, vTeamAreaIDs[rmGetPlayerTeam(p)]);
rmAreaSetSize(pondID, xsRandFloat(minPondSize, maxPondSize));
//If I swap to cWaterTundraRiver, fish appear! I assume it has to do with the depth.
rmAreaSetWaterType(pondID, cWaterTundraShallow);
rmAreaDefSetHeight(pondID, 0.0);
rmAreaSetBlobs(pondID, 1, 5);
rmAreaSetBlobDistance(pondID, 10.0, 10.0);
rmAreaSetWaterHeight(pondID, 0.0);
rmAreaSetWaterHeightBlend(pondID, cFilter5x5Gaussian, 25.0, 10);
rmAreaAddConstraint(pondID, pondAvoidPond);
rmAreaAddConstraint(pondID, pondAvoidEdge);
rmAreaAddConstraint(pondID, pondAvoidSettlement);
rmAreaAddConstraint(pondID, pondAvoidStartingLoc);
rmAreaAddConstraint(pondID, vDefaultAvoidKotH);
rmAreaAddToClass(pondID, pondClassID);
rmAreaBuild(pondID);
}
}
//Skip a bit of unecessary, unrelated code
float fishDistMeters = 25.0;
int fishID = rmObjectDefCreate("global fish");
rmObjectDefAddItem(fishID, cUnitTypeSalmon, 3, 5.0);
rmObjectDefAddConstraint(fishID, rmCreatePassabilityDistanceConstraint(cPassabilityLand, true, 2.0));
rmObjectDefAddConstraint(fishID, rmCreatePassabilityDistanceConstraint(cPassabilityWater, false, 1.0));
rmObjectDefAddConstraint(fishID, vDefaultAvoidEdge);
rmObjectDefAddConstraint(fishID, rmCreateTypeDistanceConstraint(cUnitTypeFishResource, fishDistMeters));
addObjectLocsPerPlayer(fishID, false, 1 * getMapAreaSizeFactor(), 20.0, -1.0, fishDistMeters, cBiasNone, cInAreaTeam);
generateLocs("fish locs");
Any help would be appreciated.
*The pond code is modified from Megalopolis’ ponds and the fish code is modified from Archipelago (with an added constraint from Kerlauger) in case you see any constraints that are not relevant to the current query.