- llw_getShootVector = {
- params ["_object","_pitchUp","_shootDir"];
- private ["_vector"];
- // calculate barrel vector at 0 deg. object angle
- _vector =
- [ (cos _pitchUp) * (sin _shootDir),
- (cos _pitchUp) * (cos _shootDir),
- (sin _pitchUp) ];
- vectorNormalized (_vector vectorAdd vectorUp _object)
- };
- llw_shoot = {
- params ["_objShooter","_barrelpitch","_barreldir","_shellType","_charge"];
- private ["_barrelHeight","_milsPerDegree","_pitch","_spawnPoint","_objShell","_fireVector"];
- // magic numbers
- _milsPerDegree = 17.777777;
- // preparatory calculations
- // TODO: change spawnpoint function to barrel exit vertex
- _muzzleHeight = 2;
- _spawnPoint = position _objShooter;
- _spawnPoint set [2, _muzzleHeight];
- _vector = [_objShooter,_barrelpitch / _milsPerDegree,_barrelDir] call llw_getShootVector;
- // spawn and launch
- _objShell = _shellType createVehicle _spawnPoint;
- _objShell setVectorDirAndUp [_vector,_vector];
- _objShell setVelocity (_vector vectorMultiply _charge);
- _objShell
- /* hint (["Variables"
- ,"\nObject", _objShooter
- ,"\nBarrelpitch",_barrelpitch
- ,"\nBarreldir",_barreldir
- ,"\nShelltype",_shellType
- ,"\nSpawnPoint",_spawnPoint
- ,"\nVector",_vector
- ,"\nobjShell",_objShell
- ] joinString " : "); */
- };
- /////////////////////////////////////////////
- // AFTER THIS BLOCK, ONLY FOR TESTING
- /////////////////////////////////////////////
- arty = vehicle player;
- player allowDamage false;
- arty allowDamage false;
- onEachFrame
- {
- _beg = ASLToAGL eyePos arty;
- _endE = (_beg vectorAdd (eyeDirection arty vectorMultiply 100));
- drawLine3D [ _beg, _endE, [0,1,0,1]];
- _endW = (_beg vectorAdd (arty weaponDirection currentWeapon arty vectorMultiply 100));
- drawLine3D [_beg, _endW, [1,0,0,1]];
- };
- // shell = [ arty, 45, direction arty, "LLW_81mm_HEPD_004", 1 ] call llw_shoot;
- shell = [ arty, 45, direction arty, "Sh_82mm_AMOS", 10 ] call llw_shoot;
- hint str velocity Shell;