Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frag - Cleanup and Performance #5010

Merged
merged 2 commits into from
Apr 11, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion addons/cookoff/functions/fnc_detonateAmmunition.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
11 changes: 2 additions & 9 deletions addons/frag/ACE_Settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};
12 changes: 5 additions & 7 deletions addons/frag/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 9 additions & 6 deletions addons/frag/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -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;
};

Expand All @@ -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
5 changes: 0 additions & 5 deletions addons/frag/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
16 changes: 16 additions & 0 deletions addons/frag/functions/fnc_addBlackList.sqf
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
/*
* Author: Jaynus, NouberNou
* Adds a round to the blacklist (will be ignored)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing final dot (in other new/moved/updated functions too).

*
* Arguments:
* 0: Projectile <OBJECT>
*
* 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;
50 changes: 30 additions & 20 deletions addons/frag/functions/fnc_addPfhRound.sqf
Original file line number Diff line number Diff line change
@@ -1,51 +1,62 @@
/*
* 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
#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 {
if (GVAR(spallIsTrackingCount) <= 0) 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 = [];

Expand All @@ -64,5 +75,4 @@ if (_doFragTrack && {alive _round}) then {
if (_doSpall) then {
[_round, 1, _spallTrack, _spallTrackID] call FUNC(spallTrack);
};
// ACE_player sideChat "WTF2";
};
Original file line number Diff line number Diff line change
@@ -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 = [];
Expand All @@ -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;
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
8 changes: 8 additions & 0 deletions addons/frag/functions/fnc_dev_startTracing.sqf
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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;
12 changes: 6 additions & 6 deletions addons/frag/functions/fnc_doSpall.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
};
10 changes: 9 additions & 1 deletion addons/frag/functions/fnc_fired.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Loading