Jump to content
Gemini

Dynamic Object Compositions (DoC)

Recommended Posts

Hello,

DynO function is not working anymore on ArmA III as the setVehicleInit command has been disabled for security reason.

So, I tried to do it by myself but I don't know how to use BIS_fnc_MP that is suggested on BI's wiki. Help would be very much appreciated to update the old code:

if (!isNil "_vehicleinit") then {_newObj setVehicleInit format ["%1;",_vehicleinit]};
processInitCommands;

Any idea ?

Edited by Gemini

Share this post


Link to post
Share on other sites

Sorry about the double post. Maybe a SI member could give us a few information about how to use DoC in ArmA III ? It's a fantastic feature to build dynamic content, I'm surprised nobody is talking about it.

Share this post


Link to post
Share on other sites

Well that was replaced with BIS_fnc_MP. So I would try to do something with that if i were you.

Share this post


Link to post
Share on other sites

Yes that's what I said in the first post. But I really don't see the link between "setVehicleInit" and "BIS_fnc_MP" and how to use it, that's the purpose of this topic :)

Edited by Gemini

Share this post


Link to post
Share on other sites

try this

if (!isNil "_vehicleInit") then {
		_NewUnit = format ["%1",_newobj];
		publicvariable _newunit;
		_newunit call _vehicleinit;
	};

untested but it should work after you make sure the 'this' in _vehicleinit of the unit in the composition has _ in front so it becomes '_this'.

fortunately due to the way you need to put the init for each object into a variable this is easy to do, just remember when making the composition

Share this post


Link to post
Share on other sites

Thank you for your help KevsnoTrev, I appreciate.

Well, it doesn't seem to work. Here is the error I get:

Error select: Type String, Table ,Config entry expecting
File C:\Users\Gemini\Documents\Arma 3\missions\DoC.Stratis\objectMapper.sqf, line 47

Line 47 is:

_type = _obj select 0;

Here is the complete objectMapper.sqf code:

/*
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";
*/

if (!isServer) exitWith{};

_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", "_newUnit", "_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 {_newUnit = format ["%1",_newObj]; publicVariable _newUnit; _newUnit call _vehicleinit};	
	["Imma spamming your log!","BIS_fnc_log"] spawn BIS_fnc_MP;
	[_vehicleinit, functionName, _newObj, true] spawn BIS_fnc_MP;
	_newObjs = _newObjs + [_newObj];

};

The script is called with this:

null = ["myCustomComposition", getDir player, getPos player] execVM "objectMapper.sqf"

And here is myCustomComposition.sqf:

["O_Mortar_01_F",[1.28345,1.03516,8.86917e-005],0,1,0,{}],
["Land_BagFence_Round_F",[-1.17017,1.20068,0],90,1,0,{}],
["Land_BagFence_Round_F",[1.31348,-1.32666,0],0,1,0,{}],
["Land_BagFence_Round_F",[3.70764,1.20068,0],270,1,0,{}],
["Land_BagFence_Round_F",[1.39758,3.98486,0],180,1,0,{}]

Does anybody see what's wrong ?

Edited by Gemini

Share this post


Link to post
Share on other sites

compositions need to be in this format

private ["_objs"];_objs =
[
   ["O_Mortar_01_F",[1.28345,1.03516,8.86917e-005],0,1,0,{}],
["Land_BagFence_Round_F",[-1.17017,1.20068,0],90,1,0,{}],
["Land_BagFence_Round_F",[1.31348,-1.32666,0],0,1,0,{}],
["Land_BagFence_Round_F",[3.70764,1.20068,0],270,1,0,{}],
["Land_BagFence_Round_F",[1.39758,3.98486,0],180,1,0,{}]
];


_objs

youe example seems to be missing the _objs and you are not passing the objects you want as an array.

Share this post


Link to post
Share on other sites

Thank you very much KevsnoTrev ! It works now (the composition is perfectly spawning) but I still got a message error:

[bIS_fnc_MPexec] Function '' does not exist

I guess it refers to this line in objectMapper.sqf, and especially the functionName parameter:

[_vehicleinit, functionName, _newObj, true] spawn BIS_fnc_MP;

What am I suppose to write here ? I don't understand the structure of this command :(

Edit:

I choosed randomly a BI's function and the error message has disappeared:

[_vehicleinit, "BIS_fnc_log", _newObj, true] spawn BIS_fnc_MP;

So everything is working now, without any error message, but do you think there's something smarter to use ?

Edited by Gemini

Share this post


Link to post
Share on other sites

give what I wrote, you should not need the two lines with bis_fnc_mp, it replaces it. Give it a go, just comment out // for a test.

Although I did not see that line in there, a function would need to be written to do exactly what I have done, so I believe its now the same and redundant.

Maybe someone else can confirm this.

Have you actually put an init in an object e.g. {_this setdir random 360;}

This will randomly rotate an object when using the mapper.

Although if you wanted to use the objectgrabber you would need to write this

this setvariable ["vehicleinit",{_this setdir random 360;}];

or it could be an addaction to VAS or something.

Share this post


Link to post
Share on other sites

You're right, those 2 lines are now useless.

About the object's init, it doesn't seem to work if I try to edit it. It doesn't really matter to me as I don't think I will need it. But I'm curious and maybe it could help some people, so now I think we should go ahead :)

Here is the myComposition.sqf:

private ["_objs", "_this"];

_objs =
[
	["O_Mortar_01_F",[1.28345,1.03516,8.86917e-005],0,1,0,{_this setdir random 360;}],
	["Land_BagFence_Round_F",[-1.17017,1.20068,0],90,1,0,{}],
	["Land_BagFence_Round_F",[1.31348,-1.32666,0],0,1,0,{}],
	["Land_BagFence_Round_F",[3.70764,1.20068,0],270,1,0,{}],
	["Land_BagFence_Round_F",[1.39758,3.98486,0],180,1,0,{}]
];

_objs;

And here is the error message I get:

Error setDir: Type String, Object expected

Ayway, thank you very very very much KevsnoTrev !

Edited by Gemini

Share this post


Link to post
Share on other sites

Hey guys,

Just an FYI - I have done some testing with Bis_fncObjectsMapper and bis_fnc_ObjectsGrabber and both work as intended.

  • Just remember the output is in the clipboard and not the .rpt file.
  • The object/vehicle init is now needed to be stored in "init" - eg. this setvariable ["init","this setdir random 360"]

Compositions created using the A2 version of the scripts will need to be placed and re-recorded to change the order of the variables in the output array.

Example output- compare to those above.

/*Grab data:
Mission: objectgrab_test
World: Stratis
Anchor position: [4210.73, 4857.44]
Area size: 100
Using orientation of objects: yes
*/


[
   ["FlagPole_F",[0,0,-0.00663757],45.5765,1,0,[1.06726e-007,0],"","this setdir random 360",true,false], 
   ["Land_BagFence_Long_F",[-1.20703,1.68018,-6.10352e-005],339.649,1,0,[-1.35292,-1.17876],"","",true,false], 
   ["Land_BagFence_Long_F",[1.57178,1.99365,0.00177002],8.85463,1,0,[-1.8098,6.10209],"","",true,false], 
   ["Land_BagFence_Long_F",[-3.29834,-0.0219727,0.00279236],301.678,1,0,[-6.06735,-2.93077],"","",true,false]
]

Edited by KevsnoTrev

Share this post


Link to post
Share on other sites

Hi KevsnoTrev,

How do you call this function ?

I tried to put this into the player's init to re-record my composition, but it doesn't copy anything into the clipboard:

[getPos this, 50, false] call BIS_fnc_objectsGrabber

Share this post


Link to post
Share on other sites

I used the code below in the init of a flagpole

[getpos this, 100] call bis_fnc_objectsgrabber

No problems with the clipboard, all info is there as pasted above.

I am thinking it doesn't like having the player with the init.

sample mission....just put into an empty folder with .Stratis extension

Share this post


Link to post
Share on other sites

Oh ok I understand what was wrong: I was looking for the clipboard.txt file...

So, for people who might be interested about this thread and Dynamic Object Compositions for ArmA III, I resume how to do:

1. Make your custom composition in the editor, in a flat area.

2. Place the player in the middle of your composition and put this in his init:

[getPos player, 50] call BIS_fnc_objectsGrabber

3. Create and open a new .sqf file in your mission folder

4. Do CTRL+V to paste code. You should see something similar to this:

/*Grab data:
Mission: objectgrab_test
World: Stratis
Anchor position: [4210.73, 4857.44]
Area size: 100
Using orientation of objects: yes
*/


[
   ["FlagPole_F",[0,0,-0.00663757],45.5765,1,0,[1.06726e-007,0],"","this setdir random 360",true,false], 
   ["Land_BagFence_Long_F",[-1.20703,1.68018,-6.10352e-005],339.649,1,0,[-1.35292,-1.17876],"","",true,false], 
   ["Land_BagFence_Long_F",[1.57178,1.99365,0.00177002],8.85463,1,0,[-1.8098,6.10209],"","",true,false], 
   ["Land_BagFence_Long_F",[-3.29834,-0.0219727,0.00279236],301.678,1,0,[-6.06735,-2.93077],"","",true,false]
]

5. Save and quit your composition.

6. Now, to spawn the composition:

0 = [positionWhereYouWantToSpawnYourComposition, azimutOfYourComposition, call (compile (preprocessFileLineNumbers "yourComposition.sqf"))] call BIS_fnc_ObjectsMapper;

Don't forget to replace:

- positionWhereYouWantToSpawnYourComposition : by a position array

- azimutOfYourComposition : by number you want

- yourComposition.sqf : by the name AND the path of your custom composition (for example, if you saved your composition in a "compositions" folder, it will be: "compositions\yourComposition.sqf".

I hope this will help some others. All credits are going to KevsnoTrev - thank you for you help dude ! :)

Edited by Gemini

Share this post


Link to post
Share on other sites

for beginners always keep in mind that both fncs won't spawn predefined composition and the grabber won't assemble any map static building but missionObjs instead. Btw grabber will always grab a snake in a3 so don't forget to delete it in the composition array. Be aware that the grabber does grab everything user-created both alived or not alived, so you'll always find a grabbed snake if player unit was used as the anchor pos.

Edited by ffur2007slx2_5

Share this post


Link to post
Share on other sites

Hi,

when I use this, it works but it seems to kill any "z" (height) information on creation.

I created a base with MCC or in 2d Editor, copy it and recreate it. result: Items are stuck into each other and no longer on top of each other.

Share this post


Link to post
Share on other sites
Hi,

when I use this, it works but it seems to kill any "z" (height) information on creation.

I created a base with MCC or in 2d Editor, copy it and recreate it. result: Items are stuck into each other and no longer on top of each other.

There is a custom DOC placer and grabber generator in the 3d editor under the > button. As far as I remember the Z factor is fixed there. So if you can check it out and post your resualts if it is broken i'll fix it and release it for the community

Share this post


Link to post
Share on other sites

Can't check right now as I'm at work but I'm pretty sure Z was safed in both cases (MCC and BIS-DoC). It seems to get killed at the time of creation by:

0 = [positionWhereYouWantToSpawnYourComposition, azimutOfYourComposition, call (compile (preprocessFileLineNumbers "yourComposition.sqf"))] call BIS_fnc_ObjectsMapper;

But I'll give you a reply after checking tonight (zulu).

Edit:

I think I found the problem (possibly). The "anchor point" that is given, doesn't contain Z and maybe there is a problem with my calculated Z.

@Shay_Gman: Could you include all 3 dimensions in your anchorpoint or maybe just give an option to use absolute values? Ah, not possible because the mapper doesn't work that way... hm...

Edited by mech

Share this post


Link to post
Share on other sites

The result of lots of testing: Z works properly! It's just that as soon as objects are too near (no collision necessary), the mapper screws up and they get created only a few cm above the object underneath and not at the original Z position. If there is no collision, it works perfect.

Seems like the ObjectsMapper is screwed.

Edited by mech

Share this post


Link to post
Share on other sites
The result of lots of testing: Z works properly! It's just that as soon as objects are too near (no collision necessary), the mapper screws up and they get created only a few cm above the object underneath and not at the original Z position. If there is no collision, it works perfect.

Seems like the ObjectsMapper is screwed.

I hope a ticket was created.

Share this post


Link to post
Share on other sites

Quick question: When spawning a custom made composition, is there a simple way to setVehicleVarName to a few of the objects?

Background info: I'm working on a mission that randomly spawns bases for players to use, but I need a unique name/variable name for addactions for 4 different infostands. I've considered some options, but can't come up with a working solution. My best option right now looks like just taking the infostands out of the comp, and manually putting them in (createVehicle) based off of the comp's center point, after the base itself has been spawned.

Thanks in advance,

~AF

Share this post


Link to post
Share on other sites

KevsnoTrev,

Is it possible to insert a objecttexture to the init of the object?

Because i'm trying to insert a US flag texture inside the ARMEX sign. The problem i am running into is that it does nothing when i'm using the mapper.

I've read your post about the setvariable thing but i don't understand what you exactly mean by that. Do you have to put the command inside the init of the object or do you have to put this inside the init.sqf?

With kind regards,

StayFrosty24

EDIT:

I've put the next line inside the object:

this setvariable ["init","this setObjectTexture[0,"A3\Data_F\Flags\Flag_us_co.paa"];"]

Edited by StayFrosty24

Share this post


Link to post
Share on other sites

hey frosty,

I think you need to put the code below in the 'init' field for object of the flag.

this setvariable ["init","this setTextureGlobal ..........rest of code here........."]

Share this post


Link to post
Share on other sites

KevsnoTrev,

I've tried that but the grabber doesn't grab it when i paste the clipboard inside a textEditor

EDIT:

There is something wrong with the brackets. I get the error message "Missing ]" when i place this in the object init

this setvariable ["init","this setObjectTexture [0,"A3\Data_F\Flags\Flag_us_co.paa"];"]

Edited by StayFrosty24

Share this post


Link to post
Share on other sites

this setvariable ["init","this setObjectTexture [0,'A3\Data_F\Flags\Flag_us_co.paa'];"]

You have quotes inside a string value so use the single quote ' or use two double quotes ""

If this is for MP I suggest using setObjectTextureGLobal as the flag will only show with the new texture on the server PC or you have to run this code on each clisent when they join.

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

×