Advertisement
Guest User

Untitled

a guest
Jul 4th, 2015
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.27 KB | None | 0 0
  1. //-----------------------------------------------------------//
  2. //
  3. //              DayZ Visual Mission Editor
  4. //              by Eugene Zhuravlev 2014 (c)
  5. //  Thanks to authors of EMS and WAI and BIS wiki for code examples
  6. //
  7. //
  8. //  mail    : EugeneZhuravlev@yandex.ru
  9. //  Skype   : EugeneZhuravlev
  10. //  www     : http://DayZMissionEditor.ru/
  11. //  YouTube : http://www.youtube.com/channel/UCWuzUxNJ_Ctf9ynoJqiV2ww
  12. //
  13. //-----------------------------------------------------------//
  14.    private ["_missionIndex","_missionParms","_vehicleName", "_vehiclePosType","_vehiclePos","_vehicleAzimut","_vehicle","_vehicleLootType",
  15.             "_vehicleLootItems","_vehicleLocked","_vehicleWeaponLoot","_vehicleMagazineLoot","_locationRadius","_locationPos","_vehicleLootItemsQty",
  16.             "_vehiclePermanent","_vehicleData","_vehicleList","_gunnerSpots","_static","_ZEVVehicleRandomList","_vehicleRandomList",
  17.             "_damageMin","_damageMax","_fuelMin","_fuelMax","_absolutePos"];
  18.  
  19.     _missionIndex       = _this select 0;
  20.     _vehicleData        = _this select 1;
  21.     _static             = _this select 2;
  22.     _absolutePos        = false;
  23.     if(count _this == 4) then
  24.     {
  25.         _absolutePos    = _this select 3;
  26.     };
  27.     _missionParms       = [_missionIndex, _static] call ZEVMissionGetActiveMissionParms;
  28.    
  29.     _locationPos        = _missionParms select 0;
  30.     _locationRadius     = _missionParms select 1;
  31.    
  32.     _vehicleName        = _vehicleData select 0;
  33.     _vehiclePosType     = _vehicleData select 1;
  34.     _vehiclePos         = _vehicleData select 2;
  35.     _vehicleAzimut      = _vehicleData select 3;
  36.     _vehicleLocked      = _vehicleData select 4;
  37.     _vehicleWeaponLoot  = _vehicleData select 5;
  38.     _vehicleMagazineLoot= _vehicleData select 6;
  39.     _vehiclePermanent   = _vehicleData select 7;
  40.     _vehicleRandomList  = _vehicleData select 8;
  41.     _damageMin          = _vehicleData select 9;
  42.     _damageMax          = _vehicleData select 10;
  43.     _fuelMin            = _vehicleData select 11;
  44.     _fuelMax            = _vehicleData select 12;
  45.    
  46.     if (_damageMin < 20)            then { _damageMin = 20;};
  47.     if (_damageMax > 80)            then { _damageMax = 80;};
  48.     if (_damageMin > _damageMax)    then { _damageMin = _damageMax;};
  49.        
  50.     if (_fuelMin < 0)               then { _fuelMin = 0;};
  51.     if (_fuelMax > 100)             then { _fuelMax = 100;};
  52.     if (_fuelMin > _fuelMax)        then {_fuelMin = _fuelMax;};
  53.    
  54.     _damageMin  = (_damageMin + random(_damageMax - _damageMin))/100;
  55.    
  56.     _fuelMin    = (_fuelMin + random(_fuelMax - _fuelMin))/100;
  57.     //_ZEVVehicleRandomList = [_missionIndex, _static] call ZEVMissionGetVehicleRandomList;
  58.    
  59.     _vehicleName = [_missionIndex, _vehicleName, _vehicleRandomList, ZEVVehicleList] call ZEVMissionSelect;
  60.    
  61.     if(_absolutePos) then
  62.     {
  63.         _vehiclePos = _vehiclePos;
  64.     }
  65.     else
  66.     {
  67.         _vehiclePos = [_vehiclePos, _vehiclePosType, _locationPos, _locationRadius] call ZEVMissionSelectPos;
  68.     };
  69.    
  70.     if(_vehiclePosType == "Random") then
  71.     {
  72.         _vehicleAzimut  = round(random(360));
  73.     };
  74.    
  75.     _vehicle            = createVehicle [_vehicleName, _vehiclePos, [], 0, "CAN_COLLIDE"];
  76.    
  77.  
  78.     _vehicle setPos _vehiclePos;
  79.     _vehicle setVectorUp surfaceNormal position _vehicle;  
  80.     _vehicle setDir _vehicleAzimut;
  81.    
  82.     if (_vehicle isKindOf "Car") then
  83.     {
  84.         _roads = _vehiclePos  nearRoads 20;
  85.         if(count _roads > 0) then
  86.         {
  87.             _vehiclePos = position (_roads select 0);
  88.             _vehicle setPosATL _vehiclePos;
  89.         };
  90.     };
  91.    
  92.     _vehicle setVariable ["ZEVPermanent", _vehiclePermanent, true];
  93.  
  94.    
  95.     _vehicleList = [_missionIndex, _static] call ZEVMissionGetVehicleList;
  96.    
  97.     _vehicleList set [count _vehicleList, _vehicle];
  98.    
  99.     [_missionIndex, _static, _vehicleList] call ZEVMissionSetVehicleList;
  100.    
  101.     _vehicle setVariable ["ObjectID","1",true];
  102.     _vehicle setVariable ["ZEVMissionIndex", _missionIndex, true];
  103.     PVDZE_serverObjectMonitor set [count PVDZE_serverObjectMonitor, _vehicle]; 
  104.    
  105.     clearWeaponCargoGlobal      _vehicle;
  106.     clearMagazineCargoGlobal    _vehicle;
  107.  
  108.     _vehicleLootType    = _vehicleWeaponLoot select 0;
  109.     _vehicleLootItemsQty= _vehicleWeaponLoot select 1;
  110.     _vehicleLootItems   = _vehicleWeaponLoot select 2;
  111.  
  112.    
  113.     [_vehicle, "weapon", _vehicleLootType, _vehicleLootItemsQty, _vehicleLootItems, _static] call ZEVMissionVehicleAddLoot;
  114.    
  115.     _vehicleLootType    = _vehicleMagazineLoot select 0;
  116.     _vehicleLootItemsQty= _vehicleMagazineLoot select 1;
  117.     _vehicleLootItems   = _vehicleMagazineLoot select 2;
  118.     [_vehicle, "magazine", _vehicleLootType, _vehicleLootItemsQty, _vehicleLootItems, _static] call ZEVMissionVehicleAddLoot;
  119.  
  120. /*
  121.     if(_VehiclePermanent == "No") then
  122.     {
  123.         [_vehicle] spawn {
  124.             if (!isServer) exitWith {};
  125.             private ["_veh"];
  126.             _veh = _this select 0;
  127.             waitUntil { count crew _veh > 0};
  128.            
  129.             while {(alive _veh) and ({alive _x} count crew _veh > 0)} do
  130.             {
  131.                 sleep 30;
  132.             };
  133.             sleep 1200;
  134.             _veh setDamage 1;
  135.             _veh setVariable ["killedat", time];
  136.             };
  137.     };
  138. */ 
  139.     _gunnerSpots = _vehicle emptyPositions "gunner";
  140.     if (_gunnerSpots>0) then
  141.     {
  142.         _vehicle allowCrewInImmobile true;
  143.     };
  144.    
  145.     //[_vehicle, _static, _missionIndex] spawn ZEVMissionVehicleFindGunner;
  146.    
  147.     if(_vehicleLocked == "Yes") then
  148.     {
  149.         _vehicle addEventHandler ["GetIn",{
  150.             if (isPlayer (_this select 2)) then {
  151.                 (_this select 2) action ["getOut",(_this select 0)];
  152.                 0 = [nil,(_this select 2),"loc",rTITLETEXT,"Players are not permitted to enter AI vehicles!","PLAIN DOWN",5] call RE;
  153.                 /*(_this select 0) setVehicleLock "LOCKED";*/
  154.             };
  155.         }];
  156.     };
  157.    
  158.     _vehicle setDamage _damageMin;
  159.     _vehicle setFuel _fuelMin;
  160.    
  161. _vehicle
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement