diff --git a/addons/tagging/functions/fnc_checkTaggable.sqf b/addons/tagging/functions/fnc_checkTaggable.sqf index 9bccedc79f..2a27f7873f 100644 --- a/addons/tagging/functions/fnc_checkTaggable.sqf +++ b/addons/tagging/functions/fnc_checkTaggable.sqf @@ -25,7 +25,7 @@ _objectsLeft = lineIntersectsWith [eyePos ACE_player, _posCheck, ACE_player, obj _intersectsLeft = false; { if (_x isKindOf "Static") exitWith {_intersectsLeft = true}; -} foreach _objectsLeft; +} count _objectsLeft; if (!_intersectsLeft) exitWith {false}; @@ -37,7 +37,7 @@ _objectsRight = lineIntersectsWith [eyePos ACE_player, _posCheck, ACE_player, ob _intersectsRight = false; { if (_x isKindOf "Static") exitWith {_intersectsRight = true}; -} foreach _objectsRight; +} count _objectsRight; //for readability... diff --git a/addons/tagging/functions/fnc_handleTagDestruction.sqf b/addons/tagging/functions/fnc_handleTagDestruction.sqf index af2e61242d..e7bca3cfaa 100644 --- a/addons/tagging/functions/fnc_handleTagDestruction.sqf +++ b/addons/tagging/functions/fnc_handleTagDestruction.sqf @@ -3,11 +3,11 @@ * Handles tag destruction when the object they are attached to gets destroyed. * * Arguments: - * None - * - * Return Value: * 0: The tag that should get destroyed * 1: The object the tag is attached to + * + * Return Value: + * None * * Example: * [tag, object] call ace_tagging_fnc_handleTagDestruction @@ -19,7 +19,7 @@ #include "script_component.hpp" private ["_tag", "_attachedTags", "_object"]; -PARAMS_2(_tag,_object); +params ["_tag", "_object"]; if (count (_object getVariable [QGVAR(attachedTags), []]) == 0) then { _object setVariable [QGVAR(attachedTags), [_tag]]; diff --git a/addons/tagging/functions/fnc_tagGround.sqf b/addons/tagging/functions/fnc_tagGround.sqf index 642b58ea5c..8e505687a2 100644 --- a/addons/tagging/functions/fnc_tagGround.sqf +++ b/addons/tagging/functions/fnc_tagGround.sqf @@ -16,9 +16,9 @@ #include "script_component.hpp" -private ["_color", "_tagPos", "_groundPos", "_vectorDirAndUp"]; +private ["_tagPos", "_groundPos", "_vectorDirAndUp"]; -PARAMS_1(_color); +params ["_color"]; if !((toLower _color) in ["black", "red", "green", "blue"]) exitWith { ["%1 is not a valid tag colour.", _color] call BIS_fnc_error; }; @@ -42,9 +42,12 @@ ACE_player playActionNow "PutDown"; [{ private ["_tag"]; - playSound3D [QUOTE(PATHTO_R(sounds\spray.ogg)), ACE_player, false, (getPosASL ACE_player), 10, 1, 15]; + params ["_tagPos", "_vectorDirAndUp", "_color"]; + + playSound3D [QUOTE(PATHTO_R(sounds\spray.ogg)), ACE_player, false, (eyePos ACE_player), 10, 1, 15]; + _tag = "UserTexture1m_F" createVehicle [0,0,0]; - _tag setObjectTextureGlobal [0, '\z\ace\addons\tagging\UI\tags\' + (_this select 2) + '\' + str (floor (random 3)) + '.paa']; - _tag setPosATL (_this select 0); - _tag setVectorDirAndUp (_this select 1); + _tag setObjectTextureGlobal [0, '\z\ace\addons\tagging\UI\tags\' + _color + '\' + str (floor (random 3)) + '.paa']; + _tag setPosATL _tagPos; + _tag setVectorDirAndUp _vectorDirAndUp; }, [_tagPos, _vectorDirAndUp, _color], 0.6] call EFUNC(common,waitAndExecute); \ No newline at end of file diff --git a/addons/tagging/functions/fnc_tagWall.sqf b/addons/tagging/functions/fnc_tagWall.sqf index 4ac2b3445a..630e6c926b 100644 --- a/addons/tagging/functions/fnc_tagWall.sqf +++ b/addons/tagging/functions/fnc_tagWall.sqf @@ -1,6 +1,6 @@ /* * Author: BaerMitUmlaut - * Creates a tag on a wall that is within 2m on front of the player. + * Creates a tag on a wall that is on the closest surface within 2m on front of the player. * * Arguments: * 0: The colour of the tag (valid colours are black, red, green and blue) @@ -16,65 +16,31 @@ #include "script_component.hpp" -private ["_color", "_eyepos", "_touchingPoints", "_pointCloser", "_pointFurther", "_posCheckCloser", "_posCheckFurther", "_touchingPoint"]; +private ["_posIntersect"]; -PARAMS_1(_color); +params ["_color"]; if !((toLower _color) in ["black", "red", "green", "blue"]) exitWith { ["%1 is not a valid tag colour.", _color] call BIS_fnc_error; }; -//Cache eyepos in case player moves -_eyepos = eyePos ACE_player; -_touchingPoints = []; - -{ - //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 select 2]; - - _posCheckFurther = ACE_player modelToWorldVisual [_x, (_pointCloser + ((_pointFurther - _pointCloser) / 2)), 0]; - _posCheckFurther set [2, _eyepos select 2]; - - 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 definitely precise enough. - _touchingPoint = ACE_player modelToWorldVisual [_x, _pointCloser, 0]; - _touchingPoint set [2, _eyepos select 2]; - _touchingPoints pushBack (_touchingPoint); - -} foreach [-0.5, 0.5]; +_posIntersect = ACE_player modelToWorldVisual [0, 2, 0]; +_posIntersect set [2, (eyepos ACE_player) select 2]; +((lineIntersectsSurfaces [eyepos ACE_player, _posIntersect, ACE_player, objNull, true, 1, "FIRE", "NONE"]) select 0) params ["_touchingPoint", "_surfaceNormal", "", "_object"]; ACE_player playActionNow "PutDown"; [{ - private ["_tag", "_object", "_posCheck"]; + private ["_tag"]; + params ["_touchingPoint", "_surfaceNormal", "_color", "_object"]; - _posCheck = ACE_player modelToWorldVisual [0, 2, 0]; - _posCheck set [2, (eyePos ACE_player) select 2]; - _object = (lineIntersectsWith [_posCheck, eyePos player, ACE_player, objNull, true]) select 0; + playSound3D [QUOTE(PATHTO_R(sounds\spray.ogg)), ACE_player, false, (eyePos ACE_player), 10, 1, 15]; - playSound3D [QUOTE(PATHTO_R(sounds\spray.ogg)), ACE_player, false, (getPosASL ACE_player), 10, 1, 15]; _tag = "UserTexture1m_F" createVehicle [0,0,0]; - _tag setObjectTextureGlobal [0, '\z\ace\addons\tagging\UI\tags\' + (_this select 1) + '\' + str (floor (random 3)) + '.paa']; - _tag setPosASL (((_this select 0 select 0) vectorAdd (_this select 0 select 1)) vectorMultiply 0.5); - _tag setDir (((_this select 0) call BIS_fnc_dirTo) - 90); + _tag setObjectTextureGlobal [0, '\z\ace\addons\tagging\UI\tags\' + _color + '\' + str (floor (random 3)) + '.paa']; + //Add 6cm so it doesn't get placed "into" the wall. + //6cm works with most building surfaces, but not with all of them. The LODs precision varies between 1cm and around 8cm+. + _tag setPosASL (_touchingPoint vectorAdd (_surfaceNormal vectorMultiply 0.06)); + _tag setVectorDirAndUp [(_surfaceNormal vectorMultiply -1), [0,0,1]]; [[_tag, _object], QUOTE(FUNC(handleTagDestruction)), 1] call EFUNC(common,execRemoteFnc); -}, [_touchingPoints, _color], 0.6] call EFUNC(common,waitAndExecute); \ No newline at end of file +}, [_touchingPoint, _surfaceNormal, _color, _object], 0.6] call EFUNC(common,waitAndExecute); \ No newline at end of file