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

Fire - Remove medical_engine dependency #10122

Merged
merged 2 commits into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions addons/fire/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#include "script_component.hpp"

[QGVAR(burn), LINKFUNC(burn)] call CBA_fnc_addEventHandler;
[QGVAR(burnEffects), LINKFUNC(burnEffects)] call CBA_fnc_addEventHandler;
[QGVAR(burnSimulation), LINKFUNC(burnSimulation)] call CBA_fnc_addEventHandler;
["CBA_settingsInitialized", {
TRACE_1("settingsInitialized",GVAR(enabled));

[QGVAR(playScream), {
params ["_scream", "_source"];
if (!GVAR(enabled)) exitWith {};

// Only play sound if enabled in settings and enabled for the unit
if (GVAR(enableScreams) && {_source getVariable [QGVAR(enableScreams), true]}) then {
_source say3D _scream;
};
}] call CBA_fnc_addEventHandler;
[QGVAR(burn), LINKFUNC(burn)] call CBA_fnc_addEventHandler;
[QGVAR(burnEffects), LINKFUNC(burnEffects)] call CBA_fnc_addEventHandler;
[QGVAR(burnSimulation), LINKFUNC(burnSimulation)] call CBA_fnc_addEventHandler;

if (!isServer) exitWith {};
[QGVAR(playScream), {
params ["_scream", "_source"];

["CBA_settingsInitialized", {
TRACE_1("settingsInit",GVAR(enabled));
// Only play sound if enabled in settings and enabled for the unit
if (GVAR(enableScreams) && {_source getVariable [QGVAR(enableScreams), true]}) then {
_source say3D _scream;
};
}] call CBA_fnc_addEventHandler;

if (!GVAR(enabled)) exitWith {};
if (!isServer) exitWith {};

GVAR(fireSources) = createHashMap;

Expand Down
20 changes: 20 additions & 0 deletions addons/fire/compat_medical_engine/config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "script_component.hpp"

class CfgPatches {
class SUBADDON {
name = COMPONENT_NAME;
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_medical_engine"};
skipWhenMissingDependencies = 1;
author = ECSTRING(common,ACETeam);
authors[] = {};
url = ECSTRING(main,URL);
VERSION_CONFIG;

addonRootClass = QUOTE(ADDON);
};
};

#include "ACE_Medical_Treatment_Actions.hpp"
3 changes: 3 additions & 0 deletions addons/fire/compat_medical_engine/script_component.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#define SUBCOMPONENT medical_engine
#define SUBCOMPONENT_BEAUTIFIED Medical Engine
#include "..\script_component.hpp"
13 changes: 1 addition & 12 deletions addons/fire/config.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
#include "script_component.hpp"

#pragma hemtt flag pe23_ignore_has_include
#if __has_include("\z\ace\addons\nomedical\script_component.hpp")
#define PATCH_SKIP "No Medical"
#endif

#ifdef PATCH_SKIP
ACE_PATCH_NOT_LOADED(ADDON,PATCH_SKIP)
#else
class CfgPatches {
class ADDON {
name = COMPONENT_NAME;
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common", "ace_medical_engine"};
requiredAddons[] = {"ace_common"};
author = ECSTRING(common,ACETeam);
authors[] = {"commy2", "tcvm"};
url = ECSTRING(main,URL);
Expand All @@ -25,7 +17,4 @@ class CfgPatches {
#include "CfgEventHandlers.hpp"
#include "CfgSounds.hpp"
#include "CfgVehicles.hpp"
#include "ACE_Medical_Treatment_Actions.hpp"
#include "RscTitles.hpp"

#endif
28 changes: 18 additions & 10 deletions addons/fire/functions/fnc_burnSimulation.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,27 @@ params ["_unit", "_instigator"];
_unit call FUNC(burnReaction);
};

if (!isNull _instigator) then {
_unit setVariable [QEGVAR(medical,lastDamageSource), _instigator];
_unit setVariable [QEGVAR(medical,lastInstigator), _instigator];
};
// Keep pain around unconsciousness limit to allow for more fun interactions
private _damageToAdd = [0.15, _intensity / BURN_MAX_INTENSITY] select (!alive _unit || {GET_PAIN_PERCEIVED(_unit) < (PAIN_UNCONSCIOUS + random 0.2)});

if (GETEGVAR(medical,enabled,false)) then {
if (!isNull _instigator) then {
_unit setVariable [QEGVAR(medical,lastDamageSource), _instigator];
_unit setVariable [QEGVAR(medical,lastInstigator), _instigator];
};

// Common burn areas are the hands and face https://www.ncbi.nlm.nih.gov/pubmed/16899341/
private _bodyPart = ["Head", "Body", "LeftArm", "RightArm", "LeftLeg", "RightLeg"] selectRandomWeighted [0.77, 0.5, 0.8, 0.8, 0.3, 0.3];
// Common burn areas are the hands and face https://www.ncbi.nlm.nih.gov/pubmed/16899341/
private _bodyPart = ["Head", "Body", "LeftArm", "RightArm", "LeftLeg", "RightLeg"] selectRandomWeighted [0.77, 0.5, 0.8, 0.8, 0.3, 0.3];

// Keep pain around unconciousness limit to allow for more fun interactions
private _damageToAdd = [0.15, _intensity / BURN_MAX_INTENSITY] select (!alive _unit || {GET_PAIN_PERCEIVED(_unit) < (PAIN_UNCONSCIOUS + random 0.2)});
// Use event directly, as ace_medical_fnc_addDamageToUnit requires unit to be alive
[QEGVAR(medical,woundReceived), [_unit, [[_damageToAdd, _bodyPart, _damageToAdd]], _instigator, "burn"]] call CBA_fnc_localEvent;
} else {
private _bodyParts = [["HitFace", "HitNeck", "HitHead"], ["HitPelvis", "HitAbdomen", "HitDiaphragm", "HitChest", "HitBody"], ["HitArms", "HitHands"], ["HitLegs"]] selectRandomWeighted [0.77, 0.5, 0.8, 0.3];

// Use event directly, as ace_medical_fnc_addDamageToUnit requires unit to be alive
[QEGVAR(medical,woundReceived), [_unit, [[_damageToAdd, _bodyPart, _damageToAdd]], _instigator, "burn"]] call CBA_fnc_localEvent;
{
_unit setHitPointDamage [_x, (_unit getHitPointDamage _x) + _damageToAdd, true, _instigator, _instigator];
} forEach _bodyParts;
};

_unit setVariable [QGVAR(intensity), _intensity, true]; // Globally sync intensity across all clients to make sure simulation is deterministic
};
Expand Down
2 changes: 1 addition & 1 deletion addons/fire/initSettings.inc.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
LSTRING(Category_DisplayName),
true,
1,
{[QGVAR(fireEnabled), _this] call EFUNC(common,cbaSettings_settingChanged)},
{[QGVAR(enabled), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_fnc_addSetting;

Expand Down
7 changes: 7 additions & 0 deletions addons/fire/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@
#endif

#include "\z\ace\addons\main\script_macros.hpp"

#pragma hemtt flag pe23_ignore_has_include
#if __has_include("\z\ace\addons\medical_engine\script_macros_medical.hpp")
#include "\z\ace\addons\medical_engine\script_macros_medical.hpp"
#else
#define GET_PAIN_PERCEIVED(var) 0
#define PAIN_UNCONSCIOUS 1
#endif

#define FIRE_MANAGER_PFH_DELAY 0.25
#define FLARE_SIZE_MODIFIER 5
Expand Down