Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Ja2/ub_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,17 @@ void LoadGameUBOptions()
gGameUBOptions.BorderItem = iniReader.ReadBoolean("Unfinished Business Settings","BORDER_ITEM", TRUE);

gGameUBOptions.EventAttackInitialSectorIfPlayerStillThere = iniReader.ReadBoolean("Unfinished Business Settings","EVENT_ATTACK_INITIAL_SECTOR_IF_PLAYER_STILL_THERE", TRUE);
gGameUBOptions.HandleAddingEnemiesToTunnelMaps = iniReader.ReadBoolean("Unfinished Business Settings","HANDLE_ADDING_ENEMIES_TO_TUNNEL_MAPS", TRUE);
gGameUBOptions.HandleAddingEnemiesToTunnelMaps = iniReader.ReadBoolean("Unfinished Business Settings","HANDLE_ADDING_ENEMIES_TO_TUNNEL_MAPS", TRUE);

//J14-1
gGameUBOptions.Tunnel1_SectorX = iniReader.ReadInteger("Unfinished Business Settings", "TUNNEL1_SECTOR_X", 14);
gGameUBOptions.Tunnel1_SectorY = iniReader.ReadInteger("Unfinished Business Settings", "TUNNEL1_SECTOR_Y", 10);
gGameUBOptions.Tunnel1_SectorZ = iniReader.ReadInteger("Unfinished Business Settings", "TUNNEL1_SECTOR_Z", 1);
//K14-1
gGameUBOptions.Tunnel2_SectorX = iniReader.ReadInteger("Unfinished Business Settings", "TUNNEL2_SECTOR_X", 14);
gGameUBOptions.Tunnel2_SectorY = iniReader.ReadInteger("Unfinished Business Settings", "TUNNEL2_SECTOR_Y", 11);
gGameUBOptions.Tunnel2_SectorZ = iniReader.ReadInteger("Unfinished Business Settings", "TUNNEL2_SECTOR_Z", 1);

gGameUBOptions.ubEndDefaultSectorX = iniReader.ReadInteger("Unfinished Business Settings","DEFAULT_END_SECTOR_X", 16, 1, 16);
gGameUBOptions.ubEndDefaultSectorY = iniReader.ReadInteger("Unfinished Business Settings","DEFAULT_END_SECTOR_Y", 11, 1, 16);
gGameUBOptions.ubEndDefaultSectorZ = iniReader.ReadInteger("Unfinished Business Settings","DEFAULT_END_SECTOR_Z", 0, 0, 16);
Expand Down
8 changes: 8 additions & 0 deletions Ja2/ub_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,14 @@ typedef struct
INT16 BettyBloodCatSectorX;
INT16 BettyBloodCatSectorY;
INT8 BettyBloodCatSectorZ;

INT16 Tunnel1_SectorX;
INT16 Tunnel1_SectorY;
INT8 Tunnel1_SectorZ;

INT16 Tunnel2_SectorX;
INT16 Tunnel2_SectorY;
INT8 Tunnel2_SectorZ;
} GAME_UB_OPTIONS;

extern GAME_UB_OPTIONS gGameUBOptions;
Expand Down
152 changes: 96 additions & 56 deletions Strategic/Ja25 Strategic Ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@ void InitJohnKulbaInitialSector();

void FixEnemyCounterInSectorBug();

void AddEnemiesToFirstTunnelSector();
void AddEnemiesToSecondTunnelSector();
UINT8 NumEnemiesToAttackFirstTunnelSector( UINT8 *pAdmins, UINT8 *pTroops, UINT8 *pElites, UINT8 *pTanks, UINT8 *pJeeps, UINT8 *pRobots );
UINT8 NumEnemiesToAttackSecondTunnelSector( UINT8 *pAdmins, UINT8 *pTroops, UINT8 *pElites, UINT8 *pTanks, UINT8 *pJeeps, UINT8 *pRobots );
void RemoveAllEnemySoldierInitListLinks();
Expand Down Expand Up @@ -1272,10 +1270,69 @@ void InitJa25StrategicAiBloodcats( )
}


static BOOLEAN AddEnemiesToSectorPlayerIsIn(INT16 sectorX, INT16 sectorY, INT8 sectorZ, UINT8 admins, UINT8 troops, UINT8 elites)
{
if ( gGameUBOptions.pJA2UB == TRUE )
{

if ( !(gTacticalStatus.uiFlags & INCOMBAT) )
{
SetEnemyEncounterCode(ENEMY_INVASION_CODE);
}

SetNumberJa25EnemiesInSector(sectorX, sectorY, sectorZ, admins, troops, elites, 0, 0, 0);

SetThisSectorAsEnemyControlled(sectorX, sectorY, sectorZ, FALSE);

//Set up flag so enemies will go and find the player in that sector
gJa25SaveStruct.fEnemyShouldImmediatelySeekThePlayer = TRUE;
gJa25SaveStruct.bSectorTheEnemyWillSeekEnemy = SECTOR(sectorX, sectorY);
}

return(TRUE);
}

static void AddEnemiesToFirstTunnelSector()
{
const auto x1 = gGameUBOptions.Tunnel1_SectorX;
const auto y1 = gGameUBOptions.Tunnel1_SectorY;
const auto z1 = gGameUBOptions.Tunnel1_SectorZ;

UINT8 ubNumAdmins = 0;
UINT8 ubNumTroops = 0;
UINT8 ubNumElites = 0;
UINT8 ubNumTanks = 0;
UINT8 ubNumJeeps = 0;
UINT8 ubNumRobots = 0;

NumEnemiesToAttackFirstTunnelSector(&ubNumAdmins, &ubNumTroops, &ubNumElites, &ubNumTanks, &ubNumJeeps, &ubNumRobots);
SetNumberJa25EnemiesInSector(x1, y1, z1, ubNumAdmins, ubNumTroops, ubNumElites, ubNumTanks, ubNumJeeps, ubNumRobots);
}

static void AddEnemiesToSecondTunnelSector()
{
const auto x2 = gGameUBOptions.Tunnel2_SectorX;
const auto y2 = gGameUBOptions.Tunnel2_SectorY;
const auto z2 = gGameUBOptions.Tunnel2_SectorZ;

UINT8 ubNumAdmins = 0;
UINT8 ubNumTroops = 0;
UINT8 ubNumElites = 0;
UINT8 ubNumTanks = 0;
UINT8 ubNumJeeps = 0;
UINT8 ubNumRobots = 0;

NumEnemiesToAttackSecondTunnelSector(&ubNumAdmins, &ubNumTroops, &ubNumElites, &ubNumTanks, &ubNumJeeps, &ubNumRobots);
SetNumberJa25EnemiesInSector(x2, y2, z2, ubNumAdmins, ubNumTroops, ubNumElites, ubNumTanks, ubNumJeeps, ubNumRobots);
}


void HandleAddingEnemiesToTunnelMaps()
{
BOOLEAN fInCombat = ( gTacticalStatus.uiFlags & INCOMBAT );
UINT8 ubNumEnemies=0;
UINT8 ubNumEnemies = 0;
UINT8 ubNumAdmins = 0;
UINT8 ubNumTroops = 0;
UINT8 ubNumElites = 0;

//if the player has been in the complex
if( HaveMercsEverBeenInComplex() )
Expand All @@ -1284,21 +1341,35 @@ void HandleAddingEnemiesToTunnelMaps()
return;
}

const auto x1 = gGameUBOptions.Tunnel1_SectorX;
const auto y1 = gGameUBOptions.Tunnel1_SectorY;
const auto z1 = gGameUBOptions.Tunnel1_SectorZ;

const auto x2 = gGameUBOptions.Tunnel2_SectorX;
const auto y2 = gGameUBOptions.Tunnel2_SectorY;
const auto z2 = gGameUBOptions.Tunnel2_SectorZ;

const bool isPlayerInFirstTunnel = AreAnyPlayerMercsStillInSector(x1, y1, z1);
const bool isPlayerInSecondTunnel = AreAnyPlayerMercsStillInSector(x2, y2, z2);

//if the player IS NOT in either of the tunnel sectors
if( !AreAnyPlayerMercsStillInSector( 14, 10, 1 ) &&
!AreAnyPlayerMercsStillInSector( 14, 11, 1 ) )
if( !isPlayerInFirstTunnel && !isPlayerInSecondTunnel )
{
AddEnemiesToJa25TunnelMaps();
// Add enemies to both sectors if fan was blown up
if ( gJa25SaveStruct.ubHowPlayerGotThroughFan == PG__PLAYER_BLEW_UP_FAN_TO_GET_THROUGH )
{
AddEnemiesToFirstTunnelSector();
AddEnemiesToSecondTunnelSector();
}
}

//else if the player IS NOT in the 2nd sector but in the first sector
else if( AreAnyPlayerMercsStillInSector( 14, 10, 1 ) &&
!AreAnyPlayerMercsStillInSector( 14, 11, 1 ) )
//else if the player IS NOT in the 2nd sector but is in the first sector
else if( isPlayerInFirstTunnel && !isPlayerInSecondTunnel )
{
ubNumEnemies = NumEnemiesToAttackFirstTunnelSector( NULL, NULL, NULL, NULL, NULL, NULL );
ubNumEnemies = NumEnemiesToAttackFirstTunnelSector(&ubNumAdmins, &ubNumTroops, &ubNumElites, NULL, NULL, NULL );

//Add enemies to the first sector
HandleAddEnemiesToSectorPlayerIsntIn( JA25_J14_1, ubNumEnemies );
AddEnemiesToSectorPlayerIsIn( x1, y1, z1, ubNumAdmins, ubNumTroops, ubNumElites);

//Remember to move the enemies to be in the entrance to the tunnel
SetJa25GeneralFlag( JA_GF__MOVE_ENEMIES_TO_EDGE_IN_TUNNEL_1 );
Expand All @@ -1307,58 +1378,17 @@ void HandleAddingEnemiesToTunnelMaps()
}

//else if the player is in the second sector
else if( AreAnyPlayerMercsStillInSector( 14, 11, 1 ) )
else if( isPlayerInSecondTunnel )
{
ubNumEnemies = NumEnemiesToAttackSecondTunnelSector( NULL, NULL, NULL, NULL, NULL, NULL );
ubNumEnemies = NumEnemiesToAttackSecondTunnelSector(&ubNumAdmins, &ubNumTroops, &ubNumElites, NULL, NULL, NULL );

//Add enemies to the first sector
HandleAddEnemiesToSectorPlayerIsntIn( JA25_K14_1, ubNumEnemies );
AddEnemiesToSectorPlayerIsIn(x2, y2, z2, ubNumAdmins, ubNumTroops, ubNumElites);

//Remember to move the enemies to be in the entrance to the tunnel
SetJa25GeneralFlag( JA_GF__MOVE_ENEMIES_TO_EDGE_IN_TUNNEL_2 );
}
}

void AddEnemiesToJa25TunnelMaps()
{
if( gJa25SaveStruct.ubHowPlayerGotThroughFan == PG__PLAYER_BLEW_UP_FAN_TO_GET_THROUGH )
{
//if the player blew up the fan, add a ton of enemies to the sector
AddEnemiesToFirstTunnelSector();

AddEnemiesToSecondTunnelSector();
}
else if( gJa25SaveStruct.ubHowPlayerGotThroughFan == PG__PLAYER_STOPPED_FAN_TO_GET_THROUGH )
{
}
}

void AddEnemiesToFirstTunnelSector()
{
UINT8 ubNumAdmins=0;
UINT8 ubNumTroops=0;
UINT8 ubNumElites=0;
UINT8 ubNumTanks=0;
UINT8 ubNumJeeps=0;
UINT8 ubNumRobots=0;

NumEnemiesToAttackFirstTunnelSector( &ubNumAdmins, &ubNumTroops, &ubNumElites, &ubNumTanks, &ubNumJeeps, &ubNumRobots );

SetNumberJa25EnemiesInSector( 14, 10, 1, ubNumAdmins, ubNumTroops, ubNumElites, ubNumTanks, ubNumJeeps, ubNumRobots );
}

void AddEnemiesToSecondTunnelSector()
{
UINT8 ubNumAdmins=0;
UINT8 ubNumTroops=0;
UINT8 ubNumElites=0;
UINT8 ubNumTanks=0;
UINT8 ubNumJeeps=0;
UINT8 ubNumRobots=0;

NumEnemiesToAttackSecondTunnelSector( &ubNumAdmins, &ubNumTroops, &ubNumElites, &ubNumTanks, &ubNumJeeps, &ubNumRobots );
SetNumberJa25EnemiesInSector( 14, 11, 1, ubNumAdmins, ubNumTroops, ubNumElites, ubNumTanks, ubNumJeeps, ubNumRobots );
}

UINT8 NumEnemiesToAttackFirstTunnelSector( UINT8 *pAdmins, UINT8 *pTroops, UINT8 *pElites, UINT8 *pTanks, UINT8 *pJeeps, UINT8 *pRobots )
{
Expand Down Expand Up @@ -1388,6 +1418,11 @@ UINT8 NumEnemiesToAttackFirstTunnelSector( UINT8 *pAdmins, UINT8 *pTroops, UINT8
ubNumTroops = 4 + Random( 0 );
ubNumElites = 4 + Random( 0 );
break;
case DIF_LEVEL_INSANE:
ubNumAdmins = 0 + Random(0);
ubNumTroops = 0 + Random(0);
ubNumElites = 8 + Random(0);
break;
}

if( pAdmins )
Expand Down Expand Up @@ -1440,6 +1475,11 @@ UINT8 NumEnemiesToAttackSecondTunnelSector( UINT8 *pAdmins, UINT8 *pTroops, UINT
ubNumTroops = 6 + Random( 0 );
ubNumElites = 4 + Random( 3 );
break;
case DIF_LEVEL_INSANE:
ubNumAdmins = 0 + Random(0);
ubNumTroops = 0 + Random(0);
ubNumElites = 10 + Random(0);
break;
}

if( pAdmins )
Expand Down
1 change: 0 additions & 1 deletion Strategic/Ja25 Strategic Ai.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ BOOLEAN SaveJa25SaveInfoToSaveGame( HWFILE hFile );
BOOLEAN LoadJa25SaveInfoFromSavedGame( HWFILE hFile );


void AddEnemiesToJa25TunnelMaps();
void HandleAddingEnemiesToTunnelMaps();

void SetJa25GeneralFlag( UINT32 uiFlagToSet );
Expand Down