Fixed bug in ASD code causing enemy patrols to have 0 elites no matter if ASD was enabled or not. I also changed the ASD feature, for patrols only, to assign tanks and jeeps in place of elites. So if the patrol spawned without any elite it can't have tank and jeep. Robots are still placed instead of regular troops, which however means that patrol full of elites will never have any robots.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9287 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Shadooow
2022-02-02 03:41:34 +00:00
parent 52a42d0354
commit 31b17d99d0
2 changed files with 43 additions and 2 deletions
+42 -2
View File
@@ -3146,7 +3146,10 @@ BOOLEAN SendReinforcementsForGarrison( INT32 iDstGarrisonID, UINT16 usDefencePoi
pGroup = CreateNewEnemyGroupDepartingFromSector( SECTOR( gModSettings.ubSAISpawnSectorX, gModSettings.ubSAISpawnSectorY ), 0, (UINT8)iReinforcementsApproved, 0, 0, 0, 0 );
ConvertGroupTroopsToComposition( pGroup, gGarrisonGroup[ iDstGarrisonID ].ubComposition );
pGroup->ubOriginalSector = (UINT8)SECTOR( ubDstSectorX, ubDstSectorY );
InitializeGroup(GROUP_TYPE_PATROL, (UINT8)iReinforcementsApproved, *pGroup->pEnemyGroup, Random(10) < gGameOptions.ubDifficultyLevel );
if (gGameExternalOptions.fASDActive && Random(10) < gGameOptions.ubDifficultyLevel)
{
ASDInitializePatrolGroup(pGroup);
}
//Madd: unlimited reinforcements?
if ( !gfUnlimitedTroops )
giReinforcementPool -= iReinforcementsApproved;
@@ -3236,7 +3239,10 @@ BOOLEAN SendReinforcementsForGarrison( INT32 iDstGarrisonID, UINT16 usDefencePoi
pGroup = CreateNewEnemyGroupDepartingFromSector( gGarrisonGroup[ iSrcGarrisonID ].ubSectorID, 0, (UINT8)iReinforcementsApproved, 0, 0, 0, 0 );
ConvertGroupTroopsToComposition( pGroup, gGarrisonGroup[ iDstGarrisonID ].ubComposition );
InitializeGroup(GROUP_TYPE_PATROL, (UINT8)iReinforcementsApproved, *pGroup->pEnemyGroup, Random(10) < gGameOptions.ubDifficultyLevel );
if (gGameExternalOptions.fASDActive && Random(10) < gGameOptions.ubDifficultyLevel)
{
ASDInitializePatrolGroup(pGroup);
}
RemoveSoldiersFromGarrisonBasedOnComposition( iSrcGarrisonID, pGroup->ubGroupSize );
pGroup->ubOriginalSector = (UINT8)SECTOR( ubDstSectorX, ubDstSectorY );
pGroup->ubMoveType = ONE_WAY;
@@ -7047,6 +7053,40 @@ GROUP* FindPendingGroupForGarrisonSector( UINT8 ubSectorID )
return NULL;
}
//Shadooow: new function to upgrade patrols groups with ASD to avoid overriding default patrol team composition
void ASDInitializePatrolGroup(GROUP *pGroup)
{
if (pGroup->ubGroupSize > 0 && pGroup->pEnemyGroup->ubNumElites > 0)
{
if (gGameExternalOptions.fASDAssignsTanks && ASDSoldierUpgradeToTank())
{
pGroup->pEnemyGroup->ubNumElites--;
pGroup->pEnemyGroup->ubNumTanks++;
}
if (pGroup->pEnemyGroup->ubNumElites > 0 && gGameExternalOptions.fASDAssignsJeeps && ASDSoldierUpgradeToJeep())
{
pGroup->pEnemyGroup->ubNumElites--;
pGroup->pEnemyGroup->ubNumJeeps++;
}
if (pGroup->pEnemyGroup->ubNumTroops > 0 && gGameExternalOptions.fASDAssignsRobots && ASDSoldierUpgradeToRobot())
{
int numRobots = 1 + Random(gGameOptions.ubDifficultyLevel);
if (numRobots > pGroup->pEnemyGroup->ubNumTroops)
{
pGroup->pEnemyGroup->ubNumRobots += pGroup->pEnemyGroup->ubNumTroops;
pGroup->pEnemyGroup->ubNumTroops = 0;
}
else
{
pGroup->pEnemyGroup->ubNumRobots += numRobots;
pGroup->pEnemyGroup->ubNumTroops -= numRobots;
}
}
}
}
void InitializeGroup( const GROUP_TYPE groupType, const UINT8 groupSize, ENEMYGROUP& enemyGroup, const BOOLEAN asdUpgrade )
{
InitializeGroup( groupType, groupSize, enemyGroup.ubNumTroops, enemyGroup.ubNumElites, enemyGroup.ubNumRobots, enemyGroup.ubNumJeeps, enemyGroup.ubNumTanks, asdUpgrade );
+1
View File
@@ -81,6 +81,7 @@ enum GROUP_TYPE
GROUP_TYPE_PATROL
};
void ASDInitializePatrolGroup(GROUP *pGroup);
void InitializeGroup(const GROUP_TYPE groupType, const UINT8 groupSize, ENEMYGROUP& enemyGroup, const BOOLEAN asdUpgrade);
void InitializeGroup(const GROUP_TYPE groupType, const UINT8 groupSize, UINT8 &troopCount, UINT8 &eliteCount, UINT8 &robotCount, UINT8 &jeepCount, UINT8 &tankCount, const BOOLEAN asdUpgrade);