player2_dz

va_outside_target fix fixed

Feb 22nd, 2016
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 1.76 KB | None | 0 0
  1. span class="re5"> va_outside_target = {
  2.     ARGVX3(0,_player,objNull);
  3.     ARGVX3(1,_distance,0);
  4.  
  5.     diag_log(format["va_outside_target:Input:       %1", _this]);
  6.  
  7.     if (!isPlayer _player) exitWith {};
  8.  
  9.  
  10.     _lineTarget = objNull;
  11.     _pos1 = []; _pos2 = [];
  12.     _pos1 = (eyePos player);
  13.     _pos2 = ([_pos1, cameraDirDist(_distance)] call vector_add);
  14.     _objects = [];
  15.     _objects = (lineIntersectsWith [_pos1,_pos2,objNull,objNull,true]);
  16.     if (!isARRAY(_objects) || {count _objects == 0}) then { } else {
  17.         _lineTarget = _objects select 0;
  18.     };
  19.  
  20.     diag_log(format["va_outside_target:LineObjects:         %1 (Target is first object in Array)", _objects]);
  21.     diag_log(format["va_outside_target:CursorTarget:        %1", cursorTarget]);
  22.     diag_log(format["va_outside_target:CursorObject:        %1", cursorObject]);
  23.  
  24.     //Set the target
  25.     _target = objNull;
  26.     _target = cursorObject;
  27.     _targetOk = true;
  28.     if (isNil "_target") then { _targetOk = false; };
  29.     if (isNull "_target") then { _targetOk = false;};
  30.     if (!(_targetOk)) then {
  31.         _target = objNull;
  32.         _target = cursorTarget;
  33.         _targetOk = true;
  34.         if (isNil "_target") then { _targetOk = false; };
  35.         if (isNull "_target") then { _targetOk = false;};
  36.     };
  37.  
  38.     if (!(_targetOk)) then {
  39.         _target = objNull;
  40.         _target = _lineTarget;
  41.         _targetOk = true;
  42.         if (isNil "_target") then { _targetOk = false; };
  43.         if (isNull "_target") then { _targetOk = false;};
  44.     };
  45.  
  46.     if (!(_targetOk)) then {
  47.         _target = objNull;
  48.     };
  49.  
  50.     diag_log(format["va_outside_target:FinalTarget: %1", _target]);
  51.  
  52.     if (isNil "_target") exitWith {};
  53.     if (isNull "_target") exitWith {};
  54.     if (({_target isKindOf _x } count ["Helicopter", "Plane", "Ship_F", "Car", "Motorcycle", "Tank"]) == 0) exitWith {};
  55.  
  56.     diag_log(format["va_outside_target:FinalTarget: %1, Passed all Checks!", _target]);
  57.  
  58.     _target
  59. };
Advertisement
Add Comment
Please, Sign In to add comment