DMS_Exile/@ExileServer/addons/a3_dms/scripts/fn_SpawnNonPersistentVehicle.sqf
eraser1 0544cfe9e7 Readme changes, new debug fnc, fixes, tweaks
Created disclaimer for DMS. Now mentioning that HC for DMS isn't that
good.
Some structure stuff in readme (let's see if it works lol)

* **NEW CONFIG VALUE: DMS_Use_Map_Config**
* You can now overwrite "main config values" with map-specific config
values located in the new "map_configs" folder. This should allow you to
use one DMS PBO if you have multiple servers with different maps.
Included examples for Altis, Bornholm, Esseker, and Tavi (Taviana).
* Because of the above implementation, DMS by default will not include
the salt flats blacklist for findSafePos. In addition, it is
preconfigured to the hilly terrains in Esseker and Taviana, as well as
reducing all of the blacklist distances due to the smaller map size in
Esseker.
* Created new function "DMS_fnc_DebugLog". All DMS files (that produced
debug logs) have been changed, including mission files. However,
updating them is not important (and completely pointless if you don't
even use DMS_DEBUG).
* Fixed a few locations where it said "sized" instead of "seized".
Thanks to [icomrade](https://github.com/icomrade) for pointing them out.
* DMS now utilizes the "ARMA_LOG" DLL (if it exists) by infiSTAR to
produce debug logs (if enabled). All debug logs now also include server
uptime (in seconds) and server FPS.
* The FSM no longer produces debug logs.
* AI Locality manager will now run every minute.
* Debug logs for "DMS_fnc_MissionsMonitor" will only output the mission
name and the position, instead of all of the parameters.
* "DMS_fnc_IsNearWater" will now check the provided position itself for
water.
* "DMS_fnc_IsValidPosition" will now do a surfaceNormal check within a 5
meter radius of the provided position as well.
* "_customGearSet" should now actually work for
"DMS_fnc_SpawnAISoldier", and the function title comment has been
updated for the slightly tweaked syntax.
2015-10-09 20:35:07 -05:00

102 lines
2.4 KiB
Plaintext

/*
DMS_fnc_SpawnNonPersistentVehicle
Spawn a non-saved vehicle in Exile
Created by Zupa
Edited by eraser1
Usage:
[
_vehicleClass, // STRING: Classname of the vehicle
_pos // ARRAY: Position to spawn it at (roughly)
] call DMS_fnc_SpawnNonPersistentVehicle;
Returns the vehicle object of the created vehicle.
EXAMPLE:
_exampleVeh = ['Exile_Chopper_Hummingbird_Green',_pos] call DMS_fnc_SpawnNonPersistentVehicle;
*/
private ["_vehicleClass","_position","_vehpos","_maxDistance","_vehObj"];
_OK = params
[
["_vehicleClass","",[""]],
["_position","",[[]],[2,3]]
];
if (!_OK) exitWith
{
diag_log format ["DMS ERROR :: Calling DMS_SpawnNonPersistentVehicle with invalid parameters: %1",_this];
};
_vehpos = [];
_maxDistance = 5;
while{count _vehpos < 1} do
{
_vehpos = _position findEmptyPosition [0,_maxDistance,_vehicleClass];
_maxDistance = (_maxDistance + 5);
};
_vehpos set [2, 0.1];
_vehObj = createVehicle [_vehicleClass, _vehpos, [], 0, "CAN_COLLIDE"];
clearBackpackCargoGlobal _vehObj;
clearItemCargoGlobal _vehObj;
clearMagazineCargoGlobal _vehObj;
clearWeaponCargoGlobal _vehObj;
if (_vehicleClass isKindOf "I_UGV_01_F") then
{
createVehicleCrew _vehObj;
};
if (getNumber (configFile >> "CfgSettings" >> "VehicleSpawn" >> "nightVision") isEqualTo 0) then
{
_vehObj disableNVGEquipment true;
};
if (getNumber (configFile >> "CfgSettings" >> "VehicleSpawn" >> "thermalVision") isEqualTo 0) then
{
_vehObj disableTIEquipment true;
};
_vehObj setFuel (0.75+(random 0.25));
_vehObj setDir (random 360);
_vehObj setPosATL _vehpos;
_vehObj setVectorUp (surfaceNormal _vehpos);
_vehObj setVariable ["ExileIsPersistent", false];
_vehObj addMPEventHandler ["MPKilled", { if !(isServer) exitWith {}; _this call ExileServer_object_vehicle_event_onMPKilled;}];
_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;
};
}];
};
if (!isNil "RS_VLS") then
{
[_vehObj] call RS_VLS_sanitizeVehicle;
};
_vehObj lock 2;
_vehObj allowDamage false;
_vehObj enableRopeAttach false;
_vehObj enableSimulationGlobal false;
(format ["SpawnNonPersistentVehicle :: Created %1 at %2 with calling parameters: %3",_vehObj,_vehpos,_this]) call DMS_fnc_DebugLog;
_vehObj