// find the first slot we can fit the guy in BOOLEAN AddCharacterToAnySquad( SOLDIERTYPE *pCharacter ) { // add character to any squad, if character is assigned to a squad, returns TRUE INT8 bCounter = 0; INT8 bFirstEmptySquad = -1; // remove them from current squad RemoveCharacterFromSquads( pCharacter ); // first look for a compatible NON-EMPTY squad (don't start new squad if we don't have to) for( bCounter = 0; bCounter < NUMBER_OF_SQUADS; bCounter++ ) { if( SquadIsEmpty( bCounter ) == FALSE ) { if( AddCharacterToSquad( pCharacter, bCounter ) == TRUE ) { return ( TRUE ); } } else { if ( bFirstEmptySquad == -1 ) { bFirstEmptySquad = bCounter; } } } // no non-empty compatible squads were found // try the first empty one (and there better be one) if ( bFirstEmptySquad != -1 ) { if( AddCharacterToSquad( pCharacter, bFirstEmptySquad ) == TRUE ) { return ( TRUE ); } } // should never happen! Assert( FALSE ); return( FALSE ); }
// find the first slot we can fit the guy in INT8 AddCharacterToUniqueSquad( SOLDIERTYPE *pCharacter ) { // add character to any squad, if character is assigned to a squad, returns TRUE INT8 bCounter = 0; // check if character on a squad // remove them RemoveCharacterFromSquads( pCharacter ); for( bCounter = 0; bCounter < NUMBER_OF_SQUADS; bCounter++ ) { if( SquadIsEmpty( bCounter ) == TRUE ) { if( AddCharacterToSquad( pCharacter, bCounter ) == TRUE ) { return ( bCounter ); } } } return( -1 ); }
BOOLEAN UnRecruitEPC( UINT8 ubCharNum ) { SOLDIERTYPE *pSoldier, *pNewSoldier; // Get soldier pointer pSoldier = FindSoldierByProfileID( ubCharNum, FALSE ); if (!pSoldier) { return( FALSE ); } if (pSoldier->ubWhatKindOfMercAmI != MERC_TYPE__EPC) { return( FALSE ); } if ( pSoldier->bAssignment < ON_DUTY ) { ResetDeadSquadMemberList( pSoldier->bAssignment ); } // Rmeove from squad.... RemoveCharacterFromSquads( pSoldier ); // O< check if this is the only guy in the sector.... if ( gusSelectedSoldier == pSoldier->ubID ) { gusSelectedSoldier = NOBODY; } // OK, UN set recruit flag.. gMercProfiles[ ubCharNum ].ubMiscFlags &= (~PROFILE_MISC_FLAG_EPCACTIVE); // update sector values to current // check to see if this person should disappear from the map after this if ( (ubCharNum == JOHN || ubCharNum == MARY) && pSoldier->sSectorX == 13 && pSoldier->sSectorY == MAP_ROW_B && pSoldier->bSectorZ == 0 ) { gMercProfiles[ ubCharNum ].sSectorX = 0; gMercProfiles[ ubCharNum ].sSectorY = 0; gMercProfiles[ ubCharNum ].bSectorZ = 0; } else { gMercProfiles[ ubCharNum ].sSectorX = pSoldier->sSectorX; gMercProfiles[ ubCharNum ].sSectorY = pSoldier->sSectorY; gMercProfiles[ ubCharNum ].bSectorZ = pSoldier->bSectorZ; } // how do we decide whether or not to set this? gMercProfiles[ ubCharNum ].fUseProfileInsertionInfo = TRUE; gMercProfiles[ ubCharNum ].ubMiscFlags3 |= PROFILE_MISC_FLAG3_PERMANENT_INSERTION_CODE; // Add this guy to CIV team! pNewSoldier = ChangeSoldierTeam( pSoldier, CIV_TEAM ); UpdateTeamPanelAssignments( ); return( TRUE ); }
BOOLEAN AddCharacterToSquad( SOLDIERTYPE *pCharacter, INT8 bSquadValue ) { INT8 bCounter =0; INT16 sX, sY; INT8 bZ; // BOOLEAN fBetweenSectors = FALSE; GROUP *pGroup; BOOLEAN fNewSquad; // add character to squad...return success or failure // run through list of people in squad, find first free slo if( fExitingVehicleToSquad ) { return( FALSE ); } // ATE: If any vehicle exists in this squad AND we're not set to // a driver or or passenger, when return false if ( DoesVehicleExistInSquad( bSquadValue ) ) { // We're not allowing anybody to go on a vehicle if they are not passengers! // NB: We obviously need to make sure that REAL passengers have their // flags set before adding them to a squad! if ( !( pCharacter->uiStatusFlags & ( SOLDIER_PASSENGER | SOLDIER_DRIVER | SOLDIER_VEHICLE ) ) ) { return( FALSE ); } } // if squad is on the move, can't add someone if( IsThisSquadOnTheMove( bSquadValue ) == TRUE ) { // nope, go away now return( FALSE ); } for( bCounter =0; bCounter < NUMBER_OF_SOLDIERS_PER_SQUAD; bCounter++ ) { // check if on current squad and current slot? if( Squad[ bSquadValue ][ bCounter ] == pCharacter ) { // 'successful of sorts, if there, then he's 'added' return ( TRUE ); } // free slot, add here if( Squad[ bSquadValue ][ bCounter ] == NULL ) { // check if squad empty, if not check sector x,y,z are the same as this guys if( SquadIsEmpty( bSquadValue ) == FALSE ) { GetLocationOfSquad( &sX, &sY, &bZ, bSquadValue ); // if not same, return false if( ( pCharacter->sSectorX != sX ) || ( pCharacter -> sSectorY != sY ) ||( pCharacter->bSectorZ != bZ) ) { return ( FALSE ); } // remove them RemoveCharacterFromSquads( pCharacter ); // fBetweenSectors = Squad[ bSquadValue ][ 0 ]->fBetweenSectors; } else { // remove them RemoveCharacterFromSquads( pCharacter ); } /* if( fBetweenSectors == TRUE ) { pCharacter->fBetweenSectors = TRUE; } */ // copy path of squad to this char CopyPathOfSquadToCharacter( pCharacter, bSquadValue ); // check if old mvt group if( pCharacter -> ubGroupID != 0 ) { // in valid group, remove from that group RemovePlayerFromGroup( pCharacter -> ubGroupID , pCharacter ); // character not on a reserved group if( ( pCharacter->bAssignment >= ON_DUTY ) && ( pCharacter->bAssignment != VEHICLE ) ) { // get the group from the character pGroup = GetGroup( pCharacter -> ubGroupID ); // if valid group, delete it if( pGroup ) { RemoveGroupFromList( pGroup ); } } } if( ( pCharacter->bAssignment == VEHICLE ) && ( pCharacter->iVehicleId == iHelicopterVehicleId ) && ( pCharacter-> iVehicleId != -1 ) ) { // if creating a new squad from guys exiting the chopper fNewSquad = SquadIsEmpty( bSquadValue ); RemoveSoldierFromHelicopter( pCharacter ); AddPlayerToGroup( SquadMovementGroups[ bSquadValue ], pCharacter ); SetGroupSectorValue( pCharacter->sSectorX, pCharacter->sSectorY, pCharacter->bSectorZ, SquadMovementGroups[ bSquadValue ] ); pCharacter -> ubGroupID = SquadMovementGroups[ bSquadValue ]; // if we've just started a new squad if ( fNewSquad ) { // set mvt group for GROUP *pGroup; // grab group pGroup = GetGroup( pVehicleList[ iHelicopterVehicleId ].ubMovementGroup ); Assert( pGroup ); if( pGroup ) { // set where it is and where it's going, then make it arrive there. Don't check for battle PlaceGroupInSector( SquadMovementGroups[ bSquadValue ], pGroup->ubPrevX, pGroup->ubPrevY, pGroup->ubSectorX, pGroup->ubSectorY, pGroup->ubSectorZ, FALSE ); } } } else if( ( pCharacter->bAssignment == VEHICLE ) && ( pCharacter-> iVehicleId != -1 ) ) { fExitingVehicleToSquad = TRUE; // remove from vehicle TakeSoldierOutOfVehicle( pCharacter ); fExitingVehicleToSquad = FALSE; AddPlayerToGroup( SquadMovementGroups[ bSquadValue ], pCharacter ); SetGroupSectorValue( pCharacter->sSectorX, pCharacter->sSectorY, pCharacter->bSectorZ, SquadMovementGroups[ bSquadValue ] ); pCharacter -> ubGroupID = SquadMovementGroups[ bSquadValue ]; } else { AddPlayerToGroup( SquadMovementGroups[ bSquadValue ], pCharacter ); SetGroupSectorValue( pCharacter->sSectorX, pCharacter->sSectorY, pCharacter->bSectorZ, SquadMovementGroups[ bSquadValue ] ); pCharacter -> ubGroupID = SquadMovementGroups[ bSquadValue ]; } // assign here Squad[ bSquadValue ][ bCounter ] = pCharacter; if( ( pCharacter->bAssignment != bSquadValue ) ) { // check to see if we should wake them up if ( pCharacter->fMercAsleep ) { // try to wake him up SetMercAwake( pCharacter, FALSE, FALSE ); } SetTimeOfAssignmentChangeForMerc( pCharacter ); } // set squad value ChangeSoldiersAssignment( pCharacter, bSquadValue ); if ( pCharacter->bOldAssignment < ON_DUTY ) { pCharacter->bOldAssignment = bSquadValue; } // if current tactical sqaud...upadte panel if( NumberOfPeopleInSquad( ( INT8 )iCurrentTacticalSquad ) == 0 ) { SetCurrentSquad( bSquadValue, TRUE ); } if( bSquadValue == ( INT8 ) iCurrentTacticalSquad ) { CheckForAndAddMercToTeamPanel( Squad[ iCurrentTacticalSquad ][ bCounter ] ); } if ( pCharacter->ubID == gusSelectedSoldier ) { SetCurrentSquad( bSquadValue, TRUE ); } return ( TRUE ); } } return ( FALSE ); }
BOOLEAN StrategicRemoveMerc( SOLDIERTYPE *pSoldier ) { UINT8 ubHistoryCode=0; if ( gfInContractMenuFromRenewSequence ) { EndCurrentContractRenewal( ); } // ATE: Determine which HISTORY ENTRY to use... if ( pSoldier->ubLeaveHistoryCode == 0 ) { // Default use contract expired reason... pSoldier->ubLeaveHistoryCode = HISTORY_MERC_CONTRACT_EXPIRED; } ubHistoryCode = pSoldier->ubLeaveHistoryCode; //if the soldier is DEAD if( pSoldier->stats.bLife <= 0 ) { AddCharacterToDeadList( pSoldier ); } //else if the merc was fired else if( ubHistoryCode == HISTORY_MERC_FIRED || pSoldier->bAssignment == ASSIGNMENT_POW ) { AddCharacterToFiredList( pSoldier ); } //The merc is leaving for some other reason else { AddCharacterToOtherList( pSoldier ); } if( pSoldier->ubWhatKindOfMercAmI == MERC_TYPE__NPC ) { SetupProfileInsertionDataForSoldier( pSoldier ); } if (IsVehicle(pSoldier)) { // for some reason, vehicles have their own idea of handling group ids RemovePlayerFromGroup(pVehicleList[ pSoldier->bVehicleID ].ubMovementGroup, pSoldier); } //remove him from the soldier structure if( pSoldier->bAssignment >= ON_DUTY ) { // is he/she in a mvt group, if so, remove and destroy the group if( pSoldier->ubGroupID ) { if ( pSoldier->bAssignment != VEHICLE ) { //Can only remove groups if they aren't persistant (not in a squad or vehicle) RemoveGroup( pSoldier->ubGroupID ); } else { // remove him from any existing merc slot he could be in RemoveMercSlot( pSoldier ); TakeSoldierOutOfVehicle( pSoldier ); } } } else { RemoveCharacterFromSquads( pSoldier ); } // if the merc is not dead if( gMercProfiles[ pSoldier->ubProfile ].bMercStatus != MERC_IS_DEAD ) { //Set the status to returning home ( delay the merc for rehire ) gMercProfiles[ pSoldier->ubProfile ].bMercStatus = MERC_RETURNING_HOME; // specify how long the merc will continue to be unavailable gMercProfiles[ pSoldier->ubProfile ].uiDayBecomesAvailable = 1 + Random(2); // 1-2 days HandleSoldierLeavingWithLowMorale( pSoldier ); HandleSoldierLeavingForAnotherContract( pSoldier ); } //add an entry in the history page for the firing/quiting of the merc // ATE: Don't do this if they are already dead! if ( !( pSoldier->flags.uiStatusFlags & SOLDIER_DEAD ) ) { AddHistoryToPlayersLog( ubHistoryCode, pSoldier->ubProfile, GetWorldTotalMin(), pSoldier->sSectorX, pSoldier->sSectorY ); } //if the merc was a POW, remember it becuase the merc cant show up in AIM or MERC anymore if( pSoldier->bAssignment == ASSIGNMENT_POW ) { gMercProfiles[ pSoldier->ubProfile ].bMercStatus = MERC_FIRED_AS_A_POW; } //else the merc CAN get his medical deposit back else { //Determine how much of a Medical deposit is going to be refunded to the player CalculateMedicalDepositRefund( pSoldier ); } //remove the merc from the tactical TacticalRemoveSoldier( pSoldier->ubID ); // Check if we should remove loaded world... CheckAndHandleUnloadingOfCurrentWorld(); if ( guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN ) { ReBuildCharactersList( ); } fMapPanelDirty = TRUE; fTeamPanelDirty = TRUE; fCharacterInfoPanelDirty = TRUE; // stop time compression so player can react to the departure StopTimeCompression(); // WDS: This allows for replacing dead IMP mercs. See "BtnIMPBeginScreenDoneCallback" in "IMP Begin Screen.cpp" if( ( pSoldier->ubWhatKindOfMercAmI == MERC_TYPE__PLAYER_CHARACTER ) && ( gMercProfiles[ pSoldier->ubProfile ].bMercStatus == MERC_IS_DEAD ) ) { // Replace the name with an empty string wcsncpy( gMercProfiles[ pSoldier->ubProfile ].zName, L"", 1 ); } // ATE: update team panels.... UpdateTeamPanelAssignments( ); // And unpause the @#$@#$ interface UnLockPauseState(); UnPauseGame(); if (is_client) send_dismiss(pSoldier->ubID); return( TRUE ); }
BOOLEAN HandleStrategicDeath( SOLDIERTYPE *pSoldier ) { // add the guy to the dead list //AddCharacterToDeadList( pSoldier ); // If in a vehicle, remove them! if( ( pSoldier->bAssignment == VEHICLE ) && ( pSoldier->iVehicleId != -1 ) ) { // remove from vehicle TakeSoldierOutOfVehicle( pSoldier ); } // if not in mapscreen if ( !(guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN ) ) { // ATE; At least make them dead! if( ( pSoldier->bAssignment != ASSIGNMENT_DEAD ) ) { SetTimeOfAssignmentChangeForMerc( pSoldier ); } ChangeSoldiersAssignment( pSoldier, ASSIGNMENT_DEAD ); } else if( ( pSoldier->stats.bLife == 0 )&&( pSoldier->bAssignment != ASSIGNMENT_DEAD ) ) { // died in mapscreen fReDrawFace = TRUE; // dead if( ( pSoldier->bAssignment != ASSIGNMENT_DEAD ) ) { SetTimeOfAssignmentChangeForMerc( pSoldier ); } ChangeSoldiersAssignment( pSoldier, ASSIGNMENT_DEAD ); //s et breath and breath max to 0 pSoldier->bBreath = pSoldier->bBreathMax = 0; // rebuild list ReBuildCharactersList( ); // ste merc as dead // pSoldier->flags.fUIdeadMerc = TRUE; // attempt to remove character from squad RemoveCharacterFromSquads( pSoldier ); // handle any passign comments by grunts HandleSoldierDeadComments( pSoldier ); // put the dead guys down AddDeadSoldierToUnLoadedSector( ( UINT8 ) ( pSoldier->sSectorX ), ( UINT8 )( pSoldier->sSectorY ), pSoldier->bSectorZ, pSoldier, RandomGridNo(), ADD_DEAD_SOLDIER_TO_SWEETSPOT ); fTeamPanelDirty = TRUE; fMapPanelDirty = TRUE; fCharacterInfoPanelDirty = TRUE; StopTimeCompression(); } return( TRUE ); }