Jump to content
Sign in to follow this  
CTI player IF

Multiple Launching Position

Recommended Posts

Some simple math here.

The l/p raketa/strela in Memory LOD work for aircrafts (depending on vehicle's simulation) only. Proxy of CfgNonAIVehicles available is maverickweapon (maverick of A10 and hellfire of AH64 are using this design), which work for land vehicles, but unfortunately it has fixed direction same as the Vehicle but not the turret (by the way, this is same for l/p raketa/strela).

However by directly calculation it's able to design such a function. In this way what the editor has to assign is not selections in Memory LOD of model but formula in scripts of vehicle's Fired-EH.

 

The invariant things is the relative position among launching positions and the turret. Variable is both the 3D direction of vehicle and turret. Let's start our analysis here. The "VectorUp" of vehicle is a vector parallel to the axis of turret (osaVeze), and the direction vector of turret mostly can be regarded as the direction of the projectile (shotBullet, shotShell, shotRocket with nonzero thrustTime and shotMissile within initTme will have a invariant direction), which can be obtained by "VectorDir". These 2 vectors admit an unique direction perpendicular to both of them (obtain it by vector cross), notate it as "vectorH", meaning relative horizontal direction, and then obtain "vectorV" (relative vertical direction) via vectorH and projectile's (turret's) direction.

Having know "vectorH" and "vectorV", the script can assign the initial position of projectile by current ammunition. It's seems faster to use setPosASL than setPos according to https://community.bistudio.com/wiki/Code_Optimisation .

kh5PxM3.png

 

A video of TOS-1 unit (model is from DKMM mod).

 

Another one of tunguska unit (model is from DKMM mod as well). Its cannon is noticeable.

Here is the script for M270 MLRS unit (one can find this model in M29064mm.pbo, or in COC mod, or in latest RCWC 4.9).

Spoiler

_vehicle = _this select 0; _weapon = _this select 1; _ammo = _this select 4; 
_shell = nearestObject [_vehicle, _ammo];
? isNull _shell: exit;

; ====================================================================================================================================================================
 _posShell = getPosASL _shell; _dirShell = VectorDir _shell; _upVeh = VectorUp _vehicle;
_ammunition = _vehicle ammo _weapon;
; ====================================================================================================================================================================
_corX = (_ammunition % 3) * 0.317 + ([0,1] select (_ammunition >= 6)) * 1.458; _corY = ([0,1] select (_ammunition % 6 >= 3)) * 0.317; _corX = -_corX; _corY = -_corY;

_vectorH = [_dirShell, _upVeh] call LoadFile "\TZK_Objects\Scripts\Vector\VectorCross.sqf";
_vecotrV = [_vectorH, _dirShell] call LoadFile "\TZK_Objects\Scripts\Vector\VectorCross.sqf";

_length = _vectorH call LoadFile "\TZK_Objects\Scripts\Vector\VectorLength.sqf";
_vectorH = [_vectorH, _corX/_length] call LoadFile "\TZK_Objects\Scripts\Vector\VectorScale.sqf";
_length = _vecotrV call LoadFile "\TZK_Objects\Scripts\Vector\VectorLength.sqf";
_vectorV = [_vecotrV, _corY/_length] call LoadFile "\TZK_Objects\Scripts\Vector\VectorScale.sqf";

_vectorCor = [_vectorH, _vectorV] call LoadFile "\TZK_Objects\Scripts\Vector\VectorAdd.sqf";
_launchPos = [_posShell, _vectorCor] call LoadFile "\TZK_Objects\Scripts\Vector\VectorAdd.sqf";
? local _shell: _shell setPosASL _launchPos;
; ====================================================================================================================================================================

Those SQF scripts of vector is standard calculation for 3D-vectors.

 

This design requiring 2.01 ArmA:Resistance for commandsVectorUp and VectorDir. In 1.96/1.99 it'll cost more pre-calculation due to lacking of script commands. The "VectorUp" can be obtained by 3 sensors. 3 points admits a plane, and the "UP" vector can be calculated by these sensors (the "camCreate" is recommended for it's effect is local in network game). As for the projectile's direction, it's velocity vector can be used instead. Besides, 1.96 have to use setPosbut not setPosASL commands.

Spoiler

An example for obtaining VectorUp of the land at assigned position in 1.96/1.99. The 0.8 here is the step length. The return vector isn't normalized (namely its length isn't 1):


_pos = _this;
_x0 = _pos select 0; _y0 = _pos select 1;

_cam0 = "EmptyDetector" camCreate [_x0, _y0]; _cam0 setPos [_x0, _y0];
_cam1 = "EmptyDetector" camCreate [_x0 + 0.8, _y0]; _cam1 setPos [_x0 + 0.8, _y0];
_cam2 = "EmptyDetector" camCreate [_x0, _y0 + 0.8]; _cam2 setPos [_x0, _y0 + 0.8];

_z0 = abs((getPos _cam0) select 2);
_z1 = abs((getPos _cam1) select 2);
_z2 = abs((getPos _cam2) select 2);

{deleteVehicle _x} forEach [_cam0, _cam1, _cam2];

_vector1 = [0.8, 0, _z1 - _z0];
_vector2 = [0, 0.8, _z2 - _z0];

[_vector1, _vector2] call loadFile "\TZK_Objects\Scripts\Vector\VectorCross.sqf"

However no way in 1.96/1.99 to setVectorUp as displayed in video. 2.01 is necessary.

 

Edited by CTI player IF
Updating

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×