• Our friends from AlphaCentauri2.info are in need of technical assistance. If you have experience with the LAMP stack and some hours to spare, please help them out and post here.

Caravan Range

alexb5dh

Chieftain
Joined
Apr 22, 2016
Messages
24
How does caravan range is calculated in Community Balance Patch?

I'm playing on YnAEMP Earth map (probably counted as Huge) and caravan tooltip displays its range as 12 tiles.
Take a look at the screenshot below.
Spoiler :

kMZxDi6.jpg


Shortest path from Carthage to Florence takes exactly 12 steps.
Hovewer, for some unknown reason, trade route Carthage-Florence can't be established:
Spoiler :

7DRmCrl.jpg


On the other hand, Hippo Regius is a bit futher from from Florence with corresponding trade route listed as available.
So what's going here?

The only thing I notice may be relevent is river adjacent to Hippo Regius.
But I can find any notes about rivers extending range of caravans neither, in CPP guide nor in vanilla Civ5 sources.
If a river is a cause here can anybody please provide info about such calculations?
 
I have noticed these oddities as well, I think terrain might affect the speed/range of the caravan or possibly just block it. I don't have anywhere near enough data to make a better assessment however.
 
trade routes follow a simplified version of the unit movement logic. roads and rivers tiles cost less than open terrain, rough terrain costs more, mountains are forbidden (except for inca).

so 12 tiles should more correctly be expressed as 12 "standard" tiles.
 
trade routes follow a simplified version of the unit movement logic. roads and rivers tiles cost less than open terrain, rough terrain costs more, mountains are forbidden (except for inca).

so 12 tiles should more correctly be expressed as 12 "standard" tiles.

Thanks for clarification. Exactly the answer I was looking for.
But I don't remember river tiles reducing movement cost. Does it apply to caravans only?

Also, do you know if this logic is implemented in lua or built into dll?
It would be nice to look at the algorithm.
 
Does this mean that making a road will improve traders range?

Roads have always improved caravan range, one of the reasons I build roads into my neighbors territory.

However I'm not sure if you need open borders to benefit from your neighbors roads, it would make sense and I think I've actually checked this, but I'm not sure.
 
Ok, think I found the function that handles this logic in CP enchanced dll:
Spoiler :

https://github.com/LoneGazebo/Commu...er/CvGameCoreDLL_Expansion2/CvAStar.cpp#L2558
Code:
int TradeRouteLandPathCost(const CvAStarNode* parent, const CvAStarNode* node, int, const SPathFinderUserData&, CvAStar* finder)
{
	CvMap& kMap = GC.getMap();
	int iFromPlotX = parent->m_iX;
	int iFromPlotY = parent->m_iY;
	CvPlot* pFromPlot = kMap.plotUnchecked(iFromPlotX, iFromPlotY);

	int iToPlotX = node->m_iX;
	int iToPlotY = node->m_iY;
	CvPlot* pToPlot = kMap.plotUnchecked(iToPlotX, iToPlotY);

	const TradePathCacheData* pCacheData = reinterpret_cast<const TradePathCacheData*>(finder->GetScratchBuffer());
	FeatureTypes eFeature = pToPlot->getFeatureType();

	int iCost = PATH_BASE_COST;

	// no route
	int iRouteFactor = 1;

	// super duper low costs for moving along routes - don't check for pillaging
	if (pFromPlot->getRouteType() != NO_ROUTE && pToPlot->getRouteType() != NO_ROUTE)
		iRouteFactor = 4;
	// low costs for moving along rivers
	else if (pFromPlot->isRiver() && pToPlot->isRiver() && !(pFromPlot->isRiverCrossing(directionXY(pFromPlot, pToPlot))))
		iRouteFactor = 2;
	// Iroquios ability
	else if ((eFeature == FEATURE_FOREST || eFeature == FEATURE_JUNGLE) && pCacheData->IsWoodlandMovementBonus())
		iRouteFactor = 2;

	// apply route discount
	iCost /= iRouteFactor;

	//try to avoid rough plots
	if (pToPlot->isRoughGround() && iRouteFactor==1)
		iCost += PATH_BASE_COST/2;

	//bonus for oasis
	if (eFeature == FEATURE_OASIS && iRouteFactor==1)
		iCost -= PATH_BASE_COST/4;
	
	// avoid enemy lands
	TeamTypes eToPlotTeam = pToPlot->getTeam();
	if (pCacheData->GetTeam()!=NO_TEAM && eToPlotTeam != NO_TEAM && GET_TEAM(pCacheData->GetTeam()).isAtWar(eToPlotTeam))
		iCost += PATH_BASE_COST*10;

	return iCost;
}


The following tile cost mapping should be true:

  1. road / railroad: 0.25
  2. river (not crossing): 0.5
  3. forest / jungle + Woodsman: 0.5
  4. hill / mountain (Inca): 1.5
  5. oasis: 0.75

Only the first of the matching conditions apply.
Any enemy tile makes it ×10 which makes it nearly impossible to create a route through enemy territory :D
 
Back
Top Bottom