Skip to content

Commit

Permalink
Chemical - Add JCAD Chemical Detector (KAT-Advanced-Medical#628)
Browse files Browse the repository at this point in the history
**When merged this pull request will:**
- Adds a custom JCAD Chemical Detector 

### IMPORTANT

- [Development Guidelines](https://ace3.acemod.org/wiki/development/)
are read, understood and applied.
- Title of this PR uses our standard template `Component -
Add|Fix|Improve|Change|Make|Remove {changes}`.
  • Loading branch information
mazinskihenry authored Nov 12, 2024
1 parent d63a131 commit 9f8647e
Show file tree
Hide file tree
Showing 13 changed files with 206 additions and 4 deletions.
1 change: 0 additions & 1 deletion addons/chemical/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ class CfgVehicles {
};
};


class Box_NATO_AmmoOrd_F;
class ACE_Box_82mm_Mo_HE: Box_NATO_AmmoOrd_F {
class TransportMagazines;
Expand Down
9 changes: 9 additions & 0 deletions addons/chemical/CfgWeapons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ class CfgWeapons {
};
};

class ItemWatch;
class KAT_ChemicalDetector: ItemWatch {
ACE_hideItemType = "Watch";
author = "Mazinski";
descriptionShort = CSTRING(ChemicalDetectorDescription);
displayName = CSTRING(ChemicalDetectorDisplayName);
picture = QPATHTOF(UI\kat_chemicalDet_icon.paa);
};

class CannonCore;
class mortar_82mm: CannonCore {
magazines[] += {
Expand Down
83 changes: 83 additions & 0 deletions addons/chemical/RscTitles.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#define KAT_CHEM_GRID_WAbs (((safezoneW / safezoneH) min 0.7))
#define KAT_CHEM_GRID_HAbs ((((safezoneW / safezoneH) min 1.2) / 1.6))
#define KAT_CHEM_GRID_W ((((safeZoneW / safeZoneH) min 0.7) / 40))
#define KAT_CHEM_GRID_H (((((safeZoneW / safeZoneH) min 1.2) / 1.2) / 25))
#define KAT_CHEM_GRID_X ((safeZoneX + (safeZoneW - ((safeZoneW / safeZoneH) min 1.2)) / 11))
#define KAT_CHEM_GRID_Y ((safeZoneY + (safeZoneH - (((safeZoneW / safeZoneH) min 1.2) / 1.2)) / 0.8))

#define KAT_CHEM_POS_H(N) ((N) * KAT_CHEM_GRID_H)

#define ST_LEFT 0
#define ST_CENTER 2
#define ST_RIGHT 1

#define pixelW (1 / (getResolution select 2))
#define pixelH (1 / (getResolution select 3))
#define pixelScale 0.50

// pixel grids macros
#define UI_GRID_W (pixelW * pixelGridBase)
#define UI_GRID_H (pixelH * pixelGridBase)

#define SAFEZONE_X_RIGHTEDGE ((safeZoneX - 1) * -1)
#define SAFEZONE_Y_LOWEDGE ((safeZoneY - 1) * -1)

#define FRAME_W(N) ((UI_GRID_W * (N)) * (1.7777 / (getResolution select 4)))
#define FRAME_H(N) ((UI_GRID_H * (N)))

class RscTitles
{
class KAT_ChemicalDetector
{
idd = 18835;
enableSimulation = 1;
movingEnable = 0;
fadeIn=0;
fadeOut=1;
duration = 10e10;
onLoad = "uiNamespace setVariable ['KAT_ChemicalDetector', _this select 0];";
class controls
{
class KatChemIcon: RscPicture
{
idc = 18801;
text = "\x\kat\addons\chemical\UI\kat_chemicalDet.paa";
x = QUOTE(SAFEZONE_X_RIGHTEDGE - FRAME_W(25) - FRAME_W(15));
y = QUOTE(SAFEZONE_Y_LOWEDGE - FRAME_H(25));
w = QUOTE(FRAME_W(25));
h = QUOTE(FRAME_H(25));
};
class KatChemTime: RscText
{
idc = 18804;
style = ST_CENTER;
shadow = 0;
font = "PuristaBold";
text = "12:00"; //--- ToDo: Localize;
x = QUOTE(SAFEZONE_X_RIGHTEDGE - FRAME_W(25) - FRAME_W(7.2));
y = QUOTE(SAFEZONE_Y_LOWEDGE - FRAME_H(6));
w = QUOTE(FRAME_W(7.5));
h = QUOTE(FRAME_H(4));
colorBackground[] = {0,0,0,0};
colorText[] = {0.3,0.3,0.3,0.8};
sizeEx = QUOTE(FRAME_H(2));
};
class KatChemStrength: RscText
{
idc = 18805;
style = ST_RIGHT;
valign = "middle";
shadow = 0;
font = "PuristaBold";
text = "0"; //--- ToDo: Localize;
x = QUOTE(SAFEZONE_X_RIGHTEDGE - FRAME_W(25) - FRAME_W(2.1));
y = QUOTE(SAFEZONE_Y_LOWEDGE - FRAME_H(7.5));
w = QUOTE(FRAME_W(5));
h = QUOTE(FRAME_H(3));
colorBackground[] = {0,0,0,0};
colorText[] = {0.3,0.3,0.3,0.8};
sizeEx = QUOTE(FRAME_H(2.2));
};
};
};
};
2 changes: 2 additions & 0 deletions addons/chemical/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ PREP(handleGasMaskDur);
PREP(handleRespawn);
PREP(hasGasmask);
PREP(hasGasMaskON);
PREP(hideChemDetector);
PREP(init);
PREP(initModule);
PREP(showChemDetector);
PREP(spawnSmoke);
PREP(throwGrenade);
PREP(treatmentAdvanced_AtropineLocal);
Expand Down
13 changes: 13 additions & 0 deletions addons/chemical/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,16 @@ if (hasInterface) then {
private _items = missionNamespace getVariable [QGVAR(availGasmask), "'G_AirPurifyingRespirator_01_F'"];
private _array = [_items, "CfgGlasses"] call FUNC(getList);
missionNamespace setVariable [QGVAR(availGasmaskList), _array, true];

["KAT_ChemicalDetector", QGVAR(showChemDetector), "Show Chemical Detector", {
// Conditions: canInteract
if (!([ACE_player, objNull, ["isNotEscorting", "isNotInside"]] call ACEFUNC(common,canInteractWith)) || {!('KAT_ChemicalDetector' in assignedItems ACE_player)}) exitWith { false };

if !(GETMVAR(GVAR(ChemDetectorActive),false)) then {
[ACE_player] call FUNC(showChemDetector);
} else {
call FUNC(hideChemDetector);
};

true
}, { false }, [24, [false, false, false]], false] call CBA_fnc_addKeybind;
4 changes: 3 additions & 1 deletion addons/chemical/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class CfgPatches {
"kat_gasmaskFilter",
"KAT_M7A3",
"KAT_CAS_M43_Bomb",
"KAT_CAS_R_80mm_GAS_POD"
"KAT_CAS_R_80mm_GAS_POD",
"KAT_ChemicalDetector"
};
ammo[] = {
"KAT_Gas_TripWireMine_Ammo",
Expand Down Expand Up @@ -60,5 +61,6 @@ class CfgPatches {
#include "CfgVehicles.hpp"
#include "CfgSounds.hpp"
#include "ui\RscAttributes.hpp"
#include "RscTitles.hpp"
#include "ACE_Medical_Treatment_Actions.hpp"
#include "CfgGlasses.hpp"
1 change: 1 addition & 0 deletions addons/chemical/functions/fnc_gasCheck.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ _radius_min = if (_radius_min isEqualTo 0) then {_radius_max / 2} else {_radius_
_logic setVariable [QGVAR(gas_active), true, true];
_logic setVariable [QGVAR(gas_playerArr), [], true];
_logic setVariable [QGVAR(gas_position), _position, true];
_logic setVariable [QGVAR(gas_radius), _radius_max, true];

// Function to check players within the gas zone
private _checkPlayers = {
Expand Down
19 changes: 19 additions & 0 deletions addons/chemical/functions/fnc_hideChemDetector.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "..\script_component.hpp"
/*
* Author: Garth 'L-H' de Wet
* Modified: Mazinski
* Removes the KWatch from the screen.
*
* Arguments:
* None
*
* Return Value:
* None
*
* Example:
* call kat_watch_fnc_hideKWatch
*
* Public: No
*/
GVAR(ChemDetectorActive) = false;
"KAT_ChemicalDetector" cutText ["","PLAIN",0,true];
70 changes: 70 additions & 0 deletions addons/chemical/functions/fnc_showChemDetector.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#include "..\script_component.hpp"
/*
* Author: Garth 'L-H' de Wet
* Modified: Mazinski
* Displays the KWatch on screen.
*
* Arguments:
* 0: unit <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player] call kat_watch_fnc_showKWatch
*
* Public: Yes
*/

params ["_unit"];

"KAT_ChemicalDetector" cutRsc ["KAT_ChemicalDetector", "PLAIN", 0, true];

if (isNull (uiNamespace getVariable ["KAT_ChemicalDetector", displayNull])) exitWith {};

GVAR(ChemDetectorActive) = true;

private _display = uiNamespace getVariable ["KAT_ChemicalDetector", displayNull];
private _background = _display displayCtrl 18801;
private _time = _display displayCtrl 18804;
private _exposure = _display displayCtrl 18805;

[{
_this params ["_args", "_pfhID"];
_args params ["_unit", "_time", "_exposure"];

if !(GVAR(ChemDetectorActive)) exitWith {
_pfhID call CBA_fnc_removePerFrameHandler;
};

if !(alive _unit) exitWith {
call FUNC(hideChemDetector);
_pfhID call CBA_fnc_removePerFrameHandler;
};

if !("KAT_ChemicalDetector" in assignedItems _unit) exitWith {
call FUNC(hideChemDetector);
_pfhID call CBA_fnc_removePerFrameHandler;
};

private _hour = floor dayTime;
private _minute = floor ((dayTime - _hour) * 60);

_time ctrlSetText (format ["%1:%2", [_hour, 2] call CBA_fnc_formatNumber, [_minute, 2] call CBA_fnc_formatNumber]);

private _gas = nearestObjects [_unit, ["kat_module_zeus_gas"], 2000];

if ((count _gas) > 0) then {
private _distance = _unit distance (_gas select 0);
private _radius = (_gas select 0) getVariable [QGVAR(gas_radius), 0];

_exposure ctrlSetText ((linearConversion[0, _radius, _distance, 1, 0, true]) toFixed 2);
} else {
_exposure ctrlSetText str (0);
};

}, 1, [
_unit,
_time,
_exposure
]] call CBA_fnc_addPerFrameHandler;
6 changes: 6 additions & 0 deletions addons/chemical/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@
<Russian>Герметик, который используется для герметизации предметов, например, при утечке токсичного вещества</Russian>
<Dutch>Afdichtmiddel dat gebruikt wordt om een object te dichten wanneer er bijvoorbeeld een giftige stof lekt</Dutch>
</Key>
<Key ID="STR_KAT_Chemical_ChemicalDetectorDisplayName">
<English>JCAD Chemical Detector</English>
</Key>
<Key ID="STR_KAT_Chemical_ChemicalDetectorDescription">
<English>Used to detect KAT toxic chemicals</English>
</Key>
<Key ID="STR_KAT_Chemical_giveGasMask_action">
<English>Put on gas mask</English>
<Spanish>Poner mascara de gas</Spanish>
Expand Down
2 changes: 0 additions & 2 deletions addons/chemical/ui/RscAttributes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ class RscPicture;
class ctrlToolbox;
class RscButton;



class RscDisplayAttributes {
class Controls {
class Background;
Expand Down
Binary file added addons/chemical/ui/kat_chemicalDet.paa
Binary file not shown.
Binary file added addons/chemical/ui/kat_chemicalDet_icon.paa
Binary file not shown.

0 comments on commit 9f8647e

Please sign in to comment.