mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Initial commit of frag/spalling optimization rewrite. Now tracks in single PFH, with index-based referencing instead of searches. TODO: Break spall calculation up to multiple frames. Needs testing.
This commit is contained in:
parent
021d277b12
commit
553942bbc7
@ -1,7 +1,14 @@
|
||||
class ACE_Settings {
|
||||
class GVAR(enabled) {
|
||||
displayName = "Frag System";
|
||||
description = "Enables the shrapnel system for explosives";
|
||||
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 = 1;
|
||||
};
|
||||
|
@ -2,4 +2,6 @@
|
||||
|
||||
if(isServer) then {
|
||||
[QGVAR(frag_eh), { _this call FUNC(frago); }] call ace_common_fnc_addEventHandler;
|
||||
};
|
||||
};
|
||||
|
||||
[FUNC(masterPFH), 0, []] call CBA_fnc_addPerFrameHandler;
|
@ -6,11 +6,9 @@ PREP(doSpall);
|
||||
PREP(fired);
|
||||
PREP(frago);
|
||||
PREP(spallTrack);
|
||||
PREP(trackFragRound);
|
||||
|
||||
GVAR(blackList) = [];
|
||||
GVAR(traceFrags) = false;
|
||||
GVAR(trackedObjects) = [];
|
||||
|
||||
GVAR(TOTALFRAGS) = 0;
|
||||
|
||||
@ -32,4 +30,14 @@ PREP(startTracing);
|
||||
PREP(stopTracing);
|
||||
PREP(trackTrace);
|
||||
|
||||
// New tracking mechanisms
|
||||
PREP(masterPFH);
|
||||
PREP(pfhRound);
|
||||
PREP(addPfhRound);
|
||||
PREP(removePfhRound); // THIS SHOULD ABE USED SPARINGLY
|
||||
|
||||
GVAR(objects) = [];
|
||||
GVAR(objectTypes) = [];
|
||||
GVAR(arguments) = [];
|
||||
|
||||
ADDON = true;
|
||||
|
71
addons/frag/functions/fnc_addPfhRound.sqf
Normal file
71
addons/frag/functions/fnc_addPfhRound.sqf
Normal file
@ -0,0 +1,71 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_enabled", "_gun", "_type", "_round", "_doFragTrack", "_doSpall", "_spallTrack", "_spallTrackID"];
|
||||
|
||||
if (!GVAR(enabled)) exitWith {};
|
||||
|
||||
_gun = _this select 0;
|
||||
_type = _this select 1;
|
||||
_round = _this select 2;
|
||||
|
||||
_enabled = getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(enabled));
|
||||
if(_enabled < 1) exitWith {};
|
||||
|
||||
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;
|
||||
};
|
||||
};
|
||||
};
|
||||
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)];
|
||||
|
||||
#ifdef DEBUG_MODE_FULL
|
||||
[ACE_player, _round, [1,0,0,1]] call FUNC(addTrack);
|
||||
#endif
|
||||
|
||||
// We only do the single track object check here.
|
||||
if(_doFragTrack && alive _round && {!(_round in GVAR(objects))} ) then {
|
||||
_spallTrack = [];
|
||||
_spallTrackID = [];
|
||||
|
||||
private["_args"];
|
||||
_args = [_round, (getPosASL _round), (velocity _round), _type, time, _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")))))
|
||||
];
|
||||
|
||||
GVAR(objects) pushBack _round;
|
||||
GVAR(arguments) pushBack _args;
|
||||
|
||||
if(_doSpall) then {
|
||||
[_round, 2, _spallTrack, _spallTrackID] call FUNC(spallTrack);
|
||||
};
|
||||
// ACE_player sideChat "WTF2";
|
||||
};
|
||||
|
||||
|
||||
|
@ -124,6 +124,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 +146,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);
|
||||
};
|
||||
|
@ -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";
|
||||
};
|
||||
|
46
addons/frag/functions/fnc_masterPFH.sqf
Normal file
46
addons/frag/functions/fnc_masterPFH.sqf
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Author: jaynus
|
||||
*
|
||||
* Master single PFH abstraction for all rounds being tracked by frag/spall
|
||||
*
|
||||
* Arguments:
|
||||
*
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
PARAMS_2(_pfhArgs,_handle);
|
||||
|
||||
if (!GVAR(enabled)) exitWith {};
|
||||
|
||||
private["_gcIndex"];
|
||||
_gcIndex = [];
|
||||
{
|
||||
private["_object", "_args"];
|
||||
_object = _x;
|
||||
if(!isNil "_object") then {
|
||||
if(isNull _object) then {
|
||||
_gcIndex pushBack _forEachIndex;
|
||||
} else {
|
||||
_args = GVAR(arguments) select _forEachIndex;
|
||||
|
||||
_args call FUNC(pfhRound);
|
||||
};
|
||||
|
||||
if(!alive _object) then {
|
||||
_gcIndex pushBack _forEachIndex;
|
||||
};
|
||||
};
|
||||
} forEach GVAR(objects);
|
||||
|
||||
// clean up dead object references
|
||||
private["_deletionCount", "_deleteIndex"];
|
||||
_deletionCount = 0;
|
||||
{
|
||||
_deleteIndex = _gcIndex - _deletionCount;
|
||||
GVAR(objects) deleteAt _deleteIndex;
|
||||
GVAR(arguments) deleteAt _deleteIndex;
|
||||
|
||||
_deletionCount = _deletionCount + 1;
|
||||
} forEach _gcIndex;
|
@ -1,4 +1,3 @@
|
||||
//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;
|
||||
@ -10,20 +9,17 @@ _time = _params select 4;
|
||||
_doSpall = _params select 6;
|
||||
_spallTrack = _params select 7;
|
||||
_foundObjectHPIds = _params select 8;
|
||||
_skip = _params select 9;
|
||||
_explosive = _params select 10;
|
||||
_indirectRange = _params select 11;
|
||||
_force = _params select 12;
|
||||
_fragPower = _params select 13;
|
||||
|
||||
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(_time != time && {!(_round in GVAR(blackList))}) then {
|
||||
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];
|
||||
};
|
||||
};
|
||||
};
|
||||
@ -37,11 +33,8 @@ if (!alive _round) then {
|
||||
} 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];
|
||||
};
|
||||
if(_round in GVAR(blackList)) exitWith {
|
||||
[_round] call FUNC(removePfhRound);
|
||||
};
|
||||
|
||||
_params set[1, (getPosASL _round)];
|
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];
|
@ -1,17 +1,21 @@
|
||||
<?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>
|
||||
</Package>
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user