Jump to content
Sign in to follow this  
toxim

Placing ULB Module via scripting

Recommended Posts

Hey,

I tried to create the ULB module and a AH-6X trough a script.

Well, the script does exactly that, but only once.

For the first time it works like a charm, but:

If the AH-6X gets destroyed, the script recreates both of them, but the action for the ULB is either not visible at all, or just outside the chopper.

Oh wise men of scripting, can you offer your help?

/*
Dynamic ULB Module Script 

Author: -=XTRA=- tox1m

What it does:
Creates an AH-6X, AI pilot to fly it, ULB Module and syncs them together. 
Hopefully MP Dedicated Server compatible.

What it actually does:
The above, but once destoyed and recreated, sync doesnt work from inside the chopper.
*/
private ["_dead","_spos","_run"];

_dead = false;
_spos = getMarkerPos "UAV_Module";
_run = true;

hint "Get in the choppa! Radio command is available to kill the AH-6X"; 		// For debugging
sleep 1;

// Waits until player jumps in the chopper
// "eng16" - Name of the pilot we want  to control the ULB
waitUntil {typeOf (vehicle eng16) == "AH64D_EP1"}; //or typeOf (vehicle eng16) == "AH64D"};

//Creating the ULB stuff
hint "Creating objects";	// For debugging
pilotGroup = createGroup (west);
"US_Soldier_Pilot_EP1"  createUnit [_spos, pilotGroup, "uavpilot = this"]; sleep 0.2;

hunter = createVehicle ["AH6X_EP1", _spos, [], 0, "FLY"]; sleep 0.2;
hunter setpos [getpos hunter select 0, getpos hunter select 1, 50];
hunter engineon true; sleep 0.2;

(units pilotGroup select 0) moveInDriver hunter;
pilotGroup setCombatMode "BLUE";
sleep 0.2;
ulbGroup = createGroup sideLogic;
"UAV_HeliManager" createUnit [_spos, ulbGroup, "BIS_heli_uav_0 = this"];

BIS_heli_uav_0 setvariable ["name","AH-6X"];
BIS_heli_uav_0 setvariable ["unitList",[eng16]];
BIS_heli_uav_0 setvariable ["UAVList",[hunter]];

if (isServer) then 
{
	/*
	 If the player name "eng16" is also here, ULB action only available outside the chopper
	*/
	BIS_heli_uav_0 synchronizeObjectsAdd [ah1, hunter];
};

while {_run} do
{
sleep (2 + random 5);
hintsilent "Checking if AH-6X is alive"; // For debugging
 if ((getDammage hunter > 0.5) and ({alive _x} count crew hunter == 0)) then {_dead = true; hunter setDamage 0.9};

if (_dead) then
{
	hint "AH-6X is damaged, deleting.."; // For debugging
	hunter setDamage 1; 
	sleep 2;
	unassignVehicle hunter;
	deleteVehicle hunter;
	deleteVehicle uavpilot;
	deleteGroup pilotGroup;
	deleteVehicle BIS_heli_uav_0;
	deleteGroup ulbGroup;
	sleep 5.0;

	hint "Recreating ULB stuff"; // For debugging
	pilotGroup = createGroup (west);
	"US_Soldier_Pilot_EP1"  createUnit [_spos, pilotGroup, "uavpilot = this"]; sleep 0.2;

	hunter = createVehicle ["AH6X_EP1", _spos, [], 0, "FLY"]; sleep 0.2;
	hunter setpos [getpos hunter select 0, getpos hunter select 1, 50];
	hunter engineon true; sleep 0.2;

	(units pilotGroup select 0) moveInDriver hunter;
	pilotGroup setCombatMode "BLUE";
	sleep 0.2;
	ulbGroup = createGroup sideLogic;
	"UAV_HeliManager" createUnit [_spos, ulbGroup, "BIS_heli_uav_0 = this"];

	BIS_heli_uav_0 setvariable ["name","AH-6X"];
	BIS_heli_uav_0 setvariable ["unitList",[eng16]];
	BIS_heli_uav_0 setvariable ["UAVList",[hunter]];

	if (isServer) then 
	{
		/*
		Player name "eng16" not here, and yet the ULB is only available from outside of the chopper...
		And sometimes the old action for the destroyed chopper is still visible!!!...
		*/
		BIS_heli_uav_0 synchronizeObjectsAdd [ah1, hunter];
	};
	hint "Done with recreating."; // For debugging
	_dead = false;
};
};

Here is a test mission to see it in action:

http://www.sendspace.com/file/59ytqp

Share this post


Link to post
Share on other sites

Bump - I'm interested in a soloution to this too..

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  

×