aeroson

Untitled

Aug 11th, 2013
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. /*
  2. AUTHOR: aeroson
  3. NAME: suicide_car.sqf
  4.  
  5. DESCRIPTION
  6. will add one satchel into car
  7. you can stop car from blowing by remving the satchel from its cargo
  8. if hostile unit is withing range, car will roll a dice with chance to blow up
  9. car will blow up if its dammage is lowered by 0.2
  10.  
  11. USAGE:
  12. in vehicle's init
  13. [_this, 70, 10] execVM "suicide_car.sqf";
  14. _this refers to the vehicle
  15. 70 is chance to blow up when in range, dice is rolled every second
  16. chance is from 0 to 100
  17. 10 is range in meters to look for hostiles
  18.  
  19. */
  20.  
  21. _vehicle = _this select 0;
  22. _chance = _this select 1;
  23. _range = _this select 2;
  24.  
  25. _bombClass = "SatchelCharge_Remote_Mag";
  26.  
  27. _vehicle addMagazineCargo[_bombClass, 1];
  28.  
  29. _blowUp = {
  30. //"HelicopterExploSmall" "HelicopterExploBig" "SmallSecondary"
  31. _booms = round (random 15);
  32. while { _booms>0 } do {
  33. "SmallSecondary" createVehicle (getPos _this);
  34. sleep ((random 0.2)+0.05);
  35. _booms = _booms - 1;
  36. };
  37. sleep ((random 0.1)+0.01);
  38. "HelicopterExploBig" createVehicle (getPos _this);
  39. };
  40.  
  41. _hasMagazine = {
  42. {
  43. if((_x select 0)==(_this select 1)) exitWith { true; };
  44. } forEach getMagazineCargo (_this select 0);
  45. false;
  46. };
  47.  
  48. _originalDamage = damage _vehicle;
  49.  
  50. while{canMove _vehicle && [_vehicle, _bombClass] call _hasMagazine} do {
  51.  
  52. if((damage _vehicle)-_originalDamage > 0.2) exitWith {
  53. _vehicle spawn _blowUp;
  54. false;
  55. };
  56.  
  57. _gotTarget = false;
  58. {
  59. {
  60. if (alive _x && side _x != side _vehicle) then {
  61. if (({alive _x} count (crew (vehicle _x)))>0) then {
  62. _gotTarget = true;
  63. };
  64. };
  65. } forEach ((getPos _vehicle) nearObjects [_x, _range]);
  66. } forEach ["man","air","land","ship"];
  67.  
  68. if(_gotTarget) then {
  69. if(floor(random(100-_chance))==0) exitWith {
  70. _vehicle spawn _blowUp;
  71. false;
  72. };
  73. };
  74.  
  75. };
Advertisement
Add Comment
Please, Sign In to add comment