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

General - Events for Mods #9813

Merged
merged 11 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from 10 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
1 change: 1 addition & 0 deletions addons/medical_engine/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ if (isNil QUOTE(BLOOD_LOSS_KNOCK_OUT_THRESHOLD)) then {BLOOD_LOSS_KNOCK_OUT_THRE
if (isNil QUOTE(PAIN_FADE_TIME)) then {PAIN_FADE_TIME = PAIN_FADE_TIME_DEFAULT};
if (isNil QUOTE(LIMPING_DAMAGE_THRESHOLD)) then {LIMPING_DAMAGE_THRESHOLD = LIMPING_DAMAGE_THRESHOLD_DEFAULT};
if (isNil QUOTE(FRACTURE_DAMAGE_THRESHOLD)) then {FRACTURE_DAMAGE_THRESHOLD = FRACTURE_DAMAGE_THRESHOLD_DEFAULT};
if (isNil QUOTE(CARIDAC_OUTPUT_MIN)) then {CARIDAC_OUTPUT_MIN = CARIDAC_OUTPUT_MIN_DEFAULT};
// Derive the alternate fatal damage coefficents
if (isNil QUOTE(FATAL_SUM_DAMAGE_WEIBULL_K) || isNil QUOTE(FATAL_SUM_DAMAGE_WEIBULL_L)) then {
private _x1 = 0.5;
Expand Down
4 changes: 4 additions & 0 deletions addons/medical_engine/script_macros_medical.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@
#define FRACTURE_DAMAGE_THRESHOLD EGVAR(medical,const_fractureDamageThreshold)
#define FRACTURE_DAMAGE_THRESHOLD_DEFAULT 0.50

// Minimum cardiac output
#define CARIDAC_OUTPUT_MIN EGVAR(medical,const_minCardiacOutput)
#define CARIDAC_OUTPUT_MIN_DEFAULT 0.05

// Minimum body part damage required for blood effect on uniform
#define VISUAL_BODY_DAMAGE_THRESHOLD 0.35

Expand Down
2 changes: 2 additions & 0 deletions addons/medical_gui/functions/fnc_updateBodyImage.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,5 @@ private _bodyPartBloodLoss = [0, 0, 0, 0, 0, 0];
[IDC_BODY_LEGLEFT, IDC_BODY_LEGLEFT_S, IDC_BODY_LEGLEFT_T, IDC_BODY_LEGLEFT_B],
[IDC_BODY_LEGRIGHT, IDC_BODY_LEGRIGHT_S, IDC_BODY_LEGRIGHT_T, IDC_BODY_LEGRIGHT_B]
];

[QGVAR(updateBodyImage), [_ctrlGroup, _target, _selectionN]] call CBA_fnc_localEvent;
5 changes: 3 additions & 2 deletions addons/medical_gui/functions/fnc_updateCategories.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ params ["_display"];
_x params ["_idc", "_category"];

private _ctrl = _display displayCtrl _idc;
private _enable = GVAR(actions) findIf {_category == _x select 1 && {call (_x select 2)}} > -1;
if (_category isEqualTo "triage") then {_enable = true};
private _enable = if (_category == "triage") then { true } else {
GVAR(actions) findIf {_category == _x select 1 && {call (_x select 2)}} > -1
BrettMayson marked this conversation as resolved.
Show resolved Hide resolved
};
_ctrl ctrlEnable _enable;

private _selectedColor = [
Expand Down
6 changes: 6 additions & 0 deletions addons/medical_gui/functions/fnc_updateInjuryList.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ if (_selectionN == -1) exitWith {
_ctrl lbSetCurSel -1;
};

[QGVAR(updateInjuryListGeneral), [_ctrl, _target, _selectionN, _entries]] call CBA_fnc_localEvent;

_entries pushBack ["", [1, 1, 1, 1]];

// Add selected body part name
Expand Down Expand Up @@ -184,6 +186,8 @@ switch (GET_FRACTURES(_target) select _selectionN) do {
};
};

[QGVAR(updateInjuryListPart), [_ctrl, _target, _selectionN, _entries, _bodyPartName]] call CBA_fnc_localEvent;

// Add entries for open, bandaged, and stitched wounds
private _woundEntries = [];

Expand Down Expand Up @@ -216,6 +220,8 @@ private _fnc_processWounds = {
[GET_BANDAGED_WOUNDS(_target), "[B] %1", [0.88, 0.7, 0.65, 1]] call _fnc_processWounds;
[GET_STITCHED_WOUNDS(_target), "[S] %1", [0.7, 0.7, 0.7, 1]] call _fnc_processWounds;

[QGVAR(updateInjuryListWounds), [_ctrl, _target, _selectionN, _woundEntries, _bodyPartName]] call CBA_fnc_localEvent;

// Handle no wound entries
if (_woundEntries isEqualTo []) then {
_entries pushBack [localize ELSTRING(medical_treatment,NoInjuriesBodypart), _nonissueColor];
Expand Down
6 changes: 5 additions & 1 deletion addons/medical_gui/functions/fnc_updateLogList.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ lbClear _ctrl;
{
_x params ["_message", "_timeStamp", "_arguments"];

private _unlocalizedMessage = _message;

// Localize message and arguments
if (isLocalized _message) then {
_message = localize _message;
Expand All @@ -33,5 +35,7 @@ lbClear _ctrl;
// Format message with arguments
_message = format ([_message] + _arguments);

_ctrl lbAdd format ["%1 %2", _timeStamp, _message];
private _row = _ctrl lbAdd format ["%1 %2", _timeStamp, _message];

[QGVAR(logListAppended), [_ctrl, _row, _message, _unlocalizedMessage, _timeStamp, _arguments]] call CBA_fnc_localEvent;
} forEach _logs;
2 changes: 1 addition & 1 deletion addons/medical_status/functions/fnc_getBloodLoss.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ if (_woundBleeding == 0) exitWith {0};
private _cardiacOutput = [_unit] call FUNC(getCardiacOutput);

// even if heart stops blood will still flow slowly (gravity)
(_woundBleeding * (_cardiacOutput max 0.05) * EGVAR(medical,bleedingCoefficient))
(_woundBleeding * (_cardiacOutput max CARIDAC_OUTPUT_MIN) * EGVAR(medical,bleedingCoefficient))
3 changes: 3 additions & 0 deletions addons/medical_treatment/functions/fnc_fullHealLocal.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ if ((["ace_fire"] call EFUNC(common,isModLoaded)) && {[_patient] call EFUNC(fire
_patient setVariable [QEGVAR(fire,intensity), 0, true];
};

// Allow mods to heal
[QGVAR(fullHealLocalMod), [_patient]] call CBA_fnc_localEvent;

private _state = GET_SM_STATE(_patient);
TRACE_1("start",_state);

Expand Down
16 changes: 16 additions & 0 deletions docs/wiki/framework/events-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,22 @@ MenuType: 0 = Interaction, 1 = Self Interaction
| `ace_trenches_placed` | [_unit, _trench] | Global | Listen | After trench object is placed by unit.
| `ace_trenches_finished` | [_unit, _trench] | Global | Listen | After trench object is fully dug up by unit (100% progress).

### 2.13 Medical GUI (`ace_medical_gui`)

| Event Key | Parameters | Locality | Type | Description |
|---------- |------------|----------|------|-------------|
| `ace_medical_gui_updateBodyImage` | [_ctrlGroup, _target, _selectionN] | Local | Listen | Allows mods to update any modifications they have made to the body image
| `ace_medical_gui_updateInjuryListGeneral` | [_ctrl, _target, _selectionN, _entries] | Local | Listen | Allows mods to update the general injury list by pushing to the _entries array
| `ace_medical_gui_updateInjuryListPart` | [_ctrl, _target, _selectionN, _entries, _bodyPartName] | Local | Listen | Allows mods to update the part injury list by pushing to the _entries array
| `ace_medical_gui_updateInjuryListWounds` | [_ctrl, _target, _selectionN, _woundEntries, _bodyPartName] | Local | Listen | Allows mods to update the wounds injury list by pushing to the _woundEntries array
| `ace_medical_gui_logListAppended` | [_ctrl, _row, _message, _unlocalizedMessage, _timeStamp, _arguments] | Local | Listen | After an entry is appended to the log list

### 2.14 Medical Treatment (`ace_medical_treatment`)

| Event Key | Parameters | Locality | Type | Description |
|---------- |------------|----------|------|-------------|
| `ace_medical_treatment_fullHealLocalMod` | [_patient] | Local | Listen | Called when a local unit is being fully healed, mods can listen and apply their own healing logic
BrettMayson marked this conversation as resolved.
Show resolved Hide resolved

## 3. Usage
Also Reference [CBA Events System](https://github.com/CBATeam/CBA_A3/wiki/Custom-Events-System){:target="_blank"} documentation.

Expand Down