Facebook
From Hot Shama, 6 Years ago, written in Plain Text.
This paste is a reply to Re: Untitled from Voluminous Dove - view diff
Embed
Download Paste or View Raw
Hits: 479
  1. llw_getShootVector = {
  2.         params ["_object","_pitchUp","_shootDir"];
  3.         private ["_vector"];
  4.  
  5.         // calculate barrel vector at 0 deg. object angle
  6.         _vector =
  7.         [       (cos _pitchUp) * (sin _shootDir),
  8.                 (cos _pitchUp) * (cos _shootDir),
  9.                 (sin _pitchUp) ];
  10.  
  11.         vectorNormalized (_vector vectorAdd vectorUp _object)
  12. };
  13.  
  14.  
  15. llw_shoot = {
  16.         params ["_objShooter","_barrelpitch","_barreldir","_shellType","_charge"];
  17.         private ["_barrelHeight","_milsPerDegree","_pitch","_spawnPoint","_objShell","_fireVector"];
  18.  
  19.  
  20.         // magic numbers
  21.         _milsPerDegree = 17.777777;
  22.  
  23.         // preparatory calculations
  24.         // TODO: change spawnpoint function to barrel exit vertex
  25.         _muzzleHeight = 2;
  26.         _spawnPoint = position _objShooter;
  27.         _spawnPoint set [2, _muzzleHeight];
  28.         _vector = [_objShooter,_barrelpitch / _milsPerDegree,_barrelDir] call llw_getShootVector;
  29.  
  30.         // spawn and launch
  31.         _objShell = _shellType createVehicle _spawnPoint;
  32.         _objShell setVectorDirAndUp [_vector,_vector];
  33.         _objShell setVelocity (_vector vectorMultiply _charge);
  34.         _objShell
  35.  
  36.         /* hint (["Variables"
  37.                 ,"\nObject", _objShooter
  38.                 ,"\nBarrelpitch",_barrelpitch
  39.                 ,"\nBarreldir",_barreldir
  40.                 ,"\nShelltype",_shellType
  41.                 ,"\nSpawnPoint",_spawnPoint
  42.                 ,"\nVector",_vector
  43.                 ,"\nobjShell",_objShell
  44.                 ] joinString " : "); */
  45.  
  46. };
  47.  
  48. /////////////////////////////////////////////
  49. // AFTER THIS BLOCK, ONLY FOR TESTING
  50. /////////////////////////////////////////////
  51. arty = vehicle player;
  52. player allowDamage false;
  53. arty allowDamage false;
  54.  
  55. onEachFrame
  56. {
  57.         _beg = ASLToAGL eyePos arty;
  58.         _endE = (_beg vectorAdd (eyeDirection arty vectorMultiply 100));
  59.         drawLine3D [ _beg, _endE, [0,1,0,1]];
  60.         _endW = (_beg vectorAdd (arty weaponDirection currentWeapon arty vectorMultiply 100));
  61.         drawLine3D [_beg, _endW, [1,0,0,1]];
  62. };
  63.  
  64. // shell = [ arty, 45, direction arty, "LLW_81mm_HEPD_004", 1 ] call llw_shoot;
  65. shell = [ arty, 45, direction arty, "Sh_82mm_AMOS", 10 ] call llw_shoot;
  66.  
  67. hint str velocity Shell;
  68.