mirror of
https://github.com/1dot13/source.git
synced 2026-08-05 14:00:23 +02:00
************************************************************
* Merged Source Code from Development Trunk: Revision 4063 * ************************************************************ - Source Code is merged from: https://81.169.133.124/source/ja2/branches/Wanne/JA2%201.13%20MP - This will be the Source for the Beta 2011 Test git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@4064 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -185,6 +185,344 @@ UINT8 gPurpendicularDirection[ NUM_WORLD_DIRECTIONS ][ NUM_WORLD_DIRECTIONS ] =
|
||||
};
|
||||
|
||||
|
||||
//----------------------legion by Jazz-----------------
|
||||
|
||||
BOOLEAN FindWindowJumpDirection( SOLDIERTYPE *pSoldier, INT32 sGridNo, INT8 bStartingDir, INT8 *pbDirection )
|
||||
{
|
||||
INT32 cnt;
|
||||
INT32 sNewGridNo, sOtherSideOfFence;
|
||||
BOOLEAN fFound = FALSE;
|
||||
UINT8 bMinNumTurns = 100;
|
||||
INT8 bNumTurns;
|
||||
INT8 bMinDirection = 0;
|
||||
INT8 direction2 = -1;
|
||||
|
||||
if ( pSoldier->ubDirection == NORTH )
|
||||
direction2 = NORTH;
|
||||
else if ( pSoldier->ubDirection == EAST )
|
||||
direction2 = EAST;
|
||||
else if ( pSoldier->ubDirection == SOUTH )
|
||||
direction2 = SOUTH;
|
||||
else if ( pSoldier->ubDirection == WEST )
|
||||
direction2 = WEST;
|
||||
|
||||
// WANNE: No need to check on SOUTH and EAST tile, because it is the tile that has the fence we are standing on!
|
||||
if (direction2 == NORTH || direction2 == WEST)
|
||||
{
|
||||
// IF there is a fence in this gridno, return false!
|
||||
if ( IsJumpableWindowPresentAtGridNo( sGridNo, direction2 ) )
|
||||
{
|
||||
return( FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
// LOOP THROUGH ALL 8 DIRECTIONS
|
||||
for ( cnt = 0; cnt < 8; cnt+= 2 )
|
||||
{
|
||||
if (cnt != direction2)
|
||||
continue;
|
||||
|
||||
// get the fence tile
|
||||
if (cnt == NORTH || cnt == WEST)
|
||||
{
|
||||
sNewGridNo = NewGridNo( sGridNo, (UINT16)DirectionInc( (UINT8)cnt ) );
|
||||
sOtherSideOfFence = sNewGridNo;
|
||||
}
|
||||
// current tile we are standing is the fence tile
|
||||
else
|
||||
{
|
||||
sNewGridNo = sGridNo;
|
||||
sOtherSideOfFence = NewGridNo( sNewGridNo, (UINT16)DirectionInc( (UINT8)cnt ) );
|
||||
}
|
||||
|
||||
//if ( NewOKDestination( pSoldier, sOtherSideOfFence, TRUE, 0 ) && validDestTile)
|
||||
if ( NewOKDestination( pSoldier, sOtherSideOfFence, TRUE, 0 ) /*&& validDestTile*/)
|
||||
{
|
||||
// ATE: Check if there is somebody waiting here.....
|
||||
|
||||
// Check if we have a fence here
|
||||
if ( IsJumpableWindowPresentAtGridNo( sNewGridNo , direction2) )
|
||||
{
|
||||
fFound = TRUE;
|
||||
|
||||
// FInd how many turns we should go to get here
|
||||
bNumTurns = FindNumTurnsBetweenDirs( (INT8)cnt, bStartingDir );
|
||||
|
||||
if ( bNumTurns < bMinNumTurns )
|
||||
{
|
||||
bMinNumTurns = bNumTurns;
|
||||
bMinDirection = (INT8)cnt;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( fFound )
|
||||
{
|
||||
*pbDirection = bMinDirection;
|
||||
return( TRUE );
|
||||
}
|
||||
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
BOOLEAN FindFenceDirection( SOLDIERTYPE *pSoldier, INT32 sGridNo, INT8 bStartingDir, INT8 *pbDirection )
|
||||
{
|
||||
INT32 cnt;
|
||||
INT32 sNewGridNo, sOtherSideOfFence;
|
||||
BOOLEAN fFound = FALSE;
|
||||
UINT8 bMinNumTurns = 100;
|
||||
INT8 bNumTurns;
|
||||
INT8 bMinDirection = 0;
|
||||
|
||||
// IF there is a fence in this gridno, return false!
|
||||
if ( IsLegionFencePresentAtGridno( sGridNo ) )
|
||||
{
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
// LOOP THROUGH ALL 8 DIRECTIONS
|
||||
for ( cnt = 0; cnt < 8; cnt+= 2 )
|
||||
{
|
||||
// go out *2* tiles
|
||||
sNewGridNo = NewGridNo( sGridNo, (UINT16)DirectionInc( (UINT8)cnt ) );
|
||||
sOtherSideOfFence = NewGridNo( sNewGridNo, (UINT16)DirectionInc( (UINT8)cnt ) );
|
||||
|
||||
if ( NewOKDestination( pSoldier, sOtherSideOfFence, TRUE, 0 ) )
|
||||
{
|
||||
// ATE: Check if there is somebody waiting here.....
|
||||
|
||||
|
||||
// Check if we have a fence here
|
||||
if ( IsLegionFencePresentAtGridno( sNewGridNo ) )
|
||||
{
|
||||
fFound = TRUE;
|
||||
|
||||
// FInd how many turns we should go to get here
|
||||
bNumTurns = FindNumTurnsBetweenDirs( (INT8)cnt, bStartingDir );
|
||||
|
||||
if ( bNumTurns < bMinNumTurns )
|
||||
{
|
||||
bMinNumTurns = bNumTurns;
|
||||
bMinDirection = (INT8)cnt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( fFound )
|
||||
{
|
||||
*pbDirection = bMinDirection;
|
||||
return( TRUE );
|
||||
}
|
||||
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
BOOLEAN FindHeigherLevelOkno( SOLDIERTYPE *pSoldier, INT32 sGridNo, INT8 bStartingDir, INT8 *pbDirection )
|
||||
{
|
||||
|
||||
INT32 cnt;
|
||||
INT32 sNewGridNo;
|
||||
BOOLEAN fFound = FALSE;
|
||||
UINT8 bMinNumTurns = 100;
|
||||
INT8 bNumTurns;
|
||||
INT8 bMinDirection = 0;
|
||||
|
||||
// LOOP THROUGH ALL 8 DIRECTIONS
|
||||
for ( cnt = 0; cnt < 8; cnt+= 2 )
|
||||
{
|
||||
sNewGridNo = NewGridNo( sGridNo, (UINT16)DirectionInc( (UINT8)cnt ) );
|
||||
|
||||
// Make sure there is NOT a roof here...
|
||||
// Check OK destination
|
||||
if ( NewOKDestination( pSoldier, sNewGridNo, TRUE, 0 ) )
|
||||
{
|
||||
if ( FindStructure( sNewGridNo, STRUCTURE_WALLNWINDOW ) == NULL )
|
||||
{
|
||||
{
|
||||
fFound = TRUE;
|
||||
|
||||
// FInd how many turns we should go to get here
|
||||
bNumTurns = FindNumTurnsBetweenDirs( (INT8)cnt, bStartingDir );
|
||||
|
||||
if ( bNumTurns < bMinNumTurns )
|
||||
{
|
||||
bMinNumTurns = bNumTurns;
|
||||
bMinDirection = (INT8)cnt;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( fFound )
|
||||
{
|
||||
*pbDirection = bMinDirection;
|
||||
return( TRUE );
|
||||
}
|
||||
|
||||
return( FALSE );
|
||||
|
||||
/* INT32 cnt;
|
||||
INT32 sNewGridNo;
|
||||
BOOLEAN fFound = FALSE;
|
||||
UINT8 bMinNumTurns = 100;
|
||||
INT8 bNumTurns;
|
||||
INT8 bMinDirection = 0;
|
||||
|
||||
//STRUCTURE * pStructure;
|
||||
|
||||
// IF there is a roof over our heads, this is an ivalid....
|
||||
// return ( FALSE );l
|
||||
if ( FindStructure( sGridNo, STRUCTURE_WALLNWINDOW ) != NULL )
|
||||
{
|
||||
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
for ( cnt = 0; cnt < 8; cnt+= 2 )
|
||||
{
|
||||
sNewGridNo = NewGridNo( sGridNo, (UINT16)DirectionInc( (UINT8)cnt ) );
|
||||
|
||||
if ( NewOKDestination( pSoldier, sNewGridNo, TRUE, 0 ) )
|
||||
{
|
||||
// Check if this tile has a higher level
|
||||
if ( IsOknoLevel( sNewGridNo ) )
|
||||
{
|
||||
fFound = TRUE;
|
||||
|
||||
// FInd how many turns we should go to get here
|
||||
bNumTurns = FindNumTurnsBetweenDirs( (INT8)cnt, bStartingDir );
|
||||
|
||||
if ( bNumTurns < bMinNumTurns )
|
||||
{
|
||||
bMinNumTurns = bNumTurns;
|
||||
bMinDirection = (INT8)cnt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ( fFound )
|
||||
{
|
||||
*pbDirection = bMinDirection;
|
||||
return( TRUE );
|
||||
}
|
||||
|
||||
return( FALSE );
|
||||
*/
|
||||
}
|
||||
|
||||
BOOLEAN FindHeigherLevelFence( SOLDIERTYPE *pSoldier, INT32 sGridNo, INT8 bStartingDir, INT8 *pbDirection )
|
||||
{
|
||||
INT32 cnt;
|
||||
INT32 sNewGridNo;
|
||||
BOOLEAN fFound = FALSE;
|
||||
UINT8 bMinNumTurns = 100;
|
||||
INT8 bNumTurns;
|
||||
INT8 bMinDirection = 0;
|
||||
|
||||
//STRUCTURE * pStructure;
|
||||
|
||||
// IF there is a roof over our heads, this is an ivalid....
|
||||
// return ( FALSE );l
|
||||
if ( FindStructure( sGridNo, STRUCTURE_FENCE ) != NULL )
|
||||
{
|
||||
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
for ( cnt = 0; cnt < 8; cnt+= 2 )
|
||||
{
|
||||
sNewGridNo = NewGridNo( sGridNo, (UINT16)DirectionInc( (UINT8)cnt ) );
|
||||
|
||||
if ( NewOKDestination( pSoldier, sNewGridNo, TRUE, 0 ) )
|
||||
{
|
||||
// Check if this tile has a higher level
|
||||
if ( IsLegionLevel( sNewGridNo ) )
|
||||
{
|
||||
fFound = TRUE;
|
||||
|
||||
// FInd how many turns we should go to get here
|
||||
bNumTurns = FindNumTurnsBetweenDirs( (INT8)cnt, bStartingDir );
|
||||
|
||||
if ( bNumTurns < bMinNumTurns )
|
||||
{
|
||||
bMinNumTurns = bNumTurns;
|
||||
bMinDirection = (INT8)cnt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ( fFound )
|
||||
{
|
||||
*pbDirection = bMinDirection;
|
||||
return( TRUE );
|
||||
}
|
||||
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
BOOLEAN FindLowerLevelFence( SOLDIERTYPE *pSoldier, INT32 sGridNo, INT8 bStartingDir, INT8 *pbDirection )
|
||||
{
|
||||
INT32 cnt;
|
||||
INT32 sNewGridNo;
|
||||
BOOLEAN fFound = FALSE;
|
||||
UINT8 bMinNumTurns = 100;
|
||||
INT8 bNumTurns;
|
||||
INT8 bMinDirection = 0;
|
||||
|
||||
// LOOP THROUGH ALL 8 DIRECTIONS
|
||||
for ( cnt = 0; cnt < 8; cnt+= 2 )
|
||||
{
|
||||
sNewGridNo = NewGridNo( sGridNo, (UINT16)DirectionInc( (UINT8)cnt ) );
|
||||
|
||||
// Make sure there is NOT a roof here...
|
||||
// Check OK destination
|
||||
if ( NewOKDestination( pSoldier, sNewGridNo, TRUE, 0 ) )
|
||||
{
|
||||
if ( FindStructure( sNewGridNo, STRUCTURE_FENCE ) == NULL )
|
||||
{
|
||||
{
|
||||
fFound = TRUE;
|
||||
|
||||
// FInd how many turns we should go to get here
|
||||
bNumTurns = FindNumTurnsBetweenDirs( (INT8)cnt, bStartingDir );
|
||||
|
||||
if ( bNumTurns < bMinNumTurns )
|
||||
{
|
||||
bMinNumTurns = bNumTurns;
|
||||
bMinDirection = (INT8)cnt;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( fFound )
|
||||
{
|
||||
*pbDirection = bMinDirection;
|
||||
return( TRUE );
|
||||
}
|
||||
|
||||
return( FALSE );
|
||||
}
|
||||
//---------------------------------------------------------------------------------
|
||||
|
||||
|
||||
GridNode::MapXY_t GridNode::MapXY;
|
||||
static GridNode::MapXY_t *pMapXY = GridNode::initGridNodes(); // A hack to initialize the MapXY grid
|
||||
|
||||
@@ -632,7 +970,7 @@ INT32 GetRangeFromGridNoDiff( INT32 sGridNo1, INT32 sGridNo2 )
|
||||
// Convert our grid-not into an XY
|
||||
ConvertGridNoToXY( sGridNo2, &sXPos2, &sYPos2 );
|
||||
|
||||
uiDist = sqrt((double) ( sXPos2 - sXPos )*( sXPos2 - sXPos ) + ( sYPos2 - sYPos ) * ( sYPos2 - sYPos ) );
|
||||
uiDist = (INT32)(sqrt((double) ( sXPos2 - sXPos )*( sXPos2 - sXPos ) + ( sYPos2 - sYPos ) * ( sYPos2 - sYPos ) ));
|
||||
|
||||
return( uiDist );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user