Merge pull request #1686 from acemod/fixFrag

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

View File

@ -6,7 +6,7 @@ if(GVAR(EnableDebugTrace) && !isMultiplayer) then {
}; };
if(isServer) 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; [FUNC(masterPFH), 0, []] call CBA_fnc_addPerFrameHandler;

View File

@ -1,4 +1,4 @@
#include "script_component.hpp" #include "script_component.hpp"
private ["_round"]; private ["_round"];
_round = _this select 0; _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 //#define DEBUG_MODE_FULL
#include "script_component.hpp" #include "script_component.hpp"
private ["_enabled","_doFragTrack", "_doSpall", "_spallTrack", "_spallTrackID"]; private ["_enabled", "_doSpall", "_spallTrack", "_spallTrackID"];
PARAMS_3(_gun,_type,_round); PARAMS_3(_gun,_type,_round);
DEFAULT_PARAM(3,_doFragTrack,false);
if (!GVAR(enabled)) exitWith {}; if (!GVAR(enabled)) exitWith {};
@ -16,7 +17,6 @@ if(_round in GVAR(blackList)) exitWith {
// Exit on max track // Exit on max track
if( (count GVAR(objects)) > GVAR(MaxTrack)) exitWith { }; if( (count GVAR(objects)) > GVAR(MaxTrack)) exitWith { };
_doFragTrack = false;
if(_gun == ACE_player) then { if(_gun == ACE_player) then {
_doFragTrack = true; _doFragTrack = true;
} else { } else {
@ -28,14 +28,16 @@ if(_gun == ACE_player) then {
}; };
}; };
}; };
_doSpall = false;
if(GVAR(SpallEnabled)) then { if(GVAR(SpallEnabled)) then {
if(GVAR(spallIsTrackingCount) <= 0) then { if(GVAR(spallIsTrackingCount) <= 0) then {
GVAR(spallHPData) = []; GVAR(spallHPData) = [];
}; };
if(GVAR(spallIsTrackingCount) > 5) then { if(GVAR(spallIsTrackingCount) > 5) then {
// ACE_player sideChat "LIMT!"; // ACE_player sideChat "LIMT!";
_doSpall = false;
} else { } else {
_doSpall = true;
GVAR(spallIsTrackingCount) = GVAR(spallIsTrackingCount) + 1; GVAR(spallIsTrackingCount) = GVAR(spallIsTrackingCount) + 1;
}; };
}; };
@ -55,12 +57,12 @@ if(_doFragTrack && alive _round) then {
private["_args"]; private["_args"];
_args = [_round, (getPosASL _round), (velocity _round), _type, diag_frameno, _gun, _doSpall, _spallTrack, _spallTrackID, _args = [_round, (getPosASL _round), (velocity _round), _type, diag_frameno, _gun, _doSpall, _spallTrack, _spallTrackID,
(getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(skip))), (getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(skip))),
(getNumber (configFile >> "CfgAmmo" >> _type >> "explosive")), (getNumber (configFile >> "CfgAmmo" >> _type >> "explosive")),
(getNumber (configFile >> "CfgAmmo" >> _type >> "indirectHitRange")), (getNumber (configFile >> "CfgAmmo" >> _type >> "indirectHitRange")),
(getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(force))), (getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(force))),
(getNumber(configFile >> "CfgAmmo" >> _type >> "indirecthit")*(sqrt((getNumber (configFile >> "CfgAmmo" >> _type >> "indirectHitRange"))))) (getNumber(configFile >> "CfgAmmo" >> _type >> "indirecthit")*(sqrt((getNumber (configFile >> "CfgAmmo" >> _type >> "indirectHitRange")))))
]; ];
TRACE_1("Initializing track", _round); TRACE_1("Initializing track", _round);
GVAR(objects) pushBack _round; GVAR(objects) pushBack _round;
GVAR(arguments) pushBack _args; GVAR(arguments) pushBack _args;
@ -70,6 +72,3 @@ if(_doFragTrack && alive _round) then {
}; };
// ACE_player sideChat "WTF2"; // ACE_player sideChat "WTF2";
}; };

View File

@ -2,12 +2,11 @@
#include "script_component.hpp" #include "script_component.hpp"
// ACE_player sideChat "WAAAAAAAAAAAAAAAAAAAAA"; // 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 = _this select 0;
_hitData = _params select 0;
_initialData = GVAR(spallHPData) select (_hitData 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; _object = _hpData select 0;

View File

@ -1,11 +1,7 @@
//fnc_findReflections.sqf //fnc_findReflections.sqf
#include "script_component.hpp" #include "script_component.hpp"
private ["_split", "_radi", "_params", "_pos", "_explosiveInfo", "_los", "_nlos", "_zIndex", "_depth", "_indirectHitRange", 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"];
"_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; _params = _this select 0;
_pos = _params select 0; _pos = _params select 0;

View File

@ -1,58 +1,8 @@
#include "script_component.hpp" #include "script_component.hpp"
private["_gun", "_type", "_round"];
private ["_enabled", "_gun", "_type", "_round", "_doFragTrack", "_doSpall", "_spallTrack", "_spallTrackID"];
if (!GVAR(enabled)) exitWith {};
_gun = _this select 0; _gun = _this select 0;
_type = _this select 4; _type = _this select 4;
_round = _this select 6; _round = _this select 6;
_enabled = getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(enabled)); [_gun, _type, _round] call FUNC(addPfhRound);
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";
};

View File

@ -15,11 +15,11 @@
if (!GVAR(enabled)) exitWith {}; if (!GVAR(enabled)) exitWith {};
private["_gcIndex"]; private["_gcIndex", "_iter"];
_gcIndex = []; _gcIndex = [];
_iter = 0; _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"]; private["_object", "_args"];
if(GVAR(lastIterationIndex) >= (count GVAR(objects))) then { if(GVAR(lastIterationIndex) >= (count GVAR(objects))) then {
GVAR(lastIterationIndex) = 0; GVAR(lastIterationIndex) = 0;
@ -27,18 +27,10 @@ while { (count GVAR(objects)) > 0 && { _iter < GVAR(MaxTrackPerFrame) } } do {
_object = GVAR(objects) select GVAR(lastIterationIndex); _object = GVAR(objects) select GVAR(lastIterationIndex);
if(!isNil "_object") then { if(!isNil "_object") then {
if(isNull _object) then { _args = GVAR(arguments) select GVAR(lastIterationIndex);
_gcIndex pushBack GVAR(lastIterationIndex);
} else {
_args = GVAR(arguments) select GVAR(lastIterationIndex);
if(!(_args call FUNC(pfhRound))) then { if(!(_args call FUNC(pfhRound))) then {
_gcIndex pushBack GVAR(lastIterationIndex); // Add it to the GC if it returns false _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; _iter = _iter + 1;

View File

@ -18,11 +18,11 @@ if(_round in GVAR(blackList)) exitWith {
false false
}; };
if (!alive _round) then { if (!alive _round) exitWith {
if((diag_frameno - _firedFrame) > 1) then { if((diag_frameno - _firedFrame) > 1) then { //skip if deleted within a single frame
if(_skip == 0) then { if(_skip == 0) then {
if((_explosive > 0.5 && {_indirectRange >= 4.5} && {_fragPower >= 35}) || {_force == 1} ) 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; } forEach _spallTrack;
}; };
} else { false
};
_params set[1, (getPosASL _round)]; _this set[1, (getPosASL _round)];
_params set[2, (velocity _round)]; _this set[2, (velocity _round)];
if(_doSpall) then {
private["_scale"]; if(_doSpall) then {
_scale = ( (count GVAR(objects)) / GVAR(MaxTrackPerFrame) ) max 0.1; private["_scale"];
[_round, _scale, _spallTrack, _foundObjectHPIds] call FUNC(spallTrack); _scale = ( (count GVAR(objects)) / GVAR(MaxTrackPerFrame) ) max 0.1;
}; [_round, _scale, _spallTrack, _foundObjectHPIds] call FUNC(spallTrack);
}; };
true true

View File

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

View File

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

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 { if (alive _tracerObj && (count GVAR(traces)) > 0) then {
_data = GVAR(traces) select _index; _data = GVAR(traces) select _index;
_positions = _data select 4; _positions = _data select 4;
_positions set[(count _positions), [(getPos _tracerObj), vectorMagnitude (velocity _tracerObj)]]; _positions set [(count _positions), [(getPos _tracerObj), vectorMagnitude (velocity _tracerObj)]];
} else { } else {
[(_this select 1)] call cba_fnc_removePerFrameHandler; [(_this select 1)] call cba_fnc_removePerFrameHandler;
}; };

View File

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