diff --git a/addons/cookoff/functions/fnc_detonateAmmunition.sqf b/addons/cookoff/functions/fnc_detonateAmmunition.sqf index 20ec84cbbd..c5c0a64549 100644 --- a/addons/cookoff/functions/fnc_detonateAmmunition.sqf +++ b/addons/cookoff/functions/fnc_detonateAmmunition.sqf @@ -65,7 +65,6 @@ if (_amountOfMagazines > 0) exitWith { private _velVec = _vectorAmmo vectorMultiply _speed; _projectile setVectorDir _velVec; _projectile setVelocity _velVec; - // [ACE_player, _projectile, [1,0,0,1]] call EFUNC(frag,addTrack); // visual debuging from ace_frag } else { _projectile setDamage 1; }; diff --git a/addons/frag/ACE_Settings.hpp b/addons/frag/ACE_Settings.hpp index eb0beea661..63a3d564d2 100644 --- a/addons/frag/ACE_Settings.hpp +++ b/addons/frag/ACE_Settings.hpp @@ -25,20 +25,13 @@ class ACE_Settings { displayName = CSTRING(MaxTrack); description = CSTRING(MaxTrack_Desc); typeName = "SCALAR"; - value = 500; + value = 10; }; class GVAR(maxTrackPerFrame) { category = CSTRING(Module_DisplayName); displayName = CSTRING(MaxTrackPerFrame); description = CSTRING(MaxTrackPerFrame_Desc); typeName = "SCALAR"; - value = 50; - }; - class GVAR(enableDebugTrace) { - category = CSTRING(Module_DisplayName); - displayName = CSTRING(EnableDebugTrace); - description = CSTRING(EnableDebugTrace_Desc); - typeName = "BOOL"; - value = 0; + value = 10; }; }; diff --git a/addons/frag/XEH_PREP.hpp b/addons/frag/XEH_PREP.hpp index a9a9d43c5b..a7fb8ff8c3 100644 --- a/addons/frag/XEH_PREP.hpp +++ b/addons/frag/XEH_PREP.hpp @@ -7,19 +7,17 @@ PREP(spallTrack); // * Other */ PREP(addBlackList); -PREP(addTrack); -PREP(drawTraces); -PREP(removeTrack); +PREP(dev_addTrack); +PREP(dev_drawTraces); PREP(spallHP); -PREP(startTracing); -PREP(stopTracing); -PREP(trackTrace); +PREP(dev_startTracing); +PREP(dev_stopTracing); +PREP(dev_trackTrace); // New tracking mechanisms PREP(masterPFH); PREP(pfhRound); PREP(addPfhRound); -PREP(removePfhRound); // THIS SHOULD ABE USED SPARINGLY // Explosive Reflection PREP(findReflections); diff --git a/addons/frag/XEH_postInit.sqf b/addons/frag/XEH_postInit.sqf index 31f9515750..634212354c 100644 --- a/addons/frag/XEH_postInit.sqf +++ b/addons/frag/XEH_postInit.sqf @@ -1,11 +1,7 @@ #include "script_component.hpp" -if (GVAR(enableDebugTrace) && {!isMultiplayer}) then { - GVAR(traceFrags) = true; - GVAR(autoTrace) = true; -}; - if (isServer) then { + GVAR(lastFragTime) = -1; [QGVAR(frag_eh), {_this call FUNC(frago);}] call CBA_fnc_addEventHandler; }; @@ -24,6 +20,13 @@ if (isServer) then { // Cache for ammo type configs GVAR(cacheRoundsTypesToTrack) = [false] call CBA_fnc_createNamespace; -#ifdef DEBUG_ENABLED_FRAG + +// Debug stuff: + +#ifdef DRAW_FRAG_INFO +[] call FUNC(dev_startTracing); +#endif + +#ifdef DEBUG_MODE_FULL [true, true, 30] call FUNC(dev_debugAmmo); #endif diff --git a/addons/frag/XEH_preInit.sqf b/addons/frag/XEH_preInit.sqf index da87d01194..7cbd6092a1 100644 --- a/addons/frag/XEH_preInit.sqf +++ b/addons/frag/XEH_preInit.sqf @@ -6,23 +6,18 @@ PREP_RECOMPILE_START; #include "XEH_PREP.hpp" PREP_RECOMPILE_END; -GVAR(replacedBisArtyWrapper) = true; GVAR(blackList) = []; GVAR(traceFrags) = false; -GVAR(totalFrags) = 0; - GVAR(spallHPData) = []; GVAR(spallIsTrackingCount) = 0; -GVAR(autoTrace) = false; GVAR(traceID) = -1; GVAR(traces) = []; GVAR(tracesStarted) = false; GVAR(lastIterationIndex) = 0; GVAR(objects) = []; -GVAR(objectTypes) = []; GVAR(arguments) = []; ADDON = true; diff --git a/addons/frag/functions/fnc_addBlackList.sqf b/addons/frag/functions/fnc_addBlackList.sqf index 9950cab2b0..79cb41adab 100644 --- a/addons/frag/functions/fnc_addBlackList.sqf +++ b/addons/frag/functions/fnc_addBlackList.sqf @@ -1,5 +1,21 @@ +/* + * Author: Jaynus, NouberNou + * Adds a round to the blacklist (will be ignored). + * + * Arguments: + * 0: Projectile + * + * Return Value: + * Nothing + * + * Example: + * [bullet] call ace_frag_fnc_addBlackList + * + * Public: No + */ #include "script_component.hpp" params ["_round"]; +TRACE_1("addBlackList",_round); GVAR(blackList) pushBack _round; diff --git a/addons/frag/functions/fnc_addPfhRound.sqf b/addons/frag/functions/fnc_addPfhRound.sqf index f6cddbbd37..7c609f2146 100644 --- a/addons/frag/functions/fnc_addPfhRound.sqf +++ b/addons/frag/functions/fnc_addPfhRound.sqf @@ -1,27 +1,38 @@ +/* + * Author: Jaynus, NouberNou + * Starts tracking a round that will frag. + * Should only be called once per round. + * + * Arguments: + * 0: Shooter + * 1: Ammo classname + * 2: Projectile + * + * Return Value: + * Nothing + * + * Example: + * [player, "handGrenade", bullet] call ace_frag_fnc_addPfhRound + * + * Public: No + */ //#define DEBUG_MODE_FULL #include "script_component.hpp" -params ["_gun", "_type", "_round", ["_doFragTrack", false]]; +params ["_gun", "_type", "_round"]; +TRACE_3("addPfhRound",_gun,_type,_round); -if (!GVAR(enabled)) exitWith {}; +if (!GVAR(enabled)) exitWith {TRACE_1("setting disabled",_this);}; -//_enabled = getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(enabled)); -//if (_enabled < 1) exitWith {}; +if (!alive _round) exitWith {TRACE_1("round dead?",_this);}; if (_round in GVAR(blackList)) exitWith { + TRACE_1("round in blackList",_this); REM(GVAR(blackList),_round); }; // Exit on max track -if ((count GVAR(objects)) > GVAR(maxTrack)) exitWith {}; - -if ( - _gun == ACE_player || - {(gunner _gun) == ACE_player} || - {local _gun && {!(isPlayer (gunner _gun))} && {!(isPlayer _gun)}} -) then { - _doFragTrack = true; -}; +if ((count GVAR(objects)) >= GVAR(maxTrack)) exitWith {TRACE_1("maxTrack limit",count GVAR(objects));}; private _doSpall = false; if (GVAR(SpallEnabled)) then { @@ -29,23 +40,23 @@ if (GVAR(SpallEnabled)) then { GVAR(spallHPData) = []; }; if (GVAR(spallIsTrackingCount) > 5) then { - // ACE_player sideChat "LIMT!"; + TRACE_1("At Spall Limit",GVAR(spallIsTrackingCount)); } else { _doSpall = true; INC(GVAR(spallIsTrackingCount)); }; + TRACE_2("",_doSpall,GVAR(spallIsTrackingCount)); }; -// ACE_player sideChat format ["c: %1", GVAR(spallIsTrackingCount)]; -if (GVAR(autoTrace)) then { - [ACE_player, _round, [1, 0, 0, 1]] call FUNC(addTrack); -}; +#ifdef DRAW_FRAG_INFO +[ACE_player, _round, [0, 1, 0, 1]] call FUNC(dev_addTrack); +#endif // We only do the single track object check here. // We should do an {!(_round in GVAR(objects))} // 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 -if (_doFragTrack && {alive _round}) then { +if (alive _round) then { private _spallTrack = []; private _spallTrackID = []; @@ -64,5 +75,4 @@ if (_doFragTrack && {alive _round}) then { if (_doSpall) then { [_round, 1, _spallTrack, _spallTrackID] call FUNC(spallTrack); }; - // ACE_player sideChat "WTF2"; }; diff --git a/addons/frag/functions/fnc_addTrack.sqf b/addons/frag/functions/fnc_dev_addTrack.sqf similarity index 66% rename from addons/frag/functions/fnc_addTrack.sqf rename to addons/frag/functions/fnc_dev_addTrack.sqf index a93106d518..764627b60f 100644 --- a/addons/frag/functions/fnc_addTrack.sqf +++ b/addons/frag/functions/fnc_dev_addTrack.sqf @@ -1,10 +1,5 @@ #include "script_component.hpp" -if (GVAR(autoTrace)) then { - [] call FUNC(startTracing); -}; - -// setAccTime 0.05; params ["_origin", "_obj", ["_color", [1, 0, 0, 1]]]; private _positions = []; @@ -13,4 +8,4 @@ _positions pushBack [getPos _obj, _objSpd]; private _data = [_origin, typeOf _origin, typeOf _obj, _objSpd, _positions, _color]; private _index = GVAR(traces) pushBack _data; -[DFUNC(trackTrace), 0, [_obj, _index, CBA_missionTime]] call CBA_fnc_addPerFrameHandler; +[DFUNC(dev_trackTrace), 0, [_obj, _index, CBA_missionTime]] call CBA_fnc_addPerFrameHandler; diff --git a/addons/frag/functions/fnc_drawTraces.sqf b/addons/frag/functions/fnc_dev_drawTraces.sqf similarity index 82% rename from addons/frag/functions/fnc_drawTraces.sqf rename to addons/frag/functions/fnc_dev_drawTraces.sqf index 6dd710f61c..c6ab838e84 100644 --- a/addons/frag/functions/fnc_drawTraces.sqf +++ b/addons/frag/functions/fnc_dev_drawTraces.sqf @@ -1,11 +1,10 @@ #include "script_component.hpp" { - private _positions = _x select 4; - private _color = _x select 5; + _x params ["", "", "", "", "_positions", "_color"]; private _index = 0; private _max = count _positions; - private _lastSpd = []; + // private _lastSpd = []; private _lastPos = []; while {_index < _max} do { _data1 = _positions select _index; @@ -17,7 +16,7 @@ drawLine3D [_pos1, _pos2, _color]; _lastPos = _pos2; - _lastSpd = _data1 select 1; + // _lastSpd = _data1 select 1; }; // drawIcon3D ["", [1,0,0,1], _lastPos, 0, 0, 0, format ["%1m/s", _lastSpd], 1, 0.05, "RobotoCondensed"]; } forEach GVAR(traces); diff --git a/addons/frag/functions/fnc_dev_startTracing.sqf b/addons/frag/functions/fnc_dev_startTracing.sqf new file mode 100644 index 0000000000..b58a491896 --- /dev/null +++ b/addons/frag/functions/fnc_dev_startTracing.sqf @@ -0,0 +1,8 @@ +#include "script_component.hpp" + +if (GVAR(tracesStarted)) exitWith {}; + +INFO("Starting Trace Drawing"); + +GVAR(tracesStarted) = true; +GVAR(traceID) = [LINKFUNC(dev_drawTraces), 0, []] call CBA_fnc_addPerFrameHandler; diff --git a/addons/frag/functions/fnc_stopTracing.sqf b/addons/frag/functions/fnc_dev_stopTracing.sqf similarity index 82% rename from addons/frag/functions/fnc_stopTracing.sqf rename to addons/frag/functions/fnc_dev_stopTracing.sqf index e06a9a2b46..c25021bb4e 100644 --- a/addons/frag/functions/fnc_stopTracing.sqf +++ b/addons/frag/functions/fnc_dev_stopTracing.sqf @@ -1,5 +1,8 @@ #include "script_component.hpp" if (!GVAR(tracesStarted)) exitWith {}; + +INFO("Ending Trace Drawing"); + GVAR(tracesStarted) = false; [GVAR(traceID)] call CBA_fnc_removePerFrameHandler; diff --git a/addons/frag/functions/fnc_trackTrace.sqf b/addons/frag/functions/fnc_dev_trackTrace.sqf similarity index 100% rename from addons/frag/functions/fnc_trackTrace.sqf rename to addons/frag/functions/fnc_dev_trackTrace.sqf diff --git a/addons/frag/functions/fnc_doSpall.sqf b/addons/frag/functions/fnc_doSpall.sqf index 97c52062d1..ee1bc37384 100644 --- a/addons/frag/functions/fnc_doSpall.sqf +++ b/addons/frag/functions/fnc_doSpall.sqf @@ -99,9 +99,9 @@ for "_i" from 1 to _spallCount do { _fragment setPosASL _spallPos; _fragment setVelocity _spallFragVect; - if (GVAR(traceFrags)) then { - [ACE_player, _fragment, [1, 0.5, 0, 1]] call FUNC(addTrack); - }; + #ifdef DRAW_FRAG_INFO + [ACE_player, _fragment, [1, 0.5, 0, 1]] call FUNC(dev_addTrack); + #endif }; _spread = 5 + (random 5); @@ -122,7 +122,7 @@ for "_i" from 1 to _spallCount do { _fragment setPosASL _spallPos; _fragment setVelocity _spallFragVect; - if (GVAR(traceFrags)) then { - [ACE_player, _fragment, [1, 0, 0, 1]] call FUNC(addTrack); - }; + #ifdef DRAW_FRAG_INFO + [ACE_player, _fragment, [1, 0, 0, 1]] call FUNC(dev_addTrack); + #endif }; diff --git a/addons/frag/functions/fnc_fired.sqf b/addons/frag/functions/fnc_fired.sqf index 96841dd7ac..42885d55b0 100644 --- a/addons/frag/functions/fnc_fired.sqf +++ b/addons/frag/functions/fnc_fired.sqf @@ -50,6 +50,14 @@ if (isNil "_shouldAdd") then { }; if (_shouldAdd) then { - TRACE_3("Running Frag Tracking",_unit,_ammo,_projectile); + // firedMan will have nil "_gunner", so just check _unit; for firedVehicle we want to check _gunner + private _localShooter = if (isNil "_gunner") then {local _unit} else {local _gunner}; + TRACE_4("",_localShooter,_unit,_ammo,_projectile); + if (!_localShooter) exitWith {}; + + // Skip if less than 0.5 second from last shot + if ((CBA_missionTime - (_unit getVariable [QGVAR(lastTrack), -1])) < 0.5) exitWith {}; + _unit setVariable [QGVAR(lastTrack), CBA_missionTime]; + [_unit, _ammo, _projectile] call FUNC(addPfhRound); }; diff --git a/addons/frag/functions/fnc_frago.sqf b/addons/frag/functions/fnc_frago.sqf index 5481649b54..49f1a62237 100644 --- a/addons/frag/functions/fnc_frago.sqf +++ b/addons/frag/functions/fnc_frago.sqf @@ -1,17 +1,35 @@ -//fnc_frago.sqf -// #define DEBUG_MODE_FULL +/* + * Author: Jaynus, NouberNou + * Server func to create the fragmentation for a round. + * + * Arguments: + * 0: Last Position (ASL) + * 1: Velocity + * 2: Ammo Classname + * + * Return Value: + * Nothing + * + * Example: + * [[], [], "handGrenade"] call ace_frag_fnc_frago + * + * Public: No + */ +//#define DEBUG_MODE_FULL #include "script_component.hpp" #define FRAG_VEC_VAR 0.004 - #define MAX_FRAG_COUNT 50 -if (!isServer) exitWith {}; - BEGIN_COUNTER(frago); -// _startTime = diag_tickTime; -params ["_round", "_lastPos", "_lastVel", "_shellType", "_firedFrame", "_gun"]; +params ["_lastPos", "_lastVel", "_shellType"]; +TRACE_3("frago",_lastPos,_lastVel,_shellType); + +// Limit max frag count if there was a recent frag +private _maxFrags = round (MAX_FRAG_COUNT * linearConversion [0.1, 1.5, (CBA_missionTime - GVAR(lastFragTime)), 0.1, 1, true]); +TRACE_2("",_maxFrags,CBA_missionTime - GVAR(lastFragTime)); +GVAR(lastFragTime) = CBA_missionTime; private _fragTypes = [ QGVAR(tiny), QGVAR(tiny), QGVAR(tiny), @@ -28,12 +46,6 @@ if (isArray (configFile >> "CfgAmmo" >> _shellType >> QGVAR(CLASSES))) then { _warn = true; }; -private _isArmed = true; -if (!isNil "_gun") then { - private _fuseDist = getNumber(configFile >> "CfgAmmo" >> _shellType >> "fuseDistance"); - _isArmed = ((getPosASL _gun) distance _lastPos > _fuseDist); -}; - private _indirectHitRange = getNumber(configFile >> "CfgAmmo" >> _shellType >> "indirecthitrange"); private _fragRange = 20 * _indirectHitRange * 4; // _c = 185; // grams of comp-b @@ -69,104 +81,91 @@ if ((_atlPos select 2) < 0.5) then { _lastPos vectorAdd [0, 0, 0.5]; }; -// _manObjects = _atlPos nearEntities ["CaManBase", _fragRange]; - -// setAccTime 0.01; - -//_objects = nearestObjects [_atlPos, ["AllVehicles"], _fragRange]; // Not sure if tracking "ReammoBox" is required, if so revert this change for _objects private _objects = _atlPos nearEntities [["Car", "Motorcycle", "Tank", "StaticWeapon", "CAManBase", "Air", "Ship"], _fragRange]; - -// _objects = _manObjects; // Add unique crews in faster way { { _objects pushBackUnique _x; } forEach (crew _x); } forEach _objects; +TRACE_2("",_fragRange,count _objects); private _fragCount = 0; private _fragArcs = []; _fragArcs set [360, 0]; -#ifdef DEBUG_MODE_FULL - ACE_player sideChat format ["_fragRange: %1", _fragRange]; - ACE_player sideChat format ["_objects: %1", _objects]; -#endif - private _doRandom = true; -if (_isArmed && {!(_objects isEqualTo [])}) then { +if (!(_objects isEqualTo [])) then { if (GVAR(reflectionsEnabled)) then { [_lastPos, _shellType] call FUNC(doReflections); }; { - //if (random(1) > 0.5) then { - private _target = _x; - if (alive _target) then { - (boundingBox _target) params ["_boundingBoxA", "_boundingBoxB"]; + private _target = _x; + if (alive _target) then { + (boundingBox _target) params ["_boundingBoxA", "_boundingBoxB"]; - private _cubic = ((abs (_boundingBoxA select 0)) + (_boundingBoxB select 0)) * ((abs (_boundingBoxA select 1)) + (_boundingBoxB select 1)) * ((abs (_boundingBoxA select 2)) + (_boundingBoxB select 2)); + private _cubic = ((abs (_boundingBoxA select 0)) + (_boundingBoxB select 0)) * ((abs (_boundingBoxA select 1)) + (_boundingBoxB select 1)) * ((abs (_boundingBoxA select 2)) + (_boundingBoxB select 2)); - if (_cubic <= 1) exitWith {}; - _doRandom = true; + if (_cubic <= 1) exitWith {}; + // _doRandom = true; - private _targetVel = velocity _target; - private _targetPos = getPosASL _target; - private _distance = _targetPos vectorDistance _lastPos; - private _add = ((_boundingBoxB select 2) / 2) + ((((_distance - (_fragpower / 8)) max 0) / _fragPower) * 10); + private _targetVel = velocity _target; + private _targetPos = getPosASL _target; + private _distance = _targetPos vectorDistance _lastPos; + private _add = ((_boundingBoxB select 2) / 2) + ((((_distance - (_fragpower / 8)) max 0) / _fragPower) * 10); - _targetPos = _targetPos vectorAdd [ - (_targetVel select 0) * (_distance / _fragPower), - (_targetVel select 1) * (_distance / _fragPower), - _add - ]; + _targetPos = _targetPos vectorAdd [ + (_targetVel select 0) * (_distance / _fragPower), + (_targetVel select 1) * (_distance / _fragPower), + _add + ]; - private _baseVec = _lastPos vectorFromTo _targetPos; + private _baseVec = _lastPos vectorFromTo _targetPos; - private _dir = floor (_baseVec call CBA_fnc_vectDir); - private _currentCount = RETDEF(_fragArcs select _dir,0); - if (_currentCount < 20) then { - private _count = ceil (random (sqrt (_m / 1000))); - private _vecVar = FRAG_VEC_VAR; - if (!(_target isKindOf "Man")) then { - ADD(_vecVar,(sqrt _cubic) / 2000); - if ((crew _target) isEqualTo [] && {_count > 0}) then { - _count = 0 max (_count / 2); - }; + private _dir = floor (_baseVec call CBA_fnc_vectDir); + private _currentCount = RETDEF(_fragArcs select _dir,0); + if (_currentCount < 10) then { + private _count = ceil (random (sqrt (_m / 1000))); + private _vecVar = FRAG_VEC_VAR; + if (!(_target isKindOf "Man")) then { + ADD(_vecVar,(sqrt _cubic) / 2000); + if ((crew _target) isEqualTo [] && {_count > 0}) then { + _count = 0 max (_count / 2); }; - for "_i" from 1 to _count do { - private _vec = _baseVec vectorDiff [ - (_vecVar / 2) + (random _vecVar), - (_vecVar / 2) + (random _vecVar), - (_vecVar / 2) + (random _vecVar) - ]; - - private _fp = _fragPower - (random (_fragPowerRandom)); - private _vel = _vec vectorMultiply _fp; - - private _fragType = round (random ((count _fragTypes) - 1)); - private _fragObj = (_fragTypes select _fragType) createVehicleLocal [0,0,10000]; - // diag_log text format ["fp: %1 %2", _fp, typeOf _fragObj]; - _fragObj setPosASL _lastPos; - _fragObj setVectorDir _vec; - _fragObj setVelocity _vel; - if (GVAR(traceFrags)) then { - INC(GVAR(totalFrags)); - [ACE_player, _fragObj, [1,0,0,1]] call FUNC(addTrack); - }; - INC(_fragCount); - INC(_currentCount); - }; - _fragArcs set [_dir, _currentCount]; }; + for "_i" from 1 to _count do { + private _vec = _baseVec vectorDiff [ + (_vecVar / 2) + (random _vecVar), + (_vecVar / 2) + (random _vecVar), + (_vecVar / 2) + (random _vecVar) + ]; + + private _fp = _fragPower - (random (_fragPowerRandom)); + private _vel = _vec vectorMultiply _fp; + + private _fragObj = (selectRandom _fragTypes) createVehicleLocal [0,0,10000]; + // TRACE_4("targeted",_fp, typeOf _fragObj,_lastPos vectorDistance _targetPos,typeOf _x); + _fragObj setPosASL _lastPos; + _fragObj setVectorDir _vec; + _fragObj setVelocity _vel; + #ifdef DRAW_FRAG_INFO + [ACE_player, _fragObj, [1,0,0,1]] call FUNC(dev_addTrack); + #endif + INC(_fragCount); + INC(_currentCount); + }; + _fragArcs set [_dir, _currentCount]; }; - //}; - if (_fragCount > MAX_FRAG_COUNT) exitWith {}; + }; + if (_fragCount > _maxFrags) exitWith {}; } forEach _objects; - if (_fragCount > MAX_FRAG_COUNT) exitWith {}; - private _randomCount = ((ceil ((MAX_FRAG_COUNT - _fragCount) * 0.1)) max 0) + 20; + TRACE_1("targeted",_fragCount); + if (_fragCount > _maxFrags) exitWith {}; + private _randomCount = ceil ((_maxFrags - _fragCount) * 0.35); + TRACE_1("",_randomCount); private _sectorSize = 360 / (_randomCount max 1); - // _doRandom = false; + if (_doRandom) then { for "_i" from 1 to _randomCount do { // Distribute evenly @@ -178,24 +177,19 @@ if (_isArmed && {!(_objects isEqualTo [])}) then { _vel = _vec vectorMultiply _fp; - _fragType = round (random ((count _fragTypes) - 1)); - _fragObj = (_fragTypes select _fragType) createVehicleLocal [0, 0, 10000]; + _fragObj = (selectRandom _fragTypes) createVehicleLocal [0, 0, 10000]; _fragObj setPosASL _lastPos; _fragObj setVectorDir _vec; _fragObj setVelocity _vel; - if (GVAR(traceFrags)) then { - INC(GVAR(totalFrags)); - [ACE_player, _fragObj, [1,0.5,0,1]] call FUNC(addTrack); - }; + #ifdef DRAW_FRAG_INFO + [ACE_player, _fragObj, [1,0.5,0,1]] call FUNC(dev_addTrack); + #endif INC(_fragCount); }; }; - }; -// #ifdef DEBUG_MODE_FULL - // ACE_player sideChat format["total frags: %1", GVAR(totalFrags)]; - // ACE_player sideChat format["tracks: %1", (count GVAR(trackedObjects))]; -// #endif -// _endTime = diag_tickTime; + +TRACE_1("total created",_fragCount); + END_COUNTER(frago); diff --git a/addons/frag/functions/fnc_masterPFH.sqf b/addons/frag/functions/fnc_masterPFH.sqf index f6adb56161..10b7743102 100644 --- a/addons/frag/functions/fnc_masterPFH.sqf +++ b/addons/frag/functions/fnc_masterPFH.sqf @@ -1,19 +1,20 @@ /* * Author: jaynus - * - * Master single PFH abstraction for all rounds being tracked by frag/spall + * Master single PFH abstraction for all rounds being tracked by frag/spall. * * Arguments: - * + * None * * Return Value: * None */ //#define DEBUG_MODE_FULL #include "script_component.hpp" -//PARAMS_2(_pfhArgs,_handle); -if (!GVAR(enabled)) exitWith {}; +BEGIN_COUNTER(PFH); + +// Fast exit if nothing to do +if (GVAR(objects) isEqualTo []) exitWith {END_COUNTER(PFH);}; private _gcIndex = []; @@ -47,3 +48,5 @@ private _deletionCount = 0; INC(_deletionCount); } forEach _gcIndex; + +END_COUNTER(PFH); diff --git a/addons/frag/functions/fnc_pfhRound.sqf b/addons/frag/functions/fnc_pfhRound.sqf index f233fa45a6..3c72a525c9 100644 --- a/addons/frag/functions/fnc_pfhRound.sqf +++ b/addons/frag/functions/fnc_pfhRound.sqf @@ -1,6 +1,6 @@ #include "script_component.hpp" -params ["_round", "_lastPos", "_lastVel", "_type", "_firedFrame", "_gun", "_doSpall", "_spallTrack", "_foundObjectHPIds", "_skip", "_explosive", "_indirectRange", "_force", "_fragPower"]; +params ["_round", "_lastPos", "_lastVel", "_shellType", "_firedFrame", "_gun", "_doSpall", "_spallTrack", "_foundObjectHPIds", "_skip", "_explosive", "_indirectRange", "_force", "_fragPower"]; if (_round in GVAR(blackList)) exitWith { false @@ -11,14 +11,22 @@ if (!alive _round) exitWith { if (_skip == 0) then { if ((_explosive > 0.5 && {_indirectRange >= 4.5} && {_fragPower >= 35}) || {_force == 1}) then { // shotbullet, shotShell don't seem to explode when touching water, so don't create frags - if (((_lastPos select 2) < 0) && {(toLower getText (configFile >> "CfgAmmo" >> _type >> "simulation")) in ["shotbullet", "shotshell"]}) exitWith {}; - [QGVAR(frag_eh), _this] call CBA_fnc_serverEvent; + if (((_lastPos select 2) < 0) && {(toLower getText (configFile >> "CfgAmmo" >> _shellType >> "simulation")) in ["shotbullet", "shotshell"]}) exitWith {}; + private _isArmed = true; + if (!isNil "_gun") then { + private _fuseDist = getNumber(configFile >> "CfgAmmo" >> _shellType >> "fuseDistance"); + _isArmed = ((getPosASL _gun) distance _lastPos > _fuseDist); + TRACE_2("",_fuseDist,_isArmed); + }; + if (!_isArmed) exitWith {TRACE_1("round not armed",_this);}; + TRACE_3("Sending frag event to server",_lastPos,_lastVel,_shellType); + [QGVAR(frag_eh), [_lastPos,_lastVel,_shellType]] call CBA_fnc_serverEvent; }; }; }; if (_doSpall) then { DEC(GVAR(spallIsTrackingCount)); - // diag_log text format ["F: %1", _foundObjectHPIds]; + TRACE_1("doSpall",_foundObjectHPIds); { if (!isNil "_x") then { _x removeEventHandler ["hitPart", _foundObjectHPIds select _forEachIndex]; diff --git a/addons/frag/functions/fnc_removePfhRound.sqf b/addons/frag/functions/fnc_removePfhRound.sqf deleted file mode 100644 index 9241c7aecb..0000000000 --- a/addons/frag/functions/fnc_removePfhRound.sqf +++ /dev/null @@ -1,11 +0,0 @@ -#include "script_component.hpp" - -// THIS FUNCTION SHOULD NOT BE USED BECAUSE IT CAUSES AN SEARCH AND REBUILD - -params ["_round"]; - -if (_round in GVAR(blackList)) then { - REM(GVAR(blackList),_round); -}; - -REM(GVAR(objects),_round); diff --git a/addons/frag/functions/fnc_removeTrack.sqf b/addons/frag/functions/fnc_removeTrack.sqf deleted file mode 100644 index 8c0f7e3736..0000000000 --- a/addons/frag/functions/fnc_removeTrack.sqf +++ /dev/null @@ -1,13 +0,0 @@ -#include "script_component.hpp" - -private _ret = true; -if (IS_ARRAY(_this select 0)) then { - _ret = false; -} else { - if ((_this select 0) in GVAR(trackedObjects)) then { - REM(GVAR(trackedObjects),_this select 0); - } else { - _ret = false; - }; -}; -_ret diff --git a/addons/frag/functions/fnc_startTracing.sqf b/addons/frag/functions/fnc_startTracing.sqf deleted file mode 100644 index c697a8dca2..0000000000 --- a/addons/frag/functions/fnc_startTracing.sqf +++ /dev/null @@ -1,5 +0,0 @@ -#include "script_component.hpp" - -if (GVAR(tracesStarted)) exitWith {}; -GVAR(tracesStarted) = true; -GVAR(traceID) = [FUNC(drawTraces), 0, []] call CBA_fnc_addPerFrameHandler; diff --git a/addons/frag/script_component.hpp b/addons/frag/script_component.hpp index 59868e36cf..0215e9f4d7 100644 --- a/addons/frag/script_component.hpp +++ b/addons/frag/script_component.hpp @@ -2,7 +2,7 @@ #define COMPONENT_BEAUTIFIED Frag #include "\z\ace\addons\main\script_mod.hpp" -//#define DEBUG_ENABLED_FRAG +// #define DRAW_FRAG_INFO // #define DEBUG_MODE_FULL // #define DISABLE_COMPILE_CACHE // #define ENABLE_PERFORMANCE_COUNTERS