ACE3/addons/advanced_fatigue/functions/fnc_handleStaminaBar.sqf
BaerMitUmlaut cc414de8d1 Add Advanced Fatigue component (#4321)
* Initial commit advanced fatigue

* Added animation changes

* Fixes, rewrites

* Broadcast 3den attribute and fix UBC

* Further animation tweaks

* Added Eden attribute and CBA settings

* Switch to CBA events

* Add beautified component name

* Rewrites, fixes, tweaks

* Move setVars to GVARs

* Add setting to disable

* Switch to status effect handler for sprint and jog blocking

* Add component name

* Failsafe for early unit player EH

* Removed raised weapon penalty for pistols

* Added respawn compatibility

* Tweaked side jog animation speed

* Added support for virtual load

* Added stamina bar

* Remove debug flags

* Added custom duty factor functions and values

* Added structural comments

* Disabled CBA settings, added ACE settings

* Fixed config

* Added readme

* Remove leftover debug diag_logs

* Improved stringtable
2016-09-04 21:33:07 +02:00

45 lines
1.4 KiB
Plaintext

/*
* Author: BaerMitUmlaut
* Handles visual changes of the stamina bar.
*
* Arguments:
* Percent of stamina remaining <NUMBER>
*
* Return Value:
* None
*/
#include "script_component.hpp"
params ["_stamina"];
private _staminaBarContainer = uiNamespace getVariable [QGVAR(staminaBarContainer), controlNull];
// - Size ---------------------------------------------------------------------
// Shrink the container to cut off the image (other wise it would just get stretched)
private _posAndSize = ctrlPosition _staminaBarContainer;
_posAndSize set [2, _stamina * GVAR(staminaBarWidth)];
_staminaBarContainer ctrlSetPosition _posAndSize;
// - Opacity ------------------------------------------------------------------
if (_stamina >= 0.8) then {
_staminaBarContainer ctrlSetFade (0.9 + 0.1 * (_stamina - 0.8) / 0.2);
} else {
_staminaBarContainer ctrlSetFade (0.9 * _stamina / 0.8);
};
// - Color --------------------------------------------------------------------
// 1.0 - 0.8: White
// 0.6 - 0.4: Orange
// 0.4 - 0.2: Red
private _color = [1, 1, 1];
if (_stamina < 0.6) then {
if (_stamina < 0.4) then {
_color = [1, 0, 0] vectorAdd ([0, 0.65, 0] vectorMultiply ((_stamina - 0.2) / 0.2));
} else {
_color = [1, 0.65, 0] vectorAdd ([0, 0.35, 1] vectorMultiply ((_stamina - 0.4) / 0.2));
};
};
_color pushBack 1;
(_staminaBarContainer controlsGroupCtrl 10) ctrlSetTextColor _color;
_staminaBarContainer ctrlCommit 1;