Jump to content

Recommended Posts

Hi,
I have a gun store as well as a vehicle store that were made in VR so that everything is flat which I plan to use on other terrains. It will be created via code, etc... The problem is, the compositions are very complex (in terms of how they are made) and they use vectors and all that. The BIS composition functions does this but it doesn't take these things (vector, etc) into account. The only thing I can think of is to create some function that copies position, simulation, vectors, etc. Or modify the BIS composition functions? I am looking for advice and ideas for the best approach.
This is the vehicle store (you'll see what I mean by complex)
https://imgur.com/a/RLV7I

Here are some images from gun store that will give you an idea of what the issue is:

https://imgur.com/a/ZLbvF

  • Like 1

Share this post


Link to post
Share on other sites

*edit* - NVM, wasn't thinking clearly about the question.

Share this post


Link to post
Share on other sites

Last reply... Was busy and kinda forgot about it. Though I will still need to figure this out eventually. I tried Eden Composition Spawning by @Larrow - no joy. Maybe my base composition is just too complex? :down:

Share this post


Link to post
Share on other sites

@avibird 1 - Ah. Got you. You mentioned vehicle/gun script which confused me ha. :grinning:

  • Haha 1

Share this post


Link to post
Share on other sites

Bump. I still need help with this. Any ideas?

Share this post


Link to post
Share on other sites

I've been using this  Eden Composition Spawning for the last couple of days and it seems to working quite well mixed in with a random spawn script i use.

 

Did you save the composition with a name then copy it into your mission folder? 

Did you add the name of your composition into the composition.cfg file that came with  Eden Composition Spawning?

 

ill copy one of mine here.

composition.cfg

 

LARs_spawnComp_debug = 1;

 

class CfgCompositions

{

        class Ant { #include "ant.sqe" };

        class Mort_1 { #include "Mort_1.sqe" };

        class Bandit_Camp_1 { #include "Bandit_Camp_1.sqe" };

        class Civilian_Camp_1 { #include "Civilian_Camp_1.sqe" };

};

 

I also removed all of his compositions and addActions. Then i used this code in sqf to spawn it

 

Civilian_Camp_1.sqf

 

pos = [] call BIS_fnc_randomPos;

 

_Civilian_Camp_1 = "Land_HelipadEmpty_F" createVehicle pos;

_randPos = _Civilian_Camp_1 getRelPos [0,0];

["Civilian_Camp_1", _randPos, [0,0,0], random 360, true] call LARs_fnc_spawnComp;

 

_marker = createMarker ["Civilian_Camp_1",getPos _Civilian_Camp_1];

_marker setMarkerType "mil_dot"; _marker setMarkerSize [1,1];

_marker setMarkerColor "ColorBlack";

_marker setMarkerText "Civilian Camp 1";

 

Added 

execVM "Scripts\RndComps\Civilian_Camp_1.sqf";

into my initServer.sqf to spawn it.

 

The Eden Composition Spawning will only work on a server. It will not work in singleplayer.

I only make mission for myself to play and make them mp for respawning. I just set them to 1 player.

 

My Civ Camp is a shanty town with alot in it. How are you doing it? maybe you have missed something

Share this post


Link to post
Share on other sites

@Chuc - I tried it already. Setup wasn't the issue. It works but for the two complex compositions I have, not so well. See pics in first post. There is a lot of detail and vectors, and what not. It spawned it but a lot of out of place stuff and also unlevel, etc...

Share this post


Link to post
Share on other sites

This is my own, was originally for decorating houses but worked well with a lot of objs with diff dir/vectors/objs on tables etc

Edited a bit for you to use but only uses simple objects so some checks might be needed for more advanced use.

This is basically what you describe in your first post without the check for sim.

I know all the worldpos and attaching detaching looks weird but I tested a lot. Building in VR and then spawning on diff terrains at diff elevations and such

This is the only way I could get it to work every time but maybe you can figure something I couldn't.
Can't test the edit right now so hopefully no stupid syntax errors.

Spoiler

/*
Place dummy object (currently red arrow "Sign_Arrow_F" but can be changed as long as it's not used again in composition)
dummy objects should be close to what will be the center of the composition, make sure height is 0
dummy object needs to be 2x the _dist variable away from eachother
name the dummy object in editor ex vehicleTraderComp
currently code grabs all objects withing 50m so the dummys need to be over 100m apart
build composition within _dist of the dummy
Play in editor and run following code in console
*/
_dummyObjClass = "Sign_Arrow_F";
_dist = 50;
_comps = [];
_allMObjects =allMissionObjects "All";
{

	if ((typeOf _x) isEqualTo _dummyObjClass) then
	{
		_tempH = createVehicle["Land_HelipadEmpty_F",[0,0,0],[],0,"can_collide"];
		_tempH setDir(getDir _x);
		_tempH setPosATL(getPosATL _x);
		_objs = [];
		_dummy = _x;
		_nearObj = nearestObjects [getPosATL _dummy, ["All"], _dist];
		{
			_class = typeOf _x;
			_plrClass = typeOf player;
			_blListClasses = ["Land_HelipadEmpty_F",_dummyObjClass,_plrClass];
			if !(_class in _blListClasses) then
			{
				_objPos = getPosWorld _x;
				_dummyPos = getPosWorld _tempH;
				_objZ = _objPos select 2;
				_dummyZ = _dummyPos select 2;
				_relZ = _objZ - _dummyZ;
				_relPos = _tempH worldToModel _objPos;
				_relPos set [2,_relZ];
				_relDir = getDir _x;
				_vector = vectorUp _x;
				_array = [_class,_relPos,_relDir,_vector];
				systemChat format ["%1 %2 %3", _objZ,_relPos,_relZ];
				_objs pushBack _array;
			};
		} forEach _nearObj;
	_comps pushBack [vehicleVarName _dummy,_objs];
	};
} forEach _allMObjects;
copyToClipboard str _comps;
// past copied info into text editor, will be used in next fnc that spawns
// Next code called in init of object at desired location (for testing)
this spawn
{
		_tempH=createVehicle["Land_HelipadEmpty_F",[0,0,0],[],0,"can_collide"];
		_tempH setDir(getDir _this);
		_tempH setPosATL(getPosATL _this);
	{
		_x params ["_objClass","_modelPos","_dir","_vector"];
		_obj = createSimpleObject [_objClass,[0,0,0]];
		_obj attachTo[_tempH,_modelPos];
		_obj setDir _dir;
		_obj setVectorUp _vector;
		_dirNew = _dir - (getDir _this);
		detach _obj;
		_obj setDir _dirNew;
	} forEach  ; // add array of objects ex.
	/*
	[["Land_CashDesk_F",[-1.28955,0.52832,0.2772],180.588,[0,0,1]],
	["Land_CashDesk_F",[-2.91504,0.54126,0.2772],180.588,[0,0,1]],
	["Land_ShelvesWooden_blue_F",[1.62939,2.40625,0.765773],0,[0,0,1]]]
	*/
deleteVehicle _tempH;
};

 

 

Edited by soolie
  • Like 1

Share this post


Link to post
Share on other sites

@soolie - Thank you! I'll test it now and get back to you.

Share this post


Link to post
Share on other sites

was re-reading and missed something - copyToClipboard str _houses;  _houses should be _comps now
copyToClipboard str _comps; 

Sorry!

  • Like 1

Share this post


Link to post
Share on other sites

Hehe. No worries. That was the first thing I saw and changed. Few errors in the spawning part. I can work with this. Needed to re-write the spawning part anyway. Thank you! @soolie

Not tested on other terrains yet. Will let you know how that goes when I do the spawning part.

  • Like 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

×