Merge pull request #1686 from acemod/fixFrag

Fix frag
This commit is contained in:
Glowbal 2015-07-26 23:42:16 +02:00
commit 41196c15aa
16 changed files with 65 additions and 178 deletions

View File

@ -6,7 +6,7 @@ if(GVAR(EnableDebugTrace) && !isMultiplayer) then {
};
if(isServer) then {
[QGVAR(frag_eh), { _this call FUNC(frago); }] call ace_common_fnc_addEventHandler;
[QGVAR(frag_eh), { _this call FUNC(frago); }] call EFUNC(common,addEventHandler);
};
[FUNC(masterPFH), 0, []] call CBA_fnc_addPerFrameHandler;

View File

@ -1,4 +1,4 @@
#include "script_component.hpp"
private ["_round"];
_round = _this select 0;
GVAR(blackList) set[(count GVAR(blackList)), _round];
GVAR(blackList) set [(count GVAR(blackList)), _round];

View File

@ -1,8 +1,9 @@
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
private ["_enabled","_doFragTrack", "_doSpall", "_spallTrack", "_spallTrackID"];
private ["_enabled", "_doSpall", "_spallTrack", "_spallTrackID"];
PARAMS_3(_gun,_type,_round);
DEFAULT_PARAM(3,_doFragTrack,false);
if (!GVAR(enabled)) exitWith {};
@ -16,7 +17,6 @@ if(_round in GVAR(blackList)) exitWith {
// Exit on max track
if( (count GVAR(objects)) > GVAR(MaxTrack)) exitWith { };
_doFragTrack = false;
if(_gun == ACE_player) then {
_doFragTrack = true;
} else {
@ -28,14 +28,16 @@ if(_gun == ACE_player) then {
};
};
};
_doSpall = false;
if(GVAR(SpallEnabled)) then {
if(GVAR(spallIsTrackingCount) <= 0) then {
GVAR(spallHPData) = [];
};
if(GVAR(spallIsTrackingCount) > 5) then {
// ACE_player sideChat "LIMT!";
_doSpall = false;
} else {
_doSpall = true;
GVAR(spallIsTrackingCount) = GVAR(spallIsTrackingCount) + 1;
};
};
@ -46,30 +48,27 @@ if(GVAR(autoTrace)) then {
};
// We only do the single track object check here.
// We should do an {!(_round in GVAR(objects))}
// 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")))))
];
(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";
};

View File

@ -2,12 +2,11 @@
#include "script_component.hpp"
// 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"];
private ["_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;
_hitData = _params select 0;
_hitData = _this select 0;
_initialData = GVAR(spallHPData) select (_hitData select 0);
_hpData = (_hitData select 1) select (_params select 1);
_hpData = (_hitData select 1) select (_this select 1);
_object = _hpData select 0;
@ -149,4 +148,4 @@ if(_alive || {_caliber >= 2.5} || {(_explosive > 0 && {_idh >= 1})}) then {
};
};
};
};
};

View File

@ -1,11 +1,7 @@
//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"];
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", "_zAng"];
_params = _this select 0;
_pos = _params select 0;
@ -46,7 +42,7 @@ if(_zIndex < 5) then {
// } 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;
@ -91,7 +87,7 @@ if(_zIndex < 5) then {
_avgX = 0;
_avgY = 0;
_avgZ = 0;
{
_avgX = _avgX + (_x select 0);
_avgY = _avgY + (_x select 1);
@ -99,7 +95,7 @@ if(_zIndex < 5) then {
} 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);
@ -108,16 +104,16 @@ if(_zIndex < 5) then {
_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;

View File

@ -1,58 +1,8 @@
#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 {};
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, ACE_time, _gun, _doSpall, _spallTrack, _spallTrackID]] call cba_fnc_addPerFrameHandler;
if(_doSpall) then {
[_round, 2, _spallTrack, _spallTrackID] call FUNC(spallTrack);
};
// ACE_player sideChat "WTF2";
};
[_gun, _type, _round] call FUNC(addPfhRound);

View File

@ -4,7 +4,7 @@
* Master single PFH abstraction for all rounds being tracked by frag/spall
*
* Arguments:
*
*
*
* Return Value:
* None
@ -15,30 +15,22 @@
if (!GVAR(enabled)) exitWith {};
private["_gcIndex"];
private["_gcIndex", "_iter"];
_gcIndex = [];
_iter = 0;
while { (count GVAR(objects)) > 0 && { _iter < GVAR(MaxTrackPerFrame) } } do {
while { (count GVAR(objects)) > 0 && { _iter < (GVAR(MaxTrackPerFrame) min (count GVAR(objects))) } } 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);
};
_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
};
};
_iter = _iter + 1;
@ -53,6 +45,6 @@ _deletionCount = 0;
_deleteIndex = _x - _deletionCount;
GVAR(objects) deleteAt _deleteIndex;
GVAR(arguments) deleteAt _deleteIndex;
_deletionCount = _deletionCount + 1;
} forEach _gcIndex;
} forEach _gcIndex;

View File

@ -14,15 +14,15 @@ _indirectRange = _this select 11;
_force = _this select 12;
_fragPower = _this select 13;
if(_round in GVAR(blackList)) exitWith {
if(_round in GVAR(blackList)) exitWith {
false
};
if (!alive _round) then {
if((diag_frameno - _firedFrame) > 1) then {
if (!alive _round) exitWith {
if((diag_frameno - _firedFrame) > 1) then { //skip if deleted within a single frame
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;
[QGVAR(frag_eh), _this] call EFUNC(common,serverEvent);
};
};
};
@ -35,15 +35,16 @@ if (!alive _round) then {
};
} 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);
};
false
};
true
_this set[1, (getPosASL _round)];
_this 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

View File

@ -2,8 +2,10 @@
// THIS FUNCTION SHOULD NOT BE USED BECAUSE IT CAUSES AN SEARCH AND REBUILD
PARAMS_1(_round);
if(_round in GVAR(blackList)) then {
GVAR(blackList) = GVAR(blackList) - [_round];
};
GVAR(objects) = GVAR(objects) - [_round];
GVAR(objects) = GVAR(objects) - [_round];

View File

@ -11,4 +11,4 @@ if(IS_ARRAY((_this select 0))) then {
_ret = false;
};
};
_ret
_ret

View File

@ -21,7 +21,7 @@ if ((_this select 0) <= (count GVAR(spallHPData))) then {
// diag_log text format["%1: %2", _forEachIndex, _x];
// } forEach _hp;
// } forEach (_this select 1);
[DFUNC(doSpall), 0, [_this, _forEachIndex]] call cba_fnc_addPerFrameHandler;
[DFUNC(doSpall), [_this, _forEachIndex]] call EFUNC(common,execNextFrame);
// player sideChat "WEEE";
} forEach (_this select 1);
};

View File

@ -2,4 +2,4 @@
if(!GVAR(tracesStarted)) then {
GVAR(tracesStarted) = true;
GVAR(traceID) = [FUNC(drawTraces), 0, []] call cba_fnc_addPerFrameHandler;
};
};

View File

@ -2,4 +2,4 @@
if(GVAR(tracesStarted)) then {
GVAR(tracesStarted) = false;
[GVAR(traceID)] call cba_fnc_removePerFrameHandler;
};
};

View File

@ -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 != ACE_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);
};
};

View File

@ -8,7 +8,7 @@ _index = _params select 1;
if (alive _tracerObj && (count GVAR(traces)) > 0) then {
_data = GVAR(traces) select _index;
_positions = _data select 4;
_positions set[(count _positions), [(getPos _tracerObj), vectorMagnitude (velocity _tracerObj)]];
_positions set [(count _positions), [(getPos _tracerObj), vectorMagnitude (velocity _tracerObj)]];
} else {
[(_this select 1)] call cba_fnc_removePerFrameHandler;
};

View File

@ -127,9 +127,9 @@ if (_activated) then {
_projectile setvelocity _velocity;
if (_attach) then {_projectile attachto [_logic,[0,0,_altitude]];};
// Added by ace_zeus for ace_frag compatibility
if (!isnil "ace_frag_fnc_addManualTrack") then {
[_projectile] call ace_frag_fnc_addManualTrack
// Added by ace_zeus for ace_frag compatibility
if (!isnil QEFUNC(frag,addPfhRound)) then {
[objNull, _ammo, _projectile, true] call EFUNC(frag,addPfhRound);
};
//--- Play sound