From 8858559a10cee5cca7a96e69bff8e869c9cb2e20 Mon Sep 17 00:00:00 2001 From: rftrdev <102184004+rftrdev@users.noreply.github.com> Date: Wed, 12 Oct 2022 00:58:30 -0700 Subject: [PATCH] Add checks before enabling Start Mission button Minor UI adjustments --- GameSettings.cpp | 2 ++ GameSettings.h | 2 ++ Strategic/Rebel Command.cpp | 61 +++++++++++++++++++++++++------------ Strategic/Rebel Command.h | 1 + 4 files changed, 46 insertions(+), 20 deletions(-) diff --git a/GameSettings.cpp b/GameSettings.cpp index 3a7629833..f1251c61c 100644 --- a/GameSettings.cpp +++ b/GameSettings.cpp @@ -4158,6 +4158,8 @@ void LoadRebelCommandSettings() gRebelCommandSettings.iFortificationsBonus = iniReader.ReadInteger("Rebel Command Settings", "FORTIFICATIONS_BONUS", 10, 0, 100); // agent missions + gRebelCommandSettings.iMinLoyaltyForMission = iniReader.ReadInteger("Rebel Command Settings", "MIN_LOYALTY_FOR_MISSION", 51, 0, 100); + gRebelCommandSettings.iDeepDeploymentSuccessChance = iniReader.ReadInteger("Rebel Command Settings", "DEEP_DEPLOYMENT_SUCCESS_CHANCE", 50, 0, 100); gRebelCommandSettings.iDeepDeploymentRangeNS = iniReader.ReadInteger("Rebel Command Settings", "DEEP_DEPLOYMENT_RANGE_NS", 200, 0, 1000); gRebelCommandSettings.iDeepDeploymentRangeEW = iniReader.ReadInteger("Rebel Command Settings", "DEEP_DEPLOYMENT_RANGE_EW", 350, 0, 1000); diff --git a/GameSettings.h b/GameSettings.h index 117fcf069..f28fdd7c8 100644 --- a/GameSettings.h +++ b/GameSettings.h @@ -1843,6 +1843,8 @@ typedef struct INT16 iFortificationsBonus; // agent missions + INT8 iMinLoyaltyForMission; + INT8 iDeepDeploymentSuccessChance; INT16 iDeepDeploymentRangeNS; INT16 iDeepDeploymentRangeEW; diff --git a/Strategic/Rebel Command.cpp b/Strategic/Rebel Command.cpp index 737a89e09..681bf9053 100644 --- a/Strategic/Rebel Command.cpp +++ b/Strategic/Rebel Command.cpp @@ -15,7 +15,7 @@ Directives can be improved with money. At the start of the campaign, this feature is unavailable, but the player gains access to the ARC website as soon as they complete the food delivery quest for the rebels. -Missions were added later and provide powerful temporary bonuses. To enable these bonuses, Supplies must be spent as well as sending +Missions provide powerful temporary bonuses. To enable these bonuses, Supplies must be spent as well as sending either a generic rebel agent or one of their own mercenaries, the latter providing better mission bonuses. @@ -2111,13 +2111,13 @@ BOOLEAN SetupMissionAgentBox(UINT16 x, UINT16 y, INT8 index) LineDraw(FALSE, x, y, x+230, y, Get16BPPColor(FROMRGB(0, 0, 0)), pDestBuf); // bottom horizontal line - LineDraw(FALSE, x, y+300, x+230, y+300, Get16BPPColor(FROMRGB(0, 0, 0)), pDestBuf); + LineDraw(FALSE, x, y+310, x+230, y+310, Get16BPPColor(FROMRGB(0, 0, 0)), pDestBuf); // left vertical line - LineDraw(FALSE, x, y, x, y+300, Get16BPPColor(FROMRGB(0, 0, 0)), pDestBuf); + LineDraw(FALSE, x, y, x, y+310, Get16BPPColor(FROMRGB(0, 0, 0)), pDestBuf); // right vertical line - LineDraw(FALSE, x+230, y, x+230, y+300, Get16BPPColor(FROMRGB(0, 0, 0)), pDestBuf); + LineDraw(FALSE, x+230, y, x+230, y+310, Get16BPPColor(FROMRGB(0, 0, 0)), pDestBuf); UnLockVideoSurface( FRAME_BUFFER ); @@ -2198,8 +2198,7 @@ BOOLEAN SetupMissionAgentBox(UINT16 x, UINT16 y, INT8 index) } DisplayWrappedString(x+5, y+45, 220, 2, FONT10ARIAL, FONT_MCOLOR_BLACK, sText, FONT_MCOLOR_BLACK, FALSE, 0); - // draw agent portrait - if (agentIndex[index] == mercs.size()) + if (agentIndex[index] == mercs.size()) // generic rebel agent { // draw black box for face ColorFillVideoSurfaceArea(FRAME_BUFFER, x+5, y+150+10, x+5+48, y+150+10+43, Get16BPPColor(FROMRGB(64, 64, 64))); @@ -2221,7 +2220,7 @@ BOOLEAN SetupMissionAgentBox(UINT16 x, UINT16 y, INT8 index) // draw contract DrawTextToScreen(L"Contract: ---", x+55, y+150+46, 0, FONT10ARIAL, FONT_MCOLOR_BLACK, FONT_MCOLOR_BLACK, FALSE, 0); } - else + else // one of the player's mercs { // draw face vObjDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE; @@ -2407,17 +2406,32 @@ BOOLEAN SetupMissionAgentBox(UINT16 x, UINT16 y, INT8 index) } } - // draw "start mission" btn - swprintf(sText, L"Start Mission (%d supplies)", GetMissionCost()); - btnId = CreateTextButton(sText, FONT10ARIAL, FONT_MCOLOR_LTYELLOW, FONT_BLACK, BUTTON_USE_DEFAULT, x, y+290, 231, 20, BUTTON_TOGGLE, MSYS_PRIORITY_HIGH, DEFAULT_MOVE_CALLBACK, [](GUI_BUTTON* btn, INT32 reason) - { - const INT8 index = MSYS_GetBtnUserData(btn, 0); - ButtonHelper(btn, reason, [btn, index]() { - StartMission(index); + // draw "start mission" button + const UINT8 townId = GetTownIdForSector(mercs[agentIndex[index]]->sSectorX, mercs[agentIndex[index]]->sSectorY); + const UINT8 townLoyalty = GetRegionLoyalty(townId); + if ((agentIndex[index] < static_cast(mercs.size())) && (townId < FIRST_TOWN || townId >= NUM_TOWNS || townLoyalty < gRebelCommandSettings.iMinLoyaltyForMission)) + { + swprintf(sText, L"Agent not in loyal town"); + DrawTextToScreen(sText, x, y+295, 231, FONT10ARIAL, FONT_RED, FONT_MCOLOR_BLACK, FALSE, CENTER_JUSTIFIED); + } + else if ((gTacticalStatus.uiFlags & INCOMBAT) || gTacticalStatus.fEnemyInSector) + { + swprintf(sText, L"Battle in progress"); + DrawTextToScreen(sText, x, y+295, 231, FONT10ARIAL, FONT_RED, FONT_MCOLOR_BLACK, FALSE, CENTER_JUSTIFIED); + } + else // ok to start mission + { + swprintf(sText, L"Start Mission (%d supplies)", GetMissionCost()); + btnId = CreateTextButton(sText, FONT10ARIAL, FONT_MCOLOR_LTYELLOW, FONT_BLACK, BUTTON_USE_DEFAULT, x, y+290, 231, 20, BUTTON_TOGGLE, MSYS_PRIORITY_HIGH, DEFAULT_MOVE_CALLBACK, [](GUI_BUTTON* btn, INT32 reason) + { + const INT8 index = MSYS_GetBtnUserData(btn, 0); + ButtonHelper(btn, reason, [btn, index]() { + StartMission(index); + }); }); - }); - MSYS_SetBtnUserData(btnId, 0, index); - btnIds.push_back(btnId); + MSYS_SetBtnUserData(btnId, 0, index); + btnIds.push_back(btnId); + } return TRUE; } @@ -2487,7 +2501,7 @@ void RenderMissionOverview() } // "new missions every X hours" text - DrawTextToScreen(szRebelCommandAgentMissionsText[RCAMT_NEW_MISSIONS_AVAILABLE_TIME], WEBSITE_LEFT + 22, WEBSITE_TOP + WEBSITE_HEIGHT - 17, 0, FONT10ARIAL, FONT_MCOLOR_BLACK, FONT_MCOLOR_BLACK, FALSE, 0); + DrawTextToScreen(szRebelCommandAgentMissionsText[RCAMT_NEW_MISSIONS_AVAILABLE_TIME], WEBSITE_LEFT + 22, WEBSITE_TOP + WEBSITE_HEIGHT - 14, 0, FONT10ARIAL, FONT_MCOLOR_BLACK, FONT_MCOLOR_BLACK, FALSE, 0); } void StartMission(INT8 index) @@ -2599,7 +2613,7 @@ void StartMission(INT8 index) missionSuccessChance += GetMissionSuccessChanceBonus(&merc); - if (Random(100) > missionSuccessChance) + if (Random(100) > static_cast(missionSuccessChance)) { // mission failed! missionDuration = 0; @@ -2639,7 +2653,14 @@ void StartMission(INT8 index) if (pSoldier->ubProfile != evt.mercProfileId) continue; - // rftr todo: send selected merc on assignment, like mini event adventure + //TakeSoldierOutOfVehicle(pSoldier); + //RemoveCharacterFromSquads(pSoldier); + //pSoldier->ubHoursRemainingOnMiniEvent = hoursOnMiniEvent; + //pSoldier->bSectorZ += MINI_EVENT_Z_OFFSET; + //pSoldier->bBleeding = 0; + //SetTimeOfAssignmentChangeForMerc(pSoldier); + //ChangeSoldiersAssignment(pSoldier, ASSIGNMENT_REBELCOMMAND); + for (INT8 i = 0; i < NUM_ARC_AGENT_SLOTS; ++i) { if (evt.missionId == rebelCommandSaveInfo.availableMissions[i]) diff --git a/Strategic/Rebel Command.h b/Strategic/Rebel Command.h index f3b56d953..314eaa7f3 100644 --- a/Strategic/Rebel Command.h +++ b/Strategic/Rebel Command.h @@ -5,6 +5,7 @@ #include "Soldier Control.h" #include "Types.h" +#define REBEL_COMMAND_Z_OFFSET 9 #define REBEL_COMMAND_MAX_ACTIONS_PER_REGION 6 #define NUM_ARC_AGENT_SLOTS 2