mirror of
https://github.com/Defent/DMS_Exile.git
synced 2024-08-30 16:52:12 +00:00
e3d11a0aa5
Lots of optimizations...
46 lines
915 B
Plaintext
46 lines
915 B
Plaintext
/*
|
|
DMS_fnc_CalcPos
|
|
Created by eraser1
|
|
|
|
Usage:
|
|
[
|
|
_positionOrObject, // Object or Position: The center
|
|
_relativePosition // Array: The offset
|
|
] call DMS_fnc_CalcPos;
|
|
|
|
Returns the absolute position from the provided relative position from the provided center position or object.
|
|
*/
|
|
|
|
if !(params
|
|
[
|
|
["_pos","",[[],objNull],[2,3]],
|
|
["_relPos","",[[]],[2,3]]
|
|
])
|
|
exitWith
|
|
{
|
|
diag_log format ["DMS ERROR :: Calling DMS_fnc_CalcPos with invalid parameters: %1",_this];
|
|
};
|
|
|
|
|
|
// Get the position if an object was supplied instead of position
|
|
if (_pos isEqualType objNull) then
|
|
{
|
|
_pos = getPosATL _pos;
|
|
};
|
|
|
|
// Set the center pos to 0 if it isn't defined
|
|
if ((count _pos)<3) then
|
|
{
|
|
_pos set [2,0];
|
|
};
|
|
|
|
|
|
// Set the z-pos offset to 0 if it isn't defined
|
|
if ((count _relPos)<3) then
|
|
{
|
|
_relPos set [2,0];
|
|
};
|
|
|
|
// Script command "vectorAdd" is much faster than adding each element manually.
|
|
_pos vectorAdd _relPos
|