2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2017-06-08 13:31:51 +00:00
|
|
|
/*
|
|
|
|
* Author: ACE-Team
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* call ace_frag_fnc_findReflections
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2016-05-30 16:37:03 +00:00
|
|
|
BEGIN_COUNTER(fnc_findReflections);
|
2016-10-26 22:16:31 +00:00
|
|
|
params ["_args", "_pfhID"];
|
2016-09-04 14:44:22 +00:00
|
|
|
_args params ["_pos", "_explosiveInfo", "_los", "_nlos", "_zIndex", "_depth", "_rand"];
|
2016-05-30 16:37:03 +00:00
|
|
|
|
2016-09-04 14:44:22 +00:00
|
|
|
private _split = 15;
|
2016-10-26 22:16:31 +00:00
|
|
|
private _radi = 360 / _split * _depth;
|
2016-05-30 16:37:03 +00:00
|
|
|
|
2016-10-26 22:16:31 +00:00
|
|
|
// player sideChat format ["p: %1", _explosiveInfo];
|
2016-09-04 14:44:22 +00:00
|
|
|
_explosiveInfo params ["_indirectHitRange", "_indirectHit"];
|
2016-10-26 22:16:31 +00:00
|
|
|
private _distanceCount = (floor _indirectHitRange * 4) min 100;
|
2016-05-30 16:37:03 +00:00
|
|
|
|
2016-10-26 22:16:31 +00:00
|
|
|
if (_zIndex < 5) then {
|
|
|
|
private _lastPos = _pos;
|
|
|
|
private _zAng = _zIndex * 20 + 2;
|
|
|
|
if (_zAng > 80) then {
|
2016-05-30 16:37:03 +00:00
|
|
|
_radi = 1;
|
|
|
|
_zAng = 90;
|
|
|
|
};
|
|
|
|
for "_i" from 0 to _radi do {
|
2016-10-26 22:16:31 +00:00
|
|
|
private _test = true;
|
|
|
|
private _vec = [1, ((_i * _split) + _rand) % 360, _zAng] call CBA_fnc_polar2vect;
|
2016-05-30 16:37:03 +00:00
|
|
|
for "_x" from 1 to _distanceCount do {
|
2016-10-26 22:16:31 +00:00
|
|
|
private _testPos = _pos vectorAdd (_vec vectorMultiply _x);
|
2016-05-30 16:37:03 +00:00
|
|
|
// 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,"","",""];
|
2016-10-26 22:16:31 +00:00
|
|
|
private _res = lineIntersectsWith [_pos, _testPos];
|
|
|
|
if (count _res > 0) exitWith {
|
2016-05-30 16:37:03 +00:00
|
|
|
_test = false;
|
|
|
|
_nlos pushBack _lastPos;
|
|
|
|
// {
|
2016-10-26 22:16:31 +00:00
|
|
|
// _x addEventHandler ["HandleDamage", { diag_log text format ["this: %1", _this]; }];
|
2016-05-30 16:37:03 +00:00
|
|
|
// } 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]];
|
|
|
|
|
|
|
|
};
|
2016-10-26 22:16:31 +00:00
|
|
|
// if (terrainIntersectASL [_pos, _testPos]) exitWith {};
|
2016-05-30 16:37:03 +00:00
|
|
|
_lastPos = _testPos;
|
|
|
|
};
|
|
|
|
};
|
2016-10-26 22:16:31 +00:00
|
|
|
_args set [4, _zIndex + 1];
|
2016-05-30 16:37:03 +00:00
|
|
|
} else {
|
2016-10-26 22:16:31 +00:00
|
|
|
INC(_depth);
|
|
|
|
private _buckets = [];
|
|
|
|
private _excludes = [];
|
|
|
|
private _bucketPos = nil;
|
|
|
|
private _bucketList = nil;
|
|
|
|
private _c = 0;
|
|
|
|
while {count _nlos != count _excludes && {_c < (count _nlos)}} do {
|
2016-05-30 16:37:03 +00:00
|
|
|
scopeName "mainSearch";
|
|
|
|
{
|
2016-10-26 22:16:31 +00:00
|
|
|
if (!(_forEachIndex in _excludes)) then {
|
|
|
|
private _index = _buckets pushBack [_x, [_x]];
|
2016-05-30 16:37:03 +00:00
|
|
|
_excludes pushBack _forEachIndex;
|
|
|
|
_bucketPos = _x;
|
|
|
|
_bucketList = (_buckets select _index) select 1;
|
|
|
|
breakTo "mainSearch";
|
|
|
|
};
|
|
|
|
} forEach _nlos;
|
|
|
|
{
|
2016-10-26 22:16:31 +00:00
|
|
|
if (!(_forEachIndex in _excludes)) then {
|
2016-05-30 16:37:03 +00:00
|
|
|
_testPos = _x;
|
2016-10-26 22:16:31 +00:00
|
|
|
if (_testPos vectorDistanceSqr _bucketPos <= 30) then {
|
2016-05-30 16:37:03 +00:00
|
|
|
_bucketList pushBack _x;
|
|
|
|
_excludes pushBack _forEachIndex;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
} forEach _nlos;
|
2016-10-26 22:16:31 +00:00
|
|
|
INC(_c);
|
2016-05-30 16:37:03 +00:00
|
|
|
};
|
|
|
|
|
2016-10-26 22:16:31 +00:00
|
|
|
// player sideChat format ["c: %1", count _buckets];
|
|
|
|
private _explosions = [];
|
2016-05-30 16:37:03 +00:00
|
|
|
{
|
2016-10-26 22:16:31 +00:00
|
|
|
private _blist = _x select 1;
|
2017-02-10 18:28:27 +00:00
|
|
|
private _avg = [0, 0, 0];
|
2016-05-30 16:37:03 +00:00
|
|
|
|
|
|
|
{
|
2017-06-08 13:31:51 +00:00
|
|
|
_avg = _avg vectorAdd _x;
|
2016-05-30 16:37:03 +00:00
|
|
|
} forEach _blist;
|
|
|
|
_c = count _blist;
|
2017-02-10 18:28:27 +00:00
|
|
|
private _bpos = _avg vectorMultiply (1 / _c);
|
2016-05-30 16:37:03 +00:00
|
|
|
|
2016-10-26 22:16:31 +00:00
|
|
|
private _distance = _pos vectorDistance _bpos;
|
|
|
|
private _hitFactor = 1 - (((_distance / (_indirectHitRange * 4)) min 1) max 0);
|
|
|
|
// _hitFactor = 1 / (_distance ^ 2);
|
2017-02-10 18:28:27 +00:00
|
|
|
private _hit = (floor (_indirectHit * _hitFactor / 4)) min 500;
|
2016-10-26 22:16:31 +00:00
|
|
|
SUB(_hit,_hit % 10);
|
|
|
|
private _range = (floor (_indirectHitRange - (_distance / 4))) min 100;
|
|
|
|
SUB(_range,_range % 2);
|
2016-05-30 16:37:03 +00:00
|
|
|
|
2016-10-26 22:16:31 +00:00
|
|
|
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]];
|
2016-05-30 16:37:03 +00:00
|
|
|
// TEST_PAIRS pushBack [_pos, _bpos, [1,0,0,1]];
|
2016-10-26 22:16:31 +00:00
|
|
|
private _refExp = format ["ace_explosion_reflection_%1_%2", _range, _hit];
|
2016-05-30 16:37:03 +00:00
|
|
|
// _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,"","",""];
|
|
|
|
|
2016-10-26 22:16:31 +00:00
|
|
|
_explosions pushBack [_refExp, _bpos, _hit, _distance, _indirectHitRange / 4, _depth];
|
2016-05-30 16:37:03 +00:00
|
|
|
};
|
2016-10-26 22:16:31 +00:00
|
|
|
if (count _explosions > (_radi * 2) / _depth) exitWith {};
|
2016-05-30 16:37:03 +00:00
|
|
|
} forEach _buckets;
|
|
|
|
// _can = "Land_Bricks_V4_F" createVehicle (ASLtoATL _pos);
|
2021-10-10 13:37:05 +00:00
|
|
|
// _dirvec = _pos vectorFromTo ((player modelToWorldVisualWorld (player selectionPosition "Spine3")));
|
2016-05-30 16:37:03 +00:00
|
|
|
// _dirvec = _dirvec vectorMultiply 100;
|
|
|
|
// _can setVelocity _dirvec;
|
|
|
|
[DFUNC(doExplosions), 0, [_explosions, 0]] call CBA_fnc_addPerFrameHandler;
|
2016-10-26 22:16:31 +00:00
|
|
|
[_pfhID] call CBA_fnc_removePerFrameHandler;
|
2016-05-30 16:37:03 +00:00
|
|
|
};
|
|
|
|
END_COUNTER(fnc_findReflections);
|