Skip to content

Instantly share code, notes, and snippets.

@deephack1982
Created September 10, 2019 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deephack1982/181b2d5af142bda342ddd9b95955c3b0 to your computer and use it in GitHub Desktop.
Save deephack1982/181b2d5af142bda342ddd9b95955c3b0 to your computer and use it in GitHub Desktop.
int CalculateCost(CProvince& From, CProvince& To, CUnit& Unit)
{
float vCost = 100.0f * GetDistance(From.GetProvinceID(), To.GetProvinceID());
float vSpeed = Unit.GetMovementSpeed(To);
// Advancing into the front! 300% the normal cost.
if(Unit.IsLandUnit() && From.IsLand() && To.IsLand())
{
if( To.GetController() &&
To.GetController()->IsEnemy(Unit.GetCountry()->GetCountryID()) )
{
vCost = 3.0f;
}
}
// Units that are retreating have no fuel problems... Just for gameplay reasons.
if(Unit.HasFuelProblems() && Unit.IsRetreating() == false)
vCost *= 3.0f;
return int(vCost / vSpeed);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment