mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
- Fix: ASD did not take mercs on assignment into account
- Fix: crash when entering combat without any mercs in sector on duty git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8380 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+6
-6
@@ -449,7 +449,7 @@ void ASDDecideHeliOperations()
|
||||
// lower a sector's rating for the amount of militia and mercs here - no sense in dropping a squad into a killing field
|
||||
// for now, the AI simply knows the player's amount of troops - later on, try to rely on espionage
|
||||
UINT16 num_militia = CountAllMilitiaInFiveSectors( sX, sY );
|
||||
UINT16 num_mercs = PlayerMercsInSector( sX, sY, 0 );
|
||||
UINT16 num_mercs = NumPlayerTeamMembersInSector( sX, sY, 0);
|
||||
if ( num_militia + num_mercs )
|
||||
{
|
||||
if ( num_militia + num_mercs > 2 * gEnemyHeliMaxTroops )
|
||||
@@ -619,7 +619,7 @@ void ENEMY_HELI::Destroy( )
|
||||
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 )
|
||||
if ( NumPlayerTeamMembersInSector( 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 );
|
||||
}
|
||||
@@ -954,7 +954,7 @@ void UpdateEnemyHeli( INT16 id )
|
||||
heli.flagmask &= ~ENEMYHELI_ORDER_DROPTROOPS;
|
||||
|
||||
// if no militia or mercs are here, enemy takes this sector
|
||||
if ( PlayerMercsInSector( SECTORX( heli.sector_current ), SECTORY( heli.sector_current ), 0 ) + NumNonPlayerTeamMembersInSector( SECTORX( heli.sector_current ), SECTORY( heli.sector_current ), MILITIA_TEAM ) <= 0 )
|
||||
if ( NumPlayerTeamMembersInSector( SECTORX( heli.sector_current ), SECTORY( heli.sector_current ), 0 ) + NumNonPlayerTeamMembersInSector( SECTORX( heli.sector_current ), SECTORY( heli.sector_current ), MILITIA_TEAM ) <= 0 )
|
||||
{
|
||||
SetThisSectorAsEnemyControlled( SECTORX( heli.sector_current ), SECTORY( heli.sector_current ), 0, TRUE );
|
||||
}
|
||||
@@ -969,7 +969,7 @@ void UpdateEnemyHeli( INT16 id )
|
||||
if ( heli.flagmask & ENEMYHELI_ORDER_PICKUPTROOPS && heli.sector_current == heli.sector_destination )
|
||||
{
|
||||
// for now, not if the player is here
|
||||
if ( !PlayerMercsInSector( SECTORX( heli.sector_current ), SECTORY( heli.sector_current ), 0 ) )
|
||||
if ( !NumPlayerTeamMembersInSector( SECTORX( heli.sector_current ), SECTORY( heli.sector_current ), 0 ) )
|
||||
{
|
||||
if ( heli.troopcount < gEnemyHeliMaxTroops )
|
||||
{
|
||||
@@ -1209,7 +1209,7 @@ void EnemyHeliCheckPlayerKnowledge( INT16 id )
|
||||
INT8 current_y = SECTORY( heli.sector_current );
|
||||
|
||||
// if there are mercs in this sector, they spot the heli and let us know
|
||||
if ( PlayerMercsInSector( current_x, current_y, 0 ) )
|
||||
if ( NumPlayerTeamMembersInSector( current_x, current_y, 0 ) )
|
||||
{
|
||||
// if we previously did not know of the heli, our mercs will alert us
|
||||
if ( !(heli.flagmask & ENEMYHELI_KNOWNTOPLAYER) )
|
||||
@@ -1241,7 +1241,7 @@ void EnemyHeliCheckPlayerKnowledge( INT16 id )
|
||||
if ( DoesSamCoverSector( i, heli.sector_current ) )
|
||||
{
|
||||
// if mercs man the SAM, they will let us know of the new SAM
|
||||
if ( PlayerMercsInSector( gpSamSectorX[i], gpSamSectorY[i], 0 ) )
|
||||
if ( NumPlayerTeamMembersInSector( gpSamSectorX[i], gpSamSectorY[i], 0 ) )
|
||||
{
|
||||
// if we previously did not know of the heli, our mercs will alert us
|
||||
if ( !(heli.flagmask & ENEMYHELI_KNOWNTOPLAYER) )
|
||||
|
||||
@@ -286,6 +286,29 @@ UINT8 NumNonPlayerTeamMembersInSector( INT16 sSectorX, INT16 sSectorY, UINT8 ubT
|
||||
return ubNumTroops;
|
||||
}
|
||||
|
||||
// returns how many members of a team are in a sector - only intended for OUR_TEAM! POWs not included
|
||||
UINT16 NumPlayerTeamMembersInSector( INT16 sSectorX, INT16 sSectorY, INT8 sSectorZ )
|
||||
{
|
||||
UINT16 teammemberspresent = 0;
|
||||
|
||||
SOLDIERTYPE* pTeamSoldier = NULL;
|
||||
UINT16 bMercID = gTacticalStatus.Team[gbPlayerNum].bFirstID;
|
||||
UINT16 bLastTeamID = gTacticalStatus.Team[gbPlayerNum].bLastID;
|
||||
for ( pTeamSoldier = MercPtrs[bMercID]; bMercID <= bLastTeamID; ++bMercID, pTeamSoldier++ )
|
||||
{
|
||||
// we test several conditions before we allow adding an opinion
|
||||
// other merc must be active, have a profile, be someone else and not be in transit or dead
|
||||
if ( pTeamSoldier->bActive && !pTeamSoldier->flags.fBetweenSectors && pTeamSoldier->stats.bLife > 0 && !(pTeamSoldier->flags.uiStatusFlags & SOLDIER_VEHICLE) &&
|
||||
!(pTeamSoldier->bAssignment == IN_TRANSIT || pTeamSoldier->bAssignment == ASSIGNMENT_DEAD || pTeamSoldier->bAssignment == ASSIGNMENT_POW) &&
|
||||
(pTeamSoldier->sSectorX == sSectorX && pTeamSoldier->sSectorY == sSectorY && pTeamSoldier->bSectorZ == sSectorZ) )
|
||||
{
|
||||
++teammemberspresent;
|
||||
}
|
||||
}
|
||||
|
||||
return teammemberspresent;
|
||||
}
|
||||
|
||||
UINT16 NumEnemyArmedVehiclesInSector( INT16 sSectorX, INT16 sSectorY, UINT8 usTeam )
|
||||
{
|
||||
SECTORINFO *pSector;
|
||||
|
||||
@@ -22,6 +22,9 @@ UINT8 NumEnemiesInAnySector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ );
|
||||
// returns how many members of a team are in a sector - not intended for OUR_TEAM!
|
||||
UINT8 NumNonPlayerTeamMembersInSector( INT16 sSectorX, INT16 sSectorY, UINT8 ubTeam );
|
||||
|
||||
// returns how many members of a team are in a sector - only intended for OUR_TEAM! POWs not included
|
||||
UINT16 NumPlayerTeamMembersInSector( INT16 sSectorX, INT16 sSectorY, INT8 sSectorZ );
|
||||
|
||||
UINT16 NumEnemyArmedVehiclesInSector( INT16 sSectorX, INT16 sSectorY, UINT8 usTeam );
|
||||
UINT8 NumStationaryEnemiesInSector( INT16 sSectorX, INT16 sSectorY );
|
||||
UINT8 NumMobileEnemiesInSector( INT16 sSectorX, INT16 sSectorY );
|
||||
|
||||
@@ -22387,7 +22387,7 @@ BOOLEAN IsValidArtilleryOrderSector( INT16 sSectorX, INT16 sSectorY, INT8 bSecto
|
||||
|
||||
UINT16 usEnemies = (UINT16)NumNonPlayerTeamMembersInSector( sSectorX, sSectorY, ENEMY_TEAM );
|
||||
UINT16 usMilitia = (UINT16)NumNonPlayerTeamMembersInSector( sSectorX, sSectorY, MILITIA_TEAM );
|
||||
UINT16 usMercs = (UINT16)PlayerMercsInSector( (UINT8)sSectorX, (UINT8)sSectorY, (UINT8)bSectorZ );
|
||||
UINT16 usMercs = NumPlayerTeamMembersInSector( sSectorX, sSectorY, bSectorZ );
|
||||
|
||||
SECTORINFO *pSectorInfo = &(SectorInfo[SECTOR( sSectorX, sSectorY )]);
|
||||
|
||||
|
||||
@@ -340,18 +340,16 @@ void InitTacticalPlacementGUI()
|
||||
//First pass: Count the number of mercs that are going to be placed by the player.
|
||||
// This determines the size of the array we will allocate.
|
||||
giPlacements = 0;
|
||||
for( i = gTacticalStatus.Team[ OUR_TEAM ].bFirstID; i <= gTacticalStatus.Team[ OUR_TEAM ].bLastID; i++ )
|
||||
for( i = gTacticalStatus.Team[ OUR_TEAM ].bFirstID; i <= gTacticalStatus.Team[ OUR_TEAM ].bLastID; ++i )
|
||||
{
|
||||
|
||||
if( MercPtrs[ i ]->bActive && !MercPtrs[ i ]->flags.fBetweenSectors &&
|
||||
MercPtrs[ i ]->sSectorX == gpBattleGroup->ubSectorX &&
|
||||
MercPtrs[ i ]->sSectorY == gpBattleGroup->ubSectorY &&
|
||||
CurrentBattleSectorIs( MercPtrs[i]->sSectorX, MercPtrs[i]->sSectorY, MercPtrs[i]->bSectorZ ) &&
|
||||
!( MercPtrs[ i ]->flags.uiStatusFlags & ( SOLDIER_VEHICLE ) ) && // ATE Ignore vehicles
|
||||
MercPtrs[ i ]->bAssignment != ASSIGNMENT_POW &&
|
||||
MercPtrs[ i ]->bAssignment != IN_TRANSIT &&
|
||||
!MercPtrs[ i ]->bSectorZ )
|
||||
MercPtrs[ i ]->bAssignment != IN_TRANSIT )
|
||||
{
|
||||
giPlacements++;
|
||||
++giPlacements;
|
||||
}
|
||||
}
|
||||
//Allocate the array based on how many mercs there are.
|
||||
@@ -362,12 +360,10 @@ void InitTacticalPlacementGUI()
|
||||
for( i = gTacticalStatus.Team[ OUR_TEAM ].bFirstID; i <= gTacticalStatus.Team[ OUR_TEAM ].bLastID; ++i )
|
||||
{
|
||||
if( MercPtrs[ i ]->bActive && MercPtrs[ i ]->stats.bLife && !MercPtrs[ i ]->flags.fBetweenSectors &&
|
||||
MercPtrs[ i ]->sSectorX == gpBattleGroup->ubSectorX &&
|
||||
MercPtrs[ i ]->sSectorY == gpBattleGroup->ubSectorY &&
|
||||
CurrentBattleSectorIs( MercPtrs[i]->sSectorX, MercPtrs[i]->sSectorY, MercPtrs[i]->bSectorZ ) &&
|
||||
MercPtrs[ i ]->bAssignment != ASSIGNMENT_POW &&
|
||||
MercPtrs[ i ]->bAssignment != IN_TRANSIT &&
|
||||
!( MercPtrs[ i ]->flags.uiStatusFlags & ( SOLDIER_VEHICLE ) ) && // ATE Ignore vehicles
|
||||
!MercPtrs[ i ]->bSectorZ )
|
||||
!( MercPtrs[ i ]->flags.uiStatusFlags & ( SOLDIER_VEHICLE ) ) ) // ATE Ignore vehicles
|
||||
{
|
||||
// Flugente: if options allow it and we entered this sector - in combat - via helicopter, then allow us free selection of our entry point, and drop us from the helicopter
|
||||
if ( MercPtrs[ i ]->bTeam == gbPlayerNum && gGameExternalOptions.ubSkyriderHotLZ == 3 && MercPtrs[ i ]->usSoldierFlagMask & SOLDIER_AIRDROP )
|
||||
|
||||
Reference in New Issue
Block a user