mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #1163 from acemod/fragSpallOptimization
Frag spall optimization
This commit is contained in:
commit
46751fd912
@ -1,8 +1,33 @@
|
||||
class ACE_Settings {
|
||||
class GVAR(enabled) {
|
||||
displayName = "Frag System";
|
||||
description = "Enables the shrapnel system for explosives";
|
||||
class GVAR(Enabled) {
|
||||
displayName = "$STR_ACE_frag_EnableFrag";
|
||||
description = "$STR_ACE_frag_EnableFrag_Desc";
|
||||
typeName = "BOOL";
|
||||
value = 1;
|
||||
};
|
||||
class GVAR(SpallEnabled) {
|
||||
displayName = "$STR_ACE_frag_EnableSpall";
|
||||
description = "$STR_ACE_frag_EnableSpall_Desc";
|
||||
typeName = "BOOL";
|
||||
value = 0;
|
||||
};
|
||||
class GVAR(maxTrack) {
|
||||
displayName = "$STR_ACE_frag_MaxTrack";
|
||||
description = "$STR_ACE_frag_MaxTrack_Desc";
|
||||
typeName = "SCALAR";
|
||||
value = 500;
|
||||
};
|
||||
class GVAR(MaxTrackPerFrame) {
|
||||
displayName = "$STR_ACE_frag_MaxTrackPerFrame";
|
||||
description = "$STR_ACE_frag_MaxTrackPerFrame_Desc";
|
||||
typeName = "SCALAR";
|
||||
value = 50;
|
||||
};
|
||||
|
||||
class GVAR(EnableDebugTrace) {
|
||||
displayName = "$STR_ACE_frag_EnableDebugTrace";
|
||||
description = "$STR_ACE_frag_EnableDebugTrace_Desc";
|
||||
typeName = "BOOL";
|
||||
value = 0;
|
||||
};
|
||||
};
|
||||
|
@ -8,6 +8,7 @@ class CfgAmmo {
|
||||
//class ace_arty_105mm_m1_m782_delay: ace_arty_105mm_m1_m782_prox {
|
||||
// GVAR(skip) = 1;
|
||||
//};
|
||||
|
||||
class Bo_GBU12_LGB;
|
||||
class ACE_GBU12 : Bo_GBU12_LGB {
|
||||
GVAR(enabled) = 1;
|
||||
@ -470,4 +471,6 @@ class CfgAmmo {
|
||||
class ACE_frag_spall_huge: ACE_frag_huge {
|
||||
timeToLive = 0.3;
|
||||
};
|
||||
|
||||
#include "CfgAmmoReflections.hpp"
|
||||
};
|
||||
|
2522
addons/frag/CfgAmmoReflections.hpp
Normal file
2522
addons/frag/CfgAmmoReflections.hpp
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,12 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
if(GVAR(EnableDebugTrace) && !isMultiplayer) then {
|
||||
GVAR(traceFrags) = true;
|
||||
GVAR(autoTrace) = true;
|
||||
};
|
||||
|
||||
if(isServer) then {
|
||||
[QGVAR(frag_eh), { _this call FUNC(frago); }] call ace_common_fnc_addEventHandler;
|
||||
};
|
||||
};
|
||||
|
||||
[FUNC(masterPFH), 0, []] call CBA_fnc_addPerFrameHandler;
|
@ -6,18 +6,16 @@ PREP(doSpall);
|
||||
PREP(fired);
|
||||
PREP(frago);
|
||||
PREP(spallTrack);
|
||||
PREP(trackFragRound);
|
||||
|
||||
GVAR(blackList) = [];
|
||||
GVAR(traceFrags) = false;
|
||||
GVAR(trackedObjects) = [];
|
||||
|
||||
GVAR(TOTALFRAGS) = 0;
|
||||
|
||||
GVAR(spallHPData) = [];
|
||||
GVAR(spallIsTrackingCount) = 0;
|
||||
|
||||
GVAR(autoTrace) = true;
|
||||
GVAR(autoTrace) = false;
|
||||
GVAR(traceID) = -1;
|
||||
GVAR(traces) = [];
|
||||
GVAR(tracesStarted) = false;
|
||||
@ -32,4 +30,22 @@ PREP(startTracing);
|
||||
PREP(stopTracing);
|
||||
PREP(trackTrace);
|
||||
|
||||
// New tracking mechanisms
|
||||
PREP(masterPFH);
|
||||
PREP(pfhRound);
|
||||
PREP(addPfhRound);
|
||||
PREP(removePfhRound); // THIS SHOULD ABE USED SPARINGLY
|
||||
|
||||
// Explosive Reflection
|
||||
GVAR(replacedBisArtyWrapper) = true;
|
||||
PREP(findReflections);
|
||||
PREP(doExplosions);
|
||||
PREP(doReflections);
|
||||
|
||||
|
||||
GVAR(lastIterationIndex) = 0;
|
||||
GVAR(objects) = [];
|
||||
GVAR(objectTypes) = [];
|
||||
GVAR(arguments) = [];
|
||||
|
||||
ADDON = true;
|
||||
|
75
addons/frag/functions/fnc_addPfhRound.sqf
Normal file
75
addons/frag/functions/fnc_addPfhRound.sqf
Normal file
@ -0,0 +1,75 @@
|
||||
//#define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_enabled","_doFragTrack", "_doSpall", "_spallTrack", "_spallTrackID"];
|
||||
PARAMS_3(_gun,_type,_round);
|
||||
|
||||
if (!GVAR(enabled)) exitWith {};
|
||||
|
||||
//_enabled = getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(enabled));
|
||||
//if(_enabled < 1) exitWith {};
|
||||
|
||||
if(_round in GVAR(blackList)) exitWith {
|
||||
GVAR(blackList) = GVAR(blackList) - [_round];
|
||||
};
|
||||
|
||||
// Exit on max track
|
||||
if( (count GVAR(objects)) > GVAR(MaxTrack)) exitWith { };
|
||||
|
||||
_doFragTrack = false;
|
||||
if(_gun == ACE_player) then {
|
||||
_doFragTrack = true;
|
||||
} else {
|
||||
if((gunner _gun) == ACE_player) then {
|
||||
_doFragTrack = true;
|
||||
} else {
|
||||
if(local _gun && {!(isPlayer (gunner _gun))} && {!(isPlayer _gun)}) then {
|
||||
_doFragTrack = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
if(GVAR(SpallEnabled)) then {
|
||||
if(GVAR(spallIsTrackingCount) <= 0) then {
|
||||
GVAR(spallHPData) = [];
|
||||
};
|
||||
if(GVAR(spallIsTrackingCount) > 5) then {
|
||||
// ACE_player sideChat "LIMT!";
|
||||
_doSpall = false;
|
||||
} else {
|
||||
GVAR(spallIsTrackingCount) = GVAR(spallIsTrackingCount) + 1;
|
||||
};
|
||||
};
|
||||
// ACE_player sideChat format["c: %1", GVAR(spallIsTrackingCount)];
|
||||
|
||||
if(GVAR(autoTrace)) then {
|
||||
[ACE_player, _round, [1,0,0,1]] call FUNC(addTrack);
|
||||
};
|
||||
|
||||
// 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 {
|
||||
_spallTrack = [];
|
||||
_spallTrackID = [];
|
||||
|
||||
private["_args"];
|
||||
_args = [_round, (getPosASL _round), (velocity _round), _type, diag_frameno, _gun, _doSpall, _spallTrack, _spallTrackID,
|
||||
(getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(skip))),
|
||||
(getNumber (configFile >> "CfgAmmo" >> _type >> "explosive")),
|
||||
(getNumber (configFile >> "CfgAmmo" >> _type >> "indirectHitRange")),
|
||||
(getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(force))),
|
||||
(getNumber(configFile >> "CfgAmmo" >> _type >> "indirecthit")*(sqrt((getNumber (configFile >> "CfgAmmo" >> _type >> "indirectHitRange")))))
|
||||
];
|
||||
TRACE_1("Initializing track", _round);
|
||||
GVAR(objects) pushBack _round;
|
||||
GVAR(arguments) pushBack _args;
|
||||
|
||||
if(_doSpall) then {
|
||||
[_round, 1, _spallTrack, _spallTrackID] call FUNC(spallTrack);
|
||||
};
|
||||
// ACE_player sideChat "WTF2";
|
||||
};
|
||||
|
||||
|
||||
|
26
addons/frag/functions/fnc_doExplosions.sqf
Normal file
26
addons/frag/functions/fnc_doExplosions.sqf
Normal file
@ -0,0 +1,26 @@
|
||||
//fnc_doExplosions.sqf
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_params", "_explosions", "_index", "_i", "_exp", "_refExp", "_bpos", "_hit", "_distance", "_indirectHitRange", "_depth"];
|
||||
_params = _this select 0;
|
||||
_explosions = _params select 0;
|
||||
_index = _params select 1;
|
||||
for "_i" from _index to ((_index+2) min (count _explosions)) do {
|
||||
_exp = _explosions select _i;
|
||||
_refExp = _exp select 0;
|
||||
_bpos = _exp select 1;
|
||||
_hit = _exp select 2;
|
||||
_distance = _exp select 3;
|
||||
_indirectHitRange = _exp select 4;
|
||||
_depth = _exp select 5;
|
||||
_refExp createVehicle (ASLtoATL _bpos);
|
||||
// if(_hit >= 150 && _distance > _indirectHitRange) then {
|
||||
// [_bpos, _refExp, _depth] call FUNC(doReflections);
|
||||
// };
|
||||
};
|
||||
_index = _index + 2;
|
||||
if(_index >= (count _explosions)) then {
|
||||
[(_this select 1)] call cba_fnc_removePerFrameHandler;
|
||||
} else {
|
||||
_params set[1, _index];
|
||||
};
|
22
addons/frag/functions/fnc_doReflections.sqf
Normal file
22
addons/frag/functions/fnc_doReflections.sqf
Normal file
@ -0,0 +1,22 @@
|
||||
//fnc_doReflections.sqf
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_pos", "_ammo", "_depth", "_hit", "_range", "_hitFactor", "_indirectHitRange", "_indirectHit", "_testParams"];
|
||||
|
||||
_pos = _this select 0;
|
||||
_ammo = _this select 1;
|
||||
_depth = 1;
|
||||
if(count _this > 2) then {
|
||||
_depth = _this select 2;
|
||||
};
|
||||
// TEST_ICONS pushBack [_pos, format["EXP!", _hit, _range, _hitFactor]];
|
||||
if(_depth <= 2) then {
|
||||
_indirectHitRange = getNumber(configFile >> "CfgAmmo" >> _ammo >> "indirectHitRange");
|
||||
_indirectHit = getNumber(configFile >> "CfgAmmo" >> _ammo >> "indirectHit");
|
||||
|
||||
|
||||
|
||||
|
||||
_testParams = [_pos, [_indirectHitRange, _indirectHit], [], [], -4, _depth, 0];
|
||||
[DFUNC(findReflections), 0, _testParams] call cba_fnc_addPerFrameHandler;
|
||||
};
|
@ -1,14 +1,10 @@
|
||||
//fnc_doSpall.sqf
|
||||
#include "script_component.hpp"
|
||||
#ifdef DEBUG_MODE_FULL
|
||||
GVAR(traceFrags) = true;
|
||||
#endif
|
||||
// ACE_player sideChat "WAAAAAAAAAAAAAAAAAAAAA";
|
||||
|
||||
private ["_params", "_hitData", "_initialData", "_hpData", "_object", "_foundObjects", "_index", "_foundObjecsts", "_roundType", "_round", "_caliber", "_explosive", "_idh", "_alive", "_exit", "_vm", "_velocity", "_oldVelocity", "_curVelocity", "_diff", "_polar", "_unitDir", "_spallPos", "_pos1", "_i", "_pos2", "_blah", "_data", "_spallPolar", "_warn", "_c", "_m", "_k", "_gC", "_fragPower", "_fragTypes", "_spread", "_spallCount", "_elev", "_dir", "_vel", "_spallFragVect", "_fragType", "_fragment", "_pos"];
|
||||
|
||||
_params = _this select 0;
|
||||
[(_this select 1)] call cba_fnc_removePerFrameHandler;
|
||||
_hitData = _params select 0;
|
||||
_initialData = GVAR(spallHPData) select (_hitData select 0);
|
||||
_hpData = (_hitData select 1) select (_params select 1);
|
||||
@ -124,6 +120,7 @@ if(_alive || {_caliber >= 2.5} || {(_explosive > 0 && {_idh >= 1})}) then {
|
||||
_fragment = (_fragTypes select _fragType) createVehicleLocal [0,0,10000];
|
||||
_fragment setPosASL _spallPos;
|
||||
_fragment setVelocity _spallFragVect;
|
||||
|
||||
if(GVAR(traceFrags)) then {
|
||||
[ACE_player, _fragment, [1,0.5,0,1]] call FUNC(addTrack);
|
||||
};
|
||||
@ -145,6 +142,7 @@ if(_alive || {_caliber >= 2.5} || {(_explosive > 0 && {_idh >= 1})}) then {
|
||||
_fragment = (_fragTypes select _fragType) createVehicleLocal [0,0,10000];
|
||||
_fragment setPosASL _spallPos;
|
||||
_fragment setVelocity _spallFragVect;
|
||||
|
||||
if(GVAR(traceFrags)) then {
|
||||
[ACE_player, _fragment, [1,0,0,1]] call FUNC(addTrack);
|
||||
};
|
||||
|
130
addons/frag/functions/fnc_findReflections.sqf
Normal file
130
addons/frag/functions/fnc_findReflections.sqf
Normal file
@ -0,0 +1,130 @@
|
||||
//fnc_findReflections.sqf
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_split", "_radi", "_params", "_pos", "_explosiveInfo", "_los", "_nlos", "_zIndex", "_depth", "_indirectHitRange",
|
||||
"_indirectHit", "_distanceCount", "_lastPos", "_test", "_vec", "_testPos", "_buckets", "_excludes", "_bucketIndex", "_bucketPos",
|
||||
"_bucketList", "_c", "_index", "_blist", "_avgX", "_avgY", "_avgZ", "_bpos", "_distance", "_hitFactor", "_hit", "_range", "_refExp",
|
||||
"_rand", "_i", "_x", "_res", "_forEachIndex", "_explosions", "_can", "_dirvec"];
|
||||
|
||||
|
||||
_params = _this select 0;
|
||||
_pos = _params select 0;
|
||||
_explosiveInfo = _params select 1;
|
||||
_los = _params select 2;
|
||||
_nlos = _params select 3;
|
||||
_zIndex = _params select 4;
|
||||
_depth = _params select 5;
|
||||
_rand = _params select 6;
|
||||
|
||||
_split = 15;
|
||||
_radi = (360/_split*_depth);
|
||||
|
||||
// player sideChat format["p: %1", _explosiveInfo];
|
||||
_indirectHitRange = _explosiveInfo select 0;
|
||||
_indirectHit = _explosiveInfo select 1;
|
||||
_distanceCount = (floor _indirectHitRange*4) min 100;
|
||||
|
||||
if(_zIndex < 5) then {
|
||||
_lastPos = _pos;
|
||||
_zAng = _zIndex*20+2;
|
||||
if(_zAng > 80) then {
|
||||
_radi = 1;
|
||||
_zAng = 90;
|
||||
};
|
||||
for "_i" from 0 to _radi do {
|
||||
_test = true;
|
||||
_vec = [1, ((_i*_split)+_rand) mod 360, _zAng] call cba_fnc_polar2vect;
|
||||
for "_x" from 1 to _distanceCount do {
|
||||
_testPos = _pos vectorAdd (_vec vectorMultiply _x);
|
||||
// drop ["\a3\data_f\Cl_basic","","Billboard",1,15,ASLtoATL _testPos,[0,0,0],1,1.275,1.0,0.0,[1],[[1,0,0,1]],[0],0.0,2.0,"","",""];
|
||||
_res = lineIntersectsWith [_pos, _testPos];
|
||||
if(count _res > 0) exitWith {
|
||||
_test = false;
|
||||
_nlos pushBack _lastPos;
|
||||
// {
|
||||
// _x addEventHandler ["HandleDamage", { diag_log text format["this: %1", _this]; }];
|
||||
// } forEach _res;
|
||||
// drop ["\a3\data_f\Cl_basic","","Billboard",1,15,ASLtoATL _testPos,[0,0,0],1,1.275,1.0,0.0,[1],[[1,0,0,1]],[0],0.0,2.0,"","",""];
|
||||
// TEST_PAIRS pushBack [_pos, _lastPos, [1,0,0,1]];
|
||||
|
||||
};
|
||||
// if(terrainIntersectASL [_pos, _testPos]) exitWith {};
|
||||
_lastPos = _testPos;
|
||||
};
|
||||
};
|
||||
_params set[4, _zIndex+1];
|
||||
} else {
|
||||
_depth = _depth + 1;
|
||||
_buckets = [];
|
||||
_excludes = [];
|
||||
_bucketIndex = 0;
|
||||
_bucketPos = nil;
|
||||
_bucketList = nil;
|
||||
_c = 0;
|
||||
while { count(_nlos) != count(_excludes) && _c < (count _nlos) } do {
|
||||
scopeName "mainSearch";
|
||||
{
|
||||
if(!(_forEachIndex in _excludes)) then {
|
||||
_index = _buckets pushBack [_x, [_x]];
|
||||
_excludes pushBack _forEachIndex;
|
||||
_bucketPos = _x;
|
||||
_bucketList = (_buckets select _index) select 1;
|
||||
breakTo "mainSearch";
|
||||
};
|
||||
} forEach _nlos;
|
||||
{
|
||||
if(!(_forEachIndex in _excludes)) then {
|
||||
_testPos = _x;
|
||||
if(_testPos vectorDistanceSqr _bucketPos <= 30) then {
|
||||
_bucketList pushBack _x;
|
||||
_excludes pushBack _forEachIndex;
|
||||
};
|
||||
};
|
||||
} forEach _nlos;
|
||||
_c = _c + 1;
|
||||
};
|
||||
|
||||
// player sideChat format["c: %1", count _buckets];
|
||||
_explosions = [];
|
||||
{
|
||||
_blist = _x select 1;
|
||||
_avgX = 0;
|
||||
_avgY = 0;
|
||||
_avgZ = 0;
|
||||
|
||||
{
|
||||
_avgX = _avgX + (_x select 0);
|
||||
_avgY = _avgY + (_x select 1);
|
||||
_avgZ = _avgZ + (_x select 2);
|
||||
} forEach _blist;
|
||||
_c = count _blist;
|
||||
_bpos = [_avgX/_c, _avgY/_c, _avgZ/_c];
|
||||
|
||||
_distance = _pos vectorDistance _bpos;
|
||||
_hitFactor = 1-(((_distance/(_indirectHitRange*4)) min 1) max 0);
|
||||
// _hitFactor = 1/(_distance^2);
|
||||
_hit = _indirectHit*_hitFactor;
|
||||
_hit = (floor (_hit/4)) min 500;
|
||||
_hit = _hit - (_hit%10);
|
||||
_range = (floor (_indirectHitRange-(_distance/4))) min 100;
|
||||
_range = _range - (_range%2);
|
||||
|
||||
if(_hit >= 10 && _range > 0) then {
|
||||
// TEST_ICONS pushBack [_bpos, format["h: %1, r: %2, hf: %3 d: %4 ihr: %5", _hit, _range, _hitFactor, _distance, _indirectHitRange*4]];
|
||||
// TEST_PAIRS pushBack [_pos, _bpos, [1,0,0,1]];
|
||||
_refExp = format["ace_explosion_reflection_%1_%2", _range, _hit];
|
||||
// _refExp createVehicle (ASLtoATL _bpos);
|
||||
// drop ["\a3\data_f\Cl_basic","","Billboard",1,15,ASLtoATL _bpos,[0,0,0],1,1.275,1.0,0.0,[1],[[1,0,0,1]],[0],0.0,2.0,"","",""];
|
||||
|
||||
_explosions pushBack [_refExp, _bpos, _hit, _distance, _indirectHitRange/4, _depth];
|
||||
|
||||
};
|
||||
if(count _explosions > (_radi*2)/_depth) exitWith {};
|
||||
} forEach _buckets;
|
||||
// _can = "Land_Bricks_V4_F" createVehicle (ASLtoATL _pos);
|
||||
// _dirvec = _pos vectorFromTo ((ATLtoASL (player modelToWorldVisual (player selectionPosition "Spine3"))));
|
||||
// _dirvec = _dirvec vectorMultiply 100;
|
||||
// _can setVelocity _dirvec;
|
||||
[DFUNC(doExplosions), 0, [_explosions, 0]] call cba_fnc_addPerFrameHandler;
|
||||
[(_this select 1)] call cba_fnc_removePerFrameHandler;
|
||||
};
|
@ -1,58 +1,9 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_enabled", "_gun", "_type", "_round", "_doFragTrack", "_doSpall", "_spallTrack", "_spallTrackID"];
|
||||
|
||||
if (!GVAR(enabled)) exitWith {};
|
||||
private["_gun", "_type", "_round"];
|
||||
|
||||
_gun = _this select 0;
|
||||
_type = _this select 4;
|
||||
_round = _this select 6;
|
||||
|
||||
_enabled = getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(enabled));
|
||||
if(_enabled < 1) exitWith {};
|
||||
[_gun, _type, _round] call FUNC(addPfhRound);
|
||||
|
||||
if(_round in GVAR(blackList)) exitWith {
|
||||
GVAR(blackList) = GVAR(blackList) - [_round];
|
||||
};
|
||||
|
||||
|
||||
_doFragTrack = false;
|
||||
if(_gun == ACE_player) then {
|
||||
_doFragTrack = true;
|
||||
} else {
|
||||
if((gunner _gun) == ACE_player) then {
|
||||
_doFragTrack = true;
|
||||
} else {
|
||||
if(local _gun && {!(isPlayer (gunner _gun))} && {!(isPlayer _gun)}) then {
|
||||
_doFragTrack = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
_doSpall = false;
|
||||
if(_doSpall) then {
|
||||
if(GVAR(spallIsTrackingCount) <= 0) then {
|
||||
GVAR(spallHPData) = [];
|
||||
};
|
||||
if(GVAR(spallIsTrackingCount) > 5) then {
|
||||
// ACE_player sideChat "LIMT!";
|
||||
_doSpall = false;
|
||||
} else {
|
||||
GVAR(spallIsTrackingCount) = GVAR(spallIsTrackingCount) + 1;
|
||||
};
|
||||
};
|
||||
// ACE_player sideChat format["c: %1", GVAR(spallIsTrackingCount)];
|
||||
|
||||
#ifdef DEBUG_MODE_FULL
|
||||
[ACE_player, _round, [1,0,0,1]] call FUNC(addTrack);
|
||||
#endif
|
||||
|
||||
if(_doFragTrack && alive _round) then {
|
||||
GVAR(trackedObjects) pushBack _round;
|
||||
_spallTrack = [];
|
||||
_spallTrackID = [];
|
||||
[DFUNC(trackFragRound), 0, [_round, (getPosASL _round), (velocity _round), _type, time, _gun, _doSpall, _spallTrack, _spallTrackID]] call cba_fnc_addPerFrameHandler;
|
||||
if(_doSpall) then {
|
||||
[_round, 2, _spallTrack, _spallTrackID] call FUNC(spallTrack);
|
||||
};
|
||||
// ACE_player sideChat "WTF2";
|
||||
};
|
||||
|
@ -106,8 +106,9 @@ _fragArcs set[360, 0];
|
||||
ACE_player sideChat format["_fragRange: %1", _fragRange];
|
||||
ACE_player sideChat format["_objects: %1", _objects];
|
||||
#endif
|
||||
_doRandom = false;
|
||||
_doRandom = true;
|
||||
if(_isArmed && (count _objects) > 0) then {
|
||||
[_lastPos, _shellType] call FUNC(doReflections);
|
||||
{
|
||||
//if(random(1) > 0.5) then {
|
||||
_target = _x;
|
||||
@ -162,11 +163,8 @@ if(_isArmed && (count _objects) > 0) then {
|
||||
_fragObj setPosASL _lastPos;
|
||||
_fragObj setVectorDir _vec;
|
||||
_fragObj setVelocity _vel;
|
||||
#ifdef DEBUG_MODE_FULL
|
||||
GVAR(TOTALFRAGS) = GVAR(TOTALFRAGS) + 1;
|
||||
GVAR(traceFrags) = true;
|
||||
#endif
|
||||
if(GVAR(traceFrags)) then {
|
||||
GVAR(TOTALFRAGS) = GVAR(TOTALFRAGS) + 1;
|
||||
[ACE_player, _fragObj, [1,0,0,1]] call FUNC(addTrack);
|
||||
};
|
||||
_fragCount = _fragCount + 1;
|
||||
@ -180,7 +178,7 @@ if(_isArmed && (count _objects) > 0) then {
|
||||
if(_fragCount > MAX_FRAG_COUNT) exitWith {};
|
||||
} forEach _objects;
|
||||
if(_fragCount > MAX_FRAG_COUNT) exitWith {};
|
||||
_randomCount = (ceil((MAX_FRAG_COUNT-_fragCount)*0.1)) max 0;
|
||||
_randomCount = ((ceil((MAX_FRAG_COUNT-_fragCount)*0.1)) max 0)+20;
|
||||
_sectorSize = 360 / (_randomCount max 1);
|
||||
// _doRandom = false;
|
||||
if(_doRandom) then {
|
||||
@ -199,16 +197,15 @@ if(_isArmed && (count _objects) > 0) then {
|
||||
_fragObj setPosASL _lastPos;
|
||||
_fragObj setVectorDir _vec;
|
||||
_fragObj setVelocity _vel;
|
||||
#ifdef DEBUG_MODE_FULL
|
||||
GVAR(TOTALFRAGS) = GVAR(TOTALFRAGS) + 1;
|
||||
GVAR(traceFrags) = true;
|
||||
#endif
|
||||
|
||||
if(GVAR(traceFrags)) then {
|
||||
GVAR(TOTALFRAGS) = GVAR(TOTALFRAGS) + 1;
|
||||
[ACE_player, _fragObj, [1,0.5,0,1]] call FUNC(addTrack);
|
||||
};
|
||||
_fragCount = _fragCount + 1;
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
// #ifdef DEBUG_MODE_FULL
|
||||
// ACE_player sideChat format["total frags: %1", GVAR(TOTALFRAGS)];
|
||||
|
58
addons/frag/functions/fnc_masterPFH.sqf
Normal file
58
addons/frag/functions/fnc_masterPFH.sqf
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Author: jaynus
|
||||
*
|
||||
* Master single PFH abstraction for all rounds being tracked by frag/spall
|
||||
*
|
||||
* Arguments:
|
||||
*
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*/
|
||||
//#define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
//PARAMS_2(_pfhArgs,_handle);
|
||||
|
||||
if (!GVAR(enabled)) exitWith {};
|
||||
|
||||
private["_gcIndex"];
|
||||
_gcIndex = [];
|
||||
|
||||
_iter = 0;
|
||||
while { (count GVAR(objects)) > 0 && { _iter < GVAR(MaxTrackPerFrame) } } do {
|
||||
private["_object", "_args"];
|
||||
if(GVAR(lastIterationIndex) >= (count GVAR(objects))) then {
|
||||
GVAR(lastIterationIndex) = 0;
|
||||
};
|
||||
_object = GVAR(objects) select GVAR(lastIterationIndex);
|
||||
|
||||
if(!isNil "_object") then {
|
||||
if(isNull _object) then {
|
||||
_gcIndex pushBack GVAR(lastIterationIndex);
|
||||
} else {
|
||||
_args = GVAR(arguments) select GVAR(lastIterationIndex);
|
||||
|
||||
if(!(_args call FUNC(pfhRound))) then {
|
||||
_gcIndex pushBack GVAR(lastIterationIndex); // Add it to the GC if it returns false
|
||||
};
|
||||
// If its not alive anymore, remove it from the queue, it already ran once on dead
|
||||
if(!alive _object) then {
|
||||
_gcIndex pushBack GVAR(lastIterationIndex);
|
||||
};
|
||||
};
|
||||
};
|
||||
_iter = _iter + 1;
|
||||
GVAR(lastIterationIndex) = GVAR(lastIterationIndex) + 1;
|
||||
};
|
||||
|
||||
// clean up dead object references
|
||||
private["_deletionCount", "_deleteIndex"];
|
||||
_deletionCount = 0;
|
||||
{
|
||||
TRACE_1("GC Projectile", _x);
|
||||
_deleteIndex = _x - _deletionCount;
|
||||
GVAR(objects) deleteAt _deleteIndex;
|
||||
GVAR(arguments) deleteAt _deleteIndex;
|
||||
|
||||
_deletionCount = _deletionCount + 1;
|
||||
} forEach _gcIndex;
|
49
addons/frag/functions/fnc_pfhRound.sqf
Normal file
49
addons/frag/functions/fnc_pfhRound.sqf
Normal file
@ -0,0 +1,49 @@
|
||||
#include "script_component.hpp"
|
||||
private ["_round", "_lastPos", "_lastVel", "_type", "_firedFrame", "_doSpall", "_spallTrack", "_foundObjectHPIds", "_skip", "_explosive", "_indirectRange", "_force", "_fragPower"];
|
||||
_round = _this select 0;
|
||||
_lastPos = _this select 1;
|
||||
_lastVel = _this select 2;
|
||||
_type = _this select 3;
|
||||
_firedFrame = _this select 4;
|
||||
_doSpall = _this select 6;
|
||||
_spallTrack = _this select 7;
|
||||
_foundObjectHPIds = _this select 8;
|
||||
_skip = _this select 9;
|
||||
_explosive = _this select 10;
|
||||
_indirectRange = _this select 11;
|
||||
_force = _this select 12;
|
||||
_fragPower = _this select 13;
|
||||
|
||||
if(_round in GVAR(blackList)) exitWith {
|
||||
false
|
||||
};
|
||||
|
||||
if (!alive _round) then {
|
||||
if((diag_frameno - _firedFrame) > 1) then {
|
||||
if(_skip == 0) then {
|
||||
if((_explosive > 0.5 && {_indirectRange >= 4.5} && {_fragPower >= 35}) || {_force == 1} ) then {
|
||||
[QGVAR(frag_eh), _this] call ace_common_fnc_serverEvent;
|
||||
};
|
||||
};
|
||||
};
|
||||
if(_doSpall) then {
|
||||
GVAR(spallIsTrackingCount) = GVAR(spallIsTrackingCount) - 1;
|
||||
// diag_log text format["F: %1", _foundObjectHPIds];
|
||||
{
|
||||
if(!isNil "_x") then {
|
||||
_x removeEventHandler ["hitPart", _foundObjectHPIds select _forEachIndex];
|
||||
};
|
||||
} forEach _spallTrack;
|
||||
};
|
||||
} else {
|
||||
|
||||
_params set[1, (getPosASL _round)];
|
||||
_params set[2, (velocity _round)];
|
||||
if(_doSpall) then {
|
||||
private["_scale"];
|
||||
_scale = ( (count GVAR(objects)) / GVAR(MaxTrackPerFrame) ) max 0.1;
|
||||
[_round, _scale, _spallTrack, _foundObjectHPIds] call FUNC(spallTrack);
|
||||
};
|
||||
};
|
||||
|
||||
true
|
9
addons/frag/functions/fnc_removePfhRound.sqf
Normal file
9
addons/frag/functions/fnc_removePfhRound.sqf
Normal file
@ -0,0 +1,9 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
// THIS FUNCTION SHOULD NOT BE USED BECAUSE IT CAUSES AN SEARCH AND REBUILD
|
||||
|
||||
if(_round in GVAR(blackList)) then {
|
||||
GVAR(blackList) = GVAR(blackList) - [_round];
|
||||
};
|
||||
|
||||
GVAR(objects) = GVAR(objects) - [_round];
|
@ -22,7 +22,7 @@ if (count _intersectsWith > 0) then {
|
||||
if(!(_x in _foundObjects)) then {
|
||||
// diag_log text format["Adding HP: %1", _x];
|
||||
_index = (count GVAR(spallHPData));
|
||||
_hpId = _x addEventHandler ["hitPart", format["[%1, _this] call " + QUOTE(FUNC(spallHP)), _index]];
|
||||
_hpId = _x addEventHandler ["hitPart", compile format["[%1, _this] call " + QUOTE(FUNC(spallHP)), _index]];
|
||||
_foundObjects set[(count _foundObjects), _x];
|
||||
_foundObjectHPIds set[(count _foundObjectHPIds), _hpId];
|
||||
_data = [_hpId, _x, typeOf _round, _round, _curPos, _velocity, 0, _foundObjects, _foundObjectHPIds];
|
||||
|
@ -1,52 +0,0 @@
|
||||
//fnc_trackFragRound.sqf
|
||||
#include "script_component.hpp"
|
||||
private ["_params", "_round", "_lastPos", "_lastVel", "_type", "_time", "_doSpall", "_spallTrack", "_foundObjectHPIds", "_skip", "_explosive", "_indirectRange", "_force", "_fragPower"];
|
||||
_params = _this select 0;
|
||||
_round = _params select 0;
|
||||
_lastPos = _params select 1;
|
||||
_lastVel = _params select 2;
|
||||
_type = _params select 3;
|
||||
_time = _params select 4;
|
||||
_doSpall = _params select 6;
|
||||
_spallTrack = _params select 7;
|
||||
_foundObjectHPIds = _params select 8;
|
||||
|
||||
if (!alive _round) then {
|
||||
[_this select 1] call cba_fnc_removePerFrameHandler;
|
||||
if(_time != time && {_round in GVAR(trackedObjects)} && {!(_round in GVAR(blackList))}) then {
|
||||
GVAR(trackedObjects) = GVAR(trackedObjects) - [_round];
|
||||
_skip = getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(skip));
|
||||
if(_skip == 0) then {
|
||||
_explosive = getNumber (configFile >> "CfgAmmo" >> _type >> "explosive");
|
||||
_indirectRange = getNumber (configFile >> "CfgAmmo" >> _type >> "indirectHitRange");
|
||||
_force = getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(force));
|
||||
_fragPower = getNumber(configFile >> "CfgAmmo" >> _type >> "indirecthit")*(sqrt(_indirectRange));
|
||||
if((_explosive > 0.5 && {_indirectRange >= 4.5} && {_fragPower >= 35}) || {_force == 1} ) then {
|
||||
[QGVAR(frag_eh), _params] call ace_common_fnc_serverEvent;
|
||||
GVAR(trackedObjects) = GVAR(trackedObjects) - [_round];
|
||||
};
|
||||
};
|
||||
};
|
||||
if(_doSpall) then {
|
||||
GVAR(spallIsTrackingCount) = GVAR(spallIsTrackingCount) - 1;
|
||||
// diag_log text format["F: %1", _foundObjectHPIds];
|
||||
{
|
||||
if(!isNil "_x") then {
|
||||
_x removeEventHandler ["hitPart", _foundObjectHPIds select _forEachIndex];
|
||||
};
|
||||
} forEach _spallTrack;
|
||||
};
|
||||
} else {
|
||||
if(!(_round in GVAR(trackedObjects)) || {_round in GVAR(blackList)}) then {
|
||||
[_this select 1] call cba_fnc_removePerFrameHandler;
|
||||
if(_round in GVAR(blackList)) then {
|
||||
GVAR(blackList) = GVAR(blackList) - [_round];
|
||||
};
|
||||
};
|
||||
|
||||
_params set[1, (getPosASL _round)];
|
||||
_params set[2, (velocity _round)];
|
||||
if(_doSpall) then {
|
||||
[_round, 1, _spallTrack, _foundObjectHPIds] call FUNC(spallTrack);
|
||||
};
|
||||
};
|
@ -1,17 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project name="ACE">
|
||||
<Package name="Frag">
|
||||
<Key ID="STR_DN_ACE_FRAG">
|
||||
<English>Disable Fragmentation</English>
|
||||
<German>Keine Schrapnelle</German>
|
||||
<Czech>Zakázat fragmentaci granátů</Czech>
|
||||
<Spanish>Desactivar fragmentación</Spanish>
|
||||
<Polish>Wyłącz fragmentację odłamków</Polish>
|
||||
<Russian>Выключить разлёт осколков</Russian>
|
||||
<French>Désactive la fragmentation</French>
|
||||
<Hungarian>Repeszek letiltása</Hungarian>
|
||||
<Italian>Disattiva la frammentazione</Italian>
|
||||
<Portuguese>Desabilitar Fragmentação</Portuguese>
|
||||
<Key ID="STR_ACE_frag_EnableFrag">
|
||||
<English>Fragmentation Simulation</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_frag_EnableFrag_Desc">
|
||||
<English>Enable the ACE Fragmentation Simulation</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_frag_EnableSpall">
|
||||
<English>Spalling Simulation</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_frag_EnableSpall_Desc">
|
||||
<English>Enable the ACE Spalling Simulation</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_frag_MaxTrack">
|
||||
<English>Maximum Projectiles Tracked</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_frag_MaxTrack_Desc">
|
||||
<English>This setting controls the maximum amount of projectiles the fragmentation and spalling system will track at any given time. If more projectiles are fired, they will not be tracked. Lower this setting if you do not want FPS drops at high-count projectile scenarios ( >200 rounds in the air at once)</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_frag_MaxTrackPerFrame">
|
||||
<English>Maximum Projectiles Per Frame</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_frag_MaxTrackPerFrame_Desc">
|
||||
<English>The number of spall track calculations to perform in any given frame. This helps spread the FPS impact of tracking spall rounds across multiple frames, limiting its impact even further.</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_frag_EnableDebugTrace">
|
||||
<English>(SP Only) Frag/Spall Debug Tracing</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_frag_EnableDebugTrace_Desc">
|
||||
<English>(SP Only) Requires a mission/editor restart. Enables visual tracing of fragmentation and spalling rounds in SP game mode only.</English>
|
||||
</Key>
|
||||
</Package>
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user