mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
6ca9d59443
* Merge ACEX - first attempt Backwards compatibility with XGVAR set of macros used on all settings and config entries Public API functions not taken into account yet, many other things probably still missed * Resolve issues * Switch to addSetting, backward compatible CfgPatches, missed XGVAR. * Remove unnecessary backwards compat * Convert ACEX Categorised settings to initSettings / Fix Intel items magazine * Apply suggestions from code review Co-authored-by: PabstMirror <pabstmirror@gmail.com> * Remove maintainers from merged ACEX components * Cleanup unused module and faction classes * Sitting - Add more object configs by @Dystopian https://github.com/acemod/ACEX/pull/255 * Translations - Add Japanese by @classicarma https://github.com/acemod/ACEX/pull/259 * Kill Tracker - Add killtracker.inc public include file by @Freddo3000" https://github.com/acemod/ACEX/pull/251 * Add ACEX authors and sort authors file * acex - final tweaks (#8513) * acex - handle old funcs * replace thirst/hunger setvars to acex naming fix macro Revert "fix macro" This reverts commit d807e5e804c43916eaa42d34a89af94c6d9a48ad. Revert "replace thirst/hunger setvars to acex naming" This reverts commit bafc607884932d6e339daedc7c22e25dddbdd868. x Co-authored-by: TyroneMF <TyroneMF@hotmail.com> Co-authored-by: PabstMirror <pabstmirror@gmail.com>
77 lines
2.4 KiB
Plaintext
77 lines
2.4 KiB
Plaintext
#include "script_component.hpp"
|
|
/*
|
|
* Author: mharis001, Glowbal, PabstMirror
|
|
* Main looping function that updates thirst/hunger status.
|
|
*
|
|
* Arguments:
|
|
* 0: Next MP sync <NUMBER>
|
|
*
|
|
* Return Value:
|
|
* None
|
|
*
|
|
* Example:
|
|
* [60] call ace_field_rations_fnc_update
|
|
*
|
|
* Public: No
|
|
*/
|
|
|
|
// 1 sec (update interval) * 100 (max thirst/hunger) / 3600 (sec in hour) = 0.02777778
|
|
#define CHANGE_CONSTANT 0.02777778
|
|
|
|
params ["_nextMpSync"];
|
|
|
|
// Access global variable once
|
|
private _player = ACE_player;
|
|
|
|
// Exit if player is not alive or a virtual unit
|
|
if (!alive _player || {_player isKindOf "VirtualMan_F"}) exitWith {
|
|
[FUNC(update), _nextMpSync, 1] call CBA_fnc_waitAndExecute;
|
|
QGVAR(hud) cutFadeOut 0.5;
|
|
};
|
|
|
|
// Get current thirst and hunger
|
|
private _thirst = _player getVariable [QXGVAR(thirst), 0];
|
|
private _hunger = _player getVariable [QXGVAR(hunger), 0];
|
|
|
|
// Determine base change based on work multiplier
|
|
private _currentWork = 1;
|
|
if (vehicle _player == _player && {isTouchingGround _player}) then {
|
|
private _speed = vectorMagnitude velocity _player;
|
|
_currentWork = linearConversion [2, 7, _speed, 1, 2, true];
|
|
};
|
|
|
|
private _thirstChange = _currentWork * CHANGE_CONSTANT / XGVAR(timeWithoutWater);
|
|
private _hungerChange = _currentWork * CHANGE_CONSTANT / XGVAR(timeWithoutFood);
|
|
|
|
// Run status modifiers
|
|
{_thirstChange = _thirstChange + (_player call _x) * CHANGE_CONSTANT / XGVAR(timeWithoutWater)} forEach GVAR(thirstModifiers);
|
|
{_hungerChange = _hungerChange + (_player call _x) * CHANGE_CONSTANT / XGVAR(timeWithoutFood)} forEach GVAR(hungerModifiers);
|
|
|
|
// Change thirst and hunger status
|
|
_thirst = _thirst + _thirstChange min 100 max 0;
|
|
_hunger = _hunger + _hungerChange min 100 max 0;
|
|
|
|
// Check if we want to do a MP sync
|
|
private _doSync = false;
|
|
|
|
if (CBA_missionTime >= _nextMpSync) then {
|
|
_doSync = true;
|
|
_nextMpSync = CBA_missionTime + MP_SYNC_INTERVAL;
|
|
};
|
|
|
|
// Set new thirst and hunger values
|
|
_player setVariable [QXGVAR(thirst), _thirst, _doSync];
|
|
_player setVariable [QXGVAR(hunger), _hunger, _doSync];
|
|
|
|
// Handle any effects/consequences of high thirst or hunger
|
|
[_player, _thirst, _hunger] call FUNC(handleEffects);
|
|
|
|
// Handle showing/updating or hiding of HUD
|
|
if (!EGVAR(common,OldIsCamera) && {_thirst > XGVAR(hudShowLevel) || {_hunger > XGVAR(hudShowLevel)} || {GVAR(hudInteractionHover)}}) then {
|
|
[_thirst, _hunger] call FUNC(handleHUD);
|
|
} else {
|
|
QGVAR(hud) cutFadeOut 0.5;
|
|
};
|
|
|
|
[FUNC(update), _nextMpSync, 1] call CBA_fnc_waitAndExecute;
|