From f7a76480f997e3ec5799f59553b20cfc1c9c1b3a Mon Sep 17 00:00:00 2001 From: ulteq Date: Thu, 11 Jun 2015 19:37:51 +0200 Subject: [PATCH] Made the HuntIR camera destroyable: * Shooting the parachute will increase its damage * The falling speed now increases with damage * Damaged cameras won't be able to transmit video * The HuntIR spawn positions now really depends on the grenade trajectory --- addons/huntir/CfgVehicles.hpp | 1 + addons/huntir/functions/fnc_cam.sqf | 4 +-- addons/huntir/functions/fnc_handleFired.sqf | 35 +++++++++++---------- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/addons/huntir/CfgVehicles.hpp b/addons/huntir/CfgVehicles.hpp index 3cce76e201..9e24473243 100644 --- a/addons/huntir/CfgVehicles.hpp +++ b/addons/huntir/CfgVehicles.hpp @@ -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; diff --git a/addons/huntir/functions/fnc_cam.sqf b/addons/huntir/functions/fnc_cam.sqf index af229bfe75..e922b2cbc1 100644 --- a/addons/huntir/functions/fnc_cam.sqf +++ b/addons/huntir/functions/fnc_cam.sqf @@ -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; diff --git a/addons/huntir/functions/fnc_handleFired.sqf b/addons/huntir/functions/fnc_handleFired.sqf index 16afd17546..91367ac864 100644 --- a/addons/huntir/functions/fnc_handleFired.sqf +++ b/addons/huntir/functions/fnc_handleFired.sqf @@ -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);