Implemented use conditions for PAK and SurgicalKit

It is now possible to only have a treatment action show up for stable (not bleeding) patients
This commit is contained in:
Glowbal 2015-07-03 22:16:18 +02:00
parent e153e47bb2
commit 9edf1b1adf
9 changed files with 105 additions and 10 deletions

View File

@ -11,6 +11,7 @@ class ACE_Medical_Actions {
treatmentTimeSelfCoef = 1;
items[] = {{"ACE_fieldDressing", "ACE_packingBandage", "ACE_elasticBandage", "ACE_quikclot"}};
condition = "";
patientStateCondition = 0;
itemConsumed = 1;
callbackSuccess = QUOTE(DFUNC(treatmentBasic_bandage));
@ -107,6 +108,7 @@ class ACE_Medical_Actions {
// Item required for the action. Leave empty for no item required.
items[] = {"ACE_fieldDressing"};
condition = "";
patientStateCondition = 0;
// Callbacks
callbackSuccess = QUOTE(DFUNC(treatmentAdvanced_bandage));
callbackFailure = "";
@ -206,6 +208,7 @@ class ACE_Medical_Actions {
items[] = {"ACE_surgicalKit"};
treatmentLocations[] = {QGVAR(useLocation_SurgicalKit)};
requiredMedic = QGVAR(medicSetting_SurgicalKit);
patientStateCondition = QGVAR(useCondition_SurgicalKit);
treatmentTime = "(count ((_this select 1) getVariable ['ACE_Medical_bandagedWounds', []]) * 5)";
callbackSuccess = "";
callbackProgress = QUOTE(DFUNC(treatmentAdvanced_surgicalKit_onProgress));
@ -219,6 +222,7 @@ class ACE_Medical_Actions {
items[] = {"ACE_personalAidKit"};
treatmentLocations[] = {QGVAR(useLocation_PAK)};
requiredMedic = QGVAR(medicSetting_PAK);
patientStateCondition = QGVAR(useCondition_PAK);
treatmentTime = QUOTE((_this select 1) call FUNC(treatmentAdvanced_fullHealTreatmentTime));
callbackSuccess = QUOTE(DFUNC(treatmentAdvanced_fullHeal));
itemConsumed = QGVAR(consumeItem_PAK);

View File

@ -133,6 +133,20 @@ class ACE_Settings {
value = 2;
values[] = {"Anywhere", "Medical vehicles", "Medical facility", "vehicle & facility", "Disabled"};
};
class GVAR(useCondition_PAK) {
displayName = CSTRING(AdvancedMedicalSettings_useCondition_PAK_DisplayName);
description = CSTRING(AdvancedMedicalSettings_useCondition_PAK_Description);
typeName = "SCALAR";
value = 0;
values[] = {"Anytime", "Stable"};
};
class GVAR(useCondition_SurgicalKit) {
displayName = CSTRING(AdvancedMedicalSettings_useCondition_SurgicalKit_DisplayName);
description = CSTRING(AdvancedMedicalSettings_useCondition_SurgicalKit_Description);
typeName = "SCALAR";
value = 0;
values[] = {"Anytime", "Stable"};
};
class GVAR(keepLocalSettingsSynced) {
typeName = "BOOL";
value = 1;

View File

@ -196,13 +196,21 @@ class CfgVehicles {
class consumeItem_PAK {
displayName = CSTRING(AdvancedMedicalSettings_consumeItem_PAK_DisplayName);
description = CSTRING(AdvancedMedicalSettings_consumeItem_PAK_Description);
typeName = "NUMBER";
class values {
class keep { name = CSTRING(No); value = 0; };
class remove { name = CSTRING(Yes); value = 1; default = 1; };
};
};
class useCondition_PAK {
displayName = CSTRING(AdvancedMedicalSettings_useCondition_PAK_DisplayName);
description = CSTRING(AdvancedMedicalSettings_useCondition_PAK_Description);
typeName = "NUMBER";
class values {
class AnyTime { name = CSTRING(AnyTime); value = 0; };
class Stable { name = CSTRING(Stable); value = 1; default = 1; };
};
};
class useLocation_PAK {
displayName = CSTRING(AdvancedMedicalSettings_useLocation_PAK_DisplayName);
description = CSTRING(AdvancedMedicalSettings_useLocation_PAK_Description);
@ -227,15 +235,19 @@ class CfgVehicles {
displayName = CSTRING(AdvancedMedicalSettings_useLocation_SurgicalKit_DisplayName);
description = CSTRING(AdvancedMedicalSettings_useLocation_SurgicalKit_Description);
};
class useCondition_SurgicalKit: useCondition_PAK {
displayName = CSTRING(AdvancedMedicalSettings_useCondition_SurgicalKit_DisplayName);
description = CSTRING(AdvancedMedicalSettings_useCondition_SurgicalKit_Description);
};
class healHitPointAfterAdvBandage {
displayName = CSTRING(AdvancedMedicalSettings_healHitPointAfterAdvBandage_DisplayName);
description = CSTRING(AdvancedMedicalSettings_healHitPointAfterAdvBandage_Description);
description = CSTRING(AdvancedMedicalSettings_healHitPointAfterAdvBandage_Description);
typeName = "BOOL";
defaultValue = 0;
};
class painIsOnlySuppressed {
displayName = CSTRING(AdvancedMedicalSettings_painIsOnlySuppressed_DisplayName);
description = CSTRING(AdvancedMedicalSettings_painIsOnlySuppressed_Description);
description = CSTRING(AdvancedMedicalSettings_painIsOnlySuppressed_Description);
typeName = "BOOL";
defaultValue = 1;
};

View File

@ -56,6 +56,7 @@ PREP(isInMedicalFacility);
PREP(isInMedicalVehicle);
PREP(isMedic);
PREP(isMedicalVehicle);
PREP(isInStableCondition);
PREP(itemCheck);
PREP(modifyMedicalAction);
PREP(onMedicationUsage);

View File

@ -16,7 +16,7 @@
#include "script_component.hpp"
private ["_caller", "_target", "_selectionName", "_className", "_config", "_medicRequired", "_items", "_locations", "_return", "_condition"];
private ["_caller", "_target", "_selectionName", "_className", "_config", "_medicRequired", "_items", "_locations", "_return", "_condition", "_patientStateCondition"];
_caller = _this select 0;
_target = _this select 1;
_selectionName = _this select 2;
@ -44,7 +44,6 @@ if !([_caller, _medicRequired] call FUNC(isMedic)) exitwith {false};
_items = getArray (_config >> "items");
if (count _items > 0 && {!([_caller, _target, _items] call FUNC(hasItems))}) exitwith {false};
_locations = getArray (_config >> "treatmentLocations");
_return = true;
if (getText (_config >> "condition") != "") then {
@ -62,6 +61,14 @@ if (getText (_config >> "condition") != "") then {
};
if (!_return) exitwith {false};
_patientStateCondition = if (isText(_config >> "patientStateCondition")) then {
missionNamespace getvariable [getText(_config >> "patientStateCondition"), 0]
} else {
getNumber(_config >> "patientStateCondition")
};
if (_patientStateCondition == 1 && {!([_target] call FUNC(isInStableCondition))}) exitwith {false};
_locations = getArray (_config >> "treatmentLocations");
if ("All" in _locations) exitwith {true};
private [ "_medFacility", "_medVeh"];

View File

@ -0,0 +1,30 @@
/*
* Author: Glowbal
* Check if a unit is in a stable condition
*
* Arguments:
* 0: The patient <OBJECT>
*
* Return Value:
* Is in stable condition <BOOL>
*
* Public: No
*/
#include "script_component.hpp"
private ["_unit"];
_unit = _this select 0;
if (GVAR(level) <= 1) exitwith {
([_unit] call FUNC(getBloodloss)) == 0;
};
_totalBloodLoss = 0;
_openWounds = _unit getvariable [QGVAR(openWounds), []];
{
// total bleeding ratio * percentage of injury left
_totalBloodLoss = _totalBloodLoss + ((_x select 4) * (_x select 3));
}foreach _openWounds;
(_totalBloodLoss == 0);

View File

@ -33,5 +33,7 @@ if !(_activated) exitWith {};
[_logic, QGVAR(consumeItem_SurgicalKit), "consumeItem_SurgicalKit"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(useLocation_PAK), "useLocation_PAK"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(useLocation_SurgicalKit), "useLocation_SurgicalKit"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(useCondition_PAK), "useCondition_PAK"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(useCondition_SurgicalKit), "useCondition_SurgicalKit"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(healHitPointAfterAdvBandage), "healHitPointAfterAdvBandage"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(painIsOnlySuppressed), "painIsOnlySuppressed"] call EFUNC(common,readSettingFromModule);

View File

@ -16,7 +16,7 @@
#include "script_component.hpp"
private ["_caller", "_target", "_selectionName", "_className", "_config", "_medicRequired", "_items", "_locations", "_return", "_callbackProgress", "_treatmentTime", "_callerAnim", "_patientAnim", "_iconDisplayed", "_return", "_usersOfItems", "_consumeItems", "_condition", "_displayText", "_wpn", "_treatmentTimeConfig"];
private ["_caller", "_target", "_selectionName", "_className", "_config", "_medicRequired", "_items", "_locations", "_return", "_callbackProgress", "_treatmentTime", "_callerAnim", "_patientAnim", "_iconDisplayed", "_return", "_usersOfItems", "_consumeItems", "_condition", "_displayText", "_wpn", "_treatmentTimeConfig", "_patientStateCondition"];
_caller = _this select 0;
_target = _this select 1;
_selectionName = _this select 2;
@ -53,9 +53,6 @@ if !([_caller, _medicRequired] call FUNC(isMedic)) exitwith {false};
_items = getArray (_config >> "items");
if (count _items > 0 && {!([_caller, _target, _items] call FUNC(hasItems))}) exitwith {false};
// Check allowed locations
_locations = getArray (_config >> "treatmentLocations");
_return = true;
if (isText (_config >> "Condition")) then {
_condition = getText(_config >> "condition");
@ -74,6 +71,16 @@ if (isText (_config >> "Condition")) then {
};
if (!_return) exitwith {false};
_patientStateCondition = if (isText(_config >> "patientStateCondition")) then {
missionNamespace getvariable [getText(_config >> "patientStateCondition"), 0]
} else {
getNumber(_config >> "patientStateCondition")
};
if (_patientStateCondition == 1 && {!([_target] call FUNC(isInStableCondition))}) exitwith {false};
// Check allowed locations
_locations = getArray (_config >> "treatmentLocations");
if ("All" in _locations) then {
_return = true;
} else {

View File

@ -3123,13 +3123,19 @@
<Czech>Lokace osobní lékárničky</Czech>
</Key>
<Key ID="STR_ACE_Medical_AdvancedMedicalSettings_useLocation_PAK_Description">
<English>Where can the personal aid kit be used?</English>
<English>Where can the Personal Aid Kit be used?</English>
<Russian>Где может использоваться аптечка?</Russian>
<Polish>Gdzie można korzystać z apteczek osobistych?</Polish>
<Spanish>¿Dónde se puede utilizar el equipo de primeros auxilios?</Spanish>
<German>Wo kann der Erstehilfekasten verwendet werden?</German>
<Czech>Kde může být osobní lékárnička použita?</Czech>
</Key>
<Key ID="STR_ACE_Medical_AdvancedMedicalSettings_useCondition_PAK_DisplayName">
<English>Condition PAK</English>
</Key>
<Key ID="STR_ACE_Medical_AdvancedMedicalSettings_useCondition_PAK_Description">
<English>When can the Personal Aid Kit be used?</English>
</Key>
<Key ID="STR_ACE_Medical_AdvancedMedicalSettings_anywhere">
<English>Anywhere</English>
<Russian>Где угодно</Russian>
@ -3218,6 +3224,12 @@
<German>Wo kann der Operationskasten verwendet werden?</German>
<Czech>Kde může být použita chirurgická souprava?</Czech>
</Key>
<Key ID="STR_ACE_Medical_AdvancedMedicalSettings_useCondition_SurgicalKit_DisplayName">
<English>Condition Surgical kit (Adv)</English>
</Key>
<Key ID="STR_ACE_Medical_AdvancedMedicalSettings_useCondition_SurgicalKit_Description">
<English>When can the Surgical kit be used?</English>
</Key>
<Key ID="STR_ACE_Medical_AdvancedMedicalSettings_healHitPointAfterAdvBandage_DisplayName">
<English>Bloodstains</English>
<German>Blutflecken</German>
@ -3509,5 +3521,11 @@
<Portuguese>Não</Portuguese>
<Italian>No</Italian>
</Key>
<Key ID="STR_ACE_Medical_AnyTime">
<English>Anytime</English>
</Key>
<Key ID="STR_ACE_Medical_Stable">
<English>Stable</English>
</Key>
</Package>
</Project>