I wrote the following function:
/*
funcCreateVehicle
Creates the specified vehicle
Syntax:
[
string vehicleType,
position position,
side or group or object (optional),
array of string crewSlots (optional),
array of soldiers unitList (optional)
] call funcCreateVehicle
vehicleType -- the type of vehicle
position -- position of the vehicle
group -- group of the vehicle crew,
if the soldier - will be used his group
if the side - will create a new group by this side
if the other value (eg 0 or "" or "default"), will create a new group
owned by a native vehicle side
crewSlots -- equipment of the crew. А list containing some of the following
values: "commander", "driver", "gunner", "cargo".
unitList -- if present - the units will take the crew one by one from this list
*/
//#include "\lib\common"
#define arg(X) (_this select (X))
#define argIf(X) if(count _this > (X))
#define argIfType(X,T) if(if(count _this > (X))then{typeName arg(X) == (T)}else{false})
#define argSafe(X) argIf(X)then{arg(X)}
#define argSafeType(X,T) argIfType(X,T)then{arg(X)}
#define argOr(X,V) (argSafe(X)else{V})
#define xor(A,B) (!(A && B) && (A || B))
#define inc(N) (call { N = N + 1; N })
#define dec(N) (call { N = N - 1; N })
funcCreateVehicle = {
private [
"_vehicleType", "_position", "_group",
"_crewSlots", "_getNextUnit", "_unitList",
"_unitIndex", "_crewType", "_vehicle", "_topPlace", "_moveIn"
];
_vehicleType = arg(0);
_position = arg(1);
_group = argOr(2, 0) call {
switch ( typeName _this ) do {
case "GROUP" : { _this };
case "OBJECT" : { group _this };
case "SIDE" : { createGroup createCenter _this };
default {
createGroup ( createCenter (
[
east, west, resistance, civilian, nil, enemy, friendly, nil
] select getNumber (
configFile >> "CfgVehicles" >> _vehicleType >> "side"
)
))
}
}
};
// print str _group;
_crewSlots = argSafeType(3, "array")else{
["commander", "driver", "gunner", "cargo"]
};
_getNextUnit = argIf(4)then{
_unitList = arg(4);
_unitIndex = count _unitList;
{ _unitList select dec(_unitIndex) }
}else{
_crewType = getText( configFile >> "CfgVehicles" >> _vehicleType >> "crew" );
{ _group createUnit [_crewType, _position, [], 0, "none"] }
};
_vehicle = _vehicleType createVehicle _position;
{
_topPlace = (_vehicle emptyPositions _x) - 1;
_moveIn = (switch (_x) do {
case "commander" : {{ _this moveInCommander _vehicle }};
case "driver" : {{ _this moveInDriver _vehicle }};
case "gunner" : {{ _this moveInTurret [_vehicle, [_pos]] }};
case "cargo" : {{ _this moveInCargo _vehicle }};
default { player sideChat "error in funcCreateVehicle, cargo type mismatch" }
});
for "_pos" from 0 to _topPlace do {
call _getNextUnit call _moveIn
}
} foreach _crewSlots;
_vehicle
};
Next, I create a Humvee with a crew belonging to the east side:
Humvee = [
'HMMWV50',
getpos player,
east,
["driver", "cargo"]
] call funcCreateVehicle;
Watch that displays a Humvee:
hint str Humvee // displays "EAST 1-1-A:1"
but why then:
hint str side Humvee // displays "WEST"
hint str side driver Humvee // displays "WEST"
Does this mean that there is no ability to create units with a side with not specified in the arma config?
And does this mean that all functionality associated with a flexible choice of the group (in funcCreateVehicle) does not make sense?
any ideas?