From f892cd9366f1bebe7121e340919a7c9b5f83f077 Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Fri, 27 Dec 2024 15:15:52 +0300 Subject: [PATCH] Fix some animations from scripts don't work properly in CS and SOC (#382, #392) Also returned VERIFY instead of message to the log. Logging is MUCH more annoying and drops FPS. --- src/xrGame/script_game_object3.cpp | 41 ++++++++++++++++++------------ 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/src/xrGame/script_game_object3.cpp b/src/xrGame/script_game_object3.cpp index 6f7c7904f26..8d55675619b 100644 --- a/src/xrGame/script_game_object3.cpp +++ b/src/xrGame/script_game_object3.cpp @@ -592,7 +592,7 @@ void CScriptGameObject::set_desired_direction(const Fvector* desired_direction) if (fsimilar(desired_direction->magnitude(), 0.f)) GEnv.ScriptEngine->script_log(LuaMessageType::Error, "CAI_Stalker : [%s] set_desired_direction - you passed zero direction!", stalker->cName().c_str()); - else if (!ClearSkyMode && !ShadowOfChernobylMode) + else if (!ShadowOfChernobylMode) { if (!fsimilar(desired_direction->magnitude(), 1.f)) GEnv.ScriptEngine->script_log(LuaMessageType::Error, @@ -601,7 +601,7 @@ void CScriptGameObject::set_desired_direction(const Fvector* desired_direction) } Fvector direction = *desired_direction; - if (!ClearSkyMode && !ShadowOfChernobylMode) + if (!ShadowOfChernobylMode) direction.normalize_safe(); stalker->movement().set_desired_direction(&direction); } @@ -767,12 +767,15 @@ void CScriptGameObject::set_sight(SightManager::ESightType sight_type, Fvector* } else { - if ((sight_type == SightManager::eSightTypeDirection) && vector3d && (_abs(vector3d->magnitude() - 1.f) > .01f)) + const bool check_for_norm = sight_type == SightManager::eSightTypeDirection && vector3d && + !ClearSkyMode && !ShadowOfChernobylMode; + if (check_for_norm) { -#ifndef MASTER_GOLD - Msg("~ CSightManager : non-normalized direction passed [%f][%f][%f]", VPUSH(*vector3d)); -#endif - vector3d->normalize(); + if (_abs(vector3d->magnitude() - 1.f) > .01f) + { + VERIFY2(false, make_string("non-normalized direction passed [%f][%f][%f]", VPUSH(*vector3d))); + vector3d->normalize(); + } } stalker->sight().setup(sight_type, vector3d); @@ -798,12 +801,15 @@ void CScriptGameObject::set_sight(SightManager::ESightType sight_type, Fvector& } else { - if ((sight_type == SightManager::eSightTypeDirection) && (_abs(vector3d.magnitude() - 1.f) > .01f)) + const bool check_for_norm = sight_type == SightManager::eSightTypeDirection && + !ClearSkyMode && !ShadowOfChernobylMode; + if (check_for_norm) { -#ifndef MASTER_GOLD - Msg("~ CSightManager : non-normalized direction passed [%f][%f][%f]", VPUSH(vector3d)); -#endif + if (_abs(vector3d.magnitude() - 1.f) > .01f) + { + VERIFY2(false, make_string("non-normalized direction passed [%f][%f][%f]", VPUSH(vector3d))); vector3d.normalize(); + } } stalker->sight().setup(sight_type, vector3d, torso_look); @@ -819,12 +825,15 @@ void CScriptGameObject::set_sight(SightManager::ESightType sight_type, Fvector* } else { - if ((sight_type == SightManager::eSightTypeDirection) && vector3d && (_abs(vector3d->magnitude() - 1.f) > .01f)) + const bool check_for_norm = sight_type == SightManager::eSightTypeDirection && vector3d && + !ClearSkyMode && !ShadowOfChernobylMode; + if (check_for_norm) { -#ifndef MASTER_GOLD - Msg("~ CSightManager : non-normalized direction passed [%f][%f][%f]", VPUSH(*vector3d)); -#endif - vector3d->normalize(); + if (_abs(vector3d->magnitude() - 1.f) > .01f) + { + VERIFY2(false, make_string("non-normalized direction passed [%f][%f][%f]", VPUSH(*vector3d))); + vector3d->normalize(); + } } stalker->sight().setup(sight_type, vector3d);