Skip to content

Commit

Permalink
Frag Superanal Cleanup (#4803)
Browse files Browse the repository at this point in the history
* Minimal frag cleanup

* Why did this even happen in the first place
  • Loading branch information
654wak654 authored and PabstMirror committed Feb 10, 2017
1 parent 5351b43 commit d2ee1e9
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 71 deletions.
2 changes: 1 addition & 1 deletion addons/frag/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "script_component.hpp"

if (GVAR(EnableDebugTrace) && {!isMultiplayer}) then {
if (GVAR(enableDebugTrace) && {!isMultiplayer}) then {
GVAR(traceFrags) = true;
GVAR(autoTrace) = true;
};
Expand Down
2 changes: 1 addition & 1 deletion addons/frag/functions/fnc_addPfhRound.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if (_round in GVAR(blackList)) exitWith {
};

// Exit on max track
if ((count GVAR(objects)) > GVAR(MaxTrack)) exitWith {};
if ((count GVAR(objects)) > GVAR(maxTrack)) exitWith {};

if (
_gun == ACE_player ||
Expand Down
1 change: 1 addition & 0 deletions addons/frag/functions/fnc_doSpall.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ for "_i" from 1 to _spallCount do {
[ACE_player, _fragment, [1, 0.5, 0, 1]] call FUNC(addTrack);
};
};

_spread = 5 + (random 5);
_spallCount = 3 + (random 5);
for "_i" from 1 to _spallCount do {
Expand Down
13 changes: 4 additions & 9 deletions addons/frag/functions/fnc_findReflections.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,18 @@ if (_zIndex < 5) then {
private _explosions = [];
{
private _blist = _x select 1;
private _avgX = 0;
private _avgY = 0;
private _avgZ = 0;
private _avg = [0, 0, 0];

{
ADD(_avgX,_x select 0);
ADD(_avgY,_x select 1);
ADD(_avgZ,_x select 2);
_avg = _avg vectorAdd _x;
} forEach _blist;
_c = count _blist;
private _bpos = [_avgX / _c, _avgY / _c, _avgZ / _c];
private _bpos = _avg vectorMultiply (1 / _c);

private _distance = _pos vectorDistance _bpos;
private _hitFactor = 1 - (((_distance / (_indirectHitRange * 4)) min 1) max 0);
// _hitFactor = 1 / (_distance ^ 2);
private _hit = _indirectHit * _hitFactor;
_hit = (floor (_hit / 4)) min 500;
private _hit = (floor (_indirectHit * _hitFactor / 4)) min 500;
SUB(_hit,_hit % 10);
private _range = (floor (_indirectHitRange - (_distance / 4))) min 100;
SUB(_range,_range % 2);
Expand Down
2 changes: 1 addition & 1 deletion addons/frag/functions/fnc_fired.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if (isNil "_shouldAdd") then {
_shouldAdd = false;
};

if (GVAR(SpallEnabled)) exitWith {
if (GVAR(spallEnabled)) exitWith {
//Always want to run whenever spall is enabled?
_shouldAdd = true;
TRACE_2("SettingCache[spallEnabled]",_ammo,_shouldAdd);
Expand Down
110 changes: 55 additions & 55 deletions addons/frag/functions/fnc_frago.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ if (_warn) then {
};

private _fragPower = (((_m / _c) + _k) ^ - (1 / 2)) * _gC;
_fragPower = _fragPower * 0.8; // Gunery equation is for a non-fragmenting metal, imperical value of 80% represents fragmentation
MUL(_fragPower,0.8); // Gunery equation is for a non-fragmenting metal, imperical value of 80% represents fragmentation

private _atlPos = ASLtoATL _lastPos;

private _fragPowerRandom = _fragPower * 0.5;
if ((_atlPos select 2) < 0.5) then {
_lastPos set [2, (_lastPos select 2) + 0.5];
_lastPos vectorAdd [0, 0, 0.5];
};

// _manObjects = _atlPos nearEntities ["CaManBase", _fragRange];
Expand Down Expand Up @@ -96,71 +96,71 @@ _fragArcs set [360, 0];

private _doRandom = true;
if (_isArmed && {!(_objects isEqualTo [])}) then {
if (GVAR(ReflectionsEnabled)) then {
if (GVAR(reflectionsEnabled)) then {
[_lastPos, _shellType] call FUNC(doReflections);
};
{
//if (random(1) > 0.5) then {
private _target = _x;
if (alive _target) then {
private _boundingBox = boundingBox _target;

private _cubic = 1;
for "_i" from 0 to 2 do {
MUL(_cubic,(abs ((_boundingBox select 0) select _i)) + ((_boundingBox select 1) select _i));
};

if (_cubic <= 1) exitWith {};
_doRandom = true;

private _targetVel = velocity _target;
private _targetPos = getPosASL _target;
private _distance = _targetPos distance _lastPos;
private _distance = _targetPos vectorDistance _lastPos;
private _add = (((_boundingBox select 1) select 2) / 2) + ((((_distance - (_fragpower / 8)) max 0) / _fragPower) * 10);
private _bbX = (abs ((_boundingBox select 0) select 0)) + ((_boundingBox select 1) select 0);
private _bbY = (abs ((_boundingBox select 0) select 1)) + ((_boundingBox select 1) select 1);
private _bbZ = (abs ((_boundingBox select 0) select 2)) + ((_boundingBox select 1) select 2);
private _cubic = _bbX * _bbY * _bbZ;
if (_cubic > 1) then {
_doRandom = true;

private _targetVel = velocity _target;

_targetPos = _targetPos vectorAdd [
(_targetVel select 0) * (_distance / _fragPower),
(_targetVel select 1) * (_distance / _fragPower),
_add
];

private _baseVec = _lastPos vectorFromTo _targetPos;

private _dir = floor (_baseVec call CBA_fnc_vectDir);
private _currentCount = _fragArcs select _dir;
ISNILS(_currentCount,0);
if (_currentCount < 20) then {
private _count = ceil (random (sqrt (_m / 1000)));
private _vecVar = FRAG_VEC_VAR;
if (!(_target isKindOf "Man")) then {
_vecVar = ((sqrt _cubic) / 2000) + FRAG_VEC_VAR;
if ((crew _target) isEqualTo [] && {_count > 0}) then {
_count = 0 max (_count / 2);
};

_targetPos = _targetPos vectorAdd [
(_targetVel select 0) * (_distance / _fragPower),
(_targetVel select 1) * (_distance / _fragPower),
_add
];

private _baseVec = _lastPos vectorFromTo _targetPos;

private _dir = floor (_baseVec call CBA_fnc_vectDir);
private _currentCount = RETDEF(_fragArcs select _dir,0);
if (_currentCount < 20) then {
private _count = ceil (random (sqrt (_m / 1000)));
private _vecVar = FRAG_VEC_VAR;
if (!(_target isKindOf "Man")) then {
ADD(_vecVar,(sqrt _cubic) / 2000);
if ((crew _target) isEqualTo [] && {_count > 0}) then {
_count = 0 max (_count / 2);
};
for "_i" from 1 to _count do {
private _vec = _baseVec vectorDiff [
(_vecVar / 2) + (random _vecVar),
(_vecVar / 2) + (random _vecVar),
(_vecVar / 2) + (random _vecVar)
];

private _fp = _fragPower - (random (_fragPowerRandom));
private _vel = _vec vectorMultiply _fp;

private _fragType = round (random ((count _fragTypes) - 1));
private _fragObj = (_fragTypes select _fragType) createVehicleLocal [0,0,10000];
// diag_log text format ["fp: %1 %2", _fp, typeOf _fragObj];
_fragObj setPosASL _lastPos;
_fragObj setVectorDir _vec;
_fragObj setVelocity _vel;
if (GVAR(traceFrags)) then {
INC(GVAR(totalFrags));
[ACE_player, _fragObj, [1,0,0,1]] call FUNC(addTrack);
};
INC(_fragCount);
INC(_currentCount);
};
for "_i" from 1 to _count do {
private _vec = _baseVec vectorDiff [
(_vecVar / 2) + (random _vecVar),
(_vecVar / 2) + (random _vecVar),
(_vecVar / 2) + (random _vecVar)
];

private _fp = _fragPower - (random (_fragPowerRandom));
private _vel = _vec vectorMultiply _fp;

private _fragType = round (random ((count _fragTypes) - 1));
private _fragObj = (_fragTypes select _fragType) createVehicleLocal [0,0,10000];
// diag_log text format ["fp: %1 %2", _fp, typeOf _fragObj];
_fragObj setPosASL _lastPos;
_fragObj setVectorDir _vec;
_fragObj setVelocity _vel;
if (GVAR(traceFrags)) then {
INC(GVAR(totalFrags));
[ACE_player, _fragObj, [1,0,0,1]] call FUNC(addTrack);
};
_fragArcs set [_dir, _currentCount];
INC(_fragCount);
INC(_currentCount);
};
_fragArcs set [_dir, _currentCount];
};
};
//};
Expand Down
2 changes: 1 addition & 1 deletion addons/frag/functions/fnc_masterPFH.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ private _gcIndex = [];

private _iter = 0;
private _objectCount = count GVAR(objects);
while {_objectCount > 0 && {_iter < (GVAR(MaxTrackPerFrame) min _objectCount)}} do {
while {_objectCount > 0 && {_iter < (GVAR(maxTrackPerFrame) min _objectCount)}} do {

if (GVAR(lastIterationIndex) >= _objectCount) then {
GVAR(lastIterationIndex) = 0;
Expand Down
3 changes: 1 addition & 2 deletions addons/frag/functions/fnc_pfhRound.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ _this set [1, getPosASL _round];
_this set [2, velocity _round];

if (_doSpall) then {
private ["_scale"];
_scale = ((count GVAR(objects)) / GVAR(MaxTrackPerFrame)) max 0.1;
private _scale = ((count GVAR(objects)) / GVAR(maxTrackPerFrame)) max 0.1;
[_round, _scale, _spallTrack, _foundObjectHPIds] call FUNC(spallTrack);
};

Expand Down
2 changes: 1 addition & 1 deletion addons/frag/functions/fnc_removePfhRound.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// THIS FUNCTION SHOULD NOT BE USED BECAUSE IT CAUSES AN SEARCH AND REBUILD

PARAMS_1(_round);
params ["_round"];

if (_round in GVAR(blackList)) then {
REM(GVAR(blackList),_round);
Expand Down

0 comments on commit d2ee1e9

Please sign in to comment.