@@ -1362,12 +1362,56 @@ bool CNEO_Player::IsHiddenByFog(CBaseEntity* target) const
13621362 }
13631363}
13641364
1365+ // -----------------------------------------------------------------------------
1366+ // Purpose: return 0-1 ratio where zero is not obscured, and 1 is completely obscured
1367+ // Including cloak for players
1368+ // -----------------------------------------------------------------------------
1369+ float CNEO_Player::GetFogObscuredRatio ( CBaseEntity *target ) const
1370+ {
1371+ if ( !target )
1372+ return 0 .0f ;
1373+
1374+ const float range = CBaseCombatCharacter::EyePosition ().DistTo ( target->WorldSpaceCenter () );
1375+ const float flFogRatio = GetFogObscuredRatio ( range );
1376+
1377+ auto targetPlayer = ToNEOPlayer ( target );
1378+ if ( targetPlayer )
1379+ {
1380+ const float flCloakRatio = GetCloakObscuredRatio ( targetPlayer );
1381+ return 1 .0f - ( 1 .0f - flFogRatio ) * ( 1 .0f - flCloakRatio );
1382+ }
1383+
1384+ return flFogRatio;
1385+ }
1386+
1387+ // -----------------------------------------------------------------------------
1388+ // Purpose: return 0-1 ratio where zero is not obscured, and 1 is completely obscured
1389+ // -----------------------------------------------------------------------------
1390+ float CNEO_Player::GetFogObscuredRatio ( float range ) const
1391+ {
1392+ auto controller = m_Local.m_PlayerFog .m_hCtrl .Get ();
1393+
1394+ if ( controller )
1395+ {
1396+ const fogparams_t &fog = controller->m_fog ;
1397+
1398+ if ( !fog.enable )
1399+ return 0 .0f ;
1400+
1401+ float ratio = RemapValClamped ( range, fog.start , fog.end , 0 .0f , 1 .0f );
1402+ ratio = MIN ( ratio, fog.maxdensity );
1403+ return ratio;
1404+ }
1405+
1406+ return 0 .0f ;
1407+ }
1408+
13651409// -----------------------------------------------------------------------------
13661410// Purpose: return 0-1 ratio where zero is not obscured, and 1 is completely obscured
13671411// NEO JANK: If this function is too expensive,
13681412// players may report that the game gets laggy when in line of sight bots.
13691413// -----------------------------------------------------------------------------
1370- float CNEO_Player::GetFogObscuredRatio (CBaseEntity * target) const
1414+ float CNEO_Player::GetCloakObscuredRatio (CNEO_Player * target) const
13711415{
13721416 VPROF_BUDGET (__FUNCTION__, " NextBotExpensive" );
13731417
@@ -1376,35 +1420,28 @@ float CNEO_Player::GetFogObscuredRatio(CBaseEntity* target) const
13761420 return 0 .0f ;
13771421 }
13781422
1379- auto targetPlayer = ToNEOPlayer (target);
1380- if (targetPlayer == nullptr )
1381- {
1382- // If it's not a player, this cloaking logic doesn't apply, so it is not obscured
1383- return 0 .0f ;
1384- }
1385-
13861423 if ( NEORules ()->IsTeamplay ()
1387- && (GetTeamNumber () == targetPlayer ->GetTeamNumber ()) )
1424+ && (GetTeamNumber () == target ->GetTeamNumber ()) )
13881425 {
13891426 // Teammates are always labeled with IFF markers, unless in free-for-all game modes
13901427 return 0 .0f ;
13911428 }
13921429
13931430 // If target is not cloaked, it's not obscured.
1394- if (!targetPlayer ->GetInThermOpticCamo () && !sv_neo_bot_cloak_debug_perceive_always_on.GetBool ())
1431+ if (!target ->GetInThermOpticCamo () && !sv_neo_bot_cloak_debug_perceive_always_on.GetBool ())
13951432 {
13961433 return 0 .0f ; // Not obscured
13971434 }
13981435
1399- if (targetPlayer ->IsCarryingGhost ())
1436+ if (target ->IsCarryingGhost ())
14001437 {
14011438 return 0 .0f ;
14021439 }
14031440
14041441 // From this point on, assume we are counting bonus points towards observer detection
14051442 float flDetectionBonus = 0 .0f ; // # of factors that are helping the observer detect the target
14061443
1407- if (targetPlayer ->GetBotCloakStateDisrupted ())
1444+ if (target ->GetBotCloakStateDisrupted ())
14081445 {
14091446 flDetectionBonus += sv_neo_bot_cloak_detection_bonus_disruption_effect.GetFloat ();
14101447 }
@@ -1418,8 +1455,8 @@ float CNEO_Player::GetFogObscuredRatio(CBaseEntity* target) const
14181455 return player->GetAbsVelocity ().LengthSqr () > (runSpeedThreshold * runSpeedThreshold);
14191456 };
14201457
1421- bool targetIsRunning = isRunning (targetPlayer );
1422- bool targetIsMoving = targetIsRunning || isMoving (targetPlayer );
1458+ bool targetIsRunning = isRunning (target );
1459+ bool targetIsMoving = targetIsRunning || isMoving (target );
14231460
14241461 // Class Impact:
14251462 // Assault class motion vision
@@ -1461,7 +1498,7 @@ float CNEO_Player::GetFogObscuredRatio(CBaseEntity* target) const
14611498 flDetectionBonus += sv_neo_bot_cloak_detection_bonus_target_moving.GetFloat ();
14621499 }
14631500
1464- if (!targetPlayer ->IsDucking ()) // is standing, and NOT ducking
1501+ if (!target ->IsDucking ()) // is standing, and NOT ducking
14651502 {
14661503 // target is more obvious when standing at full height
14671504 flDetectionBonus += sv_neo_bot_cloak_detection_bonus_target_standing.GetFloat ();
@@ -1490,7 +1527,7 @@ float CNEO_Player::GetFogObscuredRatio(CBaseEntity* target) const
14901527 }
14911528
14921529 // Injured Target Impact
1493- flDetectionBonus += (float )targetPlayer ->GetBotDetectableBleedingInjuryEvents () * sv_neo_bot_cloak_detection_bonus_per_injury.GetFloat ();
1530+ flDetectionBonus += (float )target ->GetBotDetectableBleedingInjuryEvents () * sv_neo_bot_cloak_detection_bonus_per_injury.GetFloat ();
14941531
14951532 // Lighting Impact
14961533 // NEO JANK: See "FIXMEL4DTOMAINMERGE" for why this doesn't have any effect yet.
0 commit comments