2016-05-30 16:37:03 +00:00
|
|
|
//fnc_doSpall.sqf
|
|
|
|
#include "script_component.hpp"
|
|
|
|
// ACE_player sideChat "WAAAAAAAAAAAAAAAAAAAAA";
|
|
|
|
|
2016-09-04 14:44:22 +00:00
|
|
|
params ["_hitData"];
|
|
|
|
private _initialData = GVAR(spallHPData) select (_hitData select 0);
|
|
|
|
private _hpData = (_hitData select 1) select (_this select 1);
|
2016-05-30 16:37:03 +00:00
|
|
|
|
2016-09-04 14:44:22 +00:00
|
|
|
_hpData params ["_object"];
|
2016-05-30 16:37:03 +00:00
|
|
|
_object removeEventHandler ["hitPart", _initialData select 0];
|
2016-09-04 14:44:22 +00:00
|
|
|
private _foundObjects = _initialData select 7;
|
|
|
|
private _index = _foundObjects find _object;
|
2016-05-30 16:37:03 +00:00
|
|
|
if(_index != -1) then {
|
2016-09-04 14:44:22 +00:00
|
|
|
_foundObjects set[_index, nil];
|
2016-05-30 16:37:03 +00:00
|
|
|
};
|
|
|
|
|
2016-09-04 14:44:22 +00:00
|
|
|
_initialData params ["", "_object", "_roundType", "_round"];
|
2016-05-30 16:37:03 +00:00
|
|
|
|
2016-09-04 14:44:22 +00:00
|
|
|
private _caliber = getNumber(configFile >> "CfgAmmo" >> _roundType >> "caliber");
|
|
|
|
private _explosive = getNumber(configFile >> "CfgAmmo" >> _roundType >> "explosive");
|
|
|
|
private _idh = getNumber(configFile >> "CfgAmmo" >> _roundType >> "indirectHitRange");
|
2016-05-30 16:37:03 +00:00
|
|
|
|
2016-09-04 14:44:22 +00:00
|
|
|
private _alive = true;
|
|
|
|
if(!alive _round && (_initialData select 6) isEqualTo 1) then {
|
2016-05-30 16:37:03 +00:00
|
|
|
_alive = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
if(_alive || {_caliber >= 2.5} || {(_explosive > 0 && {_idh >= 1})}) then {
|
|
|
|
// ACE_player sideChat format["BBBB"];
|
2016-09-04 14:44:22 +00:00
|
|
|
private _exit = false;
|
|
|
|
private _vm = 1;
|
|
|
|
private _velocity = _initialData select 5;
|
2016-05-30 16:37:03 +00:00
|
|
|
|
2016-09-04 14:44:22 +00:00
|
|
|
private _oldVelocity = vectorMagnitude _velocity;
|
|
|
|
private _curVelocity = vectorMagnitude (velocity _round);
|
2016-05-30 16:37:03 +00:00
|
|
|
|
|
|
|
if(alive _round) then {
|
2016-09-04 14:44:22 +00:00
|
|
|
private _diff = _velocity vectorDiff (velocity _round);
|
|
|
|
private _polar = _diff call CBA_fnc_vect2polar;
|
2016-05-30 16:37:03 +00:00
|
|
|
// ACE_player sideChat format["polar: %1", _polar];
|
|
|
|
if((abs(_polar select 1) > 45 || abs(_polar select 2) > 45)) then {
|
|
|
|
if(_caliber < 2.5) then {
|
|
|
|
// ACE_player sideChat format["exit!"];
|
|
|
|
_exit = true;
|
|
|
|
} else {
|
|
|
|
_vm = 1-(_curVelocity/_oldVelocity);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
if(!_exit) then {
|
2016-09-04 14:44:22 +00:00
|
|
|
private _unitDir = vectorNormalized _velocity;
|
|
|
|
private _pos = _hpData select 3;
|
|
|
|
private _spallPos = nil;
|
2016-05-30 16:37:03 +00:00
|
|
|
for "_i" from 0 to 100 do {
|
2016-09-04 14:44:22 +00:00
|
|
|
private _pos1 = _pos vectorAdd (_unitDir vectorMultiply (0.01 * _i));
|
|
|
|
private _pos2 = _pos vectorAdd (_unitDir vectorMultiply (0.01 * (_i + 1)));
|
2016-05-30 16:37:03 +00:00
|
|
|
// _blah = [_object, "FIRE"] intersect [_object worldToModel (ASLtoATL _pos1), _object worldToModel (ASLtoATL _pos2)];
|
|
|
|
// diag_log text format["b: %1", _blah];
|
|
|
|
|
|
|
|
// _data = [nil, nil, nil, 1, [[ASLtoATL _pos1, 1], [ASLtoATL _pos2, 1]]];
|
|
|
|
// NOU_TRACES set[(count NOU_TRACES), _data];
|
|
|
|
|
|
|
|
if(!lineIntersects [_pos1, _pos2]) exitWith {
|
|
|
|
// ACE_player sideChat format["FOUND!"];
|
|
|
|
_spallPos = _pos2;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
if(!isNil "_spallPos") then {
|
2016-09-04 14:44:22 +00:00
|
|
|
private _spallPolar = _velocity call CBA_fnc_vect2polar;
|
2016-05-30 16:37:03 +00:00
|
|
|
|
|
|
|
if(_explosive > 0) then {
|
|
|
|
// ACE_player sideChat format["EXPLOSIVE!"];
|
2016-09-04 14:44:22 +00:00
|
|
|
private _warn = false;
|
|
|
|
private _c = getNumber(configFile >> "CfgAmmo" >> _roundType >> QGVAR(CHARGE));
|
2016-05-30 16:37:03 +00:00
|
|
|
if(_c == 0) then { _c = 1; _warn = true;};
|
2016-09-04 14:44:22 +00:00
|
|
|
private _m = getNumber(configFile >> "CfgAmmo" >> _roundType >> QGVAR(METAL));
|
2016-05-30 16:37:03 +00:00
|
|
|
if(_m == 0) then { _m = 2; _warn = true;};
|
2016-09-04 14:44:22 +00:00
|
|
|
private _k = getNumber(configFile >> "CfgAmmo" >> _roundType >> QGVAR(GURNEY_K));
|
2016-05-30 16:37:03 +00:00
|
|
|
if(_k == 0) then { _k = 1/2; _warn = true;};
|
2016-09-04 14:44:22 +00:00
|
|
|
private _gC = getNumber(configFile >> "CfgAmmo" >> _roundType >> QGVAR(GURNEY_C));
|
2016-05-30 16:37:03 +00:00
|
|
|
if(_gC == 0) then { _gC = 2440; _warn = true;};
|
|
|
|
|
|
|
|
if(_warn) then {
|
2016-10-02 10:55:31 +00:00
|
|
|
WARNING_1("Ammo class %1 lacks proper explosive properties definitions for frag!",_roundType); //TODO: turn this off when we get closer to release
|
2016-05-30 16:37:03 +00:00
|
|
|
};
|
|
|
|
|
2016-09-04 14:44:22 +00:00
|
|
|
private _fragPower = (((_m/_c)+_k)^-(1/2))*_gC;
|
2016-05-30 16:37:03 +00:00
|
|
|
_spallPolar set[0, _fragPower*0.66];
|
|
|
|
};
|
|
|
|
|
2016-09-04 14:44:22 +00:00
|
|
|
private _fragTypes = [
|
2016-07-20 04:15:18 +00:00
|
|
|
QGVAR(spall_small), QGVAR(spall_small), QGVAR(spall_small),
|
|
|
|
QGVAR(spall_small),QGVAR(spall_medium),QGVAR(spall_medium),QGVAR(spall_medium),
|
|
|
|
QGVAR(spall_medium), QGVAR(spall_large), QGVAR(spall_large), QGVAR(spall_huge),
|
|
|
|
QGVAR(spall_huge)
|
2016-05-30 16:37:03 +00:00
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
// diag_log text format["SPALL POWER: %1", _spallPolar select 0];
|
2016-09-04 14:44:22 +00:00
|
|
|
private _spread = 15+(random 25);
|
|
|
|
private _spallCount = 5+(random 10);
|
2016-05-30 16:37:03 +00:00
|
|
|
for "_i" from 1 to _spallCount do {
|
2016-09-04 14:44:22 +00:00
|
|
|
private _elev = ((_spallPolar select 2)-_spread)+(random (_spread*2));
|
|
|
|
private _dir = ((_spallPolar select 1)-_spread)+(random (_spread*2));
|
2016-05-30 16:37:03 +00:00
|
|
|
if(abs _elev > 90) then {
|
|
|
|
_dir = _dir + 180;
|
|
|
|
};
|
|
|
|
_dir = _dir % 360;
|
2016-09-04 14:44:22 +00:00
|
|
|
private _vel = (_spallPolar select 0)*0.33*_vm;
|
2016-05-30 16:37:03 +00:00
|
|
|
_vel = (_vel-(_vel*0.25))+(random (_vel*0.5));
|
|
|
|
|
2016-09-04 14:44:22 +00:00
|
|
|
private _spallFragVect = [_vel, _dir, _elev] call CBA_fnc_polar2vect;
|
|
|
|
private _fragType = round (random ((count _fragTypes)-1));
|
|
|
|
private _fragment = (_fragTypes select _fragType) createVehicleLocal [0,0,10000];
|
2016-05-30 16:37:03 +00:00
|
|
|
_fragment setPosASL _spallPos;
|
|
|
|
_fragment setVelocity _spallFragVect;
|
|
|
|
|
|
|
|
if(GVAR(traceFrags)) then {
|
|
|
|
[ACE_player, _fragment, [1,0.5,0,1]] call FUNC(addTrack);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
_spread = 5+(random 5);
|
|
|
|
_spallCount = 3+(random 5);
|
|
|
|
for "_i" from 1 to _spallCount do {
|
2016-09-04 14:44:22 +00:00
|
|
|
private _elev = ((_spallPolar select 2)-_spread)+(random (_spread*2));
|
|
|
|
private _dir = ((_spallPolar select 1)-_spread)+(random (_spread*2));
|
2016-05-30 16:37:03 +00:00
|
|
|
if(abs _elev > 90) then {
|
|
|
|
_dir = _dir + 180;
|
|
|
|
};
|
|
|
|
_dir = _dir % 360;
|
2016-09-04 14:44:22 +00:00
|
|
|
private _vel = (_spallPolar select 0)*0.55*_vm;
|
2016-05-30 16:37:03 +00:00
|
|
|
_vel = (_vel-(_vel*0.25))+(random (_vel*0.5));
|
|
|
|
|
2016-09-04 14:44:22 +00:00
|
|
|
private _spallFragVect = [_vel, _dir, _elev] call CBA_fnc_polar2vect;
|
|
|
|
private _fragType = round (random ((count _fragTypes)-1));
|
|
|
|
private _fragment = (_fragTypes select _fragType) createVehicleLocal [0,0,10000];
|
2016-05-30 16:37:03 +00:00
|
|
|
_fragment setPosASL _spallPos;
|
|
|
|
_fragment setVelocity _spallFragVect;
|
|
|
|
|
|
|
|
if(GVAR(traceFrags)) then {
|
|
|
|
[ACE_player, _fragment, [1,0,0,1]] call FUNC(addTrack);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|