Merge branch 'master' into ExtraMercs

This commit is contained in:
Asdow
2023-07-26 13:17:49 +03:00
754 changed files with 9435 additions and 74371 deletions
+112 -50
View File
@@ -1,11 +1,5 @@
#include "builddefines.h"
#ifdef PRECOMPILEDHEADERS
#include "Strategic All.h"
#include "Loading Screen.h"
#include "Enemy Soldier Save.h"
#include "points.h"
#else
#include "strategicmap.h"
#include "strategic.h"
#include "Strategic Mines.h"
@@ -104,7 +98,6 @@
#include "Auto Resolve.h"
#include "cursors.h"
#include "GameVersion.h"
#endif
#include "LuaInitNPCs.h"
#include "Luaglobal.h"
@@ -2222,7 +2215,7 @@ BOOLEAN SetCurrentWorldSector( INT16 sMapX, INT16 sMapY, INT8 bMapZ )
// GridNo = NOWHERE, which causes this assertion to fail
//CHRISL: There's also an issue with vehicles. Soldiers in any vehicle are considered to be in sGridNo = NOWHERE
// This will result in an assertion error, so let's skip the assertion if the merc is assigned to a vehicle
if ( !(MercPtrs[i]->flags.uiStatusFlags & SOLDIER_DEAD) && MercPtrs[i]->bAssignment != VEHICLE && !SPY_LOCATION( MercPtrs[i]->bAssignment ) )
if (!(MercPtrs[i]->flags.uiStatusFlags & SOLDIER_DEAD) && MercPtrs[i]->bAssignment != VEHICLE && !SPY_LOCATION(MercPtrs[i]->bAssignment) && MercPtrs[i]->bAssignment != ASSIGNMENT_POW)
{
//Assert( !MercPtrs[i]->bActive || !MercPtrs[i]->bInSector || MercPtrs[i]->sGridNo != NOWHERE || MercPtrs[i]->bVehicleID == iHelicopterVehicleId );
Assert( !MercPtrs[i]->bActive || !MercPtrs[i]->bInSector || !TileIsOutOfBounds( MercPtrs[i]->sGridNo ) || MercPtrs[i]->bVehicleID == iHelicopterVehicleId );
@@ -2272,7 +2265,7 @@ BOOLEAN SetCurrentWorldSector( INT16 sMapX, INT16 sMapY, INT8 bMapZ )
// GridNo = NOWHERE, which causes this assertion to fail
//CHRISL: There's also an issue with vehicles. Soldiers in any vehicle are considered to be in sGridNo = NOWHERE
// This will result in an assertion error, so let's skip the assertion if the merc is assigned to a vehicle
if ( !(MercPtrs[i]->flags.uiStatusFlags & SOLDIER_DEAD) && MercPtrs[i]->bAssignment != VEHICLE )
if (!(MercPtrs[i]->flags.uiStatusFlags & SOLDIER_DEAD) && MercPtrs[i]->bAssignment != VEHICLE && MercPtrs[i]->bAssignment != ASSIGNMENT_POW)
{
//Assert( !MercPtrs[i]->bActive || !MercPtrs[i]->bInSector || MercPtrs[i]->sGridNo != NOWHERE || MercPtrs[i]->bVehicleID == iHelicopterVehicleId );
Assert( !MercPtrs[i]->bActive || !MercPtrs[i]->bInSector || !TileIsOutOfBounds( MercPtrs[i]->sGridNo ) || MercPtrs[i]->bVehicleID == iHelicopterVehicleId );
@@ -3297,23 +3290,9 @@ void UpdateMercsInSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ )
}
// ATE: Call actions based on what POW we are on...
if ( gubQuest[QUEST_HELD_IN_ALMA] == QUESTINPROGRESS )
{
// Complete quest
EndQuest( QUEST_HELD_IN_ALMA, sSectorX, sSectorY );
// Do action
HandleNPCDoAction( 0, NPC_ACTION_GRANT_EXPERIENCE_3, 0 );
}
#ifndef JA2UB
else if (gubQuest[QUEST_HELD_IN_TIXA] == QUESTINPROGRESS)
{
// Complete quest
EndQuest(QUEST_HELD_IN_TIXA, sSectorX, sSectorY);
// Do action
HandleNPCDoAction(0, NPC_ACTION_GRANT_EXPERIENCE_3, 0);
}
HandlePOWQuestState(Q_END, QUEST_HELD_IN_ALMA, sSectorX, sSectorY, bSectorZ);
HandlePOWQuestState(Q_END, QUEST_HELD_IN_TIXA, sSectorX, sSectorY, bSectorZ);
#endif
}
}
@@ -4308,6 +4287,68 @@ void JumpIntoAdjacentSector( UINT8 ubTacticalDirection, UINT8 ubJumpCode, INT32
}
}
void JumpIntoEscapedSector(UINT8 ubTacticalDirection)
{
// Remove any incapacitated mercs from current squads and assign them to new squad
UINT32 i = gTacticalStatus.Team[gbPlayerNum].bFirstID;
UINT32 const lastID = gTacticalStatus.Team[gbPlayerNum].bLastID;
INT8 currentSquad = -1;
for (SOLDIERTYPE* pSoldier = MercPtrs[i]; i <= lastID; ++i, ++pSoldier)
{
// Are we not active in sector
if (!pSoldier->bActive || !pSoldier->bInSector || pSoldier->stats.bLife >= OKLIFE)
{
continue;
}
if (currentSquad == -1)
{
currentSquad = AddCharacterToUniqueSquad(pSoldier);
continue;
}
if (!AddCharacterToSquad(pSoldier, currentSquad))
{
currentSquad = AddCharacterToUniqueSquad(pSoldier);
}
}
// Retreat squads that are capable of it
for (size_t i = 0; i < NUMBER_OF_SQUADS; i++)
{
for (size_t j = 0; j < NUMBER_OF_SOLDIERS_PER_SQUAD; j++)
{
SOLDIERTYPE* pSoldier = Squad[i][j];
if (pSoldier && OK_CONTROLLABLE_MERC(pSoldier))
{
GROUP* pGroup = GetGroup(pSoldier->ubGroupID);
switch (ubTacticalDirection)
{
case NORTH:
pGroup->ubPrevX = pGroup->ubSectorX;
pGroup->ubPrevY = pGroup->ubSectorY - 1;
break;
case EAST:
pGroup->ubPrevX = pGroup->ubSectorX + 1;
pGroup->ubPrevY = pGroup->ubSectorY;
break;
case SOUTH:
pGroup->ubPrevX = pGroup->ubSectorX;
pGroup->ubPrevY = pGroup->ubSectorY + 1;
break;
case WEST:
pGroup->ubPrevX = pGroup->ubSectorX - 1;
pGroup->ubPrevY = pGroup->ubSectorY;
break;
default:
break;
}
RetreatGroupToPreviousSector(pGroup);
break;
}
}
}
}
void HandleSoldierLeavingSectorByThemSelf( SOLDIERTYPE *pSoldier )
{
@@ -4368,17 +4409,7 @@ void AllMercsWalkedToExitGrid( )
(gubAdjacentJumpCode == JUMP_ALL_LOAD_NEW || gubAdjacentJumpCode == JUMP_SINGLE_LOAD_NEW) )
{
HandleLoyaltyImplicationsOfMercRetreat( RETREAT_TACTICAL_TRAVERSAL, gWorldSectorX, gWorldSectorY, gbWorldSectorZ );
// End inetrrogation quest if we left the sector, but haven't killed all enemies
if ( gWorldSectorX == 7 && gWorldSectorY == 14 && gbWorldSectorZ == 0 && gubQuest[QUEST_INTERROGATION] == QUESTINPROGRESS )
{
// Finish quest, although not give points here...
InternalEndQuest( QUEST_INTERROGATION, gWorldSectorX, gWorldSectorY, FALSE );
// ... give them manually, but halved
GiveQuestRewardPoint( gWorldSectorX, gWorldSectorY, 4, NO_PROFILE );
// Also get us know, we finished the quest
ResetHistoryFact( QUEST_INTERROGATION, gWorldSectorX, gWorldSectorY );
}
HandlePOWQuestState(Q_END, QUEST_INTERROGATION, gWorldSectorX, gWorldSectorY, gbWorldSectorZ);
}
////////////////////////////////////////////////////////////////////////////////////////
@@ -4546,17 +4577,7 @@ void AllMercsHaveWalkedOffSector( )
(gubAdjacentJumpCode == JUMP_ALL_LOAD_NEW || gubAdjacentJumpCode == JUMP_SINGLE_LOAD_NEW) )
{
HandleLoyaltyImplicationsOfMercRetreat( RETREAT_TACTICAL_TRAVERSAL, gWorldSectorX, gWorldSectorY, gbWorldSectorZ );
// End inetrrogation quest if we left the sector, but haven't killed all enemies
if ( gWorldSectorX == 7 && gWorldSectorY == 14 && gbWorldSectorZ == 0 && gubQuest[QUEST_INTERROGATION] == QUESTINPROGRESS )
{
// Finish quest, although not give points here...
InternalEndQuest( QUEST_INTERROGATION, gWorldSectorX, gWorldSectorY, FALSE );
// ... give them manually, but halved
GiveQuestRewardPoint( gWorldSectorX, gWorldSectorY, 4, NO_PROFILE );
// Also get us know, we finished the quest
ResetHistoryFact( QUEST_INTERROGATION, gWorldSectorX, gWorldSectorY );
}
HandlePOWQuestState(Q_END, QUEST_INTERROGATION, gWorldSectorX, gWorldSectorY, gbWorldSectorZ);
}
////////////////////////////////////////////////////////////////////////////////////////
}
@@ -5229,7 +5250,7 @@ BOOLEAN CanGoToTacticalInSector( INT16 sX, INT16 sY, UINT8 ubZ )
{
// ARM: now allows loading of sector with all mercs below OKLIFE as long as they're alive
if( ( pSoldier->bActive && pSoldier->stats.bLife ) && !( pSoldier->flags.uiStatusFlags & SOLDIER_VEHICLE ) &&
( pSoldier->bAssignment != IN_TRANSIT ) && ( pSoldier->bAssignment != ASSIGNMENT_POW ) && ( pSoldier->bAssignment != ASSIGNMENT_MINIEVENT ) &&
( pSoldier->bAssignment != IN_TRANSIT ) && ( pSoldier->bAssignment != ASSIGNMENT_POW ) && ( pSoldier->bAssignment != ASSIGNMENT_MINIEVENT ) && ( pSoldier->bAssignment != ASSIGNMENT_REBELCOMMAND ) &&
( pSoldier->bAssignment != ASSIGNMENT_DEAD ) && !SoldierAboardAirborneHeli( pSoldier )
)
@@ -6402,7 +6423,7 @@ void HandleSlayDailyEvent( void )
}
// valid soldier?
if ( (pSoldier->bActive == FALSE) || (pSoldier->stats.bLife == 0) || (pSoldier->bAssignment == IN_TRANSIT) || (pSoldier->bAssignment == ASSIGNMENT_POW) || (pSoldier->bAssignment == ASSIGNMENT_MINIEVENT) )
if ( (pSoldier->bActive == FALSE) || (pSoldier->stats.bLife == 0) || (pSoldier->bAssignment == IN_TRANSIT) || (pSoldier->bAssignment == ASSIGNMENT_POW) || (pSoldier->bAssignment == ASSIGNMENT_MINIEVENT) || (pSoldier->bAssignment == ASSIGNMENT_REBELCOMMAND) )
{
// no
return;
@@ -6928,6 +6949,47 @@ BOOLEAN EscapeDirectionIsValid( INT8 * pbDirection )
}
return(*pbDirection != -1);
}
bool IsEscapeDirectionValid(WorldDirections pbDirection)
{
bool isValid = false;
UINT8 const ubSectorID = SECTOR(gWorldSectorX, gWorldSectorY);
switch (pbDirection)
{
case NORTH:
if (!(gWorldSectorY - 1 < MINIMUM_VALID_Y_COORDINATE || gMapInformation.sNorthGridNo == NOWHERE ||
SectorInfo[ubSectorID].ubTraversability[NORTH_STRATEGIC_MOVE] == GROUNDBARRIER || SectorInfo[ubSectorID].ubTraversability[NORTH_STRATEGIC_MOVE] == EDGEOFWORLD))
{
isValid = true;
}
break;
case EAST:
if (!(gWorldSectorX + 1 > MAXIMUM_VALID_X_COORDINATE || gMapInformation.sEastGridNo == NOWHERE ||
SectorInfo[ubSectorID].ubTraversability[EAST_STRATEGIC_MOVE] == GROUNDBARRIER || SectorInfo[ubSectorID].ubTraversability[EAST_STRATEGIC_MOVE] == EDGEOFWORLD))
{
isValid = true;
}
break;
case SOUTH:
if (!(gWorldSectorY + 1 > MAXIMUM_VALID_Y_COORDINATE || gMapInformation.sSouthGridNo == NOWHERE ||
SectorInfo[ubSectorID].ubTraversability[SOUTH_STRATEGIC_MOVE] == GROUNDBARRIER || SectorInfo[ubSectorID].ubTraversability[SOUTH_STRATEGIC_MOVE] == EDGEOFWORLD))
{
isValid = true;
}
break;
case WEST:
if (!(gWorldSectorX - 1 < MINIMUM_VALID_X_COORDINATE || gMapInformation.sWestGridNo == NOWHERE ||
SectorInfo[ubSectorID].ubTraversability[WEST_STRATEGIC_MOVE] == GROUNDBARRIER || SectorInfo[ubSectorID].ubTraversability[WEST_STRATEGIC_MOVE] == EDGEOFWORLD))
{
isValid = true;
}
break;
}
return isValid;
}
#ifdef JA2UB
@@ -7975,4 +8037,4 @@ UINT8 tryToRecoverSquadsAndMovementGroups(SOLDIERTYPE* pCharacter) {
}
CheckSquadMovementGroups();
return GetSoldierGroupId(pCharacter);
}
}