Lets start.
First you launch this script from aircrafts class eventHandlers {} like this:
Code: Select all
class eventhandlers
{
fired = "_this exec ""\VTE_Config\scripts\napalm_distribution.sqs"";";
};
Code: Select all
private [
"_plane","_weapon","_ammoname","_missobj","_zpos",
"_bombvel","_bvx","_bvy","_bvz","_bpos","_numbomblets","_btype",
"_factor","_sensor","_result","_height","_newposx","_newposy",
"_ang","_nvx","_nvy","_nvz"
];
_plane = _this select 0;
_weapon = _this select 1;
_ammoname = _this select 4;
if (_ammoname != "VTE_MK74") exitWith {};
// #MoveMissile
// Get the missile object
_missobj = nearestObject [_plane, _ammoname];
// The bomb can impact, and not trigger
// Also, cluster bombs release at 50 metres
_zpos = getPos _missobj select 2;
while {_zpos > 50 && alive _missobj} do
{
sleep 0.05;
_zpos = getPos _missobj select 2;
};
if (not alive _missobj) exitWith {};
// Get the bomb velocity and position
_bombvel = velocity _missobj;
_bvx = _bombvel select 0;
_bvy = _bombvel select 1;
_bvz = _bombvel select 2;
_bpos = getPos _missobj;
// Remove the original bomb
deleteVehicle _missobj;
// How many bomblets are we releasing
_numbomblets = 20;
_factor = 1;
_btype="VTE_Bomblet";
if !(local _plane) then {_btype="VTE_Bomblet_Dummy"};
// Create an empty object
_sensor = "EmptyDetector" createVehicleLocal [0,0,0];
// Place it directly under the plane in the horizontal
_sensor setPos [_bpos select 0, _bpos select 1];
// The OFP engine puts the object on the land surface, so we can get the ground height
_result =(getPos _sensor) select 2;
// Clean up the sensor
deleteVehicle _sensor;
// Bump the zpos upwards
_height = (_bpos select 2);
while {_numbomblets > 0} do
{
// Position the bomblet
_newposx = (_bpos select 0) + (5 * (_numbomblets / 15));
_newposy = (_bpos select 1) + (5 * (_numbomblets / 15));
// Create the bomblet
// this should be createVehicleLocal to reduce the desync!
_bomblet = _btype createVehicleLocal [_newposx, _newposy, _height];
// this is additional since v0.4 style script
[_bomblet] execVM "\VTE_Config\scripts\vehicle\shared\napalm\napalm.sqf";
// Spread the bomblets into an arc randomly
_ang = - 5 + random 10;
?(_ang <0> 360) : _ang = _ang - 360;
_nvx = (_bvx * cos(_ang)) + (_bvy * sin(_ang));
_nvy =-(_bvx * sin(_ang)) + (_bvy * cos(_ang));
// Randomise the z velocity
_nvz = _bvz * ((20 + random 130) / 100);
// Re-speed the bomb
_bomblet setVelocity [_nvx* _factor, _nvy* _factor, _nvz];
// Next please
_numbomblets = _numbomblets -1;
sleep 0.05;
};
Code: Select all
_bomb = _this select 0;
?!(alive _bomb): exit;
#napalm
?!(alive _bomb): goto "create";
_x = getpos _bomb select 0;
_y = getpos _bomb select 1;
_z = getpos _bomb select 2;
~0.01
?(alive _bomb): goto "napalm";
#create
; make this createVehicleLocal so dont have desync
_smoke = "VTE_Napalm_Smoke" createVehicleLocal [_x,_y,_z];
exit;