How we run it is that first we execute firedEH.sqf called script whenever jet aircraft fires anything, this script looks like this:
Code: Select all
private [ "_thing", "_tmp" ];
_thing = _this select 1;
if (VTE_debug) then
{
player sideChat format["firedEH.sqf executed, _thing: %1", _thing];
};
if(_thing == "VTE_CBU52Rail") then
{
_tmp = _this execVM "\VTE_config\scripts\vehicle\A1\cbu_cluster.sqf";
};
Code: Select all
/*
VTE cluster bomb script
originally from unknown author (possibly Footmunch).
*/
private [
"_plane","_weapon","_ammoname","_b","_bt","_z","_bpos","_bombvel",
"_bvx", "_bvy", "_bvz", "_height", "_numbomblets", "_factor",
"_newposx", "_newposy", "_bomblet", "_ang", "_nvx", "_nvy", "_nvz"
];
// Init our local vars
_plane = _this select 0;
_weapon = _this select 1;
_ammoname = _this select 4;
// Get the cluster bomb object
_b = nearestObject[_plane, _ammoname];
// Decide on proper bomblet type in a MP environment
_bt = ["VTE_CBU25BombletSpoof", "VTE_CBU25Bomblet"] select (local _b);
// Cluster bombs release at 50 metres
_z = (getPos _b) select 2;
waitUntil
{
_z = (getPos _b) select 2;
(_z < 50) || !(alive _b);
};
// Get the bomb velocity and position
_bpos = getPos _b;
_bombvel = velocity _b;
_bvx = _bombvel select 0;
_bvy = _bombvel select 1;
_bvz = _bombvel select 2;
// Remove the original bomb
if (local _b) then
{
deleteVehicle _b;
};
// Bump the zpos upwards
_height = (_bpos select 2);
/*
REALISM vs GAMEPLAY:
How many bomblets are we releasing. realistically its 220 in one bomb case,
but thats too much for game engine to handle with script, or can the script
be tweaked not to cause huge stutter when the bombs impact?
CHANGE:
Added it now for 50, huge difference on technicality of the explosions, however
ingame visual/kill effect changes are almost none...
BUG:
There is bug howere, right now the bombles are created like "north east" from
the impact point, causing very unnatural explosion area. The area should be just
big circle around the disperal of bomblets point, possibly having the bomblets fly
towards the flight path of the aircraft.
*/
_numbomblets = 50;
_factor = 1;
while {_numbomblets > 0} do
{
// Position the bomblet
_newposx = (_bpos select 0) + (5 * (_numbomblets / 12));
_newposy = (_bpos select 1) + (5 * (_numbomblets / 12));
// Create the bomblet
_bomblet = _bt createVehicleLocal [_newposx, _newposy, _height];
// Spread the bomblets into an arc randomly
_ang = - 5 + random 10;
if (_ang < 0) then
{
_ang = _ang + 360;
};
if (_ang > 360) then
{
_ang = _ang - 360;
};
_nvx = (_bvx * cos(_ang)) + (_bvy * sin(_ang));
_nvy = - (_bvx * sin(_ang)) + (_bvy * cos(_ang));
// Randomise the z velocity
_nvz = _bvz * ((60 + random 80) / 100);
// Re-speed the bomb
_bomblet setVelocity [_nvx * _factor, _nvy * _factor, _nvz];
// Next please
_numbomblets = _numbomblets -1;
};
Okay so whats the problem? Well that script for starters creates the bomblets into too narrow (small) area, also it unnaturally creates them on sort of like north-east direction and not in a big (long?) round area.
Anyways, if anyone can improve this script to create round explosion area with optimum number of bomblets for kills and performance, it would be much appreciated.