示例#1
0
文件: Squads.c 项目: bowlofstew/ja2
void RebuildCurrentSquad( void )
{
	// rebuilds current squad to reset faces in tactical
	INT32 iCounter = 0;
	INT32 iCount = 0;
	SOLDIERTYPE *pDeadSoldier = NULL;

	// check if valid value passed
	if( ( iCurrentTacticalSquad >= NUMBER_OF_SQUADS ) || ( iCurrentTacticalSquad < 0 ) )
	{
		// no
		return;
	}

	// set default squad..just inc ase we no longer have a valid squad
	SetDefaultSquadOnSectorEntry( TRUE );

	// cleat list
	RemoveAllPlayersFromSlot( );

	// set all auto faces inactive
  SetAllAutoFacesInactive( );

	gfPausedTacticalRenderInterfaceFlags = DIRTYLEVEL2;

	if( iCurrentTacticalSquad != NO_CURRENT_SQUAD )
	{
		for( iCounter = 0; iCounter < NUMBER_OF_SOLDIERS_PER_SQUAD; iCounter++ )
		{
			if(  Squad[ iCurrentTacticalSquad ][ iCounter ] != NULL )
			{
				// squad set, now add soldiers in 
				CheckForAndAddMercToTeamPanel( Squad[ iCurrentTacticalSquad ][ iCounter ] );
			}
		}

		for( iCounter = 0; iCounter < NUMBER_OF_SOLDIERS_PER_SQUAD; iCounter++ )
		{
			if(  sDeadMercs[ iCurrentTacticalSquad ][ iCounter ] != -1 )
			{
				pDeadSoldier = FindSoldierByProfileID( ( UINT8 )( sDeadMercs[ iCurrentTacticalSquad ][ iCounter ] ), TRUE );

				if( pDeadSoldier )
				{
					// squad set, now add soldiers in 
					CheckForAndAddMercToTeamPanel( pDeadSoldier );
				}
			}
		}
	}
}
示例#2
0
文件: Squads.c 项目: bowlofstew/ja2
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 );
}
示例#3
0
文件: Squads.c 项目: bowlofstew/ja2
BOOLEAN SetCurrentSquad( INT32 iCurrentSquad, BOOLEAN fForce )
{
	// set the current tactical squad
	INT32 iCounter = 0;


	// ARM: can't call SetCurrentSquad() in mapscreen, it calls SelectSoldier(), that will initialize interface panels!!!
  // ATE: Adjusted conditions a bit ( sometimes were not getting selected )
	if ( guiCurrentScreen == LAPTOP_SCREEN || guiCurrentScreen == MAP_SCREEN )
  {
  	return( FALSE );
	}

	// ATE; Added to allow us to have NO current squad
	if ( iCurrentSquad == NO_CURRENT_SQUAD )
	{
		// set current squad and return success
		iCurrentTacticalSquad = iCurrentSquad;

		// cleat list
		RemoveAllPlayersFromSlot( );

		// set all auto faces inactive
		SetAllAutoFacesInactive( );

		return( FALSE );
	}


	// check if valid value passed
	if( ( iCurrentSquad >= NUMBER_OF_SQUADS )||( iCurrentSquad < 0 ) )
	{
		// no
		return ( FALSE );
	}

	// check if squad is current
	if( iCurrentSquad == iCurrentTacticalSquad && !fForce )
	{
		return ( TRUE );
	}

	// set current squad and return success
	iCurrentTacticalSquad = iCurrentSquad;

	// cleat list
	RemoveAllPlayersFromSlot( );

	// set all auto faces inactive
  SetAllAutoFacesInactive( );

	if( iCurrentTacticalSquad != NO_CURRENT_SQUAD )
	{
		for( iCounter = 0; iCounter < NUMBER_OF_SOLDIERS_PER_SQUAD; iCounter++ )
		{
			if(  Squad[ iCurrentTacticalSquad ][ iCounter ] != NULL )
			{
				// squad set, now add soldiers in 
				CheckForAndAddMercToTeamPanel( Squad[ iCurrentTacticalSquad ][ iCounter ] );
			}
		}
	}

	// check if the currently selected guy is on this squad, if not, get the first one on the new squad
	if ( gusSelectedSoldier != NO_SOLDIER )
	{
		if( Menptr[ gusSelectedSoldier ].bAssignment != iCurrentTacticalSquad )
		{
			// ATE: Changed this to FALSE for ackoledgement sounds.. sounds bad if just starting/entering sector..
			SelectSoldier( Squad[ iCurrentTacticalSquad ][ 0 ]->ubID, FALSE, TRUE );
		}
	}
	else
	{
		// ATE: Changed this to FALSE for ackoledgement sounds.. sounds bad if just starting/entering sector..
		SelectSoldier( Squad[ iCurrentTacticalSquad ][ 0 ]->ubID, FALSE, TRUE );
	}

	return ( TRUE );
}
示例#4
0
BOOLEAN InternalAddSoldierToSector( UINT8 ubID, BOOLEAN fCalculateDirection, BOOLEAN fUseAnimation, UINT16 usAnimState, UINT16 usAnimCode )
{
	UINT8					ubDirection, ubCalculatedDirection;
	SOLDIERTYPE		*pSoldier;
	INT16					sGridNo;
	INT16					sExitGridNo;

	pSoldier = MercPtrs[ ubID ];
	
	if ( pSoldier->bActive  )
	{
    // ATE: Make sure life of elliot is OK if from a meanwhile
    if ( AreInMeanwhile() && pSoldier->ubProfile == ELLIOT )
    {
      if ( pSoldier->bLife < OKLIFE )
      {
        pSoldier->bLife = 25;
      }
    }

		// ADD SOLDIER TO SLOT!
		if (pSoldier->uiStatusFlags & SOLDIER_OFF_MAP)
		{
			AddAwaySlot( pSoldier );

			// Guy is NOT "in sector"
			pSoldier->bInSector = FALSE;

		}
		else
		{
			AddMercSlot( pSoldier );		

			// Add guy to sector flag
			pSoldier->bInSector = TRUE;

		}

		// If a driver or passenger - stop here!
		if ( pSoldier->uiStatusFlags & SOLDIER_DRIVER || pSoldier->uiStatusFlags & SOLDIER_PASSENGER )
		{
			return( FALSE );
		}

		// Add to panel 
		CheckForAndAddMercToTeamPanel( pSoldier );

		pSoldier->usQuoteSaidFlags &= (~SOLDIER_QUOTE_SAID_SPOTTING_CREATURE_ATTACK);
		pSoldier->usQuoteSaidFlags &= (~SOLDIER_QUOTE_SAID_SMELLED_CREATURE);
		pSoldier->usQuoteSaidFlags &= (~SOLDIER_QUOTE_SAID_WORRIED_ABOUT_CREATURES);

		// Add to interface if the are ours
		if ( pSoldier->bTeam == CREATURE_TEAM )
		{
			sGridNo = FindGridNoFromSweetSpotWithStructData( pSoldier, STANDING, pSoldier->sInsertionGridNo, 7, &ubCalculatedDirection, FALSE );
			if( fCalculateDirection )
				ubDirection = ubCalculatedDirection;
			else
				ubDirection = pSoldier->ubInsertionDirection;
		}
		else
		{
			if( pSoldier->sInsertionGridNo == NOWHERE )
			{ //Add the soldier to the respective entrypoint.  This is an error condition.

				
			}
			if( pSoldier->uiStatusFlags & SOLDIER_VEHICLE )
			{
				sGridNo = FindGridNoFromSweetSpotWithStructDataUsingGivenDirectionFirst( pSoldier, STANDING, pSoldier->sInsertionGridNo, 12, &ubCalculatedDirection, FALSE, pSoldier->ubInsertionDirection );
        // ATE: Override insertion direction
				pSoldier->ubInsertionDirection = ubCalculatedDirection;
			}
			else
			{
				sGridNo = FindGridNoFromSweetSpot( pSoldier, pSoldier->sInsertionGridNo, 7, &ubCalculatedDirection );

        // ATE: Error condition - if nowhere use insertion gridno!
        if ( sGridNo == NOWHERE )
        {
          sGridNo = pSoldier->sInsertionGridNo;
        }
			}

			// Override calculated direction if we were told to....
			if ( pSoldier->ubInsertionDirection > 100 )
			{
				pSoldier->ubInsertionDirection = pSoldier->ubInsertionDirection - 100;
				fCalculateDirection = FALSE;
			}

			if ( fCalculateDirection )
			{
				ubDirection = ubCalculatedDirection;

				// Check if we need to get direction from exit grid...
				if ( pSoldier->bUseExitGridForReentryDirection )
				{
					pSoldier->bUseExitGridForReentryDirection = FALSE;

					// OK, we know there must be an exit gridno SOMEWHERE close...
					sExitGridNo = FindClosestExitGrid( pSoldier, sGridNo, 10 );

					if ( sExitGridNo != NOWHERE )
					{
						// We found one
						// Calculate direction...
						ubDirection = (UINT8)GetDirectionToGridNoFromGridNo( sExitGridNo, sGridNo );						
					}
				}
			}
			else
			{
				ubDirection = pSoldier->ubInsertionDirection;
			}
		}

		//Add
		if(gTacticalStatus.uiFlags & LOADING_SAVED_GAME )
			AddSoldierToSectorGridNo( pSoldier, sGridNo, pSoldier->bDirection, fUseAnimation, usAnimState, usAnimCode );
		else
			AddSoldierToSectorGridNo( pSoldier, sGridNo, ubDirection, fUseAnimation, usAnimState, usAnimCode );

		CheckForPotentialAddToBattleIncrement( pSoldier );

		return( TRUE );
	}

	return( FALSE );
}