// MercDailyUpdate() gets called every day at midnight. If something is to happen to a merc that day, add an event for it. void MercDailyUpdate() { INT32 cnt; INT8 bLastTeamID; SOLDIERTYPE *pSoldier; //SOLDIERTYPE *pQuitList[ 21 ]; MERCPROFILESTRUCT *pProfile; UINT32 uiChance; INT32 iOffset = 0; BOOLEAN fFoundSomeOneForMenuShowing = FALSE; //if its the first day, leave if( GetWorldDay() == 1 ) return; // debug message ScreenMsg( MSG_FONT_RED, MSG_DEBUG, L"%s - Doing MercDailyUpdate", WORLDTIMESTR ); // if the death rate is very low (this is independent of mercs' personal deathrate tolerances) if (CalcDeathRate() < 5) { // everyone gets a morale bonus, which also gets player a reputation bonus. HandleMoraleEvent( NULL, MORALE_LOW_DEATHRATE, -1, -1, -1 ); } //add an event so the merc will say the departing warning ( 2 hours prior to leaving // Do so for all time slots they will depart from AddSameDayStrategicEvent( EVENT_MERC_ABOUT_TO_LEAVE, MERC_ARRIVE_TIME_SLOT_1 - ( 2 * 60 ), 0 ); AddSameDayStrategicEvent( EVENT_MERC_ABOUT_TO_LEAVE, MERC_ARRIVE_TIME_SLOT_2 - ( 2 * 60 ), 0 ); AddSameDayStrategicEvent( EVENT_MERC_ABOUT_TO_LEAVE, MERC_ARRIVE_TIME_SLOT_3 - ( 2 * 60 ), 0 ); AddSameDayStrategicEvent( EVENT_BEGIN_CONTRACT_RENEWAL_SEQUENCE, MERC_ARRIVE_TIME_SLOT_1, 0 ); AddSameDayStrategicEvent( EVENT_BEGIN_CONTRACT_RENEWAL_SEQUENCE, MERC_ARRIVE_TIME_SLOT_2, 0 ); AddSameDayStrategicEvent( EVENT_BEGIN_CONTRACT_RENEWAL_SEQUENCE, MERC_ARRIVE_TIME_SLOT_3, 0 ); cnt = gTacticalStatus.Team[ gbPlayerNum ].bFirstID; bLastTeamID = gTacticalStatus.Team[ gbPlayerNum ].bLastID; //loop though all the mercs for ( pSoldier = MercPtrs[ cnt ]; cnt <= bLastTeamID; cnt++,pSoldier++) { //if the merc is active if ( ( pSoldier->bActive )&&( pSoldier->bAssignment != ASSIGNMENT_POW ) && ( pSoldier->bAssignment != IN_TRANSIT ) ) { //CJC: Reset dialogue flags for quotes that can be said once/day pSoldier->usQuoteSaidFlags &= ( ~SOLDIER_QUOTE_SAID_ANNOYING_MERC ); // ATE: Reset likes gun flag pSoldier->usQuoteSaidFlags &= ( ~SOLDIER_QUOTE_SAID_LIKESGUN ); // ATE: Reset seen corpse flag pSoldier->usQuoteSaidFlags &= ( ~SOLDIER_QUOTE_SAID_ROTTINGCORPSE ); // ATE; Reset found something nice flag... pSoldier->usQuoteSaidFlags &= ( ~SOLDIER_QUOTE_SAID_FOUND_SOMETHING_NICE ); // ATE: Decrement tolerance value... pSoldier->bCorpseQuoteTolerance--; if ( pSoldier->bCorpseQuoteTolerance < 0 ) { pSoldier->bCorpseQuoteTolerance = 0; } // CJC: For some personalities, reset personality quote said flag if ( pSoldier->ubProfile != NO_PROFILE ) { switch( gMercProfiles[ pSoldier->ubProfile ].bPersonalityTrait ) { case HEAT_INTOLERANT: case CLAUSTROPHOBIC: case NONSWIMMER: case FEAR_OF_INSECTS: // repeatable once per day pSoldier->usQuoteSaidFlags &= ( ~SOLDIER_QUOTE_SAID_PERSONALITY ); break; default: break; } } //ATE: Try to see if our equipment sucks! if ( SoldierHasWorseEquipmentThanUsedTo( pSoldier ) ) { // Randomly anytime between 6:00, and 10:00 AddSameDayStrategicEvent( EVENT_MERC_COMPLAIN_EQUIPMENT, 360 + Random( 1080 ) , pSoldier->ubProfile ); } // increment days served by this grunt gMercProfiles[pSoldier->ubProfile].usTotalDaysServed++; // player has hired him, so he'll eligible to get killed off on another job gMercProfiles[pSoldier->ubProfile].ubMiscFlags3 |= PROFILE_MISC_FLAG3_PLAYER_HAD_CHANCE_TO_HIRE; //if the character is an RPC if( pSoldier->ubProfile >= FIRST_RPC && pSoldier->ubProfile < FIRST_NPC ) { INT16 sSalary = gMercProfiles[ pSoldier->ubProfile ].sSalary; INT32 iMoneyOwedToMerc = 0; //increment the number of days the mercs has been on the team pSoldier->iTotalContractLength++; //if the player owes the npc money, the balance field will be negative if( gMercProfiles[ pSoldier->ubProfile ].iBalance < 0 ) { //the player owes the npc the salary and whatever money the player owes the npc iMoneyOwedToMerc = sSalary + ( - gMercProfiles[ pSoldier->ubProfile ].iBalance ); } else { //else the player only owes the salary iMoneyOwedToMerc = sSalary; } //if the player owes money if( iMoneyOwedToMerc != 0 ) { //if the player can afford to pay them if( LaptopSaveInfo.iCurrentBalance >= iMoneyOwedToMerc ) { //add the transaction to the player AddTransactionToPlayersBook( PAYMENT_TO_NPC, pSoldier->ubProfile, GetWorldTotalMin(), -iMoneyOwedToMerc); //if the player owed money to the npc if( gMercProfiles[ pSoldier->ubProfile ].iBalance < 0 ) { // reset the amount gMercProfiles[ pSoldier->ubProfile ].iBalance = 0; } } else { CHAR16 zMoney[128]; //create a string for the salary owed to the npc swprintf( zMoney, L"%d", sSalary ); InsertCommasForDollarFigure( zMoney ); InsertDollarSignInToString( zMoney ); //Display a screen msg indicating that the npc was NOT paid ScreenMsg( FONT_MCOLOR_WHITE, MSG_INTERFACE, pMessageStrings[ MSG_CANT_AFFORD_TO_PAY_NPC_DAILY_SALARY_MSG ], gMercProfiles[ pSoldier->ubProfile ].zNickname, zMoney ); //if the merc hasnt been paid for NUM_DAYS_TILL_UNPAID_RPC_QUITS days, the merc will quit if( ( gMercProfiles[ pSoldier->ubProfile ].iBalance - sSalary ) <= -( sSalary * NUM_DAYS_TILL_UNPAID_RPC_QUITS ) ) { // //Set it up so the merc quits // MercsContractIsFinished( pSoldier->ubID ); } else { //set how much money the player owes the merc gMercProfiles[ pSoldier->ubProfile ].iBalance -= sSalary; // Add even for displaying a dialogue telling the player this.... AddSameDayStrategicEvent( EVENT_RPC_WHINE_ABOUT_PAY, MERC_ARRIVE_TIME_SLOT_1, pSoldier->ubID ); } } } } DailyMoraleUpdate( pSoldier ); CheckIfMercGetsAnotherContract( pSoldier ); } else { if( ( pSoldier->bActive ) && ( pSoldier->bAssignment == ASSIGNMENT_POW ) ) { pSoldier->iEndofContractTime += 1440; } } // if active, here, & alive (POW is ok, don't care) if( ( pSoldier->bActive ) && ( pSoldier->bAssignment != ASSIGNMENT_DEAD ) && ( pSoldier->bAssignment != IN_TRANSIT ) ) { // increment the "man days" played counter for each such merc in the player's employment gStrategicStatus.uiManDaysPlayed++; } } //r eset the counter cnt = 0; for ( pSoldier = MercPtrs[ cnt ]; cnt <= bLastTeamID; cnt++,pSoldier++) { //if the merc is active if ( ( pSoldier->bActive )&&( pSoldier->bAssignment != ASSIGNMENT_POW ) && ( pSoldier->bAssignment != IN_TRANSIT ) ) { //if its a MERC merc, determine if the merc should leave ( because player refused to pay for merc ) if( pSoldier->ubWhatKindOfMercAmI == MERC_TYPE__MERC ) { //if the players account status is invalid if( LaptopSaveInfo.gubPlayersMercAccountStatus == MERC_ACCOUNT_INVALID ) { //if the soldier is alive anc concious if( IsTheSoldierAliveAndConcious( pSoldier ) ) { //if the merc should leave today MercsContractIsFinished( pSoldier->ubID ); } } } } } //Loop through all the profiles for( cnt = 0; cnt < NUM_PROFILES; cnt++) { pProfile = &(gMercProfiles[ cnt ]); // dead guys don't do nuthin' ! if ( pProfile->bMercStatus == MERC_IS_DEAD ) { continue; } //Every day reset this variable pProfile->uiPrecedentQuoteSaid = 0; // skip anyone currently on the player's team if ( IsMercOnTeam( (UINT8) cnt )) { continue; } // if he's an AIM/M.E.R.C. merc if ( cnt < AIM_AND_MERC_MERCS ) { // if he's not just on his way home if ( pProfile->bMercStatus != MERC_RETURNING_HOME ) { // check if any of his stats improve through working or training HandleUnhiredMercImprovement(pProfile); // if he's working on another job if (pProfile->bMercStatus == MERC_WORKING_ELSEWHERE) { // check if he's killed HandleUnhiredMercDeaths( cnt ); } } } // if merc is currently unavailable if( pProfile->uiDayBecomesAvailable > 0 ) { // reduce time til available by one day pProfile->uiDayBecomesAvailable--; // Check to see if the merc has become available if (pProfile->uiDayBecomesAvailable == 0) { //if the merc CAN become ready if( pProfile->bMercStatus != MERC_FIRED_AS_A_POW ) { pProfile->bMercStatus = MERC_OK; // if the player has left a message for this merc if ( pProfile->ubMiscFlags3 & PROFILE_MISC_FLAG3_PLAYER_LEFT_MSG_FOR_MERC_AT_AIM ) { iOffset = AIM_REPLY_BARRY; //remove the Flag, so if the merc goes on another assignment, the player can leave an email. pProfile->ubMiscFlags3 &= ~PROFILE_MISC_FLAG3_PLAYER_LEFT_MSG_FOR_MERC_AT_AIM; // TO DO: send E-mail to player telling him the merc has returned from an assignment AddEmail( ( UINT8 )( iOffset + ( cnt * AIM_REPLY_LENGTH_BARRY ) ), AIM_REPLY_LENGTH_BARRY, ( UINT8 )( 6 + cnt ), GetWorldTotalMin() ); } } } } else // was already available today { // if it's an AIM or M.E.R.C. merc if (cnt < AIM_AND_MERC_MERCS) { // check to see if he goes on another assignment if (cnt < MAX_NUMBER_MERCS) { // A.I.M. merc uiChance = 2 * pProfile->bExpLevel; // player has now had a chance to hire him, so he'll eligible to get killed off on another job pProfile->ubMiscFlags3 |= PROFILE_MISC_FLAG3_PLAYER_HAD_CHANCE_TO_HIRE; } else { // M.E.R.C. merc - very rarely get other work uiChance = 1 * pProfile->bExpLevel; // player doesn't have a chance to hire any M.E.R.C's until after Speck's E-mail is sent if (GetWorldDay() > DAYS_TIL_M_E_R_C_AVAIL) { // player has now had a chance to hire him, so he'll eligible to get killed off on another job pProfile->ubMiscFlags3 |= PROFILE_MISC_FLAG3_PLAYER_HAD_CHANCE_TO_HIRE; } } if (Random(100) < uiChance) { pProfile->bMercStatus = MERC_WORKING_ELSEWHERE; pProfile->uiDayBecomesAvailable = 1 + Random(6 + (pProfile->bExpLevel / 2) ); // 1-(6 to 11) days } } } // Decrement morale hangover (merc appears hirable, he just gives lame refusals during this time, though) if( pProfile->ubDaysOfMoraleHangover > 0 ) { pProfile->ubDaysOfMoraleHangover--; } } // build quit list //BuildMercQuitList( pQuitList ); HandleSlayDailyEvent( ); // rebuild list for mapscreen ReBuildCharactersList( ); }
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 ); }