mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
adjusted AI SAM site repairs:
- SAM sites are no longer repaired instantly when AI takes control of a sector - repairs begin 24 hours after the AI takes control, and repeat every 24 hours until the SAM is back at 100% - repairs can be interrupted by the player regaining control of the SAM site - time to repair a fully-destroyed SAM site depends on difficulty: novice takes 5 repair cycles, experienced takes 4, expert 3, and insane 2 - moved RepairSamSite() from ASD.h (where it was unused) into strategicmap.h - this sets up the existing but previously unused strategic event hook EVENT_SAMSITE_REPAIRED git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9349 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -1332,17 +1332,6 @@ void EnemyHeliCheckPlayerKnowledge( INT16 id )
|
||||
}
|
||||
}
|
||||
|
||||
void RepairSamSite( UINT8 aSector )
|
||||
{
|
||||
if ( IsThisSectorASAMSector( SECTORX( aSector ), SECTORY( aSector ), 0 ) )
|
||||
{
|
||||
StrategicMap[aSector].bSAMCondition = 100;
|
||||
StrategicMap[aSector].usFlags &= ~SAMSITE_REPAIR_ORDERED;
|
||||
|
||||
UpdateSAMDoneRepair( SECTORX( aSector ), SECTORY( aSector ), 0 );
|
||||
}
|
||||
}
|
||||
|
||||
UINT8 NumPlayerAirSpaceOnHeliPath( UINT8 aStart, UINT8 aEnd )
|
||||
{
|
||||
UINT8 samcontacts = 0;
|
||||
|
||||
@@ -104,8 +104,6 @@ void EnemyHeliSAMCheck( INT16 id );
|
||||
void EnemyHeliMANPADSCheck( INT16 id );
|
||||
void EnemyHeliCheckPlayerKnowledge( INT16 id );
|
||||
|
||||
void RepairSamSite( UINT8 aSector );
|
||||
|
||||
UINT8 NumPlayerAirSpaceOnHeliPath( UINT8 aStart, UINT8 aEnd );
|
||||
|
||||
// get the next sector in an enemy heli flight path.
|
||||
|
||||
@@ -266,6 +266,11 @@ BOOLEAN SetThisSectorAsPlayerControlled( INT16 sMapX, INT16 sMapY, INT8 bMapZ, B
|
||||
|
||||
StrategicMap[ usMapSector ].fEnemyControlled = FALSE;
|
||||
SectorInfo[ SECTOR( sMapX, sMapY ) ].fPlayer[ bMapZ ] = TRUE;
|
||||
if (IsThisSectorASAMSector(sMapX, sMapY, bMapZ))
|
||||
{
|
||||
StrategicMap[usMapSector].usFlags &= ~SAMSITE_REPAIR_ORDERED;
|
||||
DeleteStrategicEvent(EVENT_SAMSITE_REPAIRED, CALCULATE_STRATEGIC_INDEX(sMapX, sMapY));
|
||||
}
|
||||
|
||||
bTownId = StrategicMap[ usMapSector ].bNameId;
|
||||
|
||||
|
||||
@@ -2252,12 +2252,13 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Strategic5");
|
||||
|
||||
if( IsThisSectorASAMSector( pGroup->ubSectorX, pGroup->ubSectorY, 0 ) )
|
||||
{
|
||||
int stratsector = CALCULATE_STRATEGIC_INDEX( pGroup->ubSectorX, pGroup->ubSectorY );
|
||||
StrategicMap[stratsector].bSAMCondition = 100;
|
||||
StrategicMap[stratsector].sSamHackStatus = 100;
|
||||
StrategicMap[stratsector].usFlags &= ~SAMSITE_REPAIR_ORDERED;
|
||||
|
||||
UpdateSAMDoneRepair( pGroup->ubSectorX, pGroup->ubSectorY, 0 );
|
||||
UINT16 stratsector = CALCULATE_STRATEGIC_INDEX( pGroup->ubSectorX, pGroup->ubSectorY );
|
||||
if ((StrategicMap[stratsector].usFlags & SAMSITE_REPAIR_ORDERED) == 0 && (StrategicMap[stratsector].bSAMCondition < 100 || StrategicMap[stratsector].sSamHackStatus < 100))
|
||||
{
|
||||
StrategicMap[stratsector].usFlags |= SAMSITE_REPAIR_ORDERED;
|
||||
AddStrategicEvent(EVENT_SAMSITE_REPAIRED, GetWorldTotalMin() + 24 * 60, stratsector);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -5480,6 +5480,39 @@ BOOLEAN IsThisSectorASAMSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ )
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
void RepairSamSite( UINT16 strategicIndex )
|
||||
{
|
||||
INT8 repairAmount = 0;
|
||||
switch (gGameOptions.ubDifficultyLevel)
|
||||
{
|
||||
case DIF_LEVEL_EASY: repairAmount = AI_SAMSITE_REPAIR_EASY; break;
|
||||
case DIF_LEVEL_MEDIUM: repairAmount = AI_SAMSITE_REPAIR_MEDIUM; break;
|
||||
case DIF_LEVEL_HARD: repairAmount = AI_SAMSITE_REPAIR_HARD; break;
|
||||
case DIF_LEVEL_INSANE: repairAmount = AI_SAMSITE_REPAIR_INSANE; break;
|
||||
}
|
||||
|
||||
if ( StrategicMap[strategicIndex].fEnemyControlled && (StrategicMap[strategicIndex].usFlags & SAMSITE_REPAIR_ORDERED) && IsThisSectorASAMSector( GET_X_FROM_STRATEGIC_INDEX( strategicIndex ), GET_Y_FROM_STRATEGIC_INDEX( strategicIndex ), 0 ) )
|
||||
{
|
||||
if (StrategicMap[strategicIndex].bSAMCondition > 100 - repairAmount)
|
||||
StrategicMap[strategicIndex].bSAMCondition = 100;
|
||||
else
|
||||
StrategicMap[strategicIndex].bSAMCondition += repairAmount;
|
||||
|
||||
if (StrategicMap[strategicIndex].sSamHackStatus > 100 - repairAmount)
|
||||
StrategicMap[strategicIndex].sSamHackStatus = 100;
|
||||
else
|
||||
StrategicMap[strategicIndex].sSamHackStatus += repairAmount;
|
||||
|
||||
if (StrategicMap[strategicIndex].bSAMCondition < 100 || StrategicMap[strategicIndex].sSamHackStatus < 100)
|
||||
AddStrategicEvent(EVENT_SAMSITE_REPAIRED, GetWorldTotalMin() + 24 * 60, strategicIndex);
|
||||
else
|
||||
StrategicMap[strategicIndex].usFlags &= ~SAMSITE_REPAIR_ORDERED;
|
||||
|
||||
if (StrategicMap[strategicIndex].bSAMCondition >= MIN_CONDITION_FOR_SAM_SITE_TO_WORK)
|
||||
UpdateSAMDoneRepair( GET_X_FROM_STRATEGIC_INDEX( strategicIndex ), GET_Y_FROM_STRATEGIC_INDEX( strategicIndex ), 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// is this sector part of the town?
|
||||
BOOLEAN SectorIsPartOfTown( INT8 bTownId, INT16 sSectorX, INT16 sSectorY )
|
||||
|
||||
@@ -83,6 +83,10 @@ extern BOOLEAN gfUseAlternateMap;
|
||||
#define SECTOR_INFO_TO_STRATEGIC_INDEX( i ) ( CALCULATE_STRATEGIC_INDEX ( SECTORX( i ), SECTORY( i ) ) )
|
||||
#define STRATEGIC_INDEX_TO_SECTOR_INFO( i ) ( SECTOR( GET_X_FROM_STRATEGIC_INDEX( i ), GET_Y_FROM_STRATEGIC_INDEX( i ) ) )
|
||||
|
||||
#define AI_SAMSITE_REPAIR_EASY 20
|
||||
#define AI_SAMSITE_REPAIR_MEDIUM 25
|
||||
#define AI_SAMSITE_REPAIR_HARD 34
|
||||
#define AI_SAMSITE_REPAIR_INSANE 50
|
||||
|
||||
// grab the town id value
|
||||
UINT8 GetTownIdForSector( INT16 sMapX, INT16 sMapY );
|
||||
@@ -128,6 +132,8 @@ BOOLEAN DoesSamCoverSector( UINT8 usSam, UINT8 usSector, BOOLEAN* apSamIsWorking
|
||||
|
||||
BOOLEAN IsThisSectorASAMSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ );
|
||||
|
||||
void RepairSamSite( UINT16 aSector );
|
||||
|
||||
// init sam sites
|
||||
void InitializeSAMSites( void );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user