Advertisement
Brick

A3 Moving Target

Sep 17th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 2.73 KB | None | 0 0
  1. private _mat = "ShootingMat_01_Olive_F" createVehicle [0, 0, 0];
  2. _mat setPos getPos player;
  3. _mat setDir getDir player;
  4.  
  5. _mat setVariable ["targetMin", 600, true];
  6. _mat setVariable ["targetMax", 1200, true];
  7.  
  8. [
  9.     _mat,
  10.     {
  11.         _this addAction
  12.         [
  13.             format
  14.             [
  15.                 "<t color='#00FF00'>Reset Target (%1m - %2m)</t>",
  16.                 _mat getVariable "targetMin",
  17.                 _mat getVariable "targetMax"
  18.             ],
  19.             {
  20.                 private _target = param [0];
  21.                 private _caller = param [1];
  22.                 private _ID     = param [2];
  23.                 private _args   = param [3];
  24.  
  25.                 deleteVehicle (_target getVariable ["currentTarget", objNull]);
  26.  
  27.                 private _newObject = "TargetBootcampHumanSimple_F" createVehicle [0, 0, 0];
  28.                 _target setVariable ["currentTarget", _newObject];
  29.  
  30.                 private _min = _target getVariable "targetMin";
  31.                 private _max = _target getVariable "targetMax";
  32.  
  33.                 private _distance = random (_max - _min) + _min;
  34.  
  35.                 hint format ["Target Distance: %1", round _distance];
  36.  
  37.                 _newObject setPos (_target getRelPos [_distance, 0]);
  38.                 _newObject setDir (getDir _target);
  39.  
  40.                 _newObject addEventHandler
  41.                 [
  42.                     "HitPart",
  43.                     {
  44.                         private _params = param [0];
  45.  
  46.                         private _target   = _params param [0];
  47.                         private _position = _params param [3];
  48.                         private _direct   = _params param [10];
  49.  
  50.                         if (_direct) then
  51.                         {
  52.                             private _hitMarker = "Sign_Sphere10cm_F" createVehicleLocal [0, 0, 0];
  53.                             _hitMarker setObjectTextureGlobal [0, "#(rgb,8,8,3)color(0,1,1,1)"];
  54.                             _hitMarker setPosASL _position;
  55.  
  56.                             _hitMarker spawn
  57.                             {
  58.                                 uiSleep 1;
  59.                                 deleteVehicle _this;
  60.                             };
  61.                         };
  62.                     }
  63.                 ];
  64.             },
  65.             [ ],
  66.             5,
  67.             true,
  68.             false
  69.         ];
  70.  
  71.         _this addAction
  72.         [
  73.             "<t color='#FF0000'>Pack Up</t>",
  74.             {
  75.                 private _target = param [0];
  76.  
  77.                 deleteVehicle (_target getVariable "currentTarget");
  78.  
  79.                 deleteVehicle _target;
  80.             },
  81.             [ ],
  82.             5,
  83.             true,
  84.             false
  85.         ];
  86.     }
  87. ] remoteExec ["call", 0];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement