Jump to content
Sign in to follow this  
caseymc

Dynamically spawning Arma2 Compositions

Recommended Posts

Gents,

I am trying to enable my persistant server to spawn in and place objects dynamically on server start.

spawn_CampSiteSmall = {
private["_position","_veh","_num","_config","_itemType","_itemChance","_weights","_index","_iArray"];

waitUntil{!isNil "BIS_fnc_selectRandom"};
if (isDedicated) then {
_position = [getMarkerPos "center",0,4000,10,0,2000,0] call BIS_fnc_findSafePos;
diag_log("DEBUG: Spawning a Small Camp Site	at " + str(_position));
_veh = createVehicle ["[b]SmallTentCamp_napa[/b]",_position, [], 0, "CAN_COLLIDE"];
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_veh];
_veh setVariable ["ObjectID",1,true];
dayzFire = [_veh,2,time,false,false];
publicVariable "dayzFire";
if (isServer) then {
	nul=dayzFire spawn BIS_Effects_Burn;
};
_num = round(random 3) + 3;
_config = 		configFile >> "CfgBuildingLoot" >> "CampSiteSmall";
_itemType =		[] + getArray (_config >> "itemType");
//diag_log ("DW_DEBUG: _itemType: " + str(_itemType));	
_itemChance =	[] + getArray (_config >> "itemChance");
//diag_log ("DW_DEBUG: _itemChance: " + str(_itemChance));	
//diag_log ("DW_DEBUG: (isnil fnc_buildWeightedArray): " + str(isnil "fnc_buildWeightedArray"));	

waituntil {!isnil "fnc_buildWeightedArray"};

_weights = [];
_weights = 		[_itemType,_itemChance] call fnc_buildWeightedArray;
//diag_log ("DW_DEBUG: _weights: " + str(_weights));	
for "_x" from 1 to _num do {
	//create loot
	_index = _weights call BIS_fnc_selectRandom;
	sleep 1;
	if (count _itemType > _index) then {
		//diag_log ("DW_DEBUG: " + str(count (_itemType)) + " select " + str(_index));
		_iArray = _itemType select _index;
		_iArray set [2,_position];
		_iArray set [3,5];
		_iArray call spawn_loot;
		_nearby = _position nearObjects ["WeaponHolder",20];
		{
			_x setVariable ["permaLoot",true];
		} forEach _nearBy;
	};
};
};
};

Whenever the server starts, the RPT file reads, "Cannot create non-ai vehicle."

I read in another old thread that the classname was the cause, however http://forums.bistudio.com/showthread.php?122964-Spawning-quot-Compositions-quot States that the name i got is correct.

Any ideas?

Share this post


Link to post
Share on other sites

Yeah... one really good idea. DayZ has it's own forums.... try there mate.

Share this post


Link to post
Share on other sites

I didn't know DayZ used a different scripting language and engine then arma 2. Must have forgot DayZ Mod was its own video game.

The question has everything to do with the scripting syntax

_veh = createVehicle ["SmallTentCamp_napa",_position, [], 0, "CAN_COLLIDE"];

And whether or not Its a valid command to create that composition within mod file itself. ARMA 2 & OA : MISSIONS - Editing & Scripting, I assumed this was the right place to go.

Share this post


Link to post
Share on other sites

Compositions are not a vehicle. Compostions are a bunch of vehicles (objects in arma). You probably get the that error since it cannot find a valid vehicle. To create compositions you have to find it in the config tree, read the data such as classnames, relative positions etc. and createVehicle each thing individually. Fortunately Arma comes with scripts to do this already. For how to do this look here: http://community.bistudio.com/wiki/Dynamic_Object_Compositions

Share this post


Link to post
Share on other sites

Thanks Muzzle for the reply, going to try using that line in place for the one I posted.

Share this post


Link to post
Share on other sites
I didn't know DayZ used a different scripting language and engine then arma 2. Must have forgot DayZ Mod was its own video game.

It does use entirely different objects and scripting and databases and will in fact be it's own game. Both should be "the same" however your "SmallTentCamp_napa" might be something entirely different in DayZ.

If you're doing ANYTHING with regards to DayZ, you need to ask on the DayZ forums since even the most simple of things can break horribly and what works in A2 doesn't always work in DayZ.

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
Sign in to follow this  

×