Fix movement cost problems in 100AP. Externalized the movement cost modifiers and changed the run modifier from a divisor to a flat modifier like other forms of movement use.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@2618 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
ChrisL
2009-03-09 23:14:43 +00:00
parent e3303e321c
commit 6be3de2149
6 changed files with 83 additions and 87 deletions
+51 -57
View File
@@ -1326,18 +1326,19 @@ INT16 AStarPathfinder::CalcAP(int const terrainCost, UINT8 const direction)
case RUNNING:
case ADULTMONSTER_WALKING:
// save on casting
movementAPCost = (INT16) (movementAPCost * 100 / ( (UINT8) (RUNDIVISOR * 100)));
//movementAPCost = (INT16) (movementAPCost * 100 / ( (UINT8) (RUNDIVISOR * 100)));
movementAPCost = (INT16) movementAPCost + APBPConstants[AP_MODIFIER_RUN];
//movementAPCost = (INT16)(DOUBLE)( (sTileCost / RUNDIVISOR) ); break;
break;
case WALKING:
case ROBOT_WALK:
movementAPCost = (movementAPCost + WALKCOST);
movementAPCost = (movementAPCost + APBPConstants[AP_MODIFIER_WALK]); //WALKCOST);
break;
case SWATTING:
movementAPCost = (movementAPCost + SWATCOST);
movementAPCost = (movementAPCost + APBPConstants[AP_MODIFIER_SWAT]); //SWATCOST);
break;
case CRAWLING:
movementAPCost = (movementAPCost + CRAWLCOST);
movementAPCost = (movementAPCost + APBPConstants[AP_MODIFIER_CRAWL]); //CRAWLCOST);
break;
}
@@ -3354,29 +3355,31 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT16 sDestination, INT8 ubLevel, INT16 usMo
case ADULTMONSTER_WALKING:
// save on casting
if((UsingNewInventorySystem() == true) && s->inv[BPACKPOCKPOS].exists() == true)
ubAPCost = ubAPCost * 10 / ( (UINT8) (RUNDIVISORBPACK * 10));
//ubAPCost = ubAPCost * 10 / ( (UINT8) (RUNDIVISORBPACK * 10));
ubAPCost = ubAPCost + APBPConstants[AP_MODIFIER_RUN] + APBPConstants[AP_MODIFIER_PACK];
else
ubAPCost = (UINT8)(ubAPCost * 10 / ( (UINT8) (RUNDIVISOR * 10)));
//ubAPCost = (UINT8)(ubAPCost * 10 / ( (UINT8) (RUNDIVISOR * 10)));
ubAPCost = (UINT8)ubAPCost + APBPConstants[AP_MODIFIER_RUN];
//ubAPCost = (INT16)(DOUBLE)( (sTileCost / RUNDIVISOR) ); break;
break;
case WALKING:
case ROBOT_WALK:
if((UsingNewInventorySystem() == true) && s->inv[BPACKPOCKPOS].exists() == true)
ubAPCost = (ubAPCost + WALKCOSTBPACK);
ubAPCost = (ubAPCost + APBPConstants[AP_MODIFIER_WALK] + APBPConstants[AP_MODIFIER_PACK]); //WALKCOSTBPACK);
else
ubAPCost = (ubAPCost + WALKCOST);
ubAPCost = (ubAPCost + APBPConstants[AP_MODIFIER_WALK]); //WALKCOST);
break;
case SWATTING:
if((UsingNewInventorySystem() == true) && s->inv[BPACKPOCKPOS].exists() == true)
ubAPCost = (ubAPCost + SWATCOSTBPACK);
ubAPCost = (ubAPCost + APBPConstants[AP_MODIFIER_SWAT] + APBPConstants[AP_MODIFIER_PACK]); //SWATCOSTBPACK);
else
ubAPCost = (ubAPCost + SWATCOST);
ubAPCost = (ubAPCost + APBPConstants[AP_MODIFIER_SWAT]); //SWATCOST);
break;
case CRAWLING:
if((UsingNewInventorySystem() == true) && s->inv[BPACKPOCKPOS].exists() == true)
ubAPCost = (ubAPCost + CRAWLCOSTBPACK);
ubAPCost = (ubAPCost + APBPConstants[AP_MODIFIER_CRAWL] + APBPConstants[AP_MODIFIER_PACK]); //CRAWLCOSTBPACK);
else
ubAPCost = (ubAPCost + CRAWLCOST);
ubAPCost = (ubAPCost + APBPConstants[AP_MODIFIER_CRAWL]); //CRAWLCOST);
break;
}
@@ -4297,39 +4300,34 @@ INT16 PlotPath( SOLDIERTYPE *pSold, INT16 sDestGridno, INT8 bCopyRoute, INT8 bPl
// so, then we must modify it for other movement styles and accumulate
// CHRISL: Force display path to calculate AP cost differently if we're wearing a backpack
switch( usMovementModeToUseForAPs )
{
case RUNNING:
if((UsingNewInventorySystem() == true) && pSold->inv[BPACKPOCKPOS].exists() == true)
sPoints += (INT16)(DOUBLE)( (sTileCost / RUNDIVISORBPACK) ) + sExtraCostStand;
else
sPoints += (INT16)(DOUBLE)( (sTileCost / RUNDIVISOR) ) + sExtraCostStand;
break;
case WALKING :
if((UsingNewInventorySystem() == true) && pSold->inv[BPACKPOCKPOS].exists() == true)
sPoints += (sTileCost + WALKCOSTBPACK) + sExtraCostStand;
else
sPoints += (sTileCost + WALKCOST) + sExtraCostStand;
break;
case SWATTING:
if((UsingNewInventorySystem() == true) && pSold->inv[BPACKPOCKPOS].exists() == true)
sPoints += (sTileCost + SWATCOSTBPACK) + sExtraCostSwat;
else
sPoints += (sTileCost + SWATCOST) + sExtraCostSwat;
break;
case CRAWLING:
if((UsingNewInventorySystem() == true) && pSold->inv[BPACKPOCKPOS].exists() == true)
sPoints += (sTileCost + CRAWLCOSTBPACK) + sExtraCostCrawl;
else
sPoints += (sTileCost + CRAWLCOST) + sExtraCostCrawl;
break;
default :
if((UsingNewInventorySystem() == true) && pSold->inv[BPACKPOCKPOS].exists() == true)
sPoints = sPoints + sTileCost;
else
sPoints = sPoints + sTileCost;
break;
}
switch( usMovementModeToUseForAPs )
{
case RUNNING:
sPoints += sTileCost + sExtraCostStand + APBPConstants[AP_MODIFIER_RUN];
if((UsingNewInventorySystem() == true) && pSold->inv[BPACKPOCKPOS].exists() == true)
sPoints += APBPConstants[AP_MODIFIER_PACK];
break;
case WALKING :
sPoints += sTileCost + sExtraCostStand + APBPConstants[AP_MODIFIER_WALK];
if((UsingNewInventorySystem() == true) && pSold->inv[BPACKPOCKPOS].exists() == true)
sPoints += APBPConstants[AP_MODIFIER_PACK];
break;
case SWATTING:
sPoints += sTileCost + sExtraCostStand + APBPConstants[AP_MODIFIER_SWAT];
if((UsingNewInventorySystem() == true) && pSold->inv[BPACKPOCKPOS].exists() == true)
sPoints += APBPConstants[AP_MODIFIER_PACK];
break;
case CRAWLING:
sPoints += sTileCost + sExtraCostStand + APBPConstants[AP_MODIFIER_CRAWL];
if((UsingNewInventorySystem() == true) && pSold->inv[BPACKPOCKPOS].exists() == true)
sPoints += APBPConstants[AP_MODIFIER_PACK];
break;
default :
sPoints += sPoints + sTileCost;
if((UsingNewInventorySystem() == true) && pSold->inv[BPACKPOCKPOS].exists() == true)
sPoints += APBPConstants[AP_MODIFIER_PACK];
break;
}
}
}
@@ -4341,28 +4339,24 @@ INT16 PlotPath( SOLDIERTYPE *pSold, INT16 sDestGridno, INT8 bCopyRoute, INT8 bPl
// CHRISL: Adjusted system to use different move costs while wearing a backpack
// store WALK cost
sPointsWalk += sTileCost + APBPConstants[AP_MODIFIER_WALK] + sExtraCostStand;
if((UsingNewInventorySystem() == true) && pSold->inv[BPACKPOCKPOS].exists() == true)
sPointsWalk += (sTileCost + WALKCOSTBPACK) + sExtraCostStand;
else
sPointsWalk += (sTileCost + WALKCOST) + sExtraCostStand;
sPointsWalk += APBPConstants[AP_MODIFIER_PACK];
// now get cost as if CRAWLING
sPointsCrawl += sTileCost + APBPConstants[AP_MODIFIER_CRAWL] + sExtraCostCrawl;
if((UsingNewInventorySystem() == true) && pSold->inv[BPACKPOCKPOS].exists() == true)
sPointsCrawl += (sTileCost + CRAWLCOSTBPACK) + sExtraCostCrawl;
else
sPointsCrawl += (sTileCost + CRAWLCOST) + sExtraCostCrawl;
sPointsCrawl += APBPConstants[AP_MODIFIER_PACK];
// now get cost as if SWATTING
sPointsSwat += sTileCost + APBPConstants[AP_MODIFIER_SWAT] + sExtraCostSwat;
if((UsingNewInventorySystem() == true) && pSold->inv[BPACKPOCKPOS].exists() == true)
sPointsSwat += (sTileCost + SWATCOSTBPACK) + sExtraCostSwat;
else
sPointsSwat += (sTileCost + SWATCOST) + sExtraCostSwat;
sPointsSwat += APBPConstants[AP_MODIFIER_PACK];
// now get cost as if RUNNING
sPointsRun += sTileCost + APBPConstants[AP_MODIFIER_RUN] + sExtraCostStand;
if((UsingNewInventorySystem() == true) && pSold->inv[BPACKPOCKPOS].exists() == true)
sPointsRun += (INT16)(DOUBLE)( (sTileCost / RUNDIVISORBPACK) ) + sExtraCostStand;
else
sPointsRun += (INT16)(DOUBLE)( (sTileCost / RUNDIVISOR) ) + sExtraCostStand;
sPointsRun += APBPConstants[AP_MODIFIER_PACK];
}
if ( iCnt == 0 && bPlot )