Jump to content
Sign in to follow this  
champ-1

Creating Custom Vehicle Crew

Recommended Posts

Here is the deal, I wan't to fill vehicle with crew, but regular "createVehicleCrew" command wouldn't do it for me. Because, in my case, crew could be from another fraction than vehicle itself. Also it will be a random vehicle, so I couldn't just write some standart commands for that, since I don't even know if there is that kind of seat in that random vehicle.

How do I create a custom crew like that?

I'm thinking I could create standart crew for that vehicle, get all positions occupied by that crew, delete standart crew and move new units in that positions. But I have very general understanding how to do that, especially when it comes to vehicle's turrets.

Any help, guys?

Edited by Champ-1

Share this post


Link to post
Share on other sites

First you place an empty vehicle in the editor.

For example, place one MI-48 Kajman and name it: Heli1

Place one Bluefor helicopterpilot, and put this in his initfield:

this moveInDriver Heli1;

Place one Bluefor helicopterpilot, and out this in his initfield:

this moveInGunner Heli1

Now you have one MI-48 Kajman piloted by Bluefor.

Share this post


Link to post
Share on other sites

What about turret path, what do you know about that?

---------- Post added at 16:23 ---------- Previous post was at 16:15 ----------

Also, imagine I don't know which vehicle I'm filling with crew. It has to be universal solution.

Share this post


Link to post
Share on other sites

I'll use the Ghosthawk for this example.

Place an empty Ghosthawk and name it Heli1.

Place an Opfor helicopterpilot and put this in his initfield:

this moveInDriver Heli1;

Place an Opfor helicopterpilot and put this in his initfield, to put him in the co-pilotseat:

this moveInTurret [Heli1,[0]]

Place an Opfor helicoptcrew and put this in his initfield, to put him in the left-gunnerseat:

this moveInTurret [Heli1,[1]]

Place an Opfor helicoptcrew and put this in his initfield, to put him in the right-gunnerseat:

this moveInTurret [Heli1,[2]]

Share this post


Link to post
Share on other sites

Thanks for your contribution, Rhino. But this isn't exactly what I'm looking for. :)

Share this post


Link to post
Share on other sites

And what do you need?

kill the crew

{_x setdammage 1} forEach crew heli1

place a new unit on map and move ths unit into the helicopter.

Share this post


Link to post
Share on other sites
Also, imagine I don't know which vehicle I'm filling with crew. It has to be universal solution.

I believe all vehicles use the moveInDriver, to place a unit in its driverseat.

Copilot for all vehicles use moveInTurret [vehiclename,[0]].

Vehicles with gunnerseats like the Ghosthawk, will also use the moveInTurret [vehiclename,[1]], however the turretpath will most likely be the next number.

Share this post


Link to post
Share on other sites

It will be a random vehicle, created by script. So I can't just write some standart commands for that, since I don't even know if there is that kind of seat in that random vehicle.

That's why I have troubles with it, guys.

---------- Post added at 16:43 ---------- Previous post was at 16:40 ----------

I believe all vehicles use the moveInDriver, to place a unit in its driverseat.

Copilot for all vehicles use moveInTurret [vehiclename,[0]].

Vehicles with gunnerseats like the Ghosthawk, will also use the moveInTurret [vehiclename,[1]], however the turretpath will most likely be the next number.

I don't think there is any kind of pattern for the turret path. It can be a number or even combination of two numbers. And I don't know how to get them.

Share this post


Link to post
Share on other sites

I use blocks that look something like this, for said task:

The below will spawn a random vehicle from VEH_TYPE array, and fill the crew seats with the given units.

#define VEH_TYPE "O_MBT_02_cannon_F","O_APC_Tracked_02_cannon_F","O_APC_Wheeled_02_rcws_F","O_APC_Tracked_02_cannon_F","I_APC_Wheeled_03_cannon_F","I_APC_tracked_03_cannon_F","I_MBT_03_cannon_F"

_vehGroup = createGroup east;
_randomPos = [[[_pos, 100],[]],["water","out"]] call BIS_fnc_randomPos;
_veh = createVehicle [[VEH_TYPE] call BIS_fnc_selectRandom,_randomPos,[],0,"NONE"];
waitUntil{!isNull _veh};

"O_engineer_F" createUnit [_randomPos,_vehGroup];
"O_engineer_F" createUnit [_randomPos,_vehGroup];
"O_engineer_F" createUnit [_randomPos,_vehGroup];
((units _vehGroup) select 0) assignAsDriver _veh;
((units _vehGroup) select 0) moveInDriver _veh;
((units _vehGroup) select 1) assignAsGunner _veh;
((units _vehGroup) select 1) moveInGunner _veh;
((units _vehGroup) select 2) assignAsCommander _veh;
((units _vehGroup) select 2) moveInCommander _veh;

Edited by MDCCLXXVI

Share this post


Link to post
Share on other sites
I use blocks that look something like this, for said task:

The below will spawn a random vehicle from VEH_TYPE array, and fill the crew seats with the given units.

Some positions don't have names like "gunner", "driver", etc. They are so called "turrets".

Anyway, thanks guys, I found the solution. A little bit of search gives results as always.

Here's my function, using code from KK's function:

CH_fnc_spawnVehWithCrew = {	
private ["_turts_arr","_trts","_veh_type","_unit_type","_pos","_special","_side","_veh","_center","_group"];
_veh_type = _this select 0;
_unit_type = _this select 1;
_pos = _this select 2;
_special = _this select 3;
_side = _this select 4;

_turts_arr = [];
_trts = configFile / "CfgVehicles" / _veh_type / "Turrets";
for "_i" from 0 to count _trts - 1 do {
	_turts_arr set [count _turts_arr, [_i]];
	for "_j" from 0 to count (
		_trts / configName (_trts select _i) / "Turrets"
	) - 1 do {
		_turts_arr set [count _turts_arr, [_i, _j]];
	};
};

_veh = createVehicle [_veh_type, _pos, [], 0, _special];
createVehicleCrew _veh;

_center = createCenter _side;
_group = createGroup _side;	

if (driver _veh != objNull && group driver _veh != _group) then {
	_unit = driver _veh;
	deleteVehicle _unit;
	_unit = _group createUnit [_unit_type, [0,0,0], [], 0, "NONE"];
	_unit moveInDriver _veh;
};
if (gunner _veh != objNull && group gunner _veh != _group) then {
	_unit = gunner _veh;
	deleteVehicle _unit;
	_unit = _group createUnit [_unit_type, [0,0,0], [], 0, "NONE"];
	_unit moveInGunner _veh;
};
if (commander _veh != objNull && group commander _veh != _group) then {
	_unit = commander _veh;
	deleteVehicle _unit;
	_unit = _group createUnit [_unit_type, [0,0,0], [], 0, "NONE"];
	_unit moveInCommander _veh;
};
{
	_unit = _veh turretUnit _x;
	if (_unit != objNull && group _unit != _group) then {
		deleteVehicle _unit;
		_unit = _group createUnit [_unit_type, [0,0,0], [], 0, "NONE"];
		_unit moveInTurret [_veh, _x];
	};
} forEach _turts_arr;
_veh
};

Not tested yet, though.

Edited by Champ-1

Share this post


Link to post
Share on other sites

Thanks for posting this script, it works perfectly, however it also fills the Fire from vehicle Slots.

 

Is there a way to make sure those are not filled while "normal" turret positions are?

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  

×