Skip to content
18 changes: 3 additions & 15 deletions Strategic/Player Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,22 +523,10 @@ BOOLEAN SetThisSectorAsEnemyControlled( INT16 sMapX, INT16 sMapY, INT8 bMapZ, BO
UpdateRefuelSiteAvailability( );
}

//shadooow: re-enable quest if player loses control of the N7 prison and quest was disabled previously
if (sMapX == gModSettings.ubMeanwhileInterrogatePOWSectorX && sMapY == gModSettings.ubMeanwhileInterrogatePOWSectorY && gubQuest[QUEST_INTERROGATION] == QUESTCANNOTSTART)
{
gubQuest[QUEST_INTERROGATION] = QUESTNOTSTARTED;
}
//shadooow: re-enable quest if player loses control of the Alma prison and quest was disabled previously
if (sMapX == gModSettings.ubInitialPOWSectorX && sMapY == gModSettings.ubInitialPOWSectorY && gubQuest[QUEST_HELD_IN_ALMA] == QUESTCANNOTSTART)
{
gubQuest[QUEST_HELD_IN_ALMA] = QUESTNOTSTARTED;
}
#ifndef JA2UB
//shadooow: re-enable quest if player loses control of the Tixa prison and quest was disabled previously
if (sMapX == gModSettings.ubTixaPrisonSectorX && sMapY == gModSettings.ubTixaPrisonSectorY && gubQuest[QUEST_HELD_IN_TIXA] == QUESTCANNOTSTART)
{
gubQuest[QUEST_HELD_IN_TIXA] = QUESTNOTSTARTED;
}
HandlePOWQuestState(Q_RESET, QUEST_INTERROGATION, sMapX, sMapY, bMapZ);
HandlePOWQuestState(Q_RESET, QUEST_HELD_IN_ALMA, sMapX, sMapY, bMapZ);
HandlePOWQuestState(Q_RESET, QUEST_HELD_IN_TIXA, sMapX, sMapY, bMapZ);
#endif
// Flugente: reduce workforce
SectorInfo[SECTOR( sMapX, sMapY )].usWorkers = SectorInfo[SECTOR( sMapX, sMapY )].usWorkers * gGameExternalOptions.dInitialWorkerRate;
Expand Down
133 changes: 67 additions & 66 deletions Strategic/Queen Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "Morale.h"
#include "CampaignStats.h" // added by Flugente
#include "ASD.h" // added by Flugente
#include "Interface Panels.h"

#ifdef JA2BETAVERSION
extern BOOLEAN gfClearCreatureQuest;
Expand Down Expand Up @@ -2716,60 +2717,54 @@ void BeginCaptureSquence( )

void EndCaptureSequence( )
{
#ifdef JA2UB
// no UB
#else

#ifndef JA2UB
// Set flag...
if( !( gStrategicStatus.uiFlags & STRATEGIC_PLAYER_CAPTURED_FOR_RESCUE ) || !(gStrategicStatus.uiFlags & STRATEGIC_PLAYER_CAPTURED_FOR_ESCAPE) )
{
// CJC Dec 1 2002: fixing multiple captures:
//gStrategicStatus.uiFlags |= STRATEGIC_PLAYER_CAPTURED_FOR_RESCUE;

if ( gubQuest[ QUEST_HELD_IN_ALMA ] == QUESTNOTSTARTED )
{
// CJC Dec 1 2002: fixing multiple captures:
gStrategicStatus.uiFlags |= STRATEGIC_PLAYER_CAPTURED_FOR_RESCUE;
StartQuest( QUEST_HELD_IN_ALMA, gWorldSectorX, gWorldSectorY );
}
// CJC Dec 1 2002: fixing multiple captures:
//else if ( gubQuest[ QUEST_HELD_IN_ALMA ] == QUESTDONE )
else if (gubQuest[QUEST_HELD_IN_ALMA] != QUESTINPROGRESS && gubQuest[QUEST_HELD_IN_TIXA] == QUESTNOTSTARTED)
else if (gubQuest[QUEST_HELD_IN_TIXA] == QUESTNOTSTARTED)
{
// CJC Dec 1 2002: fixing multiple captures:
gStrategicStatus.uiFlags |= STRATEGIC_PLAYER_CAPTURED_FOR_RESCUE;
StartQuest(QUEST_HELD_IN_TIXA, gWorldSectorX, gWorldSectorY);
}
else if (gubQuest[QUEST_HELD_IN_ALMA] != QUESTINPROGRESS && gubQuest[QUEST_HELD_IN_TIXA] != QUESTINPROGRESS && gubQuest[QUEST_INTERROGATION] == QUESTNOTSTARTED)
else if (gubQuest[QUEST_INTERROGATION] == QUESTNOTSTARTED)
{
StartQuest( QUEST_INTERROGATION, gWorldSectorX, gWorldSectorY );
// CJC Dec 1 2002: fixing multiple captures:
gStrategicStatus.uiFlags |= STRATEGIC_PLAYER_CAPTURED_FOR_ESCAPE;

// OK! - Schedule Meanwhile now!
HandleInterrogationMeanwhileScene();
}
// CJC Dec 1 2002: fixing multiple captures
else
{
// !?!? set both flags
// Set both flags if we can't start any of the three POW quests
gStrategicStatus.uiFlags |= STRATEGIC_PLAYER_CAPTURED_FOR_RESCUE;
gStrategicStatus.uiFlags |= STRATEGIC_PLAYER_CAPTURED_FOR_ESCAPE;
}
}
#endif
}

void EnemyCapturesPlayerSoldier( SOLDIERTYPE *pSoldier )
int CalculateMaximumPrisonerAmount()
{
UINT32 i;
BOOLEAN fMadeCorpse;
INT32 iNumEnemiesInSector;
#ifndef JA2UB
if (gubQuest[QUEST_HELD_IN_ALMA] == QUESTNOTSTARTED) { return std::size(gModSettings.iInitialPOWGridNo); }
if (gubQuest[QUEST_HELD_IN_TIXA] == QUESTNOTSTARTED) { return std::size(gModSettings.iTixaPrisonPOWGridNo); }
if (gubQuest[QUEST_INTERROGATION] == QUESTNOTSTARTED) { return std::size(gModSettings.iMeanwhileInterrogatePOWGridNo); }
#endif
return 0;
}

void EnemyCapturesPlayerSoldier( SOLDIERTYPE *pSoldier )
{
#ifndef JA2UB
AssertNotNIL(pSoldier);

// ATE: Check first if ! in player captured sequence already
// CJC Dec 1 2002: fixing multiple captures
if ( ( gStrategicStatus.uiFlags & STRATEGIC_PLAYER_CAPTURED_FOR_RESCUE ) && (gStrategicStatus.uiFlags & STRATEGIC_PLAYER_CAPTURED_FOR_ESCAPE) )
{
return;
Expand All @@ -2780,6 +2775,7 @@ void EnemyCapturesPlayerSoldier( SOLDIERTYPE *pSoldier )
{
pSoldier->stats.bLife = 0;
pSoldier->iHealableInjury = 0; // added by SANDRO
BOOLEAN fMadeCorpse;
Comment thread
Asdow marked this conversation as resolved.
HandleSoldierDeath( pSoldier, &fMadeCorpse );
return;
}
Expand All @@ -2800,32 +2796,31 @@ void EnemyCapturesPlayerSoldier( SOLDIERTYPE *pSoldier )
return;
}

// ATE: Patch fix If in a vehicle, remove from vehicle...
TakeSoldierOutOfVehicle( pSoldier );

HandleMoraleEvent( pSoldier, MORALE_MERC_CAPTURED, pSoldier->sSectorX, pSoldier->sSectorY, pSoldier->bSectorZ );

// Change to POW....
//-add him to a POW assignment/group
if( ( pSoldier->bAssignment != ASSIGNMENT_POW ) )
if (gStrategicStatus.ubNumCapturedForRescue >= CalculateMaximumPrisonerAmount())
{
SetTimeOfAssignmentChangeForMerc( pSoldier );
SetTimeOfAssignmentChangeForMerc(pSoldier);
return;
}

ChangeSoldiersAssignment( pSoldier, ASSIGNMENT_POW );
RemoveCharacterFromSquads( pSoldier );

WORLDITEM WorldItem;
std::vector<WORLDITEM> pWorldItem;

#ifdef JA2UB
if (gStrategicStatus.ubNumCapturedForRescue < 3 && (gubQuest[QUEST_HELD_IN_ALMA] == QUESTNOTSTARTED || gubQuest[QUEST_INTERROGATION] == QUESTNOTSTARTED))
#else
if (gStrategicStatus.ubNumCapturedForRescue < 3 && (gubQuest[QUEST_HELD_IN_ALMA] == QUESTNOTSTARTED || gubQuest[QUEST_HELD_IN_TIXA] == QUESTNOTSTARTED || gubQuest[QUEST_INTERROGATION] == QUESTNOTSTARTED))
#endif
{
INT32 itemdropoffgridno = -1;
// ATE: Patch fix If in a vehicle, remove from vehicle...
TakeSoldierOutOfVehicle(pSoldier);

HandleMoraleEvent(pSoldier, MORALE_MERC_CAPTURED, pSoldier->sSectorX, pSoldier->sSectorY, pSoldier->bSectorZ);

// Change to POW....
//-add him to a POW assignment/group
if ((pSoldier->bAssignment != ASSIGNMENT_POW))
{
SetTimeOfAssignmentChangeForMerc(pSoldier);
}

ChangeSoldiersAssignment(pSoldier, ASSIGNMENT_POW);
RemoveCharacterFromSquads(pSoldier);


INT32 itemdropoffgridno = -1;
// Is this the first one..?
if ( gubQuest[QUEST_HELD_IN_ALMA] == QUESTNOTSTARTED )
{
Expand All @@ -2837,7 +2832,6 @@ void EnemyCapturesPlayerSoldier( SOLDIERTYPE *pSoldier )
pSoldier->usStrategicInsertionData = gModSettings.iInitialPOWGridNo[gStrategicStatus.ubNumCapturedForRescue];
itemdropoffgridno = gModSettings.iInitialPOWItemGridNo[gStrategicStatus.ubNumCapturedForRescue];
}
#ifndef JA2UB
else if (gubQuest[QUEST_HELD_IN_TIXA] == QUESTNOTSTARTED)
{
//-teleport him to Tixa as originally planned
Expand All @@ -2848,7 +2842,6 @@ void EnemyCapturesPlayerSoldier( SOLDIERTYPE *pSoldier )
pSoldier->usStrategicInsertionData = gModSettings.iTixaPrisonPOWGridNo[gStrategicStatus.ubNumCapturedForRescue];
itemdropoffgridno = gModSettings.iTixaPrisonPOWItemGridNo[gStrategicStatus.ubNumCapturedForRescue];
}
#endif
else //if ( gubQuest[QUEST_HELD_IN_ALMA] == QUESTDONE )
{
//-teleport him to N7
Expand All @@ -2860,8 +2853,10 @@ void EnemyCapturesPlayerSoldier( SOLDIERTYPE *pSoldier )
}

// OK, drop all items!
WORLDITEM WorldItem;
std::vector<WORLDITEM> pWorldItem;
UINT32 invsize = pSoldier->inv.size();
for ( i = 0; i < invsize; ++i )
for (UINT32 i = 0; i < invsize; ++i )
{
if ( pSoldier->inv[i].exists() )
{
Expand All @@ -2883,34 +2878,40 @@ void EnemyCapturesPlayerSoldier( SOLDIERTYPE *pSoldier )
pSoldier->ubStrategicInsertionCode = INSERTION_CODE_GRIDNO;

gStrategicStatus.ubNumCapturedForRescue++;
}

//Bandaging him would prevent him from dying (due to low HP)
pSoldier->bBleeding = 0;
//Bandaging him would prevent him from dying (due to low HP)
pSoldier->bBleeding = 0;

// wake him up
if ( pSoldier->flags.fMercAsleep )
{
PutMercInAwakeState( pSoldier );
pSoldier->flags.fForcedToStayAwake = FALSE;
}
// wake him up
if ( pSoldier->flags.fMercAsleep )
{
PutMercInAwakeState( pSoldier );
pSoldier->flags.fForcedToStayAwake = FALSE;
}

//Set his life to 50% + or - 10 HP.
INT8 oldlife = pSoldier->stats.bLife;
pSoldier->stats.bLife = max(35, pSoldier->stats.bLifeMax / 2);
//Set his life to 50% + or - 10 HP.
INT8 oldlife = pSoldier->stats.bLife;
pSoldier->stats.bLife = max(35, pSoldier->stats.bLifeMax / 2);

if ( pSoldier->stats.bLife >= 45 )
{
pSoldier->stats.bLife += (INT8)(10 - Random( 21 ) );
}
if ( pSoldier->stats.bLife >= 45 )
{
pSoldier->stats.bLife += (INT8)(10 - Random( 21 ) );
}

// SANDRO - make the lost life insta-healable
pSoldier->iHealableInjury = ((pSoldier->stats.bLifeMax - pSoldier->stats.bLife) * 100);
// SANDRO - make the lost life insta-healable
pSoldier->iHealableInjury = ((pSoldier->stats.bLifeMax - pSoldier->stats.bLife) * 100);

// make him quite exhausted when found
pSoldier->bBreath = pSoldier->bBreathMax = 50;
pSoldier->sBreathRed = 0;
pSoldier->flags.fMercCollapsedFlag = FALSE;
// make him quite exhausted when found
pSoldier->bBreath = pSoldier->bBreathMax = 50;
pSoldier->sBreathRed = 0;
pSoldier->flags.fMercCollapsedFlag = FALSE;


RemoveSoldierFromTacticalSector(pSoldier, TRUE);
RemovePlayerFromTeamSlotGivenMercID(pSoldier->ubID);
SelectNextAvailSoldier(pSoldier);
}
#endif
}


Expand Down
87 changes: 81 additions & 6 deletions Strategic/Quests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1731,9 +1731,84 @@ void GiveQuestRewardPoint( INT16 sQuestSectorX, INT16 sQuestsSectorY, INT8 bExpR
}
}







void HandlePOWQuestState(PowQuestState state, Quests quest, INT16 mapX, INT16 mapY, INT8 mapZ)
{
#ifndef JA2UB
bool correctSector = false;
switch (quest)
{
case QUEST_HELD_IN_ALMA:
correctSector = (mapX == gModSettings.ubInitialPOWSectorX && mapY == gModSettings.ubInitialPOWSectorY && mapZ == 0);
break;
case QUEST_INTERROGATION:
correctSector = (mapX == gModSettings.ubMeanwhileInterrogatePOWSectorX && mapY == gModSettings.ubMeanwhileInterrogatePOWSectorY && mapZ == 0);
break;
case QUEST_HELD_IN_TIXA:
correctSector = (mapX == gModSettings.ubTixaPrisonSectorX && mapY == gModSettings.ubTixaPrisonSectorY && mapZ == 0);
break;
default:
break;
}

if (correctSector)
{
switch (state)
{
case Q_FAIL:
// End quest if player loses prison
if (gubQuest[quest] == QUESTINPROGRESS)
{
// Quest failed
InternalEndQuest(quest, mapX, mapY, FALSE);
}
else if (gubQuest[quest] == QUESTCANNOTSTART)
{
// Re-enable quest if player loses control of the prison and quest was disabled previously
gubQuest[quest] = QUESTNOTSTARTED;
}
break;
case Q_SUCCESS:
// End quest if player takes control of the prison
if (gubQuest[quest] == QUESTINPROGRESS)
{
// Complete quest
EndQuest(quest, mapX, mapY);
}
else if (gubQuest[quest] == QUESTNOTSTARTED)
{
// Disable quest if player takes control of the prison
gubQuest[quest] = QUESTCANNOTSTART;
}
break;
case Q_RESET:
// Re-enable quest if player loses control of the prison and quest was disabled previously
if (gubQuest[quest] == QUESTCANNOTSTART)
{
gubQuest[quest] = QUESTNOTSTARTED;
}
break;
case Q_END:
if (gubQuest[quest] == QUESTINPROGRESS)
{
EndQuest(quest, mapX, mapY);
HandleNPCDoAction(0, NPC_ACTION_GRANT_EXPERIENCE_3, 0);
}
break;
case Q_LEFT_SECTOR:
// End interrogation quest if we left the sector, but haven't killed all enemies
if (gubQuest[quest] == QUESTINPROGRESS)
{
// Finish quest, although not give points here...
InternalEndQuest(quest, mapX, mapY, FALSE);
// ... give them manually, but halved
GiveQuestRewardPoint(mapX, mapY, 4, NO_PROFILE);
// Also let us know we finished the quest
ResetHistoryFact(quest, mapX, mapY);
}
break;
default:
break;
}
}
#endif
}
15 changes: 9 additions & 6 deletions Strategic/Quests.h
Original file line number Diff line number Diff line change
Expand Up @@ -756,10 +756,13 @@ extern BOOLEAN CheckForNewShipment( void );
extern BOOLEAN CheckTalkerFemale( void );
extern BOOLEAN CheckTalkerUnpropositionedFemale( void );

enum PowQuestState
{
Q_FAIL,
Q_SUCCESS,
Q_RESET,
Q_END,
Q_LEFT_SECTOR
};
Comment on lines +759 to +766
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider using enum class for this if you don't need them to implicity convert to int

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting identifier "Q_END" is undefined errors in strategicmap.cpp after changing this to enum class

void HandlePOWQuestState(PowQuestState state, Quests quest, INT16 mapX, INT16 mapY, INT8 mapZ);
#endif






4 changes: 2 additions & 2 deletions Strategic/Strategic Movement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4453,7 +4453,7 @@ void CheckMembersOfMvtGroupAndComplainAboutBleeding( SOLDIERTYPE *pSoldier )
return;
}

// make sure there are members in the group..if so, then run through and make each bleeder compain
// make sure there are members in the group..if so, then run through and make each bleeder complain
pPlayer = pGroup->pPlayerList;

// is there a player list?
Expand Down Expand Up @@ -6274,4 +6274,4 @@ void GetInfoFromGroupsInSector( INT16 sSectorX, INT16 sSectorY, UINT8 ubTeam, BO
}
pGroup = pGroup->next;
}
}
}
Loading