mirror of
https://github.com/1dot13/source.git
synced 2026-09-16 14:47:17 +02:00
Fix: movement costs are not recompiled if a structure is destroyed by gunfire or vehicular collision
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9085 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+34
-20
@@ -1895,21 +1895,28 @@ INT8 DamageStructure( STRUCTURE * pStructure, UINT8 ubDamage, UINT8 ubReason, IN
|
|||||||
// this is the damage we will cause. The higher our damage, the faster can we destroy a structure
|
// this is the damage we will cause. The higher our damage, the faster can we destroy a structure
|
||||||
damage += max(1, 2 * sAntiMaterialImpact / ubBaseArmour);
|
damage += max(1, 2 * sAntiMaterialImpact / ubBaseArmour);
|
||||||
|
|
||||||
|
// the structure might not exists afterwards, thus we store the gridno
|
||||||
|
INT32 tmpgridno = pStructure->sGridNo;
|
||||||
BOOLEAN recompile = FALSE;
|
BOOLEAN recompile = FALSE;
|
||||||
ExplosiveDamageGridNo( pStructure->sGridNo, damage, 10, &recompile, FALSE, -1, FALSE, ubOwner, 0, ubReason );
|
ExplosiveDamageGridNo( tmpgridno, damage, 10, &recompile, FALSE, -1, FALSE, ubOwner, 0, ubReason );
|
||||||
|
|
||||||
//Since the structure is being damaged, set the map element that a structure is damaged
|
//Since the structure is being damaged, set the map element that a structure is damaged
|
||||||
gpWorldLevelData[ pStructure->sGridNo ].uiFlags |= MAPELEMENT_STRUCTURE_DAMAGED;
|
gpWorldLevelData[ tmpgridno ].uiFlags |= MAPELEMENT_STRUCTURE_DAMAGED;
|
||||||
|
|
||||||
// if we destroyed something, the roof might get damaged too
|
|
||||||
// recompile = TRUE means that we destroyed something
|
// recompile = TRUE means that we destroyed something
|
||||||
if ( fWallHere && recompile )
|
if ( recompile )
|
||||||
{
|
{
|
||||||
HandleRoofDestruction( pStructure->sGridNo, damage * 0.75f );
|
// if we destroyed something, the roof might get damaged too
|
||||||
HandleRoofDestruction( NewGridNo( pStructure->sGridNo, DirectionInc( NORTH ) ), damage * 0.75f );
|
if ( fWallHere )
|
||||||
HandleRoofDestruction( NewGridNo( pStructure->sGridNo, DirectionInc( EAST ) ), damage * 0.75f );
|
{
|
||||||
HandleRoofDestruction( NewGridNo( pStructure->sGridNo, DirectionInc( WEST ) ), damage * 0.75f );
|
HandleRoofDestruction( tmpgridno, damage * 0.75f );
|
||||||
HandleRoofDestruction( NewGridNo( pStructure->sGridNo, DirectionInc( SOUTH ) ), damage * 0.75f );
|
HandleRoofDestruction( NewGridNo( tmpgridno, DirectionInc( NORTH ) ), damage * 0.75f );
|
||||||
|
HandleRoofDestruction( NewGridNo( tmpgridno, DirectionInc( EAST ) ), damage * 0.75f );
|
||||||
|
HandleRoofDestruction( NewGridNo( tmpgridno, DirectionInc( WEST ) ), damage * 0.75f );
|
||||||
|
HandleRoofDestruction( NewGridNo( tmpgridno, DirectionInc( SOUTH ) ), damage * 0.75f );
|
||||||
|
}
|
||||||
|
|
||||||
|
RecompileLocalMovementCostsFromRadius( tmpgridno, 2 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1919,11 +1926,13 @@ INT8 DamageStructure( STRUCTURE * pStructure, UINT8 ubDamage, UINT8 ubReason, IN
|
|||||||
{
|
{
|
||||||
INT16 damage = 255;
|
INT16 damage = 255;
|
||||||
|
|
||||||
|
// the structure might not exists afterwards, thus we store the gridno
|
||||||
|
INT32 tmpgridno = pStructure->sGridNo;
|
||||||
BOOLEAN recompile = FALSE;
|
BOOLEAN recompile = FALSE;
|
||||||
ExplosiveDamageGridNo( sGridNo, damage, 10, &recompile, FALSE, -1, FALSE, ubOwner, 0, ubReason );
|
ExplosiveDamageGridNo( tmpgridno, damage, 10, &recompile, FALSE, -1, FALSE, ubOwner, 0, ubReason );
|
||||||
|
|
||||||
//Since the structure is being damaged, set the map element that a structure is damaged
|
//Since the structure is being damaged, set the map element that a structure is damaged
|
||||||
gpWorldLevelData[ sGridNo ].uiFlags |= MAPELEMENT_STRUCTURE_DAMAGED;
|
gpWorldLevelData[ tmpgridno ].uiFlags |= MAPELEMENT_STRUCTURE_DAMAGED;
|
||||||
|
|
||||||
// handle structure revenge - damage to vehicle
|
// handle structure revenge - damage to vehicle
|
||||||
if ( ubOwner != NOBODY && MercPtrs[ubOwner] && !ARMED_VEHICLE( MercPtrs[ubOwner] ) )
|
if ( ubOwner != NOBODY && MercPtrs[ubOwner] && !ARMED_VEHICLE( MercPtrs[ubOwner] ) )
|
||||||
@@ -1931,18 +1940,23 @@ INT8 DamageStructure( STRUCTURE * pStructure, UINT8 ubDamage, UINT8 ubReason, IN
|
|||||||
MercPtrs[ ubOwner ]->SoldierTakeDamage( 0, Random(max(0,(ubBaseArmour-10)/5))+max(0,(ubBaseArmour-10)/5), 0, TAKE_DAMAGE_STRUCTURE_EXPLOSION, NOBODY, MercPtrs[ ubOwner ]->sGridNo, 0, TRUE );
|
MercPtrs[ ubOwner ]->SoldierTakeDamage( 0, Random(max(0,(ubBaseArmour-10)/5))+max(0,(ubBaseArmour-10)/5), 0, TAKE_DAMAGE_STRUCTURE_EXPLOSION, NOBODY, MercPtrs[ ubOwner ]->sGridNo, 0, TRUE );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flugente: if we destroyed a wall, the roof might get damaged too
|
|
||||||
// recompile = TRUE means that we destroyed something
|
// recompile = TRUE means that we destroyed something
|
||||||
if ( fWallHere && recompile )
|
if ( recompile )
|
||||||
{
|
{
|
||||||
// lets not make it that extreme
|
// if we destroyed something, the roof might get damaged too
|
||||||
damage = 100;
|
if ( fWallHere )
|
||||||
|
{
|
||||||
|
// lets not make it that extreme
|
||||||
|
damage = 100;
|
||||||
|
|
||||||
HandleRoofDestruction( sGridNo, damage * 0.75f );
|
HandleRoofDestruction( tmpgridno, damage * 0.75f );
|
||||||
HandleRoofDestruction( NewGridNo( sGridNo, DirectionInc( NORTH ) ), damage * 0.75f );
|
HandleRoofDestruction( NewGridNo( tmpgridno, DirectionInc( NORTH ) ), damage * 0.75f );
|
||||||
HandleRoofDestruction( NewGridNo( sGridNo, DirectionInc( EAST ) ), damage * 0.75f );
|
HandleRoofDestruction( NewGridNo( tmpgridno, DirectionInc( EAST ) ), damage * 0.75f );
|
||||||
HandleRoofDestruction( NewGridNo( sGridNo, DirectionInc( WEST ) ), damage * 0.75f );
|
HandleRoofDestruction( NewGridNo( tmpgridno, DirectionInc( WEST ) ), damage * 0.75f );
|
||||||
HandleRoofDestruction( NewGridNo( sGridNo, DirectionInc( SOUTH ) ), damage * 0.75f );
|
HandleRoofDestruction( NewGridNo( tmpgridno, DirectionInc( SOUTH ) ), damage * 0.75f );
|
||||||
|
}
|
||||||
|
|
||||||
|
RecompileLocalMovementCostsFromRadius( tmpgridno, 2 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user