mirror of
https://github.com/1dot13/source.git
synced 2026-08-26 14:30:26 +02:00
- Added INI Setting and ability to manually train mobile militia at a cost
- Added INI setting and ability to train veteran militia git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@586 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+42
-10
@@ -1092,21 +1092,43 @@ BOOLEAN BasicCanCharacterTrainMilitia( SOLDIERTYPE *pSoldier )
|
||||
return( TRUE );
|
||||
}
|
||||
|
||||
|
||||
// Kaiden: Roaming Militia Training:
|
||||
// Commenting out the check for:
|
||||
// IsMilitiaTrainableFromSoldiersSectorMaxed(
|
||||
// At this point, we don't care if it's full yet
|
||||
|
||||
BOOLEAN CanCharacterTrainMilitia( SOLDIERTYPE *pSoldier )
|
||||
{
|
||||
if( BasicCanCharacterTrainMilitia( pSoldier ) &&
|
||||
|
||||
if (gGameExternalOptions.gfmusttrainroaming)
|
||||
{
|
||||
if( BasicCanCharacterTrainMilitia( pSoldier ) &&
|
||||
MilitiaTrainingAllowedInSector( pSoldier->sSectorX, pSoldier->sSectorY, pSoldier->bSectorZ ) &&
|
||||
DoesSectorMercIsInHaveSufficientLoyaltyToTrainMilitia( pSoldier ) &&
|
||||
/*( IsMilitiaTrainableFromSoldiersSectorMaxed( pSoldier ) == FALSE ) && */
|
||||
( CountMilitiaTrainersInSoldiersSector( pSoldier ) < gGameExternalOptions.ubMaxMilitiaTrainersPerSector ) )
|
||||
{
|
||||
return( TRUE );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( FALSE );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( BasicCanCharacterTrainMilitia( pSoldier ) &&
|
||||
MilitiaTrainingAllowedInSector( pSoldier->sSectorX, pSoldier->sSectorY, pSoldier->bSectorZ ) &&
|
||||
DoesSectorMercIsInHaveSufficientLoyaltyToTrainMilitia( pSoldier ) &&
|
||||
( IsMilitiaTrainableFromSoldiersSectorMaxed( pSoldier ) == FALSE ) &&
|
||||
( CountMilitiaTrainersInSoldiersSector( pSoldier ) < gGameExternalOptions.ubMaxMilitiaTrainersPerSector ) )
|
||||
{
|
||||
return( TRUE );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( FALSE );
|
||||
{
|
||||
return( TRUE );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( FALSE );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7372,7 +7394,12 @@ void TrainingMenuBtnCallback( MOUSE_REGION * pRegion, INT32 iReason )
|
||||
}
|
||||
}
|
||||
|
||||
if( IsMilitiaTrainableFromSoldiersSectorMaxed( pSoldier ) )
|
||||
|
||||
// Kaiden: Roaming Militia Training:
|
||||
// Added to the if test here:
|
||||
// && (!gGameExternalOptions.gfmusttrainroaming)
|
||||
|
||||
if( IsMilitiaTrainableFromSoldiersSectorMaxed( pSoldier ) && (!gGameExternalOptions.gfmusttrainroaming))
|
||||
{
|
||||
if( bTownId == BLANK_SECTOR )
|
||||
{
|
||||
@@ -7388,7 +7415,12 @@ void TrainingMenuBtnCallback( MOUSE_REGION * pRegion, INT32 iReason )
|
||||
|
||||
DoScreenIndependantMessageBox( sString, MSG_BOX_FLAG_OK, NULL );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if ( CountMilitiaTrainersInSoldiersSector( pSoldier ) >= gGameExternalOptions.ubMaxMilitiaTrainersPerSector )
|
||||
{
|
||||
|
||||
+127
-23
@@ -456,7 +456,9 @@ void UpdateMilitiaSquads(INT16 sMapX, INT16 sMapY )
|
||||
|
||||
if( !uiMilitiaCount )return;
|
||||
|
||||
// new squad
|
||||
|
||||
//new squad
|
||||
|
||||
if( GetTownIdForSector( sMapX, sMapY ) != BLANK_SECTOR )
|
||||
{
|
||||
if( GetWorldHour() % gGameExternalOptions.guiCreateEachNHours )return;
|
||||
@@ -481,35 +483,41 @@ void UpdateMilitiaSquads(INT16 sMapX, INT16 sMapY )
|
||||
|
||||
//ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"%ld,%ld:Dir count %ld, Rand %ld. Go to %ld,%ld", sMapX, sMapY, uiDirNumber, iRandomRes, SECTORX( pMoveDir[ iRandomRes ][0] ), SECTORY( pMoveDir[ iRandomRes ][0] ));
|
||||
|
||||
GenerateMilitiaSquad( sMapX, sMapY, SECTORX( pMoveDir[ iRandomRes ][0] ), SECTORY( pMoveDir[ iRandomRes ][0] ) );
|
||||
AddToBlockMoveList( SECTORX( pMoveDir[ iRandomRes ][0] ), SECTORY( pMoveDir[ iRandomRes ][0] ) );
|
||||
|
||||
// Kaiden: Roaming Militia Training:
|
||||
// If we're training roaming militia,
|
||||
// We'll get our new squad elsewhere.
|
||||
if(!gGameExternalOptions.gfmusttrainroaming)
|
||||
{
|
||||
GenerateMilitiaSquad( sMapX, sMapY, SECTORX( pMoveDir[ iRandomRes ][0] ), SECTORY( pMoveDir[ iRandomRes ][0] ) );
|
||||
AddToBlockMoveList( SECTORX( pMoveDir[ iRandomRes ][0] ), SECTORY( pMoveDir[ iRandomRes ][0] ) );
|
||||
|
||||
if( NumEnemiesInSector( SECTORX( pMoveDir[ iRandomRes ][0] ), SECTORY( pMoveDir[ iRandomRes ][0] ) ) && CountAllMilitiaInSector( SECTORX( pMoveDir[ iRandomRes ][0] ), SECTORY( pMoveDir[ iRandomRes ][0] ) ) )
|
||||
{
|
||||
/* GROUP* pEnemyGroup = GetGroup( GetEnemyGroupIdInSector( SECTORX( pMoveDir[ iRandomRes ][0] ), SECTORY( pMoveDir[ iRandomRes ][0] ) ) );
|
||||
|
||||
if(pEnemyGroup && pEnemyGroup->ubGroupID)
|
||||
if( NumEnemiesInSector( SECTORX( pMoveDir[ iRandomRes ][0] ), SECTORY( pMoveDir[ iRandomRes ][0] ) ) && CountAllMilitiaInSector( SECTORX( pMoveDir[ iRandomRes ][0] ), SECTORY( pMoveDir[ iRandomRes ][0] ) ) )
|
||||
{
|
||||
//ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Attacking from %ld,%ld to %ld,%ld - enemy's group id %ld", sMapX, sMapY, SECTORX( pMoveDir[ iRandomRes ][0] ), SECTORY( pMoveDir[ iRandomRes ][0], pEnemyGroup->ubGroupID ));
|
||||
//ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Arrival 1, Arrival 2");
|
||||
/* GROUP* pEnemyGroup = GetGroup( GetEnemyGroupIdInSector( SECTORX( pMoveDir[ iRandomRes ][0] ), SECTORY( pMoveDir[ iRandomRes ][0] ) ) );
|
||||
|
||||
if(pEnemyGroup && pEnemyGroup->ubGroupID)
|
||||
{
|
||||
//ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Attacking from %ld,%ld to %ld,%ld - enemy's group id %ld", sMapX, sMapY, SECTORX( pMoveDir[ iRandomRes ][0] ), SECTORY( pMoveDir[ iRandomRes ][0], pEnemyGroup->ubGroupID ));
|
||||
//ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Arrival 1, Arrival 2");
|
||||
|
||||
pEnemyGroup->ubPrevX = sMapX;
|
||||
pEnemyGroup->ubPrevY = sMapY;
|
||||
pEnemyGroup->ubPrevX = sMapX;
|
||||
pEnemyGroup->ubPrevY = sMapY;
|
||||
|
||||
pEnemyGroup->ubNextX = SECTORX( pMoveDir[ iRandomRes ][0] );
|
||||
pEnemyGroup->ubNextY = SECTORY( pMoveDir[ iRandomRes ][0] );
|
||||
*/
|
||||
gfMSBattle = TRUE;
|
||||
// GroupArrivedAtSector( pEnemyGroup->ubGroupID , TRUE, FALSE );
|
||||
|
||||
EnterAutoResolveMode( SECTORX( pMoveDir[ iRandomRes ][0] ), SECTORY( pMoveDir[ iRandomRes ][0] ) );
|
||||
// }
|
||||
pEnemyGroup->ubNextX = SECTORX( pMoveDir[ iRandomRes ][0] );
|
||||
pEnemyGroup->ubNextY = SECTORY( pMoveDir[ iRandomRes ][0] );
|
||||
*/
|
||||
gfMSBattle = TRUE;
|
||||
// GroupArrivedAtSector( pEnemyGroup->ubGroupID , TRUE, FALSE );
|
||||
|
||||
EnterAutoResolveMode( SECTORX( pMoveDir[ iRandomRes ][0] ), SECTORY( pMoveDir[ iRandomRes ][0] ) );
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else return;
|
||||
|
||||
else return;
|
||||
}
|
||||
|
||||
// moving squad, if it is not a SAM site
|
||||
else if(!IsThisSectorASAMSector( sMapX, sMapY, 0 ))
|
||||
if( !PlayerMercsInSector_MSE( (UINT8)sMapX, (UINT8)sMapY, FALSE ) ) // and there's no player's mercs in the sector
|
||||
@@ -581,6 +589,102 @@ void UpdateMilitiaSquads(INT16 sMapX, INT16 sMapY )
|
||||
|
||||
}
|
||||
|
||||
// Kaiden: Roaming Militia Training:
|
||||
// If we're training roaming militia,
|
||||
// we'll get our squad from here:
|
||||
|
||||
void CreateMilitiaSquads(INT16 sMapX, INT16 sMapY )
|
||||
{
|
||||
UINT16 pMoveDir[4][3];
|
||||
UINT8 uiDirNumber = 0;
|
||||
UINT32 iRandomRes = 0, iRandom = 0;
|
||||
UINT8 x;//,y;
|
||||
SECTORINFO *pSectorInfo = &( SectorInfo[ SECTOR( sMapX, sMapY ) ] );
|
||||
UINT8 uiMilitiaCount;
|
||||
|
||||
if( !gGameExternalOptions.gfAllowMilitiaGroups )
|
||||
return;
|
||||
|
||||
if( sMapX == 1 && sMapY == 1 )
|
||||
{
|
||||
ClearBlockMoveList();
|
||||
gfMSBattle = FALSE;
|
||||
}
|
||||
|
||||
if( CheckInBlockMoveList( sMapX, sMapY ) )return;
|
||||
|
||||
uiMilitiaCount = CountMilitia(pSectorInfo);
|
||||
|
||||
if( !uiMilitiaCount )return;
|
||||
|
||||
// new squad
|
||||
|
||||
if(gGameExternalOptions.gfmusttrainroaming)
|
||||
{
|
||||
if( GetTownIdForSector( sMapX, sMapY ) != BLANK_SECTOR )
|
||||
{
|
||||
GenerateDirectionInfos( sMapX, sMapY, &uiDirNumber, pMoveDir, FALSE, FALSE, FALSE );
|
||||
|
||||
if(uiDirNumber)// && Random(100) < CHANCE_TO_GENERATE_A_SQUAD)
|
||||
{
|
||||
for( x = 1; x < uiDirNumber ; ++x )pMoveDir[x][1] += pMoveDir[x-1][1];
|
||||
|
||||
iRandomRes = Random( pMoveDir[ uiDirNumber - 1 ][1] );
|
||||
|
||||
for( x = 0; x < uiDirNumber; ++x)
|
||||
if( iRandomRes < pMoveDir[x][1] )
|
||||
{
|
||||
iRandomRes = x;
|
||||
break;
|
||||
}
|
||||
|
||||
// shouldn't be!
|
||||
if(iRandomRes >= uiDirNumber)iRandomRes = 0;
|
||||
|
||||
//ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"%ld,%ld:Dir count %ld, Rand %ld. Go to %ld,%ld", sMapX, sMapY, uiDirNumber, iRandomRes, SECTORX( pMoveDir[ iRandomRes ][0] ), SECTORY( pMoveDir[ iRandomRes ][0] ));
|
||||
|
||||
GenerateMilitiaSquad( sMapX, sMapY, SECTORX( pMoveDir[ iRandomRes ][0] ), SECTORY( pMoveDir[ iRandomRes ][0] ) );
|
||||
AddToBlockMoveList( SECTORX( pMoveDir[ iRandomRes ][0] ), SECTORY( pMoveDir[ iRandomRes ][0] ) );
|
||||
|
||||
if( NumEnemiesInSector( SECTORX( pMoveDir[ iRandomRes ][0] ), SECTORY( pMoveDir[ iRandomRes ][0] ) ) && CountAllMilitiaInSector( SECTORX( pMoveDir[ iRandomRes ][0] ), SECTORY( pMoveDir[ iRandomRes ][0] ) ) )
|
||||
{
|
||||
/* GROUP* pEnemyGroup = GetGroup( GetEnemyGroupIdInSector( SECTORX( pMoveDir[ iRandomRes ][0] ), SECTORY( pMoveDir[ iRandomRes ][0] ) ) );
|
||||
|
||||
if(pEnemyGroup && pEnemyGroup->ubGroupID)
|
||||
{
|
||||
//ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Attacking from %ld,%ld to %ld,%ld - enemy's group id %ld", sMapX, sMapY, SECTORX( pMoveDir[ iRandomRes ][0] ), SECTORY( pMoveDir[ iRandomRes ][0], pEnemyGroup->ubGroupID ));
|
||||
//ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Arrival 1, Arrival 2");
|
||||
|
||||
pEnemyGroup->ubPrevX = sMapX;
|
||||
pEnemyGroup->ubPrevY = sMapY;
|
||||
|
||||
pEnemyGroup->ubNextX = SECTORX( pMoveDir[ iRandomRes ][0] );
|
||||
pEnemyGroup->ubNextY = SECTORY( pMoveDir[ iRandomRes ][0] );
|
||||
*/
|
||||
gfMSBattle = TRUE;
|
||||
// GroupArrivedAtSector( pEnemyGroup->ubGroupID , TRUE, FALSE );
|
||||
|
||||
EnterAutoResolveMode( SECTORX( pMoveDir[ iRandomRes ][0] ), SECTORY( pMoveDir[ iRandomRes ][0] ) );
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
else return;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
extern BOOLEAN gfMSResetMilitia;
|
||||
|
||||
void DoMilitiaHelpFromAdjacentSectors( INT16 sMapX, INT16 sMapY )
|
||||
|
||||
@@ -12,6 +12,7 @@ extern UINT8 gpAttackDirs[5][4];
|
||||
extern UINT8 guiDirNumber;
|
||||
|
||||
void UpdateMilitiaSquads(INT16 sMapX, INT16 sMapY );
|
||||
void CreateMilitiaSquads(INT16 sMapX, INT16 sMapY );
|
||||
void MilitiaHelpFromAdjacentSectors( INT16 sMapX, INT16 sMapY );
|
||||
|
||||
void GenerateDirectionInfos( INT16 sMapX, INT16 sMapY, UINT8* uiDirNumber, UINT16 pMoveDir[4][3], BOOLEAN fWithCities, BOOLEAN fForBattle, BOOLEAN fOnlyCitySectors );
|
||||
|
||||
+16
-8
@@ -315,6 +315,10 @@ SOURCE=".\Merc Contract.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MilitiaSquads.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\Player Command.cpp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -339,6 +343,10 @@ SOURCE=.\QuestText.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Reinforcement.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Scheduling.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -475,6 +483,10 @@ SOURCE=".\Merc Contract.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MilitiaSquads.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\Player Command.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -491,6 +503,10 @@ SOURCE=.\Quests.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Reinforcement.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Scheduling.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -546,13 +562,5 @@ SOURCE=.\strategicmap.h
|
||||
SOURCE=".\Town Militia.h"
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MilitiaSquads.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Reinforcement.cpp
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
|
||||
+233
-97
@@ -24,6 +24,7 @@
|
||||
#include "GameSettings.h"
|
||||
#endif
|
||||
|
||||
#include "MilitiaSquads.h"
|
||||
#define SIZE_OF_MILITIA_COMPLETED_TRAINING_LIST 50
|
||||
|
||||
// temporary local global variables
|
||||
@@ -33,6 +34,7 @@ INT16 gsTownSectorServerSkipY = -1;
|
||||
UINT8 gubTownSectorServerIndex = 0;
|
||||
BOOLEAN gfYesNoPromptIsForContinue = FALSE; // this flag remembers whether we're starting new training, or continuing
|
||||
INT32 giTotalCostOfTraining = 0;
|
||||
BOOLEAN gfAreWeTrainingMobile = FALSE;
|
||||
|
||||
|
||||
//the completed list of sector soldiers for training militia
|
||||
@@ -81,7 +83,7 @@ void TownMilitiaTrainingCompleted( SOLDIERTYPE *pTrainer, INT16 sMapX, INT16 sMa
|
||||
|
||||
INT32 iMaxMilitiaPerSector = gGameExternalOptions.iMaxMilitiaPerSector;
|
||||
INT32 iTrainingSquadSize = gGameExternalOptions.iTrainingSquadSize;
|
||||
DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Militia1");
|
||||
DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Militia1");
|
||||
// get town index
|
||||
ubTownId = StrategicMap[ sMapX + sMapY * MAP_WORLD_X ].bNameId;
|
||||
|
||||
@@ -101,101 +103,149 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Militia1");
|
||||
// 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
|
||||
|
||||
while (ubMilitiaTrained < iTrainingSquadSize)
|
||||
|
||||
// Kaiden: Roaming Militia Training:
|
||||
// If we're not training roaming militia,
|
||||
// then we will handle everything as normal.
|
||||
|
||||
if( (IsMilitiaTrainableFromSoldiersSectorMaxed( pTrainer )) && (gGameExternalOptions.gfmusttrainroaming))
|
||||
{
|
||||
// is there room for another militia in the training sector itself?
|
||||
if (CountAllMilitiaInSector(sMapX, sMapY) < iMaxMilitiaPerSector)
|
||||
CreateMilitiaSquads(sMapX, sMapY );
|
||||
}
|
||||
else
|
||||
{
|
||||
while (ubMilitiaTrained < iTrainingSquadSize)
|
||||
{
|
||||
// great! Create a new GREEN militia guy in the training sector
|
||||
StrategicAddMilitiaToSector(sMapX, sMapY, GREEN_MILITIA, 1);
|
||||
// is there room for another militia in the training sector itself?
|
||||
if (CountAllMilitiaInSector(sMapX, sMapY) < iMaxMilitiaPerSector)
|
||||
{
|
||||
// great! Create a new GREEN militia guy in the training sector
|
||||
StrategicAddMilitiaToSector(sMapX, sMapY, GREEN_MILITIA, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
fFoundOne = FALSE;
|
||||
|
||||
if( ubTownId != BLANK_SECTOR )
|
||||
{
|
||||
InitFriendlyTownSectorServer(ubTownId, sMapX, sMapY);
|
||||
|
||||
// check other eligible sectors in this town for room for another militia
|
||||
while( ServeNextFriendlySectorInTown( &sNeighbourX, &sNeighbourY ) )
|
||||
{
|
||||
// is there room for another militia in this neighbouring sector ?
|
||||
if (CountAllMilitiaInSector(sNeighbourX, sNeighbourY) < iMaxMilitiaPerSector)
|
||||
{
|
||||
// great! Create a new GREEN militia guy in the neighbouring sector
|
||||
StrategicAddMilitiaToSector(sNeighbourX, sNeighbourY, GREEN_MILITIA, 1);
|
||||
|
||||
fFoundOne = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if we still haven't been able to train anyone
|
||||
if (!fFoundOne)
|
||||
{
|
||||
// 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);
|
||||
fFoundOne = 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);
|
||||
|
||||
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))
|
||||
{
|
||||
// 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 REGULAR
|
||||
StrategicPromoteMilitiaInSector(sMapX, sMapY, REGULAR_MILITIA, 1);
|
||||
fFoundOne = 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 REGULAR militia men in the neighbouring sector ?
|
||||
if (MilitiaInSectorOfRank(sNeighbourX, sNeighbourY, REGULAR_MILITIA) > 0)
|
||||
{
|
||||
// great! Promote a GREEN militia guy in the neighbouring sector to a REGULAR
|
||||
StrategicPromoteMilitiaInSector(sNeighbourX, sNeighbourY, REGULAR_MILITIA, 1);
|
||||
|
||||
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++;
|
||||
}
|
||||
else
|
||||
|
||||
|
||||
// if anyone actually got trained
|
||||
if (ubMilitiaTrained > 0)
|
||||
{
|
||||
fFoundOne = FALSE;
|
||||
// update the screen display
|
||||
fMapPanelDirty = TRUE;
|
||||
|
||||
if( ubTownId != BLANK_SECTOR )
|
||||
{
|
||||
InitFriendlyTownSectorServer(ubTownId, sMapX, sMapY);
|
||||
|
||||
// check other eligible sectors in this town for room for another militia
|
||||
while( ServeNextFriendlySectorInTown( &sNeighbourX, &sNeighbourY ) )
|
||||
{
|
||||
// is there room for another militia in this neighbouring sector ?
|
||||
if (CountAllMilitiaInSector(sNeighbourX, sNeighbourY) < iMaxMilitiaPerSector)
|
||||
{
|
||||
// great! Create a new GREEN militia guy in the neighbouring sector
|
||||
StrategicAddMilitiaToSector(sNeighbourX, sNeighbourY, GREEN_MILITIA, 1);
|
||||
|
||||
fFoundOne = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// loyalty in this town increases a bit because we obviously care about them...
|
||||
IncrementTownLoyalty( ubTownId, LOYALTY_BONUS_FOR_TOWN_TRAINING );
|
||||
}
|
||||
|
||||
// if we still haven't been able to train anyone
|
||||
if (!fFoundOne)
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
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);
|
||||
|
||||
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++;
|
||||
}
|
||||
|
||||
|
||||
// if anyone actually got trained
|
||||
if (ubMilitiaTrained > 0)
|
||||
{
|
||||
// update the screen display
|
||||
fMapPanelDirty = TRUE;
|
||||
|
||||
if( ubTownId != BLANK_SECTOR )
|
||||
{
|
||||
// loyalty in this town increases a bit because we obviously care about them...
|
||||
IncrementTownLoyalty( ubTownId, LOYALTY_BONUS_FOR_TOWN_TRAINING );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// the trainer announces to player that he's finished his assignment. Make his sector flash!
|
||||
AssignmentDone( pTrainer, TRUE, FALSE );
|
||||
|
||||
@@ -519,9 +569,21 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Militia2");
|
||||
iNumberOfSectors = GetNumberOfUnpaidTrainableSectors( );
|
||||
Assert( iNumberOfSectors > 0 );
|
||||
|
||||
// Kaiden: Roaming Militia Training:
|
||||
// We want to charge more for Roaming
|
||||
|
||||
// get total cost
|
||||
giTotalCostOfTraining = iMilitiaTrainingCost * iNumberOfSectors;
|
||||
Assert( giTotalCostOfTraining > 0 );
|
||||
if( IsMilitiaTrainableFromSoldiersSectorMaxed( pSoldier ) && (gGameExternalOptions.gfmusttrainroaming))
|
||||
{
|
||||
giTotalCostOfTraining = (iMilitiaTrainingCost*gGameExternalOptions.iMilitiaCostModifier) * iNumberOfSectors;
|
||||
Assert( giTotalCostOfTraining > 0 );
|
||||
gfAreWeTrainingMobile = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
giTotalCostOfTraining = iMilitiaTrainingCost * iNumberOfSectors;
|
||||
Assert( giTotalCostOfTraining > 0 );
|
||||
}
|
||||
|
||||
gfYesNoPromptIsForContinue = FALSE;
|
||||
|
||||
@@ -579,6 +641,7 @@ void HandleInterfaceMessageForContinuingTrainingMilitia( SOLDIERTYPE *pSoldier )
|
||||
|
||||
INT32 iMinLoyaltyToTrain = gGameExternalOptions.iMinLoyaltyToTrain;
|
||||
INT32 iMilitiaTrainingCost = gGameExternalOptions.iMilitiaTrainingCost;
|
||||
|
||||
DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Militia3");
|
||||
|
||||
sSectorX = pSoldier->sSectorX;
|
||||
@@ -599,7 +662,12 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Militia3");
|
||||
return;
|
||||
}
|
||||
|
||||
if ( IsMilitiaTrainableFromSoldiersSectorMaxed( pSoldier ) )
|
||||
// Kaiden: Roaming Militia Training:
|
||||
// Changed the if condition from
|
||||
// if ( IsMilitiaTrainableFromSoldiersSectorMaxed( pSoldier ) )
|
||||
// And we're not training mobile militia from a SAM Site
|
||||
|
||||
if (( IsMilitiaTrainableFromSoldiersSectorMaxed( pSoldier )) && (IsThisSectorASAMSector(sSectorX,sSectorY,0 )))
|
||||
{
|
||||
// we're full!!! go home!
|
||||
bTownId = GetTownIdForSector( sSectorX, sSectorY );
|
||||
@@ -618,10 +686,47 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Militia3");
|
||||
DoContinueMilitiaTrainingMessageBox( sSectorX, sSectorY, sString, MSG_BOX_FLAG_OK, CantTrainMilitiaOkBoxCallback );
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (( IsMilitiaTrainableFromSoldiersSectorMaxed( pSoldier )) && (!gGameExternalOptions.gfmusttrainroaming))
|
||||
{
|
||||
// we're full!!! go home!
|
||||
bTownId = GetTownIdForSector( sSectorX, sSectorY );
|
||||
if ( bTownId == BLANK_SECTOR )
|
||||
{
|
||||
// wilderness SAM site
|
||||
GetSectorIDString( sSectorX, sSectorY, 0, sStringB, TRUE );
|
||||
void (*tempFptr)(INT16 , INT16 , INT8 , CHAR16 *, BOOLEAN) = GetSectorIDString;
|
||||
swprintf( (wchar_t *)sString, (wchar_t *)pMilitiaConfirmStrings[ 10 ], sStringB, tempFptr, iMinLoyaltyToTrain );
|
||||
}
|
||||
else
|
||||
{
|
||||
// town
|
||||
swprintf( (wchar_t *)sString, (wchar_t *)pMilitiaConfirmStrings[ 10 ], pTownNames[ bTownId ], iMinLoyaltyToTrain );
|
||||
}
|
||||
DoContinueMilitiaTrainingMessageBox( sSectorX, sSectorY, sString, MSG_BOX_FLAG_OK, CantTrainMilitiaOkBoxCallback );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// continue training always handles just one sector at a time
|
||||
giTotalCostOfTraining = iMilitiaTrainingCost;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Kaiden: Roaming Militia Training:
|
||||
// Charging more to train Roaming Militia
|
||||
if ( IsMilitiaTrainableFromSoldiersSectorMaxed( pSoldier ) && (gGameExternalOptions.gfmusttrainroaming))
|
||||
{
|
||||
giTotalCostOfTraining = (iMilitiaTrainingCost*gGameExternalOptions.iMilitiaCostModifier);
|
||||
gfAreWeTrainingMobile = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// continue training always handles just one sector at a time
|
||||
giTotalCostOfTraining = iMilitiaTrainingCost;
|
||||
}
|
||||
// can player afford to continue training?
|
||||
if( LaptopSaveInfo.iCurrentBalance < giTotalCostOfTraining )
|
||||
{
|
||||
@@ -804,9 +909,19 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Militia4");
|
||||
if( SectorOursAndPeaceful( sSectorX, sSectorY, 0 ) )
|
||||
{
|
||||
// don't count GREEN militia, they can be trained into regulars first
|
||||
iNumberOfMilitia += MilitiaInSectorOfRank( sSectorX, sSectorY, REGULAR_MILITIA );
|
||||
iNumberOfMilitia += MilitiaInSectorOfRank( sSectorX, sSectorY, ELITE_MILITIA );
|
||||
iMaxNumber += iMaxMilitiaPerSector;
|
||||
// Kaiden: Veteran Militia Training:
|
||||
// And we don't count regulars either if we're training veterans
|
||||
if (gGameExternalOptions.gfTrainVeteranMilitia)
|
||||
{
|
||||
iNumberOfMilitia += MilitiaInSectorOfRank( sSectorX, sSectorY, ELITE_MILITIA );
|
||||
iMaxNumber += iMaxMilitiaPerSector;
|
||||
}
|
||||
else
|
||||
{
|
||||
iNumberOfMilitia += MilitiaInSectorOfRank( sSectorX, sSectorY, REGULAR_MILITIA );
|
||||
iNumberOfMilitia += MilitiaInSectorOfRank( sSectorX, sSectorY, ELITE_MILITIA );
|
||||
iMaxNumber += iMaxMilitiaPerSector;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -840,11 +955,23 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Militia5");
|
||||
if( SectorOursAndPeaceful( sSectorX, sSectorY, 0 ) )
|
||||
{
|
||||
// don't count GREEN militia, they can be trained into regulars first
|
||||
iNumberOfMilitia += MilitiaInSectorOfRank( sSectorX, sSectorY, REGULAR_MILITIA );
|
||||
iNumberOfMilitia += MilitiaInSectorOfRank( sSectorX, sSectorY, ELITE_MILITIA );
|
||||
iMaxNumber += iMaxMilitiaPerSector;
|
||||
|
||||
// Kaiden: Veteran Militia Training:
|
||||
// And we don't count regulars either if we're training veterans
|
||||
if (gGameExternalOptions.gfTrainVeteranMilitia)
|
||||
{
|
||||
iNumberOfMilitia += MilitiaInSectorOfRank( sSectorX, sSectorY, ELITE_MILITIA );
|
||||
iMaxNumber += iMaxMilitiaPerSector;
|
||||
}
|
||||
else
|
||||
{
|
||||
iNumberOfMilitia += MilitiaInSectorOfRank( sSectorX, sSectorY, REGULAR_MILITIA );
|
||||
iNumberOfMilitia += MilitiaInSectorOfRank( sSectorX, sSectorY, ELITE_MILITIA );
|
||||
iMaxNumber += iMaxMilitiaPerSector;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// now check the number of militia
|
||||
if ( iMaxNumber > iNumberOfMilitia )
|
||||
{
|
||||
@@ -1123,8 +1250,17 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Militia6");
|
||||
Assert( SectorInfo[ ubSector ].fMilitiaTrainingPaid == FALSE );
|
||||
|
||||
// spend the money
|
||||
AddTransactionToPlayersBook( TRAIN_TOWN_MILITIA, ubSector, GetWorldTotalMin(), -( iMilitiaTrainingCost ) );
|
||||
|
||||
// Kaiden: Roaming Militia Training:
|
||||
// Charging more to train Roaming Militia
|
||||
if ( gfAreWeTrainingMobile)
|
||||
{
|
||||
AddTransactionToPlayersBook( TRAIN_TOWN_MILITIA, ubSector, GetWorldTotalMin(), -( iMilitiaTrainingCost*gGameExternalOptions.iMilitiaCostModifier ) );
|
||||
gfAreWeTrainingMobile = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
AddTransactionToPlayersBook( TRAIN_TOWN_MILITIA, ubSector, GetWorldTotalMin(), -( iMilitiaTrainingCost ) );
|
||||
}
|
||||
// mark this sector sectors as being paid up
|
||||
SectorInfo[ ubSector ].fMilitiaTrainingPaid = TRUE;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user