Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.38 KB | None | 0 0
  1. /*
  2.     rhs_fnc_aps_missileFired
  3. */
  4.  
  5. params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
  6.  
  7. _aps_vehicles = missionNamespace getVariable ["rhs_aps_vehicles",[]];
  8.  
  9. if(_aps_vehicles isEqualTo [])exitWith{};
  10.  
  11. //systemChat format["%1 missile %2",_this,_projectile];
  12.  
  13. private _valid_vehicles = [];
  14. private _cleanup        = [];
  15.  
  16. {
  17.     if(!alive _x)exitWith{_cleanup pushBack _x};
  18.  
  19.     //
  20.     if( 180-(abs (180-(_unit getRelDir  _x))) < 50 && _unit != _x)then{_valid_vehicles pushBack _x};
  21. }foreach _aps_vehicles;
  22.  
  23. if(!(_cleanup isEqualTo []))then{_aps_vehicles = _aps_vehicles - _cleanup;missionNamespace setVariable ["rhs_aps_vehicles",_aps_vehicles]};
  24.  
  25. // Exit if there are no valid vehicles
  26. if(_valid_vehicles isEqualTo [])exitWith{
  27.     //systemchat "no valid vehicles"
  28. };
  29.  
  30.  
  31. if(_projectile isEqualTo objNull)exitWith{
  32.     //systemChat "no missile";
  33. };
  34.  
  35. {
  36. }foreach _valid_vehicles;
  37.  
  38. _triggerTurn = [];
  39. while{alive _projectile}do
  40. {
  41.     {
  42.         if(_projectile distance _x < 400 && !(_x in _triggerTurn))then
  43.         {
  44.             // Turn turret - TODO: move to separate function
  45.             if(isPlayer (gunner _x) or (gunner _x isEqualTo objNull))then
  46.             {
  47.                 _relDir = deg (_x animationSourcePhase "APS_Turn");
  48.                 _direction = -(_x getRelDir  _projectile)+ deg(_x animationSourcePhase "MainTurret");
  49.                 if(abs _direction > 180)then{_direction = _direction  + 360};
  50.                 _x animateSource ["APS_Turn",rad _direction,2];
  51.                 //systemchat format["%1 %2 %3",_direction, _x getRelDir _projectile,_relDir];
  52.             }else
  53.             {
  54.                 (gunner _x) doWatch (getpos _projectile);
  55.             };
  56.             _triggerTurn pushBack _x;
  57.         };
  58.  
  59.         if(_projectile distance _x < 40)exitWith{
  60.             systemchat "Hardkill triggered (UNLIMITED TEST MODE)";
  61.  
  62.             // Test particles - TODO: change to projectile?
  63.             _particle = "#particlesource" createVehicleLocal (getpos _projectile);
  64.             _particle setParticleRandom [0, [0, 0, 0], [0, 0, 0.4], 2.6, 0, [0, 0, 0, 0.1], 0.6, 0.1];
  65.             _particle setParticleParams [["\a3\Data_f\ParticleEffects\Universal\Universal", 16, 0, 8], "", "Billboard", 1, 0.2, [0, 0, 1], [0, 0, 2], 0, 12, 1.7, 0, [4, 32, 0.1], [[1, 1, 1, 0.1], [1, 1, 1, 0.1], [1, 1, 1, 0.1]], [0.08], 1, 0, "", "", _particle];
  66.             _particle setDropInterval 0.1;
  67.  
  68.             //triggerAmmo _projectile;
  69.             deleteVehicle _projectile;
  70.             _particle spawn {sleep 0.1;deleteVehicle _this};
  71.         };
  72.     }foreach _valid_vehicles;
  73.     sleep 0.05;
  74. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement