From aa7ec24ab73f2dc0f8ca0d4063b2c86f32e39434 Mon Sep 17 00:00:00 2001 From: jhh8 Date: Wed, 9 Sep 2026 23:35:46 +0300 Subject: [PATCH] make spatial features of env_ambient_light work in asw base player stays at spawn point... --- src/game/client/c_spatialentity.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/game/client/c_spatialentity.cpp b/src/game/client/c_spatialentity.cpp index 0d5aea16f..ad321f5ca 100644 --- a/src/game/client/c_spatialentity.cpp +++ b/src/game/client/c_spatialentity.cpp @@ -7,6 +7,8 @@ #include "cbase.h" #include "c_spatialentity.h" +#include "c_asw_player.h" +#include "c_asw_inhabitable_npc.h" // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -64,17 +66,17 @@ void C_SpatialEntity::ClientThink() return; } - CBaseEntity *pPlayer = C_BasePlayer::GetLocalPlayer( 0 ); - if( !pPlayer ) + C_ASW_Inhabitable_NPC* pViewNPC = C_ASW_Player::GetLocalASWPlayer()->GetViewNPC(); + if( !pViewNPC ) return; - Vector playerOrigin = pPlayer->GetAbsOrigin(); + Vector viewNPCOrigin = pViewNPC->GetAbsOrigin(); m_flWeight = 0.0f; if ( ( m_minFalloff != -1 ) && ( m_maxFalloff != -1 ) && m_minFalloff != m_maxFalloff ) { - float dist = (playerOrigin - m_vecOrigin).Length(); + float dist = (viewNPCOrigin - m_vecOrigin).Length(); m_flWeight = (dist-m_minFalloff) / (m_maxFalloff-m_minFalloff); m_flWeight = fpmax( 0.0f, m_flWeight ); m_flWeight = fpmin( 1.0f, m_flWeight );