Difficulty setting AlwaysUpGradeAdminsToTroopsProgress forces admin upgrade to troops once enough player progress is reached.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8051 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2016-02-06 00:05:51 +00:00
parent 330925b0ef
commit fe545b9eb3
3 changed files with 88 additions and 71 deletions
+2 -1
View File
@@ -75,7 +75,8 @@ typedef struct
UINT8 iWeaponCacheTroops4; UINT8 iWeaponCacheTroops4;
UINT8 iWeaponCacheTroops5; UINT8 iWeaponCacheTroops5;
BOOLEAN bUpgradeAdminsToTroops; BOOLEAN bUpgradeAdminsToTroops;
BOOLEAN bUpgradeAdminsToTroops2; BOOLEAN bUpgradeGarrisonsAdminsToTroops;
UINT8 usAlwaysUpGradeAdminsToTroopsProgress;
BOOLEAN bQueenLosingControlOfSector; BOOLEAN bQueenLosingControlOfSector;
BOOLEAN bBloodcatAmbush; BOOLEAN bBloodcatAmbush;
BOOLEAN bAirRaidLookForDive; BOOLEAN bAirRaidLookForDive;
+74 -66
View File
@@ -6316,99 +6316,107 @@ void UpgradeAdminsToTroops()
// on normal, AI evaluates approximately every 10 hrs. There are about 130 administrators seeded on the map. // 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. // Some of these will be killed by the player.
UINT8 highestplayerprogress = HighestPlayerProgressPercentage( );
// check all garrisons for administrators // 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 for( i = 0; i < giGarrisonArraySize; ++i )
if ( (gWorldSectorX != 0) && (gWorldSectorY != 0) &&
(SECTOR( gWorldSectorX, gWorldSectorY ) == gGarrisonGroup[ i ].ubSectorID) )
{ {
continue; // 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) )
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 )
{ {
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 ubAdminsToCheck = pSector->ubNumAdmins;
if ( Chance ( bPriority ) || zDiffSetting[gGameOptions.ubDifficultyLevel].bUpgradeAdminsToTroops )
{
pSector->ubNumAdmins--;
pSector->ubNumTroops++;
}
--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 // check all moving enemy groups for administrators
pGroup = gpGroupList; if ( zDiffSetting[gGameOptions.ubDifficultyLevel].bUpgradeAdminsToTroops || highestplayerprogress >= zDiffSetting[gGameOptions.ubDifficultyLevel].usAlwaysUpGradeAdminsToTroopsProgress )
while( pGroup )
{ {
if ( pGroup->ubGroupSize && pGroup->usGroupTeam == ENEMY_TEAM && !pGroup->fVehicle ) pGroup = gpGroupList;
while( pGroup )
{ {
Assert ( pGroup->pEnemyGroup ); if ( pGroup->ubGroupSize && pGroup->usGroupTeam == ENEMY_TEAM && !pGroup->fVehicle )
// skip sector if it's currently loaded, we'll never upgrade guys in those
if ( ( pGroup->ubSectorX == gWorldSectorX ) && ( pGroup->ubSectorY == gWorldSectorY ) )
{ {
pGroup = pGroup->next; Assert ( pGroup->pEnemyGroup );
continue;
}
// if there are any admins currently in this group // skip sector if it's currently loaded, we'll never upgrade guys in those
if ( pGroup->pEnemyGroup->ubNumAdmins > 0 ) if ( ( pGroup->ubSectorX == gWorldSectorX ) && ( pGroup->ubSectorY == gWorldSectorY ) )
{
// if it's a patrol group
if ( pGroup->pEnemyGroup->ubIntention == PATROL )
{ {
sPatrolIndex = FindPatrolGroupIndexForGroupID( pGroup->ubGroupID ); pGroup = pGroup->next;
Assert( sPatrolIndex != -1 ); continue;
// 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 // if there are any admins currently in this group
// priority threshold required to start triggering upgrades by 10%. if ( pGroup->pEnemyGroup->ubNumAdmins > 0 )
if ( ( 100 - ( 10 * HighestPlayerProgressPercentage() ) ) < bPriority )
{ {
ubAdminsToCheck = pGroup->pEnemyGroup->ubNumAdmins; // if it's a patrol group
if ( pGroup->pEnemyGroup->ubIntention == PATROL )
while ( ubAdminsToCheck > 0)
{ {
// chance to upgrade at each check is random, and also dependant on the group's priority sPatrolIndex = FindPatrolGroupIndexForGroupID( pGroup->ubGroupID );
if ( Chance ( bPriority ) || zDiffSetting[gGameOptions.ubDifficultyLevel].bUpgradeAdminsToTroops2 ) Assert( sPatrolIndex != -1 );
{
pGroup->pEnemyGroup->ubNumAdmins--;
pGroup->pEnemyGroup->ubNumTroops++;
}
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;
}
} }
} }
+12 -4
View File
@@ -95,6 +95,7 @@ DifficultySettingsParseDataStartElementHandle(void *userData, const XML_Char *na
strcmp(name, "WeaponCacheTroops5") == 0 || strcmp(name, "WeaponCacheTroops5") == 0 ||
strcmp(name, "UpgradeAdminsToTroops") == 0 || strcmp(name, "UpgradeAdminsToTroops") == 0 ||
strcmp(name, "UpgradeGarrisonsAdminsToTroops") == 0 || strcmp(name, "UpgradeGarrisonsAdminsToTroops") == 0 ||
strcmp(name, "AlwaysUpGradeAdminsToTroopsProgress" ) == 0 ||
strcmp(name, "QueenAttackLosingControlOfSector") == 0 || strcmp(name, "QueenAttackLosingControlOfSector") == 0 ||
strcmp(name, "BloodcatAmbushSectors") == 0 || strcmp(name, "BloodcatAmbushSectors") == 0 ||
strcmp(name, "AirRaidLookForDive") == 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].iWeaponCacheTroops5 = pData->curDifficultySettings.iWeaponCacheTroops5;
zDiffSetting[pData->curDifficultySettings.uiIndex].bUpgradeAdminsToTroops = pData->curDifficultySettings.bUpgradeAdminsToTroops; 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; 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) else if(strcmp(name, "UpgradeAdminsToTroops") == 0)
{ {
pData->curElement = ELEMENT; pData->curElement = ELEMENT;
pData->curDifficultySettings.bUpgradeAdminsToTroops2 = (BOOLEAN) atol(pData->szCharData); pData->curDifficultySettings.bUpgradeAdminsToTroops = (BOOLEAN) atol(pData->szCharData);
} }
else if(strcmp(name, "UpgradeGarrisonsAdminsToTroops") == 0) else if(strcmp(name, "UpgradeGarrisonsAdminsToTroops") == 0)
{ {
pData->curElement = ELEMENT; 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) else if(strcmp(name, "QueenAttackLosingControlOfSector") == 0)
{ {
pData->curElement = ELEMENT; pData->curElement = ELEMENT;