Skip to content

Commit

Permalink
General - Fix for ace update 3.18 (KAT-Advanced-Medical#608)
Browse files Browse the repository at this point in the history
**When merged this pull request will:**
- Title
### 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
MiszczuZPolski authored Oct 8, 2024
1 parent 4dd10ff commit 3c0fc8a
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 32 deletions.
6 changes: 1 addition & 5 deletions addons/circulation/functions/fnc_updateHeartRate.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,9 @@ if IN_CRDC_ARRST(_unit) then {
private _meanBP = (2/3) * _bloodPressureH + (1/3) * _bloodPressureL;
private _painLevel = GET_PAIN_PERCEIVED(_unit);

private _targetBP = 107;
if (_bloodVolume < BLOOD_VOLUME_CLASS_2_HEMORRHAGE) then {
_targetBP = _targetBP * (_bloodVolume / DEFAULT_BLOOD_VOLUME);
};

_targetHR = DEFAULT_HEART_RATE;
if (_bloodVolume < BLOOD_VOLUME_CLASS_3_HEMORRHAGE) then {
private _targetBP = 107 * (_bloodVolume / DEFAULT_BLOOD_VOLUME);
_targetHR = _heartRate * (_targetBP / (45 max _meanBP));
};
if (_painLevel > 0.2) then {
Expand Down
3 changes: 2 additions & 1 deletion addons/gui/functions/fnc_menuPFH.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ if !(
closeDialog 0;
// Show hint if distance condition failed
if ((ACE_player distance ACEGVAR(medical_gui,target) > ACEGVAR(medical_gui,maxDistance)) && {vehicle ACE_player != vehicle ACEGVAR(medical_gui,target)}) then {
if (((getPosATL ACEGVAR(medical_gui,target)) # 2) < -9) exitWith {}; // handle dragging corpse/clone
[[ACELSTRING(medical,DistanceToFar), ACEGVAR(medical_gui,target) call ACEFUNC(common,getName)], 2] call ACEFUNC(common,displayTextStructured);
};
};
Expand Down Expand Up @@ -62,4 +63,4 @@ private _quickView = ACEGVAR(medical_gui,target) getVariable [MED_LOG_VARNAME("q
[_ctrlQuickView, _quickView] call ACEFUNC(medical_gui,updateLogList);

// Update triage status
[_display, ACEGVAR(medical_gui,target)] call ACEFUNC(medical_gui,updateTriageStatus);
[_display, ACEGVAR(medical_gui,target)] call ACEFUNC(medical_gui,updateTriageStatus);
7 changes: 4 additions & 3 deletions addons/misc/functions/fnc_canCheckDogtag.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ params ["", "_target"];

if (isNull _target) exitWith {false};

// check if disabled for faction
if ([ACEGVAR(dogtags,disabledFactions) getVariable faction _target] param [0, false]) exitWith {false};
true
// Check if disabled for faction
if ((faction _target) in ACEGVAR(dogtags,disabledFactions)) exitWith {false};

!(_target call EFUNC(common,isAwake))
24 changes: 13 additions & 11 deletions addons/misc/functions/fnc_carryObject.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
params ["_unit", "_target"];
TRACE_2("params",_unit,_target);

// If in ViV cargo, unload it first
// Warn user if it failed to unload (shouldn't happen)
if (!isNull isVehicleCargo _target && {!(objNull setVehicleCargo _target)}) then {
WARNING_1("ViV Unload Failed %1",_target);
};

// Get attachTo offset and direction
private _position = _target getVariable [QACEGVAR(dragging,carryPosition), [0, 0, 0]];
private _direction = _target getVariable [QACEGVAR(dragging,carryDirection), 0];
Expand Down Expand Up @@ -47,9 +53,6 @@ if (_target isKindOf "CAManBase") then {

[QACEGVAR(common,setDir), [_target, _direction], _target] call CBA_fnc_targetEvent;

_unit setVariable [QACEGVAR(dragging,isCarrying), true, true];
_unit setVariable [QACEGVAR(dragging,carriedObject), _target, true];

// Add drop action
_unit setVariable [QACEGVAR(dragging,releaseActionID), [
_unit, "DefaultAction",
Expand All @@ -60,19 +63,18 @@ _unit setVariable [QACEGVAR(dragging,releaseActionID), [
// Add anim changed EH
[_unit, "AnimChanged", ACEFUNC(dragging,handleAnimChanged), [_unit]] call CBA_fnc_addBISEventHandler;

// Check everything
[ACEFUNC(dragging,carryObjectPFH), 0.5, [_unit, _target, CBA_missionTime]] call CBA_fnc_addPerFrameHandler;

// Reset current dragging height
ACEGVAR(dragging,currentHeightChange) = 0;

// Prevent UAVs from firing
private _UAVCrew = _target call ACEFUNC(common,getVehicleUAVCrew);

if (_UAVCrew isNotEqualTo []) then {
{
_target deleteVehicleCrew _x;
[_x, true] call ACEFUNC(common,disableAiUAV);
} forEach _UAVCrew;

_target setVariable [QACEGVAR(dragging,isUAV), true, true];
_target setVariable [QACEGVAR(dragging,isUAV), _UAVCrew, true];
};

// Check everything
[ACEFUNC(cdragging,carryObjectPFH), 0.5, [_unit, _target, CBA_missionTime]] call CBA_fnc_addPerFrameHandler;

[QACEGVAR(dragging,startedCarry), [_unit, _target]] call CBA_fnc_localEvent;
2 changes: 1 addition & 1 deletion addons/misc/functions/fnc_treatment.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ if (_medic isNotEqualTo player || {!_isInZeus}) then {
};

// Determine the animation length
private _animDuration = ACEGVAR(medical_treatment,animDurations) getVariable _medicAnim;
private _animDuration = ACEGVAR(medical_treatment,animDurations) get toLowerANSI _medicAnim;
if (isNil "_animDuration") then {
WARNING_2("animation [%1] for [%2] has no duration defined",_medicAnim,_classname);
_animDuration = 10;
Expand Down
2 changes: 1 addition & 1 deletion addons/misc/functions/fnc_updateDamageEffects.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ if (!_isLimping && {ACEGVAR(medical,limping) > 0}) then {
(_xAmountOf > 0)
&& {_xDamage > LIMPING_DAMAGE_THRESHOLD_DEFAULT}
// select _causeLimping from woundDetails
&& {(ACEGVAR(medical_damage,woundDetails) get (_xClassID / 10)) select 3}
&& {(ACEGVAR(medical_damage,woundDetails) get (floor (_xClassID / 10))) select 3}
) exitWith {
TRACE_1("limping because of wound",_x);
_isLimping = true;
Expand Down
12 changes: 7 additions & 5 deletions addons/misc/functions/fnc_useItem.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -70,36 +70,38 @@ if (GVAR(allowSharedVehicleEquipment) > 0 && _vehicleCondition) then {

{
private _origin = _x;
if(_forEachIndex != _vehicleIndex) then { // Remove unit item
if (_forEachIndex != _vehicleIndex) then { // Remove unit item
private _originItems = [_origin, 0] call ACEFUNC(common,uniqueItems); // Item
{
if (_x in _originItems) then {
_origin removeItem _x;
[_origin, _x] breakOut "Main";
[_origin, _x, true] breakOut "Main";
};
} forEach _items;

_originItems = [_origin, 2] call ACEFUNC(common,uniqueItems); // Magazine
{
if (_x in _originItems) then {
private _magsStart = count magazines _unit;
[_origin, _x] call ACEFUNC(common,adjustMagazineAmmo);
[_origin, _x] breakOut "Main";
private _magsEnd = count magazines _unit;
[_unit, _x, (_magsEnd < _magsStart)] breakOut "Main";
};
} forEach _items;
} else { // Remove vehicle item
private _originItems = [_origin, 0] call ACEFUNC(common,uniqueItems); // Item
{
if (_x in _originItems) then {
_origin addItemCargoGlobal [_x, -1];
[_origin, _x] breakOut "Main";
[_origin, _x, false] breakOut "Main";
};
} forEach _items;

_originItems = [_origin, 2] call ACEFUNC(common,uniqueItems); // Magazine
{
if (_x in _originItems) then {
[_origin, _x] call ACEFUNC(common,adjustMagazineAmmo);
[_origin, _x] breakOut "Main";
[_origin, _x, false] breakOut "Main";
};
} forEach _items;
};
Expand Down
7 changes: 7 additions & 0 deletions addons/pharma/functions/fnc_medicationLocal.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

// todo: move this macro to script_macros_medical.hpp?
#define MORPHINE_PAIN_SUPPRESSION 0.6
// 0.2625 = 0.6/0.8 * 0.35
// 0.6 = basic medication morph. pain suppr., 0.8 = adv. medication morph. pain suppr., 0.35 = adv. medication painkillers. pain suppr.
#define PAINKILLERS_PAIN_SUPPRESSION 0.2625

params ["_patient", "_bodyPart", "_classname"];
TRACE_3("medicationLocal",_patient,_bodyPart,_classname);
Expand Down Expand Up @@ -47,6 +50,10 @@ if !(ACEGVAR(medical_treatment,advancedMedication)) exitWith {
[QACEGVAR(medical,WakeUp), _patient] call CBA_fnc_localEvent;
};
};
case "Painkillers": {
private _painSuppress = GET_PAIN_SUPPRESS(_patient);
_patient setVariable [VAR_PAIN_SUPP, (_painSuppress + PAINKILLERS_PAIN_SUPPRESSION) min 1, true];
};
};
};
TRACE_1("Running treatmentMedicationLocal with Advanced configuration for",_patient);
Expand Down
15 changes: 12 additions & 3 deletions addons/pharma/functions/fnc_tourniquetRemove.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ private _partIndex = ALL_BODY_PARTS find toLower _bodyPart;
private _tourniquets = GET_TOURNIQUETS(_patient);

if (_tourniquets select _partIndex == 0) exitWith {
[ACELSTRING(medical_treatment,noTourniquetOnBodyPart), 1.5] call ACEFUNC(common,displayTextStructured);
if (_medic == ACE_player) then {
[ACELSTRING(medical_treatment,noTourniquetOnBodyPart), 1.5] call ACEFUNC(common,displayTextStructured);
};
};

_tourniquets set [_partIndex, 0];
Expand All @@ -39,8 +41,15 @@ TRACE_1("clearConditionCaches: tourniquetRemove",_nearPlayers);
[QACEGVAR(interact_menu,clearConditionCaches), [], _nearPlayers] call CBA_fnc_targetEvent;

// Add tourniquet item to medic or patient
private _receiver = [_patient, _medic, _medic] select ACEGVAR(medical_treatment,allowSharedEquipment);
[_receiver, "ACE_tourniquet"] call ACEFUNC(common,addToInventory);
if (_medic call ACEFUNC(common,isPlayer)) then {
private _receiver = [_patient, _medic, _medic] select ACEGVAR(medical_treatment,allowSharedEquipment);
[_receiver, "ACE_tourniquet"] call ACEFUNC(common,addToInventory);
} else {
// If the medic is AI, only return tourniquet if enabled
if (missionNamespace getVariable [QACEGVAR(medical_ai,requireItems), 0] > 0) then {
[_medic, "ACE_tourniquet"] call ACEFUNC(common,addToInventory);
};
};

// Handle occluded medications that were blocked due to tourniquet
private _occludedMedications = _patient getVariable [QACEGVAR(medical,occludedMedications), []];
Expand Down
4 changes: 2 additions & 2 deletions addons/vitals/functions/fnc_handleUnitVitals.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private _temperature = 37;
private _baroPressure = 760;

if (EGVAR(hypothermia,hypothermiaActive)) then {
// Enviromental Impact (Altitude, Temperature, Pressure)
// Enviromental Impact (Altitude, Temperature, Pressure)
private _altitude = (getPosASL _unit) select 2;
private _altitudeTempImpact = switch (true) do {
case (_altitude >= 10): { abs(_altitude/153) * -1 }; //For every 1000 meters of elevation gain, temperature decreases by ~6.5 degrees celsius
Expand All @@ -50,7 +50,7 @@ if (EGVAR(hypothermia,hypothermiaActive)) then {
};

_baroPressure = 760 * exp((-(_altitude)) / 8400);
_temperature = [_unit, _altitudeTempImpact, _bloodVolume, _deltaT, _syncValues] call FUNC(handleTemperatureFunction);
_temperature = [_unit, _altitudeTempImpact, _bloodVolume, _deltaT, _syncValues] call FUNC(handleTemperatureFunction);
};

// Set variables for synchronizing information across the net
Expand Down

0 comments on commit 3c0fc8a

Please sign in to comment.