Jump to content
M1ke_SK

[RELEASE] Composition spawning

Recommended Posts

I created simple functions to spawn editor placed objects. It captures objects around source object and collect offset and direction for objects for composition. I hope this will find use in Arma 3 community.

 

Usage:

 

1. place player unit in editor (must be set direction to 0 (true north))

2. create composition around player

3. call function

_composition = [player, 100] call MY_fnc_get_composition;

it will return array of objects and offsets of composition of 100m radius from source (player)

it will be also in copy/paste clipboard

 

4. call function  (in editor you can set source to player to spawn composition around player's position)

null = [_source, _composition] call MY_fnc_set_composition;

5. Profit

 

 

6. Will add demo version later ...

 

 

 

Code here:

 

fn_get_composition.sqf

private _source = _this select 0;
private _radius = _this select 1;

_objArray = []; 
_sourcePos = getPos _source; 
_sourceDir = getDir _source; 
{ 
    if !(_x isEqualTo _source && _x isEqualTo player) then 
    { 
        _pos = getPos _x;
        _dir = getDir _x;
        _type = typeOf _x;
        _offset = [(_pos select 0) - (_sourcePos select 0),(_pos select 1) - (_sourcePos select 1),(_pos select 2) - (_sourcePos select 2)]; 
        _dirOffset = (_dir + 360 - _sourceDir) % 360; 
        _objArray pushBack [_type, _offset, _dirOffset];
}; 
} forEach nearestObjects [_source, [], _radius]; 
copyToClipboard str _objArray;

_objArray

fn_set_composition.sqf

private _source = _this select 0;
private _composition = _this select 1;

{
_type = _x select 0;
_offset = _x select 1;
_newDir = _x select 2;
_obj = createVehicle [_type, [0,0,0], [], 0, "CAN_COLLIDE"];
_obj allowDamage false;
[_source, _obj, _offset, _newDir, true, true] call BIS_fnc_relPosObject;
} forEach _composition;

 

  • Like 6

Share this post


Link to post
Share on other sites

Put those codes into files and then call them from debug console.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×