- fixed incorrect AP and BP calculation for jumping over fences

- fixed incorrect stance handling for jumping over fences

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8635 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
silversurfer
2018-11-04 17:49:10 +00:00
parent 384572098b
commit 4021450369
6 changed files with 108 additions and 44 deletions
+2 -2
View File
@@ -55,8 +55,8 @@
#endif
CHAR8 czVersionNumber[16] = { "Build 18.03.11" }; //YY.MM.DD
CHAR8 czVersionNumber[16] = { "Build 18.04.11" }; //YY.MM.DD
CHAR16 zTrackingNumber[16] = { L"Z" };
CHAR16 zRevisionNumber[16] = { L"Revision 8634" };
CHAR16 zRevisionNumber[16] = { L"Revision 8635" };
// SAVE_GAME_VERSION is defined in header, change it there
+4 -2
View File
@@ -2091,7 +2091,7 @@ BOOLEAN HandleGotoNewGridNo( SOLDIERTYPE *pSoldier, BOOLEAN *pfKeepMoving, BOOLE
// CHRISL: Added penalty for jumping a fence while wearing a backpack
// Do we have APs?
// SANDRO - changed the static values to precise calculation here
if ((UsingNewInventorySystem() == true) && pSoldier->inv[BPACKPOCKPOS].exists() == true
/* if ((UsingNewInventorySystem() == true) && pSoldier->inv[BPACKPOCKPOS].exists() == true
//JMich.BackpackClimb
&& ((gGameExternalOptions.sBackpackWeightToClimb == -1) || (INT16)pSoldier->inv[BPACKPOCKPOS].GetWeightOfObjectInStack() + Item[pSoldier->inv[BPACKPOCKPOS].usItem].sBackpackWeightModifier > gGameExternalOptions.sBackpackWeightToClimb)
&& ((gGameExternalOptions.fUseGlobalBackpackSettings == TRUE) || (Item[pSoldier->inv[BPACKPOCKPOS].usItem].fAllowClimbing == FALSE)))
@@ -2104,8 +2104,10 @@ BOOLEAN HandleGotoNewGridNo( SOLDIERTYPE *pSoldier, BOOLEAN *pfKeepMoving, BOOLE
{
sAPCost = GetAPsToJumpFence( pSoldier, FALSE );
sBPCost = GetBPsToJumpFence( pSoldier, FALSE );
}
}*/
sAPCost = ActionPointCost( pSoldier, usNewGridNo, (INT8)pSoldier->pathing.usPathingData[ pSoldier->pathing.usPathIndex ], usAnimState );
sBPCost = TerrainBreathPoints( pSoldier, usNewGridNo, (INT8)pSoldier->pathing.usPathingData[ pSoldier->pathing.usPathIndex ], usAnimState );
if ( EnoughPoints( pSoldier, sAPCost, sBPCost, FALSE ) )
{
+21 -6
View File
@@ -3719,8 +3719,11 @@ if(!GridNoOnVisibleWorldTile(iDestination))
case CRAWLING:
// Add cost to stand up before jump and go prone after jump
ubAPCost += GetAPsCrouch(s, TRUE) + ( 2 * GetAPsProne(s, TRUE) );
// Can't do it here.....
goto NEXTDIR;
//goto NEXTDIR;
break;
}
}
else if (nextCost == TRAVELCOST_NOT_STANDING)
@@ -4598,20 +4601,28 @@ INT32 PlotPath( SOLDIERTYPE *pSold, INT32 sDestGridNo, INT8 bCopyRoute, INT8 bPl
case WALKING_DUAL_RDY:
case WALKING_ALTERNATIVE_RDY :
// Add here cost to go from crouch to stand AFTER fence hop....
// silversurfer: It doesn't matter if we continue moving after the jump. If we were standing before we will stand up again.
/* // Add here cost to go from crouch to stand AFTER fence hop....
// Since it's AFTER.. make sure we will be moving after jump...
if ( ( iCnt + 2 ) < iLastGrid )
{
sExtraCostStand += GetAPsCrouch(pSold, TRUE);
// ATE: if running, charge extra point to srart again
if ( usMovementModeToUseForAPs== RUNNING )
// ATE: if running, charge extra point to start again
if ( usMovementModeToUseForAPs == RUNNING )
{
sExtraCostStand++;
sExtraCostStand += GetAPsStartRun(pSold);
}
sPoints = sPoints + sExtraCostStand;
}*/
// Add cost to stand up after jump
sExtraCostStand += GetAPsCrouch(pSold, TRUE);
if ( ( iCnt + 2 ) < iLastGrid && usMovementModeToUseForAPs == RUNNING )
{
sExtraCostStand += GetAPsStartRun(pSold);
}
sPoints = sPoints + sExtraCostStand;
break;
case SWATTING:
@@ -4619,13 +4630,17 @@ INT32 PlotPath( SOLDIERTYPE *pSold, INT32 sDestGridNo, INT8 bCopyRoute, INT8 bPl
case CROUCHEDMOVE_PISTOL_READY:
case CROUCHEDMOVE_DUAL_READY:
// Add cost to stand once there BEFORE....
// Add cost to stand up once BEFORE....
sExtraCostSwat += GetAPsCrouch(pSold, TRUE);
sPoints = sPoints + sExtraCostSwat;
break;
case CRAWLING:
// Add cost to stand up before and go prone again after jumping
sExtraCostCrawl += GetAPsCrouch(pSold, TRUE) + ( 2 * GetAPsProne(pSold, TRUE) );
sPoints = sPoints + sExtraCostCrawl;
// Can't do it here.....
break;
+69 -13
View File
@@ -271,16 +271,24 @@ INT16 TerrainBreathPoints(SOLDIERTYPE * pSoldier, INT32 sGridNo, INT8 bDir, UINT
switch( ubMovementCost )
{
case TRAVELCOST_DIRTROAD :
case TRAVELCOST_FLAT : iPoints = APBPConstants[BP_MOVEMENT_FLAT]; break;
//case TRAVELCOST_BUMPY :
case TRAVELCOST_GRASS : iPoints = APBPConstants[BP_MOVEMENT_GRASS]; break;
case TRAVELCOST_THICK : iPoints = APBPConstants[BP_MOVEMENT_BUSH]; break;
case TRAVELCOST_FLAT : iPoints = APBPConstants[BP_MOVEMENT_FLAT]; break;
//case TRAVELCOST_BUMPY :
case TRAVELCOST_GRASS : iPoints = APBPConstants[BP_MOVEMENT_GRASS]; break;
case TRAVELCOST_THICK : iPoints = APBPConstants[BP_MOVEMENT_BUSH]; break;
case TRAVELCOST_DEBRIS : iPoints = APBPConstants[BP_MOVEMENT_RUBBLE]; break;
case TRAVELCOST_SHORE : iPoints = APBPConstants[BP_MOVEMENT_SHORE]; break; // wading shallow water
case TRAVELCOST_KNEEDEEP : iPoints = APBPConstants[BP_MOVEMENT_LAKE]; break; // wading waist/chest deep - very slow
case TRAVELCOST_SHORE : iPoints = APBPConstants[BP_MOVEMENT_SHORE]; break; // wading shallow water
case TRAVELCOST_KNEEDEEP : iPoints = APBPConstants[BP_MOVEMENT_LAKE]; break; // wading waist/chest deep - very slow
case TRAVELCOST_DEEPWATER : iPoints = APBPConstants[BP_MOVEMENT_OCEAN]; break; // can swim, so it's faster than wading
// case TRAVELCOST_VEINEND :
// case TRAVELCOST_VEINMID : iPoints = APBPConstants[BP_MOVEMENT_FLAT]; break;
case TRAVELCOST_FENCE :
if( FindBackpackOnSoldier( pSoldier ) != ITEM_NOT_FOUND )
iPoints = APBPConstants[BP_JUMPFENCEBPACK];
else
iPoints = APBPConstants[BP_JUMPFENCE];
break;
default:
if ( IS_TRAVELCOST_DOOR( ubMovementCost ) )
{
@@ -406,13 +414,13 @@ INT16 ActionPointCost( SOLDIERTYPE *pSoldier, INT32 sGridNo, INT8 bDir, UINT16 u
// Get switch value...
sSwitchValue = gubWorldMovementCosts[ sGridNo ][ bDir ][ pSoldier->pathing.bLevel ];
// Tile cost should not be reduced based on movement mode...
// silversurfer: modified handling below because we need to take stance change into account
/* // Tile cost should not be reduced based on movement mode...
if ( sSwitchValue == TRAVELCOST_FENCE )
{
return( sTileCost );
}
}*/
// WANNE.WATER: If our soldier is not on the ground level and the tile is a "water" tile, then simply set the tile to "FLAT_GROUND"
// This should fix "problems" for special modified maps
UINT8 ubTerrainID = gpWorldLevelData[ sGridNo ].ubTerrainID;
@@ -420,6 +428,45 @@ INT16 ActionPointCost( SOLDIERTYPE *pSoldier, INT32 sGridNo, INT8 bDir, UINT16 u
if ( TERRAIN_IS_WATER( ubTerrainID) && pSoldier->pathing.bLevel > 0 )
ubTerrainID = FLAT_GROUND;
// silversurfer: after we jump over a fence we end in crouched stance so we have to spend AP to get back to the original stance.
// Also we have to spend AP to get up before jumping.
if ( sSwitchValue == TRAVELCOST_FENCE )
{
switch( usMovementMode )
{
case RUNNING:
case WALKING:
case WALKING_WEAPON_RDY:
case WALKING_DUAL_RDY:
case WALKING_ALTERNATIVE_RDY:
// Add cost to stand up once after jump
sTileCost += GetAPsCrouch(pSoldier, TRUE);
break;
case SWATTING:
case START_SWAT:
case SWAT_BACKWARDS:
case SIDE_STEP_CROUCH_RIFLE:
case SIDE_STEP_CROUCH_PISTOL:
case SIDE_STEP_CROUCH_DUAL:
case CROUCHEDMOVE_RIFLE_READY:
case CROUCHEDMOVE_PISTOL_READY:
case CROUCHEDMOVE_DUAL_READY:
// Add cost to stand up once before jump
sTileCost += GetAPsCrouch(pSoldier, TRUE);
break;
case CRAWLING:
// Add cost twice to change stance
sTileCost += GetAPsCrouch(pSoldier, TRUE) + ( 2 * GetAPsProne(pSoldier, TRUE) );
break;
default:
break;
}
return( sTileCost );
}
// ATE - MAKE MOVEMENT ALWAYS WALK IF IN WATER
if ( TERRAIN_IS_WATER( ubTerrainID) )
@@ -639,11 +686,18 @@ INT16 EstimateActionPointCost( SOLDIERTYPE *pSoldier, INT32 sGridNo, INT8 bDir,
case WALKING_ALTERNATIVE_RDY :
case SIDE_STEP_ALTERNATIVE_RDY:
// Add here cost to go from crouch to stand AFTER fence hop....
// silversurfer: this is now done in function "ActionPointCost"
/* // Add here cost to go from crouch to stand AFTER fence hop....
// Since it's AFTER.. make sure we will be moving after jump...
if ( ( bPathIndex + 2 ) < bPathLength )
{
sPoints += GetAPsCrouch(pSoldier, TRUE); // SANDRO changed..
}*/
// if we were running we need to charge some APs to start running again
if ( ( bPathIndex + 2 ) < bPathLength && usMovementMode == RUNNING )
{
sPoints += GetAPsStartRun(pSoldier);
}
break;
@@ -657,8 +711,9 @@ INT16 EstimateActionPointCost( SOLDIERTYPE *pSoldier, INT32 sGridNo, INT8 bDir,
case CROUCHEDMOVE_PISTOL_READY:
case CROUCHEDMOVE_DUAL_READY:
// silversurfer: this is now done in function "ActionPointCost"
// Add cost to stand once there BEFORE....
sPoints += GetAPsCrouch(pSoldier, TRUE); // SANDRO changed..
// sPoints += GetAPsCrouch(pSoldier, TRUE); // SANDRO changed..
break;
case CRAWLING:
@@ -2739,7 +2794,7 @@ INT8 PtsToMoveDirection(SOLDIERTYPE *pSoldier, INT8 bDirection )
usMoveModeToUse = WALKING;
}
sCost = ActionPointCost( pSoldier, sGridNo, bDirection , usMoveModeToUse );
sCost = ActionPointCost( pSoldier, sGridNo, bDirection , usMoveModeToUse );
if ( gubWorldMovementCosts[ sGridNo ][ bDirection ][ pSoldier->pathing.bLevel ] != TRAVELCOST_FENCE )
{
@@ -2791,7 +2846,8 @@ INT8 MinAPsToStartMovement( SOLDIERTYPE * pSoldier, UINT16 usMovementMode )
}
else if (gAnimControl[ pSoldier->usAnimState ].ubEndHeight == ANIM_CROUCH)
{
bAPs += GetAPsCrouch(pSoldier, TRUE);
//bAPs += GetAPsCrouch(pSoldier, TRUE);
bAPs += GetAPsProne(pSoldier, TRUE);
}
break;
default:
+8 -18
View File
@@ -688,30 +688,20 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
return( TRUE );
}
// If we are at our final destination, goto stance of our movement stance...
// Only in realtime...
//if ( !( gTacticalStatus.uiFlags & INCOMBAT ) )
// This has to be here to make guys continue along fence path
#if 0
if ( pSoldier->sGridNo == pSoldier->pathing.sFinalDestination )
// take the correct stance
if ( gAnimControl[ pSoldier->usAnimState ].ubEndHeight != gAnimControl[ pSoldier->usUIMovementMode ].ubEndHeight )
{
if ( gAnimControl[ pSoldier->usAnimState ].ubEndHeight != gAnimControl[ pSoldier->usUIMovementMode ].ubEndHeight )
{
// Goto Stance...
pSoldier->flags.fDontChargeAPsForStanceChange = TRUE;
pSoldier->ChangeSoldierStance( gAnimControl[ pSoldier->usUIMovementMode ].ubEndHeight );
return( TRUE );
}
else
{
//pSoldier->SoldierGotoStationaryStance( );
// Goto Stance...
pSoldier->ChangeSoldierStance( gAnimControl[ pSoldier->usUIMovementMode ].ubEndHeight );
if ( pSoldier->sGridNo == pSoldier->pathing.sFinalDestination )
{
// Set UI Busy
UnSetUIBusy( pSoldier->ubID );
//return( TRUE );
}
return( TRUE );
}
#endif
break;
case 445:
+4 -3
View File
@@ -3906,10 +3906,11 @@ BOOLEAN SOLDIERTYPE::EVENT_InitNewSoldierAnim( UINT16 usNewState, UINT16 usStart
// ATE: If we are NOT waiting for prone down...
if ( this->flags.bTurningFromPronePosition < TURNING_FROM_PRONE_START_UP_FROM_MOVE && !this->flags.fDontChargeAPsForStanceChange )
{
// silversurfer: of course we deduct points for stance changes!
// ATE: Don't do this if we are still 'moving'....
// SANDRO - APBPConstants[AP_PRONE] changed to GetAPsProne()
if ( this->sGridNo == this->pathing.sFinalDestination || this->pathing.usPathIndex == 0 )
{
//if ( this->sGridNo == this->pathing.sFinalDestination || this->pathing.usPathIndex == 0 )
//{
// CHRISL
#if 0//dnl ch70 160913 this is wrong we cannot just add constants to sAPCost this must be done in GetAPsCrouch and GetAPsProne because all preactions calculation will show incorrect values under cursor
if ( (UsingNewInventorySystem( ) == true) && FindBackpackOnSoldier( this ) != ITEM_NOT_FOUND && !this->flags.ZipperFlag )
@@ -3951,7 +3952,7 @@ BOOLEAN SOLDIERTYPE::EVENT_InitNewSoldierAnim( UINT16 usNewState, UINT16 usStart
}
#endif
DeductPoints( this, sAPCost, sBPCost );
}
//}
}
this->flags.fDontChargeAPsForStanceChange = FALSE;
break;