Jump to content
Sign in to follow this  
USSRsniper

Tochka-U missile script

Recommended Posts

Since I'm working on Tochka-U made this simple script,

http://pastebin.com/mc231b66

Don't laugh it's my first script for a BIS game... :icon_rolleyes: Marker is there just for visuals, so I could see the missile on the map. What I'm hoping to create is a script which hopefully will work in MP.

Share this post


Link to post
Share on other sites

What do you need help with? The only thing I can see that is really wrong (with out reading too much into it) is that you are using SQS and not SQF as the language/format.

I am interested in your work on this, as I want to make an Honest John artillery rocket (on its static launcher) as one of my first footsteps into modeling.

Share this post


Link to post
Share on other sites

Hey USSRSniper, I took what you did and somewhat expanded on it (it was a good excuse for a project to learn 3DS Max...).... It is a model of Honest John, an early American artillery rocket (and first nuclear capable rocket in the US arsenal).

yE_X7gGwVhs

Find below my really ugly code that can only shoot a missile south and at a certain angle!!! :D Most of the work is in doing the smoke effects for the stabilizer motors.

//rotate.sqf
sleep random 2;
_spawner = _this select 0;
_m31 = "M31" createVehicle [getPos _spawner select 0, getPos _spawner select 1, ((getPos _spawner select 2) + 6)];
_angle = -30;
[_m31, _angle, 45] call BIS_fnc_setPitchBank;
//sleep 10;
setAccTime 0.125;  
//sleep 4;
for "_i" from 5 to 1 do {
   hintSilent format["%1", _i];
   //sleep 1;
};
_rotate = 2;
_rotateState = 45;
[_m31, _angle, _rotateState] call BIS_fnc_setPitchBank;
_thrust = 2;
/*
_camera = "camera" camCreate (getPos _m31);
_camera cameraEffect ["INTERNAL","BACK"];
showCinemaBorder false;
_relPos = [200,-600,0.10];
_fov = 0.2;
_camera camSetTarget _m31;
_camera camSetRelPos _relPos;
_camera camSetFOV _fov;
_camera camSetFocus [600,0];
_camera camCommit 0;
*/
_marker = createMarker [(format["track%1", time]), getpos _m31];
_marker setMarkerType "mil_dot";
_time = time;
_asc = true;
while {alive _m31} do {
   _dif = 0;
   _posx = getpos _m31 select 0;
   _posy = getpos _m31 select 1;
   _posz = getpos _m31 select 2;
/*
   _camera camSetTarget _m31;
   _camera camSetRelPos _relPos;
   _camera camSetFOV _fov;
   _camera camSetFocus [600,2];
   _camera camCommit 0;
*/
   _marker setMarkerPos (getpos _m31);
   "RadialBlur" ppEffectAdjust [0.02,0.02,0.1,0.1];
   "RadialBlur" ppEffectCommit 0.01;
   "RadialBlur" ppEffectEnable true;
   _tailEffectsPos = [_posx,_posy + 8.75,_posz - 7.25];
   _angle = -30;
   //player sideChat format["%1 %2 %3 %4", (time-_time), (getPosASL _m31), (_spawner distance _m31), (velocity _m31)];

   if(_asc && ((time-_time) < 25 && ((getPosASL _m31) select 2) < (8950+(random 100)))) then {
       _relPos = [0,-100,0.10];
       _fov = 0.035;
       _thrust = (_thrust + (((log _thrust)/1.75))) min 672;
       //player sideChat format["%1-%3 %2 ", _rotateState, _thrust, _rotate];
       _m31 setvelocity [ 1 *sin (getdir _spawner), (_thrust*-1)*2, _thrust];
       _r = 0.15 - random(0.05);
       _r2 = 16 - random(10);
       //drop ["\Ca\Data\Cl_basic","","Billboard",1,30.0+random(6.0),_tailEffectsPos,[0,0,0],0,1.3,1.0,0.05,[7,13+_r2,13.2+_r2,13.4+_r2,13.6+_r2,13.8+_r2,14.0+_r2,14.2+_r2,14.4+_r2],[[0,0,0,0.1],[0.2+_r,0.2+_r,0.2+_r,0.95],[0.3+_r,0.3+_r,0.3+_r,0.6],[0.46+_r,0.46+_r,0.46+_r,0.4],[0.5+_r,0.5+_r,0.5+_r,0.01]],[0],0,0.05,"","",""];
       drop ["\Ca\Data\Cl_basic","","Billboard",1,10.0+random(6.0),_tailEffectsPos,[0,0,0],0,1.3,1.0,0.05,[7,0+_r2,13.2+_r2,0.4+_r2,0.6+_r2,0.8+_r2,0.0+_r2,0.2+_r2,0.4+_r2],[[0,0,0,0.1],[0.2+_r,0.2+_r,0.2+_r,0.5],[0.3+_r,0.3+_r,0.3+_r,0.6],[0.46+_r,0.46+_r,0.46+_r,0.4],[0.5+_r,0.5+_r,0.5+_r,0.01]],[0],0,0.05,"","",""];



       drop ["\Ca\Data\kouleSvetlo.p3d",
             "",
             "Billboard",
             1,
             1.0,
             _tailEffectsPos,
             [0,0,0],
             1,
             0,
             1.0,
             0.0,
             [7],
             [[1.0,0.7,0.4,1],[1.0,0.6,0.4,0.001]],
             [0],
             0.0,
             0.0,
             "",
             "",
             ""
             ];
   } else {
       if(_asc) then {
           hintSilent format["BURN OUT %1 %2", ((getPosASL _m31) select 2), (time-_time)];
           _asc = false;
       };
       _angle = 90;
       _relPos = [-20,60,0.10];
       _fov = 0.1;
   };
   if(_thrust > 25) then {
       [_m31, _angle, _rotateState] call BIS_fnc_setPitchBank;
       _rotateState = (_rotateState + _rotate);
       _dif = 0.25;
       _rotate = (_rotate - _dif) max -15;
       if(_rotateState < -90) then {
           _rotateState = 90;
       };
       _r = 0.15 - random(0.3);
       _r2 = 9 - random(10);

       _offx = 0;
       _offy = -1;
       _offz = -1.75;
       if(_thrust < 30) then {
           {
               _az = (abs(_rotateState)+_x) mod 360;
               for "_c" from 1 to ((floor(_thrust-25))*1.5) do {
                   _popY = _posy - (sin(_az));
                   _popX = _posx - (cos(_az)*_c);
                   _popZ = _posz - (sin(_az)*_c);

                   _rotatorPos = [_popX+_offx, _popY+_offy, _popZ+_offz];
                   drop ["\Ca\Data\Cl_basic","","Billboard",1,1.0,_rotatorPos,[0,0,0],0,1.3,1,1,[2,2,1.5,1,.75],[[0,0,0,1], [1, 1, 1, 0], [0.2, 0.2, 0.2, 0.8]],[0],0,0.05,"","",""];
                   drop ["\Ca\Data\kouleSvetlo.p3d","","Billboard",1,2.0,_rotatorPos,[0,0,0],1,0,1.0,0.0,[1],[[1.0,0.7,0.4,1],[0.8,0.6,0.4,1]],[0],0.0,0.0,"","",""];
               };
           } forEach([-45, 45, 135, 225]);
       };

       if(_thrust < 300) then {
           {
               _az = (abs(_rotateState)+_x) mod 360;
               _popY = _posy - sin(_az)*1.5;
               _popX = _posx - cos(_az)*1.5;
               _popZ = _posz - (sin(_az)*1.5);

               _rotatorPos = [_popX+_offx, _popY+_offy, _popZ+_offz];

               _popY = _posy - sin(_az)*2;
               _popX = _posx - cos(_az)*2;
               _popZ = _posz - (sin(_az)*2);

               _rotatorSustainPos = [_popX+_offx, _popY+_offy, _popZ+_offz];

               drop ["\Ca\Data\Cl_basic","","Billboard",1,0.05,_rotatorPos,[0,0,0],0,1.3,1,1,[2],[[0,0,0,.5]],[0],0,0.05,"","",""];
               drop ["\Ca\Data\Cl_basic","","Billboard",1,2.0+random(2.0),_rotatorSustainPos,[0,0,0],0,1.3,1,1,[2,2.2,1.5,1,.25],[[0,0,0,.25]],[0],0,0.05,"","",""];
               _popY = _posy - sin(_az)*-2;
               _popX = _posx - cos(_az)*-2;
               _popZ = _posz - (sin(_az)*-2);

               _rotatorSustainPos = [_popX+_offx, _popY+_offy, _popZ+_offz];
               drop ["\Ca\Data\kouleSvetlo.p3d","","Billboard",1,1.0,_rotatorPos,[0,0,0],1,0,1.0,0.0,[1],[[1.0,0.7,0.4,1],[0.8,0.6,0.4,.9]],[0],0.0,0.0,"","",""];
           } forEach([-45, 45, 135, 225]);
       };

       //drop ["\Ca\Data\Cl_basic","","Billboard",1,30.0+random(6.0),_tailEffectsPos,[0,0,0],0,1.3,1.0,0.05,[7,13+_r2,13.2+_r2,13.4+_r2,13.6+_r2,13.8+_r2,14.0+_r2,14.2+_r2,14.4+_r2],[[.5,.6,.5,0.1],[0.7+_r,0.7+_r,0.7+_r,0.8],[0.6+_r,0.6+_r,0.6+_r,0.6],[0.5+_r,0.5+_r,0.5+_r,0.4],[0.5+_r,0.5+_r,0.5+_r,0.01]],[0],0,0.05,"","",""];

   };

   sleep 0.005;
};

Share this post


Link to post
Share on other sites
Hey USSRSniper, I took what you did and somewhat expanded on it (it was a good excuse for a project to learn 3DS Max...).... It is a model of Honest John, an early American artillery rocket (and first nuclear capable rocket in the US arsenal).

Nice, but in my script it actually fires in the direction of a vehicle. :)

Share this post


Link to post
Share on other sites
Nice, but in my script it actually fires in the direction of a vehicle. :)

Let me post up what I have now... :)

I should take a video too... Let me do that in a second as well...

This script can have it fire at any angle or elevation. Its range is determined by a rocket burn time (the in game simulation for rockets does not give it the desired visual effect of the rocket having to fight against gravity to gain momentum in its early burn times).

//rotate.sqf
#define __arty_vec_getPitch compile preprocessFileLineNumbers ("\ca\modules\ARTY\data\scripts\ARTY_vec_getPitch.sqf")
#define __arty_vec_getUpVec compile preprocessFileLineNumbers ("\ca\modules\ARTY\data\scripts\ARTY_vec_getUpVec.sqf")

_elevation = 16;
_azimuth = 97;
sleep (random 2);
_spawner = _this select 0;
_m31 = "M31" createVehicle [getPos _spawner select 0, getPos _spawner select 1, ((getPos _spawner select 2) + 4)];
[_m31, _elevation, 0] call BIS_fnc_setPitchBank;
//sleep 10;
//setAccTime 0.25;  
//sleep 4;
for "_i" from 5 to 1 do {
   hintSilent format["%1", _i];
   //sleep 1;
};

_emit1 = "#particlesource" createVehicle position _m31;
_emit2 = "#particlesource" createVehicle position _m31;
_emit3 = "#particlesource" createVehicle position _m31;
_emit4 = "#particlesource" createVehicle position _m31;
_emitters = [_emit1, _emit2, _emit3, _emit4];

{_x setDropInterval 0} foreach _emitters;
{_x setParticleRandom [0.5,[0.1,0.1,0.1],[0,0,0],0,0.1,[0.1,0.1,0.1,0.05],0,0]} foreach _emitters;
{
   _emit = _x select 2;           
   _rotatorSustainPos = [(_x select 0)*1, 2.05, (_x select 1)*1];
   _vel = [30*(_x select 0),0,30*(_x select 1)];
   //_vel = [0,0,0];
   _emit setParticleParams ["\Ca\Data\Cl_basic","","Billboard",1,6.0,_rotatorSustainPos,_vel,1,2,1,1,[2,2,1.5,1,.75],[[0,0,0,.8], [0, 0, 0, .7], [0.2, 0.2, 0.2, 0.5]],[0],0,0.05,"","",_m31];                

} forEach([
   [1,1, _emit1],
   [-1, 1, _emit2],
   [1, -1, _emit3],
   [-1, -1, _emit4]
]);



_rotate = 2;
_rotateState = 0;
//[_m31, _elevation, _rotateState] call BIS_fnc_setPitchBank;
_thrust = 2;

_camera = "camera" camCreate (getPos _m31);
_camera cameraEffect ["INTERNAL","BACK"];
showCinemaBorder false;
_relPos = [10,200,1];
_fov = 0.1;
_camera camSetTarget _m31;
_camera camSetRelPos _relPos;
_camera camSetFOV _fov;
_camera camSetFocus [600,0];

_marker = createMarker [(format["track%1", time]), getpos _m31];
_marker setMarkerType "mil_dot";
_time = time;
_asc = true;

_vec2pol = {
   _mag = _this select 0;
   _dir = _this select 1;
   _elev = _this select 2;

   _magCosElev = _mag * cos(_elev);

   _vx = _magCosElev * sin(_dir);
   _vz = _magCosElev * cos(_dir);
   _vy = _mag * sin(_elev);

   [_vx, _vz, _vy];
};
_spinning = false;
while {alive _m31} do {


   _camera camSetTarget _m31;
   _camera camSetRelPos _relPos;
   _camera camSetFOV _fov;
   _camera camSetFocus [600,2];
   _camera camCommit 0;

   _marker setMarkerPos (getpos _m31);
   _randAz = (random 0.25);

   if((round (random 1)) == 0) then {
       _randAz = _randAz * -1;
   };

   _rocketUnitVec = [sin(_azimuth+_randAz)*cos(_elevation),
                     cos(_azimuth+_randAz)*cos(_elevation),
                     sin(_elevation)];

   _rocketUpVec = _rocketUnitVec call __arty_vec_getUpVec;

   _velocity = velocity _m31;
   _hmag = sqrt((_velocity select 0)*(_velocity select 0) + (_velocity select 1)*(_velocity select 1));
   _pitch = (_velocity select 2) atan2 _hmag;

   _tailEffectsPos = [.25,-8.5,0];
   //player sideChat format["%1", getPos _m31];
   _sustainerTime = 15;
   _sustainerDeviation = 0.25;

   _randomSustainerTime = _sustainerTime;//(_sustainerTime - (_sustainerDeviation/2))+(random _sustainerDeviation);
   if(_asc && (time-_time) < _randomSustainerTime) then {
       _thrust = (_thrust + (((log _thrust)/(1.75/2.75)))) min 672;

       _relPos = [_thrust,(_thrust*-1.1)/3,10];

       _vx = (_rocketUnitVec select 0) * _thrust;
       _vy = (_rocketUnitVec select 1) * _thrust;
       _vz = (_rocketUnitVec select 2) * _thrust;

       _m31 setVectorDirAndUp [_rocketUnitVec, _rocketUpVec];
       _m31 setVelocity [_vx, _vy, _vz];
       [_m31, _elevation, _rotateState] call BIS_fnc_setPitchBank;
       _r = 0.15 - random(0.05);
       _r2 = 16 - random(10);
       drop ["\Ca\Data\Cl_basic","","Billboard",1,2.0+random(6.0),_tailEffectsPos,[0,0,0],0,1.3,1.0,0.05,[7,4+_r2,3.2+_r2,0.4+_r2,0.6+_r2,0.8+_r2,0.0+_r2,0.2+_r2,0.4+_r2],[[0,0,0,0.1],[0.7+_r,0.7+_r,0.7+_r,0.2],[0.7+_r,0.7+_r,0.7+_r,0.2],[0.76+_r,0.76+_r,0.76+_r,0.2],[0.5+_r,0.5+_r,0.5+_r,0.01]],[0],0,0.05,"","",_m31];



       drop ["\Ca\Data\kouleSvetlo.p3d",
             "",
             "Billboard",
             1,
             2.0,
             _tailEffectsPos,
             [0,100,0],
             1,
             0,
             1.0,
             0.0,
             [7],
             [[1.0,0.7,0.4,1],[1.0,0.6,0.4,0.001]],
             [0],
             0.0,
             0.0,
             "",
             "",
             _m31
             ];
   } else {
       if(_asc) then {
           hintSilent format["BURN OUT %1 %2", ((getPosASL _m31) select 2), (time-_time)];
           _asc = false;
       };

       [_m31, _pitch, _rotateState] call BIS_fnc_setPitchBank;
   };
   if(_thrust > 25 || !_asc) then {
        player sideChat format["%2 %1 %3", _rotate, floor time, _rotateState];
       _rotateState = (_rotateState + _rotate);
       _dif = 0.05;
       _rotate = (_rotate + _dif) min 7.5;

       if(_rotateState >= 90) then {
           _rotateState = -90;
       };
       _r = 0.15 - random(0.3);
       _r2 = 9 - random(10);

       _offx = 0;
       _offy = -1;
       _offz = -1.75;

       if(_thrust < 50 && !_spinning) then {
           _spinning = true;
           {_x setDropInterval 0.005} foreach _emitters;
           _burstSize = (floor (4+(random 4)));
           {
               for "_c" from 1 to _burstSize do {
                   _rotatorPos = [((_x select 0)*_c)+((_x select 1)*.25), 2.05, ((_x select 1)*_c)+((_x select 0)*.25)];
                   drop ["\Ca\Data\Cl_basic","","Billboard",1,1.0,_rotatorPos,_rotatorPos,1,1,1,1,[2,2,1.5,1,.75],[[0,0,0,1], [0, 0, 0, 1], [0.2, 0.2, 0.2, 0.8]],[0],0,0.05,"","",_m31];
                   drop ["\Ca\Data\kouleSvetlo.p3d","","Billboard",1,2.0,_rotatorPos,[0,0,0],1,0,1.0,0.0,[1],[[1.0,0.7,0.4,1],[0.8,0.6,0.4,1]],[0],0.0,0.0,"","",_m31];
               };
           } forEach([
               [1,1],
               [-1, 1],
               [1, -1],
               [-1, -1]
           ]);
       };

       if(_thrust < 400) then {
           {
               _rotatorSustainMotorPos = [(_x select 0)*.35, 2.05, (_x select 1)*.35];
               drop ["\Ca\Data\kouleSvetlo.p3d","","Billboard",1,1.0,_rotatorSustainMotorPos,[0,0,0],1,0,1.0,0.0,[1],[[1.0,0.7,0.4,1],[0.8,0.6,0.4,.9]],[0],0.0,0.0,"","",_m31];
           } forEach([
               [1,1],
               [-1, 1],
               [1, -1],
               [-1, -1]
           ]);
       } else {
           {_x setDropInterval 0} foreach _emitters;
       };



   };

   sleep 0.025;
};

I used particle emitters for the stabilizing motors because they can work independently of the drop command executing every script iteration. Also if you pass the object at the end of a particle array (the missile in this case) you can give 3D coordinates to the position, and the game engine will translate those correctly based on the pitch, yaw and roll of the object (so much easier than trying to do it via your own math).

Share this post


Link to post
Share on other sites

Here is the video...

c5-0eDF35f0

Unfortunately something in the game engine causes the projectile to go invisible after about 170 meters per second. I was thinking you could get around this by not making it an ammo class. You unfortunately loose some of the simulation aspects though. I am actually using the ShellBase ammo class, not RocketBase or MissileBase.

Share this post


Link to post
Share on other sites

Thanks, I hope that helps you... I wasn't sure what your original question was though... :(

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  

×