diff --git a/addons/tagging/XEH_postInit.sqf b/addons/tagging/XEH_postInit.sqf index 92a5de9a0c..31fd73d913 100644 --- a/addons/tagging/XEH_postInit.sqf +++ b/addons/tagging/XEH_postInit.sqf @@ -1,6 +1,47 @@ // by esteldunedain #include "script_component.hpp" + +// Cache for static objects +GVAR(cacheStaticModels) = createLocation ["ACE_HashLocation", [-10000,-10000,-10000], 0, 0]; +GVAR(cacheStaticModels) setText QGVAR(cacheStaticModels); + +// Consider static everything vehicle that inherit from Static +// This include houses (which we don't need), but also walls, that we do +private _cfgBase = configFile >> "CfgVehicles"; +private _countOptions = count _cfgBase; +for "_index" from 0 to (_countOptions - 1) do { + private _cfgClass = _cfgBase select _index; + if (isClass _cfgClass) then { + if ((configName _cfgClass) isKindOf "Static") then { + private _model = getText (_cfgClass >> "model"); + if (_model != "") then { + private _array = _model splitString "\"; + GVAR(cacheStaticModels) setVariable [toLower (_array select ((count _array) - 2)), _cfgClass]; + }; + }; + }; +}; + +// Also consider static all object inheriting from bridges +_cfgBase = configFile >> "CfgNonAIVehicles"; +_countOptions = count _cfgBase; +for "_index" from 0 to (_countOptions - 1) do { + private _cfgClass = _cfgBase select _index; + if (isClass _cfgClass) then { + if ((configName _cfgClass) isKindOf ["Bridge_base_F", _cfgBase]) then { + private _model = getText (_cfgClass >> "model"); + if (_model != "") then { + private _array = _model splitString "\"; + GVAR(cacheStaticModels) setVariable [toLower (_array select ((count _array) - 2)), _cfgClass]; + }; + }; + }; +}; + if (!isServer) exitWith {}; +GVAR(testingThread) = false; +GVAR(tagsToTest) = []; + ["createTag", DFUNC(createTag)] call EFUNC(common,addEventHandler); diff --git a/addons/tagging/XEH_preInit.sqf b/addons/tagging/XEH_preInit.sqf index f278fcac1f..2c11c4d42a 100644 --- a/addons/tagging/XEH_preInit.sqf +++ b/addons/tagging/XEH_preInit.sqf @@ -5,7 +5,7 @@ ADDON = false; PREP(checkTaggable); PREP(createTag); PREP(tagDirection); -PREP(tagWall); PREP(tagGround); +PREP(tagWall); ADDON = true; diff --git a/addons/tagging/functions/fnc_checkTaggable.sqf b/addons/tagging/functions/fnc_checkTaggable.sqf index c9c829bc39..4c8f0c750a 100644 --- a/addons/tagging/functions/fnc_checkTaggable.sqf +++ b/addons/tagging/functions/fnc_checkTaggable.sqf @@ -31,7 +31,26 @@ // Exit if trying to tag a non static object TRACE_1("Obj:",_intersections); - if (!isNull _object && {!(_object isKindOf "Static")}) exitWith {false}; + + // Exit if trying to tag a non static object + if ((!isNull _object) && { + // If the class is alright, do not exit + if (_object isKindOf "Static") exitWith {false}; + + // If the class is not categorized correctly search the cache + private _array = str(_object) splitString " "; + private _str = toLower (_array select 1); + TRACE_1("Object:",_str); + private _objClass = GVAR(cacheStaticModels) getVariable _str; + // If the class in not on the cache, exit + if (isNil "_objClass") exitWith { + false + }; + true + }) exitWith { + TRACE_1("Pointed object is non static",_object); + false + }; true }, missionNamespace, QGVAR(checkTaggableCache), 0.5] call EFUNC(common,cachedCall); diff --git a/addons/tagging/functions/fnc_tagDirection.sqf b/addons/tagging/functions/fnc_tagDirection.sqf index befd118826..2c03d97fd0 100644 --- a/addons/tagging/functions/fnc_tagDirection.sqf +++ b/addons/tagging/functions/fnc_tagDirection.sqf @@ -34,11 +34,26 @@ if (_intersections isEqualTo []) exitWith { TRACE_3("",_touchingPoint, _surfaceNormal, _object); // Exit if trying to tag a non static object -if (!isNull _object && {!(_object isKindOf "Static")}) exitWith { +if ((!isNull _object) && { + // If the class is alright, do not exit + if (_object isKindOf "Static") exitWith {false}; + + // If the class is not categorized correctly search the cache + private _array = str(_object) splitString " "; + private _str = toLower (_array select 1); + TRACE_1("Object:",_str); + private _objClass = GVAR(cacheStaticModels) getVariable _str; + // If the class in not on the cache, exit + if (isNil "_objClass") exitWith { + false + }; + true +}) exitWith { TRACE_1("Pointed object is non static",_object); false }; + // If the surface normal points away, flip it. This happens in weird places like the Stratis Pier if (_surfaceNormal vectorDotProduct (_endPosASL vectorDiff _startPosASL) > 0) then { _surfaceNormal = _surfaceNormal vectorMultiply -1; @@ -81,7 +96,7 @@ _unit playActionNow "PutDown"; [{ params ["", "", "", "", "_unit"]; - TRACE_1("Unit:", _unit); + TRACE_2("Unit:",_unit,_this); playSound3D [QUOTE(PATHTO_R(sounds\spray.ogg)), _unit, false, (eyePos _unit), 10, 1, 15];