Prisoner feature bugfix (#110)

* Allow game to continue after offering to surrender to enemies

* Fix issues related to surrender and POW quests

- Quests were ended prematurely if one had prisoners in both alma and tixa
- Strategic status flags for rescue/escape were not set properly
- Only the maximum amount a prison can hold will be taken as POWs, rest of the mercs will either escape or have to fight to the death, to prevent a player having unrescuable POWs
- Capturing a mercenary had a lot of functions called that should not have been, IF the merc is not going to be captured after all

* Switch all tactical surrender calls to use one unified function

* Only mercs that are capable can escape

Incapacitated mercs left behind will die.
Should probably prioritize incapacitated mercs to be captured by the enemy to prevent needless deaths

* Combine pow quest state changes into one function

* Add JumpIntoEscapedSector to header file

* Allow enemy to demand surrender even if they already have POWs in Tixa and Alma

* Remove surrender from UB

* Address review feedback
This commit is contained in:
Asdow
2023-01-22 23:35:08 +02:00
committed by GitHub
parent 57d2674f37
commit ae1fd0a2ee
21 changed files with 434 additions and 351 deletions
+80 -5
View File
@@ -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
}