diff --git a/addons/tagging/$PBOPREFIX$ b/addons/tagging/$PBOPREFIX$ new file mode 100644 index 0000000000..d841d5d209 --- /dev/null +++ b/addons/tagging/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\tagging \ No newline at end of file diff --git a/addons/tagging/CfgEventHandlers.hpp b/addons/tagging/CfgEventHandlers.hpp new file mode 100644 index 0000000000..f0a9f14d91 --- /dev/null +++ b/addons/tagging/CfgEventHandlers.hpp @@ -0,0 +1,6 @@ + +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; diff --git a/addons/tagging/CfgVehicles.hpp b/addons/tagging/CfgVehicles.hpp new file mode 100644 index 0000000000..61dac3f9c7 --- /dev/null +++ b/addons/tagging/CfgVehicles.hpp @@ -0,0 +1,18 @@ +class CfgVehicles { + class UserTexture1m_F; + class ACE_tagWall0 : UserTexture1m_F { + hiddenSelectionsTextures[] = {"\z\ace\addons\tagging\UI\tag0.paa"}; + }; + class ACE_tagWall1 : UserTexture1m_F { + hiddenSelectionsTextures[] = {"\z\ace\addons\tagging\UI\tag1.paa"}; + }; + class ACE_tagWall2 : UserTexture1m_F { + hiddenSelectionsTextures[] = {"\z\ace\addons\tagging\UI\tag2.paa"}; + }; + class ACE_tagWall3 : UserTexture1m_F { + hiddenSelectionsTextures[] = {"\z\ace\addons\tagging\UI\tag3.paa"}; + }; + class ACE_tagWall4 : UserTexture1m_F { + hiddenSelectionsTextures[] = {"\z\ace\addons\tagging\UI\tag4.paa"}; + }; +}; \ No newline at end of file diff --git a/addons/tagging/UI/tag0.paa b/addons/tagging/UI/tag0.paa new file mode 100644 index 0000000000..28047df824 Binary files /dev/null and b/addons/tagging/UI/tag0.paa differ diff --git a/addons/tagging/UI/tag1.paa b/addons/tagging/UI/tag1.paa new file mode 100644 index 0000000000..d84c7f81d1 Binary files /dev/null and b/addons/tagging/UI/tag1.paa differ diff --git a/addons/tagging/UI/tag2.paa b/addons/tagging/UI/tag2.paa new file mode 100644 index 0000000000..8c68c9af3f Binary files /dev/null and b/addons/tagging/UI/tag2.paa differ diff --git a/addons/tagging/UI/tag3.paa b/addons/tagging/UI/tag3.paa new file mode 100644 index 0000000000..e2e3e8b23e Binary files /dev/null and b/addons/tagging/UI/tag3.paa differ diff --git a/addons/tagging/UI/tag4.paa b/addons/tagging/UI/tag4.paa new file mode 100644 index 0000000000..3061f311a4 Binary files /dev/null and b/addons/tagging/UI/tag4.paa differ diff --git a/addons/tagging/XEH_preInit.sqf b/addons/tagging/XEH_preInit.sqf new file mode 100644 index 0000000000..8fbd171147 --- /dev/null +++ b/addons/tagging/XEH_preInit.sqf @@ -0,0 +1,8 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP(checkTaggable); +PREP(tagWall); + +ADDON = true; diff --git a/addons/tagging/config.cpp b/addons/tagging/config.cpp new file mode 100644 index 0000000000..dd79132d98 --- /dev/null +++ b/addons/tagging/config.cpp @@ -0,0 +1,16 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_interaction"}; + author[] = {"BlauBär"}; + authorUrl = "https://github.com/BaerMitUmlaut"; + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" +#include "CfgVehicles.hpp" \ No newline at end of file diff --git a/addons/tagging/functions/fnc_checkTaggable.sqf b/addons/tagging/functions/fnc_checkTaggable.sqf new file mode 100644 index 0000000000..33f963a4bd --- /dev/null +++ b/addons/tagging/functions/fnc_checkTaggable.sqf @@ -0,0 +1,28 @@ +#include "script_component.hpp" +private ["_posCheck", "_objectsLeft", "_intersectsLeft", "_objectsRight", "_intersectsRight"]; + + +_posCheck = ACE_player modelToWorldVisual [-0.5, 2, 0]; +_posCheck set [2, (eyePos ACE_player) select 2]; + +_objectsLeft = lineIntersectsWith [eyePos ACE_player, _posCheck, ACE_player, objNull, false]; +_intersectsLeft = false; +{ + if (_x isKindOf "HouseBase") exitWith {_intersectsLeft = true}; +} foreach _objectsLeft; + +if (!_intersectsLeft) exitWith {false}; + + +_posCheck = ACE_player modelToWorldVisual [0.5, 2, 0]; +_posCheck set [2, (eyePos ACE_player) select 2]; + +_objectsRight = lineIntersectsWith [eyePos ACE_player, _posCheck, ACE_player, objNull, false]; +_intersectsRight = false; +{ + if (_x isKindOf "HouseBase") exitWith {_intersectsRight = true}; +} foreach _objectsRight; + + +//for readability... +(_intersectsLeft && _intersectsRight) \ No newline at end of file diff --git a/addons/tagging/functions/fnc_tagWall.sqf b/addons/tagging/functions/fnc_tagWall.sqf new file mode 100644 index 0000000000..de9c605996 --- /dev/null +++ b/addons/tagging/functions/fnc_tagWall.sqf @@ -0,0 +1,52 @@ +#include "script_component.hpp" +private ["_touchingPoints", "_pointCloser", "_pointFurther", "_posCheckCloser", "_posCheckFurther", "_touchingPoint", "_tag"]; + +_touchingPoints = []; + +// _sphere1 = "Sign_Sphere10cm_F" createVehicle [0,0,0]; +// _sphere2 = "Sign_Sphere10cm_F" createVehicle [0,0,0]; + +{ + //When tagWall is called, we already know there is an object within 2m in front of us. + //We define two points (or rather distances from the player) where the wall is always in between. + + _pointCloser = 0; + _pointFurther = 2; + + for "_i" from 0 to 6 do { + + //We need to reduce the distance between those points until we get a very precise position. + //This is done by checking if it is between the closer point and the point in between the two. + + _posCheckCloser = ACE_player modelToWorldVisual [_x, _pointCloser, 0]; + _posCheckCloser set [2, (eyePos ACE_player) select 2]; + + _posCheckFurther = ACE_player modelToWorldVisual [_x, (_pointCloser + ((_pointFurther - _pointCloser) / 2)), 0]; + _posCheckFurther set [2, (eyePos ACE_player) select 2]; + + // _sphere1 setPosASL (_posCheckCloser); + // _sphere2 setPosASL (_posCheckFurther); + // sleep 0.5; + + if (lineIntersects [_posCheckCloser, _posCheckFurther, ACE_player, objNull]) then { + //If it is, we move the further point to be closer to the closer point. + _pointFurther = _pointCloser + ((_pointFurther - _pointCloser) / 2); + } else { + //If it isn't, we move the closer point towards the further point. + _pointCloser = _pointCloser + ((_pointFurther - _pointCloser) / 2); + }; + }; + + //We do this 7 times each a bit to the left and right of the player - that's by definitely precise enough. + _touchingPoint = ACE_player modelToWorldVisual [_x, _pointCloser, 0]; + _touchingPoint set [2, (eyePos ACE_player) select 2]; + _touchingPoints pushBack (_touchingPoint); + +} foreach [-0.5, 0.5]; + +_tag = ("ACE_tagWall" + str (floor (random 5))) createVehicle [0,0,0]; +_tag setPosASL (((_touchingPoints select 0) vectorAdd (_touchingPoints select 1)) vectorMultiply 0.5); +_tag setDir ((_touchingPoints call BIS_fnc_dirTo) - 90); + +// deleteVehicle _sphere1; +// deleteVehicle _sphere2; \ No newline at end of file diff --git a/addons/tagging/functions/script_component.hpp b/addons/tagging/functions/script_component.hpp new file mode 100644 index 0000000000..bc860f2283 --- /dev/null +++ b/addons/tagging/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\tagging\script_component.hpp" \ No newline at end of file diff --git a/addons/tagging/script_component.hpp b/addons/tagging/script_component.hpp new file mode 100644 index 0000000000..e8f392632b --- /dev/null +++ b/addons/tagging/script_component.hpp @@ -0,0 +1,12 @@ +#define COMPONENT tagging +#include "\z\ace\addons\main\script_mod.hpp" + +#ifdef DEBUG_ENABLED_BLANK + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_BLANK + #define DEBUG_SETTINGS DEBUG_SETTINGS_BLANK +#endif + +#include "\z\ace\addons\main\script_macros.hpp" \ No newline at end of file