mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
allowed to throw grenades from behind corners without need to move into open field
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9134 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "Dialogue Control.h" // added by Flugente
|
||||
#endif
|
||||
#include "connect.h"
|
||||
#include "PATHAI.H"
|
||||
|
||||
|
||||
//forward declarations of common classes to eliminate includes
|
||||
@@ -2096,6 +2097,95 @@ void CalculateLaunchItemBasicParams( SOLDIERTYPE *pSoldier, OBJECTTYPE *pItem, I
|
||||
(*pdDegrees ) = dDegrees;
|
||||
}
|
||||
|
||||
BOOLEAN GrenadeRollingPossible(SOLDIERTYPE *pSoldier, INT32 sGridNo, INT16 *sXPos, INT16 *sYPos)
|
||||
{
|
||||
if (!(pSoldier->bWeaponMode == WM_ATTACHED_GL || pSoldier->bWeaponMode == WM_ATTACHED_GL_BURST || pSoldier->bWeaponMode == WM_ATTACHED_GL_AUTO))
|
||||
{
|
||||
UINT8 ubDirection = GetDirectionFromGridNo(sGridNo, pSoldier);
|
||||
if (ubDirection % 2 == 1)//diagonal direction is disabled
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
INT32 sTestGridNo = NewGridNo(pSoldier->sGridNo, DirectionInc(ubDirection));
|
||||
|
||||
if (gubWorldMovementCosts[sTestGridNo][ubDirection][pSoldier->pathing.bLevel] == TRAVELCOST_WALL)
|
||||
{
|
||||
BOOLEAN obstacle = FALSE;
|
||||
INT16 newDir = (ubDirection != 2 && ubDirection != 6) ? EAST : SOUTH;
|
||||
INT32 newLoc = NewGridNo(pSoldier->sGridNo, DirectionInc(newDir));
|
||||
STRUCTURE *pStruct;
|
||||
pStruct = gpWorldLevelData[newLoc].pStructureHead;
|
||||
while (pStruct)
|
||||
{
|
||||
if ((pStruct->fFlags & STRUCTURE_ANYDOOR) && (pStruct->fFlags & STRUCTURE_OPEN))
|
||||
{
|
||||
if (gubWorldMovementCosts[newLoc][newDir][pSoldier->pathing.bLevel] >= 220)//doors are opened in a way they make an obstacle
|
||||
return FALSE;
|
||||
ConvertGridNoToCenterCellXY(newLoc, sXPos, sYPos);
|
||||
return TRUE;
|
||||
}
|
||||
pStruct = pStruct->pNext;
|
||||
}
|
||||
newLoc = NewGridNo(sTestGridNo, DirectionInc(newDir));
|
||||
pStruct = gpWorldLevelData[newLoc].pStructureHead;
|
||||
while (pStruct)
|
||||
{
|
||||
if ((pStruct->fFlags & STRUCTURE_ANYDOOR) && (pStruct->fFlags & STRUCTURE_OPEN))
|
||||
{
|
||||
ConvertGridNoToCenterCellXY(newLoc, sXPos, sYPos);
|
||||
return TRUE;
|
||||
}
|
||||
else if ((pStruct->fFlags & STRUCTURE_OBSTACLE))
|
||||
{
|
||||
obstacle = TRUE;
|
||||
}
|
||||
pStruct = pStruct->pNext;
|
||||
}
|
||||
if (!obstacle)
|
||||
{
|
||||
ConvertGridNoToCenterCellXY(newLoc, sXPos, sYPos);
|
||||
return TRUE;
|
||||
}
|
||||
obstacle = FALSE;
|
||||
newDir = (ubDirection != 2 && ubDirection != 6) ? WEST : NORTH;
|
||||
newLoc = NewGridNo(pSoldier->sGridNo, DirectionInc(newDir));
|
||||
pStruct = gpWorldLevelData[newLoc].pStructureHead;
|
||||
while (pStruct)
|
||||
{
|
||||
if ((pStruct->fFlags & STRUCTURE_ANYDOOR) && (pStruct->fFlags & STRUCTURE_OPEN))
|
||||
{
|
||||
if (gubWorldMovementCosts[newLoc][newDir][pSoldier->pathing.bLevel] >= 220)//doors are opened in a way they make an obstacle
|
||||
return FALSE;
|
||||
ConvertGridNoToCenterCellXY(newLoc, sXPos, sYPos);
|
||||
return TRUE;
|
||||
}
|
||||
pStruct = pStruct->pNext;
|
||||
}
|
||||
newLoc = NewGridNo(sTestGridNo, DirectionInc(newDir));
|
||||
pStruct = gpWorldLevelData[newLoc].pStructureHead;
|
||||
while (pStruct)
|
||||
{
|
||||
if ((pStruct->fFlags & STRUCTURE_ANYDOOR) && (pStruct->fFlags & STRUCTURE_OPEN))
|
||||
{
|
||||
ConvertGridNoToCenterCellXY(newLoc, sXPos, sYPos);
|
||||
return TRUE;
|
||||
}
|
||||
else if ((pStruct->fFlags & STRUCTURE_OBSTACLE))
|
||||
{
|
||||
obstacle = TRUE;
|
||||
}
|
||||
pStruct = pStruct->pNext;
|
||||
}
|
||||
if (!obstacle)
|
||||
{
|
||||
ConvertGridNoToCenterCellXY(newLoc, sXPos, sYPos);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN CalculateLaunchItemChanceToGetThrough( SOLDIERTYPE *pSoldier, OBJECTTYPE *pItem, INT32 sGridNo, UINT8 ubLevel, INT16 sEndZ, INT32 *psFinalGridNo, BOOLEAN fArmed, INT8 *pbLevel, BOOLEAN fFromUI )
|
||||
{
|
||||
@@ -2117,6 +2207,11 @@ BOOLEAN CalculateLaunchItemChanceToGetThrough( SOLDIERTYPE *pSoldier, OBJECTTYPE
|
||||
ConvertGridNoToCenterCellXY( sGridNo, &sDestX, &sDestY );
|
||||
ConvertGridNoToCenterCellXY( pSoldier->sGridNo, &sSrcX, &sSrcY );
|
||||
|
||||
if (GrenadeRollingPossible(pSoldier, sGridNo, &sSrcX, &sSrcY))
|
||||
{
|
||||
dForce /= 2;
|
||||
}
|
||||
|
||||
// Set position
|
||||
vPosition.x = sSrcX;
|
||||
vPosition.y = sSrcY;
|
||||
@@ -2267,6 +2362,11 @@ void CalculateLaunchItemParamsForThrow( SOLDIERTYPE *pSoldier, INT32 sGridNo, UI
|
||||
ConvertGridNoToCenterCellXY( sGridNo, &sDestX, &sDestY );
|
||||
ConvertGridNoToCenterCellXY( pSoldier->sGridNo, &sSrcX, &sSrcY );
|
||||
|
||||
if (GrenadeRollingPossible(pSoldier, sGridNo, &sSrcX, &sSrcY))
|
||||
{
|
||||
dForce /= 2;
|
||||
}
|
||||
|
||||
// OK, get direction normal
|
||||
vDirNormal.x = (float)(sDestX - sSrcX);
|
||||
vDirNormal.y = (float)(sDestY - sSrcY);
|
||||
|
||||
Reference in New Issue
Block a user