diff --git a/GameSettings.cpp b/GameSettings.cpp index 8d60e728..449c6e27 100644 --- a/GameSettings.cpp +++ b/GameSettings.cpp @@ -678,6 +678,13 @@ void LoadGameExternalOptions() gGameExternalOptions.fEnableArmorCoverage = iniReader.ReadBoolean("JA2 Tactical Settings", "ENABLE_ARMOR_COVERAGE", FALSE); // ShadoWarrior for Captain J's armor coverage + // The_Bob - real time sneaking code 01/06/09 + // Suport disabling real time sneaking via external .ini file + gGameExternalOptions.fAllowRealTimeSneak = iniReader.ReadBoolean("JA2 Real Time Sneaking Settings","ALLOW_REAL_TIME_SNEAK", FALSE); + // Silence the RT sneaking messages + gGameExternalOptions.fQuietRealTimeSneak = iniReader.ReadBoolean("JA2 Real Time Sneaking Settings","QUIET_REAL_TIME_SNEAK", FALSE); + + //################# Rain Settings ################## // Rain settings diff --git a/GameSettings.h b/GameSettings.h index eaf7ac5e..062f864c 100644 --- a/GameSettings.h +++ b/GameSettings.h @@ -629,6 +629,10 @@ BOOLEAN gbBulletTracer; // HEADROCK HAM B2.8: New Trainer Relations: 2 = Trainers will rest if no trainees available. 3 = Trainees will rest if no trainers available (not recommended). 1 = Both. 0 = Neither. UINT8 ubSmartTrainingRest; + // The_Bob - real time sneaking code 01/06/09 + // Suport disabling/silencing real time sneaking via external .ini file + BOOLEAN fAllowRealTimeSneak; + BOOLEAN fQuietRealTimeSneak; } GAME_EXTERNAL_OPTIONS; //This structure will contain general Ja2 settings NOT individual game settings. diff --git a/Tactical/Turn Based Input.cpp b/Tactical/Turn Based Input.cpp index edd07f86..413f95dd 100644 --- a/Tactical/Turn Based Input.cpp +++ b/Tactical/Turn Based Input.cpp @@ -246,6 +246,8 @@ UINT8 gubCheatLevel = STARTING_CHEAT_LEVEL; extern BOOLEAN CompatibleAmmoForGun( OBJECTTYPE *pTryObject, OBJECTTYPE *pTestObject ); extern void DetermineWhichAssignmentMenusCanBeShown( void ); extern void DetermineWhichMilitiaControlMenusCanBeShown( void ); //lalien +// The_Bob - real time sneaking, 01-06-09 +extern BOOLEAN WeSeeNoOne(void); // Needed to control entering turn-based with ctrl-x void GetTBMouseButtonInput( UINT32 *puiNewEvent ) { @@ -2363,7 +2365,53 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) } } + else if ( fCtrl ) // The_Bob - real time sneaking, 01-06-09 + { // ctrl-x: enter turn based while sneaking - check if RT sneak is on, iw we're not already in combat and if we actually see any enemies + if (gGameExternalOptions.fAllowRealTimeSneak) + { + BOOLEAN fSneakingInRealTime = true; + + if( gTacticalStatus.uiFlags & INCOMBAT ) + { // Don't allow this in combat + if (!gGameExternalOptions.fQuietRealTimeSneak) + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"In combat already !"); + fSneakingInRealTime = false; + } + + if( WeSeeNoOne() ) + { // Don't allow this if no enemies are seen - we have the forced turn mode for that + if (!gGameExternalOptions.fQuietRealTimeSneak) + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"No enemies in sight !"); + fSneakingInRealTime = false; + } + + if (fSneakingInRealTime) + EnterCombatMode(OUR_TEAM); + } + } break; + // The_Bob - real time sneaking, 01-06-09 + case 'X': // shift-ctrl-x: toggle real time sneaking + if ( fCtrl ) + { + if (gGameExternalOptions.fAllowRealTimeSneak) + { + gGameExternalOptions.fAllowRealTimeSneak = false; + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Real-time sneaking OFF"); + + if( !WeSeeNoOne() ) // if we're sneaking up on someone, enter turn-based + EnterCombatMode(OUR_TEAM); + } + else + { + gGameExternalOptions.fAllowRealTimeSneak = true; + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Real-time sneaking ON"); + } + + } + break; + + case '/': diff --git a/Tactical/opplist.cpp b/Tactical/opplist.cpp index fb286dac..440f59ba 100644 --- a/Tactical/opplist.cpp +++ b/Tactical/opplist.cpp @@ -74,6 +74,9 @@ void DecayWatchedLocs( INT8 bTeam ); void HandleManNoLongerSeen( SOLDIERTYPE * pSoldier, SOLDIERTYPE * pOpponent, INT8 * pPersOL, INT8 * pbPublOL ); +// The_Bob - real time sneaking code 01/06/09 +extern void CancelItemPointer(void); +extern BOOLEAN NobodyAlerted(void); //#define TESTOPPLIST // for ManSeesMan() @@ -480,9 +483,24 @@ void HandleBestSightingPositionInRealtime( void ) //if (gfHumanSawSomeoneInRealtime) { if (gubBestToMakeSighting[ 1 ] == NOBODY) - { - // award turn - EnterCombatMode( MercPtrs[gubBestToMakeSighting[ 0 ]]->bTeam ); + { // The_Bob - real time sneaking code 01/06/09 + // if real time sneaking conditions are met... + if (gGameExternalOptions.fAllowRealTimeSneak && MercPtrs[gubBestToMakeSighting[ 0 ]]->bTeam == OUR_TEAM && NobodyAlerted() ) + { + // get rid of the item under cursor (we gotta react FAST) + CancelItemPointer(); + // select (and center screen on) the merc who saw the enemy + if (gusSelectedSoldier != (UINT16)MercPtrs[gubBestToMakeSighting[ 0 ]]->ubID) + SelectSoldier (MercPtrs[gubBestToMakeSighting[ 0 ]]->ubID, false, true); + // if not quiet, emit a message warning the player + if (!gGameExternalOptions.fQuietRealTimeSneak) + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Enemy spotted! (ctrl-x to enter turn based)"); + + return; // and do nothing + } + else + // otherwise, simply award the turn to the team that saw the enemy first + EnterCombatMode( MercPtrs[gubBestToMakeSighting[ 0 ]]->bTeam ); } else {