@@ -1332,12 +1332,63 @@ bool CNEO_Player::IsHiddenByFog(CBaseEntity* target) const
13321332 }
13331333}
13341334
1335+ // -----------------------------------------------------------------------------
1336+ // Purpose: return 0-1 ratio where zero is not obscured, and 1 is completely obscured
1337+ // Including cloak for players
1338+ // -----------------------------------------------------------------------------
1339+ float CNEO_Player::GetFogObscuredRatio ( CBaseEntity *target ) const
1340+ {
1341+ if ( !target )
1342+ return 0 .0f ;
1343+
1344+ const float range = CBaseCombatCharacter::EyePosition ().DistTo ( target->WorldSpaceCenter () );
1345+ const float flFogRatio = GetFogObscuredRatio ( range );
1346+
1347+ auto targetPlayer = ToNEOPlayer ( target );
1348+ if ( targetPlayer )
1349+ {
1350+ const float flCloakRatio = GetCloakObscuredRatio ( targetPlayer );
1351+ return 1 .0f - ( 1 .0f - flFogRatio ) * ( 1 .0f - flCloakRatio );
1352+ }
1353+
1354+ return flFogRatio;
1355+ }
1356+
1357+ // -----------------------------------------------------------------------------
1358+ // Purpose: return 0-1 ratio where zero is not obscured, and 1 is completely obscured
1359+ // -----------------------------------------------------------------------------
1360+ float CNEO_Player::GetFogObscuredRatio ( float range ) const
1361+ {
1362+ auto controller = m_Local.m_PlayerFog .m_hCtrl .Get ();
1363+
1364+ if ( controller )
1365+ {
1366+ fogparams_t fog;
1367+ fog = controller->m_fog ;
1368+
1369+ if ( !fog.enable )
1370+ return 0 .0f ;
1371+
1372+ if ( range <= fog.start )
1373+ return 0 .0f ;
1374+
1375+ if ( range >= fog.end )
1376+ return 1 .0f ;
1377+
1378+ float ratio = (range - fog.start ) / (fog.end - fog.start );
1379+ ratio = MIN ( ratio, fog.maxdensity );
1380+ return ratio;
1381+ }
1382+
1383+ return 0 .0f ;
1384+ }
1385+
13351386// -----------------------------------------------------------------------------
13361387// Purpose: return 0-1 ratio where zero is not obscured, and 1 is completely obscured
13371388// NEO JANK: If this function is too expensive,
13381389// players may report that the game gets laggy when in line of sight bots.
13391390// -----------------------------------------------------------------------------
1340- float CNEO_Player::GetFogObscuredRatio (CBaseEntity * target) const
1391+ float CNEO_Player::GetCloakObscuredRatio (CNEO_Player * target) const
13411392{
13421393 VPROF_BUDGET (__FUNCTION__, " NextBotExpensive" );
13431394
@@ -1346,35 +1397,28 @@ float CNEO_Player::GetFogObscuredRatio(CBaseEntity* target) const
13461397 return 0 .0f ;
13471398 }
13481399
1349- auto targetPlayer = ToNEOPlayer (target);
1350- if (targetPlayer == nullptr )
1351- {
1352- // If it's not a player, this cloaking logic doesn't apply, so it is not obscured
1353- return 0 .0f ;
1354- }
1355-
13561400 if ( NEORules ()->IsTeamplay ()
1357- && (GetTeamNumber () == targetPlayer ->GetTeamNumber ()) )
1401+ && (GetTeamNumber () == target ->GetTeamNumber ()) )
13581402 {
13591403 // Teammates are always labeled with IFF markers, unless in free-for-all game modes
13601404 return 0 .0f ;
13611405 }
13621406
13631407 // If target is not cloaked, it's not obscured.
1364- if (!targetPlayer ->GetInThermOpticCamo () && !sv_neo_bot_cloak_debug_perceive_always_on.GetBool ())
1408+ if (!target ->GetInThermOpticCamo () && !sv_neo_bot_cloak_debug_perceive_always_on.GetBool ())
13651409 {
13661410 return 0 .0f ; // Not obscured
13671411 }
13681412
1369- if (targetPlayer ->IsCarryingGhost ())
1413+ if (target ->IsCarryingGhost ())
13701414 {
13711415 return 0 .0f ;
13721416 }
13731417
13741418 // From this point on, assume we are counting bonus points towards observer detection
13751419 float flDetectionBonus = 0 .0f ; // # of factors that are helping the observer detect the target
13761420
1377- if (targetPlayer ->GetBotCloakStateDisrupted ())
1421+ if (target ->GetBotCloakStateDisrupted ())
13781422 {
13791423 flDetectionBonus += sv_neo_bot_cloak_detection_bonus_disruption_effect.GetFloat ();
13801424 }
@@ -1388,8 +1432,8 @@ float CNEO_Player::GetFogObscuredRatio(CBaseEntity* target) const
13881432 return player->GetAbsVelocity ().LengthSqr () > (runSpeedThreshold * runSpeedThreshold);
13891433 };
13901434
1391- bool targetIsRunning = isRunning (targetPlayer );
1392- bool targetIsMoving = targetIsRunning || isMoving (targetPlayer );
1435+ bool targetIsRunning = isRunning (target );
1436+ bool targetIsMoving = targetIsRunning || isMoving (target );
13931437
13941438 // Class Impact:
13951439 // Assault class motion vision
@@ -1431,7 +1475,7 @@ float CNEO_Player::GetFogObscuredRatio(CBaseEntity* target) const
14311475 flDetectionBonus += sv_neo_bot_cloak_detection_bonus_target_moving.GetFloat ();
14321476 }
14331477
1434- if (!targetPlayer ->IsDucking ()) // is standing, and NOT ducking
1478+ if (!target ->IsDucking ()) // is standing, and NOT ducking
14351479 {
14361480 // target is more obvious when standing at full height
14371481 flDetectionBonus += sv_neo_bot_cloak_detection_bonus_target_standing.GetFloat ();
@@ -1460,7 +1504,7 @@ float CNEO_Player::GetFogObscuredRatio(CBaseEntity* target) const
14601504 }
14611505
14621506 // Injured Target Impact
1463- flDetectionBonus += (float )targetPlayer ->GetBotDetectableBleedingInjuryEvents () * sv_neo_bot_cloak_detection_bonus_per_injury.GetFloat ();
1507+ flDetectionBonus += (float )target ->GetBotDetectableBleedingInjuryEvents () * sv_neo_bot_cloak_detection_bonus_per_injury.GetFloat ();
14641508
14651509 // Lighting Impact
14661510 // NEO JANK: See "FIXMEL4DTOMAINMERGE" for why this doesn't have any effect yet.
0 commit comments