mirror of
https://github.com/1dot13/source.git
synced 2026-08-05 14:00:23 +02:00
New Feature: Improved ambushes have mercs face the enemy and be somewhat scattered, while the enemy encircles the player but is not at point-blank range.
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7846 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+65
-21
@@ -1044,30 +1044,26 @@ INT32 FindRandomGridNoFromSweetSpot( SOLDIERTYPE *pSoldier, INT32 sSweetGridNo,
|
||||
|
||||
}
|
||||
|
||||
// Flugente: I've altered this function in two ways:
|
||||
// 1. The gridno is now drawn from the entirety of the circle - not just for sX and sY being positive
|
||||
// 2. The direction now points to sSweetGridNo, center of the circle, instead of the map center
|
||||
INT32 FindRandomGridNoFromSweetSpotExcludingSweetSpot( SOLDIERTYPE *pSoldier, INT32 sSweetGridNo, INT8 ubRadius, UINT8 *pubDirection )
|
||||
{
|
||||
INT16 sX, sY;
|
||||
INT16 sX, sY;
|
||||
INT32 sGridNo = NOWHERE;
|
||||
INT32 leftmost;
|
||||
BOOLEAN fFound = FALSE;
|
||||
UINT32 cnt = 0;
|
||||
UINT32 cnt = 0;
|
||||
|
||||
do
|
||||
{
|
||||
sX = (UINT16)Random( ubRadius );
|
||||
sY = (UINT16)Random( ubRadius );
|
||||
|
||||
leftmost = ( ( sSweetGridNo + ( WORLD_COLS * sY ) )/ WORLD_COLS ) * WORLD_COLS;
|
||||
|
||||
sGridNo = sSweetGridNo + ( WORLD_COLS * sY ) + sX;
|
||||
|
||||
if ( sGridNo == sSweetGridNo )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( sGridNo >=0 && sGridNo < WORLD_MAX &&
|
||||
sGridNo >= leftmost && sGridNo < ( leftmost + WORLD_COLS ) )
|
||||
sX = (UINT16)Random( 2 * ubRadius ) - ubRadius;
|
||||
sY = (UINT16)Random( 2 * ubRadius ) - ubRadius;
|
||||
|
||||
sGridNo = sSweetGridNo + (WORLD_COLS * sY ) + sX;
|
||||
|
||||
if ( sGridNo == sSweetGridNo || TileIsOutOfBounds( sGridNo ) || PythSpacesAway( sGridNo, sSweetGridNo ) >= ubRadius || !IsLocationSittable( sGridNo, 0 ) )
|
||||
sGridNo = NOWHERE;
|
||||
else
|
||||
{
|
||||
// Go on sweet stop
|
||||
if ( NewOKDestination( pSoldier, sGridNo, TRUE, pSoldier->pathing.bLevel ) )
|
||||
@@ -1076,20 +1072,68 @@ INT32 FindRandomGridNoFromSweetSpotExcludingSweetSpot( SOLDIERTYPE *pSoldier, IN
|
||||
}
|
||||
}
|
||||
|
||||
cnt++;
|
||||
++cnt;
|
||||
|
||||
if ( cnt > 2000 )
|
||||
{
|
||||
return( NOWHERE );
|
||||
}
|
||||
|
||||
} while( !fFound );
|
||||
|
||||
// Set direction to center of map!
|
||||
*pubDirection = (UINT8)GetDirectionToGridNoFromGridNo( sGridNo, ( ( ( WORLD_ROWS / 2 ) * WORLD_COLS ) + ( WORLD_COLS / 2 ) ) );
|
||||
*pubDirection = (UINT8)GetDirectionToGridNoFromGridNo( sGridNo, sSweetGridNo );
|
||||
|
||||
return( sGridNo );
|
||||
}
|
||||
|
||||
// Flugente: returns random gridno in a circle around sCenterGridNo with radius uOuterRadius that is not inside the circle with radius uInnerRadius
|
||||
INT32 FindRandomGridNoBetweenCircles( INT32 sCenterGridNo, UINT8 uInnerRadius, UINT8 uOuterRadius, UINT8& urDirection )
|
||||
{
|
||||
INT16 sX, sY;
|
||||
INT32 sGridNo = NOWHERE;
|
||||
BOOLEAN fFound = FALSE;
|
||||
UINT32 cnt = 0;
|
||||
|
||||
if ( uInnerRadius >= uOuterRadius )
|
||||
return NOWHERE;
|
||||
|
||||
do
|
||||
{
|
||||
/*sX = (UINT16)Random( 2 * (uOuterRadius - uInnerRadius) ) - (uOuterRadius - uInnerRadius);
|
||||
sY = (UINT16)Random( 2 * (uOuterRadius - uInnerRadius) ) - (uOuterRadius - uInnerRadius);
|
||||
|
||||
if ( sX > 0 )
|
||||
sX += uInnerRadius;
|
||||
else
|
||||
sX -= uInnerRadius;
|
||||
|
||||
if ( sY > 0 )
|
||||
sY += uInnerRadius;
|
||||
else
|
||||
sY -= uInnerRadius;*/
|
||||
|
||||
sX = (UINT16)Random( 2 * uOuterRadius ) - uOuterRadius;
|
||||
sY = (UINT16)Random( 2 * uOuterRadius ) - uOuterRadius;
|
||||
|
||||
sGridNo = sCenterGridNo + (WORLD_COLS * sY) + sX;
|
||||
|
||||
if ( TileIsOutOfBounds( sGridNo ) || !IsLocationSittable( sGridNo, 0 ) || PythSpacesAway( sGridNo, sCenterGridNo ) <= uInnerRadius || PythSpacesAway( sGridNo, sCenterGridNo ) > uOuterRadius )
|
||||
sGridNo = NOWHERE;
|
||||
else
|
||||
fFound = TRUE;
|
||||
|
||||
++cnt;
|
||||
|
||||
if ( cnt > 2000 )
|
||||
{
|
||||
return(NOWHERE);
|
||||
}
|
||||
} while ( !fFound );
|
||||
|
||||
// Set direction to center of map!
|
||||
urDirection = (UINT8)GetDirectionToGridNoFromGridNo( sGridNo, sCenterGridNo );
|
||||
|
||||
return(sGridNo);
|
||||
}
|
||||
|
||||
|
||||
@@ -1238,7 +1282,7 @@ BOOLEAN InternalAddSoldierToSector( UINT8 ubID, BOOLEAN fCalculateDirection, BOO
|
||||
pSoldier->usSoldierFlagMask |= SOLDIER_ASSAULT_BONUS;
|
||||
|
||||
// Override calculated direction if we were told to....
|
||||
if ( pSoldier->ubInsertionDirection > 100 )
|
||||
if ( pSoldier->ubInsertionDirection >= 100 )
|
||||
{
|
||||
pSoldier->ubInsertionDirection = pSoldier->ubInsertionDirection - 100;
|
||||
fCalculateDirection = FALSE;
|
||||
|
||||
Reference in New Issue
Block a user