mirror of
https://github.com/1dot13/source.git
synced 2026-09-02 14:36:06 +02:00
Properly reset merc assignment when mission prep completes, regardless of success or failure
Fix use of merc profile id in first mission event param
This commit is contained in:
+70
-37
@@ -2664,7 +2664,7 @@ void StartMission(INT8 index)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MissionHelpers::missionParam = SerialiseMissionFirstEvent(FALSE, agentIndex[index], static_cast<RebelCommandAgentMissions>(rebelCommandSaveInfo.availableMissions[index]), missionDuration, static_cast<UINT8>(extraBits));
|
MissionHelpers::missionParam = SerialiseMissionFirstEvent(FALSE, mercs[agentIndex[index]]->ubProfile, static_cast<RebelCommandAgentMissions>(rebelCommandSaveInfo.availableMissions[index]), missionDuration, static_cast<UINT8>(extraBits));
|
||||||
if (merc->bSex == MALE)
|
if (merc->bSex == MALE)
|
||||||
swprintf(text, L"%s Send %s to prepare this mission? He will return in 24 hours.", text, merc->zNickname);
|
swprintf(text, L"%s Send %s to prepare this mission? He will return in 24 hours.", text, merc->zNickname);
|
||||||
else
|
else
|
||||||
@@ -2679,14 +2679,20 @@ void StartMission(INT8 index)
|
|||||||
|
|
||||||
if (!evt.sentGenericRebelAgent)
|
if (!evt.sentGenericRebelAgent)
|
||||||
{
|
{
|
||||||
SOLDIERTYPE* pSoldier = MercPtrs[evt.mercProfileId];
|
for (UINT8 i = gTacticalStatus.Team[OUR_TEAM].bFirstID; i <= gTacticalStatus.Team[OUR_TEAM].bLastID; ++i)
|
||||||
|
{
|
||||||
TakeSoldierOutOfVehicle(pSoldier);
|
SOLDIERTYPE* pSoldier = MercPtrs[i];
|
||||||
RemoveCharacterFromSquads(pSoldier);
|
if (pSoldier->ubProfile == evt.mercProfileId)
|
||||||
pSoldier->bSectorZ += REBEL_COMMAND_Z_OFFSET;
|
{
|
||||||
pSoldier->bBleeding = 0;
|
TakeSoldierOutOfVehicle(pSoldier);
|
||||||
SetTimeOfAssignmentChangeForMerc(pSoldier);
|
RemoveCharacterFromSquads(pSoldier);
|
||||||
ChangeSoldiersAssignment(pSoldier, ASSIGNMENT_REBELCOMMAND);
|
pSoldier->bSectorZ += REBEL_COMMAND_Z_OFFSET;
|
||||||
|
pSoldier->bBleeding = 0;
|
||||||
|
SetTimeOfAssignmentChangeForMerc(pSoldier);
|
||||||
|
ChangeSoldiersAssignment(pSoldier, ASSIGNMENT_REBELCOMMAND);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// disable missions until next refresh
|
// disable missions until next refresh
|
||||||
@@ -4316,24 +4322,24 @@ void HandleStrategicEvent(const UINT32 eventParam)
|
|||||||
// mission prep is over. see if we can activate the mission
|
// mission prep is over. see if we can activate the mission
|
||||||
missionMap.erase(static_cast<RebelCommandAgentMissions>(evt1.missionId));
|
missionMap.erase(static_cast<RebelCommandAgentMissions>(evt1.missionId));
|
||||||
|
|
||||||
|
// make sure the merc's still on our team
|
||||||
|
BOOLEAN foundMerc = FALSE;
|
||||||
|
for (UINT8 i = gTacticalStatus.Team[OUR_TEAM].bFirstID; i <= gTacticalStatus.Team[OUR_TEAM].bLastID; ++i)
|
||||||
|
{
|
||||||
|
const SOLDIERTYPE* pSoldier = MercPtrs[i];
|
||||||
|
|
||||||
|
if (pSoldier->ubProfile == evt1.mercProfileId && pSoldier->bActive)
|
||||||
|
{
|
||||||
|
foundMerc = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (evt1.isMissionSuccess)
|
if (evt1.isMissionSuccess)
|
||||||
{
|
{
|
||||||
const RebelCommandAgentMissions mission = static_cast<RebelCommandAgentMissions>(evt1.missionId);
|
const RebelCommandAgentMissions mission = static_cast<RebelCommandAgentMissions>(evt1.missionId);
|
||||||
const MERCPROFILESTRUCT merc = gMercProfiles[evt1.mercProfileId];
|
const MERCPROFILESTRUCT merc = gMercProfiles[evt1.mercProfileId];
|
||||||
|
|
||||||
// make sure the merc's still on our team
|
|
||||||
BOOLEAN foundMerc = FALSE;
|
|
||||||
for (UINT8 i = gTacticalStatus.Team[OUR_TEAM].bFirstID; i <= gTacticalStatus.Team[OUR_TEAM].bLastID; ++i)
|
|
||||||
{
|
|
||||||
const SOLDIERTYPE* pSoldier = MercPtrs[i];
|
|
||||||
|
|
||||||
if (pSoldier->ubProfile == evt1.mercProfileId)
|
|
||||||
{
|
|
||||||
foundMerc = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!foundMerc)
|
if (!foundMerc)
|
||||||
goto MissionFailed_MercNoLongerOnTeam;
|
goto MissionFailed_MercNoLongerOnTeam;
|
||||||
|
|
||||||
@@ -4377,16 +4383,17 @@ void HandleStrategicEvent(const UINT32 eventParam)
|
|||||||
|
|
||||||
if (!evt1.sentGenericRebelAgent)
|
if (!evt1.sentGenericRebelAgent)
|
||||||
{
|
{
|
||||||
SOLDIERTYPE* pSoldier = MercPtrs[evt1.mercProfileId];
|
for (UINT8 i = gTacticalStatus.Team[OUR_TEAM].bFirstID; i <= gTacticalStatus.Team[OUR_TEAM].bLastID; ++i)
|
||||||
|
{
|
||||||
// mission successful! give some experience pts
|
SOLDIERTYPE* pSoldier = MercPtrs[i];
|
||||||
StatChange(pSoldier, LDRAMT, 20, FROM_SUCCESS);
|
if (pSoldier->ubProfile == evt1.mercProfileId)
|
||||||
StatChange(pSoldier, WISDOMAMT, 15, FROM_SUCCESS);
|
{
|
||||||
pSoldier->bSectorZ -= REBEL_COMMAND_Z_OFFSET;
|
// mission successful! give some experience pts
|
||||||
pSoldier->ubInsertionDirection = DIRECTION_IRRELEVANT;
|
StatChange(pSoldier, LDRAMT, 20, FROM_SUCCESS);
|
||||||
pSoldier->ubStrategicInsertionCode = INSERTION_CODE_CENTER;
|
StatChange(pSoldier, WISDOMAMT, 15, FROM_SUCCESS);
|
||||||
AssignmentDone(pSoldier, TRUE, FALSE);
|
break;
|
||||||
AddCharacterToAnySquad(pSoldier);
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// rftr todo: tell the player that the mission has started. popupbox or screenmsg?
|
// rftr todo: tell the player that the mission has started. popupbox or screenmsg?
|
||||||
@@ -4399,12 +4406,19 @@ void HandleStrategicEvent(const UINT32 eventParam)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// rftr todo: tell the player that the mission prep failed. some popup box blurb or somesuch.
|
// rftr todo: tell the player that the mission prep failed. some popup box blurb or somesuch.
|
||||||
if (!evt1.sentGenericRebelAgent)
|
if (!evt1.sentGenericRebelAgent && foundMerc)
|
||||||
{
|
{
|
||||||
// mission failed! we tried, have some pity exp
|
for (UINT8 i = gTacticalStatus.Team[OUR_TEAM].bFirstID; i <= gTacticalStatus.Team[OUR_TEAM].bLastID; ++i)
|
||||||
SOLDIERTYPE* pSoldier = MercPtrs[evt1.mercProfileId];
|
{
|
||||||
StatChange(pSoldier, LDRAMT, 20, FROM_FAILURE);
|
SOLDIERTYPE* pSoldier = MercPtrs[i];
|
||||||
StatChange(pSoldier, WISDOMAMT, 15, FROM_FAILURE);
|
if (pSoldier->ubProfile == evt1.mercProfileId)
|
||||||
|
{
|
||||||
|
// mission failed! we tried, give some pity exp
|
||||||
|
StatChange(pSoldier, LDRAMT, 20, FROM_FAILURE);
|
||||||
|
StatChange(pSoldier, WISDOMAMT, 15, FROM_FAILURE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MissionFailed_MercNoLongerOnTeam:
|
MissionFailed_MercNoLongerOnTeam:
|
||||||
@@ -4412,6 +4426,25 @@ void HandleStrategicEvent(const UINT32 eventParam)
|
|||||||
swprintf(screenMsgText, L"Preparations for mission \"%s\" failed.", szRebelCommandAgentMissionsText[evt1.missionId * 2]);
|
swprintf(screenMsgText, L"Preparations for mission \"%s\" failed.", szRebelCommandAgentMissionsText[evt1.missionId * 2]);
|
||||||
ScreenMsg(FONT_MCOLOR_RED, MSG_INTERFACE, screenMsgText);
|
ScreenMsg(FONT_MCOLOR_RED, MSG_INTERFACE, screenMsgText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!evt1.sentGenericRebelAgent && foundMerc)
|
||||||
|
{
|
||||||
|
for (UINT8 i = gTacticalStatus.Team[OUR_TEAM].bFirstID; i <= gTacticalStatus.Team[OUR_TEAM].bLastID; ++i)
|
||||||
|
{
|
||||||
|
SOLDIERTYPE* pSoldier = MercPtrs[i];
|
||||||
|
if (pSoldier->ubProfile == evt1.mercProfileId)
|
||||||
|
{
|
||||||
|
// merc ready for reassignment
|
||||||
|
pSoldier->bSectorZ -= REBEL_COMMAND_Z_OFFSET;
|
||||||
|
pSoldier->ubInsertionDirection = DIRECTION_IRRELEVANT;
|
||||||
|
pSoldier->ubStrategicInsertionCode = INSERTION_CODE_CENTER;
|
||||||
|
AssignmentDone(pSoldier, TRUE, FALSE);
|
||||||
|
AddCharacterToAnySquad(pSoldier);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (evt2.isSecondEvent)
|
else if (evt2.isSecondEvent)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user