Fixed headers, made fire simulation local

This commit is contained in:
johnb432 2024-04-01 22:59:11 +02:00
parent c0344ee9c0
commit 2af0da4853
6 changed files with 29 additions and 38 deletions

View File

@ -60,7 +60,7 @@ if (!isServer) exitWith {};
private _hashedKey = hashValue _key; private _hashedKey = hashValue _key;
if (isNil "_hashedKey") exitWith { 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 // To avoid issues, remove existing entries first before overwriting
@ -77,7 +77,7 @@ if (!isServer) exitWith {};
private _hashedKey = hashValue _key; private _hashedKey = hashValue _key;
if (isNil "_hashedKey") exitWith { 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]]; (GVAR(fireSources) deleteAt _hashedKey) params [["_fireLogic", objNull]];

View File

@ -18,7 +18,7 @@
*/ */
if (!EGVAR(common,settingsInitFinished)) exitWith { if (!EGVAR(common,settingsInitFinished)) exitWith {
EGVAR(common,runAtSettingsInitialized) pushBack [FUNC(burn), _this]; EGVAR(common,runAtSettingsInitialized) pushBack [LINKFUNC(burn), _this];
}; };
if (!GVAR(enabled)) exitWith {}; if (!GVAR(enabled)) exitWith {};
@ -49,11 +49,10 @@ if (_unit call FUNC(isBurning)) exitWith {
_unit setVariable [QGVAR(intensity), _intensity, true]; _unit setVariable [QGVAR(intensity), _intensity, true];
// Fire simulation (objects are handled differently) // Fire simulation (objects are handled differently)
private _burnSimulationJipID = [QGVAR(burnSimulation), [_unit, _instigator]] call CBA_fnc_globalEventJIP; [QGVAR(burnSimulation), [_unit, _instigator], _unit] call CBA_fnc_targetEvent;
[_burnSimulationJipID, _unit] call CBA_fnc_removeGlobalEventJIP;
// Spawn effects for unit // Spawn effects for unit
private _burnEffectsJipID = [QGVAR(burnEffects), _unit] call CBA_fnc_globalEventJIP; private _burnEffectsJipID = [QGVAR(burnEffects), _unit] call CBA_fnc_globalEventJIP;
[_burnEffectsJipID, _unit] call CBA_fnc_removeGlobalEventJIP; [_burnEffectsJipID, _unit] call CBA_fnc_removeGlobalEventJIP;
_unit setVariable [QGVAR(jipIDs), [_burnSimulationJipID, _burnEffectsJipID], true]; _unit setVariable [QGVAR(jipID), _burnEffectsJipID, true];

View File

@ -16,14 +16,15 @@
* Public: No * Public: No
*/ */
params ["_unit", "_pfhHandle"]; params ["_unit", "_pfhID"];
if (!alive _unit || {!(_unit call FUNC(isBurning))}) exitWith { if (!alive _unit || {!(_unit call FUNC(isBurning))}) exitWith {
_pfhHandle call CBA_fnc_removePerFrameHandler; _pfhID call CBA_fnc_removePerFrameHandler;
_unit setVariable [QGVAR(burnUIPFH), nil]; _unit setVariable [QGVAR(burnUIPFH), nil];
}; };
// Don't show burn overlay if unconscious or dead
if !(_unit call EFUNC(common,isAwake)) exitWith {}; if !(_unit call EFUNC(common,isAwake)) exitWith {};
private _iteration = _unit getVariable [QGVAR(indicatorIteration), 0]; private _iteration = _unit getVariable [QGVAR(indicatorIteration), 0];

View File

@ -12,29 +12,27 @@
* None * None
* *
* Example: * Example:
* player call ace_fire_fnc_burnSimulation * [player, player] call ace_fire_fnc_burnSimulation
* *
* Public: No * Public: No
*/ */
params ["_unit", "_instigator"]; params ["_unit", "_instigator"];
// Reset variables
_unit setVariable [QGVAR(stopDropRoll), nil];
_unit setVariable [QGVAR(burnCounter), nil];
[{ [{
params ["_args", "_pfhID"]; params ["_args", "_pfhID"];
_args params ["_unit", "_instigator"]; _args params ["_unit", "_instigator"];
private _remote = !local _unit; if (isNull _unit) exitWith {
// 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 {
_pfhID call CBA_fnc_removePerFrameHandler; _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 unit is invulnerable or in water or if the fire has died out, stop burning unit
if ( if (
@ -42,21 +40,18 @@ _unit setVariable [QGVAR(burnCounter), nil];
{!(isDamageAllowed _unit && {_unit getVariable [QEGVAR(medical,allowDamage), true]})} || {!(isDamageAllowed _unit && {_unit getVariable [QEGVAR(medical,allowDamage), true]})} ||
{private _eyePos = eyePos _unit; surfaceIsWater _eyePos && {(_eyePos select 2) < 0.1}} {private _eyePos = eyePos _unit; surfaceIsWater _eyePos && {(_eyePos select 2) < 0.1}}
) exitWith { ) exitWith {
// Remove global effects and simulation // Remove global effects
{ (_unit getVariable [QGVAR(jipID), ""]) call CBA_fnc_removeGlobalEventJIP;
_x call CBA_fnc_removeGlobalEventJIP;
} forEach (_unit getVariable [QGVAR(jipIDs), []]);
// Update globally that the unit isn't burning anymore // Update globally that the unit isn't burning anymore
_unit setVariable [QGVAR(intensity), nil, true]; _unit setVariable [QGVAR(intensity), nil, true];
_pfhID call CBA_fnc_removePerFrameHandler; _pfhID call CBA_fnc_removePerFrameHandler;
_unit setVariable [QGVAR(stopDropRoll), nil]; if (!isNil {_unit getVariable QGVAR(stopDropRoll)} && {!isPlayer _unit}) then {
_unit setVariable [QGVAR(burnCounter), nil];
if (!isPlayer _unit) then {
_unit setUnitPos "AUTO"; _unit setUnitPos "AUTO";
_unit setVariable [QGVAR(stopDropRoll), nil, true];
}; };
}; };
@ -94,7 +89,7 @@ _unit setVariable [QGVAR(burnCounter), nil];
private _vehicle = objectParent _unit; private _vehicle = objectParent _unit;
if (isNull _vehicle && {_sdr || {0.05 > random 1}}) then { if (isNull _vehicle && {_sdr || {0.05 > random 1}}) then {
_unit setVariable [QGVAR(stopDropRoll), true]; _unit setVariable [QGVAR(stopDropRoll), true, true];
if (!_sdr) then { if (!_sdr) then {
TRACE_1("stop, drop, roll!",_unit); TRACE_1("stop, drop, roll!",_unit);

View File

@ -4,14 +4,13 @@
* Handles various objects on fire and determines if units close to objects deserve to get burned. * Handles various objects on fire and determines if units close to objects deserve to get burned.
* *
* Arguments: * Arguments:
* 0: Args (not used) <ARRAY> * None
* 1: PFH Handle (not used) <NUMBER>
* *
* Return Value: * Return Value:
* None * None
* *
* Example: * Example:
* [[], -1] call CBA_fnc_addPerFrameHandler * ace_fire_fnc_fireManagerPFH call CBA_fnc_addPerFrameHandler
* *
* Public: No * Public: No
*/ */
@ -37,8 +36,8 @@ private _adjustedIntensity = 0;
_distancePercent = 1 - ((_fireLogic distance _x) / _radius); _distancePercent = 1 - ((_fireLogic distance _x) / _radius);
_adjustedIntensity = _intensity * _distancePercent; _adjustedIntensity = _intensity * _distancePercent;
// Don't burn if intensity is too low // Don't burn if intensity is too low or already burning with higher intensity
if (BURN_MIN_INTENSITY > _adjustedIntensity) then { if (BURN_MIN_INTENSITY > _adjustedIntensity || {(_x getVariable [QGVAR(intensity), 0]) > _adjustedIntensity}) then {
continue; continue;
}; };

View File

@ -17,21 +17,18 @@
params ["_logic"]; params ["_logic"];
if !(local _logic) exitWith {}; if (!local _logic) exitWith {};
private _unit = attachedTo _logic; private _unit = attachedTo _logic;
deleteVehicle _logic; deleteVehicle _logic;
switch (false) do { switch (false) do {
case !(isNull _unit): { case (!isNull _unit): {
[LSTRING(NothingSelected)] call FUNC(showMessage); [LSTRING(NothingSelected)] call FUNC(showMessage);
}; };
case (_unit isKindOf "CAManBase"): { case (_unit isKindOf "CAManBase" && {getNumber (configOf _unit >> "isPlayableLogic") == 0}): {
[LSTRING(OnlyInfantry)] call FUNC(showMessage); [LSTRING(OnlyInfantry)] call FUNC(showMessage);
}; };
case (alive _unit): {
[LSTRING(OnlyAlive)] call FUNC(showMessage);
};
case (["ace_fire"] call EFUNC(common,isModLoaded)): { case (["ace_fire"] call EFUNC(common,isModLoaded)): {
[LSTRING(RequiresAddon)] call FUNC(showMessage); [LSTRING(RequiresAddon)] call FUNC(showMessage);
}; };