From 2af0da4853facca2fb3a7f258dbc6fadb160c8aa Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Mon, 1 Apr 2024 22:59:11 +0200 Subject: [PATCH] Fixed headers, made fire simulation local --- addons/fire/XEH_postInit.sqf | 4 +-- addons/fire/functions/fnc_burn.sqf | 7 ++--- addons/fire/functions/fnc_burnIndicator.sqf | 5 +-- addons/fire/functions/fnc_burnSimulation.sqf | 33 +++++++++----------- addons/fire/functions/fnc_fireManagerPFH.sqf | 9 +++--- addons/zeus/functions/fnc_moduleBurn.sqf | 9 ++---- 6 files changed, 29 insertions(+), 38 deletions(-) diff --git a/addons/fire/XEH_postInit.sqf b/addons/fire/XEH_postInit.sqf index 9becb56b71..bfcecf80bf 100644 --- a/addons/fire/XEH_postInit.sqf +++ b/addons/fire/XEH_postInit.sqf @@ -60,7 +60,7 @@ if (!isServer) exitWith {}; private _hashedKey = hashValue _key; if (isNil "_hashedKey") exitWith { - ERROR_3("Unsupported key type used: %1 - %2 - %3",_key,typeName _key,typeOf _key); + ERROR_2("Unsupported key type used: %1 - %2 - %3",_key,typeName _key); }; // To avoid issues, remove existing entries first before overwriting @@ -77,7 +77,7 @@ if (!isServer) exitWith {}; private _hashedKey = hashValue _key; if (isNil "_hashedKey") exitWith { - ERROR_3("Unsupported key type used: %1 - %2 - %3",_key,typeName _key,typeOf _key); + ERROR_2("Unsupported key type used: %1 - %2 - %3",_key,typeName _key); }; (GVAR(fireSources) deleteAt _hashedKey) params [["_fireLogic", objNull]]; diff --git a/addons/fire/functions/fnc_burn.sqf b/addons/fire/functions/fnc_burn.sqf index 511133bfd0..defc822c54 100644 --- a/addons/fire/functions/fnc_burn.sqf +++ b/addons/fire/functions/fnc_burn.sqf @@ -18,7 +18,7 @@ */ if (!EGVAR(common,settingsInitFinished)) exitWith { - EGVAR(common,runAtSettingsInitialized) pushBack [FUNC(burn), _this]; + EGVAR(common,runAtSettingsInitialized) pushBack [LINKFUNC(burn), _this]; }; if (!GVAR(enabled)) exitWith {}; @@ -49,11 +49,10 @@ if (_unit call FUNC(isBurning)) exitWith { _unit setVariable [QGVAR(intensity), _intensity, true]; // Fire simulation (objects are handled differently) -private _burnSimulationJipID = [QGVAR(burnSimulation), [_unit, _instigator]] call CBA_fnc_globalEventJIP; -[_burnSimulationJipID, _unit] call CBA_fnc_removeGlobalEventJIP; +[QGVAR(burnSimulation), [_unit, _instigator], _unit] call CBA_fnc_targetEvent; // Spawn effects for unit private _burnEffectsJipID = [QGVAR(burnEffects), _unit] call CBA_fnc_globalEventJIP; [_burnEffectsJipID, _unit] call CBA_fnc_removeGlobalEventJIP; -_unit setVariable [QGVAR(jipIDs), [_burnSimulationJipID, _burnEffectsJipID], true]; +_unit setVariable [QGVAR(jipID), _burnEffectsJipID, true]; diff --git a/addons/fire/functions/fnc_burnIndicator.sqf b/addons/fire/functions/fnc_burnIndicator.sqf index 2874b69d11..5dbc1a8cbf 100644 --- a/addons/fire/functions/fnc_burnIndicator.sqf +++ b/addons/fire/functions/fnc_burnIndicator.sqf @@ -16,14 +16,15 @@ * Public: No */ -params ["_unit", "_pfhHandle"]; +params ["_unit", "_pfhID"]; if (!alive _unit || {!(_unit call FUNC(isBurning))}) exitWith { - _pfhHandle call CBA_fnc_removePerFrameHandler; + _pfhID call CBA_fnc_removePerFrameHandler; _unit setVariable [QGVAR(burnUIPFH), nil]; }; +// Don't show burn overlay if unconscious or dead if !(_unit call EFUNC(common,isAwake)) exitWith {}; private _iteration = _unit getVariable [QGVAR(indicatorIteration), 0]; diff --git a/addons/fire/functions/fnc_burnSimulation.sqf b/addons/fire/functions/fnc_burnSimulation.sqf index 764d6383f8..e48fa38ec4 100644 --- a/addons/fire/functions/fnc_burnSimulation.sqf +++ b/addons/fire/functions/fnc_burnSimulation.sqf @@ -12,29 +12,27 @@ * None * * Example: - * player call ace_fire_fnc_burnSimulation + * [player, player] call ace_fire_fnc_burnSimulation * * Public: No */ params ["_unit", "_instigator"]; -// Reset variables -_unit setVariable [QGVAR(stopDropRoll), nil]; -_unit setVariable [QGVAR(burnCounter), nil]; - [{ params ["_args", "_pfhID"]; _args params ["_unit", "_instigator"]; - private _remote = !local _unit; - - // If unit is local and the fire has died out, the effects need to be cleaned up -> do not stop PFH here - if (isNull _unit || {_remote && {!(_unit call FUNC(isBurning))}}) exitWith { + if (isNull _unit) exitWith { _pfhID call CBA_fnc_removePerFrameHandler; }; - if (_remote) exitWith {}; + // Locality has changed + if (!local _unit) exitWith { + _pfhID call CBA_fnc_removePerFrameHandler; + + [QGVAR(burnSimulation), [_unit, _instigator], _unit] call CBA_fnc_targetEvent; + }; // If unit is invulnerable or in water or if the fire has died out, stop burning unit if ( @@ -42,21 +40,18 @@ _unit setVariable [QGVAR(burnCounter), nil]; {!(isDamageAllowed _unit && {_unit getVariable [QEGVAR(medical,allowDamage), true]})} || {private _eyePos = eyePos _unit; surfaceIsWater _eyePos && {(_eyePos select 2) < 0.1}} ) exitWith { - // Remove global effects and simulation - { - _x call CBA_fnc_removeGlobalEventJIP; - } forEach (_unit getVariable [QGVAR(jipIDs), []]); + // Remove global effects + (_unit getVariable [QGVAR(jipID), ""]) call CBA_fnc_removeGlobalEventJIP; // Update globally that the unit isn't burning anymore _unit setVariable [QGVAR(intensity), nil, true]; _pfhID call CBA_fnc_removePerFrameHandler; - _unit setVariable [QGVAR(stopDropRoll), nil]; - _unit setVariable [QGVAR(burnCounter), nil]; - - if (!isPlayer _unit) then { + if (!isNil {_unit getVariable QGVAR(stopDropRoll)} && {!isPlayer _unit}) then { _unit setUnitPos "AUTO"; + + _unit setVariable [QGVAR(stopDropRoll), nil, true]; }; }; @@ -94,7 +89,7 @@ _unit setVariable [QGVAR(burnCounter), nil]; private _vehicle = objectParent _unit; if (isNull _vehicle && {_sdr || {0.05 > random 1}}) then { - _unit setVariable [QGVAR(stopDropRoll), true]; + _unit setVariable [QGVAR(stopDropRoll), true, true]; if (!_sdr) then { TRACE_1("stop, drop, roll!",_unit); diff --git a/addons/fire/functions/fnc_fireManagerPFH.sqf b/addons/fire/functions/fnc_fireManagerPFH.sqf index 74f744cc35..eb59faef72 100644 --- a/addons/fire/functions/fnc_fireManagerPFH.sqf +++ b/addons/fire/functions/fnc_fireManagerPFH.sqf @@ -4,14 +4,13 @@ * Handles various objects on fire and determines if units close to objects deserve to get burned. * * Arguments: - * 0: Args (not used) - * 1: PFH Handle (not used) + * None * * Return Value: * None * * Example: - * [[], -1] call CBA_fnc_addPerFrameHandler + * ace_fire_fnc_fireManagerPFH call CBA_fnc_addPerFrameHandler * * Public: No */ @@ -37,8 +36,8 @@ private _adjustedIntensity = 0; _distancePercent = 1 - ((_fireLogic distance _x) / _radius); _adjustedIntensity = _intensity * _distancePercent; - // Don't burn if intensity is too low - if (BURN_MIN_INTENSITY > _adjustedIntensity) then { + // Don't burn if intensity is too low or already burning with higher intensity + if (BURN_MIN_INTENSITY > _adjustedIntensity || {(_x getVariable [QGVAR(intensity), 0]) > _adjustedIntensity}) then { continue; }; diff --git a/addons/zeus/functions/fnc_moduleBurn.sqf b/addons/zeus/functions/fnc_moduleBurn.sqf index e3e78a5f7b..9fb3b085af 100644 --- a/addons/zeus/functions/fnc_moduleBurn.sqf +++ b/addons/zeus/functions/fnc_moduleBurn.sqf @@ -17,21 +17,18 @@ params ["_logic"]; -if !(local _logic) exitWith {}; +if (!local _logic) exitWith {}; private _unit = attachedTo _logic; deleteVehicle _logic; switch (false) do { - case !(isNull _unit): { + case (!isNull _unit): { [LSTRING(NothingSelected)] call FUNC(showMessage); }; - case (_unit isKindOf "CAManBase"): { + case (_unit isKindOf "CAManBase" && {getNumber (configOf _unit >> "isPlayableLogic") == 0}): { [LSTRING(OnlyInfantry)] call FUNC(showMessage); }; - case (alive _unit): { - [LSTRING(OnlyAlive)] call FUNC(showMessage); - }; case (["ace_fire"] call EFUNC(common,isModLoaded)): { [LSTRING(RequiresAddon)] call FUNC(showMessage); };