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

Prevent bandaging when not bleeding #6532

Merged
merged 1 commit into from
Mar 30, 2019
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
6 changes: 1 addition & 5 deletions addons/medical_treatment/ACE_Medical_Treatment_Actions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class GVAR(Actions) {
treatmentTime = QFUNC(getBandageTime);
treatmentTimeSelfCoef = 1;
items[] = {{"ACE_fieldDressing", "ACE_packingBandage", "ACE_elasticBandage", "ACE_quikclot"}};
condition = QUOTE(!GVAR(advancedBandages));
condition = QFUNC(canBandage);
itemConsumed = 1;
callbackSuccess = QFUNC(treatmentBandage);
callbackFailure = "";
Expand All @@ -30,7 +30,6 @@ class GVAR(Actions) {
class FieldDressing: BasicBandage {
displayName = CSTRING(Actions_FieldDressing);
items[] = {"ACE_fieldDressing"};
condition = QGVAR(advancedBandages);
litter[] = {
{"All", "_bloodLossOnBodyPart > 0", {{"ACE_MedicalLitter_bandage2", "ACE_MedicalLitter_bandage3"}}},
{"All", "_bloodLossOnBodyPart <= 0", {"ACE_MedicalLitter_clean"}}
Expand All @@ -39,7 +38,6 @@ class GVAR(Actions) {
class PackingBandage: BasicBandage {
displayName = CSTRING(Actions_PackingBandage);
items[] = {"ACE_packingBandage"};
condition = QGVAR(advancedBandages);
litter[] = {
{"All", "", {"ACE_MedicalLitter_packingBandage"}},
{"All", "_bloodLossOnBodyPart > 0", {{"ACE_MedicalLitter_bandage2", "ACE_MedicalLitter_bandage3"}}},
Expand All @@ -49,7 +47,6 @@ class GVAR(Actions) {
class ElasticBandage: BasicBandage {
displayName = CSTRING(Actions_ElasticBandage);
items[] = {"ACE_elasticBandage"};
condition = QGVAR(advancedBandages);
litter[] = {
{"All", "_bloodLossOnBodyPart > 0", {{"ACE_MedicalLitter_bandage2", "ACE_MedicalLitter_bandage3"}}},
{"All", "_bloodLossOnBodyPart <= 0", {"ACE_MedicalLitter_clean"}}
Expand All @@ -58,7 +55,6 @@ class GVAR(Actions) {
class QuikClot: BasicBandage {
displayName = CSTRING(Actions_QuikClot);
items[] = {"ACE_quikclot"};
condition = QGVAR(advancedBandages);
litter[] = {
{"All", "", {"ACE_MedicalLitter_QuickClot"}},
{"All", "_bloodLossOnBodyPart > 0", {{"ACE_MedicalLitter_bandage2", "ACE_MedicalLitter_bandage3"}}},
Expand Down
1 change: 1 addition & 0 deletions addons/medical_treatment/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ PREP(addToTriageCard);
PREP(bodyCleanupLoop);
PREP(calculateBlood);
PREP(canAccessMedicalEquipment);
PREP(canBandage);
PREP(dropDownTriageCard);
PREP(findMostEffectiveWound);
PREP(getBandageTime);
Expand Down
36 changes: 36 additions & 0 deletions addons/medical_treatment/functions/fnc_canBandage.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include "script_component.hpp"
/*
* Author: SilentSpike
* Prevents bandage actions from showing if selected body part isn't bleeding.
* Toggles between showing all or only basic bandage action for advanced setting.
*
* Arguments:
* 0: The medic <OBJECT>
* 1: The patient <OBJECT>
* 2: Body part <STRING>
* 3: Treatment class name <STRING>
*
* ReturnValue:
* Can Bandage <BOOL>
*
* Public: No
*/

params ["_medic", "_patient", "_bodypart", "_bandage"];

// Bandage type and bandage setting XNOR to show only active actions
if ((_bandage == "BasicBandage") isEqualTo GVAR(advancedBandages)) exitWith { false };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While it works, this does not make things easier to understand imo.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this isn't the most clear code, ideally we wouldn't even be adding the actions that aren't appropriate (unless we really care about the setting being toggleable mid-mission?).


private _index = ALL_BODY_PARTS find toLower _bodypart;
private _canBandage = false;

{
_x params ["", "", "_bodyPartN", "_amountOf", "_bleeding"];

// If any single wound on the bodypart is bleeding bandaging can go ahead
if (_bodyPartN == _index && {_amountOf * _bleeding > 0}) exitWith {
_canBandage = true;
};
} forEach (_patient getVariable [QEGVAR(medical,openWounds), []]);

_canBandage