scriptname "spe_missionUtilityFunctions_fnc_moveMarker_local"; /* Author: BIS, modified by Dmitry Yuri Description: Moves marker to a new position Parameters: Select 0 - STRING: Marker Select 1 - ARRAY: New position Select 2 - NUMBER: Duration 5 Select 3 - NUMBER: Type of interpolation LINEAR 0 CUBIC 1 EASEIN 2 EASEOUT 3 EASEINOUT 4 HERMITE 5 BERP 6 BOUNCEIN 7 BOUNCEOUT 8 BOUNCEINOUT 9 QUINTICIN 10 QUINTICOUT 11 QUINTICINOUT 12 CONSTANT 13 Returns: Nothing Examples: _move = ["SPE_marker",[1111,2222,0]] call spe_missionUtilityFunctions_fnc_moveMarker_local; _move = ["SPE_marker",(getMarkerPos "SPE_marker2"),2] call spe_missionUtilityFunctions_fnc_moveMarker_local; */ // Parameters params [ ["_marker", "", [""]], ["_endLoc", [0,0,0], [[]]], ["_duration", 5, [999]], ["_interp", 4, [999]] ]; if ((_endLoc # 0) isEqualType []) then { _endLoc = _endLoc # 0; }; if (count _endLoc isEqualTo 2) then { _endLoc pushBack 0; }; if (_duration isEqualTo 0) exitWith { _marker setMarkerPosLocal _endLoc; }; // Create objects that make up the animation private _startLoc = getMarkerPos _marker; /* private _timeline = createAgent ["Timeline_F", _startLoc, [], 0, "CAN_COLLIDE"]; private _curve = createAgent ["Curve_F", _startLoc, [], 0, "CAN_COLLIDE"]; private _keyStart = createAgent ["Key_F", _startLoc, [], 0, "CAN_COLLIDE"]; private _keyEnd = createAgent ["Key_F", _endLoc, [], 0, "CAN_COLLIDE"]; private _camera = createAgent ["Logic", _startLoc, [], 0, "CAN_COLLIDE"]; */ private _timeline = "Timeline_F" createVehicleLocal _startLoc; _timeline setPos _startLoc; private _curve = "Curve_F" createVehicleLocal _startLoc; _curve setPos _startLoc; private _keyStart = "Key_F" createVehicleLocal _startLoc; _keyStart setPos _startLoc; private _keyEnd = "Key_F" createVehicleLocal _endLoc; _keyEnd setPos _endLoc; private _camera = "Logic" createVehicleLocal _startLoc; _camera setPos _startLoc; private _timeline_objects = [_curve, _keyStart, _keyEnd, _camera, _timeline]; _timeline setVariable ["spe_moveMarker_timeline_objects", _timeline_objects]; private _eventFinish = { params ["_timeline"]; private _timeline_objects = _timeline getVariable ["spe_moveMarker_timeline_objects", []]; { deleteVehicle _x; } forEach _timeline_objects; }; [{ // Condition params ["_marker", "_camera", "_keyEnd", "_finalPos"]; if (isNull _camera) exitWith {true}; _marker setMarkerPosLocal (getPosASL _camera); (((_camera distance _finalPos) < 0.001) || (missionNamespace getVariable ["spe_missionUtilityFunctions_eventTimeline_skip_blackout", false])); }, { // Statement params ["_marker","","","_finalPos"]; _marker setMarkerPosLocal _finalPos; }, [_marker, _camera, _keyEnd, _endLoc]] call SPE_fnc_waitUntilAndExecute; // Setup first key _keyStart setPosASL _startLoc; [_keyStart, 1] call BIS_fnc_key_setInterpMode; [_keyStart, 0.0, true] call BIS_fnc_key_setTime; // Setup last key _keyEnd setPosASL _endLoc; [_keyEnd, 1] call BIS_fnc_key_setInterpMode; [_keyEnd, _duration, true] call BIS_fnc_key_setTime; // Setup curve [_curve, 1] call BIS_fnc_richCurve_setOrientationMode; _curve synchronizeObjectsAdd [_timeline, _keyStart, _keyEnd, _camera]; // Setup timeline [_timeline, _interp] call BIS_fnc_timeline_setInterpMode; [_timeline, _duration] call BIS_fnc_timeline_setLength; // The pending code, to be executed at the end of the animation // See the bellow event "finished" _timeline setVariable ["BIS_scriptedAnimEvent", _eventFinish]; // Force curve computation // This is a very important step, otherwise our curve won't have needed data baked and it won't work properly // When scripting an animation, make sure to always call this for all modified curves (including child keys, control points, etc) [_curve, true] call BIS_fnc_richCurve_compute; // Play the timeline [_timeline] call BIS_fnc_timeline_play; // Timeline stops playing // Here we clear all the related animation data and objects [_timeline, "finished", { // Destroys animation (Timeline and all related objects such as curves, keys, control points and simulated objects) // [_this select 0] call BIS_fnc_timeline_cleanup; // Call script event finish code [_this select 0] call ((_this select 0) getVariable ["BIS_scriptedAnimEvent", {}]); // (_this select 0) setVariable ["BIS_scriptedAnimEvent", nil]; }] call BIS_fnc_addScriptedEventHandler;