Fix: antimateriel bullet damage to structures often isn't properly applied

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9080 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2021-06-13 17:23:55 +00:00
parent 680a8cb43a
commit ff3076203f
2 changed files with 18 additions and 15 deletions
+2 -1
View File
@@ -5633,7 +5633,8 @@ void StructureHit( INT32 iBullet, UINT16 usWeaponIndex, INT16 bWeaponStatus, UIN
// Get Structure pointer and damage it!
if ( usStructureID != INVALID_STRUCTURE_ID )
{
pStructure = FindStructureByID( sGridNo, usStructureID );
// Flugente: if possible, take the gridno of the bullet. Otherwise we often get the issue that the calculated gridno is not the one where the structure is, leading to the structure being undamaged
pStructure = FindStructureByID( pBullet ? pBullet->sGridNo : sGridNo, usStructureID );
DamageStructure( pStructure, (UINT8)iImpact, STRUCTURE_DAMAGE_GUNFIRE, sGridNo, sXPos, sYPos, ubAttackerID, pBullet->usFlags & BULLET_FLAG_ANTIMATERIEL ? pBullet->iImpact - pBullet->iImpactReduction : 0 );
}
+16 -14
View File
@@ -1834,12 +1834,7 @@ BOOLEAN DamageStructure( STRUCTURE * pStructure, UINT8 ubDamage, UINT8 ubReason,
{
ubDamage = 0;
}
// Flugente: is there a wall at the loation we are damaging?
BOOLEAN fWallHere = FALSE;
if ( FindStructure( sGridNo, STRUCTURE_WALL ) )
fWallHere = TRUE;
// OK, Let's check our reason
if ( ubReason == STRUCTURE_DAMAGE_GUNFIRE || ubReason == STRUCTURE_DAMAGE_VEHICLE_TRAUMA )
{
@@ -1883,6 +1878,13 @@ BOOLEAN DamageStructure( STRUCTURE * pStructure, UINT8 ubDamage, UINT8 ubReason,
}
}
// Flugente: is there a wall at the loation we are damaging?
BOOLEAN fWallHere = FALSE;
if ( pStructure->fFlags & STRUCTURE_WALL )
fWallHere = TRUE;
else if ( FindStructure( sGridNo, STRUCTURE_WALL ) )
fWallHere = TRUE;
// Flugente: anti-material rifles can damage and even destroy structures, but some structures remain indestructible (otherwise the player might gain access to inaccessible spots)
// the impact must be damaging enough, otherwise this won't have an effect
if ( ubBaseArmour < 75 && ubBaseArmour > 0 && sAntiMaterialImpact > ubBaseArmour * 5 / 12 )
@@ -1894,20 +1896,20 @@ BOOLEAN DamageStructure( STRUCTURE * pStructure, UINT8 ubDamage, UINT8 ubReason,
damage += max(1, 2 * sAntiMaterialImpact / ubBaseArmour);
BOOLEAN recompile = FALSE;
ExplosiveDamageGridNo( sGridNo, damage, 10, &recompile, FALSE, -1, FALSE, ubOwner, 0 );
ExplosiveDamageGridNo( pStructure->sGridNo, damage, 10, &recompile, FALSE, -1, FALSE, ubOwner, 0 );
//Since the structure is being damaged, set the map element that a structure is damaged
gpWorldLevelData[ sGridNo ].uiFlags |= MAPELEMENT_STRUCTURE_DAMAGED;
gpWorldLevelData[ pStructure->sGridNo ].uiFlags |= MAPELEMENT_STRUCTURE_DAMAGED;
// if we destroyed something, the roof might get damaged too
// recompile = TRUE means that we destroyed soemthing
// recompile = TRUE means that we destroyed something
if ( fWallHere && recompile )
{
HandleRoofDestruction( sGridNo, damage * 0.75f );
HandleRoofDestruction( NewGridNo( sGridNo, DirectionInc( NORTH ) ), damage * 0.75f );
HandleRoofDestruction( NewGridNo( sGridNo, DirectionInc( EAST ) ), damage * 0.75f );
HandleRoofDestruction( NewGridNo( sGridNo, DirectionInc( WEST ) ), damage * 0.75f );
HandleRoofDestruction( NewGridNo( sGridNo, DirectionInc( SOUTH ) ), damage * 0.75f );
HandleRoofDestruction( pStructure->sGridNo, damage * 0.75f );
HandleRoofDestruction( NewGridNo( pStructure->sGridNo, DirectionInc( NORTH ) ), damage * 0.75f );
HandleRoofDestruction( NewGridNo( pStructure->sGridNo, DirectionInc( EAST ) ), damage * 0.75f );
HandleRoofDestruction( NewGridNo( pStructure->sGridNo, DirectionInc( WEST ) ), damage * 0.75f );
HandleRoofDestruction( NewGridNo( pStructure->sGridNo, DirectionInc( SOUTH ) ), damage * 0.75f );
}
}