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 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 ); }