Facebook
From Hot Shama, 4 Years ago, written in Plain Text.
This paste is a reply to Re: Untitled from Voluminous Dove - go back
Embed
Viewing differences between Re: Untitled and Re: Re: Untitled
llw_getShootVector = {
        params ["_object","_pitchUp","_shootDir"]
["_object","_pitchUp","_shootDir"];
        private ["_vector"];

        // calculate barrel vector at 0 deg. object angle
        _vector =
        [        (cos _pitchUp) * (sin _shootDir),
                (cos _pitchUp) * (cos _shootDir),
                (sin _pitchUp) ];

        _vector = _vector vectorNormalized (_vector vectorAdd vectorUp _object;

        return vectorNormalized _vector;
}



_barrelpitch 
_object)
};


llw_shoot 
_this select 0;
_barreldir 
{
        params ["_objShooter","_barrelpitch","_barreldir","_shellType","_charge"];
        private ["_barrelHeight","_milsPerDegree","_pitch","_spawnPoint","_objShell","_fireVector"];


        // magic numbers
        _milsPerDegree 
_this select 1;
_barrelroll 
17.777777;

        // preparatory calculations
        // TODO: change spawnpoint function to barrel exit vertex
        _muzzleHeight 
_this select 2;
_charge 
2;
        _spawnPoint 
_this select 3;


_theshell 
position _objShooter;
        _spawnPoint set [2, _muzzleHeight];
        _vector 
"LLW_81mm_HEPD_004" [_objShooter,_barrelpitch / _milsPerDegree,_barrelDir] call llw_getShootVector;

        // spawn and launch
        _objShell = _shellType 
createVehicle [getpos theplayer select 0, getpos theplayer select 1, 0.5];
//barrelpitch = 819;
_pitchdegrees = _barrelpitch / 17.777777;
//_charge = 314;

_theshell setdir _barreldir;
[_theshell, _pitchdegrees, 0] call BIS_fnc_setPitchBank;

_startvelocity =

_theshell 
_spawnPoint;
        _objShell setVectorDirAndUp [_vector,_vector];
        _objShell 
setVelocity (_charge (_vector vectorMultiply [_artilleryObject,_pitchdegrees,_barreldir] _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_getShootVector)
llw_shoot;
shell = [ arty, 45, direction arty, "Sh_82mm_AMOS", 10 ] call llw_shoot;

hint str velocity _theshell;
//player attachto [_theshell, [0,0,0]];
Shell;