mirror of
https://github.com/1dot13/source.git
synced 2026-09-09 14:46:05 +02:00
Use new RandomGridNoUnloadedSector() for autoresolve
* Load required mapinfo for checking suitable gridnos * Modify SOLDIERTYPE::DropSectorEquipment( ) to take an external gridno when placing items into an unloaded sector
This commit is contained in:
@@ -2481,6 +2481,12 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Autoresolve2");
|
|||||||
DeleteVideoObjectFromIndex( gpAR->iIndent );
|
DeleteVideoObjectFromIndex( gpAR->iIndent );
|
||||||
DeleteVideoSurfaceFromIndex( gpAR->iInterfaceBuffer );
|
DeleteVideoSurfaceFromIndex( gpAR->iInterfaceBuffer );
|
||||||
|
|
||||||
|
// Load necessary mapinfo to place corpses
|
||||||
|
CHAR8 bFilename[50];
|
||||||
|
INT32 worldRows, worldCols;
|
||||||
|
GetMapFileName(gpAR->ubSectorX, gpAR->ubSectorY, 0, bFilename, TRUE, TRUE);
|
||||||
|
LoadWorldInfoForAutoResolve(bFilename, worldRows, worldCols);
|
||||||
|
|
||||||
if( fDeleteForGood )
|
if( fDeleteForGood )
|
||||||
{ //Delete the soldier instances -- done when we are completely finished.
|
{ //Delete the soldier instances -- done when we are completely finished.
|
||||||
|
|
||||||
@@ -2519,7 +2525,7 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Autoresolve2");
|
|||||||
RemoveCharacterFromSquads( gpMercs[ i ].pSoldier );
|
RemoveCharacterFromSquads( gpMercs[ i ].pSoldier );
|
||||||
ChangeSoldiersAssignment( gpMercs[ i ].pSoldier, ASSIGNMENT_DEAD );
|
ChangeSoldiersAssignment( gpMercs[ i ].pSoldier, ASSIGNMENT_DEAD );
|
||||||
|
|
||||||
AddDeadSoldierToUnLoadedSector( gpAR->ubSectorX, gpAR->ubSectorY, 0, gpMercs[ i ].pSoldier, RandomGridNo(), ADD_DEAD_SOLDIER_TO_SWEETSPOT );
|
AddDeadSoldierToUnLoadedSector( gpAR->ubSectorX, gpAR->ubSectorY, 0, gpMercs[ i ].pSoldier, RandomGridNoUnloadedSector(worldRows, worldCols), ADD_DEAD_SOLDIER_TO_SWEETSPOT );
|
||||||
}
|
}
|
||||||
else if( gpAR->ubBattleStatus == BATTLE_SURRENDERED || gpAR->ubBattleStatus == BATTLE_CAPTURED )
|
else if( gpAR->ubBattleStatus == BATTLE_SURRENDERED || gpAR->ubBattleStatus == BATTLE_CAPTURED )
|
||||||
{
|
{
|
||||||
@@ -2624,7 +2630,8 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Autoresolve2");
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Flugente: drop sector equipment
|
// Flugente: drop sector equipment
|
||||||
gpCivs[ i ].pSoldier->DropSectorEquipment();
|
const auto gridno = RandomGridNoUnloadedSector(worldRows, worldCols);
|
||||||
|
gpCivs[ i ].pSoldier->DropSectorEquipment(gridno);
|
||||||
|
|
||||||
if( fDeleteForGood && gpCivs[ i ].pSoldier->stats.bLife < OKLIFE/2 )
|
if( fDeleteForGood && gpCivs[ i ].pSoldier->stats.bLife < OKLIFE/2 )
|
||||||
{
|
{
|
||||||
@@ -2649,7 +2656,7 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Autoresolve2");
|
|||||||
UpdateMilitia( militia );
|
UpdateMilitia( militia );
|
||||||
}
|
}
|
||||||
|
|
||||||
AddDeadSoldierToUnLoadedSector( gpAR->ubSectorX, gpAR->ubSectorY, 0, gpCivs[ i ].pSoldier, RandomGridNo(), ADD_DEAD_SOLDIER_TO_SWEETSPOT );
|
AddDeadSoldierToUnLoadedSector( gpAR->ubSectorX, gpAR->ubSectorY, 0, gpCivs[ i ].pSoldier, gridno, ADD_DEAD_SOLDIER_TO_SWEETSPOT );
|
||||||
StrategicRemoveMilitiaFromSector( gpCivs[ i ].pSoldier->sSectorX, gpCivs[ i ].pSoldier->sSectorY, ubCurrentRank, 1 );
|
StrategicRemoveMilitiaFromSector( gpCivs[ i ].pSoldier->sSectorX, gpCivs[ i ].pSoldier->sSectorY, ubCurrentRank, 1 );
|
||||||
|
|
||||||
if( ProcessLoyalty() )
|
if( ProcessLoyalty() )
|
||||||
@@ -2681,7 +2688,8 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Autoresolve2");
|
|||||||
TrackEnemiesKilled( ENEMY_KILLED_IN_AUTO_RESOLVE, gpEnemies[ i ].pSoldier->ubSoldierClass ); //add casualty to some statistic
|
TrackEnemiesKilled( ENEMY_KILLED_IN_AUTO_RESOLVE, gpEnemies[ i ].pSoldier->ubSoldierClass ); //add casualty to some statistic
|
||||||
if( ProcessLoyalty() )HandleGlobalLoyaltyEvent( GLOBAL_LOYALTY_ENEMY_KILLED, gpAR->ubSectorX, gpAR->ubSectorY, 0 );
|
if( ProcessLoyalty() )HandleGlobalLoyaltyEvent( GLOBAL_LOYALTY_ENEMY_KILLED, gpAR->ubSectorX, gpAR->ubSectorY, 0 );
|
||||||
ProcessQueenCmdImplicationsOfDeath( gpEnemies[ i ].pSoldier );
|
ProcessQueenCmdImplicationsOfDeath( gpEnemies[ i ].pSoldier );
|
||||||
AddDeadSoldierToUnLoadedSector( gpAR->ubSectorX, gpAR->ubSectorY, 0, gpEnemies[ i ].pSoldier, RandomGridNo(), ADD_DEAD_SOLDIER_TO_SWEETSPOT );
|
const auto gridno = RandomGridNoUnloadedSector(worldRows, worldCols);
|
||||||
|
AddDeadSoldierToUnLoadedSector( gpAR->ubSectorX, gpAR->ubSectorY, 0, gpEnemies[ i ].pSoldier, gridno, ADD_DEAD_SOLDIER_TO_SWEETSPOT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6007,7 +6015,7 @@ void AutoResolveMilitiaDropAndPromote()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Flugente: drop sector equipment
|
// Flugente: drop sector equipment
|
||||||
gpCivs[i].pSoldier->DropSectorEquipment( );
|
gpCivs[i].pSoldier->DropSectorEquipment( NOWHERE );
|
||||||
|
|
||||||
if ( gpCivs[i].pSoldier->stats.bLife < OKLIFE / 2 )
|
if ( gpCivs[i].pSoldier->stats.bLife < OKLIFE / 2 )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11403,7 +11403,7 @@ void TeamDropAll(UINT8 bTeam, BOOLEAN fForce)
|
|||||||
// if soldier is in the current sector, drop all equipment (that has the TAKEN_BY_MILITIA-flag set)
|
// if soldier is in the current sector, drop all equipment (that has the TAKEN_BY_MILITIA-flag set)
|
||||||
if( pSoldier->bActive && ( pSoldier->sSectorX == gWorldSectorX ) && ( pSoldier->sSectorY == gWorldSectorY ) && ( pSoldier->bSectorZ == gbWorldSectorZ) )
|
if( pSoldier->bActive && ( pSoldier->sSectorX == gWorldSectorX ) && ( pSoldier->sSectorY == gWorldSectorY ) && ( pSoldier->bSectorZ == gbWorldSectorZ) )
|
||||||
{
|
{
|
||||||
pSoldier->DropSectorEquipment();
|
pSoldier->DropSectorEquipment( NOWHERE );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1066,7 +1066,7 @@ BOOLEAN TurnSoldierIntoCorpse( SOLDIERTYPE *pSoldier, BOOLEAN fRemoveMerc, BOOLE
|
|||||||
DropKeysInKeyRing( pSoldier, pSoldier->sGridNo, pSoldier->pathing.bLevel, bVisible, FALSE, 0, FALSE );
|
DropKeysInKeyRing( pSoldier, pSoldier->sGridNo, pSoldier->pathing.bLevel, bVisible, FALSE, 0, FALSE );
|
||||||
|
|
||||||
// Flugente: even if we forbid militia from dropping their equipment, they will still drop what they took via sector inventory (this functions only drops what they took)
|
// Flugente: even if we forbid militia from dropping their equipment, they will still drop what they took via sector inventory (this functions only drops what they took)
|
||||||
pSoldier->DropSectorEquipment();
|
pSoldier->DropSectorEquipment( NOWHERE );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make team look for items
|
// Make team look for items
|
||||||
|
|||||||
@@ -16818,7 +16818,7 @@ BOOLEAN SOLDIERTYPE::UpdateMultiTurnAction( )
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SOLDIERTYPE::DropSectorEquipment( )
|
void SOLDIERTYPE::DropSectorEquipment( INT32 UnloadedSectorGridNo)
|
||||||
{
|
{
|
||||||
// not if we already dropped the gear
|
// not if we already dropped the gear
|
||||||
if ( this->usSoldierFlagMask & SOLDIER_EQUIPMENT_DROPPED )
|
if ( this->usSoldierFlagMask & SOLDIER_EQUIPMENT_DROPPED )
|
||||||
@@ -16887,7 +16887,7 @@ void SOLDIERTYPE::DropSectorEquipment( )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AddItemsToUnLoadedSector( this->sSectorX, this->sSectorY, this->bSectorZ, RandomGridNo( ), counter, pObject, 0, WORLD_ITEM_REACHABLE, 0, 1, FALSE );
|
AddItemsToUnLoadedSector( this->sSectorX, this->sSectorY, this->bSectorZ, UnloadedSectorGridNo, counter, pObject, 0, WORLD_ITEM_REACHABLE, 0, 1, FALSE );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1916,7 +1916,7 @@ public:
|
|||||||
void CancelMultiTurnAction(BOOLEAN fFinished);
|
void CancelMultiTurnAction(BOOLEAN fFinished);
|
||||||
BOOLEAN UpdateMultiTurnAction();
|
BOOLEAN UpdateMultiTurnAction();
|
||||||
|
|
||||||
void DropSectorEquipment();
|
void DropSectorEquipment( INT32 UnloadedSectorGridNo);
|
||||||
|
|
||||||
// sevenfm: Take new bomb with id = usItem from iventory to HANDPOS
|
// sevenfm: Take new bomb with id = usItem from iventory to HANDPOS
|
||||||
void TakeNewBombFromInventory(UINT16 usItem);
|
void TakeNewBombFromInventory(UINT16 usItem);
|
||||||
|
|||||||
Reference in New Issue
Block a user