Jump to content
Sign in to follow this  
Luft08

My code is doo-doo. Please help!

Recommended Posts

I'm building a WW2 mission that requires I spawn in many vehicles. However, my half-tracks keep blowing up on spawn. Here's the code: 

 

Starts in initServer.sqf:

enableTeamSwitch true;
_handle = [] execVM "initVariables.sqf";
_handle = [] execVM "launchAttack.sqf";

Here's launchAttack.sqf:

_index = floor(random scenarioCount);
switch (_index) do {
	case 0: {
		_handle = [] execVM "fullBlitz.sqf";
	};
};

Here's fullBlitz.sqf:

_airIntensity = floor(random 10);
_halfTrackIntensity = floor(random 10);
_infantryGroupSize = floor(random 10);
_infantryIntensity = floor(random 5) + 5;

for "_i" from 0 to _halfTrackIntensity do {
	sleep 1;
	_handle = [] execVM "createHalfTracks.sqf";
};

sleep 60;


_handle = [_infantryIntensity, _infantryGroupSize] execVM "createInfantry.sqf";



for "_i" from 0 to _airIntensity do {
	_handle = [] execVM "createGermanAir.sqf";
	sleep 10;
};

sleep 360;

{
	_group = _x select 2;
	_destination = [19321.066, 8757.297, 310];
	deleteWaypoint [_group, 0];
	_wp = _group addWaypoint [_destination, 0];
	_wp setWaypointStatements ["true", "[_group] execVM 'this deleteVehicle';"];
} forEach enemyPlaneArray;
enemyPlaneArray deleteRange [0, count enemyPlaneArray];

Here's createHalfTracks.sqf:

if(isServer) then {
	_halfTrack_0 = "fow_v_sdkfz_250_ger_heer";
	_htGroupArray = [
				[

					[[15490.81, 8683.686, 3], 271.019],
					[[15501.603, 8669.106, 3], 271.019],
					[[15507.169, 8655.836, 3], 271.019],
					[[15514.855, 8640.385, 3], 271.019],
					[[15384.432, 8882.292, 3], 271.019],
					[[15376.535, 8943.688, 3], 271.019],
					[[15379.956, 8981.656, 3], 271.019]
				]
		];

	_groupNum = floor(random count _htGroupArray);
	_groupArray = _htGroupArray select _groupNum;
	
	{
		_target = selectRandom ["wp_0", "wp_1", "wp_2", "wp_3", "wp_4", "wp_5", "wp_6", "wp_7", "wp_8", "wp_9"];
		_pos = _x select 0;
		_position = _pos findEmptyPosition [0,300, _halfTrack_0];
		_dir = _x select 1;
		_vehArray = [_position, _dir, _halfTrack_0, east] call BIS_fnc_spawnVehicle;
		_vehArray params ["_vehicle", "_crew", "_group"];
		_veh = _vehArray select 0;
		_handle = [_veh, _target] execVM "attackArea.sqf";
		sleep 5;	
	} forEach _groupArray;	
};

The sleep command isn't working even though the method is being called though an execVM (scheduled environment).

This is really frustrating!

Share this post


Link to post
Share on other sites

The createHalfTrack.sqf code really is doo-doo. I don't know what I was thinking with the forEach loop. Let me work with it and I'll post again if I still have trouble.

 

Thanks.

Share this post


Link to post
Share on other sites

Okay, same complaint...

Here's my reworked createHalfTrack.sqf:

if(isServer) then {
	_halfTrack_0 = "fow_v_sdkfz_250_ger_heer";
	_htGroupArray = [
				[[15490.81, 8683.686, 0], 271.019],
				[[15501.603, 8669.106, 0], 271.019],
				[[15507.169, 8655.836, 0], 271.019],
				[[15514.855, 8640.385, 0], 271.019],
				[[15384.432, 8882.292, 0], 271.019],
				[[15376.535, 8943.688, 0], 271.019],
				[[15379.956, 8981.656, 0], 271.019]
		];

	_groupNum = floor(random count _htGroupArray);
	_groupArray = _htGroupArray select _groupNum;
	_target = selectRandom ["wp_0", "wp_1", "wp_2", "wp_3", "wp_4", "wp_5", "wp_6", "wp_7", "wp_8", "wp_9"];
	_pos = _groupArray select 0;
	_position = _pos findEmptyPosition [0,300, _halfTrack_0];
	_dir = _groupArray select 1;
	_vehArray = [_position, _dir, _halfTrack_0, east] call BIS_fnc_spawnVehicle;
	_vehArray params ["_vehicle", "_crew", "_group"];
	_veh = _vehArray select 0;
	_handle = [_veh, _target] execVM "attackArea.sqf";
	sleep 5;	

};

My halftracks keep spawning on top of one another and blowing up...

Share this post


Link to post
Share on other sites

Whoo-Hoo, I think I figured it out!

 

My sleep 5; shouldn't be in the createHalfTrack.sqf file, it needs to be in the fullBlitz.sqf file. I changed the sleep 1; to sleep 5; in that file and no more kabooms! It gives time for the halftracks to move out of the way.

 

Sorry for the junk thread.

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  

×