Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chemical - Add missing entries and zones #650

Merged
12 changes: 11 additions & 1 deletion addons/chemical/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ PREP_RECOMPILE_END;
[
QGVAR(gasMaskSoundVolume),
"SLIDER",
[LLSTRING(SETTING_stethoscopeSoundVolume), LLSTRING(SETTING_stethoscopeSoundVolume_DESC)],
[LLSTRING(SETTING_gasMaskSoundVolume), LLSTRING(SETTING_gasMaskSoundVolume_DESC)],
CBA_SETTINGS_CHEM,
[0, 2, 1, 1],
2,
Expand All @@ -54,4 +54,14 @@ PREP_RECOMPILE_END;
[0, 1, 0, 2, true],
true
] call CBA_Settings_fnc_init;

// Infection time
[
QGVAR(infectionTime),
"TIME",
[LLSTRING(SETTING_infectionTime), LLSTRING(SETTING_infectionTime_DESC)],
CBA_SETTINGS_CHEM,
[0, 3600, 60],
true
] call CBA_Settings_fnc_init;
ADDON = true;
2 changes: 2 additions & 0 deletions addons/chemical/functions/fnc_fullHealLocal.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ TRACE_1("fullHealLocal kat chemical",_patient);
_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);
2 changes: 2 additions & 0 deletions addons/chemical/functions/fnc_gasmodule.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ private _radius = _logic getVariable ["Radius", 20];
private _gasLevel = _logic getVariable ["GAS_type", 0];
private _isSealable = _logic getVariable ["IsSealable", false];

if (count _units == 0) then {_units pushBack _logic;};

if (!_activated) exitWith {};
if (isServer) then {

Expand Down
44 changes: 33 additions & 11 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 All @@ -37,15 +37,37 @@ if ((goggles _unit in (missionNamespace getVariable [QGVAR(availGasmaskList), []
[QGVAR(handleGasMaskDur), _unit, _unit] call CBA_fnc_targetEvent;
};

switch (_gasLevel) do {
case 0: {
_unit setVariable [QGVAR(CSGas), 30, true];
if (random 1 <= GVAR(tearGasDropChance)) then {
[QACEGVAR(hitreactions,dropWeapon), _unit, _unit] call CBA_fnc_targetEvent;
};
if (_gasLevel == 0) exitWith {
_unit setVariable [QGVAR(CSGas), 30, true];
if (random 1 <= GVAR(tearGasDropChance)) then {
[QACEGVAR(hitreactions,dropWeapon), _unit, _unit] call CBA_fnc_targetEvent;
};
case 1: {
_unit setVariable [QGVAR(airPoisoning), true, true];
};
default {};
};

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];

//Get current time left for player
private _currentInfection = _unit getVariable [QGVAR(infectionTime), 60];

private _timeLeft = _currentInfection - 1;
_timeLeft = _timeLeft max 0;

private _newTime = _timeLeft;

if (_currentInfection != _newTime) then {
_unit setVariable [QGVAR(infectionTime), _newTime, true];
};

// Exit if infection reaches 0
if (_newTime <= 0) then {
_unit setVariable [QGVAR(airPoisoning), true, true];
};
12 changes: 8 additions & 4 deletions addons/chemical/functions/fnc_ui_gasModule.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ if !(isNull attachedTo _logic) then {
};
default {};
};

} else {
[LLSTRING(OnlyObject)] call _fnc_errorAndClose;
};

private _fnc_onUnload = {
Expand Down Expand Up @@ -78,8 +75,15 @@ private _fnc_onConfirm = {
private _gasLevel = _display getVariable [QGVAR(ui_gastype), 0];
private _radius = _display getVariable [QGVAR(ui_radius), 20];
private _isSealable = _display getVariable [QGVAR(ui_sealable), false];
private _center = objNull;

if (isNull attachedTo _logic) then {
_center = _logic;
} else {
_center = attachedTo _logic;
};

[QGVAR(addGasSource), [attachedTo _logic, _radius, _gasLevel, _logic, {
[QGVAR(addGasSource), [_center, _radius, _gasLevel, _logic, {
params ["_endTime", "_logic"];

// If logic no longer exists, exit
Expand Down
2 changes: 1 addition & 1 deletion addons/chemical/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
#define X_PART(num) (W_PART(num) + (safeZoneX + (safeZoneW - SIZEX) / 2))
#define Y_PART(num) (H_PART(num) + (safeZoneY + (safeZoneH - SIZEY) / 2))

#define GAS_MANAGER_PFH_DELAY 0.25
#define GAS_MANAGER_PFH_DELAY 1
15 changes: 8 additions & 7 deletions addons/chemical/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<Russian>Определяет, как долго вы можете находиться в газе с противогазом без заражения.</Russian>
<Dutch>Bepaald hoelang je in gas kan staan zonder dat je geïnfecteerd raakt.</Dutch>
</Key>
<Key ID="STR_KAT_Chemical_SETTING_infection_time">
<Key ID="STR_KAT_Chemical_SETTING_infectionTime">
<English>Time until infection</English>
<Spanish>Tiempo hasta la infeccion</Spanish>
<German>Zeit bis zur Infektion</German>
Expand All @@ -76,7 +76,7 @@
<Russian>Время до заражения</Russian>
<Dutch>Tijd tot infectie</Dutch>
</Key>
<Key ID="STR_KAT_Chemical_SETTING_infection_time_disc">
<Key ID="STR_KAT_Chemical_SETTING_infectionTime_DESC">
<English>Time you can stand in the gas before you get infected or need a gas mask.</English>
<Spanish>Tiempo que puedes resistir en el gas hasta que resultes infectado o requieras una mascara de gas</Spanish>
<German>Die Zeit, in der man im Gas stehen kann, bevor man infiziert wird bzw. eine Gasmaske benötigt.</German>
Expand Down Expand Up @@ -787,11 +787,6 @@
<Japanese>ガスマスク使用時の呼吸音の大きさを設定します</Japanese>
<French>Détermine l'intensité des bruits respiratoires lors de l'utilisation du masque à gaz.</French>
</Key>
<Key ID="STR_KAT_Chemical_OnlyObject">
<English>Must be placed on object</English>
<Japanese>オブジェクトに配置する必要があります</Japanese>
<French>Doit être placé sur un objet</French>
</Key>
<Key ID="STR_KAT_Chemical_PutOnGasMask">
<English>Put on gas mask</English>
<Japanese>ガスマスクを装着</Japanese>
Expand All @@ -802,5 +797,11 @@
<Japanese>ガスマスクを外す</Japanese>
<French>Enlever le masque à gaz</French>
</Key>
<Key ID="STR_KAT_Chemical_SETTING_dropWeaponChance">
<English>Drop Weapon Chance</English>
</Key>
<Key ID="STR_KAT_Chemical_SETTING_dropWeaponChance_DESC">
<English>Determines chance for dropping weapon while in tear gas</English>
</Key>
</Package>
</Project>
23 changes: 23 additions & 0 deletions addons/vitals/functions/fnc_handlePoisoning.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,26 @@ params ["_unit", "_poisonAdjustment", "_deltaT", "_syncValue"];
private _currentCS = _unit getVariable [QEGVAR(chemical,CSGas), 0];

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

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 {
{
_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];
};
1 change: 1 addition & 0 deletions addons/vitals/functions/fnc_handleSimpleVitals.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ if !(_adjustments isEqualTo []) then {

private _heartRate = [_unit, _hrTargetAdjustment, _deltaT, _syncValues] call ACEFUNC(medical_vitals,updateHeartRate); //Rename
[_unit, _painSupressAdjustment, _deltaT, _syncValues] call ACEFUNC(medical_vitals,updatePainSuppress); //Leave alone
[_unit, POISON_DECREASE, _deltaT, _syncValues] call FUNC(handlePoisoning);

private _bloodPressure = [80,120];
_unit setVariable [VAR_BLOOD_PRESS, _bloodPressure, _syncValues];
Expand Down
Loading