Advertisement
JackoJammie

Arma 3 script "unit_spawn.sqf"

May 17th, 2017
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.24 KB | None | 0 0
  1. /*  AI Unit Create Script for special Crewmen or Pilots, fit for usage on ships.
  2.     Use this script especially for important AI's like Pilots or Crewmen which offer services.
  3.    
  4.     Developed by Steam-User immerfestedruv.
  5.    
  6.     In the Unit Init Field insert:
  7.     this addEventHandler ["killed", {0 = [_this,5,"blackfish_1","Driver",helipad_2,15] execVM "unit_spawn.sqf"}];
  8.    
  9.     You need to add some more Init Lines below, to handle the vehicle it should get in.*/
  10.  
  11. _unit = (_this select 0) select 0; // First Argument, get Unit's details
  12. _delay = _this select 1; // Second Argument,get the init set respawn time
  13. _vehCall = _this select 2; // Third Argument, the Variable-Name of the unit's vehicle(Call-Sign)
  14. _vehSeat = _this select 3; // Forth Argument, on which Seat shall the unit sit
  15. _parkPlace = _this select 4; // Fifth Argument, the place where the vehicle parks
  16. _parkRad = _this select 5; // Sixth Argument, possible park Radius from the center of the vehicle park
  17. hint format ["unit/delay/vehCall/vehSeat/parkPlace/parkRad %1 / %2 / %3 / %4 / %5 / %6",_unit,_delay,_vehCall,_vehSeat,_parkPlace,_parkRad];
  18. _dirUnit = getDir _unit; // get original facing
  19. _posUnit = getPosATL _unit; // get original position
  20. _unitType = typeOf _unit; // get the unit type
  21. _unitgroup = group _unit; // get group of the original unit
  22. _unitName = vehicleVarName _unit; // get the Variable-Name of the unit
  23. _unitRank = rank _unit; // get the units orignal rank
  24. _unitSkill = skill _unit; // get the original skill of the unit
  25.  
  26.  
  27. if(isServer) then{
  28.     sleep _delay*4; // sleep a bit
  29.     if(!alive _unit) then { //true if unit is not alive
  30.         deleteVehicle _unit; // clear up old units
  31.         sleep _delay; // respawn time between deletion and respawn
  32.        
  33.         // create a new unit of same type at starting position
  34.         _unitType createUnit [
  35.             _posUnit,
  36.             _unitgroup,
  37.                 // Following sentences are added to the init line of the _unit
  38.                 "_unit = this; //_unit is still an object but in nect line it will be an array
  39.                _unit setVariable [ 'unitDef',[_delay,_vehCall,_vehSeat,_parkPlace,_parkRad];
  40.                
  41.                
  42.                /* We have to extract the Definitions from our Array, but the array is in the addEventHandler known as
  43.                _this and not as _unit, so we have to define _unit again. */
  44.                _unit addEventHandler ['killed', {
  45.                    _unit = _this select 0;
  46.                    [_this, (_unit getVariable 'unitDef') select 0, //delay
  47.                    (_unit getVariable 'unitDef') select 1, //vehCall
  48.                    (_unit getVariable 'unitDef') select 2, //_vehSeat
  49.                    (_unit getVariable 'unitDef') select 3, //_parkPlace
  50.                    (_unit getVariable 'unitDef') select 4, //_parkRad
  51.                    ] execVM 'unit_spawn.sqf'}];
  52.                
  53.                
  54.                [this,_delay,_vehCall,_vehSeat,_parkPlace,_parkRad] execVM 'unit_getin.sqf';",
  55.             _unitSkill,
  56.             _unitRank];
  57.         _unit setPosATL _posUnit; // set correct position
  58.         _unit setVehicleVarName _unitName;
  59.         _unit setDir _dirUnit; // set correct facing of the unit
  60.     };
  61. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement