Advertisement
Guest User

Untitled

a guest
May 27th, 2013
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.75 KB | None | 0 0
  1. /*
  2. ==================================================================================================================
  3. Simple Vehicle Respawn Script v1.81 for Arma 3
  4. by Tophe of �stg�ta Ops [OOPS]
  5.  
  6. Put this in the vehicles init line:
  7. veh = [this] execVM "vehicle.sqf"
  8.  
  9.  
  10. Options:
  11. There are some optional settings. The format for these are:
  12. veh = [object, Delay, Deserted timer, Respawns, Effect, Dynamic] execVM "vehicle.sqf"
  13.  
  14. Default respawn delay is 30 seconds, to set a custom respawn delay time, put that in the init as well.
  15. Like this:
  16. veh = [this, 15] execVM "vehicle.sqf"
  17.  
  18. Default respawn time when vehicle is deserted, but not destroyed is 120 seconds. To set a custom timer for this
  19. first set respawn delay, then the deserted vehicle timer. (0 = disabled)
  20. Like this:
  21. veh = [this, 15, 10] execVM "vehicle.sqf"
  22.  
  23. By default the number of respawns is infinite. To set a limit first set preceding values then the number of respawns you want (0 = infinite).
  24. Like this:
  25. veh = [this, 15, 10, 5] execVM "vehicle.sqf"
  26.  
  27. Set this value to TRUE to add a special explosion effect to the wreck when respawning.
  28. Default value is FALSE, which will simply have the wreck disappear.
  29. Like this:
  30. veh = [this, 15, 10, 5, TRUE] execVM "vehicle.sqf"
  31.  
  32. By default the vehicle will respawn to the point where it first was when the mission started (static).
  33. This can be changed to dynamic. Then the vehicle will respawn to the position where it was destroyed.
  34. First set all preceding values then set TRUE for dynamic or FALSE for static.
  35. Like this:
  36. veh = [this, 15, 10, 5, TRUE, TRUE] execVM "vehicle.sqf"
  37.  
  38. If you you want to set the INIT field of the respawned vehicle, first set all other values, then set init commands.
  39. Those must be inside quotations.
  40. Like this:
  41. veh = [this, 15, 10, 5, TRUE, FALSE, "this setDammage 0.5"] execVM "vehicle.sqf"
  42.  
  43. Default values of all settings are:
  44. veh = [this, 30, 120, 0, FALSE, FALSE] execVM "vehicle.sqf"
  45.  
  46.  
  47. Contact & Bugreport: cwadensten@gmail.com
  48. ================================================================================================================== */
  49.  
  50.  
  51. private ["_hasname","_delay","_deserted","_respawns","_noend","_dead","_nodelay","_timeout","_position","_dir","_effect","_rounds","_run","_unit","_explode","_dynamic","_unitinit","_haveinit","_unitname","_type"];
  52. if (!isServer) exitWith {};
  53.  
  54. // Define variables
  55. _unit = _this select 0;
  56. _delay = if (count _this > 1) then {_this select 1} else {30};
  57. _deserted = if (count _this > 2) then {_this select 2} else {120};
  58. _respawns = if (count _this > 3) then {_this select 3} else {0};
  59. _explode = if (count _this > 4) then {_this select 4} else {false};
  60. _dynamic = if (count _this > 5) then {_this select 5} else {false};
  61. _unitinit = if (count _this > 6) then {_this select 6} else {};
  62. _haveinit = if (count _this > 6) then {true} else {false};
  63.  
  64. _hasname = false;
  65. _unitname = vehicleVarName _unit;
  66. if (isNil _unitname) then {_hasname = false;} else {_hasname = true;};
  67. _noend = true;
  68. _run = true;
  69. _rounds = 0;
  70.  
  71. if (_delay < 0) then {_delay = 0};
  72. if (_deserted < 0) then {_deserted = 0};
  73. if (_respawns <= 0) then {_respawns= 0; _noend = true;};
  74. if (_respawns > 0) then {_noend = false};
  75.  
  76. _dir = getDir _unit;
  77. _position = getPosASL _unit;
  78. _type = typeOf _unit;
  79. _dead = false;
  80. _nodelay = false;
  81.  
  82.  
  83. // Start monitoring the vehicle
  84. while {_run} do
  85. {
  86. sleep (2 + random 10);
  87. if ((getDammage _unit > 0.8) and ({alive _x} count crew _unit == 0)) then {_dead = true};
  88.  
  89. // Check if the vehicle is deserted.
  90. if (_deserted > 0) then
  91. {
  92. if ((getPosASL _unit distance _position > 10) and ({alive _x} count crew _unit == 0) and (getDammage _unit < 0.8)) then
  93. {
  94. _timeout = time + _deserted;
  95. sleep 0.1;
  96. waitUntil {_timeout < time or !alive _unit or {alive _x} count crew _unit > 0};
  97. if ({alive _x} count crew _unit > 0) then {_dead = false};
  98. if ({alive _x} count crew _unit == 0) then {_dead = true; _nodelay =true};
  99. if !(alive _unit) then {_dead = true; _nodelay = false};
  100. };
  101. };
  102.  
  103. // Respawn vehicle
  104. if (_dead) then
  105. {
  106. if (_nodelay) then {sleep 0.1; _nodelay = false;} else {sleep _delay;};
  107. if (_dynamic) then {_position = getPosASL _unit; _dir = getDir _unit;};
  108. if (_explode) then {_effect = "M_AT" createVehicle getPosASL _unit; _effect setPosASL getPosASL _unit;};
  109. sleep 0.1;
  110.  
  111. deleteVehicle _unit;
  112. sleep 2;
  113. _unit = _type createVehicle _position;
  114. _unit setPosASL _position;
  115. _unit setDir _dir;
  116.  
  117. [_unit] execVM "scripts\transport\classify.sqf";
  118.  
  119. _dead = false;
  120.  
  121. // Check respawn amount
  122. if !(_noend) then {_rounds = _rounds + 1};
  123. if ((_rounds == _respawns) and !(_noend)) then {_run = false;};
  124. };
  125. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement