Jump to content
Leopard20

Getting all "sub-objects" of a certain static object (e.g USS Freedom)

Recommended Posts

Hey everyone.

As you know, due to certain limits in Arma, when you want to create a large object (such as carriers, e.g. USS Freedom) you'll have to break it into several small objects.
 

Is there any vanilla command to get the sub-objects once you have spawned the parent object? (as in returning all of them in an array, and I don't mean the "near(est)Object(s)" command)

I already know one way to find the objects connected to each other using lineIntersectsSurfaces but the thing is I'm not sure if this sub-object actually belongs to the parent object.

P.S: Note that the USS Freedom is just an example. I need a general solution.

Share this post


Link to post
Share on other sites
11 hours ago, Leopard20 said:

Is there any vanilla command to get the sub-objects once you have spawned the parent object?

Only sure way is as per the jets aircraft carrier does it, which has all the parts that make up the ship included in its config, on the initial/placeable piece....

Spoiler

multiStructureParts[]=
{
	{
		"Land_Carrier_01_hull_01_F",
		"pos_hull_1"
	},
	
	{
		"Land_Carrier_01_hull_02_F",
		"pos_hull_2"
	},
		
	{
		"Land_Carrier_01_hull_03_1_F",
		"pos_hull_3_1"
	},
		
	{
		"Land_Carrier_01_hull_03_2_F",
		"pos_hull_3_2"
	},
			
	{
		"Land_Carrier_01_hull_04_1_F",
		"pos_hull_4_1"
	},
		
	{
		"Land_Carrier_01_hull_04_2_F",
		"pos_hull_4_2"
	},
	
	{
		"Land_Carrier_01_hull_05_1_F",
		"pos_hull_5_1"
	},
	
	{
		"Land_Carrier_01_hull_05_2_F",
		"pos_hull_5_2"
	},
		
	{
		"Land_Carrier_01_hull_06_1_F",
		"pos_hull_6_1"
	},
	
	{
		"Land_Carrier_01_hull_06_2_F",
		"pos_hull_6_2"
	},
	
	{
		"Land_Carrier_01_hull_07_1_F",
		"pos_hull_7_1"
	},
	
	{
		"Land_Carrier_01_hull_07_2_F",
		"pos_hull_7_2"
	},
	
	{
		"Land_Carrier_01_hull_08_1_F",
		"pos_hull_8_1"
	},
	
	{
		"Land_Carrier_01_hull_08_2_F",
		"pos_hull_8_2"
	},
	
	{
		"Land_Carrier_01_hull_09_1_F",
		"pos_hull_9_1"
	},
	
	{
		"Land_Carrier_01_hull_09_2_F",
		"pos_hull_9_2"
	},
	
	{
		"Land_Carrier_01_island_01_F",
		"pos_island_1"
	},
	
	{
		"Land_Carrier_01_island_02_F",
		"pos_island_2"
	},
	
	{
		"Land_Carrier_01_island_03_F",
		"pos_island_3"
	},
	
	{
		"DynamicAirport_01_F",
		"pos_Airport"
	}
};

 

...When you place the initial part the above data is used to spawn all the related parts in the correct position (BIS_fnc_carrier01Init OR BIS_fnc_carrier01EdenInit in the editor).

Spoiler

class Eventhandlers
{
	init="_this call BIS_fnc_Carrier01Init;";
	attributesChanged3DEN="_this call BIS_fnc_Carrier01PosUpdate;";
	dragged3DEN="_this call BIS_fnc_Carrier01PosUpdate;";
	registeredToWorld3DEN="_this call BIS_fnc_Carrier01EdenInit;";
	unregisteredFromWorld3DEN="_this call BIS_fnc_Carrier01EdenDelete;";
};

 

The initial part is then given a variable holding a reference to all the pieces spawned.

Spoiler

private _carrierBase = param [0, objNull];
private _carrierDir = getDir _carrierBase;
private _carrierPos = getPosWorld _carrierBase;

private _carrierPitchBank = _carrierBase call bis_fnc_getPitchBank;
_carrierPitchBank params [["_carrierPitch",0],["_carrierBank",0]];

private _cfgVehicles = configFile >> "CfgVehicles";
private _carrierParts = (_cfgVehicles >> typeOf _carrierBase >> "multiStructureParts") call bis_fnc_getCfgData;
private _carrierPartsArray = [];

//create and assemble the carrier on server
if (isServer) then
{
	private ["_dummy","_dummyClassName","_carrierPartPos"];

	{
		_dummyClassName = _x select 0;
		_dummy = createVehicle [_dummyClassName, _carrierPos, [], _carrierDir, "CAN_COLLIDE"];

		_dummy setDir _carrierDir;
		[_dummy, _carrierPitch, _carrierBank] call bis_fnc_setPitchBank;
		_carrierPartPos = _carrierBase modelToWorldWorld (_carrierBase selectionPosition (_x select 1));
		_dummy setPosWorld _carrierPartPos;
		_carrierPartsArray pushBack [_dummy,_x select 1];
		_dummy allowDamage false;
	}
	foreach _carrierParts;

	_carrierBase setVariable ["bis_carrierParts", _carrierPartsArray, true]; //Set variable on base with references to all spawned parts
};

 

Then its as easy as referencing this variable to get all the parts.

 

  • Thanks 1

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

×