Jump to content
Sign in to follow this  
Rough Knight

using createvehicle with mq-9 predator problem.

Recommended Posts

Hi guys,

I am at a loss with this one, however I Am sure there is a solution.

Because createvehicle creates an empty vehicle, I think this makes it nearly impossible to create a flying predator that can then be issued waypoints.

All my attempts have just created an airbourne predator that spirals and crashes. I'll attach some code and if anyone can point me in the correct direction I would appreciate it greatly.

In the 'init' field of my origional mq-9 I have the following:

nul = [this, "mq9spawn", "patrol1", 5] execVM "mq-9_1.sqf"

// mq-9_1.sqf
// Script for generation of MQ-9.

_unit 			= _this select 0;
_spawnpoint 		= _this select 1;
_marker                 = _this select 2;
_delay1                 = _this select 3;

sleep 0.1;

_veh1 = createVehicle ["MQ9PredatorB", getmarkerpos _spawnpoint, [], 0, "FLY"];

_veh1 enableAI "move";

[_veh1] join grpNull;
sleep 0.1;

_veh1 action ["engineOn", _veh1];

_veh1 setdir 45;

nul = [_veh1, _marker, "noslow", "nowait"] execvm "ups.sqf"; 

_veh1 flyInHeight 800;

Thanks

Frosty

Edited by Rough Knight
added some more info

Share this post


Link to post
Share on other sites

psst... no crew.. :)

If you'd like, You can either use my script, or see how I spawn a MQ-9 with crew allready using BIS's spawn vehicle function.

Share this post


Link to post
Share on other sites

Yep, any flying vehicle (even cruise missiles) need a pilot to fly it. :D

Share this post


Link to post
Share on other sites

Thanks guys,

Got it working. Sorry but it defied logic to me to have to spawn a driver and movein driver him to an unmaned drone in order for it to be able to fly:butbut:

PS: I am pretty new to scripting so please excuse any mistakes in the script or improper layout etc.

// Script for generation of MQ-9's and objective control.
// Script by Frosty 04-Oct-09
//In init field of UAV put: nul = [this, x, y, z] execvm "mq-9.sqf" where:
// this = unit, x = marker where new UAV will respawn, y = ups sript marker for uav to patrol, z = spawn delay after unit is obliterated

if (!isServer) exitWith {};

private ["_unit", "_spawnpoint", "_marker", "_spawndelay", "_spawnnow", "_unittype", "_sideHQ", "_a", "_b", "_c", "_d", "_group", "_name1", "_name2", "_Uavpilot", "_veh1"];

_unit 			= _this select 0;
_spawnpoint 		= _this select 1;
_marker                 = _this select 2;
_spawndelay             = _this select 3;

_unittype = typeof _unit;

if (_unittype == "MQ9PredatorB") then {waitUntil {!(alive _unit)}} else {};

_spawnnow = time + _spawndelay;
waitUntil {Time > _spawnnow};

sleep 0.2;

_SideHQ = createCenter Civilian;
Civilian setFriend [West, 1];
Civilian setFriend [East, 1];
_group = createGroup Civilian;

sleep 0.1;

_a = random 20000;
_b = (_a - (_b mod 1));
_c = random 20000;
_d = (_c- (_c mod 1));

_name1 = format["pilot%1", _b];
_name2 = format["uav%1", _d];

sleep 0.5;

_UAVPilot = _group createUnit ["USMC_Soldier_Pilot", getmarkerpos _spawnpoint,[],1,""];
_uavpilot setVehicleInit "_name1 = this";
sleep 0.1;
processInitCommands;

sleep 0.5;

_veh1 = createVehicle ["MQ9PredatorB", getmarkerpos _spawnpoint, [], 0, "FLY"];
_veh1 setVehicleInit "_name2 = this; _UAVPilot moveindriver this; 
		    nul = [_uavpilot, _marker, ""noslow"", ""nowait""] execvm ""ups.sqf""; 
		    nul = [_name2, ""mq9spawn"", _marker, 240] execvM ""mq-9.sqf""; 
		    this setPosATL [(getpos this select 0), (getpos this select 1), (getpos this select 2) +1500];
		    this flyInHeight 1500;
		    this setcaptive true";


sleep 0.1;

processInitCommands;

sleep 0.1;


[_name1] join grpNull;
sleep 0.1;


if (obj2 == 1) then {_name2 flyInHeight 900;} else {_name2 flyInHeight 1500};


Thanks

Frosty

Edited by Rough Knight

Share this post


Link to post
Share on other sites

It's because the driver unit has AI/brains, the vehicle it is in is just a dumb, static object. It's an game engine limitation.

Share this post


Link to post
Share on other sites

Yo Big Daddy,

The purpose of this script was not to use the actual UAV as a interactive device, but to spawn the UAV and then create triggers at certain markers.

If the UAV flys within a set distance of the marker (objectives) then the player gets his map updated with the location of the objectives.

Just a simple concept and the UAV actions are only simulated, but it does what I want it to do : )

I did have to modify the setfriend portion of the script above because it took me ages to figures out why the newly spawned UAV's where crashing. They where basically trying to engage the enemy and turned into stuka dive bombers :mad:

This script may not be usefull to most...but is ok for my kind of mission. Hopefully I will post a beta of the mission in the forum next week.

Thanks

Frosty

Edited by Rough Knight

Share this post


Link to post
Share on other sites

_uavpilot setVehicleInit format ["%1 = this;this disableAI ""AUTOTARGET"" ; this disableAI ""TARGET"" ; this setCombatMode ""BLUE"";this setBehaviour ""careless"";",_name1];

btw, here's the anti divebombing part of being a UAV..

Share this post


Link to post
Share on other sites

Hey Big Daddy,

LOL...cheers mate thats a more sensible way of doing it :)

Thanks

Frosty

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  

×