// 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 ); }
BOOLEAN RecruitEPC( UINT8 ubCharNum ) { SOLDIERTYPE *pSoldier, *pNewSoldier; // Get soldier pointer pSoldier = FindSoldierByProfileID( ubCharNum, FALSE ); if (!pSoldier) { return( FALSE ); } // OK, set recruit flag.. gMercProfiles[ ubCharNum ].ubMiscFlags |= PROFILE_MISC_FLAG_EPCACTIVE; gMercProfiles[ ubCharNum ].ubMiscFlags3 &= ~PROFILE_MISC_FLAG3_PERMANENT_INSERTION_CODE; // Add this guy to our team! pNewSoldier = ChangeSoldierTeam( pSoldier, gbPlayerNum ); pNewSoldier->ubWhatKindOfMercAmI = MERC_TYPE__EPC; // Try putting them into the current squad if ( AddCharacterToSquad( pNewSoldier, (INT8)CurrentSquad( ) ) == FALSE ) { AddCharacterToAnySquad( pNewSoldier ); } ResetDeadSquadMemberList( pNewSoldier->bAssignment ); DirtyMercPanelInterface( pNewSoldier, DIRTYLEVEL2 ); // Make the interface panel dirty.. // This will dirty the panel next frame... gfRerenderInterfaceFromHelpText = TRUE; // If we are a robot, look to update controller.... if ( pNewSoldier->uiStatusFlags & SOLDIER_ROBOT ) { UpdateRobotControllerGivenRobot( pNewSoldier ); } // Set whatkind of merc am i pNewSoldier->ubWhatKindOfMercAmI = MERC_TYPE__EPC; UpdateTeamPanelAssignments( ); return( TRUE ); }
// 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 RecruitRPC( UINT8 ubCharNum ) { SOLDIERTYPE *pSoldier, *pNewSoldier; // Get soldier pointer pSoldier = FindSoldierByProfileID( ubCharNum, FALSE ); if (!pSoldier) { return( FALSE ); } // OK, set recruit flag.. gMercProfiles[ ubCharNum ].ubMiscFlags |= PROFILE_MISC_FLAG_RECRUITED; // Add this guy to our team! pNewSoldier = ChangeSoldierTeam( pSoldier, gbPlayerNum ); // handle set up any RPC's that will leave us in time if ( ubCharNum == SLAY ) { // slay will leave in a week pNewSoldier->iEndofContractTime = GetWorldTotalMin() + ( 7 * 24 * 60 ); KickOutWheelchair( pNewSoldier ); } else if ( ubCharNum == DYNAMO && gubQuest[ QUEST_FREE_DYNAMO ] == QUESTINPROGRESS ) { EndQuest( QUEST_FREE_DYNAMO, pSoldier->sSectorX, pSoldier->sSectorY ); } // handle town loyalty adjustment HandleTownLoyaltyForNPCRecruitment( pNewSoldier ); // Try putting them into the current squad if ( AddCharacterToSquad( pNewSoldier, (INT8)CurrentSquad( ) ) == FALSE ) { AddCharacterToAnySquad( pNewSoldier ); } ResetDeadSquadMemberList( pNewSoldier->bAssignment ); DirtyMercPanelInterface( pNewSoldier, DIRTYLEVEL2 ); if ( pNewSoldier->inv[ HANDPOS ].usItem == NOTHING ) { // empty handed - swap in first available weapon INT8 bSlot; bSlot = FindObjClass( pNewSoldier, IC_WEAPON ); if ( bSlot != NO_SLOT ) { if ( Item[ pNewSoldier->inv[ bSlot ].usItem ].fFlags & ITEM_TWO_HANDED ) { if ( bSlot != SECONDHANDPOS && pNewSoldier->inv[ SECONDHANDPOS ].usItem != NOTHING ) { // need to move second hand item out first AutoPlaceObject( pNewSoldier, &(pNewSoldier->inv[ SECONDHANDPOS ]), FALSE ); } } // swap item to hand SwapObjs( &(pNewSoldier->inv[ bSlot ]), &(pNewSoldier->inv[ HANDPOS ]) ); } } #ifdef JA2DEMO HandleEndDemoInCreatureLevel( ); #endif if ( ubCharNum == IRA ) { // trigger 0th PCscript line TriggerNPCRecord( IRA, 0 ); } // Set whatkind of merc am i pNewSoldier->ubWhatKindOfMercAmI = MERC_TYPE__NPC; // //add a history log that tells the user that a npc has joined the team // // ( pass in pNewSoldier->sSectorX cause if its invalid, -1, n/a will appear as the sector in the history log ) AddHistoryToPlayersLog( HISTORY_RPC_JOINED_TEAM, pNewSoldier->ubProfile, GetWorldTotalMin(), pNewSoldier->sSectorX, pNewSoldier->sSectorY ); //remove the merc from the Personnel screens departed list ( if they have never been hired before, its ok to call it ) RemoveNewlyHiredMercFromPersonnelDepartedList( pSoldier->ubProfile ); return( TRUE ); }