@@ -57,6 +57,7 @@ _unit setVariable [QGVAR(cancelActionEH), [_unit, "zoomtemp", {true}, {GVAR(plac
5757private _supportedTriggers = getArray (_configMagazine >> " ACE_Triggers" >> " SupportedTriggers" );
5858private _aceTriggers = configFile >> " ACE_Triggers" ;
5959private _isAttachable = _supportedTriggers findIf {(getNumber (_aceTriggers >> _x >> " isAttachable" )) == 1 } ! = - 1 ;
60+ private _isSticky = getNumber (_configMagazine >> QGVAR(isSticky)) == 1 ;
6061
6162GVAR(pfeh_running) = true ;
6263GVAR(placeAction) = PLACE_WAITING;
@@ -68,7 +69,7 @@ GVAR(TweakedAngle) = 0;
6869 disableSerialization;
6970
7071 params [" _args" , " _pfhID" ];
71- _args params [" _unit" , " _magClassname" , " _setupObjectClass" , " _isAttachable" ];
72+ _args params [" _unit" , " _magClassname" , " _setupObjectClass" , " _isAttachable" , " _isSticky " ];
7273
7374 private _lookDirVector = ((positionCameraToWorld [0 , 0 , 0 ]) call EFUNC(common,positionToASL)) vectorFromTo ((positionCameraToWorld [0 , 0 , 10 ]) call EFUNC(common,positionToASL));
7475 private _basePosASL = eyePos _unit ;
@@ -121,14 +122,20 @@ GVAR(TweakedAngle) = 0;
121122 } forEach [[0 , 0 ], [- TEST_LENGTH, - TEST_LENGTH], [TEST_LENGTH, - TEST_LENGTH], [- TEST_LENGTH, TEST_LENGTH], [TEST_LENGTH, TEST_LENGTH]];
122123
123124 if (
124- ! isNull _attachVehicle &&
125- {(_attachVehicle isKindOf " Car" ) || {_attachVehicle isKindOf " Tank" } || {_attachVehicle isKindOf " Air" } || {_attachVehicle isKindOf " Ship" }} &&
125+ ! isNull _attachVehicle && (
126+ // Allow attaching to non-unit objects (if set) or any vehicle
127+ (_isSticky && {! (_attachVehicle isKindOf " Man" )}) ||
128+ {_attachVehicle isKindOf " Car" } ||
129+ {_attachVehicle isKindOf " Tank" } ||
130+ {_attachVehicle isKindOf " Air" } ||
131+ {_attachVehicle isKindOf " Ship" }
132+ ) &&
126133 {PLACE_RANGE_MIN call _testPositionIsValid }
127134 ) then {
128135 private _min = PLACE_RANGE_MIN;
129136 private _max = PLACE_RANGE_MAX;
130137
131- for " _index " from 0 to 6 do {
138+ for " _ " from 0 to 6 do {
132139 _distanceFromBase = (_min + _max ) / 2 ;
133140
134141 if (_distanceFromBase call _testPositionIsValid ) then {
@@ -207,7 +214,17 @@ GVAR(TweakedAngle) = 0;
207214 _expSetupVehicle setPosASL _virtualPosASL ;
208215 _placeAngle = _placeAngle + 180 ; // CfgAmmos seem to be 180 for some reason
209216 } else {
210- private _modelOffset = _attachVehicle worldToModel (_virtualPosASL call EFUNC(common,ASLToPosition));
217+ // Terrain objects (seemingly) can't have objects attached to them, so create a dummy instead
218+ private _modelOffset = if (_attachVehicle call CBA_fnc_isTerrainObject ) then {
219+ _attachVehicle = createVehicle [" Helper_Base_F" , [0 , 0 , 0 ], [], 0 , " CAN_COLLIDE" ];
220+ _attachVehicle setPosASL _virtualPosASL ;
221+ _attachVehicle setDir _placeAngle ;
222+
223+ [0 , 0 , 0 ];
224+ } else {
225+ _attachVehicle worldToModel (_virtualPosASL call EFUNC(common,ASLToPosition));
226+ };
227+
211228 _placeAngle = _cameraAngle - (getDir _attachVehicle ) + 180 ;
212229 _expSetupVehicle attachTo [_attachVehicle , _modelOffset ];
213230 _expSetupVehicle setVectorDirAndUp [[0 , 0 , - 1 ], [sin _placeAngle , cos _placeAngle , 0 ]];
@@ -255,6 +272,6 @@ GVAR(TweakedAngle) = 0;
255272 };
256273
257274 END_COUNTER(pfeh);
258- }, 0 , [_unit , _magClassname , _setupObjectClass , _isAttachable ]] call CBA_fnc_addPerFrameHandler ;
275+ }, 0 , [_unit , _magClassname , _setupObjectClass , _isAttachable , _isSticky ]] call CBA_fnc_addPerFrameHandler ;
259276
260277nil
0 commit comments