Jump to content
FlathEarth__Cultist

BIS_fnc_spawnVehicle is not working

Recommended Posts

Im trying to spawn jet with crew (pilot) in air, but "BIS_fnc_spawnVehicle" don't return even empty array, code:

_spawnMarker = selectRandom ["markerSPopforAC2", "markerSPopforAC1", "markerSPopforAC0"];
_enemiesCount = selectRandom [2, 3, 4];
_height = selectRandom [700, 1000, 1250, 1500];

_isSaD = false;
_position = getMarkerPos _spawnMarker;
_position set [2, _height]; //fix height

if(_spawnMarker == "markerSPopforAC2") then {
	_isSad = true;
};

try {
	["Spawning root at: %1 // count: %2 // SaD: %3", _spawnMarker, str _enemiesCount, str _isSad] call fnLog;

	_root = [_position, 180, "O_Plane_CAS_02_F", east] call BIS_fnc_spawnVehicle;
	_rootGroup = _root select 2;
	_rootVehicle = _root select 0;

	["Spawn pos: %1, root: %2", str _position, str root] call fnLog;

	// for [{_i = 0}, {_i < (_enemiesCount - 1)}, {_i = _i + 1}] do {

	// 	_child2DPos = [_position, 100, 500, 0, 1, 0, 0] call BIS_fnc_findSafePos;
	// 	_childFixedPos = [_child2DPos select 0, _child2DPos select 1, _height]; //setup array with missing height

	// 	_child = [_position, 180, "O_Plane_CAS_02_F", east] call BIS_fnc_spawnVehicle;

	// 	//_childCrew IS ARRAY
	// 	_childCrew = _child select 1;

	// 	//take first member of crew (we have only one pilot)
	// 	//and join him to group
	// 	[_childCrew select 0] join _rootGroup;
	// }; 

	_waypointPos = _position;
	_waypointType = "CYCLE";

	// if(_isSaD) then {
	// 	_waypointPos = getMarkerPos "marker_10";
	// 	_waypointType = "SAD";
	// };

	_waypoint = _rootGroup addWaypoint [_waypointPos, 0, 1];
	_waypoint setWaypointType _waypointType;
} catch {
	["Error occured: %1", str _exception] call fnLog;
	hint str _exception;
};

Sample debug output:

Spawning root at: markerSPopforAC0 // count: 4 // SaD: false
Spawn pos: [12715.8,29182.7,1000], root:

I would be thankful for any suggestions.

Share this post


Link to post
Share on other sites
1 hour ago, FlathEarth__Cultist said:

["Spawn pos: %1, root: %2", str _position, str root] call fnLog;

root has to be local: _root

  • Like 1

Share this post


Link to post
Share on other sites

Works fine for me. How are you calling this script? You must remove the comments if you are running from debug.
(7erra's point inclusive)

Share this post


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

You must remove the comments if you are running from debug.

 

I think now days // to comment out a line in debug is ok, but commenting out blocks using /* xxx */ is not. 

Share this post


Link to post
Share on other sites
2 hours ago, beno_83au said:

 

I think now days // to comment out a line in debug is ok, but commenting out blocks using /* xxx */ is not. 

It's either inconsistent, or there is a rule I can't figure out. If I put a comment anywhere in the OP's code, it will not execute and throws a seemingly nonsensical error near the comment location. If I put a comment in a simple vehicle spawn snippet it works fine. If I put a comment in a relatively complex AI debug snippet, it works fine. I am confused.

  • Haha 1

Share this post


Link to post
Share on other sites

It seems to have something to do with error logging. If I remove all logging code, I can comment with no errors. Anyway, this is tangential to the topic, so I'll go bang my head against this brick wall elsewhere.

  • 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

×