Merged revision(s) 7032 from branches/ja2_source_official_2014:

Militia improvement: If MILITIA_TRAINING_CARRYOVER_PROGRESS is set to TRUE, militia training progress is carried over to the next training session once a session finishes. This way no training is lost.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7033 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2014-03-07 22:12:32 +00:00
parent 5ba65d8377
commit 3c63b7b08c
3 changed files with 57 additions and 30 deletions
+2
View File
@@ -1957,6 +1957,8 @@ void LoadGameExternalOptions()
gGameExternalOptions.ubTownMilitiaTrainingRate = iniReader.ReadInteger("Militia Training Settings","MILITIA_TRAINING_RATE",4, 1, 10);
gGameExternalOptions.gfMilitiaTrainingCarryOver = iniReader.ReadBoolean("Militia Training Settings","MILITIA_TRAINING_CARRYOVER_PROGRESS", FALSE);
gGameExternalOptions.gfTrainVeteranMilitia = iniReader.ReadBoolean("Militia Training Settings","ALLOW_TRAINING_ELITE_MILITIA",FALSE);
gGameExternalOptions.guiTrainVeteranMilitiaDelay = iniReader.ReadInteger("Militia Training Settings","ELITE_MILITIA_TRAINING_DELAY",1, 0, 30);
+3
View File
@@ -675,6 +675,9 @@ typedef struct
// HEADROCK HAM 3.5: No longer necessary.
//INT32 ubGunRangeTrainingBonus;
INT32 ubTownMilitiaTrainingRate;
BOOLEAN gfMilitiaTrainingCarryOver; // added by Flugente
// HEADROCK HAM 3.5: No longer necessary.
//INT32 ubMaxMilitiaTrainersPerSector;
INT32 ubTeachBonusToTrain;
+52 -30
View File
@@ -5477,8 +5477,8 @@ void HandleTrainingInSector( INT16 sMapX, INT16 sMapY, INT8 bZ )
if (sTownTrainingPts > 0)
{
fTrainingCompleted = TrainTownInSector( TownTrainer[ uiCnt ].pSoldier, sMapX, sMapY, sTownTrainingPts );
if ( fTrainingCompleted )
if ( fTrainingCompleted && !gGameExternalOptions.gfMilitiaTrainingCarryOver )
{
// there's no carryover into next session for extra training (cause player might cancel), so break out of loop
break;
@@ -6449,8 +6449,7 @@ BOOLEAN TrainTownInSector( SOLDIERTYPE *pTrainer, INT16 sMapX, INT16 sMapY, INT1
{
SECTORINFO *pSectorInfo = &( SectorInfo[ SECTOR( sMapX, sMapY ) ] );
UINT8 ubTownId = 0;
// find out if a sam site here
BOOLEAN fSamSiteInSector = IsThisSectorASAMSector( sMapX, sMapY, 0 );
@@ -6465,33 +6464,44 @@ BOOLEAN TrainTownInSector( SOLDIERTYPE *pTrainer, INT16 sMapX, INT16 sMapY, INT1
StatChange( pTrainer, LDRAMT, (UINT16) ( 1 + ( sTrainingPts / 200 ) ), FALSE );
StatChange( pTrainer, WISDOMAMT, (UINT16) ( 1 + ( sTrainingPts / 400 ) ), FALSE );
// increase town's training completed percentage
if (pTrainer->bAssignment == TRAIN_TOWN)
{
pSectorInfo->ubMilitiaTrainingPercentDone += (sTrainingPts / 100);
pSectorInfo->ubMilitiaTrainingHundredths += (sTrainingPts % 100);
pSectorInfo->ubMilitiaTrainingPercentDone += (sTrainingPts / 100);
pSectorInfo->ubMilitiaTrainingHundredths += (sTrainingPts % 100);
if (pSectorInfo->ubMilitiaTrainingHundredths >= 100)
{
pSectorInfo->ubMilitiaTrainingPercentDone++;
pSectorInfo->ubMilitiaTrainingHundredths -= 100;
}
if (pSectorInfo->ubMilitiaTrainingHundredths >= 100)
{
pSectorInfo->ubMilitiaTrainingPercentDone++;
pSectorInfo->ubMilitiaTrainingHundredths -= 100;
}
// NOTE: Leave this at 100, change TOWN_TRAINING_RATE if necessary. This value gets reported to player as a %age!
if( pSectorInfo->ubMilitiaTrainingPercentDone >= 100 )
{
// zero out training completion - there's no carryover to the next training session
pSectorInfo->ubMilitiaTrainingPercentDone = 0;
pSectorInfo->ubMilitiaTrainingHundredths = 0;
// NOTE: Leave this at 100, change TOWN_TRAINING_RATE if necessary. This value gets reported to player as a %age!
if( pSectorInfo->ubMilitiaTrainingPercentDone >= 100 )
{
// Flugente: carry over training progress instead of losing it
if ( gGameExternalOptions.gfMilitiaTrainingCarryOver )
{
pSectorInfo->ubMilitiaTrainingPercentDone -= 100;
}
else
{
// zero out training completion - there's no carryover to the next training session
pSectorInfo->ubMilitiaTrainingPercentDone = 0;
pSectorInfo->ubMilitiaTrainingHundredths = 0;
}
// make the player pay again next time he wants to train here
pSectorInfo->fMilitiaTrainingPaid = FALSE;
// Flugente: this check is now necessary, as we might complete multiple militia session in one hour (theoretically)
if ( pSectorInfo->fMilitiaTrainingPaid )
{
// make the player pay again next time he wants to train here
pSectorInfo->fMilitiaTrainingPaid = FALSE;
TownMilitiaTrainingCompleted( pTrainer, sMapX, sMapY );
TownMilitiaTrainingCompleted( pTrainer, sMapX, sMapY );
}
// training done
return( TRUE );
// training done
return( TRUE );
}
}
else if (pTrainer->bAssignment == TRAIN_MOBILE)
@@ -6504,17 +6514,30 @@ BOOLEAN TrainTownInSector( SOLDIERTYPE *pTrainer, INT16 sMapX, INT16 sMapY, INT1
pSectorInfo->ubMobileMilitiaTrainingPercentDone++;
pSectorInfo->ubMobileMilitiaTrainingHundredths -= 100;
}
// NOTE: Leave this at 100, change TOWN_TRAINING_RATE if necessary. This value gets reported to player as a %age!
if( pSectorInfo->ubMobileMilitiaTrainingPercentDone >= 100 )
{
// zero out training completion - there's no carryover to the next training session
pSectorInfo->ubMobileMilitiaTrainingPercentDone = 0;
pSectorInfo->ubMobileMilitiaTrainingHundredths = 0;
// Flugente: carry over training progress instead of losing it
if ( gGameExternalOptions.gfMilitiaTrainingCarryOver )
{
pSectorInfo->ubMobileMilitiaTrainingPercentDone -= 100;
}
else
{
// zero out training completion - there's no carryover to the next training session
pSectorInfo->ubMobileMilitiaTrainingPercentDone = 0;
pSectorInfo->ubMobileMilitiaTrainingHundredths = 0;
}
// make the player pay again next time he wants to train here
pSectorInfo->fMobileMilitiaTrainingPaid = FALSE;
// Flugente: this check is now necessary, as we might complete multiple militia session in one hour (theoretically)
if ( pSectorInfo->fMobileMilitiaTrainingPaid )
{
// make the player pay again next time he wants to train here
pSectorInfo->fMobileMilitiaTrainingPaid = FALSE;
TownMilitiaTrainingCompleted( pTrainer, sMapX, sMapY );
TownMilitiaTrainingCompleted( pTrainer, sMapX, sMapY );
}
// training done
return( TRUE );
@@ -6522,7 +6545,6 @@ BOOLEAN TrainTownInSector( SOLDIERTYPE *pTrainer, INT16 sMapX, INT16 sMapY, INT1
}
return ( FALSE );
}
extern INT32 giReinforcementPool;