If a downed enemy helicopter had soldiers on it, there is a chance that they survived the crash.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8016 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2016-01-09 22:28:26 +00:00
parent 7664342746
commit f3acdb5963
5 changed files with 39 additions and 13 deletions
+34 -7
View File
@@ -354,6 +354,10 @@ void ASDDecideHeliOperations()
if ( (*it).flagmask & ENEMYHELI_ORDERS )
continue;
// if we dont have enough soldiers left to staff a helicopter, don't send one out
if ( giReinforcementPool < gEnemyHeliMaxTroops )
continue;
ENEMY_HELI& heli = (*it);
UINT32 totalrating = 0;
@@ -569,10 +573,8 @@ UINT8 ENEMY_HELI::SetHeliFlightPath( UINT8 aDest )
void ENEMY_HELI::Destroy( )
{
troopcount = 0;
hp = 0;
fuel = 0;
flagmask |= ENEMYHELI_DESTROYED;
// if the player knows about this heli, play a sound and leave a message
@@ -590,16 +592,41 @@ void ENEMY_HELI::Destroy( )
}
}
// if a helicopter was shot down, remember that for the sector - we might spawn a downed pilot for the player to search!
// if a helicopter was shot down, there might be survivors or wreckage
if ( flagmask & ENEMYHELI_SHOTDOWN )
{
SECTORINFO *pSectorInfo = &(SectorInfo[sector_current]);
// remember that a heli crashed here. When entering the sector the next time, we might spawn a downed pilot or wreckage
SectorInfo[sector_current].usSectorInfoFlag |= SECTORINFO_ENEMYHELI_SHOTDOWN;
if ( pSectorInfo )
// if the heli had soldiers aboard, they might have survived the crash. Add them to the sector in that case
// don't do this in sectors that are impassable
if ( troopcount && !SectorIsImpassable( sector_current ) )
{
pSectorInfo->usSectorInfoFlag |= SECTORINFO_ENEMYHELI_SHOTDOWN;
// it is possible that we shoot down a helicopter while in a fight. In this case, adding soldiers to a sector would either cause a second battle or a state where a fight should start but doesn't
// both is bad, so we simply don't add soldiers in that case. The player will hardly notice, as there is only a chance that soldiers survive anyway
if ( !gTacticalStatus.fEnemyInSector && !(gTacticalStatus.uiFlags & INCOMBAT) )
{
// chance that they survived at all
if ( Chance( 75 ) )
{
// not all might have made it
SectorInfo[sector_current].ubNumElites = min( 255, SectorInfo[sector_current].ubNumElites + 1 + Random(troopcount) );
// if no militia or mercs are here, enemy takes this sector
if ( PlayerMercsInSector( SECTORX( sector_current ), SECTORY( sector_current ), 0 ) + NumNonPlayerTeamMembersInSector( SECTORX( sector_current ), SECTORY( sector_current ), MILITIA_TEAM ) <= 0 )
{
SetThisSectorAsEnemyControlled( SECTORX( sector_current ), SECTORY( sector_current ), 0, TRUE );
}
CheckCombatInSectorDueToUnusualEnemyArrival( ENEMY_TEAM, SECTORX( sector_current ), SECTORY( sector_current ), 0 );
}
}
}
}
// reduce these at the end, as we might do sth based on them
fuel = 0;
troopcount = 0;
}
void EnemyHeliInit( )
-2
View File
@@ -167,8 +167,6 @@ void GenerateMilitiaSquad(INT16 sMapX, INT16 sMapY, INT16 sTMapX, INT16 sTMapY,
UINT16 usTotalMilitiaAtTarget = NumNonPlayerTeamMembersInSector( sTMapX, sTMapY, MILITIA_TEAM );
// Desired number of Greens, Regulars and Elites to create.
UINT8 ubTargetGreen, ubTargetRegular, ubTargetElite;
// Upgrade points for replacing militia with better ones.
UINT8 ubUpgradePoints;
// Calculate default number of militia to place in Target Sector.
UINT8 ubMilitiaToTrain = gGameExternalOptions.guiNumMobileMilitiaTrained;
// Percentage of troops that should be of any one type:
-1
View File
@@ -30,7 +30,6 @@ extern void UpdateCustomMapMovementCosts(); // ja25 UB
extern void MakeBadSectorListFromMapsOnHardDrive( BOOLEAN fDisplayMessages ); // ja25 UB
extern void AddCustomMap( INT32 iRow, INT32 iCol, BOOLEAN fDisplayMessages, BOOLEAN fMessageIfNotExist ); //ja25 UB
extern UNDERGROUND_SECTORINFO* NewUndergroundNode( UINT8 ubSectorX, UINT8 ubSectorY, UINT8 ubSectorZ );
extern BOOLEAN SectorIsImpassableUB( INT16 sSector );
#endif
typedef enum
+2
View File
@@ -304,6 +304,8 @@ void RandomizePatrolGroupLocation( GROUP *pGroup );
BOOLEAN InitStrategicMovementCosts();
BOOLEAN SectorIsImpassable( INT16 sSector );
void PlaceGroupInSector( UINT8 ubGroupID, INT16 sPrevX, INT16 sPrevY, INT16 sNextX, INT16 sNextY, INT8 bZ, BOOLEAN fCheckForBattle );
void SetGroupArrivalTime( GROUP *pGroup, UINT32 uiArrivalTime );
+3 -3
View File
@@ -1971,18 +1971,18 @@ UINT16 CountSurfaceSectorsVisited( void )
return( ubSectorsVisited );
}
// HEADROCK: Count number of VISITABLE sectors
UINT16 TotalVisitableSurfaceSectors( void )
{
UINT8 ubMapX, ubMapY;
UINT16 ubVisitableSectors = 0;
for ( ubMapX = 1; ubMapX < MAP_WORLD_X - 1; ubMapX++ )
{
for ( ubMapY = 1; ubMapY < MAP_WORLD_Y - 1; ubMapY++ )
{
if( SectorInfo[ SECTOR(ubMapX,ubMapY) ].ubTraversability[ THROUGH_STRATEGIC_MOVE ] != GROUNDBARRIER && SectorInfo[ SECTOR(ubMapX,ubMapY) ].ubTraversability[ THROUGH_STRATEGIC_MOVE ] != EDGEOFWORLD )
if ( !SectorIsImpassable( SECTOR( ubMapX, ubMapY ) ) )
++ubVisitableSectors;
}
}