Weaponx 10 Posted January 25, 2012 I’ve been experimenting with recording the type, position, direction of objects that are in the editor and then recreating them via script using createvehiclelocal . The purpose is to create non-destructible fighting positions i.e. artillery positions that only exist locally clients and on the server. Because they are local there is not any network traffic. The problem is that I have using getposatl, getposasl to record the data and then createvehiclelocal and then setposatl and setposasl on the object. The objects do not spawn in the same place that it was placed in the editor. What do I need to do to increase the precision of the placement? Share this post Link to post Share on other sites
AZCoder 921 Posted January 26, 2012 The get and setposATL/ASL works like a champ for me. However I have seen situations where nearby objects will offset the spawned object's location. To minimize that, use the full array version: http://community.bistudio.com/wiki/createVehicle_array and make sure to use the final option "CAN_COLLIDE". Share this post Link to post Share on other sites
Weaponx 10 Posted January 26, 2012 The problem with that is that the objects will not be local.. The idea of spawning local objects is to eleminate network traffic while still being able to use the fighting postions for cover. Share this post Link to post Share on other sites
2nd ranger 282 Posted January 26, 2012 Use ObjectGrabber.sqf place your objects, then in the init line of a central object (not an object that will be spawned): null = [getpos this,200] execvm "objectGrabber.sqf"; 200 is the size of the area you want to grab objects from. scriptName "objectGrabber.sqf"; /* File: objectGrabber.sqf Author: Joris-Jan van 't Land Description: Converts a set of placed objects to an object array for the DynO mapper. Places this information in the debug output for processing. Parameter(s): _this select 0: position of the anchor point _this select 1: size of the covered area Returns: Success flag (Boolean) init: null = [getpos this,200] execvm "objectGrabber.sqf"; */ //Validate parameter count if ((count _this) < 2) exitWith {diag_log "Log: [objectGrabber] Function requires at least 2 parameter!"; false}; private ["_anchorPos", "_anchorDim"]; _anchorPos = _this select 0; _anchorDim = _this select 1; //Validate parameters if ((typeName _anchorPos) != (typeName [])) exitWith {diag_log "Log: [objectGrabber] Anchor position (0) must be an Array!"; false}; if ((typeName _anchorDim) != (typeName 0)) exitWith {diag_log "Log: [objectGrabber] Covered area size (1) must be an Number!"; false}; private ["_objs"]; _objs = nearestObjects [_anchorPos, ["All"], _anchorDim]; diag_log "#####################################"; diag_log "### Log: objectGrabber: StartGrabbing"; diag_log "#####################################"; for "_i" from 0 to ((count _objs) - 1) do { private ["_obj", "_type"]; _obj = _objs select _i; _type = typeOf _obj; //Exclude human objects. private ["_sim"]; _sim = getText (configFile >> "CfgVehicles" >> _type >> "simulation"); if !(_sim in ["soldier"]) then { private ["_objPos", "_dX", "_dY", "_z", "_azimuth", "_fuel", "_damage", "_vehicleinit"]; _objPos = position _obj; _dX = (_objPos select 0) - (_anchorPos select 0); _dY = (_objPos select 1) - (_anchorPos select 1); _z = _objPos select 2; _azimuth = direction _obj; _fuel = fuel _obj; _damage = damage _obj; _vehicleinit = if (isnil {_obj getvariable "vehicleinit"}) then {{}} else {_obj getvariable "vehicleinit";}; // _obj setvariable ["vehicleInit",_vehicleInit]; diag_log text(format ["%1,", [_type, [_dX, _dY, _z], _azimuth, _fuel, _damage, _vehicleinit]]); }; }; diag_log "###################################"; diag_log "### Log: objectGrabber: EndGrabbing"; diag_log "###################################"; true When you preview the mission, that will create an output in the rpt file of the object names and their positions. Copy and paste that from the rpt file into a script file which looks like the following (your pasted data in red): private ["_objs"]; _objs = [ [color="DarkRed"]["Land_BagFenceLong",[-34.8926,-18.4326,-0.0566883],25.0026,1,0,{}], ["Land_House_K_3_EP1",[-37.4541,-18.4946,-20.6135],199.234,1,0,{}], ["Land_CncBlock_D",[-42.0308,-1.0166,5.53131e-005],280.453,1,0,{}], ["Hhedgehog_concrete",[-43.5625,-6.52002,0.000497818],290.058,1,0,{}], ["Land_BagFenceShort",[-36.8618,-25.6416,0.503485],21.9532,1,0,{}], ["Land_fort_bagfence_corner",[-39.8267,-23.7847,-0.0479069],22.5676,1,0,{}], ["Land_Wall_L_2m5_gate_EP1",[45.2813,-8.14209,0.0528336],97.2493,1,0,{}], ["Land_BagFenceLong",[-39.5254,-24.6392,0.21312],21.9601,1,0,{}], ["Land_BagFenceEnd",[-39.709,25.7979,-0.00840187],122.619,1,0,{}], ["Land_BagFenceShort",[-38.8701,27.1104,-9.53674e-006],123.108,1,0,{}], ["Land_BagFenceEnd",[-38.0791,28.3481,0.00218582],302.264,1,0,{}], ["Land_Wall_L_2m5_gate_EP1",[-38.4751,28.3149,0.0181103],303.056,1,0,{}], ["UAZWreck",[-40.4639,28.0996,-0.0048542],218.688,1,0,{}][/color] ]; _objs Name the file whatever, MyComposition.sqf for example. Then create a folder in the mission directory called 'Compositions' and place the file in there. Then you need CreateComposition.sqf: /* Original Script objectMapper.sqf Author: Joris-Jan van 't Land Edited by armatec Description: Takes an array of data about a dynamic object template and creates the objects. Parameter(s): _this select 0: compositions name - "fuelDepot_us" _this select 1: Direction in degrees - Number _this select 2: Location to start Exsample: ["fuelDepot_us", 0, getpos player] execVM "Createcomposition.sqf"; */ _script = _this select 0; _azi = _this select 1; _pos = _this select 2; _objs = []; _objs = call (compile (preprocessFileLineNumbers format ["compositions\%1.sqf",_script])); private ["_posX", "_posY"]; _posX = _pos select 0; _posY = _pos select 1; _newObjs = []; private ["_multiplyMatrixFunc"]; _multiplyMatrixFunc = { private ["_array1", "_array2", "_result"]; _array1 = _this select 0; _array2 = _this select 1; _result = [ (((_array1 select 0) select 0) * (_array2 select 0)) + (((_array1 select 0) select 1) * (_array2 select 1)), (((_array1 select 1) select 0) * (_array2 select 0)) + (((_array1 select 1) select 1) * (_array2 select 1)) ]; _result }; for "_i" from 0 to ((count _objs) - 1) do { private ["_obj", "_type", "_relPos", "_azimuth", "_fuel", "_damage", "_newObj", "_vehicleinit"]; _obj = _objs select _i; _type = _obj select 0; _relPos = _obj select 1; _azimuth = _obj select 2; _fuel = _obj select 3; _damage = _obj select 4; _vehicleinit = _obj select 5; private ["_rotMatrix", "_newRelPos", "_newPos"]; _rotMatrix =[[cos _azi, sin _azi],[-(sin _azi), cos _azi]]; _newRelPos = [_rotMatrix, _relPos] call _multiplyMatrixFunc; private ["_z"]; if ((count _relPos) > 2) then {_z = _relPos select 2} else {_z = 0}; _newPos = [_posX + (_newRelPos select 0), _posY + (_newRelPos select 1), _z]; _newObj = _type createVehiclelocal _newPos; _newObj setDir (_azi + _azimuth); _newObj setPos _newPos; if (!isNil "_fuel") then {_newObj setFuel _fuel}; if (!isNil "_damage") then {_newObj setDamage _damage}; if (!isNil "_vehicleinit") then {_newObj setVehicleInit format ["%1;",_vehicleinit]}; processInitCommands; _newObjs = _newObjs + [_newObj]; }; Now to spawn the objects, you can place this in the init line of that central object you used to grab the data: null= ["MyComposition", 0, getpos this] execVM "Createcomposition.sqf"; Share this post Link to post Share on other sites
Auss 208 Posted August 30, 2012 Using the method above is there anyway to set the height of a specific object when making a custom composition? I would like to place some sandbags above a wall Share this post Link to post Share on other sites
cuel 25 Posted August 30, 2012 Yes. When you place the object you can set the height in the init line this setPosATL [(getPosATL this select 0), (getPosATL this select 1),(getPosATL this select 2)+1]; The +1 at the end would place the object one meter (?) above the ground. Can also be a negative number. For a simple way to create compositions I'd suggest you use the Real time editor (not the 3d editor, but that can also be used) and then use the objectGrabber with a trigger radio. this enableSimulation false; Will also make the object not send updates across the network but would also disable any kind of animation when the object dies. Share this post Link to post Share on other sites
Auss 208 Posted August 30, 2012 Thanks for the reply cuel. I have been using the @RTE Editor but found issues namely missing objects, after placing more than 10 objects it seems to lose the rest. Share this post Link to post Share on other sites
Tankbuster 1744 Posted August 30, 2012 bleSimulation false;[/code] Will also make the object not send updates across the network Unrelated to the subject at hand, but the sedning updates behaviour was patched out by BI soon after it was discovered by users. Share this post Link to post Share on other sites
cuel 25 Posted August 30, 2012 Very good. I still presume that enableSimulation disables objects to send updates when receiving damage ? Share this post Link to post Share on other sites
Auss 208 Posted August 31, 2012 @Cuel- Doesn't work, the objects spawn on the ground after I spawn the custom composition. I added the line to each objects init space Share this post Link to post Share on other sites
cuel 25 Posted September 1, 2012 Are the objects affected by physics? Share this post Link to post Share on other sites
Gibs 10 Posted May 20, 2013 When using this, how would I make the objects that spawn unmovable? I'm creating a base and don't want the objects used movable. I've tried using this : this setVariable ["R3F_LOG_disabled", true]; this addEventHandler["handleDamage", {false}]; in the init line of the marker, but it doesn't work. Share this post Link to post Share on other sites
killzone_kid 1329 Posted May 21, 2013 Using the method above is there anyway to set the height of a specific object when making a custom composition? I would like to place some sandbags above a wall ["Land_BagFenceLong",[-34.8926,-18.4326,-0.0566883],25.0026,1,0,{}], You can edit your grabbed result manually and adjust the height. In red is Z coordinate in metres. Share this post Link to post Share on other sites
xxanimusxx 2 Posted May 21, 2013 This could be off topic but please try to bear with me: Having static objects like fortifications or "un-intelligent" ones without any attached actions won't count towards network traffic, because they have none, right? There was something meantioned in the BIKI article for enableSimulation as far as I can remember. According to this fact, isn't all this local spawning of objects to prevent network traffic irrelevant if there is none to be afraid of? Share this post Link to post Share on other sites
ringoray 1 Posted December 31, 2013 Created composition no problem, but what ever position they are created in, they just keep facing that direction when placed on new map. Any ideas how to fix this so you can make them face whatever way you want them too, like the ones from arma 2. In arma 2 ones you could just move them around until the position was satisfactory. Share this post Link to post Share on other sites
spitfire007 10 Posted April 25, 2014 ^^^^BUMP^^^^ This is a good question and one I too could use an answer on ?? Share this post Link to post Share on other sites