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
+5
View File
@@ -868,6 +868,11 @@ void LoadGameAPBPConstants()
APBPConstants[AP_MOVEMENT_SHORE] = DynamicAdjustAPConstants(iniReader.ReadInteger("APConstants","AP_MOVEMENT_SHORE",28),28);
APBPConstants[AP_MOVEMENT_LAKE] = DynamicAdjustAPConstants(iniReader.ReadInteger("APConstants","AP_MOVEMENT_LAKE",36),36);
APBPConstants[AP_MOVEMENT_OCEAN] = DynamicAdjustAPConstants(iniReader.ReadInteger("APConstants","AP_MOVEMENT_OCEAN",32),32);
APBPConstants[AP_MODIFIER_RUN] = DynamicAdjustAPConstants(iniReader.ReadInteger("APConstants","AP_MODIFIER_RUN",-8),-8);
APBPConstants[AP_MODIFIER_WALK] = DynamicAdjustAPConstants(iniReader.ReadInteger("APConstants","AP_MODIFIER_WALK",-4),-4);
APBPConstants[AP_MODIFIER_SWAT] = DynamicAdjustAPConstants(iniReader.ReadInteger("APConstants","AP_MODIFIER_SWAT",0),0);
APBPConstants[AP_MODIFIER_CRAWL] = DynamicAdjustAPConstants(iniReader.ReadInteger("APConstants","AP_MODIFIER_CRAWL",4),4);
APBPConstants[AP_MODIFIER_PACK] = DynamicAdjustAPConstants(iniReader.ReadInteger("APConstants","AP_MODIFIER_PACK",4),4);
APBPConstants[AP_CHANGE_FACING] = DynamicAdjustAPConstants(iniReader.ReadInteger("APConstants","AP_CHANGE_FACING",4),4);
APBPConstants[AP_CHANGE_TARGET] = DynamicAdjustAPConstants(iniReader.ReadInteger("APConstants","AP_CHANGE_TARGET",2),2);
APBPConstants[AP_TOSS_ITEM] = DynamicAdjustAPConstants(iniReader.ReadInteger("APConstants","AP_TOSS_ITEM",32),32);
+5
View File
@@ -32,6 +32,11 @@ AP_MOVEMENT_RUBBLE,
AP_MOVEMENT_SHORE,
AP_MOVEMENT_LAKE,
AP_MOVEMENT_OCEAN,
AP_MODIFIER_RUN,
AP_MODIFIER_WALK,
AP_MODIFIER_SWAT,
AP_MODIFIER_CRAWL,
AP_MODIFIER_PACK,
AP_CHANGE_FACING,
AP_CHANGE_TARGET,
AP_TOSS_ITEM,
+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 )
+16 -24
View File
@@ -336,10 +336,9 @@ INT16 ActionPointCost( SOLDIERTYPE *pSoldier, INT16 sGridNo, INT8 bDir, UINT16 u
case ADULTMONSTER_WALKING:
case BLOODCAT_RUN:
// CHRISL
sPoints = sTileCost + APBPConstants[AP_MODIFIER_RUN];
if((UsingNewInventorySystem() == true) && pSoldier->inv[BPACKPOCKPOS].exists() == true)
sPoints = (INT16)(DOUBLE)( (sTileCost / RUNDIVISORBPACK) );
else
sPoints = (INT16)(DOUBLE)( (sTileCost / RUNDIVISOR) );
sPoints += APBPConstants[AP_MODIFIER_PACK];
break;
case CROW_FLY:
@@ -351,26 +350,23 @@ INT16 ActionPointCost( SOLDIERTYPE *pSoldier, INT16 sGridNo, INT8 bDir, UINT16 u
case LARVAE_WALK:
case WALKING :
// CHRISL
sPoints = sTileCost + APBPConstants[AP_MODIFIER_WALK];
if((UsingNewInventorySystem() == true) && pSoldier->inv[BPACKPOCKPOS].exists() == true)
sPoints = (sTileCost + WALKCOSTBPACK);
else
sPoints = (sTileCost + WALKCOST);
sPoints += APBPConstants[AP_MODIFIER_PACK];
break;
case START_SWAT:
case SWAT_BACKWARDS:
// CHRISL
case SWATTING:
sPoints = sTileCost + APBPConstants[AP_MODIFIER_SWAT];
if((UsingNewInventorySystem() == true) && pSoldier->inv[BPACKPOCKPOS].exists() == true)
sPoints = (sTileCost + SWATCOSTBPACK);
else
sPoints = (sTileCost + SWATCOST);
sPoints += APBPConstants[AP_MODIFIER_PACK];
break;
case CRAWLING:
sPoints = sTileCost + APBPConstants[AP_MODIFIER_CRAWL];
if((UsingNewInventorySystem() == true) && pSoldier->inv[BPACKPOCKPOS].exists() == true)
sPoints = (sTileCost + CRAWLCOSTBPACK);
else
sPoints = (sTileCost + CRAWLCOST);
sPoints += APBPConstants[AP_MODIFIER_PACK];
break;
default:
@@ -426,10 +422,9 @@ INT16 EstimateActionPointCost( SOLDIERTYPE *pSoldier, INT16 sGridNo, INT8 bDir,
case ADULTMONSTER_WALKING:
case BLOODCAT_RUN:
// CHRISL
sPoints = sTileCost + APBPConstants[AP_MODIFIER_RUN];
if((UsingNewInventorySystem() == true) && pSoldier->inv[BPACKPOCKPOS].exists() == true)
sPoints = (INT16)(DOUBLE)( (sTileCost / RUNDIVISORBPACK) );
else
sPoints = (INT16)(DOUBLE)( (sTileCost / RUNDIVISOR) );
sPoints += APBPConstants[AP_MODIFIER_PACK];
break;
case CROW_FLY:
@@ -441,26 +436,23 @@ INT16 EstimateActionPointCost( SOLDIERTYPE *pSoldier, INT16 sGridNo, INT8 bDir,
case LARVAE_WALK:
// CHRISL
case WALKING :
sPoints = sTileCost + APBPConstants[AP_MODIFIER_WALK];
if((UsingNewInventorySystem() == true) && pSoldier->inv[BPACKPOCKPOS].exists() == true)
sPoints = (sTileCost + WALKCOSTBPACK);
else
sPoints = (sTileCost + WALKCOST);
sPoints += APBPConstants[AP_MODIFIER_PACK];
break;
case START_SWAT:
case SWAT_BACKWARDS:
// CHRISL
case SWATTING:
sPoints = sTileCost + APBPConstants[AP_MODIFIER_SWAT];
if((UsingNewInventorySystem() == true) && pSoldier->inv[BPACKPOCKPOS].exists() == true)
sPoints = (sTileCost + SWATCOSTBPACK);
else
sPoints = (sTileCost + SWATCOST);
sPoints += APBPConstants[AP_MODIFIER_PACK];
break;
case CRAWLING:
sPoints = sTileCost + APBPConstants[AP_MODIFIER_CRAWL];
if((UsingNewInventorySystem() == true) && pSoldier->inv[BPACKPOCKPOS].exists() == true)
sPoints = (sTileCost + CRAWLCOSTBPACK);
else
sPoints = (sTileCost + CRAWLCOST);
sPoints += APBPConstants[AP_MODIFIER_PACK];
break;
default:
+4 -4
View File
@@ -1459,13 +1459,13 @@ INT16 EstimatePathCostToLocation( SOLDIERTYPE * pSoldier, INT16 sDestGridNo, INT
// add in cost of later climbing up, too
sPathCost += APBPConstants[AP_CLIMBOFFROOF] + APBPConstants[AP_CLIMBROOF];
// add in an estimate of getting there after climbing down
sPathCost += (APBPConstants[AP_MOVEMENT_FLAT] + WALKCOST) * PythSpacesAway( sClimbGridNo, sDestGridNo );
sPathCost += (APBPConstants[AP_MOVEMENT_FLAT] + APBPConstants[AP_MODIFIER_WALK]) * PythSpacesAway( sClimbGridNo, sDestGridNo );
}
else
{
sPathCost += APBPConstants[AP_CLIMBOFFROOF];
// add in an estimate of getting there after climbing down, *but not on top of roof*
sPathCost += (APBPConstants[AP_MOVEMENT_FLAT] + WALKCOST) * PythSpacesAway( sClimbGridNo, sDestGridNo ) / 2;
sPathCost += (APBPConstants[AP_MOVEMENT_FLAT] + APBPConstants[AP_MODIFIER_WALK]) * PythSpacesAway( sClimbGridNo, sDestGridNo ) / 2;
}
*pfClimbingNecessary = TRUE;
*psClimbGridNo = sClimbGridNo;
@@ -1505,7 +1505,7 @@ INT16 EstimatePathCostToLocation( SOLDIERTYPE * pSoldier, INT16 sDestGridNo, INT
{
// add to path a rough estimate of how far to go from the climb gridno to the friend
// estimate walk cost
sPathCost += (APBPConstants[AP_MOVEMENT_FLAT] + WALKCOST) * PythSpacesAway( sClimbGridNo, sDestGridNo );
sPathCost += (APBPConstants[AP_MOVEMENT_FLAT] + APBPConstants[AP_MODIFIER_WALK]) * PythSpacesAway( sClimbGridNo, sDestGridNo );
}
}
else
@@ -1514,7 +1514,7 @@ INT16 EstimatePathCostToLocation( SOLDIERTYPE * pSoldier, INT16 sDestGridNo, INT
sPathCost += APBPConstants[AP_CLIMBOFFROOF];
// add to path a rough estimate of how far to go from the climb gridno to the friend
// estimate walk cost
sPathCost += (APBPConstants[AP_MOVEMENT_FLAT] + WALKCOST) * PythSpacesAway( sClimbGridNo, sDestGridNo );
sPathCost += (APBPConstants[AP_MOVEMENT_FLAT] + APBPConstants[AP_MODIFIER_WALK]) * PythSpacesAway( sClimbGridNo, sDestGridNo );
}
*pfClimbingNecessary = TRUE;
*psClimbGridNo = sClimbGridNo;
+2 -2
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Version="8.00"
Name="ja2_2005Express"
ProjectGUID="{F44669E7-74AC-444B-B75F-F16F4B9F0265}"
RootNamespace="ja2_2005Express"
@@ -17,7 +17,7 @@
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="C:\games\jagged alliance 2 EN"
OutputDirectory="\games\jagged alliance 2"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets=".\ja2_2005Express.vsprops;.\ja2_2005ExpressDebug.vsprops"