Skip to content

Commit 4d4907a

Browse files
lambdatigerjohnb432LinkIsGrimPabstMirrorrautamiekka
committed
Frag - Implement Arma v2.18 changes from #10157 (#10313)
* removed old parameter changed in f28d5d2 * compacted text a bit * formatting whitespace * Grammatical erros * Changes as discussed here #9728 (comment) * Few quick optimizations of == to isEqualTo * Debug updated to be easier to control * Changed how spall hold off is calculated to avoid repeated unneeded computations * clarified a hold off variable * Better approach to ACE_FRAG_RM_EH macro * Git rid of superfulous stringtable entries Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * unneeded parens Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * Clarified arguments Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * getposATL to getPosATL Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * Update addons/frag/functions/fnc_dev_addRound.sqf Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * Function header changes Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * another great isNotEqualTo opportunity Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * formatting changes Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * unneeded parens Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * Declared _ammoInfo twice * optimized around checking if systems are active and moved debug arguments to an ifdef * Removed white space from removing an if statement in a previous commit * Removed superfulous parenthese Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * clarified function description and removed unneeded comments * Moved "isServer" check to initRound function * #9728 (comment) * changed params statement, function header, and propigated doFrag argument changes * capitization from cfg to Cfg in config lookups * changed default arguments, check isKindOf to "CAManBase" * Updated function headers * white space and define placement changes * removed 2 argument option and removed some defaults * removed spurious commas * removed unused debug GVAR * Switched debug clear traces from addAction to ACE self interact * variable names weren't verbose enough * Mactched format #9728 (comment) * Updated debug settings * Shot parent possible fix #1 * Removed extra text from CfgAmmoFragParameters * Makes sure spall power square root is positive and also we don't produce fragments when for some reason the round accelerates. * white space for clarity Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * Optimize dev_hitbox deleting Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * saving people from their own bad testing setup * Since the functions always exist, I guess these variables should too * Fixe bad search function * optimization, see #9728 (comment) * changed SPG-9 Fragments * removed unneeded toLower * Changed case output to match config * Increased relative chance to hit torso/pelvis when fragemnt should hit. * Removed double space * updated some round types * Added commented 2.18 commands and updated script component * added print incomplete only option to fnc_debugAmmo * removed all spaces from macros * removd unneeded define * a Brett (HEMTT) suggested change I miss * Apply suggestions from code review Small formatting changes and small errors Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * Removed doublespace Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * Update addons/frag/functions/fnc_dev_addRound.sqf If the round isn't in the hashmap anymore, we have to stop the PFH. Brought code up to same standard as used in FUNC(dev_trackObj). - johnb432 Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * Update addons/frag/functions/fnc_dev_drawTrace.sqf Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * variable name changes * magic number clean up and white space * white space, function headers and variable names * small Should spall optimization Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * Removed blacklist functions and settings * reformatted function headers, removed value type checking, and changed lazy eval. * fixed missing underscore in change from review * function header, lazy eval, and params list simplifications * function header and variable name readability * changed defaults to make them more clear they're just a default value * Updated wiki to be clearer in a few areas, and add some other information I've found working on this * added MP debug compatability * Possible shouldFrag legibility improvement * added changes to stringtable * Grammar sweep on the wiki, and added some clarifications to config values * optimized dev_trackHitbox and made variables more explicit * Cleaned up documentation and documentation * reorganized postInit CBA_settingInitialized EH * missing underscore in fnc_dev_trackObj Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * stopped adding unneeded extra points Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * cleaned un-updated stringtable entries * reworked some function headers and deleted whitespace in doFragTargeted * Removed outdated code * Formatting and header fixes * Ignore curators and spectators * Made clear traces global again, added interaction condition * Change stringtable entries * Removed unused stringtable entries & fixed hitbox description * Small coding standard changes (missing semicolons on non-return values, extra parenthesis) * Changed sphere size and added return based on usage in dev_trackHitBox * removed "_lo" random fragment entries as they are unused * doFragRandom was always being called and spawning at least 5 fragments even when the fragment budget of 50 was reached. Fixed variable name (AGL instead of ATL). * removed unnceassary "disableCollisionWith" * Clarified trace statements and corrected format and spelling * Do spall exits for time 90% of the time (round hits multiple walls) and should exit on "hitting ground since no spalling is generated * Fixed ordering in which frag hold off variables are set to not skip when unneeded * initRound ordering and fixed define names * Fixed function header * reformatted comments and some v2.18 remakrs comments * Removed unneeded ground offset * Expanded TRACE * Fix typo * Moved event to preInit * Updated default fallback frag distance to be less extreme and changed fixed a magic number * Randomized random frag directions * removed some magic numbers, and cached numbers from shouldSpall * removed magic numbers and cached values preemptively (normally spallInfoCache is called later, but we pull the right config parameters so we might as well store them) * Unify example formatting Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> * cleaned up function examples * removed excess square brackets * Final function example reformat * Update addons/frag/script_component.hpp * Corrected docs * Use `getOrDefaultCall` * Removed unused classes, redefined using macros to minimize error and make review easier * updated debugging output and fixed velocity error * Reformatted for legibility and debug output * caught calc error while answer johnb's question * Almost finished with compats and I had some changes to align vanilla as well * Missed variable when updating * Added unneeded class details to make PBOproject happy * Forgot to update doFragRandom docs with previous changes * and the debug context * Readd blacklist * Fixed an issue with fragments being created above water for explosions below the surface * Exposed projectile event handlers for both blacklist use and other shenanigans. * Revert "Exposed projectile event handlers for both blacklist use and other shenanigans." This reverts commit eaff498. * added debug information and folded if statements * fixed error (if statement with no argument) * Only send blacklist updates to the server * Added default fragCount fallback value based on current ACE frag range calculation * Converted all positions for doFrag to AGL since we're converting to that now * removed feet hitpoints & tightened multishot submunitions. Feet hitpoitns aren't used since calculation for trajectory doesn't account for drag, fragments aimed at feet won't hit * Merge branch 'acemod:master' into master * Revert to 60a0dae, merge conflict wasn't resolved properly * Removed event handlers * Changed blacklist to acting on local projectiles to match initial performance * added fired EH and moved projectile tracking to be local to projectile * updated initialization and should frag to check for submunitions since we no longer rely on init EH * Fixed calls for shouldFrag and got rid of old initRound.sfq (maybe back after 2.18) * fixed small mistakes in names and function calls * fixed frame offset to avoid hitting dead targets * Fixed config path in shouldFrag * Didn't know that PBO project needed trailing {} on class inheritance structures * fixed more useless trailing {} * Initial rollback to old frag simulation and spalling simulation. Updated spall to function and helpter functions as well * missed comma * remove fragCount from config * made addBlackList remove projectile EHs * updated config path to be relevant to post-EH version * All spalling in current version is local * updated search pattern to one discussed in PR #9728 * updated defines to match implementation * removed commented out debug information from nouber * removed magic numbers and code with no effect * removed more magic numbers * unfucked a comma * fixed debug def names * updated documentation * changed debug colors * mass must be in grams in this version I guess * fixed errors in frag with downgrade * fixed timing and other spall issues * updated some defne names and usages * increased code legiblity and optimized some randomizations * clarified parts of the spall event chain * Optimized loop to find spall position using larger steps and fewer operations per loop * fixed small errors * removed unused variables & EHs and set defaults in the case debug mode draw isn't used * removed "class eventhandler" references * removed _fragCount reference in newly backported debug functions * fragmenting projectile velocity isn't used anywhere * removed unused variables, implemented fixes from full rewrite PR, and fixed math errors * added debug draw mode to DEBUG_ENABLED_FRAG define check * fix documentation to make units clear on metal and filler quanities * command capitalization * added target point debug spheres * fixed target sphere visability * Jank fix so that the unit firing can get hit with it's own fragments * accidentally committed script_component.hpp w/ debug enabled * Alternative way to address shot parent self-harm issue * missed comma, going to bed, sorry * add newline and fix blacklist * legability formatting * removed extra newlines and double spaces * Updated function documentation * Removed unused stringtable items * Debug sphere conditional was missing in frago * Completed suggested changed by johnb432 * restored 40mm grenade fragmentation * Apply suggestions from code review Fixed a number of config errors Co-authored-by: PabstMirror <pabstmirror@gmail.com> * Fixed firefist inheritance and order of 125mm shell * Wrong order on reflections variables, but it's not like anyone uses that * Added projectile locality * Added proper projectile locality checks * left some locality debug text * This isn't worthy of a warning as most of the time _objectHit is null is due to the projectile hitting the ground * Removed a newlines for code brackets in arrays * updated debug functions with some minor optimizations * Apply suggestions from code review Grammar and spelling corrections Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com> * didn't consider someone might use explosion reflections but not frag * addressed future arma v2.18 changes more aptly * Fixed authors line on fired function. Used to make sense different when it was an init function based on ammunition extended eventhandlers, missed the revert. * switch all hash fallbacks to getOrDefaultCall and turned default fragments array into a define * Transitioned frag system from fired to ace explode event system * decreased chance to hit / fragment inaccuracy. * fixing setShotParents only sometimes setting first argument, not instigator * cleanup * Slight optimization of "_vecVar" calculation * removed dev_addRound function * Command changes for Arma 2.18 * Fixed debug setting changes * missed exit condition * removed shot parents due to local creation of spall * simplified comment * Adjusted whitespace for readability * Reformatted comments per Johnb432's suggestions Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> * one more indent fix --------- Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> Co-authored-by: PabstMirror <pabstmirror@gmail.com> Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com>
1 parent c4ffa8c commit 4d4907a

File tree

2 files changed

+90
-103
lines changed

2 files changed

+90
-103
lines changed

addons/frag/functions/fnc_fired.sqf

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ private _hitPartEventHandler = _projectile addEventHandler ["HitPart", {
4040
private _ammo = typeOf _projectile;
4141
private _vectorUp = vectorUp _projectile;
4242

43-
/*
44-
* Wait a frame to see what happens to the round
45-
*/
43+
// Wait a frame to see what happens to the round
4644
[LINKFUNC(doSpallHitPart), [_projectile, _objectHit, _posASL, _velocity, _surfNorm, _surfType, _ammo, _vectorUp]] call CBA_fnc_execNextFrame;
4745
}];
4846
private _penetratedEventHandler = _projectile addEventHandler ["Penetrated",LINKFUNC(doSpallPenetrate)];

addons/frag/functions/fnc_frago.sqf

Lines changed: 89 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -39,120 +39,109 @@ _shellType call FUNC(getFragInfo) params ["_fragRange", "_fragVelocity", "_fragT
3939

4040
private _fragPosAGL = ASLToAGL _fragPosASL;
4141
TRACE_5("fragValues",_fragPosASL,_fragPosAGL,_fragRange,_fragVelocity,_metalMassModifier);
42-
// Post 2.18 change - uncomment line 43, modify lines 45, and remove lines 44, 51-57, 64-66
43-
// private _targets = [ASLToAGL _fragPosAGL, _fragRange, _fragRange, 0, false, _fragRange] nearEntities [["Car", "Motorcycle", "Tank", "StaticWeapon", "CAManBase", "Air", "Ship"], false, true, true];
44-
private _objects = _fragPosAGL nearEntities [["Car", "Motorcycle", "Tank", "StaticWeapon", "CAManBase", "Air", "Ship"], _fragRange];
45-
if (_objects isEqualTo []) exitWith {
42+
43+
// Compile possible targets including units, vehicles, and crews
44+
private _targets = [_fragPosAGL, _fragRange, _fragRange, 0, false, _fragRange] nearEntities [["Car", "Motorcycle", "Tank", "StaticWeapon", "CAManBase", "Air", "Ship"], false, true, true];
45+
if (_targets isEqualTo []) exitWith {
4646
TRACE_2("No nearby targets",_fragPosAGL,_fragRange);
47-
0
47+
0 // return
4848
};
49-
50-
// grab crews and add them in so that targets stay approx. sorted by distance
51-
TRACE_1("",_objects);
52-
private _targets = [];
53-
{
54-
private _crew = crew _x;
55-
_crew pushBackUnique _x;
56-
_targets append _crew;
57-
} forEach _objects;
58-
TRACE_2("",_fragRange,count _targets);
49+
TRACE_3("",_fragRange,count _targets,_targets);
5950

6051
private _fragCount = 0;
61-
6252
private _fragArcs = [];
6353
_fragArcs set [360, 0];
6454

65-
if (_targets isNotEqualTo []) then {
66-
if (GVAR(reflectionsEnabled)) then {
67-
[_fragPosASL, _shellType] call FUNC(doReflections);
68-
};
69-
{
70-
private _target = _x;
71-
if (alive _target && {getNumber ((configOf _target) >> "isPlayableLogic") == 0}) then {
72-
(boundingBox _target) params ["_boundingBoxA", "_boundingBoxB"];
73-
74-
private _cubic = ((abs (_boundingBoxA select 0)) + (_boundingBoxB select 0)) * ((abs (_boundingBoxA select 1)) + (_boundingBoxB select 1)) * ((abs (_boundingBoxA select 2)) + (_boundingBoxB select 2));
75-
76-
if (_cubic <= 1) exitWith {};
77-
78-
private _targetVel = velocity _target;
79-
private _targetPos = getPosASL _target;
80-
private _distance = _target distance _fragPosAGL;
81-
private _add = ((_boundingBoxB select 2) / 2) + ((((_distance - (_fragVelocity / 8)) max 0) / _fragVelocity) * 10);
82-
83-
_targetPos = _targetPos vectorAdd [
84-
(_targetVel select 0) * (_distance / _fragVelocity),
85-
(_targetVel select 1) * (_distance / _fragVelocity),
86-
_add
87-
];
88-
89-
private _baseVec = _fragPosASL vectorFromTo _targetPos;
90-
91-
private _dir = floor (_baseVec call CBA_fnc_vectDir);
92-
private _currentCount = RETDEF(_fragArcs select _dir,0);
93-
if (_currentCount < 10) then {
94-
private _count = ceil (random _metalMassModifier);
95-
private _vecVar = FRAG_VEC_VAR;
96-
if !(_target isKindOf "CAManBase") then {
97-
ADD(_vecVar,(sqrt _cubic) / 2000);
98-
if ((crew _target) isEqualTo [] && {_count > 0}) then {
99-
_count = 0 max (_count / 2);
100-
};
55+
if (GVAR(reflectionsEnabled)) then {
56+
[_fragPosASL, _shellType] call FUNC(doReflections);
57+
};
58+
{
59+
private _target = _x;
60+
if (getNumber ((configOf _target) >> "isPlayableLogic") == 0) then {
61+
(boundingBox _target) params ["_boundingBoxA", "_boundingBoxB"];
62+
63+
private _cubic = ((abs (_boundingBoxA select 0)) + (_boundingBoxB select 0)) * ((abs (_boundingBoxA select 1)) + (_boundingBoxB select 1)) * ((abs (_boundingBoxA select 2)) + (_boundingBoxB select 2));
64+
65+
if (_cubic <= 1) exitWith {};
66+
67+
private _targetVel = velocity _target;
68+
private _targetPos = getPosASL _target;
69+
private _distance = _target distance _fragPosAGL;
70+
private _add = ((_boundingBoxB select 2) / 2) + ((((_distance - (_fragVelocity / 8)) max 0) / _fragVelocity) * 10);
71+
72+
_targetPos = _targetPos vectorAdd [
73+
(_targetVel select 0) * (_distance / _fragVelocity),
74+
(_targetVel select 1) * (_distance / _fragVelocity),
75+
_add
76+
];
77+
78+
private _baseVec = _fragPosASL vectorFromTo _targetPos;
79+
80+
private _dir = floor (_baseVec call CBA_fnc_vectDir);
81+
private _currentCount = RETDEF(_fragArcs select _dir,0);
82+
if (_currentCount < 10) then {
83+
private _count = ceil (random _metalMassModifier);
84+
private _vecVar = FRAG_VEC_VAR;
85+
if !(_target isKindOf "CAManBase") then {
86+
ADD(_vecVar,(sqrt _cubic) / 2000);
87+
if ((crew _target) isEqualTo [] && {_count > 0}) then {
88+
_count = 0 max (_count / 2);
10189
};
102-
private _vecVarHalf = _vecVar / 2;
103-
for "_i" from 1 to _count do {
104-
private _vectorDir = _baseVec vectorDiff [
105-
_vecVarHalf - (random _vecVar),
106-
_vecVarHalf - (random _vecVar),
107-
_vecVarHalf - (random _vecVar)
108-
];
109-
110-
private _fragObjSpeed = _fragVelocity * (1 - random 0.5);
111-
private _fragObjVelocity = _vectorDir vectorMultiply _fragObjSpeed;
112-
113-
private _fragObj = createVehicleLocal [selectRandom _fragTypes, _fragPosAGL, [], 0, "CAN_COLLIDE"];
114-
_fragObj setVectorDir _vectorDir;
115-
_fragObj setVelocity _fragObjVelocity;
116-
#ifdef DEBUG_MODE_DRAW
117-
[_fragObj, "green", true] call FUNC(dev_trackObj);
118-
if (GVAR(dbgSphere)) then {
119-
[_targetPos, "(0.88,0.36,0.92,0.8)"] call FUNC(dev_sphereDraw);
120-
};
121-
#endif
122-
INC(_fragCount);
123-
INC(_currentCount);
90+
};
91+
private _vecVarHalf = _vecVar / 2;
92+
for "_i" from 1 to _count do {
93+
private _vectorDir = _baseVec vectorDiff [
94+
_vecVarHalf - (random _vecVar),
95+
_vecVarHalf - (random _vecVar),
96+
_vecVarHalf - (random _vecVar)
97+
];
98+
99+
private _fragObjSpeed = _fragVelocity * (1 - random 0.5);
100+
private _fragObjVelocity = _vectorDir vectorMultiply _fragObjSpeed;
101+
102+
private _fragObj = createVehicleLocal [selectRandom _fragTypes, _fragPosAGL, [], 0, "CAN_COLLIDE"];
103+
_fragObj setVectorDir _vectorDir;
104+
_fragObj setVelocity _fragObjVelocity;
105+
#ifdef DEBUG_MODE_DRAW
106+
[_fragObj, "green", true] call FUNC(dev_trackObj);
107+
if (GVAR(dbgSphere)) then {
108+
[_targetPos, "(0.88,0.36,0.92,0.8)"] call FUNC(dev_sphereDraw);
124109
};
125-
_fragArcs set [_dir, _currentCount];
110+
#endif
111+
INC(_fragCount);
112+
INC(_currentCount);
126113
};
114+
_fragArcs set [_dir, _currentCount];
127115
};
128-
if (_fragCount > _maxFrags) exitWith {};
129-
} forEach _targets;
130-
TRACE_1("targeted",_fragCount);
131-
if (_fragCount > _maxFrags) exitWith {};
132-
private _randomCount = ceil ((_maxFrags - _fragCount) * 0.35);
133-
TRACE_1("",_randomCount);
134-
private _sectorSize = 360 / (_randomCount max 1);
135-
136-
for "_i" from 1 to _randomCount do {
137-
// Distribute evenly
138-
private _sectorOffset = 360 * (_i - 1) / (_randomCount max 1);
139-
private _randomDir = random (_sectorSize);
140-
private _vectorDir = [cos (_sectorOffset + _randomDir), sin (_sectorOffset + _randomDir), sin (30 - (random 45))];
141-
142-
private _fragObjSpeed = _fragVelocity * (1 - random 0.5);
143-
private _fragObjVelocity = _vectorDir vectorMultiply _fragObjSpeed;
144-
145-
private _fragObj = createVehicleLocal [selectRandom _fragTypes, _fragPosAGL, [], 0, "CAN_COLLIDE"];
146-
_fragObj setVectorDir _vectorDir;
147-
_fragObj setVelocity _fragObjVelocity;
148-
149-
#ifdef DEBUG_MODE_DRAW
150-
[_fragObj, "blue", true] call FUNC(dev_trackObj);
151-
#endif
152-
INC(_fragCount);
153116
};
117+
if (_fragCount > _maxFrags) exitWith {};
118+
} forEach _targets;
119+
TRACE_1("targeted",_fragCount);
120+
if (_fragCount > _maxFrags) exitWith {};
121+
private _randomCount = ceil ((_maxFrags - _fragCount) * 0.35);
122+
TRACE_1("",_randomCount);
123+
private _sectorSize = 360 / (_randomCount max 1);
124+
125+
for "_i" from 1 to _randomCount do {
126+
// Distribute evenly
127+
private _sectorOffset = 360 * (_i - 1) / (_randomCount max 1);
128+
private _randomDir = random (_sectorSize);
129+
private _vectorDir = [cos (_sectorOffset + _randomDir), sin (_sectorOffset + _randomDir), sin (30 - (random 45))];
130+
131+
private _fragObjSpeed = _fragVelocity * (1 - random 0.5);
132+
private _fragObjVelocity = _vectorDir vectorMultiply _fragObjSpeed;
133+
134+
private _fragObj = createVehicleLocal [selectRandom _fragTypes, _fragPosAGL, [], 0, "CAN_COLLIDE"];
135+
_fragObj setVectorDir _vectorDir;
136+
_fragObj setVelocity _fragObjVelocity;
137+
138+
#ifdef DEBUG_MODE_DRAW
139+
[_fragObj, "blue", true] call FUNC(dev_trackObj);
140+
#endif
141+
INC(_fragCount);
154142
};
155143

156144
TRACE_1("total created",_fragCount);
157145

158146
END_COUNTER(frago);
147+
_fragCount // return

0 commit comments

Comments
 (0)