Cleanup Frag Component (#4581)

* Cleanup frag component

* Optimize fnc_addTrack

* Add additional cleanup

* Please work?

* Add more cleanup

* Fix script errors

* Fix/optimize spalling

* Add missing changes
This commit is contained in:
Ozan Eğitmen 2016-10-27 01:16:31 +03:00 committed by Glowbal
parent a13441fa85
commit 49b5a0ea86
32 changed files with 441 additions and 504 deletions

View File

@ -34,7 +34,6 @@ class ACE_Settings {
typeName = "SCALAR"; typeName = "SCALAR";
value = 50; value = 50;
}; };
class GVAR(enableDebugTrace) { class GVAR(enableDebugTrace) {
category = CSTRING(Module_DisplayName); category = CSTRING(Module_DisplayName);
displayName = CSTRING(EnableDebugTrace); displayName = CSTRING(EnableDebugTrace);

View File

@ -104,10 +104,8 @@ class CfgAmmo {
GVAR(gurney_k) = 1/2; GVAR(gurney_k) = 1/2;
}; };
class ACE_G_40mm_HEDP: G_40mm_HEDP { class ACE_G_40mm_HEDP: G_40mm_HEDP {};
}; class ACE_G_40mm_HE: G_40mm_HE {};
class ACE_G_40mm_HE: G_40mm_HE {
};
class ACE_G_40mm_Practice: ACE_G_40mm_HE { class ACE_G_40mm_Practice: ACE_G_40mm_HE {
GVAR(skip) = 1; GVAR(skip) = 1;
GVAR(force) = 0; GVAR(force) = 0;
@ -438,8 +436,6 @@ class CfgAmmo {
indirectHitRange = 0.25; indirectHitRange = 0.25;
airFriction = BASE_DRAG_HD*0.65; airFriction = BASE_DRAG_HD*0.65;
caliber = 2; caliber = 2;
}; };
class GVAR(huge): GVAR(large) { class GVAR(huge): GVAR(large) {

View File

@ -1,5 +1,3 @@
//CfgAmmoReflections.hpp
#define ACE_EXPLOSION_REFLECTION(range, hit)\ #define ACE_EXPLOSION_REFLECTION(range, hit)\
class ace_explosion_reflection_##range##_##hit : ace_explosion_reflection_base {\ class ace_explosion_reflection_##range##_##hit : ace_explosion_reflection_base {\
indirectHitRange = range;\ indirectHitRange = range;\

View File

@ -1,4 +1,3 @@
class Extended_PreStart_EventHandlers { class Extended_PreStart_EventHandlers {
class ADDON { class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preStart)); init = QUOTE(call COMPILE_FILE(XEH_preStart));

View File

@ -22,7 +22,6 @@ PREP(addPfhRound);
PREP(removePfhRound); // THIS SHOULD ABE USED SPARINGLY PREP(removePfhRound); // THIS SHOULD ABE USED SPARINGLY
// Explosive Reflection // Explosive Reflection
GVAR(replacedBisArtyWrapper) = true;
PREP(findReflections); PREP(findReflections);
PREP(doExplosions); PREP(doExplosions);
PREP(doReflections); PREP(doReflections);

View File

@ -1,6 +1,6 @@
#include "script_component.hpp" #include "script_component.hpp"
if(GVAR(EnableDebugTrace) && !isMultiplayer) then { if (GVAR(EnableDebugTrace) && {!isMultiplayer}) then {
GVAR(traceFrags) = true; GVAR(traceFrags) = true;
GVAR(autoTrace) = true; GVAR(autoTrace) = true;
}; };
@ -10,7 +10,6 @@ if(isServer) then {
}; };
["ace_settingsInitialized", { ["ace_settingsInitialized", {
//If not enabled, exit
if (!GVAR(enabled)) exitWith {}; if (!GVAR(enabled)) exitWith {};
// Register fire event handler // Register fire event handler
@ -20,7 +19,6 @@ if(isServer) then {
["ace_firedNonPlayerVehicle", DFUNC(fired)] call CBA_fnc_addEventHandler; ["ace_firedNonPlayerVehicle", DFUNC(fired)] call CBA_fnc_addEventHandler;
[FUNC(masterPFH), 0, []] call CBA_fnc_addPerFrameHandler; [FUNC(masterPFH), 0, []] call CBA_fnc_addPerFrameHandler;
}] call CBA_fnc_addEventHandler; }] call CBA_fnc_addEventHandler;
// Cache for ammo type configs // Cache for ammo type configs

View File

@ -4,10 +4,11 @@ ADDON = false;
#include "XEH_PREP.hpp" #include "XEH_PREP.hpp"
GVAR(replacedBisArtyWrapper) = true;
GVAR(blackList) = []; GVAR(blackList) = [];
GVAR(traceFrags) = false; GVAR(traceFrags) = false;
GVAR(TOTALFRAGS) = 0; GVAR(totalFrags) = 0;
GVAR(spallHPData) = []; GVAR(spallHPData) = [];
GVAR(spallIsTrackingCount) = 0; GVAR(spallIsTrackingCount) = 0;

View File

@ -1,4 +1,5 @@
#include "script_component.hpp" #include "script_component.hpp"
class CfgPatches { class CfgPatches {
class ADDON { class ADDON {
name = COMPONENT_NAME; name = COMPONENT_NAME;

View File

@ -1,3 +1,5 @@
#include "script_component.hpp" #include "script_component.hpp"
params ["_round"]; params ["_round"];
GVAR(blackList) set [(count GVAR(blackList)), _round];
GVAR(blackList) pushBack _round;

View File

@ -1,9 +1,7 @@
//#define DEBUG_MODE_FULL //#define DEBUG_MODE_FULL
#include "script_component.hpp" #include "script_component.hpp"
private ["_enabled", "_doSpall", "_spallTrack", "_spallTrackID"]; params ["_gun", "_type", "_round", ["_doFragTrack", false]];
PARAMS_3(_gun,_type,_round);
DEFAULT_PARAM(3,_doFragTrack,false);
if (!GVAR(enabled)) exitWith {}; if (!GVAR(enabled)) exitWith {};
@ -11,25 +9,21 @@ if (!GVAR(enabled)) exitWith {};
//if (_enabled < 1) exitWith {}; //if (_enabled < 1) exitWith {};
if (_round in GVAR(blackList)) exitWith { if (_round in GVAR(blackList)) exitWith {
GVAR(blackList) = GVAR(blackList) - [_round]; REM(GVAR(blackList),_round);
}; };
// Exit on max track // Exit on max track
if ((count GVAR(objects)) > GVAR(MaxTrack)) exitWith {}; if ((count GVAR(objects)) > GVAR(MaxTrack)) exitWith {};
if(_gun == ACE_player) then { if (
_gun == ACE_player ||
{(gunner _gun) == ACE_player} ||
{local _gun && {!(isPlayer (gunner _gun))} && {!(isPlayer _gun)}}
) then {
_doFragTrack = true; _doFragTrack = true;
} else {
if((gunner _gun) == ACE_player) then {
_doFragTrack = true;
} else {
if(local _gun && {!(isPlayer (gunner _gun))} && {!(isPlayer _gun)}) then {
_doFragTrack = true;
};
};
}; };
_doSpall = false; private _doSpall = false;
if (GVAR(SpallEnabled)) then { if (GVAR(SpallEnabled)) then {
if (GVAR(spallIsTrackingCount) <= 0) then { if (GVAR(spallIsTrackingCount) <= 0) then {
GVAR(spallHPData) = []; GVAR(spallHPData) = [];
@ -38,7 +32,7 @@ if(GVAR(SpallEnabled)) then {
// ACE_player sideChat "LIMT!"; // ACE_player sideChat "LIMT!";
} else { } else {
_doSpall = true; _doSpall = true;
GVAR(spallIsTrackingCount) = GVAR(spallIsTrackingCount) + 1; INC(GVAR(spallIsTrackingCount));
}; };
}; };
// ACE_player sideChat format ["c: %1", GVAR(spallIsTrackingCount)]; // ACE_player sideChat format ["c: %1", GVAR(spallIsTrackingCount)];
@ -52,16 +46,16 @@ if(GVAR(autoTrace)) then {
// But we leave that out here for optimization. So this cannot be a framework function // But we leave that out here for optimization. So this cannot be a framework function
// Otherwise, it should only be added once and from the FiredEH // Otherwise, it should only be added once and from the FiredEH
if (_doFragTrack && {alive _round}) then { if (_doFragTrack && {alive _round}) then {
_spallTrack = []; private _spallTrack = [];
_spallTrackID = []; private _spallTrackID = [];
private ["_args"]; private _args = [
_args = [_round, (getPosASL _round), (velocity _round), _type, diag_frameno, _gun, _doSpall, _spallTrack, _spallTrackID, _round, getPosASL _round, velocity _round, _type, diag_frameno, _gun, _doSpall, _spallTrack, _spallTrackID,
(getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(skip))), getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(skip)),
(getNumber (configFile >> "CfgAmmo" >> _type >> "explosive")), getNumber (configFile >> "CfgAmmo" >> _type >> "explosive"),
(getNumber (configFile >> "CfgAmmo" >> _type >> "indirectHitRange")), getNumber (configFile >> "CfgAmmo" >> _type >> "indirectHitRange"),
(getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(force))), getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(force)),
(getNumber(configFile >> "CfgAmmo" >> _type >> "indirecthit")*(sqrt((getNumber (configFile >> "CfgAmmo" >> _type >> "indirectHitRange"))))) getNumber (configFile >> "CfgAmmo" >> _type >> "indirecthit") * (sqrt (getNumber (configFile >> "CfgAmmo" >> _type >> "indirectHitRange")))
]; ];
TRACE_1("Initializing track", _round); TRACE_1("Initializing track", _round);
GVAR(objects) pushBack _round; GVAR(objects) pushBack _round;

View File

@ -5,16 +5,12 @@ if (GVAR(autoTrace)) then {
}; };
// setAccTime 0.05; // setAccTime 0.05;
private _index = count GVAR(traces); params ["_origin", "_obj", ["_color", [1, 0, 0, 1]]];
params ["_origin", "_obj"];
private _color = [1,0,0,1];
if((count _this) > 2) then {
_color = _this select 2;
};
private _positions = []; private _positions = [];
private _objSpd = vectorMagnitude (velocity _obj); private _objSpd = vectorMagnitude (velocity _obj);
_positions set[(count _positions), [(getPos _obj), _objSpd]]; _positions pushBack [getPos _obj, _objSpd];
private _data = [_origin, typeOf _origin, typeOf _obj, _objSpd, _positions, _color]; private _data = [_origin, typeOf _origin, typeOf _obj, _objSpd, _positions, _color];
GVAR(traces) set[_index, _data]; private _index = GVAR(traces) pushBack _data;
[DFUNC(trackTrace), 0, [_obj, _index, CBA_missionTime]] call CBA_fnc_addPerFrameHandler; [DFUNC(trackTrace), 0, [_obj, _index, CBA_missionTime]] call CBA_fnc_addPerFrameHandler;

View File

@ -1,7 +1,11 @@
#define DEBUG_MODE_FULL #define DEBUG_MODE_FULL
#include "script_component.hpp" #include "script_component.hpp"
params [["_debugMissing", true, [false]], ["_debugForce", false, [false]], ["_debugNonFrag", false, [false]]]; params [
["_debugMissing", true, [false]],
["_debugForce", false, [false]],
["_debugNonFrag", false, [false]]
];
diag_log text format ["~~~~~~~~~~~~~Start [%1]~~~~~~~~~~~~~", _this]; diag_log text format ["~~~~~~~~~~~~~Start [%1]~~~~~~~~~~~~~", _this];
@ -10,7 +14,7 @@ private _processedCfgAmmos = [];
{ {
private _ammo = toLower getText (_x >> "ammo"); private _ammo = toLower getText (_x >> "ammo");
if ((_ammo != "") && {!(_ammo in _processedCfgAmmos)}) then { if (_ammo != "" && {!(_ammo in _processedCfgAmmos)}) then {
_processedCfgAmmos pushBack _ammo; _processedCfgAmmos pushBack _ammo;
//Ignore mines/bombs //Ignore mines/bombs
@ -33,7 +37,7 @@ private _processedCfgAmmos = [];
diag_log text format [" - _force=%1,_fragPower=%2", _force, _fragPower]; diag_log text format [" - _force=%1,_fragPower=%2", _force, _fragPower];
}; };
_warn = false; private _warn = false;
_fragTypes = getArray (_ammoConfig >> QGVAR(CLASSES)); _fragTypes = getArray (_ammoConfig >> QGVAR(CLASSES));
if (_fragTypes isEqualTo []) then {_warn = true;}; if (_fragTypes isEqualTo []) then {_warn = true;};
@ -46,7 +50,7 @@ private _processedCfgAmmos = [];
_gC = getNumber(_ammoConfig >> QGVAR(GURNEY_C)); _gC = getNumber(_ammoConfig >> QGVAR(GURNEY_C));
if (_gC == 0) then {_warn = true;}; if (_gC == 0) then {_warn = true;};
if(_debugMissing && _warn) then { if (_debugMissing && {_warn}) then {
diag_log text format ["Ammo [%1] from Mag [%2] MISSING frag configs:", _ammo, configName _x]; diag_log text format ["Ammo [%1] from Mag [%2] MISSING frag configs:", _ammo, configName _x];
diag_log text format [" - _c=%1,_m=%2,_k=%3,_gC=%4,_fragTypes=%5", _c, _m, _k, _gC, _fragTypes]; diag_log text format [" - _c=%1,_m=%2,_k=%3,_gC=%4,_fragTypes=%5", _c, _m, _k, _gC, _fragTypes];
}; };

View File

@ -1,7 +1,7 @@
//fnc_doExplosions.sqf //fnc_doExplosions.sqf
#include "script_component.hpp" #include "script_component.hpp"
params ["_args"]; params ["_args", "_pfhID"];
_args params ["_explosions", "_index"]; _args params ["_explosions", "_index"];
for "_i" from _index to ((_index + 2) min (count _explosions)) do { for "_i" from _index to ((_index + 2) min (count _explosions)) do {
@ -12,9 +12,11 @@ for "_i" from _index to ((_index+2) min (count _explosions)) do {
// [_bpos, _refExp, _depth] call FUNC(doReflections); // [_bpos, _refExp, _depth] call FUNC(doReflections);
// }; // };
}; };
_index = _index + 2;
if(_index >= (count _explosions)) then { ADD(_index,2);
[(_this select 1)] call CBA_fnc_removePerFrameHandler;
if (_index >= count _explosions) then {
[_pfhID] call CBA_fnc_removePerFrameHandler;
} else { } else {
_params set[1, _index]; _args set [1, _index];
}; };

View File

@ -1,12 +1,8 @@
//fnc_doReflections.sqf //fnc_doReflections.sqf
#include "script_component.hpp" #include "script_component.hpp"
params ["_pos", "_ammo"]; params ["_pos", "_ammo", ["_depth", 1]];
private _depth = 1;
if(count _this > 2) then {
_depth = _this select 2;
};
// TEST_ICONS pushBack [_pos, format ["EXP!", _hit, _range, _hitFactor]]; // TEST_ICONS pushBack [_pos, format ["EXP!", _hit, _range, _hitFactor]];
if (_depth <= 2) then { if (_depth <= 2) then {
private _indirectHitRange = getNumber(configFile >> "CfgAmmo" >> _ammo >> "indirectHitRange"); private _indirectHitRange = getNumber(configFile >> "CfgAmmo" >> _ammo >> "indirectHitRange");

View File

@ -2,34 +2,21 @@
#include "script_component.hpp" #include "script_component.hpp"
// ACE_player sideChat "WAAAAAAAAAAAAAAAAAAAAA"; // ACE_player sideChat "WAAAAAAAAAAAAAAAAAAAAA";
params ["_hitData"]; params ["_hitData", "_hitPartDataIndex"];
private _initialData = GVAR(spallHPData) select (_hitData select 0); private _initialData = GVAR(spallHPData) select (_hitData select 0);
private _hpData = (_hitData select 1) select (_this select 1); _initialData params ["_hpId", "_object", "_roundType", "_round", "_curPos", "_velocity"];
_hpData params ["_object"]; private _hpData = (_hitData select 1) select _hitPartDataIndex;
_object removeEventHandler ["hitPart", _initialData select 0]; (_hpData select 0) removeEventHandler ["hitPart", _hpId];
private _foundObjects = _initialData select 7;
private _index = _foundObjects find _object;
if(_index != -1) then {
_foundObjects set[_index, nil];
};
_initialData params ["", "_object", "_roundType", "_round"];
private _caliber = getNumber (configFile >> "CfgAmmo" >> _roundType >> "caliber"); private _caliber = getNumber (configFile >> "CfgAmmo" >> _roundType >> "caliber");
private _explosive = getNumber (configFile >> "CfgAmmo" >> _roundType >> "explosive"); private _explosive = getNumber (configFile >> "CfgAmmo" >> _roundType >> "explosive");
private _idh = getNumber (configFile >> "CfgAmmo" >> _roundType >> "indirectHitRange"); private _idh = getNumber (configFile >> "CfgAmmo" >> _roundType >> "indirectHitRange");
private _alive = true; if !(_caliber >= 2.5 || {(_explosive > 0 && {_idh >= 1})}) exitWith {};
if(!alive _round && (_initialData select 6) isEqualTo 1) then {
_alive = false;
};
if(_alive || {_caliber >= 2.5} || {(_explosive > 0 && {_idh >= 1})}) then {
// ACE_player sideChat format ["BBBB"]; // ACE_player sideChat format ["BBBB"];
private _exit = false; private _exit = false;
private _vm = 1; private _vm = 1;
private _velocity = _initialData select 5;
private _oldVelocity = vectorMagnitude _velocity; private _oldVelocity = vectorMagnitude _velocity;
private _curVelocity = vectorMagnitude (velocity _round); private _curVelocity = vectorMagnitude (velocity _round);
@ -38,34 +25,31 @@ if(_alive || {_caliber >= 2.5} || {(_explosive > 0 && {_idh >= 1})}) then {
private _diff = _velocity vectorDiff (velocity _round); private _diff = _velocity vectorDiff (velocity _round);
private _polar = _diff call CBA_fnc_vect2polar; private _polar = _diff call CBA_fnc_vect2polar;
// ACE_player sideChat format ["polar: %1", _polar]; // ACE_player sideChat format ["polar: %1", _polar];
if((abs(_polar select 1) > 45 || abs(_polar select 2) > 45)) then { if (abs (_polar select 1) > 45 || {abs (_polar select 2) > 45}) then {
if (_caliber < 2.5) then { if (_caliber < 2.5) then {
// ACE_player sideChat format ["exit!"]; // ACE_player sideChat format ["exit!"];
_exit = true; _exit = true;
} else { } else {
_vm = 1-(_curVelocity/_oldVelocity); SUB(_vm,_curVelocity / _oldVelocity);
}; };
}; };
}; };
if(!_exit) then { if (_exit) exitWith {};
private _unitDir = vectorNormalized _velocity; private _unitDir = vectorNormalized _velocity;
private _pos = _hpData select 3; private _pos = _hpData select 3;
private _spallPos = nil; private _spallPos = [];
for "_i" from 0 to 100 do { for "_i" from 0 to 100 do {
private _pos1 = _pos vectorAdd (_unitDir vectorMultiply (0.01 * _i)); private _pos1 = _pos vectorAdd (_unitDir vectorMultiply (0.01 * _i));
private _pos2 = _pos vectorAdd (_unitDir vectorMultiply (0.01 * (_i + 1))); private _pos2 = _pos vectorAdd (_unitDir vectorMultiply (0.01 * (_i + 1)));
// _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]]]; // _data = [nil, nil, nil, 1, [[ASLtoATL _pos1, 1], [ASLtoATL _pos2, 1]]];
// NOU_TRACES set[(count NOU_TRACES), _data]; // NOU_TRACES pushBack _data;
if (!lineIntersects [_pos1, _pos2]) exitWith { if (!lineIntersects [_pos1, _pos2]) exitWith {
// ACE_player sideChat format ["FOUND!"]; // ACE_player sideChat format ["FOUND!"];
_spallPos = _pos2; _spallPos = _pos2;
}; };
}; };
if(!isNil "_spallPos") then { if (_spallPos isEqualTo []) exitWith {};
private _spallPolar = _velocity call CBA_fnc_vect2polar; private _spallPolar = _velocity call CBA_fnc_vect2polar;
if (_explosive > 0) then { if (_explosive > 0) then {
@ -103,7 +87,7 @@ if(_alive || {_caliber >= 2.5} || {(_explosive > 0 && {_idh >= 1})}) then {
private _elev = ((_spallPolar select 2) - _spread) + (random (_spread * 2)); private _elev = ((_spallPolar select 2) - _spread) + (random (_spread * 2));
private _dir = ((_spallPolar select 1) - _spread) + (random (_spread * 2)); private _dir = ((_spallPolar select 1) - _spread) + (random (_spread * 2));
if (abs _elev > 90) then { if (abs _elev > 90) then {
_dir = _dir + 180; ADD(_dir,180);
}; };
_dir = _dir % 360; _dir = _dir % 360;
private _vel = (_spallPolar select 0) * 0.33 * _vm; private _vel = (_spallPolar select 0) * 0.33 * _vm;
@ -125,7 +109,7 @@ if(_alive || {_caliber >= 2.5} || {(_explosive > 0 && {_idh >= 1})}) then {
private _elev = ((_spallPolar select 2) - _spread) + (random (_spread * 2)); private _elev = ((_spallPolar select 2) - _spread) + (random (_spread * 2));
private _dir = ((_spallPolar select 1) - _spread) + (random (_spread * 2)); private _dir = ((_spallPolar select 1) - _spread) + (random (_spread * 2));
if (abs _elev > 90) then { if (abs _elev > 90) then {
_dir = _dir + 180; ADD(_dir,180);
}; };
_dir = _dir % 360; _dir = _dir % 360;
private _vel = (_spallPolar select 0) * 0.55 * _vm; private _vel = (_spallPolar select 0) * 0.55 * _vm;
@ -141,6 +125,3 @@ if(_alive || {_caliber >= 2.5} || {(_explosive > 0 && {_idh >= 1})}) then {
[ACE_player, _fragment, [1, 0, 0, 1]] call FUNC(addTrack); [ACE_player, _fragment, [1, 0, 0, 1]] call FUNC(addTrack);
}; };
}; };
};
};
};

View File

@ -1,27 +1,19 @@
#include "script_component.hpp" #include "script_component.hpp"
private ["_color", "_index", "_lastPos", "_lastSpd", "_max", "_positions", "_startSpeed"];
{ {
_positions = _x select 4; private _positions = _x select 4;
_color = _x select 5; private _color = _x select 5;
_index = 0; private _index = 0;
_max = count _positions; private _max = count _positions;
_startSpeed = 0.01 max ((_positions select 0) select 1); private _lastSpd = [];
_lastSpd = []; private _lastPos = [];
_lastPos = [];
while {_index < _max} do { while {_index < _max} do {
_data1 = _positions select _index; _data1 = _positions select _index;
_data2 = nil; _data2 = _positions select ([_index + ACE_TRACE_DRAW_INC, _max - 1] select (_index + ACE_TRACE_DRAW_INC >= _max));
if(_index + ACE_TRACE_DRAW_INC >= _max) then {
_data2 = _positions select (_max - 1);
} else {
_data2 = _positions select (_index + ACE_TRACE_DRAW_INC);
};
_pos1 = _data1 select 0; _pos1 = _data1 select 0;
_pos2 = _data2 select 0; _pos2 = _data2 select 0;
_index = _index + ACE_TRACE_DRAW_INC; ADD(_index,ACE_TRACE_DRAW_INC);
drawLine3D [_pos1, _pos2, _color]; drawLine3D [_pos1, _pos2, _color];
_lastPos = _pos2; _lastPos = _pos2;

View File

@ -1,33 +1,31 @@
//fnc_findReflections.sqf //fnc_findReflections.sqf
#include "script_component.hpp" #include "script_component.hpp"
private ["_lastPos", "_test", "_vec", "_testPos", "_buckets", "_excludes", "_bucketIndex", "_bucketPos", "_bucketList", "_c", "_index", "_blist", "_avgX", "_avgY", "_avgZ", "_bpos", "_distance", "_hitFactor", "_hit", "_range", "_refExp", "_i", "_x", "_res", "_forEachIndex", "_explosions", "_can", "_dirvec", "_zAng"];
BEGIN_COUNTER(fnc_findReflections); BEGIN_COUNTER(fnc_findReflections);
params ["_args"]; params ["_args", "_pfhID"];
_args params ["_pos", "_explosiveInfo", "_los", "_nlos", "_zIndex", "_depth", "_rand"]; _args params ["_pos", "_explosiveInfo", "_los", "_nlos", "_zIndex", "_depth", "_rand"];
private _split = 15; private _split = 15;
private _radi = (360/_split*_depth); private _radi = 360 / _split * _depth;
// player sideChat format ["p: %1", _explosiveInfo]; // player sideChat format ["p: %1", _explosiveInfo];
_explosiveInfo params ["_indirectHitRange", "_indirectHit"]; _explosiveInfo params ["_indirectHitRange", "_indirectHit"];
private _distanceCount = (floor _indirectHitRange * 4) min 100; private _distanceCount = (floor _indirectHitRange * 4) min 100;
if (_zIndex < 5) then { if (_zIndex < 5) then {
_lastPos = _pos; private _lastPos = _pos;
_zAng = _zIndex*20+2; private _zAng = _zIndex * 20 + 2;
if (_zAng > 80) then { if (_zAng > 80) then {
_radi = 1; _radi = 1;
_zAng = 90; _zAng = 90;
}; };
for "_i" from 0 to _radi do { for "_i" from 0 to _radi do {
_test = true; private _test = true;
_vec = [1, ((_i*_split)+_rand) mod 360, _zAng] call CBA_fnc_polar2vect; private _vec = [1, ((_i * _split) + _rand) % 360, _zAng] call CBA_fnc_polar2vect;
for "_x" from 1 to _distanceCount do { for "_x" from 1 to _distanceCount do {
_testPos = _pos vectorAdd (_vec vectorMultiply _x); private _testPos = _pos vectorAdd (_vec vectorMultiply _x);
// drop ["\a3\data_f\Cl_basic","","Billboard",1,15,ASLtoATL _testPos,[0,0,0],1,1.275,1.0,0.0,[1],[[1,0,0,1]],[0],0.0,2.0,"","",""]; // drop ["\a3\data_f\Cl_basic","","Billboard",1,15,ASLtoATL _testPos,[0,0,0],1,1.275,1.0,0.0,[1],[[1,0,0,1]],[0],0.0,2.0,"","",""];
_res = lineIntersectsWith [_pos, _testPos]; private _res = lineIntersectsWith [_pos, _testPos];
if (count _res > 0) exitWith { if (count _res > 0) exitWith {
_test = false; _test = false;
_nlos pushBack _lastPos; _nlos pushBack _lastPos;
@ -44,18 +42,17 @@ if(_zIndex < 5) then {
}; };
_args set [4, _zIndex + 1]; _args set [4, _zIndex + 1];
} else { } else {
_depth = _depth + 1; INC(_depth);
_buckets = []; private _buckets = [];
_excludes = []; private _excludes = [];
_bucketIndex = 0; private _bucketPos = nil;
_bucketPos = nil; private _bucketList = nil;
_bucketList = nil; private _c = 0;
_c = 0; while {count _nlos != count _excludes && {_c < (count _nlos)}} do {
while { count(_nlos) != count(_excludes) && _c < (count _nlos) } do {
scopeName "mainSearch"; scopeName "mainSearch";
{ {
if (!(_forEachIndex in _excludes)) then { if (!(_forEachIndex in _excludes)) then {
_index = _buckets pushBack [_x, [_x]]; private _index = _buckets pushBack [_x, [_x]];
_excludes pushBack _forEachIndex; _excludes pushBack _forEachIndex;
_bucketPos = _x; _bucketPos = _x;
_bucketList = (_buckets select _index) select 1; _bucketList = (_buckets select _index) select 1;
@ -71,43 +68,42 @@ if(_zIndex < 5) then {
}; };
}; };
} forEach _nlos; } forEach _nlos;
_c = _c + 1; INC(_c);
}; };
// player sideChat format ["c: %1", count _buckets]; // player sideChat format ["c: %1", count _buckets];
_explosions = []; private _explosions = [];
{ {
_blist = _x select 1; private _blist = _x select 1;
_avgX = 0; private _avgX = 0;
_avgY = 0; private _avgY = 0;
_avgZ = 0; private _avgZ = 0;
{ {
_avgX = _avgX + (_x select 0); ADD(_avgX,_x select 0);
_avgY = _avgY + (_x select 1); ADD(_avgY,_x select 1);
_avgZ = _avgZ + (_x select 2); ADD(_avgZ,_x select 2);
} forEach _blist; } forEach _blist;
_c = count _blist; _c = count _blist;
_bpos = [_avgX/_c, _avgY/_c, _avgZ/_c]; private _bpos = [_avgX / _c, _avgY / _c, _avgZ / _c];
_distance = _pos vectorDistance _bpos; private _distance = _pos vectorDistance _bpos;
_hitFactor = 1-(((_distance/(_indirectHitRange*4)) min 1) max 0); private _hitFactor = 1 - (((_distance / (_indirectHitRange * 4)) min 1) max 0);
// _hitFactor = 1 / (_distance ^ 2); // _hitFactor = 1 / (_distance ^ 2);
_hit = _indirectHit*_hitFactor; private _hit = _indirectHit * _hitFactor;
_hit = (floor (_hit / 4)) min 500; _hit = (floor (_hit / 4)) min 500;
_hit = _hit - (_hit%10); SUB(_hit,_hit % 10);
_range = (floor (_indirectHitRange-(_distance/4))) min 100; private _range = (floor (_indirectHitRange - (_distance / 4))) min 100;
_range = _range - (_range%2); SUB(_range,_range % 2);
if(_hit >= 10 && _range > 0) then { if (_hit >= 10 && {_range > 0}) then {
// TEST_ICONS pushBack [_bpos, format ["h: %1, r: %2, hf: %3 d: %4 ihr: %5", _hit, _range, _hitFactor, _distance, _indirectHitRange*4]]; // TEST_ICONS pushBack [_bpos, format ["h: %1, r: %2, hf: %3 d: %4 ihr: %5", _hit, _range, _hitFactor, _distance, _indirectHitRange*4]];
// TEST_PAIRS pushBack [_pos, _bpos, [1,0,0,1]]; // TEST_PAIRS pushBack [_pos, _bpos, [1,0,0,1]];
_refExp = format["ace_explosion_reflection_%1_%2", _range, _hit]; private _refExp = format ["ace_explosion_reflection_%1_%2", _range, _hit];
// _refExp createVehicle (ASLtoATL _bpos); // _refExp createVehicle (ASLtoATL _bpos);
// drop ["\a3\data_f\Cl_basic","","Billboard",1,15,ASLtoATL _bpos,[0,0,0],1,1.275,1.0,0.0,[1],[[1,0,0,1]],[0],0.0,2.0,"","",""]; // drop ["\a3\data_f\Cl_basic","","Billboard",1,15,ASLtoATL _bpos,[0,0,0],1,1.275,1.0,0.0,[1],[[1,0,0,1]],[0],0.0,2.0,"","",""];
_explosions pushBack [_refExp, _bpos, _hit, _distance, _indirectHitRange / 4, _depth]; _explosions pushBack [_refExp, _bpos, _hit, _distance, _indirectHitRange / 4, _depth];
}; };
if (count _explosions > (_radi * 2) / _depth) exitWith {}; if (count _explosions > (_radi * 2) / _depth) exitWith {};
} forEach _buckets; } forEach _buckets;
@ -116,6 +112,6 @@ if(_zIndex < 5) then {
// _dirvec = _dirvec vectorMultiply 100; // _dirvec = _dirvec vectorMultiply 100;
// _can setVelocity _dirvec; // _can setVelocity _dirvec;
[DFUNC(doExplosions), 0, [_explosions, 0]] call CBA_fnc_addPerFrameHandler; [DFUNC(doExplosions), 0, [_explosions, 0]] call CBA_fnc_addPerFrameHandler;
[(_this select 1)] call CBA_fnc_removePerFrameHandler; [_pfhID] call CBA_fnc_removePerFrameHandler;
}; };
END_COUNTER(fnc_findReflections); END_COUNTER(fnc_findReflections);

View File

@ -42,7 +42,7 @@ if (isNil "_shouldAdd") then {
private _explosive = getNumber (configFile >> "CfgAmmo" >> _ammo >> "explosive"); private _explosive = getNumber (configFile >> "CfgAmmo" >> _ammo >> "explosive");
private _indirectRange = getNumber (configFile >> "CfgAmmo" >> _ammo >> "indirectHitRange"); private _indirectRange = getNumber (configFile >> "CfgAmmo" >> _ammo >> "indirectHitRange");
private _force = getNumber (configFile >> "CfgAmmo" >> _ammo >> QGVAR(force)); private _force = getNumber (configFile >> "CfgAmmo" >> _ammo >> QGVAR(force));
private _fragPower = getNumber(configFile >> "CfgAmmo" >> _ammo >> "indirecthit")*(sqrt((getNumber (configFile >> "CfgAmmo" >> _ammo >> "indirectHitRange")))); private _fragPower = getNumber (configFile >> "CfgAmmo" >> _ammo >> "indirecthit") * (sqrt (getNumber (configFile >> "CfgAmmo" >> _ammo >> "indirectHitRange")));
_shouldAdd = (_skip == 0) && {(_force == 1) || {_explosive > 0.5 && {_indirectRange >= 4.5} && {_fragPower >= 35}}}; _shouldAdd = (_skip == 0) && {(_force == 1) || {_explosive > 0.5 && {_indirectRange >= 4.5} && {_fragPower >= 35}}};
TRACE_6("SettingCache[willFrag?]",_skip,_explosive,_indirectRange,_force,_fragPower,_shouldAdd); TRACE_6("SettingCache[willFrag?]",_skip,_explosive,_indirectRange,_force,_fragPower,_shouldAdd);

View File

@ -11,13 +11,7 @@ if(!isServer) exitWith { };
BEGIN_COUNTER(frago); BEGIN_COUNTER(frago);
// _startTime = diag_tickTime; // _startTime = diag_tickTime;
private ["_fuseDist", "_indirectHitRange", "_fragRange", "_c", "_m", "_k", "_gC", "_fragPower", "_fragPowerRandom", "_manObjects", "_objects", "_crew", "_fragCount", "_fragArcs", "_doRandom", "_boundingBox", "_targetPos", "_distance", "_add", "_bbX", "_bbY", "_bbZ", "_cubic", "_targetVel", "_baseVec", "_dir", "_currentCount", "_count", "_vecVar", "_vec", "_fp", "_vel", "_fragType", "_fragObj", "_randomCount", "_sectorSize", "_sectorOffset", "_i", "_randomDir", "_endTime", "_target"]; params ["_round", "_lastPos", "_lastVel", "_shellType", "_firedFrame", "_gun"];
params ["_round", "_lastPos", "_lastVel", "_shellType"];
private _gun = nil;
if((count _this) > 5) then {
_gun = _this select 5;
};
private _fragTypes = [ private _fragTypes = [
QGVAR(tiny), QGVAR(tiny), QGVAR(tiny), QGVAR(tiny), QGVAR(tiny), QGVAR(tiny),
@ -34,16 +28,14 @@ if(isArray (configFile >> "CfgAmmo" >> _shellType >> QGVAR(CLASSES))) then {
_warn = true; _warn = true;
}; };
private _atlPos = ASLtoATL _lastPos;
private _isArmed = true; private _isArmed = true;
if (!isNil "_gun") then { if (!isNil "_gun") then {
_fuseDist = getNumber(configFile >> "CfgAmmo" >> _shellType >> "fuseDistance"); private _fuseDist = getNumber(configFile >> "CfgAmmo" >> _shellType >> "fuseDistance");
_isArmed = ((getPosASL _gun) distance _lastPos > _fuseDist); _isArmed = ((getPosASL _gun) distance _lastPos > _fuseDist);
}; };
_indirectHitRange = getNumber(configFile >> "CfgAmmo" >> _shellType >> "indirecthitrange"); private _indirectHitRange = getNumber(configFile >> "CfgAmmo" >> _shellType >> "indirecthitrange");
_fragRange = 20 * _indirectHitRange * 4; private _fragRange = 20 * _indirectHitRange * 4;
// _c = 185; // grams of comp-b // _c = 185; // grams of comp-b
// _m = 210; // grams of fragmentating metal // _m = 210; // grams of fragmentating metal
// _k = 3/5; // spherical K factor // _k = 3/5; // spherical K factor
@ -54,24 +46,25 @@ _fragRange = 20 * _indirectHitRange * 4;
// _k = 1/2; // spherical K factor // _k = 1/2; // spherical K factor
// _gC = 2320; // Gurney constant of tritonal in /ms // _gC = 2320; // Gurney constant of tritonal in /ms
private _c = getNumber (configFile >> "CfgAmmo" >> _shellType >> QGVAR(CHARGE));
_c = getNumber(configFile >> "CfgAmmo" >> _shellType >> QGVAR(CHARGE));
if (_c == 0) then {_c = 1; _warn = true;}; if (_c == 0) then {_c = 1; _warn = true;};
_m = getNumber(configFile >> "CfgAmmo" >> _shellType >> QGVAR(METAL)); private _m = getNumber (configFile >> "CfgAmmo" >> _shellType >> QGVAR(METAL));
if (_m == 0) then {_m = 2; _warn = true;}; if (_m == 0) then {_m = 2; _warn = true;};
_k = getNumber(configFile >> "CfgAmmo" >> _shellType >> QGVAR(GURNEY_K)); private _k = getNumber (configFile >> "CfgAmmo" >> _shellType >> QGVAR(GURNEY_K));
if(_k == 0) then { _k = 1/2; _warn = true;}; if (_k == 0) then {_k = 0.5; _warn = true;};
_gC = getNumber(configFile >> "CfgAmmo" >> _shellType >> QGVAR(GURNEY_C)); private _gC = getNumber (configFile >> "CfgAmmo" >> _shellType >> QGVAR(GURNEY_C));
if (_gC == 0) then {_gC = 2440; _warn = true;}; if (_gC == 0) then {_gC = 2440; _warn = true;};
if (_warn) then { if (_warn) then {
WARNING_1("Ammo class %1 lacks proper explosive properties definitions for frag!",_shellType); //TODO: turn this off when we get closer to release WARNING_1("Ammo class %1 lacks proper explosive properties definitions for frag!",_shellType); //TODO: turn this off when we get closer to release
}; };
_fragPower = (((_m/_c)+_k)^-(1/2))*_gC; private _fragPower = (((_m / _c) + _k) ^ - (1 / 2)) * _gC;
_fragPower = _fragPower * 0.8; // Gunery equation is for a non-fragmenting metal, imperical value of 80% represents fragmentation _fragPower = _fragPower * 0.8; // Gunery equation is for a non-fragmenting metal, imperical value of 80% represents fragmentation
_fragPowerRandom = _fragPower * 0.5; private _atlPos = ASLtoATL _lastPos;
private _fragPowerRandom = _fragPower * 0.5;
if ((_atlPos select 2) < 0.5) then { if ((_atlPos select 2) < 0.5) then {
_lastPos set [2, (_lastPos select 2) + 0.5]; _lastPos set [2, (_lastPos select 2) + 0.5];
}; };
@ -81,94 +74,90 @@ if((_atlPos select 2) < 0.5) then {
// setAccTime 0.01; // setAccTime 0.01;
//_objects = nearestObjects [_atlPos, ["AllVehicles"], _fragRange]; // Not sure if tracking "ReammoBox" is required, if so revert this change for _objects //_objects = nearestObjects [_atlPos, ["AllVehicles"], _fragRange]; // Not sure if tracking "ReammoBox" is required, if so revert this change for _objects
_objects = _atlPos nearEntities [["Car", "Motorcycle", "Tank", "StaticWeapon", "CAManBase", "Air", "Ship"], _fragRange]; private _objects = _atlPos nearEntities [["Car", "Motorcycle", "Tank", "StaticWeapon", "CAManBase", "Air", "Ship"], _fragRange];
// _objects = _manObjects; // _objects = _manObjects;
// Target also people inside vehicles or manning weapons // Add unique crews in faster way
_crew = [];
{ {
{ {
_crew set [count _crew,_x] _objects pushBackUnique _x;
} forEach (crew _x); } forEach (crew _x);
} forEach _objects; } forEach _objects;
_objects = _objects - _crew; private _fragCount = 0;
_objects = _objects + _crew;
_fragCount = 0; private _fragArcs = [];
_fragArcs = [];
_fragArcs set [360, 0]; _fragArcs set [360, 0];
#ifdef DEBUG_MODE_FULL #ifdef DEBUG_MODE_FULL
ACE_player sideChat format ["_fragRange: %1", _fragRange]; ACE_player sideChat format ["_fragRange: %1", _fragRange];
ACE_player sideChat format ["_objects: %1", _objects]; ACE_player sideChat format ["_objects: %1", _objects];
#endif #endif
_doRandom = true;
if(_isArmed && (count _objects) > 0) then { private _doRandom = true;
if (_isArmed && {!(_objects isEqualTo [])}) then {
if (GVAR(ReflectionsEnabled)) then { if (GVAR(ReflectionsEnabled)) then {
[_lastPos, _shellType] call FUNC(doReflections); [_lastPos, _shellType] call FUNC(doReflections);
}; };
{ {
//if (random(1) > 0.5) then { //if (random(1) > 0.5) then {
_target = _x; private _target = _x;
if (alive _target) then { if (alive _target) then {
_boundingBox = boundingBox _target; private _boundingBox = boundingBox _target;
_targetPos = (getPosASL _target); private _targetPos = getPosASL _target;
_distance = _targetPos distance _lastPos; private _distance = _targetPos distance _lastPos;
_add = (((_boundingBox select 1) select 2)/2)+((((_distance-(_fragpower/8)) max 0)/_fragPower)*10); private _add = (((_boundingBox select 1) select 2) / 2) + ((((_distance - (_fragpower / 8)) max 0) / _fragPower) * 10);
_bbX = (abs((_boundingBox select 0) select 0))+((_boundingBox select 1) select 0); private _bbX = (abs ((_boundingBox select 0) select 0)) + ((_boundingBox select 1) select 0);
_bbY = (abs((_boundingBox select 0) select 1))+((_boundingBox select 1) select 1); private _bbY = (abs ((_boundingBox select 0) select 1)) + ((_boundingBox select 1) select 1);
_bbZ = (abs((_boundingBox select 0) select 2))+((_boundingBox select 1) select 2); private _bbZ = (abs ((_boundingBox select 0) select 2)) + ((_boundingBox select 1) select 2);
_cubic = _bbX * _bbY * _bbZ; private _cubic = _bbX * _bbY * _bbZ;
if (_cubic > 1) then { if (_cubic > 1) then {
_doRandom = true; _doRandom = true;
_targetVel = (velocity _target); private _targetVel = velocity _target;
_targetPos = _targetPos vectorAdd [
(_targetVel select 0) * (_distance / _fragPower),
(_targetVel select 1) * (_distance / _fragPower),
_add
];
_targetPos set[0, (_targetPos select 0)+((_targetVel select 0)*(_distance/_fragPower))]; private _baseVec = _lastPos vectorFromTo _targetPos;
_targetPos set[1, (_targetPos select 1)+((_targetVel select 1)*(_distance/_fragPower))];
_targetPos set[2, (_targetPos select 2)+_add];
_baseVec = _lastPos vectorFromTo _targetPos; private _dir = floor (_baseVec call CBA_fnc_vectDir);
private _currentCount = _fragArcs select _dir;
_dir = floor(_baseVec call CBA_fnc_vectDir); ISNILS(_currentCount,0);
_currentCount = _fragArcs select _dir;
if(isNil "_currentCount") then {
_currentCount = 0;
};
if (_currentCount < 20) then { if (_currentCount < 20) then {
_count = ceil(random(sqrt(_m/1000))); private _count = ceil (random (sqrt (_m / 1000)));
_vecVar = FRAG_VEC_VAR; private _vecVar = FRAG_VEC_VAR;
if (!(_target isKindOf "Man")) then { if (!(_target isKindOf "Man")) then {
_vecVar = ((sqrt _cubic) / 2000) + FRAG_VEC_VAR; _vecVar = ((sqrt _cubic) / 2000) + FRAG_VEC_VAR;
if((count (crew _target)) == 0 && _count > 0) then { if ((crew _target) isEqualTo [] && {_count > 0}) then {
_count = 0 max (_count / 2); _count = 0 max (_count / 2);
}; };
}; };
for "_i" from 1 to _count do { for "_i" from 1 to _count do {
_vec = +_baseVec; private _vec = _baseVec vectorDiff [
(_vecVar / 2) + (random _vecVar),
(_vecVar / 2) + (random _vecVar),
(_vecVar / 2) + (random _vecVar)
];
_vec set[0, (_vec select 0)-(_vecVar/2)+(random _vecVar)]; private _fp = _fragPower - (random (_fragPowerRandom));
_vec set[1, (_vec select 1)-(_vecVar/2)+(random _vecVar)]; private _vel = _vec vectorMultiply _fp;
_vec set[2, (_vec select 2)-(_vecVar/2)+(random _vecVar)];
_fp = (_fragPower-(random (_fragPowerRandom))); private _fragType = round (random ((count _fragTypes) - 1));
_vel = _vec vectorMultiply _fp; private _fragObj = (_fragTypes select _fragType) createVehicleLocal [0,0,10000];
_fragType = round (random ((count _fragTypes)-1));
_fragObj = (_fragTypes select _fragType) createVehicleLocal [0,0,10000];
// diag_log text format ["fp: %1 %2", _fp, typeOf _fragObj]; // diag_log text format ["fp: %1 %2", _fp, typeOf _fragObj];
_fragObj setPosASL _lastPos; _fragObj setPosASL _lastPos;
_fragObj setVectorDir _vec; _fragObj setVectorDir _vec;
_fragObj setVelocity _vel; _fragObj setVelocity _vel;
if (GVAR(traceFrags)) then { if (GVAR(traceFrags)) then {
GVAR(TOTALFRAGS) = GVAR(TOTALFRAGS) + 1; INC(GVAR(totalFrags));
[ACE_player, _fragObj, [1,0,0,1]] call FUNC(addTrack); [ACE_player, _fragObj, [1,0,0,1]] call FUNC(addTrack);
}; };
_fragCount = _fragCount + 1; INC(_fragCount);
_currentCount = _currentCount + 1; INC(_currentCount);
}; };
_fragArcs set [_dir, _currentCount]; _fragArcs set [_dir, _currentCount];
}; };
@ -178,14 +167,14 @@ if(_isArmed && (count _objects) > 0) then {
if (_fragCount > MAX_FRAG_COUNT) exitWith {}; if (_fragCount > MAX_FRAG_COUNT) exitWith {};
} forEach _objects; } forEach _objects;
if (_fragCount > MAX_FRAG_COUNT) exitWith {}; if (_fragCount > MAX_FRAG_COUNT) exitWith {};
_randomCount = ((ceil((MAX_FRAG_COUNT - _fragCount)*0.1)) max 0)+20; private _randomCount = ((ceil ((MAX_FRAG_COUNT - _fragCount) * 0.1)) max 0) + 20;
_sectorSize = 360 / (_randomCount max 1); private _sectorSize = 360 / (_randomCount max 1);
// _doRandom = false; // _doRandom = false;
if (_doRandom) then { if (_doRandom) then {
for "_i" from 1 to _randomCount do { for "_i" from 1 to _randomCount do {
// Distribute evenly // Distribute evenly
_sectorOffset = 360 * (_i - 1) / (_randomCount max 1); private _sectorOffset = 360 * (_i - 1) / (_randomCount max 1);
_randomDir = random(_sectorSize); private _randomDir = random (_sectorSize);
_vec = [cos (_sectorOffset + _randomDir), sin (_sectorOffset + _randomDir), sin (30 - (random 45))]; _vec = [cos (_sectorOffset + _randomDir), sin (_sectorOffset + _randomDir), sin (30 - (random 45))];
_fp = (_fragPower - (random (_fragPowerRandom))); _fp = (_fragPower - (random (_fragPowerRandom)));
@ -199,16 +188,16 @@ if(_isArmed && (count _objects) > 0) then {
_fragObj setVelocity _vel; _fragObj setVelocity _vel;
if (GVAR(traceFrags)) then { if (GVAR(traceFrags)) then {
GVAR(TOTALFRAGS) = GVAR(TOTALFRAGS) + 1; INC(GVAR(totalFrags));
[ACE_player, _fragObj, [1,0.5,0,1]] call FUNC(addTrack); [ACE_player, _fragObj, [1,0.5,0,1]] call FUNC(addTrack);
}; };
_fragCount = _fragCount + 1; INC(_fragCount);
}; };
}; };
}; };
// #ifdef DEBUG_MODE_FULL // #ifdef DEBUG_MODE_FULL
// ACE_player sideChat format["total frags: %1", GVAR(TOTALFRAGS)]; // ACE_player sideChat format["total frags: %1", GVAR(totalFrags)];
// ACE_player sideChat format["tracks: %1", (count GVAR(trackedObjects))]; // ACE_player sideChat format["tracks: %1", (count GVAR(trackedObjects))];
// #endif // #endif
// _endTime = diag_tickTime; // _endTime = diag_tickTime;

View File

@ -15,36 +15,35 @@
if (!GVAR(enabled)) exitWith {}; if (!GVAR(enabled)) exitWith {};
private ["_gcIndex", "_iter"]; private _gcIndex = [];
_gcIndex = [];
_iter = 0; private _iter = 0;
while { (count GVAR(objects)) > 0 && { _iter < (GVAR(MaxTrackPerFrame) min (count GVAR(objects))) } } do { private _objectCount = count GVAR(objects);
private ["_object", "_args"]; while {_objectCount > 0 && {_iter < (GVAR(MaxTrackPerFrame) min _objectCount)}} do {
if(GVAR(lastIterationIndex) >= (count GVAR(objects))) then {
if (GVAR(lastIterationIndex) >= _objectCount) then {
GVAR(lastIterationIndex) = 0; GVAR(lastIterationIndex) = 0;
}; };
_object = GVAR(objects) select GVAR(lastIterationIndex); private _object = GVAR(objects) select GVAR(lastIterationIndex);
if (!isNil "_object") then { if (!isNil "_object") then {
_args = GVAR(arguments) select GVAR(lastIterationIndex); private _args = GVAR(arguments) select GVAR(lastIterationIndex);
if (!(_args call FUNC(pfhRound))) then { if (!(_args call FUNC(pfhRound))) then {
_gcIndex pushBack GVAR(lastIterationIndex); // Add it to the GC if it returns false _gcIndex pushBack GVAR(lastIterationIndex); // Add it to the GC if it returns false
}; };
}; };
_iter = _iter + 1; INC(_iter);
GVAR(lastIterationIndex) = GVAR(lastIterationIndex) + 1; INC(GVAR(lastIterationIndex));
}; };
// clean up dead object references // Clean up dead object references
private ["_deletionCount", "_deleteIndex"]; private _deletionCount = 0;
_deletionCount = 0;
{ {
TRACE_1("GC Projectile", _x); TRACE_1("GC Projectile", _x);
_deleteIndex = _x - _deletionCount; private _deleteIndex = _x - _deletionCount;
GVAR(objects) deleteAt _deleteIndex; GVAR(objects) deleteAt _deleteIndex;
GVAR(arguments) deleteAt _deleteIndex; GVAR(arguments) deleteAt _deleteIndex;
_deletionCount = _deletionCount + 1; INC(_deletionCount);
} forEach _gcIndex; } forEach _gcIndex;

View File

@ -1,6 +1,6 @@
#include "script_component.hpp" #include "script_component.hpp"
params ["_round", "_lastPos", "_lastVel", "_type", "_firedFrame", "", "_doSpall", "_spallTrack", "_foundObjectHPIds", "_skip", "_explosive", "_indirectRange", "_force", "_fragPower"]; params ["_round", "_lastPos", "_lastVel", "_type", "_firedFrame", "_gun", "_doSpall", "_spallTrack", "_foundObjectHPIds", "_skip", "_explosive", "_indirectRange", "_force", "_fragPower"];
if (_round in GVAR(blackList)) exitWith { if (_round in GVAR(blackList)) exitWith {
false false
@ -17,7 +17,7 @@ if (!alive _round) exitWith {
}; };
}; };
if (_doSpall) then { if (_doSpall) then {
GVAR(spallIsTrackingCount) = GVAR(spallIsTrackingCount) - 1; DEC(GVAR(spallIsTrackingCount));
// diag_log text format ["F: %1", _foundObjectHPIds]; // diag_log text format ["F: %1", _foundObjectHPIds];
{ {
if (!isNil "_x") then { if (!isNil "_x") then {
@ -28,8 +28,8 @@ if (!alive _round) exitWith {
false false
}; };
_this set[1, (getPosASL _round)]; _this set [1, getPosASL _round];
_this set[2, (velocity _round)]; _this set [2, velocity _round];
if (_doSpall) then { if (_doSpall) then {
private ["_scale"]; private ["_scale"];

View File

@ -5,7 +5,7 @@
PARAMS_1(_round); PARAMS_1(_round);
if (_round in GVAR(blackList)) then { if (_round in GVAR(blackList)) then {
GVAR(blackList) = GVAR(blackList) - [_round]; REM(GVAR(blackList),_round);
}; };
GVAR(objects) = GVAR(objects) - [_round]; REM(GVAR(objects),_round);

View File

@ -1,12 +1,11 @@
#include "script_component.hpp" #include "script_component.hpp"
private ["_ret"]; private _ret = true;
_ret = true; if (IS_ARRAY(_this select 0)) then {
if(IS_ARRAY((_this select 0))) then {
_ret = false; _ret = false;
} else { } else {
if ((_this select 0) in GVAR(trackedObjects)) then { if ((_this select 0) in GVAR(trackedObjects)) then {
GVAR(trackedObjects) = GVAR(trackedObjects) - [(_this select 0)]; REM(GVAR(trackedObjects),_this select 0);
} else { } else {
_ret = false; _ret = false;
}; };

View File

@ -1,18 +1,18 @@
#include "script_component.hpp" #include "script_component.hpp"
private ["_initialData", "_hpData", "_round", "_hpRound", "_hpDirect"];
//player sideChat format ["f: %1 c: %2", (_this select 0), (count GVAR(spallHPData))]; //player sideChat format ["f: %1 c: %2", (_this select 0), (count GVAR(spallHPData))];
if ((_this select 0) <= (count GVAR(spallHPData))) then { params ["_index", "_hitPartData"];
_initialData = GVAR(spallHPData) select (_this select 0);
if (!isNil "_initialData") then { private _initialData = GVAR(spallHPData) param [_index, []];
_hpRound = ((_this select 1) select 0) select 2; if (_initialData isEqualTo []) exitWith {};
_round = _initialData select 3;
_hpDirect = ((_this select 1) select 0) select 10; private _hpRound = (_hitPartData select 0) select 2;
private _round = _initialData select 3;
private _hpDirect = (_hitPartData select 0) select 10;
if (_hpDirect && {_round == _hpRound}) then { if (_hpDirect && {_round == _hpRound}) then {
{ {
_hpData = _x;
_round = _initialData select 3;
// diag_log text format ["HPDUMP-------------------------------------"]; // diag_log text format ["HPDUMP-------------------------------------"];
// { // {
// _hp = _x; // _hp = _x;
@ -23,7 +23,5 @@ if ((_this select 0) <= (count GVAR(spallHPData))) then {
// } forEach (_this select 1); // } forEach (_this select 1);
[DFUNC(doSpall), [_this, _forEachIndex]] call CBA_fnc_execNextFrame; [DFUNC(doSpall), [_this, _forEachIndex]] call CBA_fnc_execNextFrame;
// player sideChat "WEEE"; // player sideChat "WEEE";
} forEach (_this select 1); } forEach _hitPartData;
};
};
}; };

View File

@ -12,17 +12,15 @@ private _forwardPos = _curPos vectorAdd _velocityStep;
private _intersectsWith = lineIntersectsWith [_curPos, _forwardPos]; private _intersectsWith = lineIntersectsWith [_curPos, _forwardPos];
if (count _intersectsWith > 0) then { if (_intersectsWith isEqualTo []) exitWith {};
// player sideChat format ["inter: %1", _intersectsWith]; // player sideChat format ["inter: %1", _intersectsWith];
{ {
if(!(_x in _foundObjects)) then {
// diag_log text format ["Adding HP: %1", _x]; // diag_log text format ["Adding HP: %1", _x];
private _index = count GVAR(spallHPData); private _index = count GVAR(spallHPData);
private _hpId = _x addEventHandler ["hitPart", compile format ["[%1, _this] call " + QFUNC(spallHP), _index]]; private _hpId = _x addEventHandler ["hitPart", compile format ["[%1, _this] call " + QFUNC(spallHP), _index]];
_foundObjects set[(count _foundObjects), _x]; _foundObjects pushBack _x;
_foundObjectHPIds set[(count _foundObjectHPIds), _hpId]; _foundObjectHPIds pushBack _hpId;
private _data = [_hpId, _x, typeOf _round, _round, _curPos, _velocity, 0, _foundObjects, _foundObjectHPIds]; private _data = [_hpId, _x, typeOf _round, _round, _curPos, _velocity, 0, _foundObjects, _foundObjectHPIds];
GVAR(spallHPData) set[_index, _data]; GVAR(spallHPData) pushBack _data;
}; } forEach (_intersectsWith select {!(_x in _foundObjects)});
} forEach _intersectsWith;
};

View File

@ -1,5 +1,5 @@
#include "script_component.hpp" #include "script_component.hpp"
if(!GVAR(tracesStarted)) then {
if (GVAR(tracesStarted)) exitWith {};
GVAR(tracesStarted) = true; GVAR(tracesStarted) = true;
GVAR(traceID) = [FUNC(drawTraces), 0, []] call CBA_fnc_addPerFrameHandler; GVAR(traceID) = [FUNC(drawTraces)] call CBA_fnc_addPerFrameHandler;
};

View File

@ -1,5 +1,5 @@
#include "script_component.hpp" #include "script_component.hpp"
if(GVAR(tracesStarted)) then {
if (!GVAR(tracesStarted)) exitWith {};
GVAR(tracesStarted) = false; GVAR(tracesStarted) = false;
[GVAR(traceID)] call CBA_fnc_removePerFrameHandler; [GVAR(traceID)] call CBA_fnc_removePerFrameHandler;
};

View File

@ -1,12 +1,12 @@
#include "script_component.hpp" #include "script_component.hpp"
params ["_args"]; params ["_args", "_pfhID"];
_args params ["_tracerObj", "_index"]; _args params ["_tracerObj", "_index"];
if (alive _tracerObj && (count GVAR(traces)) > 0) then { if (alive _tracerObj && {!(GVAR(traces) isEqualTo [])}) then {
private _data = GVAR(traces) select _index; private _data = GVAR(traces) select _index;
private _positions = _data select 4; private _positions = _data select 4;
_positions pushBack [(getPos _tracerObj), vectorMagnitude (velocity _tracerObj)]; _positions pushBack [getPos _tracerObj, vectorMagnitude (velocity _tracerObj)];
} else { } else {
[(_this select 1)] call CBA_fnc_removePerFrameHandler; [_pfhID] call CBA_fnc_removePerFrameHandler;
}; };