ACE3/addons/parachute/functions/fnc_onEachFrame.sqf
Glowbal b489750d5b Minor optimizations using private, params, and isEqualType (#4323)
* Optimizations with private, params, and isEqualType

* Fixed tab being used instead of space

* Fixed tabs inserted by notepad++

* More usage of new private syntax and params

- changed a few checks for an array being empty to `_arr isEqualTo []`
rather than `count _arr == 0`
- added more uses of `private` on the same line as the variable is
declared
- added more uses of params to assign variables passed as parameters
- removed unnecessary parentheses
- removed several unnecessary variable declarations with private array
syntax

* clean up and formatting
2016-09-04 16:44:22 +02:00

33 lines
1.1 KiB
Plaintext

/*
* Author: Garth 'L-H' de Wet
* Checks whether the unit should preform landing.
*
* Arguments:
* None
*
* Return Value:
* None
*
* Example:
* call ACE_Parachute_fnc_onEachFrame;
*
* Public: No
*/
#include "script_component.hpp"
private _player = ACE_player;
if (!GVAR(PFH)) exitWith {[(_this select 1)] call CALLSTACK(CBA_fnc_removePerFrameHandler);};
if (isNull _player) exitWith {[(_this select 1)] call CALLSTACK(CBA_fnc_removePerFrameHandler);GVAR(PFH) = false;};
if !((vehicle _player) isKindOf "ParachuteBase") exitWith {[(_this select 1)] call CALLSTACK(CBA_fnc_removePerFrameHandler);GVAR(PFH) = false;};
if (isTouchingGround _player) exitWith {[(_this select 1)] call CALLSTACK(CBA_fnc_removePerFrameHandler);GVAR(PFH) = false;};
private ["_pos"];
_pos = getPosASL (vehicle _player);
if ((lineIntersects [_pos, _pos vectorAdd [0,0,-0.5], vehicle _player, _player]) || {((ASLtoATL _pos) select 2) < 0.75}) then {
[(_this select 1)] call CALLSTACK(CBA_fnc_removePerFrameHandler);
GVAR(PFH) = false;
// I believe this will not work for Zeus units.
deleteVehicle (vehicle _player);
[_player] call FUNC(doLanding);
};