Fixed problems with enemy rooftop climbing (by sevenfm)

- Also updated "Water", "DeepWater" and "WaterTooDeepForAttacks" methods: Added bLevel parameter (by sevenfm)
- see: http://thepit.ja-galaxy-forum.com/index.php?t=msg&th=22966&start=0&

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8110 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Wanne
2016-03-15 12:40:54 +00:00
parent 5bc2bae07e
commit 23d4051473
12 changed files with 118 additions and 154 deletions
+8 -69
View File
@@ -663,72 +663,8 @@ INT32 FindClosestClimbPoint( SOLDIERTYPE *pSoldier, INT32 sStartGridNo, INT32 sD
{
return( NOWHERE );
}
// WANNE: This code is from Overhauls A* climbing building, but also works here.
/*
INT32 sTestGridNo;
UINT8 ubTestDir;
INT32 sGridNo;
for (sGridNo = 0; sGridNo < WORLD_MAX; sGridNo++)
{
if (gubBuildingInfo[ sGridNo ] == gubBuildingInfo[ sDesiredGridNo ]) //&&
//gpWorldLevelData[ sGridNo ].ubExtFlags[1] & MAPELEMENT_EXT_CLIMBPOINT)
{
// Found a climb point for this building
if (fClimbUp)
{
for (ubTestDir = 0; ubTestDir < 8; ubTestDir += 2)
{
sTestGridNo = NewGridNo( sGridNo, DirectionInc( ubTestDir));
//if (gpWorldLevelData[ sTestGridNo ].ubExtFlags[0] & MAPELEMENT_EXT_CLIMBPOINT)
{
// Found a matching climb point
if ( (WhoIsThere2( sTestGridNo, 0 ) == NOBODY || sTestGridNo == pSoldier->sGridNo)
&& (WhoIsThere2( sGridNo, 1 ) == NOBODY) &&
(!pSoldier || !InGas( pSoldier, sTestGridNo ) ) )
{
// And it's open
sDistance = PythSpacesAway( sStartGridNo, sTestGridNo );
if (sDistance < sClosestDistance )
{
sClosestDistance = sDistance;
sClosestSpot = sTestGridNo;
}
}
}
}
}
else
{
for (ubTestDir = 0; ubTestDir < 8; ubTestDir += 2)
{
sTestGridNo = NewGridNo( sGridNo, DirectionInc( ubTestDir));
//if (gpWorldLevelData[ sTestGridNo ].ubExtFlags[0] & MAPELEMENT_EXT_CLIMBPOINT)
{
// Found a matching climb point
if ( (WhoIsThere2( sTestGridNo, 0 ) == NOBODY) &&
(WhoIsThere2( sGridNo, 1 ) == NOBODY || sGridNo == pSoldier->sGridNo) &&
(!pSoldier || !InGas( pSoldier, sTestGridNo ) ) )
{
// And it's open
sDistance = PythSpacesAway( sStartGridNo, sGridNo );
if (sDistance < sClosestDistance )
{
sClosestDistance = sDistance;
sClosestSpot = sGridNo;
}
}
}
}
}
}
}
return( sClosestSpot );
*/
// WANNE: This code is from "vanilla" climbing
// WANNE: Reworked climbing code from sevenfm
UINT8 ubNumClimbSpots;
INT32 * psClimbSpots;
UINT8 ubLoop;
@@ -746,9 +682,12 @@ INT32 FindClosestClimbPoint( SOLDIERTYPE *pSoldier, INT32 sStartGridNo, INT32 sD
for ( ubLoop = 0; ubLoop < ubNumClimbSpots; ubLoop++ )
{
if ( (WhoIsThere2( pBuilding->sUpClimbSpots[ ubLoop ], 0 ) == NOBODY)
&& (WhoIsThere2( pBuilding->sDownClimbSpots[ ubLoop ], 1 ) == NOBODY) &&
(!pSoldier || !InGas( pSoldier, psClimbSpots[ ubLoop] ) ) )
if( (WhoIsThere2( pBuilding->sUpClimbSpots[ ubLoop ], 0 ) == NOBODY ||
WhoIsThere2( pBuilding->sUpClimbSpots[ ubLoop ], 0 ) == pSoldier->ubID ) &&
(WhoIsThere2( pBuilding->sDownClimbSpots[ ubLoop ], 1 ) == NOBODY ||
WhoIsThere2( pBuilding->sDownClimbSpots[ ubLoop ], 1 ) == pSoldier->ubID) &&
!InGas( pSoldier, psClimbSpots[ ubLoop] ) &&
!Water( psClimbSpots[ ubLoop], pSoldier->pathing.bLevel) )
{
sDistance = PythSpacesAway( sStartGridNo, psClimbSpots[ ubLoop ] );
if (sDistance < sClosestDistance )
+17 -5
View File
@@ -3717,15 +3717,21 @@ UINT8 GetTerrainType( INT32 sGridNo )
*/
}
BOOLEAN Water( INT32 sGridNo )
BOOLEAN Water( INT32 sGridNo, BOOLEAN bLevel )
{
MAP_ELEMENT * pMapElement;
if( TileIsOutOfBounds( sGridNo ) )
{
return( FALSE );
}
// sevenfm: check bridge
if( bLevel )
{
return FALSE;
}
pMapElement = &(gpWorldLevelData[sGridNo]);
if ( TERRAIN_IS_WATER( pMapElement->ubTerrainID) )
{
@@ -3738,7 +3744,7 @@ BOOLEAN Water( INT32 sGridNo )
}
}
BOOLEAN DeepWater( INT32 sGridNo )
BOOLEAN DeepWater( INT32 sGridNo, BOOLEAN bLevel )
{
MAP_ELEMENT * pMapElement;
@@ -3747,6 +3753,12 @@ BOOLEAN DeepWater( INT32 sGridNo )
return( FALSE );
}
// sevenfm: check bridge
if( bLevel )
{
return FALSE;
}
pMapElement = &(gpWorldLevelData[sGridNo]);
if (TERRAIN_IS_DEEP_WATER( pMapElement->ubTerrainID) )
@@ -3760,9 +3772,9 @@ BOOLEAN DeepWater( INT32 sGridNo )
}
}
BOOLEAN WaterTooDeepForAttacks( INT32 sGridNo )
BOOLEAN WaterTooDeepForAttacks( INT32 sGridNo, BOOLEAN bLevel )
{
return( DeepWater( sGridNo ) );
return( DeepWater( sGridNo, bLevel ) );
}
void SetStructAframeFlags( INT32 iMapIndex, UINT32 uiFlags )
+3 -3
View File
@@ -63,9 +63,9 @@ void SetAllLandShadeLevels( INT32 iMapIndex, UINT8 ubShadeLevel );
void AdjustAllLandShadeLevels( INT32 iMapIndex, INT8 bShadeDiff );
void AdjustAllLandDirtyCount( INT32 iMapIndex, INT8 bDirtyDiff );
UINT8 GetTerrainType( INT32 sGridNo );
BOOLEAN Water( INT32 sGridNo );
BOOLEAN DeepWater( INT32 sGridNo );
BOOLEAN WaterTooDeepForAttacks( INT32 sGridNo );
BOOLEAN Water( INT32 sGridNo, BOOLEAN bLevel );
BOOLEAN DeepWater( INT32 sGridNo, BOOLEAN bLevel );
BOOLEAN WaterTooDeepForAttacks( INT32 sGridNo, BOOLEAN bLevel );
// Structure manipulation routines
BOOLEAN RemoveStruct( INT32 iMapIndex, UINT16 usIndex );