Re-allowed diagonal melee attacks, this time it will work correctly and game actually use this in pathing too, which was not the case before (by Shadooow).

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9030 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Sevenfm
2021-05-16 18:46:37 +00:00
parent 42481737ab
commit a2e0080227
5 changed files with 13 additions and 15 deletions
+1 -1
View File
@@ -1778,7 +1778,7 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, INT32 sGridNo, INT8 bLevel, UINT16 usHa
else
{
// See if we can get there to stab
sActionGridNo = FindAdjacentGridEx(pSoldier, sGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE);
sActionGridNo = FindAdjacentGridEx(pSoldier, sGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE, true);
}
if ( sActionGridNo != NOWHERE )
+1 -1
View File
@@ -4528,7 +4528,7 @@ INT8 DrawUIMovementPath( SOLDIERTYPE *pSoldier, INT32 usMapPos, UINT32 uiFlags )
else
{
// See if we can get there to stab
sActionGridNo = FindAdjacentGridEx(pSoldier, usMapPos, &ubDirection, &sAdjustedGridNo, TRUE, FALSE);
sActionGridNo = FindAdjacentGridEx(pSoldier, usMapPos, &ubDirection, &sAdjustedGridNo, TRUE, FALSE, true);
}
}
else
+9 -11
View File
@@ -5444,7 +5444,7 @@ BOOLEAN TeamMemberNear(INT8 bTeam, INT32 sGridNo, INT32 iRange)
return(FALSE);
}
INT32 FindAdjacentGridEx( SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 *pubDirection, INT32 *psAdjustedGridNo, BOOLEAN fForceToPerson, BOOLEAN fDoor )
INT32 FindAdjacentGridEx( SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 *pubDirection, INT32 *psAdjustedGridNo, BOOLEAN fForceToPerson, BOOLEAN fDoor, bool allow_diagonal )
{
// psAdjustedGridNo gets the original gridno or the new one if updated
// It will ONLY be updated IF we were over a merc, ( it's updated to their gridno )
@@ -5453,7 +5453,7 @@ INT32 FindAdjacentGridEx( SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 *pubDirect
// in that location, because we could be passed a gridno based on the overlap of soldier's graphic
// fDoor determines whether special door-handling code should be used (for interacting with doors)
INT32 sGridNoProne = -1;
INT32 sFourGrids[4], sDistance=0;
INT32 sDistance=0;
static const UINT8 sDirs[4] = { NORTH, EAST, SOUTH, WEST };
INT32 sClosest = -1, sSpot;
INT32 sCloseGridNo = NOWHERE;
@@ -5594,12 +5594,11 @@ INT32 FindAdjacentGridEx( SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 *pubDirect
}
}
for (INT8 cnt = 0; cnt < 4; ++cnt)
for (INT8 cnt = 0; cnt < (allow_diagonal ? NUM_WORLD_DIRECTIONS : 4); ++cnt)
{
// MOVE OUT TWO DIRECTIONS
sFourGrids[cnt] = sSpot = NewGridNo( sGridNo, DirectionInc( sDirs[ cnt ] ) );
ubTestDirection = sDirs[ cnt ];
ubTestDirection = (allow_diagonal ? cnt : sDirs[cnt]);
// MOVE OUT TWO DIRECTIONS
sSpot = NewGridNo( sGridNo, DirectionInc(ubTestDirection) );
// For switches, ALLOW them to walk through walls to reach it....
if ( pDoor && pDoor->fFlags & STRUCTURE_SWITCH )
@@ -5675,12 +5674,11 @@ INT32 FindAdjacentGridEx( SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 *pubDirect
}
if (sGridNoProne != -1)
{
for (INT8 cnt = 0; cnt < 4; ++cnt)
for (INT8 cnt = 0; cnt < (allow_diagonal ? NUM_WORLD_DIRECTIONS : 4); ++cnt)
{
ubTestDirection = (allow_diagonal ? cnt : sDirs[cnt]);
// MOVE OUT TWO DIRECTIONS
sFourGrids[cnt] = sSpot = NewGridNo(sGridNoProne, DirectionInc(sDirs[cnt]));
ubTestDirection = sDirs[cnt];
sSpot = NewGridNo(sGridNoProne, DirectionInc(ubTestDirection));
// For switches, ALLOW them to walk through walls to reach it....
if (pDoor && pDoor->fFlags & STRUCTURE_SWITCH)
+1 -1
View File
@@ -255,7 +255,7 @@ UINT32 EnterTacticalDemoMode();
BOOLEAN UIOKMoveDestination( SOLDIERTYPE *pSoldier, INT32 usMapPos );
INT32 FindAdjacentGridEx( SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 *pubDirection, INT32 *psAdjustedGridNo, BOOLEAN fForceToPerson, BOOLEAN fDoor );
INT32 FindAdjacentGridEx( SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 *pubDirection, INT32 *psAdjustedGridNo, BOOLEAN fForceToPerson, BOOLEAN fDoor , bool allow_diagonal = false);
INT32 FindNextToAdjacentGridEx( SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 *pubDirection, INT32 *psAdjustedGridNo, BOOLEAN fForceToPerson, BOOLEAN fDoor );
+1 -1
View File
@@ -1937,7 +1937,7 @@ INT16 CalcTotalAPsToAttack( SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 ubAddTur
else
{
// See if we can get there to stab
sActionGridNo = FindAdjacentGridEx(pSoldier, sGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE);
sActionGridNo = FindAdjacentGridEx(pSoldier, sGridNo, &ubDirection, &sAdjustedGridNo, TRUE, FALSE, true);
}
if (!TileIsOutOfBounds(sActionGridNo))