Reswept dev functions to match ACE code guidelines

This commit is contained in:
lambdatiger 2024-01-15 13:13:59 -06:00
parent 63cd1ed06a
commit f28d5d2372
10 changed files with 153 additions and 185 deletions

View File

@ -12,86 +12,76 @@
* None * None
* *
* Example: * Example:
* [_proj, false, false] call ace_frag_dev_addRound; * [_projectile, false, false] call ace_frag_dev_addRound;
* *
* Public: No * Public: No
*/ */
params [ params [
"_proj", "_projectile",
["_addEHs", true, [true]], ["_addProjectileEventHandlers", true, [true]],
["_sidePlayer", true, [true]] ["_isSidePlayer", true, [true]]
]; ];
// track round on each frame // track round on each frame
// Create entry in position array from hashmap // Create entry in position array from hashmap
if (_sidePlayer) then if (_isSidePlayer) then {
{ GVAR(dev_trackLines) set [getObjectID _projectile, [[getposATL _projectile], [0, 0, 1, 1]]];
GVAR(dev_trackLines) set [getObjectID _proj, [1, [getposATL _proj], [0, 0, 1, 1]]]; } else {
} else GVAR(dev_trackLines) set [getObjectID _projectile, [[getposATL _projectile], [1, 0, 0, 1]]];
{
GVAR(dev_trackLines) set [getObjectID _proj, [1, [getposATL _proj], [1, 0, 0, 1]]];
}; };
// eventhandler to track round and cleanup when round is "dead" // eventhandler to track round and cleanup when round is "dead"
[ [
{ {
if (isGamePaused) exitWith {}; if (isGamePaused) exitWith {};
params ["_par", "_h"]; params ["_par", "_handle"];
_par params ["_proj"]; _par params ["_projectile"];
if (!alive _proj) exitWith if (!alive _projectile) exitWith {
{ [_handle] call CBA_fnc_removePerFrameHandler;
[_h] call CBA_fnc_removePerFrameHandler;
};
private _arr = GVAR(dev_trackLines) getOrDefault [(getObjectID _proj), -1];
if (typeName _arr == "SCALAR") exitWith {};
(_arr#1) pushBack getPosATL _proj;
if (_arr#0 <= 0) exitWith
{
[_h] call CBA_fnc_removePerFrameHandler;
}; };
private _projectileArray = GVAR(dev_trackLines) getOrDefault [(getObjectID _projectile), -1];
if (typeName _projectileArray == "SCALAR") exitWith {};
(_projectileArray#0) pushBack getPosATL _projectile;
}, },
0, 0,
[_proj] [_projectile]
] call CBA_fnc_addPerFrameHandler; ] call CBA_fnc_addPerFrameHandler;
if (!_addEHs) exitWith {}; if (!_addProjectileEventHandlers) exitWith {};
// Add hitpart eventHandler // Add hitpart eventHandler
_proj addEventHandler [ _projectile addEventHandler [
"HitPart", "HitPart",
{ {
params ["_proj", "", "", "_posASL"]; params ["_projectile", "", "", "_posASL"];
private _arr = (GVAR(dev_trackLines) get (getObjectID _proj))#1; private _posArr = (GVAR(dev_trackLines) get (getObjectID _projectile))#0;
_arr pushBack ASLtoATL _posASL; _posArr pushBack ASLtoATL _posASL;
if (GVAR(dbgSphere)) then if (GVAR(dbgSphere)) then {
{
[_posASL, "green"] call FUNC(dev_sphereDraw); [_posASL, "green"] call FUNC(dev_sphereDraw);
}; };
} }
]; ];
// Add explode eventHandler // Add explode eventHandler
_proj addEventHandler [ _projectile addEventHandler [
"Explode", "Explode",
{ {
params ["_proj", "_posASL"]; params ["_projectile", "_posASL"];
private _arr = (GVAR(dev_trackLines) get (getObjectID _proj))#1; private _posArr = (GVAR(dev_trackLines) get (getObjectID _projectile))#0;
_arr pushBack ASLtoATL _posASL; _posArr pushBack ASLtoATL _posASL;
if (GVAR(dbgSphere)) then if (GVAR(dbgSphere)) then {
{
[_posASL, "red"] call FUNC(dev_sphereDraw); [_posASL, "red"] call FUNC(dev_sphereDraw);
}; };
} }
]; ];
// Add deflected eventHandler // Add deflected eventHandler
_proj addEventHandler [ _projectile addEventHandler [
"Deflected", "Deflected",
{ {
params ["_proj", "_posASL"]; params ["_projectile", "_posASL"];
private _arr = (GVAR(dev_trackLines) get (getObjectID _proj))#1; private _posArr = (GVAR(dev_trackLines) get (getObjectID _projectile))#0;
_arr pushBack ASLtoATL _posASL; _posArr pushBack ASLtoATL _posASL;
if (GVAR(dbgSphere)) then if (GVAR(dbgSphere)) then {
{
[_posASL, "blue"] call FUNC(dev_sphereDraw); [_posASL, "blue"] call FUNC(dev_sphereDraw);
}; };
} }

View File

@ -14,11 +14,10 @@
* *
* Public: No * Public: No
*/ */
GVAR(dev_trackLines) = createHashMap; for "_i" from 0 to count GVAR(dev_eventSpheres) - 1 do {
for "_i" from 0 to count GVAR(dev_eventSpheres) - 1 do
{
deleteVehicle (GVAR(dev_eventSpheres)#_i); deleteVehicle (GVAR(dev_eventSpheres)#_i);
}; };
GVAR(dev_eventSpheres) = +[]; GVAR(dev_eventSpheres) = [];
GVAR(dev_trackLines) = createHashMap;
GVAR(dev_hitBoxes) = createHashMap; GVAR(dev_hitBoxes) = createHashMap;

View File

@ -9,7 +9,7 @@
* 0: Log ammo types that wouldn't normall frag * 0: Log ammo types that wouldn't normall frag
* 1: Only export ammo classes of classes referenced in cfgAmmo * 1: Only export ammo classes of classes referenced in cfgAmmo
* and their submunitions. * and their submunitions.
* 2: Force a CSV format * 2: Force a CSV format on debug print
* *
* Return Value: * Return Value:
* None * None
@ -20,7 +20,7 @@
* Public: No * Public: No
*/ */
params [ params [
["_debugForce", false, [false]], ["_logAll", false, [false]],
["_onlyShotAmmoTypes", false, [false]], ["_onlyShotAmmoTypes", false, [false]],
["_csvFormat", false, [false]] ["_csvFormat", false, [false]]
]; ];
@ -33,7 +33,7 @@ if (_csvFormat) then {
// Gather all configs, either those that could be created from firing or all classes // Gather all configs, either those that could be created from firing or all classes
private _allAmmoConfigs = []; private _allAmmoConfigs = [];
if (_onlyShotAmmoTypes) then { if (_onlyShotAmmoTypes) then {
private _searchFunc = { private _configSearchFunc = {
params [ params [
["_ammo", "", [""]] ["_ammo", "", [""]]
]; ];
@ -44,17 +44,17 @@ if (_onlyShotAmmoTypes) then {
_subMunit = getArray (configFile >> "cfgAmmo" >> _ammo >> "submunitionAmmo"); _subMunit = getArray (configFile >> "cfgAmmo" >> _ammo >> "submunitionAmmo");
for "_i" from 0 to count _subMunit - 1 do { for "_i" from 0 to count _subMunit - 1 do {
if (_i mod 2 == 0) then { if (_i mod 2 == 0) then {
[toLower (_subMunit#_i)] call _searchFunc; [toLower (_subMunit#_i)] call _configSearchFunc;
}; };
}; };
} else { } else {
[toLower _subMunit] call _searchFunc; [toLower _subMunit] call _configSearchFunc;
}; };
}; };
private _allMagazineConfigs = configProperties [configFile >> "cfgMagazines", "isClass _x", true]; private _allMagazineConfigs = configProperties [configFile >> "cfgMagazines", "isClass _x", true];
{ {
[toLower getText (_x >> "ammo")] call _searchFunc; [toLower getText (_x >> "ammo")] call _configSearchFunc;
} forEach _allMagazineConfigs; } forEach _allMagazineConfigs;
} else { } else {
_allAmmoConfigs = configProperties [configFile >> "cfgAmmo", "isClass _x && !('ace_frag' in configName _x)", true] apply {configName _x}; _allAmmoConfigs = configProperties [configFile >> "cfgAmmo", "isClass _x && !('ace_frag' in configName _x)", true] apply {configName _x};
@ -70,7 +70,7 @@ private _printCount = 0;
private _ammoConfig = (configFile >> "cfgAmmo" >> _ammo); private _ammoConfig = (configFile >> "cfgAmmo" >> _ammo);
private _shoulFrag = [_ammo] call FUNC(shouldFrag); private _shoulFrag = [_ammo] call FUNC(shouldFrag);
if (_shoulFrag || _debugForce) then { if (_shoulFrag || _logAll) then {
private _warn = false; private _warn = false;
private _fragTypes = getArray (_ammoConfig >> QGVAR(CLASSES)); private _fragTypes = getArray (_ammoConfig >> QGVAR(CLASSES));

View File

@ -1,5 +1,5 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
#define HB_DRAW_ARRS [[3 , 2 , 1 , 5 , 6 , 7 , 3 , 0 , 4 , 5], [0, 1], [2, 6], [7, 4]] #define HITBOX_DRAW_PATH [[3 , 2 , 1 , 5 , 6 , 7 , 3 , 0 , 4 , 5], [0, 1], [2, 6], [7, 4]]
/* /*
* Author: Lambda.Tiger * Author: Lambda.Tiger
* Per frame function to draw all dev traces * Per frame function to draw all dev traces
@ -15,38 +15,33 @@
* Public: No * Public: No
*/ */
private _deleteArr = [];
{ {
if (count (_y#1) > 1) then _y params ["_posArray", "_color"]
{ if (count (_posArray) > 1) then {
for "_j" from 1 to count (_y#1) - 1 do for "_j" from 1 to count _posArray - 1 do {
{ drawLine3D [_posArray#(_j-1), _posArray#_j, _color];
drawLine3D [_y#1#(_j-1), _y#1#_j, _y#2];
}; };
}; };
} forEach GVAR(dev_trackLines); } forEach GVAR(dev_trackLines);
if (GVAR(drawHitBox)) then { if (GVAR(drawHitBox)) then {
_deleteArr = []; private _deleteArr = [];
{
_y params ["_obj", "_pts", "_color"];
if (!alive _obj) then
{ {
_y params ["_object", "_boxPoints", "_color"];
if (!alive _object) then {
_deleteArr pushBack _x; _deleteArr pushBack _x;
continue; continue;
}; };
{ {
for "_i" from 1 to count _x -1 do for "_i" from 1 to count _x -1 do {
{ drawLine3D [_object modelToWorld (_boxPoints#(_x#_i)), _object modelToWorld (_boxPoints#(_x#(_i-1))), _color];
drawLine3D [_obj modelToWorld (_pts#(_x#_i)), _obj modelToWorld (_pts#(_x#(_i-1))), _color];
}; };
} forEach HB_DRAW_ARRS; } forEach HITBOX_DRAW_PATH;
} forEach GVAR(dev_hitBoxes); } forEach GVAR(dev_hitBoxes);
for "_i" from 0 to count _deleteArr - 1 do
{ {
GVAR(dev_hitBoxes) deleteAt (_deleteArr#_i); GVAR(dev_hitBoxes) deleteAt _x;
}; } forEach _deleteArr;
}; };

View File

@ -14,5 +14,6 @@
* *
* Public: No * Public: No
*/ */
//IGNORE_PRIVATE_WARNING ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle", "_gunner", "_turret"];
TRACE_10("firedEH:",_unit, _weapon, _muzzle, _mode, _ammo, _magazine, _projectile, _vehicle, _gunner, _turret);
[_projectile, true, ((side _unit) getFriend (side ACE_player)) >= 0.6] call FUNC(dev_addRound); [_projectile, true, ((side _unit) getFriend (side ACE_player)) >= 0.6] call FUNC(dev_addRound);

View File

@ -2,13 +2,13 @@
/* /*
* Author: Lambda.Tiger, based on fnc_dev_debugAmmo by "ACE-Team" * Author: Lambda.Tiger, based on fnc_dev_debugAmmo by "ACE-Team"
* Dumps all ammo types to see if there's any reason to spawn fragments * Dumps all ammo types to see if there's any reason to spawn fragments
* given power, distance, and lifetime of each fragement. Good for grasping * given hit power and distance. Good for grasping the values used in
* the values used in shouldFrag to cull non-fragementing rounds * shouldFrag to cull non-fragementing rounds
* *
* Arguments: * Arguments:
* 0: _dispAll <BOOL> - Display rounds that will never frag (power < 5). * 0: _logAll <BOOL> - Display rounds that will never frag (power < 5).
* Default value false * Default value false
* 1: _minFrgPowRng <FLOAT> - minimum range for sqrt power calculation * 1: _minFragPower <FLOAT> - minimum range for sqrt power calculation
* *
* Return Value: * Return Value:
* None * None
@ -19,53 +19,40 @@
* Public: No * Public: No
*/ */
params [["_dispAll", false, [false]], ["_minFrgPowRng", 35, [123]]]; params [
["_logAll", false, [false]],
["_minFragPower", 35, [123]]
];
#define DT 0.01
private _allAmmoConfigs = configProperties [configFile >> "cfgAmmo", "isClass _x && !('ace_frag' in configName _x)", true]; private _allAmmoConfigs = configProperties [configFile >> "cfgAmmo", "isClass _x && !('ace_frag' in configName _x)", true];
private _processedCfgAmmos = []; private _processedCfgAmmos = [];
private _nPrinted = 0; private _nPrinted = 0;
diag_log text "//****************** fragCalcDump Beg ******************//"; diag_log text "//****************** fragCalcDump Beg ******************//";
// Processing ammo types { // Begin _allAmmoConfigs forEach
{
private _ammo = toLower configName _x; private _ammo = toLower configName _x;
if (_ammo == "" || {_ammo in _processedCfgAmmos} ) then { continue }; if (_ammo == "" || {_ammo in _processedCfgAmmos} ) then { continue };
// calculating hit range private _shouldFrag = [_ammo] call FUNC(shouldFrag);
_shouldFrag = [_ammo] call FUNC(shouldFrag); if (_nSkip || _logAll) then {
private _fragInfo = [_ammo] call FUNC(getFragInfo);
_fragInfo params ["_fragRange", "_fragMaxVelocity", "", "_modifiedFragCount"]
private _fragCount = 4 * pi* _modifiedFragCount;
private _indirectHitRange = getNumber (configFile >> "cfgAmmo" >> _ammo >> "indirectHitRange");
private _indirectHit = getNumber (configFile >> "cfgAmmo" >> _ammo >> "indirectHit");
private _fragPowerSpeedRange = [0.5, 1] vectorMultiply _fragMaxVelocity;
// Gunery equation
private _c = getNumber (configFile >> "cfgAmmo" >> _ammo >> QGVAR(CHARGE));
if (_c == 0) then {_c = 1;};
private _m = getNumber (configFile >> "cfgAmmo" >> _ammo >> QGVAR(METAL));
if (_m == 0) then {_m = 2;};
private _k = getNumber (configFile >> "cfgAmmo" >> _ammo >> QGVAR(GURNEY_K));
if (_k == 0) then {_k = 0.8;};
private _gC = getNumber (configFile >> "cfgAmmo" >> _ammo >> QGVAR(GURNEY_C));
if (_gC == 0) then {_gC = 2440;};
private _fragCount = getNumber (configFile >> "cfgAmmo" >> _ammo >> QGVAR(fragCount));
if (_fragCount == 0) then {_fragCount = 200;};
private _velocity = 0.8 * _gC * sqrt (_c /(_m + _c * _k));
// number of shrapnel to send a direction
private _count = ceil (random (sqrt (_m / 1000)));
private _fragPowerSpeedRange = [0.5, 1] vectorMultiply _fragPower;
if (_nSkip || _dispALl) then
{
diag_log text format ["Ammo type: %1 | Should frag: %2", _ammo, _shouldFrag]; diag_log text format ["Ammo type: %1 | Should frag: %2", _ammo, _shouldFrag];
diag_log text format [" Indirect hit range: %1", _indirectHitRange]; diag_log text format [" Indirect hit range: %1", _indirectHitRange];
diag_log text format [" Indirect hit: %1", _indirectHit];
diag_log text format [" Frag sqrtPower: %1", _fragPowerSqrt]; diag_log text format [" Frag sqrtPower: %1", _fragPowerSqrt];
diag_log text format [" Frag range: %1", _fragRange]; diag_log text format [" Frag range: %1", _fragRange];
diag_log text format [" Frag speed range: %1", _fragPowerSpeedRange]; diag_log text format [" Frag speed range: %1", _fragPowerSpeedRange];
diag_log text format [" Number frags: %1", _count]; diag_log text format [" Number frags: %1", _fragCount];
INC(_nPrinted); INC(_nPrinted);
}; };

View File

@ -20,18 +20,15 @@ params [
["_color", "(1,0,0,0.5)", [""]] ["_color", "(1,0,0,0.5)", [""]]
]; ];
if (count _posASL < 3) then if (count _posASL < 3) then {
{
_posASL pushBack 0; _posASL pushBack 0;
_posASL = ASLtoATL _posASL; _posASL = ASLtoATL _posASL;
_posASL set [2, 0]; _posASL set [2, 0];
_posASL = ATLtoASL _posASL; _posASL = ATLtoASL _posASL;
}; };
if (_color select [0,1] != "(") then if (_color select [0,1] != "(") then {
{ switch (toLower _color) do {
switch (toLower _color) do
{
case "blue": { _color = "(0,0,0.8,0.5)"; }; case "blue": { _color = "(0,0,0.8,0.5)"; };
case "black": { _color = "(1,1,1,0.5)"; }; case "black": { _color = "(1,1,1,0.5)"; };
case "white": { _color = "(0,0,0,0.5)"; }; case "white": { _color = "(0,0,0,0.5)"; };
@ -42,11 +39,10 @@ if (_color select [0,1] != "(") then
default { _color = "(0.8,0.8,0,0.5)";}; default { _color = "(0.8,0.8,0,0.5)";};
}; };
}; };
private _clrStr = "#(argb,8,8,3)color" + _color; private _colorString = "#(argb,8,8,3)color" + _color;
private _sphere = "Sign_Sphere25cm_F" createVehicle [1,2,34]; private _sphere = createVehicle ["Sign_Sphere25cm_F", ASLtoATL _posASL, [], 0, "CAN_COLLIDE"];
_sphere setObjectTextureGlobal [0, _clrStr]; _sphere setObjectTextureGlobal [0, _colorString];
_sphere setPosASL _posASL;
GVAR(dev_eventSpheres) pushBack _sphere; GVAR(dev_eventSpheres) pushBack _sphere;
_sphere; _sphere;

View File

@ -15,20 +15,26 @@
* *
* Public: No * Public: No
*/ */
params ["_lVic", "_cVic"]; params ["_lastUnit", "_currentUnit"];
if (_cVic isEqualTo objNull || {!local _cVic || _lVic isEqualTo _cVic}) exitWith {}; if (_currentUnit isEqualTo objNull || {_lastUnit isEqualTo _currentUnit}) exitWith {};
if (!local _currentUnit) exitWith {
[
{local _currentUnit},
FUNC(dev_switchUnitHandle),
_this,
5
] call CBA_fnc_waitUntilAndExecute;
};
private _aID = missionNamespace getVariable [QGVAR(dev_clearTraceAction), -1]; private _aID = missionNamespace getVariable [QGVAR(dev_clearTraceAction), -1];
if (_aID > -1 && {_lVic isNotEqualTo objNull}) then if (_aID > -1 && {_lastUnit isNotEqualTo objNull}) then {
{ _lastUnit removeAction _aID;
_lVic removeAction _aID;
}; };
_aID = _cVic addAction _aID = _currentUnit addAction [
[
"Reset Lines", "Reset Lines",
FUNC(dev_clearTraces), FUNC(dev_clearTraces),
nil, // arguments nil, // arguments

View File

@ -4,8 +4,8 @@
* Add a hitbox outline to an object * Add a hitbox outline to an object
* *
* Arguments: * Arguments:
* 0: Object to draw hitbox <OBJECT> * 0 <OBJECT>: Object to draw hitbox
* 1: Add center sphere <BOOL> * 1 <BOOL>: Add sphere at object origin
* *
* Return Value: * Return Value:
* None * None
@ -16,38 +16,38 @@
* Public: No * Public: No
*/ */
params [ params [
["_obj", objNull, [objNull]], ["_object", objNull, [objNull]],
["_addSphere", true, [false]] ["_addSphere", true, [turretLocal]]
]; ];
if (isNull _obj) exitWith {}; if (isNull _object) exitWith {};
// Grab the right hitBox // Grab the right hitBox
private _box = []; private _box = [];
if (_obj isKindOf "CAManBase") then { if (_object isKindOf "CAManBase") then {
if (vehicle _obj == _obj) then { if (isNull objectParent _object) then {
_box = 0 boundingBox _obj; _box = 0 boundingBox _object;
} else { } else {
_box = boundingBoxReal [_obj, "Geometry"]; _box = boundingBoxReal [_object, "Geometry"];
}; };
} else { } else {
_box = boundingBoxReal [_obj, "FireGeometry"]; _box = boundingBoxReal [_object, "FireGeometry"];
}; };
_box params ["_lowP","_upP"]; _box params ["_lowP","_upP"];
// adjust with stance // adjust with stance
private _stance = stance _obj; private _stance = stance _object;
switch (true) do { switch (true) do {
case (_stance isEqualTo "STAND"): {_upP set [2, 1.9];}; case (_stance isEqualTo "STAND"): {_upP set [2, 1.9];};
case (_stance isEqualTo "CROUCH"): {_upP set [2, 1.3];}; case (_stance isEqualTo "CROUCH"): {_upP set [2, 1.3];};
case (_stance isEqualTo "PRONE"): {_upP set [2, 0.8];}; case (_stance isEqualTo "PRONE"): {_upP set [2, 0.8];};
}; };
private _centerPoint = ASLToAGL getPosASL _obj; private _centerPoint = ASLToAGL getPosASL _object;
if (GVAR(dbgSphere) && {_addSphere && {vehicle _obj isEqualTo _obj}}) then { if (GVAR(dbgSphere) && {_addSphere && {isNull objectParent _object}}) then {
private _centerSphere = [getPosASL _obj, "yellow"] call FUNC(dev_sphereDraw); private _centerSphere = [getPosASL _object, "yellow"] call FUNC(dev_sphereDraw);
_centerSphere disableCollisionWith vehicle _obj; _centerSphere disableCollisionWith vehicle _object;
_centerSphere attachTo [_obj, _obj worldToModel _centerPoint]; _centerSphere attachTo [_object, _object worldToModel _centerPoint];
}; };
// create an optimized outline // create an optimized outline
@ -64,10 +64,10 @@ private _points =[
[_p7#0, _p1#1, _p7#2] [_p7#0, _p1#1, _p7#2]
]; ];
_color = switch (side _obj) do { _color = switch (side _object) do {
case east: {[1, 0, 0, 1]}; case east: {[1, 0, 0, 1]};
case resistance: {[0, 1, 0, 1]}; case resistance: {[0, 1, 0, 1]};
default {[0, 0, 1, 1]}; default {[0, 0, 1, 1]};
}; };
GVAR(dev_hitBoxes) set [getObjectID _obj, [_obj, _points, _color]]; GVAR(dev_hitBoxes) set [getObjectID _object, [_object, _points, _color]];

View File

@ -4,9 +4,9 @@
* This function adds an object to have it's course tracked (every frame). * This function adds an object to have it's course tracked (every frame).
* *
* Arguments: * Arguments:
* 0: Object to draw hitbox <OBJECT> * 0 <OBJECT>: Object to draw hitbox
* 1: Color of trace <STRING> * 1 <STRING>: Color of trace
* 2: Whether the object is a projectile <BOOL> * 2 <BOOL>: Whether the object is a projectile
* *
* Return Value: * Return Value:
* None * None
@ -17,11 +17,11 @@
* Public: No * Public: No
*/ */
params [ params [
"_obj", "_object",
["_color", "blue", ["blue"]], ["_color", "blue", ["blue"]],
["_isProj", false, [false]] ["_isProj", false, [false]]
]; ];
TRACE_4("devDraw",_this,_obj,_color,_isProj); TRACE_3("devDraw",_object,_color,_isProj);
// pick color and add it to the array // pick color and add it to the array
private _colorArray = switch (toLower _color) do { private _colorArray = switch (toLower _color) do {
@ -35,69 +35,63 @@ private _colorArray = switch (toLower _color) do {
case "white": {[0, 0, 0, 1]}; case "white": {[0, 0, 0, 1]};
default {[0, 0.8, 0.8, 1]}; default {[0, 0.8, 0.8, 1]};
}; };
GVAR(dev_trackLines) set [getObjectID _obj, [1, [getposATL _obj], _colorArray]]; GVAR(dev_trackLines) set [getObjectID _object, [1, [getposATL _object], _colorArray]];
// eventhandler to track round and cleanup when round is "dead" // eventhandler to track round and cleanup when round is "dead"
[ [
{ {
if (isGamePaused) exitWith {}; if (isGamePaused) exitWith {};
params ["_par", "_h"]; params ["_par", "_handle"];
_par params ["_obj"]; _par params ["_object"];
if (!alive _obj) exitWith { if (!alive _object) exitWith {
[_h] call CBA_fnc_removePerFrameHandler; [_handle] call CBA_fnc_removePerFrameHandler;
}; };
private _arr = GVAR(dev_trackLines) getOrDefault [(getObjectID _obj), -1]; private _arr = GVAR(dev_trackLines) getOrDefault [(getObjectID _object), -1];
if (typeName _arr isEqualTo "SCALAR") exitWith { if (typeName _arr isEqualTo "SCALAR") exitWith {
[_h] call CBA_fnc_removePerFrameHandler; [_handle] call CBA_fnc_removePerFrameHandler;
}; };
(_arr#1) pushBack getPosATL _obj; (_arr#0) pushBack getPosATL _object;
if (_arr#0 <= 0) exitWith {
[_h] call CBA_fnc_removePerFrameHandler;
};
}, },
0, 0,
[_obj] [_object]
] call CBA_fnc_addPerFrameHandler; ] call CBA_fnc_addPerFrameHandler;
// Projectile eventhandlers that add spheres and points for more accurate round tracking // Projectile eventhandlers that add spheres and points for more accurate round tracking
if (!_isProj) exitWith {}; if (!_isProj) exitWith {};
_obj addEventHandler [ _object addEventHandler [
"HitPart", "HitPart",
{ {
params ["_proj", "", "", "_posASL"]; params ["_projectile", "", "", "_posASL"];
private _arr = (GVAR(dev_trackLines) get (getObjectID _proj))#1; private _posArr = (GVAR(dev_trackLines) get (getObjectID _projectile))#0;
_arr pushBack ASLtoATL _posASL; _posArr pushBack ASLtoATL _posASL;
if (GVAR(dbgSphere)) then if (GVAR(dbgSphere)) then {
{
[_posASL, "green"] call FUNC(dev_sphereDraw); [_posASL, "green"] call FUNC(dev_sphereDraw);
}; };
} }
]; ];
_obj addEventHandler [ _object addEventHandler [
"Explode", "Explode",
{ {
params ["_proj", "_posASL"]; params ["_projectile", "_posASL"];
private _arr = (GVAR(dev_trackLines) get (getObjectID _proj))#1; private _posArr = (GVAR(dev_trackLines) get (getObjectID _projectile))#0;
_arr pushBack ASLtoATL _posASL; _posArr pushBack ASLtoATL _posASL;
if (GVAR(dbgSphere)) then if (GVAR(dbgSphere)) then {
{
[_posASL, "red"] call FUNC(dev_sphereDraw); [_posASL, "red"] call FUNC(dev_sphereDraw);
}; };
} }
]; ];
_obj addEventHandler [ _object addEventHandler [
"Deflected", "Deflected",
{ {
params ["_proj", "_posASL"]; params ["_projectile", "_posASL"];
private _arr = (GVAR(dev_trackLines) get (getObjectID _proj))#1; private _posArr = (GVAR(dev_trackLines) get (getObjectID _projectile))#0;
_arr pushBack ASLtoATL _posASL; _posArr pushBack ASLtoATL _posASL;
if (GVAR(dbgSphere)) then if (GVAR(dbgSphere)) then {
{
[_posASL, "blue"] call FUNC(dev_sphereDraw); [_posASL, "blue"] call FUNC(dev_sphereDraw);
}; };
} }