Advertisement
Unkl

fn_reload.sqf

Feb 15th, 2016
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 5.82 KB | None | 0 0
  1. //V1 by Ghost, added delay of 4 seconds if object moves out then no repair
  2. private ["_object","_Rearmlist","_reload_time","_type","_Object_name","_fuelstore","_removed","_f","_repairVics","_ammoVics","_fuelVics","_mssg","_objectCommander","_objectOwner","_objectTurrets","_objectTurretIds"];
  3. _repairVics = ["B_G_Offroad_01_repair_F","B_Truck_01_Repair_F","I_G_Offroad_01_repair_F","I_Truck_02_box_F","O_G_Offroad_01_repair_F","O_Truck_03_repair_F","O_Truck_02_box_F","B_APC_Tracked_01_CRV_F"];
  4. _ammoVics = ["B_Truck_01_ammo_F","I_Truck_02_ammo_F","O_Truck_03_ammo_F","O_Truck_02_Ammo_F","B_APC_Tracked_01_CRV_F"];
  5. _fuelVics = ["B_Truck_01_fuel_F","B_G_Van_01_fuel_F","I_Truck_02_fuel_F","I_G_Van_01_fuel_F","O_Truck_03_fuel_F","O_Truck_02_fuel_F","O_G_Van_01_fuel_F","B_APC_Tracked_01_CRV_F"];
  6.  
  7. _object = _this select 0;
  8. _Rearmlist = _this select 1;
  9. _reload_time = 10;
  10. _objectCommander = effectiveCommander _object;
  11. _objectOwner = owner _object;
  12. _objectTurretIds = [];
  13. _objectTurrets = allTurrets [_object, true];
  14. for "_i" from 0 to count _objectTurrets do
  15. {
  16.     _objectTurretIds set [_i, (_object turretOwner [_i])];
  17. };
  18.  
  19. //[[_objectCommander,"fn_reload.sqf was just initiated."],"groupChat",_objectOwner,false] call BIS_fnc_MP;
  20.  
  21. _type = typeof _object;
  22.  
  23. if ((_object isKindOf "ParachuteBase") or (_object isKindOf "Man")) exitWith {};
  24.  
  25. WaitUntil{_object in list _Rearmlist};
  26. sleep 4;
  27. if(!(_object in list _Rearmlist)) exitWith {_object vehiclechat "Repair Aborted"};
  28.  
  29. if !(alive _object) exitWith {};
  30. _fuelstore = fuel _object;
  31. [[_object,0],"setFuel",_objectOwner,false] call BIS_fnc_MP;
  32.  
  33. _Object_name = (configFile >> "cfgVehicles" >> (_type) >> "displayName") call bis_fnc_getcfgdata;
  34.  
  35. _mssg = format ["Servicing %1... Please stand by...", _Object_name];
  36. [[_objectCommander,_mssg],"groupChat",_objectOwner,false] call BIS_fnc_MP;
  37.  
  38.  
  39. While {alive _object} do
  40. {
  41.     if ((typeOf _object) in _repairVics) then
  42.     {
  43.         [[_object,1],"setRepairCargo",true,false] call BIS_fnc_MP;
  44.         [[_objectCommander,"Refilling repair supplies..."],"groupChat",_objectOwner,false] call BIS_fnc_MP;
  45.         sleep _reload_time;
  46.     };
  47.     if ((typeOf _object) in _ammoVics) then
  48.     {
  49.         [[_object,1],"setAmmoCargo",true,false] call BIS_fnc_MP;
  50.         [[_objectCommander,"Refilling ammunition cargo..."],"groupChat",_objectOwner,false] call BIS_fnc_MP;
  51.         sleep _reload_time;
  52.     };
  53.     if ((typeOf _object) in _fuelVics) then
  54.     {
  55.         [[_object,1],"setFuelCargo",true,false] call BIS_fnc_MP;
  56.         [[_objectCommander,"Refilling fuel cargo..."],"groupChat",_objectOwner,false] call BIS_fnc_MP;
  57.         sleep _reload_time;
  58.     };
  59.  
  60. /*
  61.     if(_object isKindOf "O_Truck_03_ammo_F") then
  62.     {              
  63.         _object vehicleChat format ["Loading infantry ammo in %1 inventory.", _Object_name];
  64.  
  65.         clearWeaponCargoGlobal      _object;
  66.         clearMagazineCargoGlobal    _object;
  67.         clearItemCargoGlobal         _object;
  68.  
  69.         _object addMagazineCargoGlobal ["30Rnd_65x39_caseless_green", 50];       
  70.         _object addMagazineCargoGlobal ["HandGrenade", 10];
  71.         _object addMagazineCargoGlobal ["MiniGrenade", 10];
  72.         _object addMagazineCargoGlobal ["SmokeShell", 5];
  73.         _object addMagazineCargoGlobal ["SmokeShellGreen", 5];
  74.         _object addMagazineCargoGlobal ["SmokeShellRed", 5];
  75.         _object addMagazineCargoGlobal ["150Rnd_762x51_Box", 10];      
  76.         _object addMagazineCargoGlobal ["1Rnd_HE_Grenade_shell", 10];
  77.         _object addMagazineCargoGlobal ["1Rnd_SmokeRed_Grenade_shell", 5];     
  78.         _object addMagazineCargoGlobal ["RPG32_HE_F", 6];      
  79.         _object addMagazineCargoGlobal ["RPG32_F", 5];     
  80.         _object addMagazineCargoGlobal ["DemoCharge_Remote_Mag", 8];  
  81.         _object addMagazineCargoGlobal ["SatchelCharge_Remote_Mag", 4];  
  82.         _object addItemCargoGlobal    ["FirstAidKit", 30];     
  83.        
  84.         sleep _reload_time;
  85.     }
  86.     else
  87.     {
  88.         if(_object isKindOf "I_UGV_01_F") then
  89.         {
  90.             if(isUavConnected _object) then
  91.             {
  92.                 _unit = (uavControl _object) select 0;
  93.                 _unit sidechat "Putting ammo in UGV.";
  94.             };
  95.  
  96.             clearWeaponCargoGlobal      _object;
  97.             clearMagazineCargoGlobal    _object;
  98.             clearItemCargoGlobal         _object;
  99.  
  100.             _object addMagazineCargoGlobal ["30Rnd_556x45_Stanag", 15];
  101.             _object addMagazineCargoGlobal ["200Rnd_65x39_cased_Box", 4];
  102.             _object addMagazineCargoGlobal ["20Rnd_762x51_Mag", 4];
  103.             _object addMagazineCargoGlobal ["1Rnd_HE_Grenade_shell", 5];
  104.             _object addMagazineCargoGlobal ["NLAW_F", 2];  
  105.             _object addMagazineCargoGlobal ["Titan_AT", 2];
  106.             //_object addMagazineCargoGlobal ["Titan_AP", 2];
  107.             _object addMagazineCargoGlobal ["DemoCharge_Remote_Mag", 2];  
  108.             _object addMagazineCargoGlobal ["SatchelCharge_Remote_Mag", 1];  
  109.             _object addItemCargoGlobal    ["FirstAidKit", 10];
  110.            
  111.             sleep _reload_time;
  112.  
  113.             if(isUavConnected _object) then
  114.             {
  115.                 _unit = (uavControl _object) select 0;
  116.                 _unit sidechat "Done. Vehicle has ammo in cargo";
  117.             };
  118.         };
  119.     };
  120. */ 
  121.  
  122.     if (count _objectTurrets > 0) then
  123.     {
  124.         [[_objectCommander,"Rearming..."],"groupChat",_objectOwner,false] call BIS_fnc_MP;
  125.         sleep _reload_time;
  126.         {
  127.             [[_object,1],"setVehicleAmmo",_x,false] call BIS_fnc_MP;
  128.         }forEach _objectTurretIds;
  129.     };
  130.  
  131.     [[_objectCommander,"Repairing..."],"groupChat",_objectOwner,false] call BIS_fnc_MP;
  132.     sleep _reload_time;
  133.     _object setDamage 0; //this command is global
  134.  
  135.     [[_objectCommander,"Refueling..."],"groupChat",_objectOwner,false] call BIS_fnc_MP;
  136.     sleep _reload_time;
  137.     _f = 0.01;
  138.     while {fuel _object < 0.99} do {
  139.         if(!(_object in list _Rearmlist)) exitWith
  140.         {
  141.             [[_objectCommander,"Fueling Aborted"],"groupChat",_objectOwner,false] call BIS_fnc_MP;
  142.             [[_object,_fuelstore + _f],"setFuel",_objectOwner,false] call BIS_fnc_MP;
  143.         };
  144.         [[_object,_fuelstore + _f],"setFuel",_objectOwner,false] call BIS_fnc_MP;
  145.         sleep 0.2;
  146.         _f = _f + 0.01;
  147.     };
  148.     _mssg = format ["%1 is ready...", _Object_name];
  149.     [[_objectCommander,_mssg],"groupChat",_objectOwner,false] call BIS_fnc_MP;
  150.     if (true) exitWith {};
  151. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement