Jump to content
Sign in to follow this  
pawelkpl

spawnvehicle script does not work in advanced flight model / heli crashes into ground

Recommended Posts

Hi All,

I have a problem with a script since advanced flight model was introduced. Simply AI and vehicle spawns ok but it does not fly even if "FLY" option is added. Heli spawns and AI turns engines on but there is not enough time to do that and heli crashes into ground. any help ? the code line looks like that:

_veh = createVehicle [_typev1, _posv1, [], 0, "FLY"];

regards;

pawel

Share this post


Link to post
Share on other sites

I'm not sure about the advanced flight model, but I'm pretty sure there are no AI in your chopper. An easy way to tell is that a helicopter with no pilot slowly tips downward and to the right, until it eventually crashes. I'm pretty sure it was specifically programmed this way. (it was pretty "funny" when players would take all your helicopters in a mission in arma 2, fly up, click autohover and eject. sarcasm, of course, it wasn't funny at all.)

Anyway where I'm getting with this is createVehicle only spawns an empty vehicle. You probably actually need AI in your helicopter. Luckily, this is very easy to do. Put this after your createVehicle:

createVehicleCrew _myCustomVehicle;

You could also use BIS_fnc_spawnVehicle; <--click that.

Hope that helps

Share this post


Link to post
Share on other sites
I'm not sure about the advanced flight model, but I'm pretty sure there are no AI in your chopper. An easy way to tell is that a helicopter with no pilot slowly tips downward and to the right, until it eventually crashes. I'm pretty sure it was specifically programmed this way. (it was pretty "funny" when players would take all your helicopters in a mission in arma 2, fly up, click autohover and eject. sarcasm, of course, it wasn't funny at all.)

Anyway where I'm getting with this is createVehicle only spawns an empty vehicle. You probably actually need AI in your helicopter. Luckily, this is very easy to do. Put this after your createVehicle:

createVehicleCrew _myCustomVehicle;

You could also use BIS_fnc_spawnVehicle; <--click that.

Hope that helps

Thank you for your reply but it spawns with crew inside, THEY start engines on but it takes time to do so. I will make short movie clip soon and give link to show how it looks like. Below you can find whole script:

#define THIS_FILE "fn_spawnvehicle.sqf"

#include "x_setup.sqf"

/*

File: spawnVehicle.sqf

Author: Joris-Jan van 't Land

Description:

Function to spawn a certain vehicle type with all crew (including turrets).

The vehicle can either become part of an existing group or create a new group.

Parameter(s):

_this select 0: desired position (Array).

_this select 1: desired azimuth (Number).

_this select 2: type of the vehicle (String).

_this select 3: side or existing group (Side or Group).

Returns:

Array:

0: new vehicle (Object).

1: all crew (Array of Objects).

2: vehicle's group (Group).

*/

private ["_posv1", "_azi", "_typev1", "_param4", "_grp", "_side", "_newGrp"];

PARAMS_4(_posv1,_azi,_typev1,_param4);

if (typeName _param4 == "SIDE") then {

_side = _param4;

_grp = [_side] call FUNC(creategroup);

_newGrp = true;

} else {

_grp = _param4;

_side = side _grp;

_newGrp = false;

};

private ["_sim", "_veh", "_crew"];

_sim = toUpper getText(configFile/"CfgVehicles"/_typev1/"simulation");

if (_sim in ["AIRPLANE", "HELICOPTER", "AIRPLANEX", "HELICOPTERX"]) then {

if (count _posv1 == 2) then {_posv1 set [count _posv1, 0]};

_posv1 set [2, (_posv1 select 2) max 200];

_veh = createVehicle [_typev1, _posv1, [], 0, "FLY"];

if (_sim == "AIRPLANEX" || {_sim == "AIRPLANE"}) then {

_veh setVelocity [100 * (sin _azi), 100 * (cos _azi), 0];

};

} else {

_veh = createVehicle [_typev1, _posv1, [], 0, "NONE"];

_svec = sizeOf _typev1;

_isFlat = (position _veh) isFlatEmpty [_svec / 2, 150, 0.7, _svec, 0, false, _veh];

if (count _isFlat > 1) then {

_posv1 = _isFlat;

_posv1 set [2, 0];

};

if (random 100 > 50) then {_veh allowCrewInImmobile true};

};

_veh setDir _azi;

_veh setPos _posv1;

_crew = [_veh, _grp] call FUNC(spawnCrew);

_grp addVehicle _veh;

if (_newGrp) then {_grp selectLeader (commander _veh)};

[_veh, _crew, _grp]

Edited by PawelKPL

Share this post


Link to post
Share on other sites

It is domi script and It worked OK before AFM was introduced. thx.

Share this post


Link to post
Share on other sites

thx to all, problems solved. BI has changed vehiclescfg/simulation and I had to update script with new cfgvehicles.

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  

×