Created
September 10, 2019 08:10
-
-
Save deephack1982/181b2d5af142bda342ddd9b95955c3b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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