Merge pull request #1582 from acemod/destroyableHuntIR

Made the HuntIR camera destroyable:
This commit is contained in:
ulteq 2015-06-11 19:40:00 +02:00
commit ab85a9ceb6
3 changed files with 21 additions and 19 deletions

View File

@ -20,6 +20,7 @@ class CfgVehicles {
class Parachute_02_base_F;
class ACE_HuntIR: Parachute_02_base_F {
scope = 1;
destrType = "DestructDefault";
displayName = "HuntIR";
model = PATHTOF(data\huntir.p3d);
castDriverShadow = 0;

View File

@ -65,12 +65,12 @@ GVAR(no_cams) sort true;
[{
GVAR(nearHuntIRs) = ACE_player nearEntities ["ACE_HuntIR", HUNTIR_MAX_TRANSMISSION_RANGE];
{
if (((getPosVisual _x) select 2) > 20 && {!(_x in GVAR(no_cams))}) then {
if (((getPosVisual _x) select 2) > 20 && {!(_x in GVAR(no_cams))} && {damage _x < 0.5}) then {
GVAR(no_cams) pushBack _x;
};
} forEach GVAR(nearHuntIRs);
{
if (((getPosVisual _x) select 2) <= 20 || {!(_x in GVAR(nearHuntIRs))}) then {
if (((getPosVisual _x) select 2) <= 20 || {!(_x in GVAR(nearHuntIRs))} || {damage _x >= 0.5}) then {
GVAR(no_cams) deleteAt _forEachIndex;
if (_forEachIndex < GVAR(cur_cam)) then {
GVAR(cur_cam) = GVAR(cur_cam) - 1;

View File

@ -23,24 +23,25 @@ PARAMS_7(_unit,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
if (_ammo != "F_HuntIR") exitWith {};
private ["_dir", "_pos", "_dirDegree", "_b", "_a", "_y", "_x"];
_dir = ACE_player weaponDirection _weapon;
_pos = getPosATL ACE_player;
_dirDegree = (_dir select 0) atan2 (_dir select 1);
_b = 500 / (tan((asin(_dir select 2)) + 10));
_a = _b * sin(_dirDegree);
_b = _a / tan(_dirDegree);
_x = (_pos select 0) + _a;
_y = (_pos select 1) + _b;
[{
PARAMS_3(_projectile,_x,_y);
PARAMS_1(_projectile);
"ACE_HuntIR_Propell" createVehicle (getPosATL _projectile);
[{
PARAMS_3(_x,_y,_z);
PARAMS_1(_position);
private ["_huntir"];
_huntir = createVehicle ["ACE_HuntIR", [_x, _y, _z], [], 0, "FLY"];
_huntir setPosATL [_x, _y, _z];
}, [_x, _y, ((getPosATL _projectile) select 2) + 400], 5, 0] call EFUNC(common,waitAndExecute);
}, [_projectile, _x, _y], 5, 0] call EFUNC(common,waitAndExecute);
_huntir = createVehicle ["ACE_HuntIR", _position, [], 0, "FLY"];
_huntir setPosATL _position;
[{
EXPLODE_1_PVT(_this select 0,_huntir);
private ["_deltaT"];
if (isNull _huntir) exitWith {
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
if (damage _huntir > 0) then {
_deltaT = ACE_time - (_huntir getVariable [QGVAR(lastTime), ACE_time]);
_huntir setVelocity (velocity _huntir vectorAdd [0, 0, -9.8066 * (damage _huntir) * _deltaT]);
_huntir setVariable [QGVAR(lastTime), ACE_time];
};
}, 0.1, [_huntir]] call CBA_fnc_addPerFrameHandler;
}, [getPosATL _projectile vectorAdd [0, 0, 400]], 5, 0] call EFUNC(common,waitAndExecute);
}, [_projectile], 5, 0] call EFUNC(common,waitAndExecute);