2015-09-01 21:24:15 +00:00
|
|
|
/*
|
2015-09-05 03:40:00 +00:00
|
|
|
DMS_fnc_SpawnNonPersistentVehicle
|
2015-09-01 21:29:46 +00:00
|
|
|
|
2015-09-02 00:43:17 +00:00
|
|
|
Spawn a non-saved vehicle in Exile
|
2015-09-01 21:29:46 +00:00
|
|
|
|
2015-09-01 21:24:15 +00:00
|
|
|
Created by Zupa
|
2015-09-02 00:43:17 +00:00
|
|
|
Edited by eraser1
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
[
|
|
|
|
_vehicleClass, // STRING: Classname of the vehicle
|
|
|
|
_pos // ARRAY: Position to spawn it at (roughly)
|
2015-09-05 03:40:00 +00:00
|
|
|
] call DMS_fnc_SpawnNonPersistentVehicle;
|
2015-09-02 00:43:17 +00:00
|
|
|
|
|
|
|
Returns the vehicle object of the created vehicle.
|
|
|
|
|
2015-09-02 05:18:26 +00:00
|
|
|
EXAMPLE:
|
2015-09-05 03:40:00 +00:00
|
|
|
_exampleVeh = ['Exile_Chopper_Hummingbird_Green',_pos] call DMS_fnc_SpawnNonPersistentVehicle;
|
2015-09-02 05:18:26 +00:00
|
|
|
|
2015-09-01 21:24:15 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
private ["_vehicleClass","_position","_vehpos","_maxDistance","_vehObj"];
|
|
|
|
|
2015-09-02 00:43:17 +00:00
|
|
|
_OK = params
|
|
|
|
[
|
|
|
|
["_vehicleClass","",[""]],
|
|
|
|
["_position","",[[]],[2,3]]
|
|
|
|
];
|
|
|
|
|
|
|
|
if (!_OK) exitWith
|
|
|
|
{
|
|
|
|
diag_log format ["DMS ERROR :: Calling DMS_SpawnNonPersistentVehicle with invalid parameters: %1",_this];
|
|
|
|
};
|
|
|
|
|
2015-09-01 21:24:15 +00:00
|
|
|
_vehpos = [];
|
2015-09-02 00:43:17 +00:00
|
|
|
_maxDistance = 10;
|
2015-09-01 21:24:15 +00:00
|
|
|
|
2015-09-02 00:43:17 +00:00
|
|
|
while{count _vehpos < 1} do
|
|
|
|
{
|
|
|
|
_vehpos = _position findEmptyPosition [20,_maxDistance,_vehicleClass];
|
2015-09-18 23:26:36 +00:00
|
|
|
_maxDistance = (_maxDistance + 5);
|
2015-09-01 21:24:15 +00:00
|
|
|
};
|
|
|
|
|
2015-09-18 23:26:36 +00:00
|
|
|
_vehpos set [2, 0.1];
|
|
|
|
|
|
|
|
_vehObj = createVehicle [_vehicleClass, _vehpos, [], 0, "CAN_COLLIDE"];
|
|
|
|
|
|
|
|
clearBackpackCargoGlobal _vehObj;
|
|
|
|
clearItemCargoGlobal _vehObj;
|
|
|
|
clearMagazineCargoGlobal _vehObj;
|
|
|
|
clearWeaponCargoGlobal _vehObj;
|
|
|
|
|
|
|
|
_vehObj setFuel (0.75+(random 0.25));
|
|
|
|
_vehObj setDir (random 360);
|
|
|
|
_vehObj setPosATL _vehpos;
|
2015-09-17 03:37:17 +00:00
|
|
|
_vehObj setVectorUp (surfaceNormal _vehpos);
|
2015-09-02 00:43:17 +00:00
|
|
|
|
2015-09-21 04:42:33 +00:00
|
|
|
_vehObj setVariable ["ExileIsPersistent", false];
|
|
|
|
_vehObj addEventHandler ["GetIn", { _this call ExileServer_object_vehicle_event_onGetIn}];
|
|
|
|
if (_vehObj isKindOf "Helicopter") then
|
|
|
|
{
|
|
|
|
_vehObj addEventHandler ["RopeAttach",
|
|
|
|
{
|
|
|
|
private "_vehicle";
|
|
|
|
_vehicle = _this select 2;
|
|
|
|
|
|
|
|
if !(simulationEnabled _vehicle) then
|
|
|
|
{
|
|
|
|
_vehicle enableSimulationGlobal true;
|
|
|
|
};
|
|
|
|
}];
|
|
|
|
};
|
|
|
|
|
2015-09-20 05:37:13 +00:00
|
|
|
if (!isNil "RS_VLS") then
|
|
|
|
{
|
2015-09-28 16:53:57 +00:00
|
|
|
[_vehObj] call RS_VLS_sanitizeVehicle;
|
2015-09-20 05:37:13 +00:00
|
|
|
};
|
|
|
|
|
2015-09-18 23:26:36 +00:00
|
|
|
_vehObj lock 2;
|
|
|
|
_vehObj allowDamage false;
|
|
|
|
_vehObj enableRopeAttach false;
|
|
|
|
_vehObj enableSimulationGlobal false;
|
|
|
|
|
2015-09-02 00:43:17 +00:00
|
|
|
if (DMS_DEBUG) then
|
|
|
|
{
|
|
|
|
diag_log format ["DMS_DEBUG SpawnNonPersistentVehicle :: Created %1 at %2 with calling parameters: %3",_vehObj,_vehpos,_this];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-09-28 16:53:57 +00:00
|
|
|
_vehObj
|