mirror of
https://github.com/1dot13/source.git
synced 2026-09-16 14:47:17 +02:00
If not enough militia can be trained due to a lack of volunteers, excess trainign goes into militia promotions instead.
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7767 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -7674,15 +7674,17 @@ void DisplayMilitiaGroupBox()
|
|||||||
|
|
||||||
SetFont( FONT12ARIAL );
|
SetFont( FONT12ARIAL );
|
||||||
|
|
||||||
if ( GetVolunteerPool() >= 2 * gGameExternalOptions.iTrainingSquadSize )
|
INT32 volunteers = GetVolunteerPool();
|
||||||
|
|
||||||
|
if ( volunteers >= 2 * gGameExternalOptions.iTrainingSquadSize )
|
||||||
SetFontForeground( FONT_FCOLOR_GREEN );
|
SetFontForeground( FONT_FCOLOR_GREEN );
|
||||||
else if ( GetVolunteerPool( ) >= gGameExternalOptions.iTrainingSquadSize )
|
else if ( volunteers >= gGameExternalOptions.iTrainingSquadSize )
|
||||||
SetFontForeground( FONT_FCOLOR_YELLOW );
|
SetFontForeground( FONT_FCOLOR_YELLOW );
|
||||||
else
|
else
|
||||||
SetFontForeground( FONT_FCOLOR_RED );
|
SetFontForeground( FONT_FCOLOR_RED );
|
||||||
|
|
||||||
// header
|
// header
|
||||||
swprintf( sVolunteerString, szMilitiaStrategicMovementText[8], GetVolunteerPool( ), CalcHourlyVolunteerGain( ) );
|
swprintf( sVolunteerString, szMilitiaStrategicMovementText[8], volunteers, CalcHourlyVolunteerGain( ) );
|
||||||
mprintf( MapScreenRect.iLeft + 20, MapScreenRect.iBottom - 10, sVolunteerString );
|
mprintf( MapScreenRect.iLeft + 20, MapScreenRect.iBottom - 10, sVolunteerString );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+61
-114
@@ -176,8 +176,12 @@ void GenerateMilitiaSquad(INT16 sMapX, INT16 sMapY, INT16 sTMapX, INT16 sTMapY,
|
|||||||
UINT8 ubTargetRegularPercent = 0;
|
UINT8 ubTargetRegularPercent = 0;
|
||||||
UINT8 ubTempLeadership = ubBestLeadership;
|
UINT8 ubTempLeadership = ubBestLeadership;
|
||||||
|
|
||||||
UINT8 ubActualyAdded = 0; // Added by SANDRO
|
UINT8 trained = 0;
|
||||||
|
UINT8 promoted = 0;
|
||||||
|
UINT8 promotionstodo = 0;
|
||||||
|
|
||||||
|
INT16 numcreated[MAX_MILITIA_LEVELS] = {0};
|
||||||
|
|
||||||
// Does trainer have enough leadership to train a squad?
|
// Does trainer have enough leadership to train a squad?
|
||||||
if ( ubBestLeadership < gGameExternalOptions.ubMinimumLeadershipToTrainMobileMilitia )
|
if ( ubBestLeadership < gGameExternalOptions.ubMinimumLeadershipToTrainMobileMilitia )
|
||||||
{
|
{
|
||||||
@@ -192,7 +196,10 @@ void GenerateMilitiaSquad(INT16 sMapX, INT16 sMapY, INT16 sTMapX, INT16 sTMapY,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Flugente: our pool of volunteers limits how many militia can be created
|
// Flugente: our pool of volunteers limits how many militia can be created
|
||||||
|
// if we can't train as many militia as we should due to lack of volunteers, the excess training goes into promoting militia
|
||||||
|
UINT8 promotionsfromvolunteers = ubMilitiaToTrain;
|
||||||
ubMilitiaToTrain = min( ubMilitiaToTrain, GetVolunteerPool( ) );
|
ubMilitiaToTrain = min( ubMilitiaToTrain, GetVolunteerPool( ) );
|
||||||
|
promotionsfromvolunteers -= ubMilitiaToTrain;
|
||||||
|
|
||||||
// HEADROCK HAM 3.4: Composition of new Mobile Militia groups is now dictated by two INI settings controlling
|
// HEADROCK HAM 3.4: Composition of new Mobile Militia groups is now dictated by two INI settings controlling
|
||||||
// the percentage of Elites and Regulars within the group. If the percentage for either is above 0, at least
|
// the percentage of Elites and Regulars within the group. If the percentage for either is above 0, at least
|
||||||
@@ -292,149 +299,92 @@ void GenerateMilitiaSquad(INT16 sMapX, INT16 sMapY, INT16 sTMapX, INT16 sTMapY,
|
|||||||
// Reduce target elite count first.
|
// Reduce target elite count first.
|
||||||
if (ubTargetElite > 0)
|
if (ubTargetElite > 0)
|
||||||
{
|
{
|
||||||
ubTargetElite--;
|
--ubTargetElite;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no more elites but still over the allowed value, then reduce one regular.
|
// If no more elites but still over the allowed value, then reduce one regular.
|
||||||
if (ubTargetRegular > 0)
|
if (ubTargetRegular > 0)
|
||||||
{
|
{
|
||||||
ubTargetRegular--;
|
--ubTargetRegular;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// No elites/regulars - reduce target green!
|
// No elites/regulars - reduce target green!
|
||||||
ubTargetGreen--;
|
--ubTargetGreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flugente: substract volunteers
|
while ( trained + promotionstodo < ubMilitiaToTrain )
|
||||||
AddVolunteers( -ubMilitiaToTrain );
|
|
||||||
|
|
||||||
while (ubMilitiaToTrain > 0)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
// Create Heterogenous Group
|
// Create Heterogenous Group
|
||||||
//
|
//
|
||||||
// As of HAM 3.4, homogenous groups are not treated any differently than these.
|
// As of HAM 3.4, homogenous groups are not treated any differently than these.
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
|
BOOLEAN fFoundOne = FALSE;
|
||||||
|
|
||||||
// Do we have room in the target sector?
|
// Do we have room in the target sector?
|
||||||
if ( usTotalMilitiaAtTarget < gGameExternalOptions.iMaxMilitiaPerSector )
|
if ( usTotalMilitiaAtTarget + trained < gGameExternalOptions.iMaxMilitiaPerSector )
|
||||||
{
|
{
|
||||||
if (ubTargetElite > 0)
|
if ( ubTargetElite > 0 )
|
||||||
{
|
{
|
||||||
// Add elite.
|
// Add elite.
|
||||||
StrategicAddMilitiaToSector( sTMapX, sTMapY, ELITE_MILITIA, 1);
|
++numcreated[ELITE_MILITIA];
|
||||||
ubTargetElite--;
|
--ubTargetElite;
|
||||||
ubMilitiaToTrain--;
|
|
||||||
ubActualyAdded++;
|
++trained;
|
||||||
MoveOneMilitiaEquipmentSet(sMapX, sMapY, sTMapX, sTMapY, ELITE_MILITIA);
|
fFoundOne = TRUE;
|
||||||
}
|
}
|
||||||
else if (ubTargetRegular > 0)
|
else if ( ubTargetRegular > 0 )
|
||||||
{
|
{
|
||||||
// Add regular.
|
// Add regular.
|
||||||
StrategicAddMilitiaToSector( sTMapX, sTMapY, REGULAR_MILITIA, 1);
|
++numcreated[REGULAR_MILITIA];
|
||||||
ubTargetRegular--;
|
--ubTargetRegular;
|
||||||
ubMilitiaToTrain--;
|
|
||||||
ubActualyAdded++;
|
++trained;
|
||||||
MoveOneMilitiaEquipmentSet(sMapX, sMapY, sTMapX, sTMapY, REGULAR_MILITIA);
|
fFoundOne = TRUE;
|
||||||
}
|
}
|
||||||
else if (ubTargetGreen > 0)
|
else if ( ubTargetGreen > 0 )
|
||||||
{
|
{
|
||||||
// Add green.
|
// Add green.
|
||||||
StrategicAddMilitiaToSector( sTMapX, sTMapY, GREEN_MILITIA, 1);
|
++numcreated[GREEN_MILITIA];
|
||||||
ubTargetGreen--;
|
--ubTargetGreen;
|
||||||
ubMilitiaToTrain--;
|
|
||||||
ubActualyAdded++;
|
++trained;
|
||||||
MoveOneMilitiaEquipmentSet(sMapX, sMapY, sTMapX, sTMapY, GREEN_MILITIA);
|
fFoundOne = TRUE;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// No one to add? Break the cycle.
|
|
||||||
ubMilitiaToTrain = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Full militia group? See if you can upgrade some.
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Are we dealing with a full-size militia group that ISN'T full-quality yet?
|
|
||||||
if (pTargetSector->ubNumberOfCivsAtLevel[ ELITE_MILITIA ] < usTotalMilitiaAtTarget &&
|
|
||||||
pTargetSector->ubNumberOfCivsAtLevel[ ELITE_MILITIA ] < gGameExternalOptions.iMaxMilitiaPerSector) // failsafe
|
|
||||||
{
|
|
||||||
// Have we got any Elites to add?
|
|
||||||
if (ubTargetElite > 0)
|
|
||||||
{
|
|
||||||
// Add elite. This will effectively replace one lower class militia
|
|
||||||
StrategicAddMilitiaToSector( sTMapX, sTMapY, ELITE_MILITIA, 1);
|
|
||||||
ubTargetElite--;
|
|
||||||
ubMilitiaToTrain--;
|
|
||||||
ubActualyAdded++;
|
|
||||||
}
|
|
||||||
else if (ubTargetRegular > 0 && // Got a regular
|
|
||||||
(!gGameExternalOptions.gfTrainVeteranMilitia || // Not allowed to train Elites
|
|
||||||
GetWorldDay( ) < gGameExternalOptions.guiTrainVeteranMilitiaDelay )) // Or not YET allowed to train elites
|
|
||||||
{
|
|
||||||
// Add a regular. This will effectively replace one Green militia
|
|
||||||
StrategicAddMilitiaToSector( sTMapX, sTMapY, REGULAR_MILITIA, 1);
|
|
||||||
ubTargetElite--;
|
|
||||||
ubMilitiaToTrain--;
|
|
||||||
ubActualyAdded++;
|
|
||||||
}
|
|
||||||
// Else, we've got more men to train but no room for them. In this case, upgrade existing
|
|
||||||
// militia to the next class, using our remainder men as "upgrade points".
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Calculate upgrade points. 1 point per Green, 2 per Regular.
|
|
||||||
ubUpgradePoints = ubTargetGreen + (2 * ubTargetRegular);
|
|
||||||
|
|
||||||
// Is Elite training allowed?
|
// Full militia group? See if you can upgrade some.
|
||||||
if ( gGameExternalOptions.gfTrainVeteranMilitia && // Elite training allowed
|
if( !fFoundOne )
|
||||||
(GetWorldDay( ) >= gGameExternalOptions.guiTrainVeteranMilitiaDelay) // Elite training allowed (time based)
|
{
|
||||||
&& ubUpgradePoints >= 2) // Enough upgrade points to create an elite
|
// we need to promote militia then
|
||||||
{
|
++promotionstodo;
|
||||||
// Add one elite
|
|
||||||
StrategicAddMilitiaToSector( sTMapX, sTMapY, ELITE_MILITIA, 1);
|
fFoundOne = TRUE;
|
||||||
if (ubTargetRegular > 0)
|
|
||||||
{
|
|
||||||
// Comes at a cost of one regular that we were supposed to train.
|
|
||||||
ubTargetRegular--;
|
|
||||||
ubMilitiaToTrain--;
|
|
||||||
ubActualyAdded++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// No regulars to train? Remove two greens instead.
|
|
||||||
ubTargetGreen -= 2;
|
|
||||||
ubMilitiaToTrain -= 2;
|
|
||||||
ubActualyAdded += 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Else elite training was not allowed or we simply did not have enough points to add an elite
|
|
||||||
else if (ubUpgradePoints >= 1)
|
|
||||||
{
|
|
||||||
// Add one regular instead of a green.
|
|
||||||
StrategicAddMilitiaToSector( sTMapX, sTMapY, REGULAR_MILITIA, 1);
|
|
||||||
ubTargetGreen--;
|
|
||||||
ubMilitiaToTrain--;
|
|
||||||
ubActualyAdded++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// No more men to train. Break the cycle.
|
|
||||||
ubMilitiaToTrain = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Sector is full-sized and full-quality. Break the cycle.
|
|
||||||
ubMilitiaToTrain = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StrategicAddMilitiaToSector( sTMapX, sTMapY, ELITE_MILITIA, numcreated[ELITE_MILITIA] );
|
||||||
|
StrategicAddMilitiaToSector( sTMapX, sTMapY, REGULAR_MILITIA, numcreated[REGULAR_MILITIA] );
|
||||||
|
StrategicAddMilitiaToSector( sTMapX, sTMapY, GREEN_MILITIA, numcreated[GREEN_MILITIA] );
|
||||||
|
|
||||||
|
MoveMilitiaEquipment( sMapX, sMapY, sTMapX, sTMapY, numcreated[ELITE_MILITIA], numcreated[REGULAR_MILITIA], numcreated[GREEN_MILITIA] );
|
||||||
|
|
||||||
|
// handle promotions
|
||||||
|
UINT8 promotions = 0;
|
||||||
|
while ( promotions < promotionstodo + promotionsfromvolunteers && TownMilitiaTrainingPromotion( sTMapX, sTMapY ) )
|
||||||
|
++promotions;
|
||||||
|
|
||||||
// SANDRO - merc records (num militia trained)
|
// SANDRO - merc records (num militia trained)
|
||||||
if( ubActualyAdded > 0 )
|
if ( trained > 0 )
|
||||||
RecordNumMilitiaTrainedForMercs( sMapX, sMapY, 0, ubActualyAdded, TRUE );
|
{
|
||||||
|
RecordNumMilitiaTrainedForMercs( sMapX, sMapY, 0, trained, TRUE );
|
||||||
|
|
||||||
|
// Flugente: substract volunteers
|
||||||
|
AddVolunteers( -trained );
|
||||||
|
}
|
||||||
|
|
||||||
// This reduces the group back to "maximum" size. It starts by eliminating extra greens, then regulars, then elites.
|
// This reduces the group back to "maximum" size. It starts by eliminating extra greens, then regulars, then elites.
|
||||||
// That produces a group of max size, with only the best troops remaining.
|
// That produces a group of max size, with only the best troops remaining.
|
||||||
@@ -2217,7 +2167,6 @@ void AdjustRoamingRestrictions( BOOLEAN fRecheck )
|
|||||||
|
|
||||||
void GenerateDirectionInfosForTraining( INT16 sMapX, INT16 sMapY, UINT8* uiDirNumber, UINT16 pMoveDir[4][3] )
|
void GenerateDirectionInfosForTraining( INT16 sMapX, INT16 sMapY, UINT8* uiDirNumber, UINT16 pMoveDir[4][3] )
|
||||||
{
|
{
|
||||||
SECTORINFO *pSectorInfo;
|
|
||||||
UINT8 ubMaxMilitia = gGameExternalOptions.iMaxMilitiaPerSector;
|
UINT8 ubMaxMilitia = gGameExternalOptions.iMaxMilitiaPerSector;
|
||||||
|
|
||||||
*uiDirNumber = 0;
|
*uiDirNumber = 0;
|
||||||
@@ -2938,11 +2887,9 @@ BOOLEAN LoadMilitiaMovementInformationFromSavedGameFile( HWFILE hFile, UINT32 ui
|
|||||||
{
|
{
|
||||||
UINT32 uiNumBytesRead;
|
UINT32 uiNumBytesRead;
|
||||||
UINT32 uiTotalNodeCount = 0;
|
UINT32 uiTotalNodeCount = 0;
|
||||||
UINT8 cnt;
|
|
||||||
UINT32 uiNodeCount = 0;
|
UINT32 uiNodeCount = 0;
|
||||||
PathSt *pPath = NULL;
|
PathSt *pPath = NULL;
|
||||||
UINT8 ubPassengerCnt = 0;
|
UINT8 ubPassengerCnt = 0;
|
||||||
PathSt *pTempPath;
|
|
||||||
UINT8 numpaths = 0;
|
UINT8 numpaths = 0;
|
||||||
|
|
||||||
DeleteAllMilitiaPaths( );
|
DeleteAllMilitiaPaths( );
|
||||||
|
|||||||
@@ -685,9 +685,6 @@ void HandleMurderOfCivilian( SOLDIERTYPE *pSoldier, BOOLEAN fIntentional )
|
|||||||
INT8 bKillerTeam = 0;
|
INT8 bKillerTeam = 0;
|
||||||
BOOLEAN fIncrement = FALSE;
|
BOOLEAN fIncrement = FALSE;
|
||||||
|
|
||||||
UINT16 iCounter2;
|
|
||||||
|
|
||||||
|
|
||||||
// ubAttacker CAN be NOBODY... Don't treat is as murder if NOBODY killed us...
|
// ubAttacker CAN be NOBODY... Don't treat is as murder if NOBODY killed us...
|
||||||
if ( pSoldier->ubAttackerID == NOBODY )
|
if ( pSoldier->ubAttackerID == NOBODY )
|
||||||
{
|
{
|
||||||
|
|||||||
+115
-105
@@ -114,6 +114,98 @@ int MilitiaListQsortCompare(const void *pArg1, const void *pArg2);
|
|||||||
void VerifyTownTrainingIsPaidFor( void );
|
void VerifyTownTrainingIsPaidFor( void );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// handle promoting a militia during militia training. return TRUE if militia could be promoted
|
||||||
|
BOOLEAN TownMilitiaTrainingPromotion( INT16 sMapX, INT16 sMapY )
|
||||||
|
{
|
||||||
|
INT16 sNeighbourX, sNeighbourY;
|
||||||
|
UINT8 ubTownId = StrategicMap[sMapX + sMapY * MAP_WORLD_X].bNameId;
|
||||||
|
|
||||||
|
// alrighty, then. We'll have to *promote* guys instead.
|
||||||
|
|
||||||
|
// are there any GREEN militia men in the training sector itself?
|
||||||
|
if ( MilitiaInSectorOfRank( sMapX, sMapY, GREEN_MILITIA ) > 0 )
|
||||||
|
{
|
||||||
|
// great! Promote a GREEN militia guy in the training sector to a REGULAR
|
||||||
|
StrategicPromoteMilitiaInSector( sMapX, sMapY, GREEN_MILITIA, 1 );
|
||||||
|
|
||||||
|
if ( sMapX == gWorldSectorX && sMapY == gWorldSectorY )
|
||||||
|
gfStrategicMilitiaChangesMade = TRUE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( ubTownId != BLANK_SECTOR )
|
||||||
|
{
|
||||||
|
// dammit! Last chance - try to find other eligible sectors in the same town with a Green guy to be promoted
|
||||||
|
InitFriendlyTownSectorServer( ubTownId, sMapX, sMapY );
|
||||||
|
|
||||||
|
// check other eligible sectors in this town for room for another militia
|
||||||
|
while ( ServeNextFriendlySectorInTown( &sNeighbourX, &sNeighbourY ) )
|
||||||
|
{
|
||||||
|
// are there any GREEN militia men in the neighbouring sector ?
|
||||||
|
if ( MilitiaInSectorOfRank( sNeighbourX, sNeighbourY, GREEN_MILITIA ) > 0 )
|
||||||
|
{
|
||||||
|
// great! Promote a GREEN militia guy in the neighbouring sector to a REGULAR
|
||||||
|
StrategicPromoteMilitiaInSector( sNeighbourX, sNeighbourY, GREEN_MILITIA, 1 );
|
||||||
|
|
||||||
|
if ( sNeighbourX == gWorldSectorX && sNeighbourY == gWorldSectorY )
|
||||||
|
gfStrategicMilitiaChangesMade = TRUE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kaiden: Veteran militia training
|
||||||
|
// This is essentially copy/pasted from above
|
||||||
|
// But the names have been changed to protect the innocent
|
||||||
|
if ( gGameExternalOptions.gfTrainVeteranMilitia && (GetWorldDay( ) >= gGameExternalOptions.guiTrainVeteranMilitiaDelay) )
|
||||||
|
{
|
||||||
|
// are there any REGULAR militia men in the training sector itself?
|
||||||
|
if ( MilitiaInSectorOfRank( sMapX, sMapY, REGULAR_MILITIA ) > 0 )
|
||||||
|
{
|
||||||
|
// great! Promote a REGULAR militia guy in the training sector to a VETERAN
|
||||||
|
StrategicPromoteMilitiaInSector( sMapX, sMapY, REGULAR_MILITIA, 1 );
|
||||||
|
|
||||||
|
if ( sMapX == gWorldSectorX && sMapY == gWorldSectorY )
|
||||||
|
gfStrategicMilitiaChangesMade = TRUE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( ubTownId != BLANK_SECTOR )
|
||||||
|
{
|
||||||
|
// dammit! Last chance - try to find other eligible sectors in the same town with a Regular guy to be promoted
|
||||||
|
InitFriendlyTownSectorServer( ubTownId, sMapX, sMapY );
|
||||||
|
|
||||||
|
// check other eligible sectors in this town for room for another militia
|
||||||
|
while ( ServeNextFriendlySectorInTown( &sNeighbourX, &sNeighbourY ) )
|
||||||
|
{
|
||||||
|
// are there any REGULAR militia men in the neighbouring sector ?
|
||||||
|
if ( MilitiaInSectorOfRank( sNeighbourX, sNeighbourY, REGULAR_MILITIA ) > 0 )
|
||||||
|
{
|
||||||
|
// great! Promote a Regular militia guy in the neighbouring sector to a Veteran
|
||||||
|
StrategicPromoteMilitiaInSector( sNeighbourX, sNeighbourY, REGULAR_MILITIA, 1 );
|
||||||
|
|
||||||
|
if ( sNeighbourX == gWorldSectorX && sNeighbourY == gWorldSectorY )
|
||||||
|
gfStrategicMilitiaChangesMade = TRUE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if we still haven't been able to train anyone
|
||||||
|
// Well, that's it. All eligible sectors of this town are full of REGULARs or ELITEs.
|
||||||
|
// The training goes to waste in this situation.
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
void TownMilitiaTrainingCompleted( SOLDIERTYPE *pTrainer, INT16 sMapX, INT16 sMapY )
|
void TownMilitiaTrainingCompleted( SOLDIERTYPE *pTrainer, INT16 sMapX, INT16 sMapY )
|
||||||
{
|
{
|
||||||
UINT8 ubMilitiaTrained = 0;
|
UINT8 ubMilitiaTrained = 0;
|
||||||
@@ -126,9 +218,13 @@ void TownMilitiaTrainingCompleted( SOLDIERTYPE *pTrainer, INT16 sMapX, INT16 sMa
|
|||||||
// HEADROCK HAM 3.6: Leadership may affect the resulting squad size.
|
// HEADROCK HAM 3.6: Leadership may affect the resulting squad size.
|
||||||
UINT8 ubTrainerEffectiveLeadership = FindBestMilitiaTrainingLeadershipInSector ( sMapX, sMapY, pTrainer->bSectorZ, TOWN_MILITIA );
|
UINT8 ubTrainerEffectiveLeadership = FindBestMilitiaTrainingLeadershipInSector ( sMapX, sMapY, pTrainer->bSectorZ, TOWN_MILITIA );
|
||||||
UINT8 iTrainingSquadSize = __min(iMaxMilitiaPerSector, CalcNumMilitiaTrained(ubTrainerEffectiveLeadership, FALSE));
|
UINT8 iTrainingSquadSize = __min(iMaxMilitiaPerSector, CalcNumMilitiaTrained(ubTrainerEffectiveLeadership, FALSE));
|
||||||
|
UINT8 promotionstodo = 0;
|
||||||
|
|
||||||
// Flugente: our pool of volunteers limits how many militia can be created
|
// Flugente: our pool of volunteers limits how many militia can be created
|
||||||
|
// if we can't train as many militia as we should due to lack of volunteers, the excess training goes into promoting militia
|
||||||
|
UINT8 promotionsfromvolunteers = iTrainingSquadSize;
|
||||||
iTrainingSquadSize = min( iTrainingSquadSize, GetVolunteerPool( ) );
|
iTrainingSquadSize = min( iTrainingSquadSize, GetVolunteerPool( ) );
|
||||||
|
promotionsfromvolunteers -= iTrainingSquadSize;
|
||||||
|
|
||||||
DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Militia1");
|
DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Militia1");
|
||||||
|
|
||||||
@@ -149,8 +245,7 @@ void TownMilitiaTrainingCompleted( SOLDIERTYPE *pTrainer, INT16 sMapX, INT16 sMa
|
|||||||
// 3) If not enough room anywhere in town, promote a number of GREENs in this sector into regulars
|
// 3) If not enough room anywhere in town, promote a number of GREENs in this sector into regulars
|
||||||
// 4) If not enough GREENS there to promote, promote GREENs in other sectors.
|
// 4) If not enough GREENS there to promote, promote GREENs in other sectors.
|
||||||
// 5) If all friendly sectors of this town are completely filled with REGULAR militia, then training effect is wasted
|
// 5) If all friendly sectors of this town are completely filled with REGULAR militia, then training effect is wasted
|
||||||
|
|
||||||
|
|
||||||
// Kaiden: Roaming Militia Training:
|
// Kaiden: Roaming Militia Training:
|
||||||
// If we're not training roaming militia,
|
// If we're not training roaming militia,
|
||||||
// then we will handle everything as normal.
|
// then we will handle everything as normal.
|
||||||
@@ -168,17 +263,20 @@ void TownMilitiaTrainingCompleted( SOLDIERTYPE *pTrainer, INT16 sMapX, INT16 sMa
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while (ubMilitiaTrained < iTrainingSquadSize)
|
// we either create new militia or promote existing ones if no space is left
|
||||||
|
while ( ubMilitiaTrained + promotionstodo < iTrainingSquadSize )
|
||||||
{
|
{
|
||||||
// is there room for another militia in the training sector itself?
|
// is there room for another militia in the training sector itself?
|
||||||
if ( NumNonPlayerTeamMembersInSector( sMapX, sMapY, MILITIA_TEAM ) < iMaxMilitiaPerSector )
|
if ( NumNonPlayerTeamMembersInSector( sMapX, sMapY, MILITIA_TEAM ) < iMaxMilitiaPerSector )
|
||||||
{
|
{
|
||||||
// great! Create a new GREEN militia guy in the training sector
|
// great! Create a new GREEN militia guy in the training sector
|
||||||
StrategicAddMilitiaToSector(sMapX, sMapY, GREEN_MILITIA, 1);
|
StrategicAddMilitiaToSector(sMapX, sMapY, GREEN_MILITIA, 1);
|
||||||
|
|
||||||
if (sMapX == gWorldSectorX && sMapY == gWorldSectorY)
|
if (sMapX == gWorldSectorX && sMapY == gWorldSectorY)
|
||||||
{
|
|
||||||
gfStrategicMilitiaChangesMade = TRUE;
|
gfStrategicMilitiaChangesMade = TRUE;
|
||||||
}
|
|
||||||
|
// next, please!
|
||||||
|
++ubMilitiaTrained;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -198,9 +296,10 @@ void TownMilitiaTrainingCompleted( SOLDIERTYPE *pTrainer, INT16 sMapX, INT16 sMa
|
|||||||
StrategicAddMilitiaToSector(sNeighbourX, sNeighbourY, GREEN_MILITIA, 1);
|
StrategicAddMilitiaToSector(sNeighbourX, sNeighbourY, GREEN_MILITIA, 1);
|
||||||
|
|
||||||
if (sNeighbourX == gWorldSectorX && sNeighbourY == gWorldSectorY)
|
if (sNeighbourX == gWorldSectorX && sNeighbourY == gWorldSectorY)
|
||||||
{
|
|
||||||
gfStrategicMilitiaChangesMade = TRUE;
|
gfStrategicMilitiaChangesMade = TRUE;
|
||||||
}
|
|
||||||
|
// next, please!
|
||||||
|
++ubMilitiaTrained;
|
||||||
|
|
||||||
fFoundOne = TRUE;
|
fFoundOne = TRUE;
|
||||||
break;
|
break;
|
||||||
@@ -211,109 +310,18 @@ void TownMilitiaTrainingCompleted( SOLDIERTYPE *pTrainer, INT16 sMapX, INT16 sMa
|
|||||||
// if we still haven't been able to train anyone
|
// if we still haven't been able to train anyone
|
||||||
if (!fFoundOne)
|
if (!fFoundOne)
|
||||||
{
|
{
|
||||||
// alrighty, then. We'll have to *promote* guys instead.
|
// we need to promote militia then
|
||||||
|
++promotionstodo;
|
||||||
|
|
||||||
// are there any GREEN militia men in the training sector itself?
|
fFoundOne = TRUE;
|
||||||
if (MilitiaInSectorOfRank(sMapX, sMapY, GREEN_MILITIA) > 0)
|
|
||||||
{
|
|
||||||
// great! Promote a GREEN militia guy in the training sector to a REGULAR
|
|
||||||
StrategicPromoteMilitiaInSector(sMapX, sMapY, GREEN_MILITIA, 1);
|
|
||||||
fFoundOne = TRUE;
|
|
||||||
if (sMapX == gWorldSectorX && sMapY == gWorldSectorY)
|
|
||||||
{
|
|
||||||
gfStrategicMilitiaChangesMade = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( ubTownId != BLANK_SECTOR )
|
|
||||||
{
|
|
||||||
// dammit! Last chance - try to find other eligible sectors in the same town with a Green guy to be promoted
|
|
||||||
InitFriendlyTownSectorServer(ubTownId, sMapX, sMapY);
|
|
||||||
|
|
||||||
// check other eligible sectors in this town for room for another militia
|
|
||||||
while( ServeNextFriendlySectorInTown( &sNeighbourX, &sNeighbourY ) )
|
|
||||||
{
|
|
||||||
// are there any GREEN militia men in the neighbouring sector ?
|
|
||||||
if (MilitiaInSectorOfRank(sNeighbourX, sNeighbourY, GREEN_MILITIA) > 0)
|
|
||||||
{
|
|
||||||
// great! Promote a GREEN militia guy in the neighbouring sector to a REGULAR
|
|
||||||
StrategicPromoteMilitiaInSector(sNeighbourX, sNeighbourY, GREEN_MILITIA, 1);
|
|
||||||
|
|
||||||
if (sNeighbourX == gWorldSectorX && sNeighbourY == gWorldSectorY)
|
|
||||||
{
|
|
||||||
gfStrategicMilitiaChangesMade = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
fFoundOne = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Kaiden: Veteran militia training
|
|
||||||
// This is essentially copy/pasted from above
|
|
||||||
// But the names have been changed to protect the innocent
|
|
||||||
if ((!fFoundOne) && (gGameExternalOptions.gfTrainVeteranMilitia)
|
|
||||||
&& (GetWorldDay( ) >= gGameExternalOptions.guiTrainVeteranMilitiaDelay))
|
|
||||||
{
|
|
||||||
// are there any REGULAR militia men in the training sector itself?
|
|
||||||
if (MilitiaInSectorOfRank(sMapX, sMapY, REGULAR_MILITIA) > 0)
|
|
||||||
{
|
|
||||||
// great! Promote a REGULAR militia guy in the training sector to a VETERAN
|
|
||||||
StrategicPromoteMilitiaInSector(sMapX, sMapY, REGULAR_MILITIA, 1);
|
|
||||||
if (sMapX == gWorldSectorX && sMapY == gWorldSectorY)
|
|
||||||
{
|
|
||||||
gfStrategicMilitiaChangesMade = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
fFoundOne = TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( ubTownId != BLANK_SECTOR )
|
|
||||||
{
|
|
||||||
// dammit! Last chance - try to find other eligible sectors in the same town with a Regular guy to be promoted
|
|
||||||
InitFriendlyTownSectorServer(ubTownId, sMapX, sMapY);
|
|
||||||
|
|
||||||
// check other eligible sectors in this town for room for another militia
|
|
||||||
while( ServeNextFriendlySectorInTown( &sNeighbourX, &sNeighbourY ) )
|
|
||||||
{
|
|
||||||
// are there any REGULAR militia men in the neighbouring sector ?
|
|
||||||
if (MilitiaInSectorOfRank(sNeighbourX, sNeighbourY, REGULAR_MILITIA) > 0)
|
|
||||||
{
|
|
||||||
// great! Promote a Regular militia guy in the neighbouring sector to a Veteran
|
|
||||||
StrategicPromoteMilitiaInSector(sNeighbourX, sNeighbourY, REGULAR_MILITIA, 1);
|
|
||||||
|
|
||||||
if (sNeighbourX == gWorldSectorX && sNeighbourY == gWorldSectorY)
|
|
||||||
{
|
|
||||||
gfStrategicMilitiaChangesMade = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
fFoundOne = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if we still haven't been able to train anyone
|
|
||||||
if (!fFoundOne)
|
|
||||||
{
|
|
||||||
// Well, that's it. All eligible sectors of this town are full of REGULARs or ELITEs.
|
|
||||||
// The training goes to waste in this situation.
|
|
||||||
break; // the main while loop
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// next, please!
|
|
||||||
++ubMilitiaTrained;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AddVolunteers( -ubMilitiaTrained );
|
// handle promotions
|
||||||
|
UINT8 promotions = 0;
|
||||||
|
while ( promotions < promotionstodo + promotionsfromvolunteers && TownMilitiaTrainingPromotion( sMapX, sMapY ) )
|
||||||
|
++promotions;
|
||||||
|
|
||||||
if (gfStrategicMilitiaChangesMade)
|
if (gfStrategicMilitiaChangesMade)
|
||||||
{
|
{
|
||||||
@@ -323,6 +331,8 @@ void TownMilitiaTrainingCompleted( SOLDIERTYPE *pTrainer, INT16 sMapX, INT16 sMa
|
|||||||
// if anyone actually got trained
|
// if anyone actually got trained
|
||||||
if (ubMilitiaTrained > 0)
|
if (ubMilitiaTrained > 0)
|
||||||
{
|
{
|
||||||
|
AddVolunteers( -ubMilitiaTrained );
|
||||||
|
|
||||||
// update the screen display
|
// update the screen display
|
||||||
fMapPanelDirty = TRUE;
|
fMapPanelDirty = TRUE;
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
//#define MIN_RATING_TO_TRAIN_TOWN 20
|
//#define MIN_RATING_TO_TRAIN_TOWN 20
|
||||||
|
|
||||||
|
|
||||||
|
// handle promoting a militia during militia training. return TRUE if militia could be promoted
|
||||||
|
BOOLEAN TownMilitiaTrainingPromotion( INT16 sMapX, INT16 sMapY );
|
||||||
|
|
||||||
// this handles what happens when a new militia unit is finishes getting trained
|
// this handles what happens when a new militia unit is finishes getting trained
|
||||||
void TownMilitiaTrainingCompleted( SOLDIERTYPE *pTrainer, INT16 sMapX, INT16 sMapY );
|
void TownMilitiaTrainingCompleted( SOLDIERTYPE *pTrainer, INT16 sMapX, INT16 sMapY );
|
||||||
|
|||||||
@@ -6663,7 +6663,7 @@ void DeathNoMessageTimerCallback( )
|
|||||||
ScreenMsg( FONT_YELLOW, MSG_CHAT, MPClientMessage[41] );
|
ScreenMsg( FONT_YELLOW, MSG_CHAT, MPClientMessage[41] );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ScreenMsg( FONT_LTBLUE, MSG_CHAT, L"spectator mode disabled");
|
ScreenMsg( FONT_LTBLUE, MSG_CHAT, MPClientMessage[74] );
|
||||||
|
|
||||||
teamwiped();
|
teamwiped();
|
||||||
}
|
}
|
||||||
@@ -9816,7 +9816,7 @@ void EndBattleWithUnconsciousGuysCallback( UINT8 bExitValue )
|
|||||||
ScreenMsg( FONT_YELLOW, MSG_CHAT, MPClientMessage[41] );
|
ScreenMsg( FONT_YELLOW, MSG_CHAT, MPClientMessage[41] );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ScreenMsg( FONT_LTBLUE, MSG_CHAT, L"spectator mode disabled");
|
ScreenMsg( FONT_LTBLUE, MSG_CHAT, MPClientMessage[74] );
|
||||||
|
|
||||||
teamwiped();
|
teamwiped();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user