mirror of
https://github.com/1dot13/source.git
synced 2026-09-09 14:46:05 +02:00
Add merc contract check to StartMission
Fail mission prep if the agent is no longer in the player's employ
This commit is contained in:
@@ -2413,6 +2413,9 @@ BOOLEAN SetupMissionAgentBox(UINT16 x, UINT16 y, INT8 index)
|
|||||||
{
|
{
|
||||||
const UINT8 townId = GetTownIdForSector(mercs[agentIndex[index]]->sSectorX, mercs[agentIndex[index]]->sSectorY);
|
const UINT8 townId = GetTownIdForSector(mercs[agentIndex[index]]->sSectorX, mercs[agentIndex[index]]->sSectorY);
|
||||||
const UINT8 townLoyalty = GetRegionLoyalty(townId);
|
const UINT8 townLoyalty = GetRegionLoyalty(townId);
|
||||||
|
const INT32 endTime = mercs[agentIndex[index]]->iEndofContractTime;
|
||||||
|
const INT32 worldMin = GetWorldTotalMin();
|
||||||
|
const INT32 remaining = endTime - worldMin;
|
||||||
|
|
||||||
if (townId < FIRST_TOWN || townId >= NUM_TOWNS || townLoyalty < gRebelCommandSettings.iMinLoyaltyForMission)
|
if (townId < FIRST_TOWN || townId >= NUM_TOWNS || townLoyalty < gRebelCommandSettings.iMinLoyaltyForMission)
|
||||||
{
|
{
|
||||||
@@ -2424,6 +2427,11 @@ BOOLEAN SetupMissionAgentBox(UINT16 x, UINT16 y, INT8 index)
|
|||||||
canStartMission = FALSE;
|
canStartMission = FALSE;
|
||||||
swprintf(sText, L"Agent unavailable");
|
swprintf(sText, L"Agent unavailable");
|
||||||
}
|
}
|
||||||
|
else if (mercs[agentIndex[index]]->ubWhatKindOfMercAmI == MERC_TYPE__AIM_MERC && remaining < 24 * 60)
|
||||||
|
{
|
||||||
|
canStartMission = FALSE;
|
||||||
|
swprintf(sText, L"Agent contract expiring");
|
||||||
|
}
|
||||||
|
|
||||||
if (!canStartMission)
|
if (!canStartMission)
|
||||||
{
|
{
|
||||||
@@ -4310,13 +4318,27 @@ 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));
|
||||||
|
|
||||||
// rftr todo: end the merc's assignment (like mini event adventures)
|
|
||||||
|
|
||||||
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)
|
||||||
|
goto MissionFailed_MercNoLongerOnTeam;
|
||||||
|
|
||||||
// what mission did we do? apply bonuses here, and don't forget to check them later when checking to see if a mission bonus should be applied
|
// what mission did we do? apply bonuses here, and don't forget to check them later when checking to see if a mission bonus should be applied
|
||||||
UINT32 durationBonus = 0;
|
UINT32 durationBonus = 0;
|
||||||
int durationBonusSkill = 0;
|
int durationBonusSkill = 0;
|
||||||
@@ -4387,6 +4409,7 @@ void HandleStrategicEvent(const UINT32 eventParam)
|
|||||||
StatChange(pSoldier, WISDOMAMT, 15, FROM_FAILURE);
|
StatChange(pSoldier, WISDOMAMT, 15, FROM_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MissionFailed_MercNoLongerOnTeam:
|
||||||
swprintf(msgBoxText, L"Mission prep failed... %s", szRebelCommandAgentMissionsText[2 + evt1.missionId * 2]);
|
swprintf(msgBoxText, L"Mission prep failed... %s", szRebelCommandAgentMissionsText[2 + evt1.missionId * 2]);
|
||||||
swprintf(screenMsgText, L"Preparations for mission \"%s\" failed.", szRebelCommandAgentMissionsText[2 + evt1.missionId * 2]);
|
swprintf(screenMsgText, L"Preparations for mission \"%s\" failed.", szRebelCommandAgentMissionsText[2 + evt1.missionId * 2]);
|
||||||
ScreenMsg(FONT_MCOLOR_RED, MSG_INTERFACE, screenMsgText);
|
ScreenMsg(FONT_MCOLOR_RED, MSG_INTERFACE, screenMsgText);
|
||||||
|
|||||||
Reference in New Issue
Block a user