Jump to content
Sign in to follow this  
Khalashnikovf

Compile preprocessFile for many diferent units at once?

Recommended Posts

Hi, another little trouble...

I need to

ShockpushPreLoad = compile preprocessFile "lk\nuke\shockpush.sqf";

Im doing it in init file.

But when I call it like this

_array = _pos nearObjects ["Man", 50000];
{nul = [_x,_pos] call ShockpushPreLoad;} forEach _array;

Its not working. There is possible that preloaded script is launched even for a hundred times at once. Is there any diferent way how to preload some script to be used for many diferent units?

thx for respond.

Share this post


Link to post
Share on other sites

Does ShockpushPreLoad work if you call it without the forEach loop? Such as

[(_array select 0),_pos] call ShockpushPreLoad;

I don't know the contents of shockpush.sqf, but what you have is structurally sound.

You can leave out 'nul =' which serves no purpose. I assume you're not returning a value, because you would be overwriting it many times over.

Also, you may need to spawn ShockpushPreLoad depending on what content is in there. For example, sleep won't work in a function initiated with a call command.

Share this post


Link to post
Share on other sites

I thought this would've worked fine:

{[_x, _pos] call ShockpushPreLoad} forEach _array;

One thing to check is if nearObjects is even returning properly, you may be passing it an empty array.

Share this post


Link to post
Share on other sites
Does ShockpushPreLoad work if you call it without the forEach loop? Such as

[(_array select 0),_pos] call ShockpushPreLoad;

I don't know the contents of shockpush.sqf, but what you have is structurally sound.

You can leave out 'nul =' which serves no purpose. I assume you're not returning a value, because you would be overwriting it many times over.

Also, you may need to spawn ShockpushPreLoad depending on what content is in there. For example, sleep won't work in a function initiated with a call command.

Well, there is a many sleep and waituntil and while and for and etc functions in that shockpush script :)

How does it work this spawn thing?

----------------

And that thing with array select 0 works well. SO there is problem with that sleep,etc stuff

----------------

Would be good to add here script it self,hm? :)

private ["_unit","_pos","_rad","_force","_xPos","_yPos","_xVel","_yVel","_zVel","_coef","_fi",
"_n","_fi","_dam","_vel","_vecUp","_nX","_nY","_nXX","_nYY","_leanF","_leanX","_leanY","_cyklus","_theta",
"_diference","_fXX","_fYY","_fZZ","_xxF","_yyF","_zzF","_spread","_omega","_heatRad","_timeAfter","_plus","_radRad",
"_material","_intenzity","_Sound","_soundPos","_SoundWave","_SoundTurbolence","_lenght","_height","_width","_weight",
"_weakness1","_weakness2","_cubature"];

// -- Declaration
_unit = _this select 0; 		// unit affected by shockwave
_pos = _this select 1;  		// centre of explosion

_theta = 0;
_omega = 0;
_n = 0;
_coef = 0;
_fi = 0;
_leaner = 0.04; // how quickly will units lean into right position after impact

// -- vehicle properties
_lenght = 0;
_height = 0;
_width = 0;
_weight = 0;
_weakness1 = "";
_weakness2 = "";
_steel = 0; //1 - Human , 2 - Cars , 3 - Trucks,Choppers,Planes, 4 - HMMWV,Jackal

// BAF_FV510_D , BAF_ATV_D , BAF_Jackal2_GMG_D , BAF_Jackal2_L2A1_D , BAF_Offroad_D

// -- Declaration of Unit type
if (_unit isKindOf "Car") then {_coef = 140; _lenght = 4.5; _height = 1.3; _width = 1.6; _weight = 800;};
if (_unit isKindOf "Bus") then {_coef = 140;  _lenght = 10; _height = 3; _width = 2.5; _weight = 5800;};
if (_unit isKindOf "HMMWV_Base") then {_coef = 140; _lenght = 4.6; _height = 1.8; _width = 1.8; _weight = 2340;};
if (_unit isKindOf "SUV_Base_EP1") then {_coef = 140; _lenght = 4.8; _height = 1.7; _width = 1.8; _weight = 2340;};
if (_unit isKindOf "ArmoredSUV_Base_PMC") then {_coef = 140; _lenght = 4.8; _height = 1.7; _width = 1.8; _weight = 2540;};
if (_unit isKindOf "Lada_base") then {_coef = 140; _lenght = 4.0; _height = 1.3; _width = 1.6; _weight = 800;};
if (_unit isKindOf "Offroad_DSHKM_base") then {_coef = 140; _lenght = 4.12; _height = 1.8; _width = 1.64; _weight = 800;};
if (_unit isKindOf "Pickup_PK_base") then {_coef = 140; _lenght = 4.1; _height = 1.8; _width = 1.6; _weight = 1000;};
if (_unit isKindOf "LandRover_Base") then {_coef = 140; _lenght = 4.1; _height = 1.8; _width = 1.6; _weight = 1500;};		
if (_unit isKindOf "SkodaBase") then {_coef = 140; _lenght = 4.16; _height = 1.4; _width = 1.595; _weight = 800;};
if (_unit isKindOf "tractor") then {_coef = 140; _lenght = 3.67; _height = 2.71; _width = 1.91; _weight = 3740;};
if (_unit isKindOf "Truck") then {_coef = 140; _lenght = 7.35; _height = 3.09; _width = 2.40; _weight = 10210;};
if (_unit isKindOf "MAZ_543_SCUD_Base_EP1") then {_coef = 120; _lenght = 12.35; _height = 4.09; _width = 3.80; _weight = 16300;};
if (_unit isKindOf "ATV_Base_EP1") then {_coef = 140; _lenght = 2.12; _height = 1.09; _width = 1.20; _weight = 100;};
if (_unit isKindOf "UAZ_Base") then {_coef = 140; _lenght = 4.02; _height = 2.05; _width = 1.78; _weight = 1650;};
if (_unit isKindOf "Wheeled_APC") then {_coef = 140; _lenght = 5.50; _height = 2.35; _width = 2.30; _weight = 5300;};
if (_unit isKindOf "Motorcycle") then {_coef = 150; _lenght = 1.33; _height = 0.83; _width = 0.3; _weight = 105;};
if (_unit isKindOf "Tank") then {_coef = 120; _lenght = 9.82; _height = 2.72; _width = 3.79; _weight = 48200;};
if (_unit isKindOf "2S6M_Tunguska") then {_coef = 120; _lenght = 9.82; _height = 2.72; _width = 3.79; _weight = 48200;};
if (_unit isKindOf "APC") then {_coef = 120; _lenght = 5.50; _height = 2.35; _width = 2.30; _weight = 5300;};
if (_unit isKindOf "StrykerBase_EP1") then {_coef = 120; _lenght = 6.95; _height = 2.64; _width = 2.72; _weight = 24000;};
if (_unit isKindOf "Tracked_APC") then {_coef = 120; _lenght = 7.94; _height = 3.26; _width = 3.27; _weight = 29100;};
if (_unit isKindOf "M1A1") then {_coef = 120; _lenght = 7.93; _height = 2.4; _width = 3.66; _weight = 61300;};
if (_unit isKindOf "M2A2_Base") then {_coef = 120; _lenght = 6.55; _height = 2.98; _width = 3.60; _weight = 27600;};
if (_unit isKindOf "T34") then {_coef = 120; _lenght = 6.68; _height = 2.45; _width = 3.00; _weight = 26500;};
if (_unit isKindOf "T72_Base") then {_coef = 120; _lenght = 6.95; _height = 2.23; _width = 3.59; _weight = 41500;};
if (_unit isKindOf "T90") then {_coef = 120; _lenght = 9.53; _height = 2.22; _width = 3.78; _weight = 46500;};
if (_unit isKindOf "ZSU_Base") then {_coef = 120; _lenght = 6.53; _height = 2.57; _width = 3.12; _weight = 16000;};
if (_unit isKindOf "MLRS_base") then {_coef = 120; _lenght = 6.85; _height = 2.59; _width = 2.97; _weight = 24950;};
if (_unit isKindOf "Man") then {_coef = 180; _lenght = 0.35; _height = 1.77; _width = 0.41; _weight = 90;};
if (_unit isKindOf "Cow") then {_coef = 180; _lenght = 3.03; _height = 1.45; _width = 0.5; _weight = 750;};
if (_unit isKindOf "Goat") then {_coef = 200; _lenght = 1.53; _height = 0.70; _width = 0.4; _weight = 80;};
if (_unit isKindOf "Hen") then {_coef = 280; _lenght = 0.30; _height = 0.37; _width = 0.18; _weight = 3.5;};
if (_unit isKindOf "Rabbit") then {_coef = 280; _lenght = 0.43; _height = 0.27; _width = 0.22; _weight = 12;};
if (_unit isKindOf "Sheep") then {_coef = 180; _lenght = 1.53; _height = 0.70; _width = 0.4; _weight = 80;};
if (_unit isKindOf "WildBoar") then {_coef = 180; _lenght = 1.23; _height = 0.90; _width = 0.42; _weight = 70;};
if (_unit isKindOf "CAManBase") then {_coef = 180; _lenght = 0.35; _height = 1.77; _width = 0.5; _weight = 95;};
if (_unit isKindOf "Air") then {_coef = 150; _lenght = 18.00; _height = 4.5; _width = 2.5; _weight = 4000;};
if (_unit isKindOf "AH1_Base") then {_coef = 150; _lenght = 16.20; _height = 4.12; _width = 2.00; _weight = 3550;};
if (_unit isKindOf "AH64_base_EP1") then {_coef = 150; _lenght = 17.73; _height = 3.87; _width = 2.2; _weight = 8000;};
if (_unit isKindOf "AW159_Lynx_BAF") then {_coef = 150; _lenght = 15.24; _height = 3.73; _width = 1.8; _weight = 4300;};
if (_unit isKindOf "BAF_Merlin_HC3_D") then {_coef = 150; _lenght = 22.81; _height = 6.65; _width = 3.2; _weight = 11550;};
if (_unit isKindOf "Ka60_GL_BASE_PMC") then {_coef = 150; _lenght = 14.50; _height = 4.93; _width = 2.8; _weight = 9800;};
if (_unit isKindOf "Mi17_base") then {_coef = 150; _lenght = 18.46; _height = 4.76; _width = 3.55; _weight = 11100;};
if (_unit isKindOf "Mi24_Base") then {_coef = 150; _lenght = 17.50; _height = 6.50; _width = 2.65; _weight = 9800;};
if (_unit isKindOf "UH1Y") then {_coef = 150; _lenght = 17.78; _height = 4.50; _width = 2.8; _weight = 6660;};
if (_unit isKindOf "UH1H_base") then {_coef = 150; _lenght = 17.40; _height = 4.39; _width = 2.8; _weight = 3600;};
if (_unit isKindOf "UH60_Base") then {_coef = 150; _lenght = 19.76; _height = 5.13; _width = 2.36; _weight = 9980;};
if (_unit isKindOf "UH60M_US_base_EP1") then {_coef = 150; _lenght = 19.76; _height = 5.13; _width = 2.36; _weight = 9980;};
if (_unit isKindOf "CH47_base_EP1") then {_coef = 150; _lenght = 30.1; _height = 5.70; _width = 3.36; _weight = 12100;};
if (_unit isKindOf "AH6_Base_EP1") then {_coef = 150; _lenght = 9.80; _height = 3.00; _width = 1.9; _weight = 980;};		 
if (_unit isKindOf "ParachuteBase") then {_coef = 180; _lenght = 5.00; _height = 2.00; _width = 5.00; _weight = 95;};
if (_unit isKindOf "A10") then {_coef = 150; _lenght = 16.26; _height = 4.47; _width = 6.8; _weight = 13782;};
if (_unit isKindOf "AV8B2") then {_coef = 150; _lenght = 14.12; _height = 3.55; _width = 7.2; _weight = 10410;};
if (_unit isKindOf "BIS_Steerable_Parachute") then {_coef = 150; _lenght = 5.00; _height = 2.00; _width = 5.00; _weight = 95;};
if (_unit isKindOf "C130J") then {_coef = 150; _lenght = 29.79; _height = 11.84; _width = 25.00; _weight = 40000;};
if (_unit isKindOf "F35_base") then {_coef = 150; _lenght = 15.67; _height = 4.33; _width = 8.3; _weight = 22470;};
if (_unit isKindOf "MV22") then {_coef = 150; _lenght = 17.50; _height = 6.73; _width = 20.00; _weight = 18000;};
if (_unit isKindOf "Su25_base") then {_coef = 150; _lenght = 15.33; _height = 4.80; _width = 11.00; _weight = 16990;};
if (_unit isKindOf "Su34") then {_coef = 150; _lenght = 23.34; _height = 6.09; _width = 11.00; _weight = 39000;};
if (_unit isKindOf "An2_Base_EP") then {_coef = 150; _lenght = 12.4; _height = 4.1; _width = 14.10; _weight = 4900;};
if (_unit isKindOf "MQ9PredatorB") then {_coef = 150; _lenght = 11.00; _height = 3.60; _width = 15.00; _weight = 3500;};
if (_unit isKindOf "Ka137_Base_PMC") then {_coef = 150; _lenght = 1.30; _height = 1.30; _width = 1.3; _weight = 80;};
if (_unit isKindOf "Pchela1T") then {_coef = 150; _lenght = 2.78; _height = 1.05; _width = 2.2; _weight = 138;};		
if (_unit isKindOf "StaticWeapon") then {_coef = 130; _lenght = 1.35; _height = 1.07; _width = 1.5; _weight = 100;};
if (_unit isKindOf "Ship") then {_coef = 100; _lenght = 5.35; _height = 3.27; _width = 2.5; _weight = 395;};
if (_unit isKindOf "Thing") then {_coef = 10; };
if (_unit isKindOf "Building") then {_coef = 8; };
if (_unit isKindOf "Strategic") then {_coef = 5; };
if (_unit isKindOf "Nonstrategic") then {_coef = 5;};

// -- Check line for good
if (isPlayer _unit or player in _unit) then { player sidechat "checkPush"; };
// -- -- -- -- -- -- -- -- 

_rad = _unit distance _pos;

// -- Sound of Vehicle shaking after Explosion
if ((isPlayer _unit or player in _unit)and(_unit distance _pos < 2500)) then
{
if (_coef != 180) then
{
	if (player distance _pos < 600) then {_intenzity = "Close";};
	if (player distance _pos >= 600 and player distance _pos < 1100) then {_intenzity = "Standard";};
	if (player distance _pos >= 1100 and player distance _pos < 2500) then {_intenzity = "Far";};
	_SoundTurbolence = "interiorTurbolance"+_intenzity;
	playsound _SoundTurbolence;
};
};

// -- Creation of Invisible Helipod which is spreading to a player
if ((isPlayer _unit or player in _unit)and(_unit distance _pos < 2500)) then
{
_soundPos = "HeliHEmpty" createVehicle (position _pos);
};
// -- Cycle which waits for a heatWave comes to a player
while {heatWaveSpreadDistance < _rad} do
{
_rad = _unit distance _pos;
_xPos = ((position _unit select 0) - (position _pos select 0));
_yPos = ((position _unit select 1) - (position _pos select 1));
if (_xPos >= 0 and _yPos >= 0) then {_fi = 0  + atan (abs(_yPos / _xPos));};
if (_xPos >= 0 and _yPos < 0) then {_fi = 270 + atan (abs(_xPos / _yPos));};
if (_xPos < 0 and _yPos < 0) then {_fi = 180 + atan (abs(_yPos / _xPos));};
if (_xPos < 0 and _yPos >= 0) then {_fi = 90 + atan (abs(_xPos / _yPos));};
_xSpos = shockWaveSpreadDistance * cos (_fi); _ySpos = shockWaveSpreadDistance * sin (_fi);
_soundPos setPos [((getPos _pos select 0)+_xSPos),((getPos _pos select 1)+_ySPos),(getPos _unit select 2)];
sleep 0.1;
};

// Sound of HeatWave impact to a unit or vehicle
if ((isPlayer _unit or player in _unit)and(_unit distance _pos < 2500)) then
{
if (_coef == 180) then {_material = "Body";} else {_material = "Metal";};
if (player distance _pos < 600) then {_intenzity = "Close";};
if (player distance _pos >= 600 and player distance _pos < 1100) then {_intenzity = "Standard";};
if (player distance _pos >= 1100 and player distance _pos < 2500) then {_intenzity = "Far";};
_Sound = "impact"+_material+"Soft"+_intenzity;
if (player distance _pos < 2500) then { playsound _Sound;};
};

// -- Damage applied by a HeatWave to a unit or vehicle
/*	// -- Overpressure in air
_xPos = ((position _unit select 0) - (position _pos select 0));
_yPos = ((position _unit select 1) - (position _pos select 1));
_zPos = ((position _unit select 2) - (position _pos select 2));

_GR = sqrt(_xPos^2 + _yPos^2);
_zMaxima = 8 * _GR^0.5;
_zChange = 15 * _GR^0.5;

if (_zPos > _zChange) then
	{
	_rad = _unit distance _pos;
	_crossXUp = 1/2*(sqrt(4*_rad^2+50625)-225);
	_crossZUp = 15 * _crossXUp^0.5;
	_k2 =(_crossZUp + 300)/(_crossXUp - 4000);
	_q2 = _crossZUp - _crossXUp*_k2;
	_crossXInter = (- _k2*_q2-8*sqrt(16-_k2*_q2)+32)/_k2^2;
	_crossZInter = 8 * _crossXInter^0.5;
	_k1 =(_crossZInter + 500)/(_crossXInter - 150);										
	_x0 = (-500 + _k1*150)/ _k1;
	};	

if (_zPos > _zMaxima and _zPos <= _zChange) then
	{
	_k2 =(_zPos + 300)/(_GR - 4000);
	_q2 = _zPos - _GR*_k2;
	_crossXInter = (- _k2*_q2-8*sqrt(16-_k2*_q2)+32)/_k2^2;
	_crossZInter = 8 * _crossXInter^0.5;
	_k1 =(_crossZInter + 500)/(_crossXInter - 150);										
	_x0 = (-500 + _k1*150)/ _k1;
	};

if (_zPos <= _zMaxima) then
	{
	_k1 =(_zPos + 500)/(_GR - 150);
	_x0 = (-500 + _k1*150)/ _k1;
	};

_kT = 1;
_overPressure =((15.071*_kT^0.5131)*(_x0/1000)^(-0.016*ln(_kT) - 1.4113))*10^9;

_xPos = ((position _unit select 0) - (position _pos select 0));
_yPos = ((position _unit select 1) - (position _pos select 1));
if (_xPos >= 0 and _yPos >= 0) then {_fi = 0  + atan (abs(_yPos / _xPos));};
if (_xPos >= 0 and _yPos < 0) then {_fi = 270 + atan (abs(_xPos / _yPos));};
if (_xPos < 0 and _yPos < 0) then {_fi = 180 + atan (abs(_yPos / _xPos));};
if (_xPos < 0 and _yPos >= 0) then {_fi = 90 + atan (abs(_xPos / _yPos));};


_force = _overpressure * _cubature;


_dam = _overPressure / 145;





if (_dam > 1) then {_dam = 1;};











*/
_dam = _coef^3.5 / _rad^3;
if (_dam > 1) then {_dam = 1;};
if (_dam > 0.05) then {nil = [_unit, 0.5, 0.0, false, true] spawn BIS_Effects_Burn;};
if (_dam > 0.5) then {nil = [_unit, 3, 0.0, false, true] spawn BIS_Effects_Burn;};
_unit setDamage ((Damage _unit) + _dam);

// -- Cycle which waits for a shockWave comes to a player
while {shockWaveSpreadDistance < _rad} do {
_rad = _unit distance _pos;
_xPos = ((position _unit select 0) - (position _pos select 0));
_yPos = ((position _unit select 1) - (position _pos select 1));
if (_xPos >= 0 and _yPos >= 0) then {_fi = 0  + atan (abs(_yPos / _xPos));};
if (_xPos >= 0 and _yPos < 0) then {_fi = 270 + atan (abs(_xPos / _yPos));};
if (_xPos < 0 and _yPos < 0) then {_fi = 180 + atan (abs(_yPos / _xPos));};
if (_xPos < 0 and _yPos >= 0) then {_fi = 90 + atan (abs(_xPos / _yPos));};
_xSpos = shockWaveSpreadDistance * cos (_fi);
_ySpos = shockWaveSpreadDistance * sin (_fi);
_soundPos setPos [((getPos _pos select 0)+_xSPos),((getPos _pos select 1)+_ySPos),(getPos _unit select 2)];
if (_unit distance _soundPos < ln(10000 - shockWaveSpreadDistance)*32) then {
if (player distance _pos < 600) then {_intenzity = "Close";};
if (player distance _pos >= 600 and player distance _pos < 1100) then {_intenzity = "Standard";};
if (player distance _pos >= 1100 and player distance _pos < 2500) then {_intenzity = "Far";};
_SoundWave = "shockwave"+_intenzity;
playsound _SoundWave; playSound "rhumble";
};
sleep 0.1;
};

// -- Sound of ShockWave impact to a unit or vehicle
if ((isPlayer _unit or player in _unit)and(_unit distance _pos < 2500)) then {
if (player distance _pos < 600) then {_intenzity = "Close";};
if (player distance _pos >= 600 and player distance _pos < 1100) then {_intenzity = "Standard";};
if (player distance _pos >= 1100 and player distance _pos < 2500) then {_intenzity = "Far";};
_Sound = "impact"+_material+"Hard"+_intenzity;
if (player distance _pos < 2500) then { playsound _Sound;};
deleteVehicle _soundPos;
};

// -- Final Declaration of Shockwave impact into a car
_xPos = ((position _unit select 0) - (position _pos select 0));
_yPos = ((position _unit select 1) - (position _pos select 1));

if (_xPos >= 0 and _yPos >= 0) then {_fi = 0  + atan (abs(_yPos / _xPos));};
if (_xPos >= 0 and _yPos < 0) then {_fi = 270 + atan (abs(_xPos / _yPos));};
if (_xPos < 0 and _yPos < 0) then {_fi = 180 + atan (abs(_yPos / _xPos));};
if (_xPos < 0 and _yPos >= 0) then {_fi = 90 + atan (abs(_xPos / _yPos));};

// -- Damage applied by a ShockWave to a unit or vehicle
_dam = _coef^5 / _rad^4;
if (_dam > 1) then {_dam = 1;};
_unit setDamage ((Damage _unit) + _dam);

// -- Part which is counting with Shock Force and Leaning of vehicle or unit
if (_coef > 10) then
{
_force = ln(_coef^2.5 / _rad^1.6)/3*20;
if (_force < 0) then {_force = 0};
// Separating elements of Force and velocity into coordinates
_xF = _force * cos(_fi);
_yF = _force * sin(_fi);
_zF = _force / 3;

_vel = velocity _unit;
_vecUp = vectorUp _unit;	

_xVel = _vel select 0;
_yVel = _vel select 1;
_zVel = _vel select 2;
// Check in which way is vehicle moving and some speed correction of it
if (_xVel >= 0 and _yVel >= 0) then {_omega = 0  + atan (abs(_yVel / _xVel));};
if (_xVel >= 0 and _yVel < 0) then {_omega = 270 + atan (abs(_xVel / _yVel));};
if (_xVel < 0 and _yVel < 0) then {_omega = 180 + atan (abs(_yVel / _xVel));};
if (_xVel < 0 and _yVel >= 0) then {_omega = 90 + atan (abs(_xVel / _yVel));};
_diferencial = abs(_omega - _fi);
if (_diferencial > 90 and _diferencial < 270) then
	{
	_xVel = _xVel * (cos(_diferencial)+2)/ ln(_coef/7.77);
	_yVel = _yVel * (cos(_diferencial)+2)/ ln(_coef/7.77);
	};

_nY = 0; _nX = 0; _nXX = 0; _nYY = 0; _fXX = 0; _fYY = 0; _fZZ = 0;
_n = (_vecUp select 0)^2 + (_vecUp select 1)^2;
// -- Setting up for Leaning
_leanF = ln(_coef^3 / _rad^2) / 3;
if (_leanF < 0) then {_leanF = 0};

_nX = _leaner * cos (_fi);
_nY = _leaner * sin (_fi);
_cyklus = abs((_leanF - _n) / _leaner);
_xxF = _xF/_cyklus;
_yyF = _yF/_cyklus;
_zzF = _zF/_cyklus;
// -- Finfing out on what side unit should lean
if ((_vecUp select 0) >= 0 and (_vecUp select 1) >= 0) then {_theta = 0  + atan (abs((_vecUp select 1) / (_vecUp select 0)));};
if ((_vecUp select 0) >= 0 and (_vecUp select 1) < 0) then {_theta = 270 + atan (abs((_vecUp select 0) / (_vecUp select 1)));};
if ((_vecUp select 0) < 0 and (_vecUp select 1) < 0) then {_theta = 180 + atan (abs((_vecUp select 1) / (_vecUp select 0)));};
if ((_vecUp select 0) < 0 and (_vecUp select 1) >= 0) then {_theta = 90 + atan (abs((_vecUp select 0) / (_vecUp select 1)));};
_diference = abs(_theta - _fi);

if (_diference < 270 and _diference > 90) then {_nX = -_nX; _nY = -_nY;};
// -- Cycle which will Lean unit and push it in wright way (also lock units in vehicle)
while {_n < _leanF} do
	{
      		sleep 0.01;
      		_unit setvectorup [(_vecUp select 0)+_nXX,(_vecUp select 1)+_nYY,(_vecUp select 2)];
		_nXX = _nXX + _nX; _nYY = _nYY + _nY; _n = _n + _leaner;
		_unit setVelocity [(_xVel+_fXX),(_yVel+_fYY),((_vel select 2)+_zF)];
		_fXX = _fXX + _xxF; _fyy = _fyy + _yyF; _fzz = _fzz + _zzF;
		{_x disableAI "MOVE";} forEach crew _unit;
		_unit lock true;
     	};
_unit setVelocity [(_xVel+_xF),(_yVel+_yF),(_zVel+_zF)];	
};

sleep 5;
// -- Opening vehicle
		{_x enableAI "MOVE";} forEach crew _unit;
		_unit lock false;

// -- Aftershock (Cycle which counts with Heat and Radioation in time)
_timeAfter = 0;

if (damage _unit < 1) then {			   //9000
while {damage _unit < 1  or _timeAfter < 9000} do { 			   //250
		if (_timeAfter <= 250) then
		{
		_heatRad = (_coef^4/(_unit distance _pos)^4)*(cos(_timeAfter/250*180)+1)/2*3/4;
		};
		_radRad  = (_coef^4/(_unit distance _pos)^4)*(cos(_timeAfter/9000*180)+1)/2*1/4;
		_unit setDamage (Damage _unit + _heatRad + _radRad);
		{_unit setDamage  (Damage _unit + (_heatRad + _radRad)/ln(_coef / 2))} forEach crew _unit;

		_plus = (2.5 + random 1);
		sleep _plus;
		_timeAfter = _timeAfter + _plus;
		};
};

Its push made by a shockwave (for my Nuke script recently added here on forum)

Edited by Khalashnikovf

Share this post


Link to post
Share on other sites

Nothing connected with launching script.

Its like AZCoder said, I need to spawn it, but have no idea how is that works

Share this post


Link to post
Share on other sites

{[_x,_pos] spawn ShockpushPreLoad} forEach _array;

While you're at it you might want to change preprocessFile to preprocessFileLineNumbers for debuging purposes.

Share this post


Link to post
Share on other sites
{[_x,_pos] spawn ShockpushPreLoad} forEach _array;

While you're at it you might want to change preprocessFile to preprocessFileLineNumbers for debuging purposes.

Dont understand the point. I need something about Spawn of that script i SPOILED a bit above.

Share this post


Link to post
Share on other sites
sleep won't work in a function initiated with a call command.

Which isn't completely correct.

It depends on from which environment you execute the call.

If done from scheduled environment (script executed with execVM, spawn; init.sqf falls under it too)

sleep and waitUntil is fine in a call, but the calling script waits until the call is finished.

It won't work in the non scheduled environment (EHs, triggers, etc.).

Beside that, _pos nearObjects ["Man", 50000] is quite an expensive operation.

Xeno

Share this post


Link to post
Share on other sites

@Khalashnikovf: the preprocessFileLineNumbers will give a bit more info on errors in the script, such as the line # of an error

@Deadfast: thanks for the spawn, took me a couple days to get back to this thread :)

@Xeno: actually didn't realize that init.sqf fell into this category, but you're right.

Share this post


Link to post
Share on other sites

So, thanks for all help with this preprocess and spawn thing but i figured out that its still doesnt work for me like I want.

Well, it works like it should, but after restart of mission.

For the first time its just completely overloaded and mission got stuck for at least 5 - 10 seconds.

Any suggestions what with that?

Here are all script running for that all mess...

Init:

waitUntil {player == player};
ShockpushPreLoad = compile preprocessFileLineNumbers "lk\nuke\shockpush.sqf";
ShockWavePreLoad = compile preprocessFileLineNumbers "lk\nuke\shockawe.sqf";
NukePreLoad = compile preprocessFileLineNumbers "lk\nuke\nuke.sqf";

nuke_countdown.sqf

//----------------------------------------------------------------------
// Script for countdown of Nuclear explosion
//
// Example nul = [center,10] execvm "lk\nuke\shockawe.sqf";
// center is center of explosion, 10 is countdown time in seconds
//
// Made by Khalashnikovf
//----------------------------------------------------------------------

_pos = _this select 0;
_t = _this select 1;
prelaunch = _this select 2;

_s = 0; _zh = 0;
_m = 0; _zm = 0;
_h = 0; _zs = 0;
_earlier = false;

if (_t < 60) then
{
_s = _t;
};

if (_t >= 60) then
{
_m = floor(_t / 60);
_s = _t - 60*_m;
if (_m >= 60) then
	{
	_h = floor(_m / 60);
	_m = _m - 60*_h;
	};
};

if (_h < 10) then {_zh = "0";} else {_zh = "";};
if (_m < 10) then {_zm = "0";} else {_zm = "";};
if (_s < 10) then {_zs = "0";} else {_zs = "";};

hintSilent parseText format ["<t color='#ff3300' size='2.0' shadow='1' shadowColor='#000000' align='center'>%1%2:%3%4:%5%6</t>",_zh,_h,_zm,_m,_zs,_s];

while {_t > 0} do
{
if (_s == 0) then
{
	_s = 60;
	_m = _m - 1;
	if (_m <= 0 and _h > 0) then {_m = 59; _h = _h - 1;};
};

_s = _s - 1;
_t = _t - 1;

if (_h < 10) then {_zh = "0";} else {_zh = "";};
if (_m < 10) then {_zm = "0";} else {_zm = "";};
if (_s < 10) then {_zs = "0";} else {_zs = "";};

sleep 1;
hintSilent parseText format ["<t color='#ff3300' size='2.0' shadow='1' shadowColor='#000000' align='center'>%1%2:%3%4:%5%6</t>",_zh,_h,_zm,_m,_zs,_s];

// random launch of Nuke earlier than after countdown	
_trig = random ceil 80;
if (_t < 10 and _trig > 0 and _trig < 3 and !_earlier and prelaunch) then
{
nul = [_pos] execvm "lk\nuke\nuke.sqf";
_earlier = true; _t = 0;
};
//---------------------------------------------------	
};

delay = ceil random 5;

while { _t < delay} do {
hintSilent parseText format ["<t color='#ff3300' size='2.0' shadow='1' shadowColor='#000000' align='center'>%1%2:%3%4:%5%6</t>",_zh,_h,_zm,_m,_zs,_s];
sleep 0.2;
hintSilent parseText format ["<t color='#ffaa00' size='2.0' shadow='1' shadowColor='#000000' align='center'>%1%2:%3%4:%5%6</t>",_zh,_h,_zm,_m,_zs,_s];
sleep 0.2;
_t = _t + 0.4;
};

if (!_earlier) then {
[_pos] spawn NukePreLoad;
};

nuke.sqf (by lk with little time modifications (maybe its that problem, that I shorten some first sleep times to minimum to avoid such a long wait for blast))

_pos = _this select 0;

nul = [] execVM "lk\nuke\nenvi.sqf";

if (player distance _pos < 6000) then {
// setup of overbrigtness since inpact
setaperture 3;

"dynamicBlur" ppEffectEnable true;
"dynamicBlur" ppEffectAdjust [0.5];
"dynamicBlur" ppEffectCommit 0.5; //2

sleep 0.3;

"dynamicBlur" ppEffectAdjust [2];
"dynamicBlur" ppEffectCommit 0.4; //1

"dynamicBlur" ppEffectAdjust [1];
"dynamicBlur" ppEffectCommit 0.5; //2

};

sleep 1; //1

//*******************************************************************
//*******************************************************************

_Cone = "#particlesource" createVehicleLocal getpos _pos;
_Cone setParticleParams [["\Ca\Data\ParticleEffects\Universal\Universal", 16, 7, 48], "", "Billboard", 1, 10, [0, 0, 0],
			[0, 0, 0], 0, 1.275, 1, 0, [40,80], [[0.25, 0.25, 0.25, 0], [0.25, 0.25, 0.25, 0.5], 
			[0.25, 0.25, 0.25, 0.5], [0.25, 0.25, 0.25, 0.05], [0.25, 0.25, 0.25, 0]], [0.25], 0.1, 1, "", "", _pos];
_Cone setParticleRandom [2, [1, 1, 30], [1, 1, 30], 0, 0, [0, 0, 0, 0.1], 0, 0];
_Cone setParticleCircle [10, [-10, -10, 20]];
_Cone setDropInterval 0.005;

_top = "#particlesource" createVehicleLocal getpos _pos;
_top setParticleParams [["\Ca\Data\ParticleEffects\Universal\Universal", 16, 3, 48, 0], "", "Billboard", 1, 21, [0, 0, 0],
			[0, 0, 65], 0, 1.7, 1, 0, [100,80,110], [[1, 1, 1, -10],[1, 1, 1, -7],[1, 1, 1, -4],[1, 1, 1, -0.5],[1, 1, 1, 0]], [0.05], 1, 1, "", "", _pos];
_top setParticleRandom [0, [75, 75, 15], [17, 17, 10], 0, 0, [0, 0, 0, 0], 0, 0, 360];
_top setDropInterval 0.002;

_top2 = "#particlesource" createVehicleLocal getpos _pos;
_top2 setParticleParams [["\Ca\Data\ParticleEffects\Universal\Universal", 16, 3, 112, 0], "", "Billboard", 1, 22, [0, 0, 0],
			[0, 0, 60], 0, 1.7, 1, 0, [100,80,100], [[1, 1, 1, 0.5],[1, 1, 1, 0]], [0.07], 1, 1, "", "", _pos];
_top2 setParticleRandom [0, [75, 75, 15], [17, 17, 10], 0, 0, [0, 0, 0, 0], 0, 0, 360];
_top2 setDropInterval 0.002;


_smoke = "#particlesource" createVehicleLocal getpos _pos;
_smoke setParticleParams [["\Ca\Data\ParticleEffects\Universal\Universal", 16, 7, 48, 1], "", "Billboard", 1, 25, [0, 0, 0],
			[0, 0, 70], 0, 1.7, 1, 0, [50,20,120], 
			[[1, 1, 1, 0.4],[1, 1, 1, 0.7],[1, 1, 1, 0.7],[1, 1, 1, 0.7],[1, 1, 1, 0.7],[1, 1, 1, 0.7],[1, 1, 1, 0.7],[1, 1, 1, 0]]
			, [0.5, 0.1], 1, 1, "", "", _pos];
_smoke setParticleRandom [0, [10, 10, 15], [15, 15, 7], 0, 0, [0, 0, 0, 0], 0, 0, 360];
_smoke setDropInterval 0.002;


_Wave = "#particlesource" createVehicleLocal getpos _pos;
_Wave setParticleParams [["\Ca\Data\ParticleEffects\Universal\Universal", 16, 7, 48], "", "Billboard", 1, 20/2, [0, 0, 0],
			[0, 0, 0], 0, 1.5, 1, 0, [50, 100], [[0.1, 0.1, 0.1, 0.5], 
			[0.5, 0.5, 0.5, 0.5], [1, 1, 1, 0.3], [1, 1, 1, 0]], [1,0.5], 0.1, 1, "", "", _pos];
_Wave setParticleRandom [2, [20, 20, 20], [5, 5, 0], 0, 0, [0, 0, 0, 0.1], 0, 0];
_Wave setParticleCircle [50, [-80, -80, 2.5]];
_Wave setDropInterval 0.0002;

_light = "#lightpoint" createVehicleLocal [((getpos _pos select 0)),(getpos _pos select 1),((getpos _pos select 2)+800)];
_light setLightAmbient[1500, 1200, 1000];
_light setLightColor[1500, 1200, 1000];
_light setLightBrightness 1000000.0;

//*******************************************************************
//*******************************************************************

sleep 0.5; //3

_Wave setDropInterval 0.001;
deletevehicle _top;
deletevehicle _top2;

sleep 0.5;

player spawn envi;
[_pos] spawn ShockWavePreLoad;
// -- color correction into red blasted one
_hndl = ppEffectCreate ["colorCorrections", 1501];
_hndl ppEffectEnable true;
_hndl ppEffectAdjust[ 1, 1, 0, [0, 0, 0, 0.5],[1.2, 0.05, -0.12, 0.5],[0.2, 0.59, 0.11, 0]];
_hndl ppEffectCommit 4;

player spawn quake;


if (player distance _pos < 1000) then {playsound "nuke2s";};
if (player distance _pos > 1000) then {playsound "nuke1s";};

sleep 1;
setaperture -1;

_top3 = "#particlesource" createVehicleLocal getpos _pos;
_top3 setParticleParams [["\Ca\Data\ParticleEffects\Universal\Universal", 16, 3, 48, 0], "", "Billboard", 1, 24, [0, 0, 450],
			[0, 0, 49], 0, 1.7, 1, 0, [120,130,150], [[1, 1, 1, -10],[1, 1, 1, -7],[1, 1, 1, -4],[1, 1, 1, -0.5],[1, 1, 1, 0]], [0.05], 1, 1, "", "", _pos];
_top3 setParticleRandom [0, [75, 75, 15], [17, 17, 10], 0, 0, [0, 0, 0, 0], 0, 0, 360];
_top3 setDropInterval 0.002;
sleep 4;
deletevehicle _top3;

sleep 4;
// -- color correction into yellow aftershock one
_hndl = ppEffectCreate ["colorCorrections", 1501];
_hndl ppEffectEnable true;
_hndl ppEffectAdjust[ 1, 1, 0, [0, 0, 0, 0.6],[2.8, 2.5, 0.7, 0.4],[0.2, 0.59, 0.11, 0]];
_hndl ppEffectCommit 5;

if (player distance _pos < 4000) then {
"dynamicBlur" ppEffectAdjust [0];
"dynamicBlur" ppEffectCommit 1;
};

_top4 = "#particlesource" createVehicleLocal getpos _pos;
_top4 setParticleParams [["\Ca\Data\ParticleEffects\Universal\Universal", 16, 3, 48, 0], "", "Billboard", 1, 22, [0, 0, 770],
			[0, 0, 30], 0, 1.7, 1, 0, [100,120,140], [[1, 1, 1, -10],[1, 1, 1, -7],[1, 1, 1, -4],[1, 1, 1, -0.5],[1, 1, 1, 0]], [0.05], 1, 1, "", "", _pos];
_top4 setParticleRandom [0, [75, 75, 15], [17, 17, 10], 0, 0, [0, 0, 0, 0], 0, 0, 360];
_top4 setDropInterval 0.002;
sleep 3;

_top4 setParticleParams [["\Ca\Data\ParticleEffects\Universal\Universal", 16, 3, 48, 0], "", "Billboard", 1, 25, [0, 0, 830],
			[0, 0, 30], 0, 1.7, 1, 0, [100,120,140], [[1, 1, 1, -10],[1, 1, 1, -7],[1, 1, 1, -4],[1, 1, 1, -0.5],[1, 1, 1, 0]], [0.05], 1, 1, "", "", _pos];



_Wave setDropInterval 0.001*10;
_Wave setParticleParams [["\Ca\Data\ParticleEffects\Universal\Universal", 16, 7, 48], "", "Billboard", 1, 20/2, [0, 0, 0],
			[0, 0, 0], 0, 1.5, 1, 0, [50, 100], [[0.1, 0.1, 0.1, 0.5], 
			[0.5, 0.5, 0.5, 0.5], [1, 1, 1, 0.3], [1, 1, 1, 0]], [1,0.5], 0.1, 1, "", "", _pos];
_Wave setParticleCircle [50, [-40, -40, 2.5]];

player spawn ash;
windv=true;
player spawn wind;
30 setovercast 0.8;

deleteVehicle _light;

60 setRain 1;

sleep 4;
// -- color correction into grey cold ash
_hndl = ppEffectCreate ["colorCorrections", 1501];
_hndl ppEffectEnable true;
_hndl ppEffectAdjust[ 1, 1, 0, [0, 0, 0, 0.8],[-0.09, 0.96, 2.63, 0.6],[0.4, 0.59, 0.11, 0]];
_hndl ppEffectCommit 120; //120

deletevehicle _top4;

_i = 0;
while {_i < 100} do
{
_light setLightBrightness (100.0 - _i)/100;
_i = _i + 1;
sleep 0.1;
};


for "_i" from 0 to 15 do {
_smoke setParticleParams [["\Ca\Data\ParticleEffects\Universal\Universal", 16, 7, 48, 1], "", "Billboard", 1, 25, [0, 0, 0],
				[0, 0, 60+_i], 0, 1.7, 1, 0, [40,15,120], 
				[[1, 1, 1, 0.4],[1, 1, 1, 0.7],[1, 1, 1, 0.7],[1, 1, 1, 0.7],[1, 1, 1, 0.7],[1, 1, 1, 0.7],[1, 1, 1, 0.7],[1, 1, 1, 0]]
				, [0.5, 0.1], 1, 1, "", "", _pos];
};


_timeNow = time;
waituntil {(time - _timeNow) > 300}; //300

_smoke setParticleParams [["\Ca\Data\ParticleEffects\Universal\Universal", 16, 7, 48, 1], "", "Billboard", 1, 25, [0, 0, 0],
			[0, 0, 30], 0, 1.7, 1, 0, [40,25+10,80], 
			[[1, 1, 1, 0.2],[1, 1, 1, 0.3],[1, 1, 1, 0.3],[1, 1, 1, 0.3],[1, 1, 1, 0.3],[1, 1, 1, 0.3],[1, 1, 1, 0.3],[1, 1, 1, 0]]
			, [0.5, 0.1], 1, 1, "", "", _pos];

_smoke setDropInterval 0.012;
_Cone setDropInterval 0.02;
_Wave setDropInterval 0.01;

sleep 10;
deleteVehicle _Wave;
deleteVehicle _cone;
deleteVehicle _smoke;
deletevehicle snow;
// -- color correction into almost origin
_hndl = ppEffectCreate ["colorCorrections", 1501];
_hndl ppEffectEnable true;
_hndl ppEffectAdjust[ 1, 1, 0, [0, 0, 0, 0.71],[0.48, 1.19, 0.4, 1.09],[0.2, 0.69, 0.11, 0]];
_hndl ppEffectCommit 280; //280

sleep 300; //300


"filmGrain" ppEffectEnable false;
sleep 10;
"colorCorrections" ppEffectEnable false;
sleep 10;
60 setovercast 0;
windv=false;

setwind [0,0,true];

shockawe.sqf

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Shockwave script 0.9
//
// Made by Khalashnikovf
// Thanks to lk and his awesome Nuke script
//
// Script is working to best of simulates effect caused by huge esplosion which is affecting close by units.
// Whole effect is based on speed of spreading wave in air and its power according to distance from center of explosion.
// Function works in hyperbolic and logharithm curves to make most believeble progress of blast
// It also "waporize" closest units especially men.
//
// Example: nul = [center] execvm "lk\nuke\shockawe.sqf"; (center is a center of explosion)
//
// Completed work: Almost everything
// Work to be done: so far so good
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

_pos = _this select 0;
_spread = 300;  // speed of shockwave in air (speed of sound is 340)
_spreadHeat = 800; // speed of heat wave in air

deletemarkerlocal "nukemarker";

nul = [_pos] execVM "lk\nuke\shockaweStatic.sqf";

// Instant waporazing of any vehicle or unit in closest area to Blast

heatWaveSpreadDistance = 0;
shockWaveSpreadDistance = 0;

_array = _pos nearObjects ["Motorcycle",100];
{deleteVehicle _x;} forEach _array;
_array = _pos nearObjects ["Car",100];
{deleteVehicle _x;} forEach _array;
_array = _pos nearObjects ["StaticWeapon", 100];
{deleteVehicle _x;} forEach _array;
_array = _pos nearObjects ["Tank", 75];
{deleteVehicle _x;} forEach _array;
_array = _pos nearObjects ["Ship", 100];
{deleteVehicle _x;} forEach _array;
_array = _pos nearObjects ["Air",50];
{deleteVehicle _x;} forEach _array;
_array = _pos nearObjects ["Man", 150];
{deleteVehicle _x;} forEach _array;
_array = _pos nearObjects ["Thing", 600];
{_x setDamage 1;} forEach _array;

// Shockwave affect
_array = _pos nearObjects ["Man", 50000];
{[_x,_pos] spawn ShockpushPreLoad} forEach _array;
//nul = [_x,_pos] execvm "lk\nuke\shockpush.sqf";
_array = _pos nearObjects ["Air",50000];
{[_x,_pos] spawn ShockpushPreLoad} forEach _array;

_array = _pos nearObjects ["Motorcycle",50000];
{[_x,_pos] spawn ShockpushPreLoad} forEach _array;

_array = _pos nearObjects ["Car",50000];
{[_x,_pos] spawn ShockpushPreLoad} forEach _array;

_array = _pos nearObjects ["Tank", 50000];
{[_x,_pos] spawn ShockpushPreLoad} forEach _array;

_array = _pos nearObjects ["Ship", 50000];
{[_x,_pos] spawn ShockpushPreLoad} forEach _array;

_array = _pos nearObjects ["StaticWeapon", 50000];
{[_x,_pos] spawn ShockpushPreLoad} forEach _array;

nul = [_pos] execVM "lk\nuke\radzone.sqf";

while {shockWaveSpreadDistance < 9999} do {
heatWaveSpreadDistance = heatWaveSpreadDistance + ln(30000 - heatWaveSpreadDistance)*78/10;
shockWaveSpreadDistance = shockWaveSpreadDistance + ln(10000 - shockWaveSpreadDistance)*32/10;
sleep 0.1;
};

shockaweStatic.sqf (for everything in closest area and all buildings so far)

private ["_array","_pos","_rad","_force","_xPos","_yPos","_push","_time","_xVel","_yVel","_zVel","_coef"];

_pos = _this select 0;

sleep (200/180);

{_x setDamage 1} forEach nearestObjects [_pos,[],400];

sleep (300/180);

_array = _pos nearObjects ["Strategic", 900];
{if (_x distance _pos > 400) then {_x setDamage (0.9999);};} forEach _array;
_array = _pos nearObjects ["NonStrategic", 900];
{if (_x distance _pos > 400) then {_x setDamage (0.9999);};} forEach _array;

sleep (400/180);

_array = _pos nearObjects ["Strategic", 1500];
{if (_x distance _pos > 900) then {_x setDamage (0.5 + random 0.3);};} forEach _array;
_array = _pos nearObjects ["NonStrategic", 1500];
{if (_x distance _pos > 900) then {_x setDamage (0.5 + random 0.3);};} forEach _array;

shockpush.sqf (this script is runned for even a hundred times ... depends on number of unit in world)

private ["_unit","_pos","_rad","_force","_xPos","_yPos","_xVel","_yVel","_zVel","_coef","_fi",
"_n","_fi","_dam","_vel","_vecUp","_nX","_nY","_nXX","_nYY","_leanF","_leanX","_leanY","_cyklus","_theta",
"_diference","_fXX","_fYY","_fZZ","_xxF","_yyF","_zzF","_spread","_omega","_heatRad","_timeAfter","_plus","_radRad",
"_material","_intenzity","_Sound","_soundPos","_SoundWave","_SoundTurbolence","_lenght","_height","_width","_weight",
"_weakness1","_weakness2","_cubature","_acc","_steel"];

// -- Declaration
_unit = _this select 0; 		// unit affected by shockwave
_pos = _this select 1;  		// centre of explosion

_theta = 0;
_omega = 0;
_n = 0;
_coef = 0;
_fi = 0;
_leaner = 0.04; // how quickly will units lean into right position after impact

// -- vehicle properties
_lenght = 0;
_height = 0;
_width = 0;
_weight = 0;
_weakness1 = "";
_weakness2 = "";
_steel = 0; //1 - Human , 2 - Cars , 3 - Trucks,Choppers,Planes, 4 - HMMWV,Jackal, 8 - T34,T55,APC, 10 - M1A1,T72,T90

// BAF_FV510_D , BAF_ATV_D , BAF_Jackal2_GMG_D , BAF_Jackal2_L2A1_D , BAF_Offroad_D

// -- Declaration of Unit type
if (_unit isKindOf "Car") then {_coef = 140; _lenght = 4.5; _height = 1.3; _width = 1.6; _weight = 800;};
if (_unit isKindOf "Bus") then {_coef = 140;  _lenght = 10; _height = 3; _width = 2.5; _weight = 5800;};
if (_unit isKindOf "HMMWV_Base") then {_coef = 140; _lenght = 4.6; _height = 1.8; _width = 1.8; _weight = 2340;};
if (_unit isKindOf "SUV_Base_EP1") then {_coef = 140; _lenght = 4.8; _height = 1.7; _width = 1.8; _weight = 2340;};
if (_unit isKindOf "ArmoredSUV_Base_PMC") then {_coef = 140; _lenght = 4.8; _height = 1.7; _width = 1.8; _weight = 2540;};
if (_unit isKindOf "Lada_base") then {_coef = 140; _lenght = 4.0; _height = 1.3; _width = 1.6; _weight = 800;};
if (_unit isKindOf "Offroad_DSHKM_base") then {_coef = 140; _lenght = 4.12; _height = 1.8; _width = 1.64; _weight = 800;};
if (_unit isKindOf "Pickup_PK_base") then {_coef = 140; _lenght = 4.1; _height = 1.8; _width = 1.6; _weight = 1000;};
if (_unit isKindOf "LandRover_Base") then {_coef = 140; _lenght = 4.1; _height = 1.8; _width = 1.6; _weight = 1500;};		
if (_unit isKindOf "SkodaBase") then {_coef = 140; _lenght = 4.16; _height = 1.4; _width = 1.595; _weight = 800;};
if (_unit isKindOf "tractor") then {_coef = 140; _lenght = 3.67; _height = 2.71; _width = 1.91; _weight = 3740;};
if (_unit isKindOf "Truck") then {_coef = 140; _lenght = 7.35; _height = 3.09; _width = 2.40; _weight = 10210;};
if (_unit isKindOf "MAZ_543_SCUD_Base_EP1") then {_coef = 120; _lenght = 12.35; _height = 4.09; _width = 3.80; _weight = 16300;};
if (_unit isKindOf "ATV_Base_EP1") then {_coef = 140; _lenght = 2.12; _height = 1.09; _width = 1.20; _weight = 100;};
if (_unit isKindOf "UAZ_Base") then {_coef = 140; _lenght = 4.02; _height = 2.05; _width = 1.78; _weight = 1650;};
if (_unit isKindOf "Wheeled_APC") then {_coef = 140; _lenght = 5.50; _height = 2.35; _width = 2.30; _weight = 5300;};
if (_unit isKindOf "Motorcycle") then {_coef = 150; _lenght = 1.33; _height = 0.83; _width = 0.3; _weight = 105;};
if (_unit isKindOf "Tank") then {_coef = 120; _lenght = 9.82; _height = 2.72; _width = 3.79; _weight = 48200;};
if (_unit isKindOf "2S6M_Tunguska") then {_coef = 120; _lenght = 9.82; _height = 2.72; _width = 3.79; _weight = 48200;};
if (_unit isKindOf "APC") then {_coef = 120; _lenght = 5.50; _height = 2.35; _width = 2.30; _weight = 5300;};
if (_unit isKindOf "StrykerBase_EP1") then {_coef = 120; _lenght = 6.95; _height = 2.64; _width = 2.72; _weight = 24000;};
if (_unit isKindOf "Tracked_APC") then {_coef = 120; _lenght = 7.94; _height = 3.26; _width = 3.27; _weight = 29100;};
if (_unit isKindOf "M1A1") then {_coef = 120; _lenght = 7.93; _height = 2.4; _width = 3.66; _weight = 61300;};
if (_unit isKindOf "M2A2_Base") then {_coef = 120; _lenght = 6.55; _height = 2.98; _width = 3.60; _weight = 27600;};
if (_unit isKindOf "T34") then {_coef = 120; _lenght = 6.68; _height = 2.45; _width = 3.00; _weight = 26500;};
if (_unit isKindOf "T72_Base") then {_coef = 120; _lenght = 6.95; _height = 2.23; _width = 3.59; _weight = 41500;};
if (_unit isKindOf "T90") then {_coef = 120; _lenght = 9.53; _height = 2.22; _width = 3.78; _weight = 46500;};
if (_unit isKindOf "ZSU_Base") then {_coef = 120; _lenght = 6.53; _height = 2.57; _width = 3.12; _weight = 16000;};
if (_unit isKindOf "MLRS_base") then {_coef = 120; _lenght = 6.85; _height = 2.59; _width = 2.97; _weight = 24950;};
if (_unit isKindOf "Man") then {_coef = 180; _lenght = 0.35; _height = 1.77; _width = 0.41; _weight = 90;};
if (_unit isKindOf "Cow") then {_coef = 180; _lenght = 3.03; _height = 1.45; _width = 0.5; _weight = 750;};
if (_unit isKindOf "Goat") then {_coef = 200; _lenght = 1.53; _height = 0.70; _width = 0.4; _weight = 80;};
if (_unit isKindOf "Hen") then {_coef = 280; _lenght = 0.30; _height = 0.37; _width = 0.18; _weight = 3.5;};
if (_unit isKindOf "Rabbit") then {_coef = 280; _lenght = 0.43; _height = 0.27; _width = 0.22; _weight = 12;};
if (_unit isKindOf "Sheep") then {_coef = 180; _lenght = 1.53; _height = 0.70; _width = 0.4; _weight = 80;};
if (_unit isKindOf "WildBoar") then {_coef = 180; _lenght = 1.23; _height = 0.90; _width = 0.42; _weight = 70;};
if (_unit isKindOf "CAManBase") then {_coef = 180; _lenght = 0.35; _height = 1.77; _width = 0.5; _weight = 95;};
if (_unit isKindOf "Air") then {_coef = 150; _lenght = 18.00; _height = 4.5; _width = 2.5; _weight = 4000;};
if (_unit isKindOf "AH1_Base") then {_coef = 150; _lenght = 16.20; _height = 4.12; _width = 2.00; _weight = 3550;};
if (_unit isKindOf "AH64_base_EP1") then {_coef = 150; _lenght = 17.73; _height = 3.87; _width = 2.2; _weight = 8000;};
if (_unit isKindOf "AW159_Lynx_BAF") then {_coef = 150; _lenght = 15.24; _height = 3.73; _width = 1.8; _weight = 4300;};
if (_unit isKindOf "BAF_Merlin_HC3_D") then {_coef = 150; _lenght = 22.81; _height = 6.65; _width = 3.2; _weight = 11550;};
if (_unit isKindOf "Ka60_GL_BASE_PMC") then {_coef = 150; _lenght = 14.50; _height = 4.93; _width = 2.8; _weight = 9800;};
if (_unit isKindOf "Mi17_base") then {_coef = 150; _lenght = 18.46; _height = 4.76; _width = 3.55; _weight = 11100;};
if (_unit isKindOf "Mi24_Base") then {_coef = 150; _lenght = 17.50; _height = 6.50; _width = 2.65; _weight = 9800;};
if (_unit isKindOf "UH1Y") then {_coef = 150; _lenght = 17.78; _height = 4.50; _width = 2.8; _weight = 6660;};
if (_unit isKindOf "UH1H_base") then {_coef = 150; _lenght = 17.40; _height = 4.39; _width = 2.8; _weight = 3600;};
if (_unit isKindOf "UH60_Base") then {_coef = 150; _lenght = 19.76; _height = 5.13; _width = 2.36; _weight = 9980;};
if (_unit isKindOf "UH60M_US_base_EP1") then {_coef = 150; _lenght = 19.76; _height = 5.13; _width = 2.36; _weight = 9980;};
if (_unit isKindOf "CH47_base_EP1") then {_coef = 150; _lenght = 30.1; _height = 5.70; _width = 3.36; _weight = 12100;};
if (_unit isKindOf "AH6_Base_EP1") then {_coef = 150; _lenght = 9.80; _height = 3.00; _width = 1.9; _weight = 980;};		 
if (_unit isKindOf "ParachuteBase") then {_coef = 180; _lenght = 5.00; _height = 2.00; _width = 5.00; _weight = 95;};
if (_unit isKindOf "A10") then {_coef = 150; _lenght = 16.26; _height = 4.47; _width = 6.8; _weight = 13782;};
if (_unit isKindOf "AV8B2") then {_coef = 150; _lenght = 14.12; _height = 3.55; _width = 7.2; _weight = 10410;};
if (_unit isKindOf "BIS_Steerable_Parachute") then {_coef = 150; _lenght = 5.00; _height = 2.00; _width = 5.00; _weight = 95;};
if (_unit isKindOf "C130J") then {_coef = 150; _lenght = 29.79; _height = 11.84; _width = 25.00; _weight = 40000;};
if (_unit isKindOf "F35_base") then {_coef = 150; _lenght = 15.67; _height = 4.33; _width = 8.3; _weight = 22470;};
if (_unit isKindOf "MV22") then {_coef = 150; _lenght = 17.50; _height = 6.73; _width = 20.00; _weight = 18000;};
if (_unit isKindOf "Su25_base") then {_coef = 150; _lenght = 15.33; _height = 4.80; _width = 11.00; _weight = 16990;};
if (_unit isKindOf "Su34") then {_coef = 150; _lenght = 23.34; _height = 6.09; _width = 11.00; _weight = 39000;};
if (_unit isKindOf "An2_Base_EP") then {_coef = 150; _lenght = 12.4; _height = 4.1; _width = 14.10; _weight = 4900;};
if (_unit isKindOf "MQ9PredatorB") then {_coef = 150; _lenght = 11.00; _height = 3.60; _width = 15.00; _weight = 3500;};
if (_unit isKindOf "Ka137_Base_PMC") then {_coef = 150; _lenght = 1.30; _height = 1.30; _width = 1.3; _weight = 80;};
if (_unit isKindOf "Pchela1T") then {_coef = 150; _lenght = 2.78; _height = 1.05; _width = 2.2; _weight = 138;};		
if (_unit isKindOf "StaticWeapon") then {_coef = 130; _lenght = 1.35; _height = 1.07; _width = 1.5; _weight = 100;};
if (_unit isKindOf "Ship") then {_coef = 100; _lenght = 5.35; _height = 3.27; _width = 2.5; _weight = 395;};
if (_unit isKindOf "Thing") then {_coef = 10; };
if (_unit isKindOf "Building") then {_coef = 8; };
if (_unit isKindOf "Strategic") then {_coef = 5; };
if (_unit isKindOf "Nonstrategic") then {_coef = 5;};

// -- Check line for good
if (isPlayer _unit or player in _unit) then { player sidechat "checkPush"; };
// -- -- -- -- -- -- -- -- 

_rad = _unit distance _pos;

// -- Sound of Vehicle shaking after Explosion
if ((isPlayer _unit or player in _unit)and(_unit distance _pos < 2500)) then
{
if (_coef != 180) then
{
	if (player distance _pos < 600) then {_intenzity = "Close";};
	if (player distance _pos >= 600 and player distance _pos < 1100) then {_intenzity = "Standard";};
	if (player distance _pos >= 1100 and player distance _pos < 2500) then {_intenzity = "Far";};
	_SoundTurbolence = "interiorTurbolance"+_intenzity;
	playsound _SoundTurbolence;
};
};

// -- Creation of Invisible Helipod which is spreading to a player
if ((isPlayer _unit or player in _unit)and(_unit distance _pos < 2500)) then
{
_soundPos = "HeliHEmpty" createVehicle (position _pos);
};
// -- Cycle which waits for a heatWave comes to a player
while {heatWaveSpreadDistance < _rad} do
{
_rad = _unit distance _pos;
_xPos = ((position _unit select 0) - (position _pos select 0));
_yPos = ((position _unit select 1) - (position _pos select 1));
if (_xPos >= 0 and _yPos >= 0) then {_fi = 0  + atan (abs(_yPos / _xPos));};
if (_xPos >= 0 and _yPos < 0) then {_fi = 270 + atan (abs(_xPos / _yPos));};
if (_xPos < 0 and _yPos < 0) then {_fi = 180 + atan (abs(_yPos / _xPos));};
if (_xPos < 0 and _yPos >= 0) then {_fi = 90 + atan (abs(_xPos / _yPos));};
_xSpos = shockWaveSpreadDistance * cos (_fi); _ySpos = shockWaveSpreadDistance * sin (_fi);
_soundPos setPos [((getPos _pos select 0)+_xSPos),((getPos _pos select 1)+_ySPos),(getPos _unit select 2)];
sleep 0.1;
};

// Sound of HeatWave impact to a unit or vehicle
if ((isPlayer _unit or player in _unit)and(_unit distance _pos < 2500)) then
{
if (_coef == 180) then {_material = "Body";} else {_material = "Metal";};
if (player distance _pos < 600) then {_intenzity = "Close";};
if (player distance _pos >= 600 and player distance _pos < 1100) then {_intenzity = "Standard";};
if (player distance _pos >= 1100 and player distance _pos < 2500) then {_intenzity = "Far";};
_Sound = "impact"+_material+"Soft"+_intenzity;
if (player distance _pos < 2500) then { playsound _Sound;};
};

// -- Damage applied by a HeatWave to a unit or vehicle
/*	// -- Overpressure in air
_xPos = ((position _unit select 0) - (position _pos select 0));
_yPos = ((position _unit select 1) - (position _pos select 1));
_zPos = ((position _unit select 2) - (position _pos select 2));

_GR = sqrt(_xPos^2 + _yPos^2);
_zMaxima = 8 * _GR^0.5;
_zChange = 15 * _GR^0.5;

if (_zPos > _zChange) then
	{
	_rad = _unit distance _pos;
	_crossXUp = 1/2*(sqrt(4*_rad^2+50625)-225);
	_crossZUp = 15 * _crossXUp^0.5;
	_k2 =(_crossZUp + 300)/(_crossXUp - 4000);
	_q2 = _crossZUp - _crossXUp*_k2;
	_crossXInter = (- _k2*_q2-8*sqrt(16-_k2*_q2)+32)/_k2^2;
	_crossZInter = 8 * _crossXInter^0.5;
	_k1 =(_crossZInter + 500)/(_crossXInter - 150);										
	_x0 = (-500 + _k1*150)/ _k1;
	};	

if (_zPos > _zMaxima and _zPos <= _zChange) then
	{
	_k2 =(_zPos + 300)/(_GR - 4000);
	_q2 = _zPos - _GR*_k2;
	_crossXInter = (- _k2*_q2-8*sqrt(16-_k2*_q2)+32)/_k2^2;
	_crossZInter = 8 * _crossXInter^0.5;
	_k1 =(_crossZInter + 500)/(_crossXInter - 150);										
	_x0 = (-500 + _k1*150)/ _k1;
	};

if (_zPos <= _zMaxima) then
	{
	_k1 =(_zPos + 500)/(_GR - 150);
	_x0 = (-500 + _k1*150)/ _k1;
	};

_kT = 1;
_overPressure =((15.071*_kT^0.5131)*(_x0/1000)^(-0.016*ln(_kT) - 1.4113))*10^9;

_xPos = ((position _unit select 0) - (position _pos select 0));
_yPos = ((position _unit select 1) - (position _pos select 1));
if (_xPos >= 0 and _yPos >= 0) then {_fi = 0  + atan (abs(_yPos / _xPos));};
if (_xPos >= 0 and _yPos < 0) then {_fi = 270 + atan (abs(_xPos / _yPos));};
if (_xPos < 0 and _yPos < 0) then {_fi = 180 + atan (abs(_yPos / _xPos));};
if (_xPos < 0 and _yPos >= 0) then {_fi = 90 + atan (abs(_xPos / _yPos));};

if (_fi <= 90) then {_blastDir = 90 - _fi;};
if (_fi > 90) then {_blastDir = 450 - _fi;};	

_dir = getDir _unit;
_diference = abs(_fi - _dir);
_cubature = (_lenght* sin(_diference) + _width * cos(_diference))*_height;
_force = _overpressure * _cubature;
_acc = _force / _weight;

_dam = _overPressure / 145; // zapracovat na steel stroje a jeho slabinach a podle toho urcit poskozeni





if (_dam > 1) then {_dam = 1;};











*/
_dam = _coef^3.5 / _rad^3;
if (_dam > 1) then {_dam = 1;};
if (_dam > 0.05) then {nil = [_unit, 0.5, 0.0, false, true] spawn BIS_Effects_Burn;};
if (_dam > 0.5) then {nil = [_unit, 3, 0.0, false, true] spawn BIS_Effects_Burn;};
_unit setDamage ((Damage _unit) + _dam);

// -- Cycle which waits for a shockWave comes to a player
while {shockWaveSpreadDistance < _rad} do {
_rad = _unit distance _pos;
_xPos = ((position _unit select 0) - (position _pos select 0));
_yPos = ((position _unit select 1) - (position _pos select 1));
if (_xPos >= 0 and _yPos >= 0) then {_fi = 0  + atan (abs(_yPos / _xPos));};
if (_xPos >= 0 and _yPos < 0) then {_fi = 270 + atan (abs(_xPos / _yPos));};
if (_xPos < 0 and _yPos < 0) then {_fi = 180 + atan (abs(_yPos / _xPos));};
if (_xPos < 0 and _yPos >= 0) then {_fi = 90 + atan (abs(_xPos / _yPos));};
_xSpos = shockWaveSpreadDistance * cos (_fi);
_ySpos = shockWaveSpreadDistance * sin (_fi);
_soundPos setPos [((getPos _pos select 0)+_xSPos),((getPos _pos select 1)+_ySPos),(getPos _unit select 2)];
if (_unit distance _soundPos < ln(10000 - shockWaveSpreadDistance)*32) then {
if (player distance _pos < 600) then {_intenzity = "Close";};
if (player distance _pos >= 600 and player distance _pos < 1100) then {_intenzity = "Standard";};
if (player distance _pos >= 1100 and player distance _pos < 2500) then {_intenzity = "Far";};
_SoundWave = "shockwave"+_intenzity;
playsound _SoundWave; playSound "rhumble";
};
sleep 0.1;
};

// -- Sound of ShockWave impact to a unit or vehicle
if ((isPlayer _unit or player in _unit)and(_unit distance _pos < 2500)) then {
if (player distance _pos < 600) then {_intenzity = "Close";};
if (player distance _pos >= 600 and player distance _pos < 1100) then {_intenzity = "Standard";};
if (player distance _pos >= 1100 and player distance _pos < 2500) then {_intenzity = "Far";};
_Sound = "impact"+_material+"Hard"+_intenzity;
if (player distance _pos < 2500) then { playsound _Sound;};
deleteVehicle _soundPos;
};

// -- Final Declaration of Shockwave impact into a car
_xPos = ((position _unit select 0) - (position _pos select 0));
_yPos = ((position _unit select 1) - (position _pos select 1));

if (_xPos >= 0 and _yPos >= 0) then {_fi = 0  + atan (abs(_yPos / _xPos));};
if (_xPos >= 0 and _yPos < 0) then {_fi = 270 + atan (abs(_xPos / _yPos));};
if (_xPos < 0 and _yPos < 0) then {_fi = 180 + atan (abs(_yPos / _xPos));};
if (_xPos < 0 and _yPos >= 0) then {_fi = 90 + atan (abs(_xPos / _yPos));};

// -- Damage applied by a ShockWave to a unit or vehicle
_dam = _coef^5 / _rad^4;
if (_dam > 1) then {_dam = 1;};
_unit setDamage ((Damage _unit) + _dam);

// -- Part which is counting with Shock Force and Leaning of vehicle or unit
if (_coef > 10) then
{
_force = ln(_coef^2.5 / _rad^1.6)/3*20;
if (_force < 0) then {_force = 0};
// Separating elements of Force and velocity into coordinates
_xF = _force * cos(_fi);
_yF = _force * sin(_fi);
_zF = _force / 3;
// Debug if speed and lean of vehicle is equal to zero
_vel = velocity _unit;
if (_vel select 0 == 0) then {_vel = [0.0001,_vel select 1, _vel select 2];};
if (_vel select 1 == 0) then {_vel = [_vel select 0,0.0001, _vel select 2];};
if (_vel select 2 == 0) then {_vel = [_vel select 0,_vel select 1, 0.0001];};	
_vecUp = vectorUp _unit;
if (_vecUp select 0 == 0) then {_vecUp = [0.0001,_vecUp select 1, _vecUp select 2];};
if (_vecUp select 1 == 0) then {_vecUp = [_vecUp select 0,0.0001, _vecUp select 2];};
if (_vecUp select 2 == 0) then {_vecUp = [_vecUp select 0,_vecUp select 1, 0.0001];};

_xVel = _vel select 0;
_yVel = _vel select 1;
_zVel = _vel select 2;
// Check in which way is vehicle moving and some speed correction of it
if (_xVel >= 0 and _yVel >= 0) then {_omega = 0  + atan (abs(_yVel / _xVel));};
if (_xVel >= 0 and _yVel < 0) then {_omega = 270 + atan (abs(_xVel / _yVel));};
if (_xVel < 0 and _yVel < 0) then {_omega = 180 + atan (abs(_yVel / _xVel));};
if (_xVel < 0 and _yVel >= 0) then {_omega = 90 + atan (abs(_xVel / _yVel));};
_diferencial = abs(_omega - _fi);
if (_diferencial > 90 and _diferencial < 270) then
	{
	_xVel = _xVel * (cos(_diferencial)+2)/ ln(_coef/7.77);
	_yVel = _yVel * (cos(_diferencial)+2)/ ln(_coef/7.77);
	};

_nY = 0; _nX = 0; _nXX = 0; _nYY = 0; _fXX = 0; _fYY = 0; _fZZ = 0;
_n = (_vecUp select 0)^2 + (_vecUp select 1)^2;
// -- Setting up for Leaning
_leanF = ln(_coef^3 / _rad^2) / 3;
if (_leanF < 0) then {_leanF = 0};

_nX = _leaner * cos (_fi);
_nY = _leaner * sin (_fi);
_cyklus = abs((_leanF - _n) / _leaner); if (_cyklus > 1) then {_cyklus = 1;};
_xxF = _xF/_cyklus;
_yyF = _yF/_cyklus;
_zzF = _zF/_cyklus;
// -- Finfing out on what side unit should lean
if ((_vecUp select 0) >= 0 and (_vecUp select 1) >= 0) then {_theta = 0  + atan (abs((_vecUp select 1) / (_vecUp select 0)));};
if ((_vecUp select 0) >= 0 and (_vecUp select 1) < 0) then {_theta = 270 + atan (abs((_vecUp select 0) / (_vecUp select 1)));};
if ((_vecUp select 0) < 0 and (_vecUp select 1) < 0) then {_theta = 180 + atan (abs((_vecUp select 1) / (_vecUp select 0)));};
if ((_vecUp select 0) < 0 and (_vecUp select 1) >= 0) then {_theta = 90 + atan (abs((_vecUp select 0) / (_vecUp select 1)));};
_diference = abs(_theta - _fi);

if (_diference < 270 and _diference > 90) then {_nX = -_nX; _nY = -_nY;};
// -- Cycle which will Lean unit and push it in wright way (also lock units in vehicle)
while {_n < _leanF} do
	{
      		sleep 0.01;
      		_unit setvectorup [(_vecUp select 0)+_nXX,(_vecUp select 1)+_nYY,(_vecUp select 2)];
		_nXX = _nXX + _nX; _nYY = _nYY + _nY; _n = _n + _leaner;
		_unit setVelocity [(_xVel+_fXX),(_yVel+_fYY),((_vel select 2)+_zF)];
		_fXX = _fXX + _xxF; _fyy = _fyy + _yyF; _fzz = _fzz + _zzF;
		{_x disableAI "MOVE";} forEach crew _unit;
		_unit lock true;
     	};
_unit setVelocity [(_xVel+_xF),(_yVel+_yF),(_zVel+_zF)];	
};

sleep 5;
// -- Opening vehicle
		{_x enableAI "MOVE";} forEach crew _unit;
		_unit lock false;

// -- Aftershock (Cycle which counts with Heat and Radioation in time)
_timeAfter = 0;

if (damage _unit < 1) then {			   //9000
while {damage _unit < 1  or _timeAfter < 9000} do { 			   //250
		if (_timeAfter <= 250) then
		{
		_heatRad = (_coef^4/(_unit distance _pos)^4)*(cos(_timeAfter/250*180)+1)/2*3/4;
		};
		_radRad  = (_coef^4/(_unit distance _pos)^4)*(cos(_timeAfter/9000*180)+1)/2*1/4;
		_unit setDamage (Damage _unit + _heatRad + _radRad);
		{_unit setDamage  (Damage _unit + (_heatRad + _radRad)/ln(_coef / 2))} forEach crew _unit;

		_plus = (2.5 + random 1);
		sleep _plus;
		_timeAfter = _timeAfter + _plus;
		};
};

Some parts are in progress like new damage count system, etc.

This one is just HUGE and needs to be runned for everz single unit alone.

I hoper that preload will help, but no, not at all.

Maybe if I run this scrit somewhere in black screen in very distance from any civilization for first time and disable any consequences. Then I could run it without problem for real where I need.

Edited by Khalashnikovf

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  

×