Frag - Cleanup and Performance (#5010)

* Frag - Cleanup and Performance

* Add dots
This commit is contained in:
PabstMirror 2017-04-11 10:33:56 -05:00 committed by GitHub
parent f44da354d5
commit 8d43b899e6
21 changed files with 201 additions and 198 deletions

View File

@ -65,7 +65,6 @@ if (_amountOfMagazines > 0) exitWith {
private _velVec = _vectorAmmo vectorMultiply _speed; private _velVec = _vectorAmmo vectorMultiply _speed;
_projectile setVectorDir _velVec; _projectile setVectorDir _velVec;
_projectile setVelocity _velVec; _projectile setVelocity _velVec;
// [ACE_player, _projectile, [1,0,0,1]] call EFUNC(frag,addTrack); // visual debuging from ace_frag
} else { } else {
_projectile setDamage 1; _projectile setDamage 1;
}; };

View File

@ -25,20 +25,13 @@ class ACE_Settings {
displayName = CSTRING(MaxTrack); displayName = CSTRING(MaxTrack);
description = CSTRING(MaxTrack_Desc); description = CSTRING(MaxTrack_Desc);
typeName = "SCALAR"; typeName = "SCALAR";
value = 500; value = 10;
}; };
class GVAR(maxTrackPerFrame) { class GVAR(maxTrackPerFrame) {
category = CSTRING(Module_DisplayName); category = CSTRING(Module_DisplayName);
displayName = CSTRING(MaxTrackPerFrame); displayName = CSTRING(MaxTrackPerFrame);
description = CSTRING(MaxTrackPerFrame_Desc); description = CSTRING(MaxTrackPerFrame_Desc);
typeName = "SCALAR"; typeName = "SCALAR";
value = 50; value = 10;
};
class GVAR(enableDebugTrace) {
category = CSTRING(Module_DisplayName);
displayName = CSTRING(EnableDebugTrace);
description = CSTRING(EnableDebugTrace_Desc);
typeName = "BOOL";
value = 0;
}; };
}; };

View File

@ -7,19 +7,17 @@ PREP(spallTrack);
// * Other */ // * Other */
PREP(addBlackList); PREP(addBlackList);
PREP(addTrack); PREP(dev_addTrack);
PREP(drawTraces); PREP(dev_drawTraces);
PREP(removeTrack);
PREP(spallHP); PREP(spallHP);
PREP(startTracing); PREP(dev_startTracing);
PREP(stopTracing); PREP(dev_stopTracing);
PREP(trackTrace); PREP(dev_trackTrace);
// New tracking mechanisms // New tracking mechanisms
PREP(masterPFH); PREP(masterPFH);
PREP(pfhRound); PREP(pfhRound);
PREP(addPfhRound); PREP(addPfhRound);
PREP(removePfhRound); // THIS SHOULD ABE USED SPARINGLY
// Explosive Reflection // Explosive Reflection
PREP(findReflections); PREP(findReflections);

View File

@ -1,11 +1,7 @@
#include "script_component.hpp" #include "script_component.hpp"
if (GVAR(enableDebugTrace) && {!isMultiplayer}) then {
GVAR(traceFrags) = true;
GVAR(autoTrace) = true;
};
if (isServer) then { if (isServer) then {
GVAR(lastFragTime) = -1;
[QGVAR(frag_eh), {_this call FUNC(frago);}] call CBA_fnc_addEventHandler; [QGVAR(frag_eh), {_this call FUNC(frago);}] call CBA_fnc_addEventHandler;
}; };
@ -24,6 +20,13 @@ if (isServer) then {
// Cache for ammo type configs // Cache for ammo type configs
GVAR(cacheRoundsTypesToTrack) = [false] call CBA_fnc_createNamespace; 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); [true, true, 30] call FUNC(dev_debugAmmo);
#endif #endif

View File

@ -6,23 +6,18 @@ PREP_RECOMPILE_START;
#include "XEH_PREP.hpp" #include "XEH_PREP.hpp"
PREP_RECOMPILE_END; PREP_RECOMPILE_END;
GVAR(replacedBisArtyWrapper) = true;
GVAR(blackList) = []; GVAR(blackList) = [];
GVAR(traceFrags) = false; GVAR(traceFrags) = false;
GVAR(totalFrags) = 0;
GVAR(spallHPData) = []; GVAR(spallHPData) = [];
GVAR(spallIsTrackingCount) = 0; GVAR(spallIsTrackingCount) = 0;
GVAR(autoTrace) = false;
GVAR(traceID) = -1; GVAR(traceID) = -1;
GVAR(traces) = []; GVAR(traces) = [];
GVAR(tracesStarted) = false; GVAR(tracesStarted) = false;
GVAR(lastIterationIndex) = 0; GVAR(lastIterationIndex) = 0;
GVAR(objects) = []; GVAR(objects) = [];
GVAR(objectTypes) = [];
GVAR(arguments) = []; GVAR(arguments) = [];
ADDON = true; ADDON = true;

View File

@ -1,5 +1,21 @@
/*
* Author: Jaynus, NouberNou
* Adds a round to the blacklist (will be ignored).
*
* Arguments:
* 0: Projectile <OBJECT>
*
* Return Value:
* Nothing
*
* Example:
* [bullet] call ace_frag_fnc_addBlackList
*
* Public: No
*/
#include "script_component.hpp" #include "script_component.hpp"
params ["_round"]; params ["_round"];
TRACE_1("addBlackList",_round);
GVAR(blackList) pushBack _round; GVAR(blackList) pushBack _round;

View File

@ -1,27 +1,38 @@
/*
* Author: Jaynus, NouberNou
* Starts tracking a round that will frag.
* Should only be called once per round.
*
* Arguments:
* 0: Shooter <OBJECT>
* 1: Ammo classname <STRING>
* 2: Projectile <OBJECT>
*
* Return Value:
* Nothing
*
* Example:
* [player, "handGrenade", bullet] call ace_frag_fnc_addPfhRound
*
* Public: No
*/
//#define DEBUG_MODE_FULL //#define DEBUG_MODE_FULL
#include "script_component.hpp" #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 (!alive _round) exitWith {TRACE_1("round dead?",_this);};
//if (_enabled < 1) exitWith {};
if (_round in GVAR(blackList)) exitWith { if (_round in GVAR(blackList)) exitWith {
TRACE_1("round in blackList",_this);
REM(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 {TRACE_1("maxTrack limit",count GVAR(objects));};
if (
_gun == ACE_player ||
{(gunner _gun) == ACE_player} ||
{local _gun && {!(isPlayer (gunner _gun))} && {!(isPlayer _gun)}}
) then {
_doFragTrack = true;
};
private _doSpall = false; private _doSpall = false;
if (GVAR(SpallEnabled)) then { if (GVAR(SpallEnabled)) then {
@ -29,23 +40,23 @@ if (GVAR(SpallEnabled)) then {
GVAR(spallHPData) = []; GVAR(spallHPData) = [];
}; };
if (GVAR(spallIsTrackingCount) > 5) then { if (GVAR(spallIsTrackingCount) > 5) then {
// ACE_player sideChat "LIMT!"; TRACE_1("At Spall Limit",GVAR(spallIsTrackingCount));
} else { } else {
_doSpall = true; _doSpall = true;
INC(GVAR(spallIsTrackingCount)); INC(GVAR(spallIsTrackingCount));
}; };
TRACE_2("",_doSpall,GVAR(spallIsTrackingCount));
}; };
// ACE_player sideChat format ["c: %1", GVAR(spallIsTrackingCount)];
if (GVAR(autoTrace)) then { #ifdef DRAW_FRAG_INFO
[ACE_player, _round, [1, 0, 0, 1]] call FUNC(addTrack); [ACE_player, _round, [0, 1, 0, 1]] call FUNC(dev_addTrack);
}; #endif
// We only do the single track object check here. // We only do the single track object check here.
// We should do an {!(_round in GVAR(objects))} // We should do an {!(_round in GVAR(objects))}
// 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 (alive _round) then {
private _spallTrack = []; private _spallTrack = [];
private _spallTrackID = []; private _spallTrackID = [];
@ -64,5 +75,4 @@ if (_doFragTrack && {alive _round}) then {
if (_doSpall) then { if (_doSpall) then {
[_round, 1, _spallTrack, _spallTrackID] call FUNC(spallTrack); [_round, 1, _spallTrack, _spallTrackID] call FUNC(spallTrack);
}; };
// ACE_player sideChat "WTF2";
}; };

View File

@ -1,10 +1,5 @@
#include "script_component.hpp" #include "script_component.hpp"
if (GVAR(autoTrace)) then {
[] call FUNC(startTracing);
};
// setAccTime 0.05;
params ["_origin", "_obj", ["_color", [1, 0, 0, 1]]]; params ["_origin", "_obj", ["_color", [1, 0, 0, 1]]];
private _positions = []; private _positions = [];
@ -13,4 +8,4 @@ _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];
private _index = GVAR(traces) pushBack _data; 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;

View File

@ -1,11 +1,10 @@
#include "script_component.hpp" #include "script_component.hpp"
{ {
private _positions = _x select 4; _x params ["", "", "", "", "_positions", "_color"];
private _color = _x select 5;
private _index = 0; private _index = 0;
private _max = count _positions; private _max = count _positions;
private _lastSpd = []; // private _lastSpd = [];
private _lastPos = []; private _lastPos = [];
while {_index < _max} do { while {_index < _max} do {
_data1 = _positions select _index; _data1 = _positions select _index;
@ -17,7 +16,7 @@
drawLine3D [_pos1, _pos2, _color]; drawLine3D [_pos1, _pos2, _color];
_lastPos = _pos2; _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"]; // drawIcon3D ["", [1,0,0,1], _lastPos, 0, 0, 0, format ["%1m/s", _lastSpd], 1, 0.05, "RobotoCondensed"];
} forEach GVAR(traces); } forEach GVAR(traces);

View File

@ -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;

View File

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

View File

@ -99,9 +99,9 @@ for "_i" from 1 to _spallCount do {
_fragment setPosASL _spallPos; _fragment setPosASL _spallPos;
_fragment setVelocity _spallFragVect; _fragment setVelocity _spallFragVect;
if (GVAR(traceFrags)) then { #ifdef DRAW_FRAG_INFO
[ACE_player, _fragment, [1, 0.5, 0, 1]] call FUNC(addTrack); [ACE_player, _fragment, [1, 0.5, 0, 1]] call FUNC(dev_addTrack);
}; #endif
}; };
_spread = 5 + (random 5); _spread = 5 + (random 5);
@ -122,7 +122,7 @@ for "_i" from 1 to _spallCount do {
_fragment setPosASL _spallPos; _fragment setPosASL _spallPos;
_fragment setVelocity _spallFragVect; _fragment setVelocity _spallFragVect;
if (GVAR(traceFrags)) then { #ifdef DRAW_FRAG_INFO
[ACE_player, _fragment, [1, 0, 0, 1]] call FUNC(addTrack); [ACE_player, _fragment, [1, 0, 0, 1]] call FUNC(dev_addTrack);
}; #endif
}; };

View File

@ -50,6 +50,14 @@ if (isNil "_shouldAdd") then {
}; };
if (_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); [_unit, _ammo, _projectile] call FUNC(addPfhRound);
}; };

View File

@ -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) <ARRAY>
* 1: Velocity <ARRAY>
* 2: Ammo Classname <STRING>
*
* Return Value:
* Nothing
*
* Example:
* [[], [], "handGrenade"] call ace_frag_fnc_frago
*
* Public: No
*/
//#define DEBUG_MODE_FULL
#include "script_component.hpp" #include "script_component.hpp"
#define FRAG_VEC_VAR 0.004 #define FRAG_VEC_VAR 0.004
#define MAX_FRAG_COUNT 50 #define MAX_FRAG_COUNT 50
if (!isServer) exitWith {};
BEGIN_COUNTER(frago); 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 = [ private _fragTypes = [
QGVAR(tiny), QGVAR(tiny), QGVAR(tiny), QGVAR(tiny), QGVAR(tiny), QGVAR(tiny),
@ -28,12 +46,6 @@ if (isArray (configFile >> "CfgAmmo" >> _shellType >> QGVAR(CLASSES))) then {
_warn = true; _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 _indirectHitRange = getNumber(configFile >> "CfgAmmo" >> _shellType >> "indirecthitrange");
private _fragRange = 20 * _indirectHitRange * 4; private _fragRange = 20 * _indirectHitRange * 4;
// _c = 185; // grams of comp-b // _c = 185; // grams of comp-b
@ -69,104 +81,91 @@ if ((_atlPos select 2) < 0.5) then {
_lastPos vectorAdd [0, 0, 0.5]; _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]; private _objects = _atlPos nearEntities [["Car", "Motorcycle", "Tank", "StaticWeapon", "CAManBase", "Air", "Ship"], _fragRange];
// _objects = _manObjects;
// Add unique crews in faster way // Add unique crews in faster way
{ {
{ {
_objects pushBackUnique _x; _objects pushBackUnique _x;
} forEach (crew _x); } forEach (crew _x);
} forEach _objects; } forEach _objects;
TRACE_2("",_fragRange,count _objects);
private _fragCount = 0; private _fragCount = 0;
private _fragArcs = []; private _fragArcs = [];
_fragArcs set [360, 0]; _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; private _doRandom = true;
if (_isArmed && {!(_objects isEqualTo [])}) then { if (!(_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 { private _target = _x;
private _target = _x; if (alive _target) then {
if (alive _target) then { (boundingBox _target) params ["_boundingBoxA", "_boundingBoxB"];
(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 {}; if (_cubic <= 1) exitWith {};
_doRandom = true; // _doRandom = true;
private _targetVel = velocity _target; private _targetVel = velocity _target;
private _targetPos = getPosASL _target; private _targetPos = getPosASL _target;
private _distance = _targetPos vectorDistance _lastPos; private _distance = _targetPos vectorDistance _lastPos;
private _add = ((_boundingBoxB select 2) / 2) + ((((_distance - (_fragpower / 8)) max 0) / _fragPower) * 10); private _add = ((_boundingBoxB select 2) / 2) + ((((_distance - (_fragpower / 8)) max 0) / _fragPower) * 10);
_targetPos = _targetPos vectorAdd [ _targetPos = _targetPos vectorAdd [
(_targetVel select 0) * (_distance / _fragPower), (_targetVel select 0) * (_distance / _fragPower),
(_targetVel select 1) * (_distance / _fragPower), (_targetVel select 1) * (_distance / _fragPower),
_add _add
]; ];
private _baseVec = _lastPos vectorFromTo _targetPos; private _baseVec = _lastPos vectorFromTo _targetPos;
private _dir = floor (_baseVec call CBA_fnc_vectDir); private _dir = floor (_baseVec call CBA_fnc_vectDir);
private _currentCount = RETDEF(_fragArcs select _dir,0); private _currentCount = RETDEF(_fragArcs select _dir,0);
if (_currentCount < 20) then { if (_currentCount < 10) then {
private _count = ceil (random (sqrt (_m / 1000))); private _count = ceil (random (sqrt (_m / 1000)));
private _vecVar = FRAG_VEC_VAR; private _vecVar = FRAG_VEC_VAR;
if (!(_target isKindOf "Man")) then { if (!(_target isKindOf "Man")) then {
ADD(_vecVar,(sqrt _cubic) / 2000); ADD(_vecVar,(sqrt _cubic) / 2000);
if ((crew _target) isEqualTo [] && {_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 {
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; } forEach _objects;
if (_fragCount > MAX_FRAG_COUNT) exitWith {}; TRACE_1("targeted",_fragCount);
private _randomCount = ((ceil ((MAX_FRAG_COUNT - _fragCount) * 0.1)) max 0) + 20; if (_fragCount > _maxFrags) exitWith {};
private _randomCount = ceil ((_maxFrags - _fragCount) * 0.35);
TRACE_1("",_randomCount);
private _sectorSize = 360 / (_randomCount max 1); private _sectorSize = 360 / (_randomCount max 1);
// _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
@ -178,24 +177,19 @@ if (_isArmed && {!(_objects isEqualTo [])}) then {
_vel = _vec vectorMultiply _fp; _vel = _vec vectorMultiply _fp;
_fragType = round (random ((count _fragTypes) - 1)); _fragObj = (selectRandom _fragTypes) createVehicleLocal [0, 0, 10000];
_fragObj = (_fragTypes select _fragType) createVehicleLocal [0, 0, 10000];
_fragObj setPosASL _lastPos; _fragObj setPosASL _lastPos;
_fragObj setVectorDir _vec; _fragObj setVectorDir _vec;
_fragObj setVelocity _vel; _fragObj setVelocity _vel;
if (GVAR(traceFrags)) then { #ifdef DRAW_FRAG_INFO
INC(GVAR(totalFrags)); [ACE_player, _fragObj, [1,0.5,0,1]] call FUNC(dev_addTrack);
[ACE_player, _fragObj, [1,0.5,0,1]] call FUNC(addTrack); #endif
};
INC(_fragCount); INC(_fragCount);
}; };
}; };
}; };
// #ifdef DEBUG_MODE_FULL
// ACE_player sideChat format["total frags: %1", GVAR(totalFrags)]; TRACE_1("total created",_fragCount);
// ACE_player sideChat format["tracks: %1", (count GVAR(trackedObjects))];
// #endif
// _endTime = diag_tickTime;
END_COUNTER(frago); END_COUNTER(frago);

View File

@ -1,19 +1,20 @@
/* /*
* Author: jaynus * 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: * Arguments:
* * None
* *
* Return Value: * Return Value:
* None * None
*/ */
//#define DEBUG_MODE_FULL //#define DEBUG_MODE_FULL
#include "script_component.hpp" #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 = []; private _gcIndex = [];
@ -47,3 +48,5 @@ private _deletionCount = 0;
INC(_deletionCount); INC(_deletionCount);
} forEach _gcIndex; } forEach _gcIndex;
END_COUNTER(PFH);

View File

@ -1,6 +1,6 @@
#include "script_component.hpp" #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 { if (_round in GVAR(blackList)) exitWith {
false false
@ -11,14 +11,22 @@ if (!alive _round) exitWith {
if (_skip == 0) then { if (_skip == 0) then {
if ((_explosive > 0.5 && {_indirectRange >= 4.5} && {_fragPower >= 35}) || {_force == 1}) 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 // 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 {}; if (((_lastPos select 2) < 0) && {(toLower getText (configFile >> "CfgAmmo" >> _shellType >> "simulation")) in ["shotbullet", "shotshell"]}) exitWith {};
[QGVAR(frag_eh), _this] call CBA_fnc_serverEvent; 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 { if (_doSpall) then {
DEC(GVAR(spallIsTrackingCount)); DEC(GVAR(spallIsTrackingCount));
// diag_log text format ["F: %1", _foundObjectHPIds]; TRACE_1("doSpall",_foundObjectHPIds);
{ {
if (!isNil "_x") then { if (!isNil "_x") then {
_x removeEventHandler ["hitPart", _foundObjectHPIds select _forEachIndex]; _x removeEventHandler ["hitPart", _foundObjectHPIds select _forEachIndex];

View File

@ -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);

View File

@ -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

View File

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

View File

@ -2,7 +2,7 @@
#define COMPONENT_BEAUTIFIED Frag #define COMPONENT_BEAUTIFIED Frag
#include "\z\ace\addons\main\script_mod.hpp" #include "\z\ace\addons\main\script_mod.hpp"
//#define DEBUG_ENABLED_FRAG // #define DRAW_FRAG_INFO
// #define DEBUG_MODE_FULL // #define DEBUG_MODE_FULL
// #define DISABLE_COMPILE_CACHE // #define DISABLE_COMPILE_CACHE
// #define ENABLE_PERFORMANCE_COUNTERS // #define ENABLE_PERFORMANCE_COUNTERS