diff --git a/GameInitOptionsScreen.h b/GameInitOptionsScreen.h index 65b94d85..aed65efc 100644 --- a/GameInitOptionsScreen.h +++ b/GameInitOptionsScreen.h @@ -75,7 +75,8 @@ typedef struct UINT8 iWeaponCacheTroops4; UINT8 iWeaponCacheTroops5; BOOLEAN bUpgradeAdminsToTroops; - BOOLEAN bUpgradeAdminsToTroops2; + BOOLEAN bUpgradeGarrisonsAdminsToTroops; + UINT8 usAlwaysUpGradeAdminsToTroopsProgress; BOOLEAN bQueenLosingControlOfSector; BOOLEAN bBloodcatAmbush; BOOLEAN bAirRaidLookForDive; diff --git a/Strategic/Strategic AI.cpp b/Strategic/Strategic AI.cpp index ac232133..f4c4109d 100644 --- a/Strategic/Strategic AI.cpp +++ b/Strategic/Strategic AI.cpp @@ -6316,99 +6316,107 @@ void UpgradeAdminsToTroops() // on normal, AI evaluates approximately every 10 hrs. There are about 130 administrators seeded on the map. // Some of these will be killed by the player. + UINT8 highestplayerprogress = HighestPlayerProgressPercentage( ); + // check all garrisons for administrators - for( i = 0; i < giGarrisonArraySize; ++i ) + if ( zDiffSetting[gGameOptions.ubDifficultyLevel].bUpgradeGarrisonsAdminsToTroops || highestplayerprogress >= zDiffSetting[gGameOptions.ubDifficultyLevel].usAlwaysUpGradeAdminsToTroopsProgress ) { - // skip sector if it's currently loaded, we'll never upgrade guys in those - if ( (gWorldSectorX != 0) && (gWorldSectorY != 0) && - (SECTOR( gWorldSectorX, gWorldSectorY ) == gGarrisonGroup[ i ].ubSectorID) ) + for( i = 0; i < giGarrisonArraySize; ++i ) { - continue; - } - - pSector = &SectorInfo[ gGarrisonGroup[ i ].ubSectorID ]; - - // if there are any admins currently in this garrison - if ( pSector->ubNumAdmins > 0 ) - { - bPriority = gArmyComp[ gGarrisonGroup[ i ].ubComposition ].bPriority; - - // highest priority sectors are upgraded first. Each 1% of progress lower the - // priority threshold required to start triggering upgrades by 10%. - if ( ( 100 - ( 10 * HighestPlayerProgressPercentage() ) ) < bPriority ) + // skip sector if it's currently loaded, we'll never upgrade guys in those + if ( (gWorldSectorX != 0) && (gWorldSectorY != 0) && + (SECTOR( gWorldSectorX, gWorldSectorY ) == gGarrisonGroup[ i ].ubSectorID) ) { - ubAdminsToCheck = pSector->ubNumAdmins; + continue; + } - while ( ubAdminsToCheck > 0) + pSector = &SectorInfo[ gGarrisonGroup[ i ].ubSectorID ]; + + // if there are any admins currently in this garrison + if ( pSector->ubNumAdmins > 0 ) + { + bPriority = gArmyComp[ gGarrisonGroup[ i ].ubComposition ].bPriority; + + // highest priority sectors are upgraded first. Each 1% of progress lower the + // priority threshold required to start triggering upgrades by 10%. + if ( (100 - (10 * highestplayerprogress)) < bPriority ) { - // chance to upgrade at each check is random, and also dependant on the garrison's priority - if ( Chance ( bPriority ) || zDiffSetting[gGameOptions.ubDifficultyLevel].bUpgradeAdminsToTroops ) - { - pSector->ubNumAdmins--; - pSector->ubNumTroops++; - } + ubAdminsToCheck = pSector->ubNumAdmins; - --ubAdminsToCheck; + while ( ubAdminsToCheck > 0) + { + // chance to upgrade at each check is random, and also dependant on the garrison's priority + if ( Chance ( bPriority ) ) + { + pSector->ubNumAdmins--; + pSector->ubNumTroops++; + } + + --ubAdminsToCheck; + } } } } } // check all moving enemy groups for administrators - pGroup = gpGroupList; - while( pGroup ) + if ( zDiffSetting[gGameOptions.ubDifficultyLevel].bUpgradeAdminsToTroops || highestplayerprogress >= zDiffSetting[gGameOptions.ubDifficultyLevel].usAlwaysUpGradeAdminsToTroopsProgress ) { - if ( pGroup->ubGroupSize && pGroup->usGroupTeam == ENEMY_TEAM && !pGroup->fVehicle ) + pGroup = gpGroupList; + while( pGroup ) { - Assert ( pGroup->pEnemyGroup ); - - // skip sector if it's currently loaded, we'll never upgrade guys in those - if ( ( pGroup->ubSectorX == gWorldSectorX ) && ( pGroup->ubSectorY == gWorldSectorY ) ) + if ( pGroup->ubGroupSize && pGroup->usGroupTeam == ENEMY_TEAM && !pGroup->fVehicle ) { - pGroup = pGroup->next; - continue; - } + Assert ( pGroup->pEnemyGroup ); - // if there are any admins currently in this group - if ( pGroup->pEnemyGroup->ubNumAdmins > 0 ) - { - // if it's a patrol group - if ( pGroup->pEnemyGroup->ubIntention == PATROL ) + // skip sector if it's currently loaded, we'll never upgrade guys in those + if ( ( pGroup->ubSectorX == gWorldSectorX ) && ( pGroup->ubSectorY == gWorldSectorY ) ) { - sPatrolIndex = FindPatrolGroupIndexForGroupID( pGroup->ubGroupID ); - Assert( sPatrolIndex != -1 ); - - // use that patrol's priority - bPriority = gPatrolGroup[ sPatrolIndex ].bPriority; - } - else // not a patrol group - { - // use a default priority - bPriority = 50; + pGroup = pGroup->next; + continue; } - // highest priority groups are upgraded first. Each 1% of progress lower the - // priority threshold required to start triggering upgrades by 10%. - if ( ( 100 - ( 10 * HighestPlayerProgressPercentage() ) ) < bPriority ) + // if there are any admins currently in this group + if ( pGroup->pEnemyGroup->ubNumAdmins > 0 ) { - ubAdminsToCheck = pGroup->pEnemyGroup->ubNumAdmins; - - while ( ubAdminsToCheck > 0) + // if it's a patrol group + if ( pGroup->pEnemyGroup->ubIntention == PATROL ) { - // chance to upgrade at each check is random, and also dependant on the group's priority - if ( Chance ( bPriority ) || zDiffSetting[gGameOptions.ubDifficultyLevel].bUpgradeAdminsToTroops2 ) - { - pGroup->pEnemyGroup->ubNumAdmins--; - pGroup->pEnemyGroup->ubNumTroops++; - } + sPatrolIndex = FindPatrolGroupIndexForGroupID( pGroup->ubGroupID ); + Assert( sPatrolIndex != -1 ); - ubAdminsToCheck--; + // use that patrol's priority + bPriority = gPatrolGroup[ sPatrolIndex ].bPriority; + } + else // not a patrol group + { + // use a default priority + bPriority = 50; + } + + // highest priority groups are upgraded first. Each 1% of progress lower the + // priority threshold required to start triggering upgrades by 10%. + if ( (100 - (10 * highestplayerprogress)) < bPriority ) + { + ubAdminsToCheck = pGroup->pEnemyGroup->ubNumAdmins; + + while ( ubAdminsToCheck > 0) + { + // chance to upgrade at each check is random, and also dependant on the group's priority + if ( Chance ( bPriority ) ) + { + pGroup->pEnemyGroup->ubNumAdmins--; + pGroup->pEnemyGroup->ubNumTroops++; + } + + ubAdminsToCheck--; + } } } } - } - pGroup = pGroup->next; + pGroup = pGroup->next; + } } } diff --git a/XML_DifficultySettings.cpp b/XML_DifficultySettings.cpp index 76d67a20..e7fa15e9 100644 --- a/XML_DifficultySettings.cpp +++ b/XML_DifficultySettings.cpp @@ -95,6 +95,7 @@ DifficultySettingsParseDataStartElementHandle(void *userData, const XML_Char *na strcmp(name, "WeaponCacheTroops5") == 0 || strcmp(name, "UpgradeAdminsToTroops") == 0 || strcmp(name, "UpgradeGarrisonsAdminsToTroops") == 0 || + strcmp(name, "AlwaysUpGradeAdminsToTroopsProgress" ) == 0 || strcmp(name, "QueenAttackLosingControlOfSector") == 0 || strcmp(name, "BloodcatAmbushSectors") == 0 || strcmp(name, "AirRaidLookForDive") == 0 || @@ -202,7 +203,8 @@ difficultySettingsEndElementHandle(void *userData, const XML_Char *name) zDiffSetting[pData->curDifficultySettings.uiIndex].iWeaponCacheTroops5 = pData->curDifficultySettings.iWeaponCacheTroops5; zDiffSetting[pData->curDifficultySettings.uiIndex].bUpgradeAdminsToTroops = pData->curDifficultySettings.bUpgradeAdminsToTroops; - zDiffSetting[pData->curDifficultySettings.uiIndex].bUpgradeAdminsToTroops2 = pData->curDifficultySettings.bUpgradeAdminsToTroops2; + zDiffSetting[pData->curDifficultySettings.uiIndex].bUpgradeGarrisonsAdminsToTroops = pData->curDifficultySettings.bUpgradeGarrisonsAdminsToTroops; + zDiffSetting[pData->curDifficultySettings.uiIndex].usAlwaysUpGradeAdminsToTroopsProgress = pData->curDifficultySettings.usAlwaysUpGradeAdminsToTroopsProgress; zDiffSetting[pData->curDifficultySettings.uiIndex].bQueenLosingControlOfSector = pData->curDifficultySettings.bQueenLosingControlOfSector; @@ -470,13 +472,19 @@ difficultySettingsEndElementHandle(void *userData, const XML_Char *name) else if(strcmp(name, "UpgradeAdminsToTroops") == 0) { pData->curElement = ELEMENT; - pData->curDifficultySettings.bUpgradeAdminsToTroops2 = (BOOLEAN) atol(pData->szCharData); + pData->curDifficultySettings.bUpgradeAdminsToTroops = (BOOLEAN) atol(pData->szCharData); } else if(strcmp(name, "UpgradeGarrisonsAdminsToTroops") == 0) { pData->curElement = ELEMENT; - pData->curDifficultySettings.bUpgradeAdminsToTroops = (BOOLEAN) atol(pData->szCharData); - } + pData->curDifficultySettings.bUpgradeGarrisonsAdminsToTroops = (BOOLEAN)atol( pData->szCharData ); + } + else if ( strcmp( name, "AlwaysUpGradeAdminsToTroopsProgress" ) == 0 ) + { + pData->curElement = ELEMENT; + pData->curDifficultySettings.usAlwaysUpGradeAdminsToTroopsProgress = (UINT8)atol( pData->szCharData ); + pData->curDifficultySettings.usAlwaysUpGradeAdminsToTroopsProgress = min( pData->curDifficultySettings.usAlwaysUpGradeAdminsToTroopsProgress, 100 ); + } else if(strcmp(name, "QueenAttackLosingControlOfSector") == 0) { pData->curElement = ELEMENT;