2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2016-09-04 19:33:07 +00:00
|
|
|
/*
|
2024-06-22 17:53:08 +00:00
|
|
|
* Author: BaerMitUmlaut, ulteq
|
|
|
|
* Handles switching units (once on init and afterwards via Zeus). Also handles CBA setting change for performance factor.
|
2016-09-04 19:33:07 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: New Unit <OBJECT>
|
|
|
|
* 1: Old Unit <OBJECT>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
2017-06-08 13:31:51 +00:00
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [newbob, oldbob] call ace_advanced_fatigue_fnc_handlePlayerChanged
|
|
|
|
*
|
|
|
|
* Public: No
|
2016-09-04 19:33:07 +00:00
|
|
|
*/
|
2024-06-22 17:53:08 +00:00
|
|
|
|
2016-09-04 19:33:07 +00:00
|
|
|
params ["_newUnit", "_oldUnit"];
|
2024-06-22 17:53:08 +00:00
|
|
|
|
2016-11-27 22:38:33 +00:00
|
|
|
TRACE_2("unit changed",_newUnit,_oldUnit);
|
2016-09-04 19:33:07 +00:00
|
|
|
|
2024-06-22 17:53:08 +00:00
|
|
|
if (!isNull _oldUnit) then {
|
|
|
|
TRACE_1("remove old",_oldUnit getVariable QGVAR(animHandler));
|
|
|
|
|
2016-09-04 19:33:07 +00:00
|
|
|
_oldUnit enableStamina true;
|
|
|
|
_oldUnit removeEventHandler ["AnimChanged", _oldUnit getVariable [QGVAR(animHandler), -1]];
|
2016-11-27 22:38:33 +00:00
|
|
|
_oldUnit setVariable [QGVAR(animHandler), nil];
|
2016-09-04 19:33:07 +00:00
|
|
|
|
|
|
|
_oldUnit setVariable [QGVAR(ae1Reserve), GVAR(ae1Reserve)];
|
|
|
|
_oldUnit setVariable [QGVAR(ae2Reserve), GVAR(ae2Reserve)];
|
|
|
|
_oldUnit setVariable [QGVAR(anReserve), GVAR(anReserve)];
|
|
|
|
_oldUnit setVariable [QGVAR(anFatigue), GVAR(anFatigue)];
|
|
|
|
_oldUnit setVariable [QGVAR(muscleDamage), GVAR(muscleDamage)];
|
2024-06-22 17:53:08 +00:00
|
|
|
_oldUnit setVariable [QGVAR(respiratoryRate), GVAR(respiratoryRate)];
|
2016-09-04 19:33:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
_newUnit enableStamina false;
|
|
|
|
|
|
|
|
// Don't add a new EH if the unit respawned
|
|
|
|
if (_newUnit getVariable [QGVAR(animHandler), -1] == -1) then {
|
|
|
|
private _animHandler = _newUnit addEventHandler ["AnimChanged", {
|
|
|
|
GVAR(animDuty) = _this call FUNC(getAnimDuty);
|
|
|
|
}];
|
2024-06-22 17:53:08 +00:00
|
|
|
|
2016-11-27 22:38:33 +00:00
|
|
|
TRACE_1("add new",_animHandler);
|
2016-09-04 19:33:07 +00:00
|
|
|
_newUnit setVariable [QGVAR(animHandler), _animHandler];
|
|
|
|
};
|
|
|
|
|
|
|
|
GVAR(ae1Reserve) = _newUnit getVariable [QGVAR(ae1Reserve), AE1_MAXRESERVE];
|
|
|
|
GVAR(ae2Reserve) = _newUnit getVariable [QGVAR(ae2Reserve), AE2_MAXRESERVE];
|
|
|
|
GVAR(anReserve) = _newUnit getVariable [QGVAR(anReserve), AN_MAXRESERVE];
|
|
|
|
GVAR(anFatigue) = _newUnit getVariable [QGVAR(anFatigue), 0];
|
|
|
|
GVAR(muscleDamage) = _newUnit getVariable [QGVAR(muscleDamage), 0];
|
2024-06-22 17:53:08 +00:00
|
|
|
GVAR(respiratoryRate) = _newUnit getVariable [QGVAR(respiratoryRate), 0];
|
2016-09-04 19:33:07 +00:00
|
|
|
|
|
|
|
// Clean variables for respawning units
|
|
|
|
{
|
|
|
|
_newUnit setVariable [_x, nil];
|
2024-06-22 17:53:08 +00:00
|
|
|
} forEach [QGVAR(ae1Reserve), QGVAR(ae2Reserve), QGVAR(anReserve), QGVAR(anFatigue), QGVAR(muscleDamage), QGVAR(respiratoryRate)];
|
2016-09-04 19:33:07 +00:00
|
|
|
|
|
|
|
GVAR(VO2Max) = 35 + 20 * (_newUnit getVariable [QGVAR(performanceFactor), GVAR(performanceFactor)]);
|
2024-06-22 17:53:08 +00:00
|
|
|
GVAR(VO2MaxPower) = GVAR(VO2Max) * SIM_BODYMASS * BIOMECH_EFFICIENCY * JOULES_PER_ML_O2 / 60;
|
2016-09-04 19:33:07 +00:00
|
|
|
GVAR(peakPower) = VO2MAX_STRENGTH * GVAR(VO2MaxPower);
|
|
|
|
|
2024-06-22 17:53:08 +00:00
|
|
|
GVAR(ae1PathwayPower) = GVAR(peakPower) / (AE1_ATP_RELEASE_RATE + AE2_ATP_RELEASE_RATE + AN_ATP_RELEASE_RATE) * AE1_ATP_RELEASE_RATE * ANTPERCENT ^ 1.28 * 1.362;
|
|
|
|
GVAR(ae2PathwayPower) = GVAR(peakPower) / (AE1_ATP_RELEASE_RATE + AE2_ATP_RELEASE_RATE + AN_ATP_RELEASE_RATE) * AE2_ATP_RELEASE_RATE * ANTPERCENT ^ 1.28 * 1.362;
|
|
|
|
GVAR(aePathwayPower) = GVAR(ae1PathwayPower) + GVAR(ae2PathwayPower);
|
|
|
|
GVAR(anPathwayPower) = GVAR(peakPower) - GVAR(aePathwayPower);
|
|
|
|
|
|
|
|
GVAR(aeWattsPerATP) = GVAR(ae1PathwayPower) / AE1_ATP_RELEASE_RATE;
|
|
|
|
GVAR(anWattsPerATP) = GVAR(anPathwayPower) / AN_ATP_RELEASE_RATE;
|
|
|
|
|
|
|
|
GVAR(respiratoryBufferDivisor) = (RESPIRATORY_BUFFER - 1) / RESPIRATORY_BUFFER;
|
|
|
|
GVAR(maxPowerFatigueRatio) = 0.057 / GVAR(peakPower);
|
2016-09-04 19:33:07 +00:00
|
|
|
|
|
|
|
GVAR(ppeBlackoutLast) = 100;
|
|
|
|
GVAR(lastBreath) = 0;
|
|
|
|
GVAR(animDuty) = [_newUnit, animationState _newUnit] call FUNC(getAnimDuty);
|