function header, lazy eval, and params list simplifications

This commit is contained in:
lambdatiger 2024-02-15 21:03:12 -06:00
parent 656fa9f7f7
commit 78a27ff025
10 changed files with 46 additions and 83 deletions

View File

@ -41,7 +41,7 @@ GVAR(dev_trackLines) set [getObjectID _object, [[getPosATL _object], _colorArray
// event handler to track round and cleanup when round is "dead" // event handler to track round and cleanup when round is "dead"
[ [
{ {
if (isGamePaused || setAccTime == 0) exitWith {}; if (isGamePaused || accTime == 0) exitWith {};
params ["_object", "_handle"]; params ["_object", "_handle"];
if (!alive _object) exitWith { if (!alive _object) exitWith {

View File

@ -1,11 +1,10 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: Jaynus, NouberNou, Lambda.Tiger * Author: Jaynus, NouberNou, Lambda.Tiger
* This function handles creating both random and targeted fragments as well * This function handles creating both random and targeted fragments as well as handling some of the performance optimizations.
* as handling some of the performance optimizations.
* *
* Arguments: * Arguments:
* 0: ASL position of projectile. <ARRAY> * 0: Position (posASL) of projectile <ARRAY>
* 1: Velocity of projectile <ARRAY> * 1: Velocity of projectile <ARRAY>
* 2: Projectile CfgAmmo classname <STRING> * 2: Projectile CfgAmmo classname <STRING>
* 3: getShotParents of projectile at EH <ARRAY> * 3: getShotParents of projectile at EH <ARRAY>
@ -19,12 +18,7 @@
* Public: No * Public: No
*/ */
TRACE_1("begin doFrag",_this); TRACE_1("begin doFrag",_this);
params [ params ["_posASL", "_velocity", "_ammo", "_shotParents"];
"_posASL",
"_velocity",
"_ammo",
"_shotParents"
];
// Don't let a single object cause all fragmentation events // Don't let a single object cause all fragmentation events
_shotParents params ["_shotParentVic"]; _shotParents params ["_shotParentVic"];
@ -35,7 +29,7 @@ _shotParentVic setVariable [QGVAR(obj_nextFragTime), CBA_missionTime + ACE_FRAG_
// Check normal round timeout and adjust _max frags // Check normal round timeout and adjust _max frags
private _timeSinceLastFrag = CBA_missionTime - GVAR(lastFragTime); private _timeSinceLastFrag = CBA_missionTime - GVAR(lastFragTime);
if (_timeSinceLastFrag < ACE_FRAG_HOLDOFF || {_posASL isEqualTo [0, 0, 0] || _ammo isEqualTo ""}) exitWith { if (_timeSinceLastFrag < ACE_FRAG_HOLDOFF || {_posASL isEqualTo [0, 0, 0]} || {_ammo isEqualTo ""}) exitWith {
TRACE_3("timeExit",_timeSinceLastFrag,CBA_missionTime,GVAR(lastFragTime)); TRACE_3("timeExit",_timeSinceLastFrag,CBA_missionTime,GVAR(lastFragTime));
}; };
private _maxFragCount = round linearConversion [ACE_FRAG_COUNT_MIN_TIME, ACE_FRAG_COUNT_MAX_TIME, _timeSinceLastFrag, ACE_FRAG_COUNT_MIN, ACE_FRAG_COUNT_MAX, true]; private _maxFragCount = round linearConversion [ACE_FRAG_COUNT_MIN_TIME, ACE_FRAG_COUNT_MAX_TIME, _timeSinceLastFrag, ACE_FRAG_COUNT_MIN, ACE_FRAG_COUNT_MAX, true];

View File

@ -1,16 +1,15 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: Jaynus, NouberNou, Lambda.Tiger * Author: Jaynus, NouberNou, Lambda.Tiger
* This function creates fragments randomly spreading out from an explosion to * This function creates fragments randomly spreading out from an explosion to a maximum of 15.
* a maximum of 15.
* *
* Arguments: * Arguments:
* 0: Position of fragmenting projectile ASL. <ARRAY> * 0: Position (posASL) of fragmenting projectile <ARRAY>
* 1: Velocity of the fragmenting projectile. <ARRAY> * 1: Velocity of the fragmenting projectile <ARRAY>
* 2: Height (AGL) of the fragmenting projectile. <NUMBER> * 2: Height (AGL) of the fragmenting projectile <NUMBER>
* 3: Type of fragments to generate. <ARRAY> * 3: Type of fragments to generate <ARRAY>
* 4: Remaining fragment budget. <NUMBER> * 4: Remaining fragment budget <NUMBER>
* 5: Shot parents. <ARRAY> * 5: Shot parents <ARRAY>
* *
* Return Value: * Return Value:
* None * None
@ -20,14 +19,7 @@
* *
* Public: No * Public: No
*/ */
params [ params ["_posASL", "_fragVelocity", "_heightAGL", "_fragType", "_maxFragCount", "_shotParents"];
"_posASL",
"_fragVelocity",
"_heightAGL",
"_fragType",
"_maxFragCount",
"_shotParents"
];
TRACE_6("doFragRandom",_posASL,_fragVelocity,_heightAGL,_fragType,_maxFragCount,_shotParents); TRACE_6("doFragRandom",_posASL,_fragVelocity,_heightAGL,_fragType,_maxFragCount,_shotParents);
// See CfgAmmoFragSpawner for different frag types // See CfgAmmoFragSpawner for different frag types

View File

@ -1,8 +1,7 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: Jaynus, NouberNou, Lambda.Tiger * Author: Jaynus, NouberNou, Lambda.Tiger
* This function creates fragments targeted at specific entities, up to * This function creates fragments targeted at specific entities, up to _maxFrags.
* a configured maximum.
* *
* Arguments: * Arguments:
* 0: Position of fragmenting projectile ASL <ARRAY> * 0: Position of fragmenting projectile ASL <ARRAY>
@ -25,15 +24,7 @@
#define ACE_FRAG_DEFAULT_CROSS_AREA 0.75 #define ACE_FRAG_DEFAULT_CROSS_AREA 0.75
#define ACE_FRAG_MIN_TARGET_AREA 0.5 #define ACE_FRAG_MIN_TARGET_AREA 0.5
params [ params [ "_posASL", "_fragVelocity", "_fragRange", "_maxFrags", "_fragTypes", "_modFragCount", "_shotParents"];
"_posASL",
"_fragVelocity",
"_fragRange",
"_maxFrags",
"_fragTypes",
"_modFragCount",
"_shotParents"
];
TRACE_5("fnc_doFragTargeted",_posASL,_fragRange,_maxFrags,_fragTypes,_modFragCount); TRACE_5("fnc_doFragTargeted",_posASL,_fragRange,_maxFrags,_fragTypes,_modFragCount);
if (_fragTypes isEqualTo []) then { if (_fragTypes isEqualTo []) then {

View File

@ -1,7 +1,7 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: Jaynus, NouberNou, Lambda.Tiger, * Author: Jaynus, NouberNou, Lambda.Tiger,
* This function creates spalling if the hit slowed the speed down enough. * This function creates spalling if the hit slowed the projectile speed down enough.
* *
* Arguments: * Arguments:
* Arguments are the same as BI's "HitPart" EH: * Arguments are the same as BI's "HitPart" EH:
@ -15,24 +15,16 @@
* *
* Public: No * Public: No
*/ */
#define GLUE(g1,g2) g1##g2
TRACE_1("doSpall",_this); TRACE_1("doSpall",_this);
params [ params ["_projectile", "_objectHit", "_lastPosASL", "_lastVelocity", "_surfaceNorm", "_surfaceType", "_ammo", "_shotParents", "_vectorUp"];
"_projectile",
"_objectHit",
"_lastPosASL",
"_lastVelocity",
"_surfaceNorm",
"_surfaceType",
"_ammo",
"_shotParents",
"_vectorUp"
];
if (CBA_missionTime < GVAR(nextSpallAllowTime) || if (CBA_missionTime < GVAR(nextSpallAllowTime) ||
_lastPosASL isEqualTo [0,0,0] || {isNull _objectHit} ||
{_ammo isEqualTo "" || {!isNull _objectHit && {_lastPosASL isEqualTo [0,0,0]} ||
{objectHit isKindOf "CAManBase"}}}) exitWith { {_ammo isEqualTo ""} ||
{_objectHit isKindOf "CAManBase"}) exitWith {
TRACE_4("time/invalidHit",CBA_missionTime,GVAR(nextSpallAllowTime),_objectHit,_lastPosASL); TRACE_4("time/invalidHit",CBA_missionTime,GVAR(nextSpallAllowTime),_objectHit,_lastPosASL);
}; };
@ -122,7 +114,7 @@ private _spawnSize = switch (true) do
}; };
private _spallSpawner = createVehicle [ private _spallSpawner = createVehicle [
"ace_frag_" + _material + _spawnSize, QUOTE(GLUE(ADDON,_)) + _material + _spawnSize,
ASLToATL _spallPosASL, ASLToATL _spallPosASL,
[], [],
0, 0,

View File

@ -1,23 +1,22 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
#define ACE_FRAG_SOUNDENVIRON_STR_LEN 12
#define ACE_FRAG_SOUNDGIT_STR_LEN 8
#define ACE_FRAG_MATERIAL_SEARCH_LEN 10
/* /*
* Author: Lambda.Tiger * Author: Lambda.Tiger
* This function returns a classification of material type based * This function returns a classification of material type based on the surface hit.
* on the surface hit.
* *
* Arguments: * Arguments:
* 0: surfacetype <STRING> - either a CfgSurfaces path .bisurf filepath * 0: Surface type given as either a CfgSurfaces path or .bisurf filepath, same format as "HitPart" projectile parameter <STRING>
* *
* Return Value: * Return Value:
* _material <STRING> - Material categories as expanded on in line 44 below * Material categories as expanded on in line 44 below <STRING>
* *
* Example: * Example:
* [_surfaceType] call ace_frag_fnc_getFragInfo; * [_surfaceType] call ace_frag_fnc_getFragInfo;
* *
* Public: No * Public: No
*/ */
#define ACE_FRAG_SOUNDENVIRON_STR_LEN 12
#define ACE_FRAG_SOUNDGIT_STR_LEN 8
#define ACE_FRAG_MATERIAL_SEARCH_LEN 10
params ["_surfType"]; params ["_surfType"];

View File

@ -1,17 +1,16 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: Lambda.Tiger * Author: Lambda.Tiger
* This function returns spalling parameters for a specific * This function returns spalling parameters for a specific ammo type.
* ammo type.
* *
* Arguments: * Arguments:
* 0: _ammo <STRING> - CfgAmmo type of ammo to check * 0: Ammo classname <STRING>
* *
* Return Value: * Return Value:
* _ammoInfo <ARRAY> * _ammoInfo <ARRAY>
* 0: _caliber - search range for fragments <NUMBER> * 0: Caliber <NUMBER>
* 1: _explosive - whether the round is explosive or not <NUMBER> * 1: What part of the hit damage is from ballistic vs explosive energy (1 for all explosive) <NUMBER>
* 2: _indirectHitRange - Indirect hit damage <NUMBER> * 2: Indirect hit damage <NUMBER>
* *
* Example: * Example:
* ["B_556x45_Ball"] call ace_frag_fnc_getSpallInfo; * ["B_556x45_Ball"] call ace_frag_fnc_getSpallInfo;

View File

@ -1,8 +1,7 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: Lambda.Tiger * Author: Lambda.Tiger
* For performance, we load a bunch of vanilla materials preemptively into * For performance, we load a bunch of vanilla materials preemptively into the spall material cache.
* the spall material cache.
* *
* Arguments: * Arguments:
* None * None
@ -11,7 +10,7 @@
* None * None
* *
* Example: * Example:
* call initMaterialCache; * call ace_frag_fnc_initMaterialCache;
* *
* Public: No * Public: No
*/ */

View File

@ -19,7 +19,7 @@
TRACE_1("ACE_Frag rndInit",_this); TRACE_1("ACE_Frag rndInit",_this);
params ["_projectile"]; params ["_projectile"];
if !(isServer) exitWith {}; if (!isServer) exitWith {};
private _ammo = typeOf _projectile; private _ammo = typeOf _projectile;
if (_ammo isEqualTo "" || {isNull _projectile}) exitWith { if (_ammo isEqualTo "" || {isNull _projectile}) exitWith {
@ -49,15 +49,12 @@ if (GVAR(spallEnabled) && {_ammo call FUNC(shouldSpall)}) then {
_projectile addEventHandler [ _projectile addEventHandler [
"HitPart", "HitPart",
{ {
params ["_projectile", "_hitObject", "", params ["_projectile", "_hitObject", "", "_posASL", "_velocity", "_surfNorm", "", "", "_surfType"];
"_posASL", "_velocity", "_surfNorm", "",
"", "_surfType"
];
private _shotParent = getShotParents _projectile; private _shotParent = getShotParents _projectile;
private _ammo = typeOf _projectile; private _ammo = typeOf _projectile;
private _vectorUp = vectorUp _projectile; private _vectorUp = vectorUp _projectile;
/* /*
* Wait a round to see what happens to the round, may result in * Wait a frame to see what happens to the round, may result in
* multiple hits / slowdowns getting shunted to the first hit * multiple hits / slowdowns getting shunted to the first hit
*/ */
[ [

View File

@ -4,7 +4,7 @@
* This function checks whether an ammunition type should cause spalling. * This function checks whether an ammunition type should cause spalling.
* *
* Arguments: * Arguments:
* 0: Type of ammo to check <STRING> * 0: Ammo classname <STRING>
* *
* Return Value: * Return Value:
* Whether the round type would spall when hitting an object <BOOL> * Whether the round type would spall when hitting an object <BOOL>