From c09c2a170caa91abece8202e3fe9339e6edca367 Mon Sep 17 00:00:00 2001 From: lambdatiger Date: Thu, 15 Feb 2024 20:59:58 -0600 Subject: [PATCH] reformatted function headers, removed value type checking, and changed lazy eval. --- addons/frag/functions/fnc_dev_addRound.sqf | 19 +++++++++---------- addons/frag/functions/fnc_dev_debugAmmo.sqf | 8 ++++---- addons/frag/functions/fnc_dev_fired.sqf | 4 +++- .../frag/functions/fnc_dev_fragCalcDump.sqf | 7 +++---- addons/frag/functions/fnc_dev_sphereDraw.sqf | 13 ++++++------- addons/frag/functions/fnc_dev_trackHitBox.sqf | 19 +++++++++---------- addons/frag/functions/fnc_dev_trackObj.sqf | 15 ++++++++------- 7 files changed, 42 insertions(+), 43 deletions(-) diff --git a/addons/frag/functions/fnc_dev_addRound.sqf b/addons/frag/functions/fnc_dev_addRound.sqf index a1cc372bb7..5995b36670 100644 --- a/addons/frag/functions/fnc_dev_addRound.sqf +++ b/addons/frag/functions/fnc_dev_addRound.sqf @@ -7,10 +7,9 @@ * green / red / blue, respectively. * * Arguments: - * 0: Projectile to be tracked. - * 1: Add projectile hit/explode/defelceted event handlers. - * 2: Is the round fired by a unit on the same side as the player - * true results in blue traces, false in red. + * 0: Projectile to be tracked + * 1: Add projectile hit/explode/defelceted event handlers (default: true) + * 2: Should the round track be blue. True results in blue traces, false in red (default: true) * * Return Value: * Nothing Useful @@ -24,10 +23,10 @@ params [ "_projectile", ["_addProjectileEventHandlers", true], - ["_isSidePlayer", true] + ["_isTraceBlue", true] ]; -if (_isSidePlayer) then { +if (_isTraceBlue) then { GVAR(dev_trackLines) set [getObjectID _projectile, [[getPosATL _projectile], [0, 0, 1, 1]]]; } else { GVAR(dev_trackLines) set [getObjectID _projectile, [[getPosATL _projectile], [1, 0, 0, 1]]]; @@ -38,17 +37,17 @@ if (_isSidePlayer) then { { if (isGamePaused) exitWith {}; params ["_projectile", "_handle"]; - + if (!alive _projectile) exitWith { [_handle] call CBA_fnc_removePerFrameHandler; }; - + private _projectileArray = GVAR(dev_trackLines) get (getObjectID _projectile); - + if (isNil "_projectileArray") exitWith { [_handle] call CBA_fnc_removePerFrameHandler; }; - + (_projectileArray#0) pushBack getPosATL _projectile; }, 0, diff --git a/addons/frag/functions/fnc_dev_debugAmmo.sqf b/addons/frag/functions/fnc_dev_debugAmmo.sqf index 2c00d98e5d..7ade5df72b 100644 --- a/addons/frag/functions/fnc_dev_debugAmmo.sqf +++ b/addons/frag/functions/fnc_dev_debugAmmo.sqf @@ -5,11 +5,11 @@ * fragments that could be fired from a weapon. * * Arguments: - * 0: Log ammo types that wouldn't normally frag. (Default: false) - * 1: Only print ammo without ACE_frag entries, inherited or otherwise. (Default: true) + * 0: Log ammo types that wouldn't normally frag (default: false) + * 1: Only print ammo without ACE_frag entries, inherited or otherwise (default: true) * 2: Only export ammo classes of classes referenced in CfgMagazines and their - * submunitions. (Default: false) - * 3: Force a CSV format on debug print. (Default: false) + * submunitions (default: false) + * 3: Force a CSV format on debug print. (default: false) * * Return Value: * None diff --git a/addons/frag/functions/fnc_dev_fired.sqf b/addons/frag/functions/fnc_dev_fired.sqf index 113fb997df..9dbd039f46 100644 --- a/addons/frag/functions/fnc_dev_fired.sqf +++ b/addons/frag/functions/fnc_dev_fired.sqf @@ -18,4 +18,6 @@ //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 group _unit, side group ACE_player] call BIS_fnc_sideIsFriendly] call FUNC(dev_addRound); +if (GVAR(debugOptions) && {_ammo call FUNC(shouldFrag) || {_ammo call FUNC(shouldSpall)}}) then { + [_projectile, true, [side group _unit, side group ACE_player] call BIS_fnc_sideIsFriendly] call FUNC(dev_addRound); +}; diff --git a/addons/frag/functions/fnc_dev_fragCalcDump.sqf b/addons/frag/functions/fnc_dev_fragCalcDump.sqf index ded15a6d1c..937cf2ddb6 100644 --- a/addons/frag/functions/fnc_dev_fragCalcDump.sqf +++ b/addons/frag/functions/fnc_dev_fragCalcDump.sqf @@ -1,12 +1,11 @@ #include "..\script_component.hpp" /* * 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 - * given hit power and distance. Good for grasping the values used in - * shouldFrag to cull non-fragmenting rounds. + * Dumps all ammo types to see if there's any reason to spawn fragments given hit power and distance. + * Good for grasping the values used in shouldFrag to cull non-fragmenting rounds. * * Arguments: - * 0: Display rounds that will never frag (power < 5). (default: false) + * 0: Display rounds that will never frag (default: false) * * Return Value: * None diff --git a/addons/frag/functions/fnc_dev_sphereDraw.sqf b/addons/frag/functions/fnc_dev_sphereDraw.sqf index 9a8408ff4c..cf9ca7335c 100644 --- a/addons/frag/functions/fnc_dev_sphereDraw.sqf +++ b/addons/frag/functions/fnc_dev_sphereDraw.sqf @@ -4,22 +4,21 @@ * Add a colored sphere at a specified point. * * Arguments: - * 0: ASL position to add sphere. - * 1: Color of sphere. (Default: Blue) + * 0: Position (posASL) to add sphere + * 1: Color of sphere (default: "blue") * * Return Value: * None * * Example: - * [getPosASL player, "blue"] call ace_frag_fnc_dev_sphereDraw; + * [getPosASL player, "red"] call ace_frag_fnc_dev_sphereDraw; * * Public: No */ -params [ - "_posASL", - ["_color", "blue", [""]] -]; +params ["_posASL", ["_color", "blue"]]; + +if (!isServer) exitWith {}; if (_color select [0,1] != "(") then { _color = switch (toLowerANSI _color) do { diff --git a/addons/frag/functions/fnc_dev_trackHitBox.sqf b/addons/frag/functions/fnc_dev_trackHitBox.sqf index 58fa9b60de..85ef03e4a8 100644 --- a/addons/frag/functions/fnc_dev_trackHitBox.sqf +++ b/addons/frag/functions/fnc_dev_trackHitBox.sqf @@ -1,12 +1,11 @@ #include "..\script_component.hpp" /* * Author: Lambda.Tiger - * Add a hit box outline to an object, outdated for unit hits as they - * use hit-point locations. + * Add a hit box outline to an object. * * Arguments: - * 0: Object that should have it's hit box drawn. - * 1: Add sphere at object origin. (Default: true) + * 0: Object that should have it's hit box drawn (default: objNull) + * 1: Add sphere at object origin (default: true) * * Return Value: * None @@ -18,8 +17,8 @@ */ params [ - ["_object", objNull, [objNull]], - ["_addSphere", true, [true]] + ["_object", objNull], + ["_addSphere", true] ]; TRACE_2("Adding hitbox",_object,_addSphere); @@ -46,7 +45,7 @@ switch (stance _object) do { }; private _centerPoint = ASLToAGL getPosASL _object; -if (GVAR(dbgSphere) && {_addSphere && {isNull objectParent _object}}) then { +if (GVAR(dbgSphere) && _addSphere && {isNull objectParent _object}) then { private _centerSphere = [getPosASL _object, "yellow"] call FUNC(dev_sphereDraw); _centerSphere disableCollisionWith _object; _centerSphere attachTo [_object, _object worldToModel _centerPoint]; @@ -67,9 +66,9 @@ private _points = [ ]; private _color = switch (side _object) do { - case east: {[1, 0, 0, 1]}; - case resistance: {[0, 1, 0, 1]}; - default {[0, 0, 1, 1]}; + case east: {[0.8, 0, 0, 1]}; + case resistance: {[0, 0.8, 0, 1]}; + default {[0, 0, 0.8, 1]}; }; GVAR(dev_hitBoxes) set [getObjectID _object, [_object, _points, _color]]; diff --git a/addons/frag/functions/fnc_dev_trackObj.sqf b/addons/frag/functions/fnc_dev_trackObj.sqf index dc695fbfea..df9f48fb49 100644 --- a/addons/frag/functions/fnc_dev_trackObj.sqf +++ b/addons/frag/functions/fnc_dev_trackObj.sqf @@ -4,9 +4,9 @@ * This function adds an object to have its course tracked (every frame). * * Arguments: - * 0: Object to draw track OBJECT> - * 1: Color of trace - * 2: Whether the object is a projectile or whether to add projectile EHs + * 0: Object to draw track OBJECT> (default: "objNull") + * 1: Color of trace (default: "blue") + * 2: Whether the object is a projectile or whether to add projectile EHs (default: false) * * Return Value: * None @@ -18,12 +18,13 @@ */ params [ - ["_object", objNull, [objNull]], - ["_color", "blue", ["blue"]], - ["_isProj", false, [false]] + ["_object", objNull], + ["_color", "blue"], + ["_isProj", false] ]; TRACE_3("devDraw",_object,_color,_isProj); + // pick color and add it to the array private _colorArray = switch (toLowerANSI _color) do { case "purple": {[0.8, 0, 0.8, 1]}; @@ -41,7 +42,7 @@ GVAR(dev_trackLines) set [getObjectID _object, [[getPosATL _object], _colorArray // event handler to track round and cleanup when round is "dead" [ { - if (isGamePaused) exitWith {}; + if (isGamePaused || setAccTime == 0) exitWith {}; params ["_object", "_handle"]; if (!alive _object) exitWith {