2015-01-11 18:24:19 +00:00
|
|
|
//fnc_spallTrack.sqf
|
|
|
|
#include "script_component.hpp"
|
2015-04-27 20:04:35 +00:00
|
|
|
|
|
|
|
private ["_round", "_multiplier", "_foundObjects", "_foundObjectHPIds", "_delta", "_curPos", "_velocity", "_velocityStep", "_forwardPos", "_intersectsWith", "_index", "_hpId", "_data"];
|
2015-01-11 18:24:19 +00:00
|
|
|
_round = _this select 0;
|
|
|
|
_multiplier = _this select 1;
|
|
|
|
_foundObjects = _this select 2;
|
|
|
|
_foundObjectHPIds = _this select 3;
|
|
|
|
|
2015-04-27 20:04:35 +00:00
|
|
|
_delta = (1/diag_fps) * _multiplier;
|
2015-01-11 18:24:19 +00:00
|
|
|
_curPos = getPosASL _round;
|
|
|
|
_velocity = velocity _round;
|
|
|
|
|
2015-04-27 20:04:35 +00:00
|
|
|
_velocityStep = _velocity vectorMultiply _delta;
|
|
|
|
_forwardPos = _curPos vectorAdd _velocityStep;
|
|
|
|
|
2015-01-11 18:24:19 +00:00
|
|
|
_intersectsWith = lineIntersectsWith [_curPos, _forwardPos];
|
|
|
|
|
2015-04-27 20:04:35 +00:00
|
|
|
if (count _intersectsWith > 0) then {
|
2015-04-06 16:22:43 +00:00
|
|
|
// player sideChat format["inter: %1", _intersectsWith];
|
|
|
|
{
|
|
|
|
if(!(_x in _foundObjects)) then {
|
|
|
|
// diag_log text format["Adding HP: %1", _x];
|
|
|
|
_index = (count GVAR(spallHPData));
|
2016-04-08 18:43:26 +00:00
|
|
|
_hpId = _x addEventHandler ["hitPart", compile format["[%1, _this] call " + QFUNC(spallHP), _index]];
|
2015-04-06 16:22:43 +00:00
|
|
|
_foundObjects set[(count _foundObjects), _x];
|
|
|
|
_foundObjectHPIds set[(count _foundObjectHPIds), _hpId];
|
|
|
|
_data = [_hpId, _x, typeOf _round, _round, _curPos, _velocity, 0, _foundObjects, _foundObjectHPIds];
|
|
|
|
GVAR(spallHPData) set[_index, _data];
|
|
|
|
};
|
|
|
|
} forEach _intersectsWith;
|
2015-04-27 20:04:35 +00:00
|
|
|
};
|