-
Notifications
You must be signed in to change notification settings - Fork 108
/
Copy pathfn_ImportFromM3E.sqf
75 lines (59 loc) · 1.73 KB
/
fn_ImportFromM3E.sqf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
DMS_fnc_ImportFromM3E
Created by eraser1
Check out M3 Editor: http://maca134.co.uk/portfolio/m3editor-arma-3-map-editor/
Usage:
[
_file, // String: The filename (or filepath under the objects folder) that contains the exported M3E objects
_pos // Object or Array: Center position
] call DMS_fnc_ImportFromM3E;
It takes RELATIVE POSITION as argument. In order to get relative positions, check this link: http://maca134.co.uk/portfolio/m3editor-arma-3-map-editor/
Returns all created objects.
*/
if !(params
[
["_file","",[""]],
["_pos","",[[],objNull],[2,3]]
])
exitWith
{
diag_log format ["DMS ERROR :: Calling DMS_fnc_ImportFromM3E 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];
};
private _export = call compile preprocessFileLineNumbers (format ["\x\addons\DMS\objects\%1.sqf",_file]);
if ((isNil "_export") || {!(_export isEqualType [])}) exitWith
{
diag_log format ["DMS ERROR :: Calling DMS_fnc_ImportFromM3E with invalid file/filepath: %1 | _export: %2",_file,_export];
[]
};
private _objs = _export apply
{
// Create the object
private _obj = createVehicle [_x select 0, [0,0,0], [], 0, "CAN_COLLIDE"];
_obj enableSimulationGlobal false;
// Calculate the object's position using provided relative position
private _objPos = [_pos,_x select 1] call DMS_fnc_CalcPos;
if (((count _x)>4) && {!(_x select 4)}) then
{
// Supports bank/pitch
_obj setPosATL _objPos;
_obj setVectorDirAndUp (_x select 3);
}
else
{
_obj setDir (_x select 2);
_obj setPos _objPos;
};
_obj;
};
_objs