Skip to content

Commit

Permalink
Merge pull request #1585 from acemod/huntirParachuteSpeed
Browse files Browse the repository at this point in the history
HuntIR parachute falling speed experiment
  • Loading branch information
ulteq committed Jun 12, 2015
2 parents c45b443 + 62fc0a9 commit 1cbe972
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 9 deletions.
1 change: 1 addition & 0 deletions addons/huntir/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
ADDON = false;

PREP(cam);
PREP(handleDamage);
PREP(handleFired);
PREP(huntir);
PREP(huntirCompass);
Expand Down
Binary file modified addons/huntir/data/huntir.p3d
Binary file not shown.
5 changes: 2 additions & 3 deletions addons/huntir/functions/fnc_cam.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ GVAR(no_cams) sort true;
};
};

private ["_cam_coord_y", "_cam_coord_x", "_speed", "_cam_time", "_cam_pos"];
private ["_cam_coord_y", "_cam_coord_x", "_cam_time", "_cam_pos"];

GVAR(logic) setPosATL (GVAR(pos) vectorAdd [0, 0, -5]);
GVAR(logic) setDir GVAR(ROTATE);
Expand All @@ -138,8 +138,7 @@ GVAR(no_cams) sort true;

ctrlSetText [1, format["%1 m", round(GVAR(pos) select 2)]];
ctrlSetText [2, format["%1", GVAR(cur_cam) + 1]];
_speed = 1 max abs((velocity GVAR(huntIR)) select 2);
_cam_time = ((GVAR(pos) select 2) - 20) / _speed;
_cam_time = ACE_time - (GVAR(huntIR) getVariable [QGVAR(startTime), ACE_time]);
ctrlSetText [3, format["%1 s", round(_cam_time)]];
_cam_pos = getPosVisual GVAR(huntIR);
_cam_pos = format ["X = %1, Y = %2", round (_cam_pos select 0), round (_cam_pos select 1)];
Expand Down
25 changes: 25 additions & 0 deletions addons/huntir/functions/fnc_handleDamage.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Author: Ruthberg
*
* Handles huntir damage
*
* Arguments:
* 0: huntir <OBJECT>
* 1: selectionName <STRING>
* 2: damage <NUMBER>
* 3: source <OBJECT>
* 4: projectile <STRING>
*
* Return Value:
* Nothing
*
* Return value:
* None
*/
#include "script_component.hpp"

PARAMS_5(_huntir,_selectionName,_damage,_source,_projectile);

systemChat format["Selection: %1; Damage: %2", _selectionName, _damage];

_damage
16 changes: 10 additions & 6 deletions addons/huntir/functions/fnc_handleFired.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,21 @@ if (_ammo != "F_HuntIR") exitWith {};
private ["_huntir"];
_huntir = createVehicle ["ACE_HuntIR", _position, [], 0, "FLY"];
_huntir setPosATL _position;
_huntir setVariable [QGVAR(startTime), ACE_time, true];
// TODO: Edit the .p3d to allow doing the following _huntir getHit "camera"; _huntir getHit "parachute";
//_huntir addEventHandler ["HandleDamage", {_this call FUNC(handleDamage)}];
[{
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];
private ["_velocity"];
_velocity = velocity _huntir;
_velocity set [2, -1 min -20 * sqrt(damage _huntir)];
_huntir setVelocity _velocity;
_huntir setVectorUp [0, 0, 1];
};
}, 0.1, [_huntir]] call CBA_fnc_addPerFrameHandler;
}, [getPosATL _projectile vectorAdd [0, 0, 400]], 5, 0] call EFUNC(common,waitAndExecute);
}, 0, [_huntir]] call CBA_fnc_addPerFrameHandler;
}, [getPosATL _projectile vectorAdd [0, 0, 50]], 2, 0] call EFUNC(common,waitAndExecute);
}, [_projectile], 5, 0] call EFUNC(common,waitAndExecute);

0 comments on commit 1cbe972

Please sign in to comment.