Skip to content

Commit

Permalink
Add infectionArray
Browse files Browse the repository at this point in the history
  • Loading branch information
mazinskihenry committed Dec 12, 2024
1 parent 86a5888 commit cd28c9a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
1 change: 1 addition & 0 deletions addons/chemical/functions/fnc_fullHealLocal.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ _patient setVariable [QGVAR(gasmask_durability), 10, true];
_patient setVariable [QGVAR(CSGas), 0, true];
_patient setVariable [QGVAR(airPoisoning), false, true];
_patient setVariable [QGVAR(infectionTime), missionNamespace getVariable [QGVAR(infectionTime), 60], true];
_patient setVariable [QGVAR(infectionArray), [], true];
5 changes: 3 additions & 2 deletions addons/chemical/functions/fnc_gasManagerPFH.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
_y params ["_gasLogic", "_radius", "_gasLevel", "_condition", "_conditionArgs", "_isSealable"];
TRACE_2("gasManagerPFH loop",_x,_y);

private _infectedObject = _y;

// Remove when condition is no longer valid
if !(_conditionArgs call _condition) then {
TRACE_2("condition no longer valid, deleting",_x,_y);
Expand All @@ -34,7 +36,6 @@

// Poison units (alive or dead) close to the gas source
{

// Get the distance of the unit from the center of the sphere (_gasLogic)
private _distance = _x distance _gasLogic;

Expand All @@ -46,7 +47,7 @@

_x setVariable [QGVAR(areaIntensity), _intensity, true];

[QGVAR(poison), [_x, _gasLevel], _x] call CBA_fnc_targetEvent;
[QGVAR(poison), [_x, _gasLevel, _infectedObject], _x] call CBA_fnc_targetEvent;

} forEach nearestObjects [_gasLogic, ["CAManBase"], _radius];
} forEach GVAR(gasSources);
12 changes: 10 additions & 2 deletions addons/chemical/functions/fnc_poison.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Public: No
*/

params ["_unit", "_gasLevel"];
params ["_unit", "_gasLevel", "_infectedObject"];

// Check if unit is remote (objNull is remote)
if (!local _unit) exitWith {
Expand Down Expand Up @@ -44,6 +44,14 @@ if (_gasLevel == 0) exitWith {
};
};

private _currentInfectionArray = _unit getVariable [QGVAR(infectionArray), []];

if ((_currentInfectionArray findIf { _x isEqualTo _infectedObject}) == -1) then {
_currentInfectionArray append [_infectedObject];
};

_unit setVariable [QGVAR(infectionArray), _currentInfectionArray, true];

//Get max infection time
private _infectionTime = missionNamespace getVariable [QGVAR(infectionTime), 60];

Expand All @@ -62,4 +70,4 @@ if (_currentInfection != _newTime) then {
// Exit if infection reaches 0
if (_newTime <= 0) then {
_unit setVariable [QGVAR(airPoisoning), true, true];
};
};
19 changes: 16 additions & 3 deletions addons/vitals/functions/fnc_handlePoisoning.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,25 @@ private _currentCS = _unit getVariable [QEGVAR(chemical,CSGas), 0];

_unit setVariable [QEGVAR(chemical,CSGas), (_currentCS - (_poisonAdjustment * _deltaT)) max 0, _syncValue];

if !(_unit getVariable [QEGVAR(chemical,airPoisoning), false]) then {
private _infectionArray = _unit getVariable [QEGVAR(chemical,infectionArray), []];

if (count _infectionArray == 0) then {
private _currentInfection = _unit getVariable [QEGVAR(chemical,infectionTime), missionNamespace getVariable [QEGVAR(chemical,infectionTime), 60]];
private _updateTime = _currentInfection + (1 * _deltaT);
_updateTime = _updateTime min (missionNamespace getVariable [QEGVAR(chemical,infectionTime), 60]);

_unit setVariable [QEGVAR(chemical,infectionTime), _updateTime, true];
} else {
_unit setVariable [QEGVAR(chemical,infectionTime), 0, true];
};
{
_x params ["_gasLogic", "_radius", "_gasLevel", "_condition", "_conditionArgs", "_isSealable"];

// Get the distance of the unit from the center of the sphere (_gasLogic)
private _distance = _unit distance _gasLogic;

if (_distance > _radius) then {
_infectionArray deleteAt _forEachIndex;
};
} forEach _infectionArray;

_unit setVariable [QEGVAR(chemical,infectionArray), _infectionArray, true];
};

0 comments on commit cd28c9a

Please sign in to comment.