Suppression:

- disabled ubAdjacentSoldierCnt check as it doesn't work correctly
- improved adjacent tile check to avoid out of bounds values

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8891 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Sevenfm
2020-08-20 04:24:44 +00:00
parent f5162b31d2
commit 4344c2caf8
2 changed files with 14 additions and 72 deletions
+9 -53
View File
@@ -7100,27 +7100,13 @@ void MoveBullet( INT32 iBullet )
if ( IS_MERC_BODY_TYPE( MercPtrs[pStructure->usStructureID] ) )
{
// HEADROCK HAM 3.3: Externalized distance at which characters suffer from friendly suppression.
// previously relied on minimum distance at which characters may suffer from friendly fire HITS.
UINT16 MIN_DIST_FOR_SCARE_FRIENDS = gGameExternalOptions.usMinDistanceFriendlySuppression;
// apply suppression, regardless of friendly or enemy
// except if friendly, not within a few tiles of shooter
if ( pBullet->ubFirerID == NOBODY || MercPtrs[ pStructure->usStructureID ]->bSide != pBullet->pFirer->bSide || pBullet->iLoop > MIN_DIST_FOR_SCARE_FRIENDS )
if (pBullet->ubFirerID == NOBODY || MercPtrs[pStructure->usStructureID]->bSide != pBullet->pFirer->bSide || pBullet->iLoop > gGameExternalOptions.usMinDistanceFriendlySuppression)
{
// buckshot has only a 1 in 2 chance of applying a suppression point
// HEADROCK HAM 5: For NCTH, make pellets as effective as any other bullet.
BOOLEAN fInflictSuppression = FALSE;
if (UsingNewCTHSystem() == true)
{
fInflictSuppression = TRUE;
}
else if ( !(pBullet->usFlags & BULLET_FLAG_BUCKSHOT) || Random( 2 ) )
{
fInflictSuppression = TRUE;
}
if (fInflictSuppression)
if (UsingNewCTHSystem() || !(pBullet->usFlags & BULLET_FLAG_BUCKSHOT) || Random(2))
{
// bullet goes whizzing by this guy!
switch ( gAnimControl[ MercPtrs[pStructure->usStructureID]->usAnimState ].ubEndHeight )
@@ -7183,32 +7169,20 @@ void MoveBullet( INT32 iBullet )
}
// check to see if any soldiers are nearby; those soldiers
// have their near-miss value incremented
if (pMapElement->ubAdjacentSoldierCnt > 0)
// sevenfm: disabled ubAdjacentSoldierCnt check as it doesn't work correctly
//if (pMapElement->ubAdjacentSoldierCnt > 0)
{
// cube level now calculated above!
// figure out the LOS cube level of the current point
//iCurrCubesAboveLevelZ = CONVERT_HEIGHTUNITS_TO_INDEX( FIXEDPT_TO_INT32( pBullet->qCurrZ - qLandHeight) );
// figure out what level to affect...
if (iCurrCubesAboveLevelZ < STRUCTURE_ON_ROOF_MAX)
{
/*
if (iCurrCubesAboveLevelZ < STRUCTURE_ON_GROUND_MAX)
{
// check objects on the ground
sDesiredLevel = 0;
}
else
{
// check objects on roofs
sDesiredLevel = 1;
}
*/
for( bDir = 0; bDir < NUM_WORLD_DIRECTIONS; bDir++)
{
iAdjGridNo = iGridNo + DirIncrementer[bDir];
//iAdjGridNo = iGridNo + DirIncrementer[bDir];
iAdjGridNo = NewGridNo(iGridNo, DirectionInc(bDir));
if ( gubWorldMovementCosts[ iAdjGridNo ][ bDir ][ sDesiredLevel ] < TRAVELCOST_BLOCKED)
if (iAdjGridNo != iGridNo && gubWorldMovementCosts[iAdjGridNo][bDir][sDesiredLevel] < TRAVELCOST_BLOCKED)
{
ubTargetID = WhoIsThere2( iAdjGridNo, (INT8) sDesiredLevel );
if (ubTargetID != NOBODY)
@@ -7216,18 +7190,9 @@ void MoveBullet( INT32 iBullet )
pTarget = MercPtrs[ ubTargetID ];
if ( IS_MERC_BODY_TYPE( pTarget ) && (pBullet->ubFirerID == NOBODY || pBullet->pFirer->bSide != pTarget->bSide) )
{
// buckshot has only a 1 in 2 chance of applying a suppression point
// HEADROCK HAM 5: For NCTH, make pellets as effective as any other bullet.
BOOLEAN fInflictSuppression = FALSE;
if (UsingNewCTHSystem() == true)
{
fInflictSuppression = TRUE;
}
else if ( !(pBullet->usFlags & BULLET_FLAG_BUCKSHOT) || Random( 2 ) )
{
fInflictSuppression = TRUE;
}
if (fInflictSuppression)
if (UsingNewCTHSystem() || !(pBullet->usFlags & BULLET_FLAG_BUCKSHOT) || Random(2))
{
// bullet goes whizzing by this guy!
switch ( gAnimControl[ pTarget->usAnimState ].ubEndHeight )
@@ -7252,14 +7217,6 @@ void MoveBullet( INT32 iBullet )
break;
}
}
/*
// this could be a close call
if ( pTarget->bTeam == gbPlayerNum && pBullet->pFirer->bTeam != gbPlayerNum )
{
pTarget->flags.fCloseCall = TRUE;
}
*/
}
}
}
@@ -9369,7 +9326,6 @@ void CalcMuzzleSway( SOLDIERTYPE *pShooter, FLOAT *dMuzzleOffsetX, FLOAT *dMuzzl
FLOAT dMaxBias = 20.0f;
FLOAT dMaxDown;
dVerticalBias = 1.0f;
CalculateSoldierZPos(pShooter, FIRING_POS, &dStartZ);
dMaxDown = -dStartZ;
+5 -19
View File
@@ -3373,28 +3373,14 @@ void GetKeyboardInput( UINT32 *puiNewEvent )
//Get the gridno the cursor is at
GetMouseMapPos( &usGridNo );
// code to test friendly fire detection
//if there is a selected soldier, and the cursor location is valid
/*if (gusSelectedSoldier != NOBODY && !TileIsOutOfBounds(usGridNo) && gfUIFullTargetFound)
{
SOLDIERTYPE *pSoldier = MercPtrs[gusSelectedSoldier];
SOLDIERTYPE *pOpponent = MercPtrs[gusUIFullTargetID];
UINT8 ubChanceToGetThrough;
if (pSoldier && pOpponent)
{
gUnderFire.Clear();
gUnderFire.Enable();
ubChanceToGetThrough = AISoldierToSoldierChanceToGetThrough(pSoldier, pOpponent);
gUnderFire.Disable();
ScreenMsg(FONT_ORANGE, MSG_INTERFACE, L"friendly fire chance %d count %d", gUnderFire.Chance(pSoldier->bTeam, pSoldier->bSide, TRUE), gUnderFire.Count(pSoldier->bTeam));
}
}*/
// if the cursor location is valid
if ( !TileIsOutOfBounds(usGridNo) )
{
// sevenfm: code to check ubAdjacentSoldierCnt
/*MAP_ELEMENT *pMapElement;
pMapElement = &(gpWorldLevelData[usGridNo]);
ScreenMsg(FONT_ORANGE, MSG_INTERFACE, L"adjacent soldiers %d", pMapElement->ubAdjacentSoldierCnt);*/
// if there is a selected soldier
if ( gusSelectedSoldier != NOBODY )
{